Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring back power stat while driving #27747

Merged
merged 1 commit into from
Jan 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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