Skip to content

Commit

Permalink
mmm hmm
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimjasmine00 committed Nov 2, 2024
1 parent ef33af3 commit 11376e5
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 59 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
with:
bindings: hiimjustin000/bindings
bindings-ref: ccdictionary
sdk: nightly
build-config: ${{ matrix.config.build-config || 'Release' }}
export-pdb: true
combine: true
Expand Down
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 "x86_64;arm64")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

project(MoreIcons VERSION 1.4.3)
project(MoreIcons VERSION 1.4.4)

add_library(${PROJECT_NAME} SHARED
src/api/MoreIconsAPI.cpp
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,21 @@ Here are some examples of how to support More Icons in your mod.
```cpp
// Get the player's icon (The parameter is the gamemode or the gamemode plus "-dual" if Separate Dual Icons is enabled)
Loader::get()->getLoadedMod("hiimjustin000.more_icons")->getSavedValue<std::string>("icon");

// Get the list of icons (The parameter is the gamemode plus the letter "s")
Loader::get()->getLoadedMod("hiimjustin000.more_icons")->getSavedValue<std::vector<std::string>>("icons");

// Change a SimplePlayer to a custom icon
DispatchEvent<SimplePlayer*, const std::string&, IconType>("hiimjustin000.more_icons/simple-player", simplePlayer, "my-icon", IconType::Icon).post();
DispatchEvent<SimplePlayer*, std::string, IconType>("hiimjustin000.more_icons/simple-player", simplePlayer, "my-icon", IconType::Cube).post();

// Change a GJRobotSprite to a custom icon
DispatchEvent<GJRobotSprite*, const std::string&>("hiimjustin000.more_icons/robot-sprite", robotSprite, "my-icon").post(); // Determines the icon type
DispatchEvent<GJRobotSprite*, const std::string&, IconType>("hiimjustin000.more_icons/robot-sprite", robotSprite, "my-icon", IconType::Robot).post();
DispatchEvent<GJRobotSprite*, std::string>("hiimjustin000.more_icons/robot-sprite", robotSprite, "my-icon").post(); // Determines the icon type

DispatchEvent<GJRobotSprite*, std::string, IconType>("hiimjustin000.more_icons/robot-sprite", robotSprite, "my-icon", IconType::Robot).post();

// Change a PlayerObject to a custom icon
DispatchEvent<PlayerObject*, const std::string&>("hiimjustin000.more_icons/player-object", playerObject, "my-icon").post(); // Determines the icon type
DispatchEvent<PlayerObject*, const std::string&, IconType>("hiimjustin000.more_icons/player-object", playerObject, "my-icon", IconType::Icon).post();
DispatchEvent<PlayerObject*, std::string>("hiimjustin000.more_icons/player-object", playerObject, "my-icon").post(); // Determines the icon type
DispatchEvent<PlayerObject*, std::string, IconType>("hiimjustin000.more_icons/player-object", playerObject, "my-icon", IconType::Cube).post();
```
## Credits
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.4.4 (2024-11-02)
- Fixed events not working properly

## v1.4.3 (2024-10-29)
- Tweaked the icon kit functionality
- Added user objects for custom icons
Expand Down
4 changes: 2 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"geode": "3.8.1",
"geode": "3.9.0",
"gd": {
"android": "2.206",
"win": "2.206",
"mac": "2.206"
},
"version": "v1.4.3",
"version": "v1.4.4",
"id": "hiimjustin000.more_icons",
"name": "More Icons",
"developer": "hiimjustin000",
Expand Down
10 changes: 5 additions & 5 deletions src/MoreIcons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

using namespace geode::prelude;

using SimplePlayerFilter = DispatchFilter<SimplePlayer*, const std::string&, IconType>;
using RobotSpriteFilter = DispatchFilter<GJRobotSprite*, const std::string&>;
using RobotSpriteTypeFilter = DispatchFilter<GJRobotSprite*, const std::string&, IconType>;
using PlayerObjectFilter = DispatchFilter<PlayerObject*, const std::string&>;
using PlayerObjectTypeFilter = DispatchFilter<PlayerObject*, const std::string&, IconType>;
using SimplePlayerFilter = DispatchFilter<SimplePlayer*, std::string, IconType>;
using RobotSpriteFilter = DispatchFilter<GJRobotSprite*, std::string>;
using RobotSpriteTypeFilter = DispatchFilter<GJRobotSprite*, std::string, IconType>;
using PlayerObjectFilter = DispatchFilter<PlayerObject*, std::string>;
using PlayerObjectTypeFilter = DispatchFilter<PlayerObject*, std::string, IconType>;

$execute {
new EventListener<SimplePlayerFilter>(+[](SimplePlayer* player, const std::string& icon, IconType type) {
Expand Down
5 changes: 5 additions & 0 deletions src/MoreIcons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ class MoreIcons {
return name;
}

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

static std::vector<std::string> getPage(IconType type, int page) {
auto& vec = MoreIconsAPI::vectorForType(type);
auto customPage = page - (GameManager::get()->countForType(type) + 35) / 36;
Expand Down
20 changes: 10 additions & 10 deletions src/hooks/GJGarageLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,12 @@ class $modify(MIGarageLayer, GJGarageLayer) {
}
auto unlockType = GameManager::get()->iconTypeToUnlockType(m_iconType);
auto popup = ItemInfoPopup::create(iconID, unlockType);
if (auto nameLabel = getChildOfType<CCLabelBMFont>(popup->m_mainLayer, 0))
if (auto nameLabel = popup->m_mainLayer->getChildByType<CCLabelBMFont>(0))
nameLabel->setString(name.substr(name.find_first_of(':') + 1).c_str());
if (auto achLabel = getChildOfType<CCLabelBMFont>(popup->m_mainLayer, 1)) achLabel->setString("Custom");
if (auto achLabel = popup->m_mainLayer->getChildByType<CCLabelBMFont>(1)) achLabel->setString("Custom");
if (auto popupIcon = findFirstChildRecursive<GJItemIcon>(popup->m_mainLayer, [](auto) { return true; }))
MoreIconsAPI::updateSimplePlayer(popupIcon->m_player, name, m_iconType);
if (auto descText = getChildOfType<TextArea>(popup->m_mainLayer, 0)) descText->setString(
if (auto descText = popup->m_mainLayer->getChildByType<TextArea>(0)) descText->setString(
fmt::format("This <cg>{}</c> is added by the <cl>More Icons</c> mod.", std::string(ItemInfoPopup::nameForUnlockType(1, unlockType))));
if (auto completionMenu = popup->m_mainLayer->getChildByID("completionMenu")) completionMenu->setVisible(false);
if (auto infoButton = popup->m_buttonMenu->getChildByID("infoButton")) infoButton->setVisible(false);
Expand Down Expand Up @@ -444,10 +444,10 @@ class $modify(MIGarageLayer, GJGarageLayer) {
if (Mod::get()->setSavedValue<std::string>(MoreIcons::savedForType(m_iconType), name) == name && selectedIconType == m_iconType) {
auto trailInfo = MoreIcons::TRAIL_INFO[name];
auto popup = ItemInfoPopup::create(!trailInfo.pack.id.empty() ? 128 : 1, UnlockType::Cube);
if (auto nameLabel = getChildOfType<CCLabelBMFont>(popup->m_mainLayer, 0))
if (auto nameLabel = popup->m_mainLayer->getChildByType<CCLabelBMFont>(0))
nameLabel->setString(name.substr(name.find_first_of(':') + 1).c_str());
if (auto achLabel = getChildOfType<CCLabelBMFont>(popup->m_mainLayer, 1)) achLabel->setString("Custom");
if (auto popupIcon = getChildOfType<GJItemIcon>(popup->m_mainLayer, 0)) {
if (auto achLabel = popup->m_mainLayer->getChildByType<CCLabelBMFont>(1)) achLabel->setString("Custom");
if (auto popupIcon = popup->m_mainLayer->getChildByType<GJItemIcon>(0)) {
popupIcon->setVisible(false);
auto square = CCSprite::createWithSpriteFrameName("playerSquare_001.png");
square->setColor({ 150, 150, 150 });
Expand All @@ -461,7 +461,7 @@ class $modify(MIGarageLayer, GJGarageLayer) {
square->setID("trail-square"_spr);
popup->m_mainLayer->addChild(square);
}
if (auto descText = getChildOfType<TextArea>(popup->m_mainLayer, 0)) descText->setString(
if (auto descText = popup->m_mainLayer->getChildByType<TextArea>(0)) descText->setString(
fmt::format("This <cg>{}</c> is added by the <cl>More Icons</c> mod.", std::string(ItemInfoPopup::nameForUnlockType(1, UnlockType::Streak))));
if (auto completionMenu = popup->m_mainLayer->getChildByID("completionMenu")) completionMenu->setVisible(false);
if (auto infoButton = popup->m_buttonMenu->getChildByID("infoButton")) infoButton->setVisible(false);
Expand All @@ -476,19 +476,19 @@ class $modify(MIGarageLayer, GJGarageLayer) {
}
if (auto p1Button = findFirstChildRecursive<CCMenuItemSpriteExtra>(popup->m_buttonMenu, [](CCMenuItemSpriteExtra* btn) {
if (auto normalImage = typeinfo_cast<CCSprite*>(btn->getNormalImage())) {
if (auto p1Label = getChildOfType<CCLabelBMFont>(normalImage, 0)) return strcmp(p1Label->getString(), "P1") == 0;
if (auto p1Label = normalImage->getChildByType<CCLabelBMFont>(0)) return strcmp(p1Label->getString(), "P1") == 0;
}
return false;
})) p1Button->setVisible(false);
if (auto p2Button = findFirstChildRecursive<CCMenuItemSpriteExtra>(popup->m_buttonMenu, [](CCMenuItemSpriteExtra* btn) {
if (auto normalImage = typeinfo_cast<CCSprite*>(btn->getNormalImage())) {
if (auto p2Label = getChildOfType<CCLabelBMFont>(normalImage, 0)) return strcmp(p2Label->getString(), "P2") == 0;
if (auto p2Label = normalImage->getChildByType<CCLabelBMFont>(0)) return strcmp(p2Label->getString(), "P2") == 0;
}
return false;
})) p2Button->setVisible(false);
if (auto gButton = findFirstChildRecursive<CCMenuItemSpriteExtra>(popup->m_buttonMenu, [](CCMenuItemSpriteExtra* btn) {
if (auto normalImage = typeinfo_cast<CCSprite*>(btn->getNormalImage())) {
if (auto gLabel = getChildOfType<CCLabelBMFont>(normalImage, 0)) return strcmp(gLabel->getString(), "G") == 0;
if (auto gLabel = normalImage->getChildByType<CCLabelBMFont>(0)) return strcmp(gLabel->getString(), "G") == 0;
}
return false;
})) gButton->setVisible(false);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/MenuLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class $modify(MIMenuLayer, MenuLayer) {
auto profileButton = static_cast<CCMenuItemSpriteExtra*>(profileMenu->getChildByID("profile-button"));
if (!profileButton) return true;

MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(profileButton->getNormalImage(), 0), GameManager::get()->m_playerIconType, false);
MoreIcons::changeSimplePlayer(profileButton->getNormalImage()->getChildByType<SimplePlayer>(0), GameManager::get()->m_playerIconType, false);

return true;
}
Expand Down
52 changes: 18 additions & 34 deletions src/hooks/ProfilePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,15 @@ class $modify(MIProfilePage, ProfilePage) {
auto playerMenu = m_mainLayer->getChildByID("player-menu");
if (!playerMenu) return;

MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-icon"), 0), IconType::Cube);
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-ship"), 0), IconType::Ship);
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-ball"), 0), IconType::Ball);
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-ufo"), 0), IconType::Ufo);
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-wave"), 0), IconType::Wave);
if (Loader::get()->isModLoaded("thesillydoggo.animatedprofiles") && !Loader::get()->isModLoaded("rynat.better_unlock_info")) {
MoreIcons::changeSimplePlayer(
getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-robot")->getChildByID("player-robot"), 0), IconType::Robot);
MoreIcons::changeSimplePlayer(
getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-spider")->getChildByID("player-spider"), 0), IconType::Spider);
} else {
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-robot"), 0), IconType::Robot);
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-spider"), 0), IconType::Spider);
}
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-swing"), 0), IconType::Swing);
if (auto playerJetpack = playerMenu->getChildByID("player-jetpack"))
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerJetpack, 0), IconType::Jetpack);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-icon")), IconType::Cube);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-ship")), IconType::Ship);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-ball")), IconType::Ball);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-ufo")), IconType::Ufo);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-wave")), IconType::Wave);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-robot")), IconType::Robot);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-spider")), IconType::Spider);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-swing")), IconType::Swing);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-jetpack")), IconType::Jetpack);

