[SOLVED]Can't change GUI image (9-verb)

Started by Fanomatic, Sun 14/04/2019 10:21:17

Previous topic - Next topic

Fanomatic

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
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
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 :)

abstauber

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.

Fanomatic

Wow, thanks for the answer abstauber, and also I'm gonna take the opportunity to say thanks a lot for 9-verbs! ;-D

abstauber

No need to thank me. Have fun creating you game :)

SMF spam blocked by CleanTalk