Skip to content

Commit 834d72c

Browse files
committed
update for geode v5
1 parent eadde07 commit 834d72c

38 files changed

+238
-519
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Added Version Info texts into the main UI
55
- Added option to change shortcut icon colour
66
- Fixed being able to complete levels when playing from a startpos with auto safe mode disabled
7+
- Improved Blur BG Performance and switched to using Blur API
78

89
# 2.5.3
910

include/BlurAPI.hpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#pragma once
2+
3+
#include <Geode/Geode.hpp>
4+
5+
#define BLUR_TAG "thesillydoggo.blur_api/blur-options"
6+
7+
namespace BlurAPI
8+
{
9+
class BlurOptions : public cocos2d::CCObject
10+
{
11+
public:
12+
int apiVersion = 1; // dont change
13+
cocos2d::CCRenderTexture* rTex = nullptr;
14+
geode::Ref<cocos2d::CCClippingNode> clip = nullptr;
15+
bool forcePasses = false;
16+
int passes = 3;
17+
float alphaThreshold = 0.01f;
18+
19+
virtual bool init() { return true; }
20+
CREATE_FUNC(BlurOptions);
21+
};
22+
23+
inline BlurOptions* getOptions(cocos2d::CCNode* node)
24+
{
25+
return static_cast<BlurOptions*>(node->getUserObject(BLUR_TAG));
26+
}
27+
28+
inline void addBlur(cocos2d::CCNode* node)
29+
{
30+
if (getOptions(node))
31+
return;
32+
33+
node->setUserObject(BLUR_TAG, BlurOptions::create());
34+
}
35+
36+
inline void removeBlur(cocos2d::CCNode* node)
37+
{
38+
node->setUserObject(BLUR_TAG, nullptr);
39+
}
40+
41+
inline bool isBlurAPIEnabled()
42+
{
43+
if (auto blur = geode::Loader::get()->getLoadedMod("thesillydoggo.blur_api"))
44+
{
45+
if (blur->getSettingValue<bool>("enabled"))
46+
return true;
47+
}
48+
49+
return false;
50+
}
51+
};

resources/translations

src/Client/ModuleNode.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "../GUI/Modules/SeperateColourCheatNames.hpp"
55
#include "../Utils/ColourUtils.hpp"
66
#include "../GUI/EditKeyConfigUI.hpp"
7-
#include "../GUI/BlurLayer.hpp"
87
#include "../GUI/BetterAlertLayer.hpp"
98
#include "../GUI/SetupShortcutUI.hpp"
109

