Skip to content

Commit

Permalink
Rename activity_level namespace to display
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
wapcaplet committed Aug 22, 2021
1 parent bd2ce6b commit e1d6c09
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/crafting_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static std::vector<std::string> recipe_info(
recp.batch_savings_string() );

oss << string_format( _( "Activity level: <color_cyan>%s</color>\n" ),
activity_level::activity_level_str( recp.exertion_level() ) );
display::activity_level_str( recp.exertion_level() ) );

const int makes = recp.makes_amount();
if( makes > 1 ) {
Expand Down
10 changes: 5 additions & 5 deletions src/panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ static std::pair<translation, nc_color> weariness_description( size_t weariness
return weary_descriptions[weariness];
}

std::string activity_level::activity_level_str( float level )
std::string display::activity_level_str( float level )
{
static const std::array<translation, 6> activity_descriptions { {
to_translation( "activity description", "None" ),
Expand Down Expand Up @@ -1075,7 +1075,7 @@ static void draw_stats( avatar &u, const catacurses::window &w )
mvwprintz( w, point( wlabel_len + 1, 1 ), weary.second, weary.first.translated() );
mvwprintz( w, point( act_start, 1 ), c_light_gray, _( activity_label ) );
mvwprintz( w, point( act_start + alabel_len + 1, 1 ), act_color,
activity_level::activity_level_str( activity ) );
display::activity_level_str( activity ) );

wnoutrefresh( w );
}
Expand Down Expand Up @@ -1393,7 +1393,7 @@ static void draw_stat_narrow( avatar &u, const catacurses::window &w )
mvwprintz( w, point( wlabel_len + 2, 3 ), weary.second, weary.first.translated() );
mvwprintz( w, point( act_start, 3 ), c_light_gray, _( activity_label ) );
mvwprintz( w, point( act_start + alabel_len + 1, 3 ), act_color,
activity_level::activity_level_str( activity ) );
display::activity_level_str( activity ) );

wnoutrefresh( w );
}
Expand Down Expand Up @@ -1444,7 +1444,7 @@ static void draw_stat_wide( avatar &u, const catacurses::window &w )
mvwprintz( w, point( wlabel_len + 2, 2 ), weary.second, weary.first.translated() );
mvwprintz( w, point( act_start, 2 ), c_light_gray, _( activity_label ) );
mvwprintz( w, point( act_start + alabel_len + 1, 2 ), act_color,
activity_level::activity_level_str( activity ) );
display::activity_level_str( activity ) );

wnoutrefresh( w );
}
Expand Down Expand Up @@ -2242,7 +2242,7 @@ static void draw_weariness_classic( const avatar &u, const catacurses::window &w
mvwprintz( w, point( wlabel_len + 1, 0 ), weary.second, weary.first.translated() );
mvwprintz( w, point( act_start, 0 ), c_light_gray, _( activity_label ) );
mvwprintz( w, point( act_start + alabel_len + 1, 0 ), act_color,
activity_level::activity_level_str( activity ) );
display::activity_level_str( activity ) );

std::pair<int, int> bar = u.weariness_transition_progress();
std::pair<std::string, nc_color> weary_bar = get_hp_bar( bar.first, bar.second );
Expand Down
7 changes: 5 additions & 2 deletions src/panels.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ class JsonOut;
class avatar;
struct point;

namespace activity_level
// The display namespace contains UI string output and colorization functions
// Some return plain strings or translations, some return a (string, color) pair,
// and some return a string with colorization tags embedded.
namespace display
{
std::string activity_level_str( float level );
} // namespace activity_level
} // namespace display

namespace catacurses
{
Expand Down

0 comments on commit e1d6c09

Please sign in to comment.