GUI nightmares

Started by
16 comments, last by Dawoodoz 9 years, 5 months ago

There's just no way to write a fully configurable and flexible GUI system without having to specify a lot of data, either by hand or by config file. So don't feel too bad.

First, look at the new JavaFX stuff for GUIs that just came out with Java 8. They had to rewrite EVERYTHING from Swing because it no longer worked. So GUI code is hard.

I am of two minds on this one. I've coded up lots of GUIs in my career, from Win32, MFC, all the way to Scheme, Java, and Javascript Web 2.0, and I have experienced so many little issues and work arounds that I know trying to create your own GUI APA is waste of time. There are too many details to work out.

However, that's not for a game, that's for an API used by a million people. For a game, if you don't roll your own, then your GUI will look just like everyone else. Creating your own controls could lead to some awesome innovation. But as pointed out above, if you try to make a super flexable, robust, easy-to-use, well-documented GUI library that can be used by millions of beginning programmers to create amazing GUIs, you'll run out of time.

Long story short (too late), don't worry if it looks bad. That means you didn't over-engineer it, which is a good thing.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

Advertisement
I don't get the overemphasis regarding code structure. Sure this code isn't exactly an example of how beautiful code looks like but if it works, is tailored to exactly what you need and you and/or your coworkers see through it - well why not?

Approx. 22 year ago, I created simple GUI. http://uloz.to/xbdamBRj/scantybasic-zip

Yes, I know what it is. On the other hand. GUI is useful smile.png

I'm also writing the GUI for my game from scratch. I would recommend you to use XML to create your windows/panels instead of pure code. That helped me to separate the code to create a new window into different modules while parsing the XML. I use TinyXML2.

Yep, that helped a lot for me too. I was so crazy though, and wrote my own XML-Parser. No reason, just madness (and probably a bit learning-factor). I also gotta say that one thing that probably makes my gui a little more complicated than it should be, is that I'm not only using it for the game, but also for the editor/toolchain. When you want to do somthing like I did in the attached screenshot, it adds some additional levels of complications in comparison to when you "only" need some simple game overlays, I assume.

Yes it seems a lot more complicated than mine. However, if I were to create a level editor (not applicable to my game) I think I would use an already existing GUI, it's not so easy to find a OpenGL or DirectX GUI, though. Because since the editor is ¨not part¨ of the game it wouldn't matter if the GUI is ugly and already used in other projects, that could actually be a point in your favor because people may be already used to that aspect or feeling of the GUI. But... I don't know, I guess that if you implemented your own XML parser is because you're using it as a learning process so it's better to do everything by yourself. biggrin.png


Yes it seems a lot more complicated than mine. However, if I were to create a level editor (not applicable to my game) I think I would use an already existing GUI, it's not so easy to find a OpenGL or DirectX GUI, though. Because since the editor is ¨not part¨ of the game it wouldn't matter if the GUI is ugly and already used in other projects, that could actually be a point in your favor because people may be already used to that aspect or feeling of the GUI. But... I don't know, I guess that if you implemented your own XML parser is because you're using it as a learning process so it's better to do everything by yourself. biggrin.png

Yeah, if I were to go back and start over I would probably use an existing gui system too. Not to say that I can't work with my own gui and that there isn't some neat stuff that probably ties in better to my overall system than an external libary would, but there is almost at least one "WTF? why is it doing that (again)???" every day biggrin.png . But you said it right, its all part of a giant learning process, for that reason I've decided to enroll almost everything on my own. But it really paid off, I've been learning so much let alone via the gui system about decoupling systems, and (ironically, looking at my first post) writing cleaner and more maintainably code. My old projects always died after a few months because the code became too messy for me to work with, this engine I'm working on for about 1 1/2 years, and still going. So people are right in a way that writing your own big guid lib for something like editor is a waste of time, but only unless for the learning experience, that is.

Eh, your code actually looks pretty slick, considering you're doing GUI programming. Also, the "established libraries" for GUIs are notoriously bulky, so hand-rolling a solution is actually a viable option in this case.

A lot of folks do not like "losing creating control" by using 3rd party GUI libraries ...

... that and a lot of free libraries have almost no good documentation that comes with it.

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

In my own table-driven programming language (Steamroller), I would just put all the values and method pointers in a table and read it from a tiny loop. I just haven't been able to connect the language to a graphics API yet.

This topic is closed to new replies.

Advertisement