mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 05:12:25 +08:00
Fix crash on effects parsing
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
3d8452ee9a
commit
64d9c2e4e6
@ -128,7 +128,7 @@ CObject* CObject::fromJSON (json data, CScene* scene, const CContainer& containe
|
|||||||
{
|
{
|
||||||
auto effectVisible = jsonFindUserConfig <CUserSettingBoolean> (data, "visible", true);
|
auto effectVisible = jsonFindUserConfig <CUserSettingBoolean> (data, "visible", true);
|
||||||
|
|
||||||
if (!effectVisible->processValue (scene->getProject ()->getProperties ()))
|
if (!effectVisible->processValue (scene->getProject ().getProperties ()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
object->insertEffect (
|
object->insertEffect (
|
||||||
@ -146,12 +146,12 @@ CObject* CObject::fromJSON (json data, CScene* scene, const CContainer& containe
|
|||||||
|
|
||||||
glm::vec3 CObject::getOrigin () const
|
glm::vec3 CObject::getOrigin () const
|
||||||
{
|
{
|
||||||
return this->m_origin->processValue (this->getScene ()->getProject ()->getProperties ());
|
return this->m_origin->processValue (this->getScene ()->getProject ().getProperties ());
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 CObject::getScale () const
|
glm::vec3 CObject::getScale () const
|
||||||
{
|
{
|
||||||
return this->m_scale->processValue (this->getScene ()->getProject ()->getProperties ());
|
return this->m_scale->processValue (this->getScene ()->getProject ().getProperties ());
|
||||||
}
|
}
|
||||||
|
|
||||||
const glm::vec3& CObject::getAngles () const
|
const glm::vec3& CObject::getAngles () const
|
||||||
@ -177,7 +177,7 @@ const std::vector<uint32_t>& CObject::getDependencies () const
|
|||||||
bool CObject::isVisible () const
|
bool CObject::isVisible () const
|
||||||
{
|
{
|
||||||
// TODO: cache this
|
// TODO: cache this
|
||||||
return this->m_visible->processValue (this->getScene ()->getProject ()->getProperties ());
|
return this->m_visible->processValue (this->getScene ()->getProject ().getProperties ());
|
||||||
}
|
}
|
||||||
|
|
||||||
CScene* CObject::getScene () const
|
CScene* CObject::getScene () const
|
||||||
|
@ -9,13 +9,11 @@
|
|||||||
using namespace WallpaperEngine::Core;
|
using namespace WallpaperEngine::Core;
|
||||||
using namespace WallpaperEngine::Assets;
|
using namespace WallpaperEngine::Assets;
|
||||||
|
|
||||||
CProject::CProject (std::string title, std::string type, CWallpaper* wallpaper, CContainer& container) :
|
CProject::CProject (std::string title, std::string type, CContainer& container) :
|
||||||
m_title (std::move (title)),
|
m_title (std::move (title)),
|
||||||
m_type (std::move (type)),
|
m_type (std::move (type)),
|
||||||
m_wallpaper (wallpaper),
|
|
||||||
m_container (container)
|
m_container (container)
|
||||||
{
|
{
|
||||||
this->m_wallpaper->setProject (this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CProject* CProject::fromFile (const std::string& filename, CContainer& container)
|
CProject* CProject::fromFile (const std::string& filename, CContainer& container)
|
||||||
@ -30,25 +28,18 @@ CProject* CProject::fromFile (const std::string& filename, CContainer& container
|
|||||||
|
|
||||||
std::transform (type.begin (), type.end (), type.begin (), tolower);
|
std::transform (type.begin (), type.end (), type.begin (), tolower);
|
||||||
|
|
||||||
|
CProject* project = new CProject (title, type, container);
|
||||||
|
|
||||||
if (type == "scene")
|
if (type == "scene")
|
||||||
{
|
wallpaper = CScene::fromFile (file, *project, container);
|
||||||
wallpaper = CScene::fromFile (file, container);
|
|
||||||
}
|
|
||||||
else if (type == "video")
|
else if (type == "video")
|
||||||
{
|
wallpaper = new CVideo (file.c_str (), *project);
|
||||||
wallpaper = new CVideo (file.c_str ());
|
|
||||||
}
|
|
||||||
else if (type == "web")
|
else if (type == "web")
|
||||||
sLog.exception ("Web wallpapers are not supported yet");
|
sLog.exception ("Web wallpapers are not supported yet");
|
||||||
else
|
else
|
||||||
sLog.exception ("Unsupported wallpaper type: ", type);
|
sLog.exception ("Unsupported wallpaper type: ", type);
|
||||||
|
|
||||||
CProject* project = new CProject (
|
project->setWallpaper (wallpaper);
|
||||||
title,
|
|
||||||
type,
|
|
||||||
wallpaper,
|
|
||||||
container
|
|
||||||
);
|
|
||||||
|
|
||||||
if (general != content.end ())
|
if (general != content.end ())
|
||||||
{
|
{
|
||||||
@ -69,6 +60,11 @@ CProject* CProject::fromFile (const std::string& filename, CContainer& container
|
|||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CProject::setWallpaper (CWallpaper* wallpaper)
|
||||||
|
{
|
||||||
|
this->m_wallpaper = wallpaper;
|
||||||
|
}
|
||||||
|
|
||||||
CWallpaper* CProject::getWallpaper () const
|
CWallpaper* CProject::getWallpaper () const
|
||||||
{
|
{
|
||||||
return this->m_wallpaper;
|
return this->m_wallpaper;
|
||||||
|
@ -27,8 +27,9 @@ namespace WallpaperEngine::Core
|
|||||||
CContainer& getContainer ();
|
CContainer& getContainer ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CProject (std::string title, std::string type, CWallpaper* wallpaper, CContainer& container);
|
CProject (std::string title, std::string type, CContainer& container);
|
||||||
|
|
||||||
|
void setWallpaper (CWallpaper* wallpaper);
|
||||||
void insertProperty (Projects::CProperty* property);
|
void insertProperty (Projects::CProperty* property);
|
||||||
private:
|
private:
|
||||||
std::vector<Projects::CProperty*> m_properties;
|
std::vector<Projects::CProperty*> m_properties;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
using namespace WallpaperEngine::Core;
|
using namespace WallpaperEngine::Core;
|
||||||
|
|
||||||
CScene::CScene (
|
CScene::CScene (
|
||||||
|
CProject& project,
|
||||||
CContainer& container,
|
CContainer& container,
|
||||||
Scenes::CCamera* camera,
|
Scenes::CCamera* camera,
|
||||||
glm::vec3 ambientColor,
|
glm::vec3 ambientColor,
|
||||||
@ -28,7 +29,7 @@ CScene::CScene (
|
|||||||
CUserSettingVector3* clearColor,
|
CUserSettingVector3* clearColor,
|
||||||
Scenes::CProjection* orthogonalProjection,
|
Scenes::CProjection* orthogonalProjection,
|
||||||
glm::vec3 skylightColor) :
|
glm::vec3 skylightColor) :
|
||||||
CWallpaper (Type),
|
CWallpaper (Type, project),
|
||||||
m_container (container),
|
m_container (container),
|
||||||
m_camera (camera),
|
m_camera (camera),
|
||||||
m_ambientColor (ambientColor),
|
m_ambientColor (ambientColor),
|
||||||
@ -51,7 +52,7 @@ CScene::CScene (
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CScene* CScene::fromFile (const std::string& filename, CContainer& container)
|
CScene* CScene::fromFile (const std::string& filename, CProject& project, CContainer& container)
|
||||||
{
|
{
|
||||||
std::string stringContent = WallpaperEngine::FileSystem::loadFullFile (filename, container);
|
std::string stringContent = WallpaperEngine::FileSystem::loadFullFile (filename, container);
|
||||||
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container));
|
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename, container));
|
||||||
@ -80,25 +81,26 @@ CScene* CScene::fromFile (const std::string& filename, CContainer& container)
|
|||||||
auto skylightcolor = jsonFindDefault <std::string> (*general_it, "skylightcolor", "0 0 0");
|
auto skylightcolor = jsonFindDefault <std::string> (*general_it, "skylightcolor", "0 0 0");
|
||||||
|
|
||||||
CScene* scene = new CScene (
|
CScene* scene = new CScene (
|
||||||
container,
|
project,
|
||||||
Scenes::CCamera::fromJSON (*camera_it),
|
container,
|
||||||
WallpaperEngine::Core::aToColorf(ambientcolor),
|
Scenes::CCamera::fromJSON (*camera_it),
|
||||||
bloom,
|
WallpaperEngine::Core::aToColorf(ambientcolor),
|
||||||
bloomstrength,
|
bloom,
|
||||||
bloomthreshold,
|
bloomstrength,
|
||||||
camerafade,
|
bloomthreshold,
|
||||||
cameraparallax,
|
camerafade,
|
||||||
cameraparallaxamount,
|
cameraparallax,
|
||||||
cameraparallaxdelay,
|
cameraparallaxamount,
|
||||||
cameraparallaxmouseinfluence,
|
cameraparallaxdelay,
|
||||||
camerapreview,
|
cameraparallaxmouseinfluence,
|
||||||
camerashake,
|
camerapreview,
|
||||||
camerashakeamplitude,
|
camerashake,
|
||||||
camerashakeroughness,
|
camerashakeamplitude,
|
||||||
camerashakespeed,
|
camerashakeroughness,
|
||||||
clearcolor,
|
camerashakespeed,
|
||||||
Scenes::CProjection::fromJSON (*orthogonalprojection_it),
|
clearcolor,
|
||||||
WallpaperEngine::Core::aToColorf(skylightcolor)
|
Scenes::CProjection::fromJSON (*orthogonalprojection_it),
|
||||||
|
WallpaperEngine::Core::aToColorf(skylightcolor)
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const auto& cur : *objects_it)
|
for (const auto& cur : *objects_it)
|
||||||
@ -143,17 +145,17 @@ const glm::vec3 &CScene::getAmbientColor() const
|
|||||||
|
|
||||||
const bool CScene::isBloom () const
|
const bool CScene::isBloom () const
|
||||||
{
|
{
|
||||||
return this->m_bloom->processValue (this->getProject ()->getProperties ());
|
return this->m_bloom->processValue (this->getProject ().getProperties ());
|
||||||
}
|
}
|
||||||
|
|
||||||
double CScene::getBloomStrength () const
|
double CScene::getBloomStrength () const
|
||||||
{
|
{
|
||||||
return this->m_bloomStrength->processValue (this->getProject ()->getProperties ());
|
return this->m_bloomStrength->processValue (this->getProject ().getProperties ());
|
||||||
}
|
}
|
||||||
|
|
||||||
double CScene::getBloomThreshold () const
|
double CScene::getBloomThreshold () const
|
||||||
{
|
{
|
||||||
return this->m_bloomThreshold->processValue (this->getProject ()->getProperties ());
|
return this->m_bloomThreshold->processValue (this->getProject ().getProperties ());
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool CScene::isCameraFade () const
|
const bool CScene::isCameraFade () const
|
||||||
@ -208,7 +210,7 @@ const double CScene::getCameraShakeSpeed () const
|
|||||||
|
|
||||||
glm::vec3 CScene::getClearColor () const
|
glm::vec3 CScene::getClearColor () const
|
||||||
{
|
{
|
||||||
return this->m_clearColor->processValue (this->getProject ()->getProperties ());
|
return this->m_clearColor->processValue (this->getProject ().getProperties ());
|
||||||
}
|
}
|
||||||
|
|
||||||
Scenes::CProjection* CScene::getOrthogonalProjection () const
|
Scenes::CProjection* CScene::getOrthogonalProjection () const
|
||||||
|
@ -17,7 +17,7 @@ namespace WallpaperEngine::Core
|
|||||||
class CScene : public CWallpaper
|
class CScene : public CWallpaper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CScene* fromFile (const std::string& filename, CContainer& container);
|
static CScene* fromFile (const std::string& filename, CProject& project, CContainer& container);
|
||||||
|
|
||||||
const std::map<uint32_t, CObject*>& getObjects () const;
|
const std::map<uint32_t, CObject*>& getObjects () const;
|
||||||
const std::vector<CObject*>& getObjectsByRenderOrder () const;
|
const std::vector<CObject*>& getObjectsByRenderOrder () const;
|
||||||
@ -45,6 +45,7 @@ namespace WallpaperEngine::Core
|
|||||||
friend class CWallpaper;
|
friend class CWallpaper;
|
||||||
|
|
||||||
CScene (
|
CScene (
|
||||||
|
CProject& project,
|
||||||
CContainer& container,
|
CContainer& container,
|
||||||
Scenes::CCamera* camera,
|
Scenes::CCamera* camera,
|
||||||
glm::vec3 ambientColor,
|
glm::vec3 ambientColor,
|
||||||
|
@ -4,10 +4,9 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core;
|
using namespace WallpaperEngine::Core;
|
||||||
|
|
||||||
CVideo::CVideo (
|
CVideo::CVideo (std::string filename, CProject& project) :
|
||||||
std::string filename) :
|
CWallpaper (Type, project),
|
||||||
CWallpaper (Type),
|
m_filename (std::move(filename))
|
||||||
m_filename (std::move(filename))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace WallpaperEngine::Core
|
|||||||
class CVideo : public CWallpaper
|
class CVideo : public CWallpaper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CVideo (std::string filename);
|
explicit CVideo (std::string filename, CProject& project);
|
||||||
|
|
||||||
const std::string& getFilename ();
|
const std::string& getFilename ();
|
||||||
|
|
||||||
|
@ -4,18 +4,13 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core;
|
using namespace WallpaperEngine::Core;
|
||||||
|
|
||||||
CWallpaper::CWallpaper (std::string type) :
|
CWallpaper::CWallpaper (std::string type, CProject& project) :
|
||||||
m_type (std::move(type)),
|
m_type (std::move(type)),
|
||||||
m_project (nullptr)
|
m_project (project)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CProject* CWallpaper::getProject () const
|
CProject& CWallpaper::getProject () const
|
||||||
{
|
{
|
||||||
return this->m_project;
|
return this->m_project;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallpaper::setProject (CProject* project)
|
|
||||||
{
|
|
||||||
this->m_project = project;
|
|
||||||
}
|
|
||||||
|
@ -16,17 +16,15 @@ namespace WallpaperEngine::Core
|
|||||||
|
|
||||||
template<class T> bool is () { return this->m_type == T::Type; }
|
template<class T> bool is () { return this->m_type == T::Type; }
|
||||||
|
|
||||||
CWallpaper (std::string type);
|
CWallpaper (std::string type, CProject& project);
|
||||||
|
|
||||||
CProject* getProject () const;
|
CProject& getProject () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class CProject;
|
friend class CProject;
|
||||||
|
|
||||||
void setProject (CProject* project);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CProject* m_project;
|
CProject& m_project;
|
||||||
|
|
||||||
std::string m_type;
|
std::string m_type;
|
||||||
};
|
};
|
||||||
|
@ -247,7 +247,7 @@ const std::vector<Effects::CFBO*>& CEffect::getFbos () const
|
|||||||
|
|
||||||
bool CEffect::isVisible () const
|
bool CEffect::isVisible () const
|
||||||
{
|
{
|
||||||
return this->m_visible->processValue (this->m_object->getScene ()->getProject ()->getProperties ());
|
return this->m_visible->processValue (this->m_object->getScene ()->getProject ().getProperties ());
|
||||||
}
|
}
|
||||||
|
|
||||||
Effects::CFBO* CEffect::findFBO (const std::string& name)
|
Effects::CFBO* CEffect::findFBO (const std::string& name)
|
||||||
|
@ -101,12 +101,12 @@ const std::string& CImage::getAlignment () const
|
|||||||
|
|
||||||
float CImage::getAlpha () const
|
float CImage::getAlpha () const
|
||||||
{
|
{
|
||||||
return this->m_alpha->processValue (this->getScene ()->getProject ()->getProperties ());
|
return this->m_alpha->processValue (this->getScene ()->getProject ().getProperties ());
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 CImage::getColor () const
|
glm::vec3 CImage::getColor () const
|
||||||
{
|
{
|
||||||
return this->m_color->processValue (this->getScene ()->getProject ()->getProperties ());
|
return this->m_color->processValue (this->getScene ()->getProject ().getProperties ());
|
||||||
}
|
}
|
||||||
|
|
||||||
float CImage::getBrightness () const
|
float CImage::getBrightness () const
|
||||||
|
Loading…
Reference in New Issue
Block a user