Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Commit 9b867ac

Browse files
committed
add bg blur and add wave trail customization
1 parent 1ec9846 commit 9b867ac

File tree

12 files changed

+259
-63
lines changed

12 files changed

+259
-63
lines changed

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"gd": {
44
"win": "2.204"
55
},
6-
"version": "v2.5.7",
6+
"version": "v2.5.8",
77
"id": "maxnu.gd_mega_overlay",
88
"name": "GD Mega Overlay",
99
"developer": "maxnu & SpaghettDev",

res/default_windows.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"Bypass": {
33
"h": 540.0,
44
"w": 200.0,
5-
"x": 0.5520833134651184,
5+
"x": 0.5521911382675171,
66
"y": 0.03703703731298447
77
},
88
"Creator": {
99
"h": 120.0,
1010
"w": 200.0,
11-
"x": 0.6979166865348816,
11+
"x": 0.6980530023574829,
1212
"y": 0.03703703731298447
1313
},
1414
"Credits": {
@@ -20,55 +20,55 @@
2020
"General": {
2121
"h": 270.0,
2222
"w": 200.0,
23-
"x": 0.03125,
23+
"x": 0.03125610202550888,
2424
"y": 0.03703703731298447
2525
},
2626
"Global": {
2727
"h": 310.0,
2828
"w": 200.0,
29-
"x": 0.15625,
29+
"x": 0.156280517578125,
3030
"y": 0.03703703731298447
3131
},
3232
"Labels": {
3333
"h": 370.0,
3434
"w": 200.0,
35-
"x": 0.6979166865348816,
35+
"x": 0.6980530023574829,
3636
"y": 0.18518517911434174
3737
},
3838
"Level": {
3939
"h": 410.0,
4040
"w": 200.0,
41-
"x": 0.2916666567325592,
41+
"x": 0.2917236387729645,
4242
"y": 0.03703703731298447
4343
},
4444
"Macrobot": {
4545
"h": 330.0,
4646
"w": 200.0,
47-
"x": 0.03125,
47+
"x": 0.03125610202550888,
4848
"y": 0.3333333432674408
4949
},
5050
"Menu Settings": {
51-
"h": 370.0,
51+
"h": 440.0,
5252
"w": 200.0,
5353
"x": 0.4166666567325592,
5454
"y": 0.37037035822868347
5555
},
5656
"Player": {
5757
"h": 320.0,
5858
"w": 200.0,
59-
"x": 0.4166666567325592,
59+
"x": 0.416748046875,
6060
"y": 0.03703703731298447
6161
},
6262
"Recorder": {
6363
"h": 430.0,
6464
"w": 200.0,
65-
"x": 0.15625,
65+
"x": 0.156280517578125,
6666
"y": 0.35185185074806213
6767
},
6868
"Shortcuts": {
6969
"h": 350.0,
7070
"w": 200.0,
71-
"x": 0.8333333134651184,
71+
"x": 0.83349609375,
7272
"y": 0.03703703731298447
7373
},
7474
"res": {

res/hacks/global.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,6 @@
3838
}
3939
]
4040
},
41-
{
42-
"description": "Enables the mod button.",
43-
"name": "Become Moderator",
44-
"opcodes": [
45-
{
46-
"address": "0x252890",
47-
"on": "90 90"
48-
},
49-
{
50-
"address": "0x252895",
51-
"on": "90 90"
52-
}
53-
]
54-
},
5541
{
5642
"description": "Removed snapping to 0.00 setting volume to 0.03",
5743
"name": "Enable Low Volume",

src/GUI/Blur.cpp

Lines changed: 101 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,84 @@
22
#include "GUI.h"
33
#include "Settings.hpp"
44

5-
#include <Geode/modify/CCDirector.hpp>
65
#include <Geode/modify/CCEGLView.hpp>
6+
#include <Geode/modify/CCNode.hpp>
77

88
using namespace geode::prelude;
99
using namespace Blur;
1010

11+
struct Vertex {
12+
float position[3]; // 12 bytes
13+
unsigned char color[4]; // 4 bytes
14+
float texCoords[2]; // 8 bytes
15+
};
16+
17+
GLuint VAO, VBO;
18+
1119
class $modify(CCEGLView) {
1220

1321
void toggleFullScreen(bool value, bool borderless) {
1422
gdRenderTexture = nullptr;
1523
CCEGLView::toggleFullScreen(value, borderless);
1624
}
25+
26+
void resizeWindow(int width, int height)
27+
{
28+
CCEGLView::resizeWindow(width, height);
29+
30+
if(gdRenderTexture)
31+
gdRenderTexture->resize({(float)width, (float)height});
32+
}
1733
};
1834

19-
class $modify(CCDirector) {
20-
void drawScene() {
35+
class $modify(CCNode) {
36+
void visit() {
2137

22-
bool blur = Settings::get<bool>("menu/blur/enabled", false);
38+
bool blur = Settings::get<bool>("menu/blur/enabled", false) || Settings::get<bool>("menu/blur/gd", false);
2339

24-
if(!GUI::shouldRender() || !blur || !blurProgram)
40+
if(this != (CCNode*)CCDirector::sharedDirector()->getRunningScene() || !GUI::shouldRender() || !blur || !blurProgram)
2541
{
26-
CCDirector::drawScene();
42+
CCNode::visit();
2743
return;
2844
}
2945

30-
CCDirector::drawScene();
31-
32-
auto winSize = this->getOpenGLView()->getViewPortRect();
3346
if(!gdRenderTexture)
34-
gdRenderTexture = RenderTexture::create({winSize.size.width, winSize.size.height});
35-
36-
if(gdRenderTexture->resolution.x != winSize.size.width || gdRenderTexture->resolution.y != winSize.size.height)
3747
{
38-
gdRenderTexture->resize({winSize.size.width, winSize.size.height});
48+
auto winSize = CCDirector::sharedDirector()->getOpenGLView()->getViewPortRect();
49+
gdRenderTexture = RenderTexture::create({winSize.size.width, winSize.size.height});
3950
}
4051

4152
gdRenderTexture->bind();
4253
gdRenderTexture->clear();
43-
this->getRunningScene()->visit();
44-
gdRenderTexture->unbind();
54+
CCNode::visit();
55+
gdRenderTexture->unbind();
56+
57+
bool blurGD = Settings::get<bool>("menu/blur/gd", false);
4558

59+
glActiveTexture(GL_TEXTURE0);
60+
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
61+
glBindTexture(GL_TEXTURE_2D, gdRenderTexture->getTexture());
62+
63+
if(blurGD)
64+
{
65+
blurProgram->use();
66+
setBlurUniforms();
67+
}
68+
else
69+
{
70+
auto* shader = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor);
71+
shader->use();
72+
shader->setUniformsForBuiltins();
73+
}
74+
75+
glBindVertexArray(VAO);
76+
glDrawArrays(GL_QUADS, 0, 4);
77+
glBindVertexArray(0);
78+
79+
glBindTexture(GL_TEXTURE_2D, oldTexture);
80+
auto *shader = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor);
81+
shader->use();
82+
shader->setUniformsForBuiltins();
4683
}
4784
};
4885

@@ -77,6 +114,7 @@ varying vec2 v_texCoord;
77114
uniform sampler2D CC_Texture0;
78115
uniform float blurDarkness;
79116
uniform float blurSize;
117+
uniform float blurAmount;
80118
uniform int blurSteps;
81119
82120
void main()
@@ -86,9 +124,11 @@ void main()
86124
87125
vec4 sum = vec4(0.);
88126
127+
float scaledBlurSize = blurAmount * blurSize * 0.001;
128+
89129
for(int x = -blurSteps; x <= blurSteps; x++){
90130
for(int y = -blurSteps; y <= blurSteps; y++){
91-
vec2 newUV = v_texCoord + vec2(float(x) * blurSize, float(y) * blurSize);
131+
vec2 newUV = v_texCoord + vec2(float(x) * scaledBlurSize, float(y) * scaledBlurSize);
92132
sum += texture(CC_Texture0, newUV) * (exp(-(pow(float(x), 2.) + pow(float(y), 2.)) / (2. * pow(sigma, 2.))) / (2. * pi * pow(sigma, 2.)));
93133
}
94134
}
@@ -109,17 +149,42 @@ void Blur::compileBlurShader()
109149
blurProgram->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
110150
blurProgram->link();
111151
blurProgram->updateUniforms();
152+
153+
auto screenSize = CCDirector::sharedDirector()->getWinSize();
154+
155+
Vertex vertices[] = {
156+
{ 0.f, 0, 0.0f, 255, 255, 255, 255, 0.0f, 0.0f },
157+
{ screenSize.width + 0.1, 0.f, 0.0f, 255, 255, 255, 255, 1.0f, 0.0f },
158+
{ screenSize.width + 0.1, screenSize.height, 0.0f, 255, 255, 255, 255, 1.0f, 1.0f },
159+
{ 0, screenSize.height + 0, 0.0f, 255, 255, 255, 255, 0.0f, 1.0f },
160+
};
161+
162+
glGenVertexArrays(1, &VAO);
163+
glGenBuffers(1, &VBO);
164+
165+
glBindVertexArray(VAO);
166+
167+
glBindBuffer(GL_ARRAY_BUFFER, VBO);
168+
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), &vertices, GL_STATIC_DRAW);
169+
170+
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)0);
171+
glEnableVertexAttribArray(0);
172+
173+
glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), (GLvoid*)12);
174+
glEnableVertexAttribArray(1);
175+
176+
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)16);
177+
glEnableVertexAttribArray(2);
178+
179+
glBindBuffer(GL_ARRAY_BUFFER, 0);
180+
glBindVertexArray(0);
112181
}
113182

