mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
Merge branch 'main' into volume-renderer
This commit is contained in:
commit
d9a7afad05
42 changed files with 539 additions and 196 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "api_lua.hpp"
|
||||
|
||||
#include "assets/Assets.hpp"
|
||||
#include "assets/AssetsLoader.hpp"
|
||||
#include "coders/png.hpp"
|
||||
#include "coders/vcm.hpp"
|
||||
#include "debug/Logger.hpp"
|
||||
|
|
@ -24,6 +25,14 @@ static void load_texture(
|
|||
}
|
||||
}
|
||||
|
||||
static int l_request_texture(lua::State* L) {
|
||||
std::string filename = lua::require_string(L, 1);
|
||||
std::string alias = lua::require_string(L, 2);
|
||||
auto& loader = engine->acquireBackgroundLoader();
|
||||
loader.add(AssetType::TEXTURE, filename, alias);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_load_texture(lua::State* L) {
|
||||
if (lua::isstring(L, 3) && lua::require_lstring(L, 3) != "png") {
|
||||
throw std::runtime_error("unsupportd image format");
|
||||
|
|
@ -108,6 +117,7 @@ static int l_to_canvas(lua::State* L) {
|
|||
}
|
||||
|
||||
const luaL_Reg assetslib[] = {
|
||||
{"request_texture", lua::wrap<l_request_texture>},
|
||||
{"load_texture", lua::wrap<l_load_texture>},
|
||||
{"parse_model", lua::wrap<l_parse_model>},
|
||||
{"to_canvas", lua::wrap<l_to_canvas>},
|
||||
|
|
|
|||
|
|
@ -397,6 +397,13 @@ static int p_get_src(UINode* node, lua::State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_fallback(UINode* node, lua::State* L) {
|
||||
if (auto image = dynamic_cast<Image*>(node)) {
|
||||
return lua::pushstring(L, image->getFallback());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int p_get_region(UINode* node, lua::State* L) {
|
||||
if (auto image = dynamic_cast<Image*>(node)) {
|
||||
const auto& region = image->getRegion();
|
||||
|
|
@ -663,6 +670,7 @@ static int l_gui_getattr(lua::State* L) {
|
|||
{"syntax", p_get_syntax},
|
||||
{"markup", p_get_markup},
|
||||
{"src", p_get_src},
|
||||
{"fallback", p_get_fallback},
|
||||
{"value", p_get_value},
|
||||
{"min", p_get_min},
|
||||
{"max", p_get_max},
|
||||
|
|
@ -790,6 +798,11 @@ static void p_set_src(UINode* node, lua::State* L, int idx) {
|
|||
modelviewer->setModel(lua::require_string(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_fallback(UINode* node, lua::State* L, int idx) {
|
||||
if (auto image = dynamic_cast<Image*>(node)) {
|
||||
image->setFallback(lua::require_string(L, idx));
|
||||
}
|
||||
}
|
||||
static void p_set_region(UINode* node, lua::State* L, int idx) {
|
||||
if (auto image = dynamic_cast<Image*>(node)) {
|
||||
auto vec = lua::tovec4(L, idx);
|
||||
|
|
@ -962,6 +975,7 @@ static int l_gui_setattr(lua::State* L) {
|
|||
{"syntax", p_set_syntax},
|
||||
{"markup", p_set_markup},
|
||||
{"src", p_set_src},
|
||||
{"fallback", p_set_fallback},
|
||||
{"caret", p_set_caret},
|
||||
{"value", p_set_value},
|
||||
{"min", p_set_min},
|
||||
|
|
|
|||
|
|
@ -87,10 +87,10 @@ static int l_pack_get_info(
|
|||
lua::setfield(L, "path");
|
||||
|
||||
if (!engine->isHeadless()) {
|
||||
auto assets = engine->getAssets();
|
||||
auto& assetsLoader = engine->acquireBackgroundLoader();
|
||||
std::string icon = pack.id + ".icon";
|
||||
if (!AssetsLoader::loadExternalTexture(
|
||||
assets, icon, {pack.folder / "icon.png"}
|
||||
assetsLoader, icon, {pack.folder / "icon.png"}
|
||||
)) {
|
||||
icon = "gui/no_icon";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,10 +56,9 @@ static int l_get_list(lua::State* L) {
|
|||
lua::pushstring(L, name);
|
||||
lua::setfield(L, "name");
|
||||
|
||||
auto assets = engine->getAssets();
|
||||
std::string icon = "world#" + name + ".icon";
|
||||
if (!engine->isHeadless() && !AssetsLoader::loadExternalTexture(
|
||||
assets,
|
||||
engine->acquireBackgroundLoader(),
|
||||
icon,
|
||||
{worlds[i] / "icon.png",
|
||||
worlds[i] / "preview.png"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue