Skip to content

Commit 7879939

Browse files
committed
Some work on adding back/reimplementing module settings that can be displayed in the UI
1 parent 93f3265 commit 7879939

File tree

5 files changed

+76
-1
lines changed

5 files changed

+76
-1
lines changed

Src/Common/ModuleSettings.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#pragma once
22

3+
#include "Parameters.h"
4+
#include <string>
5+
#include <unordered_map>
6+
37
enum setting_t {
48
T_BOOL,
59
T_LONG,
@@ -19,3 +23,52 @@ struct _SModuleSettings {
1923
const char *szDescription;
2024
};
2125

26+
enum SettingsType
27+
{
28+
Switch,
29+
TextField,
30+
Slider,
31+
Enum,
32+
Step
33+
};
34+
35+
namespace Dasher {
36+
namespace Settings {
37+
struct ModuleSetting
38+
{
39+
SettingsType Type;
40+
ModuleSetting(SettingsType Type, Dasher::Parameter Param, std::string Description) : Type(Type), Param(Param), Description(Description) {}
41+
virtual ~ModuleSetting() {};
42+
43+
std::string Description;
44+
Dasher::Parameter Param;
45+
};
46+
47+
struct TextSetting : ModuleSetting {
48+
TextSetting(Dasher::Parameter Param, std::string Description) : ModuleSetting(SettingsType::TextField, Param, Description) {}
49+
};
50+
51+
struct SliderSetting : ModuleSetting {
52+
SliderSetting(Dasher::Parameter Param, std::string Description, int min, int max, int step) : ModuleSetting(SettingsType::Slider, Param, Description), min(min), max(max), step(step) {};
53+
int min;
54+
int max;
55+
int step;
56+
};
57+
58+
struct SpinSetting : ModuleSetting {
59+
SpinSetting(Dasher::Parameter Param, std::string Description, int min, int max, int step) : ModuleSetting(SettingsType::Slider, Param, Description), min(min), max(max), step(step) {}
60+
int min;
61+
int max;
62+
int step;
63+
};
64+
65+
struct EnumSetting : ModuleSetting {
66+
EnumSetting(Dasher::Parameter Param, std::string Description, std::unordered_map<std::string, int> Enums) : ModuleSetting(SettingsType::Enum, Param, Description), Enums(Enums) {};
67+
std::unordered_map<std::string, int> Enums;
68+
};
69+
70+
struct SwitchSetting : ModuleSetting {
71+
SwitchSetting(Dasher::Parameter Param, std::string Description) : ModuleSetting(SettingsType::Switch, Param, Description) {};
72+
};
73+
}
74+
}

Src/DasherCore/DasherModule.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ class CDasherModule {
3737
return false;
3838
}
3939

40+
virtual const std::vector<Dasher::Settings::ModuleSetting>& getUISettings(){return UIList;};
4041
private:
4142
const char *m_szName;
43+
protected:
44+
std::vector<Dasher::Settings::ModuleSetting> UIList;
4245
};
4346
/// @}
4447

Src/DasherCore/DefaultFilter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "DasherInterfaceBase.h"
88

99
#include "CircleStartHandler.h"
10+
#include "DasherTypes.h"
11+
#include "ModuleSettings.h"
1012
#include "TwoBoxStartHandler.h"
1113

1214
using namespace Dasher;

Src/DasherCore/DefaultFilter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "DynamicFilter.h"
44
#include "AutoSpeedControl.h"
5+
#include "ModuleSettings.h"
56
#include "StartHandler.h"
67

78
namespace Dasher {
@@ -23,6 +24,7 @@ class CDefaultFilter : public CDynamicFilter {
2324
void Activate() override;
2425
void Deactivate() override;
2526
bool GetSettings(SModuleSettings **, int *) override;
27+
2628
void pause() override;
2729
//pauses, and calls the interface's Done() method
2830
void stop();

Src/DasherCore/PressFilter.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
#include "PressFilter.h"
2+
#include "I18n.h"
23

34
Dasher::CPressFilter::CPressFilter(CSettingsStore* pSettingsStore, CDasherInterfaceBase* pInterface, CFrameRate* pFramerate, const char *szName) : CDefaultFilter(pSettingsStore, pInterface, pFramerate, szName)
45
{
6+
UIList.push_back(Dasher::Settings::SwitchSetting(BP_REMAP_XTREME, _("At top and bottom, scroll more and translate less (makes error-correcting easier)")));
7+
UIList.push_back(Dasher::Settings::EnumSetting(LP_GEOMETRY, "Screen geometry", {
8+
{"Old Style", Dasher::Options::ScreenGeometry::old_style},
9+
{"Square without Crosshair", Dasher::Options::ScreenGeometry::square_no_xhair},
10+
{"Squish", Dasher::Options::ScreenGeometry::squish},
11+
{"Squaish + Log", Dasher::Options::ScreenGeometry::squish_and_log},
12+
}));
13+
UIList.push_back(Dasher::Settings::EnumSetting(LP_SHAPE_TYPE, "Rendering Geometry", {
14+
{"Rectangle", Dasher::Options::RenderingShapeTypes::OVERLAPPING_RECTANGLE},
15+
{"Triangle", Dasher::Options::RenderingShapeTypes::TRIANGLE},
16+
{"Truncated Triangle", Dasher::Options::RenderingShapeTypes::TRUNCATED_TRIANGLE},
17+
{"Quadric", Dasher::Options::RenderingShapeTypes::QUADRIC},
18+
{"Circle", Dasher::Options::RenderingShapeTypes::CIRCLE}
19+
}));
520
}
621

722
void Dasher::CPressFilter::KeyDown(unsigned long iTime, Keys::VirtualKey Key, CDasherView* pDasherView, CDasherInput* pInput, CDasherModel* pModel)
@@ -25,4 +40,4 @@ void Dasher::CPressFilter::KeyUp(unsigned long iTime, Keys::VirtualKey Key, CDas
2540
stop();
2641
}
2742
else if (Key == Keys::Secondary_Input || Key == Keys::Tertiary_Input || Key == Keys::Button_1) m_bTurbo = false;
28-
}
43+
}

0 commit comments

Comments
 (0)