Skip to content
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

Conversation

pierredavidbelanger
Copy link
Contributor

@pierredavidbelanger pierredavidbelanger commented Aug 23, 2019

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 a std::pair<std::string, nc_color> instead of a plain std::string, to mimic what already exist for get_hunger_description and get_thirst_description.

This means I had to touch to creature.h/cpp obviously, but also player.h/cpp to override the function and provide additional insights on the perceived pain, and also panels.cpp to use my new function instead of its own static one.

The Eat window now looks like this:

image

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) Items: Food / Vitamins Comestibles and drinks Info / User Interface Game - player communication, menus, etc. Quality of Life QoL: degree to which players are comfortable, and able to enjoy CDDA labels Aug 23, 2019
@ZhilkinSerg ZhilkinSerg merged commit d01d881 into CleverRaven:master Aug 23, 2019
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 :" ),
Copy link
Contributor

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.

Copy link
Contributor Author

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 ?

Copy link
Contributor Author

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 ?

misterprimus pushed a commit to misterprimus/Cataclysm-DDA that referenced this pull request Sep 21, 2019
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) Info / User Interface Game - player communication, menus, etc. Items: Food / Vitamins Comestibles and drinks Quality of Life QoL: degree to which players are comfortable, and able to enjoy CDDA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show hunger/thirst in eat menu
3 participants