Skip to content

Commit

Permalink
Add Hook Macro, Add Hide Pause Button, Fix UI Button Disappearing, Mo…
Browse files Browse the repository at this point in the history
…re Progress on new UI
  • Loading branch information
TheSillyDoggo committed Jul 8, 2024
1 parent 85096ce commit 6b27d66
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 28 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.4.7

- Fixed the UI Button disappearing if you have Transition Customizer enabled
- Added **Hide Pause Button**

# 1.4.6

- Fixed Touch Issues (now uses geode::Popup<>)
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.2.0",
"version": "v1.4.6",
"version": "v1.4.7",
"gd": {
"win": "2.206",
"android": "2.206"
Expand Down
2 changes: 2 additions & 0 deletions src/Client/ClientSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ class ClientUtils
cosmetic->modules.push_back(new Module("No Orb Pulse", "no-orb-pulse", "Disables orb's from pulsing, Doesn't work on main levels made before 2.2"));
cosmetic->modules.push_back(new Module("Main Menu Gameplay", "main-menu-gameplay", "Allows you to control the icons on the main menu.\nI honestly have no idea what category to put it in so its cosmetic now :3"));

cosmetic->modules.push_back(new Module("Hide Pause Button", "hide-pause-button", "Hides the pause button in game, requires reopening level to apply"));


//cosmetic->modules.push_back(new Module("No Camera Movement", "no-camera", "Disables camera movements that are made with <cl>triggers</c>"));
//cosmetic->modules.push_back(new Module("No Player Rotation", "no-plr-rot", "Disables Player Rotation :3\nIt looks ugly imo but you do you"));
Expand Down
45 changes: 45 additions & 0 deletions src/Client/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,51 @@

#include "../Layers/ModuleOptionsLayer.h"
#include "Dropdown.h"
#include "../UI/PCDrawUtils.hpp"

bool Module::touchBegan(CCPoint point, CCTouch* touch)
{
if (CCRectMake(0, 0, Client::tileSize.x, Client::tileSize.y).containsPoint(point))
{
log::info("id: {}", id);
mouseHeldDown = true;

return true;
}

return false;
}

bool Module::touchMoved(CCPoint point, CCTouch* touch)
{
return false;
}

bool Module::touchEndedOrCancelled(CCPoint point, CCTouch* touch, bool cancelled)
{
if (mouseHeldDown)
{
enabled = !enabled;
save();
onChange();

if (enabled)
enableHooks();
else
disableHooks();

mouseHeldDown = false;
}

return false;
}


void Module::drawModule(CCPoint pointTopLeft)
{
PCDrawUtils::drawRect(pointTopLeft, Client::tileSize, ccc4(0, 0, 255, 255));
}


void Module::onOptionsAndroid(CCObject* sender)
{
Expand Down
27 changes: 12 additions & 15 deletions src/Client/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@

#include <Geode/ui/TextInput.hpp>

#define public_cast(value, member) [](auto* v) { \
class FriendClass__; \
using T = std::remove_pointer<decltype(v)>::type; \
class FriendeeClass__: public T { \
protected: \
friend FriendClass__; \
}; \
class FriendClass__ { \
public: \
auto& get(FriendeeClass__* v) { return v->member; } \
} c; \
return c.get(reinterpret_cast<FriendeeClass__*>(v)); \
}(value)


using namespace geode::prelude;

class ModuleChangeDelegate
Expand Down Expand Up @@ -61,6 +46,8 @@ class Module
bool def;
float value = 1.0f;

bool mouseHeldDown = false;

ModuleChangeDelegate* delegate = nullptr;

void addHookRaw(Result<Hook*> hook);
Expand Down Expand Up @@ -101,6 +88,16 @@ class Module
this->load();
}

/// @brief
/// @param point the position of the touch relative to where the module should be drawn
/// @param touch touch
/// @return should stop input passing to gd
bool touchBegan(CCPoint point, CCTouch* touch);
bool touchMoved(CCPoint point, CCTouch* touch);
bool touchEndedOrCancelled(CCPoint point, CCTouch* touch, bool cancelled);

void drawModule(CCPoint pointTopLeft);

