Skip to content

Commit

Permalink
Added recipe activity level to crafting screen. (#49026)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Granade <[email protected]>
Co-authored-by: Saicchi <[email protected]>
  • Loading branch information
3 people authored Jul 10, 2021
1 parent 6e2d6eb commit 25cf01e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/crafting_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -227,6 +228,9 @@ static std::vector<std::string> recipe_info(
oss << string_format( _( "Batch time savings: <color_cyan>%s</color>\n" ),
recp.batch_savings_string() );

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

const int makes = recp.makes_amount();
if( makes > 1 ) {
oss << string_format( _( "Recipe makes: <color_cyan>%d</color>\n" ), makes );
Expand Down
14 changes: 9 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];
}

static std::string activity_level_str( float level )
std::string activity_level::activity_level_str( float level )
{
static const std::array<translation, 6> activity_descriptions { {
to_translation( "activity description", "None" ),
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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<int, int> bar = u.weariness_transition_progress();
std::pair<std::string, nc_color> weary_bar = get_hp_bar( bar.first, bar.second );
Expand Down
5 changes: 5 additions & 0 deletions src/panels.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 25cf01e

Please sign in to comment.