Etterna 0.74.4
Loading...
Searching...
No Matches
ScreenOptionsMasterPrefs.h
1#ifndef SCREEN_OPTIONS_MASTER_PREFS_H
2#define SCREEN_OPTIONS_MASTER_PREFS_H
3
4#include "Etterna/Models/Misc/EnumHelper.h"
5
6static const int MAX_OPTIONS = 16;
7enum OptEffect
8{
9 OPT_SAVE_PREFERENCES = (1 << 0),
10 OPT_APPLY_GRAPHICS = (1 << 1),
11 OPT_APPLY_THEME = (1 << 2),
12 OPT_CHANGE_GAME = (1 << 3),
13 OPT_APPLY_SOUND = (1 << 4),
14 OPT_APPLY_SONG = (1 << 5),
15 OPT_APPLY_ASPECT_RATIO = (1 << 6),
16 NUM_OptEffect = 7,
17 OptEffect_Invalid = MAX_OPTIONS + 1
18};
19const std::string&
20OptEffectToString(OptEffect e);
21OptEffect
22StringToOptEffect(const std::string& e);
23LuaDeclareType(OptEffect);
24
26{
27 static struct ConfOption* Find(const std::string& name);
28
29 // Name of this option.
30 std::string name;
31
32 // Name of the preference this option affects.
33 std::string m_sPrefName;
34
35 using MoveData_t = void (*)(int&, bool, const ConfOption*);
36 MoveData_t MoveData;
37 int m_iEffects;
38 bool m_bAllowThemeItems;
39
40 /* For dynamic options, update the options. Since this changes the available
41 * options, this may invalidate the offsets returned by Get() and Put(). */
42 void UpdateAvailableOptions();
43
44 /* Return the list of available selections; Get() and Put() use indexes into
45 * this array. UpdateAvailableOptions() should be called before using this.
46 */
47 void MakeOptionsList(std::vector<std::string>& out) const;
48
49 inline int Get() const
50 {
51 int sel;
52 MoveData(sel, true, this);
53 return sel;
54 }
55 inline void Put(int sel) const { MoveData(sel, false, this); }
56 int GetEffects() const;
57
58 ConfOption(const char* n,
59 MoveData_t m,
60 const char* c0 = nullptr,
61 const char* c1 = nullptr,
62 const char* c2 = nullptr,
63 const char* c3 = nullptr,
64 const char* c4 = nullptr,
65 const char* c5 = nullptr,
66 const char* c6 = nullptr,
67 const char* c7 = nullptr,
68 const char* c8 = nullptr,
69 const char* c9 = nullptr,
70 const char* c10 = nullptr,
71 const char* c11 = nullptr,
72 const char* c12 = nullptr,
73 const char* c13 = nullptr,
74 const char* c14 = nullptr,
75 const char* c15 = nullptr,
76 const char* c16 = nullptr,
77 const char* c17 = nullptr,
78 const char* c18 = nullptr,
79 const char* c19 = nullptr)
80 {
81 name = n;
82 m_sPrefName = name; // copy from name (not n), to allow refcounting
83 MoveData = m;
84 MakeOptionsListCB = nullptr;
85 m_iEffects = 0;
86 m_bAllowThemeItems = true;
87#define PUSH(c) \
88 if (c) \
89 names.push_back(c);
90 PUSH(c0);
91 PUSH(c1);
92 PUSH(c2);
93 PUSH(c3);
94 PUSH(c4);
95 PUSH(c5);
96 PUSH(c6);
97 PUSH(c7);
98 PUSH(c8);
99 PUSH(c9);
100 PUSH(c10);
101 PUSH(c11);
102 PUSH(c12);
103 PUSH(c13);
104 PUSH(c14);
105 PUSH(c15);
106 PUSH(c16);
107 PUSH(c17);
108 PUSH(c18);
109 PUSH(c19);
110 }
111 void AddOption(const std::string& sName) { PUSH(sName.c_str()); }
112#undef PUSH
113
114 ConfOption(const char* n,
115 MoveData_t m,
116 void (*lst)(std::vector<std::string>& out))
117 {
118 name = n;
119 MoveData = m;
120 MakeOptionsListCB = lst;
121 m_iEffects = 0;
122 m_bAllowThemeItems = false; // don't theme dynamic choices
123 }
124
125 // private:
126 std::vector<std::string> names;
127 void (*MakeOptionsListCB)(std::vector<std::string>& out);
128};
129
130#endif
Definition ScreenOptionsMasterPrefs.h:26