From 25267e5bfd127d684ad0063a52c00b17c340c7d4 Mon Sep 17 00:00:00 2001 From: ConfiG Date: Sat, 9 Sep 2023 11:07:56 +0300 Subject: [PATCH 1/9] add .idea to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 245693f..c337ee4 100644 --- a/.gitignore +++ b/.gitignore @@ -12,5 +12,7 @@ Source/Geode/pkg/uber-apk-signer.jar **/.vscode **/.idea +**/.idea + imgui/** imgui From 18b8f17acf3e1f4fcd9025a1459d1d3e6c8c49be Mon Sep 17 00:00:00 2001 From: ConfiG Date: Sat, 9 Sep 2023 11:09:24 +0300 Subject: [PATCH 2/9] attach a stencil component to the gd fbo --- src/platform/platform.cpp | 18 +++++++++--------- src/platform/platform.hpp | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/platform/platform.cpp b/src/platform/platform.cpp index 8ab2c9e..d8522cf 100644 --- a/src/platform/platform.cpp +++ b/src/platform/platform.cpp @@ -26,9 +26,9 @@ GLRenderCtx::~GLRenderCtx() { } void GLRenderCtx::cleanup() { - if (m_depth) { - glDeleteRenderbuffers(1, &m_depth); - m_depth = 0; + if (m_depthStencil) { + glDeleteRenderbuffers(1, &m_depthStencil); + m_depthStencil = 0; } if (m_texture) { log::info("deleting texture {}", m_texture); @@ -80,15 +80,15 @@ bool GLRenderCtx::begin() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } - if (!m_depth) { - glGenRenderbuffers(1, &m_depth); - glBindRenderbuffer(GL_RENDERBUFFER, m_depth); + if (!m_depthStencil) { + glGenRenderbuffers(1, &m_depthStencil); + glBindRenderbuffer(GL_RENDERBUFFER, m_depthStencil); glRenderbufferStorage( - GL_RENDERBUFFER, GL_DEPTH_COMPONENT, + GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, static_cast(m_size.x), static_cast(m_size.y) ); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depth); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencil); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0); } @@ -106,7 +106,7 @@ bool GLRenderCtx::begin() { void GLRenderCtx::end() { glBindFramebuffer(GL_FRAMEBUFFER, 0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glFlush(); } diff --git a/src/platform/platform.hpp b/src/platform/platform.hpp index 692c160..6344ac5 100644 --- a/src/platform/platform.hpp +++ b/src/platform/platform.hpp @@ -9,9 +9,9 @@ bool& shouldUpdateGDRenderBuffer(); class GLRenderCtx final { private: - GLuint m_buffer = 0; - GLuint m_texture = 0; - GLuint m_depth = 0; + GLuint m_buffer = 0; + GLuint m_texture = 0; + GLuint m_depthStencil = 0; ImVec2 m_size; void cleanup(); From 06802bb05edf26568392acc046c44eb9a7bb1a99 Mon Sep 17 00:00:00 2001 From: ConfiG Date: Sat, 9 Sep 2023 11:12:44 +0300 Subject: [PATCH 3/9] bump version to 1.2.1 --- mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod.json b/mod.json index 1ab58f4..6b6f290 100644 --- a/mod.json +++ b/mod.json @@ -1,6 +1,6 @@ { "geode": "v1.0.0", - "version": "v1.2.0", + "version": "v1.2.1", "id": "geode.devtools", "name": "DevTools", "developer": "Geode Team", From 516af4c826cc7fff5c809857cba84efa2726a26a Mon Sep 17 00:00:00 2001 From: ConfiG Date: Sat, 9 Sep 2023 11:26:25 +0300 Subject: [PATCH 4/9] rebind the previously bound fbo instead of 0 --- src/platform/platform.cpp | 11 +++++++++-- src/platform/platform.hpp | 7 +++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/platform/platform.cpp b/src/platform/platform.cpp index d8522cf..97acbd8 100644 --- a/src/platform/platform.cpp +++ b/src/platform/platform.cpp @@ -53,6 +53,10 @@ ImVec2 GLRenderCtx::size() const { } bool GLRenderCtx::begin() { + // save currently bound fbo + glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &m_prevDrawBuffer); + glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &m_prevReadBuffer); + if (!m_buffer) { glGenFramebuffers(1, &m_buffer); glBindFramebuffer(GL_FRAMEBUFFER, m_buffer); @@ -99,14 +103,17 @@ bool GLRenderCtx::begin() { return false; } + // bind our framebuffer glBindFramebuffer(GL_FRAMEBUFFER, m_buffer); return true; } void GLRenderCtx::end() { - glBindFramebuffer(GL_FRAMEBUFFER, 0); + // bind the framebuffer that was bound before us + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_prevDrawBuffer); + glBindFramebuffer(GL_READ_FRAMEBUFFER, m_prevReadBuffer); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - glFlush(); + //glFlush(); } diff --git a/src/platform/platform.hpp b/src/platform/platform.hpp index 6344ac5..a3facbb 100644 --- a/src/platform/platform.hpp +++ b/src/platform/platform.hpp @@ -9,11 +9,14 @@ bool& shouldUpdateGDRenderBuffer(); class GLRenderCtx final { private: - GLuint m_buffer = 0; - GLuint m_texture = 0; + GLuint m_buffer = 0; + GLuint m_texture = 0; GLuint m_depthStencil = 0; ImVec2 m_size; + GLint m_prevDrawBuffer = 0; + GLint m_prevReadBuffer = 0; + void cleanup(); public: From 057777cd64ed231a2c7f86b2524d847844701f9d Mon Sep 17 00:00:00 2001 From: DeathFuel <108496936+DeathFuel@users.noreply.github.com> Date: Thu, 14 Sep 2023 22:49:31 +0200 Subject: [PATCH 5/9] Tree: hide expand arrow in leaf nodes --- src/pages/Tree.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/Tree.cpp b/src/pages/Tree.cpp index b5fdeef..948f8ad 100644 --- a/src/pages/Tree.cpp +++ b/src/pages/Tree.cpp @@ -33,6 +33,10 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) { if (selected) { flags |= ImGuiTreeNodeFlags_Selected; } + if (!node->getChildrenCount()) + { + flags |= ImGuiTreeNodeFlags_Leaf; + } std::stringstream name; name << "[" << index << "] " << getNodeName(node) << " "; if (node->getTag() != -1) { From 79aeab526b0acfce0070c2273a4675089334f2cd Mon Sep 17 00:00:00 2001 From: DeathFuel <108496936+DeathFuel@users.noreply.github.com> Date: Thu, 14 Sep 2023 22:51:47 +0200 Subject: [PATCH 6/9] Tree: replace child count character (1) and {1} are easy to confuse, using <> fixes that IMO --- src/pages/Tree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Tree.cpp b/src/pages/Tree.cpp index 948f8ad..6e79e5d 100644 --- a/src/pages/Tree.cpp +++ b/src/pages/Tree.cpp @@ -46,7 +46,7 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) { name << "\"" << node->getID() << "\" "; } if (node->getChildrenCount()) { - name << "{" << node->getChildrenCount() << "} "; + name << "<" << node->getChildrenCount() << "> "; } if (ImGui::TreeNodeEx( node, flags, "%s", name.str().c_str() From 92690d1878e0184d4f8391e78de96b4696105976 Mon Sep 17 00:00:00 2001 From: DeathFuel <108496936+DeathFuel@users.noreply.github.com> Date: Thu, 14 Sep 2023 23:58:08 +0200 Subject: [PATCH 7/9] Add a setting to only expand nodes with the arrow --- src/DevTools.hpp | 1 + src/pages/Settings.cpp | 7 +++++++ src/pages/Tree.cpp | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/DevTools.hpp b/src/DevTools.hpp index 10aef09..d7025ec 100644 --- a/src/DevTools.hpp +++ b/src/DevTools.hpp @@ -26,6 +26,7 @@ class DevTools { bool m_alwaysHighlight = true; bool m_shouldRelayout = false; bool m_highlightLayouts = false; + bool m_arrowExpand = false; bool m_advancedSettings = false; bool m_showModGraph = false; bool m_showModIndex = false; diff --git a/src/pages/Settings.cpp b/src/pages/Settings.cpp index 9ba50d4..48b1828 100644 --- a/src/pages/Settings.cpp +++ b/src/pages/Settings.cpp @@ -34,6 +34,13 @@ void DevTools::drawSettings() { "Highlights the borders of all layouts applied to nodes" ); } + ImGui::Checkbox("Arrow to Expand", &m_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("Advanced Settings", &m_advancedSettings); if (ImGui::IsItemHovered()) { ImGui::SetTooltip( diff --git a/src/pages/Tree.cpp b/src/pages/Tree.cpp index 6e79e5d..8ad3925 100644 --- a/src/pages/Tree.cpp +++ b/src/pages/Tree.cpp @@ -37,6 +37,10 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) { { flags |= ImGuiTreeNodeFlags_Leaf; } + if (m_arrowExpand) + { + flags |= ImGuiTreeNodeFlags_OpenOnArrow; + } std::stringstream name; name << "[" << index << "] " << getNodeName(node) << " "; if (node->getTag() != -1) { @@ -51,7 +55,7 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) { if (ImGui::TreeNodeEx( node, flags, "%s", name.str().c_str() )) { - if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) { + if (ImGui::IsItemHovered() && (ImGui::IsMouseDoubleClicked(0))) { if (selected) { DevTools::get()->selectNode(nullptr); selected = false; From 6e52cd7428fea9a6bcddbfcc14646fde294b8aba Mon Sep 17 00:00:00 2001 From: DeathFuel <108496936+DeathFuel@users.noreply.github.com> Date: Fri, 15 Sep 2023 01:19:51 +0200 Subject: [PATCH 8/9] Fix a node selection bug (see desc) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's now possible to select nodes that aren't expanded. Interestingly, this bug seems to have been here before, but it was hard to notice because it (theoretically) wasn't possible to select the node without also expanding it Hope this doesn't break anything, it works on my machine 🙃 --- src/pages/Tree.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/pages/Tree.cpp b/src/pages/Tree.cpp index 8ad3925..cc382a3 100644 --- a/src/pages/Tree.cpp +++ b/src/pages/Tree.cpp @@ -52,10 +52,9 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) { if (node->getChildrenCount()) { name << "<" << node->getChildrenCount() << "> "; } - if (ImGui::TreeNodeEx( - node, flags, "%s", name.str().c_str() - )) { - if (ImGui::IsItemHovered() && (ImGui::IsMouseDoubleClicked(0))) { + // 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/ + bool expanded = ImGui::TreeNodeEx(node, flags, "%s", name.str().c_str()); + if (ImGui::IsItemHovered() && (ImGui::IsMouseDoubleClicked(0))) { if (selected) { DevTools::get()->selectNode(nullptr); selected = false; @@ -64,11 +63,10 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) { selected = true; } } - if (ImGui::IsItemHovered() && ( - m_alwaysHighlight || ImGui::IsKeyDown(ImGuiKey_ModShift) - )) { - DevTools::get()->highlightNode(node, HighlightMode::Hovered); - } + if (ImGui::IsItemHovered() && (m_alwaysHighlight || ImGui::IsKeyDown(ImGuiKey_ModShift))) { + DevTools::get()->highlightNode(node, HighlightMode::Hovered); + } + if (expanded) { if (m_attributesInTree) { this->drawNodeAttributes(node); } @@ -78,11 +76,6 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) { } ImGui::TreePop(); } - else if (ImGui::IsItemHovered() && ( - m_alwaysHighlight || ImGui::IsKeyDown(ImGuiKey_ModShift) - )) { - DevTools::get()->highlightNode(node, HighlightMode::Hovered); - } } void DevTools::drawTree() { From 176441d9196f5d9f29600176ee0499d3f1b2af84 Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Fri, 15 Sep 2023 07:47:11 +0300 Subject: [PATCH 9/9] Bump version to 1.2.2 --- mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod.json b/mod.json index 6b6f290..99e6cc4 100644 --- a/mod.json +++ b/mod.json @@ -1,6 +1,6 @@ { "geode": "v1.0.0", - "version": "v1.2.1", + "version": "v1.2.2", "id": "geode.devtools", "name": "DevTools", "developer": "Geode Team",