Double click in inventory doesn't work

Started by Pet Terry, Fri 17/10/2003 09:53:43

Previous topic - Next topic

Pet Terry

Hello. I'm making interface in which double click is used, so I want to use double click in inventory aswell. This means, that if you double click an inventory item, mouse cursor changes to an item. Single left click will USE item and right click will EXAMINE item. So, my interface works fine, but inventory doesn't. When I click item only once, I got a message, but after clicking the message away and click item again once, mouse cursor changes to an item. I think I know what's wrong with it, but I can't fix it. So, here's the code:

Quote

// main global script file
int invdoubleclick = 0;

function repeatedly_execute() {
if(IsTimerExpired(2)==1)
   {
ProcessClick(mouse.x,mouse.y, MODE_USE);
invdoubleclick = 0;
}
}

function on_mouse_click(int button) {

if (button==RIGHTINV) {
 if (GetCursorMode() == 4) SetCursorMode(0);
 else if (GetCursorMode() == 6) SetCursorMode(0);
 else ExamineInventory();
 }

else if (button==LEFTINV) {

if (GetCursorMode() != 4) {
 if (invdoubleclick==0) {
 UseInventory();
 SetTimer(2,10);
 invdoubleclick=1; }

 else if (invdoubleclick==1) {
 SetActiveInventory(game.inv_activated);
 invdoubleclick = 0;
 SetTimer(2,0);
 }
}


}
}


I think the problem is in repeatedly execute-part, right? So, help please?
<SSH> heavy pettering
Screen 7

Scorpiorus

#1
hmm, is your inventory GUI set to Popup Modal. This way it pauses the game and repeatedly_execute isn't get called. Try Normal mode instead.

btw, what does UseInventory(); do? It shouldn't use inventory item instantly but wait for the timer to be expired.

int useinv_called = 0;
function UseInventory() {
useinv_called = 1;
}

function repeatedly_execute() {
if(IsTimerExpired(2)==1)
{

if (useinv_called == 1) RunInventoryInteraction (game.inv_activated, MODE_USE);
else ProcessClick(mouse.x,mouse.y, MODE_USE);

useinv_called = 0;
invdoubleclick = 0;
}
}

I use RunInventoryInteraction() instread of ProcessClick() because the last doesn't work with GUIs:

QuoteNOTE: This function ignores all interfaces and acts as though the point is directly visible. In other words, if the co-ordinates you pass happen to lie on a button on an interface, what actually happens will be as if the user clicked behind the interface onto the actual screen.

How it turns out?


Pet Terry

Gotta try your tips. As for the UseInventory(); it is:

function UseInventory() {
if (game.inv_activated==1) { //Inventory Item 1
Display ("Used item.");
}
}

etc. etc.

Thanks!
<SSH> heavy pettering
Screen 7

Pet Terry

Well, I set the GUI to normal, and put UseInventory(); to repeadetly execute instead of ProcessClick. It works now... kinda. Sometimes when I double click, it does USE-interaction twice. Not always though.
<SSH> heavy pettering
Screen 7

Pumaman

Well, if your two clicks are more than 1/4 second apart, it will run the interaction twice rather than registering a double-click. Try making your SetTimer longer, for example 20-30 loops.

Pet Terry

Your right CJ, I forgot to update this thread, because I solved the problem by making SetTimer longer. Thanks for the help though :)
<SSH> heavy pettering
Screen 7

SMF spam blocked by CleanTalk