Added support for packages PKGV0017

Changed how some properties are loaded to provide default values

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2022-10-28 06:21:21 +02:00
parent ab308b2c63
commit 94777fc34b
4 changed files with 18 additions and 10 deletions

View File

@ -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;

View File

@ -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 <std::string> (*general_it, "ambientcolor", "0 0 0");
auto bloom = jsonFindDefault <bool> (*general_it, "bloom", false);
auto bloomstrength = jsonFindDefault <double> (*general_it, "bloomstrength", 0.0f);
auto bloomthreshold = jsonFindDefault <double> (*general_it, "bloomthreshold", 0.0f);
@ -76,12 +76,12 @@ CScene* CScene::fromFile (const std::string& filename, CContainer* container)
auto camerashakespeed = jsonFindDefault <double> (*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 <std::string> (*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 ();

View File

@ -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 <std::string> (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,

View File

@ -20,11 +20,17 @@ const uint32_t& CProjection::getHeight () const
CProjection* CProjection::fromJSON (json data)
{
auto auto_it = jsonFindDefault <bool> (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
);
}