Author Topic: Screenshots in game saves  (Read 863 times)

Screenshots in game saves
« on: 10 Apr 2018, 23:05 »
Hi there everyone :smiley:,

Recently I'm working on Save/Load system in my game. Starting from the beginning - the option 'Save screenshots in save games' available in General options of AGS doesn't do anything, at least with the latest engine version (3.4.1). I don't know if it's a bug or am I missing something? - if it is, then maybe it should be fixed with the next engine's update?. Anyway - it seems to work fine, while adding an extra line of code in Your global script in the section with save function definition, for example:

SaveScreenShot(String.Format("scrnshot%03d.bmp", screenshot));


What I'm trying to achieve is the saving system which creates a screenshot every time I'm saving a game, so that each one would show up next to a given save while loading menu appears. I was looking for similar solutions on the forum, but unfortunately none of them worked :(.

Walt
« Last Edit: 10 Apr 2018, 23:15 by Heisenberg »
If you wanna do something - you seek for solution, if you don't want to - you seek for a reason.

Snarky

  • Global Moderator
  • Private Insultant
    • I can help with proof reading
    • I can help with translating
Re: Screenshots in game saves
« Reply #1 on: 10 Apr 2018, 23:19 »
Just because a game is saved with a screenshot doesn't mean it will automatically be displayed in the load menu. You'll probably have to create your own GUI and write the necessary code to display the screenshot (though it seems probable that someone has released a module for it). The relevant command involved is DynamicSprite.CreateFromSaveGame().

Re: Screenshots in game saves
« Reply #2 on: 10 Apr 2018, 23:26 »
The point is - game is not saved with a screenshot. That's what I'm trying to say. At least setting up this function in General Settings doesn't do anything. It's more like 'nice to have' in further versions. For now it's enough if it's working with a bit of scripting. As for the saving system I mentioned above - I thought maybe someone did something similar before. I'll try to search smth again.
If you wanna do something - you seek for solution, if you don't want to - you seek for a reason.

Snarky

  • Global Moderator
  • Private Insultant
    • I can help with proof reading
    • I can help with translating
Re: Screenshots in game saves
« Reply #3 on: 10 Apr 2018, 23:30 »
While it's possible that this function is broken in the most recent version (it has certainly worked in the past), I think it's more likely that you're doing something wrong. You haven't described how you've determined that it's not working, so it's hard to say what that mistake might be.

Edit: Oh, and just in case there's any confusion – "saved with screenshot" does not mean the screenshot is stored as a separate file. It's included within the savegame file.
« Last Edit: 10 Apr 2018, 23:35 by Snarky »

Re: Screenshots in game saves
« Reply #4 on: 10 Apr 2018, 23:43 »
So, it's compiled with all other save game data in one file? Oh... didn't know that. So then for storing a screenshot as a seperate file the above code line is necessary. It does make sense now. Thanks Snarky :smiley:.
I'd be grateful for any additional help with associating screenshot with a given game save. Maybe someone did something like that before. To clarify, I'm still working on it, but maybe in the meantime someone would share some example.
« Last Edit: 10 Apr 2018, 23:47 by Heisenberg »
If you wanna do something - you seek for solution, if you don't want to - you seek for a reason.

Re: Screenshots in game saves
« Reply #5 on: 11 Apr 2018, 00:29 »
If I understand you correctly, you want to create a save/load GUI that displays the screenshot of the save location?
If that's the case, then you might want to take a look at the Extended ALARCOST (BASS) 1.4 template, it has a saving system like that.

Khris

  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: Screenshots in game saves
« Reply #6 on: 11 Apr 2018, 10:02 »
If you open up the manual to the mandatory to read Tutorial section (or search it for "screenshot"), you will find:

Setting up the game -> General Settings, which has an explanation of each setting.
Quote from: manual
Save screenshots in save games - Saves a mini-screenshot of the player's current position into the save game file. This will create larger save game files, but it will mean that you can use a save game thumbnails GUI to make the save/load interface more professional.

As for associating it with a save game, what exactly do you mean? The default game uses
Code: [Select]
  SaveGameSlot(gameSlotToSaveInto, txtNewSaveName.Text); so you can use that number and append it to the filename of your manually saved image. Is that what you mean? What is your end goal here? Why do you need extra screenshots?
« Last Edit: 11 Apr 2018, 10:04 by Khris »

Re: Screenshots in game saves
« Reply #7 on: 11 Apr 2018, 17:14 »
To sum up - I don't need extra screenshots, never did. I just didn't know why screenshots weren't shown in a game folder while the option in General Settings was set to use them. Snarky explained that. Now I just wan't to achieve what's in the example picture:

https://s17.postimg.cc/62x35l2wv/Bez_tytu_u.jpg

My save / load system is already done, but i just wan't to add a fuction that will show next to a given save a screenshot of current game progress.
If you wanna do something - you seek for solution, if you don't want to - you seek for a reason.

Snarky

  • Global Moderator
  • Private Insultant
    • I can help with proof reading
    • I can help with translating
Re: Screenshots in game saves
« Reply #8 on: 11 Apr 2018, 18:08 »
It's pretty simple, but you do need to use DynamicSprites.

DynamicSprites aren't as difficult as a lot of people think, though. You know how every sprite in AGS has a sprite number? Well, what if you want to use a sprite other than one of the ones you loaded into the AGS Editor ahead of time? Well, what you do is use a DynamicSprite, which is a class that allows you to load other graphics, and assigns them a new sprite number that you can use just like any other AGS sprite.

So basically, you put a button on your save/load GUI in each place a screenshot is supposed to go. (This is because Buttons are the main type of GUI control that you can assign a sprite to.) You declare a DynamicSprite* variable (like DynamicSprite* dsSaveGame1;) for each button (if you have many, it makes sense to declare it as an array, like DynamicSprite* dsSaveGames[10];), outside of any function. These DynamicSprites will store the screenshot graphics that we show on the buttons.

When you display the GUI, you call DynamicSprite.CreateFromSaveGame() for each of the savegames you want to display, and store the result in the corresponding variable, e.g. dsSaveGame1 = DynamicSprite.CreateFromSaveGame(/*function arguments go here*/);. Then you have to assign the sprite index of the dynamic sprite to the button graphic, with something like btnSaveGame1.NormalGraphic = dsSaveGame1.Graphic;. And then they should show up.

Re: Screenshots in game saves
« Reply #9 on: 14 Apr 2018, 02:48 »
I finally got it working. Thank You all :)

