2021-09-09 21:21:51 -04:00
|
|
|
#include <std_include.hpp>
|
|
|
|
#include "loader/component_loader.hpp"
|
|
|
|
|
|
|
|
#include "game/game.hpp"
|
|
|
|
#include "game/dvars.hpp"
|
|
|
|
|
|
|
|
#include "chat.hpp"
|
|
|
|
#include "scheduler.hpp"
|
|
|
|
#include "command.hpp"
|
|
|
|
#include "ui_scripting.hpp"
|
|
|
|
|
|
|
|
#include "game/ui_scripting/lua/engine.hpp"
|
|
|
|
|
|
|
|
#include <utils/string.hpp>
|
|
|
|
|
|
|
|
namespace ui_scripting
|
|
|
|
{
|
|
|
|
class component final : public component_interface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
void post_unpack() override
|
|
|
|
{
|
|
|
|
scheduler::once([]()
|
|
|
|
{
|
|
|
|
ui_scripting::lua::engine::start();
|
|
|
|
}, scheduler::pipeline::renderer);
|
|
|
|
|
|
|
|
scheduler::loop([]()
|
|
|
|
{
|
|
|
|
ui_scripting::lua::engine::run_frame();
|
|
|
|
}, scheduler::pipeline::renderer);
|
|
|
|
|
|
|
|
command::add("reloadmenus", []()
|
|
|
|
{
|
|
|
|
scheduler::once([]()
|
|
|
|
{
|
|
|
|
ui_scripting::lua::engine::start();
|
|
|
|
}, scheduler::pipeline::renderer);
|
|
|
|
});
|
|
|
|
|
|
|
|
command::add("openluamenu", [](const command::params& params)
|
|
|
|
{
|
|
|
|
const std::string name = params.get(1);
|
|
|
|
scheduler::once([name]()
|
|
|
|
{
|
2021-09-12 19:30:14 -04:00
|
|
|
ui_scripting::lua::engine::open_menu(name);
|
2021-09-09 21:21:51 -04:00
|
|
|
}, scheduler::pipeline::renderer);
|
|
|
|
});
|
|
|
|
|
|
|
|
command::add("closeluamenu", [](const command::params& params)
|
|
|
|
{
|
|
|
|
const std::string name = params.get(1);
|
|
|
|
scheduler::once([name]()
|
|
|
|
{
|
2021-09-12 19:30:14 -04:00
|
|
|
ui_scripting::lua::engine::close_menu(name);
|
2021-09-09 21:21:51 -04:00
|
|
|
}, scheduler::pipeline::renderer);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
REGISTER_COMPONENT(ui_scripting::component)
|