Item name on label on mouse over. [SOLVED]

Started by -Squall-, Fri 21/11/2008 00:08:43

Previous topic - Next topic

-Squall-

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!  ;)

densming


-Squall-

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:
Code: ags

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:

Code: ags

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!

Dualnames

Code: ags

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

-Squall-

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!


Khris

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

-Squall-

Thank you very much, KhrisMUC!

It works  ;D

Dualnames

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
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk