customize inventory in GUI

Started by spook1, Wed 11/06/2003 18:37:05

Previous topic - Next topic

spook1

To make a more intuitive GUI I am experimenting with the inventory window.

I have managed to create n inventory window which is always visible and one can scoll through the items in the window.
I cannot pick any inventory items from the screen though.

Can anyone help?

My code is put below

// main global script file
int get_gui;
int got_inv;
string location_name;

function game_start() {
   
game.items_per_line = 17;
game.num_inv_displayed = 17;
SetInvDimensions(16,13);  
 
}

function repeatedly_execute() {
 // put anything you want to happen every game cycle here
GetLocationName(mouse.x,mouse.y,location_name);
get_gui = GetGUIAt(mouse.x,mouse.y);
got_inv = character[EGO].activeinv;



if (get_gui != -1) { // if in  GUI


 if (got_inv != -1) { // if cursor for invmode
    SetCursorMode(4);
    }
    else {
    SetCursorMode(MODE_USE);
    SetMouseCursor(2);
    }  
}
else if ((GetLocationType(mouse.x,mouse.y) > 0) && (got_inv == -1)) { // if not in GUI nor have object as cursor
   SetMouseCursor(2);
}
else if (got_inv != -1) {
     SetCursorMode(4);
}
else { // nothing, so "Walk"
         SetMouseCursor(0);
          }
}




function on_key_press(int keycode) {
 // called when a key is pressed. keycode holds the key's ASCII code
 if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
 if (keycode==17)  QuitGame(1);   // Ctrl-Q
 if (keycode==363) SaveGameDialog();   // F5
 if (keycode==365) RestoreGameDialog();  // F7
 if (keycode==367) RestartGame();  // F9
 if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
 if (keycode==9)   InventoryScreen();  // Tab, show inventory
 if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
 if (keycode==22)  Debug(1,0);  // Ctrl-V, version
 if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
 if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room
}

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 (GetLocationType(mouse.x,mouse.y) == 0) { // if in "nothing"
   
   if (button== RIGHT) {            


        SetActiveInventory(-1);
     
     }
   if (button == LEFT) {
 
   
            ProcessClick(mouse.x,mouse.y,MODE_WALK);
            SetCursorMode(MODE_WALK);
      }
   }
   else {
       
   if (button==RIGHT) {
 
         
     if ((GetLocationType(mouse.x,mouse.y) > 0) && (got_inv != -1)) { // se nao estiver no GUI e tiver cursor como objecto
           SetActiveInventory(-1);
     }
     else {
        ProcessClick(mouse.x, mouse.y,MODE_LOOK);
        SetCursorMode(MODE_LOOK);
        SetMouseCursor(1);
       
     }
   
   }
   else {  
   
     if (GetCursorMode() != 4) {
 
        ProcessClick(mouse.x, mouse.y,MODE_USE);
        SetCursorMode(MODE_USE);
     }
     else {  

        ProcessClick(mouse.x,mouse.y,4);
     }
    }
  }
}

function interface_click(int interface, int button) {
 if (interface == 1) {
       
   if (button == 4) {   // save game
     SaveGameDialog();
   }  
   else if (button == 5){   // load game
     RestoreGameDialog();
   }  
   else if (button == 3){   // quit
     QuitGame(1);
   }  
   else if (button == 7){    // about
     Display("Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2002 Chris Jones");
   }
 if ((button == 1 ) && (game.top_inv_item > 0)) { // left
   game.top_inv_item = game.top_inv_item - 1;
   }
   else if (button == 1) {
     Display("There are no more items to the left.");
   }
   if ((button == 2 ) && (game.num_inv_items > game.top_inv_item + 17)) { // right
     game.top_inv_item = game.top_inv_item + 1;
   }  
   else if (button == 2) {
     Display("There are no more items to the right.");    
   }
 }
}

Proskrito

I´m just having a guess... but why you set manually the cursor mode 4, if AGS selects it when using the mode 2 on a inventory item?? maybe there is a reason for making it that way.
Have you tried only using cursor mode 2, and letting AGS to set the mode 4?

spook1

The mode 4 is set once an inventory is active, so this is not the problem.
I have interacte cursor, but somehow I cannot click on the inventory item...

Pumaman

Do you have "Handle inv clicks in script" ticked in the main game settings?

spook1

The handle inv. is ticked off.
I have solved all the problems now.
I have a GUI that displays all inventories all the time, whenan inv. item is slected it is temporarily removed from the inv.window, when another inv is slected, the former one is put back!

Thanks for the hints

SMF spam blocked by CleanTalk