Saving a label after quit [solved]

Started by Revae, Fri 02/11/2012 10:12:11

Previous topic - Next topic

Revae

Wasn't planning on asking a tech question so shortly after my last problem, but:

I have a custom save gui that is working quite well.  It has 4 save slots, and in each slot I'd like to put a save description, then the date, then the time onto labels like so:

Jims Save (save description)
10/31/2012 (label 1)
23:40 (label 2)

But I can't figure out how I'd get the labels that hold the date and time to stay after you quit the game/start a new game.  From what I've read the easiest way would be to use the save description as the date/time, but I'd like to have both.  Is there a way to store the information in-game, or to pop it out into the save file or another external file or some-such?  If all else fails I can always fall back on using the save description, but I'd rather not compromise.

Edit: Solved in next post.  Gracias.

Crimson Wizard

#1
Something that comes to my mind, you may save concatenated string as description, i.e. User text + Date + Time, separating them by some character, like '['. Then, when you are getting slot description in Restore game dialog, break the string you got in three parts.

Quick example:
When saving game:
Code: ags

String full_text = lblUserText.Text;
full_text = full_text.AppendChar('[');
full_text = full_text.Append(lblDate.Text);
full_text = full_text.AppendChar('[');
full_text = full_text.Append(lblTime.Text);
SaveGameSlot(slot_index, full_text);

When getting a list of games:
Code: ags

String full_text = Game.GetSaveSlotDescription(slot_index);
int ctrl_char = full_text.IndexOf("[");
lblUserText.Text = full_text.Substring(0, ctrl_char);
full_text = full_text.Substring(ctrl_char + 1, full_text.Length - ctrl_char - 1);
ctrl_char = full_text.IndexOf("[");
lblDate.Text = full_text.Substring(0, ctrl_char);
full_text = full_text.Substring(ctrl_char + 1, full_text.Length - ctrl_char - 1);
lblTime.Text = full_text;



EDIT: fixed script mistakes.
Also, tested in AGS right now, it worked :).

Revae

I completely forgot you could break apart strings.  This seems about perfect.  Thanks man!

SMF spam blocked by CleanTalk