Problem with a GUI script

Started by Mr Jake, Fri 30/01/2004 18:56:42

Previous topic - Next topic

Mr Jake

hey
This script is for an upcoming game (cannot say more  :-X )

but anyway, so far( haven't tried the Inventory bits) it works, other then the bit with the GUI being turned off, why??

else if (button==LEFT) {
   ProcessClick(mouse.x, mouse.y, MODE_WALK);
 }
 else {   // right-click, so cycle cursor
   if (IsGUIOn(3)==1){  // Is the inventory open
        if (IsGUIOn (5)==1){
          GUIOff (5);
          }
        if (GetInvAt(mouse.x,mouse.y) > -1){ //is it over a inv item?
    SetGUIPosition (5, mouse.x, mouse.y);      
    GUIOn (5);
    }
}
     else if (IsGUIOn(4)==1){  //is the GUI already on
     GUIOff(4);
     }
   else if (GetHotspotAt(mouse.x,mouse.y) > 0){ //is it over a hotspot
       SetGUIPosition (4, mouse.x, mouse.y);
       GUIOn (4);
       }
     }

thanks in advance  8)

Pumaman

Which bit with which GUI being turned off? What doesn't work?

a-v-o

When the mouse cursor is over any GUI then the right click isn't triggered. What happens to right clicks on a GUI? They don't trigger on_interface_click either.

Ytterbium

I don't know if what you're thinking of is possible yet (*nudge* *nudge*, CJ). For now, just use a button to turn off the GUI.

Currently in production: Septigon

Pumaman

Ah, then you need to handle the GUI_MDOWN call to the on_event global function. I appreciate this isn't very well documented so it should really be made more prominent.

Mr Jake

this works, but only if you right click when on the GUI (at least the new version does)

ok, new problem:

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) {
   ProcessClick(mouse.x, mouse.y, MODE_WALK);
 }
 else {   // right-click, so cycle cursor
    if (IsGUIOn(4)==1){  //is the GUI already on
     GUIOff(4);
     }
    if (IsGUIOn(3)==1){  // Is the inventory open
        if(GetInvAt(mouse.x, mouse.y) > 0){ //is it over a inv item?
    mmx=mouse.x + 25;
    mmy=mouse.y +10;        
        xspot=mouse.x;
    yspot=mouse.y;
        SetGUIPosition (5, mouse.x, mouse.y);      
    GUIOn (5);
    SetMousePosition (mmx, mmy);
    }
          if (IsGUIOn (5)==1){
          GUIOff (5);
          }
}
     
   else if ((GetHotspotAt(mouse.x,mouse.y) > 0) || (GetCharacterAt (mouse.x, mouse.y) > -1) || GetObjectAt (mouse.x, mouse.y) > -1){ //is it over a hotspot
       mmx=mouse.x + 25;
       mmy=mouse.y + 25;
   xspot=mouse.x;
   yspot=mouse.y;
       SetGUIPosition (4, mouse.x, mouse.y);
       GUIOn (4);
       SetMousePosition (mmx, mmy);
       }
     else {
       SaveGameSlot (999, "inv");
       screen= LoadSaveSlotScreenshot (999, 81, 50);
       SetButtonPic (GAMEINV, 0, 1, screen);
       GUIOn (3);
       }
     }

}
------------------------------------------------------------------------------------

The problem is with If (IsGUIon(3) == 1){ } this block of code wont run (I put a display speech in to see if it was even running, and it wasn't, sorrry if you have already explained this is what you just said, I've asked AGA and he didnt have a clue, so it cant be anything TOO easy ^_^/

Pumaman

When the mouse is over a GUI, on_mouse_click is not called. Therefore, you need to put your IsGUIOn check in the on_event function for an event of type GUI_MDOWN.

As I say, the documentation on this is quite poor so I'll see about improving it.

SMF spam blocked by CleanTalk