Browse Source

Engine: Make it compile again

master
Riyyi 2 years ago
parent
commit
2f1c6b5e75
  1. 7
      src/inferno/application.cpp
  2. 2
      src/inferno/render/gltf.cpp
  3. 3
      src/inferno/render/gltf.h
  4. 51
      src/inferno/settings.cpp
  5. 15
      src/inferno/settings.h
  6. 2
      src/inferno/util/json.h

7
src/inferno/application.cpp

@ -7,14 +7,14 @@
#include "inferno/event/event.h" #include "inferno/event/event.h"
#include "inferno/event/keyevent.h" #include "inferno/event/keyevent.h"
#include "inferno/event/mouseevent.h" #include "inferno/event/mouseevent.h"
#include "inferno/io/gltffile.h" // #include "inferno/io/gltffile.h"
#include "inferno/io/input.h" #include "inferno/io/input.h"
#include "inferno/io/log.h" #include "inferno/io/log.h"
#include "inferno/keycodes.h" #include "inferno/keycodes.h"
#include "inferno/render/buffer.h" #include "inferno/render/buffer.h"
#include "inferno/render/context.h" #include "inferno/render/context.h"
#include "inferno/render/font.h" #include "inferno/render/font.h"
#include "inferno/render/gltf.h" // #include "inferno/render/gltf.h"
#include "inferno/render/renderer.h" #include "inferno/render/renderer.h"
#include "inferno/render/shader.h" #include "inferno/render/shader.h"
#include "inferno/render/texture.h" #include "inferno/render/texture.h"
@ -22,7 +22,6 @@
#include "inferno/settings.h" #include "inferno/settings.h"
#include "inferno/time.h" #include "inferno/time.h"
#include "inferno/window.h" #include "inferno/window.h"
#include <string>
namespace Inferno { namespace Inferno {
@ -65,7 +64,7 @@ namespace Inferno {
// Gltf model = Gltf("assets/gltf/animatedmorphcube.glb"); // Gltf model = Gltf("assets/gltf/animatedmorphcube.glb");
// Gltf model = Gltf("assets/gltf/reciprocatingsaw.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() Application::~Application()

2
src/inferno/render/gltf.cpp

@ -1,3 +1,4 @@
#if 0
#include <algorithm> // std::copy #include <algorithm> // std::copy
#include <utility> // std::move #include <utility> // std::move
@ -337,3 +338,4 @@ namespace Inferno {
} }
} // namespace Inferno } // namespace Inferno
#endif

3
src/inferno/render/gltf.h

@ -1,6 +1,7 @@
#ifndef GLTF_H #ifndef GLTF_H
#define GLTF_H #define GLTF_H
#if 0
#include <cstdint> // uint32_t #include <cstdint> // uint32_t
#include <memory> // std::shared_ptr #include <memory> // std::shared_ptr
#include <string> // std::string #include <string> // std::string
@ -166,6 +167,6 @@ namespace Inferno {
}; };
} // namespace Inferno } // namespace Inferno
#endif
#endif // GLTF_H #endif // GLTF_H

51
src/inferno/settings.cpp

@ -1,10 +1,11 @@
#include <cstdint> // uint32_t #include <cstdint> // uint32_t
#include <string> // std::string #include <string> // std::string
#include "ruc/json/json.h"
#include "inferno/io/file.h" #include "inferno/io/file.h"
#include "inferno/io/log.h" #include "inferno/io/log.h"
#include "inferno/settings.h" #include "inferno/settings.h"
#include "inferno/util/json.h"
#include "inferno/window.h" #include "inferno/window.h"
namespace Inferno { namespace Inferno {
@ -27,24 +28,22 @@ namespace Inferno {
bool Settings::load() bool Settings::load()
{ {
json object; ruc::Json object;
if (!File::ioRead(&object, m_path)) { if (!File::ioRead(&object, m_path)) {
warn() << "Settings invalid formatting, using default values"; warn() << "Settings invalid formatting, using default values";
return false; return false;
} }
auto settings = Json::getPropertyValue<SettingsProperties>(object, json::value_t::object); m_properties = object.get<SettingsProperties>();
if (settings) {
m_properties = settings.value();
}
return true; return true;
} }
bool Settings::save() bool Settings::save()
{ {
json object = m_properties; ruc::Json object = m_properties;
if (!File::ioWrite(&object, m_path)) { if (!File::ioWrite(&object, m_path)) {
warn() << "Settings could not be saved"; warn() << "Settings could not be saved";
return false; return false;
@ -54,23 +53,26 @@ namespace Inferno {
return true; 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 } { "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 }, { "title", window.title },
{ "width", window.width }, { "width", window.width },
{ "height", window.height }, { "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); VERIFY(object.type() == ruc::Json::Type::Object);
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 (object.exists("title"))
if (Json::hasProperty(object, "fullscreen")) object.at("fullscreen").get_to(window.fullscreen); object.at("title").getTo(window.title);
if (Json::hasProperty(object, "vsync")) object.at("vsync").get_to(window.vsync); 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

15
src/inferno/settings.h

@ -1,7 +1,8 @@
#ifndef SETTINGS_H #ifndef SETTINGS_H
#define SETTINGS_H #define SETTINGS_H
#include "inferno/util/json.h" #include "ruc/json/json.h"
#include "inferno/window.h" #include "inferno/window.h"
namespace Inferno { 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 toJson(ruc::Json& object, const SettingsProperties& settings);
void from_json(const json& object, SettingsProperties& settings); void fromJson(const ruc::Json& object, SettingsProperties& settings);
void to_json(json& object, const WindowProperties& window); void toJson(ruc::Json& object, const WindowProperties& window);
void from_json(const json& object, WindowProperties& window); void fromJson(const ruc::Json& object, WindowProperties& window);
} } // namespace Inferno
#endif // SETTINGS_H #endif // SETTINGS_H

2
src/inferno/util/json.h

@ -1,6 +1,7 @@
#ifndef JSON_UTIL_H #ifndef JSON_UTIL_H
#define JSON_UTIL_H #define JSON_UTIL_H
#if 0
#include <cstdint> // int32_t, uint32_t #include <cstdint> // int32_t, uint32_t
#include <optional> // std::optional #include <optional> // std::optional
#include <vector> // std::vector #include <vector> // std::vector
@ -246,6 +247,7 @@ namespace Inferno {
}; };
} // namespace Inferno } // namespace Inferno
#endif
#endif // JSON_UTIL_H #endif // JSON_UTIL_H

Loading…
Cancel
Save