Author Topic: GUI Question.  (Read 1544 times)

Im working on a GUI and i cannot get it to show up in the Controls Menu,
So i ask how do i get my GUI to show up in the Controls menu?
« Last Edit: October 26, 2008, 05:52:19 AM by FaTDoG »

Well, let's say your GUI's name is "MyGui".

Then you would do this:
Code: [Select]
if (!$MyGuiBinds)
{
$remapDivision[$remapCount] = "My Category";
$remapName[$remapCount] = "Open gui";
$remapCmd[$remapCount] = "MyGui_Open";
$remapCount++;
$MyGuiBinds = 1;
}

function MyGui_Open()
{
canvas.pushDialog(MyGui);
}

What this does is:
-It adds a new category to the controls section of options. "My Category"
-In the category, it adds a new bind. "Open Gui"
-If the key is pressed, it should call function MyGui_Open.
-To avoid having this section multiple times on re-exec, I added a check. $MyGuiBinds
-I have already defined the function that will be called, in it, there's canvas.pushDialog, this function shows a GUI on the screen, canvas.popDialog does the opposite.

Thanks! This helps alot
« Last Edit: October 26, 2008, 05:09:32 PM by FaTDoG »

I asked one more person to be sure and i think you forgot something This may be very wrong
Code: [Select]

function  mygui(%val)
{
if(%val)
{
switch(mygui.isAwake())
{
case 0:
canvas.pushdialog(mygui);
case 1:
canvas.popDialog(mygui);
}
}
}
« Last Edit: October 26, 2008, 01:01:23 PM by FaTDoG »

Both are right, the only difference is that, in the one you sent, pressing the button while it is open would close it. In mine, it wouldn't close.

EDIT: Why is the %var there? It's quite useless you know.
EDIT2: Ohh... I get it, sorry. That must work.
« Last Edit: October 26, 2008, 03:03:34 PM by NiXiLL »

it's not openning
How should I exec the GUI
Exec("./rpgscript.gui"); ???

I would suggest using this, not in a function, just somewhere inside of client.cs or whatever:
Code: [Select]
if(!isObject(myGui))
   exec("./rpgscript.gui");

popDialog(); Invaild control: rpgscript

The name of your GUI isn't the name of the .gui file, it's the name you put here, inside the .gui file:
Code: [Select]
//--- OBJECT WRITE BEGIN ---
new GuiControl(TetrisGUI) {

So in this case, I would replace myGui in the above code snippets with TetrisGUI.

I searched for this and couldnt find this so id thought i would make a topic for other people to help.. It worked thank you Zor & NiXiLL