From 76d1155194a5b21ccc237e34cab92ede48bd8a04 Mon Sep 17 00:00:00 2001 From: EI IKaO <109350502+EIIKaO@users.noreply.github.com> Date: Fri, 16 Sep 2022 19:31:38 +0900 Subject: [PATCH 1/3] Enable to cancel faction base name rename --- src/basecamp.cpp | 29 ++++++++++++++++++++--------- src/basecamp.h | 2 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/basecamp.cpp b/src/basecamp.cpp index fd109a964e380..72c886560c3f3 100644 --- a/src/basecamp.cpp +++ b/src/basecamp.cpp @@ -180,7 +180,7 @@ void basecamp::add_expansion( const std::string &bldg, const tripoint_abs_omt &n void basecamp::define_camp( const tripoint_abs_omt &p, const std::string &camp_type ) { - query_new_name(); + query_new_name( true ); omt_pos = p; const oter_id &omt_ref = overmap_buffer.ter( omt_pos ); // purging the regions guarantees all entries will start with faction_base_ @@ -596,18 +596,29 @@ comp_list basecamp::get_mission_workers( const mission_id &miss_id, bool contain return available; } -void basecamp::query_new_name() +void basecamp::query_new_name( const bool force ) { - string_input_popup popup; + string_input_popup input_popup; + bool done = false; + bool need_input = true; do { - popup.title( _( "Name this camp" ) ) + input_popup.title( _( "Name this camp" ) ) .width( 40 ) - .text( "" ) .max_length( 25 ) - .query(); - } while( popup.canceled() || popup.text().empty() ); - - name = popup.text(); + .query(); + if( input_popup.canceled() || input_popup.text().empty() ) { + if( name.empty() || force ) { + popup( _( "You need to input the base camp name." ) ); + } else { + need_input = false; + } + } else { + done = true; + } + } while( !done && need_input ); + if( done ) { + name = input_popup.text(); + } } void basecamp::set_name( const std::string &new_name ) diff --git a/src/basecamp.h b/src/basecamp.h index 93249b128a664..ed53a0e473758 100644 --- a/src/basecamp.h +++ b/src/basecamp.h @@ -175,7 +175,7 @@ class basecamp //change name of camp void set_name( const std::string &new_name ); - void query_new_name(); + void query_new_name( const bool force = false ); void abandon_camp(); void scan_pseudo_items(); void add_expansion( const std::string &terrain, const tripoint_abs_omt &new_pos ); From 861e95711bae3f1c1b27200d604c45d095736a35 Mon Sep 17 00:00:00 2001 From: EI IKaO <109350502+EIIKaO@users.noreply.github.com> Date: Fri, 16 Sep 2022 20:09:02 +0900 Subject: [PATCH 2/3] AStyle --- src/basecamp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basecamp.cpp b/src/basecamp.cpp index 72c886560c3f3..31a4e15e50a53 100644 --- a/src/basecamp.cpp +++ b/src/basecamp.cpp @@ -605,7 +605,7 @@ void basecamp::query_new_name( const bool force ) input_popup.title( _( "Name this camp" ) ) .width( 40 ) .max_length( 25 ) - .query(); + .query(); if( input_popup.canceled() || input_popup.text().empty() ) { if( name.empty() || force ) { popup( _( "You need to input the base camp name." ) ); From 9401358c1c68b98f7b7062485b77922856cc6546 Mon Sep 17 00:00:00 2001 From: EI IKaO <109350502+EIIKaO@users.noreply.github.com> Date: Sat, 17 Sep 2022 01:39:09 +0900 Subject: [PATCH 3/3] Remove const declaration --- src/basecamp.cpp | 2 +- src/basecamp.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basecamp.cpp b/src/basecamp.cpp index 31a4e15e50a53..dd318d161e5d1 100644 --- a/src/basecamp.cpp +++ b/src/basecamp.cpp @@ -596,7 +596,7 @@ comp_list basecamp::get_mission_workers( const mission_id &miss_id, bool contain return available; } -void basecamp::query_new_name( const bool force ) +void basecamp::query_new_name( bool force ) { string_input_popup input_popup; bool done = false; diff --git a/src/basecamp.h b/src/basecamp.h index ed53a0e473758..136476b03e64f 100644 --- a/src/basecamp.h +++ b/src/basecamp.h @@ -175,7 +175,7 @@ class basecamp //change name of camp void set_name( const std::string &new_name ); - void query_new_name( const bool force = false ); + void query_new_name( bool force = false ); void abandon_camp(); void scan_pseudo_items(); void add_expansion( const std::string &terrain, const tripoint_abs_omt &new_pos );