Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-16-2011, 12:16 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
My first Crack at GUI

I thought about making this for a while but never got around to doing it but here it is. Its simple, but it works.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  new 
GuiWindowCtrl("ServerList_Window1") {
    
profile GuiRedWindowProfile;
    
clientrelative true;
    
clientextent "104,374";

    
alpha 5;
    
canclose false;
    
canmaximize false;
    
canminimize false;
    
canmove false;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Serverlist";
    
1050;
    
100;

    new 
GuiButtonCtrl("ServerList_Button1") {
      
profile GuiRedButtonProfile;
      
text "Login";
      
width 80;
      
10;
      
10;
    }
    new 
GuiButtonCtrl("ServerList_Button4") {
      
profile GuiRedButtonProfile;
      
text "Zone";
      
width 80;
      
10;
      
50;
    }
    new 
GuiButtonCtrl("ServerList_Button5") {
      
profile GuiRedButtonProfile;
      
text "Kingdoms";
      
width 80;
      
10;
      
90;
    }
    new 
GuiButtonCtrl("ServerList_Button6") {
      
profile GuiRedButtonProfile;
      
text "Zodiac";
      
width 80;
      
10;
      
130;
    }
    new 
GuiButtonCtrl("ServerList_Button7") {
      
profile GuiRedButtonProfile;
      
text "Era";
      
width 80;
      
10;
      
170;
    }
    new 
GuiButtonCtrl("ServerList_Button8") {
      
profile GuiRedButtonProfile;
      
text "Unholy N";
      
width 80;
      
10;
      
210;
    }
    new 
GuiButtonCtrl("ServerList_Button9") {
      
profile GuiRedButtonProfile;
      
text "Valikorlia";
      
width 80;
      
10;
      
250;
    }
    new 
GuiButtonCtrl("ServerList_Button10") {
      
profile GuiRedButtonProfile;
      
text "AEON";
      
width 80;
      
10;
      
290;
    }
    new 
GuiButtonCtrl("ServerList_Button11") {
      
profile GuiRedButtonProfile;
      
text "Maloria";
      
width 80;
      
10;
      
330;
    }
  }
}

function 
ServerList_Button1.onAction() {
  
// Button "Login" has been pressed
  
ServerWarp("Login");
}

function 
ServerList_Button4.onAction() {
  
// Button "Zone" has been pressed
  
ServerWarp("Zone");
}

function 
ServerList_Button5.onAction() {
  
// Button "Kingdoms" has been pressed
  
ServerWarp("Graal Kingdoms");
}

function 
ServerList_Button6.onAction() {
  
// Button "Zodiac" has been pressed
  
ServerWarp("Zodiac");
}

function 
ServerList_Button7.onAction() {
  
// Button "Era" has been pressed
  
ServerWarp("Era");
}

function 
ServerList_Button8.onAction() {
  
// Button "Unholy N" has been pressed
  
ServerWarp("Unholy Nation");
}

function 
ServerList_Button9.onAction() {
  
// Button "Valikorlia" has been pressed
  
ServerWarp("Valikorlia");
}

function 
ServerList_Button10.onAction() {
  
// Button "AEON" has been pressed
  
ServerWarp("AEON");
}

