add on_hud_render event
This commit is contained in:
parent
247acb3687
commit
4aa76e35b7
@ -12,6 +12,7 @@
|
||||
#include "../../items/ItemDef.hpp"
|
||||
#include "../../items/ItemStack.hpp"
|
||||
#include "../../logic/PlayerController.hpp"
|
||||
#include "../../logic/scripting/scripting_hud.hpp"
|
||||
#include "../../maths/FrustumCulling.hpp"
|
||||
#include "../../maths/voxmaths.hpp"
|
||||
#include "../../objects/Player.hpp"
|
||||
@ -199,6 +200,9 @@ void WorldRenderer::renderLevel(
|
||||
|
||||
shader->uniformMatrix("u_model", glm::mat4(1.0f));
|
||||
level->entities->render(assets, *modelBatch, *frustumCulling, pause);
|
||||
if (!pause) {
|
||||
scripting::on_frontend_render();
|
||||
}
|
||||
modelBatch->render();
|
||||
|
||||
skybox->unbind();
|
||||
|
||||
@ -139,6 +139,8 @@ void CameraControl::switchCamera() {
|
||||
if (static_cast<size_t>(index) != playerCameras.size()) {
|
||||
index = (index + 1) % playerCameras.size();
|
||||
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() {
|
||||
for (auto& pack : engine->getContentPacks()) {
|
||||
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, "on_hud_open", packid+".hudopen");
|
||||
register_event(env, "on_hud_render", packid+".hudrender");
|
||||
register_event(env, "on_hud_close", packid+".hudclose");
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ namespace scripting {
|
||||
extern Hud* hud;
|
||||
|
||||
void on_frontend_init(Hud* hud);
|
||||
void on_frontend_render();
|
||||
void on_frontend_close();
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user