mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-22 15:37:53 -05:00
remove minifunction
This commit is contained in:
parent
985b3aedb5
commit
bed622243b
49 changed files with 126 additions and 283 deletions
|
@ -12,5 +12,4 @@
|
|||
#include "utils/permission.hpp"
|
||||
#include "utils/general.hpp"
|
||||
#include "utils/timer.hpp"
|
||||
#include "utils/MiniFunction.hpp"
|
||||
#include "utils/ObjcHook.hpp"
|
||||
|
|
|
@ -1095,7 +1095,7 @@ public:
|
|||
template <class Filter, class... Args>
|
||||
geode::EventListenerProtocol* addEventListener(
|
||||
std::string const& id,
|
||||
geode::utils::MiniFunction<typename Filter::Callback> callback,
|
||||
std::function<typename Filter::Callback> callback,
|
||||
Args&&... args
|
||||
) {
|
||||
auto listener = new geode::EventListener<Filter>(
|
||||
|
@ -1106,7 +1106,7 @@ public:
|
|||
}
|
||||
template <class Filter, class... Args>
|
||||
geode::EventListenerProtocol* addEventListener(
|
||||
geode::utils::MiniFunction<typename Filter::Callback> callback,
|
||||
std::function<typename Filter::Callback> callback,
|
||||
Args&&... args
|
||||
) {
|
||||
return this->addEventListener<Filter, Args...>(
|
||||
|
@ -1916,7 +1916,7 @@ namespace geode {
|
|||
std::string m_targetID;
|
||||
|
||||
public:
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, UserObjectSetEvent* event);
|
||||
ListenerResult handle(std::function<Callback> fn, UserObjectSetEvent* event);
|
||||
|
||||
AttributeSetFilter(std::string const& id);
|
||||
};
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace geode {
|
|||
return dispatchPools()[m_id];
|
||||
}
|
||||
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, Ev* event) {
|
||||
ListenerResult handle(std::function<Callback> fn, Ev* event) {
|
||||
if (event->getID() == m_id) {
|
||||
return std::apply(fn, event->getArgs());
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "../utils/casts.hpp"
|
||||
#include "../utils/MiniFunction.hpp"
|
||||
|
||||
#include <Geode/DefaultInclude.hpp>
|
||||
#include <type_traits>
|
||||
|
@ -103,7 +102,7 @@ namespace geode {
|
|||
using Callback = ListenerResult(T*);
|
||||
using Event = T;
|
||||
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, T* e) {
|
||||
ListenerResult handle(std::function<Callback> fn, T* e) {
|
||||
return fn(e);
|
||||
}
|
||||
|
||||
|
@ -156,7 +155,7 @@ namespace geode {
|
|||
this->enable();
|
||||
}
|
||||
|
||||
EventListener(utils::MiniFunction<Callback> fn, T filter = T())
|
||||
EventListener(std::function<Callback> 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<Callback> const& fn) {
|
||||
m_callback = fn;
|
||||
}
|
||||
void bind(utils::MiniFunction<Callback>&& fn) {
|
||||
void bind(std::function<Callback> fn) {
|
||||
m_callback = fn;
|
||||
}
|
||||
|
||||
|
@ -218,12 +214,12 @@ namespace geode {
|
|||
return m_filter;
|
||||
}
|
||||
|
||||
utils::MiniFunction<Callback>& getCallback() {
|
||||
std::function<Callback>& getCallback() {
|
||||
return m_callback;
|
||||
}
|
||||
|
||||
protected:
|
||||
utils::MiniFunction<Callback> m_callback = nullptr;
|
||||
std::function<Callback> m_callback = nullptr;
|
||||
T m_filter;
|
||||
};
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace geode::ipc {
|
|||
std::string m_messageID;
|
||||
|
||||
public:
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, IPCEvent* event);
|
||||
ListenerResult handle(std::function<Callback> fn, IPCEvent* event);
|
||||
IPCFilter(
|
||||
std::string const& modID,
|
||||
std::string const& messageID
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <filesystem>
|
||||
#include "../utils/Result.hpp"
|
||||
#include "../utils/MiniFunction.hpp"
|
||||
#include "Log.hpp"
|
||||
#include "ModEvent.hpp"
|
||||
#include "ModMetadata.hpp"
|
||||
|
@ -15,7 +14,7 @@
|
|||
#include <string_view>
|
||||
|
||||
namespace geode {
|
||||
using ScheduledFunction = utils::MiniFunction<void()>;
|
||||
using ScheduledFunction = std::function<void()>;
|
||||
|
||||
struct InvalidGeodeFile {
|
||||
std::filesystem::path path;
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace geode {
|
|||
Mod* m_mod;
|
||||
|
||||
public:
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, ModStateEvent* event);
|
||||
ListenerResult handle(std::function<Callback> fn, ModStateEvent* event);
|
||||
|
||||
/**
|
||||
* Create a mod state listener
|
||||
|
|
|
@ -658,7 +658,7 @@ namespace geode {
|
|||
public:
|
||||
using Callback = void(std::shared_ptr<SettingV3>);
|
||||
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, SettingChangedEventV3* event);
|
||||
ListenerResult handle(std::function<Callback> fn, SettingChangedEventV3* event);
|
||||
/**
|
||||
* Listen to changes on a setting, or all settings
|
||||
* @param modID Mod whose settings to listen to
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "../utils/MiniFunction.hpp"
|
||||
#include "Traits.hpp"
|
||||
|
||||
#include <Geode/loader/Loader.hpp>
|
||||
|
@ -20,7 +19,7 @@ namespace geode::modifier {
|
|||
class FieldContainer {
|
||||
private:
|
||||
std::vector<void*> m_containedFields;
|
||||
std::vector<utils::MiniFunction<void(void*)>> m_destructorFunctions;
|
||||
std::vector<std::function<void(void*)>> 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<void(void*)> destructor) {
|
||||
void* setField(size_t index, size_t size, std::function<void(void*)> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace geode {
|
|||
std::optional<std::string> m_targetID;
|
||||
|
||||
public:
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, AEnterLayerEvent* event);
|
||||
ListenerResult handle(std::function<Callback> fn, AEnterLayerEvent* event);
|
||||
|
||||
AEnterLayerFilter(
|
||||
std::optional<std::string> const& id
|
||||
|
@ -63,7 +63,7 @@ namespace geode {
|
|||
std::optional<std::string> m_targetID;
|
||||
|
||||
public:
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, EnterLayerEvent<N>* event) {
|
||||
ListenerResult handle(std::function<Callback> fn, EnterLayerEvent<N>* event) {
|
||||
if (m_targetID == event->getID()) {
|
||||
fn(static_cast<T*>(event));
|
||||
}
|
||||
|
|
|
@ -11,13 +11,13 @@ namespace geode {
|
|||
class GEODE_DLL MDPopup :
|
||||
public Popup<
|
||||
std::string const&, std::string const&, char const*, char const*,
|
||||
utils::MiniFunction<void(bool)>> {
|
||||
std::function<void(bool)>> {
|
||||
protected:
|
||||
utils::MiniFunction<void(bool)> m_onClick = nullptr;
|
||||
std::function<void(bool)> m_onClick = nullptr;
|
||||
|
||||
bool setup(
|
||||
std::string const& title, std::string const& info, char const* btn1, char const* btn2,
|
||||
utils::MiniFunction<void(bool)> onClick
|
||||
std::function<void(bool)> 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<void(bool)> onClick = nullptr
|
||||
char const* btn2 = nullptr, std::function<void(bool)> onClick = nullptr
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <Geode/binding/CCMenuItemSpriteExtra.hpp>
|
||||
#include <Geode/binding/FLAlertLayer.hpp>
|
||||
#include <Geode/utils/MiniFunction.hpp>
|
||||
#include <Geode/utils/cocos.hpp>
|
||||
#include <Geode/ui/Layout.hpp>
|
||||
|
||||
|
@ -52,7 +51,7 @@ namespace geode {
|
|||
}
|
||||
|
||||
public:
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, CloseEvent* event) {
|
||||
ListenerResult handle(std::function<Callback> 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<void(FLAlertLayer*, bool)> selected, bool doShow = true
|
||||
std::function<void(FLAlertLayer*, bool)> 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<void(FLAlertLayer*, bool)> selected, bool doShow = true
|
||||
float width, std::function<void(FLAlertLayer*, bool)> selected, bool doShow = true
|
||||
);
|
||||
|
||||
GEODE_DLL FLAlertLayer* createQuickPopup(
|
||||
char const* title, std::string const& content, char const* btn1, char const* btn2,
|
||||
utils::MiniFunction<void(FLAlertLayer*, bool)> selected, bool doShow, bool cancelledByEscape
|
||||
std::function<void(FLAlertLayer*, bool)> 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<void(FLAlertLayer*, bool)> selected, bool doShow, bool cancelledByEscape
|
||||
float width, std::function<void(FLAlertLayer*, bool)> selected, bool doShow, bool cancelledByEscape
|
||||
);
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@ namespace geode {
|
|||
protected:
|
||||
std::vector<T> m_list;
|
||||
size_t m_index = 0;
|
||||
utils::MiniFunction<void(T const&, size_t)> m_onChange;
|
||||
std::function<void(T const&, size_t)> m_onChange;
|
||||
cocos2d::CCLabelBMFont* m_label;
|
||||
CCMenuItemSpriteExtra* m_prevBtn;
|
||||
CCMenuItemSpriteExtra* m_nextBtn;
|
||||
|
||||
bool init(
|
||||
float width, std::vector<T> const& list, utils::MiniFunction<void(T const&, size_t)> onChange
|
||||
float width, std::vector<T> const& list, std::function<void(T const&, size_t)> onChange
|
||||
) {
|
||||
if (!cocos2d::CCMenu::init()) return false;
|
||||
|
||||
|
@ -94,7 +94,7 @@ namespace geode {
|
|||
|
||||
public:
|
||||
static SelectList* create(
|
||||
float width, std::vector<T> const& list, utils::MiniFunction<void(T const&, size_t)> onChange
|
||||
float width, std::vector<T> const& list, std::function<void(T const&, size_t)> onChange
|
||||
) {
|
||||
auto ret = new SelectList();
|
||||
if (ret->init(width, list, onChange)) {
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace geode {
|
|||
* to distinguish between bold, italic and
|
||||
* regular text.
|
||||
*/
|
||||
using Font = utils::MiniFunction<Label(int)>;
|
||||
using Font = std::function<Label(int)>;
|
||||
|
||||
protected:
|
||||
cocos2d::CCPoint m_origin = cocos2d::CCPointZero;
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace geode {
|
|||
std::string m_id;
|
||||
|
||||
public:
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, ColorProvidedEvent* event);
|
||||
ListenerResult handle(std::function<Callback> fn, ColorProvidedEvent* event);
|
||||
|
||||
ColorProvidedFilter(std::string const& id);
|
||||
};
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "../loader/Log.hpp"
|
||||
#include <set>
|
||||
#include <variant>
|
||||
#include <Geode/utils/MiniFunction.hpp>
|
||||
#include <Geode/utils/Result.hpp>
|
||||
|
||||
namespace geode {
|
||||
|
@ -73,7 +72,7 @@ namespace geode {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
using JsonValueValidator = utils::MiniFunction<bool(T const&)>;
|
||||
using JsonValueValidator = std::function<bool(T const&)>;
|
||||
|
||||
struct JsonMaybeObject;
|
||||
struct JsonMaybeValue;
|
||||
|
|
|
@ -1,141 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <Geode/DefaultInclude.hpp>
|
||||
#include <memory>
|
||||
#include <concepts>
|
||||
#include "terminate.hpp"
|
||||
|
||||
namespace geode::utils {
|
||||
|
||||
template <class FunctionType>
|
||||
class MiniFunction;
|
||||
|
||||
template <class Ret, class... Args>
|
||||
class MiniFunctionStateBase {
|
||||
public:
|
||||
virtual ~MiniFunctionStateBase() = default;
|
||||
virtual Ret call(Args... args) const = 0;
|
||||
virtual MiniFunctionStateBase* clone() const = 0;
|
||||
};
|
||||
|
||||
template <class Type, class Ret, class... Args>
|
||||
class MiniFunctionState final : public MiniFunctionStateBase<Ret, Args...> {
|
||||
public:
|
||||
Type m_func;
|
||||
|
||||
explicit MiniFunctionState(Type func) : m_func(func) {}
|
||||
|
||||
Ret call(Args... args) const override {
|
||||
return const_cast<Type&>(m_func)(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
MiniFunctionStateBase<Ret, Args...>* clone() const override {
|
||||
return new MiniFunctionState(*this);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type, class Ret, class... Args>
|
||||
class MiniFunctionStatePointer final : public MiniFunctionStateBase<Ret, Args...> {
|
||||
public:
|
||||
Type m_func;
|
||||
|
||||
explicit MiniFunctionStatePointer(Type func) : m_func(func) {}
|
||||
|
||||
Ret call(Args... args) const override {
|
||||
return const_cast<Type&>(*m_func)(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
MiniFunctionStateBase<Ret, Args...>* clone() const override {
|
||||
return new MiniFunctionStatePointer(*this);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type, class Ret, class Class, class... Args>
|
||||
class MiniFunctionStateMemberPointer final : public MiniFunctionStateBase<Ret, Class, Args...> {
|
||||
public:
|
||||
Type m_func;
|
||||
|
||||
explicit MiniFunctionStateMemberPointer(Type func) : m_func(func) {}
|
||||
|
||||
Ret call(Class self, Args... args) const override {
|
||||
return const_cast<Type&>(self->*m_func)(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
MiniFunctionStateBase<Ret, Class, Args...>* clone() const override {
|
||||
return new MiniFunctionStateMemberPointer(*this);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Callable, class Ret, class... Args>
|
||||
concept MiniFunctionCallable = requires(Callable&& func, Args... args) {
|
||||
{ func(std::forward<Args>(args)...) } -> std::same_as<Ret>;
|
||||
};
|
||||
|
||||
template <class Ret, class... Args>
|
||||
class MiniFunction<Ret(Args...)> {
|
||||
public:
|
||||
using FunctionType = Ret(Args...);
|
||||
using StateType = MiniFunctionStateBase<Ret, Args...>;
|
||||
|
||||
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 <class Callable>
|
||||
requires(MiniFunctionCallable<Callable, Ret, Args...> && !std::is_same_v<std::decay_t<Callable>, MiniFunction<FunctionType>>)
|
||||
MiniFunction(Callable&& func) :
|
||||
m_state(new MiniFunctionState<std::decay_t<Callable>, Ret, Args...>(std::forward<Callable>(func))) {}
|
||||
|
||||
template <class FunctionPointer>
|
||||
requires(!MiniFunctionCallable<FunctionPointer, Ret, Args...> && std::is_pointer_v<FunctionPointer> && std::is_function_v<std::remove_pointer_t<FunctionPointer>>)
|
||||
MiniFunction(FunctionPointer func) :
|
||||
m_state(new MiniFunctionStatePointer<FunctionPointer, Ret, Args...>(func)) {}
|
||||
|
||||
template <class MemberFunctionPointer>
|
||||
requires(std::is_member_function_pointer_v<MemberFunctionPointer>)
|
||||
MiniFunction(MemberFunctionPointer func) :
|
||||
m_state(new MiniFunctionStateMemberPointer<MemberFunctionPointer, Ret, Args...>(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>(args)...);
|
||||
}
|
||||
|
||||
explicit operator bool() const {
|
||||
return m_state;
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "general.hpp"
|
||||
#include "MiniFunction.hpp"
|
||||
#include "../loader/Event.hpp"
|
||||
#include "../loader/Loader.hpp"
|
||||
#include <mutex>
|
||||
|
@ -249,11 +248,11 @@ namespace geode {
|
|||
|
||||
using Value = T;
|
||||
using Progress = P;
|
||||
using PostResult = utils::MiniFunction<void(Result)>;
|
||||
using PostProgress = utils::MiniFunction<void(P)>;
|
||||
using HasBeenCancelled = utils::MiniFunction<bool()>;
|
||||
using Run = utils::MiniFunction<Result(PostProgress, HasBeenCancelled)>;
|
||||
using RunWithCallback = utils::MiniFunction<void(PostResult, PostProgress, HasBeenCancelled)>;
|
||||
using PostResult = std::function<void(Result)>;
|
||||
using PostProgress = std::function<void(P)>;
|
||||
using HasBeenCancelled = std::function<bool()>;
|
||||
using Run = std::function<Result(PostProgress, HasBeenCancelled)>;
|
||||
using RunWithCallback = std::function<void(PostResult, PostProgress, HasBeenCancelled)>;
|
||||
|
||||
using Callback = void(Event*);
|
||||
|
||||
|
@ -752,7 +751,7 @@ namespace geode {
|
|||
this->listen(std::move(onResult), [](auto const&) {}, [] {});
|
||||
}
|
||||
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, Event* e) {
|
||||
ListenerResult handle(std::function<Callback> fn, Event* e) {
|
||||
if (e->m_handle == m_handle && (!e->m_for || e->m_for == m_listener)) {
|
||||
fn(e);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "../loader/Event.hpp"
|
||||
#include <Geode/binding/CCMenuItemSpriteExtra.hpp>
|
||||
#include <Geode/binding/CCMenuItemToggler.hpp>
|
||||
#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<cocos2d::CCLayer*()>;
|
||||
using CreateLayerFunc = std::function<cocos2d::CCLayer*()>;
|
||||
|
||||
/**
|
||||
* Reload textures, overwriting the scene to return to after the loading
|
||||
|
@ -726,7 +725,7 @@ namespace geode::cocos {
|
|||
* there is none
|
||||
*/
|
||||
template <class Type = cocos2d::CCNode>
|
||||
Type* findFirstChildRecursive(cocos2d::CCNode* node, utils::MiniFunction<bool(Type*)> predicate) {
|
||||
Type* findFirstChildRecursive(cocos2d::CCNode* node, std::function<bool(Type*)> predicate) {
|
||||
if (cast::typeinfo_cast<Type*>(node) && predicate(static_cast<Type*>(node)))
|
||||
return static_cast<Type*>(node);
|
||||
|
||||
|
@ -880,7 +879,7 @@ namespace geode::cocos {
|
|||
}
|
||||
|
||||
template <typename T, typename C, typename = std::enable_if_t<std::is_pointer_v<C>>>
|
||||
static cocos2d::CCArray* vectorToCCArray(std::vector<T> const& vec, utils::MiniFunction<C(T)> convFunc) {
|
||||
static cocos2d::CCArray* vectorToCCArray(std::vector<T> const& vec, std::function<C(T)> 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<C, std::string> || std::is_same_v<C, intptr_t>>>
|
||||
static cocos2d::CCDictionary* mapToCCDict(std::map<K, V> const& map, utils::MiniFunction<C(K)> convFunc) {
|
||||
static cocos2d::CCDictionary* mapToCCDict(std::map<K, V> const& map, std::function<C(K)> 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 Node>
|
||||
class LambdaCallback : public cocos2d::CCObject {
|
||||
public:
|
||||
utils::MiniFunction<void(Node*)> m_callback;
|
||||
std::function<void(Node*)> m_callback;
|
||||
|
||||
static LambdaCallback* create(utils::MiniFunction<void(Node*)>&& callback) {
|
||||
static LambdaCallback* create(std::function<void(Node*)> callback) {
|
||||
auto ret = new (std::nothrow) LambdaCallback();
|
||||
if (ret->init(std::forward<std::remove_reference_t<decltype(callback)>>(callback))) {
|
||||
if (ret->init(std::move(callback))) {
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
}
|
||||
|
@ -1192,8 +1191,8 @@ namespace geode::cocos {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool init(utils::MiniFunction<void(Node*)>&& callback) {
|
||||
m_callback = std::forward<std::remove_reference_t<decltype(callback)>>(callback);
|
||||
bool init(std::function<void(Node*)> callback) {
|
||||
m_callback = std::move(callback);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1204,20 +1203,20 @@ namespace geode::cocos {
|
|||
|
||||
public:
|
||||
static cocos2d::CCMenuItem* create(
|
||||
utils::MiniFunction<void(cocos2d::CCMenuItem*)>&& callback
|
||||
std::function<void(cocos2d::CCMenuItem*)> callback
|
||||
) {
|
||||
auto item = cocos2d::CCMenuItem::create();
|
||||
assignCallback(item, std::forward<std::remove_reference_t<decltype(callback)>>(callback));
|
||||
assignCallback(item, std::move(callback));
|
||||
return item;
|
||||
}
|
||||
|
||||
static cocos2d::CCMenuItemSprite* createSprite(
|
||||
cocos2d::CCNode* normalSprite,
|
||||
cocos2d::CCNode* selectedSprite,
|
||||
utils::MiniFunction<void(cocos2d::CCMenuItemSprite*)>&& callback
|
||||
std::function<void(cocos2d::CCMenuItemSprite*)> callback
|
||||
) {
|
||||
auto item = cocos2d::CCMenuItemSprite::create(normalSprite, selectedSprite);
|
||||
assignCallback(item, std::forward<std::remove_reference_t<decltype(callback)>>(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<void(cocos2d::CCMenuItemSprite*)>&& callback
|
||||
std::function<void(cocos2d::CCMenuItemSprite*)> callback
|
||||
) {
|
||||
auto item = cocos2d::CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite);
|
||||
assignCallback(item, std::forward<std::remove_reference_t<decltype(callback)>>(callback));
|
||||
assignCallback(item, std::move(callback));
|
||||
return item;
|
||||
}
|
||||
|
||||
static CCMenuItemSpriteExtra* createSpriteExtra(
|
||||
cocos2d::CCNode* normalSprite,
|
||||
utils::MiniFunction<void(CCMenuItemSpriteExtra*)>&& callback
|
||||
std::function<void(CCMenuItemSpriteExtra*)> callback
|
||||
) {
|
||||
auto item = CCMenuItemSpriteExtra::create(normalSprite, nullptr, nullptr);
|
||||
assignCallback(item, std::forward<std::remove_reference_t<decltype(callback)>>(callback));
|
||||
assignCallback(item, std::move(callback));
|
||||
return item;
|
||||
}
|
||||
|
||||
static CCMenuItemSpriteExtra* createSpriteExtraWithFilename(
|
||||
std::string_view normalSpriteName,
|
||||
float scale,
|
||||
utils::MiniFunction<void(CCMenuItemSpriteExtra*)>&& callback
|
||||
std::function<void(CCMenuItemSpriteExtra*)> callback
|
||||
) {
|
||||
auto sprite = cocos2d::CCSprite::create(normalSpriteName.data());
|
||||
sprite->setScale(scale);
|
||||
|
||||
return createSpriteExtra(sprite, std::forward<std::remove_reference_t<decltype(callback)>>(callback));
|
||||
return createSpriteExtra(sprite, std::move(callback));
|
||||
}
|
||||
|
||||
static CCMenuItemSpriteExtra* createSpriteExtraWithFrameName(
|
||||
std::string_view normalSpriteName,
|
||||
float scale,
|
||||
utils::MiniFunction<void(CCMenuItemSpriteExtra*)>&& callback
|
||||
std::function<void(CCMenuItemSpriteExtra*)> callback
|
||||
) {
|
||||
auto sprite = cocos2d::CCSprite::createWithSpriteFrameName(normalSpriteName.data());
|
||||
sprite->setScale(scale);
|
||||
|
||||
return createSpriteExtra(sprite, std::forward<std::remove_reference_t<decltype(callback)>>(callback));
|
||||
return createSpriteExtra(sprite, std::move(callback));
|
||||
}
|
||||
|
||||
static CCMenuItemToggler* createToggler(
|
||||
cocos2d::CCNode* onSprite,
|
||||
cocos2d::CCNode* offSprite,
|
||||
utils::MiniFunction<void(CCMenuItemToggler*)>&& callback
|
||||
std::function<void(CCMenuItemToggler*)> callback
|
||||
) {
|
||||
auto item = CCMenuItemToggler::create(offSprite, onSprite, nullptr, nullptr);
|
||||
assignCallback(item, std::forward<std::remove_reference_t<decltype(callback)>>(callback));
|
||||
assignCallback(item, std::move(callback));
|
||||
return item;
|
||||
}
|
||||
|
||||
static CCMenuItemToggler* createTogglerWithStandardSprites(
|
||||
float scale,
|
||||
utils::MiniFunction<void(CCMenuItemToggler*)>&& callback
|
||||
std::function<void(CCMenuItemToggler*)> 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<std::remove_reference_t<decltype(callback)>>(callback));
|
||||
return createToggler(onSprite, offSprite, std::move(callback));
|
||||
}
|
||||
|
||||
static CCMenuItemToggler* createTogglerWithFilename(
|
||||
std::string_view onSpriteName,
|
||||
std::string_view offSpriteName,
|
||||
float scale,
|
||||
utils::MiniFunction<void(CCMenuItemToggler*)>&& callback
|
||||
std::function<void(CCMenuItemToggler*)> 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<std::remove_reference_t<decltype(callback)>>(callback));
|
||||
return createToggler(onSprite, offSprite, std::move(callback));
|
||||
}
|
||||
|
||||
static CCMenuItemToggler* createTogglerWithFrameName(
|
||||
std::string_view onSpriteName,
|
||||
std::string_view offSpriteName,
|
||||
float scale,
|
||||
utils::MiniFunction<void(CCMenuItemToggler*)>&& callback
|
||||
std::function<void(CCMenuItemToggler*)> 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<std::remove_reference_t<decltype(callback)>>(callback));
|
||||
return createToggler(onSprite, offSprite, std::move(callback));
|
||||
}
|
||||
|
||||
template <class Node>
|
||||
static void assignCallback(
|
||||
cocos2d::CCMenuItem* item,
|
||||
utils::MiniFunction<void(Node*)>&& callback
|
||||
std::function<void(Node*)> callback
|
||||
) {
|
||||
auto lambda = LambdaCallback<Node>::create(std::forward<std::remove_reference_t<decltype(callback)>>(callback));
|
||||
auto lambda = LambdaCallback<Node>::create(std::move(callback));
|
||||
item->setTarget(lambda, menu_selector(LambdaCallback<Node>::execute));
|
||||
item->setUserObject("lambda-callback", lambda);
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace geode::utils::file {
|
|||
* @param callback Callback to call with the progress of the unzip operation
|
||||
*/
|
||||
void setProgressCallback(
|
||||
utils::MiniFunction<void(uint32_t, uint32_t)> callback
|
||||
std::function<void(uint32_t, uint32_t)> callback
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -213,7 +213,7 @@ namespace geode::utils::file {
|
|||
);
|
||||
|
||||
static Result<> intoDir(
|
||||
utils::MiniFunction<void(uint32_t, uint32_t)> progressCallback,
|
||||
std::function<void(uint32_t, uint32_t)> 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> callback, FileWatchEvent* event);
|
||||
ListenerResult handle(std::function<Callback> callback, FileWatchEvent* event);
|
||||
FileWatchFilter(std::filesystem::path const& path);
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace geode::utils::map {
|
|||
* false if not.
|
||||
*/
|
||||
template <typename T, typename R, typename H>
|
||||
bool contains(std::unordered_map<T, R, H> const& map, utils::MiniFunction<bool(R)> containFunc) {
|
||||
bool contains(std::unordered_map<T, R, H> const& map, std::function<bool(R)> containFunc) {
|
||||
for (auto const& [_, r] : map) {
|
||||
if (containFunc(r)) return true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace geode::utils::map {
|
|||
* a pointer.
|
||||
*/
|
||||
template <class T, class R, class H>
|
||||
R select(std::unordered_map<T, R, H> const& map, utils::MiniFunction<bool(R)> selectFunc) {
|
||||
R select(std::unordered_map<T, R, H> const& map, std::function<bool(R)> selectFunc) {
|
||||
for (auto const& [_, r] : map) {
|
||||
if (selectFunc(r)) return r;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace geode::utils::map {
|
|||
*/
|
||||
template <class T, class R, class H>
|
||||
std::vector<R> selectAll(
|
||||
std::unordered_map<T, R, H> const& map, utils::MiniFunction<bool(R)> selectFunc
|
||||
std::unordered_map<T, R, H> const& map, std::function<bool(R)> selectFunc
|
||||
) {
|
||||
std::vector<R> res;
|
||||
for (auto const& [_, r] : map) {
|
||||
|
@ -111,7 +111,7 @@ namespace geode::utils::map {
|
|||
template <class T1, class V1, class H1, class T2, class V2, class H2>
|
||||
std::unordered_map<T2, V2, H2> remap(
|
||||
std::unordered_map<T1, V1, H1> const& map,
|
||||
utils::MiniFunction<std::pair<T2, V2>(std::pair<T1, V1>)> remapFunc
|
||||
std::function<std::pair<T2, V2>(std::pair<T1, V1>)> remapFunc
|
||||
) {
|
||||
std::unordered_map<T2, V2, H2> res;
|
||||
for (auto const& [t, v] : map) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <Geode/DefaultInclude.hpp>
|
||||
#include "MiniFunction.hpp"
|
||||
#include <string_view>
|
||||
|
||||
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<void(bool)> callback);
|
||||
void GEODE_DLL requestPermission(Permission permission, std::function<void(bool)> callback);
|
||||
}
|
|
@ -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<Callback> fn, UserObjectSetEvent* event) {
|
||||
ListenerResult AttributeSetFilter::handle(std::function<Callback> fn, UserObjectSetEvent* event) {
|
||||
if (event->id == m_targetID) {
|
||||
fn(event);
|
||||
}
|
||||
|
|
|
@ -2,15 +2,14 @@
|
|||
|
||||
#include <Geode/DefaultInclude.hpp>
|
||||
//#include <Geode/utils/general.hpp>
|
||||
#include <Geode/utils/MiniFunction.hpp>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
class FileWatcher {
|
||||
public:
|
||||
using FileWatchCallback = geode::utils::MiniFunction<void(std::filesystem::path)>;
|
||||
using ErrorCallback = geode::utils::MiniFunction<void(std::string)>;
|
||||
using FileWatchCallback = std::function<void(std::filesystem::path)>;
|
||||
using ErrorCallback = std::function<void(std::string)>;
|
||||
|
||||
protected:
|
||||
std::filesystem::path m_file;
|
||||
|
|
|
@ -20,7 +20,7 @@ protected:
|
|||
std::string content;
|
||||
std::string optionA;
|
||||
std::string optionB;
|
||||
MiniFunction<void(bool)> after;
|
||||
std::function<void(bool)> after;
|
||||
};
|
||||
|
||||
EventListener<server::ModDownloadFilter> m_download;
|
||||
|
|
|
@ -19,7 +19,7 @@ ipc::IPCEvent::IPCEvent(
|
|||
|
||||
ipc::IPCEvent::~IPCEvent() {}
|
||||
|
||||
ListenerResult ipc::IPCFilter::handle(utils::MiniFunction<Callback> fn, IPCEvent* event) {
|
||||
ListenerResult ipc::IPCFilter::handle(std::function<Callback> fn, IPCEvent* event) {
|
||||
if (event->targetModID == m_modID && event->messageID == m_messageID) {
|
||||
event->replyData = fn(event);
|
||||
return ListenerResult::Stop;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <Geode/utils/Result.hpp>
|
||||
#include <Geode/utils/map.hpp>
|
||||
#include <Geode/utils/ranges.hpp>
|
||||
#include <Geode/utils/MiniFunction.hpp>
|
||||
#include "ModImpl.hpp"
|
||||
#include <crashlog.hpp>
|
||||
#include <mutex>
|
||||
|
@ -41,7 +40,7 @@ namespace geode {
|
|||
|
||||
LoadingState m_loadingState = LoadingState::None;
|
||||
|
||||
std::vector<utils::MiniFunction<void(void)>> m_mainThreadQueue;
|
||||
std::vector<std::function<void(void)>> m_mainThreadQueue;
|
||||
mutable std::mutex m_mainThreadMutex;
|
||||
std::vector<std::pair<Hook*, Mod*>> m_uninitializedHooks;
|
||||
bool m_readyToHook = false;
|
||||
|
|
|
@ -12,7 +12,7 @@ Mod* ModStateEvent::getMod() const {
|
|||
return m_mod;
|
||||
}
|
||||
|
||||
ListenerResult ModStateFilter::handle(utils::MiniFunction<Callback> fn, ModStateEvent* event) {
|
||||
ListenerResult ModStateFilter::handle(std::function<Callback> fn, ModStateEvent* event) {
|
||||
// log::debug("Event mod filter: {}, {}, {}, {}", m_mod, static_cast<int>(m_type), event->getMod(), static_cast<int>(event->getType()));
|
||||
if ((!m_mod || event->getMod() == m_mod) && event->getType() == m_type) {
|
||||
fn(event);
|
||||
|
|
|
@ -422,7 +422,7 @@ public:
|
|||
std::optional<std::string> settingKey;
|
||||
};
|
||||
|
||||
ListenerResult SettingChangedFilterV3::handle(utils::MiniFunction<Callback> fn, SettingChangedEventV3* event) {
|
||||
ListenerResult SettingChangedFilterV3::handle(std::function<Callback> fn, SettingChangedEventV3* event) {
|
||||
if (
|
||||
event->getSetting()->getModID() == m_impl->modID &&
|
||||
!m_impl->settingKey || event->getSetting()->getKey() == m_impl->settingKey
|
||||
|
|
|
@ -16,7 +16,7 @@ updater::ResourceDownloadEvent::ResourceDownloadEvent(
|
|||
) : status(std::move(status)) {}
|
||||
|
||||
ListenerResult updater::ResourceDownloadFilter::handle(
|
||||
const utils::MiniFunction<Callback>& fn,
|
||||
const std::function<Callback>& fn,
|
||||
ResourceDownloadEvent* event
|
||||
) {
|
||||
fn(event);
|
||||
|
@ -30,7 +30,7 @@ updater::LoaderUpdateEvent::LoaderUpdateEvent(
|
|||
) : status(std::move(status)) {}
|
||||
|
||||
ListenerResult updater::LoaderUpdateFilter::handle(
|
||||
const utils::MiniFunction<Callback>& fn,
|
||||
const std::function<Callback>& fn,
|
||||
LoaderUpdateEvent* event
|
||||
) {
|
||||
fn(event);
|
||||
|
@ -45,8 +45,8 @@ std::optional<matjson::Value> s_latestGithubRelease;
|
|||
bool s_isNewUpdateDownloaded = false;
|
||||
|
||||
void updater::fetchLatestGithubRelease(
|
||||
const utils::MiniFunction<void(matjson::Value const&)>& then,
|
||||
utils::MiniFunction<void(std::string const&)> expect, bool force
|
||||
const std::function<void(matjson::Value const&)>& then,
|
||||
std::function<void(std::string const&)> expect, bool force
|
||||
) {
|
||||
if (s_latestGithubRelease) {
|
||||
return then(s_latestGithubRelease.value());
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <string>
|
||||
#include <matjson.hpp>
|
||||
#include <Geode/utils/MiniFunction.hpp>
|
||||
#include <Geode/loader/Event.hpp>
|
||||
|
||||
namespace geode::updater {
|
||||
|
@ -20,7 +19,7 @@ namespace geode::updater {
|
|||
public:
|
||||
using Callback = void(ResourceDownloadEvent*);
|
||||
|
||||
static ListenerResult handle(const utils::MiniFunction<Callback>& fn, ResourceDownloadEvent* event);
|
||||
static ListenerResult handle(const std::function<Callback>& fn, ResourceDownloadEvent* event);
|
||||
ResourceDownloadFilter();
|
||||
};
|
||||
|
||||
|
@ -33,7 +32,7 @@ namespace geode::updater {
|
|||
public:
|
||||
using Callback = void(LoaderUpdateEvent*);
|
||||
|
||||
static ListenerResult handle(const utils::MiniFunction<Callback>& fn, LoaderUpdateEvent* event);
|
||||
static ListenerResult handle(const std::function<Callback>& fn, LoaderUpdateEvent* event);
|
||||
LoaderUpdateFilter();
|
||||
};
|
||||
|
||||
|
@ -43,8 +42,8 @@ namespace geode::updater {
|
|||
void downloadLatestLoaderResources();
|
||||
void downloadLoaderUpdate(std::string const& url);
|
||||
void fetchLatestGithubRelease(
|
||||
const utils::MiniFunction<void(matjson::Value const&)>& then,
|
||||
utils::MiniFunction<void(std::string const&)> expect,
|
||||
const std::function<void(matjson::Value const&)>& then,
|
||||
std::function<void(std::string const&)> expect,
|
||||
bool force = false
|
||||
);
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ using namespace geode::prelude;
|
|||
#include <Geode/utils/web.hpp>
|
||||
#include <filesystem>
|
||||
#include <Geode/utils/general.hpp>
|
||||
#include <Geode/utils/MiniFunction.hpp>
|
||||
#include <Geode/utils/permission.hpp>
|
||||
#include <Geode/utils/Task.hpp>
|
||||
#include <Geode/loader/Loader.hpp>
|
||||
|
@ -139,9 +138,9 @@ bool utils::file::openFolder(std::filesystem::path const& path) {
|
|||
}
|
||||
|
||||
std::mutex s_callbackMutex;
|
||||
static utils::MiniFunction<void(Result<std::filesystem::path>)> s_fileCallback {};
|
||||
static utils::MiniFunction<void(Result<std::vector<std::filesystem::path>>)> s_filesCallback {};
|
||||
static utils::MiniFunction<bool()> s_taskCancelled {};
|
||||
static std::function<void(Result<std::filesystem::path>)> s_fileCallback {};
|
||||
static std::function<void(Result<std::vector<std::filesystem::path>>)> s_filesCallback {};
|
||||
static std::function<bool()> 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<void(bool)> s_permissionCallback;
|
||||
static std::function<void(bool)> 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<void(bool)> callback) {
|
||||
void geode::utils::permission::requestPermission(Permission permission, std::function<void(bool)> callback) {
|
||||
s_permissionCallback = callback;
|
||||
JniMethodInfo info;
|
||||
if (JniHelper::getStaticMethodInfo(info, "com/geode/launcher/utils/GeodeUtils", "requestPermission", "(Ljava/lang/String;)V")) {
|
||||
|
|
|
@ -39,6 +39,6 @@ bool geode::utils::permission::getPermissionStatus(Permission permission) {
|
|||
return true; // unimplemented
|
||||
}
|
||||
|
||||
void geode::utils::permission::requestPermission(Permission permission, utils::MiniFunction<void(bool)> callback) {
|
||||
void geode::utils::permission::requestPermission(Permission permission, std::function<void(bool)> callback) {
|
||||
callback(true); // unimplemented
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ bool geode::utils::permission::getPermissionStatus(Permission permission) {
|
|||
return true; // unimplemented
|
||||
}
|
||||
|
||||
void geode::utils::permission::requestPermission(Permission permission, utils::MiniFunction<void(bool)> callback) {
|
||||
void geode::utils::permission::requestPermission(Permission permission, std::function<void(bool)> callback) {
|
||||
callback(true); // unimplemented
|
||||
}
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ bool geode::utils::permission::getPermissionStatus(Permission permission) {
|
|||
return true; // unimplemented
|
||||
}
|
||||
|
||||
void geode::utils::permission::requestPermission(Permission permission, utils::MiniFunction<void(bool)> callback) {
|
||||
void geode::utils::permission::requestPermission(Permission permission, std::function<void(bool)> callback) {
|
||||
callback(true); // unimplemented
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ using namespace server;
|
|||
|
||||
ModDownloadEvent::ModDownloadEvent(std::string const& id) : id(id) {}
|
||||
|
||||
ListenerResult ModDownloadFilter::handle(MiniFunction<Callback> fn, ModDownloadEvent* event) {
|
||||
ListenerResult ModDownloadFilter::handle(std::function<Callback> fn, ModDownloadEvent* event) {
|
||||
if (m_id.empty() || m_id == event->id) {
|
||||
fn(event);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace server {
|
|||
std::string m_id;
|
||||
|
||||
public:
|
||||
ListenerResult handle(MiniFunction<Callback> fn, ModDownloadEvent* event);
|
||||
ListenerResult handle(std::function<Callback> fn, ModDownloadEvent* event);
|
||||
|
||||
ModDownloadFilter();
|
||||
ModDownloadFilter(std::string const& id);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
UpdateModListStateEvent::UpdateModListStateEvent(UpdateState&& target) : target(target) {}
|
||||
|
||||
ListenerResult UpdateModListStateFilter::handle(MiniFunction<Callback> fn, UpdateModListStateEvent* event) {
|
||||
ListenerResult UpdateModListStateFilter::handle(std::function<Callback> fn, UpdateModListStateEvent* event) {
|
||||
if (
|
||||
// If the listener wants to hear all state updates then let it
|
||||
std::holds_alternative<UpdateWholeState>(m_target) ||
|
||||
|
|
|
@ -35,7 +35,7 @@ protected:
|
|||
UpdateState m_target;
|
||||
|
||||
public:
|
||||
ListenerResult handle(MiniFunction<Callback> fn, UpdateModListStateEvent* event);
|
||||
ListenerResult handle(std::function<Callback> fn, UpdateModListStateEvent* event);
|
||||
|
||||
UpdateModListStateFilter();
|
||||
UpdateModListStateFilter(UpdateState&& target);
|
||||
|
|
|
@ -15,7 +15,7 @@ static size_t ceildiv(size_t a, size_t b) {
|
|||
|
||||
InvalidateCacheEvent::InvalidateCacheEvent(ModListSource* src) : source(src) {}
|
||||
|
||||
ListenerResult InvalidateCacheFilter::handle(MiniFunction<Callback> fn, InvalidateCacheEvent* event) {
|
||||
ListenerResult InvalidateCacheFilter::handle(std::function<Callback> fn, InvalidateCacheEvent* event) {
|
||||
if (event->source == m_source) {
|
||||
fn(event);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ protected:
|
|||
public:
|
||||
using Callback = void(InvalidateCacheEvent*);
|
||||
|
||||
ListenerResult handle(MiniFunction<Callback> fn, InvalidateCacheEvent* event);
|
||||
ListenerResult handle(std::function<Callback> fn, InvalidateCacheEvent* event);
|
||||
|
||||
InvalidateCacheFilter() = default;
|
||||
InvalidateCacheFilter(ModListSource* src);
|
||||
|
|
|
@ -40,7 +40,7 @@ using namespace geode::prelude;
|
|||
// ColorPickPopup* popup;
|
||||
// };
|
||||
|
||||
// ListenerResult ColorPickPopupEventFilter::handle(utils::MiniFunction<Callback> fn, ColorPickPopupEvent* event) {
|
||||
// ListenerResult ColorPickPopupEventFilter::handle(std::function<Callback> fn, ColorPickPopupEvent* event) {
|
||||
// if (event->getPopup() == m_impl->popup) {
|
||||
// if (event->isPopupClosed()) {
|
||||
// m_impl->popup = nullptr;
|
||||
|
|
|
@ -8,7 +8,7 @@ AEnterLayerEvent::AEnterLayerEvent(
|
|||
) : layerID(layerID),
|
||||
layer(layer) {}
|
||||
|
||||
ListenerResult AEnterLayerFilter::handle(utils::MiniFunction<Callback> fn, AEnterLayerEvent* event) {
|
||||
ListenerResult AEnterLayerFilter::handle(std::function<Callback> fn, AEnterLayerEvent* event) {
|
||||
if (m_targetID == event->layerID) {
|
||||
fn(event);
|
||||
}
|
||||
|
|
|
@ -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<void(bool)> onClick
|
||||
std::function<void(bool)> 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<void(bool)> onClick
|
||||
std::function<void(bool)> onClick
|
||||
) {
|
||||
auto ret = new MDPopup();
|
||||
if (ret->initAnchored(
|
||||
|
|
|
@ -71,7 +71,7 @@ using namespace geode::prelude;
|
|||
|
||||
class QuickPopup : public FLAlertLayer, public FLAlertLayerProtocol {
|
||||
protected:
|
||||
MiniFunction<void(FLAlertLayer*, bool)> m_selected;
|
||||
std::function<void(FLAlertLayer*, bool)> 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<void(FLAlertLayer*, bool)> selected, bool cancelledByEscape
|
||||
float width, std::function<void(FLAlertLayer*, bool)> 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<void(FLAlertLayer*, bool)> selected, bool doShow
|
||||
std::function<void(FLAlertLayer*, bool)> 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<void(FLAlertLayer*, bool)> selected, bool doShow
|
||||
std::function<void(FLAlertLayer*, bool)> 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<void(FLAlertLayer*, bool)> selected, bool doShow, bool cancelledByEscape
|
||||
std::function<void(FLAlertLayer*, bool)> 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<void(FLAlertLayer*, bool)> selected, bool doShow, bool cancelledByEscape
|
||||
std::function<void(FLAlertLayer*, bool)> selected, bool doShow, bool cancelledByEscape
|
||||
) {
|
||||
return createQuickPopup(title, content, btn1, btn2, 350.f, selected, doShow, cancelledByEscape);
|
||||
}
|
||||
|
|
|
@ -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<Callback> fn, ColorProvidedEvent* event) {
|
||||
ListenerResult ColorProvidedFilter::handle(std::function<Callback> fn, ColorProvidedEvent* event) {
|
||||
if (event->id == m_id) {
|
||||
fn(event);
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ private:
|
|||
int32_t m_mode;
|
||||
std::variant<Path, ByteVector> m_srcDest;
|
||||
std::unordered_map<Path, ZipEntry, path_hash_t> m_entries;
|
||||
utils::MiniFunction<void(uint32_t, uint32_t)> m_progressCallback;
|
||||
std::function<void(uint32_t, uint32_t)> m_progressCallback;
|
||||
|
||||
Result<> init() {
|
||||
// open stream from file
|
||||
|
@ -295,7 +295,7 @@ public:
|
|||
return Ok(std::move(ret));
|
||||
}
|
||||
|
||||
void setProgressCallback(utils::MiniFunction<void(uint32_t, uint32_t)> callback) {
|
||||
void setProgressCallback(std::function<void(uint32_t, uint32_t)> callback) {
|
||||
m_progressCallback = callback;
|
||||
}
|
||||
|
||||
|
@ -536,7 +536,7 @@ Unzip::Path Unzip::getPath() const {
|
|||
}
|
||||
|
||||
void Unzip::setProgressCallback(
|
||||
utils::MiniFunction<void(uint32_t, uint32_t)> callback
|
||||
std::function<void(uint32_t, uint32_t)> callback
|
||||
) {
|
||||
return m_impl->setProgressCallback(callback);
|
||||
}
|
||||
|
@ -587,7 +587,7 @@ Result<> Unzip::intoDir(
|
|||
}
|
||||
|
||||
Result<> Unzip::intoDir(
|
||||
utils::MiniFunction<void(uint32_t, uint32_t)> progressCallback,
|
||||
std::function<void(uint32_t, uint32_t)> progressCallback,
|
||||
Path const& from,
|
||||
Path const& to,
|
||||
bool deleteZipAfter
|
||||
|
@ -677,7 +677,7 @@ std::filesystem::path FileWatchEvent::getPath() const {
|
|||
}
|
||||
|
||||
ListenerResult FileWatchFilter::handle(
|
||||
MiniFunction<Callback> callback,
|
||||
std::function<Callback> callback,
|
||||
FileWatchEvent* event
|
||||
) {
|
||||
std::error_code ec;
|
||||
|
|
|
@ -12,7 +12,7 @@ std::string TestEvent::getData() const {
|
|||
|
||||
TestEvent::TestEvent(std::string const& data) : data(data) {}
|
||||
|
||||
ListenerResult TestEventFilter::handle(utils::MiniFunction<Callback> fn, TestEvent* event) {
|
||||
ListenerResult TestEventFilter::handle(std::function<Callback> fn, TestEvent* event) {
|
||||
fn(event);
|
||||
return ListenerResult::Propagate;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class GEODE_TESTDEP_DLL TestEventFilter : public EventFilter<TestEvent> {
|
|||
public:
|
||||
using Callback = void(TestEvent*);
|
||||
|
||||
ListenerResult handle(utils::MiniFunction<Callback> fn, TestEvent* event);
|
||||
ListenerResult handle(std::function<Callback> fn, TestEvent* event);
|
||||
TestEventFilter();
|
||||
TestEventFilter(TestEventFilter const&) = default;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue