Skip to content

Commit fa97389

Browse files
committed
Migrate BDSP programs to TimeDurationOption.
1 parent 396dd6d commit fa97389

34 files changed

+150
-156
lines changed

SerialPrograms/Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void ssf_press_left_joystick(
6262
void ssf_press_left_joystick(
6363
SwitchControllerContext& context,
6464
uint8_t x, uint8_t y,
65-
Milliseconds delay, Milliseconds hold = 5*8ms, Milliseconds cool = 3*8ms
65+
Milliseconds delay, Milliseconds hold, Milliseconds cool = 0ms
6666
);
6767
void ssf_press_right_joystick(
6868
SwitchControllerContext& context,
@@ -72,7 +72,7 @@ void ssf_press_right_joystick(
7272
void ssf_press_right_joystick(
7373
SwitchControllerContext& context,
7474
uint8_t x, uint8_t y,
75-
Milliseconds delay, Milliseconds hold = 5*8ms, Milliseconds cool = 3*8ms
75+
Milliseconds delay, Milliseconds hold, Milliseconds cool = 0ms
7676
);
7777

7878

SerialPrograms/Source/PokemonBDSP/Programs/Eggs/PokemonBDSP_EggAutonomous.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ EggAutonomous::EggAutonomous()
5757
LockMode::LOCK_WHILE_RUNNING,
5858
10, 1, 30
5959
)
60-
, TRAVEL_TIME_PER_FETCH(
60+
, TRAVEL_TIME_PER_FETCH0(
6161
"<b>Travel Time per Fetch:</b><br>Fetch an egg after traveling for this long.",
6262
LockMode::LOCK_WHILE_RUNNING,
63-
TICKS_PER_SECOND,
64-
"20 * TICKS_PER_SECOND"
63+
"20s"
6564
)
6665
, NUM_EGGS_IN_COLUMN(
6766
"<b>Num Eggs in Column:</b><br>How many eggs already deposited in the first column in Box 1.",
@@ -121,25 +120,24 @@ EggAutonomous::EggAutonomous()
121120
, m_advanced_options(
122121
"<font size=4><b>Advanced Options:</b> You should not need to touch anything below here.</font>"
123122
)
124-
, SCROLL_TO_READ_DELAY(
123+
, SCROLL_TO_READ_DELAY0(
125124
"<b>Scroll to Read Delay:</b><br>Wait this long after scrolling in the box to read the " + STRING_POKEMON + "'s stats. "
126125
"Increase this if your video has high latency.",
127126
LockMode::LOCK_WHILE_RUNNING,
128-
TICKS_PER_SECOND,
129-
"125"
127+
"1000ms"
130128
)
131129
{
132130
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
133131
PA_ADD_OPTION(LANGUAGE);
134132
PA_ADD_OPTION(SHORTCUT);
135133
PA_ADD_OPTION(MAX_KEEPERS);
136-
PA_ADD_OPTION(TRAVEL_TIME_PER_FETCH);
134+
PA_ADD_OPTION(TRAVEL_TIME_PER_FETCH0);
137135
PA_ADD_OPTION(NUM_EGGS_IN_COLUMN);
138136
PA_ADD_OPTION(AUTO_SAVING);
139137
PA_ADD_OPTION(FILTERS0);
140138
PA_ADD_OPTION(NOTIFICATIONS);
141139
PA_ADD_STATIC(m_advanced_options);
142-
PA_ADD_OPTION(SCROLL_TO_READ_DELAY);
140+
PA_ADD_OPTION(SCROLL_TO_READ_DELAY0);
143141
}
144142

145143

@@ -192,10 +190,10 @@ void EggAutonomous::program(SingleSwitchProgramEnvironment& env, SwitchControlle
192190
stats,
193191
NOTIFICATION_NONSHINY_KEEP,
194192
NOTIFICATION_SHINY,
195-
SCROLL_TO_READ_DELAY,
193+
SCROLL_TO_READ_DELAY0,
196194
LANGUAGE,
197195
SHORTCUT,
198-
TRAVEL_TIME_PER_FETCH,
196+
TRAVEL_TIME_PER_FETCH0,
199197
FILTERS0,
200198
MAX_KEEPERS,
201199
static_cast<uint8_t>(NUM_EGGS_IN_COLUMN.current_value())

SerialPrograms/Source/PokemonBDSP/Programs/Eggs/PokemonBDSP_EggAutonomous.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "Common/Cpp/Options/StaticTextOption.h"
1111
#include "Common/Cpp/Options/SimpleIntegerOption.h"
12-
#include "Common/Cpp/Options/TimeExpressionOption.h"
12+
#include "Common/Cpp/Options/TimeDurationOption.h"
1313
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1414
#include "CommonTools/Options/LanguageOCROption.h"
1515
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
@@ -50,7 +50,7 @@ class EggAutonomous : public SingleSwitchProgramInstance{
5050

5151
ShortcutDirectionOption SHORTCUT;
5252
SimpleIntegerOption<uint8_t> MAX_KEEPERS;
53-
TimeExpressionOption<uint16_t> TRAVEL_TIME_PER_FETCH;
53+
MillisecondsOption TRAVEL_TIME_PER_FETCH0;
5454
IntegerEnumDropdownOption NUM_EGGS_IN_COLUMN;
5555

5656
enum class AutoSave{
@@ -68,7 +68,7 @@ class EggAutonomous : public SingleSwitchProgramInstance{
6868
EventNotificationsOption NOTIFICATIONS;
6969

7070
SectionDividerOption m_advanced_options;
71-
TimeExpressionOption<uint16_t> SCROLL_TO_READ_DELAY;
71+
MillisecondsOption SCROLL_TO_READ_DELAY0;
7272
};
7373

7474

SerialPrograms/Source/PokemonBDSP/Programs/Eggs/PokemonBDSP_EggAutonomousState.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ EggAutonomousState::EggAutonomousState(
9898
EggAutonomousStats& stats,
9999
EventNotificationOption& notification_nonshiny_keep,
100100
EventNotificationOption& notification_shiny,
101-
uint16_t scroll_to_read_delay,
101+
Milliseconds scroll_to_read_delay,
102102
Language language,
103103
ShortcutDirectionOption& shortcut,
104-
uint16_t travel_time_per_fetch,
104+
Milliseconds travel_time_per_fetch,
105105
const StatsHuntIvJudgeFilterTable& filters,
106106
uint8_t max_keepers,
107107
uint8_t existing_eggs_in_columns
@@ -454,8 +454,7 @@ void EggAutonomousState::hatch_rest_of_party(){
454454
int ret = run_until<SwitchControllerContext>(
455455
m_stream, m_context,
456456
[&](SwitchControllerContext& context){
457-
egg_spin(context, 480 * TICKS_PER_SECOND);
458-
// egg_spin(context, 5 * TICKS_PER_SECOND);
457+
egg_spin(context, 8min);
459458
},
460459
{
461460
{dialog},

SerialPrograms/Source/PokemonBDSP/Programs/Eggs/PokemonBDSP_EggAutonomousState.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ class EggAutonomousState{
4040
EggAutonomousStats& stats,
4141
EventNotificationOption& notification_nonshiny_keep,
4242
EventNotificationOption& notification_shiny,
43-
uint16_t scroll_to_read_delay,
43+
Milliseconds scroll_to_read_delay,
4444
Language language,
4545
ShortcutDirectionOption& shortcut,
46-
uint16_t travel_time_per_fetch,
46+
Milliseconds travel_time_per_fetch,
4747
const Pokemon::StatsHuntIvJudgeFilterTable& filters,
4848
uint8_t max_keepers,
4949
uint8_t existing_eggs_in_columns
@@ -85,10 +85,10 @@ class EggAutonomousState{
8585
static EventNotificationOption m_notification_noop;
8686
EventNotificationOption& m_notification_nonshiny_keep;
8787
EventNotificationOption& m_notification_shiny;
88-
uint16_t m_scroll_to_read_delay;
88+
Milliseconds m_scroll_to_read_delay;
8989
Language m_language;
9090
ShortcutDirectionOption& m_shortcut;
91-
uint16_t m_travel_time_per_fetch;
91+
Milliseconds m_travel_time_per_fetch;
9292
const Pokemon::StatsHuntIvJudgeFilterTable& m_filters;
9393
uint8_t m_max_keepers;
9494

SerialPrograms/Source/PokemonBDSP/Programs/Eggs/PokemonBDSP_EggFeedback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void hatch_egg(VideoStream& stream, SwitchControllerContext& context){
3535
int ret = run_until<SwitchControllerContext>(
3636
stream, context,
3737
[](SwitchControllerContext& context){
38-
egg_spin(context, 480 * TICKS_PER_SECOND);
38+
egg_spin(context, 8min);
3939
},
4040
{
4141
{dialog},

SerialPrograms/Source/PokemonBDSP/Programs/Eggs/PokemonBDSP_EggFetcher.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ EggFetcher::EggFetcher()
5151
LockMode::LOCK_WHILE_RUNNING,
5252
2000
5353
)
54-
, TRAVEL_TIME_PER_FETCH(
54+
, TRAVEL_TIME_PER_FETCH0(
5555
"<b>Travel Time per Fetch:</b><br>Fetch an egg after traveling for this long.",
5656
LockMode::LOCK_WHILE_RUNNING,
57-
TICKS_PER_SECOND,
58-
"15 * TICKS_PER_SECOND"
57+
"15s"
5958
)
6059
, NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600))
6160
, NOTIFICATIONS({
@@ -67,7 +66,7 @@ EggFetcher::EggFetcher()
6766
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
6867
PA_ADD_OPTION(SHORTCUT);
6968
PA_ADD_OPTION(MAX_FETCH_ATTEMPTS);
70-
PA_ADD_OPTION(TRAVEL_TIME_PER_FETCH);
69+
PA_ADD_OPTION(TRAVEL_TIME_PER_FETCH0);
7170
PA_ADD_OPTION(NOTIFICATIONS);
7271
}
7372

@@ -86,7 +85,7 @@ void EggFetcher::program(SingleSwitchProgramEnvironment& env, SwitchControllerCo
8685
env.update_stats();
8786
send_program_status_notification(env, NOTIFICATION_STATUS_UPDATE);
8887

89-
egg_spin_with_A(context, TRAVEL_TIME_PER_FETCH);
88+
egg_spin_with_A(context, TRAVEL_TIME_PER_FETCH0);
9089
SHORTCUT.run(context, 100);
9190

9291
// Move to man.

SerialPrograms/Source/PokemonBDSP/Programs/Eggs/PokemonBDSP_EggFetcher.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define PokemonAutomation_PokemonBDSP_EggFetcher_H
99

1010
#include "Common/Cpp/Options/SimpleIntegerOption.h"
11-
#include "Common/Cpp/Options/TimeExpressionOption.h"
11+
#include "Common/Cpp/Options/TimeDurationOption.h"
1212
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1313
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
1414
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
@@ -42,7 +42,7 @@ class EggFetcher : public SingleSwitchProgramInstance{
4242

4343
ShortcutDirectionOption SHORTCUT;
4444
SimpleIntegerOption<uint16_t> MAX_FETCH_ATTEMPTS;
45-
TimeExpressionOption<uint16_t> TRAVEL_TIME_PER_FETCH;
45+
MillisecondsOption TRAVEL_TIME_PER_FETCH0;
4646

4747
EventNotificationOption NOTIFICATION_STATUS_UPDATE;
4848
EventNotificationsOption NOTIFICATIONS;

SerialPrograms/Source/PokemonBDSP/Programs/Eggs/PokemonBDSP_EggHatcher.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,15 @@ EggHatcher::EggHatcher()
6767
, m_advanced_options(
6868
"<font size=4><b>Advanced Options:</b> You should not need to touch anything below here.</font>"
6969
)
70-
, SAFETY_TIME0(
70+
, SAFETY_TIME1(
7171
"<b>Safety Time:</b><br>Additional time added to the spinning.",
7272
LockMode::LOCK_WHILE_RUNNING,
73-
TICKS_PER_SECOND,
74-
"10 * TICKS_PER_SECOND"
73+
"10000ms"
7574
)
76-
, HATCH_DELAY(
75+
, HATCH_DELAY0(
7776
"<b>Hatch Delay:</b><br>Total animation time for hatching 5 eggs when there are no shinies.",
7877
LockMode::LOCK_WHILE_RUNNING,
79-
TICKS_PER_SECOND,
80-
"105 * TICKS_PER_SECOND"
78+
"105s"
8179
)
8280
{
8381
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
@@ -86,8 +84,8 @@ EggHatcher::EggHatcher()
8684
PA_ADD_OPTION(STEPS_TO_HATCH);
8785
PA_ADD_OPTION(SAVE_AND_RESET);
8886
PA_ADD_STATIC(m_advanced_options);
89-
PA_ADD_OPTION(SAFETY_TIME0);
90-
PA_ADD_OPTION(HATCH_DELAY);
87+
PA_ADD_OPTION(SAFETY_TIME1);
88+
PA_ADD_OPTION(HATCH_DELAY0);
9189
}
9290

9391

@@ -96,8 +94,8 @@ EggHatcher::EggHatcher()
9694
void EggHatcher::program(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context){
9795
EggHatcher_Descriptor::Stats& stats = env.current_stats<EggHatcher_Descriptor::Stats>();
9896

99-
uint16_t INCUBATION_TIME = (uint16_t)((1258.5 + 4.05 * STEPS_TO_HATCH) * 1.05);
100-
uint16_t TOTAL_DELAY = INCUBATION_TIME + SAFETY_TIME0 + HATCH_DELAY;
97+
Milliseconds INCUBATION_TIME = (uint16_t)((1258.5 + 4.05 * STEPS_TO_HATCH) * 1.05) * 8ms;
98+
Milliseconds TOTAL_DELAY = INCUBATION_TIME + SAFETY_TIME1.get() + HATCH_DELAY0.get();
10199

102100
// Connect the controller.
103101
pbf_move_right_joystick(context, 0, 255, 10, 0);

SerialPrograms/Source/PokemonBDSP/Programs/Eggs/PokemonBDSP_EggHatcher.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "Common/Cpp/Options/StaticTextOption.h"
1111
#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
1212
#include "Common/Cpp/Options/SimpleIntegerOption.h"
13-
#include "Common/Cpp/Options/TimeExpressionOption.h"
13+
#include "Common/Cpp/Options/TimeDurationOption.h"
1414
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1515
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
1616
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
@@ -51,8 +51,8 @@ class EggHatcher : public SingleSwitchProgramInstance{
5151
EventNotificationsOption NOTIFICATIONS;
5252

5353
SectionDividerOption m_advanced_options;
54-
TimeExpressionOption<uint16_t> SAFETY_TIME0;
55-
TimeExpressionOption<uint16_t> HATCH_DELAY;
54+
MillisecondsOption SAFETY_TIME1;
55+
MillisecondsOption HATCH_DELAY0;
5656
};
5757

5858

0 commit comments

Comments
 (0)