problems with custom save/load GUI script [SOLVED]

Started by hedgefield, Mon 04/07/2005 11:02:12

Previous topic - Next topic

hedgefield

I've been trying to get a custom save/load GUI in place, following the GAC tutorials, and I'm at the verge of cracking it. Even though I was going to refrain from asking for help, I can't get my mind around the following problem:

I open the save GUI and save. Yes. That works. Savefile appears. All good. BUT, when I go to the load GUI after that, the savegame is nowhere to be found. So I go back to the save GUI, where it now appears in the listbox. However, it's only the selection border, there is no text in the slot. So I go back to the load GUI. Savegame now appears there also, but no text either. It loads fine though. Then there is the issue where I cannot select any other savegame but the first to overwrite. It always jumps back to the first savegame.

For the life of me I cannot figure out what it is. I've been rearranging the script for a good hour now, and each time something changes, but it doesn't fix anything. Here's what I have:

Code: ags
// main global script file
string text;int index;


Code: ags
#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
     GUIOn(QUITDIALOG);
  if (keycode==363) //SaveGameDialog();   // F5
     //SetTextBoxText(5,0,"");              // Clear Text box
     //ListBoxSaveGameList(5,1);            // Fill List Box with saved games
     //index=ListBoxGetNumItems(5,1);       // Count how many saved games there are          
     //if (index>19){                       // If saved games 20 (maximum)
     //Display("You must overwrite a previously saved game.");  // Display warning
     //}
     GUIOn(SAVEDIALOG);                      // Bring Save interface on             
  if (keycode==365) //RestoreGameDialog();  // F7
     //ListBoxSaveGameList(4,0);            // Fill List box with saved games 
     GUIOn(LOADDIALOG);                      // Bring restore Interface on
  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
}

As you can see, I've commented out the additional lines for the save and load GUI, because when I uncomment them, every single key on the keyboard brings up both the save and the load GUI.

Code: ags
#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
  if (interface == ICONBAR) {
    if (button == 4) {  // show inventory
      show_inventory_window();
    }
    else if (button == 5) {   // use selected inventory
      if (character[ GetPlayerCharacter() ].activeinv >= 0)
        SetCursorMode(4);
    } 
    else if (button == 6)    // save game
      GUIOn (SAVEDIALOG);
      //SaveGameDialog();
    else if (button == 7)   // load game
      GUIOn (LOADDIALOG);
      //RestoreGameDialog();
    else if (button == 8)   // quit
      GUIOn (QUITDIALOG);
      //QuitGame(1);
    else if (button == 9)    // about
      Display("The Majestic Conspiracy (c) 2005 Tim Hengeveld.");
  }  // end if interface ICONBAR

  if (interface == INVENTORY) {
    // They clicked a button on the Inventory GUI
    
    if (button == 1) {
      // They pressed SELECT, so switch to the Get cursor
      SetCursorMode (MODE_USE);
      // But, override the appearance to look like the arrow
      SetMouseCursor (6);
    }
    
    if (button == 2) {
      // They pressed LOOK, so switch to that mode
      SetActiveInventory(-1);
      SetCursorMode(MODE_LOOK);  
    }
    if (button == 3) {
      // They pressed the OK button, close the GUI
      GUIOff (INVENTORY);
      SetDefaultCursor();
    }

    if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
      // scroll down
      game.top_inv_item = game.top_inv_item + game.items_per_line;
    }
    if ((button == 5) && (game.top_inv_item > 0)){
      // scroll up
      game.top_inv_item = game.top_inv_item - game.items_per_line;
    }  
  }
  
   if (interface == QUITDIALOG) {
     if (button == 0) {
       QuitGame (0);
     }
     if (button == 1) {
       GUIOff (QUITDIALOG);
    }
  }

   if (interface== LOADDIALOG) {                                // if Restore interface
     index=ListBoxSaveGameList(4,0);                                  // Fill List box with saved games
     
     if (button==1) {                                           // if cancel is pressed
      InterfaceOff(4);                                          // Close interface
    }
     else { 
      index=ListBoxGetSelected(4,0);                            // else get the selected game
      RestoreGameSlot(savegameindex[index]);}                   // restore the game
    }

     if (interface== SAVEDIALOG) {                              // if save interface
       SetTextBoxText(5,0,"");                                  // Clear Text box
       index=ListBoxSaveGameList(5,1);                                // Fill List Box with saved games
       index=ListBoxGetNumItems(5,1);                           // Count how many saved games there are          
       if (index>19){                                           // If saved games 20 (maximum)
       Display("You must overwrite a previously saved game.");  // Display warning
    }
  
     if (button==0) {                                 // if enter is pressed 
       index=ListBoxGetNumItems(5,1);                 // Count saved games 
     if (index<20) {                                  // if less than 20
       GetTextBoxText(5,0,text);                      // Get the typed text
       InterfaceOff(5);                               // Close interface
       SaveGameSlot(index+1,text);                    // Save game (text as description)
    }   
     else {                                           // if saved games are 20
       index=ListBoxGetSelected(5,1);                 // Get the selected save game
       GetTextBoxText(5,0,text);                      // Get the typed text
       InterfaceOff(5);                               // Close the interface
       SaveGameSlot(savegameindex[index],text);}      // Overwrite the selected game
    }         

     if (button==2) {
     InterfaceOff(5);                                 // if cancel is pressed close interface
  }
}
}

