Skip to content

Commit 7373e7b

Browse files
committed
2 parents 845e2d0 + 176441d commit 7373e7b

File tree

7 files changed

+50
-29
lines changed

7 files changed

+50
-29
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ Source/Geode/pkg/uber-apk-signer.jar
1212
**/.vscode
1313
**/.idea
1414

15+
**/.idea
16+
1517
imgui/**
1618
imgui

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"geode": "v1.0.0",
3-
"version": "v1.2.0",
3+
"version": "v1.2.2",
44
"id": "geode.devtools",
55
"name": "DevTools",
66
"developer": "Geode Team",

src/DevTools.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class DevTools {
2626
bool m_alwaysHighlight = true;
2727
bool m_shouldRelayout = false;
2828
bool m_highlightLayouts = false;
29+
bool m_arrowExpand = false;
2930
bool m_advancedSettings = false;
3031
bool m_showModGraph = false;
3132
bool m_showModIndex = false;

src/pages/Settings.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ void DevTools::drawSettings() {
3434
"Highlights the borders of all layouts applied to nodes"
3535
);
3636
}
37+
ImGui::Checkbox("Arrow to Expand", &m_arrowExpand);
38+
if (ImGui::IsItemHovered()) {
39+
ImGui::SetTooltip(
40+
"If enabled, expanding nodes in the Tree only works with the arrow. "
41+
"Makes selecting nodes less annoying."
42+
);
43+
}
3744
ImGui::Checkbox("Advanced Settings", &m_advancedSettings);
3845
if (ImGui::IsItemHovered()) {
3946
ImGui::SetTooltip(

src/pages/Tree.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) {
3333
if (selected) {
3434
flags |= ImGuiTreeNodeFlags_Selected;
3535
}
36+
if (!node->getChildrenCount())
37+
{
38+
flags |= ImGuiTreeNodeFlags_Leaf;
39+
}
40+
if (m_arrowExpand)
41+
{
42+
flags |= ImGuiTreeNodeFlags_OpenOnArrow;
43+
}
3644
std::stringstream name;
3745
name << "[" << index << "] " << getNodeName(node) << " ";
3846
if (node->getTag() != -1) {
@@ -42,12 +50,11 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) {
4250
name << "\"" << node->getID() << "\" ";
4351
}
4452
if (node->getChildrenCount()) {
45-
name << "{" << node->getChildrenCount() << "} ";
53+
name << "<" << node->getChildrenCount() << "> ";
4654
}
47-
if (ImGui::TreeNodeEx(
48-
node, flags, "%s", name.str().c_str()
49-
)) {
50-
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) {
55+
// The order here is unusual due to imgui weirdness; see the second-to-last paragraph in https://kahwei.dev/2022/06/20/imgui-tree-node/
56+
bool expanded = ImGui::TreeNodeEx(node, flags, "%s", name.str().c_str());
57+
if (ImGui::IsItemHovered() && (ImGui::IsMouseDoubleClicked(0))) {
5158
if (selected) {
5259
DevTools::get()->selectNode(nullptr);
5360
selected = false;
@@ -56,11 +63,10 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) {
5663
selected = true;
5764
}
5865
}
59-
if (ImGui::IsItemHovered() && (
60-
m_alwaysHighlight || ImGui::IsKeyDown(ImGuiKey_ModShift)
61-
)) {
62-
DevTools::get()->highlightNode(node, HighlightMode::Hovered);
63-
}
66+
if (ImGui::IsItemHovered() && (m_alwaysHighlight || ImGui::IsKeyDown(ImGuiKey_ModShift))) {
67+
DevTools::get()->highlightNode(node, HighlightMode::Hovered);
68+
}
69+
if (expanded) {
6470
if (m_attributesInTree) {
6571
this->drawNodeAttributes(node);
6672
}
@@ -70,11 +76,6 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) {
7076
}
7177
ImGui::TreePop();
7278
}
73-
else if (ImGui::IsItemHovered() && (
74-
m_alwaysHighlight || ImGui::IsKeyDown(ImGuiKey_ModShift)
75-
)) {
76-
DevTools::get()->highlightNode(node, HighlightMode::Hovered);
77-
}
7879
}
7980

8081
void DevTools::drawTree() {

src/platform/platform.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ GLRenderCtx::~GLRenderCtx() {
2626
}
2727

2828
void GLRenderCtx::cleanup() {
29-
if (m_depth) {
30-
glDeleteRenderbuffers(1, &m_depth);
31-
m_depth = 0;
29+
if (m_depthStencil) {
30+
glDeleteRenderbuffers(1, &m_depthStencil);
31+
m_depthStencil = 0;
3232
}
3333
if (m_texture) {
3434
log::info("deleting texture {}", m_texture);
@@ -53,6 +53,10 @@ ImVec2 GLRenderCtx::size() const {
5353
}
5454

5555
bool GLRenderCtx::begin() {
56+
// save currently bound fbo
57+
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &m_prevDrawBuffer);
58+
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &m_prevReadBuffer);
59+
5660
if (!m_buffer) {
5761
glGenFramebuffers(1, &m_buffer);
5862
glBindFramebuffer(GL_FRAMEBUFFER, m_buffer);
@@ -80,15 +84,15 @@ bool GLRenderCtx::begin() {
8084
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
8185
}
8286

83-
if (!m_depth) {
84-
glGenRenderbuffers(1, &m_depth);
85-
glBindRenderbuffer(GL_RENDERBUFFER, m_depth);
87+
if (!m_depthStencil) {
88+
glGenRenderbuffers(1, &m_depthStencil);
89+
glBindRenderbuffer(GL_RENDERBUFFER, m_depthStencil);
8690
glRenderbufferStorage(
87-
GL_RENDERBUFFER, GL_DEPTH_COMPONENT,
91+
GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
8892
static_cast<GLsizei>(m_size.x),
8993
static_cast<GLsizei>(m_size.y)
9094
);
91-
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depth);
95+
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencil);
9296

9397
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0);
9498
}
@@ -99,14 +103,17 @@ bool GLRenderCtx::begin() {
99103
return false;
100104
}
101105

106+
// bind our framebuffer
102107
glBindFramebuffer(GL_FRAMEBUFFER, m_buffer);
103108

104109
return true;
105110
}
106111

107112
void GLRenderCtx::end() {
108-
glBindFramebuffer(GL_FRAMEBUFFER, 0);
109-
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
110-
glFlush();
113+
// bind the framebuffer that was bound before us
114+
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_prevDrawBuffer);
115+
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_prevReadBuffer);
116+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
117+
//glFlush();
111118
}
112119

src/platform/platform.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ bool& shouldUpdateGDRenderBuffer();
99

1010
class GLRenderCtx final {
1111
private:
12-
GLuint m_buffer = 0;
12+
GLuint m_buffer = 0;
1313
GLuint m_texture = 0;
14-
GLuint m_depth = 0;
14+
GLuint m_depthStencil = 0;
1515
ImVec2 m_size;
1616

17+
GLint m_prevDrawBuffer = 0;
18+
GLint m_prevReadBuffer = 0;
19+
1720
void cleanup();
1821

1922
public:

0 commit comments

Comments
 (0)