format: reformat project

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov
2024-08-03 19:53:48 +03:00
committed by Pugemon
parent 736cd175d5
commit bbf33e8e4d
202 changed files with 7389 additions and 5609 deletions
+31 -23
View File
@@ -1,14 +1,13 @@
#include "scripting_hud.hpp"
#include "scripting.hpp"
#include "lua/api_lua.hpp"
#include "lua/lua_engine.hpp"
#include "../../debug/Logger.hpp"
#include "../../engine.hpp"
#include "../../files/files.hpp"
#include "../../frontend/hud.hpp"
#include "../../objects/Player.hpp"
#include "../../files/files.hpp"
#include "../../engine.hpp"
#include "lua/api_lua.hpp"
#include "lua/lua_engine.hpp"
#include "scripting.hpp"
using namespace scripting;
@@ -21,41 +20,50 @@ void scripting::on_frontend_init(Hud* hud) {
lua::openlib(lua::get_main_thread(), "hud", hudlib);
for (auto& pack : engine->getContentPacks()) {
lua::emit_event(lua::get_main_thread(), pack.id + ".hudopen",
[&] (lua::State* L) {
return lua::pushinteger(L, hud->getPlayer()->getId());
});
lua::emit_event(
lua::get_main_thread(),
pack.id + ".hudopen",
[&](lua::State* L) {
return lua::pushinteger(L, hud->getPlayer()->getId());
}
);
}
}
void scripting::on_frontend_render() {
for (auto& pack : engine->getContentPacks()) {
lua::emit_event(lua::get_main_thread(), pack.id + ".hudrender",
[&] (lua::State* L) {
return 0;
});
lua::emit_event(
lua::get_main_thread(),
pack.id + ".hudrender",
[&](lua::State* L) { return 0; }
);
}
}
void scripting::on_frontend_close() {
for (auto& pack : engine->getContentPacks()) {
lua::emit_event(lua::get_main_thread(), pack.id + ".hudclose",
[&] (lua::State* L) {
return lua::pushinteger(L, hud->getPlayer()->getId());
});
lua::emit_event(
lua::get_main_thread(),
pack.id + ".hudclose",
[&](lua::State* L) {
return lua::pushinteger(L, hud->getPlayer()->getId());
}
);
}
scripting::hud = nullptr;
}
void scripting::load_hud_script(const scriptenv& senv, const std::string& packid, const fs::path& file) {
void scripting::load_hud_script(
const scriptenv& senv, const std::string& packid, const fs::path& file
) {
int env = *senv;
std::string src = files::read_string(file);
logger.info() << "loading script " << file.u8string();
lua::execute(lua::get_main_thread(), env, src, file.u8string());
register_event(env, "init", packid+".init");
register_event(env, "on_hud_open", packid+".hudopen");
register_event(env, "on_hud_render", packid+".hudrender");
register_event(env, "on_hud_close", packid+".hudclose");
register_event(env, "init", packid + ".init");
register_event(env, "on_hud_open", packid + ".hudopen");
register_event(env, "on_hud_render", packid + ".hudrender");
register_event(env, "on_hud_close", packid + ".hudclose");
}