PDA

View Full Version : Server Select GUI


cyan3
11-21-2008, 02:53 AM
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.

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

function onKeyPressed(keychar, character)

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;
x = 5;
y = 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;
x = 5;
y = 25;
}
new GuiButtonCtrl("ServerSelect_Zone") {
profile = GuiButtonProfile;
text = "Zone";
width = 100;
x = 5;
y = 60;
}
new GuiButtonCtrl("ServerSelect_Games") {
profile = GuiButtonProfile;
text = "Graal Skills";
width = 100;
x = 110;
y = 60;
}
new GuiButtonCtrl("ServerSelect_KingdomsDebug") {
profile = GuiButtonProfile;
text = "Kingdoms Debug";
width = 100;
x = 110;
y = 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;
x = 5;
y = 115;
}
new GuiButtonCtrl("ServerSelect_Era") {
profile = GuiButtonProfile;
text = "Era";
width = 100;
x = 5;
y = 150;
}
new GuiButtonCtrl("ServerSelect_Classic") {
profile = GuiButtonProfile;
text = "Classic";
width = 100;
x = 5;
y = 185;
}
new GuiButtonCtrl("ServerSelect_Valikorlia") {
profile = GuiButtonProfile;
text = "Valikorlia";
width = 100;
x = 110;
y = 115;
}
new GuiButtonCtrl("ServerSelect_Atlantis") {
profile = GuiButtonProfile;
text = "Atlantis";
width = 100;
x = 110;
y = 150;
}
new GuiButtonCtrl("ServerSelect_Delteria") {
profile = GuiButtonProfile;
text = "Delteria";
width = 100;
x = 110;
y = 185;
}
new GuiButtonCtrl("ServerSelect_NPulse") {
profile = GuiButtonProfile;
text = "N-Pulse";
width = 100;
x = 5;
y = 220;
}
new GuiButtonCtrl("ServerSelect_UnholyNation") {
profile = GuiButtonProfile;
text = "Unholy Nation";
width = 100;
x = 110;
y = 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;
x = 5;
y = 275;
}
new GuiButtonCtrl("ServerSelect_OlWest") {
profile = GuiButtonProfile;
text = "Ol' West";
width = 100;
x = 110;
y = 275;
}
new GuiButtonCtrl("ServerSelect_Atrius") {
profile = GuiButtonProfile;
text = "Atrius";
width = 100;
x = 5;
y = 310;
}

//Other Servers
new GuiButtonCtrl("ServerSelect_Reconnect") {
profile = GuiButtonProfile;
text = "Reconnect";
width = 100;
x = 110;
y = 310;
}
new GuiButtonCtrl("ServerSelect_Disconnect") {
profile = GuiButtonProfile;
text = "Disconnect";
width = 100;
x = 5;
y = 345;
}
new GuiButtonCtrl("ServerSelect_Close") {
profile = GuiButtonProfile;
text = "Close";
width = 70;
x = 145;
y = 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 (http://forums.graalonline.com/forums/forumdisplay.php?f=179).

xXziroXx
11-21-2008, 10:04 AM
I really hate your styling, but good job :)

cyan3
11-21-2008, 01:43 PM
Nice. For future note, completed scripts to share go in the Code Gallery (http://forums.graalonline.com/forums/forumdisplay.php?f=179).

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

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
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.

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:


function onKeyPressed(keychar, character)

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:


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