How is the GUI assembled?

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
User avatar
Nathkel
Engineer
Engineer
Posts: 24
Joined: 29 Mar 2023 17:23

How is the GUI assembled?

Post by Nathkel »

I will be posting some GUI overhaul suggestions in another thread, but I'm curious, after doing a search of this website and finding so little information on the subject, how is OTTD's interface graphics drawn? Is it from an external library? Or are they game-specific drawing routines for OTTD?

I've read in a couple of posts about "blitter" drawing and SDL, but those don't mean anything to me. Does OTTD use something to the equivalent of turtle drawing, or simple line, rectangle, and point coloration routines? Obviously it used some bitmap pasting for the font. But anything else?
User avatar
jfs
Tycoon
Tycoon
Posts: 1867
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: How is the GUI assembled?

Post by jfs »

The GUI in game is a custom system. There are various functions for drawing basic parts of it like rectangles with raised or lowered effects, filling rectangles, and a bunch more. All the symbols on title bar buttons (close, pin, etc) are handled as special font characters in the private use area.

Most windows are laid out using a constraint-based nested layout system, to allow them to scale to fit the content, selected font size, texts having different lengths in different translated languages, and just plain user resizing of them.
For an example, here's how the Generate Landscape window is defined: genworld_gui.cpp lines 71-193

The drawing uses a dirty rectangle system, so only the parts of the screen that are marked as needing updates are actually redrawn.

Game world views are specially handled, and drawing GUI elements on top of game world views is poorly supported the way things are implemented right now.

There is no support for alpha channel transparency, except for in 32 bpp sprites. Most of the game is still designed around having 8 bit (256 color) rendering.
Bitmap graphics can only be loaded in from the GRF format, there isn't any convenient way to load graphics from standard file formats (like PNG files) directly in and draw on screen.
User avatar
Nathkel
Engineer
Engineer
Posts: 24
Joined: 29 Mar 2023 17:23

Re: How is the GUI assembled?

Post by Nathkel »

jfs wrote: 14 Sep 2024 10:12 For an example, here's how the Generate Landscape window is defined: genworld_gui.cpp lines 71-193
Ok, good. Simple drawing in-house instructions. I cant create code but i can follow it, and it looks like even a first year programmer could assemble a new GUI — IF he had a good consistent design to work with. I'm not good with programming but I am good with interface design, so I'm working on a complete interface overhaul using ottd code that's already present, but staying true to the original concept. (Maybe a few new techniques 8) ....)

It will of course be a patch, rather than an upgrade design to the original game.
User avatar
2TallTyler
Director
Director
Posts: 573
Joined: 11 Aug 2019 18:15
Contact:

Re: How is the GUI assembled?

Post by 2TallTyler »

I think you'll find that we are not tied to the original game, if changing the user interface is an improvement to the player experience. I'd love to see some screenshots of what you have in mind.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 3 guests