114-
void Blur::blurCallback(const ImDrawList*, const ImDrawCmd*)
183+
void Blur::setBlurUniforms()
115184
{
116-
glActiveTexture(GL_TEXTURE0);
117-
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
118-
blurProgram->use();
119-
glBindTexture(GL_TEXTURE_2D, gdRenderTexture->getTexture());
120185
blurProgram->setUniformsForBuiltins();
121186
float blurDarkness = Settings::get<float>("menu/blur/darkness", 1.f);
122-
float blurSize = Settings::get<float>("menu/blur/size", 0.0015f);
187+
float blurSize = Settings::get<float>("menu/blur/size", 1.f);
123188
int blurSteps = Settings::get<int>("menu/blur/steps", 10);
124189

125190
if(darknessUniform == -1)
@@ -136,6 +201,20 @@ void Blur::blurCallback(const ImDrawList*, const ImDrawCmd*)
136201
sizeUniform = blurProgram->getUniformLocationForName("blurSize");
137202
else
138203
blurProgram->setUniformLocationWith1f(sizeUniform, blurSize);
204+
205+
if(amountUniform == -1)
206+
amountUniform = blurProgram->getUniformLocationForName("blurAmount");
207+
else
208+
blurProgram->setUniformLocationWith1f(amountUniform, blurAmount);
209+
}
210+
211+
void Blur::blurCallback(const ImDrawList*, const ImDrawCmd*)
212+
{
213+
glActiveTexture(GL_TEXTURE0);
214+
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
215+
blurProgram->use();
216+
glBindTexture(GL_TEXTURE_2D, gdRenderTexture->getTexture());
217+
setBlurUniforms();
139218
}
140219

