How do you create a Restore and Save Game Dialog

Started by Edwin Xie, Fri 08/10/2004 05:49:37

Previous topic - Next topic

monkey0506

Generally that means that you haven't scripted anything for that button... Check to make sure that the button you are clicking is the button# you used in interface_click(int button)... And try posting the script as well...

Edwin Xie

Code: ags
// main global script file
#define SAVELOAD_SLOTS_MAX 20 Ã, // Ã, the max number of saved slots (*must* be 20 or less!);

// Slot name if user doesn't specify one:
#define SLD_DESCRIPTION_DEFAULT "Unnamed slot"

// Default warning messages:
#define SLD_MESSAGE_TooManyGameSlots Ã,  Ã,  Ã,  "There are too many game slots. Please, choose an already existing item to overwrite!"
#define SLD_MESSAGE_NoItemSelectedToLoad Ã,  "Please, choose an item to load!"
#define SLD_MESSAGE_NoItemSelectedToDelete "Please, choose a slot to delete!"

//--------
// Flags:
//--------

// Close the dialog GUI after saving the game (1 - yes, 0 - no):
int sld_bCloseGUIAfterSave = 0;

// Save the game on 'Enter' pressed:
int sld_bDoSaveOnEnterPressed = 1;



// Save/Load dialog GUI:
int sldGUI = -1; Ã,  Ã,  Ã,  Ã,  Ã, // Ã, saveload dialog GUI (-1 until opened);

// Save/Load dialog GUI objects:
int sldTextbox Ã,  Ã,  Ã, = -1; Ã, // Ã, saveload textbox GUI object number;
int sldListbox Ã,  Ã,  Ã, = -1; Ã, // Ã, saveload listbox GUI object number;

int sldSaveButton Ã,  = -1; Ã, // Ã, saveload save Ã,  button GUI object number;
int sldLoadButton Ã,  = -1; Ã, // Ã, saveload load Ã,  button GUI object number;
int sldDeleteButton = -1; Ã, // Ã, saveload delete button GUI object number;
int sldCancelButton = -1; Ã, // Ã, saveload cancel button GUI object number;



//-----------------------
// Functions:
//-----------------------

function PrepareSaveLoadDialog(
 Ã, int GUI, 
 Ã, int textbox, 
 Ã, int listbox, 
 Ã, int saveButton, 
 Ã, int loadButton, 
 Ã, int deleteButton, 
 Ã, int cancelButton) {
//=---------------------------------------------------------------------=
// Ã, Prepares a save/load dialog GUI (setting necessary GUI objects),
//=---------------------------------------------------------------------=

 Ã,  Ã, // Ã, if GUI wasn't specified:
 Ã,  Ã, if (GUI == -1)
 Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã, // Ã, display error message and abort the game:
 Ã,  Ã,  Ã,  Ã, Display("Error: Save/Load dialog GUI hasn't been set up!");
 Ã,  Ã,  Ã,  Ã, QuitGame(0);
 Ã,  Ã, }

 Ã,  Ã, sldGUI = GUI; Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, set saveload GUI;
 Ã,  Ã, sldTextbox Ã,  Ã,  Ã, = textbox; Ã,  Ã,  Ã,  // Ã, set saveload textbox GUI object number;
 Ã,  Ã, sldListbox Ã,  Ã,  Ã, = listbox; Ã,  Ã,  Ã,  // Ã, set saveload listbox GUI object number;

 Ã,  Ã, sldSaveButton Ã,  = saveButton; Ã,  Ã, // Ã, set saveload save Ã,  button GUI object number;
 Ã,  Ã, sldLoadButton Ã,  = loadButton; Ã,  Ã, // Ã, set saveload load Ã,  button GUI object number;
 Ã,  Ã, sldDeleteButton = deleteButton; Ã, // Ã, set saveload delete button GUI object number;
 Ã,  Ã, sldCancelButton = cancelButton; Ã, // Ã, set saveload cancel button GUI object number;
} 
 Ã,  

