mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-13 21:02:34 +08:00
Image color and alpha can now be user-settings
Removed old Color structures not useful anymore Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
cd40950ade
commit
176470dad9
@ -113,13 +113,14 @@ add_executable(
|
||||
src/WallpaperEngine/FileSystem/FileSystem.cpp
|
||||
src/WallpaperEngine/FileSystem/FileSystem.h
|
||||
|
||||
src/WallpaperEngine/Core/Types/FloatColor.h
|
||||
src/WallpaperEngine/Core/Types/IntegerColor.h
|
||||
|
||||
src/WallpaperEngine/Core/UserSettings/CUserSettingValue.cpp
|
||||
src/WallpaperEngine/Core/UserSettings/CUserSettingValue.h
|
||||
src/WallpaperEngine/Core/UserSettings/CUserSettingBoolean.cpp
|
||||
src/WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h
|
||||
src/WallpaperEngine/Core/UserSettings/CUserSettingColor.cpp
|
||||
src/WallpaperEngine/Core/UserSettings/CUserSettingColor.h
|
||||
src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.cpp
|
||||
src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.h
|
||||
|
||||
src/WallpaperEngine/Core/CProject.cpp
|
||||
src/WallpaperEngine/Core/CProject.h
|
||||
|
2
main.cpp
2
main.cpp
@ -26,8 +26,6 @@ float g_Time;
|
||||
bool g_KeepRunning = true;
|
||||
int g_AudioVolume = 15;
|
||||
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
const char* assets_default_paths [] = {
|
||||
".steam/steam/steamapps/common/wallpaper_engine/assets",
|
||||
".local/share/Steam/steamapps/common/wallpaper_engine/assets",
|
||||
|
@ -2,16 +2,14 @@
|
||||
#include "CProject.h"
|
||||
|
||||
#include "WallpaperEngine/FileSystem/FileSystem.h"
|
||||
#include "WallpaperEngine/Core/Types/FloatColor.h"
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h"
|
||||
|
||||
using namespace WallpaperEngine::Core;
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
CScene::CScene (
|
||||
CContainer* container,
|
||||
Scenes::CCamera* camera,
|
||||
FloatColor ambientColor,
|
||||
glm::vec3 ambientColor,
|
||||
CUserSettingBoolean* bloom,
|
||||
double bloomStrength,
|
||||
double bloomThreshold,
|
||||
@ -25,9 +23,9 @@ CScene::CScene (
|
||||
double cameraShakeAmplitude,
|
||||
double cameraShakeRoughness,
|
||||
double cameraShakeSpeed,
|
||||
FloatColor clearColor,
|
||||
glm::vec3 clearColor,
|
||||
Scenes::CProjection* orthogonalProjection,
|
||||
FloatColor skylightColor) :
|
||||
glm::vec3 skylightColor) :
|
||||
CWallpaper (Type),
|
||||
m_container (container),
|
||||
m_camera (camera),
|
||||
@ -150,7 +148,7 @@ const Scenes::CCamera* CScene::getCamera () const
|
||||
return this->m_camera;
|
||||
}
|
||||
|
||||
const FloatColor &CScene::getAmbientColor() const
|
||||
const glm::vec3 &CScene::getAmbientColor() const
|
||||
{
|
||||
return this->m_ambientColor;
|
||||
}
|
||||
@ -220,7 +218,7 @@ const double CScene::getCameraShakeSpeed () const
|
||||
return this->m_cameraShakeSpeed;
|
||||
}
|
||||
|
||||
const FloatColor& CScene::getClearColor () const
|
||||
const glm::vec3& CScene::getClearColor () const
|
||||
{
|
||||
return this->m_clearColor;
|
||||
}
|
||||
@ -230,7 +228,7 @@ Scenes::CProjection* CScene::getOrthogonalProjection () const
|
||||
return this->m_orthogonalProjection;
|
||||
}
|
||||
|
||||
const FloatColor& CScene::getSkylightColor () const
|
||||
const glm::vec3& CScene::getSkylightColor () const
|
||||
{
|
||||
return this->m_skylightColor;
|
||||
}
|
||||
|
@ -7,12 +7,10 @@
|
||||
|
||||
#include "WallpaperEngine/Core/Scenes/CCamera.h"
|
||||
#include "WallpaperEngine/Core/Scenes/CProjection.h"
|
||||
#include "WallpaperEngine/Core/Types/FloatColor.h"
|
||||
|
||||
namespace WallpaperEngine::Core
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
class CObject;
|
||||
|
||||
@ -24,7 +22,7 @@ namespace WallpaperEngine::Core
|
||||
const std::map<uint32_t, CObject*>& getObjects () const;
|
||||
const std::vector<CObject*>& getObjectsByRenderOrder () const;
|
||||
|
||||
const FloatColor& getAmbientColor() const;
|
||||
const glm::vec3& getAmbientColor() const;
|
||||
const bool isBloom() const;
|
||||
const double getBloomStrength() const;
|
||||
const double getBloomThreshold() const;
|
||||
@ -38,9 +36,9 @@ namespace WallpaperEngine::Core
|
||||
const double getCameraShakeAmplitude() const;
|
||||
const double getCameraShakeRoughness() const;
|
||||
const double getCameraShakeSpeed() const;
|
||||
const FloatColor& getClearColor() const;
|
||||
const glm::vec3& getClearColor() const;
|
||||
Scenes::CProjection* getOrthogonalProjection() const;
|
||||
const FloatColor& getSkylightColor() const;
|
||||
const glm::vec3& getSkylightColor() const;
|
||||
const Scenes::CCamera* getCamera () const;
|
||||
|
||||
protected:
|
||||
@ -49,7 +47,7 @@ namespace WallpaperEngine::Core
|
||||
CScene (
|
||||
CContainer* container,
|
||||
Scenes::CCamera* camera,
|
||||
FloatColor ambientColor,
|
||||
glm::vec3 ambientColor,
|
||||
CUserSettingBoolean* bloom,
|
||||
double bloomStrength,
|
||||
double bloomThreshold,
|
||||
@ -63,9 +61,9 @@ namespace WallpaperEngine::Core
|
||||
double cameraShakeAmplitude,
|
||||
double cameraShakeRoughness,
|
||||
double cameraShakeSpeed,
|
||||
FloatColor clearColor,
|
||||
glm::vec3 clearColor,
|
||||
Scenes::CProjection* orthogonalProjection,
|
||||
FloatColor skylightColor
|
||||
glm::vec3 skylightColor
|
||||
);
|
||||
|
||||
static const std::string Type;
|
||||
@ -78,7 +76,7 @@ namespace WallpaperEngine::Core
|
||||
Scenes::CCamera* m_camera;
|
||||
|
||||
// data from general section on the json
|
||||
FloatColor m_ambientColor;
|
||||
glm::vec3 m_ambientColor;
|
||||
CUserSettingBoolean* m_bloom;
|
||||
double m_bloomStrength;
|
||||
double m_bloomThreshold;
|
||||
@ -92,9 +90,9 @@ namespace WallpaperEngine::Core
|
||||
double m_cameraShakeAmplitude;
|
||||
double m_cameraShakeRoughness;
|
||||
double m_cameraShakeSpeed;
|
||||
FloatColor m_clearColor;
|
||||
glm::vec3 m_clearColor;
|
||||
Scenes::CProjection* m_orthogonalProjection;
|
||||
FloatColor m_skylightColor;
|
||||
glm::vec3 m_skylightColor;
|
||||
|
||||
std::map<uint32_t, CObject*> m_objects;
|
||||
std::vector<CObject*> m_objectsByRenderOrder;
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "Core.h"
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
glm::vec4 Core::aToVector4 (const char* str)
|
||||
{
|
||||
@ -45,32 +44,32 @@ glm::vec2 Core::aToVector2 (const std::string& str)
|
||||
return Core::aToVector2 (str.c_str ());
|
||||
}
|
||||
|
||||
FloatColor Core::aToColorf (const char* str)
|
||||
glm::vec3 Core::aToColorf (const char* str)
|
||||
{
|
||||
float r = strtof (str, const_cast<char **>(&str)); while (*str == ' ') str ++;
|
||||
float g = strtof (str, const_cast<char **>(&str)); while (*str == ' ') str ++;
|
||||
float b = strtof (str, const_cast<char **>(&str));
|
||||
|
||||
return {r, g, b, 1.0f};
|
||||
return {r, g, b};
|
||||
}
|
||||
|
||||
FloatColor Core::aToColorf (const std::string& str)
|
||||
glm::vec3 Core::aToColorf (const std::string& str)
|
||||
{
|
||||
return aToColorf(str.c_str());
|
||||
return aToColorf (str.c_str ());
|
||||
}
|
||||
|
||||
IntegerColor Core::aToColori (const char* str)
|
||||
glm::ivec3 Core::aToColori (const char* str)
|
||||
{
|
||||
uint8_t r = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10)); while (*str == ' ') str ++;
|
||||
uint8_t g = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10)); while (*str == ' ') str ++;
|
||||
uint8_t b = static_cast <uint8_t> (strtol (str, const_cast<char **>(&str), 10));
|
||||
|
||||
return {r, g, b, 255};
|
||||
return {r, g, b};
|
||||
}
|
||||
|
||||
IntegerColor Core::aToColori (const std::string& str)
|
||||
glm::ivec3 Core::aToColori (const std::string& str)
|
||||
{
|
||||
return aToColori(str.c_str());
|
||||
return aToColori (str.c_str ());
|
||||
}
|
||||
|
||||
nlohmann::json::iterator Core::jsonFindRequired (nlohmann::json& data, const char *key, const char *notFoundMsg)
|
||||
|
@ -6,13 +6,8 @@
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
|
||||
#include "WallpaperEngine/Core/Types/FloatColor.h"
|
||||
#include "WallpaperEngine/Core/Types/IntegerColor.h"
|
||||
|
||||
namespace WallpaperEngine::Core
|
||||
{
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
glm::vec4 aToVector4 (const char* str);
|
||||
glm::vec3 aToVector3 (const char* str);
|
||||
glm::vec2 aToVector2 (const char* str);
|
||||
@ -21,11 +16,11 @@ namespace WallpaperEngine::Core
|
||||
glm::vec3 aToVector3 (const std::string& str);
|
||||
glm::vec2 aToVector2 (const std::string& str);
|
||||
|
||||
FloatColor aToColorf (const char* str);
|
||||
FloatColor aToColorf (const std::string& str);
|
||||
glm::vec3 aToColorf (const char* str);
|
||||
glm::vec3 aToColorf (const std::string& str);
|
||||
|
||||
IntegerColor aToColori (const char* str);
|
||||
IntegerColor aToColori (const std::string& str);
|
||||
glm::ivec3 aToColori (const char* str);
|
||||
glm::ivec3 aToColori (const std::string& str);
|
||||
|
||||
nlohmann::json::iterator jsonFindRequired (nlohmann::json& data, const char *key, const char *notFoundMsg);
|
||||
nlohmann::json::iterator jsonFindRequired (nlohmann::json::iterator& data, const char *key, const char *notFoundMsg);
|
||||
|
@ -1,8 +1,11 @@
|
||||
#include "CImage.h"
|
||||
|
||||
#include <utility>
|
||||
#include "WallpaperEngine/Core/CScene.h"
|
||||
#include "WallpaperEngine/Core/Objects/Images/CMaterial.h"
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h"
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingColor.h"
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingFloat.h"
|
||||
|
||||
#include "WallpaperEngine/FileSystem/FileSystem.h"
|
||||
|
||||
@ -20,8 +23,8 @@ CImage::CImage (
|
||||
const glm::vec3& angles,
|
||||
const glm::vec2& size,
|
||||
std::string alignment,
|
||||
const glm::vec3& color,
|
||||
float alpha,
|
||||
CUserSettingColor* color,
|
||||
CUserSettingFloat* alpha,
|
||||
float brightness,
|
||||
uint32_t colorBlendMode,
|
||||
const glm::vec2& parallaxDepth
|
||||
@ -52,8 +55,22 @@ WallpaperEngine::Core::CObject* CImage::fromJSON (
|
||||
auto image_it = data.find ("image");
|
||||
auto size_val = jsonFindDefault <std::string> (data, "size", "0.0 0.0"); // this one might need some adjustment
|
||||
auto alignment = jsonFindDefault <std::string> (data, "alignment", "center");
|
||||
auto alpha = jsonFindDefault <float> (data, "alpha", 1.0);
|
||||
auto color_val = jsonFindDefault <std::string> (data, "color", "1.0 1.0 1.0");
|
||||
auto alpha_it = data.find ("alpha");
|
||||
CUserSettingFloat* alpha;
|
||||
|
||||
if (alpha_it == data.end ())
|
||||
alpha = CUserSettingFloat::fromScalar (1.0);
|
||||
else
|
||||
alpha = CUserSettingFloat::fromJSON (*alpha_it);
|
||||
|
||||
auto color_it = data.find ("color");
|
||||
CUserSettingColor* color;
|
||||
|
||||
if (color_it == data.end ())
|
||||
color = CUserSettingColor::fromScalar ({1, 1, 1});
|
||||
else
|
||||
color = CUserSettingColor::fromJSON (*color_it);
|
||||
|
||||
auto brightness_val = jsonFindDefault <float> (data, "brightness", 1.0);
|
||||
auto colorBlendMode_val = jsonFindDefault <uint32_t> (data, "colorBlendMode", 0);
|
||||
auto parallaxDepth_val = jsonFindDefault <std::string> (data, "parallaxDepth", "0 0");
|
||||
@ -73,7 +90,7 @@ WallpaperEngine::Core::CObject* CImage::fromJSON (
|
||||
angles,
|
||||
WallpaperEngine::Core::aToVector2 (size_val),
|
||||
alignment,
|
||||
WallpaperEngine::Core::aToVector3 (color_val),
|
||||
color,
|
||||
alpha,
|
||||
brightness_val,
|
||||
colorBlendMode_val,
|
||||
@ -98,12 +115,12 @@ const std::string& CImage::getAlignment () const
|
||||
|
||||
const float CImage::getAlpha () const
|
||||
{
|
||||
return this->m_alpha;
|
||||
return this->m_alpha->processValue (this->getScene ()->getProject ()->getProperties ());
|
||||
}
|
||||
|
||||
const glm::vec3& CImage::getColor () const
|
||||
glm::vec3 CImage::getColor () const
|
||||
{
|
||||
return this->m_color;
|
||||
return this->m_color->processValue (this->getScene ()->getProject ()->getProperties ());
|
||||
}
|
||||
|
||||
const float CImage::getBrightness () const
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "WallpaperEngine/Assets/CContainer.h"
|
||||
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h"
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingColor.h"
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingFloat.h"
|
||||
|
||||
namespace WallpaperEngine::Core
|
||||
{
|
||||
@ -40,7 +42,7 @@ namespace WallpaperEngine::Core::Objects
|
||||
const glm::vec2& getSize () const;
|
||||
const std::string& getAlignment () const;
|
||||
const float getAlpha () const;
|
||||
const glm::vec3& getColor () const;
|
||||
glm::vec3 getColor () const;
|
||||
const float getBrightness () const;
|
||||
const uint32_t getColorBlendMode () const;
|
||||
const glm::vec2& getParallaxDepth () const;
|
||||
@ -57,8 +59,8 @@ namespace WallpaperEngine::Core::Objects
|
||||
const glm::vec3& angles,
|
||||
const glm::vec2& size,
|
||||
std::string alignment,
|
||||
const glm::vec3& color,
|
||||
float alpha,
|
||||
CUserSettingColor* color,
|
||||
CUserSettingFloat* alpha,
|
||||
float brightness,
|
||||
uint32_t colorBlendMode,
|
||||
const glm::vec2& parallaxDepth
|
||||
@ -71,9 +73,9 @@ namespace WallpaperEngine::Core::Objects
|
||||
const glm::vec2 m_parallaxDepth;
|
||||
Images::CMaterial* m_material;
|
||||
std::string m_alignment;
|
||||
float m_alpha;
|
||||
CUserSettingFloat* m_alpha;
|
||||
float m_brightness;
|
||||
glm::vec3 m_color;
|
||||
CUserSettingColor* m_color;
|
||||
uint32_t m_colorBlendMode;
|
||||
};
|
||||
};
|
||||
|
@ -15,19 +15,19 @@ CColorRandom* CColorRandom::fromJSON (json data, uint32_t id)
|
||||
}
|
||||
|
||||
|
||||
CColorRandom::CColorRandom (uint32_t id, IntegerColor min, IntegerColor max) :
|
||||
CColorRandom::CColorRandom (uint32_t id, glm::ivec3 min, glm::ivec3 max) :
|
||||
CInitializer (id, "colorrandom"),
|
||||
m_min (min),
|
||||
m_max (max)
|
||||
{
|
||||
}
|
||||
|
||||
const IntegerColor& CColorRandom::getMinimum () const
|
||||
const glm::ivec3& CColorRandom::getMinimum () const
|
||||
{
|
||||
return this->m_min;
|
||||
}
|
||||
|
||||
const IntegerColor& CColorRandom::getMaximum () const
|
||||
const glm::ivec3& CColorRandom::getMaximum () const
|
||||
{
|
||||
return this->m_max;
|
||||
}
|
@ -6,21 +6,19 @@
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Particles::Initializers
|
||||
{
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
class CColorRandom : CInitializer
|
||||
{
|
||||
public:
|
||||
const IntegerColor& getMinimum () const;
|
||||
const IntegerColor& getMaximum () const;
|
||||
const glm::ivec3& getMinimum () const;
|
||||
const glm::ivec3& getMaximum () const;
|
||||
protected:
|
||||
friend class CInitializer;
|
||||
|
||||
static CColorRandom* fromJSON (json data, uint32_t id);
|
||||
|
||||
CColorRandom (uint32_t id, IntegerColor min, IntegerColor max);
|
||||
CColorRandom (uint32_t id, glm::ivec3 min, glm::ivec3 max);
|
||||
private:
|
||||
IntegerColor m_max;
|
||||
IntegerColor m_min;
|
||||
glm::ivec3 m_max;
|
||||
glm::ivec3 m_min;
|
||||
};
|
||||
};
|
||||
|
@ -4,17 +4,22 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Projects;
|
||||
|
||||
FloatColor ParseColor (const std::string& value)
|
||||
glm::vec3 ParseColor (std::string value)
|
||||
{
|
||||
if (value.find (',') != std::string::npos)
|
||||
{
|
||||
// replace commas with dots so it can be parsed
|
||||
std::replace (value.begin (), value.end (), ',', ' ');
|
||||
}
|
||||
|
||||
if (value.find ('.') == std::string::npos && value != "0 0 0" && value != "1 1 1")
|
||||
{
|
||||
IntegerColor intcolor = WallpaperEngine::Core::aToColori (value);
|
||||
glm::ivec3 intcolor = WallpaperEngine::Core::aToColori (value);
|
||||
|
||||
return {
|
||||
intcolor.r / 255.0,
|
||||
intcolor.g / 255.0,
|
||||
intcolor.b / 255.0,
|
||||
intcolor.a / 255.0
|
||||
intcolor.b / 255.0
|
||||
};
|
||||
}
|
||||
|
||||
@ -33,17 +38,16 @@ CPropertyColor* CPropertyColor::fromJSON (json data, const std::string& name)
|
||||
);
|
||||
}
|
||||
|
||||
const FloatColor& CPropertyColor::getValue () const
|
||||
const glm::vec3& CPropertyColor::getValue () const
|
||||
{
|
||||
return this->m_color;
|
||||
}
|
||||
|
||||
void CPropertyColor::update (const std::string& value)
|
||||
{
|
||||
this->m_color = ParseColor (value);
|
||||
this->m_color = ParseColor (std::string (value));
|
||||
}
|
||||
|
||||
|
||||
std::string CPropertyColor::dump () const
|
||||
{
|
||||
std::stringstream ss;
|
||||
@ -54,13 +58,12 @@ std::string CPropertyColor::dump () const
|
||||
<< "\t"
|
||||
<< "R: " << this->m_color.r
|
||||
<< " G: " << this->m_color.g
|
||||
<< " B: " << this->m_color.b
|
||||
<< " A: " << this->m_color.a;
|
||||
<< " B: " << this->m_color.b;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
CPropertyColor::CPropertyColor (FloatColor color, const std::string& name, const std::string& text) :
|
||||
CPropertyColor::CPropertyColor (glm::vec3 color, const std::string& name, const std::string& text) :
|
||||
CProperty (name, Type, text),
|
||||
m_color (color)
|
||||
{
|
||||
|
@ -7,22 +7,21 @@
|
||||
namespace WallpaperEngine::Core::Projects
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
class CPropertyColor : public CProperty
|
||||
{
|
||||
public:
|
||||
static CPropertyColor* fromJSON (json data, const std::string& name);
|
||||
|
||||
const FloatColor& getValue () const;
|
||||
const glm::vec3& getValue () const;
|
||||
std::string dump () const override;
|
||||
void update (const std::string& value) override;
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
CPropertyColor (FloatColor color, const std::string& name, const std::string& text);
|
||||
CPropertyColor (glm::vec3 color, const std::string& name, const std::string& text);
|
||||
|
||||
FloatColor m_color;
|
||||
glm::vec3 m_color;
|
||||
};
|
||||
};
|
||||
|
@ -7,7 +7,6 @@
|
||||
namespace WallpaperEngine::Core::Projects
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
class CPropertySlider : public CProperty
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "CCamera.h"
|
||||
|
||||
using namespace WallpaperEngine::Core::Scenes;
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
CCamera::CCamera (glm::vec3 center, glm::vec3 eye, glm::vec3 up) :
|
||||
m_center (center),
|
||||
|
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace WallpaperEngine::Core::Types
|
||||
{
|
||||
class FloatColor
|
||||
{
|
||||
public:
|
||||
FloatColor (double r, double g, double b, double a) :
|
||||
r(r), g(g), b(b), a(a) { }
|
||||
|
||||
/**
|
||||
* The red color
|
||||
*/
|
||||
double r;
|
||||
/**
|
||||
* The green color
|
||||
*/
|
||||
double g;
|
||||
/**
|
||||
* The blue color
|
||||
*/
|
||||
double b;
|
||||
/**
|
||||
* The alpha
|
||||
*/
|
||||
double a;
|
||||
};
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace WallpaperEngine::Core::Types
|
||||
{
|
||||
class IntegerColor
|
||||
{
|
||||
public:
|
||||
IntegerColor (uint8_t r, uint8_t g, uint8_t b, uint8_t a) :
|
||||
r(r), g(g), b(b), a(a) { }
|
||||
|
||||
/**
|
||||
* The red color
|
||||
*/
|
||||
uint8_t r;
|
||||
/**
|
||||
* The green color
|
||||
*/
|
||||
uint8_t g;
|
||||
/**
|
||||
* The blue color
|
||||
*/
|
||||
uint8_t b;
|
||||
/**
|
||||
* The alpha
|
||||
*/
|
||||
uint8_t a;
|
||||
};
|
||||
}
|
100
src/WallpaperEngine/Core/UserSettings/CUserSettingColor.cpp
Normal file
100
src/WallpaperEngine/Core/UserSettings/CUserSettingColor.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
#include "CUserSettingColor.h"
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
#include "WallpaperEngine/Core/Projects/CProperty.h"
|
||||
#include "WallpaperEngine/Core/Projects/CPropertyColor.h"
|
||||
|
||||
using namespace WallpaperEngine::Core;
|
||||
using namespace WallpaperEngine::Core::Projects;
|
||||
using namespace WallpaperEngine::Core::UserSettings;
|
||||
|
||||
CUserSettingColor::CUserSettingColor (bool hasCondition, bool hasSource, glm::vec3 defaultValue, std::string source, std::string expectedValue) :
|
||||
CUserSettingValue (Type),
|
||||
m_hasCondition (hasCondition),
|
||||
m_hasSource(hasSource),
|
||||
m_default(defaultValue),
|
||||
m_source (std::move(source)),
|
||||
m_expectedValue(std::move(expectedValue))
|
||||
{
|
||||
}
|
||||
|
||||
CUserSettingColor* CUserSettingColor::fromJSON (nlohmann::json& data)
|
||||
{
|
||||
bool hasCondition = false;
|
||||
bool hasSource = false;
|
||||
glm::vec3 defaultValue;
|
||||
std::string source;
|
||||
std::string expectedValue;
|
||||
|
||||
std::string json = data.dump ();
|
||||
|
||||
if (data.is_object () == true)
|
||||
{
|
||||
hasSource = true;
|
||||
auto userIt = data.find ("user");
|
||||
defaultValue = WallpaperEngine::Core::aToColorf (jsonFindDefault <std::string> (data, "value", "").c_str ()); // is this default value right?
|
||||
|
||||
if (userIt != data.end ())
|
||||
{
|
||||
if (userIt->is_string ())
|
||||
{
|
||||
source = *userIt;
|
||||
}
|
||||
else
|
||||
{
|
||||
hasCondition = true;
|
||||
source = *jsonFindRequired (userIt, "name", "Name for conditional setting must be present");
|
||||
expectedValue = *jsonFindRequired (userIt, "condition", "Condition for conditional setting must be present");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "Float color property doesn't have user member, this could mean an scripted value\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.is_string () == false)
|
||||
throw std::runtime_error ("Expected float color value on user settings");
|
||||
|
||||
defaultValue = WallpaperEngine::Core::aToColorf (data.get <std::string> ().c_str ());
|
||||
}
|
||||
|
||||
return new CUserSettingColor (hasCondition, hasSource, defaultValue, source, expectedValue);
|
||||
}
|
||||
|
||||
CUserSettingColor* CUserSettingColor::fromScalar (glm::vec3 value)
|
||||
{
|
||||
return new CUserSettingColor (false, false, value, "", "");
|
||||
}
|
||||
|
||||
glm::vec3 CUserSettingColor::getDefaultValue ()
|
||||
{
|
||||
return this->m_default;
|
||||
}
|
||||
|
||||
glm::vec3 CUserSettingColor::processValue (const std::vector<Projects::CProperty*>& properties)
|
||||
{
|
||||
if (this->m_hasSource == false && this->m_hasCondition == false)
|
||||
return this->getDefaultValue ();
|
||||
|
||||
for (auto cur : properties)
|
||||
{
|
||||
if (cur->getName () != this->m_source)
|
||||
continue;
|
||||
|
||||
if (this->m_hasCondition == false)
|
||||
{
|
||||
if (cur->is <CPropertyColor> ())
|
||||
return cur->as <CPropertyColor> ()->getValue ();
|
||||
|
||||
throw std::runtime_error ("Property without condition must match type (color)");
|
||||
}
|
||||
|
||||
throw std::runtime_error ("Color property with condition doesn't match against combo value");
|
||||
}
|
||||
|
||||
return this->m_default;
|
||||
}
|
||||
|
||||
std::string CUserSettingColor::Type = "color";
|
33
src/WallpaperEngine/Core/UserSettings/CUserSettingColor.h
Normal file
33
src/WallpaperEngine/Core/UserSettings/CUserSettingColor.h
Normal file
@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
#include "CUserSettingValue.h"
|
||||
|
||||
namespace WallpaperEngine::Core::Projects
|
||||
{
|
||||
class CProperty;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Core::UserSettings
|
||||
{
|
||||
class CUserSettingColor : public CUserSettingValue
|
||||
{
|
||||
public:
|
||||
static CUserSettingColor* fromJSON (nlohmann::json& data);
|
||||
static CUserSettingColor* fromScalar (glm::vec3 value);
|
||||
static std::string Type;
|
||||
|
||||
glm::vec3 processValue (const std::vector<Projects::CProperty*>& properties);
|
||||
glm::vec3 getDefaultValue ();
|
||||
|
||||
private:
|
||||
CUserSettingColor (bool hasCondition, bool hasSource, glm::vec3 defaultValue, std::string source, std::string expectedValue);
|
||||
|
||||
glm::vec3 m_default;
|
||||
bool m_hasCondition;
|
||||
bool m_hasSource;
|
||||
std::string m_source;
|
||||
std::string m_expectedValue;
|
||||
};
|
||||
}
|
98
src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.cpp
Normal file
98
src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
#include "CUserSettingFloat.h"
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
|
||||
#include "WallpaperEngine/Core/Projects/CProperty.h"
|
||||
#include "WallpaperEngine/Core/Projects/CPropertySlider.h"
|
||||
|
||||
using namespace WallpaperEngine::Core;
|
||||
using namespace WallpaperEngine::Core::Projects;
|
||||
using namespace WallpaperEngine::Core::UserSettings;
|
||||
|
||||
CUserSettingFloat::CUserSettingFloat (bool hasCondition, bool hasSource, double defaultValue, std::string source, std::string expectedValue) :
|
||||
CUserSettingValue (Type),
|
||||
m_hasCondition (hasCondition),
|
||||
m_hasSource(hasSource),
|
||||
m_default(defaultValue),
|
||||
m_source (std::move(source)),
|
||||
m_expectedValue(std::move(expectedValue))
|
||||
{
|
||||
}
|
||||
|
||||
CUserSettingFloat* CUserSettingFloat::fromJSON (nlohmann::json& data)
|
||||
{
|
||||
bool hasCondition = false;
|
||||
bool hasSource = false;
|
||||
double defaultValue = false;
|
||||
std::string source;
|
||||
std::string expectedValue;
|
||||
|
||||
if (data.is_object () == true)
|
||||
{
|
||||
hasSource = true;
|
||||
auto userIt = data.find ("user");
|
||||
defaultValue = jsonFindDefault (data, "value", 1.0); // is this default value right?
|
||||
|
||||
if (userIt != data.end ())
|
||||
{
|
||||
if (userIt->is_string ())
|
||||
{
|
||||
source = *userIt;
|
||||
}
|
||||
else
|
||||
{
|
||||
hasCondition = true;
|
||||
source = *jsonFindRequired (userIt, "name", "Name for conditional setting must be present");
|
||||
expectedValue = *jsonFindRequired (userIt, "condition", "Condition for conditional setting must be present");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "Boolean property doesn't have user member, this could mean an scripted value");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.is_number () == false)
|
||||
throw std::runtime_error ("Expected numeric value on user settings");
|
||||
|
||||
defaultValue = data.get<double> ();
|
||||
}
|
||||
|
||||
return new CUserSettingFloat (hasCondition, hasSource, defaultValue, source, expectedValue);
|
||||
}
|
||||
|
||||
CUserSettingFloat* CUserSettingFloat::fromScalar (double value)
|
||||
{
|
||||
return new CUserSettingFloat (false, false, value, "", "");
|
||||
}
|
||||
|
||||
double CUserSettingFloat::getDefaultValue ()
|
||||
{
|
||||
return this->m_default;
|
||||
}
|
||||
|
||||
double CUserSettingFloat::processValue (const std::vector<Projects::CProperty*>& properties)
|
||||
{
|
||||
if (this->m_hasSource == false && this->m_hasCondition == false)
|
||||
return this->getDefaultValue ();
|
||||
|
||||
for (auto cur : properties)
|
||||
{
|
||||
if (cur->getName () != this->m_source)
|
||||
continue;
|
||||
|
||||
if (this->m_hasCondition == false)
|
||||
{
|
||||
if (cur->is <CPropertySlider> ())
|
||||
return cur->as <CPropertySlider> ()->getValue ();
|
||||
|
||||
throw std::runtime_error ("Property without condition must match type (slider)");
|
||||
}
|
||||
|
||||
throw std::runtime_error ("Boolean property with condition doesn't match against combo value");
|
||||
}
|
||||
|
||||
return this->m_default;
|
||||
}
|
||||
|
||||
std::string CUserSettingFloat::Type = "float";
|
31
src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.h
Normal file
31
src/WallpaperEngine/Core/UserSettings/CUserSettingFloat.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include "CUserSettingValue.h"
|
||||
|
||||
namespace WallpaperEngine::Core::Projects
|
||||
{
|
||||
class CProperty;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Core::UserSettings
|
||||
{
|
||||
class CUserSettingFloat : public CUserSettingValue
|
||||
{
|
||||
public:
|
||||
static CUserSettingFloat* fromJSON (nlohmann::json& data);
|
||||
static CUserSettingFloat* fromScalar (double value);
|
||||
static std::string Type;
|
||||
|
||||
double processValue (const std::vector<Projects::CProperty*>& properties);
|
||||
double getDefaultValue ();
|
||||
|
||||
private:
|
||||
CUserSettingFloat (bool hasCondition, bool hasSource, double defaultValue, std::string source, std::string expectedValue);
|
||||
|
||||
double m_default;
|
||||
bool m_hasCondition;
|
||||
bool m_hasSource;
|
||||
std::string m_source;
|
||||
std::string m_expectedValue;
|
||||
};
|
||||
}
|
@ -5,7 +5,6 @@
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
using namespace WallpaperEngine::Render;
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
CCamera::CCamera (CScene* scene, const Core::Scenes::CCamera* camera) :
|
||||
m_camera (camera),
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
#include "WallpaperEngine/Core/Scenes/CCamera.h"
|
||||
|
||||
using namespace WallpaperEngine::Core::Types;
|
||||
|
||||
namespace WallpaperEngine::Render
|
||||
{
|
||||
class CScene;
|
||||
|
@ -42,7 +42,7 @@ CScene::CScene (Core::CScene* scene, CContext* context) :
|
||||
);
|
||||
|
||||
// set clear color
|
||||
FloatColor clearColor = this->getScene ()->getClearColor ();
|
||||
glm::vec3 clearColor = this->getScene ()->getClearColor ();
|
||||
|
||||
glClearColor (clearColor.r, clearColor.g, clearColor.b, 1.0f);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user