Skip to content

Commit

Permalink
Add daily health widget (#77195)
Browse files Browse the repository at this point in the history
  • Loading branch information
phelieros authored Oct 21, 2024
1 parent 9f7dcf2 commit 0366d52
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions data/json/ui/health.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
"style": "number",
"colors": [ "c_red", "c_light_red", "c_light_green", "c_green" ]
},
{
"id": "daily_health_num",
"type": "widget",
"label": "Daily health",
"var": "daily_health",
"style": "number",
"colors": [ "c_red", "c_light_red", "c_light_green", "c_green" ]
},
{
"id": "health_desc",
"type": "widget",
Expand Down
9 changes: 9 additions & 0 deletions src/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ std::string enum_to_string<widget_var>( widget_var data )
return "sleepiness";
case widget_var::health:
return "health";
case widget_var::daily_health:
return "daily_health";
case widget_var::weariness_level:
return "weariness_level";
case widget_var::mana:
Expand Down Expand Up @@ -607,6 +609,10 @@ void widget::set_default_var_range( const avatar &ava )
// Small range of normal health that won't be color-coded
_var_norm = std::make_pair( -10, 10 );
break;
case widget_var::daily_health:
_var_min = -200;
_var_max = 200;
break;
case widget_var::mana:
_var_min = 0;
_var_max = ava.magic->max_mana( ava );
Expand Down Expand Up @@ -820,6 +826,9 @@ int widget::get_var_value( const avatar &ava ) const
case widget_var::health:
value = ava.get_lifestyle();
break;
case widget_var::daily_health:
value = ava.get_daily_health();
break;
case widget_var::weariness_level:
value = ava.weariness_level();
break;
Expand Down
1 change: 1 addition & 0 deletions src/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum class widget_var : int {
stamina, // Current stamina 0-10000, greater being fuller stamina reserves
sleepiness, // Current sleepiness, integer
health, // Current hidden health value, -200 to +200
daily_health, // Current daily health value, -200 to +200
mana, // Current available mana, integer
max_mana, // Current maximum mana, integer
power_percentage, // Bionic power, relative to capacity
Expand Down

0 comments on commit 0366d52

Please sign in to comment.