Skip to content

Commit

Permalink
We're going to try this out
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimjasmine00 committed Jan 28, 2025
1 parent 34b78eb commit 789913d
Show file tree
Hide file tree
Showing 24 changed files with 118 additions and 68 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
3 changes: 3 additions & 0 deletions include/MoreIcons.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#pragma once
#include <Geode/Enums.hpp>
#include <Geode/GeneratedPredeclare.hpp>
#include <Geode/loader/Dispatch.hpp>

class MoreIcons {
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
41 changes: 41 additions & 0 deletions src/MoreIcons.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "MoreIcons.hpp"
#include <Geode/binding/SimplePlayer.hpp>
#include <Geode/loader/Dispatch.hpp>
#include <Geode/ui/Popup.hpp>

using namespace geode::prelude;

Expand Down Expand Up @@ -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<SimplePlayer>(node, [](auto) { return true; });
}

void MoreIcons::showInfoPopup(bool folderButton) {
geode::createQuickPopup(
"More Icons",
fmt::format(std::locale(""),
"<cg>Icons</c>: {:L}\n"
"<cp>Ships</c>: {:L}\n"
"<cr>Balls</c>: {:L}\n"
"<co>UFOs</c>: {:L}\n"
"<cj>Waves</c>: {:L}\n"
"Robots: {:L}\n"
"<ca>Spiders</c>: {:L}\n"
"<cy>Swings</c>: {:L}\n"
"<cd>Jetpacks</c>: {:L}\n"
"<cb>Trails</c>: {: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());
}
);
}
41 changes: 3 additions & 38 deletions src/MoreIcons.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <BS_thread_pool.hpp>
#include "api/MoreIconsAPI.hpp"
#include <BS_thread_pool.hpp>

