Savegames with screenshots

Started by AGA, Tue 06/01/2004 08:42:12

Previous topic - Next topic

AGA

Has anybody used the SaveScreenShot (or whatever the command is :P) to create a savegame GUI that stores a screenshot of the current scene yet? I could always look into doing it myself, I was just wondering if anyone had done it yet, and could save me the bother... :)

Edit by strazer:
Check out http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23320

Ryukage

I recently did that.  I don't plan to publically release my GUI as a template (at least not until I've made at least one game of my own with it), but I'll post the relevant code frags for you.

---------------------

// This is the text used by the savegame dialog for the "new file" slot
//   in the savegame list.
#define NEW_SAVE_FILE_TEXT "-> Create New File"

// These are used by the save/load system
string NewSaveSlotText;  // will contain the NEW_SAVE_FILE_TEXT string
int SaveLoadScreenshot = 0;  // pointer to screenshot sprite

function ShowSaveGameDialog() {
 // Display custom savegame dialog
 string text;

 // Create temp save so we can grab a preview shot for the save box  
 SaveGameSlot(100, "temp");
 SaveLoadScreenshot = LoadSaveSlotScreenshot(100, 104, 78);
 DeleteSaveSlot(100);
 
 // Screenshot successfly loaded, set as button pic
 if(SaveLoadScreenshot != 0) {
   SetButtonPic(SAVEGAME, 4, 1, SaveLoadScreenshot);
 }
 
 // Load up the savegame list
 ListBoxClear(SAVEGAME, 1);
 ListBoxSaveGameList(SAVEGAME, 1);
 
 // Take care of housekeeping
 if(ListBoxGetNumItems(SAVEGAME, 1) == 20) {
   // All 20 saves used, don't allow creation of new one
   Display("The save directory is full.[[Please replace a previous save.");
   ListBoxSetSelected(SAVEGAME, 1, ListBoxGetNumItems(SAVEGAME, 1) - 1);
   ListBoxGetItemText(SAVEGAME, 1,  ListBoxGetNumItems(SAVEGAME, 1) - 1, text);
   SetTextBoxText(SAVEGAME, 5, text);
 }
 else {
    // Still room, add a "new file" option to the end of the listbox
   ListBoxAdd(SAVEGAME, 1, NewSaveSlotText);
   ListBoxSetSelected(SAVEGAME, 1, ListBoxGetNumItems(SAVEGAME, 1) - 1);
   SetTextBoxText(SAVEGAME, 5, "");
 }
 
 CentreGUI(SAVEGAME);
 GUIOn(SAVEGAME);
}

function ShowLoadGameDialog() {
 // Display custom loadgame dialog
 ListBoxClear(LOADGAME, 1);
 ListBoxSaveGameList(LOADGAME, 1);
 
 if(ListBoxGetNumItems(LOADGAME, 1) == 0) {
   Display("There are no files in the save directory.[[Record your progress by clicking the 'save' button, then you can go back to the point where you saved with the 'load' button.");
   return;
 }
 
 ListBoxSetSelected(LOADGAME, 1, 0);

 SaveLoadScreenshot = LoadSaveSlotScreenshot(savegameindex[0], 104, 78);
 
 if(SaveLoadScreenshot != 0) {
   SetButtonPic(LOADGAME, 4, 1, SaveLoadScreenshot);
 }

 CentreGUI(LOADGAME);
 GUIOn(LOADGAME);
}

function game_start() {
 // Initialize the string we check against to decide whether to replace or not
 StrCopy(NewSaveSlotText, NEW_SAVE_FILE_TEXT);
 
 // Set size of savegame images to match size of button we put them on
 game.screenshot_width = 104;
 game.screenshot_height = 78;
}

