Skip to content

Commit d6c12af

Browse files
committed
bug fix
1 parent 7edf34b commit d6c12af

File tree

7 files changed

+14
-147
lines changed

7 files changed

+14
-147
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.9.2
2+
- Fix a memory leak when setting a font file on a CCLabelBMFont
3+
- Remove batch node hack :P
4+
15
## 1.9.1
26
- Fix a crash with labels
37
- Revamp Texture Loader pack nodes

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"android": "2.2074",
66
"mac": "2.2074"
77
},
8-
"version": "v1.9.1",
8+
"version": "v1.9.2",
99
"id": "alphalaneous.happy_textures",
1010
"name": "Happy Textures :3",
1111
"developer": "Alphalaneous",

src/Config.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class Config {
88
protected:
99
static Config* instance;
1010
public:
11-
bool m_batchNodesEnabled = true;
1211
std::unordered_map<std::string, std::vector<matjson::Value>> m_packSettings;
1312

1413
std::optional<matjson::Value> loadIntoJson(geode::texture_loader::Pack pack) {
@@ -58,7 +57,7 @@ class Config {
5857
}
5958

6059
void loadConfig(geode::texture_loader::Pack pack, matjson::Value config) {
61-
if (m_batchNodesEnabled) m_batchNodesEnabled = config["batch-nodes"].asBool().unwrapOr(true);
60+
6261
loadSettings(pack, config);
6362
}
6463

src/UIModding.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,7 @@ void UIModding::setFont(CCNode* node, matjson::Value attributes) {
661661
if (utils::string::endsWith(font, ".fnt")) {
662662
MyCCLabelBMFont* myTextObject = static_cast<MyCCLabelBMFont*>(textObject);
663663

664-
CCLabelBMFont* dummyTextObject = CCLabelBMFont::create("", font.c_str());
665-
if (dummyTextObject) {
664+
if (FNTConfigLoadFile(font.c_str())) {
666665
textObject->setFntFile(font.c_str());
667666

668667
if (myTextObject->m_fields->m_isLimited) {
@@ -1008,9 +1007,7 @@ void UIModding::setSprite(CCNode* node, matjson::Value attributes) {
10081007
CCSprite* spr = Utils::getValidSprite(texture.c_str());
10091008
if (!spr) return;
10101009

1011-
CCLabelBMFont* fnt = CCLabelBMFont::create("", font.c_str());
1012-
1013-
if (spr && fnt) {
1010+
if (FNTConfigLoadFile(font.c_str())) {
10141011
auto buttonSprite = ButtonSprite::create(caption.c_str(), width, absolute, font.c_str(), texture.c_str(), height, scale);
10151012
buttonNode->setNormalImage(buttonSprite);
10161013
Utils::updateSprite(buttonNode);

src/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "nodes/GJGarageLayer.h"
2626
#include "nodes/CCNode.h"
2727
#include "nodes/CCSprite.h"
28-
#include "nodes/CCSpriteBatchNode.h"
2928
#include "nodes/CCDirector.h"
3029
#include "NodeModding.h"
3130
#include "BackgroundColors.h"

src/nodes/CCLabelBMFont.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,15 @@ class $modify(MyCCLabelBMFont, CCLabelBMFont) {
9494
}
9595

9696
void checkParent(float dt) {
97-
98-
if (auto parent = this->getParent()) {
97+
if (auto parent = getParent()) {
9998
if (typeinfo_cast<LabelGameObject*>(parent)) {
100-
if (strcmp(this->getFntFile(), "bigFont.fnt") == 0) {
101-
ccBlendFunc blendFunc = this->getBlendFunc();
102-
this->setFntFile("bigFont.fnt"_spr);
103-
this->setBlendFunc(blendFunc);
99+
if (std::string_view(getFntFile()) == "bigFont.fnt") {
100+
ccBlendFunc blendFunc = getBlendFunc();
101+
setFntFile("bigFont.fnt"_spr);
102+
setBlendFunc(blendFunc);
104103
}
105104
}
106-
this->unschedule(m_fields->m_schedule);
105+
unschedule(m_fields->m_schedule);
107106
}
108107
}
109108
};

src/nodes/CCSpriteBatchNode.h

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)