Merge branch 'main' into heightmaps
This commit is contained in:
commit
7da8e133a5
@ -4,6 +4,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "constants.hpp"
|
||||||
#include "coders/json.hpp"
|
#include "coders/json.hpp"
|
||||||
#include "data/dynamic.hpp"
|
#include "data/dynamic.hpp"
|
||||||
#include "files/engine_paths.hpp"
|
#include "files/engine_paths.hpp"
|
||||||
@ -11,6 +12,12 @@
|
|||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
ContentPack ContentPack::createCore(const EnginePaths* paths) {
|
||||||
|
return ContentPack {
|
||||||
|
"core", "Core", ENGINE_VERSION_STRING, "", "", paths->getResourcesFolder(), {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<std::string> ContentPack::RESERVED_NAMES = {
|
const std::vector<std::string> ContentPack::RESERVED_NAMES = {
|
||||||
"res", "abs", "local", "core", "user", "world", "none", "null"};
|
"res", "abs", "local", "core", "user", "world", "none", "null"};
|
||||||
|
|
||||||
|
|||||||
@ -67,6 +67,8 @@ struct ContentPack {
|
|||||||
const fs::path& worldDir,
|
const fs::path& worldDir,
|
||||||
const std::string& name
|
const std::string& name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
static ContentPack createCore(const EnginePaths*);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ContentPackStats {
|
struct ContentPackStats {
|
||||||
|
|||||||
@ -313,12 +313,17 @@ void Engine::loadContent() {
|
|||||||
contentPacks = manager.getAll(names);
|
contentPacks = manager.getAll(names);
|
||||||
|
|
||||||
std::vector<PathsRoot> resRoots;
|
std::vector<PathsRoot> resRoots;
|
||||||
|
{
|
||||||
|
auto pack = ContentPack::createCore(paths);
|
||||||
|
resRoots.push_back({"core", pack.folder});
|
||||||
|
ContentLoader(&pack, contentBuilder).load();
|
||||||
|
load_configs(pack.folder);
|
||||||
|
}
|
||||||
for (auto& pack : contentPacks) {
|
for (auto& pack : contentPacks) {
|
||||||
resRoots.push_back({pack.id, pack.folder});
|
resRoots.push_back({pack.id, pack.folder});
|
||||||
ContentLoader(&pack, contentBuilder).load();
|
ContentLoader(&pack, contentBuilder).load();
|
||||||
load_configs(pack.folder);
|
load_configs(pack.folder);
|
||||||
}
|
}
|
||||||
load_configs(paths->getResourcesFolder());
|
|
||||||
|
|
||||||
content = contentBuilder.build();
|
content = contentBuilder.build();
|
||||||
resPaths = std::make_unique<ResPaths>(resdir, resRoots);
|
resPaths = std::make_unique<ResPaths>(resdir, resRoots);
|
||||||
@ -330,7 +335,13 @@ void Engine::loadContent() {
|
|||||||
|
|
||||||
void Engine::resetContent() {
|
void Engine::resetContent() {
|
||||||
auto resdir = paths->getResourcesFolder();
|
auto resdir = paths->getResourcesFolder();
|
||||||
resPaths = std::make_unique<ResPaths>(resdir, std::vector<PathsRoot>());
|
std::vector<PathsRoot> resRoots;
|
||||||
|
{
|
||||||
|
auto pack = ContentPack::createCore(paths);
|
||||||
|
resRoots.push_back({"core", pack.folder});
|
||||||
|
load_configs(pack.folder);
|
||||||
|
}
|
||||||
|
resPaths = std::make_unique<ResPaths>(resdir, resRoots);
|
||||||
contentPacks.clear();
|
contentPacks.clear();
|
||||||
content.reset();
|
content.reset();
|
||||||
|
|
||||||
|
|||||||
@ -218,10 +218,6 @@ std::string ResPaths::findRaw(const std::string& filename) const {
|
|||||||
return root.name + ":" + filename;
|
return root.name + ":" + filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto resDir = mainRoot;
|
|
||||||
if (fs::exists(resDir / std::filesystem::path(filename))) {
|
|
||||||
return "core:" + filename;
|
|
||||||
}
|
|
||||||
throw std::runtime_error("could not to find file " + util::quote(filename));
|
throw std::runtime_error("could not to find file " + util::quote(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,14 +232,6 @@ std::vector<std::string> ResPaths::listdirRaw(const std::string& folderName) con
|
|||||||
entries.emplace_back(root.name + ":" + folderName + "/" + name);
|
entries.emplace_back(root.name + ":" + folderName + "/" + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
|
||||||
auto folder = mainRoot / fs::u8path(folderName);
|
|
||||||
if (!fs::is_directory(folder)) return entries;
|
|
||||||
for (const auto& entry : fs::directory_iterator(folder)) {
|
|
||||||
auto name = entry.path().filename().u8string();
|
|
||||||
entries.emplace_back("core:" + folderName + "/" + name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,13 +247,6 @@ std::vector<std::filesystem::path> ResPaths::listdir(
|
|||||||
entries.push_back(entry.path());
|
entries.push_back(entry.path());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
|
||||||
auto folder = mainRoot / fs::u8path(folderName);
|
|
||||||
if (!fs::is_directory(folder)) return entries;
|
|
||||||
for (const auto& entry : fs::directory_iterator(folder)) {
|
|
||||||
entries.push_back(entry.path());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,6 @@ LevelController* scripting::controller = nullptr;
|
|||||||
static void load_script(const fs::path& name, bool throwable) {
|
static void load_script(const fs::path& name, bool throwable) {
|
||||||
auto paths = scripting::engine->getPaths();
|
auto paths = scripting::engine->getPaths();
|
||||||
fs::path file = paths->getResourcesFolder() / fs::path("scripts") / name;
|
fs::path file = paths->getResourcesFolder() / fs::path("scripts") / name;
|
||||||
|
|
||||||
std::string src = files::read_string(file);
|
std::string src = files::read_string(file);
|
||||||
auto L = lua::get_main_thread();
|
auto L = lua::get_main_thread();
|
||||||
lua::loadbuffer(L, 0, src, file.u8string());
|
lua::loadbuffer(L, 0, src, file.u8string());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user