function interface_click(int interface, int button) {
 if (interface == SAVEGAME) {  // Save Game
   string text;
   if(button == 1) {  // Listbox
     // Fill the textbox with description of clicked save slot
     ListBoxGetItemText(SAVEGAME, 1, ListBoxGetSelected(SAVEGAME, 1), text);
     if(StrComp(text, NewSaveSlotText))  // existing slot, use existing desc
       SetTextBoxText(SAVEGAME, 5, text);
     else    // new file slot, just empty it
       SetTextBoxText(SAVEGAME, 5, "");
   }
   else if(button == 3) {  // Cancel button
     // clean up the sprite cache
     if(SaveLoadScreenshot != 0) {
       SetButtonPic(SAVEGAME, 4, 1, 2997);  // 2997 is completely transparent
       DeleteSprite(SaveLoadScreenshot);
       SaveLoadScreenshot = 0;
     }
     GUIOff(SAVEGAME);
   }
   else {  // Save button or return in textbox
     // clean up sprite cache
     if(SaveLoadScreenshot != 0) {
       SetButtonPic(SAVEGAME, 4, 1, 2997);  // 2997 is completely transparent
       DeleteSprite(SaveLoadScreenshot);
       SaveLoadScreenshot = 0;
     }
     // don't get the GUI caught in screenshot!
     GUIOff(SAVEGAME);
     SetDefaultCursor();
     Wait(1);
     // save the game
     ListBoxGetItemText(SAVEGAME, 1, ListBoxGetSelected(SAVEGAME, 1), text);
     if(StrComp(text, NewSaveSlotText)) {
       GetTextBoxText(SAVEGAME, 5, text);
       SaveGameSlot(savegameindex[ListBoxGetSelected(SAVEGAME, 1)], text);
     }
     else {
       GetTextBoxText(SAVEGAME, 5, text);
       SaveGameSlot(ListBoxGetSelected(SAVEGAME, 1), text);
     }
   }
 }  // end if interface SAVEGAME
 
 if (interface == LOADGAME) {  // Load Game
   if(button == 1) {  // Listbox
     // Clean sprite cache
     if(SaveLoadScreenshot != 0) {
       SetButtonPic(LOADGAME, 4, 1, 2997);  // 2997 is completely transparent
       DeleteSprite(SaveLoadScreenshot);
       SaveLoadScreenshot = 0;
     }
   
     // Load up new preview shot
     SaveLoadScreenshot = LoadSaveSlotScreenshot(savegameindex[ListBoxGetSelected(LOADGAME, 1)], 104, 78);
     
     if(SaveLoadScreenshot != 0) {
       SetButtonPic(LOADGAME, 4, 1, SaveLoadScreenshot);
     }
     else {
       SetButtonPic(LOADGAME, 4, 1, 2997);  // 2997 is completely transparent
     }
   }
   else if(button == 3) {  // Cancel button
     // clean cache
     if(SaveLoadScreenshot != 0) {
       SetButtonPic(LOADGAME, 4, 1, 2997);  // 2997 is completely transparent
       DeleteSprite(SaveLoadScreenshot);
       SaveLoadScreenshot = 0;
     }
     GUIOff(LOADGAME);
   }
   else if(button == 2) {  // Load button
     // clean...yeah
     if(SaveLoadScreenshot != 0) {
       SetButtonPic(LOADGAME, 4, 1, 2997);
       DeleteSprite(SaveLoadScreenshot);
       SaveLoadScreenshot = 0;
     }
     RestoreGameSlot(savegameindex[ListBoxGetSelected(LOADGAME, 1)]);
     GUIOff(LOADGAME);
   }
 }  // end if interface LOADGAME
}
------------

The save and load GUIs are set up as follows:
0: label displaying instructions
1: lisbox for save game list
2: save or load button
3: cancel button
4: do-nothing button for screenshot preview
5: textbox (save gui only)

This code will display the shot for game about to be saved on the save dialog, and one for the game about to be loaded on the load dialog.  You can probably figure out how to change that if you want.  If there are any function calls in there that aren't in the AGS manual, they're probably something from my custom interface that I missed removing.

