Save/restore GUIs

Started by Moox, Sun 12/02/2006 05:00:51

Previous topic - Next topic

Moox

The scripting is 100% different now from when I last used ags. I managed to figure out how to code most of the guis I need, but I'm so confused as to how to script the save and restore guids.

Objects I have on the GUIs
For save:
lboxSaveÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  lboxSave_SelectionChanged
tboxSaveÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  tboxSave_Activate
btnSaveOkÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, btnSaveOk_Click
btnSaveExitÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  btnSaveExit_Click

For load:
lboxLoadÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, lboxLoad_SelectionChanged
btnLoadExitÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  btnLoadExit_Click

My scripting
Code: ags

#sectionstart interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
Ã,  // This function is obsolete, from 2.62 and earlier versions.
}
#sectionend interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart btnInvUp_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnInvUp_Click(GUIControl *control, MouseButton button) {
Ã,  invCustomInv.ScrollUp();
}
#sectionend btnInvUp_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnInvDown_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnInvDown_Click(GUIControl *control, MouseButton button) {
Ã,  invCustomInv.ScrollDown();
}
#sectionend btnInvDown_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnInvOK_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnInvOK_Click(GUIControl *control, MouseButton button) {
Ã,  
	// They pressed the OK button, close the GUI
	gInventory.Visible = false;
	mouse.UseDefaultGraphic();
}
#sectionend btnInvOK_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnInvExit_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnInvExit_Click(GUIControl *control, MouseButton button) {
Ã,  
	// They pressed the exit button, close the GUI
	gInventory.Visible = false;
	mouse.UseDefaultGraphic();
}
#sectionend btnInvExit_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnInvSelect_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnInvSelect_Click(GUIControl *control, MouseButton button) {
Ã,  
	// They pressed SELECT, so switch to the Get cursor
	mouse.Mode = eModeInteract;
	// But, override the appearance to look like the arrow
	mouse.UseModeGraphic(eModePointer);
}
#sectionend btnInvSelect_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconInv_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconInv_Click(GUIControl *control, MouseButton button) {
Ã,  
Ã,  show_inventory_window();
}
#sectionend btnIconInv_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconCurInv_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconCurInv_Click(GUIControl *control, MouseButton button) {
Ã,  
Ã,  if (player.ActiveInventory != null)
Ã,  Ã,  mouse.Mode = eModeUseinv;
}
#sectionend btnIconCurInv_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconSave_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconSave_Click(GUIControl *control, MouseButton button) {
Ã,  
Ã,  gSave.Visible = true;
Ã,  	// They pressed SELECT, so switch to the Get cursor
	mouse.Mode = eModeInteract;
	// But, override the appearance to look like the arrow
	mouse.UseModeGraphic(eModePointer);
}
#sectionend btnIconSave_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconLoad_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconLoad_Click(GUIControl *control, MouseButton button) {
Ã,  
Ã,  gLoad.Visible = true;
Ã,  	// They pressed SELECT, so switch to the Get cursor
	mouse.Mode = eModeInteract;
	// But, override the appearance to look like the arrow
	mouse.UseModeGraphic(eModePointer);
}
#sectionend btnIconLoad_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconExit_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconExit_Click(GUIControl *control, MouseButton button) {
Ã,  
Ã,  gQuit.Visible = true;
Ã,  	// They pressed SELECT, so switch to the Get cursor
	mouse.Mode = eModeInteract;
	// But, override the appearance to look like the arrow
	mouse.UseModeGraphic(eModePointer);
}
#sectionend btnIconExit_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconAbout_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconAbout_Click(GUIControl *control, MouseButton button) {
Ã,  
Ã,  gMenu.Visible = true;
Ã,  	// They pressed SELECT, so switch to the Get cursor
	mouse.Mode = eModeInteract;
	// But, override the appearance to look like the arrow
	mouse.UseModeGraphic(eModePointer);
}
#sectionend btnIconAbout_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnQuitYes_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnQuitYes_Click(GUIControl *control, MouseButton button) {
Ã,  QuitGame(0);
}
#sectionend btnQuitYes_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart btnQuitNo_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnQuitNo_Click(GUIControl *control, MouseButton button) {
Ã,  gQuit.Visible = false;Ã,  
}
#sectionend btnQuitNo_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnMenuExit_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnMenuExit_Click(GUIControl *control, MouseButton button) {
Ã,  gMenu.Visible = false;
}
#sectionend btnMenuExit_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnLoadExit_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnLoadExit_Click(GUIControl *control, MouseButton button) {
Ã,  gLoad.Visible = false;
}
#sectionend btnLoadExit_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnSaveExit_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnSaveExit_Click(GUIControl *control, MouseButton button) {
Ã,  gSave.Visible = false;
}
#sectionend btnSaveExit_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart sldVolume_ChangeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function sldVolume_Change(GUIControl *control) {
Ã,  sldVolume.Max = 100;
Ã,  sldVolume.Min = 0;
Ã,  SetMusicMasterVolume(sldVolume.Value);
}
#sectionend sldVolume_ChangeÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart sldSpeed_ChangeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function sldSpeed_Change(GUIControl *control) {
Ã,  sldSpeed.Max = 200;
Ã,  sldSpeed.Min = 40;
Ã,  SetGameSpeed(sldSpeed.Value);
 
}
#sectionend sldSpeed_ChangeÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart lboxLoad_SelectionChangedÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function lboxLoad_SelectionChanged(GUIControl *control) {
Ã,  
}
#sectionend lboxLoad_SelectionChangedÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnSaveOk_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnSaveOk_Click(GUIControl *control, MouseButton button) {
Ã,  
}
#sectionend btnSaveOk_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart lboxSave_SelectionChangedÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function lboxSave_SelectionChanged(GUIControl *control) {
Ã,  
}
#sectionend lboxSave_SelectionChangedÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart tboxSave_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function tboxSave_Activate(GUIControl *control) {
Ã,  
}
#sectionend tboxSave_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnMenuAGS_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnMenuAGS_Click(GUIControl *control, MouseButton button) {
Ã,  Display("Thanks to Chris Jones for creating the AGS engine");
}
#sectionend btnMenuAGS_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

