update Assets container - template-based now
This commit is contained in:
@@ -32,7 +32,7 @@ inline audio::speakerid_t play_sound(
|
||||
return 0;
|
||||
}
|
||||
auto assets = scripting::engine->getAssets();
|
||||
auto sound = assets->getSound(name);
|
||||
auto sound = assets->get<audio::Sound>(name);
|
||||
if (sound == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ struct DocumentNode {
|
||||
};
|
||||
|
||||
static DocumentNode getDocumentNode(lua::State*, const std::string& name, const std::string& nodeName) {
|
||||
auto doc = engine->getAssets()->getLayout(name);
|
||||
auto doc = engine->getAssets()->get<UiDocument>(name);
|
||||
if (doc == nullptr) {
|
||||
throw std::runtime_error("document '"+name+"' not found");
|
||||
}
|
||||
@@ -545,7 +545,7 @@ static int l_gui_setattr(lua::State* L) {
|
||||
|
||||
static int l_gui_get_env(lua::State* L) {
|
||||
auto name = lua::require_string(L, 1);
|
||||
auto doc = engine->getAssets()->getLayout(name);
|
||||
auto doc = engine->getAssets()->get<UiDocument>(name);
|
||||
if (doc == nullptr) {
|
||||
throw std::runtime_error("document '"+std::string(name)+"' not found");
|
||||
}
|
||||
@@ -566,7 +566,7 @@ static int l_gui_str(lua::State* L) {
|
||||
|
||||
static int l_gui_reindex(lua::State* L) {
|
||||
auto name = lua::require_string(L, 1);
|
||||
auto doc = engine->getAssets()->getLayout(name);
|
||||
auto doc = engine->getAssets()->get<UiDocument>(name);
|
||||
if (doc == nullptr) {
|
||||
throw std::runtime_error("document '"+std::string(name)+"' not found");
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ static int l_hud_open_block(lua::State* L) {
|
||||
}
|
||||
auto def = content->getIndices()->getBlockDef(vox->id);
|
||||
auto assets = engine->getAssets();
|
||||
auto layout = assets->getLayout(def->uiLayout);
|
||||
auto layout = assets->get<UiDocument>(def->uiLayout);
|
||||
if (layout == nullptr) {
|
||||
throw std::runtime_error("block '"+def->name+"' has no ui layout");
|
||||
}
|
||||
@@ -71,7 +71,7 @@ static int l_hud_show_overlay(lua::State* L) {
|
||||
bool playerInventory = lua::toboolean(L, 2);
|
||||
|
||||
auto assets = engine->getAssets();
|
||||
auto layout = assets->getLayout(name);
|
||||
auto layout = assets->get<UiDocument>(name);
|
||||
if (layout == nullptr) {
|
||||
throw std::runtime_error("there is no ui layout "+util::quote(name));
|
||||
}
|
||||
@@ -81,7 +81,7 @@ static int l_hud_show_overlay(lua::State* L) {
|
||||
|
||||
static UiDocument* require_layout(const char* name) {
|
||||
auto assets = engine->getAssets();
|
||||
auto layout = assets->getLayout(name);
|
||||
auto layout = assets->get<UiDocument>(name);
|
||||
if (layout == nullptr) {
|
||||
throw std::runtime_error("layout '"+std::string(name)+"' is not found");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user