Principia GTK dialogs, and the future

(Avatar)
ROllerozxa
Posted on 2025-03-18 13:19 Link

Ever since the beginning, Principia has been using GTK as a GUI toolkit for the more complex dialogs in the game on desktop. It was likely being used very early on in development when the game ran on Linux, and then became visible to regular players when the Windows version officially released around 1.4.

The choice of GTK for the dialogs was always seen as a quick solution until something better was implemented. But from the player's perspective it has always felt like a strange choice, as the dialogs end up being independent of the main window and generally felt out of place. In response to a (now deleted) comment on reddit, sdac wrote the following about it:

Right now we use GTK for configuration dialogs for the various objects in the game, and misc other dialogs. Our plan is to replace GTK with an OpenGL alternative, but GTK was a quick solution and easy to bundle with the exe on Windows. We had previous experience with GTK so that's why we picked it.

That plan of course never turned out as expected when the game was later abandoned in late 2014. But with the open source release, the plans to replace GTK were given another life.

Up until relatively recent developments with the game, we have always been using GTK2. While GTK3 was already released back in 2011, GTK2 was still very much current in 2012-2014. Now it is an abandoned relic that most want to drop sooner rather than later (even though it still sees use in the same way Python 2 is still used).

The natural thing to do would be to upgrade the game to use GTK3, which turned out to be a very large undertaking due to the large amount of compatibility breaking changes in version 3, but VOXEL just enough managed to do it. It was subsequently polished and made to work on Windows in a redistributable manner (which turned out to be a non-trivial endeavour).

But GTK was never a good choice for Principia. GTK3 is also very clearly not designed for our usecases. Neither was GTK2, but GTK3 is larger and more opinionated than GTK2 ever was. Just as an example, the regular colour picker dialog from GTK2 that we use for configuring colours in the game:

image.png

...Has been declared deprecated in GTK3, in favour of a new colour picker that is a toy in comparison.

image.png

I genuinely do not understand why they did this, but it doesn't really matter. There are some other features we use that have been deprecated with no proper replacement, and reimplementing them ourselves is not really worthwhile. We will not update to GTK4, nor will we update to GTK5. And until we have replacement dialogs using something else that is up to parity, we will stay on GTK3.

When discussing GUI replacements, one option that was brought up was Dear Imgui. It basically ticks all the boxes I wanted to see from a replacement, being lightweight and self-proclaimed "Bloat-free", integrates well into the Principia window and is also much more portable than GTK for any potential console endeavours. It is also very customisable and themeable, beyond the default blue theme that you probably recognise from somewhere else (a lot of games use Dear Imgui for technical development tools, modding tools and similar):

image.png

VOXEL subsequently worked on integrating Imgui into Principia's engine and began reimplementing dialogs using it in #138. I later ended up adopting it and recently got it merged into master behind an experimental compile option to build the game with it instead of GTK. Currently there are still a large amount of dialogs that are not yet implemented, tracked in issue #173, but one day the Principia GTK dialogs will finally become history.