Skip to content

Commit

Permalink
dfsg
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Aug 3, 2024
1 parent 1d35a0c commit fc386f4
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 55 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

- Fixed Crash pressing Q or E in the editor with startpos switcher enabled
- Fixed the Button disappearing when switching scenes
- Fixed Noclip not working in the editor
- Changed the Button to use textures instead of labels
- Added **Labels In Editor**

# 1.5.2

Expand Down
5 changes: 4 additions & 1 deletion src/Client/ClientSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ class ClientUtils
replay->modules.push_back(new StatusScale());

//replay->modules.push_back(new Module("Testmode", "status-testmode", "Show the test mode text if there's a startpos"));
replay->modules.push_back(new Module("Labels In Editor", "labels-in-editor", "Shows your labels in the level editor <cr>[EXPERIMENTAL]</c>"));

replay->modules.push_back(new Module("Cheat Indicator", "cheat-indicator", "Shows if you are cheating"));
replay->modules.push_back(new Module("FPS Counter", "status-fps", "Shows your current game fps"));
replay->modules.push_back(new Module("Noclip Accuracy", "status-accuracy", "Shows your accuracy in noclip (hidden when noclip is disabled)"));
Expand All @@ -378,7 +380,8 @@ class ClientUtils

for (auto mod : replay->modules)
{
mod->options.push_back(new DropdownModule({"Top Left", "Top Right", "Bottom Left", "Bottom Right"}, mod->id + "-side", 0));
if (mod->id != "labels-in-editor")
mod->options.push_back(new DropdownModule({"Top Left", "Top Right", "Bottom Left", "Bottom Right"}, mod->id + "-side", 0));
}

auto messageOption = new InputModule("Message Text: ", "status-message-text", "Default Message");
Expand Down
79 changes: 66 additions & 13 deletions src/Hacks/Noclip/Noclip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ void NoclipPlayLayer::destroyPlayer(PlayerObject* p0, GameObject* p1)
return PlayLayer::destroyPlayer(p0, p1);
}

if (!m_fields->ac)
m_fields->ac = p1;
if (!base_cast<NoclipBaseGameLayer*>(this)->m_fields->ac)
base_cast<NoclipBaseGameLayer*>(this)->m_fields->ac = p1;

if (!Client::GetModuleEnabled("noclip") || (m_fields->ac == p1))
if (!Client::GetModuleEnabled("noclip") || (base_cast<NoclipBaseGameLayer*>(this)->m_fields->ac == p1))
PlayLayer::destroyPlayer(p0, p1);
else
{
SafeMode::get()->setHackedAttempt();

if (!m_fields->hasDied)
if (!base_cast<NoclipBaseGameLayer*>(this)->m_fields->hasDied)
{
m_fields->hasDied = true;
m_fields->timeDead += CCDirector::get()->getDeltaTime();
base_cast<NoclipBaseGameLayer*>(this)->m_fields->hasDied = true;
base_cast<NoclipBaseGameLayer*>(this)->m_fields->timeDead += CCDirector::get()->getDeltaTime();
}

m_fields->isDead = true;
Expand All @@ -51,7 +51,7 @@ void NoclipPlayLayer::destroyPlayer(PlayerObject* p0, GameObject* p1)
m_fields->d++;
}

if (m_fields->ac != p1)
if (base_cast<NoclipBaseGameLayer*>(this)->m_fields->ac != p1)
m_fields->t++;

if (m_fields->tintOnDeath->enabled)
Expand All @@ -69,24 +69,77 @@ void NoclipPlayLayer::resetLevel()

m_fields->d = 0;
m_fields->t = 0;
m_fields->timeDead = 0;
base_cast<NoclipBaseGameLayer*>(this)->m_fields->timeDead = 0;
m_fields->isDead = false;
}

float NoclipPlayLayer::getNoclipAccuracy()
void NoclipBaseGameLayer::update(float dt)
{
GJBaseGameLayer::update(dt);

m_fields->hasDied = false;
}

void NoclipBaseGameLayer::resetLevelVariables()
{
GJBaseGameLayer::resetLevelVariables();

m_fields->timeDead = 0;
}

float NoclipBaseGameLayer::getNoclipAccuracy()
{
if (m_gameState.m_currentProgress == 0)
return 1;

return 1 - (m_fields->timeDead / as<float>(m_gameState.m_levelTime));
}

void NoclipBaseGameLayer::update(float dt)
void NoclipEditorLayer::playerTookDamage(PlayerObject* p0)
{
GJBaseGameLayer::update(dt);
if (Client::GetModuleEnabled("noclip"))
{
auto nbgl = base_cast<NoclipBaseGameLayer*>(this);

if (!nbgl->m_fields->ac)
nbgl->m_fields->ac = p0->m_collidedObject;

if (p0 == nbgl->m_fields->ac)
return LevelEditorLayer::playerTookDamage(p0);

if (auto layer = typeinfo_cast<PlayLayer*>(this))
if (!nbgl->m_fields->hasDied)
{
nbgl->m_fields->hasDied = true;
nbgl->m_fields->timeDead += CCDirector::get()->getDeltaTime();
}

SafeMode::get()->setHackedAttempt();
return;
}

LevelEditorLayer::playerTookDamage(p0);
}

