first moves oh lord

This commit is contained in:
Justin Pridgen 2024-08-09 17:21:14 -04:00
parent 9c9c75d46b
commit ae24abbcec
3 changed files with 41 additions and 0 deletions

BIN
loader/resources/copy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -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,35 @@ void ModsLayer::onSettings(CCObject*) {
openSettingsPopup(Mod::get());
}
void ModsLayer::onCopy(CCObject*) {
auto text = "No mods installed";
auto mods = Loader::get()->getAllMods();
if (!mods.empty()) text = "Mods list copied to clipboard!";
auto* label = CCLabelBMFont::create(text, "bigFont.fnt");
label->setPosition(CCDirector::get()->getWinSize() / 2);
label->setOpacity(0);
label->runAction(CCSequence::create(
CCFadeIn::create(.5f),
CCDelayTime::create(1.f),
CCFadeOut::create(.5f),
nullptr
));
this->addChild(label);
std::stringstream ss;
using namespace std::string_view_literals;
for (auto& mod : mods) {
ss << fmt::format("{} | [{}] {}\n",
mod->isEnabled() ? "x"sv :
mod->hasProblems() ? "!"sv :
" "sv,
mod->getVersion().toVString(), mod->getID()
);
}
clipboard::write(ss.str());
}
ModsLayer* ModsLayer::create() {
auto ret = new ModsLayer();
if (ret->init()) {

View file

@ -80,6 +80,7 @@ protected:
void onRefreshList(CCObject*);
void onTheme(CCObject*);
void onSettings(CCObject*);
void onCopy(CCObject*);
void onBack(CCObject*);
void updateState();