Skip to content

Commit

Permalink
asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Nov 27, 2024
1 parent 5cab1aa commit 3627655
Show file tree
Hide file tree
Showing 15 changed files with 369 additions and 38 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
project(CheatClient VERSION 1.0.0)

file(GLOB SOURCES
src/*.cpp
include/*.cpp
src/*.cpp
src/*/*.cpp
src/*/*/*.cpp
)
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.7.5

- Added API for mod developers to add tabs to the QOLMod UI

# 1.7.5-beta.6

- **Added Labels back on Android**
Expand Down
17 changes: 0 additions & 17 deletions include/Events.hpp

This file was deleted.

120 changes: 120 additions & 0 deletions include/ModuleExt.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#pragma once

#include <Geode/Geode.hpp>

using namespace geode::prelude;

namespace QOLModExt
{
enum class ModuleExtType
{
Boolean,
};

class ModuleExt
{
private:
std::string name;
std::string id;
std::string description;

bool canBeToggled = true;
std::string notTogglableWarning;

bool enabledByDefault;
bool enabled;

std::function<void(bool)> onToggle;

ModuleExtType type = ModuleExtType::Boolean;

public:
ModuleExt(std::string id)
{
this->id = id;
name = id;
description = "This is the help text";
}

void setName(std::string name)
{
this->name = name;
}

std::string getName()
{
return name;
}

std::string getID()
{
return id;
}

void setDescription(std::string description)
{
this->description = description;
}

std::string getDescription()
{
return description;
}

void setEnabledByDefault(bool enabled)
{
this->enabledByDefault = enabled;
}

bool getEnabledByDefault()
{
return enabledByDefault;
}

void setCanBeToggled(bool can, std::string message)
{
this->canBeToggled = can;
this->notTogglableWarning = message;
}

bool getCanBeToggled()
{
return canBeToggled;
}

std::string getCantBeToggledWarning()
{
return notTogglableWarning;
}

void setOnToggle(std::function<void(bool)> onToggle)
{
this->onToggle = onToggle;
}

std::function<void(bool)> getOnToggle()
{
return onToggle;
}

void setType(ModuleExtType type)
{
this->type = type;
}

ModuleExtType getType()
{
return type;
}

void setEnabled(bool enabled)
{
this->enabled = enabled;
}

bool getEnabled()
{
return enabled;
}
};
};
64 changes: 64 additions & 0 deletions include/QOLModExt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "QOLModExt.hpp"
#include "../src/Client/Client.h"

using namespace QOLModExt;

Module* moduleFromModuleExt(ModuleExt* modExt)
{
Module* mod;

switch (modExt->getType())
{
case ModuleExtType::Boolean:
mod = new Module(modExt->getName(), modExt->getID(), modExt->getDescription(), modExt->getEnabledByDefault());
break;
}

mod->onToggle = modExt->getOnToggle();

if (modExt->getCanBeToggled())
{
mod->setIncompatible(modExt->getCantBeToggledWarning());
}

if (modExt->getEnabled())
mod->enabled = true;

return mod;
}

Window* windowFromWindowExt(WindowExt* wndExt)
{
auto wnd = new Window();
wnd->id = wndExt->getID();
wnd->priority = wndExt->getPriority();
wnd->name = wndExt->getName();

for (auto mod : wndExt->getModules())
{
auto m = moduleFromModuleExt(mod);

wnd->modules.push_back(m);
}

return wnd;
}

$execute
{
new EventListener<EventFilter<PushWindowEvent>>(+[](PushWindowEvent* ev)
{
auto wnd = windowFromWindowExt(ev->window);

Client::get()->windows.push_back(wnd);

for (auto mod : ev->window->getModules())
{
delete mod;
}

delete ev->window;

return ListenerResult::Propagate;
});
};
49 changes: 49 additions & 0 deletions include/QOLModExt.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once
#ifndef QOLMODEXT_HPP
#define QOLMODEXT_HPP

#include <Geode/Geode.hpp>
#include "WindowExt.hpp"

using namespace geode::prelude;

namespace QOLModExt
{
class PushWindowEvent : public Event
{
public:
WindowExt* window;

PushWindowEvent(WindowExt* window)
{
this->window = window;
}
};

/// @brief Creates a window and returns it
/// @param id An id for the window, this is not shown to the user and is currently not used internally. This may change, please do not change the ID
/// @return WindowExt*
inline WindowExt* createWindow(std::string id)
{
auto window = new WindowExt(id);

return window;
}

inline ModuleExt* createModule(std::string id)
{
auto mod = new ModuleExt(id);

return mod;
}

/// @brief Adds a window and its modules to the UI. All modules and windows will be **deleted** after.
/// @param window
inline void pushWindow(WindowExt* window)
{
auto e = PushWindowEvent(window);
e.post();
}
};

#endif
68 changes: 68 additions & 0 deletions include/WindowExt.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#pragma once

#include <Geode/Geode.hpp>
#include "ModuleExt.hpp"

using namespace geode::prelude;

namespace QOLModExt
{
class WindowExt
{
private:
std::string name;
std::string id;
int priority;
std::vector<ModuleExt*> modules;
std::function<void(CCMenu*, ScrollLayer*)> createPostHook;

public:
// Please don't use this
WindowExt(std::string id)
{
this->id = id;
this->name = id;
}

std::string getID()
{
return id;
}

void setName(std::string name)
{
this->name = name;
}

std::string getName()
{
return name;
}

void setPriority(int priority)
{
this->priority = priority;
}

int getPriority()
{
return priority;
}

void addModule(ModuleExt* module)
{
modules.push_back(module);
}

std::vector<ModuleExt*> getModules()
{
return modules;
}

// Runs after the menu is created, for adding your own nodes
void setPostCreateHook(std::function<void(CCMenu*, ScrollLayer*)> hook)
{
this->createPostHook = hook;
}
};
};
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "4.0.1",
"version": "v1.7.5-beta.6",
"version": "v1.7.5",
"gd": {
"win": "2.2074",
"android": "2.2074",
Expand Down
17 changes: 9 additions & 8 deletions src/Client/AndroidBall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,17 @@ void QOLModTouchDispatcher::touches(CCSet* touches, CCEvent* event, unsigned int
{
if (auto ball = AndroidBall::get())
{
auto t = as<CCTouch*>(touches->anyObject());
if (auto t = as<CCTouch*>(touches->anyObject()))
{
if (type == ccTouchType::CCTOUCHBEGAN)
sendToGame = !ball->_ccTouchBegan(t, event);

if (type == ccTouchType::CCTOUCHBEGAN)
sendToGame = !ball->_ccTouchBegan(t, event);
if (type == ccTouchType::CCTOUCHMOVED)
sendToGame = !ball->_ccTouchMoved(t, event);

if (type == ccTouchType::CCTOUCHMOVED)
sendToGame = !ball->_ccTouchMoved(t, event);

if (type == ccTouchType::CCTOUCHENDED)
sendToGame = !ball->_ccTouchEnded(t, event);
if (type == ccTouchType::CCTOUCHENDED)
sendToGame = !ball->_ccTouchEnded(t, event);
}
}
}

Expand Down
Loading

0 comments on commit 3627655

Please sign in to comment.