Sprite 2997 is a completely transparent sprite I imported for blanking out unused buttons.  You should change that number to whatever your own blank sprite is.  This code would probably benefit from moving the "clean sprite cache" code into a function instead of repeating it all over the place.

Can't guarantee this is completely bug free, but I haven't had a problem. Hope it helps!

..

Don't suppose you could make a template now for a 'programing challenged' person like me?

Nacho

First post here! \o/ Kairus used a savegame with screenshots system for Garfield...
Are you guys ready? Let' s roll!

SSH

There's also a tutorial on a different savegame with screenshot system at: http://www.twin-design.com/agsezine/9/tutorial.cfm
12

Rui 'Trovatore' Pires

Ok, ok, here's a template!

www.freewebs.com/skimbleshanks/

Get into the "Templates" page and find my "SCI-Styled Point and Click template", the one I used for Larry 2. I has screenshot saved games.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Sam.

um, the template doesnt work. it oculd just be me but I have the newest (non beta) version of AGS and it will not start a game with the template, it just prodcues an error screen.
Bye bye thankyou I love you.

Rui 'Trovatore' Pires

Odd... I remember two people (one was Candle, the other I don't remember) managed to get it to run.

At any rate, I won't re-upload until 2.7 comes out... beta 14 is all that I have in my system at the mo. Thanks for bringing it up.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Candle

Here it is I just made a new one with beta 2.63.5220
http://uploads.savefile.com/redir/98369.zip
let me know if the zip is bad , new upload host trying out .

Rui 'Trovatore' Pires

Thanks, Candle. All the same, I'll be reuploading soon, so as to objectise the whole coding system.

BTW, with AGS's new module system, it won't be long before it becomes possible to export individual GUIs. When that happens, I hope someone will export the savegame screenies GUI and post it here. ::)
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

SSH

I'll do the same thing with my version...
12

Sam.

the tut ssh posted is excellent. works beautifully.
Bye bye thankyou I love you.

Tiki

Hmm... I'm using a Screenshot  Save GUI as well, though it's not any of the above, and I have a slight problem.

See, the game is 256 colors - therefore, any room outside of the one you were in at the time of saving shows that screenshot to have a very messed up pallate.  So, I'm wondering..

How can I make this Save Screenshot GUI work in a 256 game?  Could I make the screenshot in black and white somehow, which could be universal colors?  Is there some way to use a seperate room as the Save Game Menu?

Thanks, I'm fairly sure nobody's had this particular problem before...

SSH

Very good question, Tiki. I think the best solution would be to get CJ to get the saved screenshots to be loaded in and converted to the universal palette of the game. I don't think a separate room would help, as how would you know what palette to use for that room?

Incidentally, my tutorial won't quite work in the latest beta, but I'll soon be releasing a module and GUI to let people use it with the latest version.
12

Gilbert

Yeah I have thought of that too, since I'll only create 256 colour games, but as I'll not use this feature at the moment so I didn't care to ask for that.

Actually what I thought of is a function like:
DynamicSprite* DynamicSprite.RemapPalette(int slot, int start, int end)
which would remap a sprite using palette slots ranged from start to end, this function works only in 256 colour mode of course.
You can do for example:
Code: ags

DynamicSprite *tempspr;
DynamicSprite *remapspr;
tempspr = DynamicSprite.CreateFromSaveGame(1, 40, 30);
remapspr = DynamicSprite.RemapPalette(tempspr.Graphic, 0, 32); //uses only colour #0 thru #32
tempspr.Delete();


Afterthought is, as we can create scaled dynamic sprites from savegame and current screenshot, maybe it's also a good idea to add functions like DynamicSprite.ScaleSprite(int slot, int width, int height) , DynamicSprite.CropSprite(int slot, int x1, int y1, int x2, int y2), DynamicSprite.Hflip(int slot), DynamicSprite.Vflip(int slot) and DynamicSprite.RotateRightAngle(int slot), etc. in some future releases, to make the functionality complete.



SMF spam blocked by CleanTalk