Inventory Screen Interface

Started by M, Tue 30/12/2003 11:34:56

Previous topic - Next topic

M

Just doing some last minute tweaks to a game...

My interface is right-click to use/interact, and left-click to look (BASS style). When an inventory item is in-use (i.e. the cursor is an inventory item) you can right-click to use it, and left-click to de-select it and get back to the normal game cursor.

The thing is that in the Inventory Window/Screen, the interface isnt the same. When an inventory item is selected, you have to left-click to use and right-click to de-select it. Its probably very simple but any idea how I can change the interface in the Inventory Screen to be the same as the rest of the game?

Thanks

-Michael-

Scorpiorus

try the next implementation

1. Tick the handle inventory clicks in script options.

2. in the global script file:

function on_mouse_click(int button) {
 // called when a mouse button is clicked. button is either LEFT or RIGHT
 if (IsGamePaused() == 1) {
   // Game is paused, so do nothing (ie. don't allow mouse click)
 }
 else if (button==LEFT) {
   //... blah
   if (GetCursorMode()==MODE_USEINV) SetActiveInventory(-1);
 }
 else if (button==RIGHT) {   // right-click, so cycle cursor
   //... blah
 }
 else if (button == LEFTINV) {
   
   if (GetCursorMode()==MODE_USEINV) SetActiveInventory(-1);
   else RunInventoryInteraction (game.inv_activated, MODE_LOOK);

 }
 else if (button == RIGHTINV) {
   
   if (GetCursorMode()==MODE_USEINV) RunInventoryInteraction (game.inv_activated, MODE_USEINV);
   else SetActiveInventory (game.inv_activated);
   
 }


}


function GetMouseButtonDown() {
 if (IsButtonDown (LEFT)) return LEFT;
 else if (IsButtonDown (RIGHT)) return RIGHT;
}


int bdown=-1;
function on_event (int event, int data) {
 
   if (event == GUI_MDOWN && GetInvAt(mouse.x, mouse.y)==-1) on_mouse_click(GetMouseButtonDown());

}

Does work?

M

Thanks for the reply. I've already got code similar to that, but I'm kind of paranoid about editting it too much. Which part of the code that you wrote refers to the interactions in the Inventory Screen exactly, so I know which stuff to add?

This is the code I've got already:


function on_mouse_click(int button) {
 // called when a mouse button is clicked. button is either LEFT or RIGHT
 if (IsGamePaused() == 1) {
   // Game is paused, so do nothing (ie. don't allow mouse click)
   }
 else if (button==LEFT) {

   //inv item in use?
   if (GetCursorMode() == 4) {
   SetCursorMode(0); }//set to walk - so cursor looks like default
   else {
   if (GetHotspotAt (mouse.x, mouse.y) == 0)
   ProcessClick(mouse.x, mouse.y, MODE_WALK );

   if (GetHotspotAt (mouse.x, mouse.y) > 0)
     ProcessClick(mouse.x, mouse.y, MODE_LOOK );

   if (GetObjectAt (mouse.x, mouse.y) > -1)
     ProcessClick(mouse.x, mouse.y, MODE_LOOK );

   if (GetCharacterAt (mouse.x, mouse.y) > -1)
     ProcessClick(mouse.x, mouse.y, MODE_LOOK ); }

   }


 else {   // RIGHT-CLICK, so USE

   if (GetCursorMode() == 4) { //If inv item is equipt
   ProcessClick(mouse.x, mouse.y, MODE_USEINV); } //use the item
   else {
   ProcessClick(mouse.x, mouse.y, MODE_USE ); }

   }
 }

I'm using AGS 2.56b, by the way.

Thanks

-Michael-

Scorpiorus

#3
ok, have just combined two scripts:
Code: ags

function on_mouse_click(int button) {
   // called when a mouse button is clicked. button is either LEFT or RIGHT
   if (IsGamePaused() == 1) {
   // Game is paused, so do nothing (ie. don't allow mouse click)
   }
   else if (button==LEFT) {
    
      //inv item in use?
      if (GetCursorMode() == MODE_USEINV) {
         SetActiveInventory(-1);
         SetCursorMode(0);
      }//set to walk - so cursor looks like default
      else {
         if (GetHotspotAt (mouse.x, mouse.y) == 0)
         ProcessClick(mouse.x, mouse.y, MODE_WALK );

         if (GetHotspotAt (mouse.x, mouse.y) > 0)
         ProcessClick(mouse.x, mouse.y, MODE_LOOK );

         if (GetObjectAt (mouse.x, mouse.y) > -1)
         ProcessClick(mouse.x, mouse.y, MODE_LOOK );

         if (GetCharacterAt (mouse.x, mouse.y) > -1) 
         ProcessClick(mouse.x, mouse.y, MODE_LOOK ); 
      }
    
    
   
    
   } else if (button==RIGHT) {   // RIGHT-CLICK, so USE
      if (GetCursorMode() == MODE_USEINV) { //If inv item is equipt
         ProcessClick(mouse.x, mouse.y, MODE_USEINV); } //use the item
      else {
         ProcessClick(mouse.x, mouse.y, MODE_USE ); }
   }


   else if (button == LEFTINV) {
    
      if (GetCursorMode()==MODE_USEINV) SetActiveInventory(-1);
      else RunInventoryInteraction (game.inv_activated, MODE_LOOK);
      
   } else if (button == RIGHTINV) {
    
      if (GetCursorMode()==MODE_USEINV) RunInventoryInteraction (game.inv_activated, MODE_USEINV);
      else SetActiveInventory (game.inv_activated);
   
   }
}


function GetMouseButtonDown() {
   if (IsButtonDown (LEFT)) return LEFT;
   else if (IsButtonDown (RIGHT)) return RIGHT;
}


int bdown=-1;
function on_event (int event, int data) {
  
   if (event == GUI_MDOWN && GetInvAt(mouse.x, mouse.y)==-1) on_mouse_click(GetMouseButtonDown());
 
}


don't forget to alter handle inv clicks in script ;)

does it work as supposed?

p.s. btw the code is for custom inv dialog, not for sierra built-in one. And its visible property has to be set to Normal.

M

Thanks, Scorpiorus. It doesnt work coz I'm using the default serria one, so I guess I'll try and whip up a custom one if I have time.

Scorpiorus

You can use one that comes along with AGS:

function show_inventory_window () {
 // This demonstrates both types of inventory window - the first part is how to
 // show the built-in inventory window, the second part uses the custom one.
 // Un-comment one section or the other below.
 
 // ** DEFAULT INVENTORY WINDOW
 //InventoryScreen();
 
 // ** CUSTOM INVENTORY WINDOW
 GUIOn (INVENTORY);  
 // switch to the Use cursor (to select items with)
 SetCursorMode (MODE_USE);
 // But, override the appearance to look like the arrow
 SetMouseCursor (6);

}

and visible to Normal

SMF spam blocked by CleanTalk