So instead, I've moved those entries down here, and they seem to work. But aforementioned issues arise. Any idea what the problem might be?

Gilbert

#1
Missing braces, obviously:
#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
Ã,  Ã,  Ã, GUIOn(QUITDIALOG);
Ã,  if (keycode==363) {//SaveGameDialog();Ã,  Ã, // F5
Ã,  Ã,  Ã, SetTextBoxText(5,0,"");Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Clear Text box
Ã,  Ã,  Ã, ListBoxSaveGameList(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Fill List Box with saved games
Ã,  Ã,  Ã, index=ListBoxGetNumItems(5,1);Ã,  Ã,  Ã,  Ã, // Count how many saved games there areÃ,  Ã,  Ã,  Ã,  Ã,  
Ã,  Ã,  Ã, if (index>19){Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // If saved games 20 (maximum)
Ã,  Ã,  Ã, Display("You must overwrite a previously saved game.");Ã,  // Display warning
Ã,  Ã,  }
Ã,  Ã,  Ã, GUIOn(SAVEDIALOG);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Bring Save interface onÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 
 }
Ã,  if (keycode==365)Ã,  {//RestoreGameDialog();Ã,  // F7
Ã,  Ã,  Ã, ListBoxSaveGameList(4,0);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Fill List box with saved games 
Ã,  Ã,  Ã, GUIOn(LOADDIALOG);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Bring restore Interface on
 }
Ã,  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
}


Also, you'll need to do those preparations (fill in listboxes, etc.) for opening the save/load GUIs when you click the buttons, one lazy way to avoid repeating the code is move the interface_click() section below on_key_press() (if it's not) land then call on_key_press() directly like this:
sectionstart interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
Ã,  if (interface == ICONBAR) {
Ã,  Ã,  if (button == 4) {Ã,  // show inventory
Ã,  Ã,  Ã,  show_inventory_window();
Ã,  Ã,  }
Ã,  Ã,  else if (button == 5) {Ã,  Ã, // use selected inventory
Ã,  Ã,  Ã,  if (character[ GetPlayerCharacter() ].activeinv >= 0)
Ã,  Ã,  Ã,  Ã,  SetCursorMode(4);
Ã,  Ã,  } 
Ã,  Ã,  else if (button == 6)Ã,  Ã,  // save game
Ã,  Ã,  Ã,  on_key_press(363);
Ã,  Ã,  Ã,  //GUIOn (SAVEDIALOG);
Ã,  Ã,  Ã,  //SaveGameDialog();
Ã,  Ã,  else if (button == 7)Ã,  Ã, // load game
Ã,  Ã,  Ã,  on_key_press(365);
Ã,  Ã,  Ã,  //GUIOn (LOADDIALOG);
Ã,  Ã,  Ã,  //RestoreGameDialog();
Ã,  Ã,  else if (button == 8)Ã,  Ã, // quit
Ã,  Ã,  Ã,  GUIOn (QUITDIALOG);
Ã,  Ã,  Ã,  //QuitGame(1);
Ã,  Ã,  else if (button == 9)Ã,  Ã,  // about
Ã,  Ã,  Ã,  Display("The Majestic Conspiracy (c) 2005 Tim Hengeveld.");
Ã,  }Ã,  // end if interface ICONBAR

