GUI Scaling

Airships: Conquer the Skies
11 Feb 2017, 9:01 p.m.

A lot of the work I'm putting in for the next version of Airships relates to its interface. Be that improved module search in the editor, or the ability to mod in new map sizes and difficulty levels. One particular improvement that's long overdue is the ability to scale the user interface elements depending on the screen size.

When I started developing Airships, one of my goals was to make it playable on a resolution as low as 800x600 pixels. I also wanted crisp pixel graphics. This meant that where most modern games measure things in terms of relative size to the screen, Airships measures everything in pixels. The downside of this is that if your screen resolution is high, the user interface becomes rather... tiny. 12pt Monospace text looks crisp and readable at 800x600 but is unreadably small on a high-DPI screen.

With everything in the game based on pixels, smoothly scaling the user interface to be the same relative size for any resolution is out of the question. But I can make multiple versions of the GUI that are different sizes, and pick the most appropriate one. And the GUI metrics and appearance are already data-driven and moddable, so a lot of the work for doing this is already done.

I knew that radically changing the GUI scale was going to cause some problems. Places where I'd hard-coded sizes and offsets instead of calculating them properly. Assumptions based on things being approximately a certain size. The fastest way to find those places? Radically scale up the GUI and see where it breaks!

So that's what I did. I made a mod which scales up all user interface elements and metrics by a factor of two:

It's not actually that bad. And it's really obvious for me to now list and fix the problems. The incorrect calculation of button widths. The fixed width of the editor panel on the left. The incorrectly scaled right border of that panel. And so on. Once I've fixed all of them, the GUI will be fully capable of being any size it's told to be, and I can get to work on creating a system for multiple scales.