Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: -Squall- on Fri 21/11/2008 00:08:43

Title: Item name on label on mouse over. [SOLVED]
Post by: -Squall- on Fri 21/11/2008 00:08:43
Hi everyone:

I want to show item's name in a label on the GUI inventory on mouse over. I think i have to use InventoryItem.GetAtScreenXY(mouse.x, mouse.y) or similar, but i'm not sure. I have LucasArts status style in game (showing name in a label in top), but in Inventory it doesn't work. I don't mind if item's name are located in the same label or in a different one.

I have AGS v.3.0.2. I searched in forum but I didn't found an answer.

Thank you very much!  ;)
Title: Re: Item name on label on mouse over.
Post by: densming on Fri 21/11/2008 02:54:17
Have you looked here?
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=36068.0
Title: Re: Item name on label on mouse over.
Post by: -Squall- on Fri 21/11/2008 12:48:29
OMG, I'm really stupid. Thank you densming.

By the way, other question:
The item's name appears in label, ok, but when I click them I would like the label shows "Use (Active inventory name) with (item on mouse over)" or similar. I tried this:

if(mouse.Mode == eModeUseinv) {
LabelObj.Text = String.Format("Use %s with %s", player.ActiveInventory.Name, "@OVERHOTSPOT@");
}
else{
  LabelObj.Text = "@OVERHOTSPOT@";

}


in show_inventory_window function, but it doesn't work.

This is my mouse_on_click function:


function on_mouse_click(MouseButton button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
     if (gInventory.Visible == true) {
   if (button == eMouseRightInv) {
        mouse.Mode = eModeInteract;
        mouse.UseModeGraphic(eModePointer);
      }
      else if (button == eMouseRight) {
                mouse.Mode = eModeInteract;
        mouse.UseModeGraphic(eModePointer);
        }
      else if ((button == eMouseLeftInv) && (Mouse.Mode == eModeInteract)) {
        player.ActiveInventory=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
        Mouse.Mode=eModeUseinv;
      }
      else if ((button == eMouseLeftInv) && (Mouse.Mode == eModeLookat)) {
        inventory[game.inv_activated].RunInteraction(mouse.Mode);
      }
      else if ((button == eMouseLeftInv) && (Mouse.Mode == eModeUseinv)) {
        inventory[game.inv_activated].RunInteraction(mouse.Mode);
      }
    }
    else {
// Game paused, gInventory not on - do nothing
    }
  }
  else if (button == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseRight) {   // right-click, so cycle cursor
    mouse.SelectNextMode();
  }
}



Thank you for your patience!
Title: Re: Item name on label on mouse over.
Post by: Dualnames on Fri 21/11/2008 13:03:19

if(mouse.Mode == eModeUseinv) {
String name=Game.GetLocationName(mouse.x,mouse.y);//This might not be the exact command but search at the manual for getlocation name and you will see the syntax.
if (name==null) {
name="nothing"//or whatever
}
LabelObj.Text = String.Format("Use %s with %s", player.ActiveInventory.Name,name);
}
else{
name="";//remove this
LabelObj.Text = "@OVERHOTSPOT@";
}
}


Might do the trick..might.
Title: Re: Item name on label on mouse over.
Post by: -Squall- on Fri 21/11/2008 14:20:43
Thanks, but unfortunately it doesn't work  :(

Maybe GetLocationName only works with gInventory hidden... (because it works in my status line, but not in my label on inventory)

I realized too that player.ActiveInventory.name returns "null" until I close inventory and open it again. Then returns active item's name, even I change mouse mode or I click in another item. Maybe the problem is that the game is paused when I click on inventory's button?

Thanks a lot!

Title: Re: Item name on label on mouse over.
Post by: Khris on Fri 21/11/2008 14:48:30
Check if the Inventory GUI's visibility is set to Popup modal, this causes the game to be paused as long as the GUI is turned on. (Set it to Normal instead.)
Title: Re: Item name on label on mouse over.
Post by: -Squall- on Fri 21/11/2008 16:25:07
Thank you very much, KhrisMUC!

It works  ;D
Title: Re: Item name on label on mouse over.
Post by: Dualnames on Fri 21/11/2008 21:57:08
Quote from: KhrisMUC on Fri 21/11/2008 14:48:30
Check if the Inventory GUI's visibility is set to Popup modal, this causes the game to be paused as long as the GUI is turned on. (Set it to Normal instead.)

I got owned.  Repeatedly. I should just wait for Khris to come in and post then.. ;D