Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Dualnames on Thu 29/01/2009 09:08:09

Title: Newbie question but well..(SOLVED)
Post by: Dualnames on Thu 29/01/2009 09:08:09
Ok, I have this weird thing.. I'm using AGS 3.1.1 stable and I have this inventory GUI with an inventory window.
Normally when you right-click having an inventory item I have it get deselected (player.ActiveInventory=null;)

When I right-click having an inventory as cursor, over the inventory window, the interact/look action occurs, which I don't want it to happen. I have handle_inventory clicks option set to false.. I've tried to put a code on mouse click section but it just won't run.

Any ideas where I should put something like this to have it work? I've placed on a top of a mouse_click section but it refuses to work..


if (button==eMouseRightClick) {
if (gInventory.Visible==true) {
if (player.ActiveInventory!=null) {
InventoryItem*greif=InventoryItem.GetAtScreen(mouse.x,mouse.y);
if (greif!=null) {
Display("Got it");
return;
}
}
}
}
Title: Re: Newbie question but well..
Post by: OneDollar on Thu 29/01/2009 12:58:21
If you right-click on an inventory item I think it calls the event with eMouseRightInvClick, (or equivalent). Sorry, don't have AGS or the manual to check at the moment.

And stop using those returns ;D
Title: Re: Newbie question but well..
Post by: Dualnames on Thu 29/01/2009 13:18:34
Yeah, well, problem is that with emouserightinv it doesn't cause I have handle mouse click as false.

EDIT: I used a workaround..so thanks anyway.
Title: Re: Newbie question but well..(SOLVED)
Post by: Khris on Thu 29/01/2009 15:33:18
If you set inv click handling to false (why, if you want to tell AGS what to do after LeftInv/RightInv?), the clicks get sent to the GUI instead (only if the InvWindow is not-clickable).

You can then handle clicks like this:
function gGui1_OnClick(GUI *theGui, MouseButton button) {
  InventoryWindow1.Clickable = true;
  InventoryItem*i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  InventoryWindow1.Clickable = false;   // reset to false, so clicks get sent to the GUI!
  if (i == null) return;
  String c;
  if (button == eMouseLeft) c = "Left";
  if (button == eMouseRight) c = "Right";
  Display(String.Format("%s-click on item No. %d.", c, i.ID));
}

But, again: why would you turn that option off?

And using return seems to have become some kind of obsession for you, hasn't it... :=
Title: Re: Newbie question but well..(SOLVED)
Post by: Dualnames on Sat 31/01/2009 19:48:23
Yeah, and I'm using it in a wrong way.. I'll try and quit it. ;D

Thanks for answering Khris.. I did a workaround but it's always nice to be aware of more stuff.