Skip to content

Commit

Permalink
hfg
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Feb 8, 2024
1 parent 5d4ba2b commit 726f417
Show file tree
Hide file tree
Showing 9 changed files with 261 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Fixed Level Edit breaking level page
- Added Force Trail On and Force Trail Off
- Added No Camera Shake
- Added Menu Animations, From Left, From Right, From Top, From Bottom and Scale
- Added ~~Herobrine~~ Zulguroth

# 1.1.2
Expand Down
19 changes: 18 additions & 1 deletion src/Client/AndroidUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,25 @@ class AndroidUI : public cocos2d::CCLayerColor {
}
}

int e = Mod::get()->getSavedValue<int>("anim-mode", 2);

panel->setPosition(CCDirector::get()->getWinSize() / 2);
panel->setPositionY(-1 * panel->getContentSize().height / 2);

if (e == 1)
panel->setPositionY(panel->getContentSize().height);
if (e == 2)
panel->setPositionY(-1 * panel->getContentSize().height / 2);
if (e == 3)
panel->setPositionX(-1 * panel->getContentSize().width / 2 / 2);
if (e == 4)
panel->setPositionX(panel->getContentSize().width);

if (e == 5)
{
panel->setScale(0);

return CCSpeed::create((CCEaseElasticOut::create(CCScaleTo::create(1, 1))), 1.0f / v);
}

return CCSpeed::create((CCEaseElasticOut::create(CCMoveTo::create(1, CCDirector::get()->getWinSize() / 2))), 1.0f / v);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Client/ClientSetup.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include "Client.h"

class ClientUtils
Expand Down
47 changes: 47 additions & 0 deletions src/Client/ClippingNode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include <Geode/Geode.hpp>

//definetly not ai generated

using namespace geode::prelude;

class ClippingNode : public CCMenu {
private:
CCRect m_clipRect;

public:
static ClippingNode* create(const CCRect& clipRect) {
ClippingNode* node = new ClippingNode();
if (node && node->initWithClipRect(clipRect)) {
node->autorelease();
return node;
}
CC_SAFE_DELETE(node);
return NULL;
}

bool initWithClipRect(const CCRect& clipRect) {
if (!CCMenu::init()) {
return false;
}
m_clipRect = clipRect;
return true;
}

void setClipRect(const CCRect& clipRect)
{
m_clipRect = clipRect;
}

virtual void visit() {
if (!m_clipRect.equals(CCRectZero)) {
glEnable(GL_SCISSOR_TEST);
CCEGLView::sharedOpenGLView()->setScissorInPoints(m_clipRect.origin.x, m_clipRect.origin.y, m_clipRect.size.width, m_clipRect.size.height);
CCMenu::visit();
glDisable(GL_SCISSOR_TEST);
} else {
CCMenu::visit();
}
}
};
2 changes: 2 additions & 0 deletions src/Client/ColourUtility.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include <imgui-cocos.hpp>

class ColourUtility
Expand Down
2 changes: 2 additions & 0 deletions src/Client/DrawUtils.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include <imgui-cocos.hpp>

class DrawUtils
Expand Down
173 changes: 172 additions & 1 deletion src/Client/Dropdown.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,176 @@
#pragma once

#include <Geode/Geode.hpp>
#include "CCContentSizeTo.h"
#include "ClippingNode.h"

using namespace geode::prelude;