Ã,  if (interface == INVENTORY) {
Ã,  Ã,  // They clicked a button on the Inventory GUI
Ã,  Ã,  
Ã,  Ã,  if (button == 1) {
Ã,  Ã,  Ã,  // They pressed SELECT, so switch to the Get cursor
Ã,  Ã,  Ã,  SetCursorMode (MODE_USE);
Ã,  Ã,  Ã,  // But, override the appearance to look like the arrow
Ã,  Ã,  Ã,  SetMouseCursor (6);
Ã,  Ã,  }
Ã,  Ã,  
Ã,  Ã,  if (button == 2) {
Ã,  Ã,  Ã,  // They pressed LOOK, so switch to that mode
Ã,  Ã,  Ã,  SetActiveInventory(-1);
Ã,  Ã,  Ã,  SetCursorMode(MODE_LOOK);Ã,  
Ã,  Ã,  }
Ã,  Ã,  if (button == 3) {
Ã,  Ã,  Ã,  // They pressed the OK button, close the GUI
Ã,  Ã,  Ã,  GUIOff (INVENTORY);
Ã,  Ã,  Ã,  SetDefaultCursor();
Ã,  Ã,  }

Ã,  Ã,  if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
Ã,  Ã,  Ã,  // scroll down
Ã,  Ã,  Ã,  game.top_inv_item = game.top_inv_item + game.items_per_line;
Ã,  Ã,  }
Ã,  Ã,  if ((button == 5) && (game.top_inv_item > 0)){
Ã,  Ã,  Ã,  // scroll up
Ã,  Ã,  Ã,  game.top_inv_item = game.top_inv_item - game.items_per_line;
Ã,  Ã,  }Ã,  
Ã,  }
Ã,  
Ã,  Ã, if (interface == QUITDIALOG) {
Ã,  Ã,  Ã, if (button == 0) {
Ã,  Ã,  Ã,  Ã, QuitGame (0);
Ã,  Ã,  Ã, }
Ã,  Ã,  Ã, if (button == 1) {
Ã,  Ã,  Ã,  Ã, GUIOff (QUITDIALOG);
Ã,  Ã,  }
Ã,  }

Ã,  Ã, if (interface== LOADDIALOG) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // if Restore interface
Ã,  Ã,  Ã, index=ListBoxSaveGameList(4,0);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Fill List box with saved games
Ã,  Ã,  Ã, 
Ã,  Ã,  Ã, if (button==1) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if cancel is pressed
Ã,  Ã,  Ã,  InterfaceOff(4);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Close interface
Ã,  Ã,  }
Ã,  Ã,  Ã, else { 
Ã,  Ã,  Ã,  index=ListBoxGetSelected(4,0);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // else get the selected game
Ã,  Ã,  Ã,  RestoreGameSlot(savegameindex[index]);}Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // restore the game
Ã,  Ã,  }

