Skip to content

Commit 46e2ec7

Browse files
davidpwbrownkevingranade
authored andcommitted
Follower / Faction camp summary menu and migrate to overmap (CleverRaven#28498)
* added NPC summary window added ability to chat to NPC from menu added mission description to NPC list added camp labels and camp names moved camps to overmap get camp info works from overmapbuffer now made the om_camps accept pointers added mission description to camp menu
1 parent a868b99 commit 46e2ec7

25 files changed

+826
-114
lines changed

src/basecamp.cpp

Lines changed: 69 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
#include "string_formatter.h"
1212
#include "translations.h"
1313
#include "enums.h"
14+
#include "game.h"
1415
#include "item_group.h"
1516
#include "map.h"
1617
#include "map_iterator.h"
1718
#include "mapbuffer.h"
1819
#include "mapdata.h"
20+
#include "messages.h"
1921
#include "overmap.h"
2022
#include "overmap_ui.h"
2123
#include "overmapbuffer.h"
@@ -24,6 +26,7 @@
2426
#include "recipe_groups.h"
2527
#include "requirements.h"
2628
#include "skill.h"
29+
#include "string_input_popup.h"
2730
#include "faction_camp.h"
2831

2932
static const std::string base_dir = "[B]";
@@ -54,16 +57,15 @@ basecamp::basecamp(): bb_pos( tripoint_zero )
5457
{
5558
}
5659

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_ )
5862
{
5963
}
6064

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_ )
6769
{
6870
}
6971

@@ -93,32 +95,63 @@ void basecamp::add_expansion( const std::string &terrain, const tripoint &new_po
9395
return;
9496
}
9597

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 );
9799
expansions[ dir ] = parse_expansion( terrain, new_pos );
98100
directions.push_back( dir );
99101
}
100102