Ashen

The command names are different, but the actual mechanics of it haven't changed much - if you knew how to make save/load GUIs in the old scripting, you can probably do it now. This thread has some of the new script - it might be a bit specific to what sloppy wanted (and doesn't use the newest String types), but  perhaps it can point you in the right direction.
I know what you're thinking ... Don't think that.

Moox

Its been so long. I managed to get the listboxes to display the save games, I also am able to save in slot one so far. My load game is not working right though. I test it but I get a file can not be found message.
Code: ags

#sectionstart lboxLoad_SelectionChanged  // DO NOT EDIT OR REMOVE THIS LINE
function lboxLoad_SelectionChanged(GUIControl *control) {
int LoadGame = lboxLoad.SelectedIndex;
RestoreGameSlot(LoadGame); 

}
#sectionend lboxLoad_SelectionChanged  // DO NOT EDIT OR REMOVE THIS LINE

Thats what I have in my load GUI, what I want it to do is get the selected save and load it when enter is pressed.
Heres what I have for save so far
Code: ags

#sectionstart btnSaveOk_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnSaveOk_Click(GUIControl *control, MouseButton button) {
  String text = tboxSave.Text;
  SaveGameSlot(1, text);
  gSave.Visible = false;
}
#sectionend btnSaveOk_Click  // DO NOT EDIT OR REMOVE THIS LINE

Im trying to figure out how to script multiple slots still. I want a max of 4. I am confused as to how to create an int for the slot number to save and to check number of slots there already are. Help would be appreciated.

Ashen

#3
Go back to that other thread for more details on the SaveGUI stuff, but basically:
Code: ags

#sectionstart lboxLoad_SelectionChanged  // DO NOT EDIT OR REMOVE THIS LINE
function lboxLoad_SelectionChanged(GUIControl *control) {
int LoadGame = lboxLoad.SelectedIndex;
RestoreGameSlot(savegameindex[LoadGame]);
}
#sectionend lboxLoad_SelectionChanged  // DO NOT EDIT OR REMOVE THIS LINE

Otherwise - with a single save game - you'd be trying to load Save.000 (the first item of a ListBox being 0, and not 1), while the actual save would be Save.001. And once you get more than 1 game, it'd be even more confused (the savegames are sorted chronologicly, rather than by saveslot used).

And:
Code: ags

