Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Help with GUI? (https://forums.graalonline.com/forums/showthread.php?t=134268827)

DeCeaseD 10-12-2013 05:09 AM

Help with GUI?
 
So I'm having trouble with this inventory I'm creating. I'm basically trying to make it so when a player right clicks an item within the inventory, a Context GUIctrl will appear for displaying/clicking options. Well I've got this to work perfectly fine.. Except I can't click any of the options because oddly one of these other GUI's isn't allowing it and won't let the Context GUIctrl grab focus/activity.

I've tried doing a million different things regarding all the different GUI's, like making the other windows lose focus/activity, disabling the other gui's modal and than enabling only the options menu's modal, but alas.. nothing.

I was hoping one of you mighty fine scriptin' fellas' would be able to locate the problem a let me know because I can't find anything and it's preventing me from completing the code.

Thanks in advance, Sage! ^_^

I've attached the pieces of the code pertaining to the problem in a link here:

http://pastebin.com/bwW8e2Ma

Edit: Sorry for having to post a link rather than directly posting the code in the thread. Oddly my browser isn't letting me post it here.. it's saying something about "Owner denied your request".. Something to do with the tags around the code I think.. Not completely sure though. -_-

Jakov_the_Jakovasaur 10-12-2013 10:29 AM

hello!

i couldnt replicate this problem when using the provided script without all the server specific stuff, the item options menu appeared and functioned as expected, so i think this is interfering with another script

although this wont fix the problem a word of advice is that guis and profiles are not strings, they are objects so shouldnt really be in " " quotes

good luck!

xAndrewx 10-12-2013 11:41 AM

Debug using the following- it will tell you which GUI is stealing focus- press F2 to see the output;

HTML Code:

//#CLIENTSIDE
function onFirstResponderChanges(obj) {
  echo(format(_("Stealing Focus: %s at %f %f"), temp.obj.name, temp.obj.x, temp.obj.y));
}


DeCeaseD 10-12-2013 02:20 PM

Quote:

Originally Posted by xAndrewx (Post 1723260)
Debug using the following- it will tell you which GUI is stealing focus- press F2 to see the output;

HTML Code:

//#CLIENTSIDE
function onFirstResponderChanges(obj) {
  echo(format(_("Stealing Focus: %s at %f %f"), temp.obj.name, temp.obj.x, temp.obj.y));
}


Thanks for the input Andrew, but I've actually already done this. Oddly the return is nullified. I'm not sure what's going on here. o_O

DeCeaseD 10-13-2013 11:05 PM

So after more research.. I've found that the ContextMenuCtrl, is actually just not registering as an object. I put the GUI in it's own code and was wondering if anyone could point out the problem? Btw the debug is returning null in all aspects.. I have a feeling it's something extremely simple that I'm just overlooking.. Or perhaps it's a problem with Graal in itself?

HTML Code:

//#CLIENTSIDE
function onCreated() {
  onDisplayOptions();
}

function onDisplayOptions() {
  new GuiContextMenuCtrl("Options_Menu") {
    profile = "Necro_TextEdit";
    profile.modal = true;
    profile.active = true;
    profile.makefirstresponder = true;
    textprofile = "Necro_Text";
    text = "Options";
    width = 20;
   
    clearRows();
    bringtofront();
    isfirstresponder();
   
    addRow(0, "Options");
    addrow(-1, "-");
    for (temp.I = 0; temp.I < thiso.options.size(); temp.I++)
    {
      addRow(temp.I + 1, thiso.options[temp.I]);
    }
   
    open(mousescreenx, mousescreeny);
  }
}

function onFirstResponderChanges(obj) {
  player.chat = "Debug2:"SPC temp.obj.name SPC temp.obj.x SPC temp.obj.y;
}

Edit: I actually changed the player chat return to an echo, and it's actually echoing the name of the object now? But seemingly incorrect x/y coordinates, as they're returning null? Anyone have any idea what's going on here? haha

sssssssssss 10-13-2013 11:19 PM

I had to call to destroy() every time before showing/creating the menu ctrl on our old one, maybe that will help as hacky as it is?

Also, unless you have other windows using modal or firstresponder, at least through all my gui stuff I've done, all you should really need is bringtofront() for these types of things (unless some other reason besides just showing up front).

Also, in your posted code, line 198:
PHP Code:

function Options_Menu.onSelect(entryidtext)  {
  
temp.slot this.cell_selected;
 
  if (
temp.slot <= this.items.size()) {
    
play("necro_click2.wav");
    
temp.itemName makevar("clientr.items"thiso.backpack)[slot];
    
temp.itemRealName makevar("clientr.item_"temp.itemName)[1];
    if ( 
temp.itemName == NULL ) {
      if ( 
isObject("ItemOptions_Menu") )
        
ItemOptions_Menu.destroy();
      return;
    }
  } 

Should that be function ItemOptions_Menu?

Hopefully one of those helps.

DeCeaseD 10-13-2013 11:29 PM

Quote:

Originally Posted by sssssssssss (Post 1723297)
I had to call to destroy() every time before showing/creating the menu ctrl on our old one, maybe that will help as hacky as it is?

Also, unless you have other windows using modal or firstresponder, at least through all my gui stuff I've done, all you should really need is bringtofront() for these types of things (unless some other reason besides just showing up front).

Also, in your posted code, line 198:
PHP Code:

function Options_Menu.onSelect(entryidtext)  {
  
temp.slot this.cell_selected;
 
  if (
temp.slot <= this.items.size()) {
    
play("necro_click2.wav");
    
temp.itemName makevar("clientr.items"thiso.backpack)[slot];
    
temp.itemRealName makevar("clientr.item_"temp.itemName)[1];
    if ( 
temp.itemName == NULL ) {
      if ( 
isObject("ItemOptions_Menu") )
        
ItemOptions_Menu.destroy();
      return;
    }
  } 

Should that be function ItemOptions_Menu?

Hopefully one of those helps.

Yeah I already do destroy everytime before showing (Pretty sure you're supposed to? Correct me if I'm wrong, but that's what I've learned through experience.)

And yeah I am using modal on other GUI's so they don't immediately interfere with gameplay. As far as the firstresponder thing.. I added that as the aftermath of not being able to correctly focus the context menu, just for testing purposes to see if it would help the problem (Which obviously isn't the case now.)

And thanks for pointing out the typo. Would've noticed it eventually once I got the GUI correctly functioning, but good gesture either way.

But yeah.. none of those really help what I'm trying to accomplish here. Not sure if my last post serves any relevance to the problem, but I think it should.. and I'm not at all sure how to fix it. -_-

sssssssssss 10-13-2013 11:38 PM

PHP Code:

new GuiContextMenuCtrl("Options_Menu") {
    
profile "Necro_TextEdit";

    
textprofile "Necro_Text";
    
text "Options";
    
width 20;
    
    
clearRows();
    
bringtofront();
    
    
addRow(0"Options"); 
    
addrow(-1"-"); 
    for (
temp.0temp.thiso.options.size(); temp.I++) 
    { 
      
addRow(temp.1thiso.options[temp.I]); 
    } 
     
    
open(mousescreenxmousescreeny); 
  }
}

function 
Options_Menu.onSelect(entryidtext)  {
  
player.chat text;


Above worked just fine for me.
Quote:

Except I can't click any of the options because oddly one of these other GUI's isn't allowing it and won't let the Context GUIctrl grab focus/activity.
If that typo was what you were using that would stop it from doing anything because it wasnt reading the right gui obj name for the selection.

DeCeaseD 10-13-2013 11:58 PM

Quote:

Originally Posted by sssssssssss (Post 1723299)
PHP Code:

new GuiContextMenuCtrl("Options_Menu") {
    
profile "Necro_TextEdit";

    
textprofile "Necro_Text";
    
text "Options";
    
width 20;
    
    
clearRows();
    
bringtofront();
    
    
addRow(0"Options"); 
    
addrow(-1"-"); 
    for (
temp.0temp.thiso.options.size(); temp.I++) 
    { 
      
addRow(temp.1thiso.options[temp.I]); 
    } 
     
    
open(mousescreenxmousescreeny); 
  }
}

function 
Options_Menu.onSelect(entryidtext)  {
  
player.chat text;


Above worked just fine for me.


If that typo was what you were using that would stop it from doing anything because it wasnt reading the right gui obj name for the selection.

Hm, yeah I dunno what I was thinking. The above script DOES work fine.. so obviously this must have something to do with an interference from one of the other GUI's involved. I'm just not sure what's interfering or how.. And the typo isn't the problem. The context menu isn't correctly focusing for me to even click an option. For instance, the GUI will open and normally when mousing over an option it'll highlight the option you have moused over. This is the case when I have the Context menu in it's own script, but not the case when it's within the inventory code. It will only appear and allow me to close it.. but not highlight/select anything.


All times are GMT +2. The time now is 06:44 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.