Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Server Select GUI (https://forums.graalonline.com/forums/showthread.php?t=82844)

cyan3 11-21-2008 02:53 AM

Server Select GUI
 
1 Attachment(s)
I've been trying to teach myself some GS2 and I thought GUI scripting would be an easy place to start. So i messed around with some GUI Controls and come up with this.

PHP Code:

//Made by Felix Lionheart (cyan3)
//#CLIENTSIDE

function onKeyPressed(keycharcharacter)

  if (
character == "9"){
   
show();
}
 public function 
show()

  new 
GuiWindowCtrl("ServerSelect_Window") {
    
profile GuiWindowProfile;
    
clientrelative true;
    
clientextent "320,240";
    
extent "230 425";

    
canclose true;
    
canmaximize false;
    
canminimize true;
    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide true;
    
text "Server Select -" SPC servername;
    
5;
    
100;

//Gold Servers
    
new GuiTextCtrl("ServerSelect_GoldServers") {
      
profile GuiTextProfile;
      
profile.fontsize 15;   
      
text "Gold Servers";
      
position "5 0";
}
    new 
GuiButtonCtrl("ServerSelect_GraalKingdoms") {
      
profile GuiButtonProfile;
      
text "Graal Kingdoms";
      
width 100;
      
5;
      
25;
}
    new 
GuiButtonCtrl("ServerSelect_Zone") {
      
profile GuiButtonProfile;
      
text "Zone";
      
width 100;
      
5;
      
60;
}
    new 
GuiButtonCtrl("ServerSelect_Games") {
      
profile GuiButtonProfile;
      
text "Graal Skills";
      
width 100;
      
110;
      
60;
}
    new 
GuiButtonCtrl("ServerSelect_KingdomsDebug") {
      
profile GuiButtonProfile;
      
text "Kingdoms Debug";
      
width 100;
      
110;
      
25;
}
//Classic Servers
    
new GuiTextCtrl("ServerSelect_ClassicServers") {
      
profile GuiTextProfile;
      
profile.fontsize 15;
      
text "Classic Servers";
      
position "5 90";

    new 
GuiButtonCtrl("ServerSelect_Zodiac") {
      
profile GuiButtonProfile;
      
text "Zodiac";
      
width 100;
      
5;
      
115;
}
    new 
GuiButtonCtrl("ServerSelect_Era") {
      
profile GuiButtonProfile;
      
text "Era";
      
width 100;
      
5;
      
150;
}
    new 
GuiButtonCtrl("ServerSelect_Classic") {
      
profile GuiButtonProfile;
      
text "Classic";
      
width 100;
      
5;
      
185;
}
    new 
GuiButtonCtrl("ServerSelect_Valikorlia") {
      
profile GuiButtonProfile;
      
text "Valikorlia";
      
width 100;
      
110;
      
115;
}
    new 
GuiButtonCtrl("ServerSelect_Atlantis") {
      
profile GuiButtonProfile;
      
text "Atlantis";
      
width 100;
      
110;
      
150;
}
    new 
GuiButtonCtrl("ServerSelect_Delteria") {
      
profile GuiButtonProfile;
      
text "Delteria";
      
width 100;
      
110;
      
185;
}
    new 
GuiButtonCtrl("ServerSelect_NPulse") {
      
profile GuiButtonProfile;
      
text "N-Pulse";
      
width 100;
      
5;
      
220;
}   
    new 
GuiButtonCtrl("ServerSelect_UnholyNation") {
      
profile GuiButtonProfile;
      
text "Unholy Nation";
      
width 100;
      
110;
      
220;
}

//Hosted Servers
    
new GuiTextCtrl("ServerSelect_HostedServers") {
      
profile GuiTextProfile;
      
profile.fontsize 15;
      
text "Hosted Servers";
      
position "5 250";
}
    new 
GuiButtonCtrl("ServerSelect_Aeon") {
      
profile GuiButtonProfile;
      
text "Aeon";
      
width 100;
      
5;
      
275;
}   
    new 
GuiButtonCtrl("ServerSelect_OlWest") {
      
profile GuiButtonProfile;
      
text "Ol' West";
      
width 100;
      
110;
      
275;
}
    new 
GuiButtonCtrl("ServerSelect_Atrius") {
      
profile GuiButtonProfile;
      
text "Atrius";
      
width 100;
      
5;
      
310;
}

//Other Servers
    
new GuiButtonCtrl("ServerSelect_Reconnect") {
    
profile GuiButtonProfile;
    
text "Reconnect";
    
width 100;
    
110;
    
310;
}
    new 
GuiButtonCtrl("ServerSelect_Disconnect") {
      
profile GuiButtonProfile;
      
text "Disconnect";
      
width 100;
      
5;
      
345;
}
    new 
GuiButtonCtrl("ServerSelect_Close") {
      
profile GuiButtonProfile;
      
text "Close";
      
width 70;
      
145;
      
360;
     }
    }

//Gold Servers
function ServerSelect_GraalKingdoms.onAction() {
  
serverwarp("Graal Kingdoms");
 }

function 
ServerSelect_KingdomsDebug.onAction() {
  
serverwarp("Kingdoms Debug");
 }
 
function 
ServerSelect_Zone.onAction() {
  
serverwarp("Zone");
  }

function 
ServerSelect_Games.onAction() {
  
serverwarp("Games");
 }
 
//Classic Servers
function ServerSelect_Zodiac.onAction() {
   
serverwarp("Zodiac");
  }
  
function 
ServerSelect_Era.onAction() {
  
serverwarp("Era");
 }
 
function 
ServerSelect_Classic.onAction() {
  
serverwarp("Classic");
 }

function 
ServerSelect_Valikorlia.onAction() {
  
serverwarp("Valikorlia");
 }

function 
ServerSelect_Atlantis.onAction() {
  
serverwarp("Atlantis");
 }

function 
ServerSelect_Delteria.onAction() {
  
serverwarp("Delteria");
 }
 
function 
ServerSelect_NPulse.onAction() {
  
serverwarp("N-Pulse");
 }

//Hosted Servers
function ServerSelect_Aeon.onAction() {
  
serverwarp("AEON");
 }

function 
ServerSelect_OlWest.onAction() {
  
serverwarp("Ol' West");
 }

function 
ServerSelect_Atrius.onAction() {
  
serverwarp("Atrius");
  }

//Other Servers
function ServerSelect_Reconnect.onAction() {
  
serverwarp(servername);
 }

function 
ServerSelect_Disconnect.onAction() {
  
serverwarp("Login1");
 }

function 
ServerSelect_Close.onAction() {
  
ServerSelect_Window.destroy();



Tigairius 11-21-2008 03:17 AM

Cool :)

cbk1994 11-21-2008 05:25 AM

Nice. For future note, completed scripts to share go in the Code Gallery.

xXziroXx 11-21-2008 10:04 AM

I really hate your styling, but good job :)

cyan3 11-21-2008 01:43 PM

Quote:

Originally Posted by cbk1994 (Post 1443717)
Nice. For future note, completed scripts to share go in the Code Gallery.

I'll try and get this thread moved and remember to post in the gallery in future.

Quote:

Originally Posted by xXziroXx (Post 1443748)
I really hate your styling, but good job :)

