audio listener configuration fix
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#include "coders/GLSLExtension.h"
|
#include "coders/GLSLExtension.h"
|
||||||
#include "coders/imageio.hpp"
|
#include "coders/imageio.hpp"
|
||||||
#include "coders/json.h"
|
#include "coders/json.h"
|
||||||
|
#include "coders/toml.h"
|
||||||
#include "content/ContentLoader.h"
|
#include "content/ContentLoader.h"
|
||||||
#include "core_defs.h"
|
#include "core_defs.h"
|
||||||
#include "files/files.h"
|
#include "files/files.h"
|
||||||
@@ -41,6 +42,8 @@
|
|||||||
|
|
||||||
static debug::Logger logger("engine");
|
static debug::Logger logger("engine");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
void addWorldGenerators() {
|
void addWorldGenerators() {
|
||||||
@@ -60,6 +63,10 @@ inline void create_channel(Engine* engine, std::string name, NumberSetting& sett
|
|||||||
Engine::Engine(EngineSettings& settings, SettingsHandler& settingsHandler, EnginePaths* paths)
|
Engine::Engine(EngineSettings& settings, SettingsHandler& settingsHandler, EnginePaths* paths)
|
||||||
: settings(settings), settingsHandler(settingsHandler), paths(paths)
|
: settings(settings), settingsHandler(settingsHandler), paths(paths)
|
||||||
{
|
{
|
||||||
|
corecontent::setup_bindings();
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
|
||||||
controller = std::make_unique<EngineController>(this);
|
controller = std::make_unique<EngineController>(this);
|
||||||
if (Window::initialize(&this->settings.display)){
|
if (Window::initialize(&this->settings.display)){
|
||||||
throw initialize_error("could not initialize window");
|
throw initialize_error("could not initialize window");
|
||||||
@@ -89,6 +96,21 @@ Engine::Engine(EngineSettings& settings, SettingsHandler& settingsHandler, Engin
|
|||||||
scripting::initialize(this);
|
scripting::initialize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::loadSettings() {
|
||||||
|
fs::path settings_file = paths->getSettingsFile();
|
||||||
|
if (fs::is_regular_file(settings_file)) {
|
||||||
|
logger.info() << "loading settings";
|
||||||
|
std::string text = files::read_string(settings_file);
|
||||||
|
toml::parse(settingsHandler, settings_file.string(), text);
|
||||||
|
}
|
||||||
|
fs::path controls_file = paths->getControlsFile();
|
||||||
|
if (fs::is_regular_file(controls_file)) {
|
||||||
|
logger.info() << "loading controls";
|
||||||
|
std::string text = files::read_string(controls_file);
|
||||||
|
Events::loadBindings(controls_file.u8string(), text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Engine::onAssetsLoaded() {
|
void Engine::onAssetsLoaded() {
|
||||||
gui->onAssetsLoad(assets.get());
|
gui->onAssetsLoad(assets.get());
|
||||||
}
|
}
|
||||||
@@ -163,7 +185,14 @@ void Engine::processPostRunnables() {
|
|||||||
scripting::process_post_runnables();
|
scripting::process_post_runnables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::saveSettings() {
|
||||||
|
logger.info() << "saving settings";
|
||||||
|
files::write_string(paths->getSettingsFile(), toml::stringify(settingsHandler));
|
||||||
|
files::write_string(paths->getControlsFile(), Events::writeBindings());
|
||||||
|
}
|
||||||
|
|
||||||
Engine::~Engine() {
|
Engine::~Engine() {
|
||||||
|
saveSettings();
|
||||||
logger.info() << "shutting down";
|
logger.info() << "shutting down";
|
||||||
if (screen) {
|
if (screen) {
|
||||||
screen->onEngineShutdown();
|
screen->onEngineShutdown();
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ class Engine : public util::ObjectsKeeper {
|
|||||||
|
|
||||||
std::unique_ptr<gui::GUI> gui;
|
std::unique_ptr<gui::GUI> gui;
|
||||||
|
|
||||||
|
void loadSettings();
|
||||||
|
void saveSettings();
|
||||||
void updateTimers();
|
void updateTimers();
|
||||||
void updateHotkeys();
|
void updateHotkeys();
|
||||||
void renderFrame(Batch2D& batch);
|
void renderFrame(Batch2D& batch);
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include "WorldFiles.h"
|
#include "WorldFiles.h"
|
||||||
|
|
||||||
const fs::path SCREENSHOTS_FOLDER {"screenshots"};
|
const fs::path SCREENSHOTS_FOLDER {"screenshots"};
|
||||||
|
const fs::path CONTROLS_FILE {"controls.json"};
|
||||||
|
const fs::path SETTINGS_FILE {"settings.toml"};
|
||||||
|
|
||||||
fs::path EnginePaths::getUserfiles() const {
|
fs::path EnginePaths::getUserfiles() const {
|
||||||
return userfiles;
|
return userfiles;
|
||||||
@@ -54,6 +56,14 @@ fs::path EnginePaths::getWorldFolder(const std::string& name) {
|
|||||||
return getWorldsFolder()/fs::path(name);
|
return getWorldsFolder()/fs::path(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs::path EnginePaths::getControlsFile() {
|
||||||
|
return userfiles/fs::path(CONTROLS_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs::path EnginePaths::getSettingsFile() {
|
||||||
|
return userfiles/fs::path(SETTINGS_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<fs::path> EnginePaths::scanForWorlds() {
|
std::vector<fs::path> EnginePaths::scanForWorlds() {
|
||||||
std::vector<fs::path> folders;
|
std::vector<fs::path> folders;
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public:
|
|||||||
fs::path getWorldsFolder();
|
fs::path getWorldsFolder();
|
||||||
fs::path getWorldFolder();
|
fs::path getWorldFolder();
|
||||||
fs::path getWorldFolder(const std::string& name);
|
fs::path getWorldFolder(const std::string& name);
|
||||||
|
fs::path getControlsFile();
|
||||||
|
fs::path getSettingsFile();
|
||||||
bool isWorldNameUsed(std::string name);
|
bool isWorldNameUsed(std::string name);
|
||||||
|
|
||||||
void setUserfiles(fs::path folder);
|
void setUserfiles(fs::path folder);
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ void LevelScreen::update(float delta) {
|
|||||||
camera->position-camera->dir,
|
camera->position-camera->dir,
|
||||||
player->hitbox->velocity,
|
player->hitbox->velocity,
|
||||||
camera->dir,
|
camera->dir,
|
||||||
camera->up
|
glm::vec3(0, 1, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!hud->isPause()) {
|
if (!hud->isPause()) {
|
||||||
|
|||||||
+3
-23
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "core_defs.h"
|
#include "core_defs.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "coders/toml.h"
|
|
||||||
#include "files/files.h"
|
#include "files/files.h"
|
||||||
#include "files/settings_io.hpp"
|
#include "files/settings_io.hpp"
|
||||||
#include "files/engine_paths.h"
|
#include "files/engine_paths.h"
|
||||||
@@ -16,9 +15,6 @@
|
|||||||
#include "window/Events.h"
|
#include "window/Events.h"
|
||||||
#include "debug/Logger.hpp"
|
#include "debug/Logger.hpp"
|
||||||
|
|
||||||
inline std::string SETTINGS_FILE = "settings.toml";
|
|
||||||
inline std::string CONTROLS_FILE = "controls.json";
|
|
||||||
|
|
||||||
static debug::Logger logger("main");
|
static debug::Logger logger("main");
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
@@ -35,26 +31,10 @@ int main(int argc, char** argv) {
|
|||||||
try {
|
try {
|
||||||
EngineSettings settings;
|
EngineSettings settings;
|
||||||
SettingsHandler handler(settings);
|
SettingsHandler handler(settings);
|
||||||
|
|
||||||
fs::path settings_file = userfiles/fs::path(SETTINGS_FILE);
|
|
||||||
fs::path controls_file = userfiles/fs::path(CONTROLS_FILE);
|
|
||||||
if (fs::is_regular_file(settings_file)) {
|
|
||||||
logger.info() << "loading settings";
|
|
||||||
std::string text = files::read_string(settings_file);
|
|
||||||
toml::parse(handler, settings_file.string(), text);
|
|
||||||
}
|
|
||||||
corecontent::setup_bindings();
|
|
||||||
Engine engine(settings, handler, &paths);
|
|
||||||
if (fs::is_regular_file(controls_file)) {
|
|
||||||
logger.info() << "loading controls";
|
|
||||||
std::string text = files::read_string(controls_file);
|
|
||||||
Events::loadBindings(controls_file.string(), text);
|
|
||||||
}
|
|
||||||
engine.mainloop();
|
|
||||||
|
|
||||||
logger.info() << "saving settings";
|
Engine engine(settings, handler, &paths);
|
||||||
files::write_string(settings_file, toml::stringify(handler));
|
|
||||||
files::write_string(controls_file, Events::writeBindings());
|
engine.mainloop();
|
||||||
}
|
}
|
||||||
catch (const initialize_error& err) {
|
catch (const initialize_error& err) {
|
||||||
logger.error() << "could not to initialize engine\n" << err.what();
|
logger.error() << "could not to initialize engine\n" << err.what();
|
||||||
|
|||||||
Reference in New Issue
Block a user