141220
void Blur::resetCallback(const ImDrawList*, const ImDrawCmd*)

src/GUI/Blur.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ namespace Blur
1313
inline GLint darknessUniform = -1;
1414
inline GLint stepsUniform = -1;
1515
inline GLint sizeUniform = -1;
16+
inline GLint amountUniform = -1;
17+
18+
inline float blurAmount = 1.f;
1619

1720
void compileBlurShader();
1821

1922
void blurWindowBackground();
2023

24+
void setBlurUniforms();
25+
2126
void blurCallback(const ImDrawList*, const ImDrawCmd*);
2227
void resetCallback(const ImDrawList*, const ImDrawCmd*);
2328
};

src/GUI/GUI.cpp

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,12 @@ void GUI::toggle()
163163
SafeMode::updateAuto();
164164

165165
isVisible = true;
166-
static bool toggle = false;
167-
toggle = !toggle;
166+
toggled = !toggled;
168167

169168
// 🔥🔥🔥🔥
170-
hideTimer = toggle ? -FLT_MAX : 0;
169+
hideTimer = toggled ? -FLT_MAX : 0;
171170

172-
if (!toggle)
171+
if (!toggled)
173172
save();
174173

175174
for (WindowAction* ac : windowActions)
@@ -204,7 +203,7 @@ void GUI::toggle()
204203
float transitionDuration = Settings::get<float>("menu/transition_duration", 0.35f);
205204

206205
WindowAction* action = WindowAction::create(
207-
transitionDuration, &w, toggle ? w.position : ImVec2(w.position.x + dir.x, w.position.y + dir.y));
206+
transitionDuration, &w, toggled ? w.position : ImVec2(w.position.x + dir.x, w.position.y + dir.y));
208207
windowActions.push_back(action);
209208
}
210209
}
@@ -325,6 +324,35 @@ void GUI::load()
325324
f.close();
326325
}
327326

327+
void GUI::resetDefault()
328+
{
329+
std::ifstream f(Mod::get()->getResourcesDir() / "default_windows.json");
330+
331+
if (f)
332+
{
333+
std::stringstream buffer;
334+
buffer << f.rdbuf();
335+
try
336+
{
337+
windowPositions = json::parse(buffer.str());
338+
}
339+
catch(json::parse_error& ex)
340+
{
341+
log::error("{}", ex.what());
342+
windowPositions = json::object();
343+
}
344+
buffer.clear();
345+
}
346+
f.close();
347+
348+
for(Window& window : windows)
349+
{
350+
window.position = getJsonPosition(window.name);
351+
window.renderPosition = window.position;
352+
window.size = getJsonSize(window.name, window.size);
353+
}
354+
}
355+
328356
void GUI::saveStyle(const ghc::filesystem::path& name)
329357
{
330358
ImGuiStyle style = ImGui::GetStyle();

src/GUI/GUI.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace GUI
2323

2424
inline bool isVisible = false;
2525
inline bool shortcutLoop = false;
26+
inline bool toggled = false;
2627

2728
inline bool hasLateInit = false;
2829

@@ -53,6 +54,8 @@ namespace GUI
5354
void save();
5455
void load();
5556

57+
void resetDefault();
58+
5659
void saveStyle(const ghc::filesystem::path& name);
5760
void loadStyle(const ghc::filesystem::path& name);
5861
void setStyle();

0 commit comments

Comments
 (0)