struct TexturePack {
std::string name;
Expand Down Expand Up @@ -167,42 +167,7 @@ class MoreIcons {
return name;
}

static SimplePlayer* findPlayer(cocos2d::CCNode* node) {
if (!node) return nullptr;
return geode::cocos::findFirstChildRecursive<SimplePlayer>(node, [](auto) { return true; });
}
static SimplePlayer* findPlayer(cocos2d::CCNode* node);

static void showInfoPopup(bool folderButton = false) {
geode::createQuickPopup(
"More Icons",
fmt::format(std::locale(""),
"<cg>Icons</c>: {:L}\n"
"<cp>Ships</c>: {:L}\n"
"<cr>Balls</c>: {:L}\n"
"<co>UFOs</c>: {:L}\n"
"<cj>Waves</c>: {:L}\n"
"Robots: {:L}\n"
"<ca>Spiders</c>: {:L}\n"
"<cy>Swings</c>: {:L}\n"
"<cd>Jetpacks</c>: {:L}\n"
"<cb>Trails</c>: {: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);
};
23 changes: 23 additions & 0 deletions src/api/MoreIconsAPI.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
#include "MoreIconsAPI.hpp"
#include <Geode/binding/CCPartAnimSprite.hpp>
#include <Geode/binding/CCSpritePart.hpp>
#include <Geode/binding/GJSpiderSprite.hpp>
#include <Geode/binding/SimplePlayer.hpp>
#include <Geode/utils/cocos.hpp>

using namespace geode::prelude;

void DummyNode::setBlendFunc(ccBlendFunc blendFunc) {
CCSpriteBatchNode::setBlendFunc(blendFunc);

for (auto child : CCArrayExt<CCNode*>(getChildren())) {
if (typeinfo_cast<CCBlendProtocol*>(child)) recursiveBlend(child, blendFunc);
}
}

void DummyNode::recursiveBlend(CCNode* node, ccBlendFunc blendFunc) {
if (!node) return;

if (auto blendNode = typeinfo_cast<CCBlendProtocol*>(node)) blendNode->setBlendFunc(blendFunc);

for (auto child : CCArrayExt<CCNode*>(node->getChildren())) {
if (typeinfo_cast<CCBlendProtocol*>(child)) recursiveBlend(child, blendFunc);
}
}

std::vector<std::string>& MoreIconsAPI::vectorForType(IconType type) {
switch (type) {
case IconType::Cube: return ICONS;
Expand Down
24 changes: 8 additions & 16 deletions src/api/MoreIconsAPI.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#include <cocos2d.h>
#include <Geode/binding/GJRobotSprite.hpp>
#include <Geode/binding/PlayerObject.hpp>
#include <Geode/loader/Mod.hpp>
#include <Geode/utils/casts.hpp>

// https://github.com/Alphalaneous/FineOutline/blob/1.0.8/src/CCSpriteBatchNode.h#L24 probably
class DummyNode : public cocos2d::CCSpriteBatchNode {
public:
Expand Down Expand Up @@ -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<CCNode*>(getChildren())) {
if (geode::cast::typeinfo_cast<CCBlendProtocol*>(child)) recursiveBlend(child, blendFunc);
}
}

void recursiveBlend(CCNode* node, cocos2d::ccBlendFunc blendFunc) {
if (!node) return;

if (auto blendNode = geode::cast::typeinfo_cast<CCBlendProtocol*>(node)) blendNode->setBlendFunc(blendFunc);

for (auto child : geode::cocos::CCArrayExt<CCNode*>(node->getChildren())) {
if (geode::cast::typeinfo_cast<CCBlendProtocol*>(child)) recursiveBlend(child, blendFunc);
}
}
void recursiveBlend(CCNode* node, cocos2d::ccBlendFunc blendFunc);
};

class MoreIconsAPI {
Expand Down
1 change: 1 addition & 0 deletions src/classes/ButtonHooker.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ButtonHooker.hpp"
#include <Geode/loader/Mod.hpp>

using namespace geode::prelude;

Expand Down
2 changes: 2 additions & 0 deletions src/classes/ButtonHooker.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <cocos2d.h>

#define CALL_BUTTON_ORIGINAL(button) \
if (auto hooker = static_cast<ButtonHooker*>(static_cast<CCNode*>(button)->getUserObject("hooker"_spr))) \
(hooker->m_listener->*hooker->m_selector)(button)
Expand Down
3 changes: 3 additions & 0 deletions src/classes/LogLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "LogLayer.hpp"
#include <Geode/binding/MultilineBitmapFont.hpp>
#include <Geode/binding/TextArea.hpp>
#include <Geode/ui/ScrollLayer.hpp>

using namespace geode::prelude;

Expand Down
1 change: 1 addition & 0 deletions src/classes/LogLayer.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "../MoreIcons.hpp"
#include <Geode/ui/Popup.hpp>

class LogLayer : public geode::Popup<> {
protected:
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/AppDelegate.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "../MoreIcons.hpp"
#include <Geode/modify/AppDelegate.hpp>

using namespace geode::prelude;

#include <Geode/modify/AppDelegate.hpp>
class $modify(MIAppDelegate, AppDelegate) {
static void onModify(auto& self) {
(void)self.setHookPriority("AppDelegate::trySaveGame", -1);
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/CharacterColorPage.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "../MoreIcons.hpp"
#include <Geode/binding/SimplePlayer.hpp>
#include <Geode/modify/CharacterColorPage.hpp>

using namespace geode::prelude;

#include <Geode/modify/CharacterColorPage.hpp>
class $modify(MICharacterColorPage, CharacterColorPage) {
static void onModify(auto& self) {
(void)self.setHookPriority("CharacterColorPage::init", -1);
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/GJBaseGameLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "../MoreIcons.hpp"
#include <Geode/binding/SimplePlayer.hpp>
#include <Geode/modify/GJBaseGameLayer.hpp>

using namespace geode::prelude;

#include <Geode/modify/GJBaseGameLayer.hpp>
class $modify(MIBaseGameLayer, GJBaseGameLayer) {
void playExitDualEffect(PlayerObject* object) {
GJBaseGameLayer::playExitDualEffect(object);
Expand Down
11 changes: 10 additions & 1 deletion src/hooks/GJGarageLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#include "../classes/ButtonHooker.hpp"
#include "../classes/LogLayer.hpp"
#include <Geode/binding/BoomScrollLayer.hpp>
#include <Geode/binding/GameManager.hpp>
#include <Geode/binding/GJItemIcon.hpp>
#include <Geode/binding/GJSpiderSprite.hpp>
#include <Geode/binding/ItemInfoPopup.hpp>
#include <Geode/binding/ListButtonBar.hpp>
#include <Geode/binding/SimplePlayer.hpp>
#include <Geode/binding/TextArea.hpp>
#include <Geode/modify/GJGarageLayer.hpp>
#include <Geode/ui/BasedButtonSprite.hpp>

using namespace geode::prelude;

#include <Geode/modify/GJGarageLayer.hpp>
class $modify(MIGarageLayer, GJGarageLayer) {
struct Fields {
ListButtonBar* m_pageBar;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/GJRobotSprite.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "../api/MoreIconsAPI.hpp"
#include <Geode/modify/GJRobotSprite.hpp>

using namespace geode::prelude;

#include <Geode/modify/GJRobotSprite.hpp>
class $modify(MIRobotSprite, GJRobotSprite) {
void updateFrame(int frame) {
GJRobotSprite::updateFrame(frame);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/GameManager.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "../MoreIcons.hpp"
#include <Geode/modify/GameManager.hpp>

using namespace geode::prelude;

#include <Geode/modify/GameManager.hpp>
class $modify(MIGameManager, GameManager) {
void reloadAllStep2() {
GameManager::reloadAllStep2();
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/LoadingLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "../MoreIcons.hpp"
#include <Geode/modify/LoadingLayer.hpp>

using namespace geode::prelude;

#include <Geode/modify/LoadingLayer.hpp>
class $modify(MILoadingLayer, LoadingLayer) {
struct Fields {
int m_iconLoadStep;
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/MenuGameLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "../api/MoreIconsAPI.hpp"
#include <Geode/binding/GameManager.hpp>
#include <Geode/modify/MenuGameLayer.hpp>

using namespace geode::prelude;

#include <Geode/modify/MenuGameLayer.hpp>
class $modify(MIMenuGameLayer, MenuGameLayer) {
void resetPlayer() {
MenuGameLayer::resetPlayer();
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/MenuLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "../MoreIcons.hpp"
#include <Geode/binding/GameManager.hpp>
#include <Geode/binding/SimplePlayer.hpp>
#include <Geode/modify/MenuLayer.hpp>

using namespace geode::prelude;

#include <Geode/modify/MenuLayer.hpp>
class $modify(MIMenuLayer, MenuLayer) {
static void onModify(auto& self) {
if (auto initHookRes = self.getHook("MenuLayer::init")) {
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/PlayerObject.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "../MoreIcons.hpp"
#include <Geode/binding/GJBaseGameLayer.hpp>
#include <Geode/modify/PlayerObject.hpp>

using namespace geode::prelude;

#include <Geode/modify/PlayerObject.hpp>
class $modify(MIPlayerObject, PlayerObject) {
static void onModify(auto& self) {
(void)self.setHookPriority("PlayerObject::setupStreak", -1);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/ProfilePage.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "../MoreIcons.hpp"
#include "../classes/ButtonHooker.hpp"
#include <Geode/modify/ProfilePage.hpp>

using namespace geode::prelude;

#include <Geode/modify/ProfilePage.hpp>
class $modify(MIProfilePage, ProfilePage) {
static void onModify(auto& self) {
(void)self.setHookPriority("ProfilePage::loadPageFromUserInfo", -1);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/SimplePlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "../api/MoreIconsAPI.hpp"
#include <Geode/modify/SimplePlayer.hpp>

using namespace geode::prelude;

#include <Geode/modify/SimplePlayer.hpp>
class $modify(MISimplePlayer, SimplePlayer) {
void updatePlayerFrame(int frame, IconType type) {
SimplePlayer::updatePlayerFrame(frame, type);
Expand Down

0 comments on commit 789913d

Please sign in to comment.