mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-30 11:17:08 -05:00
why is it not loading
This commit is contained in:
parent
f79da023cf
commit
c6c9af6867
6 changed files with 121 additions and 46 deletions
Binary file not shown.
Before Width: | Height: | Size: 6.5 KiB |
|
@ -82,6 +82,9 @@
|
|||
"name": "Enable Geode-Themed Colors",
|
||||
"description": "When enabled, the Geode menu has a <ca>Geode-themed color scheme</c>. <cy>This does not affect any other menus!</c>"
|
||||
},
|
||||
"copy-mods": {
|
||||
"type": "custom:copy-mods"
|
||||
},
|
||||
"developer-title": {
|
||||
"type": "title",
|
||||
"name": "Developer Settings"
|
||||
|
|
44
loader/src/loader/CopyButtonSetting.cpp
Normal file
44
loader/src/loader/CopyButtonSetting.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include "CopyButtonSetting.hpp"
|
||||
#include <Geode/loader/Mod.hpp>
|
||||
|
||||
$execute {
|
||||
(void)Mod::get()->registerCustomSettingType("copy-mods", &CopyButtonSetting::parse);
|
||||
}
|
||||
|
||||
SettingNodeV3* CopyButtonSetting::createNode(float width) {
|
||||
return CopyButtonSettingNode::create(std::static_pointer_cast<CopyButtonSetting>(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();
|
||||
}
|
74
loader/src/loader/CopyButtonSetting.hpp
Normal file
74
loader/src/loader/CopyButtonSetting.hpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
#include <Geode/loader/SettingV3.hpp>
|
||||
#include <ui/mods/GeodeStyle.hpp>
|
||||
|
||||
using namespace geode::prelude;
|
||||
|
||||
class CopyButtonSetting : public SettingV3 {
|
||||
public:
|
||||
static Result<std::shared_ptr<CopyButtonSetting>> parse(std::string const& key, std::string const& modID, matjson::Value const& json) {
|
||||
auto res = std::make_shared<CopyButtonSetting>();
|
||||
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<CopyButtonSetting> 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<CopyButtonSetting> 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;
|
||||
}
|
||||
};
|
|
@ -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()) {
|
||||
|
|
|
@ -82,7 +82,6 @@ protected:
|
|||
void onRefreshList(CCObject*);
|
||||
void onTheme(CCObject*);
|
||||
void onSettings(CCObject*);
|
||||
void onCopy(CCObject*);
|
||||
void onBack(CCObject*);
|
||||
|
||||
void updateState();
|
||||
|
|
Loading…
Reference in a new issue