Author Topic: MODULE: A.S.S - Another Savegames with Screenshots module [updated to v1.5]  (Read 13425 times)

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • hedgefield worked on one or more games that won an AGS Award!
    •  
    • hedgefield worked on one or more games that was nominated for an AGS Award!
A.S.S. - Another Savegames with Screenshots module - v1.5 released 04.11.2011
Original code by Spyros. Enhanced and ported to AGS 3+ code by hedgefield
---------------------------------------------------------------------------------------------------------

v1.5 changelog:
- fixed a bug where pressing F5 or F7 repeatedly opened new instances of the save and load GUI respectively
- added the option to save and display the date and time the savegame was made. see readme for instructions

v1.4 changelog:
- turned the script into a module now that I know how to do that :)
- resized the GUIs back down to their original size and removed all graphics from them
- the module should now enable the "save screenshots in savegames" option for you if you hadn't already

v1.3 changelog:
- fixed a bug where the load GUI would crash when trying to load with no savegame selected

v1.2 changelog:
- fixed a bug where the load GUI would not recognize the first new savegame after deleting all the existing savegames

V1.1 changelog:
- added a delete button!
- fixed a bug where the game would crash when trying to load when no savegames existed yet
- added the ability to deselect a slot by clicking outside the listbox
- increased the walking speed of the character to make moving around less tiresome
- updated the readme with usage instructions

---

ANOTHER savegames with screenshots template you say? Indeed. It remains a much-requested feature, so why not?

This template is a port -or perhaps "mutation" is more accurate- of Spyros' old savegames with screenshots tutorial. When I upgraded to AGS v3 I had to rewrite his code to work with the new object-oriented scripting language, and made a few modifications in the process. So here it is for you to enjoy aswell!

MAKE YOUR CLICKS HERE FOR DOWNLOADING TIMES (download here)



To install:
- import ASS.scm into the Scripts library in AGS (right-click on it, choose 'import script')
- import gSave.guf and gLoad.guf the same way under the GUI library
- open ASScode.txt, copy the whole thing and paste it at the bottom of your global script

To use: When you want to open the save GUI, all you have to do is call: sl_save();
And to open the load gui - you guessed it: sl_load();

new! If you want to store the date and time the screenshot was made, put SL_DATETIME = true; under function game_start() in your Global Script.

Comes with predefined keyboard shortcuts (F5 and F7, can be edited)


Requires AGS v3.0+. Tested with AGS 3.2.1. Keyboard shortcuts are still in ASCII code for additional backwards compatibility.
« Last Edit: 04 Nov 2011, 16:04 by hedgefield »

Really good template. Thanks. :D

Hi
I can not download.I think site is filtering for my country.can you give me mirror link?

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • hedgefield worked on one or more games that won an AGS Award!
    •  
    • hedgefield worked on one or more games that was nominated for an AGS Award!
Hmm that's weird. Well, I don't have another place to upload it, but if anyone else feels like hosting a mirror, I won't object. Or just PM me your email adress and I'll send it to you.

aventurero

  • How appropiate. You fight like a cow.
    • I can help with play testing
    • I can help with story design
    • I can help with translating
You could just upload it to mediafire. Just for the bastards who doesn't live in the USA. :P
Code: Adventure Game Studio
  1. function iToxicWaste_Talk()
  2. {
  3. Display ("You eat the toxic waste. Obviously, you die.");
  4. QuitGame (0);}
  5.  

