add openSettingsPopup overload that returns the created popup
Some checks failed
Build Binaries / Build Windows (push) Has been cancelled
Build Binaries / Build macOS (push) Has been cancelled
Build Binaries / Build Android (64-bit) (push) Has been cancelled
Build Binaries / Build Android (32-bit) (push) Has been cancelled
Build Binaries / Publish (push) Has been cancelled

This commit is contained in:
HJfod 2024-09-21 15:33:59 +03:00
parent 6270e1c73b
commit dc8d271ff1
4 changed files with 20 additions and 4 deletions

View file

@ -141,6 +141,16 @@ namespace geode {
* Open the settings popup for a mod (if it has any settings)
*/
GEODE_DLL void openSettingsPopup(Mod* mod);
/**
* Open the settings popup for a mod (if it has any settings)
* @param mod Mod the open the popup for
* @param disableGeodeTheme If false, the popup follows the user's chosen
* theme options. If true, the popup is always in the GD theme (not Geode's
* dark purple colors)
* @returns A pointer to the created Popup, or null if the mod has no
* settings
*/
GEODE_DLL Popup<Mod*>* openSettingsPopup(Mod* mod, bool disableGeodeTheme);
/**
* Create a default logo sprite
*/

View file

@ -159,9 +159,15 @@ void geode::openChangelogPopup(Mod* mod) {
}
void geode::openSettingsPopup(Mod* mod) {
openSettingsPopup(mod, true);
}
Popup<Mod*>* geode::openSettingsPopup(Mod* mod, bool disableGeodeTheme) {
if (mod->hasSettings()) {
ModSettingsPopup::create(mod)->show();
auto popup = ModSettingsPopup::create(mod, disableGeodeTheme);
popup->show();
return popup;
}
return nullptr;
}
class ModLogoSprite : public CCNode {

View file

@ -345,9 +345,9 @@ void ModSettingsPopup::onClose(CCObject* sender) {
GeodePopup::onClose(sender);
}
ModSettingsPopup* ModSettingsPopup::create(Mod* mod) {
ModSettingsPopup* ModSettingsPopup::create(Mod* mod, bool forceDisableTheme) {
auto ret = new ModSettingsPopup();
if (ret->init(440, 280, mod)) {
if (ret->init(440, 280, mod, GeodePopupStyle::Default, forceDisableTheme)) {
ret->autorelease();
return ret;
}

View file

@ -33,5 +33,5 @@ protected:
void onClearSearch(CCObject*);
public:
static ModSettingsPopup* create(Mod* mod);
static ModSettingsPopup* create(Mod* mod, bool forceDisableTheme = false);
};