In-between Devlogs #040-041 Episode II
October 30th 2020 by SDGNelson
Well, I did not expect to be writing this!
I have made some progress since the last post, for example adding the ability to switch between one-handed and two-handed weapon stances, but I will save those details for the next devlog. Almost all of my time this past month has been spent on the "Potential UI Rewrite" for Unturned mentioned in the "In-between Devlogs #040-041" post.
Since this has resulted in spending two months on Unturned rather than Unturned II, my plan is to commit as much of November and December to Unturned II as possible, and hopefully finish one of the "exciting" features like open-world enemies by the end of the year.
A "glazier" is a tradesperson who does glasswork. I decided this was a good name for the Unturned UI refactor, as the system would need to learn a new technique: uGUI
The goal here was to almost seamlessly convert the entire game UI from legacy IMGUI to uGUI, with a future conversion to UIElements in mind. Each uGUI replacement should look identical to or "better" than their IMGUI counterpart.
Thankfully the game was not directly using IMGUI calls for the most part, instead wrapping them in "Sleek" classes e.g. "SleekButton". These had a pretty deep hierarchy in some places, for example Sleek > SleekLabel > SleekButton > SleekButtonIcon > SleekButtonIconConfirm, and a lot of this hierarchy was illogical.
Now the base Sleek class is an interface, "ISleekElement", with sub-interfaces like "ISleekButton". Each glazier implements these interfaces, e.g. SleekBase > GlazierBase_uGUI > GlazierButton_uGUI implements ISleekButton. All the building-block elements are now only three layers deep.
One problem was sleek subclasses composed of other elements like "SleekWorkshopSubscriptionButton" and "SleekColorPicker". They could not be direct subclasses anymore because the base had to support switching between uGUI and IMGUI. I am happy with the end design here: they instead inherit from a "SleekProxy" class which implements ISleekElement, and forwards the interface to a per-glazier implementation.
There were a ton of one-off issues to resolve, like hardcoded IMGUI usage throughout the codebase or dependence on the global GUI state, and Molt managed to find plenty of bugs, but I think it is almost ready to go now. If you would like to try it out the "glazier" beta branch on Steam was made public today!