Problem with FillSaveGameList **SOLVED**

Started by Knox, Sun 13/06/2010 19:17:42

Previous topic - Next topic

Knox

Hi guys,

I currently making it so I save the date+time inside a savegame...here is what I wrote, it works:

Code: ags

function saveWithDateTime(int iTrunc,)
{
  //suffix date+time to savegamefile
  dt = DateTime.Now;
  sSaveGameTextDateTime = String.Format("%s%02d%02d%04d%02d%02d%02d",saveGameText, dt.DayOfMonth, dt.Month, dt.Year, dt.Hour, dt.Minute, dt.Second);
  //Display("%s", sSaveGameTextDateTime);
  iLengthSaveGame = sSaveGameTextDateTime.Length;
  iTruncateNum = (iLengthSaveGame - 14); //length of the savegame input minus the 14 characters of the date + time
  sSaveGameTruncated = sSaveGameTextDateTime.Truncate(iTruncateNum);
  sSaveGameTruncatedUpper = sSaveGameTruncated.UpperCase();
  //Display("%s", sSaveGameTruncatedUpper);
  if (iTrunc == 0) saveGameText = sSaveGameTextDateTime; //means we want the date time saved 
  else if (iTrunc == 1) saveGameText = sSaveGameTruncatedUpper; //means we want to display the name without the date + time
}


The problem I have though is Im like 95% of the way there, and I dont know how to get that last 5%. Where Im stuck is Ive got a way to save the date+time info within the savegame text, and I know how to write a String variable that shows the savegaem name WITHOUT the date+time info...if I use "Display" command.

What I dont know how to do is when I get to this point (lstSaveGames.FillSaveGameList)...how to convert the savegame list (FillSaveGameList) so that I can use the variable to make sure I dont see the date+time : the string that "hides" the date+time info--> String sSaveGameTruncatedUpper

--All that is necessary for evil to triumph is for good men to do nothing.

Gilbert

You can make a dummy GUI with a listbox that's never shown and Fill it with the savegame names first. Then copy its content entry by entry (and cut off the date-time part) to another listbox that is actually shown on the GUI.

Something like:
Code: ags
lstDummy.FillSaveGameList();
lstReal.Clear();
int ii=0;
while (ii<lstDummy.ItemCount){
  lstReal.AddItem(StripDateTime(lstDummy.Items[ii])); 
  //Suppose StripDateTime() is a function that strips the date-time part from the savegame name.
  ii++;
}

(Depending on whether you want to keep the list of the original names. If you do not need them you can use only one list. After filling it with the names, just modify its content item by item:
Code: ags

lstReal.Items[ii]=StripDateTime( lstReal.Items[ii]);
)

Knox

#2
Hi Gilbet

Ok Ill give this a shot and keep you posted, thanks!

**EDIT**

Cool I got it to work!! I had to modify how my screenshots were saved/displayed though since now I have a dummy list to refer to.
--All that is necessary for evil to triumph is for good men to do nothing.

SMF spam blocked by CleanTalk