Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 104 additions & 8 deletions loader/include/Geode/modify/Modify.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,18 @@ namespace geode::modifier {

/// @brief Set the priority of a hook to be after another hook in different mods
/// @param name The name of the hook to set the priority of
/// @param after The mod to set the priority after
/// @param mod The mod to set the priority after
/// @returns Ok if the hook was found and the priority was set, Err if the hook was not found
Result<> setHookPriorityAfter(std::string_view name, Mod* mod) {
GEODE_UNWRAP_INTO(auto hook, this->getHook(name));
this->setHookPriorityAfter(hook, mod);
return Ok();
}

/// @brief Set the priority of a hook to be after another hook in different mods
/// @param hook The hook to set the priority of
/// @param mod The mod to set the priority after
void setHookPriorityAfter(Hook* hook, Mod* mod) {
auto func = [=](ModStateEvent* event){
auto hooks = mod->getHooks();
for (auto modHook : hooks) {
Expand All @@ -265,7 +273,6 @@ namespace geode::modifier {
else {
new EventListener(func, ModStateFilter(mod, ModEventType::Loaded));
}
return Ok();
}

/// @brief Set the priority of a hook to be after another hook in different mods
Expand All @@ -278,12 +285,31 @@ namespace geode::modifier {
return this->setHookPriorityAfter(name, mod);
}

/// @brief Set the priority of a hook to be after another hook in different mods
/// @param hook The hook to set the priority of
/// @param after The mod id of the mod to set the priority after
/// @returns Ok if the mod was found and the priority was set, Err if the mod was not found
Result<> setHookPriorityAfter(Hook* hook, std::string_view after) {
auto mod = Loader::get()->getInstalledMod(std::string(after));
if (!mod) return Err("Mod not found");
this->setHookPriorityAfter(hook, mod);
return Ok();
}

/// @brief Set the priority of a hook to be before another hook in different mods
/// @param name The name of the hook to set the priority of
/// @param before The mod to set the priority before
/// @param mod The mod to set the priority before
/// @returns Ok if the hook was found and the priority was set, Err if the hook was not found
Result<> setHookPriorityBefore(std::string_view name, Mod* mod) {
GEODE_UNWRAP_INTO(auto hook, this->getHook(name));
this->setHookPriorityBefore(hook, mod);
return Ok();
}

/// @brief Set the priority of a hook to be before another hook in different mods
/// @param hook The hook to set the priority of
/// @param mod The mod to set the priority before
void setHookPriorityBefore(Hook* hook, Mod* mod) {
auto func = [=](ModStateEvent* event){
auto hooks = mod->getHooks();
for (auto modHook : hooks) {
Expand All @@ -301,7 +327,6 @@ namespace geode::modifier {
else {
new EventListener(func, ModStateFilter(mod, ModEventType::Loaded));
}
return Ok();
}

/// @brief Set the priority of a hook to be before another hook in different mods
Expand All @@ -314,6 +339,17 @@ namespace geode::modifier {
return this->setHookPriorityBefore(name, mod);
}

/// @brief Set the priority of a hook to be before another hook in different mods
/// @param hook The hook to set the priority of
/// @param before The mod id of the mod to set the priority before
/// @returns Ok if the mod was found and the priority was set, Err if the mod was not found
Result<> setHookPriorityBefore(Hook* hook, std::string_view before) {
auto mod = Loader::get()->getInstalledMod(std::string(before));
if (!mod) return Err("Mod not found");
this->setHookPriorityBefore(hook, mod);
return Ok();
}

/// @brief Set the priority of a hook to be after another hook in different mods
/// @param name The name of the hook to set the priority of
/// @param after The mod id of the mod to set the priority after
Expand All @@ -324,12 +360,27 @@ namespace geode::modifier {

/// @brief Set the priority of a hook to be after another hook in different mods
/// @param name The name of the hook to set the priority of
/// @param before The mod to set the priority after
/// @param mod The mod to set the priority after
/// @returns Ok if the hook was found and the priority was set, Err if the hook was not found
Result<> setHookPriorityAfterPre(std::string_view name, Mod* mod) {
return this->setHookPriorityAfter(name, mod);
}

/// @brief Set the priority of a hook to be after another hook in different mods
/// @param hook The hook to set the priority of
/// @param after The mod id of the mod to set the priority after
/// @returns Ok if the mod was found and the priority was set, Err if the mod was not found
Result<> setHookPriorityAfterPre(Hook* hook, std::string_view after) {
return this->setHookPriorityAfter(hook, after);
}

/// @brief Set the priority of a hook to be after another hook in different mods
/// @param hook The hook to set the priority of
/// @param mod The mod to set the priority after
void setHookPriorityAfterPre(Hook* hook, Mod* mod) {
this->setHookPriorityAfter(hook, mod);
}

/// @brief Set the priority of a hook to be before another hook in different mods
/// @param name The name of the hook to set the priority of
/// @param before The mod id of the mod to set the priority before
Expand All @@ -340,12 +391,27 @@ namespace geode::modifier {

/// @brief Set the priority of a hook to be before another hook in different mods
/// @param name The name of the hook to set the priority of
/// @param before The mod to set the priority before
/// @param mod The mod to set the priority before
/// @returns Ok if the hook was found and the priority was set, Err if the hook was not found
Result<> setHookPriorityBeforePre(std::string_view name, Mod* mod) {
return this->setHookPriorityBefore(name, mod);
}

/// @brief Set the priority of a hook to be before another hook in different mods
/// @param hook The hook to set the priority of
/// @param before The mod id of the mod to set the priority before
/// @returns Ok if the mod was found and the priority was set, Err if the mod was not found
Result<> setHookPriorityBeforePre(Hook* hook, std::string_view before) {
return this->setHookPriorityBefore(hook, before);
}

/// @brief Set the priority of a hook to be before another hook in different mods
/// @param hook The hook to set the priority of
/// @param mod The mod to set the priority before
void setHookPriorityBeforePre(Hook* hook, Mod* mod) {
this->setHookPriorityBefore(hook, mod);
}

/// @brief Set the priority of a hook to be after another hook in different mods
/// @param name The name of the hook to set the priority of
/// @param after The mod id of the mod to set the priority after
Expand All @@ -356,12 +422,27 @@ namespace geode::modifier {

/// @brief Set the priority of a hook to be after another hook in different mods
/// @param name The name of the hook to set the priority of
/// @param before The mod to set the priority after
/// @param mod The mod to set the priority after
/// @returns Ok if the hook was found and the priority was set, Err if the hook was not found
Result<> setHookPriorityAfterPost(std::string_view name, Mod* mod) {
return this->setHookPriorityBefore(name, mod);
}

/// @brief Set the priority of a hook to be after another hook in different mods
/// @param hook The hook to set the priority of
/// @param after The mod id of the mod to set the priority after
/// @returns Ok if the mod was found and the priority was set, Err if the mod was not found
Result<> setHookPriorityAfterPost(Hook* hook, std::string_view after) {
return this->setHookPriorityBefore(hook, after);
}

/// @brief Set the priority of a hook to be after another hook in different mods
/// @param hook The hook to set the priority of
/// @param mod The mod to set the priority after
void setHookPriorityAfterPost(Hook* hook, Mod* mod) {
this->setHookPriorityBefore(hook, mod);
}

/// @brief Set the priority of a hook to be before another hook in different mods
/// @param name The name of the hook to set the priority of
/// @param before The mod id of the mod to set the priority before
Expand All @@ -372,12 +453,27 @@ namespace geode::modifier {

/// @brief Set the priority of a hook to be before another hook in different mods
/// @param name The name of the hook to set the priority of
/// @param before The mod to set the priority before
/// @param mod The mod to set the priority before
/// @returns Ok if the hook was found and the priority was set, Err if the hook was not found
Result<> setHookPriorityBeforePost(std::string_view name, Mod* mod) {
return this->setHookPriorityAfter(name, mod);
}

/// @brief Set the priority of a hook to be before another hook in different mods
/// @param hook The hook to set the priority of
/// @param before The mod id of the mod to set the priority before
/// @returns Ok if the mod was found and the priority was set, Err if the mod was not found
Result<> setHookPriorityBeforePost(Hook* hook, std::string_view before) {
return this->setHookPriorityAfter(hook, before);
}

/// @brief Set the priority of a hook to be before another hook in different mods
/// @param hook The hook to set the priority of
/// @param mod The mod to set the priority before
void setHookPriorityBeforePost(Hook* hook, Mod* mod) {
this->setHookPriorityAfter(hook, mod);
}

// unordered_map<handles> idea
ModifyBase() {
struct EboCheck : ModifyDerived::Base {
Expand Down
Loading