MODULE: A.S.S - Another Savegames with Screenshots module [updated to v1.5]

Started by hedgefield, Sat 26/09/2009 17:15:20

Previous topic - Next topic

hedgefield

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.


Mehrdad

Hi
I can not download.I think site is filtering for my country.can you give me mirror link?
My official site: http://www.pershaland.com/

hedgefield

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

You could just upload it to mediafire. Just for the bastards who doesn't live in the USA. :P
Code: ags
function iToxicWaste_Talk()
{
Display ("You eat the toxic waste. Obviously, you die.");
QuitGame (0);}

red runner

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


Digital Mosaic Games

Hello,

I´ve tried to use the GUIs and the Scripts from the Screenshot-Template(http://www.adventuregamestudio.co.uk/yabb/index.php?topic=38928.0) afterwards for my game.
But now the player can´t save his game no longer. No screenshots, no saves.
And when I try to load an empty slot an error occured:
"ListBox.SaveGameSlot: index out of rage"(This error occures in the original template too)

I´ve got the same scripts, for Pressing the OK-Button on Save- and Load-GUI but I post it again as a precaution:
Code: ags
function btnSaveOK_OnClick(GUIControl *control, MouseButton button) {
  if (lstSaveGames.SelectedIndex >= 0) {                        // If you've selected a savegame slot
    saveslot = lstSaveGames.SelectedIndex;                      // Get the selected savegame
    text = txtSaveName.Text;                                    // Get the typed text
    if (screenshot != null) {
      screenshot.Delete();
      btnSaveScreen.NormalGraphic = SL_EMPTY_SPRITE;            // Resets the screenshot      
    }
    gSave.Visible = false;
    mouse.Mode = eModeWalkto;
    Wait(1);
    SaveGameSlot(lstSaveGames.SaveGameSlots[saveslot],text);    // Overwrites the selected game
  }
  else {                                                        // Save the game in a new slot
    if (totalsaves < 10) {                                      // If the savegame limit is not reached (50)
      text = txtSaveName.Text;                                  // Get the typed text
      if (text == "") {
        Display("Please enter a name for your savegame.");      // If player didn't enter a name, tell them
      }
      else {                                                    // Proceed as usual
        if (screenshot != null) {
          screenshot.Delete();
          btnSaveScreen.NormalGraphic = SL_EMPTY_SPRITE;        // Resets the screenshot
        }
        
        mouse.Mode = eModeWalkto;
        Wait(1);
        SaveGameSlot(totalsaves+1,text);                        // Saves game (text as description)
      }
    }
    else Display("All save slots are full. Please overwrite a previous save.");
  }
}


Code: ags
function btnLoadOK_OnClick(GUIControl *control, MouseButton button)
{
   saveslot = lstLoadGames.SelectedIndex;                        // Gets the selected slot
  gRestoreGame.Visible = false;
  mouse.Mode = eModeWalkto;
  if (screenshot != null) {
    screenshot.Delete();
    btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE;              // Resets the screenshot
  }
  RestoreGameSlot(lstLoadGames.SaveGameSlots[saveslot]);        // Restores the selected slot
}


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

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: ags

// Load GUI
function btnLoadOK_OnClick(GUIControl *control, MouseButton button) {
  saveslot = lstLoadGames.SelectedIndex;                        // Gets the selected slot
  gLoad.Visible = false;
  mouse.Mode = eModeWalkto;
  if (screenshot != null) {
    screenshot.Delete();
    btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE;              // Resets the screenshot
  }
  RestoreGameSlot(lstLoadGames.SaveGameSlots[saveslot]);        // Restores the selected slot
}


To:

Code: ags

// Load GUI
function btnLoadOK_OnClick(GUIControl *control, MouseButton button) {
  if (totalsaves>0) {
    saveslot = lstLoadGames.SelectedIndex;                        // Gets the selected slot
    gLoad.Visible = false;
    mouse.Mode = eModeWalkto;
    if (screenshot != null) {
      screenshot.Delete();
      btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE;              // Resets the screenshot
    }
    RestoreGameSlot(lstLoadGames.SaveGameSlots[saveslot]);        // Restores the selected slot
  }
}



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.

Digital Mosaic Games

QuoteAs 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: ags
// main global script file

//--------------------------------------------------------------------------------------------------------------
// Largo's Savegames with Screenshots
//--------------------------------------------------------------------------------------------------------------
// Definitions

// Define screenshot width
#define SL_WIDTH  128  
// Define screenshot height
#define SL_HEIGHT 96  
// Define default screenshot
#define SL_EMPTY_SPRITE 2

// Variables

String text;                                                              // Stores the typed text
int saveslot = 0;                                                         // Stores the selected savegame slot
int totalsaves = 0;                                                       // Stores the total number of savegames
DynamicSprite *screenshot;                                                // Stores the screenshot

// Functions

function sl_save() {
  Wait(1);
  screenshot = DynamicSprite.CreateFromScreenShot(SL_WIDTH, SL_HEIGHT);   // Create screenshot of current game
  if (screenshot != null) {
    btnSaveScreen.NormalGraphic = screenshot.Graphic;                     // Display current screenshot
  }
  txtSaveName.Text = "";                                                  // Clear Text box
  lstSaveGames.FillSaveGameList();                                        // Fill List Box with saved games
  lstSaveGames.SelectedIndex = -1;                                        // Deselect savegame slots
  totalsaves = lstSaveGames.ItemCount;                                    // Count how many saved games there are 
  gSave.Visible = true;                                                   // Opens the save GUI
  gSave.Centre();                                                         // Centres the save GUI
  mouse.Mode = eModePointer;                                              // Set the pointer cursor
}

function sl_load() {
  lstLoadGames.FillSaveGameList();                                        // Fill List Box with saved games
  lstLoadGames.SelectedIndex = -1;                                        // Deselect savegame slots 
  gRestoreGame.Visible = true;                                                   // Opens the load GUI
  gRestoreGame.Centre();                                                         // Centres the load GUI
  mouse.Mode = eModePointer;                                              // Set the pointer cursor
}
//--------------------------------------------------------------------------------------------------------------

#sectionstart unhandled_event
function unhandled_event (int what, int type) {
}


Without this lines I couldn´t start the game. There must be an other mistake.

hedgefield

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

#12
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.

hedgefield

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: ags

function btnLoadOK_OnClick(GUIControl *control, MouseButton button) {
  if (lstLoadGames.SelectedIndex >= 0) {
    saveslot = lstLoadGames.SelectedIndex;                      // Gets the selected slot
    gLoad.Visible = false;
    mouse.Mode = eModeWalkto;
    if (screenshot != null) {
      screenshot.Delete();
      btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE;            // Resets the screenshot
    }
    RestoreGameSlot(lstLoadGames.SaveGameSlots[saveslot]);      // Restores the selected slot
  }
  else if (totalsaves>0) Display("Please select a savegame.");
  else Display("There are no savegames yet!");
}



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.

xenogia

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

hedgefield

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.

Mehrdad

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 :)
My official site: http://www.pershaland.com/