I've just started learning GS2 and my styling has not developed yet.

Loriel 11-21-2008 03:50 PM

Quote:

Originally Posted by cyan3 (Post 1443761)
I've just started learning GS2 and my styling has not developed yet.

You could apply any other C-style-syntax language's styling and it would look better than this.

I recommend the Java style guidelines at Sun's Java site, apart from the java/javadoc specific stuff.

cbk1994 11-21-2008 11:11 PM

There doesn't really seem to be any "styling". It's inconsistent throughout the script.

I recommend picking up a form of styling as soon as you can, otherwise you're going to have to start later, which is a pain.

DustyPorViva 11-21-2008 11:15 PM

Not to mention styling helps you out when you're scripting. It's a lot easier to know where a function starts and ends, what's part of a function, what's part of this if statement and not that one... so on and so forth. You a lot less likely to make errors and get lost in your own script.

And if you ever need help, it'll be a lot easier for the helper when they can understand it because of good styling.

[email protected] 11-24-2008 09:50 AM

cool, but try using a loop :)

Programmer 11-24-2008 09:15 PM

I'm surprised that this doesn't produce an error. I've never seen functions declared like so:

PHP Code:

function onKeyPressed(keycharcharacter)

  if (
character == "9"){
   
show();


When I first looked at this, it looked like you defined show() inside of onKeyPressed(). I suggest using braces where you can. This would make it a lot clearer:

PHP Code:

function onKeyPressed(keycharcharacter)
// Added a brace here ...
     
if (character == "9")
     {
          
show();
     }
// .. and here 



All times are GMT +2. The time now is 04:03 PM.

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