Looks useful, aside the unfortunate acronym. (Sorry, couldn't help myself).
"Life's too short for all this nonsense.:
  -Joseph Brophy

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • hedgefield worked on one or more games that won an AGS Award!
    •  
    • hedgefield worked on one or more games that was nominated for an AGS Award!
Oh that was intentional. ;)

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=38928.0
Code: Adventure Game Studio
  1. function btnSaveOK_OnClick(GUIControl *control, MouseButton button) {
  2.   if (lstSaveGames.SelectedIndex >= 0) {                        // If you've selected a savegame slot
  3.     saveslot = lstSaveGames.SelectedIndex;                      // Get the selected savegame
  4.     text = txtSaveName.Text;                                    // Get the typed text
  5.     if (screenshot != null) {
  6.       screenshot.Delete();
  7.       btnSaveScreen.NormalGraphic = SL_EMPTY_SPRITE;            // Resets the screenshot      
  8.     }
  9.     gSave.Visible = false;
  10.     mouse.Mode = eModeWalkto;
  11.     Wait(1);
  12.     SaveGameSlot(lstSaveGames.SaveGameSlots[saveslot],text);    // Overwrites the selected game
  13.   }
  14.   else {                                                        // Save the game in a new slot
  15.     if (totalsaves < 10) {                                      // If the savegame limit is not reached (50)
  16.       text = txtSaveName.Text;                                  // Get the typed text
  17.       if (text == "") {
  18.         Display("Please enter a name for your savegame.");      // If player didn't enter a name, tell them
  19.       }
  20.       else {                                                    // Proceed as usual
  21.         if (screenshot != null) {
  22.           screenshot.Delete();
  23.           btnSaveScreen.NormalGraphic = SL_EMPTY_SPRITE;        // Resets the screenshot
  24.         }
  25.        
  26.         mouse.Mode = eModeWalkto;
  27.         Wait(1);
  28.         SaveGameSlot(totalsaves+1,text);                        // Saves game (text as description)
  29.       }
  30.     }
  31.     else Display("All save slots are full. Please overwrite a previous save.");
  32.   }
  33. }

Code: Adventure Game Studio
  1. function btnLoadOK_OnClick(GUIControl *control, MouseButton button)
  2. {
  3.    saveslot = lstLoadGames.SelectedIndex;                        // Gets the selected slot
  4.   gRestoreGame.Visible = false;
  5.   mouse.Mode = eModeWalkto;
  6.   if (screenshot != null) {
  7.     screenshot.Delete();
  8.     btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE;              // Resets the screenshot
  9.   }
  10.   RestoreGameSlot(lstLoadGames.SaveGameSlots[saveslot]);        // Restores the selected slot
  11. }

I have the excact same GUIs(exported from template and imported in my game) and I think I have the same Scripts too. Is there maybe something I could have forgotten?
If somebody has an idea...

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • hedgefield worked on one or more games that won an AGS Award!
    •  
    • hedgefield worked on one or more games that was nominated for an AGS Award!
You have a good point, I didn't realize you can still load a saveslot if there are no saves yet. To fix this, change:

Code: Adventure Game Studio
  1. // Load GUI
  2. function btnLoadOK_OnClick(GUIControl *control, MouseButton button) {
  3.   saveslot = lstLoadGames.SelectedIndex;                        // Gets the selected slot
  4.   gLoad.Visible = false;
  5.   mouse.Mode = eModeWalkto;
  6.   if (screenshot != null) {
  7.     screenshot.Delete();
  8.     btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE;              // Resets the screenshot
  9.   }
  10.   RestoreGameSlot(lstLoadGames.SaveGameSlots[saveslot]);        // Restores the selected slot
  11. }
  12.  

To:

Code: Adventure Game Studio
  1. // Load GUI
  2. function btnLoadOK_OnClick(GUIControl *control, MouseButton button) {
  3.   if (totalsaves>0) {
  4.     saveslot = lstLoadGames.SelectedIndex;                        // Gets the selected slot
  5.     gLoad.Visible = false;
  6.     mouse.Mode = eModeWalkto;
  7.     if (screenshot != null) {
  8.       screenshot.Delete();
  9.       btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE;              // Resets the screenshot
  10.     }
  11.     RestoreGameSlot(lstLoadGames.SaveGameSlots[saveslot]);        // Restores the selected slot
  12.   }
  13. }
  14.  


As for not being able to save - did you remember to also copy all the custom functions defined at the top of the global script? The system won't work without those.