If you wanna do something - you seek for solution, if you don't want to - you seek for a reason.

Re: Screenshots in game saves
« Reply #10 on: 08 Jan 2019, 15:42 »
Hi there !

I'm quite a newbie and English is not my mother tongue, I apologize in advance <3

Re-openning the topic, I'd like to do basically the same thing as Silent Bob wanted to. I'm doing quite well. The thing is working almost perfectly, BUT it works only if I click twice on my save button. Why ? I'd like the screenshot to appears on my dynamicsprite button even if I click only once on the save button. (which sounds legit ?)

Do you have any idea of what i'm missing ? By the way, how can i make disappear the gSave GUI very quickly before the screenshot is taken ? Because right now, i do have a screenshot, but we bearly cant see the background because of my huge save GUI on the foreground. I do know how to make it disappear but, not in that precise case.


Here's some of my code :

Code: Adventure Game Studio
  1. //----------------------------------------------------------------------------------------------------
  2. // on_event
  3. //----------------------------------------------------------------------------------------------------
  4.  
  5. DynamicSprite *buttonSprite1;
  6. DynamicSprite *buttonSprite2;
  7. DynamicSprite *buttonSprite3;
  8.  
  9. function on_event (EventType event, int data)
  10. {
  11. buttonSprite1=DynamicSprite.CreateFromSaveGame(1, 200, 120);
  12. if (buttonSprite1 != null) {
  13. bScreenSlot1.NormalGraphic=buttonSprite1.Graphic;
  14. }
  15. buttonSprite2=DynamicSprite.CreateFromSaveGame(2, 200, 120);
  16. if (buttonSprite2 != null) {
  17. bScreenSlot2.NormalGraphic=buttonSprite2.Graphic;  
  18. }
  19.  
  20. buttonSprite3=DynamicSprite.CreateFromSaveGame(3, 200, 120);
  21. if (buttonSprite3 != null) {
  22. bScreenSlot3.NormalGraphic=buttonSprite3.Graphic;  
  23. }
  24. }
  25.  