if (Loader::get()->isModLoaded("weebify.separate_dual_icons")) {
auto twoPToggler = static_cast<CCMenuItemSpriteExtra*>(m_mainLayer->getChildByID("left-menu")->getChildByID("2p-toggler"));
Expand All @@ -62,23 +54,15 @@ class $modify(MIProfilePage, ProfilePage) {
auto f = m_fields.self();
(f->m_originalSDIToggleTarget->*f->m_originalSDIToggle)(sender);
auto playerMenu = m_mainLayer->getChildByID("player-menu");
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-icon"), 0), IconType::Cube);
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-ship"), 0), IconType::Ship);
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-ball"), 0), IconType::Ball);
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-ufo"), 0), IconType::Ufo);
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-wave"), 0), IconType::Wave);
if (Loader::get()->isModLoaded("thesillydoggo.animatedprofiles") && !Loader::get()->isModLoaded("rynat.better_unlock_info")) {
MoreIcons::changeSimplePlayer(
getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-robot")->getChildByID("player-robot"), 0), IconType::Robot);
MoreIcons::changeSimplePlayer(
getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-spider")->getChildByID("player-spider"), 0), IconType::Spider);
} else {
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-robot"), 0), IconType::Robot);
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-spider"), 0), IconType::Spider);
}
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerMenu->getChildByID("player-swing"), 0), IconType::Swing);
if (auto playerJetpack = playerMenu->getChildByID("player-jetpack"))
MoreIcons::changeSimplePlayer(getChildOfType<SimplePlayer>(playerJetpack, 0), IconType::Jetpack);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-icon")), IconType::Cube);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-ship")), IconType::Ship);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-ball")), IconType::Ball);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-ufo")), IconType::Ufo);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-wave")), IconType::Wave);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-robot")), IconType::Robot);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-spider")), IconType::Spider);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-swing")), IconType::Swing);
MoreIcons::changeSimplePlayer(MoreIcons::findPlayer(playerMenu->getChildByID("player-jetpack")), IconType::Jetpack);
}

void toggleShip(CCObject* sender) {
Expand Down

0 comments on commit 11376e5

Please sign in to comment.