-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5cab1aa
commit 3627655
Showing
15 changed files
with
369 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.