GUI Labeling of Iconbar Buttons? [SOLVED]

Started by Play_Pretend, Sat 20/10/2007 09:41:37

Previous topic - Next topic

Play_Pretend

Hello all!  I'm stumped...I'm trying to rework my Iconbar GUI so that when the mouse moves over the buttons for Walk, Look, Save, etc., a box in the middle of the GUI displays the name of that button.  (Although I want the display box to say things like STRIDE, MEDDLE, OGLE and so on instead of Walk, Touch, Look.)  How can I go about this?  Thanks!

Ashen

I know this has been answered before - but I can't find it anywhere, even when I cheat and look for the answer instead of the question. Perhaps it should go in the BFAQ? It's not really frequently asked, but it has been asked a few times and might be handy to include anyway.

That said, the answer isn't really that difficult: use GUIControl.GetAtScreenXY and repeatedly_execute_always (since gIconbar is blocking). E.g.:
Code: ags

function repeatedly_execute_always() {
  if (GUIControl.GetAtScreenXY(mouse.x, mouse.y) == btnIconSave) lblIconAbout.Text = "Save your game";
  else if (GUIControl.GetAtScreenXY(mouse.x, mouse.y) == btnIconLoad) lblIconAbout.Text = "Restore a game";
  else if (GUIControl.GetAtScreenXY(mouse.x, mouse.y) == btnIconExit) lblIconAbout.Text = "Quit the game";
  // Etc for the other buttons you wat
  else lblIconAbout.Text = ""; // mouse isn't over a labled control, so clear it.
}

(This obviously requires you to make a Label called 'lblIconAbout' to display the descriptions.)
I know what you're thinking ... Don't think that.

Play_Pretend

Woo-double-hoo!  That's twice you've solved my problems in one night, I should send you some cookies. :)  I swear I tried looking around and reading first, I couldn't find any answers that made sense to me until this one, because I didn't really understand the label functions until just now.  Thanks twicely, man!

SMF spam blocked by CleanTalk