Sektor 13

Hey great job !

I was wondering if it is possible to add DATE and TIME to be SAVED with the name too ?



Also i found i bug, if you press F5 over and over again, it captures screen with SAVE gui and it makes some strange effect in the saved screen. Easy fixable thou.

hedgefield

Your wish is my command! I updated the module to fix that bug (good looking out), and added support for saving the date and time the savegame was made.
It is currently formatted as savegame name - dd/mm/yyyy hh:mm, but you can modify that if you want. The code is under the btnSaveOK_OnClick section in ASScode.txt. You may also want to resize the GUI first if you're going to use that feature since it's currently not wide enough to contain all those numbers ;)

To activate the feature, put SL_DATETIME = true; in your gamestart function. See first post for the updated download link.

Sektor 13


steptoe

Hi

My AGS 3.2.0 will not import gSave.guf and gLoad.guf.. says property locked and says it may require later version... and with 3.1.2

steptoe
It's not over until the fat lady sings..

hedgefield

I don't think I've ever seen version 3.2.0.. or did you mean 3.0.2? But it could be that older versions of AGS have a problem with newly exported GUIs. I use 3.2.1, is it possible for you to upgrade to that? It would probably fix your problem.

steptoe

Hi

I changed over computer that had both the above AGS versions... Have now downloaded 3.2.1 and it now imports..

