Skip to content

Commit

Permalink
ass
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Jan 26, 2024
1 parent 5c07cc8 commit c99b633
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 15 deletions.
18 changes: 11 additions & 7 deletions src/Client/AndroidUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class AndroidUI : public cocos2d::CCLayerColor {

this->runAction(CCFadeTo::create(0.5f, 100));

this->setID("android-ui");

#pragma region Back

auto backMenu = CCMenu::create();
Expand Down Expand Up @@ -299,6 +301,9 @@ class AndroidUI : public cocos2d::CCLayerColor {

static void addToScene()
{
if (CCDirector::get()->getRunningScene()->getChildByID("android-ui"))
return;

auto l = AndroidUI::create();

CCDirector::get()->getRunningScene()->addChild(l, 69420);
Expand Down Expand Up @@ -513,7 +518,7 @@ class $modify (PlayLayer)
CCDirector::get()->getRunningScene()->addChild(andBall);
}
};

/*
class $modify (PauseLayer)
{
static PauseLayer* create(bool p0)
Expand All @@ -525,7 +530,7 @@ class $modify (PauseLayer)
return v;
}
};

*/
class $modify (LoadingLayer)
{
bool init(bool p0)
Expand All @@ -538,7 +543,7 @@ class $modify (LoadingLayer)
return true;
}
};

/*
//todo: fix android
//no longer todo i fixed it :3
Expand All @@ -560,12 +565,12 @@ class $modify (MenuLaunchFix, MenuLayer)
if (!MenuLayer::init())
return false;
this->scheduleOnce(schedule_selector(MenuLaunchFix::fix), 0.1f);
this->scheduleOnce(schedule_selector(MenuLaunchFix::fix), 10);
return true;
}
};

*/
class $modify (CCScene)
{
int getHighestChildZ()
Expand All @@ -578,7 +583,7 @@ class $modify (CCScene)
if (AndroidBall::instance)
AndroidBall::instance->setZOrder(68419);

this->scheduleOnce(schedule_selector(MenuLaunchFix::fix), 0.1f);
//this->scheduleOnce(schedule_selector(MenuLaunchFix::fix), 0.1f);

return value;
}
Expand Down Expand Up @@ -617,6 +622,5 @@ class $modify (AchievementNotifier)

p0->addChild(AndroidBall::create());
cocos::handleTouchPriority(AndroidBall::instance);
AndroidBall::instance->setTouchPriority(AndroidBall::instance->getTouchPriority() - 1);
}
};
2 changes: 1 addition & 1 deletion src/Client/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class InputModule : public Module, public TextInputDelegate
text = geode::prelude::Mod::get()->getSavedValue<std::string>(id + "_value", text);
}

void makeAndroid(CCMenu* menu, CCPoint pos)
void makeAndroid(CCMenu* menu, CCPoint pos/*, bool useless, SEL_MenuHandler event*/)
{
auto label = CCLabelBMFont::create(name.c_str(), "bigFont.fnt");
label->setAnchorPoint(ccp(0, 0.5f));
Expand Down
88 changes: 81 additions & 7 deletions src/Client/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class Window
}
};

class Speedhack : public Window
class Speedhack : public Window//, public TextInputDelegate
{
public:
Speedhack()
Expand All @@ -182,34 +182,108 @@ class Speedhack : public Window
id = "speedhack-window";
}

static inline Slider* slider = nullptr;

void clear(CCObject* sender)
{
SpeedhackTop::instance->text = "";
reinterpret_cast<geode::InputNode*>(static_cast<CCNode*>(sender)->getParent()->getChildByID("speedhack-top"))->setString("");
slider->setValue(unscaleValue(1));
}

float scaleValue(float originalValue) {
float minValue = 0.1;
float maxValue = 3.0;
float scaledValue = (maxValue - minValue) * originalValue + minValue;
return scaledValue;
}

float unscaleValue(float scaledValue) {
float minValue = 0.1;
float maxValue = 3.0;
float originalValue = (scaledValue - minValue) / (maxValue - minValue);
return originalValue;
}

void sliderChanged(CCObject* sender)
{
float v = ((slider->getThumb()->getPositionX() + 100) / 200.0f);

std::stringstream ss;
ss << round(scaleValue(v) * 100.0) / 100.0;

auto inp = static_cast<geode::InputNode*>(static_cast<CCNode*>(sender)->getParent()->getParent()->getParent()->getChildByID("speedhack-top"));
inp->setString(ss.str().c_str());
SpeedhackTop::instance->text = ss.str();

SpeedhackTop::instance->save();
}

void cocosCreate(CCMenu* menu)
{
float v = 1.0f;

if (SpeedhackTop::instance->text.size() != 0 && !SpeedhackTop::instance->text.ends_with("."))
{
v = std::stof(SpeedhackTop::instance->text);
}

if (v < 0.01f)
v = 0.01f;

if (v > 99999)
v = 99999;


auto back = CCScale9Sprite::create("square02_small.png");
back->setContentSize(menu->getContentSize() / 0.5f);
back->setPosition(ccp(0, 0));
back->setAnchorPoint(ccp(0, 0));
back->setScale(0.5f);
back->setOpacity(100);

menu->addChild(back);

for (size_t m = 0; m < modules.size(); m++)
{
modules[m]->makeAndroid(menu, {20, (menu->getContentSize().height - 20 - 20) - 7 - (28.0f * (m - 1.0f))});
}
slider = Slider::create(menu, menu_selector(Speedhack::sliderChanged));
slider->setPosition(ccp(menu->getContentSize().width / 2, menu->getContentSize().height - 80));
slider->setScale(0.875f);
slider->setContentSize(ccp(0, 0));
slider->ignoreAnchorPointForPosition(false);
slider->setValue(clampf(unscaleValue(v), 0, 1));
menu->addChild(slider, 2);

modules[0]->makeAndroid(menu, ccp(menu->getContentSize().width / 2, menu->getContentSize().height - 50) - ccp(180 / 2, 0) + ccp(10, 0));
modules[1]->makeAndroid(menu, ccp(menu->getContentSize().width / 2, menu->getContentSize().height - 200) - ccp(180 / 2, 0) + ccp(10, 0));
modules[2]->makeAndroid(menu, ccp(menu->getContentSize().width / 2, menu->getContentSize().height - 250) - ccp(180 / 2, 0) + ccp(10, 0));
//static_cast<geode::InputNode*>(menu->getChildByID("speedhack-top"))->getInput()->setDelegate(this);

auto trash = CCMenuItemSpriteExtra::create(CCSprite::createWithSpriteFrameName("GJ_trashBtn_001.png"), menu, menu_selector(Speedhack::clear));
trash->m_baseScale = 0.725f;
trash->setScale(0.725f);
trash->setPosition(ccp(210, menu->getContentSize().height - 20));
trash->setPosition(ccp((menu->getContentSize().width / 2) + (180 / 2) + 20, menu->getContentSize().height - 50));
menu->addChild(trash);
}

virtual void textChanged(CCTextInputNode* p0)
{
SpeedhackTop::instance->text = p0->getString();

float v = 1.0f;

if (SpeedhackTop::instance->text.size() != 0 && !SpeedhackTop::instance->text.ends_with("."))
{
v = std::stof(SpeedhackTop::instance->text);
}

if (v < 0.01f)
v = 0.01f;

if (v > 99999)
v = 99999;

slider->setValue(clampf(unscaleValue(v), 0, 1));

modules[0]->save();
}
};

class Credits : public Window
Expand Down

0 comments on commit c99b633

Please sign in to comment.