virtual bool Draw(ImVec2 tileSize)
{
ImVec2 pos = ImGui::GetCursorPos();
Expand Down
35 changes: 33 additions & 2 deletions src/Client/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ void Window::drawWindow()

auto pos = windowPos + offsetForTime(Client::instance->animStatus);

PCDrawUtils::drawRect(pos, Client::tileSize, ccc4(255, 0, 0, 100));
PCDrawUtils::drawRect(pos, Client::tileSize, ccc4(255, 0, 0, 255));

int i = 0;

for (auto module : modules)
{
PCDrawUtils::drawRect(pos + ccp(0, Client::tileSize.y * (i + 1)), Client::tileSize, ccc4(0, 255 - (5 * i), 0, 100));
auto point = pos + ccp(0, Client::tileSize.y * (i + 1));

module->drawModule(point);

i++;
}
Expand All @@ -35,6 +37,7 @@ bool Window::touchBegan(CCPoint point, CCTouch* touch)
{
auto pos = windowPos + offsetForTime(Client::instance->animStatus);
auto rect = CCRectMake(pos.x, pos.y, Client::tileSize.x, Client::tileSize.y);
auto wndRect = CCRectMake(pos.x, pos.y, Client::tileSize.x, Client::tileSize.y * (modules.size() + 1));

if (rect.containsPoint(PCDrawUtils::getMousePosition()))
{
Expand All @@ -43,12 +46,27 @@ bool Window::touchBegan(CCPoint point, CCTouch* touch)

return true;
}
else
{
int i = 0;

for (auto mod : modules)
{
if (mod->touchBegan((pos - point) + ccp(0, Client::tileSize.y * i), touch))
return true;

i++;
}
}

return false;
}

bool Window::touchMoved(CCPoint point, CCTouch* touch)
{
auto pos = windowPos + offsetForTime(Client::instance->animStatus);
auto wndRect = CCRectMake(pos.x, pos.y, Client::tileSize.x, Client::tileSize.y * (modules.size() + 1));

if (dragging)
{
windowPos = PCDrawUtils::getMousePosition() + offset;
Expand All @@ -58,6 +76,19 @@ bool Window::touchMoved(CCPoint point, CCTouch* touch)
return true;
}

if (true)
{
int i = 0;

for (auto mod : modules)
{
if (mod->touchMoved((pos - point) + ccp(0, Client::tileSize.y * i), touch))
return true;

i++;
}
}

return false;
}

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

using namespace geode::prelude;

class $modify (UILayer)
{
bool init(GJBaseGameLayer* p0)
{
if (!UILayer::init(p0))
return false;

if (auto menu = getChildOfType<CCMenu>(this, 0); auto btn = getChildOfType<CCMenuItemSpriteExtra>(menu, 0))
{
btn->getNormalImage()->setVisible(false);
}

return true;
}

QOLMOD_MOD_HOOK("hide-pause-button", "UILayer::init")
};
2 changes: 2 additions & 0 deletions src/Hacks/TransitionTimeCustomiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ using namespace geode::prelude;

CCScene* getSceneForSel(int i, float f, CCScene* s)
{
AppDelegate::get()->willSwitchToScene(s);

switch (i)
{
default:
Expand Down
20 changes: 10 additions & 10 deletions src/UI/PCGuiNode.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#//include "PCGuiNode.hpp"
//#include "PCGuiNode.hpp"
//
//PCGuiNode* PCGuiNode::create()
//{
Expand Down Expand Up @@ -156,12 +156,12 @@
// return CCTouchDispatcher::touches(touches, event, type);
// }
//};
//
///*
//CCTOUCHBEGAN = 0,
//CCTOUCHMOVED = 1,
//CCTOUCHENDED = 2,
//CCTOUCHCANCELLED = 3,
//
//ccTouchMax = 4,
//*/

/*
CCTOUCHBEGAN = 0,
CCTOUCHMOVED = 1,
CCTOUCHENDED = 2,
CCTOUCHCANCELLED = 3,
ccTouchMax = 4,
*/
9 changes: 9 additions & 0 deletions src/Utils/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@
return c.get(reinterpret_cast<FriendeeClass__*>(v)); \
}(value)

#define QOLMOD_MOD_HOOK(_modid, _hookname) \
static void onModify(auto& self) { \
auto hook = self.getHook(_hookname); \
Loader::get()->queueInMainThread([hook] { \
auto modu = Client::GetModule(_modid); \
modu->addHookRaw(hook); \
}); \
}

float roundUpToMultipleOf2(float num);

0 comments on commit 6b27d66

Please sign in to comment.