forked from EasyRPG/Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow_settings.h
158 lines (133 loc) · 3.28 KB
/
window_settings.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Player is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EP_WINDOW_SETTINGS_H
#define EP_WINDOW_SETTINGS_H
// Headers
#include <vector>
#include "input.h"
#include "window_numberinput.h"
#include "window_selectable.h"
/**
* Window_Settings class.
*/
class Window_Settings : public Window_Selectable {
public:
enum UiMode {
eNone,
eMain,
eInput,
eInputButtonCategory,
eInputListButtonsGame,
eInputListButtonsEngine,
eInputListButtonsDeveloper,
eInputButtonOption,
eInputButtonAdd,
eInputButtonRemove,
eVideo,
eAudio,
eLicense,
eEngine,
eSave,
eEnd,
eAbout,
eLastMode
};
enum OptionMode {
eOptionNone,
eOptionRangeInput,
eOptionPicker
};
struct Option {
std::string text;
std::string value_text;
std::string help;
std::function<void(void)> action;
OptionMode mode;
int current_value;
int original_value;
int min_value;
int max_value;
std::vector<int> options_index;
std::vector<std::string> options_text;
std::vector<std::string> options_help;
};
struct StackFrame {
UiMode uimode = eNone;
int arg = -1;
int scratch = 0;
int scratch2 = 0;
};
/** Constructor */
Window_Settings(int ix, int iy, int iwidth, int iheight);
/** @return true if the index points to an enabled action */
bool IsCurrentActionEnabled() const {
return (index >= 0
&& index < static_cast<int>(options.size())
&& static_cast<bool>(options[index].action));
}
/** Execute the action pointed to by index */
Option& GetCurrentOption() {
return options[index];
}
UiMode GetMode() const;
void Push(UiMode ui, int arg = -1);
void Pop();
StackFrame& GetFrame(int n = 0);
const StackFrame& GetFrame(int n = 0) const;
/**
* Refreshes the item list.
*/
void Refresh();
private:
/**
* Draws an item together with the quantity.
*
* @param index index of item to draw.
*/
void DrawOption(int index);
template <typename Param, typename Action>
void AddOption(const Param& p,
Action&& action);
template <typename T, typename Action>
void AddOption(const RangeConfigParam<T>& p,
Action&& action
);
template <typename T, typename Action, size_t S>
void AddOption(const EnumConfigParam<T, S>& p,
Action&& action
);
void RefreshInput();
void RefreshButtonCategory();
void RefreshButtonList();
void RefreshVideo();
void RefreshAudio();
void RefreshEngine();
void RefreshLicense();
void UpdateHelp() override;
std::vector<Option> options;
struct Memory {
int index = 0;
int top_row = 0;
};
Memory memory[eLastMode] = {};
std::array<StackFrame,8> stack;
int stack_index = 0;
std::vector<std::string> picker_options;
void SavePosition();
void RestorePosition();
};
#endif