History character name (or general object) color change.
History character name color
In DMR, when the characters are speaking in ADV mode (small textbox on the bottom), the color of the speaking character’s name is light brown. When the characters are speaking in NVL mode (large textbox that covers most of the screen), the characters get a thematic color to their name and text. The history log has the same background texture/color as the NVL mode background, so the characters need to have a dark color to their name, otherwise the contrast is too low, and it’s too difficult to read the character name. Plus, it looks really bad.
To change the color in history, just have to change the color of the name in the _history_list
, which is the list of objects that contain information for who is saying what.
screen history():
for h in _history_list:
$ h = change_history_who_color(h)
define char_who_colors = {"#471A22": ["l","lp","lpb","lpcg","lpbc","lpbc_name", "Lee McCarthy"], }#lee
def change_history_who_color(history_object):
if history_object.who:
col = store.default_char_who_color
if "color" in history_object.who_args:
for k,v in char_who_colors.items():
if history_object.who in v:
history_object.who_args["color"] = k
break
return history_object
Char_who_colors
is just a dictionary mapping the characters to their colors, because we define several Characters per character to have different styles, such as an ADV speaker or an NVL speaker.
Using this code as-is led to a bug, however. If you take a look at the log and then return to the game, then the color of the character name will change, even if it is in ADV mode and should be yellow!
We tried a few methods to fix this name color changing bug, such as adding a callback that reverts the color once the history log is closed, or changing the color if the game mode changes (see the docs for what modes are), but we couldn’t figure out where the text object on display was pulling data from.
Then we remembered that the history object we update is probably the same exact object we show in-game, and we actually want to update a copy of that object. Python deepcopy
to the rescue yet again.
from copy import deepcopy
def change_history_who_color(history_object):
if history_object.who:
col = store.default_char_who_color
if "color" in history_object.who_args:
for k,v in char_who_colors.items():
if history_object.who in v:
history_object = deepcopy(history_object)
history_object.who_args["color"] = k
break
return history_object
Now, when we go to update the color in the history log, we make a new object and replace the old version. And the in-game text object will remain untouched with its original name color.
Pale Cachexia Full Release
Pale Cachexia’s coming out this week! Keep an eye out for Wednesday, assuming everything goes as planned. We’re just cleaning up and preparing files for release now and fighting with the publishing websites. Squashing those random bugs that like to pop up out of nowhere even though nothing changed…
Questions or Comments?
Feel free to send in any AG-related questions! Our Ask Box is always open.
Thanks so much for all of your amazing support, and stay safe out there!