Skip to content

Commit

Permalink
asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Sep 18, 2024
1 parent 7c196f0 commit 1ef59df
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 12 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.6.7

- Added **Toolbox Button Bypass**
- Added **Scale Text Input**

# 1.6.6

- Changed Safe Mode to show the endscreen instead of kicking out of the level
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "3.7.1",
"version": "v1.6.6",
"version": "v1.6.7",
"gd": {
"win": "2.206",
"android": "2.206",
Expand Down
15 changes: 4 additions & 11 deletions src/Client/ClientSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ class ClientUtils
creator->modules.push_back(new SetValueModule("Set Scale:", "set-scale"));
creator->modules.push_back(new SetValueModule("Set Rotation:", "set-rot"));

creator->modules.push_back(new Module("Copy any level", "copy-hack", "Allows you to copy any level from the servers\nCode by <co>Firee</c>"));
creator->modules.push_back(new Module("Show Level Password", "show-password", "Adds a button to the password input popup that shows the level password"));
creator->modules.push_back(new Module("Copy Hack", "copy-hack", "Allows you to copy any level from the servers\nCode by <co>Firee</c>"));
creator->modules.push_back(new Module("Show Level Password", "show-password", "Adds a button to the password input popup that shows the level password", true));

creator->modules.push_back(new Module("No Copy Mark", "noc-hack", "Hides the (c) mark from your levels on publish.\nCode by <co>Firee</c>"));
creator->modules.push_back(new Module("Level Edit", "level-edit", "Allows you to edit any level"));
Expand All @@ -270,16 +270,9 @@ class ClientUtils
creator->modules.push_back(new Module("Smooth Editor Trail", "smooth-editor-trail", "Updates the editor trail at your screen refresh rate instead of 30 fps"));

creator->modules.push_back(new Module("Editor Extension", "editor-extension", "Increases the length of the editor by <cs>17895</c> times :3"));
creator->modules.push_back(new Module("Toolbox Button Bypass", "toolbox-buttons", "Unlimited <cc>Rows</c> and <cc>Columns</c> in your <cl>Object Toolbox</c>"));

//auto misc = new Module("Misc Bypasses", "misc-bypass", "Random <cl>Client Side</c> bypasses / unlocks to random editor limits");
//misc->options.push_back(new Module("Zoom Limit", "zoom-limit", "Bypass the editor zoom limit", true));
//creator->modules.push_back(misc);

//creator->modules.push_back(new Module("Free Scroll", "free-scroll", "Allows you to scroll past the limits of the editor"));

#ifdef GEODE_IS_ANDROID
//bypass->modules.push_back(new Module("Slider Limit Bypass", "slider-limit", "Allows sliders to go beyond the limit of the slider. <cr>Doesn't work for scaling in the editor currently</c>"));
#endif
creator->modules.push_back(new Module("Scale Input", "scale-input-control", "Adds an input field to the object scale control", true));


Client::instance->windows.push_back(creator);
Expand Down
213 changes: 213 additions & 0 deletions src/Hacks/ScaleTextInput.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
#include <Geode/Geode.hpp>
#include <Geode/modify/GJScaleControl.hpp>
#include "../Client/Client.h"

using namespace geode::prelude;

class $modify (InputScaleControl, GJScaleControl)
{
struct Fields
{
TextInput* scaleXInput;
TextInput* scaleYInput;
TextInput* scaleXYInput;

CCLabelBMFont* scaleXLabel;
CCLabelBMFont* scaleYLabel;
CCLabelBMFont* scaleXYLabel;
};

void updateScaleXY(std::string str)
{
auto v = numFromString<float>(str);

if (v.has_value())
{
auto value = v.unwrapOr(1);
auto wrappedValue = unscaleFloat(value, m_lowerBound, m_upperBound);

m_sliderXY->setValue(clamp<float>(wrappedValue, 0, 1));
this->sliderChanged(m_sliderXY->m_touchLogic);

if (EditorUI::get())
{
EditorUI::get()->scaleXYChanged(value, value, m_scaleLocked);
}
}
}

void updateScaleX(std::string str)
{
auto v = numFromString<float>(str);

if (v.has_value())
{
auto value = v.unwrapOr(1);
auto wrappedValue = unscaleFloat(value, m_lowerBound, m_upperBound);

m_sliderX->setValue(clamp<float>(wrappedValue, 0, 1));
this->sliderChanged(m_sliderX->m_touchLogic);

if (EditorUI::get())
{
EditorUI::get()->scaleXChanged(value, m_scaleLocked);
}
}
}

void updateScaleY(std::string str)
{
auto v = numFromString<float>(str);

if (v.has_value())
{
auto value = v.unwrapOr(1);
auto wrappedValue = unscaleFloat(value, m_lowerBound, m_upperBound);

m_sliderY->setValue(clamp<float>(wrappedValue, 0, 1));
this->sliderChanged(m_sliderY->m_touchLogic);

if (EditorUI::get())
{
EditorUI::get()->scaleYChanged(value, m_scaleLocked);
}
}
}

void addControl()
{
m_scaleLabel->setOpacity(0);
m_scaleXLabel->setOpacity(0);
m_scaleYLabel->setOpacity(0);

auto scaleXYInput = TextInput::create(70, "Scale");
scaleXYInput->setScale(0.6f);
scaleXYInput->setPosition(ccp(32, 28));
scaleXYInput->setFilter("1234567890.");
scaleXYInput->setCallback([this](const std::string& str){
updateScaleXY(str);
});

auto scaleXInput = TextInput::create(70, "Scale");
scaleXInput->setScale(0.6f);
scaleXInput->setPosition(ccp(32, 28));
scaleXInput->setFilter("1234567890.");
scaleXInput->setCallback([this](const std::string& str){
updateScaleX(str);
});

auto scaleYInput = TextInput::create(70, "Scale");
scaleYInput->setScale(0.6f);
scaleYInput->setPosition(ccp(32, 28));
scaleYInput->setFilter("1234567890.");
scaleYInput->setCallback([this](const std::string& str){
updateScaleY(str);
});

auto scaleXLabel = CCLabelBMFont::create("ScaleX:", "bigFont.fnt");
scaleXLabel->setScale(0.5f);
scaleXLabel->setAnchorPoint(ccp(1, 0.5f));
scaleXLabel->setPosition(m_scaleXLabel->getPosition());

auto scaleYLabel = CCLabelBMFont::create("ScaleY:", "bigFont.fnt");
scaleYLabel->setScale(0.5f);
scaleYLabel->setAnchorPoint(ccp(1, 0.5f));
scaleYLabel->setPosition(m_scaleYLabel->getPosition() - m_sliderY->getPosition());

auto scaleXYLabel = CCLabelBMFont::create("Scale:", "bigFont.fnt");
scaleXYLabel->setScale(0.5f);
scaleXYLabel->setAnchorPoint(ccp(1, 0.5f));
scaleXYLabel->setPosition(m_scaleLabel->getPosition());

m_sliderX->addChild(scaleXInput);
m_sliderY->addChild(scaleYInput);
m_sliderXY->addChild(scaleXYInput);

m_sliderX->addChild(scaleXLabel);
m_sliderY->addChild(scaleYLabel);
m_sliderXY->addChild(scaleXYLabel);

m_fields->scaleXInput = scaleXInput;
m_fields->scaleYInput = scaleYInput;
m_fields->scaleXYInput = scaleXYInput;

m_fields->scaleXLabel = scaleXLabel;
m_fields->scaleYLabel = scaleYLabel;
m_fields->scaleXYLabel = scaleXYLabel;
}

void removeControl()
{
m_scaleLabel->setOpacity(255);
m_scaleXLabel->setOpacity(255);
m_scaleYLabel->setOpacity(255);

m_fields->scaleXInput->removeFromParent();
m_fields->scaleYInput->removeFromParent();
m_fields->scaleXYInput->removeFromParent();

m_fields->scaleXLabel->removeFromParent();
m_fields->scaleYLabel->removeFromParent();
m_fields->scaleXYLabel->removeFromParent();
}

void loadValues(GameObject* p0, cocos2d::CCArray* p1, gd::unordered_map<int, GameObjectEditorState>& p2)
{
GJScaleControl::loadValues(p0, p1, p2);

m_fields->scaleXInput->setString(fmt::format("{:.2f}", m_valueX));
m_fields->scaleYInput->setString(fmt::format("{:.2f}", m_valueY));
m_fields->scaleXYInput->setString(fmt::format("{:.2f}", m_valueX > m_valueY ? m_valueY : m_valueX));
}

void updateLabelX(float p0)
{
GJScaleControl::updateLabelX(p0);
m_fields->scaleXInput->setString(fmt::format("{:.2f}", p0));
}

void updateLabelY(float p0)
{
GJScaleControl::updateLabelY(p0);
m_fields->scaleYInput->setString(fmt::format("{:.2f}", p0));
}

void updateLabelXY(float p0)
{
GJScaleControl::updateLabelXY(p0);
m_fields->scaleXYInput->setString(fmt::format("{:.2f}", p0));
}

virtual bool init()
{
if (!GJScaleControl::init())
return false;

addControl();

return true;
}

QOLMOD_MOD_ALL_HOOKS("scale-input-control")
};

$execute
{
Loader::get()->queueInMainThread([] {
Client::GetModule("scale-input-control")->onToggle = [](bool enabled){
if (auto editor = LevelEditorLayer::get())
{
if (auto ui = editor->m_editorUI)
{
if (auto control = as<InputScaleControl*>(ui->m_scaleControl))
{
if (enabled)
control->addControl();
else
control->removeControl();
}
}
}
};
});
}
24 changes: 24 additions & 0 deletions src/Hacks/ToolboxButtons.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <Geode/Geode.hpp>
#include <Geode/modify/EditorOptionsLayer.hpp>
#include "../Client/Client.h"

using namespace geode::prelude;

class $modify (EditorOptionsLayer)
{
void onButtonRows(cocos2d::CCObject* sender)
{
m_buttonRows += sender->getTag() ? 1 : -1;
m_buttonRows = clamp<int>(m_buttonRows, 1, m_buttonRows);
m_buttonRowsLabel->setString(fmt::format("{}", m_buttonRows).c_str());
}

void onButtonsPerRow(cocos2d::CCObject* sender)
{
m_buttonsPerRow += sender->getTag() ? 1 : -1;
m_buttonsPerRow = clamp<int>(m_buttonsPerRow, 1, m_buttonsPerRow);
m_buttonsPerRowLabel->setString(fmt::format("{}", m_buttonsPerRow).c_str());
}

QOLMOD_MOD_ALL_HOOKS("toolbox-buttons")
};
8 changes: 8 additions & 0 deletions src/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ float scaleFloat(float v, float min, float max)
return (max - min) * v + min;
}

float unscaleFloat(float v, float min, float max)
{
float minValue = min;
float maxValue = max;
float originalValue = (v - minValue) / (maxValue - minValue);
return originalValue;
}

geode::Patch* createPatchSafe(void *address, const geode::ByteVector &data)
{
auto patch = geode::Mod::get()->patch(address, data);
Expand Down
1 change: 1 addition & 0 deletions src/Utils/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static void onModify(auto& self) { \

float roundUpToMultipleOf2(float num);
float scaleFloat(float v, float min, float max);
float unscaleFloat(float v, float min, float max);
geode::Patch* createPatchSafe(void *address, const geode::ByteVector &data);
cocos2d::CCRect getScreenSafeArea();
cocos2d::CCRect getScreenSafeAreaiOS();

0 comments on commit 1ef59df

Please sign in to comment.