add on_hud_render event
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include "../../items/ItemDef.hpp"
|
#include "../../items/ItemDef.hpp"
|
||||||
#include "../../items/ItemStack.hpp"
|
#include "../../items/ItemStack.hpp"
|
||||||
#include "../../logic/PlayerController.hpp"
|
#include "../../logic/PlayerController.hpp"
|
||||||
|
#include "../../logic/scripting/scripting_hud.hpp"
|
||||||
#include "../../maths/FrustumCulling.hpp"
|
#include "../../maths/FrustumCulling.hpp"
|
||||||
#include "../../maths/voxmaths.hpp"
|
#include "../../maths/voxmaths.hpp"
|
||||||
#include "../../objects/Player.hpp"
|
#include "../../objects/Player.hpp"
|
||||||
@@ -199,6 +200,9 @@ void WorldRenderer::renderLevel(
|
|||||||
|
|
||||||
shader->uniformMatrix("u_model", glm::mat4(1.0f));
|
shader->uniformMatrix("u_model", glm::mat4(1.0f));
|
||||||
level->entities->render(assets, *modelBatch, *frustumCulling, pause);
|
level->entities->render(assets, *modelBatch, *frustumCulling, pause);
|
||||||
|
if (!pause) {
|
||||||
|
scripting::on_frontend_render();
|
||||||
|
}
|
||||||
modelBatch->render();
|
modelBatch->render();
|
||||||
|
|
||||||
skybox->unbind();
|
skybox->unbind();
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ void CameraControl::switchCamera() {
|
|||||||
if (static_cast<size_t>(index) != playerCameras.size()) {
|
if (static_cast<size_t>(index) != playerCameras.size()) {
|
||||||
index = (index + 1) % playerCameras.size();
|
index = (index + 1) % playerCameras.size();
|
||||||
player->currentCamera = playerCameras.at(index);
|
player->currentCamera = playerCameras.at(index);
|
||||||
|
} else {
|
||||||
|
player->currentCamera = camera;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,15 @@ void scripting::on_frontend_init(Hud* hud) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void scripting::on_frontend_close() {
|
void scripting::on_frontend_close() {
|
||||||
for (auto& pack : engine->getContentPacks()) {
|
for (auto& pack : engine->getContentPacks()) {
|
||||||
lua::emit_event(lua::get_main_thread(), pack.id + ".hudclose",
|
lua::emit_event(lua::get_main_thread(), pack.id + ".hudclose",
|
||||||
@@ -47,5 +56,6 @@ void scripting::load_hud_script(const scriptenv& senv, const std::string& packid
|
|||||||
|
|
||||||
register_event(env, "init", packid+".init");
|
register_event(env, "init", packid+".init");
|
||||||
register_event(env, "on_hud_open", packid+".hudopen");
|
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, "on_hud_close", packid+".hudclose");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace scripting {
|
|||||||
extern Hud* hud;
|
extern Hud* hud;
|
||||||
|
|
||||||
void on_frontend_init(Hud* hud);
|
void on_frontend_init(Hud* hud);
|
||||||
|
void on_frontend_render();
|
||||||
void on_frontend_close();
|
void on_frontend_close();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user