And

Code: Adventure Game Studio
  1.  
  2. //----------------------------------------------------------------------------------------------------
  3. // gSave
  4. //----------------------------------------------------------------------------------------------------
  5.  
  6. function bSaveSlot1_OnClick(GUIControl *control, MouseButton button)
  7. {
  8. SaveGameSlot(1, "Save 1");
  9. }
  10.  
  11. function bSaveSlot2_OnClick(GUIControl *control, MouseButton button)
  12. {
  13. SaveGameSlot(2, "Save 2");
  14. }
  15.  
  16. function bSaveSlot3_OnClick(GUIControl *control, MouseButton button)
  17. {
  18. SaveGameSlot(3, "Save 3");
  19. }

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on a game that was nominated for an AGS Award!
Re: Screenshots in game saves
« Reply #11 on: 08 Jan 2019, 17:17 »
Well, for removing the gui from the screenshot, just close it right before taking the screenshot, and then reopen it again.  It'll be fast enough for the player not to even notice that happend.  ;)

The rest of your question/problem I'll leave for the experts to answer, cause I don't know the answer...
There are those who believe that life here began out there...

Khris

  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: Screenshots in game saves
« Reply #12 on: 08 Jan 2019, 17:37 »
Why is that code in on_event? You only need to run those commands right before you turn gSave visible.

As for hiding the GUI, have you tried calling gSave.Visible = false; right before calling SaveGameSlot()? The latter command is queued and the game is only saved after the function has finished, so it should work that way. I didn't test it though.

No idea why you need to click twice. We need more details and more code to address that.

Re: Screenshots in game saves
« Reply #13 on: 11 Jan 2019, 09:29 »
Hi !

Thank you for your quick answers :)

I should have misunderstood the manual which mentionned "on_event" concerning the dynamic sprites I think.

I change a little bit of my code, trying to do what you adviced me to do, but I still have the "click twice" problem, and the GUI really doesn't want to desapear... -_-
Kris, what kind of fonctions do you think you need to see to adress that ? I had to start over my game recently, so my "global script" is still very "short".

Here's the whole thing :

