diff --git a/loader/src/ui/internal/info/ModDevsPopup.cpp b/loader/src/ui/internal/info/ModDevsPopup.cpp new file mode 100644 index 00000000..366f25ef --- /dev/null +++ b/loader/src/ui/internal/info/ModDevsPopup.cpp @@ -0,0 +1,65 @@ +#include "ModDevsPopup.hpp" +#include "DevProfilePopup.hpp" +#include +#include +#include +#include "../list/ModListCell.hpp" +#include "../list/ModListLayer.hpp" + +ModListLayer* m_layer; + +bool ModDevsPopup::setup(ModMetadata const& mod, ModListLayer* list) { + m_noElasticity = true; + m_layer = list; + + this->setTitle("Developers for " + mod.getName()); + + auto listSize = CCSize { 190.f, 150.f }; + auto devList = ScrollLayer::create(listSize); + + auto bg = CCScale9Sprite::create("square02b_001.png", { 0.0f, 0.0f, 80.0f, 80.0f }); + bg->setScale(.5f); + bg->setColor({ 0, 0, 0 }); + bg->setOpacity(115); + bg->setContentSize(listSize * 2 + ccp(10, 10)); + m_mainLayer->addChildAtPosition(bg, Anchor::Center, ccp(0, -10)); + + for (auto& dev : mod.getDevelopers()) { + auto menu = CCMenu::create(); + + auto label = CCLabelBMFont::create(dev.c_str(), "goldFont.fnt"); + label->setScale(.65f); + auto btn = CCMenuItemSpriteExtra::create(label, this, menu_selector(ModDevsPopup::onViewDev)); + btn->setUserObject(CCString::create(dev)); + menu->addChild(btn); + + menu->setContentSize({ listSize.width, 25.f }); + menu->setLayout(RowLayout::create()); + devList->m_contentLayer->addChild(menu); + } + + devList->m_contentLayer->setLayout( + ColumnLayout::create() + ->setAxisReverse(true) + ->setAutoGrowAxis(listSize.height) + ->setAxisAlignment(AxisAlignment::End) + ); + m_mainLayer->addChildAtPosition(devList, Anchor::Center, -listSize / 2 - ccp(0, 10)); + + return true; +} + +void ModDevsPopup::onViewDev(CCObject* sender) { + auto str = static_cast(static_cast(sender)->getUserObject()); + DevProfilePopup::create(str->getCString(), m_layer)->show(); +} + +ModDevsPopup* ModDevsPopup::create(ModMetadata const& mod, ModListLayer* list) { + auto ret = new ModDevsPopup(); + if (ret && ret->initAnchored(280.f, 220.f, mod, list)) { + ret->autorelease(); + return ret; + } + CC_SAFE_DELETE(ret); + return nullptr; +} diff --git a/loader/src/ui/internal/info/ModDevsPopup.hpp b/loader/src/ui/internal/info/ModDevsPopup.hpp new file mode 100644 index 00000000..89f400ce --- /dev/null +++ b/loader/src/ui/internal/info/ModDevsPopup.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +using namespace geode::prelude; + +class ModListLayer; + +class ModDevsPopup : public Popup { +protected: + ModListLayer* m_layer; + + bool setup(ModMetadata const& mod, ModListLayer* list) override; + + void onViewDev(CCObject* sender); + +public: + static ModDevsPopup* create(ModMetadata const& mod, ModListLayer* list); +}; diff --git a/loader/src/ui/internal/list/ModListCell.cpp b/loader/src/ui/internal/list/ModListCell.cpp index d6e792b2..f3e817a9 100644 --- a/loader/src/ui/internal/list/ModListCell.cpp +++ b/loader/src/ui/internal/list/ModListCell.cpp @@ -9,6 +9,7 @@ #include #include "../info/TagNode.hpp" #include "../info/DevProfilePopup.hpp" +#include "../info/ModDevsPopup.hpp" #include "ProblemsListPopup.hpp" template @@ -189,11 +190,14 @@ void ModListCell::updateCellLayout() { } void ModListCell::onViewDev(CCObject*) { - if (this->getDevelopers().size() == 1) { - DevProfilePopup::create(this->getDevelopers().front(), m_layer)->show(); - } - else { - // todo: multiple dev picker + auto meta = this->getModMetadata(); + if (meta.has_value()) { + if (meta.value().getDevelopers().size() == 1) { + DevProfilePopup::create(meta.value().getDevelopers().front(), m_layer)->show(); + } + else { + ModDevsPopup::create(meta.value(), m_layer)->show(); + } } } @@ -343,8 +347,8 @@ bool ModCell::init( return true; } -std::vector ModCell::getDevelopers() const { - return m_mod->getDevelopers(); +std::optional ModCell::getModMetadata() const { + return m_mod->getMetadata(); } CCNode* ModCell::createLogo(CCSize const& size) { @@ -433,8 +437,8 @@ void IndexItemCell::updateState() { this->updateCellLayout(); } -std::vector IndexItemCell::getDevelopers() const { - return m_item->getMetadata().getDevelopers(); +std::optional IndexItemCell::getModMetadata() const { + return m_item->getMetadata(); } CCNode* IndexItemCell::createLogo(CCSize const& size) { @@ -540,8 +544,8 @@ InvalidGeodeFileCell* InvalidGeodeFileCell::create( void InvalidGeodeFileCell::updateState() {} -std::vector InvalidGeodeFileCell::getDevelopers() const { - return {}; +std::optional InvalidGeodeFileCell::getModMetadata() const { + return std::nullopt; } CCNode* InvalidGeodeFileCell::createLogo(CCSize const& size) { @@ -663,8 +667,8 @@ ProblemsCell* ProblemsCell::create( void ProblemsCell::updateState() {} -std::vector ProblemsCell::getDevelopers() const { - return {}; +std::optional ProblemsCell::getModMetadata() const { + return std::nullopt; } CCNode* ProblemsCell::createLogo(CCSize const& size) { diff --git a/loader/src/ui/internal/list/ModListCell.hpp b/loader/src/ui/internal/list/ModListCell.hpp index 0afa5621..66c71951 100644 --- a/loader/src/ui/internal/list/ModListCell.hpp +++ b/loader/src/ui/internal/list/ModListCell.hpp @@ -40,7 +40,7 @@ protected: public: virtual void updateState() = 0; virtual CCNode* createLogo(CCSize const& size) = 0; - virtual std::vector getDevelopers() const = 0; + virtual std::optional getModMetadata() const = 0; void disableDeveloperButton(); }; @@ -74,7 +74,7 @@ public: void updateState() override; CCNode* createLogo(CCSize const& size) override; - std::vector getDevelopers() const override; + std::optional getModMetadata() const override; }; /** @@ -104,7 +104,7 @@ public: void updateState() override; CCNode* createLogo(CCSize const& size) override; - std::vector getDevelopers() const override; + std::optional getModMetadata() const override; }; /** @@ -134,7 +134,7 @@ public: void updateState() override; CCNode* createLogo(CCSize const& size) override; - std::vector getDevelopers() const override; + std::optional getModMetadata() const override; }; /** @@ -163,5 +163,5 @@ public: void updateState() override; CCNode* createLogo(CCSize const& size) override; - std::vector getDevelopers() const override; + std::optional getModMetadata() const override; };