Skip to content

Commit

Permalink
That's why yo granny ain't got no knees
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimjasmine00 committed Oct 22, 2024
1 parent 0ed4808 commit ded8542
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 164 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 "x86_64;arm64")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

project(MoreIcons VERSION 1.3.3)
project(MoreIcons VERSION 1.3.4)

add_library(${PROJECT_NAME} SHARED
src/classes/DummyNode.cpp
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# More Icons Changelog
## v1.3.4 (2024-10-21)
- Moved some logic to More Icons API
- Tweaked the logo to add drop shadow

## v1.3.3 (2024-10-19)
- Improved the duplicate system
- Changed page functionality in the icon kit
Expand Down
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"win": "2.206",
"mac": "2.206"
},
"version": "v1.3.3",
"version": "v1.3.4",
"id": "hiimjustin000.more_icons",
"name": "More Icons",
"developer": "hiimjustin000",
Expand All @@ -15,6 +15,11 @@
"id": "geode.node-ids",
"version": ">=v1.12.0",
"importance": "required"
},
{
"id": "hiimjustin000.more_icons_api",
"version": ">=v1.0.0",
"importance": "required"
}
],
"resources": {
Expand Down
Binary file modified resources/MI_moreIcons_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 0 additions & 110 deletions src/MoreIcons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,113 +500,3 @@ void MoreIcons::loadTrail(const std::filesystem::path& path, const TexturePack&
else image->release();
});
}

void MoreIcons::changeSimplePlayer(SimplePlayer* player, const std::string& file, IconType iconType) {
if (!player) return;

if (iconType == IconType::Robot) {
useCustomRobot(player->m_robotSprite, file);
return;
}
else if (iconType == IconType::Spider) {
useCustomSpider(player->m_spiderSprite, file);
return;
}

if (file.empty()) return;
switch (iconType) {
case IconType::Cube:
if (!MoreIcons::hasIcon(file)) return;
break;
case IconType::Ship:
if (!MoreIcons::hasShip(file)) return;
break;
case IconType::Ball:
if (!MoreIcons::hasBall(file)) return;
break;
case IconType::Ufo:
if (!MoreIcons::hasUfo(file)) return;
break;
case IconType::Wave:
if (!MoreIcons::hasWave(file)) return;
break;
case IconType::Swing:
if (!MoreIcons::hasSwing(file)) return;
break;
case IconType::Jetpack:;
if (!MoreIcons::hasJetpack(file)) return;
break;
default:
return;
}

auto sfc = CCSpriteFrameCache::get();
auto icon = fmt::format("{}_001.png"_spr, file);
auto icon2 = fmt::format("{}_2_001.png"_spr, file);
auto icon3 = fmt::format("{}_3_001.png"_spr, file);
auto iconExtra = fmt::format("{}_extra_001.png"_spr, file);
auto iconGlow = fmt::format("{}_glow_001.png"_spr, file);

player->m_firstLayer->setDisplayFrame(sfc->spriteFrameByName(icon.c_str()));
player->m_secondLayer->setDisplayFrame(sfc->spriteFrameByName(icon2.c_str()));
auto firstCenter = player->m_firstLayer->getContentSize() / 2;
player->m_secondLayer->setPosition(firstCenter);
player->m_outlineSprite->setDisplayFrame(sfc->spriteFrameByName(iconGlow.c_str()));
player->m_outlineSprite->setPosition(firstCenter);
if (iconType == IconType::Ufo) {
player->m_birdDome->setDisplayFrame(sfc->spriteFrameByName(icon3.c_str()));
player->m_birdDome->setPosition(firstCenter);
}
auto extraFrame = sfc->spriteFrameByName(iconExtra.c_str());
auto extraVisible = doesExist(extraFrame);
player->m_detailSprite->setVisible(extraVisible);
if (extraVisible) {
player->m_detailSprite->setDisplayFrame(extraFrame);
player->m_detailSprite->setPosition(firstCenter);
}
}

