Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: TheJBurger on Fri 20/01/2006 23:39:58

Title: Date and Time in Save Games
Post by: TheJBurger on Fri 20/01/2006 23:39:58
I'm having some trouble trying to implement date and time into my save game GUI.
Basically, I want the date and time of the save game displayed on a label in my save GUI.

I know about the date and time functions, but I still haven't been able to figure it out.

Title: Re: Date and Time in Save Games
Post by: Pumaman on Sat 21/01/2006 14:11:57
The easiest way is to modify the save game description that the user inputs, and include the date and time in it. Then, when they call up the Restore Game GUI, it will show the save slot name including the date.
Title: Re: Date and Time in Save Games
Post by: TheJBurger on Sat 21/01/2006 18:33:35
Thank you for your reply, I managed to put the date into the save game name.

However, I was wondering about something else.


Ã,  Ã,  GetTextBoxText(6,0,text);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Get the typed text
Ã,  Ã,  string buffer;
Ã,  Ã,  DateTime *dt = DateTime.Now;
Ã,  Ã,  StrFormat (buffer, "%s %02d/%02d/%04d %02d:%02d", text, dt.DayOfMonth, dt.Month, dt.Year, dt.Hour, dt.Minute);
Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 


From my code, the date and time will always be one space after the "text" they typed. Is there any way to align the date and time to always be at 20 spaces or so? Because right now it looks kind of messy having the date and time constantly shifted. For instance, one save game is only four letters long, and the next is ten letters, and then the time is shifted all over.
Title: Re: Date and Time in Save Games
Post by: Ashen on Sat 21/01/2006 19:31:31
The easiest way would probably be:

while (StrLen(text) < 20) StrCat(text, " ");


Put that after you've got the inputted name, to pad it out to 20 characters (obviously, it won't do anything if the player already gave it a name with more than 20 characters), then add the date and time as you normally would.
Title: Re: Date and Time in Save Games
Post by: TheJBurger on Sat 21/01/2006 19:50:42
It works, except that certain characters (such as 1 and 3) take up different amounts of space. So if I name my savegame "1"  the date will be placed differently than "3." But other than that it works great.
Title: Re: Date and Time in Save Games
Post by: DoorKnobHandle on Sat 21/01/2006 19:52:01
To workaround that issue you will need to import a fixed-font (such as Courier New), those fonts will use exactly the same width for any character.
Title: Re: Date and Time in Save Games
Post by: TheJBurger on Sat 21/01/2006 19:58:02
Ok, I'll try that, thanks.