function 
ServerList_Button11.onAction() {
  
// Button "Maloria" has been pressed
  
ServerWarp("Maloria");

__________________
Reply With Quote
  #2  
Old 04-16-2011, 12:22 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Ideally use clientWidth and clientHeight (or width and height if not using clientRelative) for setting the dimensions of objects (edit: just noticed you used it for the window but not the buttons; consistency is key, and make sure to give the buttons a height).

If you're interested in improving the script, look into using catchEvent to avoid duplicated code and to greatly simplify your script.
__________________
Reply With Quote
  #3  
Old 04-16-2011, 12:26 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Tip: You can center a GUI when it's created by setting it's X and Y like this:

PHP Code:
//#CLIENTSIDE
function center(guiObj) {
  
with (guiObj) {
    
= (screenwidth width) / 2;
    
= (screenheight height) / 2;
  }

In your case you could just change the X and Y lines with the ones I suggested above. The default coordinates you left (1050,100) when you were making it with the GUI Editor could cause it to be off the screen for people.

You can also use a for-each loop and catchevent to remove the redundant button code.

PHP Code:
// For-each Example
temp.servers = {
  
"Login",
  
"Graal Kingdoms",
  
"Zone",
  
"Zodiac",
  
"Era",
  
"Unholy Nations",
  
"Valikorlia",
  
"Maloria",
  
"AEON"
};
for (
temp.servertemp.servers) {
  new 
GuiButtonCtrl("ServerList_Button_" temp.server) { 
    
profile GuiRedButtonProfile
    
text temp.server
    
width 80
    
10;
    
10 + (40 temp.servers.index(temp.server);
    
thiso.catchevent(this"onAction""onServerWarp");
  }
}

// All your 'obj.onAction()' functions can then be replaced with just this:
function onServerWarp(obj) {
  
serverwarp(obj.text);

__________________
Quote:
Reply With Quote
  #4  
Old 04-16-2011, 12:29 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
This is already created, you just edited it, to keep the newer servers.
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #5  
Old 04-16-2011, 12:36 AM
MattKan MattKan is offline
the KattMan
Join Date: Aug 2010
Location: United States
Posts: 1,325
MattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to beholdMattKan is a splendid one to behold
Send a message via AIM to MattKan
Quote:
Originally Posted by Astram View Post
This is already created, you just edited it, to keep the newer servers.
Uhuh

Maybe, Emera, if you would spend your time learning instead of ripping off other people (which doesn't help you much anyways, the way you have been going), you would be able to actually learn to script...
Reply With Quote
  #6  
Old 04-27-2011, 10:44 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
I made it myself using the gui editor so stop pointing fingers please. You are just out to spot my errors astram.
__________________
Reply With Quote
  #7  
Old 04-27-2011, 01:23 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Emera View Post
I made it myself using the gui editor so stop pointing fingers please. You are just out to spot my errors astram.
Please don't use the GUI editor.
__________________
Reply With Quote
  #8  
Old 04-27-2011, 04:26 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Why is that? Sorry
__________________
Reply With Quote
  #9  
Old 04-27-2011, 04:44 PM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
It's cool and awesome of course, but lacks certain things that only coding can do. Try learning actual GUI script, wiki does have decent documentation on most GUI features, thankfully. If you learn how to GUI script, many light bulbs will click for you and you will be surprised at how many new ideas you can/will come up with, both GUI and other kinds scripts.
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote
  #10  
Old 04-27-2011, 10:00 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Emera View Post
Why is that? Sorry
It creates disgusting code, teaches you to position things absolutely (rather than based off text size, etc), is way less flexible in what it can do, and you won't understand how GUIs work as well if you continue to use it.
__________________
Reply With Quote
  #11  
Old 04-28-2011, 11:34 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Oops

Oh ok. Thanks
__________________
Reply With Quote
  #12  
Old 04-28-2011, 10:41 PM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Quote:
Originally Posted by cbk1994 View Post
It creates disgusting code, teaches you to position things absolutely (rather than based off text size, etc), is way less flexible in what it can do, and you won't understand how GUIs work as well if you continue to use it.
GUI's are fun to do also!
I like them ^.^;
Apparently I still have a few oddities in them like canMove not allowing something to move, and passing numbers via text with this. or thiso. but they are still neat to create..

I need to understand all of the types you can use in GUI; I've only used textbox, pulldown, slider, buttons, tabs and 1-2 other things so far..

I'd like to create my own tutorial which should be more helpful, but in the mean time this is what has helped me for the basics. http://forums.delteria.com/topic/1666-gui-tutorial/
__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz



Reply With Quote
  #13  
Old 04-29-2011, 11:26 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Thanks for this Devil_lord
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:15 AM.


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