mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
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
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:
parent
68ab4750ac
commit
358590b951
5 changed files with 43 additions and 29 deletions
BIN
loader/resources/persistent.png
Normal file
BIN
loader/resources/persistent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
loader/resources/save.png
Normal file
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 |
|
@ -145,28 +145,46 @@ bool ModSettingsPopup::setup(Mod* mod) {
|
||||||
);
|
);
|
||||||
m_buttonMenu->addChildAtPosition(resetBtn, Anchor::BottomLeft, ccp(45, 20));
|
m_buttonMenu->addChildAtPosition(resetBtn, Anchor::BottomLeft, ccp(45, 20));
|
||||||
|
|
||||||
auto configFolderSpr = CCSprite::createWithSpriteFrameName("folderIcon_001.png");
|
auto foldersMenu = CCMenu::create();
|
||||||
m_openConfigDirBtnSpr = createGeodeButton(configFolderSpr, "");
|
foldersMenu->setContentSize({ 0, 30 });
|
||||||
m_openConfigDirBtnSpr->setScale(.6f);
|
foldersMenu->setAnchorPoint(ccp(1, 0));
|
||||||
m_openConfigDirBtnSpr->getIcon()->setScale(m_openConfigDirBtnSpr->getIcon()->getScale() * 1.4f);
|
foldersMenu->setLayout(RowLayout::create()
|
||||||
auto openConfigDirBtn = CCMenuItemSpriteExtra::create(
|
->setAxisReverse(true)
|
||||||
m_openConfigDirBtnSpr, this, menu_selector(ModSettingsPopup::onOpenConfigDirectory)
|
->setGap(5)
|
||||||
);
|
->setAutoGrowAxis(30)
|
||||||
m_buttonMenu->addChildAtPosition(openConfigDirBtn, Anchor::BottomRight, ccp(-50, 20));
|
->setGrowCrossAxis(true));
|
||||||
|
m_buttonMenu->addChildAtPosition(foldersMenu, Anchor::BottomRight, ccp(-5, 10));
|
||||||
|
|
||||||
auto settingFolderSpr = CCSprite::createWithSpriteFrameName("folderIcon_001.png");
|
auto createFolderButton = [&, this](auto subSprName, auto callback) {
|
||||||
auto settingFolderSprSub = CCSprite::createWithSpriteFrameName("settings.png"_spr);
|
auto folderSpr = CCSprite::createWithSpriteFrameName("folderIcon_001.png");
|
||||||
settingFolderSprSub->setColor(ccBLACK);
|
auto folderSprSub = CCSprite::createWithSpriteFrameName(subSprName);
|
||||||
settingFolderSprSub->setOpacity(155);
|
folderSprSub->setColor(ccBLACK);
|
||||||
settingFolderSprSub->setScale(.55f);
|
folderSprSub->setOpacity(155);
|
||||||
settingFolderSpr->addChildAtPosition(settingFolderSprSub, Anchor::Center, ccp(0, -3));
|
folderSprSub->setScale(.55f);
|
||||||
auto openDirBtnSpr = createGeodeButton(settingFolderSpr, "");
|
folderSpr->addChildAtPosition(folderSprSub, Anchor::Center, ccp(0, -3));
|
||||||
openDirBtnSpr->setScale(.6f);
|
auto buttonSpr = createGeodeButton(folderSpr, "");
|
||||||
openDirBtnSpr->getIcon()->setScale(openDirBtnSpr->getIcon()->getScale() * 1.4f);
|
buttonSpr->setScale(.6f);
|
||||||
auto openDirBtn = CCMenuItemSpriteExtra::create(
|
buttonSpr->getIcon()->setScale(buttonSpr->getIcon()->getScale() * 1.4f);
|
||||||
openDirBtnSpr, this, menu_selector(ModSettingsPopup::onOpenSaveDirectory)
|
auto folderBtn = CCMenuItemSpriteExtra::create(
|
||||||
|
buttonSpr, this, static_cast<SEL_MenuHandler>(callback)
|
||||||
);
|
);
|
||||||
m_buttonMenu->addChildAtPosition(openDirBtn, Anchor::BottomRight, ccp(-20, 20));
|
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) {
|
m_changeListener.bind([this](auto* ev) {
|
||||||
this->updateState(ev->getNode());
|
this->updateState(ev->getNode());
|
||||||
|
@ -224,7 +242,9 @@ void ModSettingsPopup::onOpenSaveDirectory(CCObject*) {
|
||||||
}
|
}
|
||||||
void ModSettingsPopup::onOpenConfigDirectory(CCObject*) {
|
void ModSettingsPopup::onOpenConfigDirectory(CCObject*) {
|
||||||
file::openFolder(m_mod->getConfigDir());
|
file::openFolder(m_mod->getConfigDir());
|
||||||
this->updateState();
|
}
|
||||||
|
void ModSettingsPopup::onOpenPersistentDirectory(CCObject*) {
|
||||||
|
file::openFolder(m_mod->getPersistentDir());
|
||||||
}
|
}
|
||||||
void ModSettingsPopup::onClearSearch(CCObject*) {
|
void ModSettingsPopup::onClearSearch(CCObject*) {
|
||||||
m_searchInput->setString("");
|
m_searchInput->setString("");
|
||||||
|
@ -239,12 +259,6 @@ void ModSettingsPopup::updateState(SettingNodeV3* invoker) {
|
||||||
m_restartBtn->setVisible(ModSettingsManager::from(m_mod)->restartRequired());
|
m_restartBtn->setVisible(ModSettingsManager::from(m_mod)->restartRequired());
|
||||||
m_applyMenu->updateLayout();
|
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 listPosBefore = m_list->m_contentLayer->getPositionY();
|
||||||
auto listHeightBefore = m_list->m_contentLayer->getContentHeight();
|
auto listHeightBefore = m_list->m_contentLayer->getContentHeight();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ protected:
|
||||||
CCMenuItemSpriteExtra* m_applyBtn;
|
CCMenuItemSpriteExtra* m_applyBtn;
|
||||||
CCMenuItemSpriteExtra* m_restartBtn;
|
CCMenuItemSpriteExtra* m_restartBtn;
|
||||||
ButtonSprite* m_applyBtnSpr;
|
ButtonSprite* m_applyBtnSpr;
|
||||||
IconButtonSprite* m_openConfigDirBtnSpr;
|
|
||||||
TextInput* m_searchInput;
|
TextInput* m_searchInput;
|
||||||
CCMenuItemSpriteExtra* m_searchClearBtn;
|
CCMenuItemSpriteExtra* m_searchClearBtn;
|
||||||
EventListener<EventFilter<SettingNodeValueChangeEventV3>> m_changeListener;
|
EventListener<EventFilter<SettingNodeValueChangeEventV3>> m_changeListener;
|
||||||
|
@ -30,6 +29,7 @@ protected:
|
||||||
void onResetAll(CCObject*);
|
void onResetAll(CCObject*);
|
||||||
void onOpenSaveDirectory(CCObject*);
|
void onOpenSaveDirectory(CCObject*);
|
||||||
void onOpenConfigDirectory(CCObject*);
|
void onOpenConfigDirectory(CCObject*);
|
||||||
|
void onOpenPersistentDirectory(CCObject*);
|
||||||
void onClearSearch(CCObject*);
|
void onClearSearch(CCObject*);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue