From 789913d7a4015cdebd125b7818881ffcc209b808 Mon Sep 17 00:00:00 2001 From: hiimjustin000 <52604018+hiimjustin000@users.noreply.github.com> Date: Tue, 28 Jan 2025 08:23:26 -0500 Subject: [PATCH] We're going to try this out --- CMakeLists.txt | 3 ++- changelog.md | 3 +++ include/MoreIcons.hpp | 3 +++ mod.json | 2 +- src/MoreIcons.cpp | 41 ++++++++++++++++++++++++++++++++ src/MoreIcons.hpp | 41 +++----------------------------- src/api/MoreIconsAPI.cpp | 23 ++++++++++++++++++ src/api/MoreIconsAPI.hpp | 24 +++++++------------ src/classes/ButtonHooker.cpp | 1 + src/classes/ButtonHooker.hpp | 2 ++ src/classes/LogLayer.cpp | 3 +++ src/classes/LogLayer.hpp | 1 + src/hooks/AppDelegate.cpp | 2 +- src/hooks/CharacterColorPage.cpp | 3 ++- src/hooks/GJBaseGameLayer.cpp | 3 ++- src/hooks/GJGarageLayer.cpp | 11 ++++++++- src/hooks/GJRobotSprite.cpp | 2 +- src/hooks/GameManager.cpp | 2 +- src/hooks/LoadingLayer.cpp | 2 +- src/hooks/MenuGameLayer.cpp | 3 ++- src/hooks/MenuLayer.cpp | 4 +++- src/hooks/PlayerObject.cpp | 3 ++- src/hooks/ProfilePage.cpp | 2 +- src/hooks/SimplePlayer.cpp | 2 +- 24 files changed, 118 insertions(+), 68 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc5e38a..5db3440 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,9 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64") set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(GEODE_DISABLE_PRECOMPILED_HEADERS ON) -project(MoreIcons VERSION 1.6.0) +project(MoreIcons VERSION 1.6.1) add_library(${PROJECT_NAME} SHARED src/api/MoreIconsAPI.cpp diff --git a/changelog.md b/changelog.md index e8695cb..0e4ab30 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # More Icons Changelog +## v1.6.1 (2025-01-28) +- Fixed header inclusion in the API + ## v1.6.0 (2025-01-23) - Added a header-only API for other mods to use - Fixed a bug where the player's icon would not change properly when exiting dual mode (Reported by [Cocoiscool748](https://github.com/Cocoiscool748)) diff --git a/include/MoreIcons.hpp b/include/MoreIcons.hpp index f23c1f6..0014b60 100644 --- a/include/MoreIcons.hpp +++ b/include/MoreIcons.hpp @@ -1,3 +1,6 @@ +#pragma once +#include +#include #include class MoreIcons { diff --git a/mod.json b/mod.json index 48bbaf5..9ec2b0e 100644 --- a/mod.json +++ b/mod.json @@ -5,7 +5,7 @@ "win": "2.2074", "mac": "2.2074" }, - "version": "v1.6.0", + "version": "v1.6.1", "id": "hiimjustin000.more_icons", "name": "More Icons", "developer": "hiimjasmine00", diff --git a/src/MoreIcons.cpp b/src/MoreIcons.cpp index 24d7f49..e5aebae 100644 --- a/src/MoreIcons.cpp +++ b/src/MoreIcons.cpp @@ -1,5 +1,7 @@ #include "MoreIcons.hpp" +#include #include +#include using namespace geode::prelude; @@ -561,3 +563,42 @@ void MoreIcons::loadTrail(const std::filesystem::path& path, const TexturePack& else image->release(); }); } + +SimplePlayer* MoreIcons::findPlayer(cocos2d::CCNode* node) { + if (!node) return nullptr; + return geode::cocos::findFirstChildRecursive(node, [](auto) { return true; }); +} + +void MoreIcons::showInfoPopup(bool folderButton) { + geode::createQuickPopup( + "More Icons", + fmt::format(std::locale(""), + "Icons: {:L}\n" + "Ships: {:L}\n" + "Balls: {:L}\n" + "UFOs: {:L}\n" + "Waves: {:L}\n" + "Robots: {:L}\n" + "Spiders: {:L}\n" + "Swings: {:L}\n" + "Jetpacks: {:L}\n" + "Trails: {:L}", + MoreIconsAPI::ICONS.size(), + MoreIconsAPI::SHIPS.size(), + MoreIconsAPI::BALLS.size(), + MoreIconsAPI::UFOS.size(), + MoreIconsAPI::WAVES.size(), + MoreIconsAPI::ROBOTS.size(), + MoreIconsAPI::SPIDERS.size(), + MoreIconsAPI::SWINGS.size(), + MoreIconsAPI::JETPACKS.size(), + MoreIconsAPI::TRAILS.size() + ), + "OK", + folderButton ? "Folder" : nullptr, + 300.0f, + [folderButton](auto, bool btn2) { + if (folderButton && btn2) geode::utils::file::openFolder(geode::Mod::get()->getConfigDir()); + } + ); +} diff --git a/src/MoreIcons.hpp b/src/MoreIcons.hpp index 9bc7fd3..2d0fc66 100644 --- a/src/MoreIcons.hpp +++ b/src/MoreIcons.hpp @@ -1,5 +1,5 @@ -#include #include "api/MoreIconsAPI.hpp" +#include struct TexturePack { std::string name; @@ -167,42 +167,7 @@ class MoreIcons { return name; } - static SimplePlayer* findPlayer(cocos2d::CCNode* node) { - if (!node) return nullptr; - return geode::cocos::findFirstChildRecursive(node, [](auto) { return true; }); - } + static SimplePlayer* findPlayer(cocos2d::CCNode* node); - static void showInfoPopup(bool folderButton = false) { - geode::createQuickPopup( - "More Icons", - fmt::format(std::locale(""), - "Icons: {:L}\n" - "Ships: {:L}\n" - "Balls: {:L}\n" - "UFOs: {:L}\n" - "Waves: {:L}\n" - "Robots: {:L}\n" - "Spiders: {:L}\n" - "Swings: {:L}\n" - "Jetpacks: {:L}\n" - "Trails: {:L}", - MoreIconsAPI::ICONS.size(), - MoreIconsAPI::SHIPS.size(), - MoreIconsAPI::BALLS.size(), - MoreIconsAPI::UFOS.size(), - MoreIconsAPI::WAVES.size(), - MoreIconsAPI::ROBOTS.size(), - MoreIconsAPI::SPIDERS.size(), - MoreIconsAPI::SWINGS.size(), - MoreIconsAPI::JETPACKS.size(), - MoreIconsAPI::TRAILS.size() - ), - "OK", - folderButton ? "Folder" : nullptr, - 300.0f, - [folderButton](auto, bool btn2) { - if (folderButton && btn2) geode::utils::file::openFolder(geode::Mod::get()->getConfigDir()); - } - ); - } + static void showInfoPopup(bool folderButton = false); }; diff --git a/src/api/MoreIconsAPI.cpp b/src/api/MoreIconsAPI.cpp index 0a82f86..315728c 100644 --- a/src/api/MoreIconsAPI.cpp +++ b/src/api/MoreIconsAPI.cpp @@ -1,7 +1,30 @@ #include "MoreIconsAPI.hpp" +#include +#include +#include +#include +#include using namespace geode::prelude; +void DummyNode::setBlendFunc(ccBlendFunc blendFunc) { + CCSpriteBatchNode::setBlendFunc(blendFunc); + + for (auto child : CCArrayExt(getChildren())) { + if (typeinfo_cast(child)) recursiveBlend(child, blendFunc); + } +} + +void DummyNode::recursiveBlend(CCNode* node, ccBlendFunc blendFunc) { + if (!node) return; + + if (auto blendNode = typeinfo_cast(node)) blendNode->setBlendFunc(blendFunc); + + for (auto child : CCArrayExt(node->getChildren())) { + if (typeinfo_cast(child)) recursiveBlend(child, blendFunc); + } +} + std::vector& MoreIconsAPI::vectorForType(IconType type) { switch (type) { case IconType::Cube: return ICONS; diff --git a/src/api/MoreIconsAPI.hpp b/src/api/MoreIconsAPI.hpp index b4f11b8..3226eb6 100644 --- a/src/api/MoreIconsAPI.hpp +++ b/src/api/MoreIconsAPI.hpp @@ -1,3 +1,9 @@ +#include +#include +#include +#include +#include + // https://github.com/Alphalaneous/FineOutline/blob/1.0.8/src/CCSpriteBatchNode.h#L24 probably class DummyNode : public cocos2d::CCSpriteBatchNode { public: @@ -38,23 +44,9 @@ class DummyNode : public cocos2d::CCSpriteBatchNode { CCNode::visit(); } - void setBlendFunc(cocos2d::ccBlendFunc blendFunc) override { - CCSpriteBatchNode::setBlendFunc(blendFunc); + void setBlendFunc(cocos2d::ccBlendFunc blendFunc) override; - for (auto child : geode::cocos::CCArrayExt(getChildren())) { - if (geode::cast::typeinfo_cast(child)) recursiveBlend(child, blendFunc); - } - } - - void recursiveBlend(CCNode* node, cocos2d::ccBlendFunc blendFunc) { - if (!node) return; - - if (auto blendNode = geode::cast::typeinfo_cast(node)) blendNode->setBlendFunc(blendFunc); - - for (auto child : geode::cocos::CCArrayExt(node->getChildren())) { - if (geode::cast::typeinfo_cast(child)) recursiveBlend(child, blendFunc); - } - } + void recursiveBlend(CCNode* node, cocos2d::ccBlendFunc blendFunc); }; class MoreIconsAPI { diff --git a/src/classes/ButtonHooker.cpp b/src/classes/ButtonHooker.cpp index dc3c4c0..1bab8de 100644 --- a/src/classes/ButtonHooker.cpp +++ b/src/classes/ButtonHooker.cpp @@ -1,4 +1,5 @@ #include "ButtonHooker.hpp" +#include using namespace geode::prelude; diff --git a/src/classes/ButtonHooker.hpp b/src/classes/ButtonHooker.hpp index 046ed78..a066cee 100644 --- a/src/classes/ButtonHooker.hpp +++ b/src/classes/ButtonHooker.hpp @@ -1,3 +1,5 @@ +#include + #define CALL_BUTTON_ORIGINAL(button) \ if (auto hooker = static_cast(static_cast(button)->getUserObject("hooker"_spr))) \ (hooker->m_listener->*hooker->m_selector)(button) diff --git a/src/classes/LogLayer.cpp b/src/classes/LogLayer.cpp index 602b9bf..a1b3561 100644 --- a/src/classes/LogLayer.cpp +++ b/src/classes/LogLayer.cpp @@ -1,4 +1,7 @@ #include "LogLayer.hpp" +#include +#include +#include using namespace geode::prelude; diff --git a/src/classes/LogLayer.hpp b/src/classes/LogLayer.hpp index e5a715e..39a96f1 100644 --- a/src/classes/LogLayer.hpp +++ b/src/classes/LogLayer.hpp @@ -1,4 +1,5 @@ #include "../MoreIcons.hpp" +#include class LogLayer : public geode::Popup<> { protected: diff --git a/src/hooks/AppDelegate.cpp b/src/hooks/AppDelegate.cpp index b8c07ff..15ece37 100644 --- a/src/hooks/AppDelegate.cpp +++ b/src/hooks/AppDelegate.cpp @@ -1,8 +1,8 @@ #include "../MoreIcons.hpp" +#include using namespace geode::prelude; -#include class $modify(MIAppDelegate, AppDelegate) { static void onModify(auto& self) { (void)self.setHookPriority("AppDelegate::trySaveGame", -1); diff --git a/src/hooks/CharacterColorPage.cpp b/src/hooks/CharacterColorPage.cpp index 16b5f43..d6d70a6 100644 --- a/src/hooks/CharacterColorPage.cpp +++ b/src/hooks/CharacterColorPage.cpp @@ -1,8 +1,9 @@ #include "../MoreIcons.hpp" +#include +#include using namespace geode::prelude; -#include class $modify(MICharacterColorPage, CharacterColorPage) { static void onModify(auto& self) { (void)self.setHookPriority("CharacterColorPage::init", -1); diff --git a/src/hooks/GJBaseGameLayer.cpp b/src/hooks/GJBaseGameLayer.cpp index c978814..40549b4 100644 --- a/src/hooks/GJBaseGameLayer.cpp +++ b/src/hooks/GJBaseGameLayer.cpp @@ -1,8 +1,9 @@ #include "../MoreIcons.hpp" +#include +#include using namespace geode::prelude; -#include class $modify(MIBaseGameLayer, GJBaseGameLayer) { void playExitDualEffect(PlayerObject* object) { GJBaseGameLayer::playExitDualEffect(object); diff --git a/src/hooks/GJGarageLayer.cpp b/src/hooks/GJGarageLayer.cpp index 9baa889..accb266 100644 --- a/src/hooks/GJGarageLayer.cpp +++ b/src/hooks/GJGarageLayer.cpp @@ -1,9 +1,18 @@ #include "../classes/ButtonHooker.hpp" #include "../classes/LogLayer.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace geode::prelude; -#include class $modify(MIGarageLayer, GJGarageLayer) { struct Fields { ListButtonBar* m_pageBar; diff --git a/src/hooks/GJRobotSprite.cpp b/src/hooks/GJRobotSprite.cpp index b80eb3f..df76ef7 100644 --- a/src/hooks/GJRobotSprite.cpp +++ b/src/hooks/GJRobotSprite.cpp @@ -1,8 +1,8 @@ #include "../api/MoreIconsAPI.hpp" +#include using namespace geode::prelude; -#include class $modify(MIRobotSprite, GJRobotSprite) { void updateFrame(int frame) { GJRobotSprite::updateFrame(frame); diff --git a/src/hooks/GameManager.cpp b/src/hooks/GameManager.cpp index d60d193..9af413a 100644 --- a/src/hooks/GameManager.cpp +++ b/src/hooks/GameManager.cpp @@ -1,8 +1,8 @@ #include "../MoreIcons.hpp" +#include using namespace geode::prelude; -#include class $modify(MIGameManager, GameManager) { void reloadAllStep2() { GameManager::reloadAllStep2(); diff --git a/src/hooks/LoadingLayer.cpp b/src/hooks/LoadingLayer.cpp index 46d083d..300646b 100644 --- a/src/hooks/LoadingLayer.cpp +++ b/src/hooks/LoadingLayer.cpp @@ -1,8 +1,8 @@ #include "../MoreIcons.hpp" +#include using namespace geode::prelude; -#include class $modify(MILoadingLayer, LoadingLayer) { struct Fields { int m_iconLoadStep; diff --git a/src/hooks/MenuGameLayer.cpp b/src/hooks/MenuGameLayer.cpp index 4fbac89..4d55e8a 100644 --- a/src/hooks/MenuGameLayer.cpp +++ b/src/hooks/MenuGameLayer.cpp @@ -1,8 +1,9 @@ #include "../api/MoreIconsAPI.hpp" +#include +#include using namespace geode::prelude; -#include class $modify(MIMenuGameLayer, MenuGameLayer) { void resetPlayer() { MenuGameLayer::resetPlayer(); diff --git a/src/hooks/MenuLayer.cpp b/src/hooks/MenuLayer.cpp index be56092..a4a1357 100644 --- a/src/hooks/MenuLayer.cpp +++ b/src/hooks/MenuLayer.cpp @@ -1,8 +1,10 @@ #include "../MoreIcons.hpp" +#include +#include +#include using namespace geode::prelude; -#include class $modify(MIMenuLayer, MenuLayer) { static void onModify(auto& self) { if (auto initHookRes = self.getHook("MenuLayer::init")) { diff --git a/src/hooks/PlayerObject.cpp b/src/hooks/PlayerObject.cpp index 36d6631..536737f 100644 --- a/src/hooks/PlayerObject.cpp +++ b/src/hooks/PlayerObject.cpp @@ -1,8 +1,9 @@ #include "../MoreIcons.hpp" +#include +#include using namespace geode::prelude; -#include class $modify(MIPlayerObject, PlayerObject) { static void onModify(auto& self) { (void)self.setHookPriority("PlayerObject::setupStreak", -1); diff --git a/src/hooks/ProfilePage.cpp b/src/hooks/ProfilePage.cpp index e2f5a83..42c11a4 100644 --- a/src/hooks/ProfilePage.cpp +++ b/src/hooks/ProfilePage.cpp @@ -1,9 +1,9 @@ #include "../MoreIcons.hpp" #include "../classes/ButtonHooker.hpp" +#include using namespace geode::prelude; -#include class $modify(MIProfilePage, ProfilePage) { static void onModify(auto& self) { (void)self.setHookPriority("ProfilePage::loadPageFromUserInfo", -1); diff --git a/src/hooks/SimplePlayer.cpp b/src/hooks/SimplePlayer.cpp index 01a145c..24b50c1 100644 --- a/src/hooks/SimplePlayer.cpp +++ b/src/hooks/SimplePlayer.cpp @@ -1,8 +1,8 @@ #include "../api/MoreIconsAPI.hpp" +#include using namespace geode::prelude; -#include class $modify(MISimplePlayer, SimplePlayer) { void updatePlayerFrame(int frame, IconType type) { SimplePlayer::updatePlayerFrame(frame, type);