void NoclipEditorLayer::postUpdate(float p0)
{
if (Client::GetModuleEnabled("noclip"))
{
as<NoclipPlayLayer*>(layer)->m_fields->hasDied = false;
auto nbgl = base_cast<NoclipBaseGameLayer*>(this);

if (!nbgl->m_fields->hasDied)
{
nbgl->m_fields->hasDied = true;
nbgl->m_fields->timeDead += CCDirector::get()->getDeltaTime();
}

SafeMode::get()->setHackedAttempt();

if (m_player1)
m_player1->m_maybeIsColliding = false;

if (m_player2)
m_player2->m_maybeIsColliding = false;
}

LevelEditorLayer::postUpdate(p0);
}
23 changes: 17 additions & 6 deletions src/Hacks/Noclip/Noclip.hpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
#include <Geode/Geode.hpp>
#include <Geode/modify/PlayLayer.hpp>
#include <Geode/modify/GJBaseGameLayer.hpp>
#include <Geode/modify/LevelEditorLayer.hpp>
#include "../../Client/Client.h"

using namespace geode::prelude;

class $modify (NoclipPlayLayer, PlayLayer)
{
struct Fields {
GameObject* ac;
GameObject* last;

bool hasDied = false;
float timeDead = 0;

int t = 0;
int d = 0;
bool isDead = false;
Expand All @@ -27,11 +24,25 @@ class $modify (NoclipPlayLayer, PlayLayer)
bool init(GJGameLevel* level, bool useReplay, bool dontCreateObjects);
void destroyPlayer(PlayerObject* p0, GameObject* p1);
void resetLevel();

float getNoclipAccuracy();
};

class $modify (NoclipBaseGameLayer, GJBaseGameLayer)
{
struct Fields {
GameObject* ac;

float timeDead = 0;
bool hasDied = false;
};

virtual void update(float dt);
void resetLevelVariables();

float getNoclipAccuracy();
};

class $modify (NoclipEditorLayer, LevelEditorLayer)
{
virtual void playerTookDamage(PlayerObject* p0);
virtual void postUpdate(float p0);
};
3 changes: 0 additions & 3 deletions src/Hacks/SafeMode/SafeMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ bool SafeMode::shouldKickFromLevel()

void SafeMode::updateIndicator()
{
if (!PlayLayer::get())
return;

#ifdef STATUS_TEXTS

if (auto a = StatusNode::get())
Expand Down
90 changes: 66 additions & 24 deletions src/Labels/Labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Labels.h"
#include "../Hacks/Noclip/Noclip.hpp"
#include "../Hacks/SafeMode/SafeMode.hpp"

bool StatusNode::init()
{
Expand Down Expand Up @@ -103,7 +104,7 @@ void StatusNode::reorderSides()

for (auto label : sLabels)
{
int side = as<DropdownModule*>(window->modules[i + 2]->options[0])->index;
int side = as<DropdownModule*>(window->modules[i + 3]->options[0])->index;

label->setAnchorPoint(ccp((side == 0 || side == 2) ? 0 : 1, (side == 2 || side == 3) ? 0 : 1));
label->setAlignment((side == 0 || side == 2) ? CCTextAlignment::kCCTextAlignmentLeft : CCTextAlignment::kCCTextAlignmentRight);
Expand Down Expand Up @@ -175,13 +176,10 @@ class LabelModuleDelegate : public ModuleChangeDelegate
{
virtual void onModuleChanged(bool enabled)
{
if (PlayLayer::get())
if (auto stn = StatusNode::get())
{
if (auto stn = StatusNode::get())
{
stn->reorderSides();
stn->reorderPosition();
}
stn->reorderSides();
stn->reorderPosition();
}
}
};
Expand All @@ -194,8 +192,11 @@ void StatusNode::postSetup(Window* wnd)

for (auto mod : wnd->modules)
{
mod->delegate = del;
mod->options[0]->delegate = del;
if (mod->id != "labels-in-editor")
{
mod->delegate = del;
mod->options[0]->delegate = del;
}
}
}

Expand Down Expand Up @@ -235,13 +236,15 @@ void StatusNode::update(float dt)
bestRun = Client::GetModule("best-run");

if (!attPL)
attPL = static_cast<AttemptPlayLayer*>(PlayLayer::get());
attPL = static_cast<AttemptBaseGameLayer*>(GJBaseGameLayer::get());

if (!bestRunPlayLayer)
bestRunPlayLayer = static_cast<BestPlayLayer*>(PlayLayer::get());

if (!noclipLayer)
noclipLayer = static_cast<NoclipBaseGameLayer*>(GJBaseGameLayer::get());

float v = 100 * as<NoclipPlayLayer*>(PlayLayer::get())->getNoclipAccuracy();

float v = 100 * noclipLayer->getNoclipAccuracy();

sLabels[0]->setVisible(cheat->enabled);
sLabels[1]->setVisible(fps->enabled);
Expand All @@ -256,21 +259,29 @@ void StatusNode::update(float dt)
sLabels[8]->setVisible(cpsM->enabled);
sLabels[9]->setVisible(bestRun->enabled);

if (PlayLayer::get())
{
sLabels[2]->setString((numToString(v, 2) + std::string("%")).c_str());
sLabels[3]->setString((numToString(as<NoclipPlayLayer*>(PlayLayer::get())->m_fields->d, 0) + (as<NoclipPlayLayer*>(PlayLayer::get())->m_fields->d == 1 ? std::string(" Death") : std::string(" Deaths"))).c_str());
}
else
{
sLabels[2]->setString("");
sLabels[3]->setString("");
}

sLabels[2]->setString((numToString(v, 2) + std::string("%")).c_str());
sLabels[3]->setString((numToString(as<NoclipPlayLayer*>(PlayLayer::get())->m_fields->d, 0) + (as<NoclipPlayLayer*>(PlayLayer::get())->m_fields->d == 1 ? std::string(" Death") : std::string(" Deaths"))).c_str());
sLabels[4]->setString((std::string("Attempt ") + std::to_string(attPL->m_fields->attemptCount)).c_str());


std::string b = (std::string("Frame Fixes: ") + (Mod::get()->getSavedValue<bool>("frame-fixes") ? "Enabled" : "Disabled") + std::string(", Click Fixes: ") + (Mod::get()->getSavedValue<bool>("click-fixes") ? "Enabled" : "Disabled"));

sLabels[5]->setString("");
//sLabels[6]->setString(b.c_str());
//sLabels[7]->setString(inp.str().c_str());
auto v2 = as<InputModule*>(message->options[1])->text.c_str();
sLabels[6]->setString(v2);
sLabels[7]->setString(formatTime(ColourUtility::totalSessionTime).c_str());

if (as<NoclipPlayLayer*>(PlayLayer::get())->m_fields->isDead)
if (PlayLayer::get() && as<NoclipPlayLayer*>(PlayLayer::get())->m_fields->isDead)
{
sLabels[2]->stopAllActions();
sLabels[2]->setColor(ccc3(255, 0, 0));
Expand Down Expand Up @@ -315,6 +326,8 @@ void StatusNode::update(float dt)

if (bestRunPlayLayer)
sLabels[9]->setString(bestRunPlayLayer->getRunString().c_str());
else
sLabels[9]->setString("Best Run: Editor");

updateVis();
}
Expand All @@ -330,7 +343,7 @@ class $modify (PlayerObject)
{
PlayerObject::pushButton(p0);

if (p0 == PlayerButton::Jump && PlayLayer::get() && PlayLayer::get()->m_player1 == this)
if (p0 == PlayerButton::Jump && GJBaseGameLayer::get() && GJBaseGameLayer::get()->m_player1 == this)
{
if (auto stn = StatusNode::get())
{
Expand All @@ -347,7 +360,7 @@ class $modify (PlayerObject)
{
PlayerObject::releaseButton(p0);

if (p0 == PlayerButton::Jump && PlayLayer::get())
if (p0 == PlayerButton::Jump && GJBaseGameLayer::get())
{
if (auto stn = StatusNode::get())
{
Expand All @@ -369,20 +382,49 @@ class $modify (PlayLayer)
return true;

auto stn = StatusNode::create();
stn->attPL = static_cast<AttemptPlayLayer*>(PlayLayer::get());
stn->bestRunPlayLayer = as<BestPlayLayer*>(PlayLayer::get());
stn->attPL = base_cast<AttemptBaseGameLayer*>(this);
stn->bestRunPlayLayer = base_cast<BestPlayLayer*>(this);
this->addChild(stn);

return true;
}
};

void resetLevel()
class $modify (LevelEditorLayer)
{
bool init(GJGameLevel* p0, bool p1)
{
PlayLayer::resetLevel();
if (!LevelEditorLayer::init(p0, p1))
return false;

if (StatusNode::get())
StatusNode::get()->totalClicks = 0;
if (!Client::GetModuleEnabled("labels-in-editor"))
return true;

if (getChildByID("status-node"_spr))
return true;

if (m_uiLayer)
{
auto stn = StatusNode::create();
stn->attPL = base_cast<AttemptBaseGameLayer*>(this);
m_uiLayer->addChild(stn);
}

return true;
}
};

void AttemptBaseGameLayer::resetLevelVariables()
{
if (LevelEditorLayer::get() ? !LevelEditorLayer::get()->m_editorUI->m_playtestStopBtn->isVisible() : true)
m_fields->attemptCount++;

if (StatusNode::get())
StatusNode::get()->totalClicks = 0;

GJBaseGameLayer::resetLevelVariables();

SafeMode::get()->resetOnNewAttempt();
}

#endif
Loading

0 comments on commit fc386f4

Please sign in to comment.