Minor refactor
This commit is contained in:
parent
cfcfbee604
commit
abbe4021ba
@ -6,20 +6,6 @@
|
|||||||
|
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
|
||||||
#define SETTINGS_FILE "settings.toml"
|
|
||||||
#define CONTROLS_FILE "controls.json"
|
|
||||||
|
|
||||||
using std::filesystem::path;
|
|
||||||
|
|
||||||
|
|
||||||
path platform::get_settings_file() {
|
|
||||||
return path(SETTINGS_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
path platform::get_controls_file() {
|
|
||||||
return path(CONTROLS_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string platform::detect_locale() {
|
std::string platform::detect_locale() {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
std::string name = setlocale(LC_ALL, nullptr);
|
std::string name = setlocale(LC_ALL, nullptr);
|
||||||
@ -37,7 +23,9 @@ void platform::configure_encoding() {
|
|||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
setvbuf(stdout, nullptr, _IOFBF, 1000);
|
setvbuf(stdout, nullptr, _IOFBF, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void platform::configure_encoding(){
|
void platform::configure_encoding(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,12 +2,9 @@
|
|||||||
#define UTIL_PLATFORM_H_
|
#define UTIL_PLATFORM_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
namespace platform {
|
namespace platform {
|
||||||
extern void configure_encoding();
|
extern void configure_encoding();
|
||||||
extern std::filesystem::path get_settings_file();
|
|
||||||
extern std::filesystem::path get_controls_file();
|
|
||||||
extern std::string detect_locale();
|
extern std::string detect_locale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,10 @@
|
|||||||
#include "files/engine_paths.h"
|
#include "files/engine_paths.h"
|
||||||
#include "util/command_line.h"
|
#include "util/command_line.h"
|
||||||
|
|
||||||
using std::filesystem::path;
|
#define SETTINGS_FILE "settings.toml"
|
||||||
|
#define CONTROLS_FILE "controls.json"
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
EnginePaths paths;
|
EnginePaths paths;
|
||||||
@ -27,8 +30,8 @@ int main(int argc, char** argv) {
|
|||||||
EngineSettings settings;
|
EngineSettings settings;
|
||||||
std::unique_ptr<toml::Wrapper> wrapper (create_wrapper(settings));
|
std::unique_ptr<toml::Wrapper> wrapper (create_wrapper(settings));
|
||||||
|
|
||||||
path settings_file = userfiles/platform::get_settings_file();
|
fs::path settings_file = userfiles/fs::path(SETTINGS_FILE);
|
||||||
path controls_file = userfiles/platform::get_controls_file();
|
fs::path controls_file = userfiles/fs::path(CONTROLS_FILE);
|
||||||
if (std::filesystem::is_regular_file(settings_file)) {
|
if (std::filesystem::is_regular_file(settings_file)) {
|
||||||
std::cout << "-- loading settings" << std::endl;
|
std::cout << "-- loading settings" << std::endl;
|
||||||
std::string text = files::read_string(settings_file);
|
std::string text = files::read_string(settings_file);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user