Code: Adventure Game Studio
  1.  
  2. //----------------------------------------------------------------------------------------------------
  3. // game_start
  4. //----------------------------------------------------------------------------------------------------
  5. function game_start()
  6. {
  7.  
  8. }
  9.  
  10. //----------------------------------------------------------------------------------------------------
  11. // on_event
  12. //----------------------------------------------------------------------------------------------------
  13.  
  14. DynamicSprite *buttonSprite1;
  15. DynamicSprite *buttonSprite2;
  16. DynamicSprite *buttonSprite3;
  17.  
  18. function on_event (EventType event, int data)
  19. {
  20.  
  21. }
  22.  
  23.  
  24. //----------------------------------------------------------------------------------------------------
  25. // repeatedly_execute
  26. //----------------------------------------------------------------------------------------------------
  27. function repeatedly_execute()
  28. {
  29.   Hotspot* hsurvol = Hotspot.GetAtScreenXY(mouse.x,  mouse.y);
  30.   Object* osurvol = Object.GetAtScreenXY(mouse.x,  mouse.y);
  31.   Character* csurvol = Character.GetAtScreenXY(mouse.x,  mouse.y);
  32.   InventoryItem* isurvol = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  33.  
  34.   if (player.ActiveInventory != null) Mouse.Mode = eModeUseinv;
  35.   else if (hsurvol != hotspot[0]) Mouse.Mode = eModeInteract;
  36.   else if (osurvol != null) Mouse.Mode = eModeInteract;
  37.   else if (csurvol != null) Mouse.Mode = eModeInteract;
  38.   else if (isurvol != null) Mouse.Mode = eModeInteract;
  39.   else Mouse.Mode = eModeWalkto;
  40. }
  41.  
  42. //----------------------------------------------------------------------------------------------------
  43. // repeatedly_execute_always
  44. //----------------------------------------------------------------------------------------------------
  45. function repeatedly_execute_always()
  46. {
  47. }
  48.  
  49. //----------------------------------------------------------------------------------------------------
  50. // on_key_press
  51. //----------------------------------------------------------------------------------------------------
  52. function on_key_press(eKeyCode keycode)
  53. {
  54.   if (IsGamePaused()) keycode = 0;
  55.  
  56.   // "System Keys"
  57.   if (keycode == eKeyCtrlQ) QuitGame(1); // Ctrl-Q
  58.   if (keycode == eKeyF9) RestartGame(); // F9
  59.   if (keycode == eKeyF12) SaveScreenShot("scrnshot.pcx");
  60.   if (keycode == eKeyI) {
  61.   if (gInventoryBar.Visible) gInventoryBar.Visible=false;
  62.   else {
  63.   gInventoryBar.Visible=true;
  64.   gPause.Visible=false;
  65.   }
  66.   }
  67.   if (keycode == eKeyEscape) {
  68.     if (gPause.Visible) gPause.Visible=false;
  69.     else {
  70.       gInventoryBar.Visible=false;
  71.       gPause.Visible=true;
  72.     }
  73.   }
  74.  
  75.   // Debugger Keys
  76.   if (keycode == eKeyCtrlS) Debug(0,0); // Ctrl-S, give all inventory
  77.   if (keycode == eKeyCtrlV) Debug(1,0); // Ctrl-V, version
  78.   if (keycode == eKeyCtrlA) Debug(2,0); // Ctrl-A, show walkable areas
  79.   if (keycode == eKeyCtrlX) Debug(3,0); // Ctrl-X, teleport to room
  80. }
  81.  
  82. //----------------------------------------------------------------------------------------------------
  83. // on_mouse_click
  84. //----------------------------------------------------------------------------------------------------
  85. function on_mouse_click(MouseButton button)
  86. {
  87.         // all mouse clicks are handled in TwoClickHandler.asc!
  88. }
  89.  
  90. //----------------------------------------------------------------------------------------------------
  91. // dialog_request
  92. //----------------------------------------------------------------------------------------------------
  93. function dialog_request(int param)
  94. {
  95. }
  96.  
  97.  
  98. //----------------------------------------------------------------------------------------------------
  99. // gTitle
  100. //----------------------------------------------------------------------------------------------------
  101.  
  102. function bNewgame_OnClick(GUIControl *control, MouseButton button)
  103. {
  104. player.ChangeRoom(1, 600, 920, eDirectionDownRight);
  105. }
  106.  
  107. function bLoad1_OnClick(GUIControl *control, MouseButton button)
  108. {
  109. gTitle.Visible=false;
  110. gLoad.Visible=true;
  111. }
  112.  
  113. function bQuit1_OnClick(GUIControl *control, MouseButton button)
  114. {
  115. QuitGame(0);
  116. }
  117.  
  118. //----------------------------------------------------------------------------------------------------
  119. // gPause
  120. //----------------------------------------------------------------------------------------------------
  121.  
  122. function bCommandes_OnClick(GUIControl *control, MouseButton button)
  123. {
  124. gPause.Visible=false;
  125. gControl.Visible=true;
  126. }
  127.  
  128. function bSave_OnClick(GUIControl *control, MouseButton button)
  129. {
  130. gPause.Visible=false;
  131. gSave.Visible=true;
  132. }
  133.  
  134. function bReturnTitle_OnClick(GUIControl *control, MouseButton button)
  135. {
  136. gPause.Visible=false;
  137. gConfirm.Visible=true;
  138. }
  139.  
  140. //----------------------------------------------------------------------------------------------------
  141. // gSave
  142. //----------------------------------------------------------------------------------------------------
  143.  
  144. function bSaveSlot1_OnClick(GUIControl *control, MouseButton button)
  145. {
  146. gSave.Visible=false;  
  147. buttonSprite1=DynamicSprite.CreateFromSaveGame(1, 200, 120);
  148. if (buttonSprite1 != null) {
  149. bScreenSlot1.NormalGraphic=buttonSprite1.Graphic;
  150. SaveGameSlot(1, "Save 1");
  151. gSave.Visible=true;
  152. }
  153. }
  154.  
  155. function bSaveSlot2_OnClick(GUIControl *control, MouseButton button)
  156. {
  157. gSave.Visible=false;
  158. buttonSprite2=DynamicSprite.CreateFromSaveGame(2, 200, 120);
  159. if (buttonSprite2 != null) {
  160. bScreenSlot2.NormalGraphic=buttonSprite2.Graphic;
  161. SaveGameSlot(2, "Save 2");
  162. gSave.Visible=true;
  163. }
  164. }
  165.  
  166. function bSaveSlot3_OnClick(GUIControl *control, MouseButton button)
  167. {
  168. gSave.Visible=false;
  169. buttonSprite3=DynamicSprite.CreateFromSaveGame(3, 200, 120);
  170. if (buttonSprite3 != null) {
  171. bScreenSlot3.NormalGraphic=buttonSprite3.Graphic;
  172. SaveGameSlot(3, "Save 3");
  173. gSave.Visible=true;
  174. }
  175. }
  176.  
  177. function bCloseSave_OnClick(GUIControl *control, MouseButton button)
  178. {
  179. gSave.Visible=false;
  180. }
  181.  
  182.  
  183. //----------------------------------------------------------------------------------------------------
  184. // gLoad
  185. //----------------------------------------------------------------------------------------------------
  186.  
  187. function bCloseLoad_OnClick(GUIControl *control, MouseButton button)
  188. {
  189. gLoad.Visible=false;
  190. }
  191.  
  192. //----------------------------------------------------------------------------------------------------
  193. // gControl
  194. //----------------------------------------------------------------------------------------------------
  195.  
  196. function bQuitControl_OnClick(GUIControl *control, MouseButton button)
  197. {
  198. gControl.Visible=false;
  199. gPause.Visible=true;
  200. }
  201.  
  202. //----------------------------------------------------------------------------------------------------
  203. // gConfirm
  204. //----------------------------------------------------------------------------------------------------
  205.  
  206. //----------------------------------------------------------------------------------------------------
  207. // gInventoryBar
  208. //----------------------------------------------------------------------------------------------------
  209. function btnInvScrollLeft_OnClick(GUIControl *control, MouseButton button)
  210. {
  211.         InventoryWindow1.ScrollDown();
  212. }
  213.  
  214. function btnInvScrollRight_OnClick(GUIControl *control, MouseButton button)
  215. {
  216.         InventoryWindow1.ScrollUp();
  217. }
  218.  
  219. //----------------------------------------------------------------------------------------------------
  220. // unhandled_event
  221. //----------------------------------------------------------------------------------------------------
  222.  
  223. function cSuli_Look()
  224. {
  225. player.Say("C'est moi.");
  226. }
  227.  
  228. function cSuli_Interact()
  229. {
  230. player.Say("Hé ! Arrête, ça chatouille !");
  231. }
  232.  
  233.  



