Disable right click over inventory window

Started by steptoe, Wed 25/07/2012 18:56:38

Previous topic - Next topic

steptoe

Hi

this type of thing has come up a few times but I am unable to find an exact reference / solution.

Although I don't think it's a big issue I need to ask.

---Disable right mouse click when over inventory window.---

Main reason is that it has been noted and reported that I have an extra description (more detail) of each inventory item as a DisplayAt at bottom of screen as well as @OVERHOTSPOT@ due to lack of space on the gstatusline.

Right clicking on inv item brings up the DisplayAt even though the mouse modes don't go to the next one.

Ideally, I would like to disable Right mouse click if  mouse x mouse y or another way so DisplayAt does not appear when right clicking inv item and only when LookAt is used.

Is there a suitable solution to this?

cheers


It's not over until the fat lady sings..

Crimson Wizard

#1
The solution to this could be simply to check what button is pressed over inventory.
Here's some info that may be useful:
http://www.adventuregamestudio.co.uk/wiki/?title=Predefined_global_script_functions#on_mouse_click

In short, function on_mouse_click is called when player clicks mouse. You check that he clicked right mouse button over inventory item and if it is true then exit the function. You probably do not need to test coordinates, since AGS will recognize when click was made on item and sets button type to eMouseLeftInv or eMouseRightInv.

The code may look like this:

Code: ags

function on_mouse_click(MouseButton button) {
  if (button == eMouseRightInv)
  {
    return;
  }

  ... your other mouse code ...
}


This is simply an example. You may find more sutable way to manage this depending on how you handle mouse events in your game.

steptoe

Hi Monkey

unfortunately it does not seem to do trick and still shows DisplayAt.

Mmmm
It's not over until the fat lady sings..

Crimson Wizard

#3
I am not Monkey :P

Thinking of it, perhaps I started from wrong direction.
The action should not happen at first place if there's nothing coded. That means if that action takes place, it was coded. Now all you need is to find the code and remove it.

What's in yours on_mouse_click function?
Do you maybe have some "Look at inventory" event handlers for your inventory items?
Also: is your game based on any game template?

steptoe

#4
Sorry about that Crimson Wizard  :-[

Now that you have brought to my attention about 'on_mouse_click' function I see that the answer should lay within?

It obviously just needs adjusting.

QuoteDo you maybe have some "Look at inventory" event handlers for your inventory items?
I have coded 'Look at' inventory items via inventory items events panel shown as 'DisplayAt.'
The problem is to not have it show with right mouse click on inventory item.

QuoteAlso: is your game based on any game template?
No


Code: AGS
function on_mouse_click(MouseButton button) {
  
 
  if (IsGamePaused() == 1)
  {
 // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) 
  {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseRight)  // RIGHT MOUSE ACTION !
  {
  // right-click our mouse-wheel down, so cycle cursor
   mouse.SelectNextMode();  
  }
  else if (button == eMouseWheelSouth)
  {
    // right-click our mouse-wheel down, so cycle cursor
    mouse.SelectNextMode(); 
  }
  else if (button == eMouseMiddle) 
  { 
    // Middle-button-click, default make character walk to clicked area (a little shortcut)
    // Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to
    // leave our options open - what if you have a special script triggered
    // on "walking" mode?
    ProcessClick(mouse.x, mouse.y, eModeWalkto); 
  }
  else if (button == eMouseWheelNorth) 
  { 
    // Mouse-wheel up, cycle cursors 
    // If mode isn't WALK, set the previous mode (notice usage of numbers instead
    // of eNums, when it suits us)...
  if (mouse.Mode>0) mouse.Mode=mouse.Mode-1; 
  else 
  { 
      // ...but if it is WALK mode...
  if (player.ActiveInventory!=null) 
  {
  //...and the player has a selected inventory item, set mouse mode to UseInv. 
   mouse.Mode=eModeUseinv; 
  }
    else 
  {
   // If they don't, however, just set it to mode TALK (change this line if you add more cursor modes)
    mouse.Mode=eModeTalkto; 
   }
   }
   }
   }


cheers

steptoe
It's not over until the fat lady sings..

Crimson Wizard

#5
I probably know. Strange how I could forget about this one.

This is an excerpt from the manual about game's General Settings:
Quote from: AGS Manual
Override built-in inventory window click handling
Override built-in inventory window click handling - AGS has some built-in processing of Inventory Window GUI controls, whereby a right-click will Look at the item, and a left click will select it if the cursor mode is Interact...

Try to toggle that option to True (General Settings -> Inventory -> Override built-in inventory window click handling).

On other hand you will have to write additional code for selecting items by left click.
Test for eMouseLeftInv mouse "button" (not just eMouseLeft) to know when left click is made over inventory item.

steptoe

Hi Crimson Wizard

Yes, I was aware of that option. But, as you said, it would mean making more code instructions and I would rather, at this point, work on something that it tangible, flexible and without too much fuss.

Still, food for another day.

Thanks  8-)
It's not over until the fat lady sings..

Khris

You want nothing to happen on a right click, so you have to set that option to true, otherwise how could you interfere with the default behavior?
If "making more code instructions" is what keeps you from solving this problem, well...

steptoe

Hi Khris

QuoteIf "making more code instructions" is what keeps you from solving this problem, well...

That is to say I will be looking into doing just that, but, at this stage of this game, I feel it's a bit late to start pussy footing around but I will be looking at the ways to code my own so that I can do it in future games if required.



It's not over until the fat lady sings..

SMF spam blocked by CleanTalk