Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Fanomatic on Sun 14/04/2019 10:21:17

Title: [SOLVED]Can't change GUI image (9-verb)
Post by: Fanomatic on Sun 14/04/2019 10:21:17
Hello there! I have an issue with my 9-verb GUI that I hope somebody can help me with.

See, I have multiple characters the player can switch between (DoTT-style) and in order to make it easier to see what PC is currently active, I want to change the color of the interface reflecting who is active.

I tried creating a function for this in globalscript that just changes the sprites of the verbs to a sprite of another color when you switch character, like so:

Code (ags) Select
function change_interfacecolor (int interfaceColor)
{
  if (interfaceColor == 0)
  {
    Action0.NormalGraphic = 1602;
    Action0.MouseOverGraphic = 1601;
  }
  else if (interfaceColor == 1)
  {
    Action0.NormalGraphic = 125;
    Action0.MouseOverGraphic = 138;
  }
}


However, for some reason the sprite only momentarily changes to the new sprite when I trigger the function (for a frame or so) and then quickly changes back to the default one. I suspect that it might have something to do with this function in the guiscript:

Code (ags) Select
function InitGuiLanguage()
{
  AdjustLanguage();
  int i;
  GUIControl*gc;
  Button*b;
 
  while (i < A_COUNT_)
  {
    gc = gMaingui.Controls[action_button[i]];
    b =  gc.AsButton;
    b.NormalGraphic=action_button_normal[i];
    i++;
  }
}


Since it's a while-loop it might be that it's continously changing the image back to the default one. Not sure on how to go about this. If anybody have any ideas I would be glad to hear them out. Thanks :)
Title: Re: Can't change GUI image (9-verb)
Post by: abstauber on Sun 14/04/2019 20:53:53
Hi
you're right, you can't just change the buttons graphics, since the guiscript changes them back immediately. Therefore you need to tell the guiscript the new graphics with the command SetActionButtons. In the pdf that comes with the template you'll find some more information under "AdjustLanguage" around page15.
Title: Re: Can't change GUI image (9-verb)
Post by: Fanomatic on Mon 15/04/2019 00:54:34
Wow, thanks for the answer abstauber, and also I'm gonna take the opportunity to say thanks a lot for 9-verbs! ;-D
Title: Re: [SOLVED]Can't change GUI image (9-verb)
Post by: abstauber on Tue 16/04/2019 19:52:32
No need to thank me. Have fun creating you game :)