Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: BerserkerTails on Mon 27/06/2005 08:15:23

Title: GUI Listbox/Textbox woes (Solved!)
Post by: BerserkerTails on Mon 27/06/2005 08:15:23
Okay, so what I'm trying to do is code a Save-Game GUI. I want it so that when the player selects a save game from the listbox to overwrite it, it automatically fills in the textbox with the name of that saved game. I've put this command in:

ListBoxGetItemText (5, 4,  ListBoxGetSelected (5, 4),  savbuf);

Where 5 is the Save Gui, and 4 is the Listbox. So now, the name of the selected game is in the string "savbuf". Is there anyway now, to get the textbox to display that string? I've tried the SetTextBoxText function, but it only seems to want to input specific text, and not recall a string.

Any help would be appreciated, thanks!
Title: Re: GUI Listbox/Textbox woes
Post by: Gilbert on Mon 27/06/2005 08:22:03
SetTextBoxText() works for me, is it possible that there're some other codes interfering with it?
Title: Re: GUI Listbox/Textbox woes
Post by: BerserkerTails on Mon 27/06/2005 08:33:02
I don't think so. The problem I'm having is not knowing how to get SetTextBoxText() to recall the string "savebuf". I can get it to work if I tell it to set the text as something specific, such as "Save Game 1", but can't get it to set the text to a string.
Title: Re: GUI Listbox/Textbox woes
Post by: Gilbert on Mon 27/06/2005 08:53:26
Just use something like:
SetTextBoxText(2,3,savebuf);

Trust me, it will work as I had done the same stuff already.
Title: Re: GUI Listbox/Textbox woes (Half Solved)
Post by: BerserkerTails on Mon 27/06/2005 17:46:23
Thanks Gilbot, for some reason it worked when I tried it this time. I could've swore I tried that before... Oh well.

Now when you open up the Save game menu, it automatically selects the latest saved game and puts it's name in the textbox, making it easy to overwrite.

One more question though. How can I get it to get the name of other saved games when they're highlighted to be put into the textbox? For example if you want to overwrite an older saved game, how can I get the name of that older saved game to appear in the textbox when it's selected?
Title: Re: GUI Listbox/Textbox woes (Half Solved)
Post by: Gilbert on Tue 28/06/2005 02:12:53
Quote from: BerserkerTails on Mon 27/06/2005 17:46:23
One more question though. How can I get it to get the name of other saved games when they're highlighted to be put into the textbox? For example if you want to overwrite an older saved game, how can I get the name of that older saved game to appear in the textbox when it's selected?

Just put in on_mouse_click() to check if the listbox was clicked (maybe there're alternative ways with V2.7+), if it was clicked, just like you had mentioned, use:
ListBoxGetItemText (5, 4,  ListBoxGetSelected (5, 4),  savbuf);
to get the name and then SetTextBoxText() again.
Title: Re: GUI Listbox/Textbox woes (Half Solved)
Post by: BerserkerTails on Tue 28/06/2005 03:14:20
Okay, call me a complete noob, but I ave no clue how to use the on_mouse_click() function. The help file doesn't really tell me much on how it's used, so I'm kinda clueless. I put this:

      if (on_mouse_click (LEFT)) {
        ListBoxGetItemText (5, 4,  ListBoxGetSelected (5, 4),  savbuf);
        SetTextBoxText (5,1,savbuf); }


It doesn't seem to be working though. Could you perhaps tell me what I'm doing wrong?
Title: Re: GUI Listbox/Textbox woes (Half Solved)
Post by: Gilbert on Tue 28/06/2005 03:37:07
I wrote it wrongly, it should better be in interface_click(), which should be already there inside your global script, add inside several lines, like:

function interface_click(int interface, int button) {
//blahblahblargh

  if (interface==5){ //Savegame GUI
    if (button==4) { //Clicked listbox
      ListBoxGetItemText (5, 4,  ListBoxGetSelected (5, 4),  savbuf);
      SetTextBoxText(whatever appropiate parameters);
    }
  }

}
Title: Re: GUI Listbox/Textbox woes (Half Solved)
Post by: BerserkerTails on Tue 28/06/2005 03:59:41
Gilbot, you're amazing. Thanks so much, I've FINALLY got my Save/Load GUIs working properly.