Skip to content

Commit dc61099

Browse files
committed
Fixes
1 parent 565f448 commit dc61099

30 files changed

+256
-387
lines changed

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.0.5
2+
- No more flicker on table cells
3+
- Reduce hooks (using Alpha's Geode Utils)
4+
- Performance Improvements
5+
- Code cleanup
6+
17
## 2.0.4
28
- Fix a crash
39

mod.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
"mac": "2.2074",
77
"ios": "2.2074"
88
},
9-
"version": "v2.0.4",
9+
"version": "v2.0.5",
1010
"id": "alphalaneous.happy_textures",
1111
"name": "Happy Textures :3",
1212
"developer": "Alphalaneous",
1313
"description": "Texture Packs on a whole new level!",
1414
"early-load": true,
1515
"dependencies": {
1616
"geode.node-ids": ">=v1.15.0",
17+
"alphalaneous.alphas_geode_utils": ">=v1.1.7",
1718
"geode.texture-loader": {
1819
"importance": "suggested",
1920
"version": ">=v1.7.0"

src/BackgroundColors.hpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "UIModding.hpp"
88
#include "Macros.hpp"
99
#include "Utils.hpp"
10+
#include <alphalaneous.alphas_geode_utils/include/NodeModding.h>
1011

1112
using namespace geode::prelude;
1213

@@ -32,28 +33,14 @@ class $modify(CCDirector) {
3233
}
3334
};
3435

35-
class $modify(LeaderboardsLayer) {
36-
37-
static void onModify(auto& self) {
38-
HOOK_LATEST("LeaderboardsLayer::init");
39-
}
40-
41-
bool init(LeaderboardState p0) {
42-
if (!LeaderboardsLayer::init(p0)) return false;
36+
class $nodeModify(LeaderboardsLayer) {
37+
void modify() {
4338
setBackground(this);
44-
return true;
4539
}
4640
};
4741

48-
class $modify(LevelBrowserLayer) {
49-
50-
static void onModify(auto& self) {
51-
HOOK_LATEST("LevelBrowserLayer::init");
52-
}
53-
54-
bool init(GJSearchObject* p0) {
55-
if (!LevelBrowserLayer::init(p0)) return false;
42+
class $nodeModify(LevelBrowserLayer) {
43+
void modify() {
5644
setBackground(this);
57-
return true;
5845
}
5946
};

src/Config.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include <Geode/Geode.hpp>
4-
#include "Utils.hpp"
54
#include <geode.texture-loader/include/TextureLoader.hpp>
65

76
class Config {
@@ -25,7 +24,7 @@ class Config {
2524

2625
void loadPackJsons() {
2726

28-
Mod* textureLoader = Loader::get()->getLoadedMod("geode.texture-loader");
27+
geode::Mod* textureLoader = geode::Loader::get()->getLoadedMod("geode.texture-loader");
2928
if (textureLoader) {
3029
for (const geode::texture_loader::Pack& pack : geode::texture_loader::getAppliedPacks()) {
3130
std::optional<matjson::Value> json = loadIntoJson(pack);
@@ -55,7 +54,6 @@ class Config {
5554
}
5655

5756
void loadConfig(geode::texture_loader::Pack pack, matjson::Value config) {
58-
5957
loadSettings(pack, config);
6058
}
6159

src/LateQueue.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "LateQueue.hpp"
2+
3+
LateQueue* LateQueue::instance = nullptr;
4+
5+
void LateQueue::queue(ScheduledFunction&& func) {
6+
m_mainThreadQueue.push_back(std::move(func));
7+
}
8+
9+
void LateQueue::executeQueue() {
10+
for (auto const& func : m_mainThreadQueue) {
11+
if (func) func();
12+
}
13+
m_mainThreadQueue.clear();
14+
}
15+
16+
LateQueue* LateQueue::get() {
17+
if (!instance) {
18+
instance = new LateQueue();
19+
};
20+
return instance;
21+
}

src/LateQueue.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include <Geode/Geode.hpp>
4+
5+
using namespace geode::prelude;
6+
7+
//yoinked from geode
8+
class LateQueue {
9+
protected:
10+
static LateQueue* instance;
11+
public:
12+
std::vector<ScheduledFunction> m_mainThreadQueue;
13+
14+
void queue(ScheduledFunction&& func);
15+
void executeQueue();
16+
static LateQueue* get();
17+
};

src/Macros.hpp

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,17 @@ if (eventVal.contains(#type)) {
6868
} \
6969
}
7070

71-
#define setCellColors(class, method, paramType) \
72-
struct My##class : geode::Modify<My##class, class> { \
73-
static void onModify(auto& self) { \
74-
HOOK_LATEST(#class "::" #method); \
75-
} \
76-
struct Fields { \
77-
ccColor3B m_lastBG; \
78-
}; \
79-
void method(paramType* p0) { \
80-
class::method(p0); \
71+
#define setCellColors(className) \
72+
class $nodeModify(My##className, className) { \
73+
void modify() { \
8174
if (UIModding::get()->doModify) { \
8275
checkBG(0); \
83-
this->schedule(schedule_selector(My##class::checkBG)); \
76+
this->schedule(schedule_selector(My##className::checkBG)); \
8477
} \
8578
} \
8679
void checkBG(float dt) { \
87-
auto* child = this->getChildByType<CCLayerColor>(0); \
88-
if (!child) return; \
89-
\
90-
auto color = child->getColor(); \
91-
auto fields = m_fields.self(); \
92-
if (fields->m_lastBG == color) return; \
93-
fields->m_lastBG = color; \
80+
auto self = reinterpret_cast<className*>(this); \
81+
auto color = self->m_backgroundLayer->getColor(); \
9482
\
9583
struct ColorMap { \
9684
ccColor3B match; \
@@ -107,14 +95,14 @@ struct My##class : geode::Modify<My##class, class> {
10795
if (color == entry.match) { \
10896
if (auto dataOpt = UIModding::get()->getColors(entry.ID)) { \
10997
const auto& data = *dataOpt; \
110-
child->setColor(data.color); \
111-
child->setOpacity(data.alpha); \
98+
self->m_backgroundLayer->setColor(data.color); \
99+
self->m_backgroundLayer->setOpacity(data.alpha); \
112100
} \
113101
break; \
114102
} \
115103
} \
116104
} \
117-
};
105+
}
118106

119107
#define LABEL(name, value) {name, rift::Value::from(value)}
120108

src/NodeModding.hpp

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,10 @@
88
#include "nodes/CCNode.hpp"
99
#include "Utils.hpp"
1010
#include "Macros.hpp"
11+
#include "LateQueue.hpp"
1112

1213
using namespace geode::prelude;
1314

14-
// yoinked from geode but removed mutex cuz I will likely never use this in a thread and seems to crash proton/wine ??
15-
class LateQueue {
16-
protected:
17-
static LateQueue* instance;
18-
public:
19-
std::vector<std::function<void(void)>> m_mainThreadQueue;
20-
21-
void queue(ScheduledFunction&& func) {
22-
m_mainThreadQueue.push_back(std::forward<ScheduledFunction>(func));
23-
}
24-
25-
void executeQueue() {
26-
for (auto const& func : m_mainThreadQueue) {
27-
if (func) func();
28-
}
29-
m_mainThreadQueue.clear();
30-
}
31-
32-
static LateQueue* get() {
33-
if (!instance) {
34-
instance = new LateQueue();
35-
};
36-
return instance;
37-
}
38-
};
39-
LateQueue* LateQueue::instance = nullptr;
40-
4115
class $modify(CCDictionary) {
4216

4317
// Cocos will call autorelease on a nullptr here for some reason,
@@ -61,7 +35,7 @@ class $modify(CCObject) {
6135
if (!modding->doModify) return CCObject::autorelease();
6236

6337
if (MyCCNode* node = static_cast<MyCCNode*>(typeinfo_cast<CCNode*>(this))) {
64-
if (modding->finishedLoad && !node->isModified()) {
38+
if (!node->isModified()) {
6539
const std::string& className = Utils::getNodeName(node);
6640
node->retain();
6741
LateQueue::get()->queue([modding, node, className] {

src/UIModding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ void UIModding::createAndModifyNewChild(CCNode* node, const matjson::Value& newC
12851285
buttonText = attributesVal["button-text"].asString().unwrapOr("");
12861286
}
12871287
FLAlertLayer* alert = geode::createQuickPopup(title.c_str(), description, buttonText.c_str(), nullptr, nullptr, false, true);
1288-
static_cast<MyFLAlertLayer*>(alert)->setRift();
1288+
reinterpret_cast<MyFLAlertLayer*>(alert)->setRift();
12891289
DataNode* data = DataNode::create(alert);
12901290
newNode = data;
12911291
}

src/UIModding.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class UIModding {
2525
std::vector<FileWatcher*> listeners;
2626
Ref<CCArray> removalQueue = CCArray::create();
2727
bool doModify;
28-
bool finishedLoad;
2928
bool skipCheck;
3029

3130
void recursiveModify(CCNode* node, const matjson::Value& elements);

0 commit comments

Comments
 (0)