Skip to content

Commit

Permalink
Change chest overlay color
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphalaneous committed Jul 31, 2024
1 parent 87099ae commit 29ce176
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"android": "2.206",
"mac": "2.206"
},
"version": "v1.3.20",
"version": "v1.3.21",
"id": "alphalaneous.happy_textures",
"name": "Happy Textures :3",
"developer": "Alphalaneous",
Expand Down
1 change: 0 additions & 1 deletion src/CCDirector.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class $modify(CCDirector){
(void) self.setHookPriority("CCDirector::willSwitchToScene", INT_MIN);
}


void willSwitchToScene(CCScene* scene){
if(UIModding::get()->doModify){
if(CCSprite* bg = typeinfo_cast<CCSprite*>(scene->getChildByIDRecursive("background"))){
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "nodes/LoadingLayer.h"
#include "nodes/MenuGameLayer.h"
#include "nodes/MenuLayer.h"
#include "nodes/GJChestSprite.h"
#include "icons/IconHandler.h"
#include "CCDirector.h"

Expand Down
59 changes: 59 additions & 0 deletions src/nodes/GJChestSprite.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#pragma once

#ifndef MYGJCHESTSPRITE_H
#define MYGJCHESTSPRITE_H

#include <Geode/Geode.hpp>
#include <Geode/modify/GJChestSprite.hpp>

using namespace geode::prelude;

class $modify(MyGJChestSprite, GJChestSprite){

static void onModify(auto& self) {
(void) self.setHookPriority("GJChestSprite::switchToState", INT_MIN);
}

static CCNode* getChildBySpriteFrameName(CCNode* parent, const char* name, int index = 0) {
int idx = 0;
for (auto child : CCArrayExt<CCNode*>(parent->getChildren())) {
if (::isSpriteFrameName(static_cast<CCNode*>(child), name)) {
if(idx == index) return child;
idx++;
}
}
return nullptr;
}

void switchToState(ChestSpriteState p0, bool p1){

GJChestSprite::switchToState(p0, p1);

if(UIModding::get()->doModify){

if(p0 == ChestSpriteState::Opened){

auto glow0 = static_cast<CCSprite*>(getChildBySpriteFrameName(this, "chest_glow_bg_001.png"));
auto glow1 = static_cast<CCSprite*>(getChildBySpriteFrameName(this, "chest_glow_bg_001.png", 1));
auto square = static_cast<CCSprite*>(getChildBySpriteFrameName(this, "block005b_05_001.png"));

if(!glow0 || !glow1 || !square) return;

std::optional<ColorData> dataOpt = UIModding::get()->getColors("chest-opened-overlay");
if(dataOpt.has_value()){
ColorData data = dataOpt.value();

glow0->setColor(data.color);
glow1->setColor(data.color);
square->setColor(data.color);

glow0->setOpacity(data.alpha);
glow1->setOpacity(data.alpha);
square->setOpacity(data.alpha);
}
}
}
}
};

#endif

0 comments on commit 29ce176

Please sign in to comment.