Ã,  Ã,  Ã, if (interface== SAVEDIALOG) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // if save interface
Ã,  Ã,  Ã,  Ã, SetTextBoxText(5,0,"");Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Clear Text box
Ã,  Ã,  Ã,  Ã, index=ListBoxSaveGameList(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Fill List Box with saved games
Ã,  Ã,  Ã,  Ã, index=ListBoxGetNumItems(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Count how many saved games there areÃ,  Ã,  Ã,  Ã,  Ã,  
Ã,  Ã,  Ã,  Ã, if (index>19){Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // If saved games 20 (maximum)
Ã,  Ã,  Ã,  Ã, Display("You must overwrite a previously saved game.");Ã,  // Display warning
Ã,  Ã,  }
Ã,  
Ã,  Ã,  Ã, if (button==0) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if enter is pressed 
Ã,  Ã,  Ã,  Ã, index=ListBoxGetNumItems(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Count saved games 
Ã,  Ã,  Ã, if (index<20) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // if less than 20
Ã,  Ã,  Ã,  Ã, GetTextBoxText(5,0,text);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Get the typed text
Ã,  Ã,  Ã,  Ã, InterfaceOff(5);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Close interface
Ã,  Ã,  Ã,  Ã, SaveGameSlot(index+1,text);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Save game (text as description)
Ã,  Ã,  }Ã,  Ã, 
Ã,  Ã,  Ã, else {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if saved games are 20
Ã,  Ã,  Ã,  Ã, index=ListBoxGetSelected(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Get the selected save game
Ã,  Ã,  Ã,  Ã, GetTextBoxText(5,0,text);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Get the typed text
Ã,  Ã,  Ã,  Ã, InterfaceOff(5);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Close the interface
Ã,  Ã,  Ã,  Ã, SaveGameSlot(savegameindex[index],text);}Ã,  Ã,  Ã,  // Overwrite the selected game
Ã,  Ã,  }Ã,  Ã,  Ã,  Ã,  Ã, 

Ã,  Ã,  Ã, if (button==2) {
Ã,  Ã,  Ã, InterfaceOff(5);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if cancel is pressed close interface
Ã,  }
}
}

hedgefield

#2
Edited by Gilbot
Opps. Sorry, I should have replied but accidentally modified your post (which erased a bunch of its content :P), this is what would have happened for a tired dumb who's still working at 7:30p.m.. Anyway, I think you can understand what I wrote here.

Quote
There is one more modification to do, and that is copy the preparation codes from on_key_press to interface_click, otherwise the save/load GUIs wont read the previously saved games when you click on their icon in the iconbar, only when you open them using the hotkeys.
Yes, like I mentioned, a simpler way is just calling directly on_key_press() within interface_click() (see my last post). However, a more systematic (and more readible) way is to put those codes into functions, like:
Code: ags

function SaveGUI(){
  //blah blabla
}

function LoadGUI(){
  //blah blabla
}


and then call these functions within on_key_press() and interface_click().



Edited by Largo
Heh, don't worry, my frustration cache is all filled up with the script, so there's no more room for this. :)

Making this into functions would indeed be a good alternative. Though I haven't quite advanced far enough to be building complicated constructions like that.

Anyway, I just tested it again and with the current script the savegames text won't display, again...

I will go ahead and predict now it's probably a brace issue... ::)
---------------------------------------------------------------------------------------------------
Main global script file
string text;int index;

sectionstart_on_key_press
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) GUIOn(QUITDIALOG);     // Ctrl-Q     
  if (keycode==363) {                     // F5
     SetTextBoxText(5,0,"");              // Clear Text box
     ListBoxSaveGameList(5,1);            // Fill List Box with saved games
     index=ListBoxGetNumItems(5,1);       // Count how many saved games there are         
     if (index>19){                       // If saved games 20 (maximum)
     Display("You must overwrite a previously saved game.");  // Display warning
    }
     GUIOn(SAVEDIALOG);                      // Bring Save interface on             
}
  if (keycode==365)  {                    // F7
     ListBoxSaveGameList(4,0);            // Fill List box with saved games
     GUIOn(LOADDIALOG);                   // Bring restore Interface on
}
  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
}