@@ -207,7 +206,6 @@ void ModuleNode::onChangeShortcut(CCObject* sender)
207206
void ModuleNode::onInfo(CCObject* sender)
208207
{
209208
auto alert = BetterAlertLayer::createWithLocalisation(fmt::format("names/{}", getID()).c_str(), fmt::format("descriptions/{}", getID()), "ui/ok-button");
210-
alert->addChild(CCBlurLayer::create(), -3);
211209
alert->setUserData(module);
212210
alert->show();
213211

@@ -216,7 +214,7 @@ void ModuleNode::onInfo(CCObject* sender)
216214
menu->setPosition(ccp(0, 25));
217215

218216
auto btn = CCMenuItemToggler::create(CCSprite::create("favourites.png"_spr), CCSprite::create("favourites.png"_spr), alert, menu_selector(ModuleNode::onInfoToggleFavourite));
219-
btn->setPositionX(-alert->m_mainLayer->getChildByType<CCScale9Sprite>(0)->getContentWidth() / 2 + 25);
217+
btn->setPositionX(25);
220218
btn->toggle(module->isFavourited());
221219

222220
btn->setContentSize(btn->getContentSize() * 3);

src/CustomRewards/UI/CustomRewardSetupUI.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ CustomRewardSetupUI* CustomRewardSetupUI::create()
1818

1919
bool CustomRewardSetupUI::setup()
2020
{
21-
this->addChild(CCBlurLayer::create(), -3);
22-
2321
m_bgSprite->setVisible(false);
2422
bg = BackgroundSprite::create();
2523
bg->setContentSize(this->m_size);

src/CustomRewards/UI/CustomRewardSetupUI.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#include <Geode/Geode.hpp>
44
#include "../../GUI/BackgroundSprite.hpp"
5-
#include "../../GUI/BlurLayer.hpp"
65
#include "../../GUI/BetterButtonSprite.hpp"
76
#include "../../Utils/AdvancedLabel/AdvLabelBMFont.hpp"
7+
#include "../../GUI/PopupBase.hpp"
88

99
using namespace geode::prelude;
1010

11-
class CustomRewardSetupUI : public geode::Popup<>
11+
class CustomRewardSetupUI : public PopupBase
1212
{
1313
protected:
1414
BackgroundSprite* bg;

src/GUI/AndroidUI.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
#include "../Utils/RealtimeAction.hpp"
1010
#include "../Localisation/LocalisationManager.hpp"
1111
#include "BetterInputNode.hpp"
12-
#include "BlurLayer.hpp"
12+
1313
#include "FloatingButton/FloatingUIManager.hpp"
1414
#include "EasyBG.hpp"
15+
#include <BlurAPI.hpp>
1516

1617
bool AndroidUI::setup()
1718
{
18-
this->addChild(CCBlurLayer::create(), -3);
19+
instance = this;
1920
this->scheduleUpdate();
2021

2122
rt = CCRenderTexture::create(getContentWidth(), getContentHeight());
@@ -128,7 +129,6 @@ void AndroidUI::populateTabs()
128129
tabsMenu->setAnchorPoint(ccp(0, 0.5f));
129130
tabsMenu->ignoreAnchorPointForPosition(false);
130131
tabsMenu->setLayout(ColumnLayout::create()->setAxisReverse(true)->setAxisAlignment(AxisAlignment::End)->setCrossAxisOverflow(true)->setAutoScale(false)->setGap(2.5f));
131-
tabsMenu->getLayout()->ignoreInvisibleChildren(true);
132132

133133
m_mainLayer->addChildAtPosition(bg, Anchor::Left, ccp(10, 0));
134134
m_mainLayer->addChildAtPosition(tabsMenu, Anchor::Left, ccp(10 + 2.5f, 0));
@@ -251,7 +251,6 @@ AndroidUI* AndroidUI::create()
251251
if (pRet && pRet->initAnchored(475.f, 280.f))
252252
{
253253
PlatformToolbox::showCursor();
254-
instance = pRet;
255254
pRet->m_noElasticity = true;
256255

257256
pRet->autorelease();
@@ -307,7 +306,7 @@ void AndroidUI::runAnimation(MenuAnimation anim)
307306
bottomRight->setOpacity(150);
308307
this->setOpacity(150);
309308

310-
if (BlurMenuBG::get()->getRealEnabled() && anim == MenuAnimation::FadeIn)
309+
if (/*BlurMenuBG::get()->getRealEnabled() && BlurAPI::isBlurAPIEnabled() && */anim == MenuAnimation::FadeIn)
311310
anim = MenuAnimation::None;
312311

313312
switch (anim)
@@ -400,7 +399,7 @@ void AndroidUI::close()
400399

401400
void AndroidUI::keyDown(cocos2d::enumKeyCodes key, double timestamp)
402401
{
403-
geode::Popup<>::keyDown(key, 0);
402+
PopupBase::keyDown(key, 0);
404403

405404
auto old = selectedCategory;
406405

@@ -437,13 +436,13 @@ void AndroidUI::visit()
437436
// for an animation i was making, but i couldnt get clipping to work right
438437

439438
if (drawOpacity->getOpacity() == 255)
440-
return geode::Popup<>::visit();
439+
return PopupBase::visit();
441440

442441
auto op = getOpacity();
443442
this->setOpacity(0);
444443

445444
rt->beginWithClear(0, 0, 0, op / 255.0f);
446-
geode::Popup<>::visit();
445+
PopupBase::visit();
447446
rt->end();
448447

449448
this->setOpacity(op);

src/GUI/AndroidUI.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "CategoryTabSprite.hpp"
99
#include "../Utils/AdvancedLabel/AdvLabelBMFont.hpp"
1010
#include "VersionInfoNode.hpp"
11+
#include "PopupBase.hpp"
1112

1213
using namespace geode::prelude;
1314

@@ -22,7 +23,7 @@ enum class MenuAnimation
2223
FadeIn
2324
};
2425

25-
class AndroidUI : public geode::Popup<>
26+
class AndroidUI : public PopupBase
2627
{
2728
protected:
2829
friend class ThemeNode;

src/GUI/BetterAlertLayer.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "BetterAlertLayer.hpp"
22
#include "../Localisation/LocalisationManager.hpp"
33
#include "BetterButtonSprite.hpp"
4-
#include "BlurLayer.hpp"
54
#include "EasyBG.hpp"
65

76
BetterAlertLayer* BetterAlertLayer::create(FLAlertLayerProtocol* delegate, char const* title, gd::string desc, char const* btn1, char const* btn2, float width, bool scroll, float height, float textScale)
@@ -18,7 +17,7 @@ BetterAlertLayer* BetterAlertLayer::create(FLAlertLayerProtocol* delegate, char
1817
pRet->height = height;
1918
pRet->textScale = textScale;
2019

21-
if (pRet && pRet->initAnchored(0, 0))
20+
if (pRet && pRet->init(0, 0))
2221
{
2322
pRet->autorelease();
2423
return pRet;
@@ -52,8 +51,6 @@ BetterAlertLayer* BetterAlertLayer::createWithLocalisation(char const* title, co
5251

5352
bool BetterAlertLayer::setup()
5453
{
55-
this->addChild(CCBlurLayer::create(), -69);
56-
5754
m_bgSprite->setVisible(false);
5855
m_buttonMenu->setVisible(false);
5956

src/GUI/BetterAlertLayer.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
#include <Geode/Geode.hpp>
44
#include "../Utils/AdvancedLabel/AdvLabelBMFont.hpp"
5+
#include "PopupBase.hpp"
56

67
using namespace geode::prelude;
78

8-
class BetterAlertLayer : public geode::Popup<>
9+
class BetterAlertLayer : public PopupBase
910
{
1011
protected:
1112
CCScale9Sprite* bg = nullptr;

0 commit comments

Comments
 (0)