« Last Edit: 11 Jan 2019, 09:31 by Cookie_Wood »

Khris

  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: Screenshots in game saves
« Reply #14 on: 11 Jan 2019, 13:28 »
Add this function to the very top of the script:

Code: Adventure Game Studio
  1. function ShowSaveGUI() {
  2.   // prepare gSave
  3.   buttonSprite1 = DynamicSprite.CreateFromSaveGame(1, 200, 120);
  4.   if (buttonSprite1 != null) bScreenSlot1.NormalGraphic = buttonSprite1.Graphic;
  5.   buttonSprite2 = DynamicSprite.CreateFromSaveGame(2, 200, 120);
  6.   if (buttonSprite2 != null) bScreenSlot2.NormalGraphic = buttonSprite2.Graphic;
  7.   buttonSprite3 = DynamicSprite.CreateFromSaveGame(3, 200, 120);
  8.   if (buttonSprite3 != null) bScreenSlot3.NormalGraphic = buttonSprite3.Graphic;
  9.   // show it
  10.   gSave.Visible = true;
  11. }

Use this for bSave, the button that opens the Save GUI:

Code: Adventure Game Studio
  1. function bSave_OnClick(GUIControl *control, MouseButton button)
  2. {
  3.   gPause.Visible = false;
  4.   ShowSaveGUI();
  5. }

