From 281d7942d0848372ba46da6fb8a80660b5902810 Mon Sep 17 00:00:00 2001 From: Explodingbill Date: Tue, 20 Aug 2024 20:23:18 +1000 Subject: [PATCH] keybinds --- about.md | 2 +- src/Client/AndroidUI.cpp | 8 ++ src/Client/AndroidUI.h | 4 +- src/Client/Client.cpp | 52 +++++++++++ src/Client/Client.h | 4 + src/Client/Module.cpp | 14 +++ src/Client/Module.h | 5 ++ src/FrameStepper.cpp | 30 ------- src/FrameStepper.h | 10 --- src/Keybinds/KeyStruct.cpp | 27 ++++++ src/Keybinds/KeyStruct.hpp | 19 ++++ src/Keybinds/RecordKeyPopup.cpp | 2 +- src/Keybinds/RecordKeyStruct.cpp | 135 +++++++++++++++++++++++++++++ src/Keybinds/RecordKeyStruct.hpp | 24 +++++ src/Layers/ManageKeybindsLayer.cpp | 106 ++++++++++++++++++++++ src/Layers/ManageKeybindsLayer.hpp | 28 ++++++ src/ShopBypass.cpp | 15 ---- src/include.h | 7 -- src/main.cpp | 89 +++---------------- 19 files changed, 439 insertions(+), 142 deletions(-) create mode 100644 src/Client/Client.cpp delete mode 100644 src/FrameStepper.cpp delete mode 100644 src/FrameStepper.h create mode 100644 src/Keybinds/KeyStruct.cpp create mode 100644 src/Keybinds/KeyStruct.hpp create mode 100644 src/Keybinds/RecordKeyStruct.cpp create mode 100644 src/Keybinds/RecordKeyStruct.hpp create mode 100644 src/Layers/ManageKeybindsLayer.cpp create mode 100644 src/Layers/ManageKeybindsLayer.hpp delete mode 100644 src/ShopBypass.cpp delete mode 100644 src/include.h diff --git a/about.md b/about.md index d0ec39a..08dc84f 100644 --- a/about.md +++ b/about.md @@ -4,7 +4,7 @@ QOLMod is The **Best** Free Mod Menu, It has a user friendly interface with over # How to use. On Windows / Mac: -- Press **Tab**, **F12**, or **Insert** on your keyboard +- Press **Tab** or **Insert** on your keyboard - The keybinds for opening the mod menu can be changed in the Mod Settings On Android: diff --git a/src/Client/AndroidUI.cpp b/src/Client/AndroidUI.cpp index c0fca3b..114ce9f 100644 --- a/src/Client/AndroidUI.cpp +++ b/src/Client/AndroidUI.cpp @@ -28,6 +28,9 @@ bool AndroidUI::setup() backMenu->setPositionY(CCDirector::get()->getWinSize().height); backMenu->setID("back-menu"); + backMenu->addChild(CCMenuItemSpriteExtra::create(ButtonSprite::create("Button that turns you into a catboy", 1), this, menu_selector(AndroidUI::onKeybinds))); + as(backMenu->getChildren()->objectAtIndex(0))->setPosition(ccp(280, -100)); + auto backSpr = CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png"); #ifdef GEODE_IS_APPLE @@ -495,6 +498,11 @@ AndroidUI* AndroidUI::addToScene() return pRet; } +void AndroidUI::onKeybinds(CCObject*) +{ + ManageKeybindsLayer::addToScene(); +} + AndroidUI::~AndroidUI() { instance = nullptr; diff --git a/src/Client/AndroidUI.h b/src/Client/AndroidUI.h index 657b6cd..fa3ce26 100644 --- a/src/Client/AndroidUI.h +++ b/src/Client/AndroidUI.h @@ -5,6 +5,7 @@ #include "../Utils/defines.hpp" #include "idkwhattocallthis.hpp" #include "../UI/CategoryTabSprite.hpp" +#include "../Layers/ManageKeybindsLayer.hpp" using namespace geode::prelude; @@ -29,8 +30,9 @@ class AndroidUI : public geode::Popup<>, TextInputDelegate void goToPage(int p, bool transition = false); void onClose(CCObject* sender); - + void onKeybinds(CCObject*); void onPressTab(CCObject* sender); + void updateTabs(); virtual bool setup(); diff --git a/src/Client/Client.cpp b/src/Client/Client.cpp new file mode 100644 index 0000000..cdae270 --- /dev/null +++ b/src/Client/Client.cpp @@ -0,0 +1,52 @@ +#include "Client.h" + +Client* Client::get() +{ + return instance; +} + +bool Client::handleKeybinds(enumKeyCodes key, bool isDown, bool isRepeatedKey) +{ + if (!isDown || key == enumKeyCodes::KEY_Unknown) + return false; + + bool shouldPropogate = true; + + for (auto window : windows) + { + for (auto module : window->modules) + { + if (isRepeatedKey ? module->keybind.canRepeat : true) + { + bool shouldSend = true; + + if (module->keybind.key == enumKeyCodes::KEY_Unknown) + shouldSend = false; + + if (module->keybind.shift && !CCKeyboardDispatcher::get()->getShiftKeyPressed()) + shouldSend = false; + + if (module->keybind.control && !CCKeyboardDispatcher::get()->getControlKeyPressed()) + shouldSend = false; + + if (module->keybind.alt && !CCKeyboardDispatcher::get()->getAltKeyPressed()) + shouldSend = false; + + if (module->keybind.command && !CCKeyboardDispatcher::get()->getCommandKeyPressed()) + shouldSend = false; + + if (shouldSend) + { + module->onToggleAndroid(nullptr); + + log::info("toggled: {}", module->id); + + if (!shouldPropogate) + return true; + } + } + } + } + + return false; +} \ No newline at end of file diff --git a/src/Client/Client.h b/src/Client/Client.h index d4b8256..74808fa 100644 --- a/src/Client/Client.h +++ b/src/Client/Client.h @@ -34,6 +34,10 @@ class Client mod = Mod::get(); } + static Client* get(); + + bool handleKeybinds(enumKeyCodes key, bool isDown, bool isRepeatedKey); + //[[deprecated("GetModuleEnabled has been deprecated due to lag, please rember to cache the module :3")]] static bool GetModuleEnabled(std::string id) { diff --git a/src/Client/Module.cpp b/src/Client/Module.cpp index c746195..60bd745 100644 --- a/src/Client/Module.cpp +++ b/src/Client/Module.cpp @@ -76,6 +76,20 @@ void Module::onInfoAndroid(CCObject* sender) void Module::onToggleAndroid(CCObject* sender) { + if (!sender) + { + enabled = !enabled; + save(); + onChange(); + + if (enabled) + enableHooks(); + else + disableHooks(); + + return; + } + auto dat = static_cast(static_cast(sender)->getUserData()); if (dat->isInComp) diff --git a/src/Client/Module.h b/src/Client/Module.h index ca202b1..27083e1 100644 --- a/src/Client/Module.h +++ b/src/Client/Module.h @@ -4,6 +4,7 @@ #include "DrawUtils.h" #include #include "../UI/UIComponent.hpp" +#include "../Keybinds/KeyStruct.hpp" using namespace geode::prelude; @@ -41,6 +42,8 @@ class Module : public UIComponent bool onceAlert; bool isInComp; + KeyStruct keybind; + bool vAlert; bool def; @@ -113,10 +116,12 @@ class Module : public UIComponent virtual void save() { geode::prelude::Mod::get()->setSavedValue(id + "_enabled", enabled); + keybind.saveToModule(id); } virtual void load() { + keybind = KeyStruct::loadFromModule(id); enabled = geode::prelude::Mod::get()->getSavedValue(id + "_enabled", def); save(); } diff --git a/src/FrameStepper.cpp b/src/FrameStepper.cpp deleted file mode 100644 index bcd8328..0000000 --- a/src/FrameStepper.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//#include "FrameStepper.h" - -//using namespace geode::prelude; - -/*class $modify(UILayer) -{ - virtual void keyDown(enumKeyCodes key) - { - log::info("down"); - if (key == enumKeyCodes::KEY_Z) - FrameStepper::keyDown = true; - - UILayer::keyDown(key); - } - - virtual void keyUp(enumKeyCodes key) - { - log::info("up"); - FrameStepper::keyDown = false; - UILayer::keyUp(key); - } -}; - -class $modify(PlayLayer) -{ - virtual void update(float dt) - { - PlayLayer::update(dt * (FrameStepper::keyDown ? 1.0f : 0.0f)); - } -};*/ \ No newline at end of file diff --git a/src/FrameStepper.h b/src/FrameStepper.h deleted file mode 100644 index 45b1c13..0000000 --- a/src/FrameStepper.h +++ /dev/null @@ -1,10 +0,0 @@ -/*#include -//#include -//#include -#include "Client/Client.h" - -class FrameStepper -{ - public: - static inline bool keyDown = false; -};*/ \ No newline at end of file diff --git a/src/Keybinds/KeyStruct.cpp b/src/Keybinds/KeyStruct.cpp new file mode 100644 index 0000000..fc03a36 --- /dev/null +++ b/src/Keybinds/KeyStruct.cpp @@ -0,0 +1,27 @@ +#include "KeyStruct.hpp" + +using namespace geode::prelude; + +KeyStruct KeyStruct::loadFromModule(std::string id) +{ + KeyStruct key; + + key.key = as(Mod::get()->getSavedValue(fmt::format("{}_bind-key", id), -1)); + key.shift = Mod::get()->getSavedValue(fmt::format("{}_bind-shift", id), key.shift); + key.alt = Mod::get()->getSavedValue(fmt::format("{}_bind-alt", id), key.alt); + key.canRepeat = Mod::get()->getSavedValue(fmt::format("{}_bind-can-repeat", id), key.canRepeat); + key.command = Mod::get()->getSavedValue(fmt::format("{}_bind-cmd", id), key.command); + key.control = Mod::get()->getSavedValue(fmt::format("{}_bind-ctrl", id), key.control); + + return key; +} + +void KeyStruct::saveToModule(std::string id) +{ + Mod::get()->setSavedValue(fmt::format("{}_bind-key" , id), as(key)); + Mod::get()->setSavedValue(fmt::format("{}_bind-shift" , id), shift); + Mod::get()->setSavedValue(fmt::format("{}_bind-alt" , id), alt); + Mod::get()->setSavedValue(fmt::format("{}_bind-can-repeat", id), canRepeat); + Mod::get()->setSavedValue(fmt::format("{}_bind-cmd" , id), command); + Mod::get()->setSavedValue(fmt::format("{}_bind-ctrl" , id), control); +} \ No newline at end of file diff --git a/src/Keybinds/KeyStruct.hpp b/src/Keybinds/KeyStruct.hpp new file mode 100644 index 0000000..886a9fd --- /dev/null +++ b/src/Keybinds/KeyStruct.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +struct KeyStruct +{ + public: + // Modifiers + bool control; + bool alt; + bool shift; + bool command; + + cocos2d::enumKeyCodes key = cocos2d::enumKeyCodes::KEY_Unknown; + bool canRepeat = true; + + static KeyStruct loadFromModule(std::string id); + void saveToModule(std::string id); +}; \ No newline at end of file diff --git a/src/Keybinds/RecordKeyPopup.cpp b/src/Keybinds/RecordKeyPopup.cpp index 997f81c..f0f8dde 100644 --- a/src/Keybinds/RecordKeyPopup.cpp +++ b/src/Keybinds/RecordKeyPopup.cpp @@ -15,7 +15,7 @@ bool RecordKeyPopup::init(SEL_MenuHandler obj) CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, -500, true); auto bg = CCScale9Sprite::create("square02_small.png"); - bg->setOpacity(100); + bg->setOpacity(200); bg->setContentSize(ccp(245, 70)); bg->setPosition(CCDirector::get()->getWinSize() / 2); this->addChild(bg); diff --git a/src/Keybinds/RecordKeyStruct.cpp b/src/Keybinds/RecordKeyStruct.cpp new file mode 100644 index 0000000..536c754 --- /dev/null +++ b/src/Keybinds/RecordKeyStruct.cpp @@ -0,0 +1,135 @@ +#include "RecordKeyStruct.hpp" +#include + +bool RecordKeyStruct::init(geode::utils::MiniFunction obj) +{ + if (!CCLayerColor::init()) + return false; + + this->setOpacity(100); + this->setKeyboardEnabled(true); + this->setKeypadEnabled(true); + this->scheduleUpdate(); + this->callback = obj; + + CCTouchDispatcher::get()->registerForcePrio(this, 2); + CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, -500, true); + + auto bg = CCScale9Sprite::create("square02_small.png"); + bg->setOpacity(200); + bg->setContentSize(ccp(245, 90)); + bg->setPosition(CCDirector::get()->getWinSize() / 2); + this->addChild(bg); + + auto text1 = CCLabelBMFont::create("Waiting for key press", "bigFont.fnt"); + text1->setScale(0.6f); + text1->setPosition(CCDirector::get()->getWinSize() / 2 + ccp(0, 30)); + this->addChild(text1); + + auto text2 = CCLabelBMFont::create("Press Escape to cancel", "bigFont.fnt"); + text2->setScale(0.4f); + text2->setPosition(CCDirector::get()->getWinSize() / 2 + ccp(0, 10)); + this->addChild(text2); + + auto node = CCNode::create(); + node->setPosition(CCDirector::get()->getWinSize() / 2 + ccp(0, -30)); + node->setLayout(AxisLayout::create()->setAutoScale(false)->setGap(10)); + node->setContentWidth(42069); // meow meow mrrp mrrow + node->setAnchorPoint(ccp(0.5f, 0.5f)); + + shift = CCLabelBMFont::create("Shift", "bigFont.fnt"); + shift->setScale(0.5f); + ctrl = CCLabelBMFont::create("Ctrl", "bigFont.fnt"); + ctrl->setScale(0.5f); + alt = CCLabelBMFont::create("Alt", "bigFont.fnt"); + alt->setScale(0.5f); + cmd = CCLabelBMFont::create("Command", "bigFont.fnt"); + cmd->setScale(0.5f); + + if (auto popup = getChildOfType(CCScene::get(), 0)) + { + if (auto input = getChildOfType(popup, 0)) + input->onClickTrackNode(false); + } + + node->addChild(shift); + node->addChild(ctrl); + node->addChild(alt); + node->addChild(cmd); + node->updateLayout(); + + this->addChild(node); + return true; +} + +void RecordKeyStruct::keyDown(enumKeyCodes key) +{ + if (key == enumKeyCodes::KEY_Unknown) + return; + + if (key == enumKeyCodes::KEY_Shift) + return; + + if (key == enumKeyCodes::KEY_LeftShift) + return; + + if (key == enumKeyCodes::KEY_RightShift) + return; + + if (key == enumKeyCodes::KEY_Alt) + return; + + if (key == enumKeyCodes::KEY_Control) + return; + + if (key == enumKeyCodes::KEY_Home) + return; + + CCTouchDispatcher::get()->unregisterForcePrio(this); + CCTouchDispatcher::get()->removeDelegate(this); + + if (CCTouchDispatcher::get()->m_pTargetedHandlers->containsObject(this)) + CCTouchDispatcher::get()->m_pTargetedHandlers->removeObject(this, false); + + if (key == enumKeyCodes::KEY_Escape) + return this->removeFromParent(); + + KeyStruct str; + + str.alt = CCKeyboardDispatcher::get()->getAltKeyPressed(); + str.command = CCKeyboardDispatcher::get()->getCommandKeyPressed(); + str.control = CCKeyboardDispatcher::get()->getControlKeyPressed(); + str.shift = CCKeyboardDispatcher::get()->getShiftKeyPressed(); + str.key = key; + + callback(str); + + this->removeFromParent(); +} + +void RecordKeyStruct::keyBackClicked() +{ + this->keyDown(enumKeyCodes::KEY_Escape); +} + +void RecordKeyStruct::update(float dt) +{ + shift->setColor(CCKeyboardDispatcher::get()->getShiftKeyPressed() ? ccc3(255, 255, 255) : ccc3(150, 150, 150)); + ctrl->setColor(CCKeyboardDispatcher::get()->getControlKeyPressed() ? ccc3(255, 255, 255) : ccc3(150, 150, 150)); + alt->setColor(CCKeyboardDispatcher::get()->getAltKeyPressed() ? ccc3(255, 255, 255) : ccc3(150, 150, 150)); + cmd->setColor(CCKeyboardDispatcher::get()->getCommandKeyPressed() ? ccc3(255, 255, 255) : ccc3(150, 150, 150)); +} + +RecordKeyStruct* RecordKeyStruct::create(geode::utils::MiniFunction obj) +{ + auto pRet = new RecordKeyStruct(); + + if (pRet && pRet->init(obj)) + { + pRet->autorelease(); + return pRet; + } + + CC_SAFE_DELETE(pRet); + return nullptr; +} \ No newline at end of file diff --git a/src/Keybinds/RecordKeyStruct.hpp b/src/Keybinds/RecordKeyStruct.hpp new file mode 100644 index 0000000..3a1959c --- /dev/null +++ b/src/Keybinds/RecordKeyStruct.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "KeyStruct.hpp" + +using namespace geode::prelude; + +class RecordKeyStruct : public CCLayerColor +{ + public: + geode::utils::MiniFunction callback; + CCLabelBMFont* shift; + CCLabelBMFont* ctrl; + CCLabelBMFont* alt; + CCLabelBMFont* cmd; + + bool init(geode::utils::MiniFunction obj); + + virtual void keyDown(enumKeyCodes key); + virtual void keyBackClicked(); + virtual void update(float dt); + + static RecordKeyStruct* create(geode::utils::MiniFunction obj); +}; \ No newline at end of file diff --git a/src/Layers/ManageKeybindsLayer.cpp b/src/Layers/ManageKeybindsLayer.cpp new file mode 100644 index 0000000..13a2b9d --- /dev/null +++ b/src/Layers/ManageKeybindsLayer.cpp @@ -0,0 +1,106 @@ +#include "ManageKeybindsLayer.hpp" +#include "../Keybinds/RecordKeyStruct.hpp" + +#define CELL_HEIGHT 25 + +ManageKeybindsLayer* ManageKeybindsLayer::create() +{ + ManageKeybindsLayer* pRet = new ManageKeybindsLayer(); + + if (pRet && pRet->initWithSizeAndName(ccp(320, 260), "Keybinds")) + { + pRet->autorelease(); + return pRet; + } + + CC_SAFE_DELETE(pRet); + return nullptr; +} + +void ManageKeybindsLayer::customSetup() +{ + auto scroll = ScrollLayer::create(ccp(250, 170)); + scroll->setPosition(size / 2 - scroll->getContentSize() / 2 + ccp(0, 6)); + + int count = 0; + + for (auto window : Client::get()->windows) + { + count++; + + for (auto module : window->modules) + { + if (typeinfo_cast(module)) + count++; + } + } + + scroll->m_contentLayer->setContentHeight(count * CELL_HEIGHT); + scroll->moveToTop(); + + int i = 0; + + for (auto window : Client::get()->windows) + { + auto bar = CCLayerColor::create(ccc4(0, 0, 0, 125)); + bar->setAnchorPoint(ccp(0, 1)); + bar->ignoreAnchorPointForPosition(false); + bar->setPositionY(CELL_HEIGHT * count - (CELL_HEIGHT * i)); + bar->setContentSize(ccp(scroll->getContentWidth(), CELL_HEIGHT)); + + auto label = CCLabelBMFont::create(window->name.c_str(), "bigFont.fnt"); + label->setAnchorPoint(ccp(0, 0.5f)); + label->setPosition(ccp(7.5f, CELL_HEIGHT / 2)); + label->limitLabelWidth(100, 0.6f, 0); + label->setOpacity(175); + bar->addChild(label); + + scroll->m_contentLayer->addChild(bar); + + i++; + int e = 0; + for (auto module : window->modules) + { + if (dynamic_cast(module)) + { + auto bar = CCLayerColor::create(ccc4(0, 0, 0, !(e % 2) ? 25 : 75)); + bar->setAnchorPoint(ccp(0, 1)); + bar->ignoreAnchorPointForPosition(false); + bar->setPositionY(CELL_HEIGHT * count - (CELL_HEIGHT * i)); + bar->setContentSize(ccp(scroll->getContentWidth(), CELL_HEIGHT)); + + auto label = CCLabelBMFont::create(module->name.c_str(), "bigFont.fnt"); + label->setAnchorPoint(ccp(0, 0.5f)); + label->setPosition(ccp(7.5f, CELL_HEIGHT / 2)); + label->limitLabelWidth(170, 0.45f, 0); + label->setOpacity(225); + + auto setSpr = ButtonSprite::create("Set", 100, 0, 1.0f, false); + setSpr->setScale(0.6f); + + auto set = CCMenuItemSpriteExtra::create(setSpr, this, menu_selector(ManageKeybindsLayer::onSet)); + set->setUserData(module); + + auto menu = CCMenu::create(); + menu->addChild(set); + + bar->addChild(label); + bar->addChildAtPosition(menu, Anchor::Right, ccp(-25, 0)); + scroll->m_contentLayer->addChild(bar); + i++; + e++; + } + } + } + + baseLayer->addChild(scroll); +} + +void ManageKeybindsLayer::onSet(CCObject* sender) +{ + auto popup = RecordKeyStruct::create([this, sender](KeyStruct key){ + log::info("key: {}", CCKeyboardDispatcher::get()->keyToString(key.key)); + }); + + this->addChild(popup, 69); +} \ No newline at end of file diff --git a/src/Layers/ManageKeybindsLayer.hpp b/src/Layers/ManageKeybindsLayer.hpp new file mode 100644 index 0000000..86cd4fe --- /dev/null +++ b/src/Layers/ManageKeybindsLayer.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include "../Client/Module.h" + +#include "SillyBaseLayer.h" + +using namespace geode::prelude; + +class ManageKeybindsLayer : public SillyBaseLayer +{ + public: + + virtual void customSetup(); + + void onSet(CCObject* sender); + + static ManageKeybindsLayer* create(); + static ManageKeybindsLayer* addToScene() + { + auto pRet = ManageKeybindsLayer::create(); + + CCScene::get()->addChild(pRet, 99999); + + return pRet; + } +}; diff --git a/src/ShopBypass.cpp b/src/ShopBypass.cpp deleted file mode 100644 index 82f55b9..0000000 --- a/src/ShopBypass.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/*#include -#include -#include "Client/Client.h" - -using namespace geode::prelude; - -class $modify (GJStoreItem) -{ - bool init(int p0, int p1, int p2, int p3, ShopType p4) - { - log::info("p0 {}, p1: {}, p2: {}, p3: {}, p4: {}", p0, p1, p2, p3, as(p4)); - - return GJStoreItem::init(p0, p1, p2, p3, p4); - } -};*/ \ No newline at end of file diff --git a/src/include.h b/src/include.h deleted file mode 100644 index f2c9a65..0000000 --- a/src/include.h +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "Client/AndroidUI.h" -#include -#include "Client/AndroidBall.h" -#include "Layers/SillyBaseLayer.h" - -using namespace geode::prelude; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 00e067a..a080a0a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,10 @@ -#include "include.h" +#include +#include "Client/AndroidUI.h" +#include +#include "Client/AndroidBall.h" +#include "Layers/SillyBaseLayer.h" + +using namespace geode::prelude; #include #include "Keybinds/SetBindSetting.hpp" #include "Keybinds/RecordKeyPopup.hpp" @@ -64,75 +70,16 @@ class $modify (CCKeyboardDispatcher) Client::instance->open = showing; } } - } - if (!android) - { - if (key == KEY_Escape) + if (!getChildOfType(CCScene::get(), 0)) { - if (InputModule::selected) - { - InputModule::selected = nullptr; - return true; - } - } - - if (InputModule::selected) - { - if (down) - { - if (key >= 48) - { - if (key <= 90) - { - std::stringstream ss; - - if (CCKeyboardDispatcher::getShiftKeyPressed()) - ss << CCKeyboardDispatcher::keyToString(key); - else - { - ss << CCKeyboardDispatcher::keyToString(key); - } - - if (InputModule::selected->text.length() < InputModule::selected->maxSize) - { - for (size_t i = 0; i < InputModule::selected->allowedChars.length(); i++) - { - if (InputModule::selected->allowedChars[i] == ss.str()[0]) - { - InputModule::selected->text += ss.str(); - } - } - } - - return true; - } - } - - if (key == KEY_Backspace) - { - InputModule::selected->text = InputModule::selected->text.substr(0, InputModule::selected->text.length() - 1); - } - - if (key == 190) - { - if (InputModule::selected->text.length() < InputModule::selected->maxSize) - { - for (size_t i = 0; i < InputModule::selected->allowedChars.length(); i++) - { - if (InputModule::selected->allowedChars[i] == "."[0]) - { - InputModule::selected->text += "."; - } - } - } - } - - return true; - } + if (Client::get()->handleKeybinds(key, down, idk)) + return false; } } + + return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down, idk); } }; @@ -175,18 +122,6 @@ void migrateData() { migrateData(); - //android = !Mod::get()->getSettingValue("use-new-ui"); - /* - , - "use-new-ui": { - "type": "bool", - "name": "[BETA] Use PC Gui", - "default": false, - "description": "Uses a UI more comfortable for pc users, like Mega Hack. Requires Game Restart", - "platforms": [ "win", "macos" ] - } - */ - client = new Client(); Client::instance = client;