diff --git a/CMakeLists.txt b/CMakeLists.txt index f8ad3b1..83c2ed8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ file(GLOB SOURCES src/Client/*.cpp src/Hacks/*.cpp src/Utils/*.cpp + src/UI/*.cpp src/Keybinds/*.cpp src/Layers/*.cpp src/Labels/*.cpp diff --git a/changelog.md b/changelog.md index 50a09b3..f33715b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +# 1.4.4-beta.5 + +- Fixed pressing presets in speedhack section not saving the value +- Fixed the mod not loading on the latest geode beta + # 1.4.4-beta.4 - Fixed pressing the mod settings button crashing the game diff --git a/mod.json b/mod.json index 7b39a95..10c0b8d 100644 --- a/mod.json +++ b/mod.json @@ -1,6 +1,6 @@ { - "geode": "3.0.0-alpha.2", - "version": "v1.4.4-beta.4", + "geode": "3.0.0-beta.1", + "version": "v1.4.4-beta.5", "gd": { "win": "2.206", "mac": "2.206", diff --git a/src/Client/Window.h b/src/Client/Window.h index 4996742..fec01ed 100644 --- a/src/Client/Window.h +++ b/src/Client/Window.h @@ -358,70 +358,6 @@ class Speedhack : public Window//, public TextInputDelegate SpeedhackTop::instance->save(); } - void onDebug(CCObject*) - { - float v = 1.0f; - - auto x = numFromString(SpeedhackTop::instance->text); - - if (x.isOk()) - { - v = x.value(); - } - - if (v < 0.01f) - v = 0.01f; - - if (v > 99999) - v = 99999; - - bool m = SpeedhackMus::instance->enabled; - - if (SpeedhackGameplay::instance->enabled) - if (!(PlayLayer::get() || GameManager::sharedState()->getEditorLayer())) { v = 1.0f; } - - v /= CCDirector::get()->getScheduler()->getTimeScale(); - - std::stringstream ss; - - ss << "String: "; - ss << SpeedhackTop::instance->text; - ss << "\n"; - - ss << "Value: "; - ss << v; - ss << "\n"; - - ss << "Value UN-TS: "; - ss << v * CCDirector::get()->getScheduler()->getTimeScale(); - ss << "\n"; - - ss << "isOk: "; - ss << x.isOk(); - ss << "\n"; - - ss << "isErr: "; - ss << x.isErr(); - ss << "\n"; - - if (x.isErr()) - { - ss << "Error: "; - ss << x.err().value(); - ss << "\n"; - } - - ss << "Has Value: "; - ss << x.has_value(); - ss << "\n"; - - //ss << "Value RES: "; - //ss << x.value(); - //ss << "\n"; - - FLAlertLayer::create("Macro Info", ss.str(), "OK")->show(); - } - void onPreset(CCObject* sender) { float value = numFromString(as(sender)->getID(), 2).value(); @@ -430,6 +366,8 @@ class Speedhack : public Window//, public TextInputDelegate auto inp = getChildOfType(static_cast(sender)->getParent()->getParent(), 0); inp->setString(as(sender)->getID()); slider->setValue(unscaleValue(value)); + + SpeedhackTop::instance->save(); } void cocosCreate(CCMenu* menu) @@ -499,21 +437,6 @@ class Speedhack : public Window//, public TextInputDelegate presetMenu->updateLayout(); menu->addChild(presetMenu); - - return; - - auto pos = ccp(menu->getContentSize().width, 0) + ccp(-58, 22) * 0.5f; - - auto btnS = ButtonSprite::create("Debug", 90, false, "bigFont.fnt", "GJ_button_05.png", 35, 0.75f); - //as(btnS->getChildren()->objectAtIndex(0))->setScale(0.375f); - as(btnS->getChildren()->objectAtIndex(0))->setAlignment(CCTextAlignment::kCCTextAlignmentCenter); - as(btnS->getChildren()->objectAtIndex(0))->updateLabel(); - auto btn = CCMenuItemSpriteExtra::create(btnS, menu, menu_selector(Speedhack::onDebug)); - btn->m_baseScale = 0.5f; - btn->setScale(btn->m_baseScale); - btn->setSizeMult(1.15f); - btn->setPosition(pos); - menu->addChild(btn); } virtual void textChanged(CCTextInputNode* p0) @@ -860,179 +783,4 @@ class Universal : public Window btn->setPosition(pos); menu->addChild(btn); } -}; - -class _Replay : public Window -{ - public: - static inline CCMenuItemToggler* btnRec = nullptr; - static inline CCMenuItemToggler* btnPlay = nullptr; - static inline CCLabelBMFont* lbl = nullptr; - - void onSave(CCObject*) - { - //SaveMacroPopup::addToScene(); - } - - void onLoad(CCObject*) - { - //LoadMacroPopup::addToScene(); - } - - void onClear(CCObject*) - { - auto pop = geode::createQuickPopup( - "Clear Replay", - "Are you sure you want to clear this replay?\nIf you haven't saved the replay\n it will be DELETED.", - "Cancel", "Clear", - [this](FLAlertLayer* tis, bool btn2) { - log::info("click clear"); - - if (btn2) { - log::info("right btn"); - - GJReplayManager::replay = MyReplay(); - - CCScene::get()->addChild(TextAlertPopup::create("Cleared Replay", 0.5f, 0.6f, 150, ""), 9999999); - } - } - ); - - pop->m_button2->updateBGImage("GJ_button_06.png"); - } - - void onRecord(CCObject*) - { - GJReplayManager::playing = false; - GJReplayManager::recording = !GJReplayManager::recording; - - //btnRec->toggle(GJReplayManager::recording); - btnPlay->toggle(GJReplayManager::playing); - } - - void onPlay(CCObject*) - { - GJReplayManager::recording = false; - GJReplayManager::playing = !GJReplayManager::playing; - - btnRec->toggle(GJReplayManager::recording); - //btnPlay->toggle(GJReplayManager::playing); - } - - void onManage(CCObject*) - { - FLAlertLayer::create("Macro Manager", "Macro Manager is not added yet as I wanted to get the update out as fast as I could, hope you understand ^w^", "OK")->show(); - } - - void onConfig(CCObject*) - { - //ReplayOptionsLayer::addToScene(); - } - - void cocosCreate(CCMenu* menu) - { - auto back = CCScale9Sprite::create("square02b_small.png"); - back->setContentSize(menu->getContentSize() / 0.5f); - back->setPosition(ccp(0, 0)); - back->setAnchorPoint(ccp(0, 0)); - back->setScale(0.5f); - back->setOpacity(100); - back->setColor(ccc3(0, 0, 0)); - menu->addChild(back); - - lbl = CCLabelBMFont::create("Status", "bigFont.fnt"); - lbl->setPosition(ccp(5, menu->getContentSize().height - 2)); - lbl->setScale(0.725f); - lbl->setAnchorPoint(ccp(0, 1)); - lbl->setOpacity(100); - - auto menuRow = CCMenu::create(); - menuRow->ignoreAnchorPointForPosition(false); - menuRow->setContentSize(ccp(9999, 0)); - menuRow->setScale(0.625f); - menuRow->setPosition(menu->getContentSize() / 2 + ccp(0, -30) + ccp(0, -25)); - - auto btnRecSpr1 = ButtonSprite::create("Record", 105, false, "bigFont.fnt", "GJ_button_05.png", 40, 0.65f); - getChildOfType(btnRecSpr1, 0)->setOpacity(100); - getChildOfType(btnRecSpr1, 0)->setPositionX(105 / 2); - getChildOfType(btnRecSpr1, 0)->setPositionX(105 / 2); - - btnRecSpr1->setContentWidth(105); - getChildOfType(btnRecSpr1, 0)->setContentWidth(105); - - auto btnRecSpr2 = ButtonSprite::create("Recording", 105, false, "bigFont.fnt", "GJ_button_01.png", 40, 0.5f); - btnRecSpr2->setContentWidth(105); - getChildOfType(btnRecSpr2, 0)->setContentWidth(105); - getChildOfType(btnRecSpr2, 0)->setPositionX(105 / 2); - getChildOfType(btnRecSpr2, 0)->setPositionX(105 / 2); - - btnRec = CCMenuItemToggler::create(btnRecSpr1, btnRecSpr2, menu, menu_selector(_Replay::onRecord)); - btnRec->toggle(GJReplayManager::recording); - - auto btnPlaySpr1 = ButtonSprite::create("Play", 105, false, "bigFont.fnt", "GJ_button_05.png", 40, 0.65f); - getChildOfType(btnPlaySpr1, 0)->setOpacity(100); - getChildOfType(btnPlaySpr1, 0)->setPositionX(105 / 2); - getChildOfType(btnPlaySpr1, 0)->setPositionX(105 / 2); - - btnPlaySpr1->setContentWidth(105); - getChildOfType(btnPlaySpr1, 0)->setContentWidth(105); - - auto btnPlaySpr2 = ButtonSprite::create("Playing", 105, false, "bigFont.fnt", "GJ_button_01.png", 40, 0.5f); - btnPlaySpr2->setContentWidth(105); - getChildOfType(btnPlaySpr2, 0)->setContentWidth(105); - getChildOfType(btnPlaySpr2, 0)->setPositionX(105 / 2); - getChildOfType(btnPlaySpr2, 0)->setPositionX(105 / 2); - - btnPlay = CCMenuItemToggler::create(btnPlaySpr1, btnPlaySpr2, menu, menu_selector(_Replay::onPlay)); - btnPlay->toggle(GJReplayManager::playing); - - menuRow->addChild(CCMenuItemSpriteExtra::create(ButtonSprite::create("Save", "bigFont.fnt", "GJ_button_04.png"), menu, menu_selector(_Replay::onSave))); - menuRow->addChild(CCMenuItemSpriteExtra::create(ButtonSprite::create("Load", "bigFont.fnt", "GJ_button_04.png"), menu, menu_selector(_Replay::onLoad))); - menuRow->addChild(CCMenuItemSpriteExtra::create(ButtonSprite::create("Clear", "bigFont.fnt", "GJ_button_06.png"), menu, menu_selector(_Replay::onClear))); - //menuRow->addChild(CCMenuItemSpriteExtra::create(ButtonSprite::create("More", "bigFont.fnt", "GJ_button_04.png"), menu, nullptr)); - - menuRow->setLayout(RowLayout::create()->setAutoScale(false)->setGap(55)); - - auto pos = ccp(menu->getContentSize().width, 0) + ccp(-55, 22); - - auto options = CCMenuItemSpriteExtra::create(CCSprite::createWithSpriteFrameName("GJ_optionsBtn_001.png"), menu, menu_selector(_Replay::onConfig)); - options->m_baseScale = 0.6f; - options->setScale(options->m_baseScale); - menu->addChildAtPosition(options, Anchor::TopRight, ccp(-18, -18)); - - auto manager = CCMenuItemSpriteExtra::create(CCSprite::createWithSpriteFrameName("folderIcon_001.png"), menu, menu_selector(_Replay::onManage)); - - //menu->addChild(lbl); - menu->addChild(menuRow); - menu->addChildAtPosition(btnRec, Anchor::Center, ccp(-70, 0)); - menu->addChildAtPosition(btnPlay, Anchor::Center, ccp(70, 0)); - menu->addChildAtPosition(manager, Anchor::BottomLeft, ccp(25, 23)); - } -}; - -class Status : public Window -{ - public: - void onEditPositions(CCObject*) - { - //EditStatusPositionLayer::addToScene(); - } - - void cocosCreate(CCMenu* menu) - { - Window::cocosCreate(menu); - - return; - - auto pos = ccp(58, 22); - - auto btnS = ButtonSprite::create("Edit\nPositions", 90, false, "bigFont.fnt", "GJ_button_05.png", 35, 0.75f); - as(btnS->getChildren()->objectAtIndex(0))->setScale(0.375f); - as(btnS->getChildren()->objectAtIndex(0))->setAlignment(CCTextAlignment::kCCTextAlignmentCenter); - as(btnS->getChildren()->objectAtIndex(0))->updateLabel(); - auto btn = CCMenuItemSpriteExtra::create(btnS, menu, menu_selector(Status::onEditPositions)); - btn->setSizeMult(1.15f); - btn->setPosition(pos); - menu->addChild(btn); - } -}; +}; \ No newline at end of file diff --git a/src/UI/PCGuiNode.cpp b/src/UI/PCGuiNode.cpp new file mode 100644 index 0000000..3e38892 --- /dev/null +++ b/src/UI/PCGuiNode.cpp @@ -0,0 +1,73 @@ +/* +#include "PCGuiNode.hpp" + +PCGuiNode* PCGuiNode::create() +{ + auto pRet = new PCGuiNode(); + + if (pRet && pRet->init()) + { + pRet->autorelease(); + return pRet; + } + + CC_SAFE_DELETE(pRet); + return nullptr; +} + +PCGuiNode::~PCGuiNode() +{ + this->release(); +} + +PCGuiNode* PCGuiNode::get() +{ + if (!instance) + { + instance = PCGuiNode::create(); + instance->retain(); + } + + return instance; +} + +void PCGuiNode::visit() +{ + CCNode::visit(); +} + +void PCGuiNode::draw() +{ + CCNode::draw(); + ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + //if (!Client::instance) + // return; + + ccDrawSolidRect(ccp(0, 0), ccp(100, 100), ccc4f(drawScene ? 1 : 0, 0, 0, 1)); + + for (auto window : Client::instance->windows) + { + //window->draw(); + } +} + +class $modify (CCEGLView) +{ + virtual void swapBuffers() + { + PCGuiNode::get()->visit(); + + CCEGLView::swapBuffers(); + } +}; + +class $modify (CCDirector) +{ + void drawScene() + { + CCDirector::drawScene(); + + PCGuiNode::get()->visit(); + } +};*/ \ No newline at end of file diff --git a/src/UI/PCGuiNode.hpp b/src/UI/PCGuiNode.hpp new file mode 100644 index 0000000..5cec8dd --- /dev/null +++ b/src/UI/PCGuiNode.hpp @@ -0,0 +1,26 @@ +/*#pragma once + +#include +#include +#include +#include "../Client/Client.h" + +using namespace geode::prelude; + +class PCGuiNode : public CCNode +{ + private: + static inline PCGuiNode* instance = nullptr; + + public: + int v = 0; + bool drawScene = false; + + static PCGuiNode* create(); + static PCGuiNode* get(); + + virtual void visit(); + virtual void draw(); + + ~PCGuiNode(); +};*/ \ No newline at end of file