function on_event_SaveLoadDialogGUI(int event, int data) {
//=---------------------------------------------------------------------=
// Ã, Processes events catched through the on_event function.
// Ã, Note: it must be called from within the on_event function!
//=---------------------------------------------------------------------=

 Ã,  Ã, // We have to catch a click over a textbox here as
 Ã,  Ã, // the interface_click function isn't triggered
 Ã,  Ã, // if such an event happens!

 Ã,  Ã, // Ã, if there is click over a textbox:
 Ã,  Ã, if (event == GUI_MDOWN)
 Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã, if (data == sldGUI)
 Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, if (GetGUIObjectAt(mouse.x ,mouse.y) == sldTextbox)
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, remove listbox highlight (textbox has a focus now!):
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, ListBoxSetSelected(sldGUI, sldListbox, -1);
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã, }

}


function UpdateSaveLoadDialogGUI() {
//=---------------------------------------------------------------------=
// Ã, Updates the saveload dialog GUI to reflect the changes being made
// Ã, and returns the total number of saved slots.
//=---------------------------------------------------------------------=

 Ã,  Ã, // Ã, store an old value (to restore it later): Ã, 
 Ã,  Ã, int selectedItem = ListBoxGetSelected(sldGUI, sldListbox);
 Ã,  Ã, 
 Ã,  Ã, // Ã, update the savegame list (seleted item is reset here ot 0!):
 Ã,  Ã, ListBoxSaveGameList(sldGUI, sldListbox);
 Ã,  Ã, 
 Ã,  Ã, // Ã, get the number of slots (it's == number of the items in a listbox):
 Ã,  Ã, int totalSlots = ListBoxGetNumItems(sldGUI, sldListbox);
 Ã,  Ã, 
 Ã,  Ã, // Ã, if we have exceeded the limits display a warning message:
 Ã,  Ã, //if (totalSlots > SAVELOAD_SLOTS_MAX) Display("too many slots!");
 Ã,  Ã, 
 Ã,  Ã, // restore an old value (stored in selectedItem);
 Ã,  Ã, ListBoxSetSelected(sldGUI, sldListbox, selectedItem);
 Ã, 
 Ã,  Ã, // Ã, return the number of saved slots:
 Ã,  Ã, return totalSlots;
}


function OpenDialogGUI() {
//=---------------------------------------------------------------------=
// Ã, Initializes and then finally opens the save/load dialog:
//=---------------------------------------------------------------------=

 Ã,  Ã, CentreGUI(sldGUI); Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Ã, centre the save/load GUI;
 Ã,  Ã, GUIOn(sldGUI); Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Ã, turn the related GUI on;
 Ã,  Ã, UpdateSaveLoadDialogGUI(); Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Ã, refresh GUI's content (show saved games);
 Ã,  Ã, ListBoxSetSelected(sldGUI, sldListbox, -1); Ã,  Ã,  Ã, // Ã, remove the highlight:
 Ã,  Ã, 
 Ã,  Ã, // Ã, if the textbox is specified:
 Ã,  Ã, if (sldTextbox != -1)
 Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã, SetTextBoxText(sldGUI, sldTextbox, ""); Ã,  Ã,  Ã, // Ã, clear textbox;
 Ã,  Ã, }
 Ã,  Ã, 
 Ã,  Ã, Wait(1); Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Ã, update the screen to show the GUI;
 Ã,  Ã, SetMouseCursor(6); Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Ã, override cursor to look like an arrow;
}


function CloseSaveLoadDialog() {
//=---------------------------------------------------------------------=
// Ã, Closes the save/load dialog:
//=---------------------------------------------------------------------=
 Ã, 
 Ã,  Ã, SetDefaultCursor(); Ã,  Ã,  Ã,  Ã,  // Ã, restore cursor appearence;
 Ã,  Ã, GUIOff(sldGUI); Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Ã, turn the related GUI off;
 Ã,  Ã, sldGUI = -1; Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, free save/load dialog GUI;
}


