Skip to content

Commit 0554834

Browse files
author
Gin
committed
add an empty ML label image program
1 parent c3f82fd commit 0554834

File tree

9 files changed

+249
-4
lines changed

9 files changed

+249
-4
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,10 @@ file(GLOB MAIN_SOURCES
871871
Source/Kernels/Waterfill/Kernels_Waterfill_Session.h
872872
Source/Kernels/Waterfill/Kernels_Waterfill_Session.tpp
873873
Source/Kernels/Waterfill/Kernels_Waterfill_Types.h
874+
Source/ML/ML_Panels.cpp
875+
Source/ML/ML_Panels.h
876+
Source/ML/Programs/ML_LabelImages.cpp
877+
Source/ML/Programs/ML_LabelImages.h
874878
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.cpp
875879
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h
876880
Source/NintendoSwitch/Commands/NintendoSwitch_Commands_Routines.cpp

SerialPrograms/Source/CommonFramework/Panels/PanelDescriptor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ namespace PokemonAutomation{
1515

1616
class PanelInstance;
1717

18-
18+
// Abstract base class that sets the interface for program descriptors.
19+
// A program descriptor contains various information (descriptions) of a program panel UI.
20+
// It can also use function `make_panel()` to create the corresponding panel.
1921
class PanelDescriptor{
2022
public:
2123
PanelDescriptor(

SerialPrograms/Source/CommonFramework/Panels/PanelTools.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ struct PanelEntry{
4747
};
4848

4949

50-
50+
// Used by `make_panel()` to link the panel instance to the panel descriptor.
51+
// For more details, see `make_panel()` defined below.
5152
template <typename Descriptor, typename Instance>
5253
class PanelDescriptorWrapper : public Descriptor{
5354
public:
@@ -56,6 +57,17 @@ class PanelDescriptorWrapper : public Descriptor{
5657
}
5758
};
5859

60+
// Called by a program panel list factory to create a panel descriptor.
61+
// A panel descriptor holds various info (title, title color, etc.) about a program panel
62+
// and can also create the corresponding panel.
63+
//
64+
// template type `Descriptor` a derived class of CommonFramework/Panels/PanelDescriptor.h:PanelDescriptor
65+
// and `Instance` is the program panel UI instance, derived class of
66+
// CommonFramework/Panels/PanelInstance.h:Panelnstance.
67+
//
68+
// Each panel descriptor instance should have implemented `make_panel()` to create the panel instance.
69+
// But writing this creation for each unique program implementation is repetitive. In stead, this function
70+
// uses `PanelDescriptorWrapper` to implement `make_panel()`.
5971
template <typename Descriptor, typename Instance>
6072
std::unique_ptr<PanelDescriptor> make_panel(){
6173
return std::make_unique<PanelDescriptorWrapper<Descriptor, Instance>>();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* ML Panels
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include "CommonFramework/GlobalSettingsPanel.h"
8+
#include "CommonFramework/Panels/PanelTools.h"
9+
#include "Pokemon/Pokemon_Strings.h"
10+
#include "Programs/ML_LabelImages.h"
11+
12+
#include "ML_Panels.h"
13+
14+
15+
namespace PokemonAutomation{
16+
namespace ML{
17+
18+
19+
20+
PanelListFactory::PanelListFactory()
21+
: PanelListDescriptor("ML")
22+
{}
23+
24+
std::vector<PanelEntry> PanelListFactory::make_panels() const{
25+
std::vector<PanelEntry> ret;
26+
if (PreloadSettings::instance().DEVELOPER_MODE){
27+
ret.emplace_back("---- Developer Tools ----");
28+
ret.emplace_back(make_panel<LabelImages_Descriptor, LabelImages>());
29+
// ret.emplace_back(make_single_switch_program<ThreeSegmentDudunsparceFinder_Descriptor, ThreeSegmentDudunsparceFinder>());
30+
}
31+
32+
return ret;
33+
}
34+
35+
36+
37+
38+
}
39+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* ML Panels
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_ML_Panels_H
8+
#define PokemonAutomation_ML_Panels_H
9+
10+
#include "CommonFramework/Panels/PanelList.h"
11+
12+
namespace PokemonAutomation{
13+
namespace ML{
14+
15+
16+
17+
class PanelListFactory : public PanelListDescriptor{
18+
public:
19+
PanelListFactory();
20+
virtual std::vector<PanelEntry> make_panels() const;
21+
};
22+
23+
24+
25+
}
26+
}
27+
#endif
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/* Virtual Game Console
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include <QVBoxLayout>
8+
#include <QScrollArea>
9+
#include "Common/Cpp/Json/JsonValue.h"
10+
#include "Common/Qt/CollapsibleGroupBox.h"
11+
#include "ML_LabelImages.h"
12+
#include "Pokemon/Pokemon_Strings.h"
13+
14+
namespace PokemonAutomation{
15+
namespace ML{
16+
17+
LabelImages_Descriptor::LabelImages_Descriptor()
18+
: PanelDescriptor(
19+
Color(),
20+
"ML:LabelImages",
21+
"ML", "Label Images",
22+
"", // "ComputerControl/blob/master/Wiki/Programs/NintendoSwitch/LabelImages.md",
23+
"Label " + Pokemon::STRING_POKEMON + " on images"
24+
)
25+
{}
26+
27+
28+
29+
LabelImages::LabelImages(const LabelImages_Descriptor& descriptor)
30+
: PanelInstance(descriptor)
31+
// , m_switch({}, false)
32+
{}
33+
void LabelImages::from_json(const JsonValue& json){
34+
// m_switch.load_json(json);
35+
}
36+
JsonValue LabelImages::to_json() const{
37+
return {};
38+
// return m_switch.to_json();
39+
}
40+
QWidget* LabelImages::make_widget(QWidget& parent, PanelHolder& holder){
41+
return LabelImages_Widget::make(parent, *this, holder);
42+
}
43+
44+
45+
46+
LabelImages_Widget* LabelImages_Widget::make(
47+
QWidget& parent,
48+
LabelImages& instance,
49+
PanelHolder& holder
50+
){
51+
LabelImages_Widget* widget = new LabelImages_Widget(parent, instance, holder);
52+
widget->construct();
53+
return widget;
54+
}
55+
LabelImages_Widget::~LabelImages_Widget(){
56+
// delete m_switch;
57+
}
58+
LabelImages_Widget::LabelImages_Widget(
59+
QWidget& parent,
60+
LabelImages& instance,
61+
PanelHolder& holder
62+
)
63+
: PanelWidget(parent, instance, holder)
64+
// , m_session(instance.m_switch, 0, 0)
65+
{}
66+
void LabelImages_Widget::construct(){
67+
QVBoxLayout* layout = new QVBoxLayout(this);
68+
layout->setContentsMargins(0, 0, 0, 0);
69+
layout->addWidget(make_header(*this));
70+
71+
QScrollArea* scroll_outer = new QScrollArea(this);
72+
layout->addWidget(scroll_outer);
73+
scroll_outer->setWidgetResizable(true);
74+
75+
QWidget* scroll_inner = new QWidget(scroll_outer);
76+
scroll_outer->setWidget(scroll_inner);
77+
QVBoxLayout* scroll_layout = new QVBoxLayout(scroll_inner);
78+
scroll_layout->setAlignment(Qt::AlignTop);
79+
80+
// m_switch = new SwitchSystemWidget(*this, m_session, 0);
81+
// scroll_layout->addWidget(m_switch);
82+
}
83+
84+
85+
86+
87+
88+
}
89+
}
90+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* ML Label Images
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_ML_LabelImages_H
8+
#define PokemonAutomation_ML_LabelImages_H
9+
10+
#include "CommonFramework/Panels/PanelInstance.h"
11+
#include "CommonFramework/Panels/UI/PanelWidget.h"
12+
13+
14+
namespace PokemonAutomation{
15+
namespace ML{
16+
17+
18+
19+
class LabelImages_Descriptor : public PanelDescriptor{
20+
public:
21+
LabelImages_Descriptor();
22+
};
23+
24+
25+
26+
class LabelImages : public PanelInstance{
27+
public:
28+
LabelImages(const LabelImages_Descriptor& descriptor);
29+
virtual QWidget* make_widget(QWidget& parent, PanelHolder& holder) override;
30+
31+
public:
32+
// Serialization
33+
virtual void from_json(const JsonValue& json) override;
34+
virtual JsonValue to_json() const override;
35+
36+
private:
37+
friend class LabelImages_Widget;
38+
};
39+
40+
41+
42+
class LabelImages_Widget : public PanelWidget{
43+
public:
44+
static LabelImages_Widget* make(
45+
QWidget& parent,
46+
LabelImages& instance,
47+
PanelHolder& holder
48+
);
49+
50+
private:
51+
~LabelImages_Widget();
52+
LabelImages_Widget(
53+
QWidget& parent,
54+
LabelImages& instance,
55+
PanelHolder& holder
56+
);
57+
void construct();
58+
59+
private:
60+
};
61+
62+
63+
64+
65+
}
66+
}
67+
#endif
68+

SerialPrograms/Source/PanelLists.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "CommonFramework/Windows/DpiScaler.h"
1313
#include "CommonFramework/Panels/UI/PanelListWidget.h"
1414
#include "CommonFramework/GlobalSettingsPanel.h"
15+
#include "ML/ML_Panels.h"
1516
#include "NintendoSwitch/NintendoSwitch_Panels.h"
1617
#include "PokemonSwSh/PokemonSwSh_Panels.h"
1718
#include "PokemonHome/PokemonHome_Panels.h"
@@ -54,7 +55,9 @@ ProgramSelect::ProgramSelect(QWidget& parent, PanelHolder& holder)
5455
add(std::make_unique<NintendoSwitch::PokemonRSE::PanelListFactory>());
5556
}
5657
add(std::make_unique<NintendoSwitch::ZeldaTotK::PanelListFactory>());
57-
58+
if (PreloadSettings::instance().DEVELOPER_MODE){
59+
add(std::make_unique<ML::PanelListFactory>());
60+
}
5861

5962

6063
// Load the 1st list by default.

SerialPrograms/Source/PanelLists.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class QComboBox;
1515
namespace PokemonAutomation{
1616

1717

18-
18+
// The program selection UI on the left side of the program window
1919
class ProgramSelect : public QGroupBox{
2020
public:
2121
ProgramSelect(QWidget& parent, PanelHolder& holder);

0 commit comments

Comments
 (0)