101103
void basecamp::define_camp( npc &p )
102104
{
103-
pos = p.global_omt_location();
105+
query_new_name();
106+
omt_pos = p.global_omt_location();
104107
sort_points = p.companion_mission_points;
105108
// 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,
107110
true ) ) {
108111
add_expansion( expansion.first, expansion.second );
109112
}
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();
111114
if( om_cur.find( prefix ) == std::string::npos ) {
112115
expansion_data e;
113116
e.type = "camp";
114117
e.cur_level = 0;
115-
e.pos = pos;
118+
e.pos = omt_pos;
116119
expansions[ base_dir ] = e;
117120
} else {
118-
expansions[ base_dir ] = parse_expansion( om_cur, pos );
121+
expansions[ base_dir ] = parse_expansion( om_cur, omt_pos );
119122
}
120123
}
121124

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\nSkill used: %s\n%s\n" ),
145+
making.description, making.skill_used.obj().name(), comp );
146+
} else {
147+
comp = string_format( _( "Notes:\n%s\n\nSkill used: %s\n"
148+
"Difficulty: %d\n%s \nRisk: None\nTime: %s\n" ),
149+
making.description, making.skill_used.obj().name(),
150+
making.difficulty, comp, to_string( duration ) );
151+
}
152+
return comp;
153+
}
154+
122155
// upgrade levels
123156
bool basecamp::has_level( const std::string &type, int min_level, const std::string &dir ) const
124157
{
@@ -204,7 +237,7 @@ void basecamp::reset_camp_workers()
204237
camp_workers.clear();
205238
for( const auto &elem : overmap_buffer.get_companion_mission_npcs() ) {
206239
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" ) {
208241
camp_workers.push_back( elem );
209242
}
210243
}
@@ -224,6 +257,28 @@ comp_list basecamp::get_mission_workers( const std::string &mission_id, bool con
224257
return available;
225258
}
226259

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+
227282
// display names
228283
std::string basecamp::expansion_tab( const std::string &dir ) const
229284
{

src/basecamp.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,32 @@ class basecamp
3232
{
3333
public:
3434
basecamp();
35-
basecamp( const std::string &name_, const tripoint &pos_ );
36-
basecamp( const std::string &name_, const tripoint &bb_pos_, const tripoint &pos_,
37-
std::vector<tripoint> sort_points_, std::vector<std::string> directions_,
38-
std::map<std::string, expansion_data> expansions_ );
35+
basecamp( const std::string &name_, const tripoint &omt_pos );
36+
basecamp( const std::string &name_, const tripoint &bb_pos_, std::vector<tripoint> sort_points_,
37+
std::vector<std::string> directions_, std::map<std::string, expansion_data> expansions_ );
3938

4039
inline bool is_valid() const {
41-
return !name.empty() && pos != tripoint_zero;
40+
return !name.empty() && omt_pos != tripoint_zero;
4241
}
4342
inline int board_x() const {
4443
return bb_pos.x;
4544
}
4645
inline int board_y() const {
4746
return bb_pos.y;
4847
}
49-
tripoint camp_pos() const {
50-
return pos;
48+
inline tripoint camp_omt_pos() const {
49+
return omt_pos;
5150
}
5251
inline const std::string &camp_name() const {
5352
return name;
5453
}
5554
std::string board_name() const;
5655
std::vector<tripoint> sort_points;
5756
std::vector<std::string> directions;
58-
57+
std::string name;
58+
//change name of camp
59+
void set_name( const std::string &new_name );
60+
void query_new_name();
5961
void add_expansion( const std::string &terrain, const tripoint &new_pos );
6062
void define_camp( npc &p );
6163

@@ -120,6 +122,7 @@ class basecamp
120122
const std::vector<item *> &equipment,
121123
const std::string &skill_tested, int skill_level );
122124
void start_upgrade( const std::string &bldg, const std::string &key );
125+
std::string om_upgrade_description( const std::string &bldg, bool trunc );
123126
/// Called when a companion is sent to cut logs
124127
void start_cut_logs();
125128
void start_clearcut();
@@ -172,9 +175,8 @@ class basecamp
172175
void deserialize( JsonIn &jsin );
173176
void load_data( const std::string &data );
174177
private:
175-
std::string name;
176-
// location of the camp in the overmap
177-
tripoint pos;
178+
// omt pos
179+
tripoint omt_pos;
178180
// location of associated bulletin board
179181
tripoint bb_pos;
180182
std::map<std::string, expansion_data> expansions;

src/character.cpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,87 @@ int Character::get_thirst() const
19091909
return thirst;
19101910
}
19111911

1912+
std::pair<std::string, nc_color> Character::get_thirst_description() const
1913+
{
1914+
int thirst = get_thirst();
1915+
std::string hydration_string;
1916+
nc_color hydration_color = c_white;
1917+
if( thirst > 520 ) {
1918+
hydration_color = c_light_red;
1919+
hydration_string = _( "Parched" );
1920+
} else if( thirst > 240 ) {
1921+
hydration_color = c_light_red;
1922+
hydration_string = _( "Dehydrated" );
1923+
} else if( thirst > 80 ) {
1924+
hydration_color = c_yellow;
1925+
hydration_string = _( "Very thirsty" );
1926+
} else if( thirst > 40 ) {
1927+
hydration_color = c_yellow;
1928+
hydration_string = _( "Thirsty" );
1929+
} else if( thirst < -60 ) {
1930+
hydration_color = c_green;
1931+
hydration_string = _( "Turgid" );
1932+
} else if( thirst < -20 ) {
1933+
hydration_color = c_green;
1934+
hydration_string = _( "Hydrated" );
1935+
} else if( thirst < 0 ) {
1936+
hydration_color = c_green;
1937+
hydration_string = _( "Slaked" );
1938+
}
1939+
return std::make_pair( hydration_string, hydration_color );
1940+
}
1941+
1942+
std::pair<std::string, nc_color> Character::get_hunger_description() const
1943+
{
1944+
int hunger = get_hunger();
1945+
std::string hunger_string;
1946+
nc_color hunger_color = c_white;
1947+
if( hunger >= 300 && get_starvation() > 2500 ) {
1948+
hunger_color = c_red;
1949+
hunger_string = _( "Starving!" );
1950+
} else if( hunger >= 300 && get_starvation() > 1100 ) {
1951+
hunger_color = c_light_red;
1952+
hunger_string = _( "Near starving" );
1953+
} else if( hunger > 250 ) {
1954+
hunger_color = c_light_red;
1955+
hunger_string = _( "Famished" );
1956+
} else if( hunger > 100 ) {
1957+
hunger_color = c_yellow;
1958+
hunger_string = _( "Very hungry" );
1959+
} else if( hunger > 40 ) {
1960+
hunger_color = c_yellow;
1961+
hunger_string = _( "Hungry" );
1962+
} else if( hunger < -60 ) {
1963+
hunger_color = c_green;
1964+
hunger_string = _( "Engorged" );
1965+
} else if( hunger < -20 ) {
1966+
hunger_color = c_green;
1967+
hunger_string = _( "Sated" );
1968+
} else if( hunger < 0 ) {
1969+
hunger_color = c_green;
1970+
hunger_string = _( "Full" );
1971+
}
1972+
return std::make_pair( hunger_string, hunger_color );
1973+
}
1974+
1975+
std::pair<std::string, nc_color> Character::get_fatigue_description() const
1976+
{
1977+
int fatigue = get_fatigue();
1978+
std::string fatigue_string;
1979+
nc_color fatigue_color = c_white;
1980+
if( fatigue > EXHAUSTED ) {
1981+
fatigue_color = c_red;
1982+
fatigue_string = _( "Exhausted" );
1983+
} else if( fatigue > DEAD_TIRED ) {
1984+
fatigue_color = c_light_red;
1985+
fatigue_string = _( "Dead Tired" );
1986+
} else if( fatigue > TIRED ) {
1987+
fatigue_color = c_yellow;
1988+
fatigue_string = _( "Tired" );
1989+
}
1990+
return std::make_pair( fatigue_string, fatigue_color );
1991+
}
1992+
19121993
void Character::mod_thirst( int nthirst )
19131994
{
19141995
set_thirst( thirst + nthirst );

src/character.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ class Character : public Creature, public visitable<Character>
220220
virtual int get_hunger() const;
221221
virtual int get_starvation() const;
222222
virtual int get_thirst() const;
223+
virtual std::pair<std::string, nc_color> get_thirst_description() const;
224+
virtual std::pair<std::string, nc_color> get_hunger_description() const;
225+
virtual std::pair<std::string, nc_color> get_fatigue_description() const;
223226
virtual int get_fatigue() const;
224227
virtual int get_sleep_deprivation() const;
225228
virtual int get_stomach_food() const;

0 commit comments

Comments
 (0)