Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,21 @@ void flee_battle(ConsoleHandle& console, ProControllerContext& context){
}
}

void home_black_border_check(ConsoleHandle& console, ProControllerContext& context){
console.log("Going to home to check for black border.");
pbf_press_button(context, BUTTON_HOME, 120ms, 880ms);
context.wait_for_all_requests();
StartProgramChecks::check_border(console);
console.log("Returning to game.");
resume_game_from_home(console, context);
context.wait_for_all_requests();
console.log("Entered game.");
void home_black_border_check(ConsoleHandle& console, ProControllerContext& context) {
if (GameSettings::instance().DEVICE == GameSettings::Device::switch_1_2) {
console.log("Switch 1 or 2 selected in Settings.");
console.log("Going to home to check for black border.");
pbf_press_button(context, BUTTON_HOME, 120ms, 880ms);
context.wait_for_all_requests();
StartProgramChecks::check_border(console);
console.log("Returning to game.");
resume_game_from_home(console, context);
context.wait_for_all_requests();
console.log("Entered game.");
}else{
console.log("Non-Switch device selected in Settings.");
console.log("Skipping black border check.", COLOR_BLUE);
}
}


Expand Down
3 changes: 1 addition & 2 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ namespace PokemonFRLG{

// Press A+B+Select+Start at the same time to soft reset, then re-enters the game.
// There are two random waits, one before pressing start and another after loading in the game.
// This is to prevent repeatedly getting the same pokemon, due to FRLG's RNG
// For now this assumes no dry battery.
// This is to prevent repeatedly getting the same pokemon, due to FRLG's RNG.
uint64_t soft_reset(ConsoleHandle& console, ProControllerContext &context);

// From the overworld, open the summary of the Pokemon in slot 6. This assumes the menu cursor is in the top slot (POKEDEX)
Expand Down
59 changes: 58 additions & 1 deletion SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,28 @@ GameSettings& GameSettings::instance(){
static GameSettings settings;
return settings;
}
GameSettings::~GameSettings(){
DEVICE.remove_listener(*this);
GAME_BOX.remove_listener(*this);
GAME_BOX.X.remove_listener(*this);
GAME_BOX.Y.remove_listener(*this);
GAME_BOX.WIDTH.remove_listener(*this);
GAME_BOX.HEIGHT.remove_listener(*this);
}
GameSettings::GameSettings()
: BatchOption(LockMode::LOCK_WHILE_RUNNING)
, m_game_device_settings("<font size=4><b>Game Device settings:</b></font>")
, DEVICE(
"<b>Device:</b><br>Select the device the game is running on. "
"Refer to the documentation for specific setups.",
{
{Device::switch_1_2, "switch_1_2", "Nintendo Switch 1 and 2"},
//{Device::dev_test, "dev_test", "dev test rg35xx"},
//{Device::custom, "custom", "Custom"},
},
LockMode::LOCK_WHILE_RUNNING,
Device::switch_1_2
)
, GAME_BOX(
"Game Box: The part of the screen containing the actual video feed.",
LockMode::LOCK_WHILE_RUNNING,
Expand Down Expand Up @@ -57,16 +77,53 @@ GameSettings::GameSettings()
1000, 0, 48000 //2000
)
{
PA_ADD_STATIC(m_game_device_settings);
PA_ADD_OPTION(DEVICE);
PA_ADD_STATIC(GAME_BOX);
PA_ADD_STATIC(m_soft_reset_timings);
PA_ADD_OPTION(SELECT_BUTTON_MASH0);
PA_ADD_OPTION(ENTER_GAME_WAIT0);
PA_ADD_STATIC(m_shiny_audio_settings);
PA_ADD_OPTION(SHINY_SOUND_THRESHOLD);
PA_ADD_OPTION(SHINY_SOUND_LOW_FREQUENCY);
}

GameSettings::on_config_value_changed(this);
DEVICE.add_listener(*this);
GAME_BOX.add_listener(*this);
GAME_BOX.X.add_listener(*this);
GAME_BOX.Y.add_listener(*this);
GAME_BOX.WIDTH.add_listener(*this);
GAME_BOX.HEIGHT.add_listener(*this);
}

void GameSettings::on_config_value_changed(void* object){
switch (DEVICE){
case Device::switch_1_2:
GAME_BOX.X.set(0.09375);
GAME_BOX.Y.set(0.00462963);
GAME_BOX.WIDTH.set(0.8125);
GAME_BOX.HEIGHT.set(0.962963);
GAME_BOX.set_visibility(ConfigOptionState::DISABLED);
break;
case Device::dev_test:
GAME_BOX.X.set(0.125);
GAME_BOX.Y.set(0.0564814814814815);
GAME_BOX.WIDTH.set(0.7494791666666667);
GAME_BOX.HEIGHT.set(0.8861111111111111);
GAME_BOX.set_visibility(ConfigOptionState::DISABLED);
break;
case Device::custom:
GAME_BOX.set_visibility(ConfigOptionState::ENABLED);
break;
default:
GAME_BOX.X.set(0.09375);
GAME_BOX.Y.set(0.00462963);
GAME_BOX.WIDTH.set(0.8125);
GAME_BOX.HEIGHT.set(0.962963);
GAME_BOX.set_visibility(ConfigOptionState::ENABLED);
break;
}
}



Expand Down
16 changes: 14 additions & 2 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef PokemonAutomation_PokemonFRLG_Settings_H
#define PokemonAutomation_PokemonFRLG_Settings_H

#include "Common/Cpp/Options/EnumDropdownOption.h"
#include "Common/Cpp/Options/StaticTextOption.h"
#include "Common/Cpp/Options/FloatingPointOption.h"
#include "Common/Cpp/Options/TimeDurationOption.h"
Expand All @@ -18,11 +19,21 @@ namespace NintendoSwitch{
namespace PokemonFRLG{


class GameSettings : public BatchOption{
class GameSettings : public BatchOption, private ConfigOption::Listener{
~GameSettings();
GameSettings();
public:
static GameSettings& instance();

enum class Device{
switch_1_2,
dev_test,
custom,
};

SectionDividerOption m_game_device_settings;
EnumDropdownOption<Device> DEVICE;

BoxOption GAME_BOX;

SectionDividerOption m_soft_reset_timings;
Expand All @@ -34,11 +45,12 @@ class GameSettings : public BatchOption{
FloatingPointOption SHINY_SOUND_THRESHOLD;
FloatingPointOption SHINY_SOUND_LOW_FREQUENCY;

private:
virtual void on_config_value_changed(void* object) override;
};




class GameSettings_Descriptor : public PanelDescriptor{
public:
GameSettings_Descriptor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ GiftReset::GiftReset()
&NOTIFICATION_SHINY,
&NOTIFICATION_STATUS_UPDATE,
&NOTIFICATION_PROGRAM_FINISH,
&NOTIFICATION_ERROR_RECOVERABLE,
})
{
PA_ADD_OPTION(TARGET);
Expand Down Expand Up @@ -126,6 +127,7 @@ void GiftReset::obtain_pokemon(SingleSwitchProgramEnvironment& env, ProControlle
}
env.log("Initial A press completed.");
}else{
//Need to double check what the first dialog box is for the other gifts
pbf_press_button(context, BUTTON_A, 320ms, 640ms);
}
bool seen_selection_arrow = false;
Expand Down Expand Up @@ -253,6 +255,10 @@ bool GiftReset::try_open_summary(SingleSwitchProgramEnvironment& env, ProControl
if (ret < 0){
env.update_stats();
env.log("open_summary(): Unable to open Start menu after 10 attempts.", COLOR_RED);
send_program_recoverable_error_notification(
env, NOTIFICATION_ERROR_RECOVERABLE,
"open_summary(): Unable to open Start menu after 10 attempts."
);
return false;
}

Expand Down Expand Up @@ -282,6 +288,10 @@ bool GiftReset::try_open_summary(SingleSwitchProgramEnvironment& env, ProControl
env.log("Entered party menu.");
}else{
env.log("open_summary(): Unable to enter party menu.", COLOR_RED);
send_program_recoverable_error_notification(
env, NOTIFICATION_ERROR_RECOVERABLE,
"open_summary(): Unable to enter party menu."
);
return false;
}

Expand All @@ -307,6 +317,10 @@ bool GiftReset::try_open_summary(SingleSwitchProgramEnvironment& env, ProControl
env.log("Entered summary.");
}else{
env.log("open_summary(): Unable to enter summary.", COLOR_RED);
send_program_recoverable_error_notification(
env, NOTIFICATION_ERROR_RECOVERABLE,
"open_summary(): Unable to enter summary."
);
return false;
}
pbf_wait(context, 1000ms);
Expand Down