mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-13 21:02:34 +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);
|
||||
|
||||
if (!effectVisible->processValue (scene->getProject ()->getProperties ()))
|
||||
if (!effectVisible->processValue (scene->getProject ().getProperties ()))
|
||||
continue;
|
||||
|
||||
object->insertEffect (
|
||||
@ -146,12 +146,12 @@ CObject* CObject::fromJSON (json data, CScene* scene, const CContainer& containe
|
||||
|
||||
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
|
||||
{
|
||||
return this->m_scale->processValue (this->getScene ()->getProject ()->getProperties ());
|
||||
return this->m_scale->processValue (this->getScene ()->getProject ().getProperties ());
|
||||
}
|
||||
|
||||
const glm::vec3& CObject::getAngles () const
|
||||
@ -177,7 +177,7 @@ const std::vector<uint32_t>& CObject::getDependencies () const
|
||||
bool CObject::isVisible () const
|
||||
{
|
||||
// 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
|
||||
|
@ -9,13 +9,11 @@
|
||||
using namespace WallpaperEngine::Core;
|
||||
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_type (std::move (type)),
|
||||
m_wallpaper (wallpaper),
|
||||
m_container (container)
|
||||
{
|
||||
this->m_wallpaper->setProject (this);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
CProject* project = new CProject (title, type, container);
|
||||
|
||||
if (type == "scene")
|
||||
{
|
||||
wallpaper = CScene::fromFile (file, container);
|
||||
}
|
||||
wallpaper = CScene::fromFile (file, *project, container);
|
||||
else if (type == "video")
|
||||
{
|
||||
wallpaper = new CVideo (file.c_str ());
|
||||
}
|
||||
wallpaper = new CVideo (file.c_str (), *project);
|
||||
else if (type == "web")
|
||||
sLog.exception ("Web wallpapers are not supported yet");
|
||||
else
|
||||
sLog.exception ("Unsupported wallpaper type: ", type);
|
||||
|
||||
CProject* project = new CProject (
|
||||
title,
|
||||
type,
|
||||
wallpaper,
|
||||
container
|
||||
);
|
||||
project->setWallpaper (wallpaper);
|
||||
|
||||
if (general != content.end ())
|
||||
{
|
||||
@ -69,6 +60,11 @@ CProject* CProject::fromFile (const std::string& filename, CContainer& container
|
||||
return project;
|
||||
}
|
||||
|
||||
void CProject::setWallpaper (CWallpaper* wallpaper)
|
||||
{
|
||||
this->m_wallpaper = wallpaper;
|
||||
}
|
||||
|
||||
CWallpaper* CProject::getWallpaper () const
|
||||
{
|
||||
return this->m_wallpaper;
|
||||
|
@ -27,8 +27,9 @@ namespace WallpaperEngine::Core
|
||||
CContainer& getContainer ();
|
||||
|
||||
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);
|
||||
private:
|
||||
std::vector<Projects::CProperty*> m_properties;
|
||||
|
@ -9,6 +9,7 @@
|
||||
using namespace WallpaperEngine::Core;
|
||||
|
||||
CScene::CScene (
|
||||
CProject& project,
|
||||
CContainer& container,
|
||||
Scenes::CCamera* camera,
|
||||
glm::vec3 ambientColor,
|
||||
@ -28,7 +29,7 @@ CScene::CScene (
|
||||
CUserSettingVector3* clearColor,
|
||||
Scenes::CProjection* orthogonalProjection,
|
||||
glm::vec3 skylightColor) :
|
||||
CWallpaper (Type),
|
||||
CWallpaper (Type, project),
|
||||
m_container (container),
|
||||
m_camera (camera),
|
||||
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);
|
||||
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");
|
||||
|
||||
CScene* scene = new CScene (
|
||||
container,
|
||||
Scenes::CCamera::fromJSON (*camera_it),
|
||||
WallpaperEngine::Core::aToColorf(ambientcolor),
|
||||
bloom,
|
||||
bloomstrength,
|
||||
bloomthreshold,
|
||||
camerafade,
|
||||
cameraparallax,
|
||||
cameraparallaxamount,
|
||||
cameraparallaxdelay,
|
||||
cameraparallaxmouseinfluence,
|
||||
camerapreview,
|
||||
camerashake,
|
||||
camerashakeamplitude,
|
||||
camerashakeroughness,
|
||||
camerashakespeed,
|
||||
clearcolor,
|
||||
Scenes::CProjection::fromJSON (*orthogonalprojection_it),
|
||||
WallpaperEngine::Core::aToColorf(skylightcolor)
|
||||
project,
|
||||
container,
|
||||
Scenes::CCamera::fromJSON (*camera_it),
|
||||
WallpaperEngine::Core::aToColorf(ambientcolor),
|
||||
bloom,
|
||||
bloomstrength,
|
||||
bloomthreshold,
|
||||
camerafade,
|
||||
cameraparallax,
|
||||
cameraparallaxamount,
|
||||
cameraparallaxdelay,
|
||||
cameraparallaxmouseinfluence,
|
||||
camerapreview,
|
||||
camerashake,
|
||||
camerashakeamplitude,
|
||||
camerashakeroughness,
|
||||
camerashakespeed,
|
||||
clearcolor,
|
||||
Scenes::CProjection::fromJSON (*orthogonalprojection_it),
|
||||
WallpaperEngine::Core::aToColorf(skylightcolor)
|
||||
);
|
||||
|
||||
for (const auto& cur : *objects_it)
|
||||
@ -143,17 +145,17 @@ const glm::vec3 &CScene::getAmbientColor() 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
|
||||
{
|
||||
return this->m_bloomStrength->processValue (this->getProject ()->getProperties ());
|
||||
return this->m_bloomStrength->processValue (this->getProject ().getProperties ());
|
||||
}
|
||||
|
||||
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
|
||||
@ -208,7 +210,7 @@ const double CScene::getCameraShakeSpeed () 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
|
||||
|
@ -17,7 +17,7 @@ namespace WallpaperEngine::Core
|
||||
class CScene : public CWallpaper
|
||||
{
|
||||
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::vector<CObject*>& getObjectsByRenderOrder () const;
|
||||
@ -45,6 +45,7 @@ namespace WallpaperEngine::Core
|
||||
friend class CWallpaper;
|
||||
|
||||
CScene (
|
||||
CProject& project,
|
||||
CContainer& container,
|
||||
Scenes::CCamera* camera,
|
||||
glm::vec3 ambientColor,
|
||||
|
@ -4,10 +4,9 @@
|
||||
|
||||
using namespace WallpaperEngine::Core;
|
||||
|
||||
CVideo::CVideo (
|
||||
std::string filename) :
|
||||
CWallpaper (Type),
|
||||
m_filename (std::move(filename))
|
||||
CVideo::CVideo (std::string filename, CProject& project) :
|
||||
CWallpaper (Type, project),
|
||||
m_filename (std::move(filename))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace WallpaperEngine::Core
|
||||
class CVideo : public CWallpaper
|
||||
{
|
||||
public:
|
||||
explicit CVideo (std::string filename);
|
||||
explicit CVideo (std::string filename, CProject& project);
|
||||
|
||||
const std::string& getFilename ();
|
||||
|
||||
|
@ -4,18 +4,13 @@
|
||||
|
||||
using namespace WallpaperEngine::Core;
|
||||
|
||||
CWallpaper::CWallpaper (std::string type) :
|
||||
CWallpaper::CWallpaper (std::string type, CProject& project) :
|
||||
m_type (std::move(type)),
|
||||
m_project (nullptr)
|
||||
m_project (project)
|
||||
{
|
||||
}
|
||||
|
||||
CProject* CWallpaper::getProject () const
|
||||
CProject& CWallpaper::getProject () const
|
||||
{
|
||||
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; }
|
||||
|
||||
CWallpaper (std::string type);
|
||||
CWallpaper (std::string type, CProject& project);
|
||||
|
||||
CProject* getProject () const;
|
||||
CProject& getProject () const;
|
||||
|
||||
protected:
|
||||
friend class CProject;
|
||||
|
||||
void setProject (CProject* project);
|
||||
|
||||
private:
|
||||
CProject* m_project;
|
||||
CProject& m_project;
|
||||
|
||||
std::string m_type;
|
||||
};
|
||||
|
@ -247,7 +247,7 @@ const std::vector<Effects::CFBO*>& CEffect::getFbos () 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)
|
||||
|
@ -101,12 +101,12 @@ const std::string& CImage::getAlignment () 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
|
||||
{
|
||||
return this->m_color->processValue (this->getScene ()->getProject ()->getProperties ());
|
||||
return this->m_color->processValue (this->getScene ()->getProject ().getProperties ());
|
||||
}
|
||||
|
||||
float CImage::getBrightness () const
|
||||
|
Loading…
Reference in New Issue
Block a user