Skip to content

Commit de542fe

Browse files
committed
Fixes
1 parent dc61099 commit de542fe

File tree

5 files changed

+55
-137
lines changed

5 files changed

+55
-137
lines changed

changelog.md

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
## 2.0.5
1+
# 2.0.6
2+
- Quick fixes you'll never see as an end user
3+
- Still haven't fixed certain reported issues that require extensive testing, please be patient on those
4+
5+
# 2.0.5
26
- No more flicker on table cells
37
- Reduce hooks (using Alpha's Geode Utils)
48
- Performance Improvements
59
- Code cleanup
610

7-
## 2.0.4
11+
# 2.0.4
812
- Fix a crash
913

10-
## 2.0.3
14+
# 2.0.3
1115
- Fix a cocos bug
1216

13-
## 2.0.2
17+
# 2.0.2
1418
- Bug fix
1519

16-
## 2.0.1
20+
# 2.0.1
1721
- Fix a crash when a texture name was too short
1822
- Update UI at end of frame rather than start
1923

20-
## 2.0.0
24+
# 2.0.0
2125
**NOTICE! Modifying nodes by ID is removed. You must now modify them by their class name instead.**
2226
- Code cleanup
2327
- Multi pack UI modding (packs can now modify other packs based on priority in Texture Loader)
@@ -30,121 +34,121 @@
3034
- No longer double activates transitions
3135
- Hot reload fixes
3236

33-
## 1.9.10
37+
# 1.9.10
3438
- Bug fixes
3539

36-
## 1.9.9
40+
# 1.9.9
3741
- Fix sprite crash
3842

39-
## 1.9.8
43+
# 1.9.8
4044
- Add basic support for SimpleAxisLayout
4145
- Fix setDisplayFrame not using changed textures
4246

43-
## 1.9.7
47+
# 1.9.7
4448
- Fix 2
4549

46-
## 1.9.6
50+
# 1.9.6
4751
- Fix
4852

49-
## 1.9.5
53+
# 1.9.5
5054
- iOS support
5155

52-
## 1.9.4
56+
# 1.9.4
5357
- Fix a bug with sprite frames not being able to be set
5458
- Fix some load delay
5559

56-
## 1.9.3
60+
# 1.9.3
5761
**NOTICE! Modifying nodes by ID will soon be depreciated. Once the next GD update comes out, I will be removing that feature in favor of modifying nodes by their class name. This is the name BEFORE the one in quotes in DevTools. For example `ui/cvolton.betterinfo$ExtendedLevelInfo.json` will become `ui/ExtendedLevelInfo.json` and anything in the nodes folder will no longer work and should be placed in the UI folder.**
5862
- Fixed crash when pressing space on main menu for mac
5963

60-
## 1.9.2
64+
# 1.9.2
6165
- Fix a memory leak when setting a font file on a CCLabelBMFont
6266
- Remove batch node hack :P
6367

64-
## 1.9.1
68+
# 1.9.1
6569
- Fix a crash with labels
6670
- Revamp Texture Loader pack nodes
6771
- Add Friend Requests cells to the default cell color modifications
6872
- Use geode::Popup for alerts
6973
- General code cleanup
7074

71-
## 1.9.0
75+
# 1.9.0
7276
- Conditionals (If statements) (See Wiki)
7377
- Root node shortcut (See Wiki)
7478
- More variables (See Wiki)
7579
- Updated Rift
7680

77-
## 1.8.8
81+
# 1.8.8
7882
- Implement a fix for another mod's mistake :P
7983

80-
## 1.8.7
84+
# 1.8.7
8185
- Fix a very teeny bug that may break MenuLayer changes
8286

83-
## 1.8.6
87+
# 1.8.6
8488
- Added "after-transition" object for layers in a scene, allowing for you to only make changes after the transition finishes (see wiki for more details)
8589
- Fixed cache failing to be reset, resulting in missing textures when a pack is unapplied
8690

87-
## 1.8.5
91+
# 1.8.5
8892
- Cleanup filesystem code
8993
- Fix a crash when there is an invalid path (hopefully)
9094
- Fix an issue with CCSpriteWithHue
9195

92-
## 1.8.4
96+
# 1.8.4
9397
- Actually fix loading individual sprites from init
9498

95-
## 1.8.3
99+
# 1.8.3
96100
- Fix loading individual sprites from init
97101

98-
## 1.8.2
102+
# 1.8.2
99103
- Fix some layouting issues
100104
- Fix duplicated node modifications for certain layers
101105
- Fix individual sprites not working if only some qualities are present
102106
- Fix applied packs not updating (uses a new Texture Loader API, make sure Texture Loader is up to date if you experience this issue!)
103107

104-
## 1.8.1
108+
# 1.8.1
105109
- Fix crash on non-windows
106110
- Change individual sprite changing logic
107111

108-
## 1.8.0
112+
# 1.8.0
109113
- Support for retexturing individual sprites outside of spritesheets (see wiki for more details)
110114
- Support for disabling batch nodes (for UI purposes, in levels they will not be disabled)
111115

112-
## 1.7.8
116+
# 1.7.8
113117
- list-cell-selected added to hardcoded color modifications for leaderboards
114118
- Changed hook prio logic
115119
- Mac support for everything
116120

117-
## 1.7.7
121+
# 1.7.7
118122
- Zipped packs should work properly now
119123
- Fixed issues with file listener
120124
- Fixed issues with path separators
121125

122-
## 1.7.6
126+
# 1.7.6
123127
- Node by typeid bugfix
124128

125-
## 1.7.5
129+
# 1.7.5
126130
- Allow inputting hex colors
127131
- Fix sprite frame texture rotate bug
128132
- Fix an issue where onCreator and onGarage wouldn't work
129133

130-
## 1.7.4
134+
# 1.7.4
131135
- Fix a crash that can occur when pressing space on the main menu
132136
- Fix a crash that can occur with invalid parents
133137
- Added new scroll-to-top attribute for ScrollLayers
134138
- Added new lock-attributes attribute to reset attributes every frame
135139

136-
## 1.7.3
140+
# 1.7.3
137141
- Fix an issue with MenuLayer::onPlay callbacks not working because apparently it is a meanie head and wanted to be rude :(
138142

139-
## 1.7.2
143+
# 1.7.2
140144
- Add the ability to run certain button callbacks anywhere
141145

142-
## 1.7.1
146+
# 1.7.1
143147
- Fix a freeze that could happen on launch if GD was on a separate drive
144148
- Fix node modifications not properly reloading on pack change
145149
- Getting a node by type now allows for any class to be passed in
146150

147-
## 1.7.0
151+
# 1.7.0
148152
- Node Specific Changes Updates:
149153
- Now any node type can be modified
150154
- Node type modification code simplified (better performance)
@@ -158,16 +162,16 @@
158162
- Allow stacking multiple events on a button instead of only 1
159163
- General performance improvements
160164

161-
## 1.6.2
165+
# 1.6.2
162166
- Fix a crash with cursed FLAlertLayers
163167

164-
## 1.6.1
168+
# 1.6.1
165169
- Bug fix for variables not working in popups created by HT Packs
166170

167-
## 1.6.0
171+
# 1.6.0
168172
- <cg>Add extensive label variables with RIFT</c>
169173
- Add color changing for music library cells
170174
- Code cleanup
171175

172-
## <1.6.0
176+
# <1.6.0
173177
- Add everything

mod.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
2-
"geode": "4.6.2",
2+
"geode": "4.7.0",
33
"gd": {
44
"win": "2.2074",
55
"android": "2.2074",
66
"mac": "2.2074",
77
"ios": "2.2074"
88
},
9-
"version": "v2.0.5",
9+
"version": "v2.0.6",
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",
17+
"alphalaneous.alphas_geode_utils": ">=v1.1.8",
1818
"geode.texture-loader": {
1919
"importance": "suggested",
2020
"version": ">=v1.7.0"

src/NodeModding.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class $modify(CCObject) {
3636

3737
if (MyCCNode* node = static_cast<MyCCNode*>(typeinfo_cast<CCNode*>(this))) {
3838
if (!node->isModified()) {
39-
const std::string& className = Utils::getNodeName(node);
39+
const std::string& className = AlphaUtils::Cocos::getClassName(node, true);
4040
node->retain();
4141
LateQueue::get()->queue([modding, node, className] {
4242
modding->doUICheckForType(className, node);

src/UIModding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ void UIModding::reloadChildren(CCNode* parentNode, bool transition) {
14211421

14221422
void UIModding::refreshChildren(CCNode* parentNode) {
14231423
MyCCNode* myParentNode = static_cast<MyCCNode*>(parentNode);
1424-
doUICheckForType(Utils::getNodeName(parentNode), parentNode);
1424+
doUICheckForType(AlphaUtils::Cocos::getClassName(parentNode, true), parentNode);
14251425
for (auto* node : CCArrayExt<MyCCNode*>(myParentNode->getChildren())) {
14261426
refreshChildren(node);
14271427
}

src/Utils.hpp

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

33
#include <Geode/Geode.hpp>
44
#include "UIModding.hpp"
5-
#include <random>
65
#include "Macros.hpp"
76
#include <geode.texture-loader/include/TextureLoader.hpp>
7+
#include <alphalaneous.alphas_geode_utils/include/Utils.h>
88

99
using namespace geode::prelude;
1010

@@ -22,15 +22,7 @@ namespace Utils {
2222

2323
template <typename Layer, typename = std::enable_if_t<std::is_pointer_v<Layer>>>
2424
static Layer getLayer() {
25-
auto* scene = CCDirector::sharedDirector()->getRunningScene();
26-
if (!scene) return nullptr;
27-
28-
if (auto* trans = typeinfo_cast<CCTransitionScene*>(scene)) {
29-
scene = public_cast(trans, m_pInScene);
30-
if (!scene) return nullptr;
31-
}
32-
33-
return scene->getChildByType<Layer>(0);
25+
return AlphaUtils::Cocos::getLayer<Layer>().value_or(nullptr);
3426
}
3527

3628
static int getValidStat(const std::string& key) {
@@ -49,62 +41,17 @@ namespace Utils {
4941
}
5042

5143
static bool hasNode(CCNode* child, CCNode* node) {
52-
for (CCNode* current = child; current != nullptr; current = current->getParent()) {
53-
if (current == node) {
54-
return true;
55-
}
56-
}
57-
return false;
44+
return AlphaUtils::Cocos::hasNode(child, node);
5845
}
5946

60-
6147
//fix texture loader fallback
6248

6349
static CCSprite* getValidSprite(const char* sprName) {
64-
CCSprite* spr = CCSprite::create(sprName);
65-
if (!spr || spr->getUserObject("geode.texture-loader/fallback")) {
66-
return nullptr;
67-
}
68-
return spr;
50+
return AlphaUtils::Cocos::getSprite(sprName).value_or(nullptr);
6951
}
7052

71-
//fix texture loader fallback
72-
7353
static CCSprite* getValidSpriteFrame(const char* sprName) {
74-
CCSprite* spr = CCSprite::createWithSpriteFrameName(sprName);
75-
if (!spr || spr->getUserObject("geode.texture-loader/fallback")) {
76-
return nullptr;
77-
}
78-
return spr;
79-
}
80-
81-
static std::string nameForClass(const std::string& className) {
82-
size_t lastSpace = className.rfind(' ');
83-
size_t start = (lastSpace == std::string::npos) ? 0 : lastSpace + 1;
84-
85-
size_t lastColon = className.rfind("::");
86-
size_t nameStart = (lastColon != std::string::npos && lastColon >= start)
87-
? lastColon + 2
88-
: start;
89-
90-
return className.substr(nameStart);
91-
}
92-
93-
static std::string getNodeName(CCObject* node) {
94-
#ifdef GEODE_IS_WINDOWS
95-
return nameForClass(typeid(*node).name() + 6);
96-
#else
97-
std::string ret;
98-
99-
int status = 0;
100-
auto demangle = abi::__cxa_demangle(typeid(*node).name(), 0, 0, &status);
101-
if (status == 0) {
102-
ret = demangle;
103-
}
104-
free(demangle);
105-
106-
return nameForClass(ret);
107-
#endif
54+
return AlphaUtils::Cocos::getSpriteByFrameName(sprName).value_or(nullptr);
10855
}
10956

11057
static void setColorIfExists(CCRGBAProtocol* node, const std::string& colorId) {
@@ -131,15 +78,7 @@ namespace Utils {
13178
}
13279

13380
static int getRandomNumber(int lower, int upper) {
134-
if (lower > upper) {
135-
std::swap(lower, upper);
136-
}
137-
138-
static std::random_device rd;
139-
static std::mt19937 gen(rd());
140-
141-
std::uniform_int_distribution<> dist(lower, upper);
142-
return dist(gen);
81+
return AlphaUtils::Misc::getRandomNumber(lower, upper);
14382
}
14483

14584
static void clearCaches() {
@@ -215,32 +154,7 @@ namespace Utils {
215154
}
216155

217156
static CCNode* getChildByTypeName(CCNode* node, int index, const std::string& name) {
218-
if (!node || node->getChildrenCount() == 0) return nullptr;
219-
220-
size_t indexCounter = 0;
221-
const size_t childrenCount = node->getChildrenCount();
222-
223-
bool isNegativeIndex = (index < 0);
224-
if (isNegativeIndex) {
225-
index = -index - 1;
226-
}
227-
228-
for (size_t i = (isNegativeIndex ? childrenCount - 1 : 0);
229-
isNegativeIndex ? i >= 0 : i < childrenCount;
230-
isNegativeIndex ? --i : ++i) {
231-
232-
CCNode* idxNode = static_cast<CCNode*>(node->getChildren()->objectAtIndex(i));
233-
if (getNodeName(idxNode) == name) {
234-
if (indexCounter == index) {
235-
return idxNode;
236-
}
237-
++indexCounter;
238-
}
239-
240-
if (isNegativeIndex && i == 0) break;
241-
}
242-
243-
return nullptr;
157+
return AlphaUtils::Cocos::getChildByClassName(node, name, index).value_or(nullptr);
244158
}
245159

246160
}

0 commit comments

Comments
 (0)