As for the three savegame buttons, they should do this (code for button 1 shown here):

Code: Adventure Game Studio
  1. function bSaveSlot1_OnClick(GUIControl *control, MouseButton button)
  2. {
  3.   gSave.Visible = false;  
  4.   SaveGameSlot(1, "Save 1");  // gets queued, only runs after function has finished
  5.   SetTimer(1, 2);   // schedules displaying the save GUI, which should show the new screenshot
  6. }

Now add this block to your repeatedly_execute:
Code: Adventure Game Studio
  1.   if (IsTimerExpired(1)) ShowSaveGUI();

Not tested.

Re: Screenshots in game saves
« Reply #15 on: 14 Jan 2019, 07:21 »
Good lord, Kris, you're a super hero. It works great. There's only one thing that I had to change.

I had to put this into the globalscript header.ash to work. It didn't work if i put it into the globalscript.asc (token showsaveGUI unknown) But it's cleary written "do not put any function here" so... what do I risk ?

Code: Adventure Game Studio
  1. function ShowSaveGUI() {
  2.   // prepare gSave
  3.   buttonSprite1 = DynamicSprite.CreateFromSaveGame(1, 200, 120);
  4.   if (buttonSprite1 != null) bScreenSlot1.NormalGraphic = buttonSprite1.Graphic;
  5.   buttonSprite2 = DynamicSprite.CreateFromSaveGame(2, 200, 120);
  6.   if (buttonSprite2 != null) bScreenSlot2.NormalGraphic = buttonSprite2.Graphic;
  7.   buttonSprite3 = DynamicSprite.CreateFromSaveGame(3, 200, 120);
  8.   if (buttonSprite3 != null) bScreenSlot3.NormalGraphic = buttonSprite3.Graphic;
  9.   // show it
  10.   gSave.Visible = true;
  11. }

Thank you so much for your help <3

Snarky

  • Global Moderator
  • Private Insultant
    • I can help with proof reading
    • I can help with translating
Re: Screenshots in game saves
« Reply #16 on: 14 Jan 2019, 07:39 »
Put the function in the script, but put an "import" in the header – this makes it available to room scripts:

Code: Adventure Game Studio
  1. import function ShowSaveGUI()

Khris

  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: Screenshots in game saves
« Reply #17 on: 14 Jan 2019, 08:45 »
Do what Snarky said if you need to call the function from a room script.

If not, I suspect you may have missed this part:
Add this function to the very top of the script:

Functions have to be declared before they are called; "before" here means "further up the script". Since you added a call to ShowSaveGUI() to repeatedly_execute which is pretty far up the script, you need to make sure that the ShowSaveGUI function declaration is above the repeatedly_execute function declaration.

Re: Screenshots in game saves
« Reply #18 on: 14 Jan 2019, 15:32 »
Thank you so much to all of you ! Kris, Cassiebsg and Snarky ! It's totally perfect now.  :-D


Re: Screenshots in game saves
« Reply #19 on: 20 Jan 2019, 10:20 »
Hi :D

Just coming one very last time on that topic (i promise :D)

I just have one last problem with my Save and Load GUI. My dynamic sprites have a curious behaviour when it comes to delete them. I added 3 little trashbins on my GUI, to delete the saveslot, the screenshot that you guys kindly helped me with and finally a little Date and time label.

It is very weird, but when I try to delete the first ou second save, the 3rd screenshot just "slip" into the 1st screenshot button position !






This is what Khris helped me to do (sorry i misspelled your name last time Khris) + date and time label