#sectionstart btnSaveOk_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnSaveOk_Click(GUIControl *control, MouseButton button) {
  int index = lboxSave.ItemCount;
  if (index < 4) {
    String text = tboxSave.Text;
    SaveGameSlot(index+1, text);
    gSave.Visible = false;
  }
}
#sectionend btnSaveOk_Click  // DO NOT EDIT OR REMOVE THIS LINE

This'll allow a maximum of 4 save games. Again, look at the other thread for how to overwrite.
HOWEVER, since you only want/need 4 saveslots, maybe individual buttons would be the easier way to go about it, instead of messing around with the ListBoxes, e.g. (pseudocode):
Code: ags

function btnSaveOne_Click(GUIControl *control, MouseButton button) {
  String text = tboxSave.Text;
  SaveGameSlot(1, text);
  gSave.Visible = false;
}
 // etc

function btnLoadOne_Click(GUIControl *control, MouseButton button) {
  RestoreGameSlot(1);
  gLoad.Visible = false;
}
 // etc
I know what you're thinking ... Don't think that.

Moox

#4
Alright, I have the load GUI working perfect now, just a few more questions about save
Code: ags

#sectionstart btnSaveOk_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function btnSaveOk_Click(GUIControl *control, MouseButton button) {
Ã,  int index = lboxSave.ItemCount;
Ã,  if (index < 4) {
Ã,  Ã,  String text = tboxSave.Text;
Ã,  Ã,  SaveGameSlot(index+1, text);
Ã,  Ã,  gSave.Visible = false;
Ã,  }
Ã,  else {
Ã,  Ã,  String text = tboxSave.Text;
Ã,  Ã,  DisplayAtY (20, "Capacity reached, Select a slot to overwrite.");
Ã,  Ã,  int SaveGame = lboxSave.SelectedIndex;
Ã,  Ã,  SaveGameSlot(SaveGame, text);
Ã,  Ã,  Wait(5);
Ã,  Ã,  gSave.Visible = false;
Ã,  }
}
#sectionend btnSaveOk_ClickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

It still seems to overwrite the first slot, when I click one of the list boxes it still highlights the first one. Im so confused, sorry if I'm just over looking something. Also, is there a way to disable the little scroll bars that show up when my listbox is full?

Edit: The highlight in the listbox is only showing up for less then a second in the
load one too come to think of it. All my test saves are from the same room so I cant tell if its only loading the first slot.
Code: ags

#sectionstart lboxLoad_SelectionChanged  // DO NOT EDIT OR REMOVE THIS LINE
function lboxLoad_SelectionChanged(GUIControl *control) {
int LoadGame = lboxLoad.SelectedIndex;
Wait(5);
RestoreGameSlot(savegameindex[LoadGame]);
}
#sectionend lboxLoad_SelectionChanged  // DO NOT EDIT OR REMOVE THIS LINE

Does that look correct?

Ashen

#5
It doesn't seem to give the player a chance to select a slot to overwrite, it just gets the currently selected one (the first by default) and tries to save there. Like with the Load GUI, you should probably use SaveGameSlot(savegameindex[SaveGame], text); to make sure it actually saves over the selected slot (I'm assuming you're using ListBoxes and ListBox.FillSaveGameList()).
You could try deselecting all slots when you open the Save GUI (lboxSave.SelectedIndex = -1;) and forcing the player to have made a selection:
Code: ags

  else {
    String text = tboxSave.Text;
    int SaveGame = lboxSave.SelectedIndex;
    if (SaveGame == -1) DisplayAtY (20, "Capacity reached, Select a slot to overwrite.");
   else {
     SaveGameSlot(savegameindex[SaveGame], text);
     Wait(5);
     gSave.Visible = false;
   }
 }

Or, you could script a seperate Confirmation GUI that's displayed when the 4 slot limit has been reached. (Confirming an overwrite is almost certainly a good idea anyway.)

Also remember that (if you ARE still using the ListBoxes and ListBox.FillSaveGameList()) the games are ordered by most recent save, so whichever slot is saved over, it'll be at the top of the list next time you open the Save or Load GUI.

The scrollbars can be got rid off by changing the ListBox's 'Hide Borders' property to 'Yes'. (In the new betas, I think there's a seperate option for 'Hide Scrollbars'.)
I know what you're thinking ... Don't think that.

Moox

Still no luck
Code: ags
// main global script file

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  // called when the game starts, before the first room is loaded
}
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  lboxLoad.FillSaveGameList();
  lboxSave.FillSaveGameList();
  // put anything you want to happen every game cycle here
}
#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE


