diff --git a/changelog.md b/changelog.md index 1fffe8a..208ea32 100644 --- a/changelog.md +++ b/changelog.md @@ -2,7 +2,9 @@ - Fixed the UI Button disappearing if you have Transition Customizer enabled - Lowered the Hitbox Trail limit to hopefully fix lag +- Slider Limit Bypass now works on the scale slider in the editor - Added **Hide Pause Button** +- Added **Pause Countdown** # 1.4.6 diff --git a/src/Client/ClientSetup.h b/src/Client/ClientSetup.h index 3059c8b..81d0024 100644 --- a/src/Client/ClientSetup.h +++ b/src/Client/ClientSetup.h @@ -104,6 +104,8 @@ class ClientUtils level->modules.push_back(new Module("Kill at %", "kill-after", "Kills the player after a set percentage")); level->modules.push_back(new Module("Jump Hack", "jump-hack", "Allows you to jump infinitely")); + + level->modules.push_back(new Module("Pause Countdown", "pause-countdown", "Shows a countdown for 3 seconds when you unpause a level")); //level->modules.push_back(new Module("Frame Stepper", "frame-stepper", "Step the game through frames by tapping a button")); diff --git a/src/Hacks/Pause Countdown/CountdownLayer.cpp b/src/Hacks/Pause Countdown/CountdownLayer.cpp new file mode 100644 index 0000000..0bff952 --- /dev/null +++ b/src/Hacks/Pause Countdown/CountdownLayer.cpp @@ -0,0 +1,54 @@ +#include "CountdownLayer.hpp" + +bool CountdownLayer::init() +{ + if (!CCLayer::init()) + return false; + + this->setKeypadEnabled(true); + this->schedule(schedule_selector(CountdownLayer::onDecrement), 1); + + label = CCLabelBMFont::create(fmt::format("{}", count).c_str(), "goldFont.fnt"); + label->setPosition(CCDirector::get()->getWinSize() / 2); + + applyAnimation(); + + this->addChild(label); + return true; +} + +void CountdownLayer::onDecrement(float) +{ + count--; + label->setString(fmt::format("{}", count).c_str()); + applyAnimation(); + + if (count == 0) + { + onCountReachedZero(); + } +} + +void CountdownLayer::onCountReachedZero() +{ + PlayLayer::get()->resume(); + + this->removeFromParent(); +} + +void CountdownLayer::applyAnimation() +{ + label->setScale(2.2f); + label->runAction(CCEaseElasticOut::create(CCScaleTo::create(0.5f, 1.5f))); + + label->setOpacity(0); + label->runAction(CCEaseInOut::create(CCFadeTo::create(0.5f, 255), 2)); +} + +void CountdownLayer::keyBackClicked() +{ + PlayLayer::get()->resume(); + PlayLayer::get()->pauseGame(false); + + this->removeFromParent(); +} \ No newline at end of file diff --git a/src/Hacks/Pause Countdown/CountdownLayer.hpp b/src/Hacks/Pause Countdown/CountdownLayer.hpp new file mode 100644 index 0000000..7c0bbef --- /dev/null +++ b/src/Hacks/Pause Countdown/CountdownLayer.hpp @@ -0,0 +1,20 @@ +#include +#include "../../Client/Client.h" + +using namespace geode::prelude; + +class CountdownLayer : public CCLayer +{ + public: + CCLabelBMFont* label; + int count = 3; + + void onDecrement(float); + void applyAnimation(); + + virtual bool init(); + virtual void onCountReachedZero(); + virtual void keyBackClicked(); + + CREATE_FUNC(CountdownLayer); +}; \ No newline at end of file diff --git a/src/Hacks/Pause Countdown/PauseCountdown.cpp b/src/Hacks/Pause Countdown/PauseCountdown.cpp new file mode 100644 index 0000000..3f5fca2 --- /dev/null +++ b/src/Hacks/Pause Countdown/PauseCountdown.cpp @@ -0,0 +1,20 @@ +#include +#include +#include "../../Client/Client.h" +#include "CountdownLayer.hpp" + +using namespace geode::prelude; + +class $modify (PauseLayer) +{ + void onResume(cocos2d::CCObject* sender) + { + auto countdown = CountdownLayer::create(); + CCScene::get()->addChild(countdown); + + CCTouchDispatcher::get()->unregisterForcePrio(this); + this->removeFromParent(); + } + + QOLMOD_MOD_ALL_HOOKS("pause-countdown") +}; \ No newline at end of file diff --git a/src/Hacks/SliderLimit.cpp b/src/Hacks/SliderLimit.cpp index f9bcfd1..d00da98 100644 --- a/src/Hacks/SliderLimit.cpp +++ b/src/Hacks/SliderLimit.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include "../Client/Client.h" @@ -27,4 +26,28 @@ class $modify (SliderTouchLogic) modu->addHookRaw(hook); }); } +}; + +class $modify (GJScaleControl) +{ + virtual void ccTouchMoved(cocos2d::CCTouch* touch, cocos2d::CCEvent* event) + { + GJScaleControl::ccTouchMoved(touch, event); + + if (m_sliderXY && m_sliderXY->m_touchLogic->m_activateThumb) + { + m_sliderXY->getThumb()->setPositionX(this->convertToNodeSpace(touch->getLocation()).x); + m_sliderXY->updateBar(); + + float value = scaleFloat(m_sliderXY->getThumb()->getValue(), m_lowerBound, m_upperBound); + + updateLabelXY(value); + this->sliderChanged(m_sliderXY->getThumb()); + + if (EditorUI::get()) + { + EditorUI::get()->scaleXYChanged(value, value, m_scaleLocked); + } + } + } }; \ No newline at end of file diff --git a/src/Utils/Utils.cpp b/src/Utils/Utils.cpp index b256dd2..b4fb063 100644 --- a/src/Utils/Utils.cpp +++ b/src/Utils/Utils.cpp @@ -1,6 +1,12 @@ #include "Utils.hpp" -float roundUpToMultipleOf2(float num) { +float roundUpToMultipleOf2(float num) +{ float roundedNum = std::ceil(num / 2.0f) * 2.0f; return roundedNum; +} + +float scaleFloat(float v, float min, float max) +{ + return (max - min) * v + min; } \ No newline at end of file diff --git a/src/Utils/Utils.hpp b/src/Utils/Utils.hpp index a1f0471..a72fae2 100644 --- a/src/Utils/Utils.hpp +++ b/src/Utils/Utils.hpp @@ -46,4 +46,5 @@ static void onModify(auto& self) { \ }); \ } -float roundUpToMultipleOf2(float num); \ No newline at end of file +float roundUpToMultipleOf2(float num); +float scaleFloat(float v, float min, float max); \ No newline at end of file