Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Sep 15, 2023
2 parents 845e2d0 + 176441d commit 7373e7b
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ Source/Geode/pkg/uber-apk-signer.jar
**/.vscode
**/.idea

**/.idea

imgui/**
imgui
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "v1.0.0",
"version": "v1.2.0",
"version": "v1.2.2",
"id": "geode.devtools",
"name": "DevTools",
"developer": "Geode Team",
Expand Down
1 change: 1 addition & 0 deletions src/DevTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/pages/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
31 changes: 16 additions & 15 deletions src/pages/Tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index) {
if (selected) {
flags |= ImGuiTreeNodeFlags_Selected;
}
if (!node->getChildrenCount())
{
flags |= ImGuiTreeNodeFlags_Leaf;
}
if (m_arrowExpand)
{
flags |= ImGuiTreeNodeFlags_OpenOnArrow;
}
std::stringstream name;
name << "[" << index << "] " << getNodeName(node) << " ";
if (node->getTag() != -1) {
Expand All @@ -42,12 +50,11 @@ 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()
)) {
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;
Expand All @@ -56,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);
}
Expand All @@ -70,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() {
Expand Down
29 changes: 18 additions & 11 deletions src/platform/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -80,15 +84,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<GLsizei>(m_size.x),
static_cast<GLsizei>(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);
}
Expand All @@ -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);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glFlush();
// 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();
}

7 changes: 5 additions & 2 deletions src/platform/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ bool& shouldUpdateGDRenderBuffer();

class GLRenderCtx final {
private:
GLuint m_buffer = 0;
GLuint m_buffer = 0;
GLuint m_texture = 0;
GLuint m_depth = 0;
GLuint m_depthStencil = 0;
ImVec2 m_size;

GLint m_prevDrawBuffer = 0;
GLint m_prevReadBuffer = 0;

void cleanup();

public:
Expand Down

0 comments on commit 7373e7b

Please sign in to comment.