:=
It's not over until the fat lady sings..

jamesreg

I was wondering if it was possible to change the size of the snapshot image that is created on the gui?
I resized it and looked though the code but did not see an a place to do that.

Also would it be possible to instead of text with the name of the game on the load menu
to have multiple screen shots and limit the amount of saves? I know you can limit
the amount of saves seen that in code but what about the multiple screen shot
on one load gui?

Thanks

hedgefield

Hi James, you mean you resized the screenshot button on the GUI but the image is still small? If you go into ASS.asc, at the top you should see two variables, SL_WIDTH and SL_HEIGHT. This is the size of the screenshot. Just change them to the new dimensions of the button. It doesn't have to be a proper resolution like 320x240 but just make sure to keep the aspect ratio the same (4:3) or the screenshot might stretch.

If you go even higher than 320x240, you might also want to scroll down to the game_start section in ASS.asc and increase the values for game.screenshot_width & game.screenshot_height. This is the resolution of the screenshot saved in the savegame, not the size at which it is rendered on the GUI.

As for the screenshots grid, it could certainly be done. I remember making one a long time ago, but I don't remember exactly how to do it. I suppose it would involve loading all the screenshots for the savegames at once instead of waiting on one to be selected from the list.

And if you want to cap the total number of saveslots, look in the btnSaveOK_OnClick function in your globalscript for the line
if (totalsaves < 50) {
and change 50 to whichever number of saveslots you want.

jamesreg

How silly of me.

I went and looked in the scripting I copied and pasted into the main global file but forgot about the entire script file I imported.
that explains why I couldnt find what I was looking for. God don't you hate it when you do stupid stuff like that lol.

thanks for the help think ill be able to get it now.

Julius Dangerous

___________________________________________________________

formica

Hi, sorry to bother you. I don't know how but I've used your module to break my game ???

I installed it exactly as it says in the readme, but didn't delete the default save menu if that makes a difference. I ran the debug and saved/loaded to try it out, which worked, but then the game crashed when I quit using the in-game quit button that had always worked before.

Things got worse when I tried to compile and then run from the game setup - it crashes on restoring a save with a fatal exception:
Quote from: ags
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x0041DBD1 ; program pointer is +2051, ACI version 3.3.0.1162, gtags (6,3)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.

An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)
---------------------------
OK   
---------------------------

I deleted the default save menus hoping that would help, no dice.

After this I tried completely deleting the module, GUIs, global script section and adding the originals menus in, but I then get errors similar to these:


Any help would be much appreciated, otherwise my last backup was annoyingly long ago, I'll have to redo quite a lot.

hedgefield

Oof that sounds gnarly!

The only thing I can think of right now is that you didn't specify the right sprite slot for the screenshot preview and now it's trying to delete a sprite that doesn't exist. But if you removed those bits of code I don't know why it would still throw that error. What does line 342 say?

Other than that maybe something changed in the saving system since 3.1.2, I haven't really used AGS since then, at least not with this plugin, so could be that something in the code has been deprecated.

formica

Quote from: hedgefield on Sat 13/09/2014 10:09:42
Oof that sounds gnarly!

The only thing I can think of right now is that you didn't specify the right sprite slot for the screenshot preview and now it's trying to delete a sprite that doesn't exist. But if you removed those bits of code I don't know why it would still throw that error. What does line 342 say?

Other than that maybe something changed in the saving system since 3.1.2, I haven't really used AGS since then, at least not with this plugin, so could be that something in the code has been deprecated.

Yeah my hopes are not high, I did remove everything completely but it still generated the errors x.x
Line 342 is actually just the 'quitgame' line in this:

Code: ags
function btnQuit_OnClick(GUIControl *control, MouseButton button)
{
  gPanel.Visible = false;
  Wait(1);
  QuitGame(1);
  gPanel.Visible = true;
  gIconbar.Visible = false;
  mouse.UseModeGraphic(eModePointer);
}


