mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
chore: change all is/as castings to use typeid so no string comparison takes place
This commit is contained in:
parent
71bba11152
commit
918b80ae69
@ -197,7 +197,7 @@ void CWallpaperApplication::loadBackgrounds () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Core::CProject> CWallpaperApplication::loadBackground (const std::string& bg) {
|
std::unique_ptr<Core::CProject> CWallpaperApplication::loadBackground (const std::string& bg) {
|
||||||
const auto container = std::make_shared <CCombinedContainer> ();
|
const auto container = std::make_shared <CCombinedContainer> ();
|
||||||
|
|
||||||
this->setupContainer (container, bg);
|
this->setupContainer (container, bg);
|
||||||
|
@ -89,7 +89,7 @@ class CWallpaperApplication {
|
|||||||
* @param bg
|
* @param bg
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] std::shared_ptr<Core::CProject> loadBackground (const std::string& bg);
|
[[nodiscard]] std::unique_ptr<Core::CProject> loadBackground (const std::string& bg);
|
||||||
/**
|
/**
|
||||||
* Prepares all background's values and updates their properties if required
|
* Prepares all background's values and updates their properties if required
|
||||||
*/
|
*/
|
||||||
|
@ -17,11 +17,10 @@ using namespace WallpaperEngine::Assets;
|
|||||||
using namespace WallpaperEngine::Core::UserSettings;
|
using namespace WallpaperEngine::Core::UserSettings;
|
||||||
|
|
||||||
CObject::CObject (
|
CObject::CObject (
|
||||||
const Wallpapers::CScene* scene, const CUserSettingBoolean* visible, int id, std::string name, std::string type,
|
const Wallpapers::CScene* scene, const CUserSettingBoolean* visible, int id, std::string name,
|
||||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
||||||
std::vector<int> dependencies
|
std::vector<int> dependencies
|
||||||
) :
|
) :
|
||||||
m_type (std::move(type)),
|
|
||||||
m_visible (visible),
|
m_visible (visible),
|
||||||
m_id (id),
|
m_id (id),
|
||||||
m_name (std::move(name)),
|
m_name (std::move(name)),
|
||||||
|
@ -32,17 +32,23 @@ class CObject {
|
|||||||
static const CObject* fromJSON (const json& data, const Wallpapers::CScene* scene, const std::shared_ptr<const CContainer>& container);
|
static const CObject* fromJSON (const json& data, const Wallpapers::CScene* scene, const std::shared_ptr<const CContainer>& container);
|
||||||
|
|
||||||
template <class T> [[nodiscard]] const T* as () const {
|
template <class T> [[nodiscard]] const T* as () const {
|
||||||
assert (is<T> ());
|
if (is <T> ()) {
|
||||||
return reinterpret_cast<const T*> (this);
|
return static_cast <const T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> [[nodiscard]] T* as () {
|
template <class T> [[nodiscard]] T* as () {
|
||||||
assert (is<T> ());
|
if (is <T> ()) {
|
||||||
return reinterpret_cast<T*> (this);
|
return static_cast <T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> [[nodiscard]] bool is () const {
|
template <class T> [[nodiscard]] bool is () const {
|
||||||
return this->m_type == T::Type;
|
return typeid (*this) == typeid(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const std::vector<int>& getDependencies () const;
|
[[nodiscard]] const std::vector<int>& getDependencies () const;
|
||||||
@ -58,13 +64,13 @@ class CObject {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
CObject (
|
CObject (
|
||||||
const Wallpapers::CScene* scene, const CUserSettingBoolean* visible, int id, std::string name, std::string type,
|
const Wallpapers::CScene* scene, const CUserSettingBoolean* visible, int id, std::string name,
|
||||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
||||||
std::vector<int> dependencies);
|
std::vector<int> dependencies);
|
||||||
|
|
||||||
private:
|
virtual ~CObject () = default;
|
||||||
const std::string m_type;
|
|
||||||
|
|
||||||
|
private:
|
||||||
const CUserSettingBoolean* m_visible;
|
const CUserSettingBoolean* m_visible;
|
||||||
int m_id;
|
int m_id;
|
||||||
const std::string m_name;
|
const std::string m_name;
|
||||||
|
@ -34,7 +34,7 @@ CProject::~CProject () {
|
|||||||
this->m_properties.clear ();
|
this->m_properties.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CProject> CProject::fromFile (const std::string& filename, std::shared_ptr<const CContainer> container) {
|
std::unique_ptr<CProject> CProject::fromFile (const std::string& filename, std::shared_ptr<const CContainer> container) {
|
||||||
json content = json::parse (container->readFileAsString (filename));
|
json content = json::parse (container->readFileAsString (filename));
|
||||||
|
|
||||||
const auto dependency = jsonFindDefault<std::string> (content, "dependency", "No dependency");
|
const auto dependency = jsonFindDefault<std::string> (content, "dependency", "No dependency");
|
||||||
@ -71,7 +71,7 @@ std::shared_ptr<CProject> CProject::fromFile (const std::string& filename, std::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CProject> project = std::make_shared <CProject> (
|
std::unique_ptr<CProject> project = std::make_unique <CProject> (
|
||||||
jsonFindRequired <std::string> (content, "title", "Project title missing"),
|
jsonFindRequired <std::string> (content, "title", "Project title missing"),
|
||||||
type,
|
type,
|
||||||
jsonFindDefault <std::string> (content, "workshopid", std::to_string (backgroundId--)),
|
jsonFindDefault <std::string> (content, "workshopid", std::to_string (backgroundId--)),
|
||||||
|
@ -26,7 +26,7 @@ class CProject {
|
|||||||
bool supportsaudioprocessing, const std::map<std::string, Projects::CProperty*>& properties);
|
bool supportsaudioprocessing, const std::map<std::string, Projects::CProperty*>& properties);
|
||||||
~CProject();
|
~CProject();
|
||||||
|
|
||||||
static std::shared_ptr<CProject> fromFile (const std::string& filename, std::shared_ptr<const CContainer> container);
|
static std::unique_ptr<CProject> fromFile (const std::string& filename, std::shared_ptr<const CContainer> container);
|
||||||
|
|
||||||
[[nodiscard]] const CWallpaper* getWallpaper () const;
|
[[nodiscard]] const CWallpaper* getWallpaper () const;
|
||||||
[[nodiscard]] const std::string& getTitle () const;
|
[[nodiscard]] const std::string& getTitle () const;
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core;
|
using namespace WallpaperEngine::Core;
|
||||||
|
|
||||||
CWallpaper::CWallpaper (std::string type, const CProject& project) :
|
CWallpaper::CWallpaper (const CProject& project) :
|
||||||
m_project (project),
|
m_project (project) {}
|
||||||
m_type (std::move(type)) {}
|
|
||||||
|
|
||||||
const CProject& CWallpaper::getProject () const {
|
const CProject& CWallpaper::getProject () const {
|
||||||
return this->m_project;
|
return this->m_project;
|
||||||
|
@ -10,30 +10,35 @@ class CProject;
|
|||||||
|
|
||||||
class CWallpaper {
|
class CWallpaper {
|
||||||
public:
|
public:
|
||||||
template <class T> const T* as () const {
|
template <class T> [[nodiscard]] const T* as () const {
|
||||||
assert (is<T> ());
|
if (is<T> ()) {
|
||||||
return reinterpret_cast<const T*> (this);
|
return static_cast <const T*> (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> T* as () {
|
throw std::bad_cast ();
|
||||||
assert (is<T> ());
|
|
||||||
return reinterpret_cast<T*> (this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> bool is () const {
|
template <class T> [[nodiscard]] T* as () {
|
||||||
return this->m_type == T::Type;
|
if (is<T> ()) {
|
||||||
|
return static_cast <T*> (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CWallpaper (std::string type, const CProject& project);
|
throw std::bad_cast ();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T> [[nodiscard]] bool is () const {
|
||||||
|
return typeid(*this) == typeid(T);
|
||||||
|
}
|
||||||
|
|
||||||
const CProject& getProject () const;
|
const CProject& getProject () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class CProject;
|
friend class CProject;
|
||||||
|
|
||||||
|
explicit CWallpaper (const CProject& project);
|
||||||
|
virtual ~CWallpaper() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CProject& m_project;
|
const CProject& m_project;
|
||||||
|
|
||||||
const std::string m_type;
|
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core
|
} // namespace WallpaperEngine::Core
|
||||||
|
@ -18,7 +18,7 @@ CImage::CImage (
|
|||||||
const CUserSettingFloat* alpha, float brightness, uint32_t colorBlendMode, glm::vec2 parallaxDepth, bool fullscreen,
|
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
|
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)),
|
CObject (scene, visible, id, std::move(name), origin, scale, angles, std::move(dependencies)),
|
||||||
m_size (size),
|
m_size (size),
|
||||||
m_parallaxDepth (parallaxDepth),
|
m_parallaxDepth (parallaxDepth),
|
||||||
m_material (material),
|
m_material (material),
|
||||||
@ -139,5 +139,3 @@ bool CImage::isAutosize () const {
|
|||||||
const std::vector<const CEffect*>& CImage::getEffects () const {
|
const std::vector<const CEffect*>& CImage::getEffects () const {
|
||||||
return this->m_effects;
|
return this->m_effects;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CImage::Type = "image";
|
|
@ -93,11 +93,6 @@ class CImage : public CObject {
|
|||||||
bool fullscreen, bool passthrough, bool autosize, std::vector<const Objects::CEffect*> effects,
|
bool fullscreen, bool passthrough, bool autosize, std::vector<const Objects::CEffect*> effects,
|
||||||
std::vector<int> dependencies);
|
std::vector<int> dependencies);
|
||||||
|
|
||||||
/**
|
|
||||||
* Type value used to differentiate the different types of objects in a background
|
|
||||||
*/
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** The image's size */
|
/** The image's size */
|
||||||
const glm::vec2 m_size;
|
const glm::vec2 m_size;
|
||||||
|
@ -51,7 +51,7 @@ CParticle::CParticle (
|
|||||||
const std::vector<const Particles::CEmitter*>& emitters,
|
const std::vector<const Particles::CEmitter*>& emitters,
|
||||||
const std::vector<const Particles::CInitializer*>& initializers, std::vector<int> dependencies
|
const std::vector<const Particles::CInitializer*>& initializers, std::vector<int> dependencies
|
||||||
) :
|
) :
|
||||||
CObject (scene, visible, id, name, Type, origin, scale, angles, std::move(dependencies)),
|
CObject (scene, visible, id, name, origin, scale, angles, std::move(dependencies)),
|
||||||
m_starttime (starttime),
|
m_starttime (starttime),
|
||||||
m_maxcount (maxcount),
|
m_maxcount (maxcount),
|
||||||
m_controlpoints (controlpoints),
|
m_controlpoints (controlpoints),
|
||||||
@ -69,5 +69,3 @@ const std::vector<const Particles::CControlPoint*>& CParticle::getControlPoints
|
|||||||
const std::vector<const Particles::CInitializer*>& CParticle::getInitializers () const {
|
const std::vector<const Particles::CInitializer*>& CParticle::getInitializers () const {
|
||||||
return this->m_initializers;
|
return this->m_initializers;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CParticle::Type = "particle";
|
|
@ -43,11 +43,6 @@ class CParticle : public CObject {
|
|||||||
const std::vector<const Particles::CEmitter*>& emitters,
|
const std::vector<const Particles::CEmitter*>& emitters,
|
||||||
const std::vector<const Particles::CInitializer*>& initializers, std::vector<int> dependencies);
|
const std::vector<const Particles::CInitializer*>& initializers, std::vector<int> dependencies);
|
||||||
|
|
||||||
/**
|
|
||||||
* Type value used to differentiate the different types of objects in a background
|
|
||||||
*/
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** The time at which the particle system should start emitting */
|
/** The time at which the particle system should start emitting */
|
||||||
const uint32_t m_starttime;
|
const uint32_t m_starttime;
|
||||||
|
@ -11,7 +11,7 @@ CSound::CSound (
|
|||||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles, bool repeat,
|
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles, bool repeat,
|
||||||
std::vector<std::string> sounds, std::vector<int> dependencies
|
std::vector<std::string> sounds, std::vector<int> dependencies
|
||||||
) :
|
) :
|
||||||
CObject (scene, visible, id, std::move(name), Type, origin, scale, angles, std::move(dependencies)),
|
CObject (scene, visible, id, std::move(name), origin, scale, angles, std::move(dependencies)),
|
||||||
m_repeat (repeat),
|
m_repeat (repeat),
|
||||||
m_sounds (std::move(sounds)) {}
|
m_sounds (std::move(sounds)) {}
|
||||||
|
|
||||||
@ -51,5 +51,3 @@ const std::vector<std::string>& CSound::getSounds () const {
|
|||||||
bool CSound::isRepeat () const {
|
bool CSound::isRepeat () const {
|
||||||
return this->m_repeat;
|
return this->m_repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CSound::Type = "sound";
|
|
@ -39,11 +39,6 @@ class CSound : public CObject {
|
|||||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
||||||
bool repeat, std::vector<std::string> sounds, std::vector<int> dependencies);
|
bool repeat, std::vector<std::string> sounds, std::vector<int> dependencies);
|
||||||
|
|
||||||
/**
|
|
||||||
* Type value used to differentiate the different types of objects in a background
|
|
||||||
*/
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** If the sounds should repeat or not */
|
/** If the sounds should repeat or not */
|
||||||
bool m_repeat;
|
bool m_repeat;
|
||||||
|
@ -3,10 +3,3 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||||
|
|
||||||
CShaderConstant::CShaderConstant (std::string type) :
|
|
||||||
m_type (std::move(type)) {}
|
|
||||||
|
|
||||||
const std::string& CShaderConstant::getType () const {
|
|
||||||
return this->m_type;
|
|
||||||
}
|
|
||||||
|
@ -10,33 +10,31 @@ namespace WallpaperEngine::Core::Objects::Effects::Constants {
|
|||||||
*/
|
*/
|
||||||
class CShaderConstant : public DynamicValues::CDynamicValue {
|
class CShaderConstant : public DynamicValues::CDynamicValue {
|
||||||
public:
|
public:
|
||||||
explicit CShaderConstant (std::string type);
|
virtual ~CShaderConstant () = default;
|
||||||
|
|
||||||
template <class T> [[nodiscard]] const T* as () const {
|
template <class T> [[nodiscard]] const T* as () const {
|
||||||
assert (is<T> ());
|
if (is <T> ()) {
|
||||||
return reinterpret_cast<const T*> (this);
|
return static_cast <const T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> [[nodiscard]] T* as () {
|
template <class T> [[nodiscard]] T* as () {
|
||||||
assert (is<T> ());
|
if (is <T> ()) {
|
||||||
return reinterpret_cast<T*> (this);
|
return static_cast <T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> [[nodiscard]] bool is () const {
|
template <class T> [[nodiscard]] bool is () const {
|
||||||
return this->m_type == T::Type;
|
return typeid (*this) == typeid(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The type name of this constant
|
|
||||||
*/
|
|
||||||
[[nodiscard]] const std::string& getType () const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation of the constant's value
|
* @return String representation of the constant's value
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] virtual std::string toString () const = 0;
|
[[nodiscard]] virtual std::string toString () const = 0;
|
||||||
|
|
||||||
private:
|
|
||||||
const std::string m_type;
|
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||||
|
@ -2,13 +2,10 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||||
|
|
||||||
CShaderConstantFloat::CShaderConstantFloat (float value) :
|
CShaderConstantFloat::CShaderConstantFloat (float value) {
|
||||||
CShaderConstant (Type) {
|
|
||||||
this->update (value);
|
this->update (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CShaderConstantFloat::toString () const {
|
std::string CShaderConstantFloat::toString () const {
|
||||||
return std::to_string (this->getFloat ());
|
return std::to_string (this->getFloat ());
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CShaderConstantFloat::Type = "float";
|
|
@ -12,11 +12,6 @@ class CShaderConstantFloat : public CShaderConstant {
|
|||||||
public:
|
public:
|
||||||
explicit CShaderConstantFloat (float value);
|
explicit CShaderConstantFloat (float value);
|
||||||
|
|
||||||
/**
|
|
||||||
* Type string indicator
|
|
||||||
*/
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
[[nodiscard]] std::string toString () const override;
|
[[nodiscard]] std::string toString () const override;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||||
|
@ -2,13 +2,10 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||||
|
|
||||||
CShaderConstantInteger::CShaderConstantInteger (int32_t value) :
|
CShaderConstantInteger::CShaderConstantInteger (int32_t value) {
|
||||||
CShaderConstant (Type) {
|
|
||||||
this->update (value);
|
this->update (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CShaderConstantInteger::toString () const {
|
std::string CShaderConstantInteger::toString () const {
|
||||||
return std::to_string (this->getInt ());
|
return std::to_string (this->getInt ());
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CShaderConstantInteger::Type = "int";
|
|
@ -12,11 +12,6 @@ class CShaderConstantInteger : public CShaderConstant {
|
|||||||
public:
|
public:
|
||||||
explicit CShaderConstantInteger (int32_t value);
|
explicit CShaderConstantInteger (int32_t value);
|
||||||
|
|
||||||
/**
|
|
||||||
* Type string indicator
|
|
||||||
*/
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
[[nodiscard]] std::string toString () const override;
|
[[nodiscard]] std::string toString () const override;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||||
|
@ -3,13 +3,10 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||||
|
|
||||||
CShaderConstantProperty::CShaderConstantProperty (const CProperty* property) :
|
CShaderConstantProperty::CShaderConstantProperty (const CProperty* property) {
|
||||||
CShaderConstant (Type) {
|
|
||||||
property->connectOutgoing (this);
|
property->connectOutgoing (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CShaderConstantProperty::toString () const {
|
std::string CShaderConstantProperty::toString () const {
|
||||||
return "no string representation yet!";
|
return "no string representation yet!";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CShaderConstantProperty::Type = "property";
|
|
@ -15,11 +15,6 @@ class CShaderConstantProperty : public CShaderConstant {
|
|||||||
public:
|
public:
|
||||||
explicit CShaderConstantProperty (const CProperty* property);
|
explicit CShaderConstantProperty (const CProperty* property);
|
||||||
|
|
||||||
/**
|
|
||||||
* Type string indicator
|
|
||||||
*/
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
[[nodiscard]] std::string toString () const override;
|
[[nodiscard]] std::string toString () const override;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||||
|
|
||||||
CShaderConstantVector2::CShaderConstantVector2 (glm::vec2 value) :
|
CShaderConstantVector2::CShaderConstantVector2 (glm::vec2 value) {
|
||||||
CShaderConstant (Type) {
|
|
||||||
this->update (value);
|
this->update (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,5 +16,3 @@ std::string CShaderConstantVector2::toString () const {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CShaderConstantVector2::Type = "vec2";
|
|
@ -14,11 +14,6 @@ class CShaderConstantVector2 : public CShaderConstant {
|
|||||||
public:
|
public:
|
||||||
explicit CShaderConstantVector2 (glm::vec2 value);
|
explicit CShaderConstantVector2 (glm::vec2 value);
|
||||||
|
|
||||||
/**
|
|
||||||
* Type string indicator
|
|
||||||
*/
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
[[nodiscard]] std::string toString () const override;
|
[[nodiscard]] std::string toString () const override;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||||
|
|
||||||
CShaderConstantVector3::CShaderConstantVector3 (glm::vec3 value) :
|
CShaderConstantVector3::CShaderConstantVector3 (glm::vec3 value) {
|
||||||
CShaderConstant (Type) {
|
|
||||||
this->update (value);
|
this->update (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,5 +18,3 @@ std::string CShaderConstantVector3::toString () const {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CShaderConstantVector3::Type = "vec3";
|
|
@ -13,11 +13,6 @@ class CShaderConstantVector3 : public CShaderConstant {
|
|||||||
public:
|
public:
|
||||||
explicit CShaderConstantVector3 (glm::vec3 value);
|
explicit CShaderConstantVector3 (glm::vec3 value);
|
||||||
|
|
||||||
/**
|
|
||||||
* Type string indicator
|
|
||||||
*/
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
[[nodiscard]] std::string toString () const override;
|
[[nodiscard]] std::string toString () const override;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||||
|
|
||||||
CShaderConstantVector4::CShaderConstantVector4 (glm::vec4 value) :
|
CShaderConstantVector4::CShaderConstantVector4 (glm::vec4 value) {
|
||||||
CShaderConstant (Type) {
|
|
||||||
this->update (value);
|
this->update (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,5 +20,3 @@ std::string CShaderConstantVector4::toString () const {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CShaderConstantVector4::Type = "vec4";
|
|
@ -13,11 +13,6 @@ class CShaderConstantVector4 : public CShaderConstant {
|
|||||||
public:
|
public:
|
||||||
explicit CShaderConstantVector4 (glm::vec4 value);
|
explicit CShaderConstantVector4 (glm::vec4 value);
|
||||||
|
|
||||||
/**
|
|
||||||
* Type string indicator
|
|
||||||
*/
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
[[nodiscard]] std::string toString () const override;
|
[[nodiscard]] std::string toString () const override;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
} // namespace WallpaperEngine::Core::Objects::Effects::Constants
|
||||||
|
@ -13,6 +13,26 @@ class CInitializer {
|
|||||||
public:
|
public:
|
||||||
static const CInitializer* fromJSON (const json& data);
|
static const CInitializer* fromJSON (const json& data);
|
||||||
|
|
||||||
|
template <class T> [[nodiscard]] const T* as () const {
|
||||||
|
if (is <T> ()) {
|
||||||
|
return static_cast <const T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T> [[nodiscard]] T* as () {
|
||||||
|
if (is <T> ()) {
|
||||||
|
return static_cast <T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T> [[nodiscard]] bool is () const {
|
||||||
|
return typeid (*this) == typeid(T);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The name of the particle initializer, indicates what type of initialization to do
|
* @return The name of the particle initializer, indicates what type of initialization to do
|
||||||
*/
|
*/
|
||||||
@ -25,6 +45,8 @@ class CInitializer {
|
|||||||
protected:
|
protected:
|
||||||
CInitializer (uint32_t id, std::string name);
|
CInitializer (uint32_t id, std::string name);
|
||||||
|
|
||||||
|
virtual ~CInitializer() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** ID for ordering purposes */
|
/** ID for ordering purposes */
|
||||||
const uint32_t m_id;
|
const uint32_t m_id;
|
||||||
|
@ -13,15 +13,15 @@ using namespace WallpaperEngine::Core::Projects;
|
|||||||
CProperty* CProperty::fromJSON (const json& data, const std::string& name) {
|
CProperty* CProperty::fromJSON (const json& data, const std::string& name) {
|
||||||
const auto type = jsonFindRequired (data, "type", "Project properties must have the type field");
|
const auto type = jsonFindRequired (data, "type", "Project properties must have the type field");
|
||||||
|
|
||||||
if (*type == CPropertyColor::Type)
|
if (*type == "color")
|
||||||
return CPropertyColor::fromJSON (data, name);
|
return CPropertyColor::fromJSON (data, name);
|
||||||
if (*type == CPropertyBoolean::Type)
|
if (*type == "bool")
|
||||||
return CPropertyBoolean::fromJSON (data, name);
|
return CPropertyBoolean::fromJSON (data, name);
|
||||||
if (*type == CPropertySlider::Type)
|
if (*type == "slider")
|
||||||
return CPropertySlider::fromJSON (data, name);
|
return CPropertySlider::fromJSON (data, name);
|
||||||
if (*type == CPropertyCombo::Type)
|
if (*type == "combo")
|
||||||
return CPropertyCombo::fromJSON (data, name);
|
return CPropertyCombo::fromJSON (data, name);
|
||||||
if (*type == CPropertyText::Type)
|
if (*type == "text")
|
||||||
return CPropertyText::fromJSON (data, name);
|
return CPropertyText::fromJSON (data, name);
|
||||||
|
|
||||||
// show the error and ignore this property
|
// show the error and ignore this property
|
||||||
@ -31,8 +31,7 @@ CProperty* CProperty::fromJSON (const json& data, const std::string& name) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CProperty::CProperty (std::string name, std::string type, std::string text) :
|
CProperty::CProperty (std::string name, std::string text) :
|
||||||
m_type (std::move(type)),
|
|
||||||
m_name (std::move(name)),
|
m_name (std::move(name)),
|
||||||
m_text (std::move(text)) {}
|
m_text (std::move(text)) {}
|
||||||
|
|
||||||
@ -52,10 +51,6 @@ const std::string& CProperty::getName () const {
|
|||||||
return this->m_name;
|
return this->m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& CProperty::getType () const {
|
|
||||||
return this->m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& CProperty::getText () const {
|
const std::string& CProperty::getText () const {
|
||||||
return this->m_text;
|
return this->m_text;
|
||||||
}
|
}
|
@ -19,17 +19,23 @@ class CProperty : public CDynamicValue {
|
|||||||
static CProperty* fromJSON (const json& data, const std::string& name);
|
static CProperty* fromJSON (const json& data, const std::string& name);
|
||||||
|
|
||||||
template <class T> [[nodiscard]] const T* as () const {
|
template <class T> [[nodiscard]] const T* as () const {
|
||||||
assert (is<T> ());
|
if (is <T> ()) {
|
||||||
return reinterpret_cast<const T*> (this);
|
return static_cast <const T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> [[nodiscard]] T* as () {
|
template <class T> [[nodiscard]] T* as () {
|
||||||
assert (is<T> ());
|
if (is <T> ()) {
|
||||||
return reinterpret_cast<T*> (this);
|
return static_cast <T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> [[nodiscard]] bool is () const {
|
template <class T> [[nodiscard]] bool is () const {
|
||||||
return this->m_type == T::Type;
|
return typeid (*this) == typeid(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,9 +53,9 @@ class CProperty : public CDynamicValue {
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] const std::string& getName () const;
|
[[nodiscard]] const std::string& getName () const;
|
||||||
/**
|
/**
|
||||||
* @return Type of the property
|
* @return Textual type representation of this property
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] const std::string& getType () const;
|
[[nodiscard]] virtual const char* getType () const = 0;
|
||||||
/**
|
/**
|
||||||
* @return Text of the property
|
* @return Text of the property
|
||||||
*/
|
*/
|
||||||
@ -64,12 +70,10 @@ class CProperty : public CDynamicValue {
|
|||||||
protected:
|
protected:
|
||||||
void propagate () const override;
|
void propagate () const override;
|
||||||
|
|
||||||
CProperty (std::string name, std::string type, std::string text);
|
CProperty (std::string name, std::string text);
|
||||||
|
|
||||||
/** Functions to call when this property's value changes */
|
/** Functions to call when this property's value changes */
|
||||||
mutable std::vector<function_type> m_subscriptions;
|
mutable std::vector<function_type> m_subscriptions;
|
||||||
/** Type of property */
|
|
||||||
const std::string m_type;
|
|
||||||
/** Name of the property */
|
/** Name of the property */
|
||||||
const std::string m_name;
|
const std::string m_name;
|
||||||
/** Description of the property for the user */
|
/** Description of the property for the user */
|
||||||
|
@ -31,7 +31,9 @@ std::string CPropertyBoolean::dump () const {
|
|||||||
return ss.str ();
|
return ss.str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
CPropertyBoolean::CPropertyBoolean (bool value, std::string name, std::string text) :
|
const char* CPropertyBoolean::getType () const {
|
||||||
CProperty (std::move(name), Type, std::move(text)) {}
|
return "bool";
|
||||||
|
}
|
||||||
|
|
||||||
const std::string CPropertyBoolean::Type = "bool";
|
CPropertyBoolean::CPropertyBoolean (bool value, std::string name, std::string text) :
|
||||||
|
CProperty (std::move(name), std::move(text)) {}
|
||||||
|
@ -12,12 +12,9 @@ class CPropertyBoolean final : public CProperty {
|
|||||||
public:
|
public:
|
||||||
static CPropertyBoolean* fromJSON (const json& data, std::string name);
|
static CPropertyBoolean* fromJSON (const json& data, std::string name);
|
||||||
|
|
||||||
/** @inheritdoc */
|
|
||||||
[[nodiscard]] std::string dump () const override;
|
[[nodiscard]] std::string dump () const override;
|
||||||
/** @inheritdoc */
|
|
||||||
void set (const std::string& value) override;
|
void set (const std::string& value) override;
|
||||||
|
[[nodiscard]] const char* getType () const override;
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CPropertyBoolean (bool value, std::string name, std::string text);
|
CPropertyBoolean (bool value, std::string name, std::string text);
|
||||||
|
@ -45,9 +45,11 @@ std::string CPropertyColor::dump () const {
|
|||||||
return ss.str ();
|
return ss.str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
CPropertyColor::CPropertyColor (const std::string& color, std::string name, std::string text) :
|
const char* CPropertyColor::getType () const {
|
||||||
CProperty (std::move(name), Type, std::move(text)) {
|
return "color";
|
||||||
this->set (color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CPropertyColor::Type = "color";
|
CPropertyColor::CPropertyColor (const std::string& color, std::string name, std::string text) :
|
||||||
|
CProperty (std::move(name), std::move(text)) {
|
||||||
|
this->set (color);
|
||||||
|
}
|
||||||
|
@ -16,8 +16,7 @@ class CPropertyColor final : public CProperty {
|
|||||||
|
|
||||||
[[nodiscard]] std::string dump () const override;
|
[[nodiscard]] std::string dump () const override;
|
||||||
void set (const std::string& value) override;
|
void set (const std::string& value) override;
|
||||||
|
[[nodiscard]] const char* getType () const override;
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CPropertyColor (const std::string& color, std::string name, std::string text);
|
CPropertyColor (const std::string& color, std::string name, std::string text);
|
||||||
|
@ -40,7 +40,7 @@ CPropertyCombo* CPropertyCombo::fromJSON (const json& data, std::string name) {
|
|||||||
CPropertyCombo::CPropertyCombo (
|
CPropertyCombo::CPropertyCombo (
|
||||||
std::string name, std::string text, const std::string& defaultValue, std::vector<const CPropertyComboValue*> values
|
std::string name, std::string text, const std::string& defaultValue, std::vector<const CPropertyComboValue*> values
|
||||||
) :
|
) :
|
||||||
CProperty (std::move(name), Type, std::move(text)),
|
CProperty (std::move(name), std::move(text)),
|
||||||
m_values (std::move(values)) {
|
m_values (std::move(values)) {
|
||||||
this->set (defaultValue);
|
this->set (defaultValue);
|
||||||
}
|
}
|
||||||
@ -108,4 +108,6 @@ int CPropertyCombo::translateValueToIndex (const std::string& value) const {
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CPropertyCombo::Type = "combo";
|
const char* CPropertyCombo::getType () const {
|
||||||
|
return "combo";
|
||||||
|
}
|
||||||
|
@ -30,8 +30,7 @@ class CPropertyCombo final : public CProperty {
|
|||||||
[[nodiscard]] std::string dump () const override;
|
[[nodiscard]] std::string dump () const override;
|
||||||
void set (const std::string& value) override;
|
void set (const std::string& value) override;
|
||||||
int translateValueToIndex (const std::string& value) const;
|
int translateValueToIndex (const std::string& value) const;
|
||||||
|
[[nodiscard]] const char* getType () const override;
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CPropertyCombo (
|
CPropertyCombo (
|
||||||
|
@ -53,13 +53,15 @@ void CPropertySlider::set (const std::string& value) {
|
|||||||
this->update (newValue);
|
this->update (newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* CPropertySlider::getType () const {
|
||||||
|
return "slider";
|
||||||
|
}
|
||||||
|
|
||||||
CPropertySlider::CPropertySlider (float value, const std::string& name, const std::string& text, float min,
|
CPropertySlider::CPropertySlider (float value, const std::string& name, const std::string& text, float min,
|
||||||
float max, float step) :
|
float max, float step) :
|
||||||
CProperty (name, Type, text),
|
CProperty (name, text),
|
||||||
m_min (min),
|
m_min (min),
|
||||||
m_max (max),
|
m_max (max),
|
||||||
m_step (step) {
|
m_step (step) {
|
||||||
this->update (value);
|
this->update (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CPropertySlider::Type = "slider";
|
|
@ -28,8 +28,7 @@ class CPropertySlider final : public CProperty {
|
|||||||
[[nodiscard]] const float& getStep () const;
|
[[nodiscard]] const float& getStep () const;
|
||||||
[[nodiscard]] std::string dump () const override;
|
[[nodiscard]] std::string dump () const override;
|
||||||
void set (const std::string& value) override;
|
void set (const std::string& value) override;
|
||||||
|
[[nodiscard]] const char* getType () const override;
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CPropertySlider (float value, const std::string& name, const std::string& text, float min, float max, float step);
|
CPropertySlider (float value, const std::string& name, const std::string& text, float min, float max, float step);
|
||||||
|
@ -26,7 +26,9 @@ void CPropertyText::set (const std::string& value) {
|
|||||||
this->m_text = value;
|
this->m_text = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPropertyText::CPropertyText (std::string name, std::string text) :
|
const char* CPropertyText::getType () const {
|
||||||
CProperty (std::move(name), Type, std::move(text)) {}
|
return "text";
|
||||||
|
}
|
||||||
|
|
||||||
const std::string CPropertyText::Type = "text";
|
CPropertyText::CPropertyText (std::string name, std::string text) :
|
||||||
|
CProperty (std::move(name), std::move(text)) {}
|
||||||
|
@ -13,8 +13,7 @@ class CPropertyText final : public CProperty {
|
|||||||
static CPropertyText* fromJSON (const json& data, std::string name);
|
static CPropertyText* fromJSON (const json& data, std::string name);
|
||||||
[[nodiscard]] std::string dump () const override;
|
[[nodiscard]] std::string dump () const override;
|
||||||
void set (const std::string& value) override;
|
void set (const std::string& value) override;
|
||||||
|
[[nodiscard]] const char* getType () const override;
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CPropertyText (std::string name, std::string text);
|
CPropertyText (std::string name, std::string text);
|
||||||
|
@ -18,7 +18,7 @@ using namespace WallpaperEngine::Core::UserSettings;
|
|||||||
CUserSettingBoolean::CUserSettingBoolean (
|
CUserSettingBoolean::CUserSettingBoolean (
|
||||||
bool hasCondition, bool defaultValue, const Projects::CProperty* source, std::string expectedValue
|
bool hasCondition, bool defaultValue, const Projects::CProperty* source, std::string expectedValue
|
||||||
) :
|
) :
|
||||||
CUserSettingValue (Type),
|
CUserSettingValue (),
|
||||||
m_hasCondition (hasCondition),
|
m_hasCondition (hasCondition),
|
||||||
m_source (source),
|
m_source (source),
|
||||||
m_expectedValue (std::move(expectedValue)) {
|
m_expectedValue (std::move(expectedValue)) {
|
||||||
@ -91,5 +91,3 @@ const CUserSettingBoolean* CUserSettingBoolean::fromJSON (const nlohmann::json&
|
|||||||
const CUserSettingBoolean* CUserSettingBoolean::fromScalar (const bool value) {
|
const CUserSettingBoolean* CUserSettingBoolean::fromScalar (const bool value) {
|
||||||
return new CUserSettingBoolean (false, value, nullptr, "");
|
return new CUserSettingBoolean (false, value, nullptr, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CUserSettingBoolean::Type = "boolean";
|
|
@ -14,7 +14,6 @@ class CUserSettingBoolean : public CUserSettingValue {
|
|||||||
|
|
||||||
static const CUserSettingBoolean* fromJSON (const nlohmann::json& data, const CProject& project);
|
static const CUserSettingBoolean* fromJSON (const nlohmann::json& data, const CProject& project);
|
||||||
static const CUserSettingBoolean* fromScalar (bool value);
|
static const CUserSettingBoolean* fromScalar (bool value);
|
||||||
static std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CUserSettingBoolean (
|
CUserSettingBoolean (
|
||||||
|
@ -15,7 +15,7 @@ using namespace WallpaperEngine::Core::UserSettings;
|
|||||||
CUserSettingFloat::CUserSettingFloat (
|
CUserSettingFloat::CUserSettingFloat (
|
||||||
bool hasCondition, float defaultValue, const Projects::CProperty* source, std::string expectedValue
|
bool hasCondition, float defaultValue, const Projects::CProperty* source, std::string expectedValue
|
||||||
) :
|
) :
|
||||||
CUserSettingValue (Type),
|
CUserSettingValue (),
|
||||||
m_default (defaultValue),
|
m_default (defaultValue),
|
||||||
m_hasCondition (hasCondition),
|
m_hasCondition (hasCondition),
|
||||||
m_source (source),
|
m_source (source),
|
||||||
@ -85,5 +85,3 @@ const CUserSettingFloat* CUserSettingFloat::fromJSON (const nlohmann::json& data
|
|||||||
const CUserSettingFloat* CUserSettingFloat::fromScalar (const float value) {
|
const CUserSettingFloat* CUserSettingFloat::fromScalar (const float value) {
|
||||||
return new CUserSettingFloat (false, value, nullptr, "");
|
return new CUserSettingFloat (false, value, nullptr, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CUserSettingFloat::Type = "float";
|
|
@ -14,7 +14,6 @@ class CUserSettingFloat : public CUserSettingValue {
|
|||||||
|
|
||||||
static const CUserSettingFloat* fromJSON (const nlohmann::json& data, const CProject& project);
|
static const CUserSettingFloat* fromJSON (const nlohmann::json& data, const CProject& project);
|
||||||
static const CUserSettingFloat* fromScalar (float value);
|
static const CUserSettingFloat* fromScalar (float value);
|
||||||
static std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CUserSettingFloat (
|
CUserSettingFloat (
|
||||||
|
@ -3,6 +3,3 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
using namespace WallpaperEngine::Core::UserSettings;
|
using namespace WallpaperEngine::Core::UserSettings;
|
||||||
|
|
||||||
CUserSettingValue::CUserSettingValue (std::string type) :
|
|
||||||
m_type (std::move(type)) {}
|
|
@ -10,23 +10,26 @@ using namespace WallpaperEngine::Core::DynamicValues;
|
|||||||
class CUserSettingValue : public CDynamicValue {
|
class CUserSettingValue : public CDynamicValue {
|
||||||
public:
|
public:
|
||||||
template <class T> [[nodiscard]] const T* as () const {
|
template <class T> [[nodiscard]] const T* as () const {
|
||||||
assert (is<T> ());
|
if (is <T> ()) {
|
||||||
return reinterpret_cast<const T*> (this);
|
return static_cast <const T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> [[nodiscard]] T* as () {
|
template <class T> [[nodiscard]] T* as () {
|
||||||
assert (is<T> ());
|
if (is <T> ()) {
|
||||||
return reinterpret_cast<T*> (this);
|
return static_cast <T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> [[nodiscard]] bool is () const {
|
template <class T> [[nodiscard]] bool is () const {
|
||||||
return this->m_type == T::Type;
|
return typeid (*this) == typeid(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit CUserSettingValue (std::string type);
|
virtual ~CUserSettingValue() = default;
|
||||||
|
|
||||||
private:
|
|
||||||
const std::string m_type;
|
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::UserSettings
|
} // namespace WallpaperEngine::Core::UserSettings
|
||||||
|
@ -15,7 +15,7 @@ using namespace WallpaperEngine::Core::UserSettings;
|
|||||||
CUserSettingVector3::CUserSettingVector3 (
|
CUserSettingVector3::CUserSettingVector3 (
|
||||||
bool hasCondition, glm::vec3 defaultValue, const Projects::CProperty* source, std::string expectedValue
|
bool hasCondition, glm::vec3 defaultValue, const Projects::CProperty* source, std::string expectedValue
|
||||||
) :
|
) :
|
||||||
CUserSettingValue (Type),
|
CUserSettingValue (),
|
||||||
m_hasCondition (hasCondition),
|
m_hasCondition (hasCondition),
|
||||||
m_source (source),
|
m_source (source),
|
||||||
m_expectedValue (std::move(expectedValue)) {
|
m_expectedValue (std::move(expectedValue)) {
|
||||||
@ -85,5 +85,3 @@ const CUserSettingVector3* CUserSettingVector3::fromJSON (const nlohmann::json&
|
|||||||
const CUserSettingVector3* CUserSettingVector3::fromScalar (const glm::vec3 value) {
|
const CUserSettingVector3* CUserSettingVector3::fromScalar (const glm::vec3 value) {
|
||||||
return new CUserSettingVector3 (false, value, nullptr, "");
|
return new CUserSettingVector3 (false, value, nullptr, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CUserSettingVector3::Type = "color";
|
|
@ -16,7 +16,6 @@ class CUserSettingVector3 : public CUserSettingValue {
|
|||||||
|
|
||||||
static const CUserSettingVector3* fromJSON (const nlohmann::json& data, const CProject& project);
|
static const CUserSettingVector3* fromJSON (const nlohmann::json& data, const CProject& project);
|
||||||
static const CUserSettingVector3* fromScalar (glm::vec3 value);
|
static const CUserSettingVector3* fromScalar (glm::vec3 value);
|
||||||
static std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CUserSettingVector3 (
|
CUserSettingVector3 (
|
||||||
|
@ -18,7 +18,7 @@ CScene::CScene (
|
|||||||
float cameraShakeAmplitude, float cameraShakeRoughness, float cameraShakeSpeed,
|
float cameraShakeAmplitude, float cameraShakeRoughness, float cameraShakeSpeed,
|
||||||
const CUserSettingVector3* clearColor, const Scenes::CProjection* orthogonalProjection, glm::vec3 skylightColor
|
const CUserSettingVector3* clearColor, const Scenes::CProjection* orthogonalProjection, glm::vec3 skylightColor
|
||||||
) :
|
) :
|
||||||
CWallpaper (Type, project),
|
CWallpaper (project),
|
||||||
m_container (std::move(container)),
|
m_container (std::move(container)),
|
||||||
m_camera (camera),
|
m_camera (camera),
|
||||||
m_ambientColor (ambientColor),
|
m_ambientColor (ambientColor),
|
||||||
@ -167,5 +167,3 @@ const Scenes::CProjection* CScene::getOrthogonalProjection () const {
|
|||||||
const glm::vec3& CScene::getSkylightColor () const {
|
const glm::vec3& CScene::getSkylightColor () const {
|
||||||
return this->m_skylightColor;
|
return this->m_skylightColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CScene::Type = "scene";
|
|
||||||
|
@ -52,8 +52,6 @@ class CScene : public CWallpaper {
|
|||||||
float cameraShakeAmplitude, float cameraShakeRoughness, float cameraShakeSpeed,
|
float cameraShakeAmplitude, float cameraShakeRoughness, float cameraShakeSpeed,
|
||||||
const CUserSettingVector3* clearColor, const Scenes::CProjection* orthogonalProjection, glm::vec3 skylightColor);
|
const CUserSettingVector3* clearColor, const Scenes::CProjection* orthogonalProjection, glm::vec3 skylightColor);
|
||||||
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
void insertObject (const CObject* object);
|
void insertObject (const CObject* object);
|
||||||
|
|
||||||
[[nodiscard]] std::shared_ptr<const CContainer> getContainer () const;
|
[[nodiscard]] std::shared_ptr<const CContainer> getContainer () const;
|
||||||
|
@ -6,11 +6,9 @@ using namespace WallpaperEngine::Core;
|
|||||||
using namespace WallpaperEngine::Core::Wallpapers;
|
using namespace WallpaperEngine::Core::Wallpapers;
|
||||||
|
|
||||||
CVideo::CVideo (std::string filename, const CProject& project) :
|
CVideo::CVideo (std::string filename, const CProject& project) :
|
||||||
CWallpaper (Type, project),
|
CWallpaper (project),
|
||||||
m_filename (std::move(filename)) {}
|
m_filename (std::move(filename)) {}
|
||||||
|
|
||||||
const std::string& CVideo::getFilename () const {
|
const std::string& CVideo::getFilename () const {
|
||||||
return this->m_filename;
|
return this->m_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CVideo::Type = "video";
|
|
||||||
|
@ -21,7 +21,5 @@ class CVideo : public CWallpaper {
|
|||||||
friend class CWallpaper;
|
friend class CWallpaper;
|
||||||
|
|
||||||
const std::string m_filename;
|
const std::string m_filename;
|
||||||
|
|
||||||
static const std::string Type;
|
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core
|
} // namespace WallpaperEngine::Core
|
||||||
|
@ -10,7 +10,5 @@ const std::string& CWeb::getFilename () const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CWeb::CWeb (std::string filename, const CProject& project) :
|
CWeb::CWeb (std::string filename, const CProject& project) :
|
||||||
CWallpaper (Type, project),
|
CWallpaper (project),
|
||||||
m_filename (std::move(filename)) {}
|
m_filename (std::move(filename)) {}
|
||||||
|
|
||||||
const std::string CWeb::Type = "web";
|
|
||||||
|
@ -29,8 +29,6 @@ namespace WallpaperEngine::Core::Wallpapers
|
|||||||
|
|
||||||
const std::string m_filename;
|
const std::string m_filename;
|
||||||
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -6,9 +6,8 @@ using namespace WallpaperEngine;
|
|||||||
using namespace WallpaperEngine::Render;
|
using namespace WallpaperEngine::Render;
|
||||||
using namespace WallpaperEngine::Render::Wallpapers;
|
using namespace WallpaperEngine::Render::Wallpapers;
|
||||||
|
|
||||||
CObject::CObject (Wallpapers::CScene* scene, std::string type, const Core::CObject* object) :
|
CObject::CObject (Wallpapers::CScene* scene, const Core::CObject* object) :
|
||||||
Helpers::CContextAware (scene),
|
Helpers::CContextAware (scene),
|
||||||
m_type (std::move (type)),
|
|
||||||
m_scene (scene),
|
m_scene (scene),
|
||||||
m_object (object) {}
|
m_object (object) {}
|
||||||
|
|
||||||
|
@ -14,18 +14,24 @@ class CScene;
|
|||||||
namespace WallpaperEngine::Render {
|
namespace WallpaperEngine::Render {
|
||||||
class CObject : public Helpers::CContextAware {
|
class CObject : public Helpers::CContextAware {
|
||||||
public:
|
public:
|
||||||
template <class T> const T* as () const {
|
template <class T> [[nodiscard]] const T* as () const {
|
||||||
assert (is<T> ());
|
if (is <T> ()) {
|
||||||
return reinterpret_cast<const T*> (this);
|
return static_cast <const T*> (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> T* as () {
|
throw std::bad_cast ();
|
||||||
assert (is<T> ());
|
|
||||||
return reinterpret_cast<T*> (this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> bool is () {
|
template <class T> [[nodiscard]] T* as () {
|
||||||
return this->m_type == T::Type;
|
if (is <T> ()) {
|
||||||
|
return static_cast <T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T> [[nodiscard]] bool is () const {
|
||||||
|
return typeid (*this) == typeid(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void render () = 0;
|
virtual void render () = 0;
|
||||||
@ -35,12 +41,10 @@ class CObject : public Helpers::CContextAware {
|
|||||||
[[nodiscard]] int getId () const;
|
[[nodiscard]] int getId () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CObject (Wallpapers::CScene* scene, std::string type, const Core::CObject* object);
|
CObject (Wallpapers::CScene* scene, const Core::CObject* object);
|
||||||
~CObject () override = default;
|
virtual ~CObject () override = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_type;
|
|
||||||
|
|
||||||
Wallpapers::CScene* m_scene;
|
Wallpapers::CScene* m_scene;
|
||||||
const Core::CObject* m_object;
|
const Core::CObject* m_object;
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
using namespace WallpaperEngine::Render;
|
using namespace WallpaperEngine::Render;
|
||||||
|
|
||||||
CWallpaper::CWallpaper (
|
CWallpaper::CWallpaper (
|
||||||
const Core::CWallpaper* wallpaperData, std::string type, CRenderContext& context,CAudioContext& audioContext,
|
const Core::CWallpaper* wallpaperData, CRenderContext& context,CAudioContext& audioContext,
|
||||||
const CWallpaperState::TextureUVsScaling& scalingMode,
|
const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
||||||
) :
|
) :
|
||||||
@ -26,7 +26,6 @@ CWallpaper::CWallpaper (
|
|||||||
a_TexCoord (GL_NONE),
|
a_TexCoord (GL_NONE),
|
||||||
m_vaoBuffer (GL_NONE),
|
m_vaoBuffer (GL_NONE),
|
||||||
m_destFramebuffer (GL_NONE),
|
m_destFramebuffer (GL_NONE),
|
||||||
m_type (std::move (type)),
|
|
||||||
m_audioContext (audioContext),
|
m_audioContext (audioContext),
|
||||||
m_state (scalingMode, clampMode) {
|
m_state (scalingMode, clampMode) {
|
||||||
// generate the VAO to stop opengl from complaining
|
// generate the VAO to stop opengl from complaining
|
||||||
|
@ -30,21 +30,27 @@ class CContextAware;
|
|||||||
|
|
||||||
class CWallpaper : public Helpers::CContextAware {
|
class CWallpaper : public Helpers::CContextAware {
|
||||||
public:
|
public:
|
||||||
template <class T> [[nodiscard]]const T* as () const {
|
template <class T> [[nodiscard]] const T* as () const {
|
||||||
assert (is<T> ());
|
if (is <T> ()) {
|
||||||
return reinterpret_cast<const T*> (this);
|
return static_cast <const T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> [[nodiscard]] T* as () {
|
template <class T> [[nodiscard]] T* as () {
|
||||||
assert (is<T> ());
|
if (is <T> ()) {
|
||||||
return reinterpret_cast<T*> (this);
|
return static_cast <T*> (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw std::bad_cast ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> [[nodiscard]] bool is () const {
|
template <class T> [[nodiscard]] bool is () const {
|
||||||
return this->m_type == T::Type;
|
return typeid (*this) == typeid(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
~CWallpaper () override;
|
virtual ~CWallpaper () override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a render pass of the wallpaper
|
* Performs a render pass of the wallpaper
|
||||||
@ -154,7 +160,7 @@ class CWallpaper : public Helpers::CContextAware {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
CWallpaper (
|
CWallpaper (
|
||||||
const Core::CWallpaper* wallpaperData, std::string type, CRenderContext& context, CAudioContext& audioContext,
|
const Core::CWallpaper* wallpaperData, CRenderContext& context, CAudioContext& audioContext,
|
||||||
const CWallpaperState::TextureUVsScaling& scalingMode,
|
const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
||||||
|
|
||||||
@ -189,8 +195,6 @@ class CWallpaper : public Helpers::CContextAware {
|
|||||||
GLuint m_destFramebuffer;
|
GLuint m_destFramebuffer;
|
||||||
/** Setups OpenGL's shaders for this wallpaper backbuffer */
|
/** Setups OpenGL's shaders for this wallpaper backbuffer */
|
||||||
void setupShaders ();
|
void setupShaders ();
|
||||||
/** The type of background this wallpaper is */
|
|
||||||
std::string m_type;
|
|
||||||
/** List of FBOs registered for this wallpaper */
|
/** List of FBOs registered for this wallpaper */
|
||||||
std::map<std::string, std::shared_ptr<const CFBO>> m_fbos;
|
std::map<std::string, std::shared_ptr<const CFBO>> m_fbos;
|
||||||
/** Audio context that is using this wallpaper */
|
/** Audio context that is using this wallpaper */
|
||||||
|
@ -5,7 +5,7 @@ using namespace WallpaperEngine;
|
|||||||
using namespace WallpaperEngine::Render::Objects;
|
using namespace WallpaperEngine::Render::Objects;
|
||||||
|
|
||||||
CImage::CImage (Wallpapers::CScene* scene, const Core::Objects::CImage* image) :
|
CImage::CImage (Wallpapers::CScene* scene, const Core::Objects::CImage* image) :
|
||||||
Render::CObject (scene, Type, image),
|
Render::CObject (scene, image),
|
||||||
m_texture (nullptr),
|
m_texture (nullptr),
|
||||||
m_sceneSpacePosition (GL_NONE),
|
m_sceneSpacePosition (GL_NONE),
|
||||||
m_copySpacePosition (GL_NONE),
|
m_copySpacePosition (GL_NONE),
|
||||||
@ -481,5 +481,3 @@ GLuint CImage::getTexCoordCopy () const {
|
|||||||
GLuint CImage::getTexCoordPass () const {
|
GLuint CImage::getTexCoordPass () const {
|
||||||
return this->m_texcoordPass;
|
return this->m_texcoordPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CImage::Type = "image";
|
|
@ -56,8 +56,6 @@ class CImage final : public CObject {
|
|||||||
void pinpongFramebuffer (std::shared_ptr<const CFBO>* drawTo, std::shared_ptr<const ITexture>* asInput);
|
void pinpongFramebuffer (std::shared_ptr<const CFBO>* drawTo, std::shared_ptr<const ITexture>* asInput);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
void setupPasses ();
|
void setupPasses ();
|
||||||
|
|
||||||
void updateScreenSpacePosition ();
|
void updateScreenSpacePosition ();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
using namespace WallpaperEngine::Render::Objects;
|
using namespace WallpaperEngine::Render::Objects;
|
||||||
|
|
||||||
CSound::CSound (Wallpapers::CScene* scene, const Core::Objects::CSound* sound) :
|
CSound::CSound (Wallpapers::CScene* scene, const Core::Objects::CSound* sound) :
|
||||||
CObject (scene, Type, sound),
|
CObject (scene, sound),
|
||||||
m_sound (sound) {
|
m_sound (sound) {
|
||||||
if (this->getContext ().getApp ().getContext ().settings.audio.enabled)
|
if (this->getContext ().getApp ().getContext ().settings.audio.enabled)
|
||||||
this->load ();
|
this->load ();
|
||||||
@ -38,5 +38,3 @@ void CSound::load () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CSound::render () {}
|
void CSound::render () {}
|
||||||
|
|
||||||
const std::string CSound::Type = "sound";
|
|
@ -20,8 +20,6 @@ class CSound final : public CObject {
|
|||||||
void render () override;
|
void render () override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
void load ();
|
void load ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -21,7 +21,7 @@ CScene::CScene (
|
|||||||
const CWallpaperState::TextureUVsScaling& scalingMode,
|
const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
||||||
) :
|
) :
|
||||||
CWallpaper (scene, Type, context, audioContext, scalingMode, clampMode),
|
CWallpaper (scene, context, audioContext, scalingMode, clampMode),
|
||||||
m_mousePosition (),
|
m_mousePosition (),
|
||||||
m_mousePositionLast (),
|
m_mousePositionLast (),
|
||||||
m_parallaxDisplacement () {
|
m_parallaxDisplacement () {
|
||||||
@ -271,5 +271,3 @@ glm::vec2* CScene::getParallaxDisplacement () {
|
|||||||
const std::vector<CObject*>& CScene::getObjectsByRenderOrder () const {
|
const std::vector<CObject*>& CScene::getObjectsByRenderOrder () const {
|
||||||
return this->m_objectsByRenderOrder;
|
return this->m_objectsByRenderOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CScene::Type = "scene";
|
|
||||||
|
@ -38,8 +38,6 @@ class CScene final : public CWallpaper {
|
|||||||
|
|
||||||
friend class CWallpaper;
|
friend class CWallpaper;
|
||||||
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Render::CObject* createObject (const Core::CObject* object);
|
Render::CObject* createObject (const Core::CObject* object);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ CVideo::CVideo (
|
|||||||
const CWallpaperState::TextureUVsScaling& scalingMode,
|
const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
||||||
) :
|
) :
|
||||||
CWallpaper (video, Type, context, audioContext, scalingMode, clampMode),
|
CWallpaper (video, context, audioContext, scalingMode, clampMode),
|
||||||
m_mpvGl (nullptr),
|
m_mpvGl (nullptr),
|
||||||
m_paused (false),
|
m_paused (false),
|
||||||
m_width (16),
|
m_width (16),
|
||||||
@ -141,5 +141,3 @@ int CVideo::getWidth () const {
|
|||||||
int CVideo::getHeight () const {
|
int CVideo::getHeight () const {
|
||||||
return this->m_height;
|
return this->m_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CVideo::Type = "video";
|
|
||||||
|
@ -28,8 +28,6 @@ class CVideo final : public CWallpaper {
|
|||||||
|
|
||||||
friend class CWallpaper;
|
friend class CWallpaper;
|
||||||
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mpv_handle* m_mpv;
|
mpv_handle* m_mpv;
|
||||||
mpv_render_context* m_mpvGl;
|
mpv_render_context* m_mpvGl;
|
||||||
|
@ -15,7 +15,7 @@ CWeb::CWeb (
|
|||||||
CWebBrowserContext& browserContext, const CWallpaperState::TextureUVsScaling& scalingMode,
|
CWebBrowserContext& browserContext, const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
||||||
) :
|
) :
|
||||||
CWallpaper (web, Type, context, audioContext, scalingMode, clampMode),
|
CWallpaper (web, context, audioContext, scalingMode, clampMode),
|
||||||
m_browserContext (browserContext),
|
m_browserContext (browserContext),
|
||||||
m_browser (),
|
m_browser (),
|
||||||
m_client (),
|
m_client (),
|
||||||
@ -122,5 +122,3 @@ CWeb::~CWeb () {
|
|||||||
|
|
||||||
delete this->m_renderHandler;
|
delete this->m_renderHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string CWeb::Type = "web";
|
|
@ -45,8 +45,6 @@ class CWeb : public CWallpaper
|
|||||||
|
|
||||||
friend class CWallpaper;
|
friend class CWallpaper;
|
||||||
|
|
||||||
static const std::string Type;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WallpaperEngine::WebBrowser::CWebBrowserContext& m_browserContext;
|
WallpaperEngine::WebBrowser::CWebBrowserContext& m_browserContext;
|
||||||
CefRefPtr<CefBrowser> m_browser;
|
CefRefPtr<CefBrowser> m_browser;
|
||||||
|
Loading…
Reference in New Issue
Block a user