class Dropdown : public /*CCMenu*/ClippingNode {
private:
CCLabelBMFont* tex;
CCSize size;
CCScale9Sprite* bg;
CCSprite* sprBtn;
CCSprite* sprBtn2;
CCMenuItemSprite* btn;

int selected = 0;
bool open;
std::vector<std::string> strs;
std::vector<CCMenuItemSprite*> btns;

cocos2d::SEL_MenuHandler event;

public:
void onToggleVisible(CCObject*)
{
open = !open;

btn->stopAllActions();

if (open)
{
btn->runAction(CCEaseBackOut::create(CCScaleTo::create(0.35f, 1, -1)));

setVis(true);
}
else
{
btn->runAction(CCEaseBackOut::create(CCScaleTo::create(0.35f, 1, 1)));

setVis(false);
}
}

void setVis(bool n)
{
CCPoint s = ccp(size.width, size.height * (1 + (open ? strs.size() : 0)));
bg->stopAllActions();
bg->runAction(CCEaseInOut::create( CCContentSizeTo::create(0.35f, s / 0.5f), 2.0f));

if (n)
{
for (size_t i = 0; i < btns.size(); i++)
{
btns[i]->stopAllActions();

//btns[i]->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.1f * i), CCEaseInOut::create(CCScaleTo::create(0.5f, 1), 2)));
}
}
else
{
std::reverse(btns.begin(), btns.end());

for (size_t i = 0; i < btns.size(); i++)
{
btns[i]->stopAllActions();

//btns[i]->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.1f * i), CCEaseInOut::create(CCScaleTo::create(0.35f, 0), 2)));
}

std::reverse(btns.begin(), btns.end());
}
}

void onPress(CCObject* sender)
{
open = false;
setSelected(as<CCNode*>(sender)->getTag());

btn->runAction(CCEaseBackOut::create(CCScaleTo::create(0.35f, 1, 1)));
setVis(false);

if (event)
(this->*event)(sender);
}

bool init(CCSize size, std::vector<std::string> strs, cocos2d::SEL_MenuHandler callback, int sel = 0)
{
if (!CCMenu::init())
return false;

this->size = size;
this->strs = strs;
this->event = callback;

this->setContentSize(size);
bg = CCScale9Sprite::create("square02b_small.png");
bg->setAnchorPoint(ccp(0, 0));
bg->setContentSize(size / 0.5f);
bg->setScale(0.5f);
bg->setColor(ccc3(0, 0, 0));
bg->setOpacity(100);
bg->setPositionY(size.height);
bg->setScaleY(-1 * 0.5f);
this->addChild(bg);

sprBtn = CCSprite::createWithSpriteFrameName("edit_downBtn_001.png");
sprBtn->setColor({200, 200, 200});
sprBtn2 = CCSprite::createWithSpriteFrameName("edit_downBtn_001.png");
btn = CCMenuItemSprite::create(sprBtn, sprBtn2, this, menu_selector(Dropdown::onToggleVisible));
btn->setPosition(size + ccp(-7.5f - sprBtn->getContentSize().width / 2, -1 * (size.height / 2)));
this->addChild(btn);

tex = CCLabelBMFont::create(strs[sel].c_str(), "bigFont.fnt");
tex->setPosition(size / 2 + ccp(-1 * sprBtn->getContentSize().width, 0) + ccp(10 / 2, 0));
tex->limitLabelWidth(size.width - 10 - (7.5f + sprBtn->getContentSize().width), 0.7f, 0.05f);
this->addChild(tex);

for (size_t s = 0; s < strs.size(); s++)
{
auto lbl = CCLabelBMFont::create(strs[s].c_str(), "bigFont.fnt");
lbl->limitLabelWidth(size.width - 10 - 10, 0.7f, 0.01f);
lbl->setColor(ccc3(200, 200, 200));

auto btn = CCMenuItemSpriteExtra::create(lbl, this, menu_selector(Dropdown::onPress));
btn->setPosition(ccp(size.width / 2, (size.height * (s + 1) * -1) + size.height / 2 ));
btn->setScale(1);
btn->setTag(s);
this->addChild(btn);

btns.push_back(btn);
}

this->registerWithTouchDispatcher();
this->scheduleUpdate();
cocos::handleTouchPriority(this);

return true;
}

int getSelectedIndex() { return selected; }

void setSelected(int sh)
{
selected = sh;

auto ss = (strs[sh]);
tex->setString(ss.c_str());
tex->limitLabelWidth(size.width - 10 - (7.5f + sprBtn->getContentSize().width), 0.7f, 0.05f);
}

void update(float dt)
{
this->setClipRect(CCRectMake(this->getParent()->convertToWorldSpace(this->getPosition()).x - 50, this->getParent()->convertToWorldSpace(this->getPosition()).y - (bg->getContentSize().height / 2) + size.height, size.width + 50 + 50, size.height * (strs.size() + 2)));
}

static Dropdown* create(CCSize size, std::vector<std::string> strs, cocos2d::SEL_MenuHandler callback, int sel = 0) {
Dropdown* ret = new Dropdown();
if (ret && ret->init(size, strs, callback, sel)) {
ret->autorelease();
return ret;
} else {
delete ret;
ret = nullptr;
return nullptr;
}
}
};

/*
#pragma once
#include <Geode/Geode.hpp>
#include "CCContentSizeTo.h"
Expand Down Expand Up @@ -175,4 +346,4 @@ class Dropdown : public CCMenu {
return nullptr;
}
}
};
};*/
14 changes: 11 additions & 3 deletions src/Client/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ class Config : public Window
static inline Slider* normal = nullptr;
static inline Slider* GP = nullptr;
static inline Slider* ED = nullptr;
static inline Dropdown* dd = nullptr;

void changeTheme(CCObject* sender)
{
Expand Down Expand Up @@ -605,6 +606,11 @@ class Config : public Window
a->setID(as<CCNode*>(sender)->getID());
}

void onDropdownChanged(CCObject*)
{
Mod::get()->setSavedValue<int>("anim-mode", dd->getSelectedIndex());
}

void cocosCreate(CCMenu* menu)
{
btns.clear();
Expand Down Expand Up @@ -675,8 +681,8 @@ class Config : public Window
ED->setScaleX(0.8f);
ED->getThumb()->setScaleX((1.0f / 0.8f) * 0.5f);

modules[0]->makeAndroid(menu, ccp(132, menu->getContentSize().height - 90));
modules[1]->makeAndroid(menu, ccp(132, menu->getContentSize().height - 90 - 28));
modules[0]->makeAndroid(menu, ccp(132, menu->getContentSize().height - 90 - 28));
modules[1]->makeAndroid(menu, ccp(132, menu->getContentSize().height - 90 - 30 - 28));

menu->addChild(lNormal);
menu->addChild(normal);
Expand All @@ -695,7 +701,9 @@ class Config : public Window
yt->setID("https://www.youtube.com/@TheSillyDoggo");
menu->addChild(yt);

menu->addChild(Dropdown::create({130, 30}, {"hi", "b", "c"}, nullptr));
dd = Dropdown::create({130, 25}, {"None", "From Top", "From Bottom", "From Left", "From Right", "Scale"}, menu_selector(Config::onDropdownChanged), Mod::get()->getSavedValue<int>("anim-mode", 2));
dd->setPosition(ccp(120.5f, menu->getContentSize().height - 90));
menu->addChild(dd);
}
};

Expand Down
6 changes: 6 additions & 0 deletions src/Hacks/ForcePlatformer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <Geode/Geode.hpp>
#include <Geode/modify/PlayerObject.hpp>
#include <Geode/modify/UILayer.hpp>
#include "../Client/Client.h"

using namespace geode::prelude;
Expand All @@ -9,7 +10,12 @@ class $modify (PlayerObject)
virtual void update(float dt)
{
if (Client::GetModuleEnabled("force-plat"))
{
this->togglePlatformerMode(true);
#ifdef GEODE_IS_ANDROID
PlayLayer::get()->m_uiLayer->togglePlatformerMode(true);
#endif
}

PlayerObject::update(dt);
}
Expand Down

0 comments on commit 726f417

Please sign in to comment.