Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Scan for Savegames and pick the newest  (Read 3108 times)

0 Members and 1 Guest are viewing this topic.

Darky

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 109
    • View Profile
    • Spreadcamp
Scan for Savegames and pick the newest
« on: August 07, 2010, 12:33:16 AM »

I'm implementing a "Resume Game" button to my startmenu when you launch the game. It's disabled if there are no savegames present, and if there are savegames present it is active and is supposed to load the latest savegame automaticly on click.

I so far worked around reading if there are save games present. But how can I approach that it finds out which of the savegames is the latest and loads that? WME has a File Object and I thought that would come in handy, but I couldn't find out how or if at all you can read the Date attribute of the files with that.

What solution is there for this problem?

How I read if there are save games:
Code: WME Script
  1. var SaveGamePresent;
  2.  
  3. for(var i=0; i<101; i=i+1) // 101 is my amount of save slots
  4. {
  5.         // set to true and break loop the moment a savegame is found
  6.         if(Game.IsSaveSlotUsed(i))
  7.         {
  8.                 SaveGamePresent = true;
  9.                 break;
  10.         } else SaveGamePresent = false;
  11. }
  12.  
  13. // activate the button if there are no savegames, disable it if there are none
  14. var button;
  15. button = WinMainMenu.GetControl("resume");
  16. if(SaveGamePresent) button.Disabled = false;
  17. else button.Disabled = true;
  18.  

Thanks alot
Darky
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Scan for Savegames and pick the newest
« Reply #1 on: August 07, 2010, 11:33:15 AM »

I used registry to store the last savegame. It was easy to implement and reliable.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Darky

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 109
    • View Profile
    • Spreadcamp
Re: Scan for Savegames and pick the newest
« Reply #2 on: August 08, 2010, 03:07:29 AM »

That's a clever use of the registry functions and just as you said really easy to implement and works fine as expected. Thank you alot :)
Logged
 

Page created in 0.021 seconds with 24 queries.