[crossfire] GtkV2 client theme support.
Mark Wedel
mwedel at sonic.net
Mon Feb 5 02:58:30 CST 2007
I've just committed a change to the GTK2 client so it now supports different
themes. There are only 2 now (Standard & Black), but should be easy to make
more. Various notes:
- The various hard coded values in the client are gone, and are now in the
themes (fonts and in some places colors). This means that if you don't install
the themes, you'll have a plainer looking client. If you do a 'make install',
it will install the themes where the client expects to find them. Your theme
preference will be stored in the gdefaults2 file, and can be changed in the
config window. If no default is specified, it defaults to the Standard theme.
- The 'Standard' theme is a theme that I wrote that tries to match the previous
hardcode values (red for cursed inventory items, matching colors for text, etc).
In addition to the Standard & Black themes, there is also a 'None' theme,
which basically means don't use any special theme - just get all values from
system wide theme. Effect on this is you won't see any colored text in the text
panes, the inventories won't differ based on magic/cursed/etc status, and stat
bars will use system default color for progressbars.
- The client does support switching between themes on the fly - no restart
needed. Even things like style of the text messages will get updated. However,
if you go to the None theme, and then go to another theme, the text messages
will still all appear in the default color - this is because when switching to
the None theme, it deletes all the color text tags, where as when switching
between actual themes, it updates the text tags with new values.
- One case where the new system is slightly lacking compared to old is compound
status on inventory items - old code had special logic for cursed & magic items
(drawn in dark navy). Given there are 5 different status of items right now, I
didn't want to try to handle all of those possible combos, so instead it just
has a simple precedence (unpaid > cursed > magical > applied > locked)
- There are many areas where this new code has more options than previous:
- For the inventory lists, foreground color and font style can be set. The
Standard setting extends previous logic by drawing locked items in italics
and equipped items in bold.
- The color for the stat (hp/grace/food/etc) bars can now be individually
set. You can have your HP bar be red, you grace green, mana blue, etc.
You can also use different colors based on graduated drawing or simple
low/high/super vlaues.
- You can now override the text colors in use. Eg, for black background,
you want to change how black text will be drawn, so can say 'draw black
text as white text instead'. And like the inventory lists, for all of
the text pane values, font and both foreground/background colors can be
set
- The themes allow setting of font & color values for all of the message
type/subtype values. So it possible to change things such that good
messages are green, bad are red, etc.
Loose ends/TODO:
- When I wrote the theme styles for the message type/subtype handling, I looked
in the server code to see what colors were being used for the type/subtype.
However, in some cases, for the same type of message, different colors were
being used depending on who wrote the code. In those cases, I took which color
was being used the most, or made the most sense.
- Related to above, it may actually make sense to depart from trying to keep
things as is, and instead update/re-arrange things so color in the text messages
is more consistent and plays a better role, like green=good, red=bad messages,
related (but different enough) colors for all chat related messages, etc.
- The [color=...] in message tags is problematic. Current handling is that if
it setting the color to one of the standard crossfire colors, it works as
expected. If setting to anything else, including RGB values, it is just
ignored. The problem comes in that the message itself has no idea what styles
I'm using on the client. A [color=#000000] really sucks if I have a black
background. Using the standard crossfire colors isn't a problem, because the
setting files can change how those look. One thought might be to change the
client logic some to try to find the closes match to one of the crossfire color,
and use that style. Or another would be to say 'only use standard crossfire
colors' in the [color] tags.
- The list of themes you can choose from is determined by what files exist in
the themes directory. So if you don't see any option under the theme config
option, you probably didn't do a make install. Also, it only reads in that
directory once at startup IIRC, so if you are working on a new theme and copy it
to that directory, you'll have to restart to client to see it in the list.
- If doing development, the client will not do anything if the theme doesn't
change - there is no 'reread' existing theme option. So your best bet is to
choose a different theme, hit apply, then select your test theme again.
If you have questions/comments, feel free to ask.
More information about the crossfire
mailing list