diff --git a/loader/include/Geode/UI.hpp b/loader/include/Geode/UI.hpp index fc326ce6..2330064c 100644 --- a/loader/include/Geode/UI.hpp +++ b/loader/include/Geode/UI.hpp @@ -10,7 +10,6 @@ #include "ui/ListView.hpp" #include "ui/MDPopup.hpp" #include "ui/MDTextArea.hpp" -#include "ui/MenuItemSpriteExtra.hpp" #include "ui/Notification.hpp" #include "ui/Popup.hpp" #include "ui/SceneManager.hpp" diff --git a/loader/include/Geode/ui/MenuItemSpriteExtra.hpp b/loader/include/Geode/ui/MenuItemSprite.hpp similarity index 81% rename from loader/include/Geode/ui/MenuItemSpriteExtra.hpp rename to loader/include/Geode/ui/MenuItemSprite.hpp index 776519ed..113eb80d 100644 --- a/loader/include/Geode/ui/MenuItemSpriteExtra.hpp +++ b/loader/include/Geode/ui/MenuItemSprite.hpp @@ -6,20 +6,19 @@ #pragma warning(disable : 4275) namespace geode { - class GEODE_DLL MenuItemSpriteExtra : public cocos2d::CCMenuItemSprite { + class GEODE_DLL MenuItemSprite : public cocos2d::CCMenuItemSprite { protected: - bool m_scaleSprites; - MenuItemSpriteExtra(); - ~MenuItemSpriteExtra() override; + MenuItemSprite(); + ~MenuItemSprite() override; public: - static MenuItemSpriteExtra* create( + static MenuItemSprite* create( cocos2d::CCNode* normalSprite, cocos2d::CCNode* disabledSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback ); - static MenuItemSpriteExtra* create( + static MenuItemSprite* create( cocos2d::CCNode* normalSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback ); @@ -40,8 +39,6 @@ namespace geode { void selected() override; void unselected() override; - void setScaleSprites(bool scale); - void setImage(cocos2d::CCNode* image); void setNormalImage(cocos2d::CCNode* image) override; void setDisabledImage(cocos2d::CCNode* image) override; diff --git a/loader/include/Geode/ui/MenuItemToggle.hpp b/loader/include/Geode/ui/MenuItemToggle.hpp index 2e704c8a..6399773a 100644 --- a/loader/include/Geode/ui/MenuItemToggle.hpp +++ b/loader/include/Geode/ui/MenuItemToggle.hpp @@ -1,15 +1,15 @@ #pragma once #include -#include "MenuItemSpriteExtra.hpp" +#include "MenuItemSprite.hpp" #pragma warning(disable : 4275) namespace geode { class GEODE_DLL MenuItemToggle : public cocos2d::CCMenuItem { protected: - MenuItemSpriteExtra* m_offButton; - MenuItemSpriteExtra* m_onButton; + MenuItemSprite* m_offButton; + MenuItemSprite* m_onButton; bool m_toggled; MenuItemToggle(); @@ -26,10 +26,10 @@ namespace geode { cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback ); - void setOffButton(MenuItemSpriteExtra* button); - void setOnButton(MenuItemSpriteExtra* button); - MenuItemSpriteExtra* getOffButton() const; - MenuItemSpriteExtra* getOnButton() const; + void setOffButton(MenuItemSprite* button); + void setOnButton(MenuItemSprite* button); + MenuItemSprite* getOffButton() const; + MenuItemSprite* getOnButton() const; bool isToggled() const; void toggle(bool enabled); diff --git a/loader/src/hooks/MenuLayer.cpp b/loader/src/hooks/MenuLayer.cpp index 4bddc8f1..869d1bce 100644 --- a/loader/src/hooks/MenuLayer.cpp +++ b/loader/src/hooks/MenuLayer.cpp @@ -77,7 +77,7 @@ struct CustomMenuLayer : Modify { auto bottomMenu = static_cast(this->getChildByID("bottom-menu")); - auto btn = MenuItemSpriteExtra::create( + auto btn = CCMenuItemSpriteExtra::create( m_fields->m_geodeButton, this, static_cast(geodeBtnSelector) ); diff --git a/loader/src/ui/internal/info/ModInfoPopup.cpp b/loader/src/ui/internal/info/ModInfoPopup.cpp index d1c5c230..945e5ec4 100644 --- a/loader/src/ui/internal/info/ModInfoPopup.cpp +++ b/loader/src/ui/internal/info/ModInfoPopup.cpp @@ -151,13 +151,13 @@ bool ModInfoPopup::init(ModMetadata const& metadata, ModListLayer* list) { auto infoSpr = CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png"); infoSpr->setScale(.85f); - m_infoBtn = MenuItemSpriteExtra::create(infoSpr, this, menu_selector(ModInfoPopup::onInfo)); + m_infoBtn = CCMenuItemSpriteExtra::create(infoSpr, this, menu_selector(ModInfoPopup::onInfo)); m_infoBtn->setPosition(LAYER_SIZE.width / 2 - 25.f, LAYER_SIZE.height / 2 - 25.f); m_buttonMenu->addChild(m_infoBtn); // repo button if (metadata.getRepository()) { - auto repoBtn = MenuItemSpriteExtra::create( + auto repoBtn = CCMenuItemSpriteExtra::create( CCSprite::createWithSpriteFrameName("github.png"_spr), this, menu_selector(ModInfoPopup::onRepository) @@ -168,7 +168,7 @@ bool ModInfoPopup::init(ModMetadata const& metadata, ModListLayer* list) { // support button if (metadata.getSupportInfo()) { - auto supportBtn = MenuItemSpriteExtra::create( + auto supportBtn = CCMenuItemSpriteExtra::create( CCSprite::createWithSpriteFrameName("gift.png"_spr), this, menu_selector(ModInfoPopup::onSupport) @@ -181,7 +181,7 @@ bool ModInfoPopup::init(ModMetadata const& metadata, ModListLayer* list) { closeSpr->setScale(.8f); auto closeBtn = - MenuItemSpriteExtra::create(closeSpr, this, menu_selector(ModInfoPopup::onClose)); + CCMenuItemSpriteExtra::create(closeSpr, this, menu_selector(ModInfoPopup::onClose)); closeBtn->setPosition(-LAYER_SIZE.width / 2 + 3.f, LAYER_SIZE.height / 2 - 3.f); m_buttonMenu->addChild(closeBtn); @@ -399,7 +399,7 @@ bool LocalModInfoPopup::init(Mod* mod, ModListLayer* list) { settingsSpr->setScale(.65f); auto settingsBtn = - MenuItemSpriteExtra::create(settingsSpr, this, menu_selector(LocalModInfoPopup::onSettings)); + CCMenuItemSpriteExtra::create(settingsSpr, this, menu_selector(LocalModInfoPopup::onSettings)); settingsBtn->setPosition(-LAYER_SIZE.width / 2 + 25.f, -LAYER_SIZE.height / 2 + 25.f); m_buttonMenu->addChild(settingsBtn); @@ -410,7 +410,7 @@ bool LocalModInfoPopup::init(Mod* mod, ModListLayer* list) { ); configSpr->setScale(.65f); - auto configBtn = MenuItemSpriteExtra::create( + auto configBtn = CCMenuItemSpriteExtra::create( configSpr, this, menu_selector(LocalModInfoPopup::onOpenConfigDir) ); configBtn->setPosition(-LAYER_SIZE.width / 2 + 65.f, -LAYER_SIZE.height / 2 + 25.f); @@ -451,7 +451,7 @@ bool LocalModInfoPopup::init(Mod* mod, ModListLayer* list) { ButtonSprite::create("Uninstall", "bigFont.fnt", "GJ_button_05.png", .6f); uninstallBtnSpr->setScale(.6f); - auto uninstallBtn = MenuItemSpriteExtra::create( + auto uninstallBtn = CCMenuItemSpriteExtra::create( uninstallBtnSpr, this, menu_selector(LocalModInfoPopup::onUninstall) ); uninstallBtn->setPosition(-85.f, 75.f); @@ -467,7 +467,7 @@ bool LocalModInfoPopup::init(Mod* mod, ModListLayer* list) { ); m_installBtnSpr->setScale(.6f); - m_installBtn = MenuItemSpriteExtra::create(m_installBtnSpr, this, menu_selector(LocalModInfoPopup::onUpdate)); + m_installBtn = CCMenuItemSpriteExtra::create(m_installBtnSpr, this, menu_selector(LocalModInfoPopup::onUpdate)); m_installBtn->setPosition(-8.0f, 75.f); m_buttonMenu->addChild(m_installBtn); @@ -536,7 +536,7 @@ bool LocalModInfoPopup::init(Mod* mod, ModListLayer* list) { ); issuesBtnSpr->setScale(.75f); - auto issuesBtn = MenuItemSpriteExtra::create( + auto issuesBtn = CCMenuItemSpriteExtra::create( issuesBtnSpr, this, menu_selector(LocalModInfoPopup::onIssues) ); issuesBtn->setPosition(0.f, -LAYER_SIZE.height / 2 + 25.f); @@ -726,7 +726,7 @@ bool IndexItemInfoPopup::init(IndexItemHandle item, ModListLayer* list) { ); m_installBtnSpr->setScale(.6f); - m_installBtn = MenuItemSpriteExtra::create( + m_installBtn = CCMenuItemSpriteExtra::create( m_installBtnSpr, this, menu_selector(IndexItemInfoPopup::onInstall) ); m_installBtn->setPosition(-143.0f, 75.f); diff --git a/loader/src/ui/internal/info/ModInfoPopup.hpp b/loader/src/ui/internal/info/ModInfoPopup.hpp index e9ab045a..808cd918 100644 --- a/loader/src/ui/internal/info/ModInfoPopup.hpp +++ b/loader/src/ui/internal/info/ModInfoPopup.hpp @@ -6,7 +6,6 @@ #include #include #include -#include using namespace geode::prelude; @@ -32,8 +31,8 @@ protected: ModListLayer* m_layer = nullptr; DownloadStatusNode* m_installStatus = nullptr; IconButtonSprite* m_installBtnSpr; - MenuItemSpriteExtra* m_installBtn; - MenuItemSpriteExtra* m_infoBtn; + CCMenuItemSpriteExtra* m_installBtn; + CCMenuItemSpriteExtra* m_infoBtn; CCLabelBMFont* m_latestVersionLabel = nullptr; CCLabelBMFont* m_minorVersionLabel = nullptr; MDTextArea* m_detailsArea; diff --git a/loader/src/ui/internal/list/InstallListCell.cpp b/loader/src/ui/internal/list/InstallListCell.cpp index ce309181..352d8aaf 100644 --- a/loader/src/ui/internal/list/InstallListCell.cpp +++ b/loader/src/ui/internal/list/InstallListCell.cpp @@ -1,6 +1,7 @@ #include "InstallListCell.hpp" #include "InstallListPopup.hpp" #include +#include #include #include #include @@ -212,7 +213,7 @@ bool IndexItemInstallListCell::init( versionSelectSpr->setScale(.7f); auto versionSelectBtn = - MenuItemSpriteExtra::create(versionSelectSpr, this, menu_selector(IndexItemInstallListCell::onSelectVersion)); + CCMenuItemSpriteExtra::create(versionSelectSpr, this, menu_selector(IndexItemInstallListCell::onSelectVersion)); versionSelectBtn->setAnchorPoint({1.f, .5f}); versionSelectBtn->setPosition({m_toggle->getPositionX() - m_toggle->getContentSize().width - 5, m_height / 2}); m_menu->addChild(versionSelectBtn); @@ -371,7 +372,7 @@ bool SelectVersionCell::init(IndexItemHandle item, SelectVersionPopup* versionPo ); selectSpr->setScale(.6f); - auto selectBtn = MenuItemSpriteExtra::create( + auto selectBtn = CCMenuItemSpriteExtra::create( selectSpr, this, menu_selector(SelectVersionCell::onSelected) ); selectBtn->setAnchorPoint({1.f, .5f}); diff --git a/loader/src/ui/internal/list/InstallListPopup.cpp b/loader/src/ui/internal/list/InstallListPopup.cpp index 2acbb670..e561ca9b 100644 --- a/loader/src/ui/internal/list/InstallListPopup.cpp +++ b/loader/src/ui/internal/list/InstallListPopup.cpp @@ -22,7 +22,7 @@ bool InstallListPopup::setup(IndexItemHandle item, MiniFunctionsetScale(.6f); - auto installBtn = MenuItemSpriteExtra::create( + auto installBtn = CCMenuItemSpriteExtra::create( installBtnSpr, this, menu_selector(InstallListPopup::onInstall) diff --git a/loader/src/ui/internal/list/ModListCell.cpp b/loader/src/ui/internal/list/ModListCell.cpp index b1614011..061e6dcb 100644 --- a/loader/src/ui/internal/list/ModListCell.cpp +++ b/loader/src/ui/internal/list/ModListCell.cpp @@ -2,6 +2,7 @@ #include "ModListLayer.hpp" #include "../info/ModInfoPopup.hpp" #include +#include #include #include #include @@ -143,7 +144,7 @@ void ModListCell::setupInfo( creatorLabel->setColor({ 163, 163, 163 }); } - m_developerBtn = MenuItemSpriteExtra::create( + m_developerBtn = CCMenuItemSpriteExtra::create( creatorLabel, this, menu_selector(ModListCell::onViewDev) ); m_columnMenu->addChild(m_developerBtn); @@ -291,7 +292,7 @@ bool ModCell::init( exMark->setScale(.5f); m_unresolvedExMark = - MenuItemSpriteExtra::create(exMark, this, menu_selector(ModCell::onUnresolvedInfo)); + CCMenuItemSpriteExtra::create(exMark, this, menu_selector(ModCell::onUnresolvedInfo)); m_unresolvedExMark->setVisible(false); m_menu->addChild(m_unresolvedExMark); @@ -299,7 +300,7 @@ bool ModCell::init( auto restartSpr = ButtonSprite::create("Restart", "bigFont.fnt", "GJ_button_03.png", .8f); restartSpr->setScale(.65f); - auto restartBtn = MenuItemSpriteExtra::create(restartSpr, this, menu_selector(ModCell::onRestart)); + auto restartBtn = CCMenuItemSpriteExtra::create(restartSpr, this, menu_selector(ModCell::onRestart)); m_menu->addChild(restartBtn); } else { @@ -334,7 +335,7 @@ bool ModCell::init( } } - auto viewBtn = MenuItemSpriteExtra::create(viewSpr, this, menu_selector(ModCell::onInfo)); + auto viewBtn = CCMenuItemSpriteExtra::create(viewSpr, this, menu_selector(ModCell::onInfo)); m_menu->addChild(viewBtn); } @@ -394,7 +395,7 @@ bool IndexItemCell::init( auto restartSpr = ButtonSprite::create("Restart", "bigFont.fnt", "GJ_button_03.png", .8f); restartSpr->setScale(.65f); - auto restartBtn = MenuItemSpriteExtra::create(restartSpr, this, menu_selector(IndexItemCell::onRestart)); + auto restartBtn = CCMenuItemSpriteExtra::create(restartSpr, this, menu_selector(IndexItemCell::onRestart)); m_menu->addChild(restartBtn); } else { @@ -402,7 +403,7 @@ bool IndexItemCell::init( viewSpr->setScale(.65f); auto viewBtn = - MenuItemSpriteExtra::create(viewSpr, this, menu_selector(IndexItemCell::onInfo)); + CCMenuItemSpriteExtra::create(viewSpr, this, menu_selector(IndexItemCell::onInfo)); m_menu->addChild(viewBtn); } @@ -516,7 +517,7 @@ bool InvalidGeodeFileCell::init( whySpr->setScale(.65f); auto viewBtn = - MenuItemSpriteExtra::create(whySpr, this, menu_selector(InvalidGeodeFileCell::onInfo)); + CCMenuItemSpriteExtra::create(whySpr, this, menu_selector(InvalidGeodeFileCell::onInfo)); menu->addChild(viewBtn); return true; @@ -634,7 +635,7 @@ bool ProblemsCell::init( viewSpr->setScale(.65f); auto viewBtn = - MenuItemSpriteExtra::create(viewSpr, this, menu_selector(ProblemsCell::onInfo)); + CCMenuItemSpriteExtra::create(viewSpr, this, menu_selector(ProblemsCell::onInfo)); m_menu->addChild(viewBtn); m_menu->updateLayout(); diff --git a/loader/src/ui/internal/list/ModListCell.hpp b/loader/src/ui/internal/list/ModListCell.hpp index 446f5b06..28e253d9 100644 --- a/loader/src/ui/internal/list/ModListCell.hpp +++ b/loader/src/ui/internal/list/ModListCell.hpp @@ -5,7 +5,6 @@ #include #include #include -#include using namespace geode::prelude; @@ -23,8 +22,8 @@ protected: CCMenu* m_menu; CCLabelBMFont* m_description; CCMenuItemToggler* m_enableToggle = nullptr; - MenuItemSpriteExtra* m_unresolvedExMark; - MenuItemSpriteExtra* m_developerBtn; + CCMenuItemSpriteExtra* m_unresolvedExMark; + CCMenuItemSpriteExtra* m_developerBtn; SpacerNode* m_spacer = nullptr; CCMenu* m_columnMenu = nullptr; CCMenu* m_labelMenu = nullptr; diff --git a/loader/src/ui/internal/list/ModListLayer.cpp b/loader/src/ui/internal/list/ModListLayer.cpp index 7f44d9ae..e950a521 100644 --- a/loader/src/ui/internal/list/ModListLayer.cpp +++ b/loader/src/ui/internal/list/ModListLayer.cpp @@ -16,6 +16,8 @@ #include #include +#include + #define FTS_FUZZY_MATCH_IMPLEMENTATION #include @@ -259,7 +261,7 @@ bool ModListLayer::init() { m_topMenu = CCMenu::create(); // add back button - auto backBtn = MenuItemSpriteExtra::create( + auto backBtn = MenuItemSprite::create( CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png"), this, menu_selector(ModListLayer::onExit) ); @@ -270,7 +272,7 @@ bool ModListLayer::init() { auto reloadSpr = CCSprite::createWithSpriteFrameName("GJ_updateBtn_001.png"); reloadSpr->setScale(.8f); auto reloadBtn = - MenuItemSpriteExtra::create(reloadSpr, this, menu_selector(ModListLayer::onReload)); + CCMenuItemSpriteExtra::create(reloadSpr, this, menu_selector(ModListLayer::onReload)); reloadBtn->setPosition(-winSize.width / 2 + 30.0f, -winSize.height / 2 + 30.0f); m_menu->addChild(reloadBtn); @@ -279,7 +281,7 @@ bool ModListLayer::init() { "gj_folderBtn_001.png", .7f, CircleBaseColor::Green, CircleBaseSize::Small ); auto openBtn = - MenuItemSpriteExtra::create(openSpr, this, menu_selector(ModListLayer::onOpenFolder)); + CCMenuItemSpriteExtra::create(openSpr, this, menu_selector(ModListLayer::onOpenFolder)); openBtn->setPosition(-winSize.width / 2 + 30.0f, -winSize.height / 2 + 80.0f); m_menu->addChild(openBtn); @@ -394,7 +396,7 @@ void ModListLayer::createSearchControl() { filterSpr->setScale(.7f); m_filterBtn = - MenuItemSpriteExtra::create(filterSpr, this, menu_selector(ModListLayer::onFilters)); + CCMenuItemSpriteExtra::create(filterSpr, this, menu_selector(ModListLayer::onFilters)); m_filterBtn->setPosition(-10.f, 0.f); menu->addChild(m_filterBtn); @@ -402,14 +404,14 @@ void ModListLayer::createSearchControl() { auto searchSpr = CCSprite::createWithSpriteFrameName("gj_findBtn_001.png"); searchSpr->setScale(.7f); - m_searchBtn = MenuItemSpriteExtra::create(searchSpr, this, nullptr); + m_searchBtn = CCMenuItemSpriteExtra::create(searchSpr, this, nullptr); m_searchBtn->setPosition(-35.f, 0.f); menu->addChild(m_searchBtn); auto searchClearSpr = CCSprite::createWithSpriteFrameName("gj_findBtnOff_001.png"); searchClearSpr->setScale(.7f); - m_searchClearBtn = MenuItemSpriteExtra::create( + m_searchClearBtn = CCMenuItemSpriteExtra::create( searchClearSpr, this, menu_selector(ModListLayer::onResetSearch) ); m_searchClearBtn->setPosition(-35.f, 0.f); @@ -561,7 +563,7 @@ void ModListLayer::reloadList(bool keepScroll, std::optional const if (!m_checkForUpdatesBtn) { auto checkSpr = ButtonSprite::create("Check for Updates"); checkSpr->setScale(.7f); - m_checkForUpdatesBtn = MenuItemSpriteExtra::create( + m_checkForUpdatesBtn = CCMenuItemSpriteExtra::create( checkSpr, this, menu_selector(ModListLayer::onCheckForUpdates) ); m_checkForUpdatesBtn->setPosition(0, -winSize.height / 2 + 40.f); diff --git a/loader/src/ui/internal/list/ModListLayer.hpp b/loader/src/ui/internal/list/ModListLayer.hpp index f9a3780a..0afa2839 100644 --- a/loader/src/ui/internal/list/ModListLayer.hpp +++ b/loader/src/ui/internal/list/ModListLayer.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include using namespace geode::prelude; @@ -55,13 +54,13 @@ protected: CCMenuItemToggler* m_installedTabBtn; CCMenuItemToggler* m_downloadTabBtn; CCMenuItemToggler* m_featuredTabBtn; - MenuItemSpriteExtra* m_searchBtn; - MenuItemSpriteExtra* m_searchClearBtn; - MenuItemSpriteExtra* m_checkForUpdatesBtn = nullptr; + CCMenuItemSpriteExtra* m_searchBtn; + CCMenuItemSpriteExtra* m_searchClearBtn; + CCMenuItemSpriteExtra* m_checkForUpdatesBtn = nullptr; CCNode* m_searchBG = nullptr; CCTextInputNode* m_searchInput = nullptr; LoadingCircle* m_loadingCircle = nullptr; - MenuItemSpriteExtra* m_filterBtn; + CCMenuItemSpriteExtra* m_filterBtn; ModListQuery m_query; ModListDisplay m_display = ModListDisplay::Concise; EventListener m_indexListener; diff --git a/loader/src/ui/internal/list/ProblemsListCell.cpp b/loader/src/ui/internal/list/ProblemsListCell.cpp index 4b545b70..faa2086b 100644 --- a/loader/src/ui/internal/list/ProblemsListCell.cpp +++ b/loader/src/ui/internal/list/ProblemsListCell.cpp @@ -1,7 +1,7 @@ #include "ProblemsListCell.hpp" #include "ProblemsListPopup.hpp" #include -#include +#include #include #include #include @@ -115,7 +115,7 @@ bool ProblemsListCell::init(LoadProblem problem, ProblemsListPopup* list, CCSize viewSpr->setScale(.65f); auto viewBtn = - MenuItemSpriteExtra::create(viewSpr, this, menu_selector(ProblemsListCell::onMore)); + CCMenuItemSpriteExtra::create(viewSpr, this, menu_selector(ProblemsListCell::onMore)); m_menu->addChild(viewBtn); } diff --git a/loader/src/ui/internal/settings/GeodeSettingNode.cpp b/loader/src/ui/internal/settings/GeodeSettingNode.cpp index 4f603e5d..28a37e1e 100644 --- a/loader/src/ui/internal/settings/GeodeSettingNode.cpp +++ b/loader/src/ui/internal/settings/GeodeSettingNode.cpp @@ -74,7 +74,7 @@ Slider* createSlider(C* node, GeodeSettingValue* setting, float width) { template std::pair< - MenuItemSpriteExtra*, MenuItemSpriteExtra* + CCMenuItemSpriteExtra*, CCMenuItemSpriteExtra* > createArrows(C* node, GeodeSettingValue* setting, float width, bool big) { auto yPos = setting->castDefinition().controls.slider ? 5.f : 0.f; auto decArrowSpr = CCSprite::createWithSpriteFrameName( @@ -83,7 +83,7 @@ std::pair< decArrowSpr->setFlipX(true); decArrowSpr->setScale(.3f); - auto decArrow = MenuItemSpriteExtra::create( + auto decArrow = CCMenuItemSpriteExtra::create( decArrowSpr, node, menu_selector(C::onArrow) ); decArrow->setPosition(-width / 2 + (big ? 65.f : 80.f), yPos); @@ -97,7 +97,7 @@ std::pair< ); incArrowSpr->setScale(.3f); - auto incArrow = MenuItemSpriteExtra::create( + auto incArrow = CCMenuItemSpriteExtra::create( incArrowSpr, node, menu_selector(C::onArrow) ); incArrow->setTag(big ? @@ -377,7 +377,7 @@ bool FileSettingNode::setup(FileSettingValue* setting, float width) { auto fileBtnSpr = CCSprite::createWithSpriteFrameName("gj_folderBtn_001.png"); fileBtnSpr->setScale(.5f); - auto fileBtn = MenuItemSpriteExtra::create( + auto fileBtn = CCMenuItemSpriteExtra::create( fileBtnSpr, this, menu_selector(FileSettingNode::onPickFile) ); fileBtn->setPosition(.0f, .0f); @@ -410,7 +410,7 @@ bool ColorSettingNode::setup(ColorSettingValue* setting, float width) { m_colorSpr->setColor(m_uncommittedValue); m_colorSpr->setScale(.65f); - auto button = MenuItemSpriteExtra::create( + auto button = CCMenuItemSpriteExtra::create( m_colorSpr, this, menu_selector(ColorSettingNode::onSelectColor) ); button->setPositionX(-10.f); @@ -445,7 +445,7 @@ bool ColorAlphaSettingNode::setup(ColorAlphaSettingValue* setting, float width) m_colorSpr->updateOpacity(m_uncommittedValue.a / 255.f); m_colorSpr->setScale(.65f); - auto button = MenuItemSpriteExtra::create( + auto button = CCMenuItemSpriteExtra::create( m_colorSpr, this, menu_selector(ColorAlphaSettingNode::onSelectColor) ); button->setPositionX(-10.f); diff --git a/loader/src/ui/internal/settings/GeodeSettingNode.hpp b/loader/src/ui/internal/settings/GeodeSettingNode.hpp index 2a320b53..c32a6066 100644 --- a/loader/src/ui/internal/settings/GeodeSettingNode.hpp +++ b/loader/src/ui/internal/settings/GeodeSettingNode.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -40,7 +40,7 @@ protected: CCMenu* m_menu; CCLabelBMFont* m_nameLabel; CCLabelBMFont* m_errorLabel; - MenuItemSpriteExtra* m_resetBtn; + CCMenuItemSpriteExtra* m_resetBtn; bool init(GeodeSettingValue* setting, float width) { if (!SettingNode::init(setting)) @@ -81,7 +81,7 @@ protected: auto infoSpr = CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png"); infoSpr->setScale(.6f); - auto infoBtn = MenuItemSpriteExtra::create( + auto infoBtn = CCMenuItemSpriteExtra::create( infoSpr, this, menu_selector(GeodeSettingNode::onDescription) ); infoBtn->setPosition( @@ -97,7 +97,7 @@ protected: auto resetBtnSpr = CCSprite::createWithSpriteFrameName("reset-gold.png"_spr); resetBtnSpr->setScale(.5f); - m_resetBtn = MenuItemSpriteExtra::create( + m_resetBtn = CCMenuItemSpriteExtra::create( resetBtnSpr, this, menu_selector(GeodeSettingNode::onReset) ); m_resetBtn->setPosition( @@ -210,10 +210,10 @@ protected: InputNode* m_input = nullptr; CCLabelBMFont* m_label = nullptr; Slider* m_slider = nullptr; - MenuItemSpriteExtra* m_decArrow = nullptr; - MenuItemSpriteExtra* m_incArrow = nullptr; - MenuItemSpriteExtra* m_bigDecArrow = nullptr; - MenuItemSpriteExtra* m_bigIncArrow = nullptr; + CCMenuItemSpriteExtra* m_decArrow = nullptr; + CCMenuItemSpriteExtra* m_incArrow = nullptr; + CCMenuItemSpriteExtra* m_bigDecArrow = nullptr; + CCMenuItemSpriteExtra* m_bigIncArrow = nullptr; void valueChanged(bool updateText) override; void textChanged(CCTextInputNode* input) override; @@ -239,10 +239,10 @@ protected: InputNode* m_input = nullptr; CCLabelBMFont* m_label = nullptr; Slider* m_slider = nullptr; - MenuItemSpriteExtra* m_decArrow = nullptr; - MenuItemSpriteExtra* m_incArrow = nullptr; - MenuItemSpriteExtra* m_bigDecArrow = nullptr; - MenuItemSpriteExtra* m_bigIncArrow = nullptr; + CCMenuItemSpriteExtra* m_decArrow = nullptr; + CCMenuItemSpriteExtra* m_incArrow = nullptr; + CCMenuItemSpriteExtra* m_bigDecArrow = nullptr; + CCMenuItemSpriteExtra* m_bigIncArrow = nullptr; void valueChanged(bool updateText) override; void textChanged(CCTextInputNode* input) override; diff --git a/loader/src/ui/internal/settings/ModSettingsPopup.cpp b/loader/src/ui/internal/settings/ModSettingsPopup.cpp index 369041a1..60f4b6f6 100644 --- a/loader/src/ui/internal/settings/ModSettingsPopup.cpp +++ b/loader/src/ui/internal/settings/ModSettingsPopup.cpp @@ -90,7 +90,7 @@ bool ModSettingsPopup::setup(Mod* mod) { m_applyBtnSpr = ButtonSprite::create("Apply", "goldFont.fnt", "GJ_button_01.png", .7f); m_applyBtnSpr->setScale(.7f); - m_applyBtn = MenuItemSpriteExtra::create( + m_applyBtn = CCMenuItemSpriteExtra::create( m_applyBtnSpr, this, menu_selector(ModSettingsPopup::onApply) ); m_applyBtn->setPosition(.0f, -m_size.height / 2 + 20.f); @@ -99,7 +99,7 @@ bool ModSettingsPopup::setup(Mod* mod) { auto resetBtnSpr = ButtonSprite::create("Reset All", "goldFont.fnt", "GJ_button_05.png", .7f); resetBtnSpr->setScale(.7f); - auto resetBtn = MenuItemSpriteExtra::create( + auto resetBtn = CCMenuItemSpriteExtra::create( resetBtnSpr, this, menu_selector(ModSettingsPopup::onResetAll) ); resetBtn->setPosition(-m_size.width / 2 + 45.f, -m_size.height / 2 + 20.f); @@ -109,7 +109,7 @@ bool ModSettingsPopup::setup(Mod* mod) { ButtonSprite::create("Open Folder", "goldFont.fnt", "GJ_button_05.png", .7f); openDirBtnSpr->setScale(.7f); - auto openDirBtn = MenuItemSpriteExtra::create( + auto openDirBtn = CCMenuItemSpriteExtra::create( openDirBtnSpr, this, menu_selector(ModSettingsPopup::onOpenSaveDirectory) ); openDirBtn->setPosition(m_size.width / 2 - 53.f, -m_size.height / 2 + 20.f); diff --git a/loader/src/ui/internal/settings/ModSettingsPopup.hpp b/loader/src/ui/internal/settings/ModSettingsPopup.hpp index d861e241..834214d5 100644 --- a/loader/src/ui/internal/settings/ModSettingsPopup.hpp +++ b/loader/src/ui/internal/settings/ModSettingsPopup.hpp @@ -10,7 +10,7 @@ class ModSettingsPopup : public Popup, public SettingNodeDelegate { protected: Mod* m_mod; std::vector m_settings; - MenuItemSpriteExtra* m_applyBtn; + CCMenuItemSpriteExtra* m_applyBtn; ButtonSprite* m_applyBtnSpr; void settingValueChanged(SettingNode*) override; diff --git a/loader/src/ui/nodes/ColorPickPopup.cpp b/loader/src/ui/nodes/ColorPickPopup.cpp index db7b6a10..0fafb50f 100644 --- a/loader/src/ui/nodes/ColorPickPopup.cpp +++ b/loader/src/ui/nodes/ColorPickPopup.cpp @@ -157,7 +157,7 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) { okBtnSpr->setScale(.7f); auto okBtn = - MenuItemSpriteExtra::create(okBtnSpr, this, menu_selector(ColorPickPopup::onClose)); + CCMenuItemSpriteExtra::create(okBtnSpr, this, menu_selector(ColorPickPopup::onClose)); okBtn->setPosition(.0f, -m_size.height / 2 + 20.f); m_buttonMenu->addChild(okBtn); diff --git a/loader/src/ui/nodes/MDPopup.cpp b/loader/src/ui/nodes/MDPopup.cpp index 39d5153e..2f0929da 100644 --- a/loader/src/ui/nodes/MDPopup.cpp +++ b/loader/src/ui/nodes/MDPopup.cpp @@ -24,14 +24,14 @@ bool MDPopup::setup( auto btnSpr = ButtonSprite::create(btn1Text); - auto btn = MenuItemSpriteExtra::create(btnSpr, this, menu_selector(MDPopup::onBtn)); + auto btn = CCMenuItemSpriteExtra::create(btnSpr, this, menu_selector(MDPopup::onBtn)); btn->setTag(0); m_buttonMenu->addChild(btn); if (btn2Text) { auto btn2Spr = ButtonSprite::create(btn2Text); - auto btn2 = MenuItemSpriteExtra::create(btn2Spr, this, menu_selector(MDPopup::onBtn)); + auto btn2 = CCMenuItemSpriteExtra::create(btn2Spr, this, menu_selector(MDPopup::onBtn)); btn2->setTag(1); m_buttonMenu->addChild(btn2); diff --git a/loader/src/ui/nodes/MenuItemSpriteExtra.cpp b/loader/src/ui/nodes/MenuItemSprite.cpp similarity index 58% rename from loader/src/ui/nodes/MenuItemSpriteExtra.cpp rename to loader/src/ui/nodes/MenuItemSprite.cpp index 64a71e64..cb6ec2a2 100644 --- a/loader/src/ui/nodes/MenuItemSpriteExtra.cpp +++ b/loader/src/ui/nodes/MenuItemSprite.cpp @@ -1,19 +1,19 @@ -#include +#include using namespace geode::prelude; -MenuItemSpriteExtra* MenuItemSpriteExtra::create( +MenuItemSprite* MenuItemSprite::create( cocos2d::CCNode* normalSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback ) { - return MenuItemSpriteExtra::create(normalSprite, nullptr, target, callback); + return MenuItemSprite::create(normalSprite, nullptr, target, callback); } -MenuItemSpriteExtra* MenuItemSpriteExtra::create( +MenuItemSprite* MenuItemSprite::create( cocos2d::CCNode* normalSprite, cocos2d::CCNode* disabledSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback ) { - auto ret = new MenuItemSpriteExtra(); + auto ret = new MenuItemSprite(); if (ret && ret->init(normalSprite, disabledSprite, target, callback)) { ret->autorelease(); return ret; @@ -22,12 +22,12 @@ MenuItemSpriteExtra* MenuItemSpriteExtra::create( return nullptr; } -MenuItemSpriteExtra::MenuItemSpriteExtra() : m_scaleSprites(false) {} +MenuItemSprite::MenuItemSprite() {} -MenuItemSpriteExtra::~MenuItemSpriteExtra() { +MenuItemSprite::~MenuItemSprite() { } -void MenuItemSpriteExtra::setImage(cocos2d::CCNode* image) { +void MenuItemSprite::setImage(cocos2d::CCNode* image) { if (image) { image->setAnchorPoint({ 0.5f, 0.5f }); image->setPosition(image->getContentSize() / 2); @@ -35,20 +35,20 @@ void MenuItemSpriteExtra::setImage(cocos2d::CCNode* image) { } // why are the members private like what -void MenuItemSpriteExtra::setNormalImage(cocos2d::CCNode* image) { +void MenuItemSprite::setNormalImage(cocos2d::CCNode* image) { CCMenuItemSprite::setNormalImage(image); this->setImage(image); } -void MenuItemSpriteExtra::setDisabledImage(cocos2d::CCNode* image) { +void MenuItemSprite::setDisabledImage(cocos2d::CCNode* image) { CCMenuItemSprite::setDisabledImage(image); this->setImage(image); } -void MenuItemSpriteExtra::setSelectedImage(cocos2d::CCNode* image) { +void MenuItemSprite::setSelectedImage(cocos2d::CCNode* image) { CCMenuItemSprite::setSelectedImage(image); this->setImage(image); } -bool MenuItemSpriteExtra::init( +bool MenuItemSprite::init( cocos2d::CCNode* normalSprite, cocos2d::CCNode* disabledSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback ) { @@ -67,41 +67,32 @@ bool MenuItemSpriteExtra::init( return true; } -void MenuItemSpriteExtra::runActionOnSprite(cocos2d::CCNode* sprite, cocos2d::CCAction* generator) { +void MenuItemSprite::runActionOnSprite(cocos2d::CCNode* sprite, cocos2d::CCAction* generator) { if (sprite) { sprite->stopAllActions(); if (generator) sprite->runAction(generator); } } -void MenuItemSpriteExtra::runActionOnSprites(MiniFunction generator) { - if (m_scaleSprites) { - this->runActionOnSprite(this->getNormalImage(), generator()); - this->runActionOnSprite(this->getDisabledImage(), generator()); - this->runActionOnSprite(this->getSelectedImage(), generator()); - } - else { - if (auto action = generator()) this->runAction(action); - } +void MenuItemSprite::runActionOnSprites(MiniFunction generator) { + this->runActionOnSprite(this->getNormalImage(), generator()); + this->runActionOnSprite(this->getDisabledImage(), generator()); + this->runActionOnSprite(this->getSelectedImage(), generator()); } -void MenuItemSpriteExtra::activate() { +void MenuItemSprite::activate() { this->runActionOnSprites(m_activateAction); CCMenuItem::activate(); } -void MenuItemSpriteExtra::selected() { +void MenuItemSprite::selected() { if (!m_bEnabled) return; CCMenuItem::selected(); this->runActionOnSprites(m_selectedAction); } -void MenuItemSpriteExtra::unselected() { +void MenuItemSprite::unselected() { if (!m_bEnabled) return; CCMenuItem::unselected(); this->runActionOnSprites(m_unselectedAction); -} - -void MenuItemSpriteExtra::setScaleSprites(bool scale) { - m_scaleSprites = scale; } \ No newline at end of file diff --git a/loader/test/dependency/main.cpp b/loader/test/dependency/main.cpp index 4a2713b6..2f6bd35d 100644 --- a/loader/test/dependency/main.cpp +++ b/loader/test/dependency/main.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include "main.hpp" @@ -92,7 +92,7 @@ protected: } else { btnSpr->setColor({ 200, 200, 200 }); } - auto btn = MenuItemSpriteExtra::create( + auto btn = CCMenuItemSpriteExtra::create( btnSpr, this, menu_selector(MySettingNode::onSelect) ); btn->setTag(static_cast(icon)); @@ -113,7 +113,7 @@ protected: } m_currentIcon = static_cast(sender->getTag()); static_cast( - static_cast(sender)->getNormalImage() + static_cast(sender)->getNormalImage() )->setColor({ 0, 255, 0 }); this->dispatchChanged(); }