sectionstart_interface_click
function interface_click(int interface, int button) {
  if (interface == ICONBAR) {
    if (button == 4) {  // show inventory
      show_inventory_window();
    }
    else if (button == 6) {   // save game
      SetTextBoxText(5,0,"");              // Clear Text box
      ListBoxSaveGameList(5,1);            // Fill List Box with saved games
      index=ListBoxGetNumItems(5,1);       // Count how many saved games there are         
      if (index>19){                       // If saved games 20 (maximum)
      Display("You must overwrite a previously saved game.");  // Display warning
    }
      GUIOn(SAVEDIALOG);                   // Bring Save interface on             
}
    else if (button == 7) {  // load game
     ListBoxSaveGameList(4,0);
     GUIOn (LOADDIALOG); }
    else if (button == 8 )   // quit
      GUIOn (QUITDIALOG);
    else if (button == 9)    // about
      Display("The Majestic Conspiracy (c) 2005 Tim Hengeveld.");
  }  // end if interface ICONBAR

  if (interface == INVENTORY) {
    // They clicked a button on the Inventory GUI
   
    if (button == 1) {
      // They pressed SELECT, so switch to the Get cursor
      SetCursorMode (MODE_USE);
      // But, override the appearance to look like the arrow
      SetMouseCursor (6);
    }
   
    if (button == 2) {
      // They pressed LOOK, so switch to that mode
      SetActiveInventory(-1);
      SetCursorMode(MODE_LOOK);
    }
    if (button == 3) {
      // They pressed the OK button, close the GUI
      GUIOff (INVENTORY);
      SetDefaultCursor();
    }

    if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
      // scroll down
      game.top_inv_item = game.top_inv_item + game.items_per_line;
    }
    if ((button == 5) && (game.top_inv_item > 0)){
      // scroll up
      game.top_inv_item = game.top_inv_item - game.items_per_line;
    }
  }

   if (interface == QUITDIALOG) {
     if (button == 0) {
       QuitGame (0);
     }
     if (button == 1) {
       GUIOff (QUITDIALOG);
    }
  }

   if (interface== LOADDIALOG) {                                // if Restore interface
     if (button==1) {                                           // if cancel is pressed
      InterfaceOff(4);                                          // Close interface
    }
     else {
      index=ListBoxGetSelected(4,0);                            // else get the selected game
      RestoreGameSlot(savegameindex[index]);}                   // restore the game
    }

     if (interface== SAVEDIALOG) {                              // if save interface
       SetTextBoxText(5,0,"");                                  // Clear Text box
       ListBoxSaveGameList(5,1);                                // Fill List Box with saved games
       index=ListBoxGetNumItems(5,1);                           // Count how many saved games there are         
       if (index>19){                                           // If saved games 20 (maximum)
       Display("You must overwrite a previously saved game.");  // Display warning
    }

     if (button==0) {                                 // if enter is pressed
       index=ListBoxGetNumItems(5,1);                 // Count saved games
     if (index<20) {                                  // if less than 20
       GetTextBoxText(5,0,text);                      // Get the typed text
       InterfaceOff(5);                               // Close interface
       SaveGameSlot(index+1,text);                    // Save game (text as description)
    }   
     else {                                           // if saved games are 20
       index=ListBoxGetSelected(5,1);                 // Get the selected save game
       GetTextBoxText(5,0,text);                      // Get the typed text
       InterfaceOff(5);                               // Close the interface
       SaveGameSlot(savegameindex[index],text);}      // Overwrite the selected game
    }         

     if (button==2) {
     InterfaceOff(5);                                 // if cancel is pressed close interface
  }
}
}
--------------------------------------------------------------------------------------------------
Load GUI = 4
  -Object:Listbox = 0
  -Object:Button = 1
Save GUI = 5
  -Object:Textbox = 0
  -Object:Listbox = 1
  -Object:Button = 2

Gijs

#3
I think you have to put this in somewhere at the SAVEDIALOG-GUI script:Ã,  Ã, 

ListBoxSaveGameList (4,0);Ã,  Ã, 

I think like this:

Code: ags

