Skip to content

Commit

Permalink
log stuff + other stuff (v1.2.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined06855 committed Dec 26, 2024
1 parent 072deff commit 6be4ca7
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 24 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

# add_definitions( -DDEBUG )
# add_definitions( -DDEBUG_DRAW_NODE )

project(IconNinja VERSION 1.0.0)

Expand Down
2 changes: 1 addition & 1 deletion TODO.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
- Customisable swords (based on player colours, perhaps)
- leaderboards???????????
- screen shake + window shake if in windowed
- window shake if in windowed
2 changes: 1 addition & 1 deletion about.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Planned Features:
- Leaderboards
Suggest features and report bugs at the github link in the bottom left!

This mod now has Known Players compatibility! Install the mod to be able to slice up your favourite GD players!
This mod has Known Players compatibility! Install the mod to be able to slice up your favourite GD players!

---

Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Icon Ninja Changelog
## v1.2.2
- Added option to disable logging
- (Internal) Renamed debug flag to `-DDEBUG_DRAW_NODE` to prevent conflicts that may have been happening
## v1.2.1
- Made robots and spiders not animate while being flung
- Made swing fire show all fires instead of the two by default
Expand Down
11 changes: 9 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"geode": "4.0.1",
"geode": "4.1.0",
"gd": {
"win": "2.2074",
"android": "2.2074"
},

"id": "undefined0.icon_ninja",
"name": "Icon Ninja",
"version": "v1.2.1",
"version": "v1.2.2",
"developer": "undefined0",
"description": "Makes killing icons like Fruit Ninja!",
"tags": [ "joke", "offline", "modtober24" ],
Expand Down Expand Up @@ -47,6 +47,7 @@
},
"particles": {
"name": "Enable bomb particles",
"description": "Can be buggy at times, so has been disabled by default. Made by flingus!",
"type": "bool",
"default": false
},
Expand Down Expand Up @@ -74,6 +75,12 @@
"arrows": true,
"input": true
}
},
"enable-log": {
"name": "Enable logging",
"description": "Enables logging to help debugging the mod.",
"type": "bool",
"default": false
}
}
}
3 changes: 2 additions & 1 deletion src/CCAnimatedSprite.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "CCAnimatedSprite.hpp"
#include "utils/log.hpp"

void HookedCCAnimatedSprite::runAnimation(gd::string animID) {
std::string replacement = getReplacementAnimID(animID);
geode::log::info("convert anim {} -> {}", animID, replacement);
ninja::log::info("convert anim {} -> {}", animID, replacement);
CCAnimatedSprite::runAnimation(replacement);
}

Expand Down
27 changes: 14 additions & 13 deletions src/NinjaSwipeLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "NinjaSwipeLayer.hpp"
#include "MenuLayer.hpp"
#include "utils/random.hpp"
#include "utils/log.hpp"
#include "FlashbangLayer.hpp"

