From a65834ea33178140077c6d660a1593fa1fb5a6fb Mon Sep 17 00:00:00 2001 From: Explodingbill Date: Tue, 23 Jul 2024 21:41:57 +1000 Subject: [PATCH] asdf --- changelog.md | 2 ++ src/Client/ClientSetup.h | 1 + src/Hacks/NoGlow.cpp | 29 +++++++++-------------------- src/Labels/BestRun.cpp | 26 ++++++++++++++++++++++++++ src/Labels/BestRun.hpp | 23 +++++++++++++++++++++++ src/Labels/Labels.cpp | 10 +++++++++- src/Labels/Labels.h | 4 ++++ 7 files changed, 74 insertions(+), 21 deletions(-) create mode 100644 src/Labels/BestRun.cpp create mode 100644 src/Labels/BestRun.hpp diff --git a/changelog.md b/changelog.md index d60e023..6f543b3 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ - Fixed Unlock Buttons applying on list pages - Fixed Confirm Practice Mode not working for exiting practice mode - Fixed the FPS label text appearing as (a body part on girls that i dont think hjfod will let me say on new index) for the first few seconds +- Fixed No Glow not working - Ported **All Modes Platformer** on Windows - Ported **Random Seed** - Added **No Robot Fire** @@ -15,6 +16,7 @@ - Added **No Spider Dash Effect** - Added **Longer Trail** - Added **Suicide** +- Added **Best Run Label** # 1.4.9 diff --git a/src/Client/ClientSetup.h b/src/Client/ClientSetup.h index 0658f80..2eac945 100644 --- a/src/Client/ClientSetup.h +++ b/src/Client/ClientSetup.h @@ -365,6 +365,7 @@ class ClientUtils replay->modules.push_back(new Module("Message", "status-message", "Write a message of your choice to be shown")); replay->modules.push_back(new Module("Session Time", "status-session", "Shows the time you've had the game open for in the format hh::mm::ss")); replay->modules.push_back(new Module("CPS Counter", "status-cps", "Shows your clicks per second. Tints Green while you are clicking")); + replay->modules.push_back(new Module("Best Run", "best-run", "Shows your best run")); //replay->modules.push_back(new StatusMessage()); diff --git a/src/Hacks/NoGlow.cpp b/src/Hacks/NoGlow.cpp index dfcb72d..142ac1f 100644 --- a/src/Hacks/NoGlow.cpp +++ b/src/Hacks/NoGlow.cpp @@ -1,28 +1,17 @@ -#ifndef GEODE_IS_ANDROID32 - #include -#include -#include +#include #include "../Client/Client.h" using namespace geode::prelude; -Module* noGlow = nullptr; - -class $modify(GameObject) { - - void commonSetup() +class $modify(PlayLayer) +{ + void addObject(GameObject* obj) { - GameObject::commonSetup(); + obj->m_hasNoGlow = true; - if (!noGlow) - noGlow = Client::GetModule("no-glow"); - - if (PlayLayer::get()) - { - if (noGlow->enabled) - m_hasNoGlow = true; - } + PlayLayer::addObject(obj); } -}; -#endif \ No newline at end of file + + QOLMOD_MOD_HOOK("no-glow", "PlayLayer::addObject") +}; \ No newline at end of file diff --git a/src/Labels/BestRun.cpp b/src/Labels/BestRun.cpp new file mode 100644 index 0000000..32d40e5 --- /dev/null +++ b/src/Labels/BestRun.cpp @@ -0,0 +1,26 @@ +#include "BestRun.hpp" + +void BestPlayLayer::resetLevel() +{ + m_fields->toPercent = getCurrentPercent(); + + auto length = m_fields->toPercent - m_fields->fromPercent; + + if (length > m_fields->bestLength) + { + m_fields->bestLength = length; + m_fields->bestFrom = m_fields->fromPercent; + m_fields->bestTo = m_fields->toPercent; + } + + PlayLayer::resetLevel(); + m_fields->fromPercent = getCurrentPercent(); +} + +std::string BestPlayLayer::getRunString() +{ + if (m_fields->bestLength == 0) + return "Best Run: None"; + + return fmt::format("Best Run: {} - {}%", as(m_fields->bestFrom), as(m_fields->bestTo)); +} \ No newline at end of file diff --git a/src/Labels/BestRun.hpp b/src/Labels/BestRun.hpp new file mode 100644 index 0000000..86d9759 --- /dev/null +++ b/src/Labels/BestRun.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include +#include +#include +#include "../Client/Client.h" + +using namespace geode::prelude; + +class $modify (BestPlayLayer, PlayLayer) +{ + struct Fields { + float fromPercent; + float toPercent; + + float bestFrom; + float bestTo; + float bestLength; + }; + + void resetLevel(); + std::string getRunString(); +}; \ No newline at end of file diff --git a/src/Labels/Labels.cpp b/src/Labels/Labels.cpp index 89b2dc5..83728b9 100644 --- a/src/Labels/Labels.cpp +++ b/src/Labels/Labels.cpp @@ -34,7 +34,7 @@ bool StatusNode::init() bottomRight->setID("bottom-right"); this->addChild(bottomRight); - int count = 9; + int count = 10; for (size_t i = 0; i < count; i++) { @@ -230,9 +230,15 @@ void StatusNode::update(float dt) if (!cpsM) cpsM = Client::GetModule("status-cps"); + + if (!bestRun) + bestRun = Client::GetModule("best-run"); if (!attPL) attPL = static_cast(PlayLayer::get()); + + if (!bestRunPlayLayer) + bestRunPlayLayer = static_cast(PlayLayer::get()); float v = 100 * as(PlayLayer::get())->getNoclipAccuracy(); @@ -302,6 +308,7 @@ void StatusNode::update(float dt) cps.erase(std::remove_if(cps.begin(), cps.end(), [](float i){ return i < 0; }), cps.end()); sLabels[8]->setString((cpsM->options[1]->enabled ? fmt::format("{} / {} CPS", cps.size(), totalClicks) : fmt::format("{} CPS", cps.size(), totalClicks)).c_str()); + sLabels[9]->setString(bestRunPlayLayer->getRunString().c_str()); updateVis(); } @@ -357,6 +364,7 @@ class $modify (PlayLayer) auto stn = StatusNode::create(); stn->attPL = static_cast(PlayLayer::get()); + stn->bestRunPlayLayer = as(PlayLayer::get()); this->addChild(stn); return true; diff --git a/src/Labels/Labels.h b/src/Labels/Labels.h index a7a7c73..5f02870 100644 --- a/src/Labels/Labels.h +++ b/src/Labels/Labels.h @@ -5,6 +5,7 @@ #include #include #include +#include "BestRun.hpp" #include "../Client/Client.h" using namespace geode::prelude; @@ -60,6 +61,7 @@ class StatusNode : public CCNode static inline Module* message = nullptr; static inline Module* session = nullptr; static inline Module* cpsM = nullptr; + static inline Module* bestRun = nullptr; static inline Module* noclip = nullptr; @@ -82,6 +84,8 @@ class StatusNode : public CCNode std::vector cps; int totalClicks = 0; + BestPlayLayer* bestRunPlayLayer; + std::string formatTime(float time) { // Convert float time to milliseconds std::chrono::milliseconds duration(static_cast(time * 1000));