function show_inventory_window () {
  // This demonstrates both types of inventory window - the first part is how to
  // show the built-in inventory window, the second part uses the custom one.
  // Un-comment one section or the other below.
  
  // ** DEFAULT INVENTORY WINDOW
//  InventoryScreen();

  // ** CUSTOM INVENTORY WINDOW
  gInventory.Visible = true;
  // switch to the Use cursor (to select items with)
  mouse.Mode = eModeInteract;
  // But, override the appearance to look like the arrow
  mouse.UseModeGraphic(eModePointer);

}

#sectionstart on_key_press  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) {
  // called when a key is pressed. keycode holds the key's ASCII code
  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
  if (keycode==17)  QuitGame(1);   // Ctrl-Q
  if (keycode==363) SaveGameDialog();   // F5
  if (keycode==365) RestoreGameDialog();  // F7
  if (keycode==367) RestartGame();  // F9
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9)   show_inventory_window();  // Tab, show inventory

  if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode==22)  Debug(1,0);  // Ctrl-V, version
  if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room
}
#sectionend on_key_press  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else {   // right-click, so cycle cursor
    mouse.SelectNextMode();
  }
}
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
  // This function is obsolete, from 2.62 and earlier versions.
}
#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart btnInvUp_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnInvUp_Click(GUIControl *control, MouseButton button) {
  invCustomInv.ScrollUp();
}
#sectionend btnInvUp_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnInvDown_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnInvDown_Click(GUIControl *control, MouseButton button) {
  invCustomInv.ScrollDown();
}
#sectionend btnInvDown_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnInvOK_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnInvOK_Click(GUIControl *control, MouseButton button) {
  
	// They pressed the OK button, close the GUI
	gInventory.Visible = false;
	mouse.UseDefaultGraphic();
}
#sectionend btnInvOK_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnInvExit_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnInvExit_Click(GUIControl *control, MouseButton button) {
  
	// They pressed the exit button, close the GUI
	gInventory.Visible = false;
	mouse.UseDefaultGraphic();
}
#sectionend btnInvExit_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnInvSelect_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnInvSelect_Click(GUIControl *control, MouseButton button) {
  
	// They pressed SELECT, so switch to the Get cursor
	mouse.Mode = eModeInteract;
	// But, override the appearance to look like the arrow
	mouse.UseModeGraphic(eModePointer);
}
#sectionend btnInvSelect_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconInv_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconInv_Click(GUIControl *control, MouseButton button) {
  
  show_inventory_window();
}
#sectionend btnIconInv_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconCurInv_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconCurInv_Click(GUIControl *control, MouseButton button) {
  
  if (player.ActiveInventory != null)
    mouse.Mode = eModeUseinv;
}
#sectionend btnIconCurInv_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconSave_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconSave_Click(GUIControl *control, MouseButton button) {
  
  gSave.Visible = true;
  	// They pressed SELECT, so switch to the Get cursor
	mouse.Mode = eModeInteract;
	// But, override the appearance to look like the arrow
	mouse.UseModeGraphic(eModePointer);
}
#sectionend btnIconSave_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconLoad_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconLoad_Click(GUIControl *control, MouseButton button) {
  
  gLoad.Visible = true;
  	// They pressed SELECT, so switch to the Get cursor
	mouse.Mode = eModeInteract;
	// But, override the appearance to look like the arrow
	mouse.UseModeGraphic(eModePointer);
}
#sectionend btnIconLoad_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconExit_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconExit_Click(GUIControl *control, MouseButton button) {
  
  gQuit.Visible = true;
  	// They pressed SELECT, so switch to the Get cursor
	mouse.Mode = eModeInteract;
	// But, override the appearance to look like the arrow
	mouse.UseModeGraphic(eModePointer);
}
#sectionend btnIconExit_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnIconAbout_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnIconAbout_Click(GUIControl *control, MouseButton button) {
  
  gMenu.Visible = true;
  	// They pressed SELECT, so switch to the Get cursor
	mouse.Mode = eModeInteract;
	// But, override the appearance to look like the arrow
	mouse.UseModeGraphic(eModePointer);
}
#sectionend btnIconAbout_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnQuitYes_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnQuitYes_Click(GUIControl *control, MouseButton button) {
  QuitGame(0);
}
#sectionend btnQuitYes_Click  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart btnQuitNo_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnQuitNo_Click(GUIControl *control, MouseButton button) {
  gQuit.Visible = false;  
}
#sectionend btnQuitNo_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnMenuExit_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnMenuExit_Click(GUIControl *control, MouseButton button) {
  gMenu.Visible = false;
}
#sectionend btnMenuExit_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnLoadExit_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnLoadExit_Click(GUIControl *control, MouseButton button) {
  gLoad.Visible = false;
}
#sectionend btnLoadExit_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnSaveExit_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnSaveExit_Click(GUIControl *control, MouseButton button) {
  gSave.Visible = false;
}
#sectionend btnSaveExit_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart sldVolume_Change  // DO NOT EDIT OR REMOVE THIS LINE
function sldVolume_Change(GUIControl *control) {
  sldVolume.Max = 100;
  sldVolume.Min = 0;
  SetMusicMasterVolume(sldVolume.Value);
}
#sectionend sldVolume_Change  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart sldSpeed_Change  // DO NOT EDIT OR REMOVE THIS LINE
function sldSpeed_Change(GUIControl *control) {
  sldSpeed.Max = 200;
  sldSpeed.Min = 40;
  SetGameSpeed(sldSpeed.Value);
 
}
#sectionend sldSpeed_Change  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart lboxLoad_SelectionChanged  // DO NOT EDIT OR REMOVE THIS LINE
function lboxLoad_SelectionChanged(GUIControl *control) {
int LoadGame = lboxLoad.SelectedIndex;
Wait(5);
RestoreGameSlot(savegameindex[LoadGame]);
}
#sectionend lboxLoad_SelectionChanged  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnSaveOk_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnSaveOk_Click(GUIControl *control, MouseButton button) {
  int index = lboxSave.ItemCount;
  if (index < 4) {
    String text = tboxSave.Text;
    SaveGameSlot(index+1, text);
    gSave.Visible = false;
  }
