Skip to content

Commit

Permalink
Enable to cancel rename the faction base name (#61040)
Browse files Browse the repository at this point in the history
* Enable to cancel faction base name rename

* AStyle

* Remove const declaration
  • Loading branch information
EIIKaO authored Sep 17, 2022
1 parent 915da83 commit 5a867d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
27 changes: 19 additions & 8 deletions src/basecamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down Expand Up @@ -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( 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();
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 )
Expand Down
2 changes: 1 addition & 1 deletion src/basecamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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( bool force = false );
void abandon_camp();
void scan_pseudo_items();
void add_expansion( const std::string &terrain, const tripoint_abs_omt &new_pos );
Expand Down

0 comments on commit 5a867d1

Please sign in to comment.