From bed622243b82d963bf9d7f67d0e2e8bbf8ca49bc Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Mon, 4 Nov 2024 20:42:09 +0300 Subject: [PATCH] remove minifunction --- loader/include/Geode/Utils.hpp | 1 - .../include/Geode/cocos/base_nodes/CCNode.h | 6 +- loader/include/Geode/loader/Dispatch.hpp | 2 +- loader/include/Geode/loader/Event.hpp | 14 +- loader/include/Geode/loader/IPC.hpp | 2 +- loader/include/Geode/loader/Loader.hpp | 3 +- loader/include/Geode/loader/ModEvent.hpp | 2 +- loader/include/Geode/loader/SettingV3.hpp | 2 +- loader/include/Geode/modify/Field.hpp | 7 +- loader/include/Geode/ui/EnterLayerEvent.hpp | 4 +- loader/include/Geode/ui/MDPopup.hpp | 8 +- loader/include/Geode/ui/Popup.hpp | 11 +- loader/include/Geode/ui/SelectList.hpp | 6 +- loader/include/Geode/ui/TextRenderer.hpp | 2 +- loader/include/Geode/utils/ColorProvider.hpp | 2 +- loader/include/Geode/utils/JsonValidation.hpp | 3 +- loader/include/Geode/utils/MiniFunction.hpp | 141 ------------------ loader/include/Geode/utils/Task.hpp | 13 +- loader/include/Geode/utils/cocos.hpp | 63 ++++---- loader/include/Geode/utils/file.hpp | 6 +- loader/include/Geode/utils/map.hpp | 8 +- loader/include/Geode/utils/permission.hpp | 3 +- loader/src/hooks/GeodeNodeMetadata.cpp | 2 +- loader/src/internal/FileWatcher.hpp | 5 +- loader/src/internal/FixModIssues.cpp | 2 +- loader/src/loader/IPC.cpp | 2 +- loader/src/loader/LoaderImpl.hpp | 3 +- loader/src/loader/ModEvent.cpp | 2 +- loader/src/loader/SettingV3.cpp | 2 +- loader/src/loader/updater.cpp | 8 +- loader/src/loader/updater.hpp | 9 +- loader/src/platform/android/util.cpp | 11 +- loader/src/platform/ios/util.mm | 2 +- loader/src/platform/mac/util.mm | 2 +- loader/src/platform/windows/util.cpp | 2 +- loader/src/server/DownloadManager.cpp | 2 +- loader/src/server/DownloadManager.hpp | 2 +- loader/src/ui/mods/UpdateModListState.cpp | 2 +- loader/src/ui/mods/UpdateModListState.hpp | 2 +- loader/src/ui/mods/sources/ModListSource.cpp | 2 +- loader/src/ui/mods/sources/ModListSource.hpp | 2 +- loader/src/ui/nodes/ColorPickPopup.cpp | 2 +- loader/src/ui/nodes/EnterLayerEvent.cpp | 2 +- loader/src/ui/nodes/MDPopup.cpp | 4 +- loader/src/ui/nodes/Popup.cpp | 12 +- loader/src/utils/ColorProvider.cpp | 2 +- loader/src/utils/file.cpp | 10 +- loader/test/dependency/main.cpp | 2 +- loader/test/dependency/main.hpp | 2 +- 49 files changed, 126 insertions(+), 283 deletions(-) delete mode 100644 loader/include/Geode/utils/MiniFunction.hpp diff --git a/loader/include/Geode/Utils.hpp b/loader/include/Geode/Utils.hpp index b21d5a07..5554a91f 100644 --- a/loader/include/Geode/Utils.hpp +++ b/loader/include/Geode/Utils.hpp @@ -12,5 +12,4 @@ #include "utils/permission.hpp" #include "utils/general.hpp" #include "utils/timer.hpp" -#include "utils/MiniFunction.hpp" #include "utils/ObjcHook.hpp" diff --git a/loader/include/Geode/cocos/base_nodes/CCNode.h b/loader/include/Geode/cocos/base_nodes/CCNode.h index ecce00e2..1bbf681c 100644 --- a/loader/include/Geode/cocos/base_nodes/CCNode.h +++ b/loader/include/Geode/cocos/base_nodes/CCNode.h @@ -1095,7 +1095,7 @@ public: template geode::EventListenerProtocol* addEventListener( std::string const& id, - geode::utils::MiniFunction callback, + std::function callback, Args&&... args ) { auto listener = new geode::EventListener( @@ -1106,7 +1106,7 @@ public: } template geode::EventListenerProtocol* addEventListener( - geode::utils::MiniFunction callback, + std::function callback, Args&&... args ) { return this->addEventListener( @@ -1916,7 +1916,7 @@ namespace geode { std::string m_targetID; public: - ListenerResult handle(utils::MiniFunction fn, UserObjectSetEvent* event); + ListenerResult handle(std::function fn, UserObjectSetEvent* event); AttributeSetFilter(std::string const& id); }; diff --git a/loader/include/Geode/loader/Dispatch.hpp b/loader/include/Geode/loader/Dispatch.hpp index 1ce7bb9c..629ede39 100644 --- a/loader/include/Geode/loader/Dispatch.hpp +++ b/loader/include/Geode/loader/Dispatch.hpp @@ -53,7 +53,7 @@ namespace geode { return dispatchPools()[m_id]; } - ListenerResult handle(utils::MiniFunction fn, Ev* event) { + ListenerResult handle(std::function fn, Ev* event) { if (event->getID() == m_id) { return std::apply(fn, event->getArgs()); } diff --git a/loader/include/Geode/loader/Event.hpp b/loader/include/Geode/loader/Event.hpp index 55a12e8a..d7420a03 100644 --- a/loader/include/Geode/loader/Event.hpp +++ b/loader/include/Geode/loader/Event.hpp @@ -1,7 +1,6 @@ #pragma once #include "../utils/casts.hpp" -#include "../utils/MiniFunction.hpp" #include #include @@ -103,7 +102,7 @@ namespace geode { using Callback = ListenerResult(T*); using Event = T; - ListenerResult handle(utils::MiniFunction fn, T* e) { + ListenerResult handle(std::function fn, T* e) { return fn(e); } @@ -156,7 +155,7 @@ namespace geode { this->enable(); } - EventListener(utils::MiniFunction fn, T filter = T()) + EventListener(std::function fn, T filter = T()) : m_callback(fn), m_filter(filter) { m_filter.setListener(this); @@ -193,10 +192,7 @@ namespace geode { this->enable(); } - void bind(utils::MiniFunction const& fn) { - m_callback = fn; - } - void bind(utils::MiniFunction&& fn) { + void bind(std::function fn) { m_callback = fn; } @@ -218,12 +214,12 @@ namespace geode { return m_filter; } - utils::MiniFunction& getCallback() { + std::function& getCallback() { return m_callback; } protected: - utils::MiniFunction m_callback = nullptr; + std::function m_callback = nullptr; T m_filter; }; diff --git a/loader/include/Geode/loader/IPC.hpp b/loader/include/Geode/loader/IPC.hpp index 6ffd8631..73e32d1e 100644 --- a/loader/include/Geode/loader/IPC.hpp +++ b/loader/include/Geode/loader/IPC.hpp @@ -57,7 +57,7 @@ namespace geode::ipc { std::string m_messageID; public: - ListenerResult handle(utils::MiniFunction fn, IPCEvent* event); + ListenerResult handle(std::function fn, IPCEvent* event); IPCFilter( std::string const& modID, std::string const& messageID diff --git a/loader/include/Geode/loader/Loader.hpp b/loader/include/Geode/loader/Loader.hpp index 0c577de4..061d9edc 100644 --- a/loader/include/Geode/loader/Loader.hpp +++ b/loader/include/Geode/loader/Loader.hpp @@ -2,7 +2,6 @@ #include #include "../utils/Result.hpp" -#include "../utils/MiniFunction.hpp" #include "Log.hpp" #include "ModEvent.hpp" #include "ModMetadata.hpp" @@ -15,7 +14,7 @@ #include namespace geode { - using ScheduledFunction = utils::MiniFunction; + using ScheduledFunction = std::function; struct InvalidGeodeFile { std::filesystem::path path; diff --git a/loader/include/Geode/loader/ModEvent.hpp b/loader/include/Geode/loader/ModEvent.hpp index 83699e50..b9801c2c 100644 --- a/loader/include/Geode/loader/ModEvent.hpp +++ b/loader/include/Geode/loader/ModEvent.hpp @@ -43,7 +43,7 @@ namespace geode { Mod* m_mod; public: - ListenerResult handle(utils::MiniFunction fn, ModStateEvent* event); + ListenerResult handle(std::function fn, ModStateEvent* event); /** * Create a mod state listener diff --git a/loader/include/Geode/loader/SettingV3.hpp b/loader/include/Geode/loader/SettingV3.hpp index cb91201c..bea8bda8 100644 --- a/loader/include/Geode/loader/SettingV3.hpp +++ b/loader/include/Geode/loader/SettingV3.hpp @@ -658,7 +658,7 @@ namespace geode { public: using Callback = void(std::shared_ptr); - ListenerResult handle(utils::MiniFunction fn, SettingChangedEventV3* event); + ListenerResult handle(std::function fn, SettingChangedEventV3* event); /** * Listen to changes on a setting, or all settings * @param modID Mod whose settings to listen to diff --git a/loader/include/Geode/modify/Field.hpp b/loader/include/Geode/modify/Field.hpp index 3769dc51..95e794a6 100644 --- a/loader/include/Geode/modify/Field.hpp +++ b/loader/include/Geode/modify/Field.hpp @@ -1,6 +1,5 @@ #pragma once -#include "../utils/MiniFunction.hpp" #include "Traits.hpp" #include @@ -20,7 +19,7 @@ namespace geode::modifier { class FieldContainer { private: std::vector m_containedFields; - std::vector> m_destructorFunctions; + std::vector> m_destructorFunctions; public: ~FieldContainer() { @@ -40,9 +39,9 @@ namespace geode::modifier { return m_containedFields.at(index); } - void* setField(size_t index, size_t size, utils::MiniFunction destructor) { + void* setField(size_t index, size_t size, std::function destructor) { m_containedFields.at(index) = operator new(size); - m_destructorFunctions.at(index) = destructor; + m_destructorFunctions.at(index) = std::move(destructor); return m_containedFields.at(index); } diff --git a/loader/include/Geode/ui/EnterLayerEvent.hpp b/loader/include/Geode/ui/EnterLayerEvent.hpp index 31252892..138cfe98 100644 --- a/loader/include/Geode/ui/EnterLayerEvent.hpp +++ b/loader/include/Geode/ui/EnterLayerEvent.hpp @@ -30,7 +30,7 @@ namespace geode { std::optional m_targetID; public: - ListenerResult handle(utils::MiniFunction fn, AEnterLayerEvent* event); + ListenerResult handle(std::function fn, AEnterLayerEvent* event); AEnterLayerFilter( std::optional const& id @@ -63,7 +63,7 @@ namespace geode { std::optional m_targetID; public: - ListenerResult handle(utils::MiniFunction fn, EnterLayerEvent* event) { + ListenerResult handle(std::function fn, EnterLayerEvent* event) { if (m_targetID == event->getID()) { fn(static_cast(event)); } diff --git a/loader/include/Geode/ui/MDPopup.hpp b/loader/include/Geode/ui/MDPopup.hpp index 4ed45176..63b3681c 100644 --- a/loader/include/Geode/ui/MDPopup.hpp +++ b/loader/include/Geode/ui/MDPopup.hpp @@ -11,13 +11,13 @@ namespace geode { class GEODE_DLL MDPopup : public Popup< std::string const&, std::string const&, char const*, char const*, - utils::MiniFunction> { + std::function> { protected: - utils::MiniFunction m_onClick = nullptr; + std::function m_onClick = nullptr; bool setup( std::string const& title, std::string const& info, char const* btn1, char const* btn2, - utils::MiniFunction onClick + std::function onClick ) override; void onBtn(CCObject*); @@ -27,7 +27,7 @@ namespace geode { public: static MDPopup* create( std::string const& title, std::string const& content, char const* btn1, - char const* btn2 = nullptr, utils::MiniFunction onClick = nullptr + char const* btn2 = nullptr, std::function onClick = nullptr ); }; } diff --git a/loader/include/Geode/ui/Popup.hpp b/loader/include/Geode/ui/Popup.hpp index d7b3809d..7f0e4ce8 100644 --- a/loader/include/Geode/ui/Popup.hpp +++ b/loader/include/Geode/ui/Popup.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -52,7 +51,7 @@ namespace geode { } public: - ListenerResult handle(utils::MiniFunction fn, CloseEvent* event) { + ListenerResult handle(std::function fn, CloseEvent* event) { if (event->getPopup() == m_impl->popup) { fn(event); } @@ -214,21 +213,21 @@ namespace geode { GEODE_DLL FLAlertLayer* createQuickPopup( char const* title, std::string const& content, char const* btn1, char const* btn2, - utils::MiniFunction selected, bool doShow = true + std::function selected, bool doShow = true ); GEODE_DLL FLAlertLayer* createQuickPopup( char const* title, std::string const& content, char const* btn1, char const* btn2, - float width, utils::MiniFunction selected, bool doShow = true + float width, std::function selected, bool doShow = true ); GEODE_DLL FLAlertLayer* createQuickPopup( char const* title, std::string const& content, char const* btn1, char const* btn2, - utils::MiniFunction selected, bool doShow, bool cancelledByEscape + std::function selected, bool doShow, bool cancelledByEscape ); GEODE_DLL FLAlertLayer* createQuickPopup( char const* title, std::string const& content, char const* btn1, char const* btn2, - float width, utils::MiniFunction selected, bool doShow, bool cancelledByEscape + float width, std::function selected, bool doShow, bool cancelledByEscape ); } diff --git a/loader/include/Geode/ui/SelectList.hpp b/loader/include/Geode/ui/SelectList.hpp index 33619026..df224875 100644 --- a/loader/include/Geode/ui/SelectList.hpp +++ b/loader/include/Geode/ui/SelectList.hpp @@ -14,13 +14,13 @@ namespace geode { protected: std::vector m_list; size_t m_index = 0; - utils::MiniFunction m_onChange; + std::function m_onChange; cocos2d::CCLabelBMFont* m_label; CCMenuItemSpriteExtra* m_prevBtn; CCMenuItemSpriteExtra* m_nextBtn; bool init( - float width, std::vector const& list, utils::MiniFunction onChange + float width, std::vector const& list, std::function onChange ) { if (!cocos2d::CCMenu::init()) return false; @@ -94,7 +94,7 @@ namespace geode { public: static SelectList* create( - float width, std::vector const& list, utils::MiniFunction onChange + float width, std::vector const& list, std::function onChange ) { auto ret = new SelectList(); if (ret->init(width, list, onChange)) { diff --git a/loader/include/Geode/ui/TextRenderer.hpp b/loader/include/Geode/ui/TextRenderer.hpp index d749d1b5..b0719769 100644 --- a/loader/include/Geode/ui/TextRenderer.hpp +++ b/loader/include/Geode/ui/TextRenderer.hpp @@ -122,7 +122,7 @@ namespace geode { * to distinguish between bold, italic and * regular text. */ - using Font = utils::MiniFunction; + using Font = std::function; protected: cocos2d::CCPoint m_origin = cocos2d::CCPointZero; diff --git a/loader/include/Geode/utils/ColorProvider.hpp b/loader/include/Geode/utils/ColorProvider.hpp index 547cb3ee..804572f0 100644 --- a/loader/include/Geode/utils/ColorProvider.hpp +++ b/loader/include/Geode/utils/ColorProvider.hpp @@ -21,7 +21,7 @@ namespace geode { std::string m_id; public: - ListenerResult handle(utils::MiniFunction fn, ColorProvidedEvent* event); + ListenerResult handle(std::function fn, ColorProvidedEvent* event); ColorProvidedFilter(std::string const& id); }; diff --git a/loader/include/Geode/utils/JsonValidation.hpp b/loader/include/Geode/utils/JsonValidation.hpp index 461be50b..7dd18a46 100644 --- a/loader/include/Geode/utils/JsonValidation.hpp +++ b/loader/include/Geode/utils/JsonValidation.hpp @@ -4,7 +4,6 @@ #include "../loader/Log.hpp" #include #include -#include #include namespace geode { @@ -73,7 +72,7 @@ namespace geode { } template - using JsonValueValidator = utils::MiniFunction; + using JsonValueValidator = std::function; struct JsonMaybeObject; struct JsonMaybeValue; diff --git a/loader/include/Geode/utils/MiniFunction.hpp b/loader/include/Geode/utils/MiniFunction.hpp deleted file mode 100644 index b29d1735..00000000 --- a/loader/include/Geode/utils/MiniFunction.hpp +++ /dev/null @@ -1,141 +0,0 @@ -#pragma once - -#include -#include -#include -#include "terminate.hpp" - -namespace geode::utils { - - template - class MiniFunction; - - template - class MiniFunctionStateBase { - public: - virtual ~MiniFunctionStateBase() = default; - virtual Ret call(Args... args) const = 0; - virtual MiniFunctionStateBase* clone() const = 0; - }; - - template - class MiniFunctionState final : public MiniFunctionStateBase { - public: - Type m_func; - - explicit MiniFunctionState(Type func) : m_func(func) {} - - Ret call(Args... args) const override { - return const_cast(m_func)(std::forward(args)...); - } - - MiniFunctionStateBase* clone() const override { - return new MiniFunctionState(*this); - } - }; - - template - class MiniFunctionStatePointer final : public MiniFunctionStateBase { - public: - Type m_func; - - explicit MiniFunctionStatePointer(Type func) : m_func(func) {} - - Ret call(Args... args) const override { - return const_cast(*m_func)(std::forward(args)...); - } - - MiniFunctionStateBase* clone() const override { - return new MiniFunctionStatePointer(*this); - } - }; - - template - class MiniFunctionStateMemberPointer final : public MiniFunctionStateBase { - public: - Type m_func; - - explicit MiniFunctionStateMemberPointer(Type func) : m_func(func) {} - - Ret call(Class self, Args... args) const override { - return const_cast(self->*m_func)(std::forward(args)...); - } - - MiniFunctionStateBase* clone() const override { - return new MiniFunctionStateMemberPointer(*this); - } - }; - - template - concept MiniFunctionCallable = requires(Callable&& func, Args... args) { - { func(std::forward(args)...) } -> std::same_as; - }; - - template - class MiniFunction { - public: - using FunctionType = Ret(Args...); - using StateType = MiniFunctionStateBase; - - private: - StateType* m_state; - - public: - MiniFunction() : m_state(nullptr) {} - - MiniFunction(std::nullptr_t) : MiniFunction() {} - - MiniFunction(MiniFunction const& other) : - m_state(other.m_state ? other.m_state->clone() : nullptr) {} - - MiniFunction(MiniFunction&& other) : m_state(other.m_state) { - other.m_state = nullptr; - } - - ~MiniFunction() { - if (m_state) delete m_state; - } - - template - requires(MiniFunctionCallable && !std::is_same_v, MiniFunction>) - MiniFunction(Callable&& func) : - m_state(new MiniFunctionState, Ret, Args...>(std::forward(func))) {} - - template - requires(!MiniFunctionCallable && std::is_pointer_v && std::is_function_v>) - MiniFunction(FunctionPointer func) : - m_state(new MiniFunctionStatePointer(func)) {} - - template - requires(std::is_member_function_pointer_v) - MiniFunction(MemberFunctionPointer func) : - m_state(new MiniFunctionStateMemberPointer(func)) {} - - MiniFunction& operator=(MiniFunction const& other) { - if (m_state) delete m_state; - m_state = other.m_state ? other.m_state->clone() : nullptr; - return *this; - } - - MiniFunction& operator=(MiniFunction&& other) { - if (m_state) delete m_state; - m_state = other.m_state; - other.m_state = nullptr; - return *this; - } - - Ret operator()(Args... args) const { - if (!m_state) { - utils::terminate( - "Attempted to call a MiniFunction that was never assigned " - "any function, or one that has been moved" - ); - } - return m_state->call(std::forward(args)...); - } - - explicit operator bool() const { - return m_state; - } - }; -} diff --git a/loader/include/Geode/utils/Task.hpp b/loader/include/Geode/utils/Task.hpp index d6691257..1d69b155 100644 --- a/loader/include/Geode/utils/Task.hpp +++ b/loader/include/Geode/utils/Task.hpp @@ -1,7 +1,6 @@ #pragma once #include "general.hpp" -#include "MiniFunction.hpp" #include "../loader/Event.hpp" #include "../loader/Loader.hpp" #include @@ -249,11 +248,11 @@ namespace geode { using Value = T; using Progress = P; - using PostResult = utils::MiniFunction; - using PostProgress = utils::MiniFunction; - using HasBeenCancelled = utils::MiniFunction; - using Run = utils::MiniFunction; - using RunWithCallback = utils::MiniFunction; + using PostResult = std::function; + using PostProgress = std::function; + using HasBeenCancelled = std::function; + using Run = std::function; + using RunWithCallback = std::function; using Callback = void(Event*); @@ -752,7 +751,7 @@ namespace geode { this->listen(std::move(onResult), [](auto const&) {}, [] {}); } - ListenerResult handle(utils::MiniFunction fn, Event* e) { + ListenerResult handle(std::function fn, Event* e) { if (e->m_handle == m_handle && (!e->m_for || e->m_for == m_listener)) { fn(e); } diff --git a/loader/include/Geode/utils/cocos.hpp b/loader/include/Geode/utils/cocos.hpp index a25c2586..5eb5f557 100644 --- a/loader/include/Geode/utils/cocos.hpp +++ b/loader/include/Geode/utils/cocos.hpp @@ -10,7 +10,6 @@ #include "../loader/Event.hpp" #include #include -#include "MiniFunction.hpp" // support converting ccColor3B / ccColor4B to / from json @@ -658,7 +657,7 @@ namespace geode::cocos { */ GEODE_DLL cocos2d::CCScene* switchToScene(cocos2d::CCLayer* layer); - using CreateLayerFunc = utils::MiniFunction; + using CreateLayerFunc = std::function; /** * Reload textures, overwriting the scene to return to after the loading @@ -726,7 +725,7 @@ namespace geode::cocos { * there is none */ template - Type* findFirstChildRecursive(cocos2d::CCNode* node, utils::MiniFunction predicate) { + Type* findFirstChildRecursive(cocos2d::CCNode* node, std::function predicate) { if (cast::typeinfo_cast(node) && predicate(static_cast(node))) return static_cast(node); @@ -880,7 +879,7 @@ namespace geode::cocos { } template >> - static cocos2d::CCArray* vectorToCCArray(std::vector const& vec, utils::MiniFunction convFunc) { + static cocos2d::CCArray* vectorToCCArray(std::vector const& vec, std::function convFunc) { auto res = cocos2d::CCArray::createWithCapacity(vec.size()); for (auto const& item : vec) res->addObject(convFunc(item)); @@ -907,7 +906,7 @@ namespace geode::cocos { template < typename K, typename V, typename C, typename = std::enable_if_t || std::is_same_v>> - static cocos2d::CCDictionary* mapToCCDict(std::map const& map, utils::MiniFunction convFunc) { + static cocos2d::CCDictionary* mapToCCDict(std::map const& map, std::function convFunc) { auto res = cocos2d::CCDictionary::create(); for (auto const& [key, value] : map) res->setObject(value, convFunc(key)); @@ -1180,11 +1179,11 @@ namespace geode::cocos { template class LambdaCallback : public cocos2d::CCObject { public: - utils::MiniFunction m_callback; + std::function m_callback; - static LambdaCallback* create(utils::MiniFunction&& callback) { + static LambdaCallback* create(std::function callback) { auto ret = new (std::nothrow) LambdaCallback(); - if (ret->init(std::forward>(callback))) { + if (ret->init(std::move(callback))) { ret->autorelease(); return ret; } @@ -1192,8 +1191,8 @@ namespace geode::cocos { return nullptr; } - bool init(utils::MiniFunction&& callback) { - m_callback = std::forward>(callback); + bool init(std::function callback) { + m_callback = std::move(callback); return true; } @@ -1204,20 +1203,20 @@ namespace geode::cocos { public: static cocos2d::CCMenuItem* create( - utils::MiniFunction&& callback + std::function callback ) { auto item = cocos2d::CCMenuItem::create(); - assignCallback(item, std::forward>(callback)); + assignCallback(item, std::move(callback)); return item; } static cocos2d::CCMenuItemSprite* createSprite( cocos2d::CCNode* normalSprite, cocos2d::CCNode* selectedSprite, - utils::MiniFunction&& callback + std::function callback ) { auto item = cocos2d::CCMenuItemSprite::create(normalSprite, selectedSprite); - assignCallback(item, std::forward>(callback)); + assignCallback(item, std::move(callback)); return item; } @@ -1225,57 +1224,57 @@ namespace geode::cocos { cocos2d::CCNode* normalSprite, cocos2d::CCNode* selectedSprite, cocos2d::CCNode* disabledSprite, - utils::MiniFunction&& callback + std::function callback ) { auto item = cocos2d::CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite); - assignCallback(item, std::forward>(callback)); + assignCallback(item, std::move(callback)); return item; } static CCMenuItemSpriteExtra* createSpriteExtra( cocos2d::CCNode* normalSprite, - utils::MiniFunction&& callback + std::function callback ) { auto item = CCMenuItemSpriteExtra::create(normalSprite, nullptr, nullptr); - assignCallback(item, std::forward>(callback)); + assignCallback(item, std::move(callback)); return item; } static CCMenuItemSpriteExtra* createSpriteExtraWithFilename( std::string_view normalSpriteName, float scale, - utils::MiniFunction&& callback + std::function callback ) { auto sprite = cocos2d::CCSprite::create(normalSpriteName.data()); sprite->setScale(scale); - return createSpriteExtra(sprite, std::forward>(callback)); + return createSpriteExtra(sprite, std::move(callback)); } static CCMenuItemSpriteExtra* createSpriteExtraWithFrameName( std::string_view normalSpriteName, float scale, - utils::MiniFunction&& callback + std::function callback ) { auto sprite = cocos2d::CCSprite::createWithSpriteFrameName(normalSpriteName.data()); sprite->setScale(scale); - return createSpriteExtra(sprite, std::forward>(callback)); + return createSpriteExtra(sprite, std::move(callback)); } static CCMenuItemToggler* createToggler( cocos2d::CCNode* onSprite, cocos2d::CCNode* offSprite, - utils::MiniFunction&& callback + std::function callback ) { auto item = CCMenuItemToggler::create(offSprite, onSprite, nullptr, nullptr); - assignCallback(item, std::forward>(callback)); + assignCallback(item, std::move(callback)); return item; } static CCMenuItemToggler* createTogglerWithStandardSprites( float scale, - utils::MiniFunction&& callback + std::function callback ) { auto offSprite = cocos2d::CCSprite::createWithSpriteFrameName("GJ_checkOff_001.png"); auto onSprite = cocos2d::CCSprite::createWithSpriteFrameName("GJ_checkOn_001.png"); @@ -1283,14 +1282,14 @@ namespace geode::cocos { offSprite->setScale(scale); onSprite->setScale(scale); - return createToggler(onSprite, offSprite, std::forward>(callback)); + return createToggler(onSprite, offSprite, std::move(callback)); } static CCMenuItemToggler* createTogglerWithFilename( std::string_view onSpriteName, std::string_view offSpriteName, float scale, - utils::MiniFunction&& callback + std::function callback ) { auto offSprite = cocos2d::CCSprite::create(offSpriteName.data()); auto onSprite = cocos2d::CCSprite::create(onSpriteName.data()); @@ -1298,14 +1297,14 @@ namespace geode::cocos { offSprite->setScale(scale); onSprite->setScale(scale); - return createToggler(onSprite, offSprite, std::forward>(callback)); + return createToggler(onSprite, offSprite, std::move(callback)); } static CCMenuItemToggler* createTogglerWithFrameName( std::string_view onSpriteName, std::string_view offSpriteName, float scale, - utils::MiniFunction&& callback + std::function callback ) { auto offSprite = cocos2d::CCSprite::createWithSpriteFrameName(offSpriteName.data()); auto onSprite = cocos2d::CCSprite::createWithSpriteFrameName(onSpriteName.data()); @@ -1313,15 +1312,15 @@ namespace geode::cocos { offSprite->setScale(scale); onSprite->setScale(scale); - return createToggler(onSprite, offSprite, std::forward>(callback)); + return createToggler(onSprite, offSprite, std::move(callback)); } template static void assignCallback( cocos2d::CCMenuItem* item, - utils::MiniFunction&& callback + std::function callback ) { - auto lambda = LambdaCallback::create(std::forward>(callback)); + auto lambda = LambdaCallback::create(std::move(callback)); item->setTarget(lambda, menu_selector(LambdaCallback::execute)); item->setUserObject("lambda-callback", lambda); } diff --git a/loader/include/Geode/utils/file.hpp b/loader/include/Geode/utils/file.hpp index 620a71bc..427c6de4 100644 --- a/loader/include/Geode/utils/file.hpp +++ b/loader/include/Geode/utils/file.hpp @@ -162,7 +162,7 @@ namespace geode::utils::file { * @param callback Callback to call with the progress of the unzip operation */ void setProgressCallback( - utils::MiniFunction callback + std::function callback ); /** @@ -213,7 +213,7 @@ namespace geode::utils::file { ); static Result<> intoDir( - utils::MiniFunction progressCallback, + std::function progressCallback, Path const& from, Path const& to, bool deleteZipAfter = false @@ -281,7 +281,7 @@ namespace geode::utils::file { public: using Callback = void(FileWatchEvent*); - ListenerResult handle(utils::MiniFunction callback, FileWatchEvent* event); + ListenerResult handle(std::function callback, FileWatchEvent* event); FileWatchFilter(std::filesystem::path const& path); }; diff --git a/loader/include/Geode/utils/map.hpp b/loader/include/Geode/utils/map.hpp index 00868ef8..3806dd8a 100644 --- a/loader/include/Geode/utils/map.hpp +++ b/loader/include/Geode/utils/map.hpp @@ -20,7 +20,7 @@ namespace geode::utils::map { * false if not. */ template - bool contains(std::unordered_map const& map, utils::MiniFunction containFunc) { + bool contains(std::unordered_map const& map, std::function containFunc) { for (auto const& [_, r] : map) { if (containFunc(r)) return true; } @@ -39,7 +39,7 @@ namespace geode::utils::map { * a pointer. */ template - R select(std::unordered_map const& map, utils::MiniFunction selectFunc) { + R select(std::unordered_map const& map, std::function selectFunc) { for (auto const& [_, r] : map) { if (selectFunc(r)) return r; } @@ -59,7 +59,7 @@ namespace geode::utils::map { */ template std::vector selectAll( - std::unordered_map const& map, utils::MiniFunction selectFunc + std::unordered_map const& map, std::function selectFunc ) { std::vector res; for (auto const& [_, r] : map) { @@ -111,7 +111,7 @@ namespace geode::utils::map { template std::unordered_map remap( std::unordered_map const& map, - utils::MiniFunction(std::pair)> remapFunc + std::function(std::pair)> remapFunc ) { std::unordered_map res; for (auto const& [t, v] : map) { diff --git a/loader/include/Geode/utils/permission.hpp b/loader/include/Geode/utils/permission.hpp index c7c15ca3..dd0b83e3 100644 --- a/loader/include/Geode/utils/permission.hpp +++ b/loader/include/Geode/utils/permission.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include "MiniFunction.hpp" #include namespace geode::utils::permission { @@ -21,5 +20,5 @@ namespace geode::utils::permission { * @param permission The permission * @param callback The callback, passed value is 'true' if permission was granted and 'false' otherwise. */ - void GEODE_DLL requestPermission(Permission permission, utils::MiniFunction callback); + void GEODE_DLL requestPermission(Permission permission, std::function callback); } \ No newline at end of file diff --git a/loader/src/hooks/GeodeNodeMetadata.cpp b/loader/src/hooks/GeodeNodeMetadata.cpp index 37e22b8d..0d6ba416 100644 --- a/loader/src/hooks/GeodeNodeMetadata.cpp +++ b/loader/src/hooks/GeodeNodeMetadata.cpp @@ -335,7 +335,7 @@ void CCNode::updateLayout(bool updateChildOrder) { UserObjectSetEvent::UserObjectSetEvent(CCNode* node, std::string const& id, CCObject* value) : node(node), id(id), value(value) {} -ListenerResult AttributeSetFilter::handle(MiniFunction fn, UserObjectSetEvent* event) { +ListenerResult AttributeSetFilter::handle(std::function fn, UserObjectSetEvent* event) { if (event->id == m_targetID) { fn(event); } diff --git a/loader/src/internal/FileWatcher.hpp b/loader/src/internal/FileWatcher.hpp index 2c7fb128..30913786 100644 --- a/loader/src/internal/FileWatcher.hpp +++ b/loader/src/internal/FileWatcher.hpp @@ -2,15 +2,14 @@ #include //#include -#include #include #include #include class FileWatcher { public: - using FileWatchCallback = geode::utils::MiniFunction; - using ErrorCallback = geode::utils::MiniFunction; + using FileWatchCallback = std::function; + using ErrorCallback = std::function; protected: std::filesystem::path m_file; diff --git a/loader/src/internal/FixModIssues.cpp b/loader/src/internal/FixModIssues.cpp index ed68a4c9..e97bcd15 100644 --- a/loader/src/internal/FixModIssues.cpp +++ b/loader/src/internal/FixModIssues.cpp @@ -20,7 +20,7 @@ protected: std::string content; std::string optionA; std::string optionB; - MiniFunction after; + std::function after; }; EventListener m_download; diff --git a/loader/src/loader/IPC.cpp b/loader/src/loader/IPC.cpp index 6fbabcab..c2870fa3 100644 --- a/loader/src/loader/IPC.cpp +++ b/loader/src/loader/IPC.cpp @@ -19,7 +19,7 @@ ipc::IPCEvent::IPCEvent( ipc::IPCEvent::~IPCEvent() {} -ListenerResult ipc::IPCFilter::handle(utils::MiniFunction fn, IPCEvent* event) { +ListenerResult ipc::IPCFilter::handle(std::function fn, IPCEvent* event) { if (event->targetModID == m_modID && event->messageID == m_messageID) { event->replyData = fn(event); return ListenerResult::Stop; diff --git a/loader/src/loader/LoaderImpl.hpp b/loader/src/loader/LoaderImpl.hpp index 7f79d8e3..99016566 100644 --- a/loader/src/loader/LoaderImpl.hpp +++ b/loader/src/loader/LoaderImpl.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include "ModImpl.hpp" #include #include @@ -41,7 +40,7 @@ namespace geode { LoadingState m_loadingState = LoadingState::None; - std::vector> m_mainThreadQueue; + std::vector> m_mainThreadQueue; mutable std::mutex m_mainThreadMutex; std::vector> m_uninitializedHooks; bool m_readyToHook = false; diff --git a/loader/src/loader/ModEvent.cpp b/loader/src/loader/ModEvent.cpp index 2abdd2c4..f699619a 100644 --- a/loader/src/loader/ModEvent.cpp +++ b/loader/src/loader/ModEvent.cpp @@ -12,7 +12,7 @@ Mod* ModStateEvent::getMod() const { return m_mod; } -ListenerResult ModStateFilter::handle(utils::MiniFunction fn, ModStateEvent* event) { +ListenerResult ModStateFilter::handle(std::function fn, ModStateEvent* event) { // log::debug("Event mod filter: {}, {}, {}, {}", m_mod, static_cast(m_type), event->getMod(), static_cast(event->getType())); if ((!m_mod || event->getMod() == m_mod) && event->getType() == m_type) { fn(event); diff --git a/loader/src/loader/SettingV3.cpp b/loader/src/loader/SettingV3.cpp index 32511f0e..e7b3292a 100644 --- a/loader/src/loader/SettingV3.cpp +++ b/loader/src/loader/SettingV3.cpp @@ -422,7 +422,7 @@ public: std::optional settingKey; }; -ListenerResult SettingChangedFilterV3::handle(utils::MiniFunction fn, SettingChangedEventV3* event) { +ListenerResult SettingChangedFilterV3::handle(std::function fn, SettingChangedEventV3* event) { if ( event->getSetting()->getModID() == m_impl->modID && !m_impl->settingKey || event->getSetting()->getKey() == m_impl->settingKey diff --git a/loader/src/loader/updater.cpp b/loader/src/loader/updater.cpp index 9fda6f27..10c12f8a 100644 --- a/loader/src/loader/updater.cpp +++ b/loader/src/loader/updater.cpp @@ -16,7 +16,7 @@ updater::ResourceDownloadEvent::ResourceDownloadEvent( ) : status(std::move(status)) {} ListenerResult updater::ResourceDownloadFilter::handle( - const utils::MiniFunction& fn, + const std::function& fn, ResourceDownloadEvent* event ) { fn(event); @@ -30,7 +30,7 @@ updater::LoaderUpdateEvent::LoaderUpdateEvent( ) : status(std::move(status)) {} ListenerResult updater::LoaderUpdateFilter::handle( - const utils::MiniFunction& fn, + const std::function& fn, LoaderUpdateEvent* event ) { fn(event); @@ -45,8 +45,8 @@ std::optional s_latestGithubRelease; bool s_isNewUpdateDownloaded = false; void updater::fetchLatestGithubRelease( - const utils::MiniFunction& then, - utils::MiniFunction expect, bool force + const std::function& then, + std::function expect, bool force ) { if (s_latestGithubRelease) { return then(s_latestGithubRelease.value()); diff --git a/loader/src/loader/updater.hpp b/loader/src/loader/updater.hpp index a5bee7eb..31641b93 100644 --- a/loader/src/loader/updater.hpp +++ b/loader/src/loader/updater.hpp @@ -2,7 +2,6 @@ #include #include -#include #include namespace geode::updater { @@ -20,7 +19,7 @@ namespace geode::updater { public: using Callback = void(ResourceDownloadEvent*); - static ListenerResult handle(const utils::MiniFunction& fn, ResourceDownloadEvent* event); + static ListenerResult handle(const std::function& fn, ResourceDownloadEvent* event); ResourceDownloadFilter(); }; @@ -33,7 +32,7 @@ namespace geode::updater { public: using Callback = void(LoaderUpdateEvent*); - static ListenerResult handle(const utils::MiniFunction& fn, LoaderUpdateEvent* event); + static ListenerResult handle(const std::function& fn, LoaderUpdateEvent* event); LoaderUpdateFilter(); }; @@ -43,8 +42,8 @@ namespace geode::updater { void downloadLatestLoaderResources(); void downloadLoaderUpdate(std::string const& url); void fetchLatestGithubRelease( - const utils::MiniFunction& then, - utils::MiniFunction expect, + const std::function& then, + std::function expect, bool force = false ); diff --git a/loader/src/platform/android/util.cpp b/loader/src/platform/android/util.cpp index 0f534dda..549d9c51 100644 --- a/loader/src/platform/android/util.cpp +++ b/loader/src/platform/android/util.cpp @@ -6,7 +6,6 @@ using namespace geode::prelude; #include #include #include -#include #include #include #include @@ -139,9 +138,9 @@ bool utils::file::openFolder(std::filesystem::path const& path) { } std::mutex s_callbackMutex; -static utils::MiniFunction)> s_fileCallback {}; -static utils::MiniFunction>)> s_filesCallback {}; -static utils::MiniFunction s_taskCancelled {}; +static std::function)> s_fileCallback {}; +static std::function>)> s_filesCallback {}; +static std::function s_taskCancelled {}; extern "C" JNIEXPORT void JNICALL Java_com_geode_launcher_utils_GeodeUtils_selectFileCallback( @@ -356,7 +355,7 @@ bool geode::utils::permission::getPermissionStatus(Permission permission) { return false; } -static MiniFunction s_permissionCallback; +static std::function s_permissionCallback; extern "C" JNIEXPORT void JNICALL Java_com_geode_launcher_utils_GeodeUtils_permissionCallback( @@ -371,7 +370,7 @@ JNIEXPORT void JNICALL Java_com_geode_launcher_utils_GeodeUtils_permissionCallba } } -void geode::utils::permission::requestPermission(Permission permission, utils::MiniFunction callback) { +void geode::utils::permission::requestPermission(Permission permission, std::function callback) { s_permissionCallback = callback; JniMethodInfo info; if (JniHelper::getStaticMethodInfo(info, "com/geode/launcher/utils/GeodeUtils", "requestPermission", "(Ljava/lang/String;)V")) { diff --git a/loader/src/platform/ios/util.mm b/loader/src/platform/ios/util.mm index 3d21fee5..3242d156 100644 --- a/loader/src/platform/ios/util.mm +++ b/loader/src/platform/ios/util.mm @@ -39,6 +39,6 @@ bool geode::utils::permission::getPermissionStatus(Permission permission) { return true; // unimplemented } -void geode::utils::permission::requestPermission(Permission permission, utils::MiniFunction callback) { +void geode::utils::permission::requestPermission(Permission permission, std::function callback) { callback(true); // unimplemented } diff --git a/loader/src/platform/mac/util.mm b/loader/src/platform/mac/util.mm index 88a30eab..b68def89 100644 --- a/loader/src/platform/mac/util.mm +++ b/loader/src/platform/mac/util.mm @@ -309,7 +309,7 @@ bool geode::utils::permission::getPermissionStatus(Permission permission) { return true; // unimplemented } -void geode::utils::permission::requestPermission(Permission permission, utils::MiniFunction callback) { +void geode::utils::permission::requestPermission(Permission permission, std::function callback) { callback(true); // unimplemented } diff --git a/loader/src/platform/windows/util.cpp b/loader/src/platform/windows/util.cpp index b2a6e8b7..d5020657 100644 --- a/loader/src/platform/windows/util.cpp +++ b/loader/src/platform/windows/util.cpp @@ -275,7 +275,7 @@ bool geode::utils::permission::getPermissionStatus(Permission permission) { return true; // unimplemented } -void geode::utils::permission::requestPermission(Permission permission, utils::MiniFunction callback) { +void geode::utils::permission::requestPermission(Permission permission, std::function callback) { callback(true); // unimplemented } diff --git a/loader/src/server/DownloadManager.cpp b/loader/src/server/DownloadManager.cpp index 9cd8ff5b..573881e9 100644 --- a/loader/src/server/DownloadManager.cpp +++ b/loader/src/server/DownloadManager.cpp @@ -9,7 +9,7 @@ using namespace server; ModDownloadEvent::ModDownloadEvent(std::string const& id) : id(id) {} -ListenerResult ModDownloadFilter::handle(MiniFunction fn, ModDownloadEvent* event) { +ListenerResult ModDownloadFilter::handle(std::function fn, ModDownloadEvent* event) { if (m_id.empty() || m_id == event->id) { fn(event); } diff --git a/loader/src/server/DownloadManager.hpp b/loader/src/server/DownloadManager.hpp index a6df29d7..de2ffeb0 100644 --- a/loader/src/server/DownloadManager.hpp +++ b/loader/src/server/DownloadManager.hpp @@ -49,7 +49,7 @@ namespace server { std::string m_id; public: - ListenerResult handle(MiniFunction fn, ModDownloadEvent* event); + ListenerResult handle(std::function fn, ModDownloadEvent* event); ModDownloadFilter(); ModDownloadFilter(std::string const& id); diff --git a/loader/src/ui/mods/UpdateModListState.cpp b/loader/src/ui/mods/UpdateModListState.cpp index 4e18fcd0..e6443a09 100644 --- a/loader/src/ui/mods/UpdateModListState.cpp +++ b/loader/src/ui/mods/UpdateModListState.cpp @@ -2,7 +2,7 @@ UpdateModListStateEvent::UpdateModListStateEvent(UpdateState&& target) : target(target) {} -ListenerResult UpdateModListStateFilter::handle(MiniFunction fn, UpdateModListStateEvent* event) { +ListenerResult UpdateModListStateFilter::handle(std::function fn, UpdateModListStateEvent* event) { if ( // If the listener wants to hear all state updates then let it std::holds_alternative(m_target) || diff --git a/loader/src/ui/mods/UpdateModListState.hpp b/loader/src/ui/mods/UpdateModListState.hpp index 38175509..55bb5eeb 100644 --- a/loader/src/ui/mods/UpdateModListState.hpp +++ b/loader/src/ui/mods/UpdateModListState.hpp @@ -35,7 +35,7 @@ protected: UpdateState m_target; public: - ListenerResult handle(MiniFunction fn, UpdateModListStateEvent* event); + ListenerResult handle(std::function fn, UpdateModListStateEvent* event); UpdateModListStateFilter(); UpdateModListStateFilter(UpdateState&& target); diff --git a/loader/src/ui/mods/sources/ModListSource.cpp b/loader/src/ui/mods/sources/ModListSource.cpp index e19e1c43..c7b301a0 100644 --- a/loader/src/ui/mods/sources/ModListSource.cpp +++ b/loader/src/ui/mods/sources/ModListSource.cpp @@ -15,7 +15,7 @@ static size_t ceildiv(size_t a, size_t b) { InvalidateCacheEvent::InvalidateCacheEvent(ModListSource* src) : source(src) {} -ListenerResult InvalidateCacheFilter::handle(MiniFunction fn, InvalidateCacheEvent* event) { +ListenerResult InvalidateCacheFilter::handle(std::function fn, InvalidateCacheEvent* event) { if (event->source == m_source) { fn(event); } diff --git a/loader/src/ui/mods/sources/ModListSource.hpp b/loader/src/ui/mods/sources/ModListSource.hpp index 8506d305..5b61d22a 100644 --- a/loader/src/ui/mods/sources/ModListSource.hpp +++ b/loader/src/ui/mods/sources/ModListSource.hpp @@ -21,7 +21,7 @@ protected: public: using Callback = void(InvalidateCacheEvent*); - ListenerResult handle(MiniFunction fn, InvalidateCacheEvent* event); + ListenerResult handle(std::function fn, InvalidateCacheEvent* event); InvalidateCacheFilter() = default; InvalidateCacheFilter(ModListSource* src); diff --git a/loader/src/ui/nodes/ColorPickPopup.cpp b/loader/src/ui/nodes/ColorPickPopup.cpp index 7a6b46c3..49a0b4fc 100644 --- a/loader/src/ui/nodes/ColorPickPopup.cpp +++ b/loader/src/ui/nodes/ColorPickPopup.cpp @@ -40,7 +40,7 @@ using namespace geode::prelude; // ColorPickPopup* popup; // }; -// ListenerResult ColorPickPopupEventFilter::handle(utils::MiniFunction fn, ColorPickPopupEvent* event) { +// ListenerResult ColorPickPopupEventFilter::handle(std::function fn, ColorPickPopupEvent* event) { // if (event->getPopup() == m_impl->popup) { // if (event->isPopupClosed()) { // m_impl->popup = nullptr; diff --git a/loader/src/ui/nodes/EnterLayerEvent.cpp b/loader/src/ui/nodes/EnterLayerEvent.cpp index 1f68f53f..5bb1bf60 100644 --- a/loader/src/ui/nodes/EnterLayerEvent.cpp +++ b/loader/src/ui/nodes/EnterLayerEvent.cpp @@ -8,7 +8,7 @@ AEnterLayerEvent::AEnterLayerEvent( ) : layerID(layerID), layer(layer) {} -ListenerResult AEnterLayerFilter::handle(utils::MiniFunction fn, AEnterLayerEvent* event) { +ListenerResult AEnterLayerFilter::handle(std::function fn, AEnterLayerEvent* event) { if (m_targetID == event->layerID) { fn(event); } diff --git a/loader/src/ui/nodes/MDPopup.cpp b/loader/src/ui/nodes/MDPopup.cpp index 462dcc71..1b79daaa 100644 --- a/loader/src/ui/nodes/MDPopup.cpp +++ b/loader/src/ui/nodes/MDPopup.cpp @@ -6,7 +6,7 @@ using namespace geode::prelude; bool MDPopup::setup( std::string const& title, std::string const& info, char const* btn1Text, char const* btn2Text, - utils::MiniFunction onClick + std::function onClick ) { this->setTitle(title.c_str(), "goldFont.fnt", .9f, 33.f); @@ -60,7 +60,7 @@ float MDPopup::estimateHeight(std::string const& content) { MDPopup* MDPopup::create( std::string const& title, std::string const& content, char const* btn1, char const* btn2, - utils::MiniFunction onClick + std::function onClick ) { auto ret = new MDPopup(); if (ret->initAnchored( diff --git a/loader/src/ui/nodes/Popup.cpp b/loader/src/ui/nodes/Popup.cpp index 714e3f4e..b8fab53b 100644 --- a/loader/src/ui/nodes/Popup.cpp +++ b/loader/src/ui/nodes/Popup.cpp @@ -71,7 +71,7 @@ using namespace geode::prelude; class QuickPopup : public FLAlertLayer, public FLAlertLayerProtocol { protected: - MiniFunction m_selected; + std::function m_selected; bool m_cancelledByEscape; bool m_usedEscape = false; @@ -92,7 +92,7 @@ protected: public: static QuickPopup* create( char const* title, std::string const& content, char const* btn1, char const* btn2, - float width, MiniFunction selected, bool cancelledByEscape + float width, std::function selected, bool cancelledByEscape ) { auto inst = new QuickPopup; inst->m_selected = selected; @@ -109,7 +109,7 @@ public: FLAlertLayer* geode::createQuickPopup( char const* title, std::string const& content, char const* btn1, char const* btn2, float width, - MiniFunction selected, bool doShow + std::function selected, bool doShow ) { auto ret = QuickPopup::create(title, content, btn1, btn2, width, selected, false); if (doShow) { @@ -120,14 +120,14 @@ FLAlertLayer* geode::createQuickPopup( FLAlertLayer* geode::createQuickPopup( char const* title, std::string const& content, char const* btn1, char const* btn2, - MiniFunction selected, bool doShow + std::function selected, bool doShow ) { return createQuickPopup(title, content, btn1, btn2, 350.f, selected, doShow); } FLAlertLayer* geode::createQuickPopup( char const* title, std::string const& content, char const* btn1, char const* btn2, float width, - MiniFunction selected, bool doShow, bool cancelledByEscape + std::function selected, bool doShow, bool cancelledByEscape ) { auto ret = QuickPopup::create(title, content, btn1, btn2, width, selected, cancelledByEscape); if (doShow) { @@ -138,7 +138,7 @@ FLAlertLayer* geode::createQuickPopup( FLAlertLayer* geode::createQuickPopup( char const* title, std::string const& content, char const* btn1, char const* btn2, - MiniFunction selected, bool doShow, bool cancelledByEscape + std::function selected, bool doShow, bool cancelledByEscape ) { return createQuickPopup(title, content, btn1, btn2, 350.f, selected, doShow, cancelledByEscape); } diff --git a/loader/src/utils/ColorProvider.cpp b/loader/src/utils/ColorProvider.cpp index 4f2a922b..644634bc 100644 --- a/loader/src/utils/ColorProvider.cpp +++ b/loader/src/utils/ColorProvider.cpp @@ -6,7 +6,7 @@ using namespace geode::prelude; ColorProvidedEvent::ColorProvidedEvent(std::string const& id, cocos2d::ccColor4B const& color) : id(id), color(color) {} -ListenerResult ColorProvidedFilter::handle(MiniFunction fn, ColorProvidedEvent* event) { +ListenerResult ColorProvidedFilter::handle(std::function fn, ColorProvidedEvent* event) { if (event->id == m_id) { fn(event); } diff --git a/loader/src/utils/file.cpp b/loader/src/utils/file.cpp index 0d514f5d..cecd1254 100644 --- a/loader/src/utils/file.cpp +++ b/loader/src/utils/file.cpp @@ -180,7 +180,7 @@ private: int32_t m_mode; std::variant m_srcDest; std::unordered_map m_entries; - utils::MiniFunction m_progressCallback; + std::function m_progressCallback; Result<> init() { // open stream from file @@ -295,7 +295,7 @@ public: return Ok(std::move(ret)); } - void setProgressCallback(utils::MiniFunction callback) { + void setProgressCallback(std::function callback) { m_progressCallback = callback; } @@ -536,7 +536,7 @@ Unzip::Path Unzip::getPath() const { } void Unzip::setProgressCallback( - utils::MiniFunction callback + std::function callback ) { return m_impl->setProgressCallback(callback); } @@ -587,7 +587,7 @@ Result<> Unzip::intoDir( } Result<> Unzip::intoDir( - utils::MiniFunction progressCallback, + std::function progressCallback, Path const& from, Path const& to, bool deleteZipAfter @@ -677,7 +677,7 @@ std::filesystem::path FileWatchEvent::getPath() const { } ListenerResult FileWatchFilter::handle( - MiniFunction callback, + std::function callback, FileWatchEvent* event ) { std::error_code ec; diff --git a/loader/test/dependency/main.cpp b/loader/test/dependency/main.cpp index d765941e..caafb23a 100644 --- a/loader/test/dependency/main.cpp +++ b/loader/test/dependency/main.cpp @@ -12,7 +12,7 @@ std::string TestEvent::getData() const { TestEvent::TestEvent(std::string const& data) : data(data) {} -ListenerResult TestEventFilter::handle(utils::MiniFunction fn, TestEvent* event) { +ListenerResult TestEventFilter::handle(std::function fn, TestEvent* event) { fn(event); return ListenerResult::Propagate; } diff --git a/loader/test/dependency/main.hpp b/loader/test/dependency/main.hpp index abf4f610..f6364391 100644 --- a/loader/test/dependency/main.hpp +++ b/loader/test/dependency/main.hpp @@ -29,7 +29,7 @@ class GEODE_TESTDEP_DLL TestEventFilter : public EventFilter { public: using Callback = void(TestEvent*); - ListenerResult handle(utils::MiniFunction fn, TestEvent* event); + ListenerResult handle(std::function fn, TestEvent* event); TestEventFilter(); TestEventFilter(TestEventFilter const&) = default; };