The patch is finally complete, it works perfectly for all systems as all colour stuff is only called after simgraph_init().
I decided that there's no need to keep the fixed colours as PIXVAL, after all they are fixed. The whole idea of the project was to have good colours for themes and not fixed colours. Time for a review of the whole thing:Does it bring anything to pak maintainers?
Yes, at least if they are working with themes. Now the colours defined in the themes.tab will be much closer to what will show in the game. With the current buggy code the colours are confined to 224 colours, which is a subset of the 8bit palette. So even if you define full black (0x000000) in the theme you only get brown.Does it bring anything to users?
Of course, as I said above now themes can have real colours and not only 224. This will give better themes to the users.Does it bring any incompatibilities?
No, current paksets and themes will continue to work, though themes will look better. You can still use hex colours or the 8 bit index numbers, both still work. The settings file will be automatically updated.
There are though, two parameters that have died and two that took their place.front_window_bar_color
are obsolete now. They won't be read any more, as their info is useless with this patch.
Instead now you will be using bottom_window_darkness
, this will define the percentage of black over the titlebar of background windows. Using 0 will give no effect at all, while 100 will just make the titlebar fully black. You can use any value between those values, though the values 25, 50 & 75 have a code shortcut and execute faster (though it may not be so significant).
And the other new parameter is default_window_title_color
, this one won't change the highlight of the titlebar, instead it defines the colour of the titlebar for windows that don't have special titlebar colours. So now the theme can define which will be that colour, which for years has been orange. Finance windows and other windows that show the player colour will still display the titlebar in the player colour, but now you can define the default colour of the titlebar. I know Leartin will like it Does it bring anything else to the code?
It will work even with 24bit or 32bit colours, RGB, BGR, ARGB or any other combination. The functions are already done in a way they won't need change.Quirks of the code
- COLOR_VAL is dead, colours are now PIXVAL which is the colour in the system format. Currently as uint16.
- PLAYER_COLOR_VAL has become FLAGGED_PIXVAL, as the previous name made no sense after the introduction of transparency flags. It's uint32 and it's simply a PIXVAL with flags in the upper bits [16~23] 0x00FF0000
- Some colours in simcolor.h are in indexed format, while others are already as color_idx_to_rgb(X), this is to make sure colours defined as globals work as one can't have the system format while the graphic system has started (at least on SDL1)
- All functions are now their _rgb versions, the non-rgb version were removed as they are useless.
- The colours that are saved in settings.xml are saved as RGB888, this is to make the file compatible between systems. Saving them as the system format would kill the portability of the user settings. That's why those are duplicated, one that holds the colour as the system format and another as RGB888, identified with the _rgb suffix.
- The simuconf reader had a non-sense close() call. Functions should not close files they don't open, it also brought problems with my code as now we read simuconf again only for the colours when the graphic system has already started.
- Because with RGB you can't use sums to change brightness or lightness I make use of display_blend