Quote
As for not being able to save - did you remember to also copy all the custom functions defined at the top of the global script? The system won't work without those.
I have also copied all the costume functions as you can see here:
Code: Adventure Game Studio
  1. // main global script file
  2.  
  3. //--------------------------------------------------------------------------------------------------------------
  4. // Largo's Savegames with Screenshots
  5. //--------------------------------------------------------------------------------------------------------------
  6. // Definitions
  7.  
  8. // Define screenshot width
  9. #define SL_WIDTH  128  
  10. // Define screenshot height
  11. #define SL_HEIGHT 96  
  12. // Define default screenshot
  13. #define SL_EMPTY_SPRITE 2
  14.  
  15. // Variables
  16.  
  17. String text;                                                              // Stores the typed text
  18. int saveslot = 0;                                                         // Stores the selected savegame slot
  19. int totalsaves = 0;                                                       // Stores the total number of savegames
  20. DynamicSprite *screenshot;                                                // Stores the screenshot
  21.  
  22. // Functions
  23.  
  24. function sl_save() {
  25.   Wait(1);
  26.   screenshot = DynamicSprite.CreateFromScreenShot(SL_WIDTH, SL_HEIGHT);   // Create screenshot of current game
  27.   if (screenshot != null) {
  28.     btnSaveScreen.NormalGraphic = screenshot.Graphic;                     // Display current screenshot
  29.   }
  30.   txtSaveName.Text = "";                                                  // Clear Text box
  31.   lstSaveGames.FillSaveGameList();                                        // Fill List Box with saved games
  32.   lstSaveGames.SelectedIndex = -1;                                        // Deselect savegame slots
  33.   totalsaves = lstSaveGames.ItemCount;                                    // Count how many saved games there are
  34.   gSave.Visible = true;                                                   // Opens the save GUI
  35.   gSave.Centre();                                                         // Centres the save GUI
  36.   mouse.Mode = eModePointer;                                              // Set the pointer cursor
  37. }
  38.  
  39. function sl_load() {
  40.   lstLoadGames.FillSaveGameList();                                        // Fill List Box with saved games
  41.   lstLoadGames.SelectedIndex = -1;                                        // Deselect savegame slots
  42.   gRestoreGame.Visible = true;                                                   // Opens the load GUI
  43.   gRestoreGame.Centre();                                                         // Centres the load GUI
  44.   mouse.Mode = eModePointer;                                              // Set the pointer cursor
  45. }
  46. //--------------------------------------------------------------------------------------------------------------
  47.  
  48. #sectionstart unhandled_event
  49. function unhandled_event (int what, int type) {
  50. }

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • hedgefield worked on one or more games that won an AGS Award!
    •  
    • hedgefield worked on one or more games that was nominated for an AGS Award!
Hmm, I'll need some further information on what exactly you're doing in order to pinpoint what is causing this bug. Or, if you want, you can send me your project files and I can take a look at them directly, which would make it much easier for me to see what is happening.


hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • hedgefield worked on one or more games that won an AGS Award!
    •  
    • hedgefield worked on one or more games that was nominated for an AGS Award!
Through my correspondance with NEON I've managed to fix the bug he mentioned, as well as figure out how to make a delete button! I always wanted to include one in the template but I never took the time to figure out how to actually make one. Turned out it was fairly easy too, so I've released an updated template with this spiffy new function :) See first post for details.
« Last Edit: 31 Jan 2010, 00:06 by largopredator »

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • hedgefield worked on one or more games that won an AGS Award!
    •  
    • hedgefield worked on one or more games that was nominated for an AGS Award!
Argh, another little oversight on my part! Thanks for bringing this to my attention.

Luckily the fix is quite simple (because admittedly, the error is quite dumb...) - replace the whole btnLoadOK_OnClick function with the following code:

Code: Adventure Game Studio
  1. function btnLoadOK_OnClick(GUIControl *control, MouseButton button) {
  2.   if (lstLoadGames.SelectedIndex >= 0) {
  3.     saveslot = lstLoadGames.SelectedIndex;                      // Gets the selected slot
  4.     gLoad.Visible = false;
  5.     mouse.Mode = eModeWalkto;
  6.     if (screenshot != null) {
  7.       screenshot.Delete();
  8.       btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE;            // Resets the screenshot
  9.     }
  10.     RestoreGameSlot(lstLoadGames.SaveGameSlots[saveslot]);      // Restores the selected slot
  11.   }
  12.   else if (totalsaves>0) Display("Please select a savegame.");
  13.   else Display("There are no savegames yet!");
  14. }
  15.  


What it did before was make sure there were at least actual savegames to load. However, if you don't select any of those savegames before you press load, obviously it will crash! :) The script above now checks whether you actually selected a saveslot before trying to load anything. That oughta fix it.

Wow that was truly quick largopredator, thanks for the fantastic fix.

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
    • hedgefield worked on one or more games that won an AGS Award!
    •  
    • hedgefield worked on one or more games that was nominated for an AGS Award!
After I finally got around to figuring out how to create modules, I thought it might be a good idea to convert this template into one. So now you don't have to start a project from scratch (or do a lot of awkward copy-pasting) to be able to use it!

See the first post for updated download link and installation instructions, and let me know if you spot any bugs.

sorry for this post .but if can you give any mirror link?this link is block in my country.can you upload in mediafire?

thanks a lot :)


Oh.Thanks at milllions for mirror ;D

Great job, I really like this module.