~ changed all iterators to auto

~ changed most pointers to const references to prevent modification, specially from the background parser

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2019-09-10 11:02:45 +02:00
parent 3371e10b01
commit 3587fdec1e
76 changed files with 636 additions and 618 deletions

View File

@ -53,8 +53,8 @@ void initialize_viewports ()
if (info == nullptr) if (info == nullptr)
continue; continue;
std::vector<std::string>::iterator cur = Screens.begin (); auto cur = Screens.begin ();
std::vector<std::string>::iterator end = Screens.end (); auto end = Screens.end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -318,8 +318,8 @@ int main (int argc, char* argv[])
if (Viewports.size () > 0) if (Viewports.size () > 0)
{ {
std::vector<irr::core::rect<irr::s32>>::iterator cur = Viewports.begin (); auto cur = Viewports.begin ();
std::vector<irr::core::rect<irr::s32>>::iterator end = Viewports.end (); auto end = Viewports.end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {

View File

@ -29,13 +29,13 @@ CObject::CObject (
CObject* CObject::fromJSON (json data) CObject* CObject::fromJSON (json data)
{ {
json::const_iterator id_it = data.find ("id"); auto id_it = data.find ("id");
json::const_iterator visible_it = data.find ("visible"); auto visible_it = data.find ("visible");
json::const_iterator origin_it = data.find ("origin"); auto origin_it = data.find ("origin");
json::const_iterator scale_it = data.find ("scale"); auto scale_it = data.find ("scale");
json::const_iterator angles_it = data.find ("angles"); auto angles_it = data.find ("angles");
json::const_iterator name_it = data.find ("name"); auto name_it = data.find ("name");
json::const_iterator effects_it = data.find ("effects"); auto effects_it = data.find ("effects");
bool visible = true; bool visible = true;
@ -70,9 +70,9 @@ CObject* CObject::fromJSON (json data)
visible = *visible_it; visible = *visible_it;
} }
json::const_iterator image_it = data.find ("image"); auto image_it = data.find ("image");
json::const_iterator sound_it = data.find ("sound"); auto sound_it = data.find ("sound");
json::const_iterator particle_it = data.find ("particle"); auto particle_it = data.find ("particle");
CObject* object = nullptr; CObject* object = nullptr;
@ -117,8 +117,8 @@ CObject* CObject::fromJSON (json data)
if (effects_it != data.end () && (*effects_it).is_array () == true) if (effects_it != data.end () && (*effects_it).is_array () == true)
{ {
json::const_iterator cur = (*effects_it).begin (); auto cur = (*effects_it).begin ();
json::const_iterator end = (*effects_it).end (); auto end = (*effects_it).end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -131,29 +131,29 @@ CObject* CObject::fromJSON (json data)
return object; return object;
} }
irr::core::vector3df* CObject::getOrigin () const irr::core::vector3df& CObject::getOrigin () const
{ {
return &this->m_origin; return this->m_origin;
} }
irr::core::vector3df* CObject::getScale () const irr::core::vector3df& CObject::getScale () const
{ {
return &this->m_scale; return this->m_scale;
} }
irr::core::vector3df* CObject::getAngles () const irr::core::vector3df& CObject::getAngles () const
{ {
return &this->m_angles; return this->m_angles;
} }
std::string CObject::getName () const std::string& CObject::getName () const
{ {
return this->m_name; return this->m_name;
} }
std::vector<Objects::CEffect*>* CObject::getEffects () const std::vector<Objects::CEffect*>& CObject::getEffects () const
{ {
return &this->m_effects; return this->m_effects;
} }
bool CObject::isVisible () bool CObject::isVisible ()
@ -161,7 +161,7 @@ bool CObject::isVisible ()
return this->m_visible; return this->m_visible;
} }
int CObject::getId () const int CObject::getId () const
{ {
return this->m_id; return this->m_id;
} }

View File

@ -19,18 +19,18 @@ namespace WallpaperEngine::Core
public: public:
static CObject* fromJSON (json data); static CObject* fromJSON (json data);
template<class T> const T* As () const { assert (Is<T> ()); return (const T*) this; } template<class T> const T* as () const { assert (is <T> ()); return (const T*) this; }
template<class T> T* As () { assert (Is<T> ()); return (T*) this; } template<class T> T* as () { assert (is <T> ()); return (T*) this; }
template<class T> bool Is () { return this->m_type == T::Type; } template<class T> bool is () { return this->m_type == T::Type; }
std::vector<Objects::CEffect*>* getEffects (); const std::vector<Objects::CEffect*>& getEffects () const;
int getId (); const int getId () const;
irr::core::vector3df* getOrigin (); const irr::core::vector3df& getOrigin () const;
irr::core::vector3df* getScale (); const irr::core::vector3df& getScale () const;
irr::core::vector3df* getAngles (); const irr::core::vector3df& getAngles () const;
std::string getName (); const std::string& getName () const;
bool isVisible (); bool isVisible ();
protected: protected:

View File

@ -16,10 +16,10 @@ CProject* CProject::fromFile (const irr::io::path& filename)
{ {
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename)); json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename));
json::const_iterator title = content.find ("title"); auto title = content.find ("title");
json::const_iterator type = content.find ("type"); auto type = content.find ("type");
json::const_iterator file = content.find ("file"); auto file = content.find ("file");
json::const_iterator general = content.find ("general"); auto general = content.find ("general");
if (title == content.end ()) if (title == content.end ())
{ {
@ -44,12 +44,12 @@ CProject* CProject::fromFile (const irr::io::path& filename)
if (general != content.end ()) if (general != content.end ())
{ {
json::const_iterator properties = (*general).find ("properties"); auto properties = (*general).find ("properties");
if (properties != (*general).end ()) if (properties != (*general).end ())
{ {
json::const_iterator cur = (*properties).begin (); auto cur = (*properties).begin ();
json::const_iterator end = (*properties).end (); auto end = (*properties).end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -63,24 +63,24 @@ CProject* CProject::fromFile (const irr::io::path& filename)
return project; return project;
} }
CScene* CProject::getScene () const CScene* CProject::getScene () const
{ {
return this->m_scene; return this->m_scene;
} }
std::string CProject::getTitle () const std::string& CProject::getTitle () const
{ {
return this->m_title; return this->m_title;
} }
std::string CProject::getType () const std::string& CProject::getType () const
{ {
return this->m_type; return this->m_type;
} }
std::vector<Projects::CProperty*>* CProject::getProperties () const std::vector<Projects::CProperty*>& CProject::getProperties () const
{ {
return &this->m_properties; return this->m_properties;
} }
void CProject::insertProperty (Projects::CProperty* property) void CProject::insertProperty (Projects::CProperty* property)

View File

@ -17,11 +17,11 @@ namespace WallpaperEngine::Core
public: public:
static CProject* fromFile (const irr::io::path& filename); static CProject* fromFile (const irr::io::path& filename);
CScene* getScene (); const CScene* getScene () const;
std::string getTitle (); const std::string& getTitle () const;
std::string getType (); const std::string& getType () const;
std::vector<Projects::CProperty*>* getProperties (); const std::vector<Projects::CProperty*>& getProperties () const;
protected: protected:
CProject (std::string title, std::string type, CScene* scene); CProject (std::string title, std::string type, CScene* scene);

View File

@ -50,9 +50,9 @@ CScene* CScene::fromFile (const irr::io::path& filename)
{ {
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename)); json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename));
json::const_iterator camera_it = content.find ("camera"); auto camera_it = content.find ("camera");
json::const_iterator general_it = content.find ("general"); auto general_it = content.find ("general");
json::const_iterator objects_it = content.find ("objects"); auto objects_it = content.find ("objects");
if (camera_it == content.end ()) if (camera_it == content.end ())
{ {
@ -69,23 +69,23 @@ CScene* CScene::fromFile (const irr::io::path& filename)
throw std::runtime_error ("Scenes must have a list of objects to display"); throw std::runtime_error ("Scenes must have a list of objects to display");
} }
json::const_iterator ambientcolor_it = (*general_it).find ("ambientcolor"); auto ambientcolor_it = (*general_it).find ("ambientcolor");
json::const_iterator bloom_it = (*general_it).find ("bloom"); auto bloom_it = (*general_it).find ("bloom");
json::const_iterator bloomstrength_it = (*general_it).find ("bloomstrength"); auto bloomstrength_it = (*general_it).find ("bloomstrength");
json::const_iterator bloomthreshold_it = (*general_it).find ("bloomthreshold"); auto bloomthreshold_it = (*general_it).find ("bloomthreshold");
json::const_iterator camerafade_it = (*general_it).find ("camerafade"); auto camerafade_it = (*general_it).find ("camerafade");
json::const_iterator cameraparallax_it = (*general_it).find ("cameraparallax"); auto cameraparallax_it = (*general_it).find ("cameraparallax");
json::const_iterator cameraparallaxamount_it = (*general_it).find ("cameraparallaxamount"); auto cameraparallaxamount_it = (*general_it).find ("cameraparallaxamount");
json::const_iterator cameraparallaxdelay_it = (*general_it).find ("cameraparallaxdelay"); auto cameraparallaxdelay_it = (*general_it).find ("cameraparallaxdelay");
json::const_iterator cameraparallaxmouseinfluence_it = (*general_it).find ("cameraparallaxmouseinfluence"); auto cameraparallaxmouseinfluence_it = (*general_it).find ("cameraparallaxmouseinfluence");
json::const_iterator camerapreview_it = (*general_it).find ("camerapreview"); auto camerapreview_it = (*general_it).find ("camerapreview");
json::const_iterator camerashake_it = (*general_it).find ("camerashake"); auto camerashake_it = (*general_it).find ("camerashake");
json::const_iterator camerashakeamplitude_it = (*general_it).find ("camerashakeamplitude"); auto camerashakeamplitude_it = (*general_it).find ("camerashakeamplitude");
json::const_iterator camerashakeroughness_it = (*general_it).find ("camerashakeroughness"); auto camerashakeroughness_it = (*general_it).find ("camerashakeroughness");
json::const_iterator camerashakespeed_it = (*general_it).find ("camerashakespeed"); auto camerashakespeed_it = (*general_it).find ("camerashakespeed");
json::const_iterator clearcolor_it = (*general_it).find ("clearcolor"); auto clearcolor_it = (*general_it).find ("clearcolor");
json::const_iterator orthogonalprojection_it = (*general_it).find ("orthogonalprojection"); auto orthogonalprojection_it = (*general_it).find ("orthogonalprojection");
json::const_iterator skylightcolor_it = (*general_it).find ("skylightcolor"); auto skylightcolor_it = (*general_it).find ("skylightcolor");
if (ambientcolor_it == (*general_it).end ()) if (ambientcolor_it == (*general_it).end ())
{ {
@ -193,8 +193,8 @@ CScene* CScene::fromFile (const irr::io::path& filename)
WallpaperEngine::Core::atoSColorf (*skylightcolor_it) WallpaperEngine::Core::atoSColorf (*skylightcolor_it)
); );
json::const_iterator cur = (*objects_it).begin (); auto cur = (*objects_it).begin ();
json::const_iterator end = (*objects_it).end (); auto end = (*objects_it).end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -207,9 +207,9 @@ CScene* CScene::fromFile (const irr::io::path& filename)
} }
std::vector<CObject*>* CScene::getObjects () const std::vector<CObject*>& CScene::getObjects () const
{ {
return &this->m_objects; return this->m_objects;
} }
void CScene::insertObject (CObject* object) void CScene::insertObject (CObject* object)
@ -227,7 +227,7 @@ void CScene::setProject (CProject* project)
this->m_project = project; this->m_project = project;
} }
Scenes::CCamera* CScene::getCamera () const Scenes::CCamera* CScene::getCamera () const
{ {
return this->m_camera; return this->m_camera;
} }
@ -237,82 +237,82 @@ const irr::video::SColorf &CScene::getAmbientColor() const
return this->m_ambientColor; return this->m_ambientColor;
} }
bool CScene::isBloom () const const bool CScene::isBloom () const
{ {
return this->m_bloom; return this->m_bloom;
} }
irr::f64 CScene::getBloomStrength () const const irr::f64 CScene::getBloomStrength () const
{ {
return this->m_bloomStrength; return this->m_bloomStrength;
} }
irr::f64 CScene::getBloomThreshold () const const irr::f64 CScene::getBloomThreshold () const
{ {
return this->m_bloomThreshold; return this->m_bloomThreshold;
} }
bool CScene::isCameraFade () const const bool CScene::isCameraFade () const
{ {
return this->m_cameraFade; return this->m_cameraFade;
} }
bool CScene::isCameraParallax () const const bool CScene::isCameraParallax () const
{ {
return this->m_cameraParallax; return this->m_cameraParallax;
} }
irr::f64 CScene::getCameraParallaxAmount () const const irr::f64 CScene::getCameraParallaxAmount () const
{ {
return this->m_cameraParallaxAmount; return this->m_cameraParallaxAmount;
} }
irr::f64 CScene::getCameraParallaxDelay () const const irr::f64 CScene::getCameraParallaxDelay () const
{ {
return this->m_cameraParallaxDelay; return this->m_cameraParallaxDelay;
} }
irr::f64 CScene::getCameraParallaxMouseInfluence () const const irr::f64 CScene::getCameraParallaxMouseInfluence () const
{ {
return this->m_cameraParallaxMouseInfluence; return this->m_cameraParallaxMouseInfluence;
} }
bool CScene::isCameraPreview () const const bool CScene::isCameraPreview () const
{ {
return this->m_cameraPreview; return this->m_cameraPreview;
} }
bool CScene::isCameraShake () const const bool CScene::isCameraShake () const
{ {
return this->m_cameraShake; return this->m_cameraShake;
} }
irr::f64 CScene::getCameraShakeAmplitude () const const irr::f64 CScene::getCameraShakeAmplitude () const
{ {
return this->m_cameraShakeAmplitude; return this->m_cameraShakeAmplitude;
} }
irr::f64 CScene::getCameraShakeRoughness () const const irr::f64 CScene::getCameraShakeRoughness () const
{ {
return this->m_cameraShakeRoughness; return this->m_cameraShakeRoughness;
} }
irr::f64 CScene::getCameraShakeSpeed () const const irr::f64 CScene::getCameraShakeSpeed () const
{ {
return this->m_cameraShakeSpeed; return this->m_cameraShakeSpeed;
} }
const irr::video::SColorf &CScene::getClearColor () const const irr::video::SColorf& CScene::getClearColor () const
{ {
return this->m_clearColor; return this->m_clearColor;
} }
Scenes::CProjection* CScene::getOrthogonalProjection () const const Scenes::CProjection* CScene::getOrthogonalProjection () const
{ {
return this->m_orthogonalProjection; return this->m_orthogonalProjection;
} }
const irr::video::SColorf &CScene::getSkylightColor () const const irr::video::SColorf& CScene::getSkylightColor () const
{ {
return this->m_skylightColor; return this->m_skylightColor;
} }

