I can't help but wonder how much game devs would benefit from a UI framework. Laying out UI elements in code just seems so 90's. While his transformations surely improved the code--and actually start making it resemble a typical UI framework--markup languages take it to a whole new level of compressed clarity. Like XAML:
Here's a video from the same author about immediate-mode GUIs, which are a conscious effort to avoid that sort of UI design.
In your case you may have simplified the code that creates the UI, but you aren't showing the code that maps the string "do_auto_snap" to the function that performs the action.
In your case you may have simplified the code that creates the UI, but you aren't showing the code that maps the string "do_auto_snap" to the function that performs the action.
Because the framework does that for you at compile time.
What we really need is a way to interleave retained mode UI surfaces with immediate mode rendering surfaces. There are various frameworks that support that but I suspect none are a good fit for cross platform game development.
I wonder if this guy advocating purely immediate-mode GUIs has ever worked on a substantial UI before (i.e., not one that looks like it was made by an engineer, and that is more complicated than a game UI). You quickly benefit from design tools.
I am not a great person to argue about retained vs immediate mode UIs, but as an anecdote: I just made a UI in Qt which is effectively a property sheet: editing a bunch of properties of different types. So for every property, I had to create the retained mode controls programmatically and hook them up. Qt did some very nice stuff for me automatically (minimal layout hassles, yay!), but then I spent a bunch of time mirroring values stored in different places. The underlaying data could change, at which point I had to change the controls' value, or a control could change and I had to mirror the value to the underlying value. And when there are two controls for the same value (text field and slider for instance), I need to avoid making my changes to one control trigger a signal and notify me again for the other control when I push the change to it. And to enable/disable these controls, I need to keep them all in a list so I can go find them and turn off their 'enabled' state. All of those problems go away in a proper immediate-mode implementation, where there isn't a separate piece of state I have to spend a lot of code to maintain.
Almost all AAA developers use Autodesk Scaleform, which is built on Flash. And yet they continue to find new and innovative ways to fuck that up. Worst case I've seen is where everything was rendered by Flash, but managed by C++, meaning elements didn't know if they had focus and input had to be handled by the game instead of Flash.
The best UI framework with a markup language I've used is Qt, but I wouldn't build a game with it. Designers need more than just "a button", they need buttons that dance, bounce, pop in and out of view, are animated or are just pretending to be a button. Scaleform and specifically Flash gives them that freedom, because a "button" is nothing more but a movieclip with a predefined list of animated "states".
I don't get why Scaleform is so popular. It seems that it would be shunned for being based on a web ui technology. The performance obsessed gaming community I would think would throw it out in favor of making their own uis. What do you really need more than polygons and a little animation. Isn't that the bread and butter of gaming dev work? Checkboxes are just items with two states, and scrollbars dont have to be there, everything can be paged...
Worst I've seen was Tribes Ascend, Scaleform for all in game ui. If you disabled everything, you gained about 20 fps, but you couldn't play the game.
A couple of things make Scaleform the best solution.
Tools, tools and tools. You can make the best UI toolkit ever, but artists have to use it as well. Flash allows the creation of art assets, animating them and scripting them. You can say to a UI artist "make me a button" and she'll be able to draw it, test it and hopefully deploy it in the game.
A lot of these types of decisions can be traced back to tools. Why do gamedevs write C++ in Visual Studio? Because it's the best tool for C++.
And Scaleform is surprisingly fast. It has a custom-built VM for the scripts and it renders everything using textures and primitives. Unlike Flash, which renders in software, which is why it's well-known for its poor performance.
What do you really need more than polygons and a little animation.
Turns out, you need a lot. You need a list that can render an arbitrary amount of items that needs to be filled from the game. You need a checkbox that responds to mouse input. You need a dialog box that steals focus from underlying elements. I would say 40% of my work involves wrestling with focus and input issues. It is always a headache.
4
u/WhyComplicateThingz May 28 '14
I can't help but wonder how much game devs would benefit from a UI framework. Laying out UI elements in code just seems so 90's. While his transformations surely improved the code--and actually start making it resemble a typical UI framework--markup languages take it to a whole new level of compressed clarity. Like XAML:
This allows styling and layout to be nicely decoupled from hit-testing and behaviors.