NinjaSwipeLayer* NinjaSwipeLayer::create() {
Expand Down Expand Up @@ -74,7 +75,7 @@ bool NinjaSwipeLayer::init() {

scheduleUpdate();

#ifdef DEBUG
#ifdef DEBUG_DRAW_NODE
m_debugNode = cocos2d::CCDrawNode::create();
m_debugNode->init();
m_debugNode->setZOrder(999999);
Expand Down Expand Up @@ -114,14 +115,14 @@ void NinjaSwipeLayer::checkSwipeIntersection(const cocos2d::CCPoint& from, const
if (from.getDistanceSq(to) < .5f) return;
if (m_isBombCurrentlyExploding) return;

#ifdef DEBUG
#ifdef DEBUG_DRAW_NODE
m_debugLastCheckFrom = from;
m_debugLastCheckTo = to;
#endif

for (auto player : m_players) {
if (!player || player->retainCount() == 0) {
geode::log::warn("player is nullptr!");
ninja::log::warn("player is nullptr!");
continue;
}

Expand Down Expand Up @@ -171,7 +172,7 @@ bool NinjaSwipeLayer::lineIntersectsCircle(const cocos2d::CCPoint& circleCenter,

void NinjaSwipeLayer::killPlayer(MenuIcon* player) {
if (player->m_type == MenuIconType::Bomb) {
geode::log::info("bomb!");
ninja::log::info("bomb!");
m_isBombCurrentlyExploding = true;
player->m_isBombExploding = true;
if (geode::Mod::get()->getSettingValue<bool>("particles")) player->m_particles->removeFromParent();
Expand Down Expand Up @@ -242,7 +243,7 @@ void NinjaSwipeLayer::killPlayer(MenuIcon* player) {
// auto skibidi = cocos2d::CCNode::create();
// skibidi->release();
// geode::Loader::get()->queueInMainThread([=]{
// geode::log::info("{}", skibidi);
// ninja::log::info("{}", skibidi);
// });
})
)
Expand Down Expand Up @@ -294,7 +295,7 @@ void NinjaSwipeLayer::update(float dt) {

auto dir = cocos2d::CCDirector::sharedDirector();
if (player->getPositionY() <= -50.f || player->getPositionX() <= -50.f || player->getPositionX() >= dir->getScreenRight() + 50.f) {
geode::log::info("icon fell offscreen :broken_heart:");
ninja::log::info("icon fell offscreen :broken_heart:");
playersToRemove.push_back(player);

// offscreen, below starting point, remove and reset combo
Expand All @@ -309,7 +310,7 @@ void NinjaSwipeLayer::update(float dt) {
}

if (m_players.size() == 0 && !m_waitingForNextSpawn && !m_isSendingOutSpree && !m_isBombCurrentlyExploding) {
geode::log::info("ran out! wait 1.5 secs, ill spawn some more");
ninja::log::info("ran out! wait 1.5 secs, ill spawn some more");
// ran out!
auto action = cocos2d::CCSequence::createWithTwoActions(
cocos2d::CCDelayTime::create(1.5f),
Expand All @@ -322,7 +323,7 @@ void NinjaSwipeLayer::update(float dt) {
m_waitingForNextSpawn = true;
}

#ifdef DEBUG
#ifdef DEBUG_DRAW_NODE
m_debugNode->clear();
for (auto player : m_players) {
float radius = player->getRadius();
Expand Down Expand Up @@ -378,7 +379,7 @@ void NinjaSwipeLayer::startShake() {
// I shake it off, I shake it off (hoo-hoo-hoo)

m_shakeTick = m_maxShakeTick;
geode::log::info("shakey bakey");
ninja::log::info("shakey bakey");
}

void NinjaSwipeLayer::removePlayer(MenuIcon* player) {
Expand All @@ -392,7 +393,7 @@ void NinjaSwipeLayer::enterGameplay() {
if (m_state == State::Gameplay) return;

m_state = State::Gameplay;
geode::log::info("NINJA TIME BABY");
ninja::log::info("NINJA TIME BABY");
auto menuLayer = static_cast<HookedMenuLayer*>(MenuLayer::get());
menuLayer->runEnterGameplayAnimations();

Expand All @@ -410,7 +411,7 @@ void NinjaSwipeLayer::exitGameplay(cocos2d::CCObject* sender) {
if (m_state == State::Default) return;

m_state = State::Default;
geode::log::info("no more ninja time :broken_heart:");
ninja::log::info("no more ninja time :broken_heart:");
auto menuLayer = static_cast<HookedMenuLayer*>(MenuLayer::get());
menuLayer->runExitGameplayAnimations();

Expand Down Expand Up @@ -471,7 +472,7 @@ void NinjaSwipeLayer::spawnPlayers() {
type = ninja::random::spawnTypeDistribution(ninja::random::gen);
} while (type == m_lastSpawnType);

geode::log::info("spawning players (type: {})", type);
ninja::log::info("spawning players (type: {})", type);
m_lastSpawnType = type;
switch(type) {
case 0: {
Expand Down Expand Up @@ -550,5 +551,5 @@ void NinjaSwipeLayer::spawnPlayers() {
}

$on_mod(Loaded) {
geode::log::info("hi spaghettdev");
ninja::log::info("hi spaghettdev");
}
2 changes: 1 addition & 1 deletion src/NinjaSwipeLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NinjaSwipeLayer : public cocos2d::CCLayer {
static NinjaSwipeLayer* create();
bool init() override;

#ifdef DEBUG
#ifdef DEBUG_DRAW_NODE
cocos2d::CCDrawNode* m_debugNode;
cocos2d::CCPoint m_debugLastCheckFrom = {0, 0};
cocos2d::CCPoint m_debugLastCheckTo = {0, 0};
Expand Down
29 changes: 29 additions & 0 deletions src/utils/log.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once
#include <Geode/Geode.hpp>

// lazy
#define LOG_ENABLE_CHECK geode::Mod::get()->getSettingValue<bool>("enable-log")

namespace ninja::log {

template <typename... Args>
inline void debug(geode::log::impl::FmtStr<Args...> str, Args&&... args) {
if (LOG_ENABLE_CHECK) geode::log::debug(str, std::forward<Args>(args)...);
}

template <typename... Args>
inline void info(geode::log::impl::FmtStr<Args...> str, Args&&... args) {
if (LOG_ENABLE_CHECK) geode::log::info(str, std::forward<Args>(args)...);
}

template <typename... Args>
inline void warn(geode::log::impl::FmtStr<Args...> str, Args&&... args) {
if (LOG_ENABLE_CHECK) geode::log::warn(str, std::forward<Args>(args)...);
}

template <typename... Args>
inline void error(geode::log::impl::FmtStr<Args...> str, Args&&... args) {
if (LOG_ENABLE_CHECK) geode::log::error(str, std::forward<Args>(args)...);
}

}
3 changes: 2 additions & 1 deletion src/utils/random.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <Geode/Geode.hpp>
#include "random.hpp"
#include "log.hpp"
#include "../external/KnownPlayers.h"

namespace ninja {
Expand Down Expand Up @@ -29,7 +30,7 @@ PlayerObject* createRandomPlayerObject() {
event.post();

if (!event.done) {
geode::log::warn("Known Players did not return event! Switching to fallback...");
ninja::log::warn("Known Players did not return event! Switching to fallback...");
randomisePlayerObject(ret);
}
} else {
Expand Down
4 changes: 1 addition & 3 deletions src/utils/random.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once
#include <random>

namespace ninja {
namespace random {
namespace ninja::random {

extern std::mt19937 gen;
extern std::uniform_real_distribution<float> startXDistribution;
Expand All @@ -21,4 +20,3 @@ PlayerObject* createRandomPlayerObject();
void randomisePlayerObject(PlayerObject* player);

}
}

0 comments on commit 6be4ca7

Please sign in to comment.