else {
    String text = tboxSave.Text;
    int SaveGame = lboxSave.SelectedIndex;
    if (SaveGame == -1) DisplayAtY (20, "Capacity reached, Select a slot to overwrite.");
   else {
     SaveGameSlot(savegameindex[SaveGame], text);
     Wait(5);
     gSave.Visible = false;
   }
}
}
#sectionend btnSaveOk_Click  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart lboxSave_SelectionChanged  // DO NOT EDIT OR REMOVE THIS LINE
function lboxSave_SelectionChanged(GUIControl *control) {
}
#sectionend lboxSave_SelectionChanged  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart tboxSave_Activate  // DO NOT EDIT OR REMOVE THIS LINE
function tboxSave_Activate(GUIControl *control) {
  
}
#sectionend tboxSave_Activate  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart btnMenuAGS_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnMenuAGS_Click(GUIControl *control, MouseButton button) {
  Display("Thanks to Chris Jones for creating the AGS engine.");
}
#sectionend btnMenuAGS_Click  // DO NOT EDIT OR REMOVE THIS LINE


Is it because I have the fill list stuff in rep execute?

Ashen

That'll be it, alright. You only need the ListBox.FillSaveGameList() commands calling when you turn the GUI on (btnIconSave/Load and probably on_key_press although that's still using the defualts) - otherwise the list is constantly refreshed and, as you've noticed, the selected item is reset.
I know what you're thinking ... Don't think that.

Moox

Everything is working great now, thanks for all the help Ashen. One last question, how do I make it so if the player hits enter when in the save game text box it saves?
I know enter is number 13. I just dont know how to script it anymore, I remember there was an old command to find out if the key was pressed, im pretty sure IsKeyPressed (13); wont work though.

Ashen

Well, pressing enter will trigger the TextBox's Control Function, so just copy the code from the Save button (btnSaveOk_Click) into tboxSave_Activate - or setting tboxSave_Activate to run btnSaveOk's function could work, too:
Code: ags

#sectionstart tboxSave_Activate  // DO NOT EDIT OR REMOVE THIS LINE
function tboxSave_Activate(GUIControl *control) {
  btnSaveOk_Click(btnSaveOK, eMouseLeft);
  // The parameters don't really matter, as long as SOMETHING's there
}
#sectionend tboxSave_Activate  // DO NOT EDIT OR REMOVE THIS LINE
[/code
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk