CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.26k stars 4.11k forks source link

Cannot make colored text in npc dialogue #66510

Open gettingusedto opened 1 year ago

gettingusedto commented 1 year ago

Describe the bug

I once had an idea to color the one part of the pyromaniac mission text to highlight the fact that you need to bring gasoline. after i covered said part of the text with <color_yellow> & </color> and ran the game to check it, it does not appear yellow.

Attach save file

N/A

Steps to reproduce

  1. cover a npc text with the aforementioned <color_(colorname)> [NPC_Text] </color> in the json.
  2. run the game and check said npc text
  3. it does not get colored.

Expected behavior

The npc dialogue text being colorable.

Screenshots

No response

Versions and configuration

Additional context

No response

ZhilkinSerg commented 1 year ago

fold_and_print_from function (or something similar) should be used to draw text with color tags.

NPC dialog window uses multiline_list::print_line which strips color tags from the output text (and does some other color manipulations):

https://github.com/CleverRaven/Cataclysm-DDA/blob/93d1f4abe99e5041fd9499865742a3c6591ef2f0/src/output.cpp#L1997-L2007

ZeroInternalReflection commented 7 months ago

I've been unable to replicate this. Adding colour tags to npc dialogue in the json appears to work properly. In the tests below, "Emergency" and "Panic" had red tags added, "Help/Tutorial" had yellow added. The text colour gets changed in both the dialogue selection panel and the message history panel.

Talking_to_ally Talking_to_pc

NPC dialog window uses multiline_list::print_line which strips color tags from the output text (and does some other color manipulations):

It took me a minute to remember what was going on there, but the remove_color_tags() line is not actually used in the dialogue screen. It was added as infrastructure so that I could convert some of the character creation screens to multiline_list (which hasn't happened yet, and probably needs some separate work). The only colour change that multiline_list should be doing to the text is highlighting the selected line.

Can anyone who has run into this issue specify what files/lines they encountered it on?