Add Date and Time to Menu
Moderator: InsideQC Admins
2 posts
• Page 1 of 1
Add Date and Time to Menu
Just create 2 files called time.c and time.h

time.h:
time.c:
Open the menu.c now and search for:
after that you add this:
now looking in "void M_Main_Draw (void)" for that:

time.h:
- Code: Select all
#ifndef __TIME_H__
#define __TIME_H__
int Time_Draw ();
#endif
time.c:
- Code: Select all
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include "quakedef.h"
int Time_Draw () {
time_t current_time;
struct tm *tm_ptr;
static int current_min = 0;
current_time = time(0);
localtime(¤t_time);
tm_ptr = gmtime(¤t_time);
char *result[24];
int hour = tm_ptr->tm_hour;
int ampm = 0;
current_min = tm_ptr->tm_min;
if(hour == 0)
hour = 12;
else if(hour >= 12) {
ampm = 1;
if(hour >= 13)
hour -= 12;
}
if(ampm == 0)
snprintf (result, 20, "%02d/%02d AM %02d:%02d", tm_ptr->tm_mon+1, tm_ptr->tm_mday, hour, tm_ptr->tm_min);
else
snprintf (result, 20, "%02d/%02d PM %02d:%02d", tm_ptr->tm_mon+1, tm_ptr->tm_mday, hour, tm_ptr->tm_min);
M_Print (200 + ((vid.width - 320)>>1), 8, result);
return 0;
}
Open the menu.c now and search for:
- Code: Select all
void M_DrawColorBar (int x, int y, int highlight) {
...
}
after that you add this:
- Code: Select all
#include "time.h"
now looking in "void M_Main_Draw (void)" for that:
- Code: Select all
M_DrawTransPic (54, 32 + m_main_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
- Code: Select all
Time_Draw ();
I am sorry for my English...
-

Rikku2000 - Posts: 49
- Joined: Wed Oct 20, 2010 6:33 pm
- Location: Germany
Re: Add Date and Time to Menu
Thanks! And happy Xmas! 
Meadow Fun!! - my first commercial game, made with FTEQW game engine
- toneddu2000
- Posts: 1352
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
2 posts
• Page 1 of 1
Return to Programming Tutorials
Who is online
Users browsing this forum: No registered users and 1 guest