-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathSettings.cpp
More file actions
280 lines (248 loc) · 9.35 KB
/
Settings.cpp
File metadata and controls
280 lines (248 loc) · 9.35 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#include "../DevTools.hpp"
#include <Geode/loader/Loader.hpp>
#include <Geode/loader/Mod.hpp>
#include <Geode/utils/ranges.hpp>
// #include <Geode/binding/FMODAudioEngine.hpp>
#include <Geode/modify/AppDelegate.hpp>
#include <fmod.hpp>
#include <numeric>
#include <Geode/binding/GameManager.hpp>
using namespace geode::prelude;
static float RAINBOW_HUE = 0.f;
void DevTools::drawSettings() {
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { 1.f, 1.f });
#ifdef GEODE_IS_MOBILE
ImGui::Dummy({0.f, 60.f});
#endif
// TODO: fix this option as it hasnt worked in a while lol
#if 0
ImGui::Checkbox("GD in Window", &m_settings.GDInWindow);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Show GD inside a window when DevTools are open");
}
ImGui::Checkbox("Attributes in Tree", &m_settings.attributesInTree);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Show node attributes in the Tree");
}
#endif
ImGui::Checkbox("Highlight Nodes", &m_settings.alwaysHighlight);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"Always highlight nodes when hovered in the Tree. "
"When disabled, you can highlight by pressing Shift."
);
}
ImGui::Checkbox("Highlight Layouts", &m_settings.highlightLayouts);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"Highlights the borders of all layouts applied to nodes"
);
}
ImGui::Checkbox("Arrow to Expand", &m_settings.arrowExpand);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"If enabled, expanding nodes in the Tree only works with the arrow. "
"Makes selecting nodes less annoying."
);
}
ImGui::Checkbox("Order Node Children", &m_settings.orderChildren);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"When enabled (default behavior) node children are sorted by Z Order.\n"
"When disabled, children have the same order they do during init functions (maybe).\n"
"As a side effect to disabling this, things may render incorrectly."
);
}
ImGui::Checkbox("Node Tree Reordering", &m_settings.treeDragReorder);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"(Experimental)\nAllows you to drag/drop nodes in the node tree, changing\ntheir parents or ordering."
);
}
ImGui::Checkbox("Advanced Settings", &m_settings.advancedSettings);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"Shows advanced settings. Mostly useful only for development of Geode itself."
);
}
ImGui::Checkbox("Show Memory Viewer", &m_settings.showMemoryViewer);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"Shows the memory viewer window."
);
}
ImGui::Checkbox("Show Mod Graph", &m_settings.showModGraph);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"Shows the mod graph window."
);
}
ImGui::Checkbox("Show Touch Priority Viewer", &m_settings.showTouchPrio);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"Shows the touch priority viewer window."
);
}
ImGui::PopStyleVar();
ImGui::Separator();
ImGui::DragFloat("Font Size", &ImGui::GetIO().FontGlobalScale, 0.01f, 1.0f, 3.0f);
#ifdef GEODE_IS_DESKTOP
ImGui::Separator();
ImGui::Text("GD Window");
auto winSize = CCDirector::get()->getWinSize();
auto frameSize = GameManager::get()->resolutionForKey(GameManager::get()->m_resolution);
auto fps = roundf(1 / CCDirector::get()->getAnimationInterval());
auto ratio = std::gcd(static_cast<int>(frameSize.width), static_cast<int>(frameSize.height));
#ifdef GEODE_IS_WINDOWS
std::string text = "";
text += "Custom";
text.push_back('\0');
for (int i = 1; i < 28; i++) {
auto size = GameManager::get()->resolutionForKey(i);
text += fmt::format("{}x{}", size.width, size.height);
text.push_back('\0');
}
int selectedResolution = GameManager::get()->m_resolution;
static CCSize customResolution = frameSize;
if (ImGui::Combo("##devtools/resolution", &selectedResolution, text.c_str())) {
GameManager::get()->m_resolution = selectedResolution;
// TODO: idk how to do this on macos
if (selectedResolution != 0) {
auto size = GameManager::get()->resolutionForKey(selectedResolution);
CCEGLView::get()->resizeWindow(size.width, size.height);
}
else {
CCEGLView::get()->resizeWindow(customResolution.width, customResolution.height);
}
CCEGLView::get()->centerWindow();
}
if (selectedResolution == 0) {
int size[2] = {
static_cast<int>(customResolution.width),
static_cast<int>(customResolution.height),
};
if (ImGui::DragInt2("Size", size)) {
size[0] = std::fabs(size[0]);
size[1] = std::fabs(size[1]);
customResolution = CCSizeMake(size[0], size[1]);
}
if (ImGui::Button("Apply##size-apply")) {
GameManager::get()->m_resolution = 0;
CCEGLView::get()->resizeWindow(customResolution.width, customResolution.height);
CCEGLView::get()->centerWindow();
}
}
#endif
ImGui::TextWrapped(
"GL Size: %dx%d",
static_cast<int>(winSize.width),
static_cast<int>(winSize.height)
);
ImGui::TextWrapped(
"Frame Size: %dx%d",
static_cast<int>(frameSize.width),
static_cast<int>(frameSize.height)
);
ImGui::TextWrapped("FPS: %d", static_cast<int>(fps));
ImGui::TextWrapped(
"Aspect Ratio: %d:%d",
static_cast<int>(frameSize.width / ratio),
static_cast<int>(frameSize.height / ratio)
);
if (ImGui::Checkbox("Button Enabled", &m_settings.buttonEnabled)) {
if (m_settings.buttonEnabled) setupDragButton();
else removeDragButton();
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"Shows the mobile button."
);
}
#endif
if (isButtonEnabled()) {
ImGui::Checkbox("Button In Editor", &m_settings.buttonInEditor);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"Shows the mobile button in the editor."
);
}
ImGui::Checkbox("Button In Game", &m_settings.buttonInGame);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
"Shows the mobile button in levels."
);
}
}
#if 0
static Ref<CCSet> PAUSED_TARGETS = nullptr;
if (ImGui::Button(m_pauseGame ? "Resume Game" : "Pause Game")) {
m_pauseGame ^= 1;
if (m_pauseGame) {
FMODAudioEngine::sharedEngine()->m_globalChannel->setPaused(true);
PAUSED_TARGETS = CCDirector::get()->getScheduler()->pauseAllTargets();
}
else if (PAUSED_TARGETS) {
FMODAudioEngine::sharedEngine()->m_globalChannel->setPaused(false);
CCDirector::get()->getScheduler()->resumeTargets(PAUSED_TARGETS);
}
}
#endif
ImGui::Separator();
ImGui::Text("Theme");
static auto SELECTED = static_cast<int>(getThemeIndex(m_settings.theme));
if (ImGui::Combo("##devtools/theme", &SELECTED,
(ranges::join(getThemeOptions(), std::string(1, '\0')) + '\0').c_str()
)) {
m_settings.theme = getThemeAtIndex(SELECTED);
m_reloadTheme = true;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Select Theme");
}
if (m_settings.theme == "Dark") {
auto color = m_settings.themeColor;
float _color[4] = { color.r / 255.f, color.g / 255.f, color.b / 255.f, color.a / 255.f };
if (ImGui::ColorEdit4("Primary Color", _color)) {
color.r = _color[0] * 255;
color.g = _color[1] * 255;
color.b = _color[2] * 255;
color.a = _color[3] * 255;
m_settings.themeColor = color;
m_reloadTheme = true;
}
}
ImGui::Separator();
ImGui::TextWrapped("Developed by ");
float dt = CCDirector::get()->getDeltaTime();
RAINBOW_HUE += 0.25f * dt;
if (RAINBOW_HUE >= 1.f) {
RAINBOW_HUE = 0.f;
}
float hue = RAINBOW_HUE;
ImVec4 color;
color.w = 1.f;
for (auto c : std::string("Geode Team")) {
hue += 0.04f;
ImGui::SameLine(0.f, 0.f);
ImGui::ColorConvertHSVtoRGB(hue, .5f, 1.f, color.x, color.y, color.z);
ImGui::TextColored(color, "%c", c);
}
ImGui::TextWrapped(
"Running Geode %s, DevTools %s",
Loader::get()->getVersion().toVString().c_str(),
Mod::get()->getVersion().toVString().c_str()
);
if (ImGui::Button("Reset Layout")) {
m_shouldRelayout = true;
}
}
// TODO: this hook also isnt gd *
/*class $modify(AppDelegate) {
void applicationWillEnterForeground() override {
AppDelegate::applicationWillEnterForeground();
if (DevTools::get()->pausedGame()) {
// TODO: undo later
// FMODAudioEngine::sharedEngine()->m_globalChannel->setPaused(true);
}
}
};*/