-
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
Show needs in the comestible inventory windows #33481
Show needs in the comestible inventory windows #33481
Conversation
…/color pair just like get_hunger_description and get_thirst_description
…selector's hint line
const auto &cmgr = get_all_colors(); | ||
auto hint = std::string(); | ||
auto desc = p.get_hunger_description(); | ||
hint.append( string_format( "[%s <color_%s>%s</color>] ", _( "Food :" ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor points:
It might be cleaner to use the colorize
function here rather than writing the tags manually in the format string. Then you don't need to bother with get_all_colors
.
Also, it might be worth translating this format string just in case another language wants things formatted differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbytheway oh, nice, I did not see this colorize
function, I will make this change, this will make the code cleaner.
Also, about:
translating this format string just in case another language wants things formatted differently
Nothing do do here, it should already be translated since I am using the _( std::string )
function, just like its done in the panels, and also get_hunger_description
, get_thirst_description
and get_pain_description
returns already translated strings.
But, maybe you are suggesting to use a big parametrized string, all in one for the 3 needs ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I push in this already merged PR though or open a new one for this ?
* small refactor to make Creature::get_pain_description returns a label/color pair just like get_hunger_description and get_thirst_description * show needs in the 4 comestible inventory windows using the inventory_selector's hint line
Summary
SUMMARY: Features "Show needs in the comestible inventory windows"
Purpose of change
Fixes #33393 - Show hunger/thirst in eat menu
Describe the solution
I simply used the
inventory_selector
hint
line to display a needs bar (using the same stats as the right panels)Additional context
I could not refrain from refactoring the
Creature::get_pain_description()
to returns astd::pair<std::string, nc_color>
instead of a plainstd::string
, to mimic what already exist forget_hunger_description
andget_thirst_description
.This means I had to touch to
creature.h/cpp
obviously, but alsoplayer.h/cpp
to override the function and provide additional insights on the perceived pain, and alsopanels.cpp
to use my new function instead of its ownstatic
one.The
E
at window now looks like this: