mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
chore: moved more things to std::unique_ptr and std::shared_ptr
This commit is contained in:
parent
f5da9a01f6
commit
f877d2b1a7
@ -197,7 +197,7 @@ void CWallpaperApplication::loadBackgrounds () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Core::CProject> CWallpaperApplication::loadBackground (const std::string& bg) {
|
std::shared_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);
|
||||||
|
@ -72,7 +72,7 @@ class CWallpaperApplication {
|
|||||||
* @param bg
|
* @param bg
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] std::unique_ptr<Core::CProject> loadBackground (const std::string& bg);
|
[[nodiscard]] std::shared_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
|
||||||
*/
|
*/
|
||||||
|
@ -173,6 +173,10 @@ CPulseAudioPlaybackRecorder::CPulseAudioPlaybackRecorder () :
|
|||||||
}
|
}
|
||||||
|
|
||||||
CPulseAudioPlaybackRecorder::~CPulseAudioPlaybackRecorder () {
|
CPulseAudioPlaybackRecorder::~CPulseAudioPlaybackRecorder () {
|
||||||
|
if (m_captureData.captureStream) {
|
||||||
|
pa_stream_unref (m_captureData.captureStream);
|
||||||
|
}
|
||||||
|
|
||||||
delete [] this->m_captureData.audioBufferTmp;
|
delete [] this->m_captureData.audioBufferTmp;
|
||||||
delete [] this->m_captureData.audioBuffer;
|
delete [] this->m_captureData.audioBuffer;
|
||||||
free (this->m_captureData.kisscfg);
|
free (this->m_captureData.kisscfg);
|
||||||
|
@ -17,7 +17,7 @@ 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::shared_ptr <const Core::CProject> project, 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
|
||||||
) :
|
) :
|
||||||
@ -27,17 +27,17 @@ CObject::CObject (
|
|||||||
m_origin (origin),
|
m_origin (origin),
|
||||||
m_scale (scale),
|
m_scale (scale),
|
||||||
m_angles (angles),
|
m_angles (angles),
|
||||||
m_scene (scene),
|
m_project (project),
|
||||||
m_dependencies (std::move(dependencies)) {}
|
m_dependencies (std::move(dependencies)) {}
|
||||||
|
|
||||||
const CObject* CObject::fromJSON (
|
const CObject* CObject::fromJSON (
|
||||||
const json& data, const Wallpapers::CScene* scene, const std::shared_ptr<const CContainer>& container
|
const json& data, std::shared_ptr <const Core::CProject> project, const std::shared_ptr<const CContainer>& container
|
||||||
) {
|
) {
|
||||||
const auto id = jsonFindRequired <int> (data, "id", "Objects must have id");
|
const auto id = jsonFindRequired <int> (data, "id", "Objects must have id");
|
||||||
const auto visible = jsonFindUserConfig<CUserSettingBoolean> (data, scene->getProject(), "visible", true);
|
const auto visible = jsonFindUserConfig<CUserSettingBoolean> (data, *project, "visible", true);
|
||||||
const auto origin = jsonFindUserConfig<CUserSettingVector3> (data, scene->getProject(), "origin", {0, 0, 0});
|
const auto origin = jsonFindUserConfig<CUserSettingVector3> (data, *project, "origin", {0, 0, 0});
|
||||||
const auto scale = jsonFindUserConfig<CUserSettingVector3> (data, scene->getProject(), "scale", {1, 1, 1});
|
const auto scale = jsonFindUserConfig<CUserSettingVector3> (data, *project, "scale", {1, 1, 1});
|
||||||
const auto angles_val = jsonFindUserConfig<CUserSettingVector3> (data, scene->getProject(), "angles", glm::vec3 (0, 0, 0));
|
const auto angles_val = jsonFindUserConfig<CUserSettingVector3> (data, *project, "angles", glm::vec3 (0, 0, 0));
|
||||||
const auto name = jsonFindRequired <std::string> (data, "name", "Objects must have name");
|
const auto name = jsonFindRequired <std::string> (data, "name", "Objects must have name");
|
||||||
const auto effects_it = data.find ("effects");
|
const auto effects_it = data.find ("effects");
|
||||||
const auto dependencies_it = data.find ("dependencies");
|
const auto dependencies_it = data.find ("dependencies");
|
||||||
@ -59,14 +59,14 @@ const CObject* CObject::fromJSON (
|
|||||||
|
|
||||||
if (image_it != data.end () && !image_it->is_null ()) {
|
if (image_it != data.end () && !image_it->is_null ()) {
|
||||||
object = Objects::CImage::fromJSON (
|
object = Objects::CImage::fromJSON (
|
||||||
scene, data, container, visible, id, name, origin, scale, angles_val, effects_it, dependencies);
|
project, data, container, visible, id, name, origin, scale, angles_val, effects_it, dependencies);
|
||||||
} else if (sound_it != data.end () && !sound_it->is_null ()) {
|
} else if (sound_it != data.end () && !sound_it->is_null ()) {
|
||||||
object = Objects::CSound::fromJSON (scene, data, visible, id, name, origin, scale, angles_val, dependencies);
|
object = Objects::CSound::fromJSON (project, data, visible, id, name, origin, scale, angles_val, dependencies);
|
||||||
} else if (particle_it != data.end () && !particle_it->is_null ()) {
|
} else if (particle_it != data.end () && !particle_it->is_null ()) {
|
||||||
/// TODO: XXXHACK -- TO REMOVE WHEN PARTICLE SUPPORT IS PROPERLY IMPLEMENTED
|
/// TODO: XXXHACK -- TO REMOVE WHEN PARTICLE SUPPORT IS PROPERLY IMPLEMENTED
|
||||||
try {
|
try {
|
||||||
object = Objects::CParticle::fromFile (
|
object = Objects::CParticle::fromFile (
|
||||||
scene, particle_it->get<std::string> (), container, visible, id, name, origin, angles_val, scale, dependencies);
|
project, particle_it->get<std::string> (), container, visible, id, name, origin, angles_val, scale, dependencies);
|
||||||
} catch (std::runtime_error&) {
|
} catch (std::runtime_error&) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -107,8 +107,8 @@ bool CObject::isVisible () const {
|
|||||||
return this->m_visible->getBool ();
|
return this->m_visible->getBool ();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Wallpapers::CScene* CObject::getScene () const {
|
std::shared_ptr <const CProject> CObject::getProject () const {
|
||||||
return this->m_scene;
|
return this->m_project;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CObject::getId () const {
|
int CObject::getId () const {
|
||||||
|
@ -29,7 +29,8 @@ class CObject {
|
|||||||
friend class Wallpapers::CScene;
|
friend class Wallpapers::CScene;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
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, std::shared_ptr <const Core::CProject> project,
|
||||||
|
const std::shared_ptr<const CContainer>& container);
|
||||||
|
|
||||||
template <class T> [[nodiscard]] const T* as () const {
|
template <class T> [[nodiscard]] const T* as () const {
|
||||||
if (is <T> ()) {
|
if (is <T> ()) {
|
||||||
@ -60,11 +61,11 @@ class CObject {
|
|||||||
[[nodiscard]] const std::string& getName () const;
|
[[nodiscard]] const std::string& getName () const;
|
||||||
|
|
||||||
[[nodiscard]] bool isVisible () const;
|
[[nodiscard]] bool isVisible () const;
|
||||||
[[nodiscard]] const Wallpapers::CScene* getScene () const;
|
[[nodiscard]] std::shared_ptr <const Core::CProject> getProject () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CObject (
|
CObject (
|
||||||
const Wallpapers::CScene* scene, const CUserSettingBoolean* visible, int id, std::string name,
|
std::shared_ptr <const Core::CProject> 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);
|
||||||
|
|
||||||
@ -80,6 +81,6 @@ class CObject {
|
|||||||
|
|
||||||
const std::vector<int> m_dependencies;
|
const std::vector<int> m_dependencies;
|
||||||
|
|
||||||
const Wallpapers::CScene* m_scene;
|
const std::shared_ptr <const Core::CProject> m_project;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core
|
} // namespace WallpaperEngine::Core
|
||||||
|
@ -16,7 +16,7 @@ static int backgroundId = -1;
|
|||||||
|
|
||||||
CProject::CProject (
|
CProject::CProject (
|
||||||
std::string title, std::string type, std::string workshopid, std::shared_ptr<const CContainer> container,
|
std::string title, std::string type, std::string workshopid, std::shared_ptr<const CContainer> container,
|
||||||
bool supportsaudioprocessing, const std::map<std::string, Projects::CProperty*>& properties
|
bool supportsaudioprocessing, const std::map<std::string, std::shared_ptr<Projects::CProperty>>& properties
|
||||||
) :
|
) :
|
||||||
m_workshopid(std::move(workshopid)),
|
m_workshopid(std::move(workshopid)),
|
||||||
m_title (std::move(title)),
|
m_title (std::move(title)),
|
||||||
@ -26,15 +26,7 @@ CProject::CProject (
|
|||||||
m_properties (properties),
|
m_properties (properties),
|
||||||
m_supportsaudioprocessing (supportsaudioprocessing) {}
|
m_supportsaudioprocessing (supportsaudioprocessing) {}
|
||||||
|
|
||||||
CProject::~CProject () {
|
std::shared_ptr<CProject> CProject::fromFile (const std::string& filename, std::shared_ptr<const CContainer> container) {
|
||||||
for (auto& [_, property] : this->m_properties) {
|
|
||||||
delete property;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->m_properties.clear ();
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
||||||
@ -49,8 +41,8 @@ std::unique_ptr<CProject> CProject::fromFile (const std::string& filename, std::
|
|||||||
auto type = jsonFindRequired <std::string> (content, "type", "Project type missing");
|
auto type = jsonFindRequired <std::string> (content, "type", "Project type missing");
|
||||||
const auto file = jsonFindRequired <std::string> (content, "file", "Project's main file missing");
|
const auto file = jsonFindRequired <std::string> (content, "file", "Project's main file missing");
|
||||||
auto general = content.find ("general");
|
auto general = content.find ("general");
|
||||||
const CWallpaper* wallpaper;
|
std::shared_ptr <const CWallpaper> wallpaper = nullptr;
|
||||||
std::map<std::string, Projects::CProperty*> properties;
|
std::map<std::string, std::shared_ptr <Projects::CProperty>> properties;
|
||||||
|
|
||||||
std::transform (type.begin (), type.end (), type.begin (), tolower);
|
std::transform (type.begin (), type.end (), type.begin (), tolower);
|
||||||
|
|
||||||
@ -66,12 +58,12 @@ std::unique_ptr<CProject> CProject::fromFile (const std::string& filename, std::
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
properties.emplace (property->getName (), property);
|
properties.emplace (property->getName (), std::move (property));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CProject> project = std::make_unique <CProject> (
|
std::shared_ptr<CProject> project = std::make_shared <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--)),
|
||||||
@ -81,11 +73,11 @@ std::unique_ptr<CProject> CProject::fromFile (const std::string& filename, std::
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (type == "scene")
|
if (type == "scene")
|
||||||
wallpaper = CScene::fromFile (file, *project, container);
|
wallpaper = CScene::fromFile (file, project, container);
|
||||||
else if (type == "video")
|
else if (type == "video")
|
||||||
wallpaper = new CVideo (file, *project);
|
wallpaper = std::make_shared<CVideo> (file, project);
|
||||||
else if (type == "web")
|
else if (type == "web")
|
||||||
wallpaper = new CWeb (file, *project);
|
wallpaper = std::make_shared<CWeb> (file, project);
|
||||||
else
|
else
|
||||||
sLog.exception ("Unsupported wallpaper type: ", type);
|
sLog.exception ("Unsupported wallpaper type: ", type);
|
||||||
|
|
||||||
@ -94,11 +86,11 @@ std::unique_ptr<CProject> CProject::fromFile (const std::string& filename, std::
|
|||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CProject::setWallpaper (const CWallpaper* wallpaper) {
|
void CProject::setWallpaper (std::shared_ptr <const CWallpaper> wallpaper) {
|
||||||
this->m_wallpaper = wallpaper;
|
this->m_wallpaper = wallpaper;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CWallpaper* CProject::getWallpaper () const {
|
const std::shared_ptr <const CWallpaper> CProject::getWallpaper () const {
|
||||||
return this->m_wallpaper;
|
return this->m_wallpaper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +102,7 @@ const std::string& CProject::getType () const {
|
|||||||
return this->m_type;
|
return this->m_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<std::string, Projects::CProperty*>& CProject::getProperties () const {
|
const std::map<std::string, std::shared_ptr <Projects::CProperty>>& CProject::getProperties () const {
|
||||||
return this->m_properties;
|
return this->m_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,15 +23,14 @@ class CProject {
|
|||||||
public:
|
public:
|
||||||
CProject (
|
CProject (
|
||||||
std::string title, std::string type, std::string workshopid, std::shared_ptr<const CContainer> container,
|
std::string title, std::string type, std::string workshopid, std::shared_ptr<const CContainer> container,
|
||||||
bool supportsaudioprocessing, const std::map<std::string, Projects::CProperty*>& properties);
|
bool supportsaudioprocessing, const std::map<std::string, std::shared_ptr<Projects::CProperty>>& properties);
|
||||||
~CProject();
|
|
||||||
|
|
||||||
static std::unique_ptr<CProject> fromFile (const std::string& filename, std::shared_ptr<const CContainer> container);
|
static std::shared_ptr<CProject> fromFile (const std::string& filename, std::shared_ptr<const CContainer> container);
|
||||||
|
|
||||||
[[nodiscard]] const CWallpaper* getWallpaper () const;
|
[[nodiscard]] const std::shared_ptr <const CWallpaper> getWallpaper () const;
|
||||||
[[nodiscard]] const std::string& getTitle () const;
|
[[nodiscard]] const std::string& getTitle () const;
|
||||||
[[nodiscard]] const std::string& getType () const;
|
[[nodiscard]] const std::string& getType () const;
|
||||||
[[nodiscard]] const std::map<std::string, Projects::CProperty*>& getProperties () const;
|
[[nodiscard]] const std::map<std::string, std::shared_ptr <Projects::CProperty>>& getProperties () const;
|
||||||
[[nodiscard]] const std::string& getWorkshopId () const;
|
[[nodiscard]] const std::string& getWorkshopId () const;
|
||||||
|
|
||||||
[[nodiscard]] bool supportsAudioProcessing () const;
|
[[nodiscard]] bool supportsAudioProcessing () const;
|
||||||
@ -39,16 +38,16 @@ class CProject {
|
|||||||
[[nodiscard]] std::shared_ptr<const CContainer> getContainer () const;
|
[[nodiscard]] std::shared_ptr<const CContainer> getContainer () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setWallpaper (const CWallpaper* wallpaper);
|
void setWallpaper (std::shared_ptr <const CWallpaper> wallpaper);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, Projects::CProperty*> m_properties;
|
std::map<std::string, std::shared_ptr<Projects::CProperty>> m_properties;
|
||||||
|
|
||||||
const std::string m_workshopid;
|
const std::string m_workshopid;
|
||||||
const std::string m_title;
|
const std::string m_title;
|
||||||
const std::string m_type;
|
const std::string m_type;
|
||||||
const bool m_supportsaudioprocessing;
|
const bool m_supportsaudioprocessing;
|
||||||
const CWallpaper* m_wallpaper;
|
std::shared_ptr <const CWallpaper> m_wallpaper;
|
||||||
std::shared_ptr<const CContainer> m_container = nullptr;
|
std::shared_ptr<const CContainer> m_container = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core
|
} // namespace WallpaperEngine::Core
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core;
|
using namespace WallpaperEngine::Core;
|
||||||
|
|
||||||
CWallpaper::CWallpaper (const CProject& project) :
|
CWallpaper::CWallpaper (std::shared_ptr <const CProject> project) :
|
||||||
m_project (project) {}
|
m_project (project) {}
|
||||||
|
|
||||||
const CProject& CWallpaper::getProject () const {
|
std::shared_ptr <const CProject> CWallpaper::getProject () const {
|
||||||
return this->m_project;
|
return this->m_project;
|
||||||
}
|
}
|
||||||
|
@ -30,15 +30,15 @@ class CWallpaper {
|
|||||||
return typeid(*this) == typeid(T);
|
return typeid(*this) == typeid(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CProject& getProject () const;
|
std::shared_ptr <const CProject> getProject () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class CProject;
|
friend class CProject;
|
||||||
|
|
||||||
explicit CWallpaper (const CProject& project);
|
explicit CWallpaper (std::shared_ptr <const CProject> project);
|
||||||
virtual ~CWallpaper() = default;
|
virtual ~CWallpaper() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CProject& m_project;
|
std::shared_ptr <const CProject> m_project;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core
|
} // namespace WallpaperEngine::Core
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
namespace WallpaperEngine::Core::DynamicValues {
|
namespace WallpaperEngine::Core::DynamicValues {
|
||||||
class CDynamicValue {
|
class CDynamicValue {
|
||||||
public:
|
public:
|
||||||
~CDynamicValue ();
|
virtual ~CDynamicValue ();
|
||||||
|
|
||||||
[[nodiscard]] const glm::ivec4& getIVec4 () const;
|
[[nodiscard]] const glm::ivec4& getIVec4 () const;
|
||||||
[[nodiscard]] const glm::ivec3& getIVec3 () const;
|
[[nodiscard]] const glm::ivec3& getIVec3 () const;
|
||||||
|
@ -21,8 +21,9 @@ using namespace WallpaperEngine::Core::Objects;
|
|||||||
using namespace WallpaperEngine::Core::UserSettings;
|
using namespace WallpaperEngine::Core::UserSettings;
|
||||||
|
|
||||||
CEffect::CEffect (
|
CEffect::CEffect (
|
||||||
std::string name, std::string description, std::string group, std::string preview, const CProject& project,
|
std::string name, std::string description, std::string group, std::string preview,
|
||||||
const CUserSettingBoolean* visible, std::vector<std::string> dependencies, std::vector<const Effects::CFBO*> fbos,
|
std::shared_ptr <const Core::CProject> project, const CUserSettingBoolean* visible,
|
||||||
|
std::vector<std::string> dependencies, std::vector<const Effects::CFBO*> fbos,
|
||||||
std::vector<const Images::CMaterial*> materials
|
std::vector<const Images::CMaterial*> materials
|
||||||
) :
|
) :
|
||||||
m_name (std::move(name)),
|
m_name (std::move(name)),
|
||||||
@ -36,8 +37,8 @@ CEffect::CEffect (
|
|||||||
m_materials (std::move(materials)) {}
|
m_materials (std::move(materials)) {}
|
||||||
|
|
||||||
const CEffect* CEffect::fromJSON (
|
const CEffect* CEffect::fromJSON (
|
||||||
const json& data, const CUserSettingBoolean* visible, const CProject& project, const Images::CMaterial* material,
|
const json& data, const CUserSettingBoolean* visible, std::shared_ptr <const Core::CProject> project,
|
||||||
const std::shared_ptr<const CContainer>& container
|
const Images::CMaterial* material, const std::shared_ptr<const CContainer>& container
|
||||||
) {
|
) {
|
||||||
const auto file = jsonFindRequired <std::string> (data, "file", "Object effect must have a file");
|
const auto file = jsonFindRequired <std::string> (data, "file", "Object effect must have a file");
|
||||||
const auto effectpasses_it = data.find ("passes");
|
const auto effectpasses_it = data.find ("passes");
|
||||||
@ -86,7 +87,7 @@ std::map<std::string, int> CEffect::combosFromJSON (const json::const_iterator&
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, const Core::Objects::Effects::Constants::CShaderConstant*> CEffect::constantsFromJSON (
|
std::map<std::string, const Core::Objects::Effects::Constants::CShaderConstant*> CEffect::constantsFromJSON (
|
||||||
const json::const_iterator& constants_it, const CProject& project
|
const json::const_iterator& constants_it, std::shared_ptr <const Core::CProject> project
|
||||||
) {
|
) {
|
||||||
std::map<std::string, const Core::Objects::Effects::Constants::CShaderConstant*> constants;
|
std::map<std::string, const Core::Objects::Effects::Constants::CShaderConstant*> constants;
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ std::map<std::string, const Core::Objects::Effects::Constants::CShaderConstant*>
|
|||||||
|
|
||||||
if (user != cur.value ().end () && user->is_string ()) {
|
if (user != cur.value ().end () && user->is_string ()) {
|
||||||
// look for a property with the correct name
|
// look for a property with the correct name
|
||||||
const auto& properties = project.getProperties ();
|
const auto& properties = project->getProperties ();
|
||||||
const auto property = properties.find (*user);
|
const auto property = properties.find (*user);
|
||||||
|
|
||||||
if (property != properties.end ()) {
|
if (property != properties.end ()) {
|
||||||
@ -234,7 +235,8 @@ std::vector<const Images::CMaterial*> CEffect::materialsFromJSON (
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::map<int, Images::CMaterial::OverrideInfo> CEffect::overridesFromJSON (
|
std::map<int, Images::CMaterial::OverrideInfo> CEffect::overridesFromJSON (
|
||||||
const json::const_iterator& passes_it, const Images::CMaterial* material, const CProject& project
|
const json::const_iterator& passes_it, const Images::CMaterial* material,
|
||||||
|
std::shared_ptr <const Core::CProject> project
|
||||||
) {
|
) {
|
||||||
std::map<int, Images::CMaterial::OverrideInfo> result;
|
std::map<int, Images::CMaterial::OverrideInfo> result;
|
||||||
|
|
||||||
@ -301,7 +303,7 @@ const std::vector<const Effects::CFBO*>& CEffect::getFbos () const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Core::CProject& CEffect::getProject () const {
|
const Core::CProject& CEffect::getProject () const {
|
||||||
return this->m_project;
|
return *this->m_project;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CEffect::isVisible () const {
|
bool CEffect::isVisible () const {
|
||||||
|
@ -27,13 +27,14 @@ using namespace WallpaperEngine::Core::UserSettings;
|
|||||||
class CEffect {
|
class CEffect {
|
||||||
public:
|
public:
|
||||||
CEffect (
|
CEffect (
|
||||||
std::string name, std::string description, std::string group, std::string preview, const CProject& project,
|
std::string name, std::string description, std::string group, std::string preview,
|
||||||
const CUserSettingBoolean* visible, std::vector<std::string> dependencies,
|
std::shared_ptr <const Core::CProject>, const CUserSettingBoolean* visible,
|
||||||
std::vector<const Effects::CFBO*> fbos, std::vector<const Images::CMaterial*> materials);
|
std::vector<std::string> dependencies, std::vector<const Effects::CFBO*> fbos,
|
||||||
|
std::vector<const Images::CMaterial*> materials);
|
||||||
|
|
||||||
static const CEffect* fromJSON (
|
static const CEffect* fromJSON (
|
||||||
const json& data, const CUserSettingBoolean* visible, const CProject& object, const Images::CMaterial* material,
|
const json& data, const CUserSettingBoolean* visible, std::shared_ptr <const Core::CProject> project,
|
||||||
const std::shared_ptr<const CContainer>& container);
|
const Images::CMaterial* material, const std::shared_ptr<const CContainer>& container);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return List of dependencies for the effect to work
|
* @return List of dependencies for the effect to work
|
||||||
@ -66,7 +67,7 @@ class CEffect {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static std::map<std::string, const Core::Objects::Effects::Constants::CShaderConstant*> constantsFromJSON (
|
static std::map<std::string, const Core::Objects::Effects::Constants::CShaderConstant*> constantsFromJSON (
|
||||||
const json::const_iterator& constants_it, const CProject& project);
|
const json::const_iterator& constants_it, std::shared_ptr <const Core::CProject> project);
|
||||||
static std::map<std::string, int> combosFromJSON (const json::const_iterator& combos_it);
|
static std::map<std::string, int> combosFromJSON (const json::const_iterator& combos_it);
|
||||||
static std::vector<const Effects::CFBO*> fbosFromJSON (const json::const_iterator& fbos_it);
|
static std::vector<const Effects::CFBO*> fbosFromJSON (const json::const_iterator& fbos_it);
|
||||||
static std::vector<std::string> dependenciesFromJSON (const json::const_iterator& dependencies_it);
|
static std::vector<std::string> dependenciesFromJSON (const json::const_iterator& dependencies_it);
|
||||||
@ -74,7 +75,8 @@ class CEffect {
|
|||||||
const json::const_iterator& passes_it, const std::string& name,
|
const json::const_iterator& passes_it, const std::string& name,
|
||||||
const std::shared_ptr<const CContainer>& container, std::map<int, Images::CMaterial::OverrideInfo>);
|
const std::shared_ptr<const CContainer>& container, std::map<int, Images::CMaterial::OverrideInfo>);
|
||||||
static std::map<int, Images::CMaterial::OverrideInfo> overridesFromJSON (
|
static std::map<int, Images::CMaterial::OverrideInfo> overridesFromJSON (
|
||||||
const json::const_iterator& passes_it, const Images::CMaterial* material, const CProject& project);
|
const json::const_iterator& passes_it, const Images::CMaterial* material,
|
||||||
|
std::shared_ptr <const Core::CProject> project);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Effect's name */
|
/** Effect's name */
|
||||||
@ -88,7 +90,7 @@ class CEffect {
|
|||||||
/** If the effect is visible or not */
|
/** If the effect is visible or not */
|
||||||
const UserSettings::CUserSettingBoolean* m_visible;
|
const UserSettings::CUserSettingBoolean* m_visible;
|
||||||
/** Project this effect is part of */
|
/** Project this effect is part of */
|
||||||
const CProject& m_project;
|
std::shared_ptr <const Core::CProject> m_project;
|
||||||
|
|
||||||
/** List of dependencies for the effect */
|
/** List of dependencies for the effect */
|
||||||
const std::vector<std::string> m_dependencies;
|
const std::vector<std::string> m_dependencies;
|
||||||
|
@ -12,13 +12,14 @@ using namespace WallpaperEngine::Core::Objects;
|
|||||||
using namespace WallpaperEngine::Core::UserSettings;
|
using namespace WallpaperEngine::Core::UserSettings;
|
||||||
|
|
||||||
CImage::CImage (
|
CImage::CImage (
|
||||||
const Wallpapers::CScene* scene, const Images::CMaterial* material, const CUserSettingBoolean* visible, int id,
|
std::shared_ptr <const Core::CProject> project, const Images::CMaterial* material,
|
||||||
std::string name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
const CUserSettingBoolean* visible, int id, std::string name, const CUserSettingVector3* origin,
|
||||||
const CUserSettingVector3* angles, glm::vec2 size, std::string alignment, const CUserSettingVector3* color,
|
const CUserSettingVector3* scale, const CUserSettingVector3* angles, glm::vec2 size, std::string alignment,
|
||||||
const CUserSettingFloat* alpha, float brightness, uint32_t colorBlendMode, glm::vec2 parallaxDepth, bool fullscreen,
|
const CUserSettingVector3* color, const CUserSettingFloat* alpha, float brightness, uint32_t colorBlendMode,
|
||||||
bool passthrough, bool autosize, std::vector<const Objects::CEffect*> effects, std::vector<int> dependencies
|
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), origin, scale, angles, std::move(dependencies)),
|
CObject (project, 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),
|
||||||
@ -33,7 +34,7 @@ CImage::CImage (
|
|||||||
m_effects (std::move(effects)) {}
|
m_effects (std::move(effects)) {}
|
||||||
|
|
||||||
const WallpaperEngine::Core::CObject* CImage::fromJSON (
|
const WallpaperEngine::Core::CObject* CImage::fromJSON (
|
||||||
const Wallpapers::CScene* scene, const json& data, const std::shared_ptr<const CContainer>& container,
|
std::shared_ptr <const Core::CProject> project, const json& data, const std::shared_ptr<const CContainer>& container,
|
||||||
const CUserSettingBoolean* visible, int id, std::string name, const CUserSettingVector3* origin,
|
const CUserSettingBoolean* visible, int id, std::string name, const CUserSettingVector3* origin,
|
||||||
const CUserSettingVector3* scale, const CUserSettingVector3* angles, const json::const_iterator& effects_it,
|
const CUserSettingVector3* scale, const CUserSettingVector3* angles, const json::const_iterator& effects_it,
|
||||||
std::vector<int> dependencies
|
std::vector<int> dependencies
|
||||||
@ -50,7 +51,7 @@ const WallpaperEngine::Core::CObject* CImage::fromJSON (
|
|||||||
|
|
||||||
if (effects_it != data.end () && effects_it->is_array ()) {
|
if (effects_it != data.end () && effects_it->is_array ()) {
|
||||||
for (auto& cur : *effects_it) {
|
for (auto& cur : *effects_it) {
|
||||||
const auto effectVisible = jsonFindUserConfig<CUserSettingBoolean> (cur, scene->getProject(), "visible", true);
|
const auto effectVisible = jsonFindUserConfig<CUserSettingBoolean> (cur, *project, "visible", true);
|
||||||
|
|
||||||
// TODO: USER CANNOT MODIFY VALUES ON THE FLY, BUT IT MIGHT BE INTERESTING TO SUPPORT THAT AT SOME POINT?
|
// TODO: USER CANNOT MODIFY VALUES ON THE FLY, BUT IT MIGHT BE INTERESTING TO SUPPORT THAT AT SOME POINT?
|
||||||
// TODO: AT LEAST THE ORIGINAL SOFTWARE ALLOWS YOU TO DO THAT IN THE PREVIEW WINDOW
|
// TODO: AT LEAST THE ORIGINAL SOFTWARE ALLOWS YOU TO DO THAT IN THE PREVIEW WINDOW
|
||||||
@ -62,14 +63,14 @@ const WallpaperEngine::Core::CObject* CImage::fromJSON (
|
|||||||
|
|
||||||
effects.push_back (
|
effects.push_back (
|
||||||
Objects::CEffect::fromJSON (
|
Objects::CEffect::fromJSON (
|
||||||
cur, effectVisible, scene->getProject (), material, container
|
cur, effectVisible, project, material, container
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CImage (
|
return new CImage (
|
||||||
scene,
|
project,
|
||||||
material,
|
material,
|
||||||
visible,
|
visible,
|
||||||
id,
|
id,
|
||||||
@ -79,8 +80,8 @@ const WallpaperEngine::Core::CObject* CImage::fromJSON (
|
|||||||
angles,
|
angles,
|
||||||
jsonFindDefault<glm::vec2> (data, "size", glm::vec2 (0.0, 0.0)),
|
jsonFindDefault<glm::vec2> (data, "size", glm::vec2 (0.0, 0.0)),
|
||||||
jsonFindDefault<std::string> (data, "alignment", "center"),
|
jsonFindDefault<std::string> (data, "alignment", "center"),
|
||||||
jsonFindUserConfig<CUserSettingVector3> (data, scene->getProject(), "color", {1, 1, 1}),
|
jsonFindUserConfig<CUserSettingVector3> (data, *project, "color", {1, 1, 1}),
|
||||||
jsonFindUserConfig<CUserSettingFloat> (data, scene->getProject(), "alpha", 1.0),
|
jsonFindUserConfig<CUserSettingFloat> (data, *project, "alpha", 1.0),
|
||||||
jsonFindDefault<float> (data, "brightness", 1.0),
|
jsonFindDefault<float> (data, "brightness", 1.0),
|
||||||
jsonFindDefault<uint32_t> (data, "colorBlendMode", 0),
|
jsonFindDefault<uint32_t> (data, "colorBlendMode", 0),
|
||||||
jsonFindDefault<glm::vec2> (data, "parallaxDepth", glm::vec2 (0.0, 0.0)),
|
jsonFindDefault<glm::vec2> (data, "parallaxDepth", glm::vec2 (0.0, 0.0)),
|
||||||
|
@ -30,10 +30,10 @@ class CImage : public CObject {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static const CObject* fromJSON (
|
static const CObject* fromJSON (
|
||||||
const Wallpapers::CScene* scene, const json& data, const std::shared_ptr<const CContainer>& container,
|
std::shared_ptr <const Core::CProject> project, const json& data,
|
||||||
const CUserSettingBoolean* visible, int id, std::string name, const CUserSettingVector3* origin,
|
const std::shared_ptr<const CContainer>& container, const CUserSettingBoolean* visible, int id,
|
||||||
const CUserSettingVector3* scale, const CUserSettingVector3* angles, const json::const_iterator& effects_it,
|
std::string name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
||||||
std::vector<int> dependencies);
|
const CUserSettingVector3* angles, const json::const_iterator& effects_it, std::vector<int> dependencies);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The base material to use for the image
|
* @return The base material to use for the image
|
||||||
@ -86,12 +86,12 @@ class CImage : public CObject {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
CImage (
|
CImage (
|
||||||
const Wallpapers::CScene* scene, const Images::CMaterial* material, const CUserSettingBoolean* visible, int id,
|
std::shared_ptr <const Core::CProject> project, const Images::CMaterial* material,
|
||||||
std::string name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
const CUserSettingBoolean* visible, int id, std::string name, const CUserSettingVector3* origin,
|
||||||
const CUserSettingVector3* angles, glm::vec2 size, std::string alignment, const CUserSettingVector3* color,
|
const CUserSettingVector3* scale, const CUserSettingVector3* angles, glm::vec2 size, std::string alignment,
|
||||||
const CUserSettingFloat* alpha, float brightness, uint32_t colorBlendMode, glm::vec2 parallaxDepth,
|
const CUserSettingVector3* color, const CUserSettingFloat* alpha, float brightness, uint32_t colorBlendMode,
|
||||||
bool fullscreen, bool passthrough, bool autosize, std::vector<const Objects::CEffect*> effects,
|
glm::vec2 parallaxDepth, bool fullscreen, bool passthrough, bool autosize,
|
||||||
std::vector<int> dependencies);
|
std::vector<const Objects::CEffect*> effects, std::vector<int> dependencies);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** The image's size */
|
/** The image's size */
|
||||||
|
@ -5,9 +5,10 @@
|
|||||||
using namespace WallpaperEngine::Core::Objects;
|
using namespace WallpaperEngine::Core::Objects;
|
||||||
|
|
||||||
const CParticle* CParticle::fromFile (
|
const CParticle* CParticle::fromFile (
|
||||||
const Wallpapers::CScene* scene, const std::string& filename, std::shared_ptr<const CContainer> container,
|
std::shared_ptr <const Core::CProject> project, const std::string& filename,
|
||||||
const CUserSettingBoolean* visible, int id, const std::string& name, const CUserSettingVector3* origin,
|
const std::shared_ptr<const CContainer>& container, const CUserSettingBoolean* visible, int id,
|
||||||
const CUserSettingVector3* angles, const CUserSettingVector3* scale, std::vector<int> dependencies
|
const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* angles,
|
||||||
|
const CUserSettingVector3* scale, std::vector<int> dependencies
|
||||||
) {
|
) {
|
||||||
json data = json::parse (container->readFileAsString (filename));
|
json data = json::parse (container->readFileAsString (filename));
|
||||||
const auto controlpoint_it = data.find ("controlpoint");
|
const auto controlpoint_it = data.find ("controlpoint");
|
||||||
@ -28,7 +29,7 @@ const CParticle* CParticle::fromFile (
|
|||||||
initializers.push_back (Particles::CInitializer::fromJSON (cur));
|
initializers.push_back (Particles::CInitializer::fromJSON (cur));
|
||||||
|
|
||||||
return new CParticle (
|
return new CParticle (
|
||||||
scene,
|
project,
|
||||||
jsonFindRequired <uint32_t> (data, "starttime", "Particles must have start time"),
|
jsonFindRequired <uint32_t> (data, "starttime", "Particles must have start time"),
|
||||||
jsonFindRequired <uint32_t> (data, "maxcount", "Particles must have maximum count"),
|
jsonFindRequired <uint32_t> (data, "maxcount", "Particles must have maximum count"),
|
||||||
visible,
|
visible,
|
||||||
@ -45,13 +46,14 @@ const CParticle* CParticle::fromFile (
|
|||||||
}
|
}
|
||||||
|
|
||||||
CParticle::CParticle (
|
CParticle::CParticle (
|
||||||
const Wallpapers::CScene* scene, uint32_t starttime, uint32_t maxcount, const CUserSettingBoolean* visible, int id,
|
std::shared_ptr <const Core::CProject> project, uint32_t starttime, uint32_t maxcount,
|
||||||
const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
const CUserSettingBoolean* visible, int id, const std::string& name, const CUserSettingVector3* origin,
|
||||||
const CUserSettingVector3* angles, const std::vector<const Particles::CControlPoint*>& controlpoints,
|
const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
||||||
|
const std::vector<const Particles::CControlPoint*>& controlpoints,
|
||||||
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, origin, scale, angles, std::move(dependencies)),
|
CObject (project, 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),
|
||||||
|
@ -18,9 +18,10 @@ class CParticle : public CObject {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static const CParticle* fromFile (
|
static const CParticle* fromFile (
|
||||||
const Wallpapers::CScene* scene, const std::string& filename, std::shared_ptr<const CContainer> container,
|
std::shared_ptr <const Core::CProject> project, const std::string& filename,
|
||||||
const CUserSettingBoolean* visible, int id, const std::string& name, const CUserSettingVector3* origin,
|
const std::shared_ptr<const CContainer>& container, const CUserSettingBoolean* visible, int id,
|
||||||
const CUserSettingVector3* angles, const CUserSettingVector3* scale, std::vector<int> dependencies);
|
const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* angles,
|
||||||
|
const CUserSettingVector3* scale, std::vector<int> dependencies);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The list of emitters for the particle system
|
* @return The list of emitters for the particle system
|
||||||
@ -37,9 +38,10 @@ class CParticle : public CObject {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
CParticle (
|
CParticle (
|
||||||
const Wallpapers::CScene* scene, uint32_t starttime, uint32_t maxcount, const CUserSettingBoolean* visible,
|
std::shared_ptr <const Core::CProject> project, uint32_t starttime, uint32_t maxcount,
|
||||||
int id, const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
const CUserSettingBoolean* visible, int id, const std::string& name, const CUserSettingVector3* origin,
|
||||||
const CUserSettingVector3* angles, const std::vector<const Particles::CControlPoint*>& controlpoints,
|
const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
||||||
|
const std::vector<const Particles::CControlPoint*>& controlpoints,
|
||||||
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);
|
||||||
|
|
||||||
|
@ -7,17 +7,17 @@
|
|||||||
using namespace WallpaperEngine::Core::Objects;
|
using namespace WallpaperEngine::Core::Objects;
|
||||||
|
|
||||||
CSound::CSound (
|
CSound::CSound (
|
||||||
const Wallpapers::CScene* scene, const CUserSettingBoolean* visible, int id, std::string name,
|
std::shared_ptr <const Core::CProject> project, const CUserSettingBoolean* visible, int id, std::string name,
|
||||||
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles, bool repeat,
|
const CUserSettingVector3* origin, const CUserSettingVector3* scale, const CUserSettingVector3* angles,
|
||||||
std::vector<std::string> sounds, std::vector<int> dependencies
|
bool repeat, std::vector<std::string> sounds, std::vector<int> dependencies
|
||||||
) :
|
) :
|
||||||
CObject (scene, visible, id, std::move(name), origin, scale, angles, std::move(dependencies)),
|
CObject (project, 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)) {}
|
||||||
|
|
||||||
const WallpaperEngine::Core::CObject* CSound::fromJSON (
|
const WallpaperEngine::Core::CObject* CSound::fromJSON (
|
||||||
const Wallpapers::CScene* scene, const json& data, const CUserSettingBoolean* visible, int id,
|
std::shared_ptr <const Core::CProject> project, const json& data, const CUserSettingBoolean* visible,
|
||||||
const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
int id, const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
||||||
const CUserSettingVector3* angles, std::vector<int> dependencies
|
const CUserSettingVector3* angles, std::vector<int> dependencies
|
||||||
) {
|
) {
|
||||||
// TODO: PARSE AUDIO VOLUME
|
// TODO: PARSE AUDIO VOLUME
|
||||||
@ -31,7 +31,7 @@ const WallpaperEngine::Core::CObject* CSound::fromJSON (
|
|||||||
sounds.push_back (cur);
|
sounds.push_back (cur);
|
||||||
|
|
||||||
return new CSound (
|
return new CSound (
|
||||||
scene,
|
project,
|
||||||
visible,
|
visible,
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
|
@ -20,7 +20,7 @@ class CSound : public CObject {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static const CObject* fromJSON (
|
static const CObject* fromJSON (
|
||||||
const Wallpapers::CScene* scene, const json& data, const CUserSettingBoolean* visible,
|
std::shared_ptr <const Core::CProject> project, const json& data, const CUserSettingBoolean* visible,
|
||||||
int id, const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
int id, const std::string& name, const CUserSettingVector3* origin, const CUserSettingVector3* scale,
|
||||||
const CUserSettingVector3* angles, std::vector<int> dependencies);
|
const CUserSettingVector3* angles, std::vector<int> dependencies);
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ class CSound : public CObject {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
CSound (
|
CSound (
|
||||||
const Wallpapers::CScene* scene, const CUserSettingBoolean* visible, int id, std::string name,
|
std::shared_ptr <const Core::CProject> project, 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,
|
||||||
bool repeat, std::vector<std::string> sounds, std::vector<int> dependencies);
|
bool repeat, std::vector<std::string> sounds, std::vector<int> dependencies);
|
||||||
|
|
||||||
@ -43,6 +43,6 @@ class CSound : public CObject {
|
|||||||
/** If the sounds should repeat or not */
|
/** If the sounds should repeat or not */
|
||||||
bool m_repeat = false;
|
bool m_repeat = false;
|
||||||
/** The list of sounds to play */
|
/** The list of sounds to play */
|
||||||
std::vector<std::string> m_sounds;
|
std::vector<std::string> m_sounds = {};
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Objects
|
} // namespace WallpaperEngine::Core::Objects
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
using namespace WallpaperEngine::Core::Objects::Effects::Constants;
|
||||||
|
|
||||||
CShaderConstantProperty::CShaderConstantProperty (const CProperty* property) {
|
CShaderConstantProperty::CShaderConstantProperty (std::shared_ptr <const CProperty> property) {
|
||||||
property->connectOutgoing (this);
|
property->connectOutgoing (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ using namespace WallpaperEngine::Core::Projects;
|
|||||||
*/
|
*/
|
||||||
class CShaderConstantProperty : public CShaderConstant {
|
class CShaderConstantProperty : public CShaderConstant {
|
||||||
public:
|
public:
|
||||||
explicit CShaderConstantProperty (const CProperty* property);
|
explicit CShaderConstantProperty (std::shared_ptr <const CProperty> property);
|
||||||
|
|
||||||
[[nodiscard]] std::string toString () const override;
|
[[nodiscard]] std::string toString () const override;
|
||||||
};
|
};
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Projects;
|
using namespace WallpaperEngine::Core::Projects;
|
||||||
|
|
||||||
CProperty* CProperty::fromJSON (const json& data, const std::string& name) {
|
std::shared_ptr<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 == "color")
|
if (*type == "color")
|
||||||
|
@ -16,7 +16,7 @@ class CProperty : public CDynamicValue {
|
|||||||
public:
|
public:
|
||||||
typedef std::function<void(const CProperty*)> function_type;
|
typedef std::function<void(const CProperty*)> function_type;
|
||||||
virtual ~CProperty () = default;
|
virtual ~CProperty () = default;
|
||||||
static CProperty* fromJSON (const json& data, const std::string& name);
|
static std::shared_ptr<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 {
|
||||||
if (is <T> ()) {
|
if (is <T> ()) {
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Projects;
|
using namespace WallpaperEngine::Core::Projects;
|
||||||
|
|
||||||
CPropertyBoolean* CPropertyBoolean::fromJSON (const json& data, std::string name) {
|
std::shared_ptr<CPropertyBoolean> CPropertyBoolean::fromJSON (const json& data, std::string name) {
|
||||||
return new CPropertyBoolean (
|
return std::make_shared <CPropertyBoolean> (
|
||||||
jsonFindRequired <bool> (data, "value", "Boolean property must have a value"),
|
jsonFindRequired <bool> (data, "value", "Boolean property must have a value"),
|
||||||
std::move(name),
|
std::move(name),
|
||||||
jsonFindDefault<std::string> (data, "text", "")
|
jsonFindDefault<std::string> (data, "text", "")
|
||||||
|
@ -10,13 +10,12 @@ using json = nlohmann::json;
|
|||||||
*/
|
*/
|
||||||
class CPropertyBoolean final : public CProperty {
|
class CPropertyBoolean final : public CProperty {
|
||||||
public:
|
public:
|
||||||
static CPropertyBoolean* fromJSON (const json& data, std::string name);
|
CPropertyBoolean (bool value, std::string name, std::string text);
|
||||||
|
|
||||||
|
static std::shared_ptr<CPropertyBoolean> 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;
|
|
||||||
|
|
||||||
private:
|
[[nodiscard]] const char* getType () const override;
|
||||||
CPropertyBoolean (bool value, std::string name, std::string text);
|
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Projects
|
} // namespace WallpaperEngine::Core::Projects
|
||||||
|
@ -21,11 +21,11 @@ glm::vec3 ParseColor (std::string value) {
|
|||||||
return WallpaperEngine::Core::aToColorf (value);
|
return WallpaperEngine::Core::aToColorf (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPropertyColor* CPropertyColor::fromJSON (const json& data, std::string name) {
|
std::shared_ptr<CPropertyColor> CPropertyColor::fromJSON (const json& data, std::string name) {
|
||||||
const auto value = jsonFindRequired <std::string> (data, "value", "Color property must have a value");
|
const auto value = jsonFindRequired <std::string> (data, "value", "Color property must have a value");
|
||||||
const auto text = jsonFindDefault<std::string> (data, "text", "");
|
const auto text = jsonFindDefault<std::string> (data, "text", "");
|
||||||
|
|
||||||
return new CPropertyColor (value, std::move(name), text);
|
return std::make_shared <CPropertyColor> (value, std::move(name), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPropertyColor::set (const std::string& value) {
|
void CPropertyColor::set (const std::string& value) {
|
||||||
|
@ -12,13 +12,12 @@ using json = nlohmann::json;
|
|||||||
*/
|
*/
|
||||||
class CPropertyColor final : public CProperty {
|
class CPropertyColor final : public CProperty {
|
||||||
public:
|
public:
|
||||||
static CPropertyColor* fromJSON (const json& data, std::string name);
|
CPropertyColor (const std::string& color, std::string name, std::string text);
|
||||||
|
|
||||||
|
static std::shared_ptr<CPropertyColor> 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;
|
|
||||||
|
|
||||||
private:
|
[[nodiscard]] const char* getType () const override;
|
||||||
CPropertyColor (const std::string& color, std::string name, std::string text);
|
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Projects
|
} // namespace WallpaperEngine::Core::Projects
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Projects;
|
using namespace WallpaperEngine::Core::Projects;
|
||||||
|
|
||||||
CPropertyCombo* CPropertyCombo::fromJSON (const json& data, std::string name) {
|
std::shared_ptr<CPropertyCombo> CPropertyCombo::fromJSON (const json& data, std::string name) {
|
||||||
std::vector<const CPropertyComboValue*> values;
|
std::vector<CPropertyComboValue> values;
|
||||||
const auto options = jsonFindRequired (data, "options", "Options for a property combo is required");
|
const auto options = jsonFindRequired (data, "options", "Options for a property combo is required");
|
||||||
|
|
||||||
if (!options->is_array ())
|
if (!options->is_array ())
|
||||||
@ -21,15 +21,13 @@ CPropertyCombo* CPropertyCombo::fromJSON (const json& data, std::string name) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// check for label and value to ensure they're there
|
// check for label and value to ensure they're there
|
||||||
auto prop = new CPropertyComboValue {
|
values.push_back ({
|
||||||
.label = jsonFindRequired <std::string> (cur, "label", "Label is required for a property combo option"),
|
.label = jsonFindRequired<std::string> (cur, "label", "Label is required for a property combo option"),
|
||||||
.value = jsonFindRequired <std::string> (cur, "value", "Value is required for a property combo option")
|
.value = jsonFindRequired<std::string> (cur, "value", "Value is required for a property combo option")
|
||||||
};
|
});
|
||||||
|
|
||||||
values.push_back (prop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CPropertyCombo (
|
return std::make_shared <CPropertyCombo> (
|
||||||
std::move(name),
|
std::move(name),
|
||||||
jsonFindDefault<std::string> (data, "text", ""),
|
jsonFindDefault<std::string> (data, "text", ""),
|
||||||
jsonFindRequired<std::string> (data, "value", "Value is required for a property combo"),
|
jsonFindRequired<std::string> (data, "value", "Value is required for a property combo"),
|
||||||
@ -38,18 +36,14 @@ 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<CPropertyComboValue> values
|
||||||
) :
|
) :
|
||||||
CProperty (std::move(name), 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPropertyCombo::~CPropertyCombo () {
|
|
||||||
for (const auto* value : this->m_values)
|
|
||||||
delete value;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CPropertyCombo::dump () const {
|
std::string CPropertyCombo::dump () const {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
@ -61,8 +55,8 @@ std::string CPropertyCombo::dump () const {
|
|||||||
<< "\t\t"
|
<< "\t\t"
|
||||||
<< "Posible values:" << std::endl;
|
<< "Posible values:" << std::endl;
|
||||||
|
|
||||||
for (const auto cur : this->m_values)
|
for (const auto& cur : this->m_values)
|
||||||
ss << "\t\t" << cur->label << " -> " << cur->value << std::endl;
|
ss << "\t\t" << cur.label << " -> " << cur.value << std::endl;
|
||||||
|
|
||||||
return ss.str ();
|
return ss.str ();
|
||||||
}
|
}
|
||||||
@ -72,8 +66,8 @@ void CPropertyCombo::set (const std::string& value) {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
// ensure the value is present somewhere in the value list
|
// ensure the value is present somewhere in the value list
|
||||||
for (const auto cur : this->m_values) {
|
for (const auto& cur : this->m_values) {
|
||||||
if (cur->value == value) {
|
if (cur.value == value) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -92,8 +86,8 @@ int CPropertyCombo::translateValueToIndex (const std::string& value) const {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
// ensure the value is present somewhere in the value list
|
// ensure the value is present somewhere in the value list
|
||||||
for (const auto cur : this->m_values) {
|
for (const auto& cur : this->m_values) {
|
||||||
if (cur->value == value) {
|
if (cur.value == value) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ using json = nlohmann::json;
|
|||||||
/**
|
/**
|
||||||
* Represents different combo values
|
* Represents different combo values
|
||||||
*/
|
*/
|
||||||
class CPropertyComboValue {
|
struct CPropertyComboValue {
|
||||||
public:
|
public:
|
||||||
const std::string label;
|
const std::string label;
|
||||||
const std::string value;
|
const std::string value;
|
||||||
@ -23,20 +23,20 @@ class CPropertyComboValue {
|
|||||||
*/
|
*/
|
||||||
class CPropertyCombo final : public CProperty {
|
class CPropertyCombo final : public CProperty {
|
||||||
public:
|
public:
|
||||||
static CPropertyCombo* fromJSON (const json& data, std::string name);
|
static std::shared_ptr<CPropertyCombo> fromJSON (const json& data, std::string name);
|
||||||
|
|
||||||
~CPropertyCombo () override;
|
CPropertyCombo (
|
||||||
|
std::string name, std::string text, const std::string& defaultValue,
|
||||||
|
std::vector<CPropertyComboValue> values);
|
||||||
|
|
||||||
[[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;
|
[[nodiscard]] const char* getType () const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CPropertyCombo (
|
|
||||||
std::string name, std::string text, const std::string& defaultValue, std::vector<const CPropertyComboValue*> values);
|
|
||||||
|
|
||||||
/** List of values available to select */
|
/** List of values available to select */
|
||||||
const std::vector<const CPropertyComboValue*> m_values;
|
const std::vector<CPropertyComboValue> m_values;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Projects
|
} // namespace WallpaperEngine::Core::Projects
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Projects;
|
using namespace WallpaperEngine::Core::Projects;
|
||||||
|
|
||||||
CPropertySlider* CPropertySlider::fromJSON (const json& data, const std::string& name) {
|
std::shared_ptr<CPropertySlider> CPropertySlider::fromJSON (const json& data, const std::string& name) {
|
||||||
const auto value = data.find ("value");
|
const auto value = data.find ("value");
|
||||||
const auto text = jsonFindDefault<std::string> (data, "text", "");
|
const auto text = jsonFindDefault<std::string> (data, "text", "");
|
||||||
const auto min = jsonFindDefault (data, "min", 0.0f);
|
const auto min = jsonFindDefault (data, "min", 0.0f);
|
||||||
const auto max = jsonFindDefault (data, "max", 0.0f);
|
const auto max = jsonFindDefault (data, "max", 0.0f);
|
||||||
const auto step = jsonFindDefault (data, "step", 0.0f);
|
const auto step = jsonFindDefault (data, "step", 0.0f);
|
||||||
|
|
||||||
return new CPropertySlider (*value, name, text, min, max, step);
|
return std::make_shared <CPropertySlider> (*value, name, text, min, max, step);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float& CPropertySlider::getMinValue () const {
|
const float& CPropertySlider::getMinValue () const {
|
||||||
|
@ -12,8 +12,9 @@ using json = nlohmann::json;
|
|||||||
*/
|
*/
|
||||||
class CPropertySlider final : public CProperty {
|
class CPropertySlider final : public CProperty {
|
||||||
public:
|
public:
|
||||||
static CPropertySlider* fromJSON (const json& data, const std::string& name);
|
CPropertySlider (float value, const std::string& name, const std::string& text, float min, float max, float step);
|
||||||
|
|
||||||
|
static std::shared_ptr<CPropertySlider> fromJSON (const json& data, const std::string& name);
|
||||||
/**
|
/**
|
||||||
* @return The slider's minimum value
|
* @return The slider's minimum value
|
||||||
*/
|
*/
|
||||||
@ -28,10 +29,9 @@ 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;
|
|
||||||
|
|
||||||
|
[[nodiscard]] const char* getType () const override;
|
||||||
private:
|
private:
|
||||||
CPropertySlider (float value, const std::string& name, const std::string& text, float min, float max, float step);
|
|
||||||
|
|
||||||
/** Minimum value */
|
/** Minimum value */
|
||||||
const float m_min;
|
const float m_min;
|
||||||
|
@ -5,11 +5,9 @@
|
|||||||
|
|
||||||
using namespace WallpaperEngine::Core::Projects;
|
using namespace WallpaperEngine::Core::Projects;
|
||||||
|
|
||||||
CPropertyText* CPropertyText::fromJSON (const json& data, std::string name) {
|
std::shared_ptr<CPropertyText> CPropertyText::fromJSON (const json& data, std::string name) {
|
||||||
//TODO: VALIDATE THIS IS RIGHT
|
//TODO: VALIDATE THIS IS RIGHT
|
||||||
const auto text = data.find ("type");
|
return std::make_shared <CPropertyText> (std::move(name), *data.find ("type"));
|
||||||
|
|
||||||
return new CPropertyText (std::move(name), *text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CPropertyText::dump () const {
|
std::string CPropertyText::dump () const {
|
||||||
|
@ -10,12 +10,13 @@ using json = nlohmann::json;
|
|||||||
*/
|
*/
|
||||||
class CPropertyText final : public CProperty {
|
class CPropertyText final : public CProperty {
|
||||||
public:
|
public:
|
||||||
static CPropertyText* fromJSON (const json& data, std::string name);
|
CPropertyText (std::string name, std::string text);
|
||||||
|
|
||||||
|
static std::shared_ptr<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;
|
|
||||||
|
|
||||||
|
[[nodiscard]] const char* getType () const override;
|
||||||
private:
|
private:
|
||||||
CPropertyText (std::string name, std::string text);
|
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::Projects
|
} // namespace WallpaperEngine::Core::Projects
|
||||||
|
@ -16,7 +16,7 @@ using namespace WallpaperEngine::Core::Projects;
|
|||||||
using namespace WallpaperEngine::Core::UserSettings;
|
using namespace WallpaperEngine::Core::UserSettings;
|
||||||
|
|
||||||
CUserSettingBoolean::CUserSettingBoolean (
|
CUserSettingBoolean::CUserSettingBoolean (
|
||||||
bool hasCondition, bool defaultValue, const Projects::CProperty* source, std::string expectedValue
|
bool hasCondition, bool defaultValue, std::shared_ptr <const Projects::CProperty> source, std::string expectedValue
|
||||||
) :
|
) :
|
||||||
CUserSettingValue (),
|
CUserSettingValue (),
|
||||||
m_hasCondition (hasCondition),
|
m_hasCondition (hasCondition),
|
||||||
@ -41,7 +41,7 @@ CUserSettingBoolean::CUserSettingBoolean (
|
|||||||
|
|
||||||
const CUserSettingBoolean* CUserSettingBoolean::fromJSON (const nlohmann::json& data, const CProject& project) {
|
const CUserSettingBoolean* CUserSettingBoolean::fromJSON (const nlohmann::json& data, const CProject& project) {
|
||||||
bool hasCondition = false;
|
bool hasCondition = false;
|
||||||
const Projects::CProperty* sourceProperty = nullptr;
|
std::shared_ptr <const Projects::CProperty> sourceProperty = nullptr;
|
||||||
bool defaultValue;
|
bool defaultValue;
|
||||||
std::string source;
|
std::string source;
|
||||||
std::string expectedValue;
|
std::string expectedValue;
|
||||||
|
@ -17,10 +17,10 @@ class CUserSettingBoolean : public CUserSettingValue {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CUserSettingBoolean (
|
CUserSettingBoolean (
|
||||||
bool hasCondition, bool defaultValue, const Projects::CProperty* source, std::string expectedValue);
|
bool hasCondition, bool defaultValue, std::shared_ptr <const Projects::CProperty> source, std::string expectedValue);
|
||||||
|
|
||||||
const bool m_hasCondition;
|
const bool m_hasCondition;
|
||||||
const std::string m_expectedValue;
|
const std::string m_expectedValue;
|
||||||
const Projects::CProperty* m_source;
|
const std::shared_ptr <const Projects::CProperty> m_source;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::UserSettings
|
} // namespace WallpaperEngine::Core::UserSettings
|
@ -13,7 +13,7 @@ using namespace WallpaperEngine::Core::Projects;
|
|||||||
using namespace WallpaperEngine::Core::UserSettings;
|
using namespace WallpaperEngine::Core::UserSettings;
|
||||||
|
|
||||||
CUserSettingFloat::CUserSettingFloat (
|
CUserSettingFloat::CUserSettingFloat (
|
||||||
bool hasCondition, float defaultValue, const Projects::CProperty* source, std::string expectedValue
|
bool hasCondition, float defaultValue, std::shared_ptr <const Projects::CProperty> source, std::string expectedValue
|
||||||
) :
|
) :
|
||||||
CUserSettingValue (),
|
CUserSettingValue (),
|
||||||
m_default (defaultValue),
|
m_default (defaultValue),
|
||||||
@ -38,7 +38,7 @@ const CUserSettingFloat* CUserSettingFloat::fromJSON (const nlohmann::json& data
|
|||||||
std::string source;
|
std::string source;
|
||||||
std::string expectedValue;
|
std::string expectedValue;
|
||||||
bool hasCondition = false;
|
bool hasCondition = false;
|
||||||
const Projects::CProperty* sourceProperty = nullptr;
|
std::shared_ptr <const Projects::CProperty> sourceProperty = nullptr;
|
||||||
|
|
||||||
if (data.is_object ()) {
|
if (data.is_object ()) {
|
||||||
auto animation = data.find ("animation");
|
auto animation = data.find ("animation");
|
||||||
|
@ -17,11 +17,11 @@ class CUserSettingFloat : public CUserSettingValue {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CUserSettingFloat (
|
CUserSettingFloat (
|
||||||
bool hasCondition, float defaultValue, const Projects::CProperty* source, std::string expectedValue);
|
bool hasCondition, float defaultValue, std::shared_ptr <const Projects::CProperty> source, std::string expectedValue);
|
||||||
|
|
||||||
const double m_default;
|
const double m_default;
|
||||||
const bool m_hasCondition;
|
const bool m_hasCondition;
|
||||||
const Projects::CProperty* m_source;
|
const std::shared_ptr <const Projects::CProperty> m_source;
|
||||||
const std::string m_expectedValue;
|
const std::string m_expectedValue;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::UserSettings
|
} // namespace WallpaperEngine::Core::UserSettings
|
@ -13,7 +13,7 @@ using namespace WallpaperEngine::Core::Projects;
|
|||||||
using namespace WallpaperEngine::Core::UserSettings;
|
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, std::shared_ptr <const Projects::CProperty> source, std::string expectedValue
|
||||||
) :
|
) :
|
||||||
CUserSettingValue (),
|
CUserSettingValue (),
|
||||||
m_hasCondition (hasCondition),
|
m_hasCondition (hasCondition),
|
||||||
@ -35,7 +35,7 @@ CUserSettingVector3::CUserSettingVector3 (
|
|||||||
|
|
||||||
const CUserSettingVector3* CUserSettingVector3::fromJSON (const nlohmann::json& data, const CProject& project) {
|
const CUserSettingVector3* CUserSettingVector3::fromJSON (const nlohmann::json& data, const CProject& project) {
|
||||||
bool hasCondition = false;
|
bool hasCondition = false;
|
||||||
const Projects::CProperty* sourceProperty = nullptr;
|
std::shared_ptr <const Projects::CProperty> sourceProperty = nullptr;
|
||||||
glm::vec3 defaultValue;
|
glm::vec3 defaultValue;
|
||||||
std::string source;
|
std::string source;
|
||||||
std::string expectedValue;
|
std::string expectedValue;
|
||||||
|
@ -19,10 +19,11 @@ class CUserSettingVector3 : public CUserSettingValue {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CUserSettingVector3 (
|
CUserSettingVector3 (
|
||||||
bool hasCondition, glm::vec3 defaultValue, const Projects::CProperty* source, std::string expectedValue);
|
bool hasCondition, glm::vec3 defaultValue, std::shared_ptr<const Projects::CProperty> source,
|
||||||
|
std::string expectedValue);
|
||||||
|
|
||||||
const bool m_hasCondition;
|
const bool m_hasCondition;
|
||||||
const Projects::CProperty* m_source;
|
const std::shared_ptr <const Projects::CProperty> m_source;
|
||||||
const std::string m_expectedValue;
|
const std::string m_expectedValue;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Core::UserSettings
|
} // namespace WallpaperEngine::Core::UserSettings
|
@ -11,7 +11,7 @@ using namespace WallpaperEngine::Core;
|
|||||||
using namespace WallpaperEngine::Core::Wallpapers;
|
using namespace WallpaperEngine::Core::Wallpapers;
|
||||||
|
|
||||||
CScene::CScene (
|
CScene::CScene (
|
||||||
const CProject& project, std::shared_ptr<const CContainer> container, const Scenes::CCamera* camera,
|
std::shared_ptr <const CProject> project, std::shared_ptr<const CContainer> container, const Scenes::CCamera* camera,
|
||||||
glm::vec3 ambientColor, const CUserSettingBoolean* bloom, const CUserSettingFloat* bloomStrength,
|
glm::vec3 ambientColor, const CUserSettingBoolean* bloom, const CUserSettingFloat* bloomStrength,
|
||||||
const CUserSettingFloat* bloomThreshold, bool cameraFade, bool cameraParallax, float cameraParallaxAmount,
|
const CUserSettingFloat* bloomThreshold, bool cameraFade, bool cameraParallax, float cameraParallaxAmount,
|
||||||
float cameraParallaxDelay, float cameraParallaxMouseInfluence, bool cameraPreview, bool cameraShake,
|
float cameraParallaxDelay, float cameraParallaxMouseInfluence, bool cameraPreview, bool cameraShake,
|
||||||
@ -39,7 +39,10 @@ CScene::CScene (
|
|||||||
m_orthogonalProjection (orthogonalProjection),
|
m_orthogonalProjection (orthogonalProjection),
|
||||||
m_skylightColor (skylightColor) {}
|
m_skylightColor (skylightColor) {}
|
||||||
|
|
||||||
const CScene* CScene::fromFile (const std::string& filename, const CProject& project, const std::shared_ptr<const CContainer>& container) {
|
std::shared_ptr <const CScene> CScene::fromFile (
|
||||||
|
const std::string& filename, std::shared_ptr <const Core::CProject> project,
|
||||||
|
const std::shared_ptr<const CContainer>& container
|
||||||
|
) {
|
||||||
json content = json::parse (container->readFileAsString (filename));
|
json content = json::parse (container->readFileAsString (filename));
|
||||||
|
|
||||||
const auto general_it = jsonFindRequired (content, "general", "Scenes must have a general section");
|
const auto general_it = jsonFindRequired (content, "general", "Scenes must have a general section");
|
||||||
@ -48,13 +51,13 @@ const CScene* CScene::fromFile (const std::string& filename, const CProject& pro
|
|||||||
// TODO: FIND IF THESE DEFAULTS ARE SENSIBLE OR NOT AND PERFORM PROPER VALIDATION WHEN CAMERA PREVIEW AND CAMERA
|
// TODO: FIND IF THESE DEFAULTS ARE SENSIBLE OR NOT AND PERFORM PROPER VALIDATION WHEN CAMERA PREVIEW AND CAMERA
|
||||||
// PARALLAX ARE PRESENT
|
// PARALLAX ARE PRESENT
|
||||||
|
|
||||||
auto* scene = new CScene (
|
auto scene = std::make_shared <CScene> (
|
||||||
project, container,
|
project, container,
|
||||||
Scenes::CCamera::fromJSON (jsonFindRequired (content, "camera", "Scenes must have a defined camera")),
|
Scenes::CCamera::fromJSON (jsonFindRequired (content, "camera", "Scenes must have a defined camera")),
|
||||||
jsonFindDefault<glm::vec3> (*general_it, "ambientcolor", glm::vec3 (0, 0, 0)),
|
jsonFindDefault<glm::vec3> (*general_it, "ambientcolor", glm::vec3 (0, 0, 0)),
|
||||||
jsonFindUserConfig<CUserSettingBoolean> (*general_it, project, "bloom", false),
|
jsonFindUserConfig<CUserSettingBoolean> (*general_it, *project, "bloom", false),
|
||||||
jsonFindUserConfig<CUserSettingFloat> (*general_it, project, "bloomstrength", 0.0),
|
jsonFindUserConfig<CUserSettingFloat> (*general_it, *project, "bloomstrength", 0.0),
|
||||||
jsonFindUserConfig<CUserSettingFloat> (*general_it, project, "bloomthreshold", 0.0),
|
jsonFindUserConfig<CUserSettingFloat> (*general_it, *project, "bloomthreshold", 0.0),
|
||||||
jsonFindDefault<bool> (*general_it, "camerafade", false),
|
jsonFindDefault<bool> (*general_it, "camerafade", false),
|
||||||
jsonFindDefault<bool> (*general_it, "cameraparallax", true),
|
jsonFindDefault<bool> (*general_it, "cameraparallax", true),
|
||||||
jsonFindDefault<float> (*general_it, "cameraparallaxamount", 1.0f),
|
jsonFindDefault<float> (*general_it, "cameraparallaxamount", 1.0f),
|
||||||
@ -65,13 +68,13 @@ const CScene* CScene::fromFile (const std::string& filename, const CProject& pro
|
|||||||
jsonFindDefault<float> (*general_it, "camerashakeamplitude", 0.0f),
|
jsonFindDefault<float> (*general_it, "camerashakeamplitude", 0.0f),
|
||||||
jsonFindDefault<float> (*general_it, "camerashakeroughness", 0.0f),
|
jsonFindDefault<float> (*general_it, "camerashakeroughness", 0.0f),
|
||||||
jsonFindDefault<float> (*general_it, "camerashakespeed", 0.0f),
|
jsonFindDefault<float> (*general_it, "camerashakespeed", 0.0f),
|
||||||
jsonFindUserConfig<CUserSettingVector3> (*general_it, project, "clearcolor", {1, 1, 1}),
|
jsonFindUserConfig<CUserSettingVector3> (*general_it, *project, "clearcolor", {1, 1, 1}),
|
||||||
Scenes::CProjection::fromJSON (jsonFindRequired (*general_it, "orthogonalprojection", "General section must have orthogonal projection info")),
|
Scenes::CProjection::fromJSON (jsonFindRequired (*general_it, "orthogonalprojection", "General section must have orthogonal projection info")),
|
||||||
jsonFindDefault<glm::vec3> (*general_it, "skylightcolor", glm::vec3 (0, 0, 0))
|
jsonFindDefault<glm::vec3> (*general_it, "skylightcolor", glm::vec3 (0, 0, 0))
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const auto& cur : *objects_it)
|
for (const auto& cur : *objects_it)
|
||||||
scene->insertObject (CObject::fromJSON (cur, scene, container));
|
scene->insertObject (CObject::fromJSON (cur, project, container));
|
||||||
|
|
||||||
return scene;
|
return scene;
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,21 @@ using json = nlohmann::json;
|
|||||||
|
|
||||||
class CScene : public CWallpaper {
|
class CScene : public CWallpaper {
|
||||||
public:
|
public:
|
||||||
static const CScene* fromFile (const std::string& filename, const CProject& project, const std::shared_ptr<const CContainer>& container);
|
CScene (
|
||||||
|
std::shared_ptr <const Core::CProject> project, std::shared_ptr<const CContainer> container,
|
||||||
|
const Scenes::CCamera* camera, glm::vec3 ambientColor, const CUserSettingBoolean* bloom,
|
||||||
|
const CUserSettingFloat* bloomStrength, const CUserSettingFloat* bloomThreshold, bool cameraFade,
|
||||||
|
bool cameraParallax, float cameraParallaxAmount, float cameraParallaxDelay, float cameraParallaxMouseInfluence,
|
||||||
|
bool cameraPreview, bool cameraShake, float cameraShakeAmplitude, float cameraShakeRoughness,
|
||||||
|
float cameraShakeSpeed, const CUserSettingVector3* clearColor, const Scenes::CProjection* orthogonalProjection,
|
||||||
|
glm::vec3 skylightColor);
|
||||||
|
|
||||||
|
static std::shared_ptr <const CScene> fromFile (
|
||||||
|
const std::string& filename, std::shared_ptr <const Core::CProject> project,
|
||||||
|
const std::shared_ptr<const CContainer>& container);
|
||||||
[[nodiscard]] const std::map<uint32_t, const CObject*>& getObjects () const;
|
[[nodiscard]] const std::map<uint32_t, const CObject*>& getObjects () const;
|
||||||
[[nodiscard]] const std::vector<const CObject*>& getObjectsByRenderOrder () const;
|
|
||||||
|
|
||||||
|
[[nodiscard]] const std::vector<const CObject*>& getObjectsByRenderOrder () const;
|
||||||
[[nodiscard]] const glm::vec3& getAmbientColor () const;
|
[[nodiscard]] const glm::vec3& getAmbientColor () const;
|
||||||
[[nodiscard]] bool isBloom () const;
|
[[nodiscard]] bool isBloom () const;
|
||||||
[[nodiscard]] float getBloomStrength () const;
|
[[nodiscard]] float getBloomStrength () const;
|
||||||
@ -39,18 +49,11 @@ class CScene : public CWallpaper {
|
|||||||
[[nodiscard]] const glm::vec3& getClearColor () const;
|
[[nodiscard]] const glm::vec3& getClearColor () const;
|
||||||
[[nodiscard]] const Scenes::CProjection* getOrthogonalProjection () const;
|
[[nodiscard]] const Scenes::CProjection* getOrthogonalProjection () const;
|
||||||
[[nodiscard]] const glm::vec3& getSkylightColor () const;
|
[[nodiscard]] const glm::vec3& getSkylightColor () const;
|
||||||
|
|
||||||
[[nodiscard]] const Scenes::CCamera* getCamera () const;
|
[[nodiscard]] const Scenes::CCamera* getCamera () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class CWallpaper;
|
|
||||||
|
|
||||||
CScene (
|
friend class CWallpaper;
|
||||||
const CProject& project, std::shared_ptr<const CContainer> container, const Scenes::CCamera* camera,
|
|
||||||
glm::vec3 ambientColor, const CUserSettingBoolean* bloom, const CUserSettingFloat* bloomStrength,
|
|
||||||
const CUserSettingFloat* bloomThreshold, bool cameraFade, bool cameraParallax, float cameraParallaxAmount,
|
|
||||||
float cameraParallaxDelay, float cameraParallaxMouseInfluence, bool cameraPreview, bool cameraShake,
|
|
||||||
float cameraShakeAmplitude, float cameraShakeRoughness, float cameraShakeSpeed,
|
|
||||||
const CUserSettingVector3* clearColor, const Scenes::CProjection* orthogonalProjection, glm::vec3 skylightColor);
|
|
||||||
|
|
||||||
void insertObject (const CObject* object);
|
void insertObject (const CObject* object);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
using namespace WallpaperEngine::Core;
|
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, std::shared_ptr <const CProject> project) :
|
||||||
CWallpaper (project),
|
CWallpaper (project),
|
||||||
m_filename (std::move(filename)) {}
|
m_filename (std::move(filename)) {}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ extern "C" {
|
|||||||
namespace WallpaperEngine::Core::Wallpapers {
|
namespace WallpaperEngine::Core::Wallpapers {
|
||||||
class CVideo : public CWallpaper {
|
class CVideo : public CWallpaper {
|
||||||
public:
|
public:
|
||||||
CVideo (std::string filename, const CProject& project);
|
CVideo (std::string filename, std::shared_ptr <const CProject> project);
|
||||||
|
|
||||||
const std::string& getFilename () const;
|
const std::string& getFilename () const;
|
||||||
|
|
||||||
|
@ -9,6 +9,6 @@ const std::string& CWeb::getFilename () const {
|
|||||||
return this->m_filename;
|
return this->m_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
CWeb::CWeb (std::string filename, const CProject& project) :
|
CWeb::CWeb (std::string filename, std::shared_ptr <const CProject> project) :
|
||||||
CWallpaper (project),
|
CWallpaper (project),
|
||||||
m_filename (std::move(filename)) {}
|
m_filename (std::move(filename)) {}
|
||||||
|
@ -19,7 +19,7 @@ extern "C"
|
|||||||
namespace WallpaperEngine::Core::Wallpapers {
|
namespace WallpaperEngine::Core::Wallpapers {
|
||||||
class CWeb : public CWallpaper {
|
class CWeb : public CWallpaper {
|
||||||
public:
|
public:
|
||||||
CWeb (std::string filename, const CProject& project);
|
CWeb (std::string filename, std::shared_ptr <const CProject> project);
|
||||||
|
|
||||||
const std::string& getFilename () const;
|
const std::string& getFilename () const;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ void CRenderContext::render (Drivers::Output::COutputViewport* viewport) {
|
|||||||
viewport->swapOutput ();
|
viewport->swapOutput ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRenderContext::setWallpaper (const std::string& display, CWallpaper* wallpaper) {
|
void CRenderContext::setWallpaper (const std::string& display, std::shared_ptr <CWallpaper> wallpaper) {
|
||||||
this->m_wallpapers.insert_or_assign (display, wallpaper);
|
this->m_wallpapers.insert_or_assign (display, wallpaper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ std::shared_ptr<const ITexture> CRenderContext::resolveTexture (const std::strin
|
|||||||
return this->m_textureCache->resolve (name);
|
return this->m_textureCache->resolve (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<std::string, CWallpaper*>& CRenderContext::getWallpapers () const {
|
const std::map<std::string, std::shared_ptr <CWallpaper>>& CRenderContext::getWallpapers () const {
|
||||||
return this->m_wallpapers;
|
return this->m_wallpapers;
|
||||||
}
|
}
|
||||||
} // namespace WallpaperEngine::Render
|
} // namespace WallpaperEngine::Render
|
||||||
|
@ -35,20 +35,20 @@ class CRenderContext {
|
|||||||
CRenderContext (Drivers::CVideoDriver& driver, CWallpaperApplication& app);
|
CRenderContext (Drivers::CVideoDriver& driver, CWallpaperApplication& app);
|
||||||
|
|
||||||
void render (Drivers::Output::COutputViewport* viewport);
|
void render (Drivers::Output::COutputViewport* viewport);
|
||||||
void setWallpaper (const std::string& display, CWallpaper* wallpaper);
|
void setWallpaper (const std::string& display, std::shared_ptr <CWallpaper> wallpaper);
|
||||||
void setPause (bool newState);
|
void setPause (bool newState);
|
||||||
[[nodiscard]] Input::CInputContext& getInputContext () const;
|
[[nodiscard]] Input::CInputContext& getInputContext () const;
|
||||||
[[nodiscard]] const CWallpaperApplication& getApp () const;
|
[[nodiscard]] const CWallpaperApplication& getApp () const;
|
||||||
[[nodiscard]] const Drivers::CVideoDriver& getDriver () const;
|
[[nodiscard]] const Drivers::CVideoDriver& getDriver () const;
|
||||||
[[nodiscard]] const Drivers::Output::COutput& getOutput () const;
|
[[nodiscard]] const Drivers::Output::COutput& getOutput () const;
|
||||||
std::shared_ptr<const ITexture> resolveTexture (const std::string& name);
|
std::shared_ptr<const ITexture> resolveTexture (const std::string& name);
|
||||||
[[nodiscard]] const std::map<std::string, CWallpaper*>& getWallpapers () const;
|
[[nodiscard]] const std::map<std::string, std::shared_ptr <CWallpaper>>& getWallpapers () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Video driver in use */
|
/** Video driver in use */
|
||||||
Drivers::CVideoDriver& m_driver;
|
Drivers::CVideoDriver& m_driver;
|
||||||
/** Maps screen -> wallpaper list */
|
/** Maps screen -> wallpaper list */
|
||||||
std::map<std::string, CWallpaper*> m_wallpapers = {};
|
std::map<std::string, std::shared_ptr <CWallpaper>> m_wallpapers = {};
|
||||||
/** App that holds the render context */
|
/** App that holds the render context */
|
||||||
CWallpaperApplication& m_app;
|
CWallpaperApplication& m_app;
|
||||||
/** Texture cache for the render */
|
/** Texture cache for the render */
|
||||||
|
@ -6,26 +6,16 @@
|
|||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
using namespace WallpaperEngine::Render;
|
using namespace WallpaperEngine::Render;
|
||||||
|
|
||||||
CWallpaper::CWallpaper (
|
CWallpaper::CWallpaper (
|
||||||
const Core::CWallpaper* wallpaperData, CRenderContext& context,CAudioContext& audioContext,
|
std::shared_ptr <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
|
||||||
) :
|
) :
|
||||||
CContextAware (context),
|
CContextAware (context),
|
||||||
m_wallpaperData (wallpaperData),
|
m_wallpaperData (wallpaperData),
|
||||||
m_sceneFBO (nullptr),
|
|
||||||
m_texCoordBuffer (GL_NONE),
|
|
||||||
m_positionBuffer (GL_NONE),
|
|
||||||
m_shader (GL_NONE),
|
|
||||||
g_Texture0 (GL_NONE),
|
|
||||||
a_Position (GL_NONE),
|
|
||||||
a_TexCoord (GL_NONE),
|
|
||||||
m_vaoBuffer (GL_NONE),
|
|
||||||
m_destFramebuffer (GL_NONE),
|
|
||||||
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
|
||||||
@ -52,10 +42,10 @@ CWallpaper::CWallpaper (
|
|||||||
CWallpaper::~CWallpaper () = default;
|
CWallpaper::~CWallpaper () = default;
|
||||||
|
|
||||||
std::shared_ptr<const CContainer> CWallpaper::getContainer () const {
|
std::shared_ptr<const CContainer> CWallpaper::getContainer () const {
|
||||||
return this->m_wallpaperData->getProject ().getContainer ();
|
return this->m_wallpaperData->getProject ()->getContainer ();
|
||||||
}
|
}
|
||||||
|
|
||||||
const WallpaperEngine::Core::CWallpaper* CWallpaper::getWallpaperData () const {
|
std::shared_ptr <const WallpaperEngine::Core::CWallpaper> CWallpaper::getWallpaperData () const {
|
||||||
return this->m_wallpaperData;
|
return this->m_wallpaperData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,20 +275,20 @@ std::shared_ptr<const CFBO> CWallpaper::getFBO () const {
|
|||||||
return this->m_sceneFBO;
|
return this->m_sceneFBO;
|
||||||
}
|
}
|
||||||
|
|
||||||
CWallpaper* CWallpaper::fromWallpaper (
|
std::shared_ptr<CWallpaper> CWallpaper::fromWallpaper (
|
||||||
const Core::CWallpaper* wallpaper, CRenderContext& context, CAudioContext& audioContext,
|
std::shared_ptr<const Core::CWallpaper> wallpaper, CRenderContext& context, CAudioContext& audioContext,
|
||||||
WebBrowser::CWebBrowserContext& browserContext, const CWallpaperState::TextureUVsScaling& scalingMode,
|
WebBrowser::CWebBrowserContext& browserContext, const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
||||||
) {
|
) {
|
||||||
if (wallpaper->is<Core::Wallpapers::CScene> ()) {
|
if (wallpaper->is<Core::Wallpapers::CScene> ()) {
|
||||||
return new WallpaperEngine::Render::Wallpapers::CScene (
|
return std::make_shared <WallpaperEngine::Render::Wallpapers::CScene> (
|
||||||
wallpaper->as<Core::Wallpapers::CScene> (), context, audioContext, scalingMode, clampMode);
|
wallpaper, context, audioContext, scalingMode, clampMode);
|
||||||
} else if (wallpaper->is<Core::Wallpapers::CVideo> ()) {
|
} else if (wallpaper->is<Core::Wallpapers::CVideo> ()) {
|
||||||
return new WallpaperEngine::Render::Wallpapers::CVideo (
|
return std::make_shared<WallpaperEngine::Render::Wallpapers::CVideo> (
|
||||||
wallpaper->as<Core::Wallpapers::CVideo> (), context, audioContext, scalingMode, clampMode);
|
wallpaper, context, audioContext, scalingMode, clampMode);
|
||||||
} else if (wallpaper->is<Core::Wallpapers::CWeb> ()) {
|
} else if (wallpaper->is<Core::Wallpapers::CWeb> ()) {
|
||||||
return new WallpaperEngine::Render::Wallpapers::CWeb (
|
return std::make_shared<WallpaperEngine::Render::Wallpapers::CWeb> (
|
||||||
wallpaper->as<Core::Wallpapers::CWeb> (), context, audioContext, browserContext, scalingMode, clampMode);
|
wallpaper, context, audioContext, browserContext, scalingMode, clampMode);
|
||||||
} else
|
} else
|
||||||
sLog.exception ("Unsupported wallpaper type");
|
sLog.exception ("Unsupported wallpaper type");
|
||||||
}
|
}
|
||||||
|
@ -153,15 +153,15 @@ class CWallpaper : public Helpers::CContextAware {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static CWallpaper* fromWallpaper (
|
static std::shared_ptr<CWallpaper> fromWallpaper (
|
||||||
const Core::CWallpaper* wallpaper, CRenderContext& context, CAudioContext& audioContext,
|
std::shared_ptr<const Core::CWallpaper> wallpaper, CRenderContext& context, CAudioContext& audioContext,
|
||||||
WebBrowser::CWebBrowserContext& browserContext, const CWallpaperState::TextureUVsScaling& scalingMode,
|
WebBrowser::CWebBrowserContext& browserContext, const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CWallpaper (
|
CWallpaper (
|
||||||
const Core::CWallpaper* wallpaperData, CRenderContext& context, CAudioContext& audioContext,
|
std::shared_ptr <const WallpaperEngine::Core::CWallpaper> wallpaperData, CRenderContext& context,
|
||||||
const CWallpaperState::TextureUVsScaling& scalingMode,
|
CAudioContext& audioContext, const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -174,9 +174,9 @@ class CWallpaper : public Helpers::CContextAware {
|
|||||||
*/
|
*/
|
||||||
void setupFramebuffers ();
|
void setupFramebuffers ();
|
||||||
|
|
||||||
const Core::CWallpaper* m_wallpaperData;
|
std::shared_ptr <const WallpaperEngine::Core::CWallpaper> m_wallpaperData;
|
||||||
|
|
||||||
[[nodiscard]] const Core::CWallpaper* getWallpaperData () const;
|
[[nodiscard]] std::shared_ptr <const WallpaperEngine::Core::CWallpaper> getWallpaperData () const;
|
||||||
|
|
||||||
/** The FBO used for scene output */
|
/** The FBO used for scene output */
|
||||||
std::shared_ptr<const CFBO> m_sceneFBO = nullptr;
|
std::shared_ptr<const CFBO> m_sceneFBO = nullptr;
|
||||||
|
@ -236,7 +236,7 @@ void CImage::setup () {
|
|||||||
new CEffect (
|
new CEffect (
|
||||||
this,
|
this,
|
||||||
new Core::Objects::CEffect (
|
new Core::Objects::CEffect (
|
||||||
"", "", "", "", this->m_image->getScene ()->getProject (),
|
"", "", "", "", this->m_image->getProject (),
|
||||||
Core::UserSettings::CUserSettingBoolean::fromScalar (true),
|
Core::UserSettings::CUserSettingBoolean::fromScalar (true),
|
||||||
{}, {}, {})),
|
{}, {}, {})),
|
||||||
this->m_image->getMaterial ()
|
this->m_image->getMaterial ()
|
||||||
@ -272,7 +272,7 @@ void CImage::setup () {
|
|||||||
new CEffect (
|
new CEffect (
|
||||||
this,
|
this,
|
||||||
new Core::Objects::CEffect (
|
new Core::Objects::CEffect (
|
||||||
"", "", "", "", this->m_image->getScene ()->getProject (),
|
"", "", "", "", this->m_image->getProject (),
|
||||||
Core::UserSettings::CUserSettingBoolean::fromScalar (true), {}, {}, {}
|
Core::UserSettings::CUserSettingBoolean::fromScalar (true), {}, {}, {}
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -17,14 +17,13 @@ using namespace WallpaperEngine::Render;
|
|||||||
using namespace WallpaperEngine::Render::Wallpapers;
|
using namespace WallpaperEngine::Render::Wallpapers;
|
||||||
|
|
||||||
CScene::CScene (
|
CScene::CScene (
|
||||||
const Core::Wallpapers::CScene* scene, CRenderContext& context, CAudioContext& audioContext,
|
std::shared_ptr<const Core::CWallpaper> wallpaper, CRenderContext& context, CAudioContext& audioContext,
|
||||||
const CWallpaperState::TextureUVsScaling& scalingMode,
|
const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
||||||
) :
|
) :
|
||||||
CWallpaper (scene, context, audioContext, scalingMode, clampMode),
|
CWallpaper (wallpaper, context, audioContext, scalingMode, clampMode) {
|
||||||
m_mousePosition (),
|
// caller should check this, if not a std::bad_cast is good to throw
|
||||||
m_mousePositionLast (),
|
const auto& scene = wallpaper->as <Core::Wallpapers::CScene> ();
|
||||||
m_parallaxDisplacement () {
|
|
||||||
// setup the scene camera
|
// setup the scene camera
|
||||||
this->m_camera = new CCamera (this, scene->getCamera ());
|
this->m_camera = new CCamera (this, scene->getCamera ());
|
||||||
|
|
||||||
@ -151,7 +150,7 @@ CScene::CScene (
|
|||||||
// create image for bloom passes
|
// create image for bloom passes
|
||||||
if (this->getScene ()->isBloom ()) {
|
if (this->getScene ()->isBloom ()) {
|
||||||
this->m_bloomObject = this->createObject (
|
this->m_bloomObject = this->createObject (
|
||||||
WallpaperEngine::Core::CObject::fromJSON (json, this->getScene (), this->getContainer ()));
|
WallpaperEngine::Core::CObject::fromJSON (json, scene->getProject (), this->getContainer ()));
|
||||||
|
|
||||||
this->m_objectsByRenderOrder.push_back (this->m_bloomObject);
|
this->m_objectsByRenderOrder.push_back (this->m_bloomObject);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace WallpaperEngine::Render::Wallpapers {
|
|||||||
class CScene final : public CWallpaper {
|
class CScene final : public CWallpaper {
|
||||||
public:
|
public:
|
||||||
CScene (
|
CScene (
|
||||||
const Core::Wallpapers::CScene* scene, CRenderContext& context, CAudioContext& audioContext,
|
std::shared_ptr<const Core::CWallpaper> wallpaper, CRenderContext& context, CAudioContext& audioContext,
|
||||||
const CWallpaperState::TextureUVsScaling& scalingMode,
|
const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
||||||
|
|
||||||
|
@ -12,11 +12,11 @@ void* get_proc_address (void* ctx, const char* name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CVideo::CVideo (
|
CVideo::CVideo (
|
||||||
const Core::Wallpapers::CVideo* video, CRenderContext& context, CAudioContext& audioContext,
|
std::shared_ptr<const Core::CWallpaper> wallpaper, CRenderContext& context, CAudioContext& audioContext,
|
||||||
const CWallpaperState::TextureUVsScaling& scalingMode,
|
const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode
|
||||||
) :
|
) :
|
||||||
CWallpaper (video, context, audioContext, scalingMode, clampMode) {
|
CWallpaper (wallpaper, context, audioContext, scalingMode, clampMode) {
|
||||||
double volume = this->getContext ().getApp ().getContext ().settings.audio.volume * 100.0 / 128.0;
|
double volume = this->getContext ().getApp ().getContext ().settings.audio.volume * 100.0 / 128.0;
|
||||||
|
|
||||||
// create mpv contexts
|
// create mpv contexts
|
||||||
@ -54,7 +54,7 @@ CVideo::CVideo (
|
|||||||
sLog.exception ("Failed to initialize MPV's GL context");
|
sLog.exception ("Failed to initialize MPV's GL context");
|
||||||
|
|
||||||
const std::filesystem::path videopath =
|
const std::filesystem::path videopath =
|
||||||
this->getVideo ()->getProject ().getContainer ()->resolveRealFile (this->getVideo ()->getFilename ());
|
this->getVideo ()->getProject ()->getContainer ()->resolveRealFile (this->getVideo ()->getFilename ());
|
||||||
|
|
||||||
// build the path to the video file
|
// build the path to the video file
|
||||||
const char* command [] = {"loadfile", videopath.c_str (), nullptr};
|
const char* command [] = {"loadfile", videopath.c_str (), nullptr};
|
||||||
|
@ -11,7 +11,7 @@ namespace WallpaperEngine::Render::Wallpapers {
|
|||||||
class CVideo final : public CWallpaper {
|
class CVideo final : public CWallpaper {
|
||||||
public:
|
public:
|
||||||
CVideo (
|
CVideo (
|
||||||
const Core::Wallpapers::CVideo* video, CRenderContext& context, CAudioContext& audioContext,
|
std::shared_ptr<const Core::CWallpaper> video, CRenderContext& context, CAudioContext& audioContext,
|
||||||
const CWallpaperState::TextureUVsScaling& scalingMode,
|
const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@ using namespace WallpaperEngine::WebBrowser;
|
|||||||
using namespace WallpaperEngine::WebBrowser::CEF;
|
using namespace WallpaperEngine::WebBrowser::CEF;
|
||||||
|
|
||||||
CWeb::CWeb (
|
CWeb::CWeb (
|
||||||
const Core::Wallpapers::CWeb* web, CRenderContext& context, CAudioContext& audioContext,
|
std::shared_ptr<const Core::CWallpaper> wallpaper, CRenderContext& context, CAudioContext& audioContext,
|
||||||
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, context, audioContext, scalingMode, clampMode),
|
CWallpaper (wallpaper, context, audioContext, scalingMode, clampMode),
|
||||||
m_browserContext (browserContext) {
|
m_browserContext (browserContext) {
|
||||||
// setup framebuffers
|
// setup framebuffers
|
||||||
this->setupFramebuffers ();
|
this->setupFramebuffers ();
|
||||||
@ -32,7 +32,7 @@ CWeb::CWeb (
|
|||||||
this->m_client = new WebBrowser::CEF::CBrowserClient (m_renderHandler);
|
this->m_client = new WebBrowser::CEF::CBrowserClient (m_renderHandler);
|
||||||
// use the custom scheme for the wallpaper's files
|
// use the custom scheme for the wallpaper's files
|
||||||
const std::string htmlURL =
|
const std::string htmlURL =
|
||||||
CWPSchemeHandlerFactory::generateSchemeName(this->getWeb ()->getProject ().getWorkshopId ()) +
|
CWPSchemeHandlerFactory::generateSchemeName(this->getWeb ()->getProject ()->getWorkshopId ()) +
|
||||||
"://root/" +
|
"://root/" +
|
||||||
this->getWeb()->getFilename ();
|
this->getWeb()->getFilename ();
|
||||||
this->m_browser =
|
this->m_browser =
|
||||||
|
@ -25,7 +25,7 @@ class CWeb : public CWallpaper
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CWeb (
|
CWeb (
|
||||||
const Core::Wallpapers::CWeb* scene, CRenderContext& context, CAudioContext& audioContext,
|
std::shared_ptr<const Core::CWallpaper> wallpaper, CRenderContext& context, CAudioContext& audioContext,
|
||||||
WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext,
|
WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext,
|
||||||
const CWallpaperState::TextureUVsScaling& scalingMode,
|
const CWallpaperState::TextureUVsScaling& scalingMode,
|
||||||
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
const WallpaperEngine::Assets::ITexture::TextureFlags& clampMode);
|
||||||
|
@ -9,12 +9,8 @@ using namespace WallpaperEngine::Assets;
|
|||||||
using namespace WallpaperEngine::WebBrowser::CEF;
|
using namespace WallpaperEngine::WebBrowser::CEF;
|
||||||
|
|
||||||
CWPSchemeHandler::CWPSchemeHandler(std::shared_ptr<const Core::CProject> project) :
|
CWPSchemeHandler::CWPSchemeHandler(std::shared_ptr<const Core::CProject> project) :
|
||||||
m_project (project),
|
m_project (project) {
|
||||||
m_contents (nullptr),
|
this->m_container = this->m_project->getWallpaper ()->getProject ()->getContainer ();
|
||||||
m_filesize (0),
|
|
||||||
m_mimeType (),
|
|
||||||
m_offset (0) {
|
|
||||||
this->m_container = this->m_project->getWallpaper ()->getProject ().getContainer ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWPSchemeHandler::Open(CefRefPtr<CefRequest> request,
|
bool CWPSchemeHandler::Open(CefRefPtr<CefRequest> request,
|
||||||
|
Loading…
Reference in New Issue
Block a user