diff --git a/src/WallpaperEngine/Data/Model/Material.h b/src/WallpaperEngine/Data/Model/Material.h index 1b6f698..339d977 100644 --- a/src/WallpaperEngine/Data/Model/Material.h +++ b/src/WallpaperEngine/Data/Model/Material.h @@ -22,6 +22,8 @@ struct MaterialPass { std::string shader; /** List of textures defined for this pass */ TextureMap textures; + /** List of user textures defined for this pass */ + TextureMap usertextures; /** The combos and their values to pass onto the shader */ ComboMap combos; }; diff --git a/src/WallpaperEngine/Data/Model/Property.h b/src/WallpaperEngine/Data/Model/Property.h index d919e9c..de17ebf 100644 --- a/src/WallpaperEngine/Data/Model/Property.h +++ b/src/WallpaperEngine/Data/Model/Property.h @@ -135,4 +135,18 @@ class PropertyText : public Property { return this->text; } }; + +class PropertySceneTexture : public Property { + public: + explicit PropertySceneTexture (PropertyData data, std::string value) : Property (std::move(data)) { + this->update (value); + } + + void update(const std::string& value) override { + this->m_value = value; + } + + private: + std::string m_value; +}; } \ No newline at end of file diff --git a/src/WallpaperEngine/Data/Parsers/MaterialParser.cpp b/src/WallpaperEngine/Data/Parsers/MaterialParser.cpp index edc2d3f..ab9e5ea 100644 --- a/src/WallpaperEngine/Data/Parsers/MaterialParser.cpp +++ b/src/WallpaperEngine/Data/Parsers/MaterialParser.cpp @@ -35,6 +35,7 @@ std::vector MaterialParser::parsePasses (const JSON& it, MaterialPassUniquePtr MaterialParser::parsePass (const JSON& it, Project& project) { const auto textures = it.optional ("textures"); + const auto usertextures = it.optional ("usertextures"); const auto combos = it.optional ("combos"); const auto constants = it.optional ("constants"); @@ -45,8 +46,9 @@ MaterialPassUniquePtr MaterialParser::parsePass (const JSON& it, Project& projec .depthtest = it.optional ("depthtest", std::string ("disabled")), .depthwrite = it.optional ("depthwrite", std::string ("disabled")), .shader = it.require ("shader", "Material pass must have a shader"), - .textures = textures.has_value () ? parseTextures (*textures) : std::map {}, - .combos = combos.has_value () ? parseCombos (*combos) : std::map {}, + .textures = textures.has_value () ? parseTextures (*textures) : TextureMap {}, + .usertextures = usertextures.has_value () ? parseTextures (*usertextures) : TextureMap {}, + .combos = combos.has_value () ? parseCombos (*combos) : ComboMap {}, }); } diff --git a/src/WallpaperEngine/Data/Parsers/PropertyParser.cpp b/src/WallpaperEngine/Data/Parsers/PropertyParser.cpp index 93f1247..aeacae4 100644 --- a/src/WallpaperEngine/Data/Parsers/PropertyParser.cpp +++ b/src/WallpaperEngine/Data/Parsers/PropertyParser.cpp @@ -22,6 +22,9 @@ PropertySharedPtr PropertyParser::parse (const JSON& it, std::string name) { if (type == "text") { return parseText (it, name); } + if (type == "scenetexture") { + return parseSceneTexture (it, name); + } if (type != "group") { // show the error and ignore this property @@ -95,4 +98,11 @@ PropertySharedPtr PropertyParser::parseText (const JSON& it, std::string name) { .name = name, .text = it.optional ("text", ""), }); +} + +PropertySharedPtr PropertyParser::parseSceneTexture (const JSON& it, std::string name) { + return std::make_shared (PropertyData { + .name = name, + .text = it.optional ("text", ""), + }, it.require ("value", "Property must have a value")); } \ No newline at end of file diff --git a/src/WallpaperEngine/Data/Parsers/PropertyParser.h b/src/WallpaperEngine/Data/Parsers/PropertyParser.h index 5dd2e83..99383ad 100644 --- a/src/WallpaperEngine/Data/Parsers/PropertyParser.h +++ b/src/WallpaperEngine/Data/Parsers/PropertyParser.h @@ -16,5 +16,6 @@ class PropertyParser { static PropertySharedPtr parseBoolean (const JSON& it, std::string name); static PropertySharedPtr parseSlider (const JSON& it, std::string name); static PropertySharedPtr parseText (const JSON& it, std::string name); + static PropertySharedPtr parseSceneTexture (const JSON& it, std::string name); }; } \ No newline at end of file diff --git a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp b/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp index 78e8f4c..9db5623 100644 --- a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp +++ b/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp @@ -409,6 +409,7 @@ void CShaderUnit::parseParameterConfiguration ( // now convert it to integer // TODO: BETTER CONVERSION HERE size_t index = value - '0'; + // TODO: SUPPORT USER TEXTURES!! if (combo != data.end ()) { // TODO: CLEANUP HOW THIS IS DETERMINED FIRST