From eed99d16c5a77954e20d1c8281f92010b210d20c Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Wed, 28 Feb 2024 21:33:58 +0200 Subject: [PATCH] update default logo to just N/A + move featured to a star icon next to the title rather than glow since we can't enforce mod logo shape --- loader/include/Geode/ui/GeodeUI.hpp | 2 +- loader/src/ui/GeodeUI.cpp | 50 ++++------------------------- loader/src/ui/mods/ModItem.cpp | 23 ++++++++++++- loader/src/ui/mods/ModItem.hpp | 3 ++ 4 files changed, 33 insertions(+), 45 deletions(-) diff --git a/loader/include/Geode/ui/GeodeUI.hpp b/loader/include/Geode/ui/GeodeUI.hpp index b02d98f2..de817fb5 100644 --- a/loader/include/Geode/ui/GeodeUI.hpp +++ b/loader/include/Geode/ui/GeodeUI.hpp @@ -40,5 +40,5 @@ namespace geode { * logo is initially a loading circle, with the actual sprite downloaded * asynchronously */ - GEODE_DLL cocos2d::CCNode* createServerModLogo(std::string const& id, bool featured); + GEODE_DLL cocos2d::CCNode* createServerModLogo(std::string const& id); } diff --git a/loader/src/ui/GeodeUI.cpp b/loader/src/ui/GeodeUI.cpp index 43ffaafc..49ad84ca 100644 --- a/loader/src/ui/GeodeUI.cpp +++ b/loader/src/ui/GeodeUI.cpp @@ -69,10 +69,9 @@ class ModLogoSprite : public CCNode { protected: std::string m_modID; CCNode* m_sprite = nullptr; - CCNode* m_featuredSprite = nullptr; EventListener> m_listener; - bool init(std::string const& id, bool fetch, bool featured) { + bool init(std::string const& id, bool fetch) { if (!CCNode::init()) return false; @@ -82,13 +81,6 @@ protected: m_modID = id; m_listener.bind(this, &ModLogoSprite::onFetch); - if (featured) { - m_featuredSprite = CCSprite::createWithSpriteFrameName("logo-glow.png"_spr); - limitNodeSize(m_featuredSprite, m_obContentSize * 1.15f, 99.f, .1f); - m_featuredSprite->setZOrder(-1); - this->addChildAtPosition(m_featuredSprite, Anchor::Center); - } - // Load from Resources if (!fetch) { this->setSprite(id == "geode.loader" ? @@ -104,10 +96,6 @@ protected: m_listener.setFilter(server::getModLogo(id).listen()); } - if (m_featuredSprite) { - m_featuredSprite->setVisible(!fetch); - } - return true; } @@ -118,21 +106,13 @@ protected: } // Fallback to default logo if the sprite is null if (!sprite) { - sprite = CCSprite::createWithSpriteFrameName("no-logo.png"_spr); - } - // Fallback to lobotomy if Geode sprites are missing - if (!sprite) { - sprite = CCSprite::createWithSpriteFrameName("difficulty_02_btn_001.png"); + sprite = CCLabelBMFont::create("N/A", "bigFont.fnt"); + static_cast(sprite)->setOpacity(90); } // Set sprite and scale it to node size m_sprite = sprite; limitNodeSize(m_sprite, m_obContentSize, 99.f, .05f); this->addChildAtPosition(m_sprite, Anchor::Center); - - // Featured sprite is initially invisible if fetched from server - if (m_featuredSprite) { - m_featuredSprite->setVisible(true); - } } void onFetch(PromiseEvent* event) { @@ -151,9 +131,9 @@ protected: } public: - static ModLogoSprite* create(std::string const& id, bool fetch = false, bool featured = false) { + static ModLogoSprite* create(std::string const& id, bool fetch = false) { auto ret = new ModLogoSprite(); - if (ret && ret->init(id, fetch, featured)) { + if (ret && ret->init(id, fetch)) { ret->autorelease(); return ret; } @@ -170,22 +150,6 @@ CCNode* geode::createModLogo(Mod* mod) { return ModLogoSprite::create(mod->getID()); } -CCNode* geode::createServerModLogo(std::string const& id, bool featured) { - return ModLogoSprite::create(id, true, featured); +CCNode* geode::createServerModLogo(std::string const& id) { + return ModLogoSprite::create(id, true); } - -// CCNode* geode::createIndexItemLogo(IndexItemHandle item) { -// auto logoPath = ghc::filesystem::absolute(item->getRootPath() / "logo.png"); -// CCNode* spr = CCSprite::create(logoPath.string().c_str()); -// if (!spr) { -// spr = createDefaultLogo(); -// } -// if (item->isFeatured()) { -// auto logoGlow = CCSprite::createWithSpriteFrameName("logo-glow.png"_spr); -// spr->setScaleX(logoGlow->getContentWidth() / spr->getContentWidth()); -// spr->setScaleY(logoGlow->getContentHeight() / spr->getContentHeight()); -// logoGlow->addChildAtPosition(spr, Anchor::Center); -// spr = logoGlow; -// } -// return spr; -// } diff --git a/loader/src/ui/mods/ModItem.cpp b/loader/src/ui/mods/ModItem.cpp index 29a82721..bc962785 100644 --- a/loader/src/ui/mods/ModItem.cpp +++ b/loader/src/ui/mods/ModItem.cpp @@ -120,9 +120,30 @@ bool ServerModItem::init(server::ServerModMetadata const& metadata) { if (!BaseModItem::init()) return false; + if (metadata.featured) { + m_checkmark = CCScale9Sprite::createWithSpriteFrameName("GJ_colorBtn_001.png"); + m_checkmark->setContentSize({ 50, 38 }); + m_checkmark->setColor({ 255, 255, 120 }); + m_checkmark->setOpacity(45); + + auto tick = CCSprite::createWithSpriteFrameName("GJ_starsIcon_001.png"); + m_checkmark->addChildAtPosition(tick, Anchor::Center); + this->addChild(m_checkmark); + } + return true; } +void ServerModItem::updateSize(float width, bool big) { + BaseModItem::updateSize(width, big); + + if (m_checkmark) { + auto size = m_title->getScaledContentSize(); + limitNodeSize(m_checkmark, ccp(100, size.height), 1.f, .1f); + m_checkmark->setPosition(m_title->getPosition() + ccp(size.width + 10, 0)); + } +} + ServerModItem* ServerModItem::create(server::ServerModMetadata const& metadata) { auto ret = new ServerModItem(); if (ret && ret->init(metadata)) { @@ -138,7 +159,7 @@ ModMetadata ServerModItem::getMetadata() const { } CCNode* ServerModItem::createModLogo() const { - return createServerModLogo(m_metadata.id, m_metadata.featured); + return createServerModLogo(m_metadata.id); } bool ServerModItem::wantsRestart() const { diff --git a/loader/src/ui/mods/ModItem.hpp b/loader/src/ui/mods/ModItem.hpp index d2020833..7511247d 100644 --- a/loader/src/ui/mods/ModItem.hpp +++ b/loader/src/ui/mods/ModItem.hpp @@ -47,6 +47,7 @@ public: class ServerModItem : public BaseModItem { protected: server::ServerModMetadata m_metadata; + CCScale9Sprite* m_checkmark = nullptr; bool init(server::ServerModMetadata const& metadata); @@ -59,4 +60,6 @@ public: ModMetadata getMetadata() const override; CCNode* createModLogo() const override; bool wantsRestart() const override; + + void updateSize(float width, bool big) override; };