15
15
#include " vpart_position.h"
16
16
#include " weather.h"
17
17
18
- static const efftype_id effect_bandaged ( " bandaged" );
19
18
static const efftype_id effect_bite ( " bite" );
20
19
static const efftype_id effect_bleed ( " bleed" );
21
- static const efftype_id effect_disinfected ( " disinfected" );
22
20
static const efftype_id effect_got_checked ( " got_checked" );
23
21
static const efftype_id effect_hunger_blank ( " hunger_blank" );
24
22
static const efftype_id effect_hunger_engorged ( " hunger_engorged" );
@@ -32,7 +30,6 @@ static const efftype_id effect_hunger_very_hungry( "hunger_very_hungry" );
32
30
static const efftype_id effect_infected ( " infected" );
33
31
34
32
static const flag_id json_flag_RAD_DETECT ( " RAD_DETECT" );
35
- static const flag_id json_flag_SPLINT ( " SPLINT" );
36
33
static const flag_id json_flag_THERMOMETER ( " THERMOMETER" );
37
34
38
35
static const itype_id fuel_type_muscle ( " muscle" );
@@ -1016,135 +1013,6 @@ std::pair<std::string, nc_color> display::vehicle_fuel_percent_text_color( const
1016
1013
return std::make_pair ( fuel_text, fuel_color );
1017
1014
}
1018
1015
1019
- // Return status/color pairs for all statuses affecting body part (bleeding, bitten, bandaged, etc.)
1020
- static std::map<bodypart_status, nc_color> bodypart_status_colors ( const Character &u,
1021
- const bodypart_id &bp, const std::string &wgt_id )
1022
- {
1023
- // List of active statuses and associated colors
1024
- std::map<bodypart_status, nc_color> ret;
1025
-
1026
- // Empty if no bodypart given
1027
- if ( bp == bodypart_str_id::NULL_ID () ) {
1028
- return ret;
1029
- }
1030
-
1031
- const int bleed_intensity = u.get_effect_int ( effect_bleed, bp );
1032
- const bool bleeding = bleed_intensity > 0 ;
1033
- const bool bitten = u.has_effect ( effect_bite, bp.id () );
1034
- const bool infected = u.has_effect ( effect_infected, bp.id () );
1035
- const bool broken = u.is_limb_broken ( bp ) && bp->is_limb ;
1036
- const bool splinted = u.worn_with_flag ( json_flag_SPLINT, bp );
1037
- const bool bandaged = u.has_effect ( effect_bandaged, bp.id () );
1038
- const bool disinfected = u.has_effect ( effect_disinfected, bp.id () );
1039
-
1040
- auto get_clr = [&wgt_id]( const bodypart_status & stat, int val ) {
1041
- widget_id id ( wgt_id );
1042
- if ( id.is_valid () ) {
1043
- return widget_phrase::get_color_for_id ( io::enum_to_string ( stat ), id, val );
1044
- }
1045
- return c_white;
1046
- };
1047
-
1048
- // Ailments
1049
- if ( broken ) {
1050
- ret[bodypart_status::BROKEN] = get_clr ( bodypart_status::BROKEN, INT_MIN );
1051
- }
1052
- if ( bitten ) {
1053
- ret[bodypart_status::BITTEN] = get_clr ( bodypart_status::BITTEN, INT_MIN );
1054
- }
1055
- if ( bleeding ) {
1056
- ret[bodypart_status::BLEEDING] = get_clr ( bodypart_status::BLEEDING, bleed_intensity );
1057
- }
1058
- if ( infected ) {
1059
- ret[bodypart_status::INFECTED] = get_clr ( bodypart_status::INFECTED, INT_MIN );
1060
- }
1061
- // Treatments
1062
- if ( splinted ) {
1063
- ret[bodypart_status::SPLINTED] = get_clr ( bodypart_status::SPLINTED, INT_MIN );
1064
- }
1065
- if ( bandaged ) {
1066
- ret[bodypart_status::BANDAGED] = get_clr ( bodypart_status::BANDAGED, INT_MIN );
1067
- }
1068
- if ( disinfected ) {
1069
- ret[bodypart_status::DISINFECTED] = get_clr ( bodypart_status::DISINFECTED, INT_MIN );
1070
- }
1071
-
1072
- return ret;
1073
- }
1074
-
1075
- static const std::string &sym_for_bp_status ( const bodypart_status &stat )
1076
- {
1077
- static const std::string none = " ." ;
1078
- static const std::map<bodypart_status, std::string> symmap {
1079
- { bodypart_status::BITTEN, " B" },
1080
- { bodypart_status::INFECTED, " I" },
1081
- { bodypart_status::BROKEN, " %" },
1082
- { bodypart_status::BLEEDING, " b" },
1083
- { bodypart_status::SPLINTED, " =" },
1084
- { bodypart_status::BANDAGED, " +" },
1085
- { bodypart_status::DISINFECTED, " $" },
1086
- { bodypart_status::num_bodypart_status, none }
1087
- };
1088
- auto sym = symmap.find ( stat );
1089
- return sym == symmap.end () ? none : sym->second ;
1090
- }
1091
-
1092
- std::string display::colorized_bodypart_status_legend_text ( const Character &u,
1093
- const std::set<bodypart_id> &bplist, const std::string &wgt_id, int width, int max_height,
1094
- int &height )
1095
- {
1096
- std::vector<std::string> keys;
1097
- std::set<bodypart_status> status;
1098
- widget_id wid ( wgt_id );
1099
- for ( const bodypart_id &bp : bplist ) {
1100
- for ( const auto &bpcol : bodypart_status_colors ( u, bp, wgt_id ) ) {
1101
- if ( status.find ( bpcol.first ) == status.end () ) {
1102
- status.emplace ( bpcol.first );
1103
- std::string key = io::enum_to_string ( bpcol.first );
1104
- std::string sym;
1105
- if ( wid.is_valid () ) {
1106
- translation t = widget_phrase::get_text_for_id ( key, wid );
1107
- key = t.empty () ? key : t.translated ();
1108
- sym = widget_phrase::get_sym_for_id ( io::enum_to_string ( bpcol.first ), wid );
1109
- }
1110
- sym = sym.empty () ? sym_for_bp_status ( bpcol.first ) : sym;
1111
- sym = colorize ( sym, bpcol.second );
1112
- keys.emplace_back ( string_format ( " %s %s" , sym, key ) );
1113
- }
1114
- }
1115
- }
1116
- // Split legend keys into X lines, where X = height.
1117
- // Lines use the provided width.
1118
- // This effectively limits the text to a 'width'x'height' box.
1119
- std::string ret;
1120
- height = 0 ;
1121
- const int h_max = max_height == 0 ? INT_MAX : max_height;
1122
- const int nsize = keys.size ();
1123
- for ( int row = 0 , nidx = 0 ; row < h_max && nidx < nsize; row++ ) {
1124
- int wavail = width;
1125
- int nwidth = utf8_width ( keys[nidx], true );
1126
- bool startofline = true ;
1127
- while ( nidx < nsize && ( wavail > nwidth || startofline ) ) {
1128
- startofline = false ;
1129
- wavail -= nwidth;
1130
- ret += keys[nidx];
1131
- nidx++;
1132
- if ( nidx < nsize ) {
1133
- nwidth = utf8_width ( keys[nidx], true );
1134
- if ( wavail > nwidth ) {
1135
- ret += " " ;
1136
- wavail -= 2 ;
1137
- }
1138
- }
1139
- }
1140
- if ( row < h_max - 1 ) {
1141
- ret += " \n " ;
1142
- }
1143
- height++;
1144
- }
1145
- return ret;
1146
- }
1147
-
1148
1016
std::string display::colorized_bodypart_outer_armor ( const Character &u, const bodypart_id &bp )
1149
1017
{
1150
1018
for ( std::list<item>::const_iterator it = u.worn .end (); it != u.worn .begin (); ) {
0 commit comments