This commit is contained in:
MihailRis
2024-12-18 04:13:33 +03:00
parent 5e55e20ec4
commit d745a34657
33 changed files with 209 additions and 205 deletions
+1 -1
View File
@@ -225,7 +225,7 @@ static int l_load_texture(lua::State* L) {
}
static int l_open_folder(lua::State* L) {
auto path = engine->getPaths()->resolve(lua::require_string(L, 1));
auto path = engine->getPaths().resolve(lua::require_string(L, 1));
platform::open_folder(path);
return 0;
}
+2 -2
View File
@@ -14,14 +14,14 @@ namespace fs = std::filesystem;
using namespace scripting;
static fs::path resolve_path(const std::string& path) {
return engine->getPaths()->resolve(path);
return engine->getPaths().resolve(path);
}
static fs::path resolve_path_soft(const std::string& path) {
if (path.find(':') == std::string::npos) {
return fs::u8path("");
}
return engine->getPaths()->resolve(path, false);
return engine->getPaths().resolve(path, false);
}
static int l_find(lua::State* L) {
@@ -12,9 +12,9 @@
using namespace scripting;
static int l_save_fragment(lua::State* L) {
auto paths = engine->getPaths();
const auto& paths = engine->getPaths();
auto fragment = lua::touserdata<lua::LuaVoxelFragment>(L, 1);
auto file = paths->resolve(lua::require_string(L, 2), true);
auto file = paths.resolve(lua::require_string(L, 2), true);
auto map = fragment->getFragment()->serialize();
auto bytes = json::to_binary(map, true);
files::write_bytes(file, bytes.data(), bytes.size());
@@ -35,9 +35,9 @@ static int l_create_fragment(lua::State* L) {
}
static int l_load_fragment(lua::State* L) {
auto paths = engine->getPaths();
const auto& paths = engine->getPaths();
auto filename = lua::require_string(L, 1);
auto path = paths->resolve(filename);
auto path = paths.resolve(filename);
if (!std::filesystem::exists(path)) {
throw std::runtime_error("file "+path.u8string()+" does not exist");
}
+1 -1
View File
@@ -125,7 +125,7 @@ static void resetPackBindings(fs::path& packFolder) {
}
static int l_reset_bindings(lua::State*) {
auto resFolder = engine->getPaths()->getResourcesFolder();
auto resFolder = engine->getPaths().getResourcesFolder();
resetPackBindings(resFolder);
for (auto& pack : engine->getContentPacks()) {
resetPackBindings(pack.folder);
+3 -3
View File
@@ -34,8 +34,8 @@ static int l_is_open(lua::State* L) {
}
static int l_get_list(lua::State* L) {
auto paths = engine->getPaths();
auto worlds = paths->scanForWorlds();
const auto& paths = engine->getPaths();
auto worlds = paths.scanForWorlds();
lua::createtable(L, worlds.size(), 0);
for (size_t i = 0; i < worlds.size(); i++) {
@@ -104,7 +104,7 @@ static int l_get_seed(lua::State* L) {
static int l_exists(lua::State* L) {
auto name = lua::require_string(L, 1);
auto worldsDir = engine->getPaths()->getWorldFolderByName(name);
auto worldsDir = engine->getPaths().getWorldFolderByName(name);
return lua::pushboolean(L, fs::is_directory(worldsDir));
}
@@ -50,9 +50,9 @@ const float* LuaHeightmap::getValues() const {
}
static int l_dump(lua::State* L) {
auto paths = scripting::engine->getPaths();
const auto& paths = scripting::engine->getPaths();
if (auto heightmap = touserdata<LuaHeightmap>(L, 1)) {
auto file = paths->resolve(require_string(L, 2));
auto file = paths.resolve(require_string(L, 2));
uint w = heightmap->getWidth();
uint h = heightmap->getHeight();
ImageData image(ImageFormat::rgb888, w, h);