hud events update
This commit is contained in:
@@ -628,3 +628,7 @@ void Hud::setPause(bool pause) {
|
|||||||
darkOverlay->setVisible(pause);
|
darkOverlay->setVisible(pause);
|
||||||
menu->setVisible(pause);
|
menu->setVisible(pause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player* Hud::getPlayer() const {
|
||||||
|
return frontend->getLevel()->player;
|
||||||
|
}
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ public:
|
|||||||
void add(HudElement element);
|
void add(HudElement element);
|
||||||
void remove(HudElement& element);
|
void remove(HudElement& element);
|
||||||
void remove(std::shared_ptr<gui::UINode> node);
|
void remove(std::shared_ptr<gui::UINode> node);
|
||||||
|
|
||||||
|
Player* getPlayer() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SRC_HUD_H_ */
|
#endif /* SRC_HUD_H_ */
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "lua/libhud.h"
|
#include "lua/libhud.h"
|
||||||
#include "lua/LuaState.h"
|
#include "lua/LuaState.h"
|
||||||
|
|
||||||
|
#include "../../frontend/hud.h"
|
||||||
|
#include "../../objects/Player.h"
|
||||||
#include "../../files/files.h"
|
#include "../../files/files.h"
|
||||||
#include "../../engine.h"
|
#include "../../engine.h"
|
||||||
|
|
||||||
@@ -21,7 +23,8 @@ void scripting::on_frontend_init(Hud* hud) {
|
|||||||
|
|
||||||
for (auto& pack : scripting::engine->getContentPacks()) {
|
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||||
if (state->getglobal(pack.id+".hudopen")) {
|
if (state->getglobal(pack.id+".hudopen")) {
|
||||||
state->callNoThrow(0);
|
state->pushinteger(hud->getPlayer()->getId());
|
||||||
|
state->callNoThrow(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,7 +33,8 @@ void scripting::on_frontend_close() {
|
|||||||
scripting::hud = nullptr;
|
scripting::hud = nullptr;
|
||||||
for (auto& pack : scripting::engine->getContentPacks()) {
|
for (auto& pack : scripting::engine->getContentPacks()) {
|
||||||
if (state->getglobal(pack.id+".hudclose")) {
|
if (state->getglobal(pack.id+".hudclose")) {
|
||||||
state->callNoThrow(0);
|
state->pushinteger(hud->getPlayer()->getId());
|
||||||
|
state->callNoThrow(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,10 @@ public:
|
|||||||
void deserialize(dynamic::Map *src) override;
|
void deserialize(dynamic::Map *src) override;
|
||||||
|
|
||||||
static void convert(dynamic::Map* data, const ContentLUT* lut);
|
static void convert(dynamic::Map* data, const ContentLUT* lut);
|
||||||
|
|
||||||
|
inline int getId() const {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SRC_OBJECTS_PLAYER_H_ */
|
#endif /* SRC_OBJECTS_PLAYER_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user