From 25cf01e5a50470a2ac2a1b4a20e4582077476b2c Mon Sep 17 00:00:00 2001 From: Kelenius Date: Sat, 10 Jul 2021 05:44:43 +0300 Subject: [PATCH] Added recipe activity level to crafting screen. (#49026) Co-authored-by: Kevin Granade Co-authored-by: Saicchi <47158232+Saicchi@users.noreply.github.com> --- src/crafting_gui.cpp | 4 ++++ src/panels.cpp | 14 +++++++++----- src/panels.h | 5 +++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/crafting_gui.cpp b/src/crafting_gui.cpp index 9ba8438533cba..5c6c48cc25b36 100644 --- a/src/crafting_gui.cpp +++ b/src/crafting_gui.cpp @@ -27,6 +27,7 @@ #include "json.h" #include "optional.h" #include "output.h" +#include "panels.h" #include "point.h" #include "popup.h" #include "recipe.h" @@ -227,6 +228,9 @@ static std::vector recipe_info( oss << string_format( _( "Batch time savings: %s\n" ), recp.batch_savings_string() ); + oss << string_format( _( "Activity level: %s\n" ), + activity_level::activity_level_str( recp.exertion_level() ) ); + const int makes = recp.makes_amount(); if( makes > 1 ) { oss << string_format( _( "Recipe makes: %d\n" ), makes ); diff --git a/src/panels.cpp b/src/panels.cpp index fe62335588d1a..dd45ac491dd4f 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1012,7 +1012,7 @@ static std::pair weariness_description( size_t weariness return weary_descriptions[weariness]; } -static std::string activity_level_str( float level ) +std::string activity_level::activity_level_str( float level ) { static const std::array activity_descriptions { { to_translation( "activity description", "None" ), @@ -1074,7 +1074,8 @@ static void draw_stats( avatar &u, const catacurses::window &w ) mvwprintz( w, point_south, c_light_gray, _( weary_label ) ); 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_str( activity ) ); + mvwprintz( w, point( act_start + alabel_len + 1, 1 ), act_color, + activity_level::activity_level_str( activity ) ); wnoutrefresh( w ); } @@ -1391,7 +1392,8 @@ static void draw_stat_narrow( avatar &u, const catacurses::window &w ) mvwprintz( w, point( 1, 3 ), c_light_gray, _( weary_label ) ); 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_str( activity ) ); + mvwprintz( w, point( act_start + alabel_len + 1, 3 ), act_color, + activity_level::activity_level_str( activity ) ); wnoutrefresh( w ); } @@ -1441,7 +1443,8 @@ static void draw_stat_wide( avatar &u, const catacurses::window &w ) mvwprintz( w, point( 1, 2 ), c_light_gray, _( weary_label ) ); 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_str( activity ) ); + mvwprintz( w, point( act_start + alabel_len + 1, 2 ), act_color, + activity_level::activity_level_str( activity ) ); wnoutrefresh( w ); } @@ -2209,7 +2212,8 @@ static void draw_weariness_classic( const avatar &u, const catacurses::window &w mvwprintz( w, point_zero, c_light_gray, _( weary_label ) ); 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_str( activity ) ); + mvwprintz( w, point( act_start + alabel_len + 1, 0 ), act_color, + activity_level::activity_level_str( activity ) ); std::pair bar = u.weariness_transition_progress(); std::pair weary_bar = get_hp_bar( bar.first, bar.second ); diff --git a/src/panels.h b/src/panels.h index cba5614e27643..4c0a91b86eef2 100644 --- a/src/panels.h +++ b/src/panels.h @@ -16,6 +16,11 @@ class JsonOut; class avatar; struct point; +namespace activity_level +{ +const std::string activity_level_str( float level ); +} // namespace activity_level + namespace catacurses { class window;