mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
fix: angles can be an user setting too, also added detection for animation frames to show a warning
This commit is contained in:
parent
c3d969ecf8
commit
499c7490eb
@ -18,7 +18,8 @@ using namespace WallpaperEngine::Core::UserSettings;
|
||||
|
||||
CObject::CObject (
|
||||
const Wallpapers::CScene* scene, const CUserSettingBoolean* visible, int id, std::string name, std::string type,
|
||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, glm::vec3 angles, std::vector<int> dependencies
|
||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
||||
std::vector<int> dependencies
|
||||
) :
|
||||
m_type (std::move(type)),
|
||||
m_visible (visible),
|
||||
@ -37,7 +38,7 @@ const CObject* CObject::fromJSON (
|
||||
const auto visible = jsonFindUserConfig<CUserSettingBoolean> (data, scene->getProject(), "visible", true);
|
||||
const auto origin = jsonFindUserConfig<CUserSettingVector3> (data, scene->getProject(), "origin", {0, 0, 0});
|
||||
const auto scale = jsonFindUserConfig<CUserSettingVector3> (data, scene->getProject(), "scale", {1, 1, 1});
|
||||
const auto angles_val = jsonFindDefault<glm::vec3> (data, "angles", glm::vec3 (0, 0, 0));
|
||||
const auto angles_val = jsonFindUserConfig<CUserSettingVector3> (data, scene->getProject(), "angles", glm::vec3 (0, 0, 0));
|
||||
const auto name = jsonFindRequired <std::string> (data, "name", "Objects must have name");
|
||||
const auto effects_it = data.find ("effects");
|
||||
const auto dependencies_it = data.find ("dependencies");
|
||||
@ -66,7 +67,7 @@ const CObject* CObject::fromJSON (
|
||||
/// TODO: XXXHACK -- TO REMOVE WHEN PARTICLE SUPPORT IS PROPERLY IMPLEMENTED
|
||||
try {
|
||||
object = Objects::CParticle::fromFile (
|
||||
scene, particle_it->get<std::string> (), container, visible, id, name, origin, scale, dependencies);
|
||||
scene, particle_it->get<std::string> (), container, visible, id, name, origin, angles_val, scale, dependencies);
|
||||
} catch (std::runtime_error&) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -92,7 +93,7 @@ const glm::vec3& CObject::getScale () const {
|
||||
}
|
||||
|
||||
const glm::vec3& CObject::getAngles () const {
|
||||
return this->m_angles;
|
||||
return this->m_angles->getVec3 ();
|
||||
}
|
||||
|
||||
const std::string& CObject::getName () const {
|
||||
|
@ -31,17 +31,17 @@ class CObject {
|
||||
public:
|
||||
static const CObject* fromJSON (const json& data, const Wallpapers::CScene* scene, const CContainer* container);
|
||||
|
||||
template <class T> const T* as () const {
|
||||
template <class T> [[nodiscard]] const T* as () const {
|
||||
assert (is<T> ());
|
||||
return reinterpret_cast<const T*> (this);
|
||||
}
|
||||
|
||||
template <class T> T* as () {
|
||||
template <class T> [[nodiscard]] T* as () {
|
||||
assert (is<T> ());
|
||||
return reinterpret_cast<T*> (this);
|
||||
}
|
||||
|
||||
template <class T> bool is () const {
|
||||
template <class T> [[nodiscard]] bool is () const {
|
||||
return this->m_type == T::Type;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class CObject {
|
||||
protected:
|
||||
CObject (
|
||||
const Wallpapers::CScene* scene, const CUserSettingBoolean* visible, int id, std::string name, std::string type,
|
||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, glm::vec3 angles,
|
||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
||||
std::vector<int> dependencies);
|
||||
|
||||
private:
|
||||
@ -70,7 +70,7 @@ class CObject {
|
||||
const std::string m_name;
|
||||
const CUserSettingVector3* m_origin;
|
||||
const CUserSettingVector3* m_scale;
|
||||
const glm::vec3 m_angles;
|
||||
const CUserSettingVector3* m_angles;
|
||||
|
||||
const std::vector<int> m_dependencies;
|
||||
|
||||
|
@ -13,10 +13,10 @@ using namespace WallpaperEngine::Core::UserSettings;
|
||||
|
||||
CImage::CImage (
|
||||
const Wallpapers::CScene* scene, const Images::CMaterial* material, const CUserSettingBoolean* visible, int id,
|
||||
std::string name, const CUserSettingVector3* origin, const CUserSettingVector3* scale, glm::vec3 angles,
|
||||
glm::vec2 size, std::string alignment, const CUserSettingVector3* color, const CUserSettingFloat* alpha,
|
||||
float brightness, uint32_t colorBlendMode, glm::vec2 parallaxDepth, bool fullscreen, bool passthrough,
|
||||
bool autosize, std::vector<const Objects::CEffect*> effects, std::vector<int> dependencies
|
||||
std::string name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
||||
const CUserSettingVector3* angles, glm::vec2 size, std::string alignment, const CUserSettingVector3* color,
|
||||
const CUserSettingFloat* alpha, float brightness, uint32_t colorBlendMode, glm::vec2 parallaxDepth, bool fullscreen,
|
||||
bool passthrough, bool autosize, std::vector<const Objects::CEffect*> effects, std::vector<int> dependencies
|
||||
) :
|
||||
CObject (scene, visible, id, std::move(name), Type, origin, scale, angles, std::move(dependencies)),
|
||||
m_size (size),
|
||||
@ -35,7 +35,7 @@ CImage::CImage (
|
||||
const WallpaperEngine::Core::CObject* CImage::fromJSON (
|
||||
const Wallpapers::CScene* scene, const json& data, const CContainer* container,
|
||||
const CUserSettingBoolean* visible, int id, std::string name, const CUserSettingVector3* origin,
|
||||
const CUserSettingVector3* scale, glm::vec3 angles, const json::const_iterator& effects_it,
|
||||
const CUserSettingVector3* scale, const CUserSettingVector3* angles, const json::const_iterator& effects_it,
|
||||
std::vector<int> dependencies
|
||||
) {
|
||||
const auto image = jsonFindRequired <std::string>(data, "image", "Image must have an image");
|
||||
|
@ -30,7 +30,7 @@ class CImage : public CObject {
|
||||
static const CObject* fromJSON (
|
||||
const Wallpapers::CScene* scene, const json& data, const CContainer* container,
|
||||
const CUserSettingBoolean* visible, int id, std::string name, const CUserSettingVector3* origin,
|
||||
const CUserSettingVector3* scale, glm::vec3 angles, const json::const_iterator& effects_it,
|
||||
const CUserSettingVector3* scale, const CUserSettingVector3* angles, const json::const_iterator& effects_it,
|
||||
std::vector<int> dependencies);
|
||||
|
||||
/**
|
||||
@ -85,10 +85,11 @@ class CImage : public CObject {
|
||||
protected:
|
||||
CImage (
|
||||
const Wallpapers::CScene* scene, const Images::CMaterial* material, const CUserSettingBoolean* visible, int id,
|
||||
std::string name, const CUserSettingVector3* origin, const CUserSettingVector3* scale, glm::vec3 angles,
|
||||
glm::vec2 size, std::string alignment, const CUserSettingVector3* color, const CUserSettingFloat* alpha,
|
||||
float brightness, uint32_t colorBlendMode, glm::vec2 parallaxDepth, bool fullscreen, bool passthrough,
|
||||
bool autosize, std::vector<const Objects::CEffect*> effects, std::vector<int> dependencies);
|
||||
std::string name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
||||
const CUserSettingVector3* angles, glm::vec2 size, std::string alignment, const CUserSettingVector3* color,
|
||||
const CUserSettingFloat* alpha, float brightness, uint32_t colorBlendMode, glm::vec2 parallaxDepth,
|
||||
bool fullscreen, bool passthrough, bool autosize, std::vector<const Objects::CEffect*> effects,
|
||||
std::vector<int> dependencies);
|
||||
|
||||
/**
|
||||
* Type value used to differentiate the different types of objects in a background
|
||||
|
@ -7,7 +7,7 @@ using namespace WallpaperEngine::Core::Objects;
|
||||
const CParticle* CParticle::fromFile (
|
||||
const Wallpapers::CScene* scene, const std::string& filename, const CContainer* container,
|
||||
const CUserSettingBoolean* visible, int id, const std::string& name, const CUserSettingVector3* origin,
|
||||
const CUserSettingVector3* scale, std::vector<int> dependencies
|
||||
const CUserSettingVector3* angles, const CUserSettingVector3* scale, std::vector<int> dependencies
|
||||
) {
|
||||
json data = json::parse (container->readFileAsString (filename));
|
||||
const auto controlpoint_it = data.find ("controlpoint");
|
||||
@ -36,6 +36,7 @@ const CParticle* CParticle::fromFile (
|
||||
name,
|
||||
origin,
|
||||
scale,
|
||||
angles,
|
||||
controlpoints,
|
||||
emitters,
|
||||
initializers,
|
||||
@ -46,11 +47,11 @@ const CParticle* CParticle::fromFile (
|
||||
CParticle::CParticle (
|
||||
const Wallpapers::CScene* scene, uint32_t starttime, uint32_t maxcount, const CUserSettingBoolean* visible, int id,
|
||||
const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
||||
const std::vector<const Particles::CControlPoint*>& controlpoints,
|
||||
const CUserSettingVector3* angles, const std::vector<const Particles::CControlPoint*>& controlpoints,
|
||||
const std::vector<const Particles::CEmitter*>& emitters,
|
||||
const std::vector<const Particles::CInitializer*>& initializers, std::vector<int> dependencies
|
||||
) :
|
||||
CObject (scene, visible, id, name, Type, origin, scale, glm::vec3 (), std::move(dependencies)),
|
||||
CObject (scene, visible, id, name, Type, origin, scale, angles, std::move(dependencies)),
|
||||
m_starttime (starttime),
|
||||
m_maxcount (maxcount),
|
||||
m_controlpoints (controlpoints),
|
||||
|
@ -20,7 +20,7 @@ class CParticle : public CObject {
|
||||
static const CParticle* fromFile (
|
||||
const Wallpapers::CScene* scene, const std::string& filename, const CContainer* container,
|
||||
const CUserSettingBoolean* visible, int id, const std::string& name, const CUserSettingVector3* origin,
|
||||
const CUserSettingVector3* scale, std::vector<int> dependencies);
|
||||
const CUserSettingVector3* angles, const CUserSettingVector3* scale, std::vector<int> dependencies);
|
||||
|
||||
/**
|
||||
* @return The list of emitters for the particle system
|
||||
@ -39,7 +39,7 @@ class CParticle : public CObject {
|
||||
CParticle (
|
||||
const Wallpapers::CScene* scene, uint32_t starttime, uint32_t maxcount, const CUserSettingBoolean* visible,
|
||||
int id, const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
||||
const std::vector<const Particles::CControlPoint*>& controlpoints,
|
||||
const CUserSettingVector3* angles, const std::vector<const Particles::CControlPoint*>& controlpoints,
|
||||
const std::vector<const Particles::CEmitter*>& emitters,
|
||||
const std::vector<const Particles::CInitializer*>& initializers, std::vector<int> dependencies);
|
||||
|
||||
|
@ -8,7 +8,7 @@ using namespace WallpaperEngine::Core::Objects;
|
||||
|
||||
CSound::CSound (
|
||||
const Wallpapers::CScene* scene, const CUserSettingBoolean* visible, int id, std::string name,
|
||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, glm::vec3 angles, bool repeat,
|
||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles, bool repeat,
|
||||
std::vector<std::string> sounds, std::vector<int> dependencies
|
||||
) :
|
||||
CObject (scene, visible, id, std::move(name), Type, origin, scale, angles, std::move(dependencies)),
|
||||
@ -17,8 +17,8 @@ CSound::CSound (
|
||||
|
||||
const WallpaperEngine::Core::CObject* CSound::fromJSON (
|
||||
const Wallpapers::CScene* scene, const json& data, const CUserSettingBoolean* visible, int id,
|
||||
const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale, glm::vec3 angles,
|
||||
std::vector<int> dependencies
|
||||
const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
||||
const CUserSettingVector3* angles, std::vector<int> dependencies
|
||||
) {
|
||||
// TODO: PARSE AUDIO VOLUME
|
||||
std::vector<std::string> sounds;
|
||||
|
@ -21,8 +21,8 @@ class CSound : public CObject {
|
||||
public:
|
||||
static const CObject* fromJSON (
|
||||
const Wallpapers::CScene* scene, const json& data, const CUserSettingBoolean* visible,
|
||||
int id, const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale, glm::vec3 angles,
|
||||
std::vector<int> dependencies);
|
||||
int id, const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
||||
const CUserSettingVector3* angles, std::vector<int> dependencies);
|
||||
|
||||
/**
|
||||
* @return The list of sounds to play
|
||||
@ -36,8 +36,8 @@ class CSound : public CObject {
|
||||
protected:
|
||||
CSound (
|
||||
const Wallpapers::CScene* scene, const CUserSettingBoolean* visible, int id, std::string name,
|
||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, glm::vec3 angles, bool repeat,
|
||||
std::vector<std::string> sounds, std::vector<int> dependencies);
|
||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
||||
bool repeat, std::vector<std::string> sounds, std::vector<int> dependencies);
|
||||
|
||||
/**
|
||||
* Type value used to differentiate the different types of objects in a background
|
||||
|
@ -47,6 +47,7 @@ const CUserSettingBoolean* CUserSettingBoolean::fromJSON (const nlohmann::json&
|
||||
std::string expectedValue;
|
||||
|
||||
if (data.is_object ()) {
|
||||
auto animation = data.find ("animation");
|
||||
auto userIt = data.find ("user");
|
||||
defaultValue = jsonFindDefault (data, "value", true); // is this default value right?
|
||||
|
||||
@ -73,6 +74,10 @@ const CUserSettingBoolean* CUserSettingBoolean::fromJSON (const nlohmann::json&
|
||||
} else {
|
||||
sLog.error ("Boolean property doesn't have user member, this could mean an scripted value");
|
||||
}
|
||||
|
||||
if (animation != data.end ()) {
|
||||
sLog.error ("Detected a setting with animation data, which is not supported yet!");
|
||||
}
|
||||
} else {
|
||||
if (!data.is_boolean ())
|
||||
sLog.error ("Expected boolean value on user setting");
|
||||
|
@ -13,7 +13,7 @@ class CUserSettingBoolean : public CUserSettingValue {
|
||||
typedef bool data_type;
|
||||
|
||||
static const CUserSettingBoolean* fromJSON (const nlohmann::json& data, const CProject& project);
|
||||
static const CUserSettingBoolean* fromScalar (const bool value);
|
||||
static const CUserSettingBoolean* fromScalar (bool value);
|
||||
static std::string Type;
|
||||
|
||||
private:
|
||||
|
@ -41,6 +41,7 @@ const CUserSettingFloat* CUserSettingFloat::fromJSON (const nlohmann::json& data
|
||||
const Projects::CProperty* sourceProperty = nullptr;
|
||||
|
||||
if (data.is_object ()) {
|
||||
auto animation = data.find ("animation");
|
||||
auto userIt = data.find ("user");
|
||||
defaultValue = jsonFindDefault (data, "value", 1.0f); // is this default value right?
|
||||
|
||||
@ -64,6 +65,10 @@ const CUserSettingFloat* CUserSettingFloat::fromJSON (const nlohmann::json& data
|
||||
if (sourceProperty == nullptr) {
|
||||
sLog.error ("Cannot find property ", source, " to get value from for user setting value, using default value: ", defaultValue);
|
||||
}
|
||||
|
||||
if (animation != data.end ()) {
|
||||
sLog.error ("Detected a setting with animation data, which is not supported yet!");
|
||||
}
|
||||
} else {
|
||||
sLog.error ("Float property doesn't have user member, this could mean an scripted value");
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class CUserSettingFloat : public CUserSettingValue {
|
||||
typedef float data_type;
|
||||
|
||||
static const CUserSettingFloat* fromJSON (const nlohmann::json& data, const CProject& project);
|
||||
static const CUserSettingFloat* fromScalar (const float value);
|
||||
static const CUserSettingFloat* fromScalar (float value);
|
||||
static std::string Type;
|
||||
|
||||
private:
|
||||
|
@ -41,6 +41,7 @@ const CUserSettingVector3* CUserSettingVector3::fromJSON (const nlohmann::json&
|
||||
std::string expectedValue;
|
||||
|
||||
if (data.is_object ()) {
|
||||
auto animation = data.find ("animation");
|
||||
auto userIt = data.find ("user");
|
||||
defaultValue = jsonFindDefault (data, "value", glm::vec3()); // is this default value right?
|
||||
|
||||
@ -67,6 +68,10 @@ const CUserSettingVector3* CUserSettingVector3::fromJSON (const nlohmann::json&
|
||||
} else {
|
||||
sLog.error ("Vector property doesn't have user member, this could mean an scripted value");
|
||||
}
|
||||
|
||||
if (animation != data.end ()) {
|
||||
sLog.error ("Detected a setting with animation data, which is not supported yet!");
|
||||
}
|
||||
} else {
|
||||
if (!data.is_string ())
|
||||
sLog.exception ("Expected vector value on user settings");
|
||||
|
@ -15,7 +15,7 @@ class CUserSettingVector3 : public CUserSettingValue {
|
||||
typedef glm::vec3 data_type;
|
||||
|
||||
static const CUserSettingVector3* fromJSON (const nlohmann::json& data, const CProject& project);
|
||||
static const CUserSettingVector3* fromScalar (const glm::vec3 value);
|
||||
static const CUserSettingVector3* fromScalar (glm::vec3 value);
|
||||
static std::string Type;
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user