add persistent folder button
Some checks are pending
Build Binaries / Build Windows (push) Waiting to run
Build Binaries / Build macOS (push) Waiting to run
Build Binaries / Build Android (64-bit) (push) Waiting to run
Build Binaries / Build Android (32-bit) (push) Waiting to run
Build Binaries / Publish (push) Blocked by required conditions

This commit is contained in:
altalk23 2024-09-14 12:41:23 +03:00
parent 68ab4750ac
commit 358590b951
5 changed files with 43 additions and 29 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
loader/resources/save.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -145,28 +145,46 @@ bool ModSettingsPopup::setup(Mod* mod) {
);
m_buttonMenu->addChildAtPosition(resetBtn, Anchor::BottomLeft, ccp(45, 20));
auto configFolderSpr = CCSprite::createWithSpriteFrameName("folderIcon_001.png");
m_openConfigDirBtnSpr = createGeodeButton(configFolderSpr, "");
m_openConfigDirBtnSpr->setScale(.6f);
m_openConfigDirBtnSpr->getIcon()->setScale(m_openConfigDirBtnSpr->getIcon()->getScale() * 1.4f);
auto openConfigDirBtn = CCMenuItemSpriteExtra::create(
m_openConfigDirBtnSpr, this, menu_selector(ModSettingsPopup::onOpenConfigDirectory)
);
m_buttonMenu->addChildAtPosition(openConfigDirBtn, Anchor::BottomRight, ccp(-50, 20));
auto foldersMenu = CCMenu::create();
foldersMenu->setContentSize({ 0, 30 });
foldersMenu->setAnchorPoint(ccp(1, 0));
foldersMenu->setLayout(RowLayout::create()
->setAxisReverse(true)
->setGap(5)
->setAutoGrowAxis(30)
->setGrowCrossAxis(true));
m_buttonMenu->addChildAtPosition(foldersMenu, Anchor::BottomRight, ccp(-5, 10));
auto settingFolderSpr = CCSprite::createWithSpriteFrameName("folderIcon_001.png");
auto settingFolderSprSub = CCSprite::createWithSpriteFrameName("settings.png"_spr);
settingFolderSprSub->setColor(ccBLACK);
settingFolderSprSub->setOpacity(155);
settingFolderSprSub->setScale(.55f);
settingFolderSpr->addChildAtPosition(settingFolderSprSub, Anchor::Center, ccp(0, -3));
auto openDirBtnSpr = createGeodeButton(settingFolderSpr, "");
openDirBtnSpr->setScale(.6f);
openDirBtnSpr->getIcon()->setScale(openDirBtnSpr->getIcon()->getScale() * 1.4f);
auto openDirBtn = CCMenuItemSpriteExtra::create(
openDirBtnSpr, this, menu_selector(ModSettingsPopup::onOpenSaveDirectory)
);
m_buttonMenu->addChildAtPosition(openDirBtn, Anchor::BottomRight, ccp(-20, 20));
auto createFolderButton = [&, this](auto subSprName, auto callback) {
auto folderSpr = CCSprite::createWithSpriteFrameName("folderIcon_001.png");
auto folderSprSub = CCSprite::createWithSpriteFrameName(subSprName);
folderSprSub->setColor(ccBLACK);
folderSprSub->setOpacity(155);
folderSprSub->setScale(.55f);
folderSpr->addChildAtPosition(folderSprSub, Anchor::Center, ccp(0, -3));
auto buttonSpr = createGeodeButton(folderSpr, "");
buttonSpr->setScale(.6f);
buttonSpr->getIcon()->setScale(buttonSpr->getIcon()->getScale() * 1.4f);
auto folderBtn = CCMenuItemSpriteExtra::create(
buttonSpr, this, static_cast<SEL_MenuHandler>(callback)
);
foldersMenu->addChild(folderBtn);
return folderBtn;
};
createFolderButton("save.png"_spr, &ModSettingsPopup::onOpenSaveDirectory);
createFolderButton("settings.png"_spr, &ModSettingsPopup::onOpenConfigDirectory);
auto persistentBtn = createFolderButton("persistent.png"_spr, &ModSettingsPopup::onOpenPersistentDirectory);
if (!std::filesystem::exists(mod->getPersistentDir(false))) {
persistentBtn->setEnabled(false);
auto spr = static_cast<CCSprite*>(persistentBtn->getNormalImage());
spr->setCascadeColorEnabled(true);
spr->setCascadeOpacityEnabled(true);
spr->setColor(ccGRAY);
spr->setOpacity(155);
}
foldersMenu->updateLayout();
m_changeListener.bind([this](auto* ev) {
this->updateState(ev->getNode());
@ -224,7 +242,9 @@ void ModSettingsPopup::onOpenSaveDirectory(CCObject*) {
}
void ModSettingsPopup::onOpenConfigDirectory(CCObject*) {
file::openFolder(m_mod->getConfigDir());
this->updateState();
}
void ModSettingsPopup::onOpenPersistentDirectory(CCObject*) {
file::openFolder(m_mod->getPersistentDir());
}
void ModSettingsPopup::onClearSearch(CCObject*) {
m_searchInput->setString("");
@ -239,12 +259,6 @@ void ModSettingsPopup::updateState(SettingNodeV3* invoker) {
m_restartBtn->setVisible(ModSettingsManager::from(m_mod)->restartRequired());
m_applyMenu->updateLayout();
auto configDirExists = std::filesystem::exists(m_mod->getConfigDir(false));
m_openConfigDirBtnSpr->setCascadeColorEnabled(true);
m_openConfigDirBtnSpr->setCascadeOpacityEnabled(true);
m_openConfigDirBtnSpr->setColor(configDirExists ? ccWHITE : ccGRAY);
m_openConfigDirBtnSpr->setOpacity(configDirExists ? 255 : 155);
auto listPosBefore = m_list->m_contentLayer->getPositionY();
auto listHeightBefore = m_list->m_contentLayer->getContentHeight();

View file

@ -16,7 +16,6 @@ protected:
CCMenuItemSpriteExtra* m_applyBtn;
CCMenuItemSpriteExtra* m_restartBtn;
ButtonSprite* m_applyBtnSpr;
IconButtonSprite* m_openConfigDirBtnSpr;
TextInput* m_searchInput;
CCMenuItemSpriteExtra* m_searchClearBtn;
EventListener<EventFilter<SettingNodeValueChangeEventV3>> m_changeListener;
@ -30,6 +29,7 @@ protected:
void onResetAll(CCObject*);
void onOpenSaveDirectory(CCObject*);
void onOpenConfigDirectory(CCObject*);
void onOpenPersistentDirectory(CCObject*);
void onClearSearch(CCObject*);
public: