cleanup EnginePaths
This commit is contained in:
parent
3486cbd4c9
commit
4d1a2b3764
@ -7,7 +7,6 @@
|
||||
#include "debug/Logger.hpp"
|
||||
#include "assets/AssetsLoader.hpp"
|
||||
#include "audio/audio.hpp"
|
||||
#include "voxels/Block.hpp"
|
||||
#include "coders/GLSLExtension.hpp"
|
||||
#include "coders/imageio.hpp"
|
||||
#include "coders/json.hpp"
|
||||
@ -30,7 +29,6 @@
|
||||
#include "logic/scripting/scripting.hpp"
|
||||
#include "logic/scripting/scripting_hud.hpp"
|
||||
#include "network/Network.hpp"
|
||||
#include "util/listutil.hpp"
|
||||
#include "util/platform.hpp"
|
||||
#include "window/Camera.hpp"
|
||||
#include "window/input.hpp"
|
||||
@ -90,8 +88,6 @@ void Engine::initialize(CoreParameters coreParameters) {
|
||||
}
|
||||
loadSettings();
|
||||
|
||||
auto resdir = paths.getResourcesFolder();
|
||||
|
||||
controller = std::make_unique<EngineController>(*this);
|
||||
if (!params.headless) {
|
||||
std::string title = "VoxelCore v" +
|
||||
@ -153,7 +149,7 @@ void Engine::initialize(CoreParameters coreParameters) {
|
||||
}
|
||||
|
||||
void Engine::loadSettings() {
|
||||
io::path settings_file = paths.getSettingsFile();
|
||||
io::path settings_file = EnginePaths::SETTINGS_FILE;
|
||||
if (io::is_regular_file(settings_file)) {
|
||||
logger.info() << "loading settings";
|
||||
std::string text = io::read_string(settings_file);
|
||||
@ -167,7 +163,7 @@ void Engine::loadSettings() {
|
||||
}
|
||||
|
||||
void Engine::loadControls() {
|
||||
io::path controls_file = paths.getControlsFile();
|
||||
io::path controls_file = EnginePaths::CONTROLS_FILE;
|
||||
if (io::is_regular_file(controls_file)) {
|
||||
logger.info() << "loading controls";
|
||||
std::string text = io::read_string(controls_file);
|
||||
@ -240,10 +236,10 @@ void Engine::renderFrame() {
|
||||
|
||||
void Engine::saveSettings() {
|
||||
logger.info() << "saving settings";
|
||||
io::write_string(paths.getSettingsFile(), toml::stringify(*settingsHandler));
|
||||
io::write_string(EnginePaths::SETTINGS_FILE, toml::stringify(*settingsHandler));
|
||||
if (!params.headless) {
|
||||
logger.info() << "saving bindings";
|
||||
io::write_string(paths.getControlsFile(), input->getBindings().write());
|
||||
io::write_string(EnginePaths::CONTROLS_FILE, input->getBindings().write());
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,11 +304,9 @@ void Engine::loadAssets() {
|
||||
}
|
||||
}
|
||||
assets = std::move(new_assets);
|
||||
|
||||
if (content) {
|
||||
ModelsGenerator::prepare(*content, *assets);
|
||||
}
|
||||
|
||||
assets->setup();
|
||||
gui->onAssetsLoad(assets.get());
|
||||
}
|
||||
|
||||
@ -31,13 +31,9 @@ namespace fs = std::filesystem;
|
||||
|
||||
static debug::Logger logger("engine-paths");
|
||||
|
||||
static inline io::path SCREENSHOTS_FOLDER = "screenshots";
|
||||
static inline io::path CONTENT_FOLDER = "content";
|
||||
static inline io::path WORLDS_FOLDER = "worlds";
|
||||
static inline io::path CONFIG_FOLDER = "config";
|
||||
static inline io::path EXPORT_FOLDER = "export";
|
||||
static inline io::path CONTROLS_FILE = "controls.toml";
|
||||
static inline io::path SETTINGS_FILE = "settings.toml";
|
||||
static inline io::path SCREENSHOTS_FOLDER = "user:screenshots";
|
||||
static inline io::path CONTENT_FOLDER = "user:content";
|
||||
static inline io::path WORLDS_FOLDER = "user:worlds";
|
||||
|
||||
void EnginePaths::prepare() {
|
||||
io::set_device("res", std::make_shared<io::StdfsDevice>(resourcesFolder, false));
|
||||
@ -51,14 +47,13 @@ void EnginePaths::prepare() {
|
||||
logger.info() << "resources folder: " << fs::canonical(resourcesFolder).u8string();
|
||||
logger.info() << "user files folder: " << fs::canonical(userFilesFolder).u8string();
|
||||
|
||||
auto contentFolder = io::path("user:") / CONTENT_FOLDER;
|
||||
if (!io::is_directory(contentFolder)) {
|
||||
io::create_directories(contentFolder);
|
||||
if (!io::is_directory(CONTENT_FOLDER)) {
|
||||
io::create_directories(CONTENT_FOLDER);
|
||||
}
|
||||
|
||||
io::create_subdevice("core", "res", "");
|
||||
io::create_subdevice("export", "user", EXPORT_FOLDER);
|
||||
io::create_subdevice("config", "user", CONFIG_FOLDER);
|
||||
io::create_subdevice("export", "user", "export");
|
||||
io::create_subdevice("config", "user", "config");
|
||||
}
|
||||
|
||||
const std::filesystem::path& EnginePaths::getUserFilesFolder() const {
|
||||
@ -70,7 +65,7 @@ const std::filesystem::path& EnginePaths::getResourcesFolder() const {
|
||||
}
|
||||
|
||||
io::path EnginePaths::getNewScreenshotFile(const std::string& ext) {
|
||||
auto folder = io::path("user:") / SCREENSHOTS_FOLDER;
|
||||
auto folder = SCREENSHOTS_FOLDER;
|
||||
if (!io::is_directory(folder)) {
|
||||
io::create_directories(folder);
|
||||
}
|
||||
@ -94,11 +89,7 @@ io::path EnginePaths::getNewScreenshotFile(const std::string& ext) {
|
||||
}
|
||||
|
||||
io::path EnginePaths::getWorldsFolder() const {
|
||||
return io::path("user:") / WORLDS_FOLDER;
|
||||
}
|
||||
|
||||
io::path EnginePaths::getConfigFolder() const {
|
||||
return io::path("user:") / CONFIG_FOLDER;
|
||||
return WORLDS_FOLDER;
|
||||
}
|
||||
|
||||
io::path EnginePaths::getCurrentWorldFolder() {
|
||||
@ -109,14 +100,6 @@ io::path EnginePaths::getWorldFolderByName(const std::string& name) {
|
||||
return getWorldsFolder() / name;
|
||||
}
|
||||
|
||||
io::path EnginePaths::getControlsFile() const {
|
||||
return io::path("user:") / CONTROLS_FILE;
|
||||
}
|
||||
|
||||
io::path EnginePaths::getSettingsFile() const {
|
||||
return io::path("user:") / SETTINGS_FILE;
|
||||
}
|
||||
|
||||
std::vector<io::path> EnginePaths::scanForWorlds() const {
|
||||
std::vector<io::path> folders;
|
||||
|
||||
|
||||
@ -58,14 +58,10 @@ public:
|
||||
|
||||
io::path getWorldFolderByName(const std::string& name);
|
||||
io::path getWorldsFolder() const;
|
||||
io::path getConfigFolder() const;
|
||||
|
||||
void setCurrentWorldFolder(io::path folder);
|
||||
io::path getCurrentWorldFolder();
|
||||
|
||||
io::path getNewScreenshotFile(const std::string& ext);
|
||||
io::path getControlsFile() const;
|
||||
io::path getSettingsFile() const;
|
||||
|
||||
std::string mount(const io::path& file);
|
||||
void unmount(const std::string& name);
|
||||
@ -79,6 +75,8 @@ public:
|
||||
static std::tuple<std::string, std::string> parsePath(std::string_view view);
|
||||
|
||||
static inline io::path CONFIG_DEFAULTS = "config/defaults.toml";
|
||||
static inline io::path CONTROLS_FILE = "user:controls.toml";
|
||||
static inline io::path SETTINGS_FILE = "user:settings.toml";
|
||||
private:
|
||||
std::filesystem::path userFilesFolder {"."};
|
||||
std::filesystem::path resourcesFolder {"res"};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user