From b3ae72046791328e25c47c2a935de4eef110f3c2 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:18:56 +0200 Subject: [PATCH] add $override annotations + comment out the crashing func on android --- .gitignore | 1 + CMakeLists.txt | 2 ++ src/features/BetterColorSelect.cpp | 19 ++++++++++++++----- src/features/BetterFontSelect.cpp | 1 + src/features/FixMouseControls.cpp | 3 ++- src/features/Keybinds.cpp | 1 + src/features/scaling/EditorPauseUIScaling.cpp | 1 + src/features/scaling/EditorUIScaling.cpp | 1 + 8 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index ab857f9c..4db610b0 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ # Ignore build folders **/build +**/build-* # Workspace files are user-specific *.sublime-workspace diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b8603b8..c74baf14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,8 @@ file(GLOB SOURCES add_library(${PROJECT_NAME} SHARED ${SOURCES}) +target_include_directories(${PROJECT_NAME} PUBLIC "src") + if (NOT DEFINED ENV{GEODE_SDK}) message(FATAL_ERROR "Unable to find Geode SDK! Please define GEODE_SDK environment variable to point to Geode") else() diff --git a/src/features/BetterColorSelect.cpp b/src/features/BetterColorSelect.cpp index ed31d365..b1b0a59c 100644 --- a/src/features/BetterColorSelect.cpp +++ b/src/features/BetterColorSelect.cpp @@ -137,9 +137,7 @@ class $modify(NewColorSelect, CustomizeObjectLayer) { void updateSpritesInMenu(CCNode* menu) { if (menu) { for (auto child : CCArrayExt(menu->getChildren())) { - if (auto spr = static_cast( - child->getChildByID("channel-sprite"_spr) - )) { + if (auto spr = static_cast(child->getChildByID("channel-sprite"_spr))) { this->updateSprite(spr); } } @@ -149,9 +147,10 @@ class $modify(NewColorSelect, CustomizeObjectLayer) { void updateSprites() { this->updateSpritesInMenu(m_mainLayer->getChildByID("channels-menu")); this->updateSpritesInMenu(m_mainLayer->getChildByID("special-channels-menu")); - this->updateSpritesInMenu(m_mainLayer->getChildByID("recent-channels-menu")); + this->updateSpritesInMenu(m_mainLayer->getChildByID("recent-channels-menu"_spr)); } + $override void onSelectColor(CCObject* sender) { if (!Mod::get()->template getSettingValue("new-color-menu")) { return CustomizeObjectLayer::onSelectColor(sender); @@ -177,6 +176,7 @@ class $modify(NewColorSelect, CustomizeObjectLayer) { } } + $override void highlightSelected(ButtonSprite* sprite) { if (!Mod::get()->template getSettingValue("new-color-menu")) { return CustomizeObjectLayer::highlightSelected(sprite); @@ -184,9 +184,12 @@ class $modify(NewColorSelect, CustomizeObjectLayer) { auto selected = this->getActiveMode(true); this->highlightSelectedInMenu(m_mainLayer->getChildByID("channels-menu"), selected); this->highlightSelectedInMenu(m_mainLayer->getChildByID("special-channels-menu"), selected); - this->highlightSelectedInMenu(m_mainLayer->getChildByID("recent-channels-menu"), selected); + this->highlightSelectedInMenu(m_mainLayer->getChildByID("recent-channels-menu"_spr), selected); } +// todo: hooking this virtual crashes on Android? probably a TulipHook or loader issue +#ifndef GEODE_IS_ANDROID + $override void colorSelectClosed(CCNode* target) { if (!Mod::get()->template getSettingValue("new-color-menu")) { return CustomizeObjectLayer::colorSelectClosed(target); @@ -194,7 +197,9 @@ class $modify(NewColorSelect, CustomizeObjectLayer) { CustomizeObjectLayer::colorSelectClosed(target); this->updateSprites(); } +#endif + $override void updateCustomColorLabels() { if (!Mod::get()->template getSettingValue("new-color-menu")) { return CustomizeObjectLayer::updateCustomColorLabels(); @@ -207,6 +212,7 @@ class $modify(NewColorSelect, CustomizeObjectLayer) { m_customColorInput->m_textField->detachWithIME(); } + $override void onUpdateCustomColor(CCObject* sender) { if (!Mod::get()->template getSettingValue("new-color-menu")) { return CustomizeObjectLayer::onUpdateCustomColor(sender); @@ -290,6 +296,7 @@ class $modify(NewColorSelect, CustomizeObjectLayer) { m_fields->modified = true; } + $override void textChanged(CCTextInputNode* input) { if (!Mod::get()->template getSettingValue("new-color-menu")) { return CustomizeObjectLayer::textChanged(input); @@ -299,6 +306,7 @@ class $modify(NewColorSelect, CustomizeObjectLayer) { m_fields->modified = true; } + $override void onClose(CCObject* sender) { if (!Mod::get()->template getSettingValue("new-color-menu")) { return CustomizeObjectLayer::onClose(sender); @@ -359,6 +367,7 @@ class $modify(NewColorSelect, CustomizeObjectLayer) { this->gotoPage(m_fields->page + sender->getTag()); } + $override bool init(GameObject* obj, CCArray* objs) { if (!CustomizeObjectLayer::init(obj, objs)) return false; diff --git a/src/features/BetterFontSelect.cpp b/src/features/BetterFontSelect.cpp index 12cb883a..c97475c2 100644 --- a/src/features/BetterFontSelect.cpp +++ b/src/features/BetterFontSelect.cpp @@ -27,6 +27,7 @@ class $modify(BetterSelectFontLayer, SelectFontLayer) { } } + $override bool init(LevelEditorLayer* p0) { if (!SelectFontLayer::init(p0)) return false; diff --git a/src/features/FixMouseControls.cpp b/src/features/FixMouseControls.cpp index acafb252..720ce537 100644 --- a/src/features/FixMouseControls.cpp +++ b/src/features/FixMouseControls.cpp @@ -10,7 +10,8 @@ using namespace geode::prelude; class $modify(EditorUI) { - void scrollWheel(float y, float x) override { + $override + virtual void scrollWheel(float y, float x) { // this is used a lot so store it in a variable auto objLayer = m_editorLayer->m_objectLayer; diff --git a/src/features/Keybinds.cpp b/src/features/Keybinds.cpp index fb933d2b..2ddf91c3 100644 --- a/src/features/Keybinds.cpp +++ b/src/features/Keybinds.cpp @@ -10,6 +10,7 @@ using namespace geode::prelude; using namespace keybinds; struct $modify(EditorUI) { + $override bool init(LevelEditorLayer* lel) { if (!EditorUI::init(lel)) return false; diff --git a/src/features/scaling/EditorPauseUIScaling.cpp b/src/features/scaling/EditorPauseUIScaling.cpp index 36abcab8..3597019a 100644 --- a/src/features/scaling/EditorPauseUIScaling.cpp +++ b/src/features/scaling/EditorPauseUIScaling.cpp @@ -5,6 +5,7 @@ using namespace geode::prelude; class $modify(EditorPauseLayer) { + $override bool init(LevelEditorLayer* p0) { if (!EditorPauseLayer::init(p0)) return false; diff --git a/src/features/scaling/EditorUIScaling.cpp b/src/features/scaling/EditorUIScaling.cpp index 9b909706..ac30956f 100644 --- a/src/features/scaling/EditorUIScaling.cpp +++ b/src/features/scaling/EditorUIScaling.cpp @@ -7,6 +7,7 @@ using namespace geode::prelude; class $modify(EditorUI) { + $override bool init(LevelEditorLayer* p0) { if (!EditorUI::init(p0)) return false;