function interface_click_SaveLoadDialogGUI(int button) {
//=---------------------------------------------------------------------=
// Ã, Processes clicks on a save/load dialog GUI.
// Ã, Note: it must be called from within the interface_click function!
//=---------------------------------------------------------------------=


//-------------------------------------------------------------------
 Ã,  Ã, // if click on a *listbox item*:
 Ã,  Ã, if Ã,  Ã,  Ã, (button == sldListbox)
 Ã,  Ã, {
 Ã,  Ã,  // Ã, Show currently selected saved slot's description in a textbox:
 Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, give us a temp buffer to transfer string:
 Ã,  Ã,  Ã,  Ã, string buffer;
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, get selected item:
 Ã,  Ã,  Ã,  Ã, int selectedItem = ListBoxGetSelected(sldGUI, button);
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, copy saved game description into 'buffer':
 Ã,  Ã,  Ã,  Ã, ListBoxGetItemText(sldGUI, button, selectedItem, buffer);

 Ã,  Ã,  Ã,  Ã, // Ã, and finally, if the textbox exists:
 Ã,  Ã,  Ã,  Ã, if (sldTextbox != -1)
 Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, fill the textbox with what is stored in 'buffer':
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SetTextBoxText(sldGUI, sldTextbox, buffer);
 Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã, }
//-------------------------------------------------------------------
 Ã,  Ã, // if click on a *save button* or *enter key* is pressed:
 Ã,  Ã, else if ( (button == sldSaveButton) || ((button == sldTextbox) && (sld_bDoSaveOnEnterPressed == 1)) )
 Ã,  Ã, {
 Ã,  Ã,  // Save a game to slot:
 Ã,  Ã,  
 Ã,  Ã,  Ã,  Ã, // Ã, get total the number of slots:
 Ã,  Ã,  Ã,  Ã, int totalSlots = UpdateSaveLoadDialogGUI();
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, get selected item:
 Ã,  Ã,  Ã,  Ã, int selectedItem = ListBoxGetSelected(sldGUI, sldListbox);
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, allocate string to transfer slot description:
 Ã,  Ã,  Ã,  Ã, string strDescription;
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, fill 'strDescription' with the message in a listbox:
 Ã,  Ã,  Ã,  Ã, GetTextBoxText(sldGUI, sldTextbox, strDescription);
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, if there is no text description then set default SLD_DESCRIPTION_DEFAULT:
 Ã,  Ã,  Ã,  Ã, if (StrLen(strDescription) == 0) StrCopy(strDescription, SLD_DESCRIPTION_DEFAULT);
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, if it's not out of bounds...
 Ã,  Ã,  Ã,  Ã, if ( ( selectedItem >= 0 ) && ( selectedItem < SAVELOAD_SLOTS_MAX ) )
 Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, overwrite save game slot (with a GUI temporarily disabled):
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GUIOff(sldGUI);
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SetDefaultCursor();
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SaveGameSlot(savegameindex[selectedItem], strDescription);
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SetMouseCursor(6);
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GUIOn(sldGUI);
 Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã,  Ã,  Ã, // Ã, if there is no slot selected...
 Ã,  Ã,  Ã,  Ã, else if ( (selectedItem == -1) && (totalSlots < SAVELOAD_SLOTS_MAX) )
 Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, save to a new slot (with a GUI temporarily disabled):
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GUIOff(sldGUI);
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SetDefaultCursor();
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SaveGameSlot(totalSlots + 1, strDescription);
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, SetMouseCursor(6);
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, GUIOn(sldGUI);
 Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã,  Ã,  Ã, else
 Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, display a warning message (slots limit was exceeded):
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, Display(SLD_MESSAGE_TooManyGameSlots);
 Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, update the save/load GUI
 Ã,  Ã,  Ã,  Ã, UpdateSaveLoadDialogGUI();
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, remove the highlight:
 Ã,  Ã,  Ã,  Ã, ListBoxSetSelected(sldGUI, sldListbox, -1);
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, clear a textbox;
 Ã,  Ã,  Ã,  Ã, SetTextBoxText(sldGUI, sldTextbox, "");
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, if the sld_bCloseGUIAfterSave flag is true then close the GUI:
 Ã,  Ã,  Ã,  Ã, if (sld_bCloseGUIAfterSave == 1)
 Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, CloseSaveLoadDialog(); // close the save/load GUI;
 Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã, }
//-------------------------------------------------------------------
 Ã,  Ã, // if click on a *load button*:
 Ã,  Ã, else if (button == sldLoadButton)
 Ã,  Ã, {
 Ã,  Ã,  // Try to delete a saved slot:
 Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, get selected item:
 Ã,  Ã,  Ã,  Ã, int selectedItem = ListBoxGetSelected(sldGUI, sldListbox);
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, if it's not out of bounds...
 Ã,  Ã,  Ã,  Ã, if ( ( selectedItem >= 0 ) && ( selectedItem < SAVELOAD_SLOTS_MAX ) )
 Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, restore game from the slot:
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, RestoreGameSlot(savegameindex[selectedItem]);
 Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã,  Ã,  Ã, else // Ã, otherwise...
 Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, display a message (as slot isn't selected):
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, Display(SLD_MESSAGE_NoItemSelectedToLoad);
 Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, update the save/load GUI
 Ã,  Ã,  Ã,  Ã, UpdateSaveLoadDialogGUI();
 Ã,  Ã, }
//-------------------------------------------------------------------
 Ã,  Ã, // if click on a *delete button*:
 Ã,  Ã, else if (button == sldDeleteButton)
 Ã,  Ã, {
 Ã,  Ã,  // Try to delete a saved slot:

 Ã,  Ã,  Ã,  Ã, // Ã, get selected item:
 Ã,  Ã,  Ã,  Ã, int selectedItem = ListBoxGetSelected(sldGUI, sldListbox);
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã, // Ã, if it's not out of bounds...
 Ã,  Ã,  Ã,  Ã, if ( ( selectedItem >= 0 ) && ( selectedItem < SAVELOAD_SLOTS_MAX ) )
 Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, delete the slot:
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, DeleteSaveSlot(savegameindex[selectedItem]);
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, update the save/load GUI and get the number of items:
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, int totalSlots = UpdateSaveLoadDialogGUI();
 Ã,  Ã,  Ã,  Ã, 
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, When we delete *the last* slot the highlight is
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, removed, so we should get it back by highlighting
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, a new last slot:
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, if (ListBoxGetSelected(sldGUI, sldListbox) == -1)
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, highlight the last item if required:
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, ListBoxSetSelected(sldGUI, sldListbox, totalSlots - 1);
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã,  Ã,  Ã, else // Ã, otherwise...
 Ã,  Ã,  Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Ã, display a message (as slot isn't selected):
 Ã,  Ã,  Ã,  Ã,  Ã,  Ã, Display(SLD_MESSAGE_NoItemSelectedToDelete);
 Ã,  Ã,  Ã,  Ã, }
 Ã,  Ã, }
//-------------------------------------------------------------------
 Ã,  Ã, // if click on a *cancel button*:
 Ã,  Ã, else if (button == sldCancelButton)
 Ã,  Ã, {
 Ã,  Ã,  Ã,  Ã, CloseSaveLoadDialog(); // close the save/load GUI;
 Ã,  Ã, }

}


function OpenSaveLoadDialog() {
//=---------------------------------------------------------------------=
// Ã, Opens the *save/load* combo dialog:
//=---------------------------------------------------------------------=

 Ã,  Ã, // Ã, Setting up the GUI (pass -1 if the GUI object is unused!):
 Ã,  Ã, // Ã, ------------------------GUI---tbox--lbox--save--load--del--cancel
 Ã,  Ã, PrepareSaveLoadDialog( Ã,  Ã,  Ã,  10, Ã, 0, Ã,  Ã, 1, Ã,  Ã, 4, Ã,  Ã, 3, Ã,  5, Ã,  Ã, 6 Ã, );
 Ã,  Ã, 
 Ã,  Ã, // Ã, Open GUI:
 Ã,  Ã, OpenDialogGUI();
}


function OpenSaveDialog() {
//=---------------------------------------------------------------------=
// Ã, Opens the *save* dialog:
//=---------------------------------------------------------------------=

 Ã,  Ã, // Ã, Setting up the GUI (pass -1 if the GUI object is unused!):
 Ã,  Ã, // Ã, ------------------------GUI---tbox--lbox--save--load--del--cancel
 Ã,  Ã, PrepareSaveLoadDialog( Ã,  Ã,  Ã,  8, Ã,  Ã,  3, Ã,  Ã, 2, Ã,  Ã, 0, Ã,  -1, Ã,  5, Ã,  Ã, 1 Ã, );
 Ã,  Ã, 
 Ã,  Ã, // Ã, Open GUI:
 Ã,  Ã, OpenDialogGUI();

}


function OpenLoadDialog() {
//=---------------------------------------------------------------------=
// Ã, Opens the *load* dialog:
//=---------------------------------------------------------------------=

 Ã,  Ã, // Ã, Setting up the GUI (pass -1 if the GUI object is unused!):
 Ã,  Ã, // Ã, ------------------------GUI---tbox--lbox--save--load--del--cancel
 Ã,  Ã, PrepareSaveLoadDialog( Ã,  Ã,  Ã,  9, Ã,  Ã, -1, Ã,  Ã, 0, Ã,  -1, Ã,  Ã, 1, Ã, -1, Ã,  Ã, 2 Ã, );
 Ã,  Ã, 
 Ã,  Ã, // Ã, Open GUI:
 Ã,  Ã, OpenDialogGUI();
}





function on_event(int event, int data) {
 Ã, // called when an event happens (see AGS manual for details)
 Ã, 
 Ã,  Ã, // Ã, inform our save/load GUI of the event;
 Ã,  Ã, on_event_SaveLoadDialogGUI(event, data);
}
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Edwin Xie

And that is only part of it. Since I can't exceed the 20000 characters limit in these forums. I am forced to double post and here is the rest of it:
http://www.2dadventure.com/ags/edsglobalscript1.zip
sorry for the zip file, 2dadventure does not allow txt files.....
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Scorpiorus

You forget to add one essential line into interface_click:

function interface_click(int interface, int button) {

Ã,  //Ã,  calling our function for clicks over sldGUI:
Ã,  if (interface == sldGUI) interface_click_SaveLoadDialogGUI(button);

...
...

Edwin Xie

Thanks. Uhoh, now I realized that when I read your post it took almost 100 seconds. With 19 queries. Maybe I was downloading that game at 10kbps when it should normally be about 4kbps.
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Edwin Xie

I have one final question to ask, which lines do I have to modify to make it so that the player can save a limit of 100 save game slots?
Moving at superhigh speed getting to the planet called Earth. But it is boxed in white......thing.....

Scorpiorus

It's not currently possible to rise the limit beyond 20. As I said before, I'll look into how it can be increased and reply back then. ;)

monkey0506

It is currently possible, just not using the savegameindex[] array...  :P You have to use SaveGameSlot(int slot, string description) and RestoreGameSlot(int slot). However, this changes the way you have to set up your listbox. You could use something like:

Code: ags
function ListBox(int gui, int object){
string buffer, description;
int counter;
ListBoxClear(gui, object);
while (counter<100){
  StrFormat(buffer, "%d. ", counter+1);
  if (GetSaveSlotDescription(counter+100, description)!=1) StrCopy(description, "");
  StrCat(buffer, description);
  ListBoxAdd(gui, object, buffer);
  counter++;
  }
ListBoxSetTopItem(gui, object, 0);
ListBoxSetSelected(gui, object, -1);
}


Thanks to Proskrito for the script... I don't know if you wanted your listbox items numbered, but if not, you can just do:

Code: ags
function ListBox(int gui, int object){
string description;
int saveslot;
ListBoxClear(gui, object);
while (saveslot<100){
  if (GetSaveSlotDescription(saveslot+100, description)!=1) StrCopy(description, "");
  ListBoxAdd(gui, object, description);
  saveslot++;
  }
ListBoxSetTopItem(gui, object, 0);
ListBoxSetSelected(gui, object, -1);
}


Or something like that...  ;)

dreammaster

A minor plug - version 1.1 of my Black Cauldron remake contains a custom save/restore dialog box with support for more than 20 slots. In retrospect I could have optimised it further, since I didn't know about the GetSaveSlotDescription method, but you may get some good ideas for it. Basically, I use a custom file to store the current ordering of save game slots, and then use it to load the listbox with the save games in the correct order.

http://tg_comics.tripod.com/bc.html

SMF spam blocked by CleanTalk