mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-27 01:45:35 -05:00
Compare commits
3 commits
7050be188f
...
31d522a089
Author | SHA1 | Date | |
---|---|---|---|
|
31d522a089 | ||
|
c0514b1915 | ||
|
dd1d83558f |
5 changed files with 140 additions and 1 deletions
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -1,5 +1,21 @@
|
|||
# Geode Changelog
|
||||
|
||||
## v4.0.0-beta.2
|
||||
* Add grid view to mod list (7bcf50d, 1ff24f0)
|
||||
* Add safe mode tip to windows crashlog window (38f3385)
|
||||
* Disable enabled button on outdated mods (302eea1)
|
||||
* Add a button to copy list of mods to clipboard (#1039)
|
||||
* Fix VersionInfo toJson (f6c2322)
|
||||
* Add `GEODE_DESKTOP(...)` and `GEODE_MOBILE(...)` macros (d6f0c59)
|
||||
* Fix CCCallFuncExt (b9fb2f6)
|
||||
* Fix `utils::string::replaceIP` when filter is empty (4d5e465)
|
||||
* Fix more log nesting issues (2221095)
|
||||
* Fix new before/after priority system (17bf772)
|
||||
* Added European Portuguese translation (#1160)
|
||||
* Add missing CCHttpRequest methods and members (#1161)
|
||||
* Fix downloading many mods at once causing the UI to lag (c94a533)
|
||||
* Fix vv version (6e86b38)
|
||||
|
||||
## v4.0.0-beta.1
|
||||
* Button to manually install mods from files (e881dc5)
|
||||
* Add `ModRequestedAction::Update` (e881dc5)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
4.0.0-beta.1
|
||||
4.0.0-beta.2
|
||||
|
|
|
@ -91,6 +91,10 @@
|
|||
"name": "Expand Installed Mods List",
|
||||
"description": "Make the installed mods list a single infinite scrollable list instead of having pages"
|
||||
},
|
||||
"copy-mods": {
|
||||
"type": "custom:copy-mods",
|
||||
"name": ""
|
||||
},
|
||||
"developer-title": {
|
||||
"type": "title",
|
||||
"name": "Developer Settings"
|
||||
|
|
43
loader/src/loader/CopyButtonSetting.cpp
Normal file
43
loader/src/loader/CopyButtonSetting.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include "CopyButtonSetting.hpp"
|
||||
#include <Geode/loader/Mod.hpp>
|
||||
|
||||
$on_mod(Loaded) {
|
||||
(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::string modsList;
|
||||
using namespace std::string_view_literals;
|
||||
for (int i = 0; i < mods.size(); i++) {
|
||||
auto& mod = mods[i];
|
||||
modsList += fmt::format("{} | [{}] {}{}",
|
||||
mod->isEnabled() ? "x"sv :
|
||||
mod->hasLoadProblems() ? "!"sv :
|
||||
mod->targetsOutdatedVersion() ? "*"sv :
|
||||
" "sv,
|
||||
mod->getVersion().toVString(), mod->getID(),
|
||||
i < mods.size() ? "\n" : ""
|
||||
);
|
||||
}
|
||||
clipboard::write(modsList);
|
||||
|
||||
Notification::create("Mods list copied to clipboard", NotificationIcon::Info, 0.5f)->show();
|
||||
}
|
76
loader/src/loader/CopyButtonSetting.hpp
Normal file
76
loader/src/loader/CopyButtonSetting.hpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
#include <Geode/loader/SettingV3.hpp>
|
||||
#include <ui/mods/GeodeStyle.hpp>
|
||||
|
||||
using namespace geode::prelude;
|
||||
|
||||
class CopyButtonSetting : public SettingV3 {
|
||||
public:
|
||||
static Result<std::shared_ptr<SettingV3>> 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);
|
||||
res->parseNameAndDescription(root);
|
||||
|
||||
return root.ok(std::static_pointer_cast<SettingV3>(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()->setPosition(getContentSize() / 2);
|
||||
this->getButtonMenu()->setAnchorPoint({ .5f, .5f });
|
||||
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;
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue