- Joined
- Jun 12, 2010
- Messages
- 413
[GUI-Friendly] MUI Engine v2.0.0
This system facilitates the generation of unique index numbers for the creation of MUI spells and systems. It uses a hashtable to allow for practically limitless indexes, but it also allows users to create unique recycling arrays using Child Hashtables. Thus, you can use this system along with warcraft 3's arrays (which are limited to 8192 indexes, from 0 to 8191).
The main reason for this system's existence is to provide an easy platform for the creation of other GUI systems and to simplify MUIness for simple applications. However, spell makers that want something more modular than Bribe's Spell System may also find this useful, though I still recommend you try using Bribe's Spell System when possible.
How to Import:
Using the System:
This is the core of MUI. Using this method, you will generate a unique index for whatever you need which will be stored in the GMUI_Index variable. Using this method, you may end up getting indexes that are larger than 8191, thus it can be unsafe to use this index as array indices.
GUI-only method:
For systems and spells that use their own recycle index, simply use a variable with a generated Recycle Key instead of the number 1 for the value of GMUI_RecycleKey. Examples are included in the test map.
This is as important as generating unique indexes. When you are done with an index and are not going to use it anymore, you should recycle it with this method.
Note: NEVER recycle indexes that are not being used.
GUI-only method:
A Recycle Key is used for specific cases in which you need to make sure that the indexes will not surpass the limit of 8191 for an array. Most complex systems and spells will want their own recycle key, which can be generated like so:
GUI-only method:
For most intents and purposes, a Recycle Key will not need to be destroyed. However, if you don't need to use a certain Recycle Key anymore, you can free it up with the following method:
Note: NEVER destroy Recycle Keys that are not being used.
GUI-only method:
This is only useful for JASS scripters who are intializing their systems from a trigger initialization function. GMUI includes a function called GMUI_Initialize that initalizes the system if it has not already been initialized. This is useful since you cannot declare dependencies like in vJASS.
Below you will find an example of how to initalize your own system, using my other system, GIUL, which depends on GMUI, as an example:
Test Map:
The Test Map has 3 coded unit indexers, each one working separately for Footman, Rifleman and Knights. Thus, each unit indexer recycles indexes separately and has its own Recycle Key. Check out the triggers to see how Recycle Keys work.
Updates and Version History:
This system facilitates the generation of unique index numbers for the creation of MUI spells and systems. It uses a hashtable to allow for practically limitless indexes, but it also allows users to create unique recycling arrays using Child Hashtables. Thus, you can use this system along with warcraft 3's arrays (which are limited to 8192 indexes, from 0 to 8191).
The main reason for this system's existence is to provide an easy platform for the creation of other GUI systems and to simplify MUIness for simple applications. However, spell makers that want something more modular than Bribe's Spell System may also find this useful, though I still recommend you try using Bribe's Spell System when possible.
Recycle Keys:
A recycle key is a unique number associated with different recycling arrays. For example, while the system will not generate 2 as an index of Recycle Key 1 as long as that index has not been freed up for Recycle Key 1, it will generate 2 as an index of Recycle Key 2 if that index is not being used. You can think of this as two dimensional arrays. If [1][2] exists, then the system will not generate [1][2] again. However, it can still generate [2][2].
Most complex systems and spells that employ arrays will need their own unique Recycle Key, thus the system allows them to easily generate it without conflicting with other systems. However, for many purposes, users can just use the generic Recycle Key: 1.
1: This is a generic index array, for when you don't care how many instances there will be.
How to Import:
- Open World Editor. File -> Preferences -> Tick box for "Automatically create unknown variables (...)"
- Copy the text in this map header into the map header of your own map
- Copy the trigger category "GUI MUI Engine" into your map
- Done!
Get Unused Index
Recycle Used Index
Create Recycle Key
Destroy Recycle Key
Initialization
This is the core of MUI. Using this method, you will generate a unique index for whatever you need which will be stored in the GMUI_Index variable. Using this method, you may end up getting indexes that are larger than 8191, thus it can be unsafe to use this index as array indices.
GUI-only method:
-
Set GMUI_RecycleKey = 1
-
Set GMUI_Index = 0
-
Trigger - Run GMUI Main <gen> (checking conditions)
-
Actions
-
Custom script: set udg_GMUI_Index = GMUI_GetIndex(1, 0)
-
For systems and spells that use their own recycle index, simply use a variable with a generated Recycle Key instead of the number 1 for the value of GMUI_RecycleKey. Examples are included in the test map.
-
Set GMUI_RecycleKey = MyRecycleKey
-
Set GMUI_Index = 0
-
Trigger - Run GMUI Main <gen> (checking conditions)
-
Actions
-
Custom script: set udg_GMUI_Index = GMUI_GetIndex(udg_MyRecycleKey, 0)
-
This is as important as generating unique indexes. When you are done with an index and are not going to use it anymore, you should recycle it with this method.
Note: NEVER recycle indexes that are not being used.
GUI-only method:
-
Set GMUI_RecycleKey = 1
-
Set GMUI_Index = IndexYouWantToRecycle
-
Trigger - Run GMUI Main <gen> (checking conditions)
-
Actions
-
Custom script: call GMUI_RecycleIndex(1, udg_IndexYouWantToRecycle)
-
A Recycle Key is used for specific cases in which you need to make sure that the indexes will not surpass the limit of 8191 for an array. Most complex systems and spells will want their own recycle key, which can be generated like so:
GUI-only method:
-
Actions
-
Set GMUI_RecycleKey = 0
-
Trigger - Run GMUI Main <gen> (ignoring conditions)
-
-
Actions
-
Custom script: set GMUI_RecycleKey = GMUI_CreateRecycleKey()
-
For most intents and purposes, a Recycle Key will not need to be destroyed. However, if you don't need to use a certain Recycle Key anymore, you can free it up with the following method:
Note: NEVER destroy Recycle Keys that are not being used.
GUI-only method:
-
Actions
-
Set GMUI_RecycleKey = KeyYouWantToRecycle
-
Trigger - Run GMUI Main <gen> (ignoring conditions)
-
-
Actions
-
Custom script: call GMUI_DestroyRecycleKey(udg_KeyYouWantToRecycle)
-
This is only useful for JASS scripters who are intializing their systems from a trigger initialization function. GMUI includes a function called GMUI_Initialize that initalizes the system if it has not already been initialized. This is useful since you cannot declare dependencies like in vJASS.
Below you will find an example of how to initalize your own system, using my other system, GIUL, which depends on GMUI, as an example:
JASS:
function GIUL_Initialize takes nothing returns nothing
if udg_GIUL_Hashtable == null then
//Initialize dependencies
call GMUI_Initialize()
//Initialize Hashtable
set udg_GIUL_Hashtable = InitHashtable()
//Get Recycle Key
set udg_GIUL_RECYCLE_KEY = GMUI_CreateRecycleKey()
endif
endfunction
Test Map:
Command | Action |
kill | Kills and removes from the game your selected units. |
The Test Map has 3 coded unit indexers, each one working separately for Footman, Rifleman and Knights. Thus, each unit indexer recycles indexes separately and has its own Recycle Key. Check out the triggers to see how Recycle Keys work.
Updates and Version History:
v1:
1.0.0 > Initial Release
2.0.0 >
Upcoming:2.0.0 >
API change: all functions now include "GMUI_" prefix.
Added GMUI_Initialize function
Added GMUI_Initialize function
|
Attachments
Last edited: