From c1550f1e1428488333940118454f42adef3a7f97 Mon Sep 17 00:00:00 2001
From: Alphalaneous <38200084+Alphalaneous@users.noreply.github.com>
Date: Wed, 14 Aug 2024 06:58:35 -0400
Subject: [PATCH] Important fixes
---
README.md | 17 ++++++++++++++
mod.json | 2 +-
src/UIModding.cpp | 15 +++++++++++-
src/UIModding.h | 1 +
src/nodes/MenuGameLayer.h | 48 +++++++++++++++++++++------------------
5 files changed, 59 insertions(+), 24 deletions(-)
diff --git a/README.md b/README.md
index bd6fa51..2c78374 100644
--- a/README.md
+++ b/README.md
@@ -438,6 +438,23 @@ When it comes to using the position attribute, you can change the x and y coordi
+ |
+
+
+
+ base-scale |
+ Set the base scale of a button (scaling a button returns to this rather than 1 when clicked). |
+
+
+```json
+"base-scale": 2
+```
+
+ |
+
+
+
+
|
diff --git a/mod.json b/mod.json
index 47a8c1f..c727592 100644
--- a/mod.json
+++ b/mod.json
@@ -5,7 +5,7 @@
"android": "2.206",
"mac": "2.206"
},
- "version": "v1.3.23",
+ "version": "v1.4.0",
"id": "alphalaneous.happy_textures",
"name": "Happy Textures :3",
"developer": "Alphalaneous",
diff --git a/src/UIModding.cpp b/src/UIModding.cpp
index b80955d..9043547 100644
--- a/src/UIModding.cpp
+++ b/src/UIModding.cpp
@@ -453,9 +453,9 @@ void UIModding::playSound(CCNode* node, matjson::Object attributes){
std::string sound = soundVal.as_string();
#ifndef GEODE_IS_ANDROID
- FMODAudioEngine::sharedEngine()->m_currentSoundChannel->setPaused(false);
FMODAudioEngine::sharedEngine()->m_backgroundMusicChannel->setPaused(false);
FMODAudioEngine::sharedEngine()->m_globalChannel->setPaused(false);
+ FMODAudioEngine::sharedEngine()->m_channelGroup2->setPaused(false);
FMODAudioEngine::sharedEngine()->m_system->update();
#endif
std::string soundPath = getSound(sound);
@@ -821,6 +821,18 @@ void UIModding::setScaleMult(CCNode* node, matjson::Object attributes){
}
}
+void UIModding::setScaleBase(CCNode* node, matjson::Object attributes){
+ if(attributes.contains("base-scale")){
+ matjson::Value baseVal = attributes["base-scale"];
+ if(baseVal.is_number()){
+ float base = baseVal.as_double();
+ if(CCMenuItemSpriteExtra* button = typeinfo_cast(node)) {
+ button->m_baseScale = base;
+ }
+ }
+ }
+}
+
void UIModding::setText(CCNode* node, matjson::Object attributes){
if(attributes.contains("text")){
matjson::Value textVal = attributes["text"];
@@ -1174,6 +1186,7 @@ void UIModding::handleModifications(CCNode* node, matjson::Object nodeObject){
nodesFor(setPosition);
nodesFor(setText);
nodesFor(setScaleMult);
+ nodesFor(setScaleBase);
nodesFor(setZOrder);
nodesFor(setFont);
nodesFor(setFlip);
diff --git a/src/UIModding.h b/src/UIModding.h
index be13d20..4176529 100644
--- a/src/UIModding.h
+++ b/src/UIModding.h
@@ -35,6 +35,7 @@ class UIModding {
void setColor(CCNode* node, matjson::Object attributes);
void setText(CCNode* node, matjson::Object attributes);
void setScaleMult(CCNode* node, matjson::Object attributes);
+ void setScaleBase(CCNode* node, matjson::Object attributes);
void setZOrder(CCNode* node, matjson::Object attributes);
void setFont(CCNode* node, matjson::Object attributes);
void setFlip(CCNode* node, matjson::Object attributes);
diff --git a/src/nodes/MenuGameLayer.h b/src/nodes/MenuGameLayer.h
index 63a57a7..3a74f1d 100644
--- a/src/nodes/MenuGameLayer.h
+++ b/src/nodes/MenuGameLayer.h
@@ -14,13 +14,29 @@ class $modify(MyMenuGameLayer, MenuGameLayer){
(void) self.setHookPriority("MenuGameLayer::update", INT_MIN);
}
+ void updateGroundSprite(CCSprite* spr){
+ std::optional dataOpt = UIModding::get()->getColors("main-menu-ground");
+ if(dataOpt.has_value()){
+ for(CCNode* node : CCArrayExt(spr->getChildren())){
+ if(CCSprite* child = typeinfo_cast(node)){
+ ColorData data = dataOpt.value();
+ child->setColor(data.color);
+ child->setOpacity(data.alpha);
+ }
+ }
+ ColorData data = dataOpt.value();
+ spr->setColor(data.color);
+ spr->setOpacity(data.alpha);
+ }
+ }
+
void update(float p0){
MenuGameLayer::update(p0);
if(UIModding::get()->doModify){
- CCSprite* bg = getChildOfType(this, 0);
- GJGroundLayer* ground = getChildOfType(this, 0);
+ CCSprite* bg = typeinfo_cast(getChildByID("background"));
+ GJGroundLayer* ground = typeinfo_cast(getChildByID("ground"));
if(bg){
std::optional dataOpt = UIModding::get()->getColors("main-menu-bg");
@@ -31,26 +47,14 @@ class $modify(MyMenuGameLayer, MenuGameLayer){
}
}
if(ground){
- CCSpriteBatchNode* groundBatch = getChildOfType(ground, 0);
- if(groundBatch){
- CCSprite* groundSprite = getChildOfType(groundBatch, 0);
- if(groundSprite){
- for(CCNode* node : CCArrayExt(groundSprite->getChildren())){
- if(CCSprite* child = typeinfo_cast(node)){
- std::optional dataOpt = UIModding::get()->getColors("main-menu-ground");
- if(dataOpt.has_value()){
- ColorData data = dataOpt.value();
- child->setColor(data.color);
- child->setOpacity(data.alpha);
- }
- }
- }
- std::optional dataOpt = UIModding::get()->getColors("main-menu-ground");
- if(dataOpt.has_value()){
- ColorData data = dataOpt.value();
- groundSprite->setColor(data.color);
- groundSprite->setOpacity(data.alpha);
- }
+ if(CCSpriteBatchNode* groundSprites = typeinfo_cast(ground->getChildByID("ground-sprites"))){
+ if(CCSprite* groundSprite = getChildOfType(groundSprites, 0)) {
+ updateGroundSprite(groundSprite);
+ }
+ }
+ if(CCSpriteBatchNode* groundSprites2 = typeinfo_cast(ground->getChildByID("ground-sprites-2"))){
+ if(CCSprite* groundSprite = getChildOfType(groundSprites2, 0)) {
+ updateGroundSprite(groundSprite);
}
}
}