Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: monkey0506 on Thu 07/09/2006 07:16:20

Title: SUGGESTION: Button.UseGraphic()
Post by: monkey0506 on Thu 07/09/2006 07:16:20
There's been a couple of situations where I have wanted to set a Button to use it's PushedGraphic when it isn't actually pushed, so to achieve this I have to store the NormalGraphic, set the NormalGraphic to the PushedGraphic, and then set the NormalGraphic back when I'm done with it.

Okay, it's not exactly difficult to work around, it would just be easier if we had something like Button.UseGraphic(int slot) and Button.UseDefaultGraphic().
Title: Re: SUGGESTION: Button.UseGraphic()
Post by: Gilbert on Thu 07/09/2006 10:01:59
Actually I don't quite understand what you meant, did you mean UseGraphic() will set ALL 3 graphics of the button to a specific slot temporary, and UseDefaultGraphic() resets them?

Maybe something like this?
int butnormaldef[1500], butpusheddef[1500], butoverdef[1500];

function SetAllButtonGraphic(Button but, int slot) {
  butnormaldef[(but.OwningGUI.ID*30)+but.ID]=but.NormalGraphic;
  butpusheddef[(but.OwningGUI.ID*30)+but.ID]=but.PushedGraphic;
  butoverdef[(but.OwningGUI.ID*30)+but.ID]=but.MouseOverGraphic;
  but.NormalGraphic=slot;
  but.PushedGraphic=slot;
  but.MouseOverGraphic=slot;
}

function SetButtonDefaultGraphic(Button but) {
  but.NormalGraphic=butnormaldef[(but.OwningGUI.ID*30)+but.ID];
  but.PushedGraphic=butpusheddef[(but.OwningGUI.ID*30)+but.ID];
  but.MouseOverGraphic=butoverdef[(but.OwningGUI.ID*30)+but.ID];
}



BTW @CJ:
I'm just curious, when OO was introduced, I understand that the migration to those NormalGraphic, PushedGraphic, etc properties did make sense. However, in some cases if we want to somehow iterate with the graphic slots of the buttons, it seems that the old Get/SetButtonPic() functions are more convenient, like for example:
i=1;
while (i<=3){
  SetbuttonPic(4,5,i,16+i);
  i++;
}

So I wonder if it's worth introducing (back) new oOO functions like button.SetPic(int which, int slot) and button.GetPic(int which) (since if we want to use old functions we're forced to turn on old scripting support), though they're not difficult to script either.

Title: Re: SUGGESTION: Button.UseGraphic()
Post by: SSH on Thu 07/09/2006 10:46:12
Yeah, monkey, I have to say, why not just write a function for this? There are far more important things for CJ to add/fix with AGS without easily work-aroundable things like this. Now if you could add your own functions to the Button type, now THAT would be awesome (and solve your problem)
Title: Re: SUGGESTION: Button.UseGraphic()
Post by: monkey0506 on Thu 07/09/2006 19:00:06
I know it's not hard to work around...it would just make it more convenient for me and save me a bunch of global variables...er...local variables with a scope global to the script they're created in.