Skip to content

Commit

Permalink
version 123 (prev commits have messed up history dw)
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined06855 committed Jan 5, 2025
1 parent adf7af1 commit ca664b7
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 22 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"geode": "4.1.0",
"geode": "4.1.2",
"gd": {
"win": "2.2074",
"android": "2.2074"
},

"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" ],
Expand Down
7 changes: 1 addition & 6 deletions src/MenuGameLayer.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 0 additions & 4 deletions src/MenuGameLayer.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#pragma once
#include <Geode/modify/MenuGameLayer.hpp>
#include "NinjaSwipeLayer.hpp"

class $modify(HookedMenuGameLayer, MenuGameLayer) {
struct Fields {
NinjaSwipeLayer* ninjaSwipeLayer;
};
bool init();
void update(float dt);
};
4 changes: 2 additions & 2 deletions src/MenuIcon.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "MenuIcon.hpp"
#include "MenuGameLayer.hpp"
#include "MenuLayer.hpp"
#include "utils/random.hpp"

MenuIcon* MenuIcon::create(MenuIconType type) {
Expand Down Expand Up @@ -69,7 +69,7 @@ cocos2d::CCPoint MenuIcon::getWorldPos() {
cocos2d::CCPoint worldPos = convertToWorldSpace(getPosition());

// convert to node space relative to swipeLayer
auto swipeLayer = static_cast<HookedMenuGameLayer*>(MenuLayer::get()->m_menuGameLayer)->m_fields->ninjaSwipeLayer;
auto swipeLayer = static_cast<HookedMenuLayer*>(MenuLayer::get())->m_fields->ninjaSwipeLayer;

return swipeLayer->convertToNodeSpace(worldPos);
}
Expand Down
59 changes: 51 additions & 8 deletions src/MenuLayer.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<std::string, 5> 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<cocos2d::CCNode*>(menu->getChildren())) {
for (auto& innerChild : geode::cocos::CCArrayExt<cocos2d::CCNode*>(child->getChildren())) {
auto castInnerChild = geode::cast::typeinfo_cast<cocos2d::CCNodeRGBA*>(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<HookedMenuGameLayer*>(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;
}
Expand All @@ -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<CCNode*>(getChildren())) {
if (child == m_menuGameLayer) continue;
if (child == m_menuGameLayer || child == m_fields->ninjaSwipeLayer) continue;

// get side + move dist
cocos2d::CCPoint movement;
Expand Down
4 changes: 4 additions & 0 deletions src/MenuLayer.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#pragma once
#include <Geode/Geode.hpp>
#include <Geode/modify/MenuLayer.hpp>
#include "NinjaSwipeLayer.hpp"

class $modify(HookedMenuLayer, MenuLayer) {
static void onModify(auto& self);

struct Fields {
std::map<cocos2d::CCNode*, cocos2d::CCPoint> movedNodeMovements;
NinjaSwipeLayer* ninjaSwipeLayer;
};

bool init();
Expand Down
1 change: 1 addition & 0 deletions src/NinjaSwipeLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>("font");
Expand Down

0 comments on commit ca664b7

Please sign in to comment.