Skip to content

Commit f572225

Browse files
committed
Add option to specify Switch model.
1 parent 5698d78 commit f572225

12 files changed

+92
-36
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ TestProgram::TestProgram()
266266
PA_ADD_OPTION(BUTTON0);
267267
PA_ADD_OPTION(BUTTON1);
268268
PA_ADD_OPTION(LANGUAGE);
269-
PA_ADD_OPTION(CONSOLE_MODEL);
269+
// PA_ADD_OPTION(CONSOLE_MODEL);
270270
PA_ADD_OPTION(IMAGE_PATH);
271271
PA_ADD_OPTION(STATIC_TEXT);
272272
PA_ADD_OPTION(SELECT);
@@ -321,7 +321,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
321321
ProControllerContext context(scope, console.pro_controller());
322322
VideoOverlaySet overlays(overlay);
323323

324-
console.state().set_console_type(CONSOLE_MODEL);
324+
// console.state().set_console_type(CONSOLE_MODEL);
325325

326326
while (true){
327327
home_to_date_time(console, context, true);

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class TestProgram : public MultiSwitchProgramInstance, public ButtonListener{
7878
// PokemonSV::PlayerListTable PLAYER_LIST;
7979
DateTimeOption DATE0;
8080
DateTimeOption DATE1;
81-
ConsoleModelOption CONSOLE_MODEL;
81+
// ConsoleModelOption CONSOLE_MODEL;
8282

8383
MillisecondsOption DURATION;
8484
ColorCell COLOR;

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ void MultiSwitchProgramSession::internal_run_program(){
174174
session.audio(),
175175
session.stream_history()
176176
);
177+
handles.back().state().set_console_type(session.console_type());
177178
}
178179

179180

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void SingleSwitchProgramSession::internal_run_program(){
143143
m_system.audio(),
144144
m_system.stream_history()
145145
);
146+
env.console.state().set_console_type(m_system.console_type());
146147

147148
try{
148149
logger().log("<b>Starting Program: " + identifier() + "</b>");

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SwitchSystemOption.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ Color pick_color(
5757
}
5858

5959

60-
const std::string SwitchSystemOption::JSON_CONTROLLER = "Controller";
61-
const std::string SwitchSystemOption::JSON_CAMERA = "Camera";
62-
const std::string SwitchSystemOption::JSON_VIDEO = "Video";
63-
const std::string SwitchSystemOption::JSON_AUDIO = "Audio";
64-
const std::string SwitchSystemOption::JSON_OVERLAY = "Overlay";
60+
const std::string SwitchSystemOption::JSON_CONTROLLER = "Controller";
61+
const std::string SwitchSystemOption::JSON_CAMERA = "Camera";
62+
const std::string SwitchSystemOption::JSON_VIDEO = "Video";
63+
const std::string SwitchSystemOption::JSON_AUDIO = "Audio";
64+
const std::string SwitchSystemOption::JSON_OVERLAY = "Overlay";
65+
const std::string SwitchSystemOption::JSON_CONSOLE_TYPE = "ConsoleType";
6566

6667

6768
SwitchSystemOption::SwitchSystemOption(
@@ -103,6 +104,10 @@ void SwitchSystemOption::load_json(const JsonValue& json){
103104
if (value){
104105
m_overlay.load_json(*value);
105106
}
107+
value = obj->get_value(JSON_CONSOLE_TYPE);
108+
if (value){
109+
m_console_type.load_json(*value);
110+
}
106111
}
107112
JsonValue SwitchSystemOption::to_json() const{
108113
JsonObject root;
@@ -111,6 +116,8 @@ JsonValue SwitchSystemOption::to_json() const{
111116
root[JSON_VIDEO] = m_video.to_json();
112117
root[JSON_AUDIO] = m_audio.to_json();
113118
root[JSON_OVERLAY] = m_overlay.to_json();
119+
root[JSON_CONSOLE_TYPE] = m_console_type.to_json();
120+
114121
return root;
115122
}
116123

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SwitchSystemOption.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "CommonFramework/VideoPipeline/VideoOverlayOption.h"
2222
#include "Controllers/ControllerCapability.h"
2323
#include "Controllers/ControllerDescriptor.h"
24+
#include "NintendoSwitch/Options/NintendoSwitch_ModelType.h"
2425

2526
namespace PokemonAutomation{
2627
class ControllerRequirements;
@@ -43,6 +44,7 @@ class SwitchSystemOption{
4344
static const std::string JSON_VIDEO;
4445
static const std::string JSON_AUDIO;
4546
static const std::string JSON_OVERLAY;
47+
static const std::string JSON_CONSOLE_TYPE;
4648

4749
public:
4850
SwitchSystemOption(
@@ -67,6 +69,7 @@ class SwitchSystemOption{
6769
VideoSourceOption m_video;
6870
AudioOption m_audio;
6971
VideoOverlayOption m_overlay;
72+
ConsoleModelCell m_console_type;
7073
};
7174

7275

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SwitchSystemSession.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class SwitchSystemSession final : public TrackableConsole{
5959
virtual ControllerSession& controller() override{ return m_controller; };
6060
VideoOverlay& overlay(){ return m_overlay; }
6161
const StreamHistorySession& stream_history() const{ return m_history; }
62+
ConsoleModelCell& console_type(){ return m_option.m_console_type; }
6263

6364
public:
6465
void get(SwitchSystemOption& option);

SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_CommandRow.cpp

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <QHBoxLayout>
8+
#include "Common/Qt/Options/ConfigWidget.h"
89
#include "CommonFramework/GlobalSettingsPanel.h"
910
#include "CommonFramework/Options/Environment/ThemeSelectorOption.h"
1011
#include "CommonFramework/Recording/StreamHistoryOption.h"
@@ -26,6 +27,7 @@ CommandRow::CommandRow(
2627
QWidget& parent,
2728
ControllerSession& controller,
2829
VideoOverlaySession& session,
30+
ConsoleModelCell& console_type,
2931
bool allow_commands_while_running
3032
)
3133
: QWidget(&parent)
@@ -38,52 +40,68 @@ CommandRow::CommandRow(
3840
QHBoxLayout* command_row = new QHBoxLayout(this);
3941
command_row->setContentsMargins(0, 0, 0, 0);
4042

41-
command_row->addWidget(new QLabel("<b>Keyboard Input:</b>", this), 2);
43+
command_row->addWidget(new QLabel("<b>Console Type:</b>", this), 2);
4244
command_row->addSpacing(5);
4345

44-
m_status = new QLabel(this);
45-
command_row->addWidget(m_status, 12);
46+
ConfigWidget* console_type_box = console_type.make_QtWidget(*this);
47+
command_row->addWidget(&console_type_box->widget(), 4);
4648
command_row->addSpacing(5);
4749

48-
command_row->addWidget(new QLabel("<b>Overlays:<b>", this));
50+
QHBoxLayout* row = new QHBoxLayout();
51+
command_row->addLayout(row, 12);
52+
53+
54+
#if 0
55+
row->addWidget(new QLabel("<b>Keyboard Input:</b>", this), 2);
56+
row->addSpacing(5);
57+
#endif
58+
59+
row->addStretch(100);
60+
61+
m_status = new QLabel(this);
62+
m_status->setVisible(false);
63+
// row->addWidget(m_status, 12);
64+
// row->addSpacing(5);
65+
66+
// row->addWidget(new QLabel("<b>Overlays:<b>", this));
4967

5068
m_overlay_boxes = new QCheckBox("Boxes", this);
5169
m_overlay_boxes->setChecked(session.enabled_boxes());
52-
command_row->addWidget(m_overlay_boxes);
70+
row->addWidget(m_overlay_boxes);
5371

5472
m_overlay_text = new QCheckBox("Text", this);
5573
m_overlay_text->setHidden(true); // Nothing uses text overlay yet.
5674
m_overlay_text->setChecked(session.enabled_text());
57-
command_row->addWidget(m_overlay_text);
75+
row->addWidget(m_overlay_text);
5876

59-
m_overlay_images = new QCheckBox("Images/Masks", this);
77+
m_overlay_images = new QCheckBox("Masks", this);
6078
m_overlay_images->setChecked(session.enabled_images());
61-
command_row->addWidget(m_overlay_images);
79+
row->addWidget(m_overlay_images);
6280

6381

6482
m_overlay_log = new QCheckBox("Log", this);
6583
m_overlay_log->setChecked(session.enabled_log());
66-
command_row->addWidget(m_overlay_log);
84+
row->addWidget(m_overlay_log);
6785

6886
m_overlay_stats = new QCheckBox("Stats", this);
6987
m_overlay_stats->setChecked(session.enabled_stats());
70-
command_row->addWidget(m_overlay_stats);
88+
row->addWidget(m_overlay_stats);
7189

72-
command_row->addSpacing(5);
90+
row->addSpacing(5);
7391

7492
m_load_profile_button = new QPushButton("Load Profile", this);
75-
command_row->addWidget(m_load_profile_button, 2);
93+
row->addWidget(m_load_profile_button, 2);
7694

7795
m_save_profile_button = new QPushButton("Save Profile", this);
78-
command_row->addWidget(m_save_profile_button, 2);
96+
row->addWidget(m_save_profile_button, 2);
7997

8098
m_screenshot_button = new QPushButton("Screenshot", this);
8199
// m_screenshot_button->setToolTip("Take a screenshot of the console and save to disk.");
82-
command_row->addWidget(m_screenshot_button, 2);
100+
row->addWidget(m_screenshot_button, 2);
83101

84102

85103
// m_test_button = new QPushButton("Test Button", this);
86-
// command_row->addWidget(m_test_button, 3);
104+
// row->addWidget(m_test_button, 3);
87105

88106
update_ui();
89107

SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_CommandRow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "CommonFramework/Globals.h"
1515
#include "CommonFramework/VideoPipeline/VideoOverlaySession.h"
1616
#include "Controllers/ControllerSession.h"
17+
#include "NintendoSwitch/Options/NintendoSwitch_ModelType.h"
1718

1819
namespace PokemonAutomation{
1920
namespace NintendoSwitch{
@@ -34,6 +35,7 @@ class CommandRow :
3435
QWidget& parent,
3536
ControllerSession& controller,
3637
VideoOverlaySession& session,
38+
ConsoleModelCell& console_type,
3739
bool allow_commands_while_running
3840
);
3941

SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ SwitchSystemWidget::SwitchSystemWidget(
105105
*widget,
106106
m_session.controller_session(),
107107
m_session.overlay_session(),
108+
m_session.console_type(),
108109
m_session.allow_commands_while_running()
109110
);
110111
group_layout->addWidget(m_command);

0 commit comments

Comments
 (0)