- Joined
- Sep 26, 2009
- Messages
- 9,534
Hi all.
I've been working on a project getting all my major GUI systems compatible with vJass without breaking ANY of the GUI compatibility that they are known for. Stuff like Table just cannot be ported to GUI, but the rest certainly can.
However, there's been a pretty big hurdle I've been trying to work against, which is to do with the initialization priorities in GUI VS what JassHelper compiles.
Problem 1: GUI InitTrigs run after ALL vJass systems have initialized. If a system like GUI Unit Event initializes from a vJass initializer, any preplaced units will not fire off any of the "UnitIndexEvent" triggers that GUI might use.
Problem 2: vJass Initializes before the "InitGlobals" line is called. This means that if I use a GUI Configuration trigger (like in Damage Engine or Spell System) from a vJass initializer, all of those configurable udg_ values will be overwritten (not to mention the gg_trg values will also be overwritten, because they haven't been created yet).
Possible solution to problem 1) Force GUI users to use an interface that requires them to run their triggers manually from a bulk trigger. A very annoying solution which doesn't addess Problem 2 at all.
Possible solution to problem 2) Force vJass users to call to a function that basically makes them "wait" until the GUI stuff has initialized. This has the problem of timing - should I then call trigger from an InitTrig, or from a Map Initialization trigger? If it's the former, it's prone to errors with problem 1. But if it's the latter, any Map Initialization triggers might not have their shit together yet (in case they depend on those systems).
So I've found a weird "solution" to both problems, by using the "inject" feature with replacing every possible GUI Initialization function call wrapped in "ExecuteFunc" so as to not cause syntax errors. I then force the initialization to cooperate with both GUI and vJass as well as possible. This then introduces, however, a problem where InitTrigs will initialize before vJass - but this isn't a problem in GUI - only in custom vanilla JASS script. The solution is for any JASS initializer using an InitTrig to just switch to a scope/struct/library initializer.
So, here's what I've got (along with a cute description):
Of course the user has to then extract any kind of Map Options that get killed by the //! inject call, so I'm going to offer mapmakers the self-service of me tooling their Map Options into raw JASS for them to circumvent that issue.
I've been working on a project getting all my major GUI systems compatible with vJass without breaking ANY of the GUI compatibility that they are known for. Stuff like Table just cannot be ported to GUI, but the rest certainly can.
However, there's been a pretty big hurdle I've been trying to work against, which is to do with the initialization priorities in GUI VS what JassHelper compiles.
Problem 1: GUI InitTrigs run after ALL vJass systems have initialized. If a system like GUI Unit Event initializes from a vJass initializer, any preplaced units will not fire off any of the "UnitIndexEvent" triggers that GUI might use.
Problem 2: vJass Initializes before the "InitGlobals" line is called. This means that if I use a GUI Configuration trigger (like in Damage Engine or Spell System) from a vJass initializer, all of those configurable udg_ values will be overwritten (not to mention the gg_trg values will also be overwritten, because they haven't been created yet).
Possible solution to problem 1) Force GUI users to use an interface that requires them to run their triggers manually from a bulk trigger. A very annoying solution which doesn't addess Problem 2 at all.
Possible solution to problem 2) Force vJass users to call to a function that basically makes them "wait" until the GUI stuff has initialized. This has the problem of timing - should I then call trigger from an InitTrig, or from a Map Initialization trigger? If it's the former, it's prone to errors with problem 1. But if it's the latter, any Map Initialization triggers might not have their shit together yet (in case they depend on those systems).
So I've found a weird "solution" to both problems, by using the "inject" feature with replacing every possible GUI Initialization function call wrapped in "ExecuteFunc" so as to not cause syntax errors. I then force the initialization to cooperate with both GUI and vJass as well as possible. This then introduces, however, a problem where InitTrigs will initialize before vJass - but this isn't a problem in GUI - only in custom vanilla JASS script. The solution is for any JASS initializer using an InitTrig to just switch to a scope/struct/library initializer.
So, here's what I've got (along with a cute description):
JASS:
// The next lines of code exist because vJass initialization is an absolute pain in the ass
// So this overwrites all calls in "main" instead of adding to them, so I have to use ExecuteFunc
// I'm pretty sure I covered all the possible initializers which would be added to "main"
// Any settings done in the "Map Properties - Options" will be overwritten, but there is a way to save them
// Contact Bribe @ Hiveworkshop.com if you need any help or run into issues implementing this into your map.
//! inject main
call ExecuteFunc("InitSounds")
call ExecuteFunc("CreateRegions")
call ExecuteFunc("CreateCameras")
call ExecuteFunc("CreateAllDestructables")
call ExecuteFunc("CreateAllUnits")
call ExecuteFunc("CreateAllItems")
call ExecuteFunc("InitUpgrades")
call ExecuteFunc("InitTechTree")
call InitBlizzard()
call ExecuteFunc("InitGlobals")
call ExecuteFunc("InitCustomTriggers")
//! dovjassinit
call ExecuteFunc("RunInitializationTriggers")
//! endinject
Of course the user has to then extract any kind of Map Options that get killed by the //! inject call, so I'm going to offer mapmakers the self-service of me tooling their Map Options into raw JASS for them to circumvent that issue.
Last edited: