From fcd8a4a3b9cc9a2682586d69924bac0737f20518 Mon Sep 17 00:00:00 2001 From: DumbCaveSpider <56347227+DumbCaveSpider@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:21:39 +0800 Subject: [PATCH 1/2] accept tos improvements --- src/util/ui/TermsAndConditions.hpp | 9 ++++ src/util/ui/src/TermsAndConditions.cpp | 71 +++++++++++++++++++++++--- 2 files changed, 74 insertions(+), 6 deletions(-) diff --git a/src/util/ui/TermsAndConditions.hpp b/src/util/ui/TermsAndConditions.hpp index f2e12a7..2e08cbd 100644 --- a/src/util/ui/TermsAndConditions.hpp +++ b/src/util/ui/TermsAndConditions.hpp @@ -1,14 +1,23 @@ #pragma once #include +#include namespace horrible { namespace ui { class TermsAndConditions final : public geode::Popup { using Callback = geode::CopyableFunction; + private: + geode::Button* m_acceptBtn = nullptr; + cocos2d::CCPoint m_acceptVelocity = {0.f, 0.f}; + float m_acceptSpeed = 2400.f; + float m_mouseAvoidDistance = 25.f; + float m_mouseAvoidMultiplier = 1.75f; + protected: void finishBtnFade(cocos2d::CCNode* sender); + void update(float dt) override; bool init(Callback&& cb); diff --git a/src/util/ui/src/TermsAndConditions.cpp b/src/util/ui/src/TermsAndConditions.cpp index 0a84763..e7edbfc 100644 --- a/src/util/ui/src/TermsAndConditions.cpp +++ b/src/util/ui/src/TermsAndConditions.cpp @@ -1,8 +1,10 @@ #include "../TermsAndConditions.hpp" +#include #include #include +#include "Geode/cocos/cocoa/CCGeometry.h" using namespace geode::prelude; using namespace horrible::prelude; @@ -48,7 +50,7 @@ bool TermsAndConditions::init(Callback&& cb) { m_mainLayer->addChild(tosArea); - auto acceptBtn = Button::createWithNode( + m_acceptBtn = Button::createWithNode( ButtonSprite::create( "Accept", "bigFont.fnt", @@ -58,12 +60,12 @@ bool TermsAndConditions::init(Callback&& cb) { if (cb) cb(true); removeFromParent(); }); - acceptBtn->setScale(0.75f); + m_acceptBtn->setScale(0.75f); auto declineBtn = Button::createWithNode( ButtonSprite::create( "Decline", - "goldFont.fnt", + "bigFont.fnt", themes::getButtonSquareSprite(theme)), [this, cb](auto) { sfx::play(sfx::file::bad); @@ -72,11 +74,15 @@ bool TermsAndConditions::init(Callback&& cb) { }); declineBtn->setScale(0.75f); - m_mainLayer->addChildAtPosition(acceptBtn, Anchor::Bottom, {-60.f, 25.f}); + m_mainLayer->addChildAtPosition(m_acceptBtn, Anchor::Bottom, {-60.f, 25.f}); m_mainLayer->addChildAtPosition(declineBtn, Anchor::Bottom, {60.f, 25.f}); - if (auto acceptBtnSpr = typeinfo_cast(acceptBtn->getDisplayNode())) { - acceptBtn->setEnabled(false); + auto const angle = rng::get(2.f * std::numbers::pi); + m_acceptVelocity = ccp(cosf(angle), sinf(angle)); + scheduleUpdate(); + + if (auto acceptBtnSpr = typeinfo_cast(m_acceptBtn->getDisplayNode())) { + m_acceptBtn->setEnabled(false); acceptBtnSpr->setOpacity(0); acceptBtnSpr->runAction(CCSpawn::createWithTwoActions( @@ -94,6 +100,59 @@ void TermsAndConditions::finishBtnFade(CCNode* sender) { if (auto btn = typeinfo_cast(sender->getParent())) btn->setEnabled(true); }; +void TermsAndConditions::update(float dt) { + if (!m_acceptBtn) return; + + CCPoint const winSize = CCDirector::sharedDirector()->getWinSize(); + CCPoint pos = m_acceptBtn->getPosition(); + CCSize const buttonSize = m_acceptBtn->getScaledContentSize(); + + CCPoint const mousePos = cocos::getMousePos(); + CCPoint const away = ccpSub(pos, mousePos); + float const dist = std::sqrt(away.x * away.x + away.y * away.y); + float speed = m_acceptSpeed; + + if (dist < m_mouseAvoidDistance && dist > 0.f) { + auto normalizedAway = ccp(away.x / dist, away.y / dist); + auto currentVelLen = std::sqrt(m_acceptVelocity.x * m_acceptVelocity.x + m_acceptVelocity.y * m_acceptVelocity.y); + if (currentVelLen > 0.f) { + normalizedAway.x += m_acceptVelocity.x / currentVelLen; + normalizedAway.y += m_acceptVelocity.y / currentVelLen; + } + auto const newLen = std::sqrt(normalizedAway.x * normalizedAway.x + normalizedAway.y * normalizedAway.y); + if (newLen > 0.f) { + normalizedAway.x /= newLen; + normalizedAway.y /= newLen; + m_acceptVelocity = normalizedAway; + } + speed *= m_mouseAvoidMultiplier; + } + + auto const delta = ccpMult(m_acceptVelocity, speed * dt); + pos = ccpAdd(pos, delta); + + auto const halfW = buttonSize.width / 2.f; + auto const halfH = buttonSize.height / 2.f; + + if (pos.x < halfW) { + pos.x = halfW; + m_acceptVelocity.x = fabsf(m_acceptVelocity.x); + } else if (pos.x > winSize.width - halfW) { + pos.x = winSize.width - halfW; + m_acceptVelocity.x = -fabsf(m_acceptVelocity.x); + } + + if (pos.y < halfH) { + pos.y = halfH; + m_acceptVelocity.y = fabsf(m_acceptVelocity.y); + } else if (pos.y > winSize.height - halfH) { + pos.y = winSize.height - halfH; + m_acceptVelocity.y = -fabsf(m_acceptVelocity.y); + } + + m_acceptBtn->setPosition(pos); +}; + TermsAndConditions* TermsAndConditions::create(Callback&& cb) { auto ret = new TermsAndConditions(); if (ret->init(std::move(cb))) { From c9d9d12e40334b6d73412dd64b85b8877b066461 Mon Sep 17 00:00:00 2001 From: DumbCaveSpider <56347227+DumbCaveSpider@users.noreply.github.com> Date: Mon, 1 Jun 2026 16:34:08 +0800 Subject: [PATCH 2/2] tos fixed and improved --- src/hooks/obstructive/TOS.cpp | 2 +- src/util/ui/TermsAndConditions.hpp | 2 +- src/util/ui/src/TermsAndConditions.cpp | 33 +++++++++++++++----------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/hooks/obstructive/TOS.cpp b/src/hooks/obstructive/TOS.cpp index aaa81a6..3c525e8 100644 --- a/src/hooks/obstructive/TOS.cpp +++ b/src/hooks/obstructive/TOS.cpp @@ -51,7 +51,7 @@ class $modify(TOSGJBaseGameLayer, GJBaseGameLayer) { cursor::show(); - updateTimeWarp(0.125f); + //updateTimeWarp(0.125f); }; }; }; diff --git a/src/util/ui/TermsAndConditions.hpp b/src/util/ui/TermsAndConditions.hpp index 2e08cbd..05e7865 100644 --- a/src/util/ui/TermsAndConditions.hpp +++ b/src/util/ui/TermsAndConditions.hpp @@ -11,7 +11,7 @@ namespace horrible { private: geode::Button* m_acceptBtn = nullptr; cocos2d::CCPoint m_acceptVelocity = {0.f, 0.f}; - float m_acceptSpeed = 2400.f; + float m_acceptSpeed = 100.f; float m_mouseAvoidDistance = 25.f; float m_mouseAvoidMultiplier = 1.75f; diff --git a/src/util/ui/src/TermsAndConditions.cpp b/src/util/ui/src/TermsAndConditions.cpp index 2bc3208..98aaa06 100644 --- a/src/util/ui/src/TermsAndConditions.cpp +++ b/src/util/ui/src/TermsAndConditions.cpp @@ -4,7 +4,6 @@ #include #include -#include "Geode/cocos/cocoa/CCGeometry.h" using namespace geode::prelude; using namespace horrible::prelude; @@ -58,8 +57,12 @@ bool TermsAndConditions::init(Callback&& cb) { [this, cb](auto) { sfx::play(sfx::file::good); if (cb) cb(true); + if (auto pl = PlayLayer::get()) { + pl->resume(); + } removeFromParent(); }); + m_acceptBtn->setZOrder(10); m_acceptBtn->setScale(0.75f); auto declineBtn = Button::createWithNode( @@ -72,6 +75,7 @@ bool TermsAndConditions::init(Callback&& cb) { if (cb) cb(false); removeFromParent(); }); + declineBtn->setZOrder(10); declineBtn->setScale(0.75f); m_mainLayer->addChildAtPosition(m_acceptBtn, Anchor::Bottom, {-60.f, 25.f}); @@ -104,14 +108,16 @@ void TermsAndConditions::update(float dt) { if (!m_acceptBtn) return; CCSize const winSize = CCDirector::sharedDirector()->getWinSize(); - CCPoint pos = m_acceptBtn->getPosition(); + CCPoint const localPos = m_acceptBtn->getPosition(); + CCPoint worldPos = m_mainLayer->convertToWorldSpace(localPos); CCSize const buttonSize = m_acceptBtn->getScaledContentSize(); CCPoint const mousePos = cocos::getMousePos(); - CCPoint const away = ccpSub(pos, mousePos); + CCPoint const away = ccpSub(worldPos, mousePos); float const dist = std::sqrt(away.x * away.x + away.y * away.y); float speed = m_acceptSpeed; + // make the mouse (like cheeseworks) to chase the accept button cuz im evil if (dist < m_mouseAvoidDistance && dist > 0.f) { auto normalizedAway = ccp(away.x / dist, away.y / dist); auto currentVelLen = std::sqrt(m_acceptVelocity.x * m_acceptVelocity.x + m_acceptVelocity.y * m_acceptVelocity.y); @@ -128,29 +134,28 @@ void TermsAndConditions::update(float dt) { speed *= m_mouseAvoidMultiplier; } - auto const delta = ccpMult(m_acceptVelocity, speed * dt); - pos = ccpAdd(pos, delta); + worldPos = ccpAdd(worldPos, ccpMult(m_acceptVelocity, speed * dt)); auto const halfW = buttonSize.width / 2.f; auto const halfH = buttonSize.height / 2.f; - if (pos.x < halfW) { - pos.x = halfW; + if (worldPos.x < halfW) { + worldPos.x = halfW; m_acceptVelocity.x = fabsf(m_acceptVelocity.x); - } else if (pos.x > winSize.width - halfW) { - pos.x = winSize.width - halfW; + } else if (worldPos.x > winSize.width - halfW) { + worldPos.x = winSize.width - halfW; m_acceptVelocity.x = -fabsf(m_acceptVelocity.x); } - if (pos.y < halfH) { - pos.y = halfH; + if (worldPos.y < halfH) { + worldPos.y = halfH; m_acceptVelocity.y = fabsf(m_acceptVelocity.y); - } else if (pos.y > winSize.height - halfH) { - pos.y = winSize.height - halfH; + } else if (worldPos.y > winSize.height - halfH) { + worldPos.y = winSize.height - halfH; m_acceptVelocity.y = -fabsf(m_acceptVelocity.y); } - m_acceptBtn->setPosition(pos); + m_acceptBtn->setPosition(m_mainLayer->convertToNodeSpace(worldPos)); }; TermsAndConditions* TermsAndConditions::create(Callback&& cb) {