From 93c981115d825f3ba9f25100f16986cab7954b27 Mon Sep 17 00:00:00 2001 From: Explodingbill Date: Wed, 17 Jul 2024 15:32:13 +1000 Subject: [PATCH] update --- changelog.md | 2 ++ src/Client/Module.h | 4 ++-- src/Client/Types/ColourPickModule.cpp | 23 +++++++---------------- src/Client/Types/ColourPickModule.hpp | 14 +++----------- src/Keybinds/SetBindSetting.hpp | 7 ++----- src/Layers/SillyBaseLayer.cpp | 26 +++++++++++++------------- src/Layers/SillyBaseLayer.h | 4 ++++ src/UI/UIComponent.cpp | 14 ++++++++++++++ src/UI/UIComponent.hpp | 13 +++++++++++++ src/Utils/CCPastelLabelBMFont.hpp | 17 +++++++++-------- src/main.cpp | 2 +- 11 files changed, 70 insertions(+), 56 deletions(-) create mode 100644 src/UI/UIComponent.cpp create mode 100644 src/UI/UIComponent.hpp diff --git a/changelog.md b/changelog.md index 47973cb..00db9b8 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,8 @@ - Fixed multiple CPS Counter bugs - Added Total CPS option to CPS Counter - Changed how FPS is counted, should be more accurate +- Removed F12 keybind by default +- Fixed more touch issues # 1.4.7 diff --git a/src/Client/Module.h b/src/Client/Module.h index ca93963..97dcd50 100644 --- a/src/Client/Module.h +++ b/src/Client/Module.h @@ -2,8 +2,8 @@ #include "ColourUtility.h" #include "DrawUtils.h" - #include +#include "../UI/UIComponent.hpp" using namespace geode::prelude; @@ -21,7 +21,7 @@ class ModuleChangeDelegate } }; -class Module +class Module : public UIComponent { protected: std::vector hooks = {}; diff --git a/src/Client/Types/ColourPickModule.cpp b/src/Client/Types/ColourPickModule.cpp index a59184b..3d84894 100644 --- a/src/Client/Types/ColourPickModule.cpp +++ b/src/Client/Types/ColourPickModule.cpp @@ -11,9 +11,8 @@ void ColourModule::makeAndroid(CCNode* menu, CCPoint pos) btnSpr = CCSprite::createWithSpriteFrameName("GJ_colorBtn_001.png"); btnSpr->setColor(colour); btnSpr->setScale(0.75f); - auto btn = CCMenuItemSpriteExtra::create(btnSpr, menu, menu_selector(ColourModule::onPickColourAndroid)); + auto btn = CCMenuItemSpriteExtra::create(btnSpr, this, menu_selector(ColourModule::onPickColourAndroid)); - btn->setUserData(this); btn->setPosition(pos + ccp(135, 0) + ccp(-15, 0)); menu->addChild(btn); @@ -22,25 +21,17 @@ void ColourModule::makeAndroid(CCNode* menu, CCPoint pos) void ColourModule::onPickColourAndroid(CCObject* sender) { - auto v = as(as(sender)->getUserData()); + auto men = geode::ColorPickPopup::create(colour); - if (!v->delegate) - { - v->delegate = new ColourModuleDelegate(); - v->delegate->mod = v; - } - - auto men = geode::ColorPickPopup::create(v->colour); - - men->setDelegate(v->delegate); + men->setDelegate(this); men->show(); } -void ColourModuleDelegate::updateColor(cocos2d::ccColor4B const& color) +void ColourModule::updateColor(cocos2d::ccColor4B const& color) { - as(mod)->colour = ccc3(color.r, color.g, color.b); - as(mod)->btnSpr->setColor(as(mod)->colour); - as(mod)->save(); + colour = ccc3(color.r, color.g, color.b); + btnSpr->setColor(colour); + save(); } ColourModule::ColourModule(std::string name, std::string id, ccColor3B def) diff --git a/src/Client/Types/ColourPickModule.hpp b/src/Client/Types/ColourPickModule.hpp index d119d41..541f217 100644 --- a/src/Client/Types/ColourPickModule.hpp +++ b/src/Client/Types/ColourPickModule.hpp @@ -5,15 +5,7 @@ using namespace geode::prelude; -class ColourModuleDelegate : public ColorPickPopupDelegate -{ - public: - Module* mod; - - virtual void updateColor(cocos2d::ccColor4B const& color); -}; - -class ColourModule : public Module +class ColourModule : public Module, public ColorPickPopupDelegate { public: static inline ColourModule* selected = nullptr; @@ -21,8 +13,6 @@ class ColourModule : public Module ccColor3B colour = ccc3(255, 255, 255); ccColor3B def = ccc3(255, 255, 255); - ColourModuleDelegate* delegate; - CCSprite* btnSpr = nullptr; ColourModule(std::string name, std::string id, ccColor3B def); @@ -33,4 +23,6 @@ class ColourModule : public Module void onPickColourAndroid(cocos2d::CCObject* sender); void makeAndroid(CCNode* menu, CCPoint pos); + + virtual void updateColor(cocos2d::ccColor4B const& color); }; \ No newline at end of file diff --git a/src/Keybinds/SetBindSetting.hpp b/src/Keybinds/SetBindSetting.hpp index 4c8a255..2d693e0 100644 --- a/src/Keybinds/SetBindSetting.hpp +++ b/src/Keybinds/SetBindSetting.hpp @@ -12,7 +12,7 @@ class SetBindValue : public SettingValue public: static inline SetBindValue* instance = nullptr; - std::vector buttons = { enumKeyCodes::KEY_Tab, enumKeyCodes::KEY_Insert, enumKeyCodes::KEY_F12 }; + std::vector buttons = { enumKeyCodes::KEY_Tab, enumKeyCodes::KEY_Insert }; SetBindValue(std::string const& key, std::string const& modID) : SettingValue(key, modID) {} @@ -97,9 +97,6 @@ class SetBindNode : public SettingNode if (as(m_value)->buttons[0] != enumKeyCodes::KEY_Insert) return true; - if (as(m_value)->buttons[0] != enumKeyCodes::KEY_F12) - return true; - return false; } @@ -109,7 +106,7 @@ class SetBindNode : public SettingNode } void resetToDefault() override { - as(m_value)->buttons = { enumKeyCodes::KEY_Tab, enumKeyCodes::KEY_Insert, enumKeyCodes::KEY_F12 }; + as(m_value)->buttons = { enumKeyCodes::KEY_Tab, enumKeyCodes::KEY_Insert }; } static SetBindNode* create(SetBindValue* value, float width) { diff --git a/src/Layers/SillyBaseLayer.cpp b/src/Layers/SillyBaseLayer.cpp index 1c3024a..58946a1 100644 --- a/src/Layers/SillyBaseLayer.cpp +++ b/src/Layers/SillyBaseLayer.cpp @@ -2,14 +2,6 @@ bool SillyBaseLayer::setup() { - return true; -} - -bool SillyBaseLayer::initWithSizeAndName(CCPoint size, std::string _title, bool createWithOK, bool animate, bool noBlur) -{ - if (!initAnchored(69, 420)) - return false; - m_mainLayer->setVisible(false); this->stopAllActions(); this->setOpacity(0); @@ -21,9 +13,6 @@ bool SillyBaseLayer::initWithSizeAndName(CCPoint size, std::string _title, bool this->addChild(blur); } - this->size = size; - int priority = -504; - this->runAction(CCFadeTo::create(1, 100)); this->setKeypadEnabled(true); this->setTouchEnabled(false); @@ -32,7 +21,6 @@ bool SillyBaseLayer::initWithSizeAndName(CCPoint size, std::string _title, bool l->setContentSize(size); l->setPosition(CCDirector::get()->getWinSize() / 2); l->ignoreAnchorPointForPosition(false); - l->setTouchPriority(priority); int theme = Mod::get()->getSavedValue("theme", 5); @@ -133,7 +121,19 @@ bool SillyBaseLayer::initWithSizeAndName(CCPoint size, std::string _title, bool this->customSetup(); - handleTouchPriority(this); // sets the priority after setting up the custom layer, this will come back to fuck me in the ass + return true; +} + +bool SillyBaseLayer::initWithSizeAndName(CCPoint size, std::string _title, bool createWithOK, bool animate, bool noBlur) +{ + this->_title = _title; + this->createWithOK = createWithOK; + this->animate = animate; + this->noBlur = noBlur; + this->size = size; + + if (!initAnchored(69, 420)) + return false; return true; } diff --git a/src/Layers/SillyBaseLayer.h b/src/Layers/SillyBaseLayer.h index 28da8c3..c6717fb 100644 --- a/src/Layers/SillyBaseLayer.h +++ b/src/Layers/SillyBaseLayer.h @@ -14,6 +14,10 @@ class SillyBaseLayer : public geode::Popup<> CCMenuItemSpriteExtra* ok = nullptr; CCPoint size = CCPointZero; CCBlurLayer* blur = nullptr; + std::string _title; + bool createWithOK; + bool animate; + bool noBlur; ~SillyBaseLayer(); diff --git a/src/UI/UIComponent.cpp b/src/UI/UIComponent.cpp new file mode 100644 index 0000000..52308df --- /dev/null +++ b/src/UI/UIComponent.cpp @@ -0,0 +1,14 @@ +#include "UIComponent.hpp" + +void UIComponent::refreshNode() +{ + +} + +void UIComponent::setParent(CCNode* parent) +{ + CCNode::setParent(parent); + + this->removeAllChildrenWithCleanup(true); + refreshNode(); +} \ No newline at end of file diff --git a/src/UI/UIComponent.hpp b/src/UI/UIComponent.hpp new file mode 100644 index 0000000..f2fa9f9 --- /dev/null +++ b/src/UI/UIComponent.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include + +using namespace geode::prelude; + +class UIComponent : public CCNode +{ + public: + virtual void refreshNode(); + + virtual void setParent(CCNode* parent); +}; \ No newline at end of file diff --git a/src/Utils/CCPastelLabelBMFont.hpp b/src/Utils/CCPastelLabelBMFont.hpp index 5ae0ee6..c6beed8 100644 --- a/src/Utils/CCPastelLabelBMFont.hpp +++ b/src/Utils/CCPastelLabelBMFont.hpp @@ -4,14 +4,15 @@ using namespace geode::prelude; -class CCPastelLabelBMFont : public CCLabelBMFont { -public: - static CCPastelLabelBMFont* create(const char* text, const char* fontFile); - void update(float dt); +class CCPastelLabelBMFont : public CCLabelBMFont +{ + public: + static CCPastelLabelBMFont* create(const char* text, const char* fontFile); + void update(float dt); -protected: - CCPastelLabelBMFont(); - virtual ~CCPastelLabelBMFont(); + protected: + CCPastelLabelBMFont(); + virtual ~CCPastelLabelBMFont(); - bool initWithString(const char* text, const char* fontFile); + bool initWithString(const char* text, const char* fontFile); }; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index c569b48..0490926 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,7 +28,7 @@ class $modify (CCKeyboardDispatcher) { bool v = false; - std::vector btns = { enumKeyCodes::KEY_Tab, enumKeyCodes::KEY_F12, enumKeyCodes::KEY_Insert }; + std::vector btns = { enumKeyCodes::KEY_Tab, enumKeyCodes::KEY_Insert }; if (SetBindValue::instance) btns = SetBindValue::instance->buttons;