void MoreIcons::useCustomSprite(GJRobotSprite* robot, const std::string& file) {
robot->setBatchNode(nullptr);
robot->m_paSprite->setBatchNode(nullptr);
auto spriteParts = robot->m_paSprite->m_spriteParts;
auto spriteFrameCache = CCSpriteFrameCache::get();
for (int i = 0; i < spriteParts->count(); i++) {
auto spritePart = static_cast<CCSpritePart*>(spriteParts->objectAtIndex(i));
auto tag = spritePart->getTag();

auto spriteFrame = fmt::format("{}_{:02}_001.png"_spr, file, tag);
auto sprite2Frame = fmt::format("{}_{:02}_2_001.png"_spr, file, tag);
auto spriteExtraFrame = fmt::format("{}_{:02}_extra_001.png"_spr, file, tag);
auto spriteGlowFrame = fmt::format("{}_{:02}_glow_001.png"_spr, file, tag);

spritePart->setBatchNode(nullptr);
spritePart->setDisplayFrame(spriteFrameCache->spriteFrameByName(spriteFrame.c_str()));
if (auto secondSprite = static_cast<CCSprite*>(robot->m_secondArray->objectAtIndex(i))) {
secondSprite->setBatchNode(nullptr);
secondSprite->setDisplayFrame(spriteFrameCache->spriteFrameByName(sprite2Frame.c_str()));
secondSprite->setPosition(spritePart->getContentSize() / 2);
}

auto glowChild = static_cast<CCSprite*>(robot->m_glowSprite->getChildren()->objectAtIndex(i));
glowChild->setBatchNode(nullptr);
glowChild->setDisplayFrame(spriteFrameCache->spriteFrameByName(spriteGlowFrame.c_str()));

if (spritePart == robot->m_headSprite) {
auto extraFrame = spriteFrameCache->spriteFrameByName(spriteExtraFrame.c_str());
auto hasExtra = MoreIcons::doesExist(extraFrame);
if (hasExtra) {
if (robot->m_extraSprite) {
robot->m_extraSprite->setBatchNode(nullptr);
robot->m_extraSprite->setDisplayFrame(extraFrame);
}
else {
robot->m_extraSprite = CCSprite::createWithSpriteFrame(extraFrame);
robot->m_headSprite->addChild(robot->m_extraSprite, 2);
}
robot->m_extraSprite->setPosition(spritePart->getContentSize() / 2);
}
robot->m_extraSprite->setVisible(hasExtra);
}
}
}
40 changes: 4 additions & 36 deletions src/MoreIcons.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <BS_thread_pool.hpp>
#include <hiimjustin000.more_icons_api/include/MoreIconsAPI.hpp>

