From c6c9af68674f92b32779c21ca8aab64d931c9a08 Mon Sep 17 00:00:00 2001 From: Justin Pridgen Date: Tue, 10 Sep 2024 15:57:50 -0400 Subject: [PATCH] why is it not loading --- loader/resources/copy.png | Bin 6635 -> 0 bytes loader/resources/mod.json.in | 3 + loader/src/loader/CopyButtonSetting.cpp | 44 ++++++++++++++ loader/src/loader/CopyButtonSetting.hpp | 74 ++++++++++++++++++++++++ loader/src/ui/mods/ModsLayer.cpp | 45 -------------- loader/src/ui/mods/ModsLayer.hpp | 1 - 6 files changed, 121 insertions(+), 46 deletions(-) delete mode 100644 loader/resources/copy.png create mode 100644 loader/src/loader/CopyButtonSetting.cpp create mode 100644 loader/src/loader/CopyButtonSetting.hpp diff --git a/loader/resources/copy.png b/loader/resources/copy.png deleted file mode 100644 index e9209613fcfecf68f7932de6e193dc44f55a1a7d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6635 zcma)>WlS7gu=jB+eWOs;$MiZyP0t zvPJ7H9~Li&aR)kaKyosw`7)hwpD>?rbpp}VaD2)Ed(o}h_SoZS;<&2p19I!RNaIj( zJO+}p`Hau^JbQ6S%RPb4AZ)l?KTdx&QizeOtTpEkp)2;!P^E5!E#Bp@Rjcl-098BS z&iF*|gdJJP2%XS$ep>-s-f@#OD)GHaff}oi1uZOC-tsnjdp|DYMp)|D(fw4NZ)jP} zeOx{Vv%?!7W~)M$9Gfdzw<-f$49-f%OTI-4gv^BH(Rg{AK5GZrrxXU{`%dH-$dYMiOE_6B@{08{A z9JXcsaI#(FHYYRsNZE>hXMJ*j+%2Kojc^WnI$7r9`ptouwr9@0d9lb@g{G%r*pD-? z#m$7l+b|q64%^DA)CQVb<=pHKYylnq`IRCW^@mly!)caV=Ruzd|C(Cvq(o*Mb_6Q< zAoHX3`_dS3+ktc|shIcg-~!!*($7wKiqjBQBK{NvDWlYsS}z?GLwuf(z1A_=W0r(} z*vFjZ#{B!|!$+vbs%Xow%Mt@SynVmUb(1u(K-&QA2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I(XZgiIgtqE!N9DgJMOX82nY*I~gwK6CVn;`v1<0m1)H zWy>HzQ(fx0MBghzkb74uSoJ3Ix{j$oLzoGyg5IZvy_;}7ing<77M;_vtzm6M9m7`c zy={*c*BZGwc-6B(B#bZ9(`y>V^Z2I!wN?=46F@J#Q#118&_IF5^ zrqN$8excL;n{@IA=Wfo}K8%6^kz0x+|^an%O#`7UL;R$Ka};vdE34}1#-Yi)nUA-T@= zXA5`EU4c)t{~CYEJ=6VmB-uYQD+fHdz#(u?Ks=`k{&pIwh&i&6A$3OR2}`)!!Q5)4 zvS<6oaQ{^-r^;hkZ=nI(S}#_T=%NC@0rO{_WBBOHU$SYVgD5hR2j@qWU%K*fXK-$! z0S#3L(^G|?8k;fvuDSm*bYLoyObqkr9J*`%)}{3zI7o7xs`*5?^s23*>#2?O1YIcJ zcsyyC|o>dhBz7SEpxKlxOK_^=Gg0O#Rcj1N69URWA5!c%>44^IE>b8AFY% z5%VO~s;?{wmK@8FIW~Fi4>8UYJq})kF?K*aI?PJWl~0%=t-~s@g3>-q)42sa$(iW^ zd)`WUO4Bt=Rav%*&G4N%P;jjfi6Xh;pgHFYN1ko1VtMb~08hRktC9H_tGq|)6hPH0 zmc$^Y)nhK7XdghA5^qQQ8Sx4A2_!LycN@XuDbX(PIf%R^3Um@MRtX?NiH5OGeode-themed color scheme. This does not affect any other menus!" }, + "copy-mods": { + "type": "custom:copy-mods" + }, "developer-title": { "type": "title", "name": "Developer Settings" diff --git a/loader/src/loader/CopyButtonSetting.cpp b/loader/src/loader/CopyButtonSetting.cpp new file mode 100644 index 00000000..178aea7a --- /dev/null +++ b/loader/src/loader/CopyButtonSetting.cpp @@ -0,0 +1,44 @@ +#include "CopyButtonSetting.hpp" +#include + +$execute { + (void)Mod::get()->registerCustomSettingType("copy-mods", &CopyButtonSetting::parse); +} + +SettingNodeV3* CopyButtonSetting::createNode(float width) { + return CopyButtonSettingNode::create(std::static_pointer_cast(shared_from_this()), width); +} + +void CopyButtonSettingNode::onCopy(CCObject*) { + auto mods = Loader::get()->getAllMods(); + if (mods.empty()) { + Notification::create("No mods installed", NotificationIcon::Info, 0.5f)->show(); + return; + } + + std::sort(mods.begin(), mods.end(), [](Mod* a, Mod* b) { + auto const s1 = a->getID(); + auto const s2 = b->getID(); + return std::lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end(), [](auto a, auto b) { + return std::tolower(a) < std::tolower(b); + }); + }); + + std::stringstream ss; + using namespace std::string_view_literals; + for (int i = 0; i < mods.size(); i++) { + auto& mod = mods[i]; + ss << fmt::format("{} | [{}] {}", + mod->isEnabled() ? "x"sv : + mod->hasProblems() ? "!"sv : + " "sv, + mod->getVersion().toVString(), mod->getID() + ); + if (i != mods.size() - 1) { + ss << "\n"; + } + } + clipboard::write(ss.str()); + + Notification::create("Mods list copied to clipboard", NotificationIcon::Info, 0.5f)->show(); +} diff --git a/loader/src/loader/CopyButtonSetting.hpp b/loader/src/loader/CopyButtonSetting.hpp new file mode 100644 index 00000000..ac87eff5 --- /dev/null +++ b/loader/src/loader/CopyButtonSetting.hpp @@ -0,0 +1,74 @@ +#include +#include + +using namespace geode::prelude; + +class CopyButtonSetting : public SettingV3 { +public: + static Result> parse(std::string const& key, std::string const& modID, matjson::Value const& json) { + auto res = std::make_shared(); + auto root = checkJson(json, "CopyButtonSetting"); + + res->init(key, modID, root); + + return root.ok(res); + } + + bool load(matjson::Value const& json) override { + return true; + } + bool save(matjson::Value& json) const override { + return true; + } + + bool isDefaultValue() const override { + return true; + } + void reset() override {} + + SettingNodeV3* createNode(float width) override; +}; + +class CopyButtonSettingNode : public SettingNodeV3 { +protected: + bool init(std::shared_ptr setting, float width) { + if (!SettingNodeV3::init(setting, width)) + return false; + + auto buttonSprite = createGeodeButton("Copy Mods"); + buttonSprite->setScale(.5f); + auto button = CCMenuItemSpriteExtra::create( + buttonSprite, this, menu_selector(CopyButtonSettingNode::onCopy) + ); + this->getButtonMenu()->addChildAtPosition(button, Anchor::Center); + this->getButtonMenu()->setContentWidth(60); + this->getButtonMenu()->updateLayout(); + + this->updateState(nullptr); + + return true; + } + + void onCopy(CCObject*); + + void onCommit() override {} + void onResetToDefault() override {} + +public: + static CopyButtonSettingNode* create(std::shared_ptr setting, float width) { + auto ret = new CopyButtonSettingNode(); + if (ret && ret->init(setting, width)) { + ret->autorelease(); + return ret; + } + CC_SAFE_DELETE(ret); + return nullptr; + } + + bool hasUncommittedChanges() const override { + return false; + } + bool hasNonDefaultValue() const override { + return false; + } +}; diff --git a/loader/src/ui/mods/ModsLayer.cpp b/loader/src/ui/mods/ModsLayer.cpp index 30e61b7e..ce7562f8 100644 --- a/loader/src/ui/mods/ModsLayer.cpp +++ b/loader/src/ui/mods/ModsLayer.cpp @@ -380,17 +380,6 @@ bool ModsLayer::init() { folderBtn->setID("mods-folder-button"); actionsMenu->addChild(folderBtn); - auto copySpr = createGeodeCircleButton( - CCSprite::createWithSpriteFrameName("copy.png"_spr), 1.f, - CircleBaseSize::Medium - ); - copySpr->setScale(.8f); - auto copyBtn = CCMenuItemSpriteExtra::create( - copySpr, this, menu_selector(ModsLayer::onCopy) - ); - copyBtn->setID("copy-button"); - actionsMenu->addChild(copyBtn); - actionsMenu->setLayout( ColumnLayout::create() ->setAxisAlignment(AxisAlignment::Start) @@ -718,40 +707,6 @@ void ModsLayer::onSettings(CCObject*) { openSettingsPopup(Mod::get()); } -void ModsLayer::onCopy(CCObject*) { - auto mods = Loader::get()->getAllMods(); - if (mods.empty()) { - Notification::create("No mods installed", NotificationIcon::Info, 0.5f)->show(); - return; - } - - std::sort(mods.begin(), mods.end(), [](Mod* a, Mod* b) { - auto const s1 = a->getID(); - auto const s2 = b->getID(); - return std::lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end(), [](auto a, auto b) { - return std::tolower(a) < std::tolower(b); - }); - }); - - std::stringstream ss; - using namespace std::string_view_literals; - for (int i = 0; i < mods.size(); i++) { - auto& mod = mods[i]; - ss << fmt::format("{} | [{}] {}", - mod->isEnabled() ? "x"sv : - mod->hasProblems() ? "!"sv : - " "sv, - mod->getVersion().toVString(), mod->getID() - ); - if (i != mods.size() - 1) { - ss << "\n"; - } - } - clipboard::write(ss.str()); - - Notification::create("Mods list copied to clipboard", NotificationIcon::Info, 0.5f)->show(); -} - ModsLayer* ModsLayer::create() { auto ret = new ModsLayer(); if (ret->init()) { diff --git a/loader/src/ui/mods/ModsLayer.hpp b/loader/src/ui/mods/ModsLayer.hpp index c0572fd7..35e36b97 100644 --- a/loader/src/ui/mods/ModsLayer.hpp +++ b/loader/src/ui/mods/ModsLayer.hpp @@ -82,7 +82,6 @@ protected: void onRefreshList(CCObject*); void onTheme(CCObject*); void onSettings(CCObject*); - void onCopy(CCObject*); void onBack(CCObject*); void updateState();