From 94777fc34b114ca4761788f482b5599c230d67a1 Mon Sep 17 00:00:00 2001 From: Alexis Maiquez Date: Fri, 28 Oct 2022 06:21:21 +0200 Subject: [PATCH] Added support for packages PKGV0017 Changed how some properties are loaded to provide default values Signed-off-by: Alexis Maiquez --- src/WallpaperEngine/Assets/CPackage.cpp | 1 + src/WallpaperEngine/Core/CScene.cpp | 8 ++++---- .../Core/Objects/Images/Materials/CPass.cpp | 5 +++-- src/WallpaperEngine/Core/Scenes/CProjection.cpp | 14 ++++++++++---- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/WallpaperEngine/Assets/CPackage.cpp b/src/WallpaperEngine/Assets/CPackage.cpp index b8c8b57..dcf8109 100644 --- a/src/WallpaperEngine/Assets/CPackage.cpp +++ b/src/WallpaperEngine/Assets/CPackage.cpp @@ -115,6 +115,7 @@ void CPackage::validateHeader (FILE* fp) strcmp ("PKGV0014", pointer) != 0 && strcmp ("PKGV0015", pointer) != 0 && strcmp ("PKGV0016", pointer) != 0 && + strcmp ("PKGV0017", pointer) != 0 && strcmp ("PKGV0018", pointer) != 0) { std::stringstream msg; diff --git a/src/WallpaperEngine/Core/CScene.cpp b/src/WallpaperEngine/Core/CScene.cpp index 67b97dd..15cf964 100644 --- a/src/WallpaperEngine/Core/CScene.cpp +++ b/src/WallpaperEngine/Core/CScene.cpp @@ -60,7 +60,7 @@ CScene* CScene::fromFile (const std::string& filename, CContainer* container) auto objects_it = jsonFindRequired (content, "objects", "Scenes must have a list of objects to display"); // TODO: FIND IF THESE DEFAULTS ARE SENSIBLE OR NOT AND PERFORM PROPER VALIDATION WHEN CAMERA PREVIEW AND CAMERA PARALLAX ARE PRESENT - auto ambientcolor_it = jsonFindRequired (*general_it, "ambientcolor", "General section must have ambient color"); + auto ambientcolor = jsonFindDefault (*general_it, "ambientcolor", "0 0 0"); auto bloom = jsonFindDefault (*general_it, "bloom", false); auto bloomstrength = jsonFindDefault (*general_it, "bloomstrength", 0.0f); auto bloomthreshold = jsonFindDefault (*general_it, "bloomthreshold", 0.0f); @@ -76,12 +76,12 @@ CScene* CScene::fromFile (const std::string& filename, CContainer* container) auto camerashakespeed = jsonFindDefault (*general_it, "camerashakespeed", 0.0f); auto clearcolor_it = jsonFindRequired (*general_it, "clearcolor", "General section must have clear color"); auto orthogonalprojection_it = jsonFindRequired (*general_it, "orthogonalprojection", "General section must have orthogonal projection info"); - auto skylightcolor_it = jsonFindRequired (*general_it, "skylightcolor", "General section must have skylight color"); + auto skylightcolor = jsonFindDefault (*general_it, "skylightcolor", "0 0 0"); CScene* scene = new CScene ( container, Scenes::CCamera::fromJSON (*camera_it), - WallpaperEngine::Core::aToColorf(*ambientcolor_it), + WallpaperEngine::Core::aToColorf(ambientcolor), bloom, bloomstrength, bloomthreshold, @@ -97,7 +97,7 @@ CScene* CScene::fromFile (const std::string& filename, CContainer* container) camerashakespeed, WallpaperEngine::Core::aToColorf(*clearcolor_it), Scenes::CProjection::fromJSON (*orthogonalprojection_it), - WallpaperEngine::Core::aToColorf(*skylightcolor_it) + WallpaperEngine::Core::aToColorf(skylightcolor) ); auto cur = (*objects_it).begin (); diff --git a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp b/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp index dce2b5d..1065ce1 100644 --- a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp +++ b/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp @@ -14,7 +14,8 @@ CPass::CPass (std::string blending, std::string cullmode, std::string depthtest, CPass* CPass::fromJSON (json data) { - auto blending_it = jsonFindRequired (data, "blending", "Material pass must have blending specified"); + // TODO: FIGURE OUT DEFAULT BLENDING MODE + auto blending = jsonFindDefault (data, "blending", "normal"); auto cullmode_it = jsonFindRequired (data, "cullmode", "Material pass must have cullmode specified"); auto depthtest_it = jsonFindRequired (data, "depthtest", "Material pass must have depthtest specified"); auto depthwrite_it = jsonFindRequired (data, "depthwrite", "Material pass must have depthwrite specified"); @@ -32,7 +33,7 @@ CPass* CPass::fromJSON (json data) } CPass* pass = new CPass ( - *blending_it, + blending, *cullmode_it, *depthtest_it, *depthwrite_it, diff --git a/src/WallpaperEngine/Core/Scenes/CProjection.cpp b/src/WallpaperEngine/Core/Scenes/CProjection.cpp index 3c315d7..183e4d0 100644 --- a/src/WallpaperEngine/Core/Scenes/CProjection.cpp +++ b/src/WallpaperEngine/Core/Scenes/CProjection.cpp @@ -20,11 +20,17 @@ const uint32_t& CProjection::getHeight () const CProjection* CProjection::fromJSON (json data) { + auto auto_it = jsonFindDefault (data, "auto", false); + auto width_it = jsonFindRequired (data, "width", "Projection must have width"); auto height_it = jsonFindRequired (data, "height", "Projection must have height"); - return new CProjection ( - *width_it, - *height_it - ); + // TODO: PROPERLY SUPPORT AUTO-DETECTING SIZE + if (auto_it == true) + return new CProjection (1920, 1080); + else + return new CProjection ( + *width_it, + *height_it + ); } \ No newline at end of file