Skip to content

Commit

Permalink
add option to disable child ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Dec 16, 2023
1 parent e0e4eb4 commit 2745126
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
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.4",
"version": "v1.3.0",
"id": "geode.devtools",
"name": "DevTools",
"developer": "Geode Team",
Expand Down
4 changes: 4 additions & 0 deletions src/DevTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ bool DevTools::isSetup() const {
return m_setup;
}

bool DevTools::shouldOrderChildren() const {
return m_orderChildren;
}

CCNode* DevTools::getSelectedNode() const {
return m_selectedNode;
}
Expand Down
2 changes: 2 additions & 0 deletions src/DevTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DevTools {
bool m_showModGraph = false;
bool m_showModIndex = false;
bool m_pauseGame = false;
bool m_orderChildren = true;
std::string m_theme = DARK_THEME;
ImGuiID m_dockspaceID;
ImFont* m_defaultFont = nullptr;
Expand Down Expand Up @@ -72,6 +73,7 @@ class DevTools {
bool shouldPopGame() const;
bool pausedGame() const;
bool isSetup() const;
bool shouldOrderChildren() const;

CCNode* getSelectedNode() const;
void selectNode(CCNode* node);
Expand Down
9 changes: 9 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
#include <Geode/modify/AchievementNotifier.hpp>
#include <Geode/modify/CCDirector.hpp>
#include <Geode/modify/CCEGLView.hpp>
#include <Geode/modify/CCNode.hpp>
#include "DevTools.hpp"
#include <imgui.h>
#include "ImGui.hpp"

using namespace geode::prelude;

class $modify(CCNode) {
void sortAllChildren() override {
if (DevTools::get()->shouldOrderChildren()) {
CCNode::sortAllChildren();
}
}
};

// todo: use shortcuts api once Geode has those
class $modify(CCKeyboardDispatcher) {
bool dispatchKeyboardMSG(enumKeyCodes key, bool down) {
Expand Down
8 changes: 8 additions & 0 deletions src/pages/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ void DevTools::drawSettings() {
"Makes selecting nodes less annoying."
);
}
ImGui::Checkbox("Order Node Children", &m_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("Advanced Settings", &m_advancedSettings);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(
Expand Down

0 comments on commit 2745126

Please sign in to comment.