Where are all the good GUI libraries?

Started by
39 comments, last by MartinZhel 10 years, 11 months ago

I gave up on using 3rd party GUI's for games a while ago. They always make me feel like I'm trying to insert a square peg in a round hole. With games I need to have the power of my own custom code and I don't like modifying other peoples code, most of which does 99% more than what I require.

What I've done is basically just bite the bullet and create a few very simple and lightweight classes that are loosely based on the Visual Basic/ C# event model. Event delegation and the use of partial classes are key to this design.

IMO, this is a proven GUI general use design model and has been around since the inception of VB in the 90's. Of course, I don't need XML or a scripting language for what I'm doing, and I prefer to keep most that in code anyway, but I guess I could always serialize my GUI objects if I have the need.

Advertisement

I don't think that GUIs are all that hard to write, but it's probably a bit of a thankless task to write them.

Simplui worked pretty well after only a couple of months development - at some point I'd love to find the time to build a full UI toolkit along similar lines.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Simplui worked pretty well after only a couple of months development - at some point I'd love to find the time to build a full UI toolkit along similar lines.

I did actually use Simpleui for a while (thanks!) but replaced it with kytten for some reason that I have since forgotten. (Possibly the absence of a list view/grid controls? I remember trying to fake a grid with nested VLayout/HLayouts.) I think Simpleui was the most sane-looking of the smaller GUI toolkits I've come across. Perhaps I should try extending that.

What I've done is basically just bite the bullet and create a few very simple and lightweight classes that are loosely based on the Visual Basic/ C# event model.

I'd be reasonably happy to do that, but unfortunately, trying to implement any kind of scrollable region when your graphics API doesn't allow you to clip one object's rendering to an arbitrary rectangle is quite awkward. (I'm looking at you, Unity.) Some people have hacked it with a custom clipping shader but that is out of my realm of expertise.

What about Java... you can use the SWING GUI components in your UI.

Do you folks like coffee?

I think Simpleui was the most sane-looking of the smaller GUI toolkits I've come across.

It was/is. Unfortunately, there were a number of things about GUI layout and measure that I hadn't yet learned at the time - controls like grids and lists would be much simpler if there was proper support for scrolling, among other things.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

What about Java... you can use the SWING GUI components in your UI.

Does that even qualify as UI design.. they look like little rectangles with ugly blue gradients inside. It might be fine for tiny utility programs or applications where a nice interface isn't important, but for games where you need complete control over your graphical user interface, I think SWING doesn't cut it. At least, last time I checked... yes, yes, I know.. it's portable.. but still..

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

I always just roll my own GUI Library with features that are specific to each game. I should probably just write one that can be used across all my games, but to lazy fo' that.

GUI's for me are the most trivial task in game development, it doesn't take a long time providing you don't need super complex things.

The only real problems I have come across is scrolling.

I am left to suspect (partly from experience) that it may be that GUI is one of those things it is difficult to really get "right".

I really don't think this is the case. We have several reasonable GUIs that exist for C++ apps and they look pretty good. We have decades of experience all the way back from Smalltalk through MFC up to Qt and WxWidgets about how GUIs can be written and made effective (to a greater or lesser extent), and a large number of developers now working with HTML/CSS/Javascript to create and use GUIs. In theory the only difference between these GUIs and game GUIs is the rendering aspect, which itself can often be abstracted away, but for some reason few people are attempting to get this right.

this may not necessarily be because GUI libraries are easy to get right, but because many of the particularly awful ones tend to be quickly forgotten (and never gained much ground within the developer community).

what most people tend to see are not necessarily all the things which were ever written, but more the things which were "good enough" to gain widespread adoption.

if a programmer goes and writes something particularly awful, often no one else will use it either, and maybe soon enough the original developer will abandon it, and to the larger world, it appears as if it had never existed.

what generally does end up being seen, are those things which were generally good enough that people started using them.

granted, this isn't necessarily unique to GUI libraries though...

Can I construct a complex dialogue dynamically through code? If not, it's worthless, because static dialogues are quite easy to implement without a GUI system just by drawing some sprites and looking to see where the mouse clicks go.

Hmm, so dynamically creating dialogue boxes, do you mean you store a large set of possible text responses and the dialogue GUI can dynamically resize itsellf based on the amount of text? Let's say the dialogue had anywhere from 0-5 clickable response lines and those spawned different dialogues, maybe ultimately leading to a dialogue with a reward in it (completed a quest for example). This shouldn't be too difficult to do as long as a flexible dialogue prefab is constructed and then you call it's creation with the parameters you want in your game code. I haven't gotten far enough in my own game to do this yet (create a dynamic dialogue system), but I will definitely make sure I consider all the possible use cases.

Can it layout objects for me in lists and grids? If not, it's going to be a nightmare to use for any complex data. I need to be able to push an arbitrary number of objects into a container and have it position them for me - otherwise, I may as well just render them directly myself.

Yea this definitely be doable with a panel GUI object. My editor started out as a world map generator, so it can randomly generate say 1,000 connected solar systems with the ability to highlight a path between any 2 given systems using a BFS algorithm using the GUI hierarchy, each with randomly generated tooltips, names, hoverstate animations, etc all within a pannable, zoomable parent panel. The way entities are related to eachother spatially within a panel parent should be highly configurable out of the box. So to create a grid like inventory system GUI for example, the children entities would have a 90 degree step and 0 degree random variation.

Can it handle scrolling areas? This is the main thing that stops me writing my own GUI in Unity - since there is no access to scissor rectangles I can't implement scrolling areas myself. NGUI have got around this with custom shaders, which is a fun hack, but they obviously have no clue how to handle input management properly so that's a non-starter.

So, a scrollable panel parent should either be able to dynamically resize itself or force a dynamic rescaling of the children objects to fit a fixed parent size. The input system is all based on one ray cast to determine where your mouse is currently located and which actions are available depend on the GUI prefab your on. I'm pretty surprised this requires custom shaders in NGUI. Are the items you want to fit within a scrollable parent all different sizes or something?

Can I change the state of the GUI easily? HTML has this 100% right - if you want to change something, it's one simple function call to find it, then one property access to change it. No need to hook up signals and slots. No need to manually traverse the tree of elements. No need to pre-create the element so that you can hold a reference to it and change it later.

Basically I currently have it as GameObject.Find to get an arbitrary reference, the editor forces a naming convention such that the any given can be constructed using prefixes of the parent objects, to ensure that an arbitrary hierarchy object has a unique name. Problem is the names can get pretty long, I might need to rethink this design later. Once you have a reference to it, you can cast it to the type of GUI object it is to access the data. Additionally, you will also be able to add, delete, get, or set arbitrary data for any GUI object.

Can the GUI effectively tell me when things happen? Usually this is done with callbacks attached to events on controls. Some GUIs like to run in immediate mode which makes life much harder since in most languages you only get one return value from a function, meaning each control can only really signal one type of event.

This should be easy enough :)

Thanks for the ideas, this is a pretty complex, but fun project :)

Guess I'm already late for the comment, but:

I'm half-tempted just to go for HTML5 because at least HTML does a decent job of GUIs - but then is a typical HTML GUI compatible with HTML5 gaming libraries? Seems like they render everything onto a canvas so I'm guessing the answer is no.

You could always overlay the GUI on top of the canvas without much issue and let the browser handle that =P

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

This topic is closed to new replies.

Advertisement