From e43760d2e616c3ee8cd140d5e80d451987c6e91a Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Fri, 1 Nov 2019 11:27:02 +0100 Subject: [PATCH 1/2] Bionic menu clean up --- src/bionics_ui.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index f41d7e49576d7..0711063ae6f4c 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -59,18 +59,24 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, bionic_menu_mode mode ) { werase( window ); - std::ostringstream fuel_stream; - fuel_stream << _( "Available Fuel: " ); + std::string fuel_string; + bool found_fuel = false; + fuel_string = _( "Available Fuel: " ); for( const bionic &bio : *p->my_bionics ) { for( const itype_id fuel : p->get_fuel_available( bio.id ) ) { + found_fuel = true; const item temp_fuel( fuel ) ; if( temp_fuel.has_flag( "PERPETUAL" ) ) { + fuel_string += "" + temp_fuel.tname() + ""; continue; } - fuel_stream << temp_fuel.tname() << ": " << "" << p->get_value( - fuel ) << "" << "/" << p->get_total_fuel_capacity( fuel ) << " "; + fuel_string += temp_fuel.tname() + ": " + p->get_value( + fuel ) + "/" + std::to_string( p->get_total_fuel_capacity( fuel ) ) + " "; } } + if( !found_fuel ) { + fuel_string.clear(); + } std::string power_string; const int curr_power = units::to_millijoule( p->get_power_level() ); const int kilo = curr_power / units::to_millijoule( 1_kJ ); @@ -98,6 +104,7 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, std::string desc; if( mode == REASSIGNING ) { desc = _( "Reassigning.\nSelect a bionic to reassign or press SPACE to cancel." ); + fuel_string.clear(); } else if( mode == ACTIVATING ) { desc = _( "Activating ! to examine, = to reassign, TAB to switch tabs." ); } else if( mode == EXAMINING ) { @@ -105,7 +112,7 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, } int n_pt_y = 0; fold_and_print( window, point( 1, n_pt_y++ ), pwr_str_pos, c_white, desc ); - fold_and_print( window, point( 1, n_pt_y++ ), pwr_str_pos, c_white, fuel_stream.str() ); + fold_and_print( window, point( 1, n_pt_y++ ), pwr_str_pos, c_white, fuel_string ); wrefresh( window ); } From a72bfcb04eab4781db02b6707f6e4e4cea1f38e8 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sun, 3 Nov 2019 15:55:01 +0100 Subject: [PATCH 2/2] use colorize --- src/bionics_ui.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index 0711063ae6f4c..1863273e5e720 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -67,11 +67,11 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, found_fuel = true; const item temp_fuel( fuel ) ; if( temp_fuel.has_flag( "PERPETUAL" ) ) { - fuel_string += "" + temp_fuel.tname() + ""; + fuel_string += colorize( temp_fuel.tname(), c_green ) + " "; continue; } - fuel_string += temp_fuel.tname() + ": " + p->get_value( - fuel ) + "/" + std::to_string( p->get_total_fuel_capacity( fuel ) ) + " "; + fuel_string += temp_fuel.tname() + ": " + colorize( p->get_value( fuel ), + c_green ) + "/" + std::to_string( p->get_total_fuel_capacity( fuel ) ) + " "; } } if( !found_fuel ) {