fix
This commit is contained in:
@@ -117,7 +117,8 @@ SlotView::SlotView(
|
|||||||
|
|
||||||
void SlotView::draw(const GfxContext* pctx, Assets* assets) {
|
void SlotView::draw(const GfxContext* pctx, Assets* assets) {
|
||||||
if (bound == nullptr)
|
if (bound == nullptr)
|
||||||
throw std::runtime_error("unbound slot");
|
return;
|
||||||
|
|
||||||
ItemStack& stack = *bound;
|
ItemStack& stack = *bound;
|
||||||
|
|
||||||
glm::vec2 coord = calcCoord();
|
glm::vec2 coord = calcCoord();
|
||||||
@@ -206,7 +207,7 @@ bool SlotView::isHighlighted() const {
|
|||||||
|
|
||||||
void SlotView::clicked(gui::GUI* gui, int button) {
|
void SlotView::clicked(gui::GUI* gui, int button) {
|
||||||
if (bound == nullptr)
|
if (bound == nullptr)
|
||||||
throw std::runtime_error("unbound slot");
|
return;
|
||||||
|
|
||||||
ItemStack& grabbed = interaction->getGrabbedItem();
|
ItemStack& grabbed = interaction->getGrabbedItem();
|
||||||
ItemStack& stack = *bound;
|
ItemStack& stack = *bound;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "../../../items/Inventories.h"
|
#include "../../../items/Inventories.h"
|
||||||
#include "../../../engine.h"
|
#include "../../../engine.h"
|
||||||
#include "../../../frontend/UiDocument.h"
|
#include "../../../frontend/UiDocument.h"
|
||||||
|
#include "../../../frontend/InventoryView.h"
|
||||||
|
|
||||||
namespace scripting {
|
namespace scripting {
|
||||||
extern Hud* hud;
|
extern Hud* hud;
|
||||||
@@ -76,6 +77,10 @@ UiDocument* require_layout(lua_State* L, const char* name) {
|
|||||||
|
|
||||||
int l_hud_open_permanent(lua_State* L) {
|
int l_hud_open_permanent(lua_State* L) {
|
||||||
auto layout = require_layout(L, lua_tostring(L, 1));
|
auto layout = require_layout(L, lua_tostring(L, 1));
|
||||||
|
auto invview = std::dynamic_pointer_cast<InventoryView>(layout->getRoot());
|
||||||
|
if (invview) {
|
||||||
|
luaL_error(L, "layout must not contain 'inventory' element");
|
||||||
|
}
|
||||||
scripting::hud->openPermanent(layout);
|
scripting::hud->openPermanent(layout);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user