Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Baron on Tue 18/01/2011 04:18:11

Title: SOLVED- Multi Purpose GUI Label
Post by: Baron on Tue 18/01/2011 04:18:11
     So I've got this label on my persistent GUI that tells the player what the mouse is over: a plain and simple @hotspot@ command not only displays the names of hotspots, but also characters and objects as well.  Brilliant!
     I'm looking to take this a step further and tell the player what they're pointing at in the GUI on the same label, should the mouse coordinates indicate that that's where their interest lies.  But I can't find the code to do such a thing, or actually to set it back to @hotspot@ when the mouse leaves the GUI.  The best I could come up with was Label.Text, but short of determining precise co-ordinate boxes and constantly checking in Rep Ex if the mouse was over a button (roughly) I can't think of a mechanism for activating the label change (i.e. Label.Text = "Game Options";), and as mentioned how to get it back (Label.Text = @hotspot@ throws an error due to the @ symbols).
     This isn't really a game breaker but it'd be nice to implement because my GUI only has room for picture buttons and not labels for what everything is.  Any and all ideas are appreciated.
Title: Re: Multi Purpose GUI Label
Post by: monkey0506 on Tue 18/01/2011 05:02:41
I'd suggest checking out GUIControl.GetAtScreenXY..

// rep_exec
 GUIControl *gcat = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
 if (gcat == btnSettings) lblDescription.Text = "Settings";
 else if (gcat == btnSave) lblDescription.Text = "Save";
 else if (gcat == btnLoad) lblDescription.Text = "Load";
 else if (gcat == btnCancel) lblDescription.Text = "Cancel";
 // ...
 else lblDescription.Text = "@OVERHOTSPOT@";


Also, plain-text must always be encapsulated within quotation marks within the script. In the editor it's handled automatically.

Edit: To be slightly clearer, I should say "Elsewhere in the editor it's handled automatically."
Title: Re: Multi Purpose GUI Label
Post by: Baron on Wed 19/01/2011 01:11:53
Monkeys kill birds with stones -I never knew that. 

Many thanks!