Mod developer of older games. These include: Ground Control II, Sins of a Solar Empire (Rebellion), Freelancer, FreeSpace 2 (SCP), Allegiance, Independence War 2, and some little stuff here and there. So far I've only made a release for GC2.

Latest Media

No images, videos or audio files have been added to this gallery. Join now to share media with the community.

Blog RSS Feed Report abuse Latest Blog: Qt is the chindōgu of GUI programming

0 comments by Flamecurse on Mar 10th, 2014

..or at least, its documentation is.

While I do enjoy modding games (especially ones with intuitive code and good debugging tools; Sins of a Solar Empire tops the list out of all the ones I've worked with) I have always kept my distance from the programming aspect of things. I've gleaned enough over the years to have a broad idea of how the inner workings of many games function, but have never had any desire to modify or replicate it.

When I started working on version 3 of my Reversal mod back in January one of the ideas I came up with was to make a small launcher program with a menu GUI to let you select which variation of the mod to play on. In older versions (and the original Terrans mod) the easiest way to do this was to hand out batch files and/or instruct people on how to configure their shortcuts. I figured a menu would be far more user-friendly, picked up a C++ IDE and went looking for some tutorials on how to get started.

Learning to program took a backseat to developing the mod, but near the end of development I found out that there was a C++ derivative called Qt. It built on what I had already learned and was much easier to use for creating GUIs. And it really is. Just not for a beginner.

There is a wealth of documentation on Qt, both official and unofficial. The official stuff is paradoxically informative yet unhelpful, a good reference for someone already familiar with the language but too nebulous to be useful for someone just getting started with it. It does a good job explaining syntax, but doesn't provide anywhere near enough concrete examples to show how it should actually be used. Parts of the language that claim to do something either require additional undocumented steps to function properly or have simply been broken or deprecated.

The unofficial documentation is whatever you can find through search engines and a good half of it - helpfully linked to by experienced programmers - is located on websites that either don't exist anymore or are so out of date that attempting to follow along only makes the problem worse.

My experience with getting a simple launcher menu to work amounted to a week of headache-inducing frustration scouring through search engine results and the official documentation. It was an effort to piece together the full picture on how to do things I would consider to be some of the most basic parts of the whole programming language: Create one window, press a button, get result. Not all parts of this were painful, indeed some things turned out to be well documented, exampled and painless to bring into effect.

On the other hand I lost two days just trying to figure out why any significantly-sized program would crash if started by the launcher: It turns out that Qt instructs any program it starts to run in the launcher's directory rather than the program's own. While I feel this is counter-intuitive, it wouldn't have been a problem if ANY of the examples, guides or documentation mentioned it. I was saved instead by some very helpful startup crash error messaging in one of the games I tried it with. Once I realized that I had to set the working directory manually, and figured out which methods to do so actually still worked the whole thing didn't take much time to finish. All I had left to do was pack it up and include it with the mod.

Well, the frustration wasn't over yet and neither were the headaches. See, there's two ways to make a program: Pack the library files it needs into the .exe or just include them with a package. These libraries are the bridge between an operating system and the programming language; In short they're needed so that the computer knows what to do with my code.

I was hoping to put everything into the executable and not worry about clogging up my mod users' system paths with these relatively obscure library files. Long story short, I'm just going to paraphrase someone I read on a YouTube tutorial's comments section: "Watching paint dry would be more productive than trying to learn how to statically compile Qt." I wish I had read that first, it would have saved me a lot of time.

By this point I had pretty solidly burned out on the whole project in general and the programming in particular, and I just wanted it over and done with. So I figured fine, lets just include the libraries with the mod and not worry about how inefficient or ugly it might look. So long as most or hopefully all of the users don't have any problems getting it to run I'm satisfied. And that brings me to the whole point of writing this blog:

The launcher I made is a mere 90 kilobytes. It would fit on an old floppy disc from the 80s several times over with room to spare. The libraries required for it to run are a mind-blowing 45 megabytes. That doesn't even include the ones Windows users should already have. 45MB for a menu and some buttons is beyond unreasonable, its outrageous. The size isn't even the worst of it, these are nine different .dll files taking up all this space. I would have thought the most basic, common functions would be in their own small library, and as you got to creating larger and more complex programs the libraries you'd need for all the specialist code would scale with it. Not so. Instead even the most bare-bones program with Qt requires all of these same libraries to run. Sprinkling all the different bits of basic code into a slew of different libraries just seems ridiculous to me for a default, out of the box configuration.

I'm sure there's a way to make it more streamlined but I'm neither experienced nor patient enough to try. Just getting to the point where changes could be made required downloading (and/or learning) Microsoft's version of the C++ tools (in addition to the ones I was already using) along with Python, Perl and Ruby and then getting them configured on my system. All to put the Qt source code together so I could go back to learning how it works, so I could maybe shrink the library sizes down or get it to static compile. Rube Goldberg could've invented less convoluted systems than this.

So if any of you are wondering why the entire mod package has ballooned in size, this is it (aside from all the new map and model fixes). But at least it works.

Post comment Comments
OrangeNero Sep 9 2014, 12:45pm says:

nevermind the problems :)
I read about using the .bat file and that works fine. You may delete my previous comments if you wish. review incoming! a bit late sry but still the mod is very much appreciated.

+1 vote     reply to comment
Flamecurse Creator
Flamecurse Sep 11 2014, 7:43am replied:

Glad to hear it! I'm ashamed that I even made that launcher in the first place, its atrocious. I've been meaning to give it the axe for a while now, and go back to just packing stuff in a .zip file as with the previous versions. Going to go do that now; I guess late is better than never!

+1 vote   reply to comment
OrangeNero Sep 9 2014, 12:18pm says:

I really love you blog btw. Some C&C modders including me started to write a review similar to yours xD its a small world

+1 vote     reply to comment
Flamecurse Creator
Flamecurse Sep 11 2014, 7:55am replied:

Nice to hear I'm not alone. I wrote & posted that rant after days of frustration. Afterwards I regretted it because a lot more people read it than I had expected! Looking back now, it doesn't seem quite so badly written after all.

Although it speaks volumes that I haven't written a single line of code since, even months later. :P

+1 vote   reply to comment
OrangeNero Sep 9 2014, 12:16pm says:

Hey may I ask?
I got the GOG version of GC2 and your mod wont start. I installed in the main GC2 directoy where also the game exe is. E:\GOG Games\Ground Control II

The error messages tells me:

This application failed to start because it could not find or load the Qt platform plugin "windows"

next message tells me that it terminates the process. Running the mod launcher as administrator did not help. Windows 7 btw.

+1 vote     reply to comment
Guest Apr 8 2014, 1:10pm says:

This comment is currently awaiting admin approval, join now to view.

Flamecurse Creator
Flamecurse Apr 12 2014, 5:57am replied:

That's been in the Reversal mod since the very beginning; Check out the Vindicator Centruroid in the final Viron missions or Skirmish mode. ;)

+1 vote   reply to comment
blahdy Dec 31 2012, 1:47pm says:

Great job with GC2!

+1 vote     reply to comment
GeneralKong Oct 2 2011, 1:07pm says:

you are awesome, i love the GC2 Reversal mod, brilliant work :)

+1 vote     reply to comment
Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Offline Since
Mar 26, 2015
Canada Canada
Member Watch
Track this member
Activity Points
17,840 of 500,830
3 members
Time Online
1 hour
Site Visits
Profile Visitors
2,133 (4 today)
Private Message
Send Now
Members Only
GeneralKong friends since Nov 27, 2011