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/




SMF spam blocked by CleanTalk