-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathDevTools.hpp
More file actions
164 lines (140 loc) · 4.43 KB
/
Copy pathDevTools.hpp
File metadata and controls
164 lines (140 loc) · 4.43 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
#pragma once
#include "platform/platform.hpp"
#include <imgui.h>
#include "themes.hpp"
#include <cocos2d.h>
#include <Geode/utils/cocos.hpp>
#include <Geode/utils/addresser.hpp>
#include <Geode/loader/Loader.hpp>
#include <Geode/loader/ModMetadata.hpp>
#include "nodes/DragButton.hpp"
using namespace geode::prelude;
enum class HighlightMode {
Selected,
Hovered,
Layout,
};
struct Settings {
bool GDInWindow = true;
bool attributesInTree = false;
bool alwaysHighlight = true;
bool highlightLayouts = false;
bool arrowExpand = false;
bool orderChildren = true;
bool advancedSettings = false;
bool showMemoryViewer = false;
bool showModGraph = false;
float scrollbarSize = GEODE_DESKTOP(14.f) GEODE_MOBILE(60.f);
std::string theme = DARK_THEME;
ccColor4B themeColor = {2, 119, 189, 255};
CCPoint buttonPos = {50, 50};
bool buttonInEditor = false;
bool buttonInGame = false;
bool buttonEnabled = false;
bool treeDragReorder = false;
#ifdef GEODE_IS_MOBILE
float fontScale = 2.f;
#else
float fontScale = 1.f;
#endif
bool hideFlaggedNodes = false;
};
struct TreeBranchOptions {
bool drag = true;
bool visible = true;
bool fake = false;
bool flagHidden = false;
};
struct ParentNodeInformation {
bool drag = true;
bool visible = true;
bool flagHidden = false;
};
class DevTools {
protected:
bool m_visible = false;
bool m_setup = false;
bool m_reloadTheme = true;
bool m_shouldRelayout = false;
bool m_showModGraph = false;
bool m_pauseGame = false;
Settings m_settings;
ImGuiID m_dockspaceID;
ImFont* m_defaultFont = nullptr;
ImFont* m_smallFont = nullptr;
ImFont* m_monoFont = nullptr;
ImFont* m_boxFont = nullptr;
CCTexture2D* m_fontTexture = nullptr;
Ref<CCNode> m_selectedNode;
Ref<CCNode> m_draggedNode;
std::vector<std::pair<CCNode*, HighlightMode>> m_toHighlight;
std::vector<Function<void(CCNode*)>> m_customCallbacks;
std::string m_searchQuery;
std::string m_prevQuery;
std::unordered_map<CCNode*, bool> m_nodeOpen;
DragButton* m_dragButton = nullptr;
void setupFonts();
void setupPlatform();
void drawTree();
void drawTreeBranch(CCNode* node, size_t index, TreeBranchOptions options);
void drawNodeChildren(CCNode* node, ParentNodeInformation info);
void drawSettings();
void drawAdvancedSettings();
void drawNodeAttributes(CCNode* node);
void drawAttributes();
void drawBasicAttributes(CCNode* node);
void drawColorAttributes(CCNode* node);
void drawLabelAttributes(CCNode* node);
void drawAxisGapAttribute(CCNode* node);
void drawTextureAttributes(CCNode* node);
void drawMenuItemAttributes(CCNode* node);
void drawLayoutOptionsAttributes(CCNode* node);
void drawLayoutAttributes(CCNode* node);
void drawPreview();
void drawNodePreview(CCNode* node);
void drawHighlight(CCNode* node, HighlightMode mode);
void drawLayoutHighlights(CCNode* node);
void drawGD(GLRenderCtx* ctx);
void drawModGraph();
void drawModGraphNode(Mod* node);
ModMetadata inputMetadata(void* treePtr, ModMetadata metadata);
void drawPage(const char* name, void(DevTools::* fun)());
void drawPages();
void drawMemory();
void draw(GLRenderCtx* ctx);
void newFrame();
void renderDrawData(ImDrawData*);
void renderDrawDataFallback(ImDrawData*);
bool searchBranch(CCNode* node);
bool hasExtension(const std::string& ext) const;
DevTools() { loadSettings(); }
public:
static DevTools* get();
void loadSettings();
void saveSettings();
Settings getSettings();
void setBallPosition(CCPoint pos);
bool shouldUseGDWindow() const;
bool shouldPopGame() const;
bool pausedGame() const;
bool isSetup() const;
bool shouldOrderChildren() const;
CCNode* getSelectedNode() const;
void selectNode(CCNode* node);
void highlightNode(CCNode* node, HighlightMode mode);
CCNode* getDraggedNode() const;
void setDraggedNode(CCNode* node);
void addCustomCallback(Function<void(CCNode*)>&& callback);
DragButton* getDragButton();
void setupDragButton();
void removeDragButton();
bool isButtonEnabled();
void sceneChanged();
void render(GLRenderCtx* ctx);
// setup ImGui & DevTools
void setup();
void destroy();
void show(bool visible);
void toggle();
bool isVisible();
};