Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-17-2009, 12:39 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
Post Guide: Naming GUI Controls

I've seen a lot of people doing this lately, and I wanted to let them know that it should be done differently in nearly all cases.

Rather than naming your GUI windows (and other controls) such as

Graal Script Code:
new GuiWindowCtrl("Window") {
  
// whatever

put part of the thing you're creating it in

Graal Script Code:
new GuiWindowCtrl("JailInformation_Window") {
 
// whatever

The reason this matters is because if you name your buttons things like "Button1" and "Close", which I've seen a lot of people doing, any script that has

Graal Script Code:
function Button1.onAction() {
  
triggerserver("gui"name"summonAllPlayers");

or any other function having to do with that button would be called, not just the script that created it.

Lesson's over, thanks for reading.
__________________
Reply With Quote
  #2  
Old 05-17-2009, 12:41 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Stickied.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 05-17-2009, 08:00 PM
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
I normally name the GuiWindowCtrl's or GuiBitmapBorderCtrl's after the main title for it.

I.e: JailInformation instead of JailInformation_Window

But everything below that uses your naming convention.

I.e Close button: JailInformation_Close
__________________
Quote:
Reply With Quote
  #4  
Old 05-17-2009, 08:12 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Personal preference.
__________________
Reply With Quote
  #5  
Old 05-17-2009, 11:52 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Chompy View Post
Personal preference.
I disagree, more like coding standard.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #6  
Old 05-18-2009, 12:12 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
Quote:
Originally Posted by fowlplay4 View Post
I normally name the GuiWindowCtrl's or GuiBitmapBorderCtrl's after the main title for it.

I.e: JailInformation instead of JailInformation_Window

But everything below that uses your naming convention.

I.e Close button: JailInformation_Close
The reason I would add the _Window is so I can, for example, close all those windows.

Graal Script Code:
for (temp.control GraalControl.controls) {
  if (
control.name.starts("JailInformation_")) {
    
control.destroy();
  }

without picking up JailInformation2_Window or whatever for a completely different window.

I see what you mean, though.
Quote:
Originally Posted by Chompy View Post
Personal preference.
It's not really personal preference. If you name all your windows "Window", you're going to have problems.
__________________
Reply With Quote
  #7  
Old 05-18-2009, 02:00 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Chompy View Post
Personal preference.
Actually, it is completely common sense. If we all had scripts using generic GUI object names like "Window", then everyone's scripts would break everyone else's scripts. At least having the name of the script or something means that the chance of collision is much less likely.

It's actually quite funny how many times I came across this when I was a GST; people's scripts not working because they did the exact same thing and used generic object names, only to later find that the same object name had been used elsewhere and that they were going to conflict.
Reply With Quote
  #8  
Old 05-21-2009, 12:02 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Chompy View Post
Personal preference.
I believe Chompy is referring to this:
Quote:
Originally Posted by fowlplay4 View Post
I normally name the GuiWindowCtrl's or GuiBitmapBorderCtrl's after the main title for it.

I.e: JailInformation instead of JailInformation_Window

But everything below that uses your naming convention.

I.e Close button: JailInformation_Close
... not to using descriptive names.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #9  
Old 05-21-2009, 12:09 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by LoneAngelIbesu View Post
I believe Chompy is referring to this:


... not to using descriptive names.
Indeed, forgot to quote Jerret. D:
Sorry.
__________________
Reply With Quote
  #10  
Old 11-23-2011, 04:53 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
Quote:
Originally Posted by khortez View Post
Why am I naming my Gui's anything?
So your GUI has an ID that you can use to manipulate/debug it in your code. Properly labeled code is also much more readable.

Labeled incorrectly you would not know which button is the close or open button:

MyForm_Button_1
MyForm_Button_2

Labeled and used correctly you have a much better idea:

MyForm_Button_Open
MyForm_Button_Close

This can be applied to many other object types or GUIs.
__________________
Quote:
Reply With Quote
  #11  
Old 11-23-2011, 05:00 AM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
Quote:
Originally Posted by fowlplay4 View Post
So your GUI has an ID that you can use to manipulate/debug it in your code. Properly labeled code is also much more readable.

Labeled incorrectly you would not know which button is the close or open button:

MyForm_Button_1
MyForm_Button_2

Labeled and used correctly you have a much better idea:

MyForm_Button_Open
MyForm_Button_Close

This can be applied to many other object types or GUIs.
thanks, now how would i make a custom profile?
Reply With Quote
  #12  
Old 11-23-2011, 05:33 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
Quote:
Originally Posted by khortez View Post
thanks, now how would i make a custom profile?
Search the forums and the wiki next time:
http://wiki.graal.net/index.php/Crea...g_GUI_Profiles
__________________
Quote:
Reply With Quote
  #13  
Old 11-23-2011, 05:51 AM
khortez khortez is offline
PrototypeX
khortez's Avatar
Join Date: Dec 2008
Posts: 91
khortez will become famous soon enough
I have, even seen that link you gave me just now. But there is always a possibility I misinterpreted what i've read.



Edit: If there was anyone that can say they have searched everywhere or at least thoroughly for answers, it'd be me.
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 11:17 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.