Code: Adventure Game Studio
  1. DynamicSprite *buttonSprite1;
  2. DynamicSprite *buttonSprite2;
  3. DynamicSprite *buttonSprite3;
  4.  
  5. DynamicSprite *buttonSpriteLoad1;
  6. DynamicSprite *buttonSpriteLoad2;
  7. DynamicSprite *buttonSpriteLoad3;
  8.  
  9.  
  10. function ShowSaveGUI()
  11. {
  12.   // prepare gSave
  13.   buttonSprite1 = DynamicSprite.CreateFromSaveGame(1, 150, 90);
  14.   if (buttonSprite1 != null) {
  15.  
  16.   bScreenSlot1.NormalGraphic = buttonSprite1.Graphic;
  17.  
  18.   lblDateSave1.Text = Game.GetSaveSlotDescription(1);
  19.   lblDateSave1.TextColor = 3;
  20.  
  21.   }
  22.  
  23.   buttonSprite2 = DynamicSprite.CreateFromSaveGame(2, 150, 90);
  24.   if (buttonSprite2 != null) {
  25.    
  26.   bScreenSlot2.NormalGraphic = buttonSprite2.Graphic;
  27.  
  28.   lblDateSave2.Text = Game.GetSaveSlotDescription(2);
  29.   lblDateSave2.TextColor = 3;
  30.  
  31.   }
  32.  
  33.  
  34.   buttonSprite3 = DynamicSprite.CreateFromSaveGame(3, 150, 90);
  35.   if (buttonSprite3 != null) {
  36.    
  37.   bScreenSlot3.NormalGraphic = buttonSprite3.Graphic;
  38.  
  39.   lblDateSave3.Text = Game.GetSaveSlotDescription(3);
  40.   lblDateSave3.TextColor = 3;
  41.  
  42.   }
  43.  
  44.   // show it
  45.   gSave.Visible = true;
  46. }
  47.  
  48. function ShowLoadGUI()
  49. {
  50. buttonSpriteLoad1 = DynamicSprite.CreateFromSaveGame(1, 150, 90);
  51. if (buttonSpriteLoad1 != null) {
  52.  
  53.   bScreenLoadSlot1.NormalGraphic = buttonSpriteLoad1.Graphic;
  54.  
  55.   lblDateLoad1.Text = Game.GetSaveSlotDescription(1);
  56.   lblDateLoad1.TextColor = 3;
  57. }
  58.  
  59. buttonSpriteLoad2 = DynamicSprite.CreateFromSaveGame(2, 150, 90);
  60. if (buttonSpriteLoad2 != null) {
  61.  
  62.   bScreenLoadSlot2.NormalGraphic = buttonSpriteLoad2.Graphic;
  63.  
  64.   lblDateLoad2.Text = Game.GetSaveSlotDescription(2);
  65.   lblDateLoad2.TextColor = 3;
  66. }
  67.  
  68. buttonSpriteLoad3 = DynamicSprite.CreateFromSaveGame(3, 150, 90);
  69. if (buttonSpriteLoad3 != null) {
  70.  
  71.   bScreenLoadSlot3.NormalGraphic = buttonSpriteLoad3.Graphic;
  72.  
  73.   lblDateLoad3.Text = Game.GetSaveSlotDescription(3);
  74.   lblDateLoad3.TextColor = 3;
  75. }
  76. gLoad.Visible = true;
  77. }
  78.  

Saving or deleting saveslots by clicking on the portrait or the trashbin (and then openning the "confirm gui" before deleting)
 
