11
11
#include " string_formatter.h"
12
12
#include " translations.h"
13
13
#include " enums.h"
14
+ #include " game.h"
14
15
#include " item_group.h"
15
16
#include " map.h"
16
17
#include " map_iterator.h"
17
18
#include " mapbuffer.h"
18
19
#include " mapdata.h"
20
+ #include " messages.h"
19
21
#include " overmap.h"
20
22
#include " overmap_ui.h"
21
23
#include " overmapbuffer.h"
24
26
#include " recipe_groups.h"
25
27
#include " requirements.h"
26
28
#include " skill.h"
29
+ #include " string_input_popup.h"
27
30
#include " faction_camp.h"
28
31
29
32
static const std::string base_dir = " [B]" ;
@@ -54,16 +57,15 @@ basecamp::basecamp(): bb_pos( tripoint_zero )
54
57
{
55
58
}
56
59
57
- basecamp::basecamp ( const std::string &name_, const tripoint &pos_ ): name( name_ ), pos( pos_ )
60
+ basecamp::basecamp ( const std::string &name_, const tripoint &omt_pos_ ): name( name_ ),
61
+ omt_pos( omt_pos_ )
58
62
{
59
63
}
60
64
61
- basecamp::basecamp ( const std::string &name_, const tripoint &bb_pos_, const tripoint &pos_,
62
- std::vector<tripoint> sort_points_,
63
- std::vector<std::string> directions_,
64
- std::map<std::string, expansion_data> expansions_ ):
65
- sort_points( sort_points_ ), directions( directions_ ), name( name_ ),
66
- pos( pos_ ), bb_pos( bb_pos_ ), expansions( expansions_ )
65
+ basecamp::basecamp ( const std::string &name_, const tripoint &bb_pos_,
66
+ std::vector<tripoint> sort_points_, std::vector<std::string> directions_,
67
+ std::map<std::string, expansion_data> expansions_ ): sort_points( sort_points_ ),
68
+ directions( directions_ ), name( name_ ), bb_pos( bb_pos_ ), expansions( expansions_ )
67
69
{
68
70
}
69
71
@@ -93,32 +95,63 @@ void basecamp::add_expansion( const std::string &terrain, const tripoint &new_po
93
95
return ;
94
96
}
95
97
96
- const std::string dir = talk_function::om_simple_dir ( pos , new_pos );
98
+ const std::string dir = talk_function::om_simple_dir ( omt_pos , new_pos );
97
99
expansions[ dir ] = parse_expansion ( terrain, new_pos );
98
100
directions.push_back ( dir );
99
101
}
100
102
101
103
void basecamp::define_camp ( npc &p )
102
104
{
103
- pos = p.global_omt_location ();
105
+ query_new_name ();
106
+ omt_pos = p.global_omt_location ();
104
107
sort_points = p.companion_mission_points ;
105
108
// purging the regions guarantees all entries will start with faction_base_
106
- for ( std::pair<std::string, tripoint> expansion : talk_function::om_building_region ( pos , 1 ,
109
+ for ( std::pair<std::string, tripoint> expansion : talk_function::om_building_region ( omt_pos , 1 ,
107
110
true ) ) {
108
111
add_expansion ( expansion.first , expansion.second );
109
112
}
110
- const std::string om_cur = overmap_buffer.ter ( pos ).id ().c_str ();
113
+ const std::string om_cur = overmap_buffer.ter ( omt_pos ).id ().c_str ();
111
114
if ( om_cur.find ( prefix ) == std::string::npos ) {
112
115
expansion_data e;
113
116
e.type = " camp" ;
114
117
e.cur_level = 0 ;
115
- e.pos = pos ;
118
+ e.pos = omt_pos ;
116
119
expansions[ base_dir ] = e;
117
120
} else {
118
- expansions[ base_dir ] = parse_expansion ( om_cur, pos );
121
+ expansions[ base_dir ] = parse_expansion ( om_cur, omt_pos );
119
122
}
120
123
}
121
124
125
+ // / Returns the description for the recipe of the next building @ref bldg
126
+ std::string basecamp::om_upgrade_description ( const std::string &bldg, bool trunc )
127
+ {
128
+ const recipe &making = recipe_id ( bldg ).obj ();
129
+ const inventory &total_inv = g->u .crafting_inventory ();
130
+
131
+ std::vector<std::string> component_print_buffer;
132
+ const int pane = FULL_SCREEN_WIDTH;
133
+ const auto tools = making.requirements ().get_folded_tools_list ( pane, c_white, total_inv, 1 );
134
+ const auto comps = making.requirements ().get_folded_components_list ( pane, c_white, total_inv, 1 );
135
+ component_print_buffer.insert ( component_print_buffer.end (), tools.begin (), tools.end () );
136
+ component_print_buffer.insert ( component_print_buffer.end (), comps.begin (), comps.end () );
137
+
138
+ std::string comp;
139
+ for ( auto &elem : component_print_buffer ) {
140
+ comp = comp + elem + " \n " ;
141
+ }
142
+ time_duration duration = time_duration::from_turns ( making.time / 100 );
143
+ if ( trunc ) {
144
+ comp = string_format ( _ ( " Notes:\n %s\n\n Skill used: %s\n %s\n " ),
145
+ making.description , making.skill_used .obj ().name (), comp );
146
+ } else {
147
+ comp = string_format ( _ ( " Notes:\n %s\n\n Skill used: %s\n "
148
+ " Difficulty: %d\n %s \n Risk: None\n Time: %s\n " ),
149
+ making.description , making.skill_used .obj ().name (),
150
+ making.difficulty , comp, to_string ( duration ) );
151
+ }
152
+ return comp;
153
+ }
154
+
122
155
// upgrade levels
123
156
bool basecamp::has_level ( const std::string &type, int min_level, const std::string &dir ) const
124
157
{
@@ -204,7 +237,7 @@ void basecamp::reset_camp_workers()
204
237
camp_workers.clear ();
205
238
for ( const auto &elem : overmap_buffer.get_companion_mission_npcs () ) {
206
239
npc_companion_mission c_mission = elem->get_companion_mission ();
207
- if ( c_mission.position == pos && c_mission.role_id == " FACTION_CAMP" ) {
240
+ if ( c_mission.position == omt_pos && c_mission.role_id == " FACTION_CAMP" ) {
208
241
camp_workers.push_back ( elem );
209
242
}
210
243
}
@@ -224,6 +257,28 @@ comp_list basecamp::get_mission_workers( const std::string &mission_id, bool con
224
257
return available;
225
258
}
226
259
260
+ void basecamp::query_new_name ()
261
+ {
262
+ std::string camp_name;
263
+ string_input_popup popup;
264
+ popup.title ( string_format ( _ ( " Name this camp" ) ) )
265
+ .width ( 40 )
266
+ .text ( " " )
267
+ .max_length ( 25 )
268
+ .query ();
269
+ if ( popup.canceled () || popup.text () == " " ) {
270
+ camp_name = " faction_camp" ;
271
+ } else {
272
+ camp_name = popup.text ();
273
+ }
274
+ name = camp_name;
275
+ }
276
+
277
+ void basecamp::set_name ( const std::string &new_name )
278
+ {
279
+ name = new_name;
280
+ }
281
+
227
282
// display names
228
283
std::string basecamp::expansion_tab ( const std::string &dir ) const
229
284
{
0 commit comments