- Joined
- Sep 6, 2013
- Messages
- 6,742
GPAG - GUI Proper Application Guide
1. Introduction
GPAG defines uniform standards and conventions that we strive to apply in our GUI submissions.
The goal is to come on the same page for coding style, and to ensure clean and readable triggers.
The goal is to come on the same page for coding style, and to ensure clean and readable triggers.
2. Naming Conventions
2.1. Prefix
To avoid name collision each system is asked to define a PREFIX. The spell/system PREFIX is a constant name and should be resource descriptive. For example, if it's a fireball spell, the prefix might be "FIREBALL" or "Fireball". It's up to you, if you decide to write the prefix LIKE_CONSTANTS, or like VariableNames -- choose what you prefer. The PREFIX length should be at least 3-4 characters long, or even more, to ensure some uniqueness. Also, no matter what variables your system creates, all of them must be advanced by the PREFIX and an underscore _.
2.2. VariablesVariableNames start with a capital letter and also each new word is indicated by a new capitalitzed letter. The name itself must be descriptive for the variable's purpose. - What does this mean? When you work with temporary variables it's totally okay to give generic names, like: "Unit, String, Real, Point". However, when the variable usage is specified, then its name should be specified as well. So then, the name style changes from generic to specific. Here are examples:
The final variable name, combined with the prefix, looks like: PREFIX_VariableName:
FIREBALL_Caster
FIREBALL_Duration
|
|
The final variable name, combined with the prefix, looks like: PREFIX_VariableName:
FIREBALL_Caster
FIREBALL_Duration
2.3. Constant VariablesCONSTANT_VARIABLES are exclusivly written in capital letters and each new word is seperated with an underscore _ . Constant variables are only set once, usually after map loading, and the capital letters indicates to never change the variable's value. They are usually used to define some system default datas to get the system working.
The final variable name for constants, combined with the prefix, looks like: PREFIX_CONSTANT_VARIABLE.
FIREBALL_ABILITY_ID
FIREBALL_ORDER_ID
The final variable name for constants, combined with the prefix, looks like: PREFIX_CONSTANT_VARIABLE.
FIREBALL_ABILITY_ID
FIREBALL_ORDER_ID
2.4 TriggersThe same principle from variables applies to your triggers. The trigger's name will result in: PREFIX TriggerName.
The TriggerName should be descriptive, similar like variable names. Example names for triggers for a fireball spell:
The TriggerName should be descriptive, similar like variable names. Example names for triggers for a fireball spell:
FIREBALL Setup
-> here the user can find everything config related.FIREBALL Cast
-> this is the trigger with obivously "A Unit Casts" event.FIREBALL Periodic
-> this trigger runs periodically. Probably used for fireball movement.
2.5 Object DataFor object editor data, except for items and doodads, there exists a field named "Text - Editor Suffix". This field comes handy when your system uses custom object data, so you can use it to put in your PREFIX there. The idea behind is that the user will always be able to easily distinguish which object data belongs to which system or spell.
There are cases though, where it doesn't really make sense to use a object suffix. For example, when we import a "Fireball" spell and the prefix is "Fireball".
The name result in object editor would look like "Fireball (Fireball)", so you see that it doesn't really help anyone to distinguish data.
However, when the object editor data differs from the prefix, then using "Text - Editor Suffix" is indeed often helpful and asked for.
There are cases though, where it doesn't really make sense to use a object suffix. For example, when we import a "Fireball" spell and the prefix is "Fireball".
The name result in object editor would look like "Fireball (Fireball)", so you see that it doesn't really help anyone to distinguish data.
However, when the object editor data differs from the prefix, then using "Text - Editor Suffix" is indeed often helpful and asked for.
3. Documentation
Documentation is something good and each coder's friend. However, only when done correctly. We don't need to know uninteresting details like
"Here I set my integer variable." We can see that! Instead, it's much more important to understand why/for what you do something. We want to understand the purpose.
You usually don't need to document each single line, but instead, try to describe a whole code block in a concise manner, always when you think that some information could be helpful at that point. The bigger the code gets, the more benefits you will have from comments.
"Here I set my integer variable." We can see that! Instead, it's much more important to understand why/for what you do something. We want to understand the purpose.
You usually don't need to document each single line, but instead, try to describe a whole code block in a concise manner, always when you think that some information could be helpful at that point. The bigger the code gets, the more benefits you will have from comments.
4. Configuration
Configuration needs to be seperated from the system's core code. That's mostly done with putting all config-related parts into a seperate trigger.
Usually, things like:" Damage, Size, Durations, Radius, Effects, ..." are meant to be configured. The user doesn't care about the system's core code and he only wants to know what he should change to get the code properly working. Therefore, also the configuration always requires a proper Documentation to ensure that the user easily can follow and understand everything related.
Usually, things like:" Damage, Size, Durations, Radius, Effects, ..." are meant to be configured. The user doesn't care about the system's core code and he only wants to know what he should change to get the code properly working. Therefore, also the configuration always requires a proper Documentation to ensure that the user easily can follow and understand everything related.
5. Last Word
We prefer following GPAG, but at same time we won't blindly enforce it. So in case your personal standard sligthly differs from GPAG, it may be accepted as well, as long as clean and readable code is ensured. In case of uncertainties feel free to inquire about it with the respective moderators in Staff Contact or discuss it here in this thread.
Last edited: