mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-30 11:17:08 -05:00
Merge 3222c12e90
into adfc942fa0
This commit is contained in:
commit
84d9975c87
3 changed files with 46 additions and 0 deletions
BIN
loader/resources/copy.png
Normal file
BIN
loader/resources/copy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
|
@ -375,6 +375,17 @@ 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)
|
||||
|
@ -702,6 +713,40 @@ 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()) {
|
||||
|
|
|
@ -80,6 +80,7 @@ protected:
|
|||
void onRefreshList(CCObject*);
|
||||
void onTheme(CCObject*);
|
||||
void onSettings(CCObject*);
|
||||
void onCopy(CCObject*);
|
||||
void onBack(CCObject*);
|
||||
|
||||
void updateState();
|
||||
|
|
Loading…
Reference in a new issue