Skip to content

Commit 64707b7

Browse files
committed
use geode button
1 parent ee0e122 commit 64707b7

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "5.0.0-beta.4",
2+
"geode": "5.0.0",
33
"gd": {
44
"win": "2.2081",
55
"android": "2.2081",

src/Utils.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
#include <cocos2d.h>
1515

16+
#include <Geode/ui/Button.hpp>
17+
1618
#include <Geode/binding/FMODAudioEngine.hpp>
1719

1820
// Additional utility methods for Horrible Ideas

src/menu/OptionMenu.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ class OptionMenu final : public Popup {
2121
ccColor3B color;
2222
};
2323

24-
using Callback = void(*)(CCMenuItem*);
25-
2624
struct SocialBtnData final {
2725
const char* sprite;
2826
const char* id;
29-
Callback callback;
27+
Button::ButtonCallback callback;
3028
};
3129

3230
protected:

src/menu/src/OptionMenu.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <Geode/Geode.hpp>
99

1010
#include <Geode/ui/GeodeUI.hpp>
11-
#include <Geode/ui/TextInput.hpp>
1211

1312
#include <Geode/utils/terminate.hpp>
1413

@@ -204,7 +203,7 @@ bool OptionMenu::init() {
204203
btnSprite->m_label->setColor(filterBtn.color);
205204
btnSprite->setScale(0.8f);
206205

207-
if (auto btn = CCMenuItemExt::createSpriteExtra(
206+
if (auto btn = Button::createWithNode(
208207
btnSprite,
209208
[this, filterBtn](auto) {
210209
// Toggle: clicking same button disables filter
@@ -228,15 +227,14 @@ bool OptionMenu::init() {
228227

229228
m_mainLayer->addChild(filterMenu);
230229

231-
// get the options data
230+
// get all the options data
232231
m_impl->filterOptions(options::getAll());
233232

234-
// add a mod settings at the bottom left
235233
// @geode-ignore(unknown-resource)
236234
auto settingsBtnSprite = CircleButtonSprite::createWithSpriteFrameName("geode.loader/settings.png");
237235
settingsBtnSprite->setScale(0.625f);
238236

239-
auto settingsBtn = CCMenuItemExt::createSpriteExtra(
237+
auto settingsBtn = Button::createWithNode(
240238
settingsBtnSprite,
241239
[](auto) {
242240
openSettingsPopup(horribleMod);
@@ -249,7 +247,7 @@ bool OptionMenu::init() {
249247
auto resetFiltersBtnSprite = CCSprite::createWithSpriteFrameName("GJ_replayBtn_001.png");
250248
resetFiltersBtnSprite->setScale(0.375f);
251249

252-
auto resetFiltersBtn = CCMenuItemExt::createSpriteExtra(
250+
auto resetFiltersBtn = Button::createWithNode(
253251
resetFiltersBtnSprite,
254252
[this](auto) {
255253
createQuickPopup(
@@ -283,7 +281,7 @@ bool OptionMenu::init() {
283281
socialMenu->setContentWidth(0.f);
284282
socialMenu->setLayout(socialMenuLayout);
285283

286-
constexpr SocialBtnData socialBtns[] = {
284+
auto socialBtns = std::to_array<SocialBtnData>({
287285
{
288286
"gj_ytIcon_001.png",
289287
"horrible-mods-series-btn",
@@ -320,15 +318,15 @@ bool OptionMenu::init() {
320318
openSupportPopup(horribleMod);
321319
}
322320
}
323-
};
321+
});
324322

325-
for (auto const& socialBtn : socialBtns) {
323+
for (auto& socialBtn : socialBtns) {
326324
if (auto sprite = CCSprite::createWithSpriteFrameName(socialBtn.sprite)) {
327325
sprite->setScale(0.75f);
328326

329-
if (auto btn = CCMenuItemExt::createSpriteExtra(
327+
if (auto btn = Button::createWithNode(
330328
sprite,
331-
socialBtn.callback
329+
std::move(socialBtn.callback)
332330
)) {
333331
btn->setID(socialBtn.id);
334332

src/menu/src/SettingV3.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <Geode/Geode.hpp>
66

7+
#include <Geode/ui/Button.hpp>
8+
79
using namespace geode::prelude;
810
using namespace horrible::prelude;
911

@@ -41,7 +43,7 @@ SettingNodeV3* HorribleSettingV3::createNode(float width) {
4143
class HorribleSettingNodeV3::Impl final {
4244
public:
4345
Ref<ButtonSprite> buttonSprite = nullptr;
44-
CCMenuItemSpriteExtra* button = nullptr;
46+
Button* button = nullptr;
4547
};
4648

4749
HorribleSettingNodeV3::HorribleSettingNodeV3() : m_impl(std::make_unique<Impl>()) {};
@@ -58,7 +60,7 @@ bool HorribleSettingNodeV3::init(std::shared_ptr<HorribleSettingV3> setting, flo
5860
);
5961
m_impl->buttonSprite->setScale(.5f);
6062

61-
m_impl->button = CCMenuItemExt::createSpriteExtra(
63+
m_impl->button = Button::createWithNode(
6264
m_impl->buttonSprite,
6365
[](auto) {
6466
menu::open();

0 commit comments

Comments
 (0)