Skip to content

Commit 81d1e9e

Browse files
author
Gin
committed
add village warp points to LA travel locations
1 parent 932334e commit 81d1e9e

10 files changed

+130
-55
lines changed

SerialPrograms/Source/PokemonLA/Options/PokemonLA_CustomPathTable.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,21 @@ void CustomPathCell::on_config_value_changed(void* object){
176176

177177

178178

179-
CustomPathTableRow2::CustomPathTableRow2(EditableTableOption& parent_table)
179+
CustomPathTableRow::CustomPathTableRow(EditableTableOption& parent_table)
180180
: EditableTableRow(parent_table)
181181
, action(PathAction_Database(), LockMode::LOCK_WHILE_RUNNING, PathAction::NO_ACTION)
182182
, parameters(action)
183183
{
184184
PA_ADD_OPTION(action);
185185
PA_ADD_OPTION(parameters);
186186
}
187-
std::unique_ptr<EditableTableRow> CustomPathTableRow2::clone() const{
188-
std::unique_ptr<CustomPathTableRow2> ret(new CustomPathTableRow2(parent()));
187+
std::unique_ptr<EditableTableRow> CustomPathTableRow::clone() const{
188+
std::unique_ptr<CustomPathTableRow> ret(new CustomPathTableRow(parent()));
189189
ret->action.set(action);
190190
ret->parameters = parameters;
191191
return ret;
192192
}
193-
void CustomPathTableRow2::load_json(const JsonValue& json){
193+
void CustomPathTableRow::load_json(const JsonValue& json){
194194
const JsonObject* obj = json.to_object();
195195
if (obj == nullptr){
196196
return;
@@ -269,7 +269,7 @@ void CustomPathTableRow2::load_json(const JsonValue& json){
269269
break;
270270
}
271271
}
272-
JsonValue CustomPathTableRow2::to_json() const{
272+
JsonValue CustomPathTableRow::to_json() const{
273273
JsonObject obj;
274274
obj["Action"] = action.to_json();
275275
switch (action){
@@ -298,8 +298,8 @@ JsonValue CustomPathTableRow2::to_json() const{
298298
return obj;
299299
}
300300

301-
CustomPathTable2::CustomPathTable2()
302-
: EditableTableOption_t<CustomPathTableRow2>(
301+
CustomPathTable::CustomPathTable()
302+
: EditableTableOption_t<CustomPathTableRow>(
303303
"<b>Custom Path Table:</b><br>"
304304
"Set a sequence of actions to navigate the map. By default, the shiny detected behavior is \"Enroute Shiny Action\".<br>"
305305
"<font color=\"red\">If you wish to ignore enroute shinies, make sure you set \"Enroute Shiny Action\" to ignore shinies.</font>",
@@ -308,35 +308,35 @@ CustomPathTable2::CustomPathTable2()
308308
make_defaults()
309309
)
310310
{}
311-
std::vector<std::string> CustomPathTable2::make_header() const{
311+
std::vector<std::string> CustomPathTable::make_header() const{
312312
return std::vector<std::string>{
313313
"Action",
314314
"Parameters",
315315
};
316316
}
317-
std::vector<std::unique_ptr<EditableTableRow>> CustomPathTable2::make_defaults(){
317+
std::vector<std::unique_ptr<EditableTableRow>> CustomPathTable::make_defaults(){
318318
std::vector<std::unique_ptr<EditableTableRow>> ret;
319-
auto row = std::make_unique<CustomPathTableRow2>(*this);
319+
auto row = std::make_unique<CustomPathTableRow>(*this);
320320
row->action.set(PathAction::START_LISTEN);
321321
ret.emplace_back(std::move(row));
322322

323-
row = std::make_unique<CustomPathTableRow2>(*this);
323+
row = std::make_unique<CustomPathTableRow>(*this);
324324
row->action.set(PathAction::CHANGE_MOUNT);
325325
row->parameters.mount.set(PathMount::WYRDEER);
326326
ret.emplace_back(std::move(row));
327327

328-
row = std::make_unique<CustomPathTableRow2>(*this);
328+
row = std::make_unique<CustomPathTableRow>(*this);
329329
row->action.set(PathAction::MOVE_IN_DIRECTION);
330330
row->parameters.move_forward.set("3200 ms");
331331
row->parameters.left_x.set(-1.0);
332332
row->parameters.left_y.set(1.0);
333333
ret.emplace_back(std::move(row));
334334

335-
row = std::make_unique<CustomPathTableRow2>(*this);
335+
row = std::make_unique<CustomPathTableRow>(*this);
336336
row->action.set(PathAction::CENTER_CAMERA);
337337
ret.emplace_back(std::move(row));
338338

339-
row = std::make_unique<CustomPathTableRow2>(*this);
339+
row = std::make_unique<CustomPathTableRow>(*this);
340340
row->action.set(PathAction::MOVE_FORWARD);
341341
row->parameters.move_speed.set(PathSpeed::DASH);
342342
row->parameters.move_forward.set("3200 ms");
@@ -353,7 +353,7 @@ std::vector<std::unique_ptr<EditableTableRow>> CustomPathTable2::make_defaults()
353353

354354

355355

356-
CustomPathTable::CustomPathTable()
356+
CustomPathTableFromJubilife::CustomPathTableFromJubilife()
357357
: BatchOption(LockMode::LOCK_WHILE_RUNNING)
358358
// : PATH(
359359
// "<b>Custom Path Table:</b><br>"
@@ -369,7 +369,7 @@ CustomPathTable::CustomPathTable()
369369

370370
class CustomPathTableWidget : public QWidget, public ConfigWidget{
371371
public:
372-
CustomPathTableWidget(QWidget& parent, CustomPathTable& value)
372+
CustomPathTableWidget(QWidget& parent, CustomPathTableFromJubilife& value)
373373
: QWidget(&parent)
374374
, ConfigWidget(value, *this)
375375
{
@@ -396,7 +396,7 @@ class CustomPathTableWidget : public QWidget, public ConfigWidget{
396396

397397
connect(load_button, &QPushButton::clicked, this, [&value, this](bool){
398398
std::string path = QFileDialog::getOpenFileName(this, tr("Open option file"), ".", "*.json").toStdString();
399-
std::cout << "Load CustomPathTable from " << path << std::endl;
399+
std::cout << "Load CustomPathTableFromJubilife from " << path << std::endl;
400400
if (path.empty()){
401401
return;
402402
}
@@ -415,7 +415,7 @@ class CustomPathTableWidget : public QWidget, public ConfigWidget{
415415

416416
connect(save_button, &QPushButton::clicked, this, [&value, this](bool){
417417
std::string path = QFileDialog::getSaveFileName(this, tr("Open option file"), ".", "*.json").toStdString();
418-
std::cout << "Save CustomPathTable from " << path << std::endl;
418+
std::cout << "Save CustomPathTableFromJubilife from " << path << std::endl;
419419
if (path.size() > 0){
420420
try{
421421
JsonObject root;
@@ -435,7 +435,7 @@ class CustomPathTableWidget : public QWidget, public ConfigWidget{
435435
ConfigWidget* m_table_widget = nullptr;
436436
};
437437

438-
ConfigWidget* CustomPathTable::make_QtWidget(QWidget& parent){
438+
ConfigWidget* CustomPathTableFromJubilife::make_QtWidget(QWidget& parent){
439439
return new CustomPathTableWidget(parent, *this);
440440
}
441441

SerialPrograms/Source/PokemonLA/Options/PokemonLA_CustomPathTable.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class CustomPathCell : public BatchOption, private ConfigOption::Listener{
8181
MillisecondsOption wait;
8282
};
8383

84-
class CustomPathTableRow2 : public EditableTableRow{
84+
class CustomPathTableRow : public EditableTableRow{
8585
public:
86-
CustomPathTableRow2(EditableTableOption& parent_table);
86+
CustomPathTableRow(EditableTableOption& parent_table);
8787
virtual std::unique_ptr<EditableTableRow> clone() const override;
8888

8989
virtual void load_json(const JsonValue& json) override;
@@ -94,9 +94,9 @@ class CustomPathTableRow2 : public EditableTableRow{
9494
CustomPathCell parameters;
9595
};
9696

97-
class CustomPathTable2 : public EditableTableOption_t<CustomPathTableRow2>{
97+
class CustomPathTable : public EditableTableOption_t<CustomPathTableRow>{
9898
public:
99-
CustomPathTable2();
99+
CustomPathTable();
100100
virtual std::vector<std::string> make_header() const override;
101101

102102
private:
@@ -108,19 +108,19 @@ class CustomPathTable2 : public EditableTableOption_t<CustomPathTableRow2>{
108108

109109

110110
// A program option to build a custom path to navigate the map
111-
class CustomPathTable : public BatchOption{
111+
class CustomPathTableFromJubilife : public BatchOption{
112112
public:
113-
CustomPathTable();
113+
CustomPathTableFromJubilife();
114114

115-
const TravelLocationOption& travel_location() const{ return TRAVEL_LOCATION; }
115+
const WildTravelLocationOption& travel_location() const{ return TRAVEL_LOCATION; }
116116

117117
virtual ConfigWidget* make_QtWidget(QWidget& parent) override;
118118

119119
public:
120120
friend class CustomPathTableWidget;
121121

122-
TravelLocationOption TRAVEL_LOCATION;
123-
CustomPathTable2 PATH;
122+
WildTravelLocationOption TRAVEL_LOCATION;
123+
CustomPathTable PATH;
124124
};
125125

126126

SerialPrograms/Source/PokemonLA/Options/PokemonLA_TravelLocation.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,31 @@ namespace NintendoSwitch{
1212
namespace PokemonLA{
1313

1414

15-
TravelLocationOption::TravelLocationOption()
15+
WildTravelLocationOption::WildTravelLocationOption()
1616
: IntegerEnumDropdownOption(
1717
"<b>Start Location:</b><br>Travel from this location.",
18-
TravelLocations::instance().database(),
18+
TravelLocations::instance().database_outside_village(),
1919
LockMode::LOCK_WHILE_RUNNING,
2020
0
2121
)
2222
{}
2323

24-
TravelLocationOption::operator TravelLocation() const{
24+
WildTravelLocationOption::operator TravelLocation() const{
25+
size_t index = this->current_value();
26+
return TravelLocations::instance()[index];
27+
}
28+
29+
30+
AllTravelLocationOption::AllTravelLocationOption()
31+
: IntegerEnumDropdownOption(
32+
"<b>Start Location:</b><br>Travel from this location.",
33+
TravelLocations::instance().database_including_village(),
34+
LockMode::LOCK_WHILE_RUNNING,
35+
0
36+
)
37+
{}
38+
39+
AllTravelLocationOption::operator TravelLocation() const{
2540
size_t index = this->current_value();
2641
return TravelLocations::instance()[index];
2742
}

SerialPrograms/Source/PokemonLA/Options/PokemonLA_TravelLocation.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ namespace NintendoSwitch{
1515
namespace PokemonLA{
1616

1717

18-
class TravelLocationOption : public IntegerEnumDropdownOption{
18+
// Warp points in wild areas + custom location after hardcoded movement + ancient retreat
19+
class WildTravelLocationOption : public IntegerEnumDropdownOption{
1920
public:
20-
TravelLocationOption();
21+
WildTravelLocationOption();
2122
operator TravelLocation() const;
2223
};
2324

24-
25+
// All locations in WildTravelLocationOption + Jubilife village warp points
26+
class AllTravelLocationOption : public IntegerEnumDropdownOption{
27+
public:
28+
AllTravelLocationOption();
29+
operator TravelLocation() const;
30+
};
2531

2632

2733

SerialPrograms/Source/PokemonLA/PokemonLA_TravelLocations.cpp

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,22 @@ const TravelLocations& TravelLocations::instance(){
3737
static const TravelLocations locations;
3838
return locations;
3939
}
40-
const IntegerEnumDropdownDatabase& TravelLocations::database() const{
41-
return m_database;
42-
}
4340

4441

45-
void TravelLocations::add_location(const TravelLocation& location){
42+
void TravelLocations::add_location(const TravelLocation& location, bool inside_village){
4643
if (!m_map.emplace(location.display, &location).second){
4744
throw InternalProgramError(
4845
nullptr, PA_CURRENT_FUNCTION,
4946
std::string("Duplicate TravelLocation name: ") + location.display
5047
);
5148
}
5249
m_list.emplace_back(&location);
53-
m_database.add(m_list.size() - 1, location.slug, location.display, true);
50+
m_database_include_village.add(m_list.size() - 1, location.slug, location.display, true);
51+
52+
if (!inside_village){
53+
m_database_outside_village.add(m_list.size() - 1, location.slug, location.display, true);
54+
}
55+
5456
}
5557
TravelLocations::TravelLocations()
5658
: Fieldlands_Fieldlands(
@@ -170,6 +172,31 @@ TravelLocations::TravelLocations()
170172
"Ancient Retreat",
171173
MapRegion::RETREAT, 0, 0, nullptr, false
172174
)
175+
, Village_GalaxyHall(
176+
"village-galaxyhall",
177+
"Jubilife Village - Galaxy Hall",
178+
MapRegion::JUBILIFE, 0, 0, nullptr, false
179+
)
180+
, Village_FrontGate(
181+
"village-frontgate",
182+
"Jubilife Village - Front Gate",
183+
MapRegion::JUBILIFE, 0, 1, nullptr, false
184+
)
185+
, Village_PracticeField(
186+
"village-practicefield",
187+
"Jubilife Village - Practice Field",
188+
MapRegion::JUBILIFE, 0, 2, nullptr, false
189+
)
190+
, Village_Farm(
191+
"village-farm",
192+
"Jubilife Village - Farm",
193+
MapRegion::JUBILIFE, 0, 3, nullptr, false
194+
)
195+
, Village_TrainingGrounds(
196+
"village-traininggrounds",
197+
"Jubilife Village - Training Grounds",
198+
MapRegion::JUBILIFE, 0, 2, nullptr, true
199+
)
173200
{
174201
add_location(Fieldlands_Fieldlands);
175202
add_location(Fieldlands_Heights);
@@ -196,6 +223,13 @@ TravelLocations::TravelLocations()
196223
add_location(Icelands_PearlSettlement_SW);
197224
add_location(Icelands_Arena);
198225
add_location(Retreat);
226+
227+
const bool inside_village = true;
228+
add_location(Village_GalaxyHall, inside_village);
229+
add_location(Village_FrontGate, inside_village);
230+
add_location(Village_PracticeField, inside_village);
231+
add_location(Village_Farm, inside_village);
232+
add_location(Village_TrainingGrounds, inside_village);
199233
}
200234

201235

SerialPrograms/Source/PokemonLA/PokemonLA_TravelLocations.h

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ struct TravelLocation{
2727
const char* display;
2828

2929
MapRegion region;
30-
uint8_t warp_slot; // which menu slot to warp from the full-Hisui map when leaving the village.
31-
uint8_t warp_sub_slot; // which menu slot to warp the region map, if the location is a settlement or arena that requires an in-region warp.
32-
bool reverse_sub_menu_direction; // whether it is faster to go upwards in the in-region warp map to reach the destination slot.
30+
// which menu slot to warp from the full-Hisui map when leaving the village.
31+
uint8_t warp_slot;
32+
// which menu slot to warp across the region map, if the location is a settlement
33+
// or arena that requires an in-region warp.
34+
uint8_t warp_sub_slot;
35+
// whether it is faster to go upwards in the in-region warp map to reach the
36+
// destination slot.
37+
bool reverse_sub_menu_direction;
3338

3439
std::function<void(VideoStream& stream, ProControllerContext& context)> post_arrival_maneuver;
3540

@@ -43,14 +48,18 @@ struct TravelLocation{
4348
};
4449

4550

51+
// Singleton to return all travel locations from the Jubilife Village Gate
52+
// To create a program option to select travel location, use:
53+
// SerialPrograms/Source/PokemonLA/Options/PokemonLA_TravelLocation.h:TravelLocationOption
4654
class TravelLocations{
4755
public:
4856
static const TravelLocations& instance();
4957

5058
const TravelLocation& operator[](size_t index) const{
5159
return *m_list[index];
5260
}
53-
const IntegerEnumDropdownDatabase& database() const;
61+
const IntegerEnumDropdownDatabase& database_outside_village() const { return m_database_outside_village; }
62+
const IntegerEnumDropdownDatabase& database_including_village() const { return m_database_include_village; }
5463

5564

5665
public:
@@ -81,15 +90,21 @@ class TravelLocations{
8190

8291
const TravelLocation Retreat;
8392

93+
const TravelLocation Village_GalaxyHall;
94+
const TravelLocation Village_FrontGate;
95+
const TravelLocation Village_PracticeField;
96+
const TravelLocation Village_Farm;
97+
const TravelLocation Village_TrainingGrounds;
8498

8599
private:
86100
TravelLocations();
87-
void add_location(const TravelLocation& location);
101+
void add_location(const TravelLocation& location, bool inside_village = false);
88102

89103
std::vector<const TravelLocation*> m_list;
90104
std::map<std::string, const TravelLocation*> m_map;
91-
92-
IntegerEnumDropdownDatabase m_database;
105+
106+
IntegerEnumDropdownDatabase m_database_outside_village;
107+
IntegerEnumDropdownDatabase m_database_include_village;
93108
};
94109

95110

SerialPrograms/Source/PokemonLA/Programs/PokemonLA_RegionNavigation.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ void goto_camp_from_jubilife(
265265
context.wait_for(std::chrono::milliseconds(500));
266266

267267
DpadPosition direction = location.region < MapRegion::HIGHLANDS ? DPAD_RIGHT : DPAD_LEFT;
268+
if (location.region == MapRegion::JUBILIFE){
269+
OperationFailedException::fire(
270+
ErrorReport::SEND_ERROR_REPORT,
271+
std::string("Should not choose Jubilife Village as destination when leaving camp"),
272+
stream
273+
);
274+
}
268275

269276
// Move to region.
270277
MapRegion current_region = MapRegion::NONE;

0 commit comments

Comments
 (0)