It crashed when I tried to quit after restoring a save... yep. Thanks for the help by the way! Not your fault I wasn't smart enough to back up :)

Edit: I should add that I actually tried creating a sprite 195 (which was the next number in line for my sprite numbers). The next time I tried the error just read 196, and so on. I guess its trying to delete the sprite created as the screenshot?

hedgefield

Oh that's weird. The screenshot sprite should be referencing a fixed sprite number, so I don't know why the game keeps looking for the last number in the sequence + 1...

Looks like the Quit game function is cleaning up the sprites and causing the errors you're seeing, but why that is I don't dare say. Sorry I can't be more helpful! :undecided: Maybe some other sourcecode whizz knows why this would be happening but if you removed all traces of this module I don't see why it would still be throwing errors.

Best of luck anyway!


Monsieur OUXX

Formica I'm not sure how familiar you are with AGS, but I smell something fishy with the way you (or the module) manages sprites.

Apparently AGS crashes at "quitgame" time because there is still a sprite floating around, and that's usually the sign of a DynamicSprite not properly deleted, or deleted too early! It should be automated, but I suggest you try calling ".Delete()" on every DynamicSprite you created manually in your script.

Are you sure you removed everything from the module? For example, are you sure you also removed the function in charge of deleting the snapshot sprite? Maybe it's still there, trying to delete it when it doesn't actually exist anymore.
 

Crimson Wizard

@Monsieur OUXX

This sounds like another occurance of this bug:
http://www.adventuregamestudio.co.uk/forums/index.php?issue=362.0
http://www.adventuregamestudio.co.uk/forums/index.php?topic=47064.0
But I guess you may know this already.

I think it is possible to fix by cleaning up everything before calling QuitGame; problem is, however, that this won't work if player closed the game window by clicking on X button, or hit "Alt + X".

The AGS is clearly lacking "on_exit" event handler...

Monsieur OUXX

Quote from: Crimson Wizard on Wed 15/10/2014 00:23:11
This sounds like another occurance of this bug: (...)

The AGS is clearly lacking "on_exit" event handler...

Thanks for the info! I never had that issue :) Probably it's because I'm old school and always click on my own internal "quit" button ;) Old reflexes from Windows 3.11 ;)
If I didn't know you and other C++ wizards are so busy already (and even officially retired ;) ), I'd say: "Let's add that event to The AGS!" :D
 

Crimson Wizard

Quote from: Monsieur OUXX on Wed 15/10/2014 10:41:46
If I didn't know you and other C++ wizards are so busy already (and even officially retired ;) ), I'd say: "Let's add that event to The AGS!" :D
Actually I was thinking about adding it myself. This should not be too hard to do... or so I hope.

formica

Hey! Sorry it took me forever to reply to this. I know very little about AGS so I can't say, but I did scour the code and remove everything so I guess it is the problem Crimson Wizard is talking about? I ended up rolling back, which wasn't as bad as I thought it would be at all. Out of curiousity I tried the module again, and this time got it working completely fine on the same game, though I'm sure my bad quitting habits persist.

Thanks hedgefield for the cool module!

TheVolumeRemote

I’m getting a strange error saying the GUI scripts require a newer version of AGS and I’m on 3.5.27...

Does anyone know what I might be able to do? :)

Crimson Wizard

Quote from: TheVolumeRemote on Fri 05/03/2021 00:57:31
I’m getting a strange error saying the GUI scripts require a newer version of AGS and I’m on 3.5.27...

The version check for importing GUI in the editor makes no sense and interprets any different version as being too high, even if it's lower. This got to be fixed.

The GUI version has changed around 3.5.0.
Try importing into AGS 3.4 instead, save project, and then load in 3.5.0.

TheVolumeRemote

I will try that this evening, thank you!! :)

EDIT: That worked! Thank you and to anyone using 3.5(+) here’s the gSave.guf, gLoad.guf and ASS.scm files, converted for use in 3.5 (tested working in 3.5.27)

https://www.dropbox.com/s/q40w5i4jcrqibxd/AGS_ASS_module.zip?dl=0

SMF spam blocked by CleanTalk