Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Right click to bring up menu  (Read 3850 times)

0 Members and 1 Guest are viewing this topic.

Mikael

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 127
    • View Profile
    • MDNA Games
Right click to bring up menu
« on: September 04, 2007, 01:53:22 AM »

I've touched upon this subject before in the forum, but from a slightly different angle. What I want is to bring up the main menu with a simple right click. I now use right click for examining inventory items and deselecting them, nothing else. What I want is a right click in any other situation to bring up the menu. I've tried so many approaches to this, and nearly gotten there, but the complexity of the "RightClick" section in game.script prevents me from succeeding completely.

Thanks in advance!

Mikael
Logged

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Right click to bring up menu
« Reply #1 on: September 04, 2007, 06:14:42 AM »

Might be best to post your current game.script first, as it's probably been changed from the original.

As I see it, the right click section of the game.script is primarily concerned with checking to see what the mouse cursor is currently hovering over, and then applying the relevant code. Or, in the case of selected inventory items, deselecting them.

In its original form, it first checks to see if an inventory item is selected, and if it is, then it deselects it. If an item is not selected, the script then checks to see if the verb bar/coin is active. If it is, it makes in inactive. If not, then it checks to see if the cursor is over a hotspot. If it is, it makes the verb bar/coin active.

If there is no inventory item selected, the verb bar is not active, and the verb bar is not even needed, then the script runs whatever "RightClick" event is contained in the script of whatever the cursor is hovering over.

If it's hovering over empty space then the script does nothing at all.

So, I think what you want is to do something when the cursor is not hovering over anything but empty space.

I think you can just put the menu loading code after the two IF statements in the right click section of the game.script, so then it will check everything else first, and if none of the above are required, it will then run the menu loading code, and load your menu.
« Last Edit: September 04, 2007, 06:46:32 AM by TheDerman »
Logged

Mikael

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 127
    • View Profile
    • MDNA Games
Re: Right click to bring up menu
« Reply #2 on: September 04, 2007, 07:50:08 AM »

Thanks Derman.

So, I think what you want is to do something when the cursor is not hovering over anything but empty space.

The thing is that I don't use any verb bar whatsoever. I now use right click for examining inventory items and deselecting them, nothing else. Off course I do have active areas (look, take, gear icons, etc., and directional arrows), but I want the menu brought up even if you right click on one of those areas.

The right click section of my game.script is now exactly like it is in the WME demo, so there is no need to post it.

Mikael

Logged

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Right click to bring up menu
« Reply #3 on: September 04, 2007, 08:29:19 AM »

How about this:

Code: WME Script
  1. on "RightClick"
  2. {
  3.   // if inventory item selected? deselect it
  4.   if (Game.SelectedItem != null)
  5.    {
  6.     Game.SelectedItem = null;
  7.     return;
  8.    }
  9.  
  10.   var ActObj = Game.ActiveObject;
  11.  
  12.   if(Game.InventoryVisible) ActObj.ApplyEvent("RightClick");
  13.  
  14.   else
  15.    {
  16.     // load and display the main menu window
  17.     WinCaption.Visible = false;
  18.     var WinMainMenu = Game.LoadWindow("interface\system\mainmenu.window");
  19.     WinMainMenu.Center();
  20.     WinMainMenu.GoSystemExclusive();
  21.     Game.UnloadObject(WinMainMenu);
  22.    }
  23. }
  24.  
Logged

Mikael

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 127
    • View Profile
    • MDNA Games
Re: Right click to bring up menu
« Reply #4 on: September 04, 2007, 03:58:23 PM »

Yes, that's exactly what i meant! ;D Thanks a lot.

There's just one very, very minor issue now. When the inventory is visible, and I move the mouse very slowly downwards, the inventory doesn't disappear until I'm 10 pixels or something beneath it (which is "normal"). When I click in this area (that is, in the scene, but with the inventory still visible), I get a script runtime error which reads like this: "Call to undefined method 'ApplyEvent'. Ignored."

If this is unclear, I've uploaded a picture here:
http://www.mdna-games.com/ex.jpg

The large red dot is my cursor.

This could be easily solved if the inventory disappeared at the same height as the inventory background, but I'm not sure about how to control this.

Mikael
Logged

Mikael

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 127
    • View Profile
    • MDNA Games
Re: Right click to bring up menu
« Reply #5 on: September 04, 2007, 08:07:45 PM »

Solved it myself:

EXCLUSIVE = TRUE in inventory.def.

Mikael
Logged
 

Page created in 0.047 seconds with 24 queries.