diff --git a/src/inferno/application.cpp b/src/inferno/application.cpp index 3caa73f..c9beb2f 100644 --- a/src/inferno/application.cpp +++ b/src/inferno/application.cpp @@ -7,14 +7,14 @@ #include "inferno/event/event.h" #include "inferno/event/keyevent.h" #include "inferno/event/mouseevent.h" -#include "inferno/io/gltffile.h" +// #include "inferno/io/gltffile.h" #include "inferno/io/input.h" #include "inferno/io/log.h" #include "inferno/keycodes.h" #include "inferno/render/buffer.h" #include "inferno/render/context.h" #include "inferno/render/font.h" -#include "inferno/render/gltf.h" +// #include "inferno/render/gltf.h" #include "inferno/render/renderer.h" #include "inferno/render/shader.h" #include "inferno/render/texture.h" @@ -22,7 +22,6 @@ #include "inferno/settings.h" #include "inferno/time.h" #include "inferno/window.h" -#include namespace Inferno { @@ -65,7 +64,7 @@ namespace Inferno { // Gltf model = Gltf("assets/gltf/animatedmorphcube.glb"); // Gltf model = Gltf("assets/gltf/reciprocatingsaw.glb"); - Gltf model = Gltf("assets/gltf/triangle-without-indices.gltf"); + // Gltf model = Gltf("assets/gltf/triangle-without-indices.gltf"); } Application::~Application() diff --git a/src/inferno/render/gltf.cpp b/src/inferno/render/gltf.cpp index 8608f4c..c74b985 100644 --- a/src/inferno/render/gltf.cpp +++ b/src/inferno/render/gltf.cpp @@ -1,3 +1,4 @@ +#if 0 #include // std::copy #include // std::move @@ -337,3 +338,4 @@ namespace Inferno { } } // namespace Inferno +#endif diff --git a/src/inferno/render/gltf.h b/src/inferno/render/gltf.h index 32fcceb..fa622ba 100644 --- a/src/inferno/render/gltf.h +++ b/src/inferno/render/gltf.h @@ -1,6 +1,7 @@ #ifndef GLTF_H #define GLTF_H +#if 0 #include // uint32_t #include // std::shared_ptr #include // std::string @@ -166,6 +167,6 @@ namespace Inferno { }; } // namespace Inferno - +#endif #endif // GLTF_H diff --git a/src/inferno/settings.cpp b/src/inferno/settings.cpp index 63fc22a..b4e60c5 100644 --- a/src/inferno/settings.cpp +++ b/src/inferno/settings.cpp @@ -1,10 +1,11 @@ #include // uint32_t #include // std::string +#include "ruc/json/json.h" + #include "inferno/io/file.h" #include "inferno/io/log.h" #include "inferno/settings.h" -#include "inferno/util/json.h" #include "inferno/window.h" namespace Inferno { @@ -27,24 +28,22 @@ namespace Inferno { bool Settings::load() { - json object; + ruc::Json object; if (!File::ioRead(&object, m_path)) { warn() << "Settings invalid formatting, using default values"; return false; } - auto settings = Json::getPropertyValue(object, json::value_t::object); - if (settings) { - m_properties = settings.value(); - } + m_properties = object.get(); return true; } bool Settings::save() { - json object = m_properties; + ruc::Json object = m_properties; + if (!File::ioWrite(&object, m_path)) { warn() << "Settings could not be saved"; return false; @@ -54,23 +53,26 @@ namespace Inferno { return true; } -// ----------------------------------------- + // ------------------------------------- - void to_json(json& object, const SettingsProperties& settings) + void toJson(ruc::Json& object, const SettingsProperties& settings) { - object = json { + object = ruc::Json { { "window", settings.window } }; } - void from_json(const json& object, SettingsProperties& settings) + void fromJson(const ruc::Json& object, SettingsProperties& settings) { - if (Json::hasProperty(object, "window")) object.at("window").get_to(settings.window); + VERIFY(object.type() == ruc::Json::Type::Object); + + if (object.exists("window")) + object.at("window").getTo(settings.window); } - void to_json(json& object, const WindowProperties& window) + void toJson(ruc::Json& object, const WindowProperties& window) { - object = json { + object = ruc::Json { { "title", window.title }, { "width", window.width }, { "height", window.height }, @@ -79,13 +81,20 @@ namespace Inferno { }; } - void from_json(const json& object, WindowProperties& window) + void fromJson(const ruc::Json& object, WindowProperties& window) { - if (Json::hasProperty(object, "title")) object.at("title").get_to(window.title); - if (Json::hasProperty(object, "width")) object.at("width").get_to(window.width); - if (Json::hasProperty(object, "height")) object.at("height").get_to(window.height); - if (Json::hasProperty(object, "fullscreen")) object.at("fullscreen").get_to(window.fullscreen); - if (Json::hasProperty(object, "vsync")) object.at("vsync").get_to(window.vsync); + VERIFY(object.type() == ruc::Json::Type::Object); + + if (object.exists("title")) + object.at("title").getTo(window.title); + if (object.exists("width")) + object.at("width").getTo(window.width); + if (object.exists("height")) + object.at("height").getTo(window.height); + if (object.exists("fullscreen")) + object.at("fullscreen").getTo(window.fullscreen); + if (object.exists("vsync")) + object.at("vsync").getTo(window.vsync); } -} +} // namespace Inferno diff --git a/src/inferno/settings.h b/src/inferno/settings.h index d5e3c42..61cc21e 100644 --- a/src/inferno/settings.h +++ b/src/inferno/settings.h @@ -1,7 +1,8 @@ #ifndef SETTINGS_H #define SETTINGS_H -#include "inferno/util/json.h" +#include "ruc/json/json.h" + #include "inferno/window.h" namespace Inferno { @@ -27,14 +28,14 @@ namespace Inferno { // ----------------------------------------- - // nlohmann::json arbitrary type conversion functions + // Json arbitrary type conversion functions - void to_json(json& object, const SettingsProperties& settings); - void from_json(const json& object, SettingsProperties& settings); + void toJson(ruc::Json& object, const SettingsProperties& settings); + void fromJson(const ruc::Json& object, SettingsProperties& settings); - void to_json(json& object, const WindowProperties& window); - void from_json(const json& object, WindowProperties& window); + void toJson(ruc::Json& object, const WindowProperties& window); + void fromJson(const ruc::Json& object, WindowProperties& window); -} +} // namespace Inferno #endif // SETTINGS_H diff --git a/src/inferno/util/json.h b/src/inferno/util/json.h index f122042..07aa402 100644 --- a/src/inferno/util/json.h +++ b/src/inferno/util/json.h @@ -1,6 +1,7 @@ #ifndef JSON_UTIL_H #define JSON_UTIL_H +#if 0 #include // int32_t, uint32_t #include // std::optional #include // std::vector @@ -246,6 +247,7 @@ namespace Inferno { }; } // namespace Inferno +#endif #endif // JSON_UTIL_H