Ã,  Ã,  Ã, if (interface== SAVEDIALOG) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // if save interface
Ã,  Ã,  Ã,  Ã, SetTextBoxText(5,0,"");Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Clear Text box
Ã,  Ã,  Ã,  Ã, ListBoxSaveGameList(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Fill List Box with saved games
Ã,  Ã,  Ã,  Ã, index=ListBoxGetNumItems(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Count how many saved games there areÃ,  Ã,  Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  Ã, if (index>19){Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // If saved games 20 (maximum)
Ã,  Ã,  Ã,  Ã, Display("You must overwrite a previously saved game.");Ã,  // Display warning
Ã,  Ã,  }
 
Ã,  Ã,  Ã, if (button==0) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if enter is pressed
Ã,  Ã,  Ã,  Ã, index=ListBoxGetNumItems(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Count saved games
Ã,  Ã,  Ã, if (index<20) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // if less than 20
Ã,  Ã,  Ã,  Ã, GetTextBoxText(5,0,text);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Get the typed text
Ã,  Ã,  Ã,  Ã, InterfaceOff(5);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Close interface
Ã,  Ã,  Ã,  Ã, SaveGameSlot(index+1,text);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Save game (text as description)
Ã,  Ã,  }Ã,  Ã, 
Ã,  Ã,  Ã, else {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if saved games are 20
Ã,  Ã,  Ã,  Ã, index=ListBoxGetSelected(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Get the selected save game
Ã,  Ã,  Ã,  Ã, GetTextBoxText(5,0,text);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Get the typed text
Ã,  Ã,  Ã,  Ã, InterfaceOff(5);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Close the interface
Ã,  Ã,  Ã,  Ã, SaveGameSlot(savegameindex[index],text);}Ã,  Ã,  Ã,  // Overwrite the selected game
Ã,  Ã,  }Ã,  Ã,  Ã,  Ã,  Ã, 
ListBoxSaveGameList (4,0); //  <----------------here-----
Ã,  Ã,  }
Ã,  Ã,  Ã, if (button==2) {
Ã,  Ã,  Ã, InterfaceOff(5);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if cancel is pressed close interface 
Ã,  Ã, }
}


Don't know for sure.

Gilbert

Yes, but the textbox for save game GUI is (5,1), so:
sectionstart_interface_click
function interface_click(int interface, int button) {
Ã,  if (interface == ICONBAR) {
Ã,  Ã,  if (button == 4) {Ã,  // show inventory
Ã,  Ã,  Ã,  show_inventory_window();
Ã,  Ã,  }
Ã,  Ã,  else if (button == 6) {Ã,  Ã, // save game
Ã,  Ã,  Ã,  SetTextBoxText(5,0,"");Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Clear Text box
Ã,  Ã,  Ã,  ListBoxSaveGameList(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Fill List Box with saved games
Ã,  Ã,  Ã,  index=ListBoxGetNumItems(5,1);Ã,  Ã,  Ã,  Ã, // Count how many saved games there areÃ,  Ã,  Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  if (index>19){Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // If saved games 20 (maximum)
Ã,  Ã,  Ã,  Display("You must overwrite a previously saved game.");Ã,  // Display warning
Ã,  Ã,  }
Ã,  Ã,  Ã,  GUIOn(SAVEDIALOG);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Bring Save interface onÃ,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 
 }
Ã,  Ã,  else if (button == 7) {Ã,  // load game
Ã,  Ã,  Ã, ListBoxSaveGameList(4,0);
Ã,  Ã,  Ã, GUIOn (LOADDIALOG); }
Ã,  Ã,  else if (button == 8 )Ã,  Ã, // quit
Ã,  Ã,  Ã,  GUIOn (QUITDIALOG);
Ã,  Ã,  else if (button == 9)Ã,  Ã,  // about
Ã,  Ã,  Ã,  Display("The Majestic Conspiracy (c) 2005 Tim Hengeveld.");
Ã,  }Ã,  // end if interface ICONBAR

Ã,  if (interface == INVENTORY) {
Ã,  Ã,  // They clicked a button on the Inventory GUI
Ã,  Ã, 
Ã,  Ã,  if (button == 1) {
Ã,  Ã,  Ã,  // They pressed SELECT, so switch to the Get cursor
Ã,  Ã,  Ã,  SetCursorMode (MODE_USE);
Ã,  Ã,  Ã,  // But, override the appearance to look like the arrow
Ã,  Ã,  Ã,  SetMouseCursor (6);
Ã,  Ã,  }
Ã,  Ã, 
Ã,  Ã,  if (button == 2) {
Ã,  Ã,  Ã,  // They pressed LOOK, so switch to that mode
Ã,  Ã,  Ã,  SetActiveInventory(-1);
Ã,  Ã,  Ã,  SetCursorMode(MODE_LOOK); 
Ã,  Ã,  }
Ã,  Ã,  if (button == 3) {
Ã,  Ã,  Ã,  // They pressed the OK button, close the GUI
Ã,  Ã,  Ã,  GUIOff (INVENTORY);
Ã,  Ã,  Ã,  SetDefaultCursor();
Ã,  Ã,  }

Ã,  Ã,  if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
Ã,  Ã,  Ã,  // scroll down
Ã,  Ã,  Ã,  game.top_inv_item = game.top_inv_item + game.items_per_line;
Ã,  Ã,  }
Ã,  Ã,  if ((button == 5) && (game.top_inv_item > 0)){
Ã,  Ã,  Ã,  // scroll up
Ã,  Ã,  Ã,  game.top_inv_item = game.top_inv_item - game.items_per_line;
Ã,  Ã,  } 
Ã,  }
 
