Skip to content

Commit a9df43b

Browse files
author
Gin
committed
add video overlay log on program start and end
1 parent a5765ed commit a9df43b

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,24 @@ void MultiSwitchProgramSession::internal_run_program(){
189189

190190
try{
191191
logger().log("<b>Starting Program: " + identifier() + "</b>");
192+
env.add_overlay_log_to_all_consoles("- Starting Program -");
192193
run_program_instance(env, scope);
193194
// m_setup->wait_for_all_requests();
195+
env.add_overlay_log_to_all_consoles("- Program Finished -");
194196
logger().log("Program finished normally!", COLOR_BLUE);
195197
}catch (OperationCancelledException&){
198+
env.add_overlay_log_to_all_consoles("- Operation Cancelled -", COLOR_RED);
196199
}catch (ProgramCancelledException&){
200+
env.add_overlay_log_to_all_consoles("- Program Stopped -");
197201
}catch (ProgramFinishedException& e){
198202
logger().log("Program finished early!", COLOR_BLUE);
203+
env.add_overlay_log_to_all_consoles("- Program Finished -");
199204
e.send_notification(env, m_option.instance().NOTIFICATION_PROGRAM_FINISH);
200205
}catch (InvalidConnectionStateException&){
206+
env.add_overlay_log_to_all_consoles("- Invalid Connection -", COLOR_RED);
201207
}catch (ScreenshotException& e){
202208
logger().log("Program stopped with an exception!", COLOR_RED);
203-
209+
env.add_overlay_log_to_all_consoles("- Program Error -", COLOR_RED);
204210
// If the exception doesn't already have console information,
205211
// attach the 1st console here.
206212
e.add_stream_if_needed(env.consoles[0]);
@@ -213,6 +219,7 @@ void MultiSwitchProgramSession::internal_run_program(){
213219
e.send_notification(env, m_option.instance().NOTIFICATION_ERROR_FATAL);
214220
}catch (Exception& e){
215221
logger().log("Program stopped with an exception!", COLOR_RED);
222+
env.add_overlay_log_to_all_consoles("- Program Error -", COLOR_RED);
216223
std::string message = e.message();
217224
if (message.empty()){
218225
message = e.name();
@@ -224,6 +231,7 @@ void MultiSwitchProgramSession::internal_run_program(){
224231
);
225232
}catch (std::exception& e){
226233
logger().log("Program stopped with an exception!", COLOR_RED);
234+
env.add_overlay_log_to_all_consoles("- Program Error -", COLOR_RED);
227235
std::string message = e.what();
228236
if (message.empty()){
229237
message = "Unknown std::exception.";
@@ -235,6 +243,7 @@ void MultiSwitchProgramSession::internal_run_program(){
235243
);
236244
}catch (...){
237245
logger().log("Program stopped with an exception!", COLOR_RED);
246+
env.add_overlay_log_to_all_consoles("- Unknown Error -", COLOR_RED);
238247
report_error("Unknown error.");
239248
send_program_fatal_error_notification(
240249
env, m_option.instance().NOTIFICATION_ERROR_FATAL,

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,23 @@ void SingleSwitchProgramSession::internal_run_program(){
146146

147147
try{
148148
logger().log("<b>Starting Program: " + identifier() + "</b>");
149+
env.console.overlay().add_log("- Starting Program -");
149150
run_program_instance(env, context);
151+
env.console.overlay().add_log("- Program Finished -");
150152
logger().log("Program finished normally!", COLOR_BLUE);
151153
}catch (OperationCancelledException&){
154+
env.console.overlay().add_log("- Operation Cancelled -", COLOR_RED);
152155
}catch (ProgramCancelledException&){
156+
env.console.overlay().add_log("- Program Stopped -");
153157
}catch (ProgramFinishedException& e){
154158
logger().log("Program finished early!", COLOR_BLUE);
159+
env.console.overlay().add_log("- Program Finished -");
155160
e.send_notification(env, m_option.instance().NOTIFICATION_PROGRAM_FINISH);
156161
}catch (InvalidConnectionStateException&){
162+
env.console.overlay().add_log("- Invalid Connection -", COLOR_RED);
157163
}catch (ScreenshotException& e){
158164
logger().log("Program stopped with an exception!", COLOR_RED);
165+
env.console.overlay().add_log("- Program Error -", COLOR_RED);
159166
e.add_stream_if_needed(env.console);
160167
std::string message = e.message();
161168
if (message.empty()){
@@ -165,6 +172,7 @@ void SingleSwitchProgramSession::internal_run_program(){
165172
e.send_notification(env, m_option.instance().NOTIFICATION_ERROR_FATAL);
166173
}catch (Exception& e){
167174
logger().log("Program stopped with an exception!", COLOR_RED);
175+
env.console.overlay().add_log("- Program Error -", COLOR_RED);
168176
std::string message = e.message();
169177
if (message.empty()){
170178
message = e.name();
@@ -178,6 +186,7 @@ void SingleSwitchProgramSession::internal_run_program(){
178186
#ifdef PA_CATCH_PROGRAM_SYSTEM_EXCEPTIONS
179187
catch (std::exception& e){
180188
logger().log("Program stopped with an exception!", COLOR_RED);
189+
env.console.overlay().add_log("- Program Error -", COLOR_RED);
181190
std::string message = e.what();
182191
if (message.empty()){
183192
message = "Unknown std::exception.";
@@ -189,6 +198,7 @@ void SingleSwitchProgramSession::internal_run_program(){
189198
);
190199
}catch (...){
191200
logger().log("Program stopped with an exception!", COLOR_RED);
201+
env.console.overlay().add_log("- Unknown Error -", COLOR_RED);
192202
report_error("Unknown error.");
193203
send_program_fatal_error_notification(
194204
env, m_option.instance().NOTIFICATION_ERROR_FATAL,

SerialPrograms/Source/NintendoSwitch/NintendoSwitch_MultiSwitchProgram.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ void MultiSwitchProgramEnvironment::run_in_parallel(
9191
);
9292
}
9393

94+
void MultiSwitchProgramEnvironment::add_overlay_log_to_all_consoles(const std::string& message, Color color){
95+
for (auto&console: consoles){
96+
console.overlay().add_log(message, color);
97+
}
98+
}
9499

95100

96101
MultiSwitchProgramDescriptor::MultiSwitchProgramDescriptor(
@@ -207,5 +212,7 @@ void MultiSwitchProgramInstance::restore_defaults(){
207212

208213

209214

215+
216+
210217
}
211218
}

SerialPrograms/Source/NintendoSwitch/NintendoSwitch_MultiSwitchProgram.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class MultiSwitchProgramEnvironment : public ProgramEnvironment{
6161
const std::function<void(ConsoleHandle& console, ProControllerContext& context)>& func
6262
);
6363

64+
// add video overlay log on all console video streams
65+
void add_overlay_log_to_all_consoles(const std::string& message, Color color = COLOR_WHITE);
6466
};
6567

6668

0 commit comments

Comments
 (0)