add gd-style colors option

This commit is contained in:
HJfod 2024-04-29 19:39:02 +03:00
parent 7ed58b8896
commit afa57371ec
15 changed files with 191 additions and 68 deletions

View file

@ -186,6 +186,7 @@ namespace geode {
* Set an offset to the top sprite
*/
void setTopOffset(cocos2d::CCPoint const& offset);
void setTopRelativeScale(float scale);
cocos2d::CCNode* getTopNode() const;
};

View file

@ -82,6 +82,12 @@
"max": 100,
"name": "Server Cache Size Limit",
"description": "Limits the size of the cache used for loading mods. Higher values result in higher memory usage."
},
"enable-geode-theme": {
"type": "bool",
"default": true,
"name": "Enable Geode-Themed Colors",
"description": "When enabled, the Geode menu has a <ca>Geode-themed color scheme</c>. <cy>This does not affect any other menus!</c>"
}
},
"issues": {

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View file

@ -1,6 +1,7 @@
#include "GeodeStyle.hpp"
#include <Geode/utils/cocos.hpp>
#include <Geode/utils/ColorProvider.hpp>
#include <Geode/loader/SettingEvent.hpp>
$execute {
// todo: these names should probably be shorter so they fit in SSO...
@ -14,6 +15,7 @@ $execute {
ColorProvider::get()->define("mod-list-updates-available-bg-2"_spr, { 45, 110, 222, 255 });
ColorProvider::get()->define("mod-list-errors-found"_spr, { 235, 35, 112, 255 });
ColorProvider::get()->define("mod-list-errors-found-2"_spr, { 245, 27, 27, 255 });
ColorProvider::get()->define("mod-list-tab-deselected-bg"_spr, { 26, 24, 29, 255 });
ColorProvider::get()->define("mod-list-tab-selected-bg"_spr, { 168, 147, 185, 255 });
ColorProvider::get()->define("mod-list-tab-selected-bg-alt"_spr, { 147, 163, 185, 255 });
ColorProvider::get()->define("mod-list-featured-color"_spr, { 255, 255, 120, 255 });
@ -22,10 +24,35 @@ $execute {
ColorProvider::get()->define("mod-list-recommended-bg"_spr, ccc3(25, 255, 167));
ColorProvider::get()->define("mod-list-recommended-by"_spr, ccc3(25, 255, 167));
ColorProvider::get()->define("mod-list-recommended-by-2"_spr, ccc3(47, 255, 255));
auto updateColors = +[](bool enabled) {
if (enabled) {
ColorProvider::get()->reset("mod-list-bg"_spr);
ColorProvider::get()->reset("mod-list-search-bg"_spr);
ColorProvider::get()->reset("mod-list-tab-deselected-bg"_spr);
ColorProvider::get()->reset("mod-list-tab-selected-bg"_spr);
ColorProvider::get()->reset("mod-list-tab-selected-bg-alt"_spr);
ColorProvider::get()->reset("mod-list-restart-required-label"_spr);
ColorProvider::get()->reset("mod-list-restart-required-label-bg"_spr);
}
else {
ColorProvider::get()->override("mod-list-bg"_spr, { 168, 85, 44, 255 });
ColorProvider::get()->override("mod-list-search-bg"_spr, { 114, 63, 31, 255 });
ColorProvider::get()->override("mod-list-tab-deselected-bg"_spr, { 54, 31, 16, 255 });
ColorProvider::get()->override("mod-list-tab-selected-bg"_spr, { 248, 200, 43, 255 });
ColorProvider::get()->override("mod-list-tab-selected-bg-alt"_spr, { 156, 185, 147, 255 });
ColorProvider::get()->override("mod-list-restart-required-label"_spr, ccc3(10, 226, 255));
ColorProvider::get()->override("mod-list-restart-required-label-bg"_spr, ccc3(0, 174, 180));
}
};
// Update colors when the theme is changed
listenForSettingChanges("enable-geode-theme", updateColors);
updateColors(Mod::get()->template getSettingValue<bool>("enable-geode-theme"));
}
bool GeodeSquareSprite::init(CCSprite* top, bool* state) {
if (!CCSprite::initWithFile("GE_button_05.png"_spr))
if (!CCSprite::initWithFile(isGeodeTheme() ? "GE_button_05.png"_spr : "GJ_button_01.png"))
return false;
m_stateSrc = state;
@ -47,7 +74,8 @@ void GeodeSquareSprite::update(float dt) {
if (m_stateSrc && m_state != *m_stateSrc) {
m_state = *m_stateSrc;
this->setTexture(CCTextureCache::get()->addImage(
(m_state ? "GJ_button_02.png" : "GE_button_05.png"_spr), true
(m_state ? "GJ_button_02.png" : (isGeodeTheme() ? "GE_button_05.png"_spr : "GJ_button_01.png")),
true
));
}
}
@ -126,16 +154,41 @@ CCNode* createLoadingCircle(float sideLength, const char* id) {
return spinner;
}
IconButtonSprite* createGeodeButton(CCNode* icon, std::string const& text, std::string const& bg) {
return IconButtonSprite::create(bg.c_str(), icon, text.c_str(), "bigFont.fnt");
const char* getGeodeButtonSpriteName(GeodeButtonSprite spr) {
if (isGeodeTheme()) {
switch (spr) {
default:
case GeodeButtonSprite::Default: return "GE_button_05.png"_spr;
case GeodeButtonSprite::Install: return "GE_button_01.png"_spr;
case GeodeButtonSprite::Delete: return "GJ_button_06.png";
case GeodeButtonSprite::Enable: return "GJ_button_01.png";
}
}
else {
switch (spr) {
default:
case GeodeButtonSprite::Default: return "GJ_button_01.png";
case GeodeButtonSprite::Install: return "GE_button_01.png"_spr;
case GeodeButtonSprite::Delete: return "GJ_button_06.png";
case GeodeButtonSprite::Enable: return "GJ_button_02.png";
}
}
}
ButtonSprite* createGeodeButton(std::string const& text, bool gold, std::string const& bg) {
return ButtonSprite::create(text.c_str(), gold ? "goldFont.fnt" : "bigFont.fnt", bg.c_str(), .8f);
IconButtonSprite* createGeodeButton(CCNode* icon, std::string const& text, GeodeButtonSprite bg) {
return IconButtonSprite::create(getGeodeButtonSpriteName(bg), icon, text.c_str(), "bigFont.fnt");
}
ButtonSprite* createGeodeButton(std::string const& text, bool gold, GeodeButtonSprite bg) {
return ButtonSprite::create(text.c_str(), gold ? "goldFont.fnt" : "bigFont.fnt", getGeodeButtonSpriteName(bg), .8f);
}
CircleButtonSprite* createGeodeCircleButton(const char* topFrameName) {
return CircleButtonSprite::createWithSpriteFrameName(topFrameName, 1.f, CircleBaseColor::DarkPurple);
CircleButtonSprite* createGeodeCircleButton(CCSprite* top, float scale, CircleBaseSize size, bool altColor) {
const auto geodeTheme = isGeodeTheme();
auto ret = CircleButtonSprite::create(
top, geodeTheme ? (altColor ? CircleBaseColor::DarkAqua : CircleBaseColor::DarkPurple) : CircleBaseColor::Green, size
);
ret->setTopRelativeScale(scale);
return ret;
}
ButtonSprite* createGeodeTagLabel(std::string const& text, std::optional<std::pair<ccColor3B, ccColor3B>> const& color) {
@ -165,11 +218,17 @@ std::pair<ccColor3B, ccColor3B> geodeTagColor(std::string_view const& text) {
ListBorders* createGeodeListBorders(CCSize const& size) {
auto ret = ListBorders::create();
ret->setSpriteFrames("geode-list-top.png"_spr, "geode-list-side.png"_spr, 2);
if (isGeodeTheme()) {
ret->setSpriteFrames("geode-list-top.png"_spr, "geode-list-side.png"_spr, 2);
}
ret->setContentSize(size);
return ret;
}
bool isGeodeTheme() {
return Mod::get()->template getSettingValue<bool>("enable-geode-theme");
}
bool GeodeTabSprite::init(const char* iconFrame, const char* text, float width, bool altColor) {
if (!CCNode::init())
return false;
@ -183,7 +242,7 @@ bool GeodeTabSprite::init(const char* iconFrame, const char* text, float width,
m_deselectedBG = CCScale9Sprite::createWithSpriteFrameName("tab-bg.png"_spr);
m_deselectedBG->setScale(.8f);
m_deselectedBG->setContentSize(itemSize / .8f);
m_deselectedBG->setColor({ 26, 24, 29 });
m_deselectedBG->setColor("mod-list-tab-deselected-bg"_cc3b);
this->addChildAtPosition(m_deselectedBG, Anchor::Center);
m_selectedBG = CCScale9Sprite::createWithSpriteFrameName("tab-bg.png"_spr);

View file

@ -16,12 +16,13 @@ template <class... Args>
class GeodePopup : public Popup<Args...> {
protected:
bool init(float width, float height, Args... args, GeodePopupStyle style = GeodePopupStyle::Default) {
const bool geodeTheme = Mod::get()->template getSettingValue<bool>("enable-geode-theme");
const char* bg;
switch (style) {
default:
case GeodePopupStyle::Default: bg = "GE_square01.png"_spr; break;
case GeodePopupStyle::Alt: bg = "GE_square02.png"_spr; break;
case GeodePopupStyle::Alt2: bg = "GE_square03.png"_spr; break;
case GeodePopupStyle::Default: bg = geodeTheme ? "GE_square01.png"_spr : "GJ_square01.png"; break;
case GeodePopupStyle::Alt: bg = geodeTheme ? "GE_square02.png"_spr : "GJ_square02.png"; break;
case GeodePopupStyle::Alt2: bg = geodeTheme ? "GE_square03.png"_spr : "GJ_square02.png"; break;
}
if (!Popup<Args...>::initAnchored(width, height, std::forward<Args>(args)..., bg))
return false;
@ -29,7 +30,10 @@ protected:
this->setCloseButtonSpr(
CircleButtonSprite::createWithSpriteFrameName(
"close.png"_spr, .85f,
(style == GeodePopupStyle::Default ? CircleBaseColor::DarkPurple : CircleBaseColor::DarkAqua)
(geodeTheme ?
(style == GeodePopupStyle::Default ? CircleBaseColor::DarkPurple : CircleBaseColor::DarkAqua) :
CircleBaseColor::Green
)
)
);
@ -56,16 +60,25 @@ public:
CCNode* createLoadingCircle(float sideLength, const char* id = "loading-spinner");
IconButtonSprite* createGeodeButton(CCNode* icon, std::string const& text, std::string const& bg = "GE_button_05.png"_spr);
ButtonSprite* createGeodeButton(std::string const& text, bool gold = false, std::string const& bg = "GE_button_05.png"_spr);
enum class GeodeButtonSprite {
Default,
Install,
Delete,
Enable,
};
const char* getGeodeButtonSpriteName(GeodeButtonSprite spr);
IconButtonSprite* createGeodeButton(CCNode* icon, std::string const& text, GeodeButtonSprite bg = GeodeButtonSprite::Default);
ButtonSprite* createGeodeButton(std::string const& text, bool gold = false, GeodeButtonSprite bg = GeodeButtonSprite::Default);
CircleButtonSprite* createGeodeCircleButton(const char* topFrameName);
CircleButtonSprite* createGeodeCircleButton(CCSprite* top, float scale = 1.f, CircleBaseSize size = CircleBaseSize::Medium, bool altColor = false);
ButtonSprite* createGeodeTagLabel(std::string const& text, std::optional<std::pair<ccColor3B, ccColor3B>> const& color = std::nullopt);
std::pair<ccColor3B, ccColor3B> geodeTagColor(std::string_view const& text);
ListBorders* createGeodeListBorders(CCSize const& size);
bool isGeodeTheme();
class GeodeTabSprite : public CCNode {
protected:
CCScale9Sprite* m_deselectedBG;

View file

@ -275,7 +275,14 @@ bool ModsLayer::init() {
auto winSize = CCDirector::get()->getWinSize();
this->addChild(SwelvyBG::create());
const bool geodeTheme = isGeodeTheme();
if (geodeTheme) {
this->addChild(SwelvyBG::create());
}
else {
this->addChild(createLayerBG());
addSideArt(this);
}
auto backMenu = CCMenu::create();
backMenu->setContentWidth(100.f);
@ -297,9 +304,8 @@ bool ModsLayer::init() {
actionsMenu->setContentHeight(200.f);
actionsMenu->setAnchorPoint({ .5f, .0f });
auto reloadSpr = CircleButtonSprite::create(
CCSprite::createWithSpriteFrameName("reload.png"_spr),
CircleBaseColor::DarkPurple,
auto reloadSpr = createGeodeCircleButton(
CCSprite::createWithSpriteFrameName("reload.png"_spr), 1.f,
CircleBaseSize::Medium
);
reloadSpr->setScale(.8f);
@ -309,6 +315,17 @@ bool ModsLayer::init() {
);
actionsMenu->addChild(reloadBtn);
auto themeSpr = createGeodeCircleButton(
CCSprite::create("GJ_paletaBtn_001.png"), 1.f,
CircleBaseSize::Medium
);
themeSpr->setScale(.8f);
themeSpr->setTopOffset(ccp(1, 0));
auto themeBtn = CCMenuItemSpriteExtra::create(
themeSpr, this, menu_selector(ModsLayer::onTheme)
);
actionsMenu->addChild(themeBtn);
actionsMenu->setLayout(
ColumnLayout::create()
->setAxisAlignment(AxisAlignment::Start)
@ -324,20 +341,20 @@ bool ModsLayer::init() {
frameBG->ignoreAnchorPointForPosition(false);
m_frame->addChildAtPosition(frameBG, Anchor::Center);
auto tabsTop = CCSprite::createWithSpriteFrameName("mods-list-top.png"_spr);
auto tabsTop = CCSprite::createWithSpriteFrameName(geodeTheme ? "mods-list-top.png"_spr : "mods-list-top-gd.png"_spr);
tabsTop->setAnchorPoint({ .5f, .0f });
m_frame->addChildAtPosition(tabsTop, Anchor::Top, ccp(0, -2));
auto tabsLeft = CCSprite::createWithSpriteFrameName("mods-list-side.png"_spr);
auto tabsLeft = CCSprite::createWithSpriteFrameName(geodeTheme ? "mods-list-side.png"_spr : "mods-list-side-gd.png"_spr);
tabsLeft->setScaleY(m_frame->getContentHeight() / tabsLeft->getContentHeight());
m_frame->addChildAtPosition(tabsLeft, Anchor::Left, ccp(6, 0));
auto tabsRight = CCSprite::createWithSpriteFrameName("mods-list-side.png"_spr);
auto tabsRight = CCSprite::createWithSpriteFrameName(geodeTheme ? "mods-list-side.png"_spr : "mods-list-side-gd.png"_spr);
tabsRight->setFlipX(true);
tabsRight->setScaleY(m_frame->getContentHeight() / tabsRight->getContentHeight());
m_frame->addChildAtPosition(tabsRight, Anchor::Right, ccp(-6, 0));
auto tabsBottom = CCSprite::createWithSpriteFrameName("mods-list-bottom.png"_spr);
auto tabsBottom = CCSprite::createWithSpriteFrameName(geodeTheme ? "mods-list-bottom.png"_spr : "mods-list-bottom-gd.png"_spr);
tabsBottom->setAnchorPoint({ .5f, 1.f });
m_frame->addChildAtPosition(tabsBottom, Anchor::Bottom, ccp(0, 2));
@ -505,13 +522,11 @@ void ModsLayer::updateState() {
void ModsLayer::onTab(CCObject* sender) {
this->gotoTab(static_cast<ModListSource*>(static_cast<CCNode*>(sender)->getUserData()));
}
void ModsLayer::onRefreshList(CCObject*) {
if (m_currentSource) {
m_lists.at(m_currentSource)->reloadPage();
}
}
void ModsLayer::onBack(CCObject*) {
CCDirector::get()->replaceScene(CCTransitionFade::create(.5f, MenuLayer::scene(false)));
@ -519,7 +534,6 @@ void ModsLayer::onBack(CCObject*) {
server::clearServerCaches(true);
ModListSource::clearAllCaches();
}
void ModsLayer::onGoToPage(CCObject*) {
auto popup = SetTextPopup::create("", "Page", 5, "Go to Page", "OK", true, 60.f);
popup->m_delegate = this;
@ -527,7 +541,6 @@ void ModsLayer::onGoToPage(CCObject*) {
popup->setID("go-to-page"_spr);
popup->show();
}
void ModsLayer::onBigView(CCObject*) {
m_bigView = !m_bigView;
// Make sure to avoid a crash
@ -535,7 +548,6 @@ void ModsLayer::onBigView(CCObject*) {
m_lists.at(m_currentSource)->updateSize(m_bigView);
}
}
void ModsLayer::onSearch(CCObject*) {
m_showSearch = !m_showSearch;
// Make sure to avoid a crash
@ -543,6 +555,27 @@ void ModsLayer::onSearch(CCObject*) {
m_lists.at(m_currentSource)->activateSearch(m_showSearch);
}
}
void ModsLayer::onTheme(CCObject*) {
auto old = Mod::get()->template getSettingValue<bool>("enable-geode-theme");
createQuickPopup(
"Switch Theme",
fmt::format(
"Do you want to switch the <cp>color scheme</c> of the Geode menu "
"to {}?",
(old ? "<cy>GD-style colors</c>" : "<ca>Geode-style colors</c>")
),
"Cancel", "Switch",
[old](auto*, bool btn2) {
if (btn2) {
Mod::get()->setSettingValue("enable-geode-theme", !old);
// todo: the touch priority on the new scene is screwed up and i can't figure out how to fix it
Loader::get()->queueInMainThread([] {
ModsLayer::scene();
});
}
}
);
}
ModsLayer* ModsLayer::create() {
auto ret = new ModsLayer();

View file

@ -61,6 +61,7 @@ protected:
void onSearch(CCObject*);
void onGoToPage(CCObject*);
void onRefreshList(CCObject*);
void onTheme(CCObject*);
void onBack(CCObject*);
void updateState();

View file

@ -139,9 +139,9 @@ bool ModItem::init(ModSource&& source) {
m_viewMenu->updateLayout();
}
if (mod->hasProblems()) {
auto viewErrorSpr = CircleButtonSprite::createWithSpriteFrameName(
"exclamation.png"_spr, 1.f,
CircleBaseColor::DarkPurple, CircleBaseSize::Small
auto viewErrorSpr = createGeodeCircleButton(
CCSprite::createWithSpriteFrameName("exclamation.png"_spr), 1.f,
CircleBaseSize::Small
);
auto viewErrorBtn = CCMenuItemSpriteExtra::create(
viewErrorSpr, this, menu_selector(ModItem::onViewError)
@ -183,8 +183,9 @@ bool ModItem::init(ModSource&& source) {
},
});
auto updateSpr = CircleButtonSprite::createWithSpriteFrameName(
"update.png"_spr, 1.15f, CircleBaseColor::DarkAqua
auto updateSpr = createGeodeCircleButton(
CCSprite::createWithSpriteFrameName("update.png"_spr), 1.15f,
CircleBaseSize::Medium, true
);
m_updateBtn = CCMenuItemSpriteExtra::create(
updateSpr, this, menu_selector(ModItem::onInstall)
@ -246,23 +247,29 @@ void ModItem::updateState() {
// (possibly overriding later based on state)
m_source.visit(makeVisitor {
[this](Mod* mod) {
m_bg->setColor(ccWHITE);
m_bg->setOpacity(mod->isOrWillBeEnabled() ? 25 : 10);
if (isGeodeTheme()) {
m_bg->setColor(ccWHITE);
m_bg->setOpacity(mod->isOrWillBeEnabled() ? 25 : 10);
}
else {
m_bg->setColor(ccBLACK);
m_bg->setOpacity(mod->isOrWillBeEnabled() ? 90 : 60);
}
m_titleLabel->setOpacity(mod->isOrWillBeEnabled() ? 255 : 155);
m_versionLabel->setOpacity(mod->isOrWillBeEnabled() ? 255 : 155);
m_developerLabel->setOpacity(mod->isOrWillBeEnabled() ? 255 : 155);
},
[this](server::ServerModMetadata const& metadata) {
m_bg->setColor(ccWHITE);
m_bg->setOpacity(25);
if (metadata.featured) {
m_bg->setColor(isGeodeTheme() ? ccWHITE : ccBLACK);
m_bg->setOpacity(isGeodeTheme() ? 25 : 90);
if (isGeodeTheme() && metadata.featured) {
m_bg->setColor("mod-list-featured-color"_cc3b);
m_bg->setOpacity(40);
}
},
[this](ModSuggestion const& suggestion) {
m_bg->setColor("mod-list-recommended-bg"_cc3b);
m_bg->setOpacity(25);
m_bg->setOpacity(isGeodeTheme() ? 25 : 90);
}
});
@ -276,7 +283,7 @@ void ModItem::updateState() {
m_versionLabel->setColor(to3B(ColorProvider::get()->color("mod-list-version-label-updates-available"_spr)));
m_bg->setColor(to3B(ColorProvider::get()->color("mod-list-version-label-updates-available"_spr)));
m_bg->setOpacity(40);
m_bg->setOpacity(isGeodeTheme() ? 25 : 90);
}
else {
m_updateBtn->setVisible(false);
@ -289,13 +296,13 @@ void ModItem::updateState() {
// If there were problems, tint the BG red
if (m_source.asMod() && m_source.asMod()->hasProblems()) {
m_bg->setColor("mod-list-errors-found"_cc3b);
m_bg->setOpacity(40);
m_bg->setOpacity(isGeodeTheme() ? 25 : 90);
}
// Highlight item via BG if it wants to restart for extra UI attention
if (wantsRestart) {
m_bg->setColor(to3B(ColorProvider::get()->color("mod-list-restart-required-label"_spr)));
m_bg->setOpacity(40);
m_bg->setColor("mod-list-restart-required-label"_cc3b);
m_bg->setOpacity(isGeodeTheme() ? 25 : 90);
}
// Update enable toggle state

View file

@ -68,11 +68,11 @@ bool ModList::init(ModListSource* src, CCSize const& size) {
auto showUpdatesSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("GJ_filterIcon_001.png"),
"Show Updates", "GE_button_01.png"_spr
"Show Updates", GeodeButtonSprite::Install
);
auto hideUpdatesSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("GJ_filterIcon_001.png"),
"Hide Updates", "GE_button_05.png"_spr
"Hide Updates", GeodeButtonSprite::Default
);
m_toggleUpdatesOnlyBtn = CCMenuItemToggler::create(
showUpdatesSpr, hideUpdatesSpr, this, menu_selector(ModList::onToggleUpdates)
@ -82,7 +82,7 @@ bool ModList::init(ModListSource* src, CCSize const& size) {
auto updateAllSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("update.png"_spr),
"Update All", "GE_button_01.png"_spr
"Update All", GeodeButtonSprite::Install
);
m_updateAllBtn = CCMenuItemSpriteExtra::create(
updateAllSpr, this, menu_selector(ModList::onUpdateAll)
@ -130,11 +130,11 @@ bool ModList::init(ModListSource* src, CCSize const& size) {
auto showErrorsSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("GJ_filterIcon_001.png"),
"Show Errors Only", "GJ_button_06.png"
"Show Errors Only", GeodeButtonSprite::Delete
);
auto hideErrorsSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("GJ_filterIcon_001.png"),
"Hide Errors Only", "GE_button_05.png"_spr
"Hide Errors Only", GeodeButtonSprite::Default
);
m_toggleErrorsOnlyBtn = CCMenuItemToggler::create(
showErrorsSpr, hideErrorsSpr, this, menu_selector(ModList::onToggleErrors)

View file

@ -288,7 +288,7 @@ bool ModPopup::setup(ModSource&& src) {
auto updateModSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("update.png"_spr),
"Update",
"GE_button_01.png"_spr
GeodeButtonSprite::Install
);
updateModSpr->setScale(.5f);
m_updateBtn = CCMenuItemSpriteExtra::create(
@ -299,13 +299,13 @@ bool ModPopup::setup(ModSource&& src) {
auto enableModOffSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("GJ_completesIcon_001.png"),
"Enable",
"GJ_button_01.png"
GeodeButtonSprite::Enable
);
enableModOffSpr->setScale(.5f);
auto enableModOnSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("GJ_deleteIcon_001.png"),
"Disable",
"GJ_button_06.png"
GeodeButtonSprite::Delete
);
enableModOnSpr->setScale(.5f);
m_enableBtn = CCMenuItemToggler::create(
@ -318,13 +318,13 @@ bool ModPopup::setup(ModSource&& src) {
auto reenableModOffSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("reset.png"_spr),
"Re-Enable",
"GE_button_05.png"_spr
GeodeButtonSprite::Default
);
reenableModOffSpr->setScale(.5f);
auto reenableModOnSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("reset.png"_spr),
"Re-Disable",
"GE_button_05.png"_spr
GeodeButtonSprite::Default
);
reenableModOnSpr->setScale(.5f);
m_reenableBtn = CCMenuItemToggler::create(
@ -337,7 +337,7 @@ bool ModPopup::setup(ModSource&& src) {
auto installModSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("GJ_downloadsIcon_001.png"),
"Install",
"GE_button_01.png"_spr
GeodeButtonSprite::Install
);
installModSpr->setScale(.5f);
m_installBtn = CCMenuItemSpriteExtra::create(
@ -348,7 +348,7 @@ bool ModPopup::setup(ModSource&& src) {
auto uninstallModSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("delete-white.png"_spr),
"Uninstall",
"GE_button_05.png"_spr
GeodeButtonSprite::Default
);
uninstallModSpr->setScale(.5f);
m_uninstallBtn = CCMenuItemSpriteExtra::create(
@ -359,7 +359,7 @@ bool ModPopup::setup(ModSource&& src) {
auto cancelDownloadSpr = createGeodeButton(
CCSprite::createWithSpriteFrameName("GJ_deleteIcon_001.png"),
"Cancel",
"GE_button_05.png"_spr
GeodeButtonSprite::Default
);
cancelDownloadSpr->setScale(.5f);
m_cancelBtn = CCMenuItemSpriteExtra::create(
@ -496,7 +496,7 @@ bool ModPopup::setup(ModSource&& src) {
mainContainer->updateLayout();
m_mainLayer->addChildAtPosition(mainContainer, Anchor::Center);
auto settingsSpr = createGeodeCircleButton("settings.png"_spr);
auto settingsSpr = createGeodeCircleButton(CCSprite::createWithSpriteFrameName("settings.png"_spr));
settingsSpr->setScale(.6f);
auto settingsBtn = CCMenuItemSpriteExtra::create(
settingsSpr, this, menu_selector(ModPopup::onSettings)

View file

@ -210,6 +210,13 @@ void BasedButtonSprite::setTopOffset(CCPoint const& offset) {
m_onTop->setPosition(this->getContentSize() / 2 + offset);
}
}
void BasedButtonSprite::setTopRelativeScale(float scale) {
m_onTopRelativeScale = scale;
if (m_onTop) {
limitNodeSize(m_onTop, this->getMaxTopSize(), 999.f, .1f);
m_onTop->setScale(m_onTop->getScale() * m_onTopRelativeScale);
}
}
bool BasedButtonSprite::initWithSprite(
char const* sprName, float sprScale, BaseType type, int size, int color

View file

@ -174,15 +174,11 @@ void ListBorders::setSprites(
}
void ListBorders::setContentSize(CCSize const& size) {
CCNode::setContentSize(size);
this->updateLayout();
m_top->setContentWidth(size.width + m_topPadding);
m_bottom->setContentWidth(size.width + m_bottomPadding);
m_left->setScaleY(
(size.height - m_top->getScaledContentHeight() - m_bottom->getScaledContentHeight()) /
m_left->getScaledContentHeight()
);
m_right->setScaleY(
(size.height - m_top->getScaledContentHeight() - m_bottom->getScaledContentHeight()) /
m_right->getScaledContentHeight()
);
this->updateLayout();
auto height = m_top->getContentHeight() * 0.75 + m_bottom->getContentHeight() * 0.75;
m_left->setScaleY((size.height - height) / m_left->getContentHeight());
m_right->setScaleY((size.height - height) / m_right->getContentHeight());
}