update hud.open(...)
This commit is contained in:
@@ -382,16 +382,11 @@ void Hud::openInventory() {
|
||||
add(HudElement(hud_element_mode::inventory_bound, nullptr, exchangeSlot, false));
|
||||
}
|
||||
|
||||
void Hud::openInventory(
|
||||
std::shared_ptr<Inventory> Hud::openInventory(
|
||||
UiDocument* doc,
|
||||
std::shared_ptr<Inventory> inv,
|
||||
bool playerInventory
|
||||
) {
|
||||
if (inv == nullptr) {
|
||||
// why try to open nox-existent inventory??
|
||||
return;
|
||||
}
|
||||
|
||||
if (isInventoryOpen()) {
|
||||
closeInventory();
|
||||
}
|
||||
@@ -413,6 +408,7 @@ void Hud::openInventory(
|
||||
}
|
||||
secondInvView->bind(inv, content);
|
||||
add(HudElement(hud_element_mode::inventory_bound, doc, secondUI, false));
|
||||
return inv;
|
||||
}
|
||||
|
||||
void Hud::openInventory(
|
||||
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
/// @param doc ui layout
|
||||
/// @param inv inventory
|
||||
/// @param playerInventory show player inventory too
|
||||
void openInventory(
|
||||
std::shared_ptr<Inventory> openInventory(
|
||||
UiDocument* doc,
|
||||
std::shared_ptr<Inventory> inv,
|
||||
bool playerInventory
|
||||
|
||||
@@ -37,23 +37,20 @@ static int l_close_inventory(lua::State*) {
|
||||
}
|
||||
|
||||
static int l_open(lua::State* L) {
|
||||
auto invid = lua::tointeger(L, 1);
|
||||
auto layoutid = lua::require_string(L, 2);
|
||||
bool playerInventory = !lua::toboolean(L, 3);
|
||||
auto layoutid = lua::require_string(L, 1);
|
||||
bool playerInventory = !lua::toboolean(L, 2);
|
||||
auto invid = lua::tointeger(L, 3);
|
||||
|
||||
auto assets = engine->getAssets();
|
||||
auto layout = assets->get<UiDocument>(layoutid);
|
||||
if (layout == nullptr) {
|
||||
throw std::runtime_error("there is no ui layout " + util::quote(layoutid));
|
||||
}
|
||||
|
||||
hud->openInventory(
|
||||
return lua::pushinteger(L, hud->openInventory(
|
||||
layout,
|
||||
level->inventories->get(invid),
|
||||
playerInventory
|
||||
);
|
||||
|
||||
return 0;
|
||||
)->getId());
|
||||
}
|
||||
|
||||
static int l_open_block(lua::State* L) {
|
||||
|
||||
Reference in New Issue
Block a user