Skip to content

Commit

Permalink
frame stepper
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Oct 3, 2024
1 parent 91eb96a commit 1295281
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 14 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# 1.7.0

- Made Icon Effects change colour of objects that use player colour in the level
- Frame Stepper no longer saves ticks if you are dead
- Frame Stepper buttons now repeat presses when being held down
- Rewrote **Show Layout** to be better, allowing it to be ported to Windows and macOS
- Added **Chest Unlock Bypass**

Expand Down
9 changes: 6 additions & 3 deletions src/Hacks/Frame Stepper/FrameStepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ void SteppedBaseGameLayer::storeState()
if (!typeinfo_cast<PlayLayer*>(this))
return;

if (m_player1 && m_player1->m_isDead)
return;

auto fields = m_fields.self();

if (fields->states.size() + 1 > MAX_STORED_STATES)
Expand Down Expand Up @@ -91,13 +94,13 @@ bool SteppedUILayer::init(GJBaseGameLayer* bgl)

menu->setPosition(ccp(135 / 2, 40 / 2) + ccp(25, 25));

m_fields->pause = CCMenuItemSpriteExtra::create(CCSprite::createWithSpriteFrameName("GJ_pauseBtn_001.png"), this, menu_selector(SteppedUILayer::onTogglePaused));
m_fields->pause = RepeatableMenuItemSpriteExtra::create(CCSprite::createWithSpriteFrameName("GJ_pauseBtn_001.png"), this, menu_selector(SteppedUILayer::onTogglePaused));
m_fields->pause->getNormalImage()->setScale(0.8f);

m_fields->prev = CCMenuItemSpriteExtra::create(CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png"), this, menu_selector(SteppedUILayer::onPreviousFrame));
m_fields->prev = RepeatableMenuItemSpriteExtra::create(CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png"), this, menu_selector(SteppedUILayer::onPreviousFrame));
m_fields->prev->getNormalImage()->setScale(0.8f);

auto next = CCMenuItemSpriteExtra::create(CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png"), this, menu_selector(SteppedUILayer::onStepFrame));
auto next = RepeatableMenuItemSpriteExtra::create(CCSprite::createWithSpriteFrameName("GJ_arrow_02_001.png"), this, menu_selector(SteppedUILayer::onStepFrame));
next->getNormalImage()->setScale(0.8f);
as<CCSprite*>(next->getNormalImage())->setFlipX(true);

Expand Down
7 changes: 4 additions & 3 deletions src/Hacks/Frame Stepper/FrameStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <Geode/modify/UILayer.hpp>
#include "../../Layers/EditPositionLayer.hpp"
#include "../../Client/Client.h"
#include "../../UI/RepeatableMenuItemSpriteExtra.hpp"

using namespace geode::prelude;

Expand Down Expand Up @@ -35,9 +36,9 @@ class $modify (SteppedUILayer, UILayer)
{
struct Fields
{
CCMenuItemSpriteExtra* next;
CCMenuItemSpriteExtra* prev;
CCMenuItemSpriteExtra* pause;
RepeatableMenuItemSpriteExtra* next;
RepeatableMenuItemSpriteExtra* prev;
RepeatableMenuItemSpriteExtra* pause;
CCMenu* menu;
};

Expand Down
11 changes: 3 additions & 8 deletions src/Hacks/Show Layout/Layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class $modify (LayoutBaseGameLayer, GJBaseGameLayer)
static void onModify(auto& self)
{
showLayoutHooks.push_back(self.getHook("GJBaseGameLayer::updateColor").unwrapOr(nullptr));
showLayoutHooks.push_back(self.getHook("GJBaseGameLayer::updateColor").unwrapOr(nullptr));
showLayoutHooks.push_back(self.getHook("GJBaseGameLayer::createBackground").unwrapOr(nullptr));
showLayoutHooks.push_back(self.getHook("GJBaseGameLayer::createGroundLayer").unwrapOr(nullptr));
showLayoutHooks.push_back(self.getHook("GJBaseGameLayer::createMiddleground").unwrapOr(nullptr));

for (auto hook : showLayoutHooks)
hook->setAutoEnable(false);
Expand All @@ -76,12 +78,5 @@ class $modify (LayoutBaseGameLayer, GJBaseGameLayer)
void createGroundLayer(int p0, int p1);
void createMiddleground(int p0);

void updateDualGround(PlayerObject* p0, int p1, bool p2, float p3)
{
log::info("p0: {}, p1: {}, p2: {}, p3: {}", p0, p1, p2, p3);

GJBaseGameLayer::updateDualGround(p0, p1, p2, p3);
}

virtual void updateColor(cocos2d::ccColor3B& color, float fadeTime, int colorID, bool blending, float opacity, cocos2d::ccHSVValue& copyHSV, int colorIDToCopy, bool copyOpacity, EffectGameObject* callerObject, int unk1, int unk2);
};
61 changes: 61 additions & 0 deletions src/UI/RepeatableMenuItemSpriteExtra.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "RepeatableMenuItemSpriteExtra.hpp"

void RepeatableMenuItemSpriteExtra::update(float dt)
{
if (!m_bEnabled)
{
m_bSelected = false;
}

if (!m_bSelected)
{
t = 0;
v = 0;
d = 0;
return;
}

t += dt;

if (t > startDelay)
{
v += dt;

if (v > repeatTime - d)
{
v -= repeatTime - d;

d += repTimeInc;

if (d > repeatTime - maxSpeed)
d = repeatTime - maxSpeed;

activate();

auto sequence = CCSequence::create(CCEaseBackOut::create(CCScaleBy::create(0.07f, 1.2f)), CCDelayTime::create(0.02f), CCScaleBy::create(0.1f, 1.0f / 1.2f), nullptr);

this->runAction(sequence);
}
}
}

RepeatableMenuItemSpriteExtra* RepeatableMenuItemSpriteExtra::create(cocos2d::CCNode* sprite, cocos2d::CCNode* disabledSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback)
{
auto pRet = new RepeatableMenuItemSpriteExtra();

if (pRet && pRet->init(sprite, disabledSprite, target, callback))
{
pRet->scheduleUpdate();

pRet->autorelease();
return pRet;
}

CC_SAFE_DELETE(pRet);
return nullptr;
}

RepeatableMenuItemSpriteExtra* RepeatableMenuItemSpriteExtra::create(cocos2d::CCNode* sprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback)
{
return create(sprite, nullptr, target, callback);
}
22 changes: 22 additions & 0 deletions src/UI/RepeatableMenuItemSpriteExtra.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <Geode/Geode.hpp>

using namespace geode::prelude;

class RepeatableMenuItemSpriteExtra : public CCMenuItemSpriteExtra
{
public:
float maxSpeed = 0.03f;
float repTimeInc = 0.003f;
float repeatTime = 0.15f;
float startDelay = 0.4f;
float t = 0;
float v = 0;
float d = 0;

virtual void update(float dt);

static RepeatableMenuItemSpriteExtra* create(cocos2d::CCNode* sprite, cocos2d::CCNode* disabledSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback);
static RepeatableMenuItemSpriteExtra* create(cocos2d::CCNode* sprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback);
};

0 comments on commit 1295281

Please sign in to comment.