Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Cassiebsg on Sun 28/09/2014 23:44:51

Title: Default GUIs - can they be changed/costumized?
Post by: Cassiebsg on Sun 28/09/2014 23:44:51
It's me again.

I've been trying to fix GUIs for my MAGS game, but I can't even find how to setup/customize/change the default GUIs. :(
Been reading the forum, and all I come to was "It's not directly possible" but it's possible in some other complicated (or so complicated) scripting thing (the link that was suppose to have this tutorial, just links redirects to the Wiki)...

I'm a bit lost on this, as the current GUIs look so ugly with text that doesn't even fit the space and buttons...(am running game at 640x400 32bit).
Title: Re: Default GUIs - can they be changed/costumized?
Post by: Wicked on Mon 29/09/2014 22:10:14
You can set up and change how the GUIs look,any GUI thats in there you can change, the buttons the background the font you can also change and none of that you dont need scripting to do any of that. Is that what you mean ?
Title: Re: Default GUIs - can they be changed/costumized?
Post by: Cassiebsg on Mon 29/09/2014 23:54:23
Problem is that the default GUIs are not on the GUI list.
These ones:
Code (ags) Select

if (keycode == eKeyCtrlQ) QuitGame(1); // Ctrl-Q
if (keycode == eKeyF9) RestartGame(); // F9
if (keycode == eKeyF5) SaveGameDialog(); // F5
if (keycode == eKeyF7) RestoreGameDialog(); // F7


Yes, I can create my own custom GUIs, and call those instead. But since I'm still a newbie to AGS, I have yet to manage to get my custom save/load/delete to work. And MAGS deadline is tomorrow! (well, since it's already 00:51 over here, it's technically today).
Oh, well, back to coding, and will try to solve this once the rest is done.
It's probably just a line or two of code somewhere that got lost.
Title: Re: Default GUIs - can they be changed/costumized?
Post by: Crimson Wizard on Tue 30/09/2014 00:02:12
Just check how this is done in Default template.
Create a new dummy game from Default template and copy necessary parts.

Here I once answered similar question:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=49663.msg636475622#msg636475622
(scroll down to the second part of my post, beyond "EDIT")

I think you may ask MAGS host to give you 1-2 days more. Usually they allow this :).

BTW, my first MAGS game had not only default GUI, but also default Roger sprites as a character :)
Title: Re: Default GUIs - can they be changed/costumized?
Post by: Cassiebsg on Tue 30/09/2014 01:44:38
Now this is even sounding/looking more mystics to me... cause that was exactly what did when I realized that the BASS template did not come with panel/save/restore etc GUIs. I open the default template, exported the GUIs and global script, then imported the GUIs and global script with a new name GLOBAL, then copy past all the code I could find related to the GUIs, and deleted GLOBAL.
And checking my global script, the code looks identical to what you have on that post, yet, clicking the save button does nothing, and both lists from the restore and save dialog show no save games, yet if I use the default with F5 and F7 as in my code above, I have a save game there that I can load and save over... :/

So, unless I broke it by copying/importing/exporting something the wrong way, I'm a bit lost.
Oh well, I just got my BG for the start and end scene done, so I'll work on the game, and leave this for later if I have time to solve it.

Well, not sure if it's fair to ask for an extension, when so many already have their game finished.
Title: Re: Default GUIs - can they be changed/costumized?
Post by: Snarky on Tue 30/09/2014 10:40:17
The way to get around the in-built dialogs is simply to not use them. Instead, create your own GUIs, and just have them perform the necessary functions. So instead of if (keycode == eKeyCtrlQ) QuitGame(1); (which brings up the built-in dialog) you bring up the Quit GUI you made, and then if the user clicks on the Quit button (or whatever you want them to do) you call QuitGame(0) (which quits immediately). And similarly for the other dialogs.

Edit: OK, reading the thread more closely it sounds like you already realize this and just haven't got the script commands to work. The relevant commands are QuitGame(0), SaveGameSlot(), RestoreGameSlot() and RestartGame() (with SetRestartPoint() to control where that brings you to). To properly display the Restore/Save game lists you probably need GetSaveSlotDescription().

However, your immediate problem seems to be that the Save button Click Action hasn't been linked to the right method. Go to the properties view of the button and select "Run interaction", then click on the "..." to bring you to the script it will run. Copy the relevant code in there.
Title: Re: Default GUIs - can they be changed/costumized?
Post by: Cassiebsg on Tue 30/09/2014 17:16:13
Snarky, the code is there and doesn't look broken to me.

Code (ags) Select

function btnSaveGame_OnClick(GUIControl *control, MouseButton button)
{
  int gameSlotToSaveInto = lstSaveGamesList.ItemCount + 1;
  int i = 0;
  while (i < lstSaveGamesList.ItemCount)
  {
    if (lstSaveGamesList.Items[i] == txtNewSaveName.Text)
    {
      gameSlotToSaveInto = lstSaveGamesList.SaveGameSlots[i];
    }
    i++;
  }
  SaveGameSlot(gameSlotToSaveInto, txtNewSaveName.Text);
  close_save_game_dialog();
}


Next time, I'll learn to start a game with default template instead. ;)
I'll try and figure that out later, or to a version 2, if I ever do a version 2.
For the time being, I'll link to the built in default, so ppl can at least use the save/load function, even if it looks bad.
Title: Re: Default GUIs - can they be changed/costumized?
Post by: Snarky on Tue 30/09/2014 19:46:53
Well, what I was saying was that the link between the code and the button interaction may have become broken as you moved it over. As I assume you know, you have to set the Click event handler as a property for the button, it's not just magically going to know to run btnSaveGame_OnClick() when you click on it. And the link between the property and the actual code in the script can be a bit fragile. The safest thing is generally to let AGS generate a stub for you, and copy your code into the body of that method.

Have you actually tested it on the button properties/event pane to see that it's linked to that code? Even if it looks OK, if it's not working I would definitely try to let AGS generate another stub.
Title: Re: Default GUIs - can they be changed/costumized?
Post by: Cassiebsg on Tue 30/09/2014 20:57:09
I'll let it try and generate another entry. And yes, have tried and know I need to click the event handler.
And yes, when I click the button or the ..., it goes to the appropriate code in the global script.
But I'll give it a try an erase the code, and generate a new one stub.