Skip to content

Commit 62cce32

Browse files
blurry game
1 parent 056bceb commit 62cce32

2 files changed

Lines changed: 101 additions & 0 deletions

File tree

include/BlurAPI.hpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
52+
inline bool willLoad()
53+
{
54+
if (auto blur = geode::Loader::get()->getInstalledMod("thesillydoggo.blur-api"))
55+
{
56+
if (blur->shouldLoad())
57+
{
58+
return true;
59+
}
60+
}
61+
62+
return false;
63+
}
64+
};

src/hooks/PlayLayer/BlurGame.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <Utils.hpp>
2+
3+
#include <Geode/Geode.hpp>
4+
5+
#include <Geode/modify/PlayLayer.hpp>
6+
#include <BlurAPI.hpp>
7+
#include "Geode/cocos/layers_scenes_transitions_nodes/CCLayer.h"
8+
9+
using namespace geode::prelude;
10+
using namespace horrible::prelude;
11+
12+
inline static constexpr auto id = "blurry";
13+
14+
inline static Option const o = {
15+
id,
16+
"Blurry Game",
17+
"Makes the entire game blurry. I think you forgot your glasses.\n<cy>Required Blur API by the thesillydoggo mod installed.</c>\n<cl>Credit: ArcticWoof</c>",
18+
category::obstructive,
19+
SillyTier::Medium,
20+
};
21+
HORRIBLE_REGISTER_OPTION(o);
22+
23+
class $modify(BlurPlayLayer, PlayLayer) {
24+
HORRIBLE_DELEGATE_HOOKS(id);
25+
26+
void setupHasCompleted() {
27+
PlayLayer::setupHasCompleted();
28+
29+
auto colorLayer = CCLayerColor::create({0, 0, 0, 0});
30+
colorLayer->setID("blur-color-layer"_spr);
31+
colorLayer->setContentSize({getScaledContentWidth(), getScaledContentHeight()});
32+
colorLayer->setPosition({0, 0});
33+
this->addChild(colorLayer, 98);
34+
BlurAPI::addBlur(colorLayer);
35+
}
36+
37+
};

0 commit comments

Comments
 (0)