@@ -33,35 +33,21 @@ ShinyRequiresAudioText::ShinyRequiresAudioText()
3333
3434
3535
36- ShinyDetectedActionOption::ShinyDetectedActionOption (
36+ OverworldShinyDetectedActionOption::OverworldShinyDetectedActionOption (
3737 std::string label, std::string description,
3838 std::string default_delay,
39- ShinyDetectedAction default_action
39+ OverworldShinyDetectedAction default_action
4040)
41- : ShinyDetectedActionOption(
42- label,
43- std::move (description),
44- label,
45- std::move(default_delay),
46- std::move(default_action)
47- )
48- {}
49- ShinyDetectedActionOption::ShinyDetectedActionOption (
50- std::string label, std::string description,
51- std::string notification_label,
52- std::string default_delay,
53- ShinyDetectedAction default_action
54- )
55- : GroupOption(std::move(label), LockMode::LOCK_WHILE_RUNNING)
41+ : GroupOption(std::move(label), LockMode::UNLOCK_WHILE_RUNNING)
5642 , DESCRIPTION(std::move(description))
5743 , ACTION(
5844 " <b>Shiny Detected Action:</b>" ,
5945 {
60- {ShinyDetectedAction ::IGNORE, " ignore" , " Ignore the shiny. Do not stop the program." },
61- {ShinyDetectedAction ::STOP_PROGRAM, " stop" , " Stop program. Align camera for a screenshot. Then go Home." },
62- {ShinyDetectedAction ::TAKE_VIDEO_STOP_PROGRAM, " video+stop" , " Stop program. Align camera for a screenshot + video. Then go Home." },
46+ {OverworldShinyDetectedAction ::IGNORE, " ignore" , " Ignore the shiny. Do not stop the program." },
47+ {OverworldShinyDetectedAction ::STOP_PROGRAM, " stop" , " Stop program. Align camera for a screenshot. Then go Home." },
48+ {OverworldShinyDetectedAction ::TAKE_VIDEO_STOP_PROGRAM, " video+stop" , " Stop program. Align camera for a screenshot + video. Then go Home." },
6349 },
64- LockMode::LOCK_WHILE_RUNNING ,
50+ LockMode::UNLOCK_WHILE_RUNNING ,
6551 default_action
6652 )
6753// , STOP_PROGRAM("<b>Stop Program:</b><br>Stop program and go Home if it hears a shiny.", true)
@@ -70,11 +56,11 @@ ShinyDetectedActionOption::ShinyDetectedActionOption(
7056 " <b>Screenshot Delay:</b><br>"
7157 " Align the camera, then wait this long before taking a screenshot + video of the shiny.<br>"
7258 " Set to zero to skip this. Don't set this too large or the shiny may run away!" ,
73- LockMode::LOCK_WHILE_RUNNING ,
59+ LockMode::UNLOCK_WHILE_RUNNING ,
7460 std::move (default_delay)
7561 )
7662 , NOTIFICATIONS(
77- std::move (notification_label ),
63+ this -> label ( ),
7864 true, true,
7965 ImageAttachmentMode::JPG,
8066 {" Notifs" , " Showcase" }
@@ -88,8 +74,30 @@ ShinyDetectedActionOption::ShinyDetectedActionOption(
8874// PA_ADD_OPTION(TAKE_VIDEO);
8975 PA_ADD_OPTION (SCREENSHOT_DELAY0);
9076}
91- bool ShinyDetectedActionOption::stop_on_shiny () const {
92- return ACTION != ShinyDetectedAction::IGNORE;
77+ bool OverworldShinyDetectedActionOption::stop_on_shiny () const {
78+ return ACTION != OverworldShinyDetectedAction::IGNORE;
79+ }
80+
81+
82+
83+ BattleMatchActionOption::BattleMatchActionOption (
84+ std::string label, std::string description,
85+ std::string default_delay
86+ )
87+ : GroupOption(std::move(label), LockMode::UNLOCK_WHILE_RUNNING)
88+ , DESCRIPTION(std::move(description))
89+ , TAKE_VIDEO(" <b>Take Video:</b>" , LockMode::UNLOCK_WHILE_RUNNING, true )
90+ , NOTIFICATIONS(
91+ this ->label (),
92+ true, true,
93+ ImageAttachmentMode::JPG,
94+ {" Notifs" , " Showcase" }
95+ )
96+ {
97+ if (!DESCRIPTION.text ().empty ()){
98+ PA_ADD_OPTION (DESCRIPTION);
99+ }
100+ PA_ADD_OPTION (TAKE_VIDEO);
93101}
94102
95103
@@ -99,7 +107,7 @@ bool ShinyDetectedActionOption::stop_on_shiny() const{
99107
100108bool on_shiny_callback (
101109 ProgramEnvironment& env, VideoStream& stream,
102- ShinyDetectedActionOption & options,
110+ OverworldShinyDetectedActionOption & options,
103111 float error_coefficient
104112){
105113 {
@@ -109,8 +117,8 @@ bool on_shiny_callback(
109117
110118 // If we're not ignoring the shiny, return now. Actions will be deferred
111119 // until after the session ends.
112- ShinyDetectedAction action = options.ACTION ;
113- if (action != ShinyDetectedAction ::IGNORE){
120+ OverworldShinyDetectedAction action = options.ACTION ;
121+ if (action != OverworldShinyDetectedAction ::IGNORE){
114122 return true ;
115123 }
116124 }
@@ -134,7 +142,7 @@ bool on_shiny_callback(
134142}
135143void on_shiny_sound (
136144 ProgramEnvironment& env, VideoStream& stream, ProControllerContext& context,
137- ShinyDetectedActionOption & options,
145+ OverworldShinyDetectedActionOption & options,
138146 float error_coefficient
139147){
140148 std::vector<std::pair<std::string, std::string>> embeds;
@@ -157,46 +165,45 @@ void on_shiny_sound(
157165 stream.video ().snapshot (), true
158166 );
159167
160- ShinyDetectedAction action = options.ACTION ;
161- if (action == ShinyDetectedAction::TAKE_VIDEO_STOP_PROGRAM){
168+ switch (options.ACTION ){
169+ case OverworldShinyDetectedAction::IGNORE:
170+ break ;
171+ case OverworldShinyDetectedAction::STOP_PROGRAM:
172+ pbf_press_button (context, BUTTON_HOME, 160ms, GameSettings::instance ().GAME_TO_HOME_DELAY0 );
173+ context.wait_for_all_requests ();
174+ throw ProgramFinishedException ();
175+ case OverworldShinyDetectedAction::TAKE_VIDEO_STOP_PROGRAM:
162176 pbf_press_button (context, BUTTON_CAPTURE, 2 * TICKS_PER_SECOND, 0 );
177+ pbf_press_button (context, BUTTON_HOME, 160ms, GameSettings::instance ().GAME_TO_HOME_DELAY0 );
178+ context.wait_for_all_requests ();
179+ throw ProgramFinishedException ();
163180 }
164-
165- pbf_press_button (context, BUTTON_HOME, 160ms, GameSettings::instance ().GAME_TO_HOME_DELAY0 );
166- context.wait_for_all_requests ();
167- throw ProgramFinishedException ();
168181}
169182
170- void on_match_found (
183+ void on_battle_match_found (
171184 ProgramEnvironment& env, VideoStream& stream, ProControllerContext& context,
172- ShinyDetectedActionOption& options, bool stop_program
185+ BattleMatchActionOption& options,
186+ bool allow_notification
173187){
174- std::vector<std::pair<std::string, std::string>> embeds;
175-
176- pbf_mash_button (context, BUTTON_ZL, options.SCREENSHOT_DELAY0 );
177188 context.wait_for_all_requests ();
178189
179- send_program_notification (
180- env, options.NOTIFICATIONS ,
181- Pokemon::COLOR_STAR_SHINY,
182- " Match Found" ,
183- embeds, " " ,
184- stream.video ().snapshot (), true
185- );
186-
187- ShinyDetectedAction action = options.ACTION ;
188- if (action == ShinyDetectedAction::TAKE_VIDEO_STOP_PROGRAM){
189- pbf_press_button (context, BUTTON_CAPTURE, 2 * TICKS_PER_SECOND, 0 );
190+ if (allow_notification){
191+ send_program_notification (
192+ env, options.NOTIFICATIONS ,
193+ Pokemon::COLOR_STAR_SHINY,
194+ " Match Found" ,
195+ {}, " " ,
196+ stream.video ().snapshot (), true
197+ );
190198 }
191199
192- if (stop_program){
193- stream.log (" Stopping..." );
194- // pbf_press_button(context, BUTTON_HOME, 20, GameSettings::instance().GAME_TO_HOME_DELAY);
195- context.wait_for_all_requests ();
196- throw ProgramFinishedException ();
200+ if (options.TAKE_VIDEO ){
201+ pbf_press_button (context, BUTTON_CAPTURE, 2 * TICKS_PER_SECOND, 0 );
197202 }
198203
199- stream.log (" Continuing..." );
204+ stream.log (" Stopping..." );
205+ context.wait_for_all_requests ();
206+ throw ProgramFinishedException ();
200207}
201208
202209
0 commit comments