View File

@ -22,26 +22,26 @@ namespace WallpaperEngine::Core
static CScene* fromFile (const irr::io::path& filename); static CScene* fromFile (const irr::io::path& filename);
CProject* getProject (); CProject* getProject ();
std::vector<CObject*>* getObjects (); const std::vector<CObject*>& getObjects () const;
const irr::video::SColorf &getAmbientColor() const; const irr::video::SColorf& getAmbientColor() const;
bool isBloom() const; const bool isBloom() const;
irr::f64 getBloomStrength() const; const irr::f64 getBloomStrength() const;
irr::f64 getBloomThreshold() const; const irr::f64 getBloomThreshold() const;
bool isCameraFade() const; const bool isCameraFade() const;
bool isCameraParallax() const; const bool isCameraParallax() const;
irr::f64 getCameraParallaxAmount() const; const irr::f64 getCameraParallaxAmount() const;
irr::f64 getCameraParallaxDelay() const; const irr::f64 getCameraParallaxDelay() const;
irr::f64 getCameraParallaxMouseInfluence() const; const irr::f64 getCameraParallaxMouseInfluence() const;
bool isCameraPreview() const; const bool isCameraPreview() const;
bool isCameraShake() const; const bool isCameraShake() const;
irr::f64 getCameraShakeAmplitude() const; const irr::f64 getCameraShakeAmplitude() const;
irr::f64 getCameraShakeRoughness() const; const irr::f64 getCameraShakeRoughness() const;
irr::f64 getCameraShakeSpeed() const; const irr::f64 getCameraShakeSpeed() const;
const irr::video::SColorf &getClearColor() const; const irr::video::SColorf& getClearColor() const;
Scenes::CProjection *getOrthogonalProjection() const; const Scenes::CProjection* getOrthogonalProjection() const;
const irr::video::SColorf &getSkylightColor() const; const irr::video::SColorf& getSkylightColor() const;
Scenes::CCamera* getCamera (); const Scenes::CCamera* getCamera () const;
protected: protected:
friend class CProject; friend class CProject;

View File

@ -1,7 +1,9 @@
#include <irrlicht/irrlicht.h> #include <irrlicht/irrlicht.h>
#include "Core.h" #include "Core.h"
irr::core::vector3df WallpaperEngine::Core::ato3vf(const char *str) using namespace WallpaperEngine;
irr::core::vector3df Core::ato3vf(const char *str)
{ {
irr::f32 x = irr::core::fast_atof (str, &str); while (*str == ' ') str ++; irr::f32 x = irr::core::fast_atof (str, &str); while (*str == ' ') str ++;
irr::f32 y = irr::core::fast_atof (str, &str); while (*str == ' ') str ++; irr::f32 y = irr::core::fast_atof (str, &str); while (*str == ' ') str ++;
@ -10,7 +12,7 @@ irr::core::vector3df WallpaperEngine::Core::ato3vf(const char *str)
return irr::core::vector3df (x, y, z); return irr::core::vector3df (x, y, z);
} }
irr::core::vector2df WallpaperEngine::Core::ato2vf (const char *str) irr::core::vector2df Core::ato2vf (const char *str)
{ {
irr::f32 x = irr::core::fast_atof (str, &str); while (*str == ' ') str ++; irr::f32 x = irr::core::fast_atof (str, &str); while (*str == ' ') str ++;
irr::f32 y = irr::core::fast_atof (str, &str); irr::f32 y = irr::core::fast_atof (str, &str);
@ -18,19 +20,19 @@ irr::core::vector2df WallpaperEngine::Core::ato2vf (const char *str)
return irr::core::vector2df (x, y); return irr::core::vector2df (x, y);
} }
irr::core::vector3df WallpaperEngine::Core::ato3vf (const std::string& str) irr::core::vector3df Core::ato3vf (const std::string& str)
{ {
return WallpaperEngine::Core::ato3vf (str.c_str ()); return Core::ato3vf (str.c_str ());
} }
irr::core::vector2df WallpaperEngine::Core::ato2vf (const std::string& str) irr::core::vector2df Core::ato2vf (const std::string& str)
{ {
return WallpaperEngine::Core::ato2vf (str.c_str ()); return Core::ato2vf (str.c_str ());
} }
irr::video::SColorf WallpaperEngine::Core::atoSColorf (const char *str) irr::video::SColorf Core::atoSColorf (const char *str)
{ {
irr::core::vector3df vector = WallpaperEngine::Core::ato3vf (str); irr::core::vector3df vector = Core::ato3vf (str);
return irr::video::SColorf ( return irr::video::SColorf (
vector.X, vector.X,
@ -39,12 +41,12 @@ irr::video::SColorf WallpaperEngine::Core::atoSColorf (const char *str)
); );
} }
irr::video::SColorf WallpaperEngine::Core::atoSColorf (const std::string& str) irr::video::SColorf Core::atoSColorf (const std::string& str)
{ {
return WallpaperEngine::Core::atoSColorf (str.c_str ()); return Core::atoSColorf (str.c_str ());
} }
irr::video::SColor WallpaperEngine::Core::atoSColor (const char *str) irr::video::SColor Core::atoSColor (const char *str)
{ {
irr::f32 r = irr::core::strtoul10 (str, &str); while (*str == ' ') str ++; irr::f32 r = irr::core::strtoul10 (str, &str); while (*str == ' ') str ++;
irr::f32 g = irr::core::strtoul10 (str, &str); while (*str == ' ') str ++; irr::f32 g = irr::core::strtoul10 (str, &str); while (*str == ' ') str ++;
@ -53,7 +55,7 @@ irr::video::SColor WallpaperEngine::Core::atoSColor (const char *str)
return irr::video::SColor (255, r, g, b); return irr::video::SColor (255, r, g, b);
} }
irr::video::SColor WallpaperEngine::Core::atoSColor (const std::string& str) irr::video::SColor Core::atoSColor (const std::string& str)
{ {
return WallpaperEngine::Core::atoSColor (str.c_str ()); return Core::atoSColor (str.c_str ());
} }

View File

