Author Topic: [SOLVED]Can't change GUI image (9-verb)  (Read 240 times)

[SOLVED]Can't change GUI image (9-verb)
« on: 14 Apr 2019, 10:21 »
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: Adventure Game Studio
  1. function change_interfacecolor (int interfaceColor)
  2. {
  3.   if (interfaceColor == 0)
  4.   {
  5.     Action0.NormalGraphic = 1602;
  6.     Action0.MouseOverGraphic = 1601;
  7.   }
  8.   else if (interfaceColor == 1)
  9.   {
  10.     Action0.NormalGraphic = 125;
  11.     Action0.MouseOverGraphic = 138;
  12.   }
  13. }

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: Adventure Game Studio
  1. function InitGuiLanguage()
  2. {
  3.   AdjustLanguage();
  4.   int i;
  5.   GUIControl*gc;
  6.   Button*b;
  7.  
  8.   while (i < A_COUNT_)
  9.   {
  10.     gc = gMaingui.Controls[action_button[i]];
  11.     b =  gc.AsButton;
  12.     b.NormalGraphic=action_button_normal[i];
  13.     i++;
  14.   }
  15. }

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 :)
« Last Edit: 15 Apr 2019, 00:55 by Fanomatic »

abstauber

  • Cavefish
  • still mowing the lawn
    • abstauber worked on one or more games that won an AGS Award!
    •  
    • abstauber worked on one or more games that was nominated for an AGS Award!
Re: Can't change GUI image (9-verb)
« Reply #1 on: 14 Apr 2019, 20: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.

Re: Can't change GUI image (9-verb)
« Reply #2 on: 15 Apr 2019, 00:54 »
Wow, thanks for the answer abstauber, and also I'm gonna take the opportunity to say thanks a lot for 9-verbs! ;-D

abstauber

  • Cavefish
  • still mowing the lawn
    • abstauber worked on one or more games that won an AGS Award!
    •  
    • abstauber worked on one or more games that was nominated for an AGS Award!
Re: [SOLVED]Can't change GUI image (9-verb)
« Reply #3 on: 16 Apr 2019, 19:52 »
No need to thank me. Have fun creating you game :)