h1-mod/src/client/component/ui_scripting.hpp

50 lines
1.1 KiB
C++
Raw Normal View History

2022-03-02 06:26:55 -05:00
#pragma once
namespace ui_scripting
{
2022-05-19 18:06:09 -04:00
template <class... Args, std::size_t... I>
auto wrap_function(const std::function<void(Args...)>& f, std::index_sequence<I...>)
{
return [f](const function_arguments& args)
{
f(args[I]...);
return arguments{{}};
};
}
2022-03-02 06:26:55 -05:00
2022-05-19 18:06:09 -04:00
template <class... Args, std::size_t... I>
auto wrap_function(const std::function<arguments(Args...)>& f, std::index_sequence<I...>)
{
return [f](const function_arguments& args)
{
return f(args[I]...);
};
}
template <typename R, class... Args, std::size_t... I>
auto wrap_function(const std::function<R(Args...)>& f, std::index_sequence<I...>)
{
return [f](const function_arguments& args)
{
return arguments{f(args[I]...)};
};
}
template <typename R, class... Args>
auto wrap_function(const std::function<R(Args...)>& f)
{
return wrap_function(f, std::index_sequence_for<Args...>{});
}
template <class F>
auto wrap_function(F f)
{
return wrap_function(std::function(f));
}
template <typename F>
game::hks::cclosure* convert_function(F f);
2022-04-11 05:05:21 -04:00
bool lui_running();
2022-05-19 18:06:09 -04:00
}