-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move display-related string colorization functions out of Character class #50972
Move display-related string colorization functions out of Character class #50972
Conversation
I am tempted to call reductions in the size of character.cpp a bugfix... EDIT: Sorry, didn't realize you were editing the labels at the same time as I was. |
10e962d
to
31a3a7c
Compare
Failing test case in "Basic Build / Basic Build and Test (GCC 9, Curses, LTO)" appears unrelated:
|
31a3a7c
to
49bf9d6
Compare
This namespace is presently only used as a wrapper to make `activity_level_str` accessible to the crafting GUI, per CleverRaven#49026. I intend to move several other descriptive functions defined in `panels.h|cpp` into this namespace, making it a more general-purpose collection of descriptive text and color translation methods. Hence, the namespace is here renamed to `display`.
Move to `display` namespace in panels.h, and rename to hunger_text_color and thirst_text_color, taking a Character instance as an argument.
75b707e
to
5e246d0
Compare
Move these three functions out of `character.h|cpp` and into `panels.h|cpp` with a `const Character` argument: - get_weight_string => display::weight_string - get_weight_description => display::weight_text_color - get_weight_long_description => display::weight_long_description
Relocate to `panels.h|cpp` and rename to `fatigue_text_color`.
Move these display-related functions into `panels.h|cpp` and rename to `pain_text_color` to match their brethren.
Apply suggestion from code review. Co-authored-by: Kevin Granade <[email protected]>
5e246d0
to
63ab28e
Compare
Never mind, looks like I somehow had some stale |
Summary
None
Purpose of change
To de-bloat the Character class and make display-related functions more logically named.
Describe the solution
Move and rename these functions out of the Character class, into a
display
namespace inpanels.h|cpp
:Character::get_thirst_description
->display::thirst_text_color
Character::get_hunger_description
->display::hunger_text_color
Character::get_fatigue_description
->display::fatigue_text_color
Character::get_pain_description
->display::pain_text_color
Character::get_weight_description
->display::weight_text_color
Character::get_weight_string
->display::weight_string
Character::get_weight_long_description
->display::weight_long_description
static weariness_description
->display::weariness_text_color
The new
text_color
names were chosen to reflect the fact that these functions return a (string, color) or (translation, color) pair.Leave the existing
activity_level_str
function in place in the new namespace (formerly calledactivity_level
).Describe alternatives you've considered
Going the other way around (migrating display functions from panels into character) seemed like the wrong choice, considering the massive size of the Character class already. These functions are only loosely coupled to the class and don't really belong here.
Considering the sort of general-purpose usage of these functions throughout the codebase (not just for the panels), perhaps
panels.h|cpp
is not ideal either; however the panels are the biggest consumer of these functions (and the incoming panel widgets in #50945 do too), plus there is a collection of similar functions already in there (dex_string
,focus_color
,get_moon
and so forth), so I think it's a good fit.Testing
Play the game and ensure the colored descriptive text in sidebar still looks OK.
Additional context
This is mainly in support of #50945
Probably easiest to review commit-by-commit (one or two functions factored out per commit).