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?
How is the GUI assembled?
Moderator: OpenTTD Developers
Re: How is the GUI assembled?
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.
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.
Re: How is the GUI assembled?
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 techniquesjfs wrote: 14 Sep 2024 10:12 For an example, here's how the Generate Landscape window is defined: genworld_gui.cpp lines 71-193

It will of course be a patch, rather than an upgrade design to the original game.
- 2TallTyler
- Director
- Posts: 573
- Joined: 11 Aug 2019 18:15
- Contact:
Re: How is the GUI assembled?
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.
Who is online
Users browsing this forum: No registered users and 3 guests