From 38a68d156db2127f9841643f86a2833ab1bab0ed Mon Sep 17 00:00:00 2001 From: David Pires <79417054+Dacops@users.noreply.github.com> Date: Sun, 17 Dec 2023 17:29:04 +0000 Subject: [PATCH] feat(engine): import from ~/old in bridge samples --- .../include/cubos/engine/assets/bridges/json.hpp | 14 ++------------ engine/samples/assets/json/main.cpp | 6 +++--- engine/samples/assets/saving/main.cpp | 4 ++-- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/engine/include/cubos/engine/assets/bridges/json.hpp b/engine/include/cubos/engine/assets/bridges/json.hpp index 69397aec6d..be67d97ce3 100644 --- a/engine/include/cubos/engine/assets/bridges/json.hpp +++ b/engine/include/cubos/engine/assets/bridges/json.hpp @@ -46,11 +46,6 @@ namespace cubos::engine // Deserialize the asset and store it in the asset manager. T data{}; deserializer.read(data); - if (deserializer.failed()) - { - CUBOS_ERROR("Could not deserialize asset from JSON file"); - return false; - } assets.store(handle, std::move(data)); return true; @@ -63,16 +58,11 @@ namespace cubos::engine // Read the asset from the asset manager and serialize it to the file stream. auto data = assets.read(handle); - serializer.write(*data, nullptr); // JSON serializer does not use names. - if (serializer.failed()) - { - CUBOS_ERROR("Could not serialize asset to JSON file"); - return false; - } + serializer.write(*data); // new JSONSerializer() does not receive a stream to write to, need to write to it manually auto jsonStr = serializer.output().dump(); - stream.write(jsonStr.begin(), jsonStr.size()); + stream.print(jsonStr); return true; } }; diff --git a/engine/samples/assets/json/main.cpp b/engine/samples/assets/json/main.cpp index c7e1af6d93..9e9ea6169a 100644 --- a/engine/samples/assets/json/main.cpp +++ b/engine/samples/assets/json/main.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include @@ -60,7 +60,7 @@ static void configSystem(Settings& settings) /// [Register bridge] static void bridgeSystem(Assets& assets) { - assets.registerBridge(".strings", std::make_unique>()); + assets.registerBridge(".strings", std::make_unique>()); } /// [Register bridge] @@ -89,4 +89,4 @@ int main() cubos.startupSystem(configSystem).tagged("cubos.settings"); cubos.run(); -} +} \ No newline at end of file diff --git a/engine/samples/assets/saving/main.cpp b/engine/samples/assets/saving/main.cpp index 54510aff3a..fd318841d1 100644 --- a/engine/samples/assets/saving/main.cpp +++ b/engine/samples/assets/saving/main.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -58,7 +58,7 @@ static void configSystem(Settings& settings) static void bridgeSystem(Assets& assets) { - assets.registerBridge(".int", std::make_unique>()); + assets.registerBridge(".int", std::make_unique>()); } /// [Create a new asset]