@ -28,8 +28,8 @@ CEffect::CEffect (
CEffect* CEffect::fromJSON (json data, Core::CObject* object) CEffect* CEffect::fromJSON (json data, Core::CObject* object)
{ {
json::const_iterator file_it = data.find ("file"); auto file_it = data.find ("file");
json::const_iterator effectpasses_it = data.find ("passes"); auto effectpasses_it = data.find ("passes");
if (file_it == data.end ()) if (file_it == data.end ())
{ {
@ -38,12 +38,12 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile ((*file_it).get <std::string> ().c_str ())); json content = json::parse (WallpaperEngine::FileSystem::loadFullFile ((*file_it).get <std::string> ().c_str ()));
json::const_iterator name_it = content.find ("name"); auto name_it = content.find ("name");
json::const_iterator description_it = content.find ("description"); auto description_it = content.find ("description");
json::const_iterator group_it = content.find ("group"); auto group_it = content.find ("group");
json::const_iterator preview_it = content.find ("preview"); auto preview_it = content.find ("preview");
json::const_iterator passes_it = content.find ("passes"); auto passes_it = content.find ("passes");
json::const_iterator dependencies_it = content.find ("dependencies"); auto dependencies_it = content.find ("dependencies");
if (name_it == content.end ()) if (name_it == content.end ())
{ {
@ -83,12 +83,12 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
object object
); );
json::const_iterator cur = (*passes_it).begin (); auto cur = (*passes_it).begin ();
json::const_iterator end = (*passes_it).end (); auto end = (*passes_it).end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
json::const_iterator materialfile = (*cur).find ("material"); auto materialfile = (*cur).find ("material");
if (materialfile == (*cur).end ()) if (materialfile == (*cur).end ())
{ {
@ -115,13 +115,13 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
for (int passNumber = 0; cur != end; cur ++, passNumber ++) for (int passNumber = 0; cur != end; cur ++, passNumber ++)
{ {
json::const_iterator constants_it = (*cur).find ("constantshadervalues"); auto constants_it = (*cur).find ("constantshadervalues");
if (constants_it == (*cur).end ()) if (constants_it == (*cur).end ())
continue; continue;
json::const_iterator constantCur = (*constants_it).begin (); auto constantCur = (*constants_it).begin ();
json::const_iterator constantEnd = (*constants_it).end (); auto constantEnd = (*constants_it).end ();
for (; constantCur != constantEnd; constantCur ++) for (; constantCur != constantEnd; constantCur ++)
{ {
@ -147,19 +147,19 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
effect->insertConstant (constantCur.key (), constant); effect->insertConstant (constantCur.key (), constant);
} }
json::const_iterator textures_it = (*cur).find ("textures"); auto textures_it = (*cur).find ("textures");
if (textures_it == (*cur).end ()) if (textures_it == (*cur).end ())
continue; continue;
Images::CMaterial* material = effect->getMaterials ()->at (passNumber); Images::CMaterial* material = effect->getMaterials ().at (passNumber);
std::vector<Images::Materials::CPassess*>::const_iterator materialCur = material->getPasses ()->begin (); auto passCur = material->getPasses ().begin ();
std::vector<Images::Materials::CPassess*>::const_iterator materialEnd = material->getPasses ()->end (); auto passEnd = material->getPasses ().end ();
for (; materialCur != materialEnd; materialCur ++) for (; passCur != passEnd; passCur ++)
{ {
json::const_iterator texturesCur = (*textures_it).begin (); auto texturesCur = (*textures_it).begin ();
json::const_iterator texturesEnd = (*textures_it).end (); auto texturesEnd = (*textures_it).end ();
for (int textureNumber = 0; texturesCur != texturesEnd; texturesCur ++) for (int textureNumber = 0; texturesCur != texturesEnd; texturesCur ++)
{ {
@ -167,21 +167,21 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
if ((*texturesCur).is_null () == true) if ((*texturesCur).is_null () == true)
{ {
if (object->Is <CImage> () == false) if (object->is<CImage>() == false)
{ {
throw std::runtime_error ("unexpected null texture for non-image object"); throw std::runtime_error ("unexpected null texture for non-image object");
} }
CImage* image = object->As <CImage> (); CImage* image = object->as<CImage>();
texture = (*(*image->getMaterial ()->getPasses ()->begin ())->getTextures ()->begin ()); texture = (*(*image->getMaterial ()->getPasses ().begin ())->getTextures ()->begin ());
} }
else else
{ {
texture = *texturesCur; texture = *texturesCur;
} }
std::vector<std::string>* passTextures = (*materialCur)->getTextures (); std::vector<std::string>* passTextures = (*passCur)->getTextures ();
if (textureNumber < passTextures->size ()) if (textureNumber < passTextures->size ())
passTextures->at (textureNumber) = texture; passTextures->at (textureNumber) = texture;
@ -198,19 +198,19 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
return effect; return effect;
} }
std::vector<std::string>* CEffect::getDependencies () const std::vector<std::string>& CEffect::getDependencies () const
{ {
return &this->m_dependencies; return this->m_dependencies;
} }
std::vector<Images::CMaterial*>* CEffect::getMaterials () const std::vector<Images::CMaterial*>& CEffect::getMaterials () const
{ {
return &this->m_materials; return this->m_materials;
} }
std::map<std::string, Effects::CShaderConstant*>* CEffect::getConstants () const std::map<std::string, Effects::CShaderConstant*>& CEffect::getConstants () const
{ {
return &this->m_constants; return this->m_constants;
} }
void CEffect::insertDependency (const std::string& dep) void CEffect::insertDependency (const std::string& dep)

View File

@ -29,9 +29,9 @@ namespace WallpaperEngine::Core::Objects
static CEffect* fromJSON (json data, Core::CObject* object); static CEffect* fromJSON (json data, Core::CObject* object);
std::vector<std::string>* getDependencies (); const std::vector<std::string>& getDependencies () const;
std::vector<Images::CMaterial*>* getMaterials (); const std::vector<Images::CMaterial*>& getMaterials () const;
std::map<std::string, Effects::CShaderConstant*>* getConstants (); const std::map<std::string, Effects::CShaderConstant*>& getConstants () const;
protected: protected:
void insertDependency (const std::string& dep); void insertDependency (const std::string& dep);
void insertMaterial (Images::CMaterial* material); void insertMaterial (Images::CMaterial* material);

View File

@ -30,8 +30,8 @@ WallpaperEngine::Core::CObject* CImage::fromJSON (
const irr::core::vector3df& scale, const irr::core::vector3df& scale,
const irr::core::vector3df& angles) const irr::core::vector3df& angles)
{ {
json::const_iterator image_it = data.find ("image"); auto image_it = data.find ("image");
json::const_iterator size_it = data.find ("size"); auto size_it = data.find ("size");
if (size_it == data.end ()) if (size_it == data.end ())
{ {
@ -40,7 +40,7 @@ WallpaperEngine::Core::CObject* CImage::fromJSON (
json content = json::parse (WallpaperEngine::FileSystem::loadFullFile ((*image_it).get <std::string> ().c_str ())); json content = json::parse (WallpaperEngine::FileSystem::loadFullFile ((*image_it).get <std::string> ().c_str ()));
json::const_iterator material_it = content.find ("material"); auto material_it = content.find ("material");
if (material_it == content.end ()) if (material_it == content.end ())
{ {
@ -59,14 +59,14 @@ WallpaperEngine::Core::CObject* CImage::fromJSON (
); );
} }
Images::CMaterial* CImage::getMaterial () const Images::CMaterial* CImage::getMaterial () const
{ {
return this->m_material; return this->m_material;
} }
irr::core::vector2df* CImage::getSize () const irr::core::vector2df& CImage::getSize () const
{ {
return &this->m_size; return this->m_size;
} }

View File

@ -26,8 +26,8 @@ namespace WallpaperEngine::Core::Objects
const irr::core::vector3df& angles const irr::core::vector3df& angles
); );
Images::CMaterial* getMaterial (); const Images::CMaterial* getMaterial () const;
irr::core::vector2df* getSize (); const irr::core::vector2df& getSize () const;
protected: protected:
CImage ( CImage (

View File

@ -13,11 +13,11 @@ CParticle* CParticle::fromFile (
const irr::core::vector3df& scale) const irr::core::vector3df& scale)
{ {
json data = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename)); json data = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename));
json::const_iterator controlpoint_it = data.find ("controlpoint"); auto controlpoint_it = data.find ("controlpoint");
json::const_iterator starttime_it = data.find ("starttime"); auto starttime_it = data.find ("starttime");
json::const_iterator maxcount_it = data.find ("maxcount"); auto maxcount_it = data.find ("maxcount");
json::const_iterator emitter_it = data.find ("emitter"); auto emitter_it = data.find ("emitter");
json::const_iterator initializer_it = data.find ("initializer"); auto initializer_it = data.find ("initializer");
if (starttime_it == data.end ()) if (starttime_it == data.end ())
{ {
@ -50,8 +50,8 @@ CParticle* CParticle::fromFile (
if (controlpoint_it != data.end ()) if (controlpoint_it != data.end ())
{ {
json::const_iterator cur = (*controlpoint_it).begin (); auto cur = (*controlpoint_it).begin ();
json::const_iterator end = (*controlpoint_it).end (); auto end = (*controlpoint_it).end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -61,8 +61,8 @@ CParticle* CParticle::fromFile (
} }
} }
json::const_iterator cur = (*emitter_it).begin (); auto cur = (*emitter_it).begin ();
json::const_iterator end = (*emitter_it).end (); auto end = (*emitter_it).end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -97,19 +97,19 @@ CParticle::CParticle (
{ {
} }
std::vector<Particles::CEmitter*>* CParticle::getEmitters () const std::vector<Particles::CEmitter*>& CParticle::getEmitters () const
{ {
return &this->m_emitters; return this->m_emitters;
} }
std::vector<Particles::CControlPoint*>* CParticle::getControlPoints () const std::vector<Particles::CControlPoint*>& CParticle::getControlPoints () const
{ {
return &this->m_controlpoints; return this->m_controlpoints;
} }
std::vector<Particles::CInitializer*>* CParticle::getInitializers () const std::vector<Particles::CInitializer*>& CParticle::getInitializers () const
{ {
return &this->m_initializers; return this->m_initializers;
} }
void CParticle::insertControlPoint (Particles::CControlPoint* controlpoint) void CParticle::insertControlPoint (Particles::CControlPoint* controlpoint)

View File

@ -26,9 +26,9 @@ namespace WallpaperEngine::Core::Objects
const irr::core::vector3df& scale const irr::core::vector3df& scale
); );
std::vector<Particles::CEmitter*>* getEmitters (); const std::vector<Particles::CEmitter*>& getEmitters () const;
std::vector<Particles::CControlPoint*>* getControlPoints (); const std::vector<Particles::CControlPoint*>& getControlPoints () const;
std::vector<Particles::CInitializer*>* getInitializers (); const std::vector<Particles::CInitializer*>& getInitializers () const;
protected: protected:
CParticle ( CParticle (

View File

@ -25,7 +25,7 @@ WallpaperEngine::Core::CObject* CSound::fromJSON (
const irr::core::vector3df& scale, const irr::core::vector3df& scale,
const irr::core::vector3df& angles) const irr::core::vector3df& angles)
{ {
json::const_iterator sound_it = data.find ("sound"); auto sound_it = data.find ("sound");
if (sound_it == data.end ()) if (sound_it == data.end ())
{ {
@ -46,8 +46,8 @@ WallpaperEngine::Core::CObject* CSound::fromJSON (
angles angles
); );
json::const_iterator cur = (*sound_it).begin (); auto cur = (*sound_it).begin ();
json::const_iterator end = (*sound_it).end (); auto end = (*sound_it).end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -62,9 +62,9 @@ void CSound::insertSound (std::string filename)
this->m_sounds.push_back (filename); this->m_sounds.push_back (filename);
} }
std::vector<std::string>* CSound::getSounds () const std::vector<std::string>& CSound::getSounds () const
{ {
return &this->m_sounds; return this->m_sounds;
} }
const std::string CSound::Type = "sound"; const std::string CSound::Type = "sound";

View File

@ -25,7 +25,7 @@ namespace WallpaperEngine::Core::Objects
); );
void insertSound (std::string filename); void insertSound (std::string filename);
std::vector<std::string>* getSounds (); const std::vector<std::string>& getSounds () const;
protected: protected:
CSound ( CSound (

View File

@ -9,10 +9,10 @@ namespace WallpaperEngine::Core::Objects::Effects
public: public:
CShaderConstant (std::string type); CShaderConstant (std::string type);
template<class T> const T* As () const { assert (Is<T> ()); return (const T*) this; } template<class T> const T* as () const { assert (is <T> ()); return (const T*) this; }
template<class T> T* As () { assert (Is<T> ()); return (T*) this; } template<class T> T* as () { assert (is <T> ()); return (T*) this; }
template<class T> bool Is () { return this->m_type == T::Type; } template<class T> bool is () { return this->m_type == T::Type; }
private: private:
std::string m_type; std::string m_type;

View File

@ -20,7 +20,7 @@ CMaterial* CMaterial::fromFile (irr::io::path filename)
CMaterial* CMaterial::fromJSON (json data) CMaterial* CMaterial::fromJSON (json data)
{ {
json::const_iterator passes_it = data.find ("passes"); auto passes_it = data.find ("passes");
if (passes_it == data.end ()) if (passes_it == data.end ())
{ {
@ -29,8 +29,8 @@ CMaterial* CMaterial::fromJSON (json data)
CMaterial* material = new CMaterial (); CMaterial* material = new CMaterial ();
json::const_iterator cur = (*passes_it).begin (); auto cur = (*passes_it).begin ();
json::const_iterator end = (*passes_it).end (); auto end = (*passes_it).end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -47,7 +47,7 @@ void CMaterial::insertPass (Materials::CPassess* mass)
this->m_passes.push_back (mass); this->m_passes.push_back (mass);
} }
std::vector <Materials::CPassess*>* CMaterial::getPasses () const std::vector <Materials::CPassess*>& CMaterial::getPasses () const
{ {
return &this->m_passes; return this->m_passes;
} }

View File

@ -17,7 +17,7 @@ namespace WallpaperEngine::Core::Objects::Images
void insertPass (Materials::CPassess* mass); void insertPass (Materials::CPassess* mass);
std::vector <Materials::CPassess*>* getPasses (); const std::vector <Materials::CPassess*>& getPasses () const;
protected: protected:
CMaterial (); CMaterial ();
private: private:

View File

@ -11,20 +11,15 @@ CPassess::CPassess (std::string blending, std::string cullmode, std::string dept
{ {
} }
std::vector<std::string>* CPassess::getTextures ()
{
return &this->m_textures;
}
CPassess* CPassess::fromJSON (json data) CPassess* CPassess::fromJSON (json data)
{ {
json::const_iterator blending_it = data.find ("blending"); auto blending_it = data.find ("blending");
json::const_iterator cullmode_it = data.find ("cullmode"); auto cullmode_it = data.find ("cullmode");
json::const_iterator depthtest_it = data.find ("depthtest"); auto depthtest_it = data.find ("depthtest");
json::const_iterator depthwrite_it = data.find ("depthwrite"); auto depthwrite_it = data.find ("depthwrite");
json::const_iterator shader_it = data.find ("shader"); auto shader_it = data.find ("shader");
json::const_iterator textures_it = data.find ("textures"); auto textures_it = data.find ("textures");
json::const_iterator combos_it = data.find ("combos"); auto combos_it = data.find ("combos");
if (blending_it == data.end ()) if (blending_it == data.end ())
{ {
@ -70,8 +65,8 @@ CPassess* CPassess::fromJSON (json data)
if (textures_it != data.end ()) if (textures_it != data.end ())
{ {
json::const_iterator cur = (*textures_it).begin (); auto cur = (*textures_it).begin ();
json::const_iterator end = (*textures_it).end (); auto end = (*textures_it).end ();
for (;cur != end; cur ++) for (;cur != end; cur ++)
{ {
@ -88,8 +83,8 @@ CPassess* CPassess::fromJSON (json data)
if (combos_it != data.end ()) if (combos_it != data.end ())
{ {
json::const_iterator cur = (*combos_it).begin (); auto cur = (*combos_it).begin ();
json::const_iterator end = (*combos_it).end (); auto end = (*combos_it).end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -109,7 +104,6 @@ CPassess* CPassess::fromJSON (json data)
return pass; return pass;
} }
void CPassess::insertTexture (const std::string& texture) void CPassess::insertTexture (const std::string& texture)
{ {
this->m_textures.push_back (texture); this->m_textures.push_back (texture);
@ -120,12 +114,37 @@ void CPassess::insertCombo (const std::string& name, int value)
this->m_combos.insert (std::pair <std::string, int> (name, value)); this->m_combos.insert (std::pair <std::string, int> (name, value));
} }
std::map<std::string, int>* CPassess::getCombos () std::vector<std::string>* CPassess::getTextures ()
{ {
return &this->m_combos; return &this->m_textures;
} }
std::string CPassess::getShader () const std::map<std::string, int>& CPassess::getCombos () const
{
return this->m_combos;
}
const std::string& CPassess::getShader () const
{ {
return this->m_shader; return this->m_shader;
} }
const std::string& CPassess::getBlendingMode () const
{
return this->m_blending;
}
const std::string& CPassess::getCullingMode () const
{
return this->m_cullmode;
}
const std::string& CPassess::getDepthTest () const
{
return this->m_depthtest;
}
const std::string& CPassess::getDepthWrite ()const
{
return this->m_depthwrite;
}

View File

@ -12,8 +12,14 @@ namespace WallpaperEngine::Core::Objects::Images::Materials
static CPassess* fromJSON (json data); static CPassess* fromJSON (json data);
std::vector<std::string>* getTextures (); std::vector<std::string>* getTextures ();
std::map<std::string, int>* getCombos ();
std::string getShader (); const std::map<std::string, int>& getCombos () const;
const std::string& getShader () const;
const std::string& getBlendingMode () const;
const std::string& getCullingMode () const;
const std::string& getDepthTest () const;
const std::string& getDepthWrite () const;
protected: protected:
CPassess (std::string blending, std::string cullmode, std::string depthtest, std::string depthwrite, std::string shader); CPassess (std::string blending, std::string cullmode, std::string depthtest, std::string depthwrite, std::string shader);

View File

@ -6,9 +6,9 @@ using namespace WallpaperEngine::Core::Objects::Particles;
CControlPoint* CControlPoint::fromJSON (json data) CControlPoint* CControlPoint::fromJSON (json data)
{ {
json::const_iterator flags_it = data.find ("flags"); auto flags_it = data.find ("flags");
json::const_iterator id_it = data.find ("id"); auto id_it = data.find ("id");
json::const_iterator offset_it = data.find ("offset"); auto offset_it = data.find ("offset");
if (id_it == data.end ()) if (id_it == data.end ())
{ {
@ -47,12 +47,12 @@ void CControlPoint::setFlags (irr::u32 flags)
this->m_flags = flags; this->m_flags = flags;
} }
irr::core::vector3df* CControlPoint::getOffset () const irr::core::vector3df& CControlPoint::getOffset () const
{ {
return &this->m_offset; return this->m_offset;
} }
irr::u32 CControlPoint::getFlags () const irr::u32 CControlPoint::getFlags () const
{ {
return this->m_flags; return this->m_flags;
} }

View File

@ -12,8 +12,8 @@ namespace WallpaperEngine::Core::Objects::Particles
public: public:
static CControlPoint* fromJSON (json data); static CControlPoint* fromJSON (json data);
irr::core::vector3df* getOffset (); const irr::core::vector3df& getOffset () const;
irr::u32 getFlags (); const irr::u32 getFlags () const;
protected: protected:
CControlPoint (irr::u32 id, irr::u32 flags = 0); CControlPoint (irr::u32 id, irr::u32 flags = 0);

View File

@ -6,13 +6,13 @@ using namespace WallpaperEngine::Core::Objects::Particles;
CEmitter* CEmitter::fromJSON (json data) CEmitter* CEmitter::fromJSON (json data)
{ {
json::const_iterator directions_it = data.find ("directions"); auto directions_it = data.find ("directions");
json::const_iterator distancemax_it = data.find ("distancemax"); auto distancemax_it = data.find ("distancemax");
json::const_iterator distancemin_it = data.find ("distancemin"); auto distancemin_it = data.find ("distancemin");
json::const_iterator id_it = data.find ("id"); auto id_it = data.find ("id");
json::const_iterator name_it = data.find ("name"); auto name_it = data.find ("name");
json::const_iterator origin_it = data.find ("origin"); auto origin_it = data.find ("origin");
json::const_iterator rate_it = data.find ("rate"); auto rate_it = data.find ("rate");
if (directions_it == data.end ()) if (directions_it == data.end ())
{ {
@ -79,27 +79,27 @@ const std::string& CEmitter::getName () const
return this->m_name; return this->m_name;
} }
irr::u32 CEmitter::getDistanceMax () const const irr::u32 CEmitter::getDistanceMax () const
{ {
return this->m_distancemax; return this->m_distancemax;
} }
irr::u32 CEmitter::getDistanceMin () const const irr::u32 CEmitter::getDistanceMin () const
{ {
return this->m_distancemin; return this->m_distancemin;
} }
irr::core::vector3df* CEmitter::getDirections () const irr::core::vector3df& CEmitter::getDirections () const
{ {
return &this->m_directions; return this->m_directions;
} }
irr::core::vector3df* CEmitter::getOrigin () const irr::core::vector3df& CEmitter::getOrigin () const
{ {
return &this->m_origin; return this->m_origin;
} }
irr::f64 CEmitter::getRate () const const irr::f64 CEmitter::getRate () const
{ {
return this->m_rate; return this->m_rate;
} }

View File

@ -13,11 +13,11 @@ namespace WallpaperEngine::Core::Objects::Particles
static CEmitter* fromJSON (json data); static CEmitter* fromJSON (json data);
const std::string& getName () const; const std::string& getName () const;
irr::u32 getDistanceMax () const; const irr::u32 getDistanceMax () const;
irr::u32 getDistanceMin () const; const irr::u32 getDistanceMin () const;
irr::core::vector3df* getDirections (); const irr::core::vector3df& getDirections () const;
irr::core::vector3df* getOrigin (); const irr::core::vector3df& getOrigin () const;
irr::f64 getRate () const; const irr::f64 getRate () const;
protected: protected:
CEmitter ( CEmitter (
const irr::core::vector3df& directions, const irr::core::vector3df& directions,

View File

@ -12,8 +12,8 @@ using namespace WallpaperEngine::Core::Objects::Particles;
CInitializer* CInitializer::fromJSON (json data) CInitializer* CInitializer::fromJSON (json data)
{ {
json::const_iterator id_it = data.find ("id"); auto id_it = data.find ("id");
json::const_iterator name_it = data.find ("name"); auto name_it = data.find ("name");
irr::u32 id = ((id_it == data.end ()) ? 0 : (irr::u32) (*id_it)); irr::u32 id = ((id_it == data.end ()) ? 0 : (irr::u32) (*id_it));
if (name_it == data.end ()) if (name_it == data.end ())
@ -63,12 +63,12 @@ CInitializer::CInitializer (irr::u32 id, std::string name) :
} }
std::string& CInitializer::getName () const std::string& CInitializer::getName () const
{ {
return this->m_name; return this->m_name;
} }
irr::u32 CInitializer::getId () const irr::u32 CInitializer::getId () const
{ {
return this->m_id; return this->m_id;
} }

View File

@ -12,8 +12,8 @@ namespace WallpaperEngine::Core::Objects::Particles
public: public:
static CInitializer* fromJSON (json data); static CInitializer* fromJSON (json data);
std::string& getName (); const std::string& getName () const;
irr::u32 getId (); const irr::u32 getId () const;
protected: protected:
CInitializer (irr::u32 id, std::string name); CInitializer (irr::u32 id, std::string name);
private: private:

View File

@ -4,8 +4,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
CAlphaRandom* CAlphaRandom::fromJSON (json data, irr::u32 id) CAlphaRandom* CAlphaRandom::fromJSON (json data, irr::u32 id)
{ {
json::const_iterator min_it = data.find ("min"); auto min_it = data.find ("min");
json::const_iterator max_it = data.find ("max"); auto max_it = data.find ("max");
if (min_it == data.end ()) if (min_it == data.end ())
{ {
@ -27,12 +27,12 @@ CAlphaRandom::CAlphaRandom (irr::u32 id, irr::f64 min, irr::f64 max) :
{ {
} }
irr::f64 CAlphaRandom::getMinimum () const irr::f64 CAlphaRandom::getMinimum () const
{ {
return this->m_min; return this->m_min;
} }
irr::f64 CAlphaRandom::getMaximum () const irr::f64 CAlphaRandom::getMaximum () const
{ {
return this->m_max; return this->m_max;
} }

View File

@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
class CAlphaRandom : CInitializer class CAlphaRandom : CInitializer
{ {
public: public:
irr::f64 getMinimum (); const irr::f64 getMinimum () const;
irr::f64 getMaximum (); const irr::f64 getMaximum () const;
protected: protected:
friend class CInitializer; friend class CInitializer;

View File

@ -6,8 +6,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
CAngularVelocityRandom* CAngularVelocityRandom::fromJSON (json data, irr::u32 id) CAngularVelocityRandom* CAngularVelocityRandom::fromJSON (json data, irr::u32 id)
{ {
json::const_iterator min_it = data.find ("min"); auto min_it = data.find ("min");
json::const_iterator max_it = data.find ("max"); auto max_it = data.find ("max");
if (min_it == data.end ()) if (min_it == data.end ())
{ {
@ -34,12 +34,12 @@ CAngularVelocityRandom::CAngularVelocityRandom (irr::u32 id, irr::core::vector3d
{ {
} }
irr::core::vector3df* CAngularVelocityRandom::getMinimum () const irr::core::vector3df& CAngularVelocityRandom::getMinimum () const
{ {
return &this->m_min; return this->m_min;
} }
irr::core::vector3df* CAngularVelocityRandom::getMaximum () const irr::core::vector3df& CAngularVelocityRandom::getMaximum () const
{ {
return &this->m_max; return this->m_max;
} }

View File

@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
class CAngularVelocityRandom : CInitializer class CAngularVelocityRandom : CInitializer
{ {
public: public:
irr::core::vector3df* getMinimum (); const irr::core::vector3df& getMinimum () const;
irr::core::vector3df* getMaximum (); const irr::core::vector3df& getMaximum () const;
protected: protected:
friend class CInitializer; friend class CInitializer;

View File

@ -6,8 +6,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
CColorRandom* CColorRandom::fromJSON (json data, irr::u32 id) CColorRandom* CColorRandom::fromJSON (json data, irr::u32 id)
{ {
json::const_iterator min_it = data.find ("min"); auto min_it = data.find ("min");
json::const_iterator max_it = data.find ("max"); auto max_it = data.find ("max");
if (min_it == data.end ()) if (min_it == data.end ())
{ {
@ -34,12 +34,12 @@ CColorRandom::CColorRandom (irr::u32 id, irr::video::SColor min, irr::video::SCo
{ {
} }
irr::video::SColor* CColorRandom::getMinimum () const irr::video::SColor& CColorRandom::getMinimum () const
{ {
return &this->m_min; return this->m_min;
} }
irr::video::SColor* CColorRandom::getMaximum () const irr::video::SColor& CColorRandom::getMaximum () const
{ {
return &this->m_max; return this->m_max;
} }

View File

@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
class CColorRandom : CInitializer class CColorRandom : CInitializer
{ {
public: public:
irr::video::SColor* getMinimum (); const irr::video::SColor& getMinimum () const;
irr::video::SColor* getMaximum (); const irr::video::SColor& getMaximum () const;
protected: protected:
friend class CInitializer; friend class CInitializer;

View File

@ -4,8 +4,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
CLifeTimeRandom* CLifeTimeRandom::fromJSON (json data, irr::u32 id) CLifeTimeRandom* CLifeTimeRandom::fromJSON (json data, irr::u32 id)
{ {
json::const_iterator min_it = data.find ("min"); auto min_it = data.find ("min");
json::const_iterator max_it = data.find ("max"); auto max_it = data.find ("max");
if (min_it == data.end ()) if (min_it == data.end ())
{ {
@ -28,12 +28,12 @@ CLifeTimeRandom::CLifeTimeRandom (irr::u32 id, irr::u32 min, irr::u32 max) :
{ {
} }
irr::u32 CLifeTimeRandom::getMinimum () const irr::u32 CLifeTimeRandom::getMinimum () const
{ {
return this->m_min; return this->m_min;
} }
irr::u32 CLifeTimeRandom::getMaximum () const irr::u32 CLifeTimeRandom::getMaximum () const
{ {
return this->m_max; return this->m_max;
} }

View File

@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
class CLifeTimeRandom : CInitializer class CLifeTimeRandom : CInitializer
{ {
public: public:
irr::u32 getMinimum (); const irr::u32 getMinimum () const;
irr::u32 getMaximum (); const irr::u32 getMaximum () const;
protected: protected:
friend class CInitializer; friend class CInitializer;

View File

@ -4,8 +4,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
CRotationRandom* CRotationRandom::fromJSON (json data, irr::u32 id) CRotationRandom* CRotationRandom::fromJSON (json data, irr::u32 id)
{ {
json::const_iterator min_it = data.find ("min"); auto min_it = data.find ("min");
json::const_iterator max_it = data.find ("max"); auto max_it = data.find ("max");
irr::f64 min = 0.0f; irr::f64 min = 0.0f;
irr::f64 max = 360.0f; irr::f64 max = 360.0f;
@ -30,12 +30,12 @@ CRotationRandom::CRotationRandom (irr::u32 id, irr::f64 min, irr::f64 max) :
{ {
} }
irr::f64 CRotationRandom::getMinimum () const irr::f64 CRotationRandom::getMinimum () const
{ {
return this->m_min; return this->m_min;
} }
irr::f64 CRotationRandom::getMaximum () const irr::f64 CRotationRandom::getMaximum () const
{ {
return this->m_max; return this->m_max;
} }

View File

@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
class CRotationRandom : CInitializer class CRotationRandom : CInitializer
{ {
public: public:
irr::f64 getMinimum (); const irr::f64 getMinimum () const;
irr::f64 getMaximum (); const irr::f64 getMaximum () const;
protected: protected:
friend class CInitializer; friend class CInitializer;

View File

@ -4,8 +4,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
CSizeRandom* CSizeRandom::fromJSON (json data, irr::u32 id) CSizeRandom* CSizeRandom::fromJSON (json data, irr::u32 id)
{ {
json::const_iterator min_it = data.find ("min"); auto min_it = data.find ("min");
json::const_iterator max_it = data.find ("max"); auto max_it = data.find ("max");
if (min_it == data.end ()) if (min_it == data.end ())
{ {
@ -27,12 +27,12 @@ CSizeRandom::CSizeRandom (irr::u32 id, irr::u32 min, irr::u32 max) :
{ {
} }
irr::u32 CSizeRandom::getMinimum () const irr::u32 CSizeRandom::getMinimum () const
{ {
return this->m_min; return this->m_min;
} }
irr::u32 CSizeRandom::getMaximum () const irr::u32 CSizeRandom::getMaximum () const
{ {
return this->m_max; return this->m_max;
} }

View File

@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
class CSizeRandom : CInitializer class CSizeRandom : CInitializer
{ {
public: public:
irr::u32 getMinimum (); const irr::u32 getMinimum () const;
irr::u32 getMaximum (); const irr::u32 getMaximum () const;
protected: protected:
friend class CInitializer; friend class CInitializer;

View File

@ -6,8 +6,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers;
CVelocityRandom* CVelocityRandom::fromJSON (json data, irr::u32 id) CVelocityRandom* CVelocityRandom::fromJSON (json data, irr::u32 id)
{ {
json::const_iterator min_it = data.find ("min"); auto min_it = data.find ("min");
json::const_iterator max_it = data.find ("max"); auto max_it = data.find ("max");
if (min_it == data.end ()) if (min_it == data.end ())
{ {
@ -34,12 +34,12 @@ CVelocityRandom::CVelocityRandom (irr::u32 id, irr::core::vector3df min, irr::co
{ {
} }
irr::core::vector3df* CVelocityRandom::getMinimum () const irr::core::vector3df& CVelocityRandom::getMinimum () const
{ {
return &this->m_min; return this->m_min;
} }
irr::core::vector3df* CVelocityRandom::getMaximum () const irr::core::vector3df& CVelocityRandom::getMaximum () const
{ {
return &this->m_max; return this->m_max;
} }

View File

@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers
class CVelocityRandom : CInitializer class CVelocityRandom : CInitializer
{ {
public: public:
irr::core::vector3df* getMinimum (); const irr::core::vector3df& getMinimum () const;
irr::core::vector3df* getMaximum (); const irr::core::vector3df& getMaximum () const;
protected: protected:
friend class CInitializer; friend class CInitializer;

View File

@ -1,13 +1,13 @@
#include "CProperty.h" #include "CProperty.h"
#include "CPropertyColor.h" #include "CPropertyColor.h"
namespace WallpaperEngine::Core::Projects using namespace WallpaperEngine::Core::Projects;
CProperty* CProperty::fromJSON (json data, const std::string& name)
{ {
CProperty* CProperty::fromJSON (json data, const std::string& name) auto type = data.find ("type");
{ auto value = data.find ("value");
json::const_iterator type = data.find ("type"); auto text = data.find ("text");
json::const_iterator value = data.find ("value");
json::const_iterator text = data.find ("text");
if (value == data.end ()) if (value == data.end ())
{ {
@ -25,27 +25,26 @@ namespace WallpaperEngine::Core::Projects
} }
throw std::runtime_error ("Unexpected type for property"); throw std::runtime_error ("Unexpected type for property");
} }
CProperty::CProperty (std::string name, std::string type, std::string text) : CProperty::CProperty (std::string name, std::string type, std::string text) :
m_name (std::move(name)), m_name (std::move(name)),
m_type (std::move(type)), m_type (std::move(type)),
m_text (std::move(text)) m_text (std::move(text))
{ {
} }
std::string& CProperty::getName () const std::string& CProperty::getName () const
{ {
return this->m_name; return this->m_name;
} }
std::string& CProperty::getType () const std::string& CProperty::getType () const
{ {
return this->m_type; return this->m_type;
} }
std::string& CProperty::getText () const std::string& CProperty::getText () const
{ {
return this->m_text; return this->m_text;
} }
};

View File

@ -13,14 +13,14 @@ namespace WallpaperEngine::Core::Projects
public: public:
static CProperty* fromJSON (json data, const std::string& name); static CProperty* fromJSON (json data, const std::string& name);
template<class T> const T* As () const { assert (Is<T> ()); return (const T*) this; } template<class T> const T* as () const { assert (is <T> ()); return (const T*) this; }
template<class T> T* As () { assert (Is<T> ()); return (T*) this; } template<class T> T* as () { assert (is <T> ()); return (T*) this; }
template<class T> bool Is () { return this->m_type == T::Type; } template<class T> bool is () { return this->m_type == T::Type; }
std::string& getName (); const std::string& getName () const;
std::string& getType (); const std::string& getType () const;
std::string& getText (); const std::string& getText () const;
protected: protected:
CProperty (std::string name, std::string type, std::string text); CProperty (std::string name, std::string type, std::string text);

View File

@ -5,8 +5,8 @@ using namespace WallpaperEngine::Core::Projects;
CPropertyColor* CPropertyColor::fromJSON (json data, const std::string& name) CPropertyColor* CPropertyColor::fromJSON (json data, const std::string& name)
{ {
json::const_iterator value = data.find ("value"); auto value = data.find ("value");
json::const_iterator text = data.find ("type"); auto text = data.find ("type");
return new CPropertyColor ( return new CPropertyColor (
WallpaperEngine::Core::atoSColor (*value), WallpaperEngine::Core::atoSColor (*value),
@ -15,9 +15,9 @@ CPropertyColor* CPropertyColor::fromJSON (json data, const std::string& name)
); );
} }
irr::video::SColor* CPropertyColor::getValue () const irr::video::SColor& CPropertyColor::getValue () const
{ {
return &this->m_color; return this->m_color;
} }
CPropertyColor::CPropertyColor (irr::video::SColor color, const std::string& name, const std::string& text) : CPropertyColor::CPropertyColor (irr::video::SColor color, const std::string& name, const std::string& text) :

View File

@ -13,7 +13,7 @@ namespace WallpaperEngine::Core::Projects
public: public:
static CPropertyColor* fromJSON (json data, const std::string& name); static CPropertyColor* fromJSON (json data, const std::string& name);
irr::video::SColor* getValue (); const irr::video::SColor& getValue () const;
static const std::string Type; static const std::string Type;

View File

@ -10,26 +10,26 @@ CCamera::CCamera (irr::core::vector3df center, irr::core::vector3df eye, irr::co
{ {
} }
irr::core::vector3df* CCamera::getCenter () const irr::core::vector3df& CCamera::getCenter () const
{ {
return &this->m_center; return this->m_center;
} }
irr::core::vector3df* CCamera::getEye () const irr::core::vector3df& CCamera::getEye () const
{ {
return &this->m_eye; return this->m_eye;
} }
irr::core::vector3df* CCamera::getUp () const irr::core::vector3df& CCamera::getUp () const
{ {
return &this->m_up; return this->m_up;
} }
CCamera* CCamera::fromJSON (json data) CCamera* CCamera::fromJSON (json data)
{ {
json::const_iterator center_it = data.find ("center"); auto center_it = data.find ("center");
json::const_iterator eye_it = data.find ("eye"); auto eye_it = data.find ("eye");
json::const_iterator up_it = data.find ("up"); auto up_it = data.find ("up");
if (center_it == data.end ()) if (center_it == data.end ())
{ {

View File

@ -12,9 +12,9 @@ namespace WallpaperEngine::Core::Scenes
public: public:
static CCamera* fromJSON (json data); static CCamera* fromJSON (json data);
irr::core::vector3df* getCenter (); const irr::core::vector3df& getCenter () const;
irr::core::vector3df* getEye (); const irr::core::vector3df& getEye () const;
irr::core::vector3df* getUp (); const irr::core::vector3df& getUp () const;
protected: protected:
CCamera (irr::core::vector3df center, irr::core::vector3df eye, irr::core::vector3df up); CCamera (irr::core::vector3df center, irr::core::vector3df eye, irr::core::vector3df up);
private: private:

View File

@ -9,20 +9,20 @@ CProjection::CProjection (irr::u32 width, irr::u32 height) :
{ {
} }
irr::u32 CProjection::getWidth () const irr::u32& CProjection::getWidth () const
{ {
return this->m_width; return this->m_width;
} }
irr::u32 CProjection::getHeight () const irr::u32& CProjection::getHeight () const
{ {
return this->m_height; return this->m_height;
} }
CProjection* CProjection::fromJSON (json data) CProjection* CProjection::fromJSON (json data)
{ {
json::const_iterator width_it = data.find ("width"); auto width_it = data.find ("width");
json::const_iterator height_it = data.find ("height"); auto height_it = data.find ("height");
if (width_it == data.end ()) if (width_it == data.end ())
{ {

View File

@ -12,8 +12,8 @@ namespace WallpaperEngine::Core::Scenes
public: public:
static CProjection* fromJSON (json data); static CProjection* fromJSON (json data);
irr::u32 getWidth (); const irr::u32& getWidth () const;
irr::u32 getHeight (); const irr::u32& getHeight () const;
protected: protected:
CProjection (irr::u32 width, irr::u32 height); CProjection (irr::u32 width, irr::u32 height);
private: private:

View File

@ -8,7 +8,7 @@ extern WallpaperEngine::Irrlicht::CContext* IrrlichtContext;
namespace WallpaperEngine::FileSystem namespace WallpaperEngine::FileSystem
{ {
std::string loadFullFile (irr::io::path file) std::string loadFullFile (const irr::io::path& file)
{ {
irr::io::IReadFile* reader = IrrlichtContext->getDevice ()->getFileSystem ()->createAndOpenFile (file); irr::io::IReadFile* reader = IrrlichtContext->getDevice ()->getFileSystem ()->createAndOpenFile (file);

View File

@ -16,5 +16,5 @@ namespace WallpaperEngine::FileSystem
* @param file * @param file
* @return * @return
*/ */
std::string loadFullFile (irr::io::path file); std::string loadFullFile (const irr::io::path& file);
} }

View File

@ -1,14 +1,13 @@
#include "CContext.h" #include "CContext.h"
namespace WallpaperEngine::Irrlicht using namespace WallpaperEngine::Irrlicht;
{
void CContext::setDevice (irr::IrrlichtDevice* device)
{
this->m_device = device;
}
irr::IrrlichtDevice* CContext::getDevice () void CContext::setDevice (irr::IrrlichtDevice* device)
{ {
this->m_device = device;
}
irr::IrrlichtDevice* CContext::getDevice ()
{
return this->m_device; return this->m_device;
} }
};

View File

@ -2,48 +2,47 @@
#include "CFileList.h" #include "CFileList.h"
namespace WallpaperEngine::Irrlicht using namespace WallpaperEngine::Irrlicht;
{ static const irr::io::path emptyFileListEntry;
static const irr::io::path emptyFileListEntry;
CFileList::CFileList (const irr::io::path& path, bool ignoreCase, bool ignorePaths) : CFileList::CFileList (const irr::io::path& path, bool ignoreCase, bool ignorePaths) :
m_ignorePaths (ignorePaths), m_ignorePaths (ignorePaths),
m_ignoreCase (ignoreCase), m_ignoreCase (ignoreCase),
m_path(path) m_path(path)
{ {
this->m_path.replace ('\\', '/'); this->m_path.replace ('\\', '/');
} }
CFileList::~CFileList () CFileList::~CFileList ()
{ {
this->m_files.clear (); this->m_files.clear ();
} }
irr::u32 CFileList::getFileCount () const irr::u32 CFileList::getFileCount () const
{ {
return this->m_files.size (); return this->m_files.size ();
} }
void CFileList::sort () void CFileList::sort ()
{ {
this->m_files.sort (); this->m_files.sort ();
} }
const irr::io::path& CFileList::getFileName (irr::u32 index) const const irr::io::path& CFileList::getFileName (irr::u32 index) const
{ {
return (index < this->m_files.size ()) ? this->m_files [index].Name : emptyFileListEntry; return (index < this->m_files.size ()) ? this->m_files [index].Name : emptyFileListEntry;
} }
//! Gets the full name of a file in the list, path included, based on an index. //! Gets the full name of a file in the list, path included, based on an index.
const irr::io::path& CFileList::getFullFileName (irr::u32 index) const const irr::io::path& CFileList::getFullFileName (irr::u32 index) const
{ {
return (index < this->m_files.size ()) ? this->m_files [index].FullName : emptyFileListEntry; return (index < this->m_files.size ()) ? this->m_files [index].FullName : emptyFileListEntry;
} }
//! adds a file or folder //! adds a file or folder
irr::u32 CFileList::addItem (const irr::io::path& fullPath, irr::u32 offset, irr::u32 size, bool isDirectory, irr::u32 id) irr::u32 CFileList::addItem (const irr::io::path& fullPath, irr::u32 offset, irr::u32 size, bool isDirectory, irr::u32 id)
{ {
SFileListEntry entry; SFileListEntry entry;
entry.ID = id ? id : this->m_files.size (); entry.ID = id ? id : this->m_files.size ();
entry.Offset = offset; entry.Offset = offset;
@ -73,35 +72,35 @@ namespace WallpaperEngine::Irrlicht
this->m_files.push_back (entry); this->m_files.push_back (entry);
return this->m_files.size () - 1; return this->m_files.size () - 1;
} }
//! Returns the ID of a file in the file list, based on an index. //! Returns the ID of a file in the file list, based on an index.
irr::u32 CFileList::getID (irr::u32 index) const irr::u32 CFileList::getID (irr::u32 index) const
{ {
return (index < this->m_files.size ()) ? this->m_files [index].ID : 0; return (index < this->m_files.size ()) ? this->m_files [index].ID : 0;
} }
bool CFileList::isDirectory (irr::u32 index) const bool CFileList::isDirectory (irr::u32 index) const
{ {
return (index < this->m_files.size ()) ? this->m_files [index].IsDirectory : false; return (index < this->m_files.size ()) ? this->m_files [index].IsDirectory : false;
} }
//! Returns the size of a file //! Returns the size of a file
irr::u32 CFileList::getFileSize (irr::u32 index) const irr::u32 CFileList::getFileSize (irr::u32 index) const
{ {
return (index < this->m_files.size ()) ? this->m_files [index].Size : 0; return (index < this->m_files.size ()) ? this->m_files [index].Size : 0;
} }
//! Returns the size of a file //! Returns the size of a file
irr::u32 CFileList::getFileOffset (irr::u32 index) const irr::u32 CFileList::getFileOffset (irr::u32 index) const
{ {
return (index < this->m_files.size ()) ? this->m_files [index].Offset : 0; return (index < this->m_files.size ()) ? this->m_files [index].Offset : 0;
} }
//! Searches for a file or folder within the list, returns the index //! Searches for a file or folder within the list, returns the index
irr::s32 CFileList::findFile (const irr::io::path& filename, bool isDirectory = false) const irr::s32 CFileList::findFile (const irr::io::path& filename, bool isDirectory = false) const
{ {
SFileListEntry entry; SFileListEntry entry;
// we only need FullName to be set for the search // we only need FullName to be set for the search
entry.FullName = filename; entry.FullName = filename;
@ -125,12 +124,11 @@ namespace WallpaperEngine::Irrlicht
irr::core::deletePathFromFilename (entry.FullName); irr::core::deletePathFromFilename (entry.FullName);
return this->m_files.binary_search (entry); return this->m_files.binary_search (entry);
} }
//! Returns the base path of the file list //! Returns the base path of the file list
const irr::io::path& CFileList::getPath () const const irr::io::path& CFileList::getPath () const
{ {
return m_path; return m_path;
} }
};

View File

@ -46,8 +46,8 @@ namespace WallpaperEngine::Irrlicht
CImageLoaderTex::TextureContainer::~TextureContainer () CImageLoaderTex::TextureContainer::~TextureContainer ()
{ {
std::vector <TextureMipmap*>::const_iterator cur = this->mipmaps.begin (); auto cur = this->mipmaps.begin ();
std::vector <TextureMipmap*>::const_iterator end = this->mipmaps.end (); auto end = this->mipmaps.end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {

View File

@ -3,13 +3,14 @@
using namespace WallpaperEngine; using namespace WallpaperEngine;
using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Render;
CCamera::CCamera (CScene* scene, Core::Scenes::CCamera* camera) : CCamera::CCamera (CScene* scene, const Core::Scenes::CCamera* camera) :
m_camera (camera), m_camera (camera),
m_scene (scene) m_scene (scene)
{ {
this->m_sceneCamera = scene->getContext ()->getDevice ()->getSceneManager ()->addCameraSceneNode ( this->m_sceneCamera = scene->getContext ()->getDevice ()->getSceneManager ()->addCameraSceneNode (
scene, *this->getEye (), *this->getCenter (), scene->nextId () scene, this->getEye (), this->getCenter (), scene->nextId ()
); );
this->m_sceneCamera->setUpVector (this->getUp ());
} }
CCamera::~CCamera () CCamera::~CCamera ()
@ -17,17 +18,17 @@ CCamera::~CCamera ()
this->m_sceneCamera->remove (); this->m_sceneCamera->remove ();
} }
irr::core::vector3df* CCamera::getCenter () const irr::core::vector3df& CCamera::getCenter () const
{ {
return this->m_camera->getCenter (); return this->m_camera->getCenter ();
} }
irr::core::vector3df* CCamera::getEye () const irr::core::vector3df& CCamera::getEye () const
{ {
return this->m_camera->getEye (); return this->m_camera->getEye ();
} }
irr::core::vector3df* CCamera::getUp () const irr::core::vector3df& CCamera::getUp () const
{ {
return this->m_camera->getUp (); return this->m_camera->getUp ();
} }
@ -37,8 +38,8 @@ void CCamera::setOrthogonalProjection (irr::f32 width, irr::f32 height)
irr::core::matrix4 identity; identity.makeIdentity (); irr::core::matrix4 identity; identity.makeIdentity ();
irr::core::matrix4 orthogonalProjection; orthogonalProjection.buildProjectionMatrixOrthoLH ( irr::core::matrix4 orthogonalProjection; orthogonalProjection.buildProjectionMatrixOrthoLH (
width, height, width, height,
this->getCenter ()->Z, this->getCenter ().Z,
this->getEye ()->Z this->getEye ().Z
); );
this->m_sceneCamera->setProjectionMatrix (orthogonalProjection); this->m_sceneCamera->setProjectionMatrix (orthogonalProjection);

View File

@ -11,17 +11,17 @@ namespace WallpaperEngine::Render
class CCamera class CCamera
{ {
public: public:
CCamera (CScene* scene, Core::Scenes::CCamera* camera); CCamera (CScene* scene, const Core::Scenes::CCamera* camera);
~CCamera (); ~CCamera ();
void setOrthogonalProjection (irr::f32 width, irr::f32 height); void setOrthogonalProjection (irr::f32 width, irr::f32 height);
irr::core::vector3df* getCenter (); const irr::core::vector3df& getCenter () const;
irr::core::vector3df* getEye (); const irr::core::vector3df& getEye () const;
irr::core::vector3df* getUp (); const irr::core::vector3df& getUp () const;
private: private:
Core::Scenes::CCamera* m_camera; const Core::Scenes::CCamera* m_camera;
irr::scene::ICameraSceneNode* m_sceneCamera; irr::scene::ICameraSceneNode* m_sceneCamera;
CScene* m_scene; CScene* m_scene;
}; };

View File

@ -19,7 +19,7 @@ CObject::~CObject()
{ {
} }
CScene* CObject::getScene () CScene* CObject::getScene () const
{ {
return this->m_scene; return this->m_scene;
} }

View File

@ -21,11 +21,11 @@ namespace WallpaperEngine::Render
protected: protected:
CObject (CScene* scene, std::string type, Core::CObject *object); CObject (CScene* scene, std::string type, Core::CObject *object);
~CObject (); ~CObject () override;
void OnRegisterSceneNode () override; void OnRegisterSceneNode () override;
CScene* getScene (); CScene* getScene () const;
private: private:
std::string m_type; std::string m_type;

View File

@ -9,7 +9,7 @@
using namespace WallpaperEngine; using namespace WallpaperEngine;
using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Render;
CScene::CScene (Core::CProject* project, Irrlicht::CContext* context) : CScene::CScene (const Core::CProject* project, Irrlicht::CContext* context) :
irr::scene::ISceneNode ( irr::scene::ISceneNode (
context->getDevice ()->getSceneManager ()->getRootSceneNode (), context->getDevice ()->getSceneManager ()->getRootSceneNode (),
context->getDevice ()->getSceneManager () context->getDevice ()->getSceneManager ()
@ -24,8 +24,8 @@ CScene::CScene (Core::CProject* project, Irrlicht::CContext* context) :
this->m_scene->getOrthogonalProjection ()->getHeight () this->m_scene->getOrthogonalProjection ()->getHeight ()
); );
std::vector<Core::CObject*>::const_iterator cur = this->m_scene->getObjects ()->begin (); auto cur = this->m_scene->getObjects ().begin ();
std::vector<Core::CObject*>::const_iterator end = this->m_scene->getObjects ()->end (); auto end = this->m_scene->getObjects ().end ();
int highestId = 0; int highestId = 0;
@ -34,13 +34,13 @@ CScene::CScene (Core::CProject* project, Irrlicht::CContext* context) :
if ((*cur)->getId () > highestId) if ((*cur)->getId () > highestId)
highestId = (*cur)->getId (); highestId = (*cur)->getId ();
if ((*cur)->Is <Core::Objects::CImage> () == true) if ((*cur)->is<Core::Objects::CImage>() == true)
{ {
new Objects::CImage (this, (*cur)->As <Core::Objects::CImage> ()); new Objects::CImage (this, (*cur)->as<Core::Objects::CImage>());
} }
else if ((*cur)->Is <Core::Objects::CSound> () == true) else if ((*cur)->is<Core::Objects::CSound>() == true)
{ {
new Objects::CSound (this, (*cur)->As <Core::Objects::CSound> ()); new Objects::CSound (this, (*cur)->as<Core::Objects::CSound>());
} }
} }
@ -58,12 +58,12 @@ Irrlicht::CContext* CScene::getContext ()
return this->m_context; return this->m_context;
} }
Core::CScene* CScene::getScene () const Core::CScene* CScene::getScene () const
{ {
return this->m_scene; return this->m_scene;
} }
CCamera* CScene::getCamera () CCamera* CScene::getCamera () const
{ {
return this->m_camera; return this->m_camera;
} }

View File

@ -14,20 +14,20 @@ namespace WallpaperEngine::Render
class CScene : public irr::scene::ISceneNode class CScene : public irr::scene::ISceneNode
{ {
public: public:
CScene (Core::CProject* project, Irrlicht::CContext* context); CScene (const Core::CProject* project, Irrlicht::CContext* context);
~CScene (); ~CScene () override;
Irrlicht::CContext* getContext (); Irrlicht::CContext* getContext ();
Core::CScene* getScene (); const Core::CScene* getScene () const;
CCamera* getCamera (); CCamera* getCamera () const;
int nextId (); int nextId ();
void render () override; void render () override;
const irr::core::aabbox3d<irr::f32>& getBoundingBox() const override; const irr::core::aabbox3d<irr::f32>& getBoundingBox() const override;
void OnRegisterSceneNode () override; void OnRegisterSceneNode () override;
private: private:
Core::CProject* m_project; const Core::CProject* m_project;
Core::CScene* m_scene; const Core::CScene* m_scene;
CCamera* m_camera; CCamera* m_camera;
Irrlicht::CContext* m_context; Irrlicht::CContext* m_context;
irr::u32 m_nextId; irr::u32 m_nextId;

View File

@ -20,11 +20,11 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
m_passes (0) m_passes (0)
{ {
// TODO: INITIALIZE NEEDED EFFECTS AND PROPERLY CALCULATE THESE? // TODO: INITIALIZE NEEDED EFFECTS AND PROPERLY CALCULATE THESE?
irr::f32 xright = this->m_image->getOrigin ()->X; irr::f32 xright = this->m_image->getOrigin ().X;
irr::f32 xleft = -this->m_image->getOrigin ()->X; irr::f32 xleft = -this->m_image->getOrigin ().X;
irr::f32 ztop = this->m_image->getOrigin ()->Y; irr::f32 ztop = this->m_image->getOrigin ().Y;
irr::f32 zbottom = -this->m_image->getOrigin ()->Y; irr::f32 zbottom = -this->m_image->getOrigin ().Y;
irr::f32 z = this->m_image->getOrigin ()->Z; irr::f32 z = this->m_image->getOrigin ().Z;
// top left // top left
this->m_vertex [0].Pos = irr::core::vector3df (xleft, ztop, z); this->m_vertex [0].Pos = irr::core::vector3df (xleft, ztop, z);
@ -59,11 +59,11 @@ void CImage::render()
irr::video::IVideoDriver* driver = SceneManager->getVideoDriver (); irr::video::IVideoDriver* driver = SceneManager->getVideoDriver ();
std::vector<irr::video::SMaterial>::const_iterator cur = this->m_materials.begin (); auto cur = this->m_materials.begin ();
std::vector<irr::video::SMaterial>::const_iterator end = this->m_materials.end (); auto end = this->m_materials.end ();
std::vector<irr::video::ITexture*>::const_iterator textureCur = this->m_renderTextures.begin (); auto textureCur = this->m_renderTextures.begin ();
std::vector<irr::video::ITexture*>::const_iterator textureEnd = this->m_renderTextures.end (); auto textureEnd = this->m_renderTextures.end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -87,26 +87,26 @@ void CImage::render()
void CImage::generateMaterial () void CImage::generateMaterial ()
{ {
std::vector<Core::Objects::Images::Materials::CPassess*>::const_iterator cur = this->m_image->getMaterial ()->getPasses ()->begin (); auto cur = this->m_image->getMaterial ()->getPasses ().begin ();
std::vector<Core::Objects::Images::Materials::CPassess*>::const_iterator end = this->m_image->getMaterial ()->getPasses ()->end (); auto end = this->m_image->getMaterial ()->getPasses ().end ();
for (; cur != end; cur++) for (; cur != end; cur++)
{ {
this->generatePass (*cur); this->generatePass (*cur);
} }
std::vector<Core::Objects::CEffect*>::const_iterator effectCur = this->m_image->getEffects ()->begin (); auto effectCur = this->m_image->getEffects ().begin ();
std::vector<Core::Objects::CEffect*>::const_iterator effectEnd = this->m_image->getEffects ()->end (); auto effectEnd = this->m_image->getEffects ().end ();
for (; effectCur != effectEnd; effectCur++) for (; effectCur != effectEnd; effectCur++)
{ {
std::vector<Core::Objects::Images::CMaterial*>::const_iterator materialCur = (*effectCur)->getMaterials ()->begin (); auto materialCur = (*effectCur)->getMaterials ().begin ();
std::vector<Core::Objects::Images::CMaterial*>::const_iterator materialEnd = (*effectCur)->getMaterials ()->end (); auto materialEnd = (*effectCur)->getMaterials ().end ();
for (; materialCur != materialEnd; materialCur++) for (; materialCur != materialEnd; materialCur++)
{ {
cur = (*materialCur)->getPasses ()->begin (); cur = (*materialCur)->getPasses ().begin ();
end = (*materialCur)->getPasses ()->end (); end = (*materialCur)->getPasses ().end ();
for (; cur != end; cur++) for (; cur != end; cur++)
{ {
@ -121,8 +121,8 @@ void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass)
std::vector<std::string>* textures = pass->getTextures (); std::vector<std::string>* textures = pass->getTextures ();
irr::video::SMaterial material; irr::video::SMaterial material;
std::vector<std::string>::const_iterator texturesCur = textures->begin (); auto texturesCur = textures->begin ();
std::vector<std::string>::const_iterator texturesEnd = textures->end (); auto texturesEnd = textures->end ();
for (int textureNumber = 0; texturesCur != texturesEnd; texturesCur ++, textureNumber ++) for (int textureNumber = 0; texturesCur != texturesEnd; texturesCur ++, textureNumber ++)
{ {
@ -141,8 +141,6 @@ void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass)
), ("_RT_" + this->m_image->getName () + std::to_string (textureNumber) + "_" + std::to_string (this->m_passes)).c_str () ), ("_RT_" + this->m_image->getName () + std::to_string (textureNumber) + "_" + std::to_string (this->m_passes)).c_str ()
); );
//originalTexture->drop ();
this->m_renderTextures.push_back (texture); this->m_renderTextures.push_back (texture);
} }
else else
@ -150,8 +148,6 @@ void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass)
texture = this->getScene ()->getContext ()->getDevice ()->getVideoDriver ()->getTexture (texturepath); texture = this->getScene ()->getContext ()->getDevice ()->getVideoDriver ()->getTexture (texturepath);
} }
//texture->grab ();
material.setTexture (textureNumber, texture); material.setTexture (textureNumber, texture);
} }
@ -196,23 +192,23 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
irr::f32 g_Texture6 = 6; irr::f32 g_Texture6 = 6;
irr::f32 g_Texture7 = 7; irr::f32 g_Texture7 = 7;
irr::f32 g_Texture0Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z }; irr::f32 g_Texture0Rotation [4] = { this->m_image->getAngles ().X, this->m_image->getAngles ().Y, this->m_image->getAngles ().Z, this->m_image->getAngles ().Z };
irr::f32 g_Texture1Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z }; irr::f32 g_Texture1Rotation [4] = { this->m_image->getAngles ().X, this->m_image->getAngles ().Y, this->m_image->getAngles ().Z, this->m_image->getAngles ().Z };
irr::f32 g_Texture2Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z }; irr::f32 g_Texture2Rotation [4] = { this->m_image->getAngles ().X, this->m_image->getAngles ().Y, this->m_image->getAngles ().Z, this->m_image->getAngles ().Z };
irr::f32 g_Texture3Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z }; irr::f32 g_Texture3Rotation [4] = { this->m_image->getAngles ().X, this->m_image->getAngles ().Y, this->m_image->getAngles ().Z, this->m_image->getAngles ().Z };
irr::f32 g_Texture4Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z }; irr::f32 g_Texture4Rotation [4] = { this->m_image->getAngles ().X, this->m_image->getAngles ().Y, this->m_image->getAngles ().Z, this->m_image->getAngles ().Z };
irr::f32 g_Texture5Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z }; irr::f32 g_Texture5Rotation [4] = { this->m_image->getAngles ().X, this->m_image->getAngles ().Y, this->m_image->getAngles ().Z, this->m_image->getAngles ().Z };
irr::f32 g_Texture6Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z }; irr::f32 g_Texture6Rotation [4] = { this->m_image->getAngles ().X, this->m_image->getAngles ().Y, this->m_image->getAngles ().Z, this->m_image->getAngles ().Z };
irr::f32 g_Texture7Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z }; irr::f32 g_Texture7Rotation [4] = { this->m_image->getAngles ().X, this->m_image->getAngles ().Y, this->m_image->getAngles ().Z, this->m_image->getAngles ().Z };
irr::f32 g_Texture0Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y }; irr::f32 g_Texture0Resolution [4] = { this->m_image->getSize ().X, this->m_image->getSize ().Y, this->m_image->getSize ().X, this->m_image->getSize ().Y };
irr::f32 g_Texture1Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y }; irr::f32 g_Texture1Resolution [4] = { this->m_image->getSize ().X, this->m_image->getSize ().Y, this->m_image->getSize ().X, this->m_image->getSize ().Y };
irr::f32 g_Texture2Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y }; irr::f32 g_Texture2Resolution [4] = { this->m_image->getSize ().X, this->m_image->getSize ().Y, this->m_image->getSize ().X, this->m_image->getSize ().Y };
irr::f32 g_Texture3Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y }; irr::f32 g_Texture3Resolution [4] = { this->m_image->getSize ().X, this->m_image->getSize ().Y, this->m_image->getSize ().X, this->m_image->getSize ().Y };
irr::f32 g_Texture4Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y }; irr::f32 g_Texture4Resolution [4] = { this->m_image->getSize ().X, this->m_image->getSize ().Y, this->m_image->getSize ().X, this->m_image->getSize ().Y };
irr::f32 g_Texture5Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y }; irr::f32 g_Texture5Resolution [4] = { this->m_image->getSize ().X, this->m_image->getSize ().Y, this->m_image->getSize ().X, this->m_image->getSize ().Y };
irr::f32 g_Texture6Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y }; irr::f32 g_Texture6Resolution [4] = { this->m_image->getSize ().X, this->m_image->getSize ().Y, this->m_image->getSize ().X, this->m_image->getSize ().Y };
irr::f32 g_Texture7Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y }; irr::f32 g_Texture7Resolution [4] = { this->m_image->getSize ().X, this->m_image->getSize ().Y, this->m_image->getSize ().X, this->m_image->getSize ().Y };
irr::video::IVideoDriver* driver = services->getVideoDriver (); irr::video::IVideoDriver* driver = services->getVideoDriver ();
@ -224,12 +220,12 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
Render::Shaders::Compiler* vertexShader = this->m_vertexShaders.at (userData); Render::Shaders::Compiler* vertexShader = this->m_vertexShaders.at (userData);
Render::Shaders::Compiler* pixelShader = this->m_pixelShaders.at (userData); Render::Shaders::Compiler* pixelShader = this->m_pixelShaders.at (userData);
std::vector<Render::Shaders::Parameters::CShaderParameter*>::const_iterator cur = vertexShader->getParameters ().begin (); auto cur = vertexShader->getParameters ().begin ();
std::vector<Render::Shaders::Parameters::CShaderParameter*>::const_iterator end = vertexShader->getParameters ().end (); auto end = vertexShader->getParameters ().end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
if ((*cur)->Is <CShaderParameterInteger> () == true) if ((*cur)->is <CShaderParameterInteger> () == true)
{ {
services->setVertexShaderConstant ( services->setVertexShaderConstant (
(*cur)->getName ().c_str (), (*cur)->getName ().c_str (),
@ -238,10 +234,10 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
); );
} }
else if ( else if (
(*cur)->Is <CShaderParameterFloat> () == true || (*cur)->is <CShaderParameterFloat> () == true ||
(*cur)->Is <CShaderParameterVector2> () == true || (*cur)->is <CShaderParameterVector2> () == true ||
(*cur)->Is <CShaderParameterVector3> () == true || (*cur)->is <CShaderParameterVector3> () == true ||
(*cur)->Is <CShaderParameterVector4> () == true) (*cur)->is <CShaderParameterVector4> () == true)
{ {
services->setVertexShaderConstant ( services->setVertexShaderConstant (
(*cur)->getName ().c_str (), (*cur)->getName ().c_str (),
@ -256,7 +252,7 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
if ((*cur)->Is <CShaderParameterInteger> () == true) if ((*cur)->is <CShaderParameterInteger> () == true)
{ {
services->setPixelShaderConstant ( services->setPixelShaderConstant (
(*cur)->getName ().c_str (), (*cur)->getName ().c_str (),
@ -265,10 +261,10 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in
); );
} }
else if ( else if (
(*cur)->Is <CShaderParameterFloat> () == true || (*cur)->is <CShaderParameterFloat> () == true ||
(*cur)->Is <CShaderParameterVector2> () == true || (*cur)->is <CShaderParameterVector2> () == true ||
(*cur)->Is <CShaderParameterVector3> () == true || (*cur)->is <CShaderParameterVector3> () == true ||
(*cur)->Is <CShaderParameterVector4> () == true) (*cur)->is <CShaderParameterVector4> () == true)
{ {
services->setPixelShaderConstant ( services->setPixelShaderConstant (
(*cur)->getName ().c_str (), (*cur)->getName ().c_str (),

View File

@ -18,8 +18,8 @@ CSound::CSound (CScene* scene, Core::Objects::CSound* sound) :
void CSound::load () void CSound::load ()
{ {
std::vector<std::string>::const_iterator cur = this->m_sound->getSounds ()->begin (); std::vector<std::string>::const_iterator cur = this->m_sound->getSounds ().begin ();
std::vector<std::string>::const_iterator end = this->m_sound->getSounds ()->end (); std::vector<std::string>::const_iterator end = this->m_sound->getSounds ().end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -31,7 +31,7 @@ void CSound::load ()
readfile->read (filebuffer, filesize); readfile->read (filebuffer, filesize);
sdlRwops = SDL_RWFromConstMem(filebuffer, filesize); sdlRwops = SDL_RWFromConstMem (filebuffer, filesize);
music = Mix_LoadMUS_RW (sdlRwops); music = Mix_LoadMUS_RW (sdlRwops);
readfile->drop (); readfile->drop ();

View File

@ -19,13 +19,16 @@
namespace WallpaperEngine::Render::Shaders namespace WallpaperEngine::Render::Shaders
{ {
Compiler::Compiler (irr::io::path& file, Type type, std::map<std::string, int>* combos, bool recursive) Compiler::Compiler (irr::io::path& file, Type type, const std::map<std::string, int>& combos, bool recursive) :
m_combos (combos),
m_recursive (recursive),
m_type (type),
m_file (file),
m_error (""),
m_errorInfo ("")
{ {
this->m_recursive = recursive;
this->m_combos = combos;
// begin with an space so it gets ignored properly on parse // begin with an space so it gets ignored properly on parse
if (recursive == false) if (this->m_recursive == false)
{ {
// compatibility layer for OpenGL shaders // compatibility layer for OpenGL shaders
this->m_content = "#version 120\n" this->m_content = "#version 120\n"
@ -47,8 +50,8 @@ namespace WallpaperEngine::Render::Shaders
"#define ddy(x) dFdy(-(x))\n" "#define ddy(x) dFdy(-(x))\n"
"#define GLSL 1\n\n"; "#define GLSL 1\n\n";
std::map<std::string, int>::const_iterator cur = this->m_combos->begin (); auto cur = this->m_combos.begin ();
std::map<std::string, int>::const_iterator end = this->m_combos->end (); auto end = this->m_combos.end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -61,11 +64,6 @@ namespace WallpaperEngine::Render::Shaders
} }
this->m_content.append (WallpaperEngine::FileSystem::loadFullFile (file)); this->m_content.append (WallpaperEngine::FileSystem::loadFullFile (file));
// append file content
this->m_type = type;
this->m_file = file;
} }
bool Compiler::peekString(std::string str, std::string::const_iterator& it) bool Compiler::peekString(std::string str, std::string::const_iterator& it)
@ -126,8 +124,8 @@ namespace WallpaperEngine::Render::Shaders
std::string Compiler::extractType (std::string::const_iterator& it) std::string Compiler::extractType (std::string::const_iterator& it)
{ {
std::vector<std::string>::const_iterator cur = sTypes.begin (); auto cur = sTypes.begin ();
std::vector<std::string>::const_iterator end = sTypes.end (); auto end = sTypes.end ();
while (cur != end) while (cur != end)
{ {
@ -227,8 +225,8 @@ namespace WallpaperEngine::Render::Shaders
std::string Compiler::lookupReplaceSymbol (std::string symbol) std::string Compiler::lookupReplaceSymbol (std::string symbol)
{ {
std::map<std::string, std::string>::const_iterator cur = sVariableReplacement.begin (); auto cur = sVariableReplacement.begin ();
std::map<std::string, std::string>::const_iterator end = sVariableReplacement.end (); auto end = sVariableReplacement.end ();
while (cur != end) while (cur != end)
{ {
@ -458,8 +456,8 @@ namespace WallpaperEngine::Render::Shaders
void Compiler::parseComboConfiguration (const std::string& content) void Compiler::parseComboConfiguration (const std::string& content)
{ {
json data = json::parse (content); json data = json::parse (content);
json::const_iterator combo = data.find ("combo"); auto combo = data.find ("combo");
json::const_iterator defvalue = data.find ("default"); auto defvalue = data.find ("default");
// add line feed just in case // add line feed just in case
this->m_compiledContent += "\n"; this->m_compiledContent += "\n";
@ -470,11 +468,11 @@ namespace WallpaperEngine::Render::Shaders
} }
// check the combos // check the combos
std::map<std::string, int>::const_iterator entry = this->m_combos->find ((*combo).get <std::string> ()); std::map<std::string, int>::const_iterator entry = this->m_combos.find ((*combo).get <std::string> ());
// if the combo was not found in the predefined values this means that the default value in the JSON data can be used // if the combo was not found in the predefined values this means that the default value in the JSON data can be used
// so only define the ones that are not already defined // so only define the ones that are not already defined
if (entry == this->m_combos->end ()) if (entry == this->m_combos.end ())
{ {
// if no combo is defined just load the default settings // if no combo is defined just load the default settings
if ((*defvalue).is_number_float ()) if ((*defvalue).is_number_float ())
@ -499,9 +497,9 @@ namespace WallpaperEngine::Render::Shaders
void Compiler::parseParameterConfiguration (const std::string& type, const std::string& name, const std::string& content) void Compiler::parseParameterConfiguration (const std::string& type, const std::string& name, const std::string& content)
{ {
json data = json::parse (content); json data = json::parse (content);
json::const_iterator material = data.find ("material"); auto material = data.find ("material");
json::const_iterator defvalue = data.find ("default"); auto defvalue = data.find ("default");
json::const_iterator range = data.find ("range"); auto range = data.find ("range");
// this is not a real parameter // this is not a real parameter
if (material == data.end () || defvalue == data.end ()) if (material == data.end () || defvalue == data.end ())
@ -558,10 +556,10 @@ namespace WallpaperEngine::Render::Shaders
this->m_parameters.push_back (parameter); this->m_parameters.push_back (parameter);
} }
Parameters::CShaderParameter* Compiler::findParameter (std::string identifier) Parameters::CShaderParameter* Compiler::findParameter (const std::string& identifier)
{ {
std::vector<Parameters::CShaderParameter*>::const_iterator cur = this->m_parameters.begin (); auto cur = this->m_parameters.begin ();
std::vector<Parameters::CShaderParameter*>::const_iterator end = this->m_parameters.end (); auto end = this->m_parameters.end ();
for (; cur != end; cur ++) for (; cur != end; cur ++)
{ {
@ -574,7 +572,7 @@ namespace WallpaperEngine::Render::Shaders
return nullptr; return nullptr;
} }
std::vector <Parameters::CShaderParameter*>& Compiler::getParameters () const std::vector <Parameters::CShaderParameter*>& Compiler::getParameters () const
{ {
return this->m_parameters; return this->m_parameters;
} }

View File

@ -46,7 +46,7 @@ namespace WallpaperEngine::Render::Shaders
* @param type The type of shader * @param type The type of shader
* @param recursive Whether the compiler should add base definitions or not * @param recursive Whether the compiler should add base definitions or not
*/ */
Compiler (irr::io::path& file, Type type, std::map<std::string, int>* combos, bool recursive = false); Compiler (irr::io::path& file, Type type, const std::map<std::string, int>& combos, bool recursive = false);
/** /**
* Performs the actual pre-compilation/pre-processing over the shader files * Performs the actual pre-compilation/pre-processing over the shader files
* This step is kinda big, replaces variables names on sVariableReplacement, * This step is kinda big, replaces variables names on sVariableReplacement,
@ -62,12 +62,12 @@ namespace WallpaperEngine::Render::Shaders
* @param identifier The identifier to search for * @param identifier The identifier to search for
* @return The shader information * @return The shader information
*/ */
Parameters::CShaderParameter* findParameter (std::string identifier); Parameters::CShaderParameter* findParameter (const std::string& identifier);
/** /**
* @return The list of parameters available for this shader with their default values * @return The list of parameters available for this shader with their default values
*/ */
std::vector <Parameters::CShaderParameter*>& getParameters (); const std::vector <Parameters::CShaderParameter*>& getParameters () const;
private: private:
/** /**
@ -206,7 +206,7 @@ namespace WallpaperEngine::Render::Shaders
/** /**
* The combos the shader should be generated with * The combos the shader should be generated with
*/ */
std::map <std::string, int>* m_combos; const std::map <std::string, int>& m_combos;
/** /**
* Whether this compilation is a recursive one or not * Whether this compilation is a recursive one or not
*/ */

View File

@ -12,7 +12,7 @@ CShaderParameter::CShaderParameter (void* defaultValue, void* value, std::string
} }
void* CShaderParameter::getValue () const void* CShaderParameter::getValue () const
{ {
if (this->m_value) if (this->m_value)
return this->m_value; return this->m_value;
@ -25,12 +25,12 @@ void CShaderParameter::setValue (void* value)
this->m_value = value; this->m_value = value;
} }
std::string CShaderParameter::getIdentifierName () const std::string& CShaderParameter::getIdentifierName () const
{ {
return this->m_identifierName; return this->m_identifierName;
} }
std::string CShaderParameter::getName () const std::string& CShaderParameter::getName () const
{ {
return this->m_name; return this->m_name;
} }

View File

@ -9,19 +9,19 @@ namespace WallpaperEngine::Render::Shaders::Parameters
public: public:
CShaderParameter (void* defaultValue, void* value, std::string type); CShaderParameter (void* defaultValue, void* value, std::string type);
template<class T> const T* As () const { assert (Is<T> ()); return (const T*) this; } template<class T> const T* as () const { assert (is <T> ()); return (const T*) this; }
template<class T> T* As () { assert (Is<T> ()); return (T*) this; } template<class T> T* as () { assert (is <T> ()); return (T*) this; }
template<class T> bool Is () { return this->m_type == T::Type; } template<class T> bool is () { return this->m_type == T::Type; }
std::string getIdentifierName (); const std::string& getIdentifierName () const;
std::string getName (); const std::string& getName () const;
void setIdentifierName (std::string identifierName); void setIdentifierName (std::string identifierName);
void setName (std::string name); void setName (std::string name);
void* getValue (); const void* getValue () const;
virtual int getSize () = 0; virtual const int getSize () const = 0;
protected: protected:
void setValue (void* value); void setValue (void* value);

View File

@ -17,7 +17,7 @@ void CShaderParameterFloat::setValue (irr::f32 value)
CShaderParameter::setValue (&this->m_value); CShaderParameter::setValue (&this->m_value);
} }
int CShaderParameterFloat::getSize () const int CShaderParameterFloat::getSize () const
{ {
return 1; return 1;
} }

View File

@ -11,7 +11,7 @@ namespace WallpaperEngine::Render::Shaders::Parameters
public: public:
CShaderParameterFloat (irr::f32 defaultValue); CShaderParameterFloat (irr::f32 defaultValue);
int getSize () override; const int getSize () const override;
void setValue (irr::f32 value); void setValue (irr::f32 value);

View File

@ -16,7 +16,7 @@ void CShaderParameterInteger::setValue (irr::s32 value)
CShaderParameter::setValue (&this->m_value); CShaderParameter::setValue (&this->m_value);
} }
int CShaderParameterInteger::getSize () const int CShaderParameterInteger::getSize () const
{ {
return 1; return 1;
} }

View File

@ -11,7 +11,7 @@ namespace WallpaperEngine::Render::Shaders::Parameters
public: public:
CShaderParameterInteger (irr::s32 defaultValue); CShaderParameterInteger (irr::s32 defaultValue);
int getSize () override; const int getSize () const override;
static const std::string Type; static const std::string Type;

View File

@ -17,7 +17,7 @@ void CShaderParameterVector2::setValue (irr::core::vector2df value)
CShaderParameter::setValue (&this->m_value); CShaderParameter::setValue (&this->m_value);
} }
int CShaderParameterVector2::getSize () const int CShaderParameterVector2::getSize () const
{ {
return 2; return 2;
} }

View File

@ -11,7 +11,7 @@ namespace WallpaperEngine::Render::Shaders::Parameters
public: public:
CShaderParameterVector2 (const irr::core::vector2df& defaultValue); CShaderParameterVector2 (const irr::core::vector2df& defaultValue);
int getSize () override; const int getSize () const override;
void setValue (irr::core::vector2df value); void setValue (irr::core::vector2df value);

View File

@ -16,7 +16,7 @@ void CShaderParameterVector3::setValue (irr::core::vector3df value)
CShaderParameter::setValue (&this->m_value); CShaderParameter::setValue (&this->m_value);
} }
int CShaderParameterVector3::getSize () const int CShaderParameterVector3::getSize () const
{ {
return 3; return 3;
} }

View File

@ -11,7 +11,7 @@ namespace WallpaperEngine::Render::Shaders::Parameters
public: public:
CShaderParameterVector3 (const irr::core::vector3df& defaultValue); CShaderParameterVector3 (const irr::core::vector3df& defaultValue);
int getSize () override; const int getSize () const override;
void setValue (irr::core::vector3df value); void setValue (irr::core::vector3df value);

View File

@ -16,7 +16,7 @@ void CShaderParameterVector4::setValue (irr::core::vector3df value)
CShaderParameter::setValue (&this->m_value); CShaderParameter::setValue (&this->m_value);
} }
int CShaderParameterVector4::getSize () const int CShaderParameterVector4::getSize () const
{ {
return 4; return 4;
} }

View File

@ -11,7 +11,7 @@ namespace WallpaperEngine::Render::Shaders::Parameters
public: public:
CShaderParameterVector4 (const irr::core::vector3df& defaultValue); CShaderParameterVector4 (const irr::core::vector3df& defaultValue);
int getSize () override; const int getSize () const override;
void setValue (irr::core::vector3df value); void setValue (irr::core::vector3df value);