Skip to content

Commit 22fb78c

Browse files
committed
Change program colors to reflect controller requirements. Platform bot and sandwich maker don't need TickPrecise.
1 parent 4b2fad1 commit 22fb78c

11 files changed

+69
-9
lines changed

SerialPrograms/Source/CommonFramework/Panels/UI/PanelElements.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <QPushButton>
1111
#include "CommonFramework/Globals.h"
1212
#include "CommonFramework/Options/Environment/ThemeSelectorOption.h"
13+
#include "Controllers/ControllerCapability.h"
1314
#include "PanelElements.h"
1415

1516
namespace PokemonAutomation{
@@ -50,6 +51,7 @@ CollapsibleGroupBox* make_panel_header(
5051

5152
return header;
5253
}
54+
#if 0
5355
CollapsibleGroupBox* make_panel_header(
5456
QWidget& parent,
5557
const std::string& display_name,
@@ -92,6 +94,37 @@ CollapsibleGroupBox* make_panel_header(
9294

9395
return header;
9496
}
97+
#endif
98+
CollapsibleGroupBox* make_panel_header(
99+
QWidget& parent,
100+
const std::string& display_name,
101+
const std::string& doc_link,
102+
const std::string& description,
103+
const ControllerRequirements& requirements
104+
){
105+
CollapsibleGroupBox* header = make_panel_header(parent, display_name, doc_link, description);
106+
QLayout* layout = header->widget()->layout();
107+
108+
std::string text;
109+
do{
110+
if (requirements.contains(ControllerFeature::NintendoSwitch_DateSkip)){
111+
text = html_color_text("(This program requires advanced RPCs. It requires Serial PABotBase.)", COLOR_RED);
112+
break;
113+
}
114+
if (requirements.contains(ControllerFeature::TickPrecise)){
115+
text = html_color_text("(This program requires a tick-precise controller.)", COLOR_PURPLE);
116+
break;
117+
}
118+
119+
text = html_color_text("(This program does not have any special requirements.)", COLOR_BLUE);
120+
}while (false);
121+
122+
QLabel* label = new QLabel(QString::fromStdString(text), header);
123+
label->setWordWrap(true);
124+
layout->addWidget(label);
125+
126+
return header;
127+
}
95128

96129

97130

SerialPrograms/Source/CommonFramework/Panels/UI/PanelElements.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class QPushButton;
1616

1717
namespace PokemonAutomation{
1818

19+
class ControllerRequirements;
20+
1921

2022

2123
CollapsibleGroupBox* make_panel_header(
@@ -24,13 +26,22 @@ CollapsibleGroupBox* make_panel_header(
2426
const std::string& doc_link,
2527
const std::string& description
2628
);
29+
#if 0
2730
CollapsibleGroupBox* make_panel_header(
2831
QWidget& parent,
2932
const std::string& display_name,
3033
const std::string& doc_link,
3134
const std::string& description,
3235
FeedbackType feedback
3336
);
37+
#endif
38+
CollapsibleGroupBox* make_panel_header(
39+
QWidget& parent,
40+
const std::string& display_name,
41+
const std::string& doc_link,
42+
const std::string& description,
43+
const ControllerRequirements& requirements
44+
);
3445

3546

3647

SerialPrograms/Source/Controllers/ControllerCapability.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ class ControllerRequirements{
6969
public:
7070
ControllerRequirements(std::initializer_list<ControllerFeature> args);
7171

72+
bool contains(ControllerFeature feature) const{
73+
return m_features.contains(feature);
74+
}
75+
7276
// Check compatibility. If compatible, returns empty string.
7377
// Otherwise returns one of the missing features.
7478
std::string check_compatibility(const std::set<ControllerFeature>& features) const;

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SwitchSystemOption.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
namespace PokemonAutomation{
1414
namespace NintendoSwitch{
1515

16-
// constexpr Color COLOR_GREEN2(0xff00aa00);
16+
// constexpr Color COLOR_GREEN2(0xff00aa00);
1717

18+
#if 0
1819
Color pick_color(FeedbackType feedback){
1920
switch (feedback){
2021
case FeedbackType::NONE:
@@ -28,7 +29,16 @@ Color pick_color(FeedbackType feedback){
2829
}
2930
return Color();
3031
}
31-
32+
#endif
33+
Color pick_color(const ControllerRequirements& requirements){
34+
if (requirements.contains(ControllerFeature::NintendoSwitch_DateSkip)){
35+
return COLOR_RED;
36+
}
37+
if (requirements.contains(ControllerFeature::TickPrecise)){
38+
return COLOR_PURPLE;
39+
}
40+
return COLOR_BLUE;
41+
}
3242

3343

3444
const std::string SwitchSystemOption::JSON_CONTROLLER = "Controller";

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SwitchSystemOption.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
#include "Controllers/ControllerDescriptor.h"
2525

2626
namespace PokemonAutomation{
27+
class ControllerRequirements;
2728
namespace NintendoSwitch{
2829

2930

30-
Color pick_color(FeedbackType feedback);
31+
//Color pick_color(FeedbackType feedback);
32+
Color pick_color(const ControllerRequirements& requirements);
3133

3234

3335
class SwitchSystemOption{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ MultiSwitchProgramWidget2::MultiSwitchProgramWidget2(
6060
descriptor.display_name(),
6161
descriptor.doc_link(),
6262
descriptor.description(),
63-
descriptor.feedback()
63+
descriptor.requirements()
6464
);
6565
layout->addWidget(header);
6666

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ SingleSwitchProgramWidget2::SingleSwitchProgramWidget2(
5252
descriptor.display_name(),
5353
descriptor.doc_link(),
5454
descriptor.description(),
55-
descriptor.feedback()
55+
descriptor.requirements()
5656
);
5757
layout->addWidget(header);
5858

SerialPrograms/Source/NintendoSwitch/NintendoSwitch_MultiSwitchProgram.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ MultiSwitchProgramDescriptor::MultiSwitchProgramDescriptor(
7979
size_t default_switches
8080
)
8181
: ProgramDescriptor(
82-
pick_color(feedback),
82+
pick_color(requirements),
8383
std::move(identifier),
8484
std::move(category), std::move(display_name),
8585
std::move(doc_link),

SerialPrograms/Source/NintendoSwitch/NintendoSwitch_SingleSwitchProgram.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ SingleSwitchProgramDescriptor::SingleSwitchProgramDescriptor(
2727
ControllerRequirements requirements
2828
)
2929
: ProgramDescriptor(
30-
pick_color(feedback),
30+
pick_color(requirements),
3131
std::move(identifier),
3232
std::move(category), std::move(display_name),
3333
std::move(doc_link),

SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichMaker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ SandwichMaker_Descriptor::SandwichMaker_Descriptor()
2828
"Make a sandwich of your choice.",
2929
FeedbackType::REQUIRED,
3030
AllowCommandsWhenRunning::DISABLE_COMMANDS,
31-
{SerialPABotBase::OLD_NINTENDO_SWITCH_DEFAULT_REQUIREMENTS}
31+
{ControllerFeature::NintendoSwitch_ProController}
3232
)
3333
{}
3434

0 commit comments

Comments
 (0)