struct TexturePack {
std::string name;
Expand Down Expand Up @@ -214,15 +215,13 @@ class MoreIcons {
}

static void changeSimplePlayer(SimplePlayer* player, IconType type) {
changeSimplePlayer(player, geode::Mod::get()->getSavedValue<std::string>(savedForType(type), ""), type);
MoreIconsAPI::updateSimplePlayer(player, geode::Mod::get()->getSavedValue<std::string>(savedForType(type), ""), type);
}

static void changeSimplePlayer(SimplePlayer* player, IconType type, bool dual) {
changeSimplePlayer(player, geode::Mod::get()->getSavedValue<std::string>(savedForType(type, dual), ""), type);
MoreIconsAPI::updateSimplePlayer(player, geode::Mod::get()->getSavedValue<std::string>(MoreIconsAPI::savedForType(type, dual), ""), type);
}

static void changeSimplePlayer(SimplePlayer*, const std::string&, IconType);

static bool doesExist(cocos2d::CCSpriteFrame* frame) {
return frame != nullptr && frame->getTag() != 105871529;
}
Expand Down Expand Up @@ -297,26 +296,7 @@ class MoreIcons {

static std::string savedForType(IconType type) {
auto sdi = geode::Loader::get()->getLoadedMod("weebify.separate_dual_icons");
return savedForType(type, sdi && sdi->getSavedValue("2pselected", false));
}

static std::string savedForType(IconType type, bool dual) {
std::string prefix;
switch (type) {
case IconType::Cube: prefix = "icon"; break;
case IconType::Ship: prefix = "ship"; break;
case IconType::Ball: prefix = "ball"; break;
case IconType::Ufo: prefix = "ufo"; break;
case IconType::Wave: prefix = "wave"; break;
case IconType::Robot: prefix = "robot"; break;
case IconType::Spider: prefix = "spider"; break;
case IconType::Swing: prefix = "swing"; break;
case IconType::Jetpack: prefix = "jetpack"; break;
case IconType::Special: prefix = "trail"; break;
default: prefix = ""; break;
}

return getDual(prefix, dual);
return MoreIconsAPI::savedForType(type, sdi && sdi->getSavedValue("2pselected", false));
}

static std::string getFrameName(const std::string& name, const std::string prefix, IconType type) {
Expand Down Expand Up @@ -368,18 +348,6 @@ class MoreIcons {
return page * 36 < count;
}

static void useCustomRobot(GJRobotSprite* robot, const std::string& robotFile) {
if (!robot || robotFile.empty() || !hasRobot(robotFile)) return;
useCustomSprite(robot, robotFile);
}

static void useCustomSpider(GJSpiderSprite* spider, const std::string& spiderFile) {
if (!spider || spiderFile.empty() || !hasSpider(spiderFile)) return;
useCustomSprite(spider, spiderFile);
}

static void useCustomSprite(GJRobotSprite* robot, const std::string& file);

static void showInfoPopup(bool folderButton = false) {
geode::createQuickPopup(
"More Icons",
Expand Down
24 changes: 12 additions & 12 deletions src/hooks/GJGarageLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class $modify(MIGarageLayer, GJGarageLayer) {
f->m_pages[IconType::Cube] = m_iconPages[IconType::Cube];

auto iconType = GameManager::get()->m_playerIconType;
MoreIcons::changeSimplePlayer(m_playerObject, Mod::get()->getSavedValue<std::string>(MoreIcons::savedForType(iconType, false), ""), iconType);
MoreIconsAPI::updateSimplePlayer(m_playerObject, Mod::get()->getSavedValue<std::string>(MoreIconsAPI::savedForType(iconType, false), ""), iconType);
auto sdi = Loader::get()->getLoadedMod("weebify.separate_dual_icons");
if (sdi) {
auto lastmode = (IconType)sdi->getSavedValue("lastmode", 0);
MoreIcons::changeSimplePlayer(static_cast<SimplePlayer*>(getChildByID("player2-icon")),
Mod::get()->getSavedValue<std::string>(MoreIcons::savedForType(lastmode, true), ""), lastmode);
MoreIconsAPI::updateSimplePlayer(static_cast<SimplePlayer*>(getChildByID("player2-icon")),
Mod::get()->getSavedValue<std::string>(MoreIconsAPI::savedForType(lastmode, true), ""), lastmode);
}

auto customIcon = Mod::get()->getSavedValue<std::string>("icon", "");
Expand Down Expand Up @@ -107,10 +107,10 @@ class $modify(MIGarageLayer, GJGarageLayer) {
MoreIcons::swapDual("jetpack");
MoreIcons::swapDual("trail");
auto iconType = GameManager::get()->m_playerIconType;
MoreIcons::changeSimplePlayer(m_playerObject, Mod::get()->getSavedValue<std::string>(MoreIcons::savedForType(iconType, false), ""), iconType);
MoreIconsAPI::updateSimplePlayer(m_playerObject, Mod::get()->getSavedValue<std::string>(MoreIconsAPI::savedForType(iconType, false), ""), iconType);
auto lastmode = (IconType)Loader::get()->getLoadedMod("weebify.separate_dual_icons")->getSavedValue("lastmode", 0);
MoreIcons::changeSimplePlayer(static_cast<SimplePlayer*>(getChildByID("player2-icon")),
Mod::get()->getSavedValue<std::string>(MoreIcons::savedForType(lastmode, true), ""), lastmode);
MoreIconsAPI::updateSimplePlayer(static_cast<SimplePlayer*>(getChildByID("player2-icon")),
Mod::get()->getSavedValue<std::string>(MoreIconsAPI::savedForType(lastmode, true), ""), lastmode);
setupCustomPage(f->m_pages[m_iconType]);
}

Expand Down Expand Up @@ -261,12 +261,12 @@ class $modify(MIGarageLayer, GJGarageLayer) {
createNavMenu();

auto iconType = GameManager::get()->m_playerIconType;
MoreIcons::changeSimplePlayer(m_playerObject, Mod::get()->getSavedValue<std::string>(MoreIcons::savedForType(iconType, false), ""), iconType);
MoreIconsAPI::updateSimplePlayer(m_playerObject, Mod::get()->getSavedValue<std::string>(MoreIconsAPI::savedForType(iconType, false), ""), iconType);
auto sdi = Loader::get()->getLoadedMod("weebify.separate_dual_icons");
if (sdi) {
auto lastmode = (IconType)sdi->getSavedValue("lastmode", 0);
MoreIcons::changeSimplePlayer(static_cast<SimplePlayer*>(getChildByID("player2-icon")),
Mod::get()->getSavedValue<std::string>(MoreIcons::savedForType(lastmode, true), ""), lastmode);
MoreIconsAPI::updateSimplePlayer(static_cast<SimplePlayer*>(getChildByID("player2-icon")),
Mod::get()->getSavedValue<std::string>(MoreIconsAPI::savedForType(lastmode, true), ""), lastmode);
}

auto spriteFrameCache = CCSpriteFrameCache::get();
Expand All @@ -287,7 +287,7 @@ class $modify(MIGarageLayer, GJGarageLayer) {
for (auto name : MoreIcons::getPage(m_iconType, f->m_pages[m_iconType])) {
auto itemIcon = GJItemIcon::createBrowserItem(unlockType, 1);
itemIcon->setScale(GJItemIcon::scaleForType(unlockType));
MoreIcons::changeSimplePlayer(itemIcon->m_player, name, m_iconType);
MoreIconsAPI::updateSimplePlayer(itemIcon->m_player, name, m_iconType);
if (hasAnimProf) {
if (auto robotSprite = itemIcon->m_player->m_robotSprite) robotSprite->runAnimation("idle01");
if (auto spiderSprite = itemIcon->m_player->m_spiderSprite) spiderSprite->runAnimation("idle01");
Expand All @@ -298,7 +298,7 @@ class $modify(MIGarageLayer, GJGarageLayer) {
auto player = dual ? static_cast<SimplePlayer*>(getChildByID("player2-icon")) : m_playerObject;
player->updatePlayerFrame(1, m_iconType);
player->updateColors();
MoreIcons::changeSimplePlayer(player, name, m_iconType);
MoreIconsAPI::updateSimplePlayer(player, name, m_iconType);
if (!dual) gameManager->m_playerIconType = m_iconType;
player->setScale(m_iconType == IconType::Jetpack ? 1.5f : 1.6f);
auto selectedIconType = dual ? (IconType)sdi->getSavedValue("lasttype", 0) : m_selectedIconType;
Expand All @@ -309,7 +309,7 @@ class $modify(MIGarageLayer, GJGarageLayer) {
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 = findFirstChildRecursive<GJItemIcon>(popup->m_mainLayer, [](auto) { return true; }))
MoreIcons::changeSimplePlayer(popupIcon->m_player, name, m_iconType);
MoreIconsAPI::updateSimplePlayer(popupIcon->m_player, name, m_iconType);
if (auto descText = getChildOfType<TextArea>(popup->m_mainLayer, 0)) descText->setString(
fmt::format("This <cg>{}</c> is added by the <cl>More Icons</c> mod.", std::string(ItemInfoPopup::nameForUnlockType(1, unlockType))));
if (!iconInfo.id.empty()) {
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/PlayerObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ class $modify(MIPlayerObject, PlayerObject) {
if (!m_gameLayer->m_player1 || m_gameLayer->m_player1 == this) {
auto robotFile = Mod::get()->getSavedValue<std::string>(MoreIcons::getDual("robot", false), "");
if (robotFile.empty() || !MoreIcons::hasRobot(robotFile)) return;
MoreIcons::useCustomRobot(m_robotSprite, robotFile);
MoreIconsAPI::updateRobotSprite(m_robotSprite, robotFile, IconType::Robot);
}
else if (!m_gameLayer->m_player2 || m_gameLayer->m_player2 == this) {
auto robotFile = Mod::get()->getSavedValue<std::string>(MoreIcons::getDual("robot", true), "");
if (robotFile.empty() || !MoreIcons::hasRobot(robotFile)) return;
MoreIcons::useCustomRobot(m_robotSprite, robotFile);
MoreIconsAPI::updateRobotSprite(m_robotSprite, robotFile, IconType::Robot);
}
else return;

Expand All @@ -236,12 +236,12 @@ class $modify(MIPlayerObject, PlayerObject) {
if (!m_gameLayer->m_player1 || m_gameLayer->m_player1 == this) {
auto spiderFile = Mod::get()->getSavedValue<std::string>(MoreIcons::getDual("spider", false), "");
if (spiderFile.empty() || !MoreIcons::hasSpider(spiderFile)) return;
MoreIcons::useCustomSpider(m_spiderSprite, spiderFile);
MoreIconsAPI::updateRobotSprite(m_spiderSprite, spiderFile, IconType::Spider);
}
else if (!m_gameLayer->m_player2 || m_gameLayer->m_player2 == this) {
auto spiderFile = Mod::get()->getSavedValue<std::string>(MoreIcons::getDual("spider", true), "");
if (spiderFile.empty() || !MoreIcons::hasSpider(spiderFile)) return;
MoreIcons::useCustomSpider(m_spiderSprite, spiderFile);
MoreIconsAPI::updateRobotSprite(m_spiderSprite, spiderFile, IconType::Spider);
}
else return;

Expand Down

0 comments on commit ded8542

Please sign in to comment.