Code: Adventure Game Studio
  1. //----------------------------------------------------------------------------------------------------
  2. // gSave
  3. //----------------------------------------------------------------------------------------------------
  4.  
  5.  
  6. function bSaveSlot1_OnClick(GUIControl *control, MouseButton button)
  7. {
  8.  gSave.Visible = false;
  9.  DateTime *dt = DateTime.Now;
  10.  SaveGameSlot(1, String.Format("%02d/%02d/%04d - %02d:%02d:%02d", dt.DayOfMonth, dt.Month, dt.Year, dt.Hour, dt.Minute, dt.Second));
  11.  lblDateSave1.Visible=true; //////// attention new
  12.  lblDateLoad1.Visible=true;
  13.  Overlay *textOverlaySaving;
  14.  textOverlaySaving = Overlay.CreateTextual(800, 300, 400, eFontfntSpeech, 3, "Partie sauvegardée !");
  15.  Wait(50);
  16.  }
  17.  
  18.  
  19.  
  20. function bSaveSlot2_OnClick(GUIControl *control, MouseButton button)
  21. {
  22.  gSave.Visible = false;  
  23.  DateTime *dt = DateTime.Now;
  24.  SaveGameSlot(2, String.Format("%02d/%02d/%04d - %02d:%02d:%02d", dt.DayOfMonth, dt.Month, dt.Year, dt.Hour, dt.Minute, dt.Second));
  25.  lblDateSave2.Visible=true; //////// attention new
  26.  lblDateLoad2.Visible=true;
  27.  Overlay *textOverlaySaving;
  28.  textOverlaySaving = Overlay.CreateTextual(800, 300, 400, eFontfntSpeech, 3, "Partie sauvegardée !");
  29.  Wait(50);
  30. }
  31.  
  32. function bSaveSlot3_OnClick(GUIControl *control, MouseButton button)
  33. {
  34.  gSave.Visible = false;  
  35.  DateTime *dt = DateTime.Now;
  36.  SaveGameSlot(3, String.Format("%02d/%02d/%04d - %02d:%02d:%02d", dt.DayOfMonth, dt.Month, dt.Year, dt.Hour, dt.Minute, dt.Second));
  37.  lblDateSave3.Visible=true; //////// attention new
  38.  lblDateLoad3.Visible=true;
  39.  Overlay *textOverlaySaving;
  40.  textOverlaySaving = Overlay.CreateTextual(800, 300, 400, eFontfntSpeech, 3, "Partie sauvegardée !");
  41.  Wait(50);
  42. }
  43.  
  44. function bCloseSave_OnClick(GUIControl *control, MouseButton button)
  45. {
  46. gSave.Visible=false;
  47. }
  48.  
  49.  
  50. function bSaveTrashbin1_OnClick(GUIControl *control, MouseButton button)
  51. {
  52. gSave.Visible=false;  
  53. gConfirm3.Visible=true;
  54. }
  55.  
  56. function bSaveTrashbin2_OnClick(GUIControl *control, MouseButton button)
  57. {
  58. gSave.Visible=false;
  59. gConfirm4.Visible=true;
  60. }
  61.  
  62. function bSaveTrashbin3_OnClick(GUIControl *control, MouseButton button)
  63. {
  64. gSave.Visible=false;
  65. gConfirm5.Visible=true;
  66. }

Delete the saveslot, the dynamic sprite and label when "confirm Yes"

Code: Adventure Game Studio
  1. //----------------------------------------------------------------------------------------------------
  2. // gConfirm3 DeleteSave1
  3. //----------------------------------------------------------------------------------------------------
  4.  
  5.  
  6. function bYesConfirm3_OnClick(GUIControl *control, MouseButton button)
  7. {
  8. DeleteSaveSlot(1);
  9. gConfirm3.Visible=false;
  10. Overlay *textOverlaySaving;
  11. textOverlaySaving = Overlay.CreateTextual(800, 300, 400, eFontfntSpeech, 3, "Partie supprimée !");
  12. Wait(50);
  13.  
  14. if (buttonSprite1!= null) {
  15. buttonSprite1.Delete();
  16. }
  17.  
  18. if (buttonSpriteLoad1!= null) {
  19. buttonSpriteLoad1.Delete();
  20. }
  21.  
  22. lblDateSave1.Visible=false;
  23. lblDateLoad1.Visible=false;
  24. }
  25.  
  26. function bNoConfirm3_OnClick(GUIControl *control, MouseButton button)
  27. {
  28. gConfirm3.Visible=false;
  29. }

Does someone see why the 3rd screenshot does not want to stay properly on the third button when trying to delete saveslot 1 or 2 ?
I hope I gave enought informations :)
Edit: it's a little bit confusing but : gConfim3 = Save1, gConfirm4= Save2 et gConfirm5 = Save3 (gConfirm 1 et 2 are used to close the game or to return to main menu)
« Last Edit: 20 Jan 2019, 10:33 by Cookie_Wood »