From ca664b78df2ea5e884624bbe636a92007ebc3cbb Mon Sep 17 00:00:00 2001 From: undefined06855 Date: Sun, 5 Jan 2025 12:38:52 +0000 Subject: [PATCH] version 123 (prev commits have messed up history dw) --- changelog.md | 4 +++ mod.json | 4 +-- src/MenuGameLayer.cpp | 7 +---- src/MenuGameLayer.hpp | 4 --- src/MenuIcon.cpp | 4 +-- src/MenuLayer.cpp | 59 +++++++++++++++++++++++++++++++++++------ src/MenuLayer.hpp | 4 +++ src/NinjaSwipeLayer.cpp | 1 + 8 files changed, 65 insertions(+), 22 deletions(-) diff --git a/changelog.md b/changelog.md index 6512dad..88fdbd1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,8 @@ # Icon Ninja Changelog +## v1.2.3 +- Moved around node order for better compatibility +- Added Day & Night System compatibility +- Fixed issues with glyphs of certain buttons not fading out ## v1.2.2 - Added option to disable logging - (Internal) Renamed debug flag to `-DDEBUG_DRAW_NODE` to prevent conflicts that may have been happening diff --git a/mod.json b/mod.json index 8548e09..97948f2 100644 --- a/mod.json +++ b/mod.json @@ -1,5 +1,5 @@ { - "geode": "4.1.0", + "geode": "4.1.2", "gd": { "win": "2.2074", "android": "2.2074" @@ -7,7 +7,7 @@ "id": "undefined0.icon_ninja", "name": "Icon Ninja", - "version": "v1.2.2", + "version": "v1.2.3", "developer": "undefined0", "description": "Makes killing icons like Fruit Ninja!", "tags": [ "joke", "offline", "modtober24" ], diff --git a/src/MenuGameLayer.cpp b/src/MenuGameLayer.cpp index 47474e6..1e7a3de 100644 --- a/src/MenuGameLayer.cpp +++ b/src/MenuGameLayer.cpp @@ -1,18 +1,13 @@ #include "MenuGameLayer.hpp" -#include "NinjaSwipeLayer.hpp" bool HookedMenuGameLayer::init() { if (!MenuGameLayer::init()) return false; - // add custom layer to detect touch and draw the swipe - m_fields->ninjaSwipeLayer = NinjaSwipeLayer::create(); - m_fields->ninjaSwipeLayer->setZOrder(999); - addChild(m_fields->ninjaSwipeLayer); // remove touch from this setTouchEnabled(false); cocos2d::CCTouchDispatcher::get()->removeDelegate(this); - // remove shit + // remove other shit m_groundLayer->setVisible(false); return true; diff --git a/src/MenuGameLayer.hpp b/src/MenuGameLayer.hpp index efd3c04..76b36b3 100644 --- a/src/MenuGameLayer.hpp +++ b/src/MenuGameLayer.hpp @@ -1,11 +1,7 @@ #pragma once #include -#include "NinjaSwipeLayer.hpp" class $modify(HookedMenuGameLayer, MenuGameLayer) { - struct Fields { - NinjaSwipeLayer* ninjaSwipeLayer; - }; bool init(); void update(float dt); }; diff --git a/src/MenuIcon.cpp b/src/MenuIcon.cpp index 880a02b..a0b6ef4 100644 --- a/src/MenuIcon.cpp +++ b/src/MenuIcon.cpp @@ -1,5 +1,5 @@ #include "MenuIcon.hpp" -#include "MenuGameLayer.hpp" +#include "MenuLayer.hpp" #include "utils/random.hpp" MenuIcon* MenuIcon::create(MenuIconType type) { @@ -69,7 +69,7 @@ cocos2d::CCPoint MenuIcon::getWorldPos() { cocos2d::CCPoint worldPos = convertToWorldSpace(getPosition()); // convert to node space relative to swipeLayer - auto swipeLayer = static_cast(MenuLayer::get()->m_menuGameLayer)->m_fields->ninjaSwipeLayer; + auto swipeLayer = static_cast(MenuLayer::get())->m_fields->ninjaSwipeLayer; return swipeLayer->convertToNodeSpace(worldPos); } diff --git a/src/MenuLayer.cpp b/src/MenuLayer.cpp index d022190..9401c61 100644 --- a/src/MenuLayer.cpp +++ b/src/MenuLayer.cpp @@ -1,7 +1,14 @@ #include "MenuLayer.hpp" #include "MenuGameLayer.hpp" -#include "NinjaSwipeLayer.hpp" #include "utils/random.hpp" +#include "utils/log.hpp" + +void HookedMenuLayer::onModify(auto& self) { + ninja::log::info("hook prio time"); + if (!self.setHookPriority("MenuLayer::init", geode::Priority::VeryLatePost)) { + ninja::log::warn("failed to set hook prio??? compats may be broken"); + } +} bool HookedMenuLayer::init() { if (!MenuLayer::init()) return false; @@ -11,14 +18,50 @@ bool HookedMenuLayer::init() { title->setCascadeOpacityEnabled(true); } + // day and night system compatibility + if (auto dnsEventNode = getChildByID("ninsam.day_and_night_system/Events")) { + ninja::log::info("day and night system momento"); + dnsEventNode->setZOrder(-2); + } + + // gd compatibility (real) + // ensure cascade opacity is enabled for children of buttons and such (really just circlebuttonsprite) + std::array menuNames = { + "bottom-menu", + "right-side-menu", + "top-right-menu", + "side-menu", + "close-menu" + }; + + for (auto& name : menuNames) { + auto menu = getChildByID(name); + if (!menu) continue; + + for (auto& child : geode::cocos::CCArrayExt(menu->getChildren())) { + for (auto& innerChild : geode::cocos::CCArrayExt(child->getChildren())) { + auto castInnerChild = geode::cast::typeinfo_cast(innerChild); + if (!castInnerChild) continue; + castInnerChild->setCascadeOpacityEnabled(true); + } + } + } + + + // add our very own brand spanking new shiny icon ninja custom layer!!!!!!!! + m_fields->ninjaSwipeLayer = NinjaSwipeLayer::create(); + addChild(m_fields->ninjaSwipeLayer, -1); + + m_menuGameLayer->setZOrder(-5); // get back there + return true; } void HookedMenuLayer::keyDown(cocos2d::enumKeyCodes code) { - auto mgl = static_cast(m_menuGameLayer); - auto nsl = mgl->m_fields->ninjaSwipeLayer; - if (nsl->m_state == State::Gameplay) { - if (code == cocos2d::enumKeyCodes::KEY_Escape) nsl->exitGameplay(nullptr); + auto ninja = m_fields->ninjaSwipeLayer; + + if (ninja->m_state == State::Gameplay) { + if (code == cocos2d::enumKeyCodes::KEY_Escape) ninja->exitGameplay(nullptr); // dont call orig return; } @@ -35,10 +78,10 @@ void HookedMenuLayer::runEnterGameplayAnimations() { // dw about this code // rewrite it if you wish - // gets all children and if they're not this figures out where they should - // move to and stores it in (std::map)m_fields->movedNodeMovements + // gets all children and if they should be moved figures out where they + // should move to and stores it in (std::map)m_fields->movedNodeMovements for (auto& child : geode::cocos::CCArrayExt(getChildren())) { - if (child == m_menuGameLayer) continue; + if (child == m_menuGameLayer || child == m_fields->ninjaSwipeLayer) continue; // get side + move dist cocos2d::CCPoint movement; diff --git a/src/MenuLayer.hpp b/src/MenuLayer.hpp index 7d4cd03..9fff8c2 100644 --- a/src/MenuLayer.hpp +++ b/src/MenuLayer.hpp @@ -1,10 +1,14 @@ #pragma once #include #include +#include "NinjaSwipeLayer.hpp" class $modify(HookedMenuLayer, MenuLayer) { + static void onModify(auto& self); + struct Fields { std::map movedNodeMovements; + NinjaSwipeLayer* ninjaSwipeLayer; }; bool init(); diff --git a/src/NinjaSwipeLayer.cpp b/src/NinjaSwipeLayer.cpp index 6854820..c571924 100644 --- a/src/NinjaSwipeLayer.cpp +++ b/src/NinjaSwipeLayer.cpp @@ -49,6 +49,7 @@ bool NinjaSwipeLayer::init() { m_scoreLayer->setPosition(dir->getWinSize() / 2); m_scoreLayer->setPositionY(m_scoreLayer->getPositionY() + 140.f); m_scoreLayer->runAction(cocos2d::CCFadeOut::create(0.f)); // setOpacity(0) doesnt work idfk please tell me why + m_scoreLayer->setOpacity(0); // for the platforms where it does (also it might have fixed itself maybe) std::string fontString = "bigFont.fnt"; int64_t font = geode::Mod::get()->getSettingValue("font");