Skip to content

Commit

Permalink
Merge pull request #27747 from nsklaus/bring_back_power_stat_while_dr…
Browse files Browse the repository at this point in the history
…iving

bring back power stat while driving
  • Loading branch information
ZhilkinSerg authored Jan 22, 2019
2 parents c2c2b01 + 7a90b72 commit a7ab652
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions src/sidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ void player::disp_status( const catacurses::window &w, const catacurses::window
veh = veh_pointer_or_null( g->m.veh_at( pos() ) );
}
if( veh ) {
veh->print_fuel_indicators( w, sideStyle ? 4 : 3, sideStyle ? getmaxx( w ) - 5 : 49 );
veh->print_fuel_indicators( w, sideStyle ? 5 : 3, sideStyle ? getmaxx( w ) - 5 : 49 );
nc_color col_indf1 = c_light_gray;

const float strain = veh->strain();
Expand Down Expand Up @@ -520,7 +520,7 @@ void player::disp_status( const catacurses::window &w, const catacurses::window

wprintz( w, c_white, " " );
}

wmove( w, sideStyle ? 4 : 3, getmaxx( w ) - ( sideStyle ? 14 : 12 ) );
//Vehicle direction indicator in 0-359° where 0 is north (veh->face.dir() 0° is west)
wprintz( w, c_white, "%3d°", ( veh->face.dir() + 90 ) % 360 );

Expand Down Expand Up @@ -568,57 +568,57 @@ void player::disp_status( const catacurses::window &w, const catacurses::window
//~ Movement type: "running". Max string length: one letter.
const auto str_run = pgettext( "movement-type", "R" );
wprintz( w, c_white, " %s", move_mode == "walk" ? str_walk : str_run );
}
// display power level
wmove( sideStyle ? w : g->w_HP,
sideStyle ? 4 : 21,
sideStyle ? 17 : 0 );

// display power level
wmove( sideStyle ? w : g->w_HP,
sideStyle ? spdy - 1 : 21,
sideStyle ? ( wx + dx * 4 - 1 ) : 0 );
wprintz( sideStyle ? w : g->w_HP, c_white, _( "Pwr " ) );

wprintz( sideStyle ? w : g->w_HP, c_white, _( "Pwr " ) );
if( this->max_power_level == 0 ) {
wprintz( sideStyle ? w : g->w_HP, c_light_gray, " --" );
} else {
nc_color color = c_red;
if( this->power_level >= this->max_power_level / 2 ) {
color = c_green;
} else if( this->power_level >= this->max_power_level / 3 ) {
color = c_yellow;
} else if( this->power_level >= this->max_power_level / 4 ) {
color = c_red;
}

if( this->max_power_level == 0 ) {
wprintz( sideStyle ? w : g->w_HP, c_light_gray, " --" );
} else {
nc_color color = c_red;
if( this->power_level >= this->max_power_level / 2 ) {
color = c_green;
} else if( this->power_level >= this->max_power_level / 3 ) {
color = c_yellow;
} else if( this->power_level >= this->max_power_level / 4 ) {
color = c_red;
// calc number of digits in powerlevel int
int offset = get_int_digits( this->power_level );

// case power_level > 999 display 1k instead
int display_power = this->power_level;
std::string unit = "";
if( this->power_level > 999 ) {
switch( offset ) {
case 4:
display_power /= 1000;
unit = "k";
offset = 2;
break;
case 5:
display_power /= 1000;
unit = "k";
offset = 0;
break;
}

// calc number of digits in powerlevel int
int offset = get_int_digits( this->power_level );

// case power_level > 999 display 1k instead
int display_power = this->power_level;
std::string unit = "";
if( this->power_level > 999 ) {
switch( offset ) {
case 4:
display_power /= 1000;
unit = "k";
offset = 2;
break;
case 5:
display_power /= 1000;
unit = "k";
offset = 0;
break;
}
} else {
unit = "";
}

wmove( sideStyle ? w : g->w_HP,
sideStyle ? spdy - 1 : 21,
sideStyle ? ( wx + dx * 4 + 6 ) - offset : 7 - offset );
std::string power_value = std::to_string( display_power ) + unit;
wprintz( sideStyle ? w : g->w_HP, color, power_value );
} else {
unit = "";
}
wrefresh( sideStyle ? w : g->w_HP );

wmove( sideStyle ? w : g->w_HP,
sideStyle ? 4 : 21,
sideStyle ? 17 - offset : 7 - offset );
std::string power_value = std::to_string( display_power ) + unit;
wprintz( sideStyle ? w : g->w_HP, color, power_value );
}
wrefresh( sideStyle ? w : g->w_HP );

}

int get_int_digits( const int &digits )
Expand Down

0 comments on commit a7ab652

Please sign in to comment.