Ã,  Ã, if (interface == QUITDIALOG) {
Ã,  Ã,  Ã, if (button == 0) {
Ã,  Ã,  Ã,  Ã, QuitGame (0);
Ã,  Ã,  Ã, }
Ã,  Ã,  Ã, if (button == 1) {
Ã,  Ã,  Ã,  Ã, GUIOff (QUITDIALOG);
Ã,  Ã,  }
Ã,  }

Ã,  Ã, if (interface== LOADDIALOG) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // if Restore interface
Ã,  Ã,  Ã, if (button==1) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if cancel is pressed
Ã,  Ã,  Ã,  InterfaceOff(4);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Close interface
Ã,  Ã,  }
Ã,  Ã,  Ã, else {
Ã,  Ã,  Ã,  index=ListBoxGetSelected(4,0);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // else get the selected game
Ã,  Ã,  Ã,  RestoreGameSlot(savegameindex[index]);}Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // restore the game
Ã,  Ã,  }

Ã,  Ã,  Ã, if (interface== SAVEDIALOG) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // if save interface
/* This part is useless and can cause problems
Ã,  Ã,  Ã,  Ã, SetTextBoxText(5,0,"");Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Clear Text box
Ã,  Ã,  Ã,  Ã, ListBoxSaveGameList(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Fill List Box with saved games
Ã,  Ã,  Ã,  Ã, index=ListBoxGetNumItems(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Count how many saved games there areÃ,  Ã,  Ã,  Ã,  Ã, 
Ã,  Ã,  Ã,  Ã, if (index>19){Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // If saved games 20 (maximum)
Ã,  Ã,  Ã,  Ã, Display("You must overwrite a previously saved game.");Ã,  // Display warning
Ã,  Ã,  }
*/ 
Ã,  Ã,  Ã, if (button==0) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if enter is pressed
Ã,  Ã,  Ã,  Ã, index=ListBoxGetNumItems(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Count saved games
Ã,  Ã,  Ã, if (index<20) {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // if less than 20
Ã,  Ã,  Ã,  Ã, GetTextBoxText(5,0,text);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Get the typed text
Ã,  Ã,  Ã,  Ã, InterfaceOff(5);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Close interface
Ã,  Ã,  Ã,  Ã, SaveGameSlot(index+1,text);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Save game (text as description)
Ã,  Ã,  }Ã,  Ã, 
Ã,  Ã,  Ã, else {Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if saved games are 20
Ã,  Ã,  Ã,  Ã, index=ListBoxGetSelected(5,1);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Get the selected save game
Ã,  Ã,  Ã,  Ã, GetTextBoxText(5,0,text);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Get the typed text
Ã,  Ã,  Ã,  Ã, InterfaceOff(5);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // Close the interface
Ã,  Ã,  Ã,  Ã, SaveGameSlot(savegameindex[index],text);}Ã,  Ã,  Ã,  // Overwrite the selected game
Ã,  Ã,  Ã,  ListBoxSaveGameList (5,1); //Here
Ã,  Ã,  }Ã,  Ã,  Ã,  Ã,  Ã, 

Ã,  Ã,  Ã, if (button==2) {
Ã,  Ã,  Ã, InterfaceOff(5);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, // if cancel is pressed close interface
Ã,  }
}
}

hedgefield

Great, that did it, thanks a lot! :) Now finally it all works correctly. Whew.

SMF spam blocked by CleanTalk