diff --git a/main.cpp b/main.cpp index c140b4a..18d18b1 100644 --- a/main.cpp +++ b/main.cpp @@ -53,8 +53,8 @@ void initialize_viewports () if (info == nullptr) continue; - std::vector::iterator cur = Screens.begin (); - std::vector::iterator end = Screens.end (); + auto cur = Screens.begin (); + auto end = Screens.end (); for (; cur != end; cur ++) { @@ -318,8 +318,8 @@ int main (int argc, char* argv[]) if (Viewports.size () > 0) { - std::vector>::iterator cur = Viewports.begin (); - std::vector>::iterator end = Viewports.end (); + auto cur = Viewports.begin (); + auto end = Viewports.end (); for (; cur != end; cur ++) { diff --git a/src/WallpaperEngine/Core/CObject.cpp b/src/WallpaperEngine/Core/CObject.cpp index e69594d..b1ea1cf 100644 --- a/src/WallpaperEngine/Core/CObject.cpp +++ b/src/WallpaperEngine/Core/CObject.cpp @@ -29,13 +29,13 @@ CObject::CObject ( CObject* CObject::fromJSON (json data) { - json::const_iterator id_it = data.find ("id"); - json::const_iterator visible_it = data.find ("visible"); - json::const_iterator origin_it = data.find ("origin"); - json::const_iterator scale_it = data.find ("scale"); - json::const_iterator angles_it = data.find ("angles"); - json::const_iterator name_it = data.find ("name"); - json::const_iterator effects_it = data.find ("effects"); + auto id_it = data.find ("id"); + auto visible_it = data.find ("visible"); + auto origin_it = data.find ("origin"); + auto scale_it = data.find ("scale"); + auto angles_it = data.find ("angles"); + auto name_it = data.find ("name"); + auto effects_it = data.find ("effects"); bool visible = true; @@ -70,9 +70,9 @@ CObject* CObject::fromJSON (json data) visible = *visible_it; } - json::const_iterator image_it = data.find ("image"); - json::const_iterator sound_it = data.find ("sound"); - json::const_iterator particle_it = data.find ("particle"); + auto image_it = data.find ("image"); + auto sound_it = data.find ("sound"); + auto particle_it = data.find ("particle"); CObject* object = nullptr; @@ -117,8 +117,8 @@ CObject* CObject::fromJSON (json data) if (effects_it != data.end () && (*effects_it).is_array () == true) { - json::const_iterator cur = (*effects_it).begin (); - json::const_iterator end = (*effects_it).end (); + auto cur = (*effects_it).begin (); + auto end = (*effects_it).end (); for (; cur != end; cur ++) { @@ -131,29 +131,29 @@ CObject* CObject::fromJSON (json data) 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; } -std::vector* CObject::getEffects () +const std::vector& CObject::getEffects () const { - return &this->m_effects; + return this->m_effects; } bool CObject::isVisible () @@ -161,7 +161,7 @@ bool CObject::isVisible () return this->m_visible; } -int CObject::getId () +const int CObject::getId () const { return this->m_id; } diff --git a/src/WallpaperEngine/Core/CObject.h b/src/WallpaperEngine/Core/CObject.h index 6a7ecba..9b1fa3f 100644 --- a/src/WallpaperEngine/Core/CObject.h +++ b/src/WallpaperEngine/Core/CObject.h @@ -19,18 +19,18 @@ namespace WallpaperEngine::Core public: static CObject* fromJSON (json data); - template const T* As () const { assert (Is ()); return (const T*) this; } - template T* As () { assert (Is ()); return (T*) this; } + template const T* as () const { assert (is ()); return (const T*) this; } + template T* as () { assert (is ()); return (T*) this; } - template bool Is () { return this->m_type == T::Type; } + template bool is () { return this->m_type == T::Type; } - std::vector* getEffects (); - int getId (); + const std::vector& getEffects () const; + const int getId () const; - irr::core::vector3df* getOrigin (); - irr::core::vector3df* getScale (); - irr::core::vector3df* getAngles (); - std::string getName (); + const irr::core::vector3df& getOrigin () const; + const irr::core::vector3df& getScale () const; + const irr::core::vector3df& getAngles () const; + const std::string& getName () const; bool isVisible (); protected: diff --git a/src/WallpaperEngine/Core/CProject.cpp b/src/WallpaperEngine/Core/CProject.cpp index 4740b57..af8f6e0 100644 --- a/src/WallpaperEngine/Core/CProject.cpp +++ b/src/WallpaperEngine/Core/CProject.cpp @@ -16,10 +16,10 @@ CProject* CProject::fromFile (const irr::io::path& filename) { json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename)); - json::const_iterator title = content.find ("title"); - json::const_iterator type = content.find ("type"); - json::const_iterator file = content.find ("file"); - json::const_iterator general = content.find ("general"); + auto title = content.find ("title"); + auto type = content.find ("type"); + auto file = content.find ("file"); + auto general = content.find ("general"); if (title == content.end ()) { @@ -44,12 +44,12 @@ CProject* CProject::fromFile (const irr::io::path& filename) if (general != content.end ()) { - json::const_iterator properties = (*general).find ("properties"); + auto properties = (*general).find ("properties"); if (properties != (*general).end ()) { - json::const_iterator cur = (*properties).begin (); - json::const_iterator end = (*properties).end (); + auto cur = (*properties).begin (); + auto end = (*properties).end (); for (; cur != end; cur ++) { @@ -63,24 +63,24 @@ CProject* CProject::fromFile (const irr::io::path& filename) return project; } -CScene* CProject::getScene () +const CScene* CProject::getScene () const { return this->m_scene; } -std::string CProject::getTitle () +const std::string& CProject::getTitle () const { return this->m_title; } -std::string CProject::getType () +const std::string& CProject::getType () const { return this->m_type; } -std::vector* CProject::getProperties () +const std::vector& CProject::getProperties () const { - return &this->m_properties; + return this->m_properties; } void CProject::insertProperty (Projects::CProperty* property) diff --git a/src/WallpaperEngine/Core/CProject.h b/src/WallpaperEngine/Core/CProject.h index a806ec5..570b50b 100644 --- a/src/WallpaperEngine/Core/CProject.h +++ b/src/WallpaperEngine/Core/CProject.h @@ -17,11 +17,11 @@ namespace WallpaperEngine::Core public: static CProject* fromFile (const irr::io::path& filename); - CScene* getScene (); + const CScene* getScene () const; - std::string getTitle (); - std::string getType (); - std::vector* getProperties (); + const std::string& getTitle () const; + const std::string& getType () const; + const std::vector& getProperties () const; protected: CProject (std::string title, std::string type, CScene* scene); diff --git a/src/WallpaperEngine/Core/CScene.cpp b/src/WallpaperEngine/Core/CScene.cpp index 698770d..c7112d4 100644 --- a/src/WallpaperEngine/Core/CScene.cpp +++ b/src/WallpaperEngine/Core/CScene.cpp @@ -50,9 +50,9 @@ CScene* CScene::fromFile (const irr::io::path& filename) { json content = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename)); - json::const_iterator camera_it = content.find ("camera"); - json::const_iterator general_it = content.find ("general"); - json::const_iterator objects_it = content.find ("objects"); + auto camera_it = content.find ("camera"); + auto general_it = content.find ("general"); + auto objects_it = content.find ("objects"); 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"); } - json::const_iterator ambientcolor_it = (*general_it).find ("ambientcolor"); - json::const_iterator bloom_it = (*general_it).find ("bloom"); - json::const_iterator bloomstrength_it = (*general_it).find ("bloomstrength"); - json::const_iterator bloomthreshold_it = (*general_it).find ("bloomthreshold"); - json::const_iterator camerafade_it = (*general_it).find ("camerafade"); - json::const_iterator cameraparallax_it = (*general_it).find ("cameraparallax"); - json::const_iterator cameraparallaxamount_it = (*general_it).find ("cameraparallaxamount"); - json::const_iterator cameraparallaxdelay_it = (*general_it).find ("cameraparallaxdelay"); - json::const_iterator cameraparallaxmouseinfluence_it = (*general_it).find ("cameraparallaxmouseinfluence"); - json::const_iterator camerapreview_it = (*general_it).find ("camerapreview"); - json::const_iterator camerashake_it = (*general_it).find ("camerashake"); - json::const_iterator camerashakeamplitude_it = (*general_it).find ("camerashakeamplitude"); - json::const_iterator camerashakeroughness_it = (*general_it).find ("camerashakeroughness"); - json::const_iterator camerashakespeed_it = (*general_it).find ("camerashakespeed"); - json::const_iterator clearcolor_it = (*general_it).find ("clearcolor"); - json::const_iterator orthogonalprojection_it = (*general_it).find ("orthogonalprojection"); - json::const_iterator skylightcolor_it = (*general_it).find ("skylightcolor"); + auto ambientcolor_it = (*general_it).find ("ambientcolor"); + auto bloom_it = (*general_it).find ("bloom"); + auto bloomstrength_it = (*general_it).find ("bloomstrength"); + auto bloomthreshold_it = (*general_it).find ("bloomthreshold"); + auto camerafade_it = (*general_it).find ("camerafade"); + auto cameraparallax_it = (*general_it).find ("cameraparallax"); + auto cameraparallaxamount_it = (*general_it).find ("cameraparallaxamount"); + auto cameraparallaxdelay_it = (*general_it).find ("cameraparallaxdelay"); + auto cameraparallaxmouseinfluence_it = (*general_it).find ("cameraparallaxmouseinfluence"); + auto camerapreview_it = (*general_it).find ("camerapreview"); + auto camerashake_it = (*general_it).find ("camerashake"); + auto camerashakeamplitude_it = (*general_it).find ("camerashakeamplitude"); + auto camerashakeroughness_it = (*general_it).find ("camerashakeroughness"); + auto camerashakespeed_it = (*general_it).find ("camerashakespeed"); + auto clearcolor_it = (*general_it).find ("clearcolor"); + auto orthogonalprojection_it = (*general_it).find ("orthogonalprojection"); + auto skylightcolor_it = (*general_it).find ("skylightcolor"); if (ambientcolor_it == (*general_it).end ()) { @@ -193,8 +193,8 @@ CScene* CScene::fromFile (const irr::io::path& filename) WallpaperEngine::Core::atoSColorf (*skylightcolor_it) ); - json::const_iterator cur = (*objects_it).begin (); - json::const_iterator end = (*objects_it).end (); + auto cur = (*objects_it).begin (); + auto end = (*objects_it).end (); for (; cur != end; cur ++) { @@ -207,9 +207,9 @@ CScene* CScene::fromFile (const irr::io::path& filename) } -std::vector* CScene::getObjects () +const std::vector& CScene::getObjects () const { - return &this->m_objects; + return this->m_objects; } void CScene::insertObject (CObject* object) @@ -227,7 +227,7 @@ void CScene::setProject (CProject* project) this->m_project = project; } -Scenes::CCamera* CScene::getCamera () +const Scenes::CCamera* CScene::getCamera () const { return this->m_camera; } @@ -237,82 +237,82 @@ const irr::video::SColorf &CScene::getAmbientColor() const return this->m_ambientColor; } -bool CScene::isBloom () const +const bool CScene::isBloom () const { return this->m_bloom; } -irr::f64 CScene::getBloomStrength () const +const irr::f64 CScene::getBloomStrength () const { return this->m_bloomStrength; } -irr::f64 CScene::getBloomThreshold () const +const irr::f64 CScene::getBloomThreshold () const { return this->m_bloomThreshold; } -bool CScene::isCameraFade () const +const bool CScene::isCameraFade () const { return this->m_cameraFade; } -bool CScene::isCameraParallax () const +const bool CScene::isCameraParallax () const { return this->m_cameraParallax; } -irr::f64 CScene::getCameraParallaxAmount () const +const irr::f64 CScene::getCameraParallaxAmount () const { return this->m_cameraParallaxAmount; } -irr::f64 CScene::getCameraParallaxDelay () const +const irr::f64 CScene::getCameraParallaxDelay () const { return this->m_cameraParallaxDelay; } -irr::f64 CScene::getCameraParallaxMouseInfluence () const +const irr::f64 CScene::getCameraParallaxMouseInfluence () const { return this->m_cameraParallaxMouseInfluence; } -bool CScene::isCameraPreview () const +const bool CScene::isCameraPreview () const { return this->m_cameraPreview; } -bool CScene::isCameraShake () const +const bool CScene::isCameraShake () const { return this->m_cameraShake; } -irr::f64 CScene::getCameraShakeAmplitude () const +const irr::f64 CScene::getCameraShakeAmplitude () const { return this->m_cameraShakeAmplitude; } -irr::f64 CScene::getCameraShakeRoughness () const +const irr::f64 CScene::getCameraShakeRoughness () const { return this->m_cameraShakeRoughness; } -irr::f64 CScene::getCameraShakeSpeed () const +const irr::f64 CScene::getCameraShakeSpeed () const { return this->m_cameraShakeSpeed; } -const irr::video::SColorf &CScene::getClearColor () const +const irr::video::SColorf& CScene::getClearColor () const { return this->m_clearColor; } -Scenes::CProjection* CScene::getOrthogonalProjection () const +const Scenes::CProjection* CScene::getOrthogonalProjection () const { return this->m_orthogonalProjection; } -const irr::video::SColorf &CScene::getSkylightColor () const +const irr::video::SColorf& CScene::getSkylightColor () const { return this->m_skylightColor; } diff --git a/src/WallpaperEngine/Core/CScene.h b/src/WallpaperEngine/Core/CScene.h index 4165463..842c499 100644 --- a/src/WallpaperEngine/Core/CScene.h +++ b/src/WallpaperEngine/Core/CScene.h @@ -22,26 +22,26 @@ namespace WallpaperEngine::Core static CScene* fromFile (const irr::io::path& filename); CProject* getProject (); - std::vector* getObjects (); + const std::vector& getObjects () const; - const irr::video::SColorf &getAmbientColor() const; - bool isBloom() const; - irr::f64 getBloomStrength() const; - irr::f64 getBloomThreshold() const; - bool isCameraFade() const; - bool isCameraParallax() const; - irr::f64 getCameraParallaxAmount() const; - irr::f64 getCameraParallaxDelay() const; - irr::f64 getCameraParallaxMouseInfluence() const; - bool isCameraPreview() const; - bool isCameraShake() const; - irr::f64 getCameraShakeAmplitude() const; - irr::f64 getCameraShakeRoughness() const; - irr::f64 getCameraShakeSpeed() const; - const irr::video::SColorf &getClearColor() const; - Scenes::CProjection *getOrthogonalProjection() const; - const irr::video::SColorf &getSkylightColor() const; - Scenes::CCamera* getCamera (); + const irr::video::SColorf& getAmbientColor() const; + const bool isBloom() const; + const irr::f64 getBloomStrength() const; + const irr::f64 getBloomThreshold() const; + const bool isCameraFade() const; + const bool isCameraParallax() const; + const irr::f64 getCameraParallaxAmount() const; + const irr::f64 getCameraParallaxDelay() const; + const irr::f64 getCameraParallaxMouseInfluence() const; + const bool isCameraPreview() const; + const bool isCameraShake() const; + const irr::f64 getCameraShakeAmplitude() const; + const irr::f64 getCameraShakeRoughness() const; + const irr::f64 getCameraShakeSpeed() const; + const irr::video::SColorf& getClearColor() const; + const Scenes::CProjection* getOrthogonalProjection() const; + const irr::video::SColorf& getSkylightColor() const; + const Scenes::CCamera* getCamera () const; protected: friend class CProject; diff --git a/src/WallpaperEngine/Core/Core.cpp b/src/WallpaperEngine/Core/Core.cpp index 1d3f52f..90d00ea 100644 --- a/src/WallpaperEngine/Core/Core.cpp +++ b/src/WallpaperEngine/Core/Core.cpp @@ -1,7 +1,9 @@ #include #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 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); } -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 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); } -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 ( 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 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); } -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 ()); } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/CEffect.cpp b/src/WallpaperEngine/Core/Objects/CEffect.cpp index 8a8fd34..346947e 100644 --- a/src/WallpaperEngine/Core/Objects/CEffect.cpp +++ b/src/WallpaperEngine/Core/Objects/CEffect.cpp @@ -28,8 +28,8 @@ CEffect::CEffect ( CEffect* CEffect::fromJSON (json data, Core::CObject* object) { - json::const_iterator file_it = data.find ("file"); - json::const_iterator effectpasses_it = data.find ("passes"); + auto file_it = data.find ("file"); + auto effectpasses_it = data.find ("passes"); 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 ().c_str ())); - json::const_iterator name_it = content.find ("name"); - json::const_iterator description_it = content.find ("description"); - json::const_iterator group_it = content.find ("group"); - json::const_iterator preview_it = content.find ("preview"); - json::const_iterator passes_it = content.find ("passes"); - json::const_iterator dependencies_it = content.find ("dependencies"); + auto name_it = content.find ("name"); + auto description_it = content.find ("description"); + auto group_it = content.find ("group"); + auto preview_it = content.find ("preview"); + auto passes_it = content.find ("passes"); + auto dependencies_it = content.find ("dependencies"); if (name_it == content.end ()) { @@ -83,12 +83,12 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object) object ); - json::const_iterator cur = (*passes_it).begin (); - json::const_iterator end = (*passes_it).end (); + auto cur = (*passes_it).begin (); + auto end = (*passes_it).end (); for (; cur != end; cur ++) { - json::const_iterator materialfile = (*cur).find ("material"); + auto materialfile = (*cur).find ("material"); if (materialfile == (*cur).end ()) { @@ -115,13 +115,13 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object) 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 ()) continue; - json::const_iterator constantCur = (*constants_it).begin (); - json::const_iterator constantEnd = (*constants_it).end (); + auto constantCur = (*constants_it).begin (); + auto constantEnd = (*constants_it).end (); for (; constantCur != constantEnd; constantCur ++) { @@ -147,19 +147,19 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object) effect->insertConstant (constantCur.key (), constant); } - json::const_iterator textures_it = (*cur).find ("textures"); + auto textures_it = (*cur).find ("textures"); if (textures_it == (*cur).end ()) continue; - Images::CMaterial* material = effect->getMaterials ()->at (passNumber); - std::vector::const_iterator materialCur = material->getPasses ()->begin (); - std::vector::const_iterator materialEnd = material->getPasses ()->end (); + Images::CMaterial* material = effect->getMaterials ().at (passNumber); + auto passCur = material->getPasses ().begin (); + auto passEnd = material->getPasses ().end (); - for (; materialCur != materialEnd; materialCur ++) + for (; passCur != passEnd; passCur ++) { - json::const_iterator texturesCur = (*textures_it).begin (); - json::const_iterator texturesEnd = (*textures_it).end (); + auto texturesCur = (*textures_it).begin (); + auto texturesEnd = (*textures_it).end (); 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 (object->Is () == false) + if (object->is() == false) { throw std::runtime_error ("unexpected null texture for non-image object"); } - CImage* image = object->As (); + CImage* image = object->as(); - texture = (*(*image->getMaterial ()->getPasses ()->begin ())->getTextures ()->begin ()); + texture = (*(*image->getMaterial ()->getPasses ().begin ())->getTextures ()->begin ()); } else { texture = *texturesCur; } - std::vector* passTextures = (*materialCur)->getTextures (); + std::vector* passTextures = (*passCur)->getTextures (); if (textureNumber < passTextures->size ()) passTextures->at (textureNumber) = texture; @@ -198,19 +198,19 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object) return effect; } -std::vector* CEffect::getDependencies () +const std::vector& CEffect::getDependencies () const { - return &this->m_dependencies; + return this->m_dependencies; } -std::vector* CEffect::getMaterials () +const std::vector& CEffect::getMaterials () const { - return &this->m_materials; + return this->m_materials; } -std::map* CEffect::getConstants () +const std::map& CEffect::getConstants () const { - return &this->m_constants; + return this->m_constants; } void CEffect::insertDependency (const std::string& dep) diff --git a/src/WallpaperEngine/Core/Objects/CEffect.h b/src/WallpaperEngine/Core/Objects/CEffect.h index a23915b..ab48862 100644 --- a/src/WallpaperEngine/Core/Objects/CEffect.h +++ b/src/WallpaperEngine/Core/Objects/CEffect.h @@ -29,9 +29,9 @@ namespace WallpaperEngine::Core::Objects static CEffect* fromJSON (json data, Core::CObject* object); - std::vector* getDependencies (); - std::vector* getMaterials (); - std::map* getConstants (); + const std::vector& getDependencies () const; + const std::vector& getMaterials () const; + const std::map& getConstants () const; protected: void insertDependency (const std::string& dep); void insertMaterial (Images::CMaterial* material); diff --git a/src/WallpaperEngine/Core/Objects/CImage.cpp b/src/WallpaperEngine/Core/Objects/CImage.cpp index 76da058..4ca86b0 100644 --- a/src/WallpaperEngine/Core/Objects/CImage.cpp +++ b/src/WallpaperEngine/Core/Objects/CImage.cpp @@ -30,8 +30,8 @@ WallpaperEngine::Core::CObject* CImage::fromJSON ( const irr::core::vector3df& scale, const irr::core::vector3df& angles) { - json::const_iterator image_it = data.find ("image"); - json::const_iterator size_it = data.find ("size"); + auto image_it = data.find ("image"); + auto size_it = data.find ("size"); if (size_it == data.end ()) { @@ -40,7 +40,7 @@ WallpaperEngine::Core::CObject* CImage::fromJSON ( json content = json::parse (WallpaperEngine::FileSystem::loadFullFile ((*image_it).get ().c_str ())); - json::const_iterator material_it = content.find ("material"); + auto material_it = content.find ("material"); 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; } -irr::core::vector2df* CImage::getSize () +const irr::core::vector2df& CImage::getSize () const { - return &this->m_size; + return this->m_size; } diff --git a/src/WallpaperEngine/Core/Objects/CImage.h b/src/WallpaperEngine/Core/Objects/CImage.h index 38f5a94..6f5c88d 100644 --- a/src/WallpaperEngine/Core/Objects/CImage.h +++ b/src/WallpaperEngine/Core/Objects/CImage.h @@ -26,8 +26,8 @@ namespace WallpaperEngine::Core::Objects const irr::core::vector3df& angles ); - Images::CMaterial* getMaterial (); - irr::core::vector2df* getSize (); + const Images::CMaterial* getMaterial () const; + const irr::core::vector2df& getSize () const; protected: CImage ( diff --git a/src/WallpaperEngine/Core/Objects/CParticle.cpp b/src/WallpaperEngine/Core/Objects/CParticle.cpp index 8b334c8..df0b5ed 100644 --- a/src/WallpaperEngine/Core/Objects/CParticle.cpp +++ b/src/WallpaperEngine/Core/Objects/CParticle.cpp @@ -13,11 +13,11 @@ CParticle* CParticle::fromFile ( const irr::core::vector3df& scale) { json data = json::parse (WallpaperEngine::FileSystem::loadFullFile (filename)); - json::const_iterator controlpoint_it = data.find ("controlpoint"); - json::const_iterator starttime_it = data.find ("starttime"); - json::const_iterator maxcount_it = data.find ("maxcount"); - json::const_iterator emitter_it = data.find ("emitter"); - json::const_iterator initializer_it = data.find ("initializer"); + auto controlpoint_it = data.find ("controlpoint"); + auto starttime_it = data.find ("starttime"); + auto maxcount_it = data.find ("maxcount"); + auto emitter_it = data.find ("emitter"); + auto initializer_it = data.find ("initializer"); if (starttime_it == data.end ()) { @@ -50,8 +50,8 @@ CParticle* CParticle::fromFile ( if (controlpoint_it != data.end ()) { - json::const_iterator cur = (*controlpoint_it).begin (); - json::const_iterator end = (*controlpoint_it).end (); + auto cur = (*controlpoint_it).begin (); + auto end = (*controlpoint_it).end (); for (; cur != end; cur ++) { @@ -61,8 +61,8 @@ CParticle* CParticle::fromFile ( } } - json::const_iterator cur = (*emitter_it).begin (); - json::const_iterator end = (*emitter_it).end (); + auto cur = (*emitter_it).begin (); + auto end = (*emitter_it).end (); for (; cur != end; cur ++) { @@ -97,19 +97,19 @@ CParticle::CParticle ( { } -std::vector* CParticle::getEmitters () +const std::vector& CParticle::getEmitters () const { - return &this->m_emitters; + return this->m_emitters; } -std::vector* CParticle::getControlPoints () +const std::vector& CParticle::getControlPoints () const { - return &this->m_controlpoints; + return this->m_controlpoints; } -std::vector* CParticle::getInitializers () +const std::vector& CParticle::getInitializers () const { - return &this->m_initializers; + return this->m_initializers; } void CParticle::insertControlPoint (Particles::CControlPoint* controlpoint) diff --git a/src/WallpaperEngine/Core/Objects/CParticle.h b/src/WallpaperEngine/Core/Objects/CParticle.h index fec7b48..34bf6ac 100644 --- a/src/WallpaperEngine/Core/Objects/CParticle.h +++ b/src/WallpaperEngine/Core/Objects/CParticle.h @@ -26,9 +26,9 @@ namespace WallpaperEngine::Core::Objects const irr::core::vector3df& scale ); - std::vector* getEmitters (); - std::vector* getControlPoints (); - std::vector* getInitializers (); + const std::vector& getEmitters () const; + const std::vector& getControlPoints () const; + const std::vector& getInitializers () const; protected: CParticle ( diff --git a/src/WallpaperEngine/Core/Objects/CSound.cpp b/src/WallpaperEngine/Core/Objects/CSound.cpp index 79a0dcf..6f6f6f4 100644 --- a/src/WallpaperEngine/Core/Objects/CSound.cpp +++ b/src/WallpaperEngine/Core/Objects/CSound.cpp @@ -25,7 +25,7 @@ WallpaperEngine::Core::CObject* CSound::fromJSON ( const irr::core::vector3df& scale, const irr::core::vector3df& angles) { - json::const_iterator sound_it = data.find ("sound"); + auto sound_it = data.find ("sound"); if (sound_it == data.end ()) { @@ -46,8 +46,8 @@ WallpaperEngine::Core::CObject* CSound::fromJSON ( angles ); - json::const_iterator cur = (*sound_it).begin (); - json::const_iterator end = (*sound_it).end (); + auto cur = (*sound_it).begin (); + auto end = (*sound_it).end (); for (; cur != end; cur ++) { @@ -62,9 +62,9 @@ void CSound::insertSound (std::string filename) this->m_sounds.push_back (filename); } -std::vector* CSound::getSounds () +const std::vector& CSound::getSounds () const { - return &this->m_sounds; + return this->m_sounds; } const std::string CSound::Type = "sound"; \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/CSound.h b/src/WallpaperEngine/Core/Objects/CSound.h index ebb35f9..a9c4173 100644 --- a/src/WallpaperEngine/Core/Objects/CSound.h +++ b/src/WallpaperEngine/Core/Objects/CSound.h @@ -25,7 +25,7 @@ namespace WallpaperEngine::Core::Objects ); void insertSound (std::string filename); - std::vector* getSounds (); + const std::vector& getSounds () const; protected: CSound ( diff --git a/src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.h b/src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.h index 1593e25..e038536 100644 --- a/src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.h +++ b/src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.h @@ -9,10 +9,10 @@ namespace WallpaperEngine::Core::Objects::Effects public: CShaderConstant (std::string type); - template const T* As () const { assert (Is ()); return (const T*) this; } - template T* As () { assert (Is ()); return (T*) this; } + template const T* as () const { assert (is ()); return (const T*) this; } + template T* as () { assert (is ()); return (T*) this; } - template bool Is () { return this->m_type == T::Type; } + template bool is () { return this->m_type == T::Type; } private: std::string m_type; diff --git a/src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp b/src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp index 71a284f..71ee169 100644 --- a/src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp +++ b/src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp @@ -20,7 +20,7 @@ CMaterial* CMaterial::fromFile (irr::io::path filename) CMaterial* CMaterial::fromJSON (json data) { - json::const_iterator passes_it = data.find ("passes"); + auto passes_it = data.find ("passes"); if (passes_it == data.end ()) { @@ -29,8 +29,8 @@ CMaterial* CMaterial::fromJSON (json data) CMaterial* material = new CMaterial (); - json::const_iterator cur = (*passes_it).begin (); - json::const_iterator end = (*passes_it).end (); + auto cur = (*passes_it).begin (); + auto end = (*passes_it).end (); for (; cur != end; cur ++) { @@ -47,7 +47,7 @@ void CMaterial::insertPass (Materials::CPassess* mass) this->m_passes.push_back (mass); } -std::vector * CMaterial::getPasses () +const std::vector & CMaterial::getPasses () const { - return &this->m_passes; + return this->m_passes; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Images/CMaterial.h b/src/WallpaperEngine/Core/Objects/Images/CMaterial.h index bc2ba04..fe6d1fc 100644 --- a/src/WallpaperEngine/Core/Objects/Images/CMaterial.h +++ b/src/WallpaperEngine/Core/Objects/Images/CMaterial.h @@ -17,7 +17,7 @@ namespace WallpaperEngine::Core::Objects::Images void insertPass (Materials::CPassess* mass); - std::vector * getPasses (); + const std::vector & getPasses () const; protected: CMaterial (); private: diff --git a/src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.cpp b/src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.cpp index ac3ff48..8a97703 100644 --- a/src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.cpp +++ b/src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.cpp @@ -11,20 +11,15 @@ CPassess::CPassess (std::string blending, std::string cullmode, std::string dept { } -std::vector* CPassess::getTextures () -{ - return &this->m_textures; -} - CPassess* CPassess::fromJSON (json data) { - json::const_iterator blending_it = data.find ("blending"); - json::const_iterator cullmode_it = data.find ("cullmode"); - json::const_iterator depthtest_it = data.find ("depthtest"); - json::const_iterator depthwrite_it = data.find ("depthwrite"); - json::const_iterator shader_it = data.find ("shader"); - json::const_iterator textures_it = data.find ("textures"); - json::const_iterator combos_it = data.find ("combos"); + auto blending_it = data.find ("blending"); + auto cullmode_it = data.find ("cullmode"); + auto depthtest_it = data.find ("depthtest"); + auto depthwrite_it = data.find ("depthwrite"); + auto shader_it = data.find ("shader"); + auto textures_it = data.find ("textures"); + auto combos_it = data.find ("combos"); if (blending_it == data.end ()) { @@ -70,8 +65,8 @@ CPassess* CPassess::fromJSON (json data) if (textures_it != data.end ()) { - json::const_iterator cur = (*textures_it).begin (); - json::const_iterator end = (*textures_it).end (); + auto cur = (*textures_it).begin (); + auto end = (*textures_it).end (); for (;cur != end; cur ++) { @@ -88,8 +83,8 @@ CPassess* CPassess::fromJSON (json data) if (combos_it != data.end ()) { - json::const_iterator cur = (*combos_it).begin (); - json::const_iterator end = (*combos_it).end (); + auto cur = (*combos_it).begin (); + auto end = (*combos_it).end (); for (; cur != end; cur ++) { @@ -109,7 +104,6 @@ CPassess* CPassess::fromJSON (json data) return pass; } - void CPassess::insertTexture (const std::string& 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 (name, value)); } -std::map* CPassess::getCombos () +std::vector* CPassess::getTextures () { - return &this->m_combos; + return &this->m_textures; } -std::string CPassess::getShader () +const std::map& CPassess::getCombos () const +{ + return this->m_combos; +} + +const std::string& CPassess::getShader () const { 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; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.h b/src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.h index eaf3214..1d1e3d5 100644 --- a/src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.h +++ b/src/WallpaperEngine/Core/Objects/Images/Materials/CPassess.h @@ -12,8 +12,14 @@ namespace WallpaperEngine::Core::Objects::Images::Materials static CPassess* fromJSON (json data); std::vector* getTextures (); - std::map* getCombos (); - std::string getShader (); + + const std::map& 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: CPassess (std::string blending, std::string cullmode, std::string depthtest, std::string depthwrite, std::string shader); diff --git a/src/WallpaperEngine/Core/Objects/Particles/CControlPoint.cpp b/src/WallpaperEngine/Core/Objects/Particles/CControlPoint.cpp index 32be7d2..b89d975 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/CControlPoint.cpp +++ b/src/WallpaperEngine/Core/Objects/Particles/CControlPoint.cpp @@ -6,9 +6,9 @@ using namespace WallpaperEngine::Core::Objects::Particles; CControlPoint* CControlPoint::fromJSON (json data) { - json::const_iterator flags_it = data.find ("flags"); - json::const_iterator id_it = data.find ("id"); - json::const_iterator offset_it = data.find ("offset"); + auto flags_it = data.find ("flags"); + auto id_it = data.find ("id"); + auto offset_it = data.find ("offset"); if (id_it == data.end ()) { @@ -47,12 +47,12 @@ void CControlPoint::setFlags (irr::u32 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; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Particles/CControlPoint.h b/src/WallpaperEngine/Core/Objects/Particles/CControlPoint.h index b642d28..2a00dd5 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/CControlPoint.h +++ b/src/WallpaperEngine/Core/Objects/Particles/CControlPoint.h @@ -12,8 +12,8 @@ namespace WallpaperEngine::Core::Objects::Particles public: static CControlPoint* fromJSON (json data); - irr::core::vector3df* getOffset (); - irr::u32 getFlags (); + const irr::core::vector3df& getOffset () const; + const irr::u32 getFlags () const; protected: CControlPoint (irr::u32 id, irr::u32 flags = 0); diff --git a/src/WallpaperEngine/Core/Objects/Particles/CEmitter.cpp b/src/WallpaperEngine/Core/Objects/Particles/CEmitter.cpp index 86d00c7..21cccbe 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/CEmitter.cpp +++ b/src/WallpaperEngine/Core/Objects/Particles/CEmitter.cpp @@ -6,13 +6,13 @@ using namespace WallpaperEngine::Core::Objects::Particles; CEmitter* CEmitter::fromJSON (json data) { - json::const_iterator directions_it = data.find ("directions"); - json::const_iterator distancemax_it = data.find ("distancemax"); - json::const_iterator distancemin_it = data.find ("distancemin"); - json::const_iterator id_it = data.find ("id"); - json::const_iterator name_it = data.find ("name"); - json::const_iterator origin_it = data.find ("origin"); - json::const_iterator rate_it = data.find ("rate"); + auto directions_it = data.find ("directions"); + auto distancemax_it = data.find ("distancemax"); + auto distancemin_it = data.find ("distancemin"); + auto id_it = data.find ("id"); + auto name_it = data.find ("name"); + auto origin_it = data.find ("origin"); + auto rate_it = data.find ("rate"); if (directions_it == data.end ()) { @@ -79,27 +79,27 @@ const std::string& CEmitter::getName () const return this->m_name; } -irr::u32 CEmitter::getDistanceMax () const +const irr::u32 CEmitter::getDistanceMax () const { return this->m_distancemax; } -irr::u32 CEmitter::getDistanceMin () const +const irr::u32 CEmitter::getDistanceMin () const { 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; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Particles/CEmitter.h b/src/WallpaperEngine/Core/Objects/Particles/CEmitter.h index 70b18de..f574b13 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/CEmitter.h +++ b/src/WallpaperEngine/Core/Objects/Particles/CEmitter.h @@ -13,11 +13,11 @@ namespace WallpaperEngine::Core::Objects::Particles static CEmitter* fromJSON (json data); const std::string& getName () const; - irr::u32 getDistanceMax () const; - irr::u32 getDistanceMin () const; - irr::core::vector3df* getDirections (); - irr::core::vector3df* getOrigin (); - irr::f64 getRate () const; + const irr::u32 getDistanceMax () const; + const irr::u32 getDistanceMin () const; + const irr::core::vector3df& getDirections () const; + const irr::core::vector3df& getOrigin () const; + const irr::f64 getRate () const; protected: CEmitter ( const irr::core::vector3df& directions, diff --git a/src/WallpaperEngine/Core/Objects/Particles/CInitializer.cpp b/src/WallpaperEngine/Core/Objects/Particles/CInitializer.cpp index 7d1f506..39bf0f0 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/CInitializer.cpp +++ b/src/WallpaperEngine/Core/Objects/Particles/CInitializer.cpp @@ -12,8 +12,8 @@ using namespace WallpaperEngine::Core::Objects::Particles; CInitializer* CInitializer::fromJSON (json data) { - json::const_iterator id_it = data.find ("id"); - json::const_iterator name_it = data.find ("name"); + auto id_it = data.find ("id"); + auto name_it = data.find ("name"); irr::u32 id = ((id_it == data.end ()) ? 0 : (irr::u32) (*id_it)); 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; } -irr::u32 CInitializer::getId () +const irr::u32 CInitializer::getId () const { return this->m_id; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Particles/CInitializer.h b/src/WallpaperEngine/Core/Objects/Particles/CInitializer.h index b1151eb..0aa6ee1 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/CInitializer.h +++ b/src/WallpaperEngine/Core/Objects/Particles/CInitializer.h @@ -12,8 +12,8 @@ namespace WallpaperEngine::Core::Objects::Particles public: static CInitializer* fromJSON (json data); - std::string& getName (); - irr::u32 getId (); + const std::string& getName () const; + const irr::u32 getId () const; protected: CInitializer (irr::u32 id, std::string name); private: diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.cpp b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.cpp index 7a52206..57be620 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.cpp +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.cpp @@ -4,8 +4,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers; CAlphaRandom* CAlphaRandom::fromJSON (json data, irr::u32 id) { - json::const_iterator min_it = data.find ("min"); - json::const_iterator max_it = data.find ("max"); + auto min_it = data.find ("min"); + auto max_it = data.find ("max"); 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; } -irr::f64 CAlphaRandom::getMaximum () +const irr::f64 CAlphaRandom::getMaximum () const { return this->m_max; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.h b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.h index 6f5845a..02a2d17 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.h +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAlphaRandom.h @@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers class CAlphaRandom : CInitializer { public: - irr::f64 getMinimum (); - irr::f64 getMaximum (); + const irr::f64 getMinimum () const; + const irr::f64 getMaximum () const; protected: friend class CInitializer; diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.cpp b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.cpp index 3e62294..de3b5a6 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.cpp +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.cpp @@ -6,8 +6,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers; CAngularVelocityRandom* CAngularVelocityRandom::fromJSON (json data, irr::u32 id) { - json::const_iterator min_it = data.find ("min"); - json::const_iterator max_it = data.find ("max"); + auto min_it = data.find ("min"); + auto max_it = data.find ("max"); 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; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.h b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.h index fda06f2..353dc3d 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.h +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CAngularVelocityRandom.h @@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers class CAngularVelocityRandom : CInitializer { public: - irr::core::vector3df* getMinimum (); - irr::core::vector3df* getMaximum (); + const irr::core::vector3df& getMinimum () const; + const irr::core::vector3df& getMaximum () const; protected: friend class CInitializer; diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.cpp b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.cpp index 4f543ca..927d7d6 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.cpp +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.cpp @@ -6,8 +6,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers; CColorRandom* CColorRandom::fromJSON (json data, irr::u32 id) { - json::const_iterator min_it = data.find ("min"); - json::const_iterator max_it = data.find ("max"); + auto min_it = data.find ("min"); + auto max_it = data.find ("max"); 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; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.h b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.h index 4b19128..306469d 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.h +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CColorRandom.h @@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers class CColorRandom : CInitializer { public: - irr::video::SColor* getMinimum (); - irr::video::SColor* getMaximum (); + const irr::video::SColor& getMinimum () const; + const irr::video::SColor& getMaximum () const; protected: friend class CInitializer; diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.cpp b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.cpp index 7d48927..c60ef6b 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.cpp +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.cpp @@ -4,8 +4,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers; CLifeTimeRandom* CLifeTimeRandom::fromJSON (json data, irr::u32 id) { - json::const_iterator min_it = data.find ("min"); - json::const_iterator max_it = data.find ("max"); + auto min_it = data.find ("min"); + auto max_it = data.find ("max"); 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; } -irr::u32 CLifeTimeRandom::getMaximum () +const irr::u32 CLifeTimeRandom::getMaximum () const { return this->m_max; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.h b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.h index 8acef3e..e6c7435 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.h +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CLifeTimeRandom.h @@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers class CLifeTimeRandom : CInitializer { public: - irr::u32 getMinimum (); - irr::u32 getMaximum (); + const irr::u32 getMinimum () const; + const irr::u32 getMaximum () const; protected: friend class CInitializer; diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.cpp b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.cpp index 0de09f7..2029f9b 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.cpp +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.cpp @@ -4,8 +4,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers; CRotationRandom* CRotationRandom::fromJSON (json data, irr::u32 id) { - json::const_iterator min_it = data.find ("min"); - json::const_iterator max_it = data.find ("max"); + auto min_it = data.find ("min"); + auto max_it = data.find ("max"); irr::f64 min = 0.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; } -irr::f64 CRotationRandom::getMaximum () +const irr::f64 CRotationRandom::getMaximum () const { return this->m_max; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.h b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.h index 8b0c104..6c4acb4 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.h +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CRotationRandom.h @@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers class CRotationRandom : CInitializer { public: - irr::f64 getMinimum (); - irr::f64 getMaximum (); + const irr::f64 getMinimum () const; + const irr::f64 getMaximum () const; protected: friend class CInitializer; diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.cpp b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.cpp index ff34a80..ad67131 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.cpp +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.cpp @@ -4,8 +4,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers; CSizeRandom* CSizeRandom::fromJSON (json data, irr::u32 id) { - json::const_iterator min_it = data.find ("min"); - json::const_iterator max_it = data.find ("max"); + auto min_it = data.find ("min"); + auto max_it = data.find ("max"); 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; } -irr::u32 CSizeRandom::getMaximum () +const irr::u32 CSizeRandom::getMaximum () const { return this->m_max; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.h b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.h index 693d5a5..afecd47 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.h +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CSizeRandom.h @@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers class CSizeRandom : CInitializer { public: - irr::u32 getMinimum (); - irr::u32 getMaximum (); + const irr::u32 getMinimum () const; + const irr::u32 getMaximum () const; protected: friend class CInitializer; diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.cpp b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.cpp index 1a435d9..6c652fe 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.cpp +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.cpp @@ -6,8 +6,8 @@ using namespace WallpaperEngine::Core::Objects::Particles::Initializers; CVelocityRandom* CVelocityRandom::fromJSON (json data, irr::u32 id) { - json::const_iterator min_it = data.find ("min"); - json::const_iterator max_it = data.find ("max"); + auto min_it = data.find ("min"); + auto max_it = data.find ("max"); 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; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.h b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.h index 56b6c9c..131b061 100644 --- a/src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.h +++ b/src/WallpaperEngine/Core/Objects/Particles/Initializers/CVelocityRandom.h @@ -10,8 +10,8 @@ namespace WallpaperEngine::Core::Objects::Particles::Initializers class CVelocityRandom : CInitializer { public: - irr::core::vector3df* getMinimum (); - irr::core::vector3df* getMaximum (); + const irr::core::vector3df& getMinimum () const; + const irr::core::vector3df& getMaximum () const; protected: friend class CInitializer; diff --git a/src/WallpaperEngine/Core/Projects/CProperty.cpp b/src/WallpaperEngine/Core/Projects/CProperty.cpp index 1055b20..9054638 100644 --- a/src/WallpaperEngine/Core/Projects/CProperty.cpp +++ b/src/WallpaperEngine/Core/Projects/CProperty.cpp @@ -1,51 +1,50 @@ #include "CProperty.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"); + auto text = data.find ("text"); + + if (value == data.end ()) { - json::const_iterator type = data.find ("type"); - json::const_iterator value = data.find ("value"); - json::const_iterator text = data.find ("text"); - - if (value == data.end ()) - { - throw std::runtime_error ("Project properties must have the value field"); - } - - if (type == data.end ()) - { - throw std::runtime_error ("Project properties must have the type field"); - } - - if (*type == CPropertyColor::Type) - { - return CPropertyColor::fromJSON (data, name); - } - - throw std::runtime_error ("Unexpected type for property"); + throw std::runtime_error ("Project properties must have the value field"); } - CProperty::CProperty (std::string name, std::string type, std::string text) : - m_name (std::move(name)), - m_type (std::move(type)), - m_text (std::move(text)) + if (type == data.end ()) { + throw std::runtime_error ("Project properties must have the type field"); } - std::string& CProperty::getName () + if (*type == CPropertyColor::Type) { - return this->m_name; + return CPropertyColor::fromJSON (data, name); } - std::string& CProperty::getType () - { - return this->m_type; - } + throw std::runtime_error ("Unexpected type for property"); +} - std::string& CProperty::getText () - { - return this->m_text; - } -}; +CProperty::CProperty (std::string name, std::string type, std::string text) : + m_name (std::move(name)), + m_type (std::move(type)), + m_text (std::move(text)) +{ +} + +const std::string& CProperty::getName () const +{ + return this->m_name; +} + +const std::string& CProperty::getType () const +{ + return this->m_type; +} + +const std::string& CProperty::getText () const +{ + return this->m_text; +} \ No newline at end of file diff --git a/src/WallpaperEngine/Core/Projects/CProperty.h b/src/WallpaperEngine/Core/Projects/CProperty.h index 0f91ad5..29c4405 100644 --- a/src/WallpaperEngine/Core/Projects/CProperty.h +++ b/src/WallpaperEngine/Core/Projects/CProperty.h @@ -13,14 +13,14 @@ namespace WallpaperEngine::Core::Projects public: static CProperty* fromJSON (json data, const std::string& name); - template const T* As () const { assert (Is ()); return (const T*) this; } - template T* As () { assert (Is ()); return (T*) this; } + template const T* as () const { assert (is ()); return (const T*) this; } + template T* as () { assert (is ()); return (T*) this; } - template bool Is () { return this->m_type == T::Type; } + template bool is () { return this->m_type == T::Type; } - std::string& getName (); - std::string& getType (); - std::string& getText (); + const std::string& getName () const; + const std::string& getType () const; + const std::string& getText () const; protected: CProperty (std::string name, std::string type, std::string text); diff --git a/src/WallpaperEngine/Core/Projects/CPropertyColor.cpp b/src/WallpaperEngine/Core/Projects/CPropertyColor.cpp index 73849de..31e70e6 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertyColor.cpp +++ b/src/WallpaperEngine/Core/Projects/CPropertyColor.cpp @@ -5,8 +5,8 @@ using namespace WallpaperEngine::Core::Projects; CPropertyColor* CPropertyColor::fromJSON (json data, const std::string& name) { - json::const_iterator value = data.find ("value"); - json::const_iterator text = data.find ("type"); + auto value = data.find ("value"); + auto text = data.find ("type"); return new CPropertyColor ( 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) : diff --git a/src/WallpaperEngine/Core/Projects/CPropertyColor.h b/src/WallpaperEngine/Core/Projects/CPropertyColor.h index 3464d53..af4bd76 100644 --- a/src/WallpaperEngine/Core/Projects/CPropertyColor.h +++ b/src/WallpaperEngine/Core/Projects/CPropertyColor.h @@ -13,7 +13,7 @@ namespace WallpaperEngine::Core::Projects public: static CPropertyColor* fromJSON (json data, const std::string& name); - irr::video::SColor* getValue (); + const irr::video::SColor& getValue () const; static const std::string Type; diff --git a/src/WallpaperEngine/Core/Scenes/CCamera.cpp b/src/WallpaperEngine/Core/Scenes/CCamera.cpp index b9fd2ba..eadf5e0 100644 --- a/src/WallpaperEngine/Core/Scenes/CCamera.cpp +++ b/src/WallpaperEngine/Core/Scenes/CCamera.cpp @@ -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) { - json::const_iterator center_it = data.find ("center"); - json::const_iterator eye_it = data.find ("eye"); - json::const_iterator up_it = data.find ("up"); + auto center_it = data.find ("center"); + auto eye_it = data.find ("eye"); + auto up_it = data.find ("up"); if (center_it == data.end ()) { diff --git a/src/WallpaperEngine/Core/Scenes/CCamera.h b/src/WallpaperEngine/Core/Scenes/CCamera.h index 99d8438..1e9efce 100644 --- a/src/WallpaperEngine/Core/Scenes/CCamera.h +++ b/src/WallpaperEngine/Core/Scenes/CCamera.h @@ -12,9 +12,9 @@ namespace WallpaperEngine::Core::Scenes public: static CCamera* fromJSON (json data); - irr::core::vector3df* getCenter (); - irr::core::vector3df* getEye (); - irr::core::vector3df* getUp (); + const irr::core::vector3df& getCenter () const; + const irr::core::vector3df& getEye () const; + const irr::core::vector3df& getUp () const; protected: CCamera (irr::core::vector3df center, irr::core::vector3df eye, irr::core::vector3df up); private: diff --git a/src/WallpaperEngine/Core/Scenes/CProjection.cpp b/src/WallpaperEngine/Core/Scenes/CProjection.cpp index e9f87cd..45bd412 100644 --- a/src/WallpaperEngine/Core/Scenes/CProjection.cpp +++ b/src/WallpaperEngine/Core/Scenes/CProjection.cpp @@ -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; } -irr::u32 CProjection::getHeight () +const irr::u32& CProjection::getHeight () const { return this->m_height; } CProjection* CProjection::fromJSON (json data) { - json::const_iterator width_it = data.find ("width"); - json::const_iterator height_it = data.find ("height"); + auto width_it = data.find ("width"); + auto height_it = data.find ("height"); if (width_it == data.end ()) { diff --git a/src/WallpaperEngine/Core/Scenes/CProjection.h b/src/WallpaperEngine/Core/Scenes/CProjection.h index e225c67..537735f 100644 --- a/src/WallpaperEngine/Core/Scenes/CProjection.h +++ b/src/WallpaperEngine/Core/Scenes/CProjection.h @@ -12,8 +12,8 @@ namespace WallpaperEngine::Core::Scenes public: static CProjection* fromJSON (json data); - irr::u32 getWidth (); - irr::u32 getHeight (); + const irr::u32& getWidth () const; + const irr::u32& getHeight () const; protected: CProjection (irr::u32 width, irr::u32 height); private: diff --git a/src/WallpaperEngine/FileSystem/FileSystem.cpp b/src/WallpaperEngine/FileSystem/FileSystem.cpp index c1de720..7765c53 100644 --- a/src/WallpaperEngine/FileSystem/FileSystem.cpp +++ b/src/WallpaperEngine/FileSystem/FileSystem.cpp @@ -8,7 +8,7 @@ extern WallpaperEngine::Irrlicht::CContext* IrrlichtContext; 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); diff --git a/src/WallpaperEngine/FileSystem/FileSystem.h b/src/WallpaperEngine/FileSystem/FileSystem.h index 7b63879..b79290b 100644 --- a/src/WallpaperEngine/FileSystem/FileSystem.h +++ b/src/WallpaperEngine/FileSystem/FileSystem.h @@ -16,5 +16,5 @@ namespace WallpaperEngine::FileSystem * @param file * @return */ - std::string loadFullFile (irr::io::path file); + std::string loadFullFile (const irr::io::path& file); } diff --git a/src/WallpaperEngine/Irrlicht/CContext.cpp b/src/WallpaperEngine/Irrlicht/CContext.cpp index 1f2755b..d296943 100644 --- a/src/WallpaperEngine/Irrlicht/CContext.cpp +++ b/src/WallpaperEngine/Irrlicht/CContext.cpp @@ -1,14 +1,13 @@ #include "CContext.h" -namespace WallpaperEngine::Irrlicht -{ - void CContext::setDevice (irr::IrrlichtDevice* device) - { - this->m_device = device; - } +using namespace WallpaperEngine::Irrlicht; - irr::IrrlichtDevice* CContext::getDevice () - { - return this->m_device; - } -}; \ No newline at end of file +void CContext::setDevice (irr::IrrlichtDevice* device) +{ + this->m_device = device; +} + +irr::IrrlichtDevice* CContext::getDevice () +{ + return this->m_device; +} \ No newline at end of file diff --git a/src/WallpaperEngine/Irrlicht/CFileList.cpp b/src/WallpaperEngine/Irrlicht/CFileList.cpp index 9cf6c23..cbb55bd 100644 --- a/src/WallpaperEngine/Irrlicht/CFileList.cpp +++ b/src/WallpaperEngine/Irrlicht/CFileList.cpp @@ -2,135 +2,133 @@ #include "CFileList.h" -namespace WallpaperEngine::Irrlicht +using namespace WallpaperEngine::Irrlicht; +static const irr::io::path emptyFileListEntry; + +CFileList::CFileList (const irr::io::path& path, bool ignoreCase, bool ignorePaths) : + m_ignorePaths (ignorePaths), + m_ignoreCase (ignoreCase), + m_path(path) { - static const irr::io::path emptyFileListEntry; + this->m_path.replace ('\\', '/'); +} - CFileList::CFileList (const irr::io::path& path, bool ignoreCase, bool ignorePaths) : - m_ignorePaths (ignorePaths), - m_ignoreCase (ignoreCase), - m_path(path) - { - this->m_path.replace ('\\', '/'); - } +CFileList::~CFileList () +{ + this->m_files.clear (); +} - CFileList::~CFileList () - { - this->m_files.clear (); - } +irr::u32 CFileList::getFileCount () const +{ + return this->m_files.size (); +} - irr::u32 CFileList::getFileCount () const - { - return this->m_files.size (); - } +void CFileList::sort () +{ + this->m_files.sort (); +} - void CFileList::sort () - { - this->m_files.sort (); - } - - const irr::io::path& CFileList::getFileName (irr::u32 index) const - { - return (index < this->m_files.size ()) ? this->m_files [index].Name : emptyFileListEntry; - } +const irr::io::path& CFileList::getFileName (irr::u32 index) const +{ + 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. - const irr::io::path& CFileList::getFullFileName (irr::u32 index) const - { - return (index < this->m_files.size ()) ? this->m_files [index].FullName : emptyFileListEntry; - } +const irr::io::path& CFileList::getFullFileName (irr::u32 index) const +{ + return (index < this->m_files.size ()) ? this->m_files [index].FullName : emptyFileListEntry; +} //! 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; + entry.ID = id ? id : this->m_files.size (); + entry.Offset = offset; + entry.Size = size; + entry.Name = fullPath; + entry.Name.replace ('\\', '/'); + entry.IsDirectory = isDirectory; + + // remove trailing slash + if (entry.Name.lastChar () == '/') { - SFileListEntry entry; - entry.ID = id ? id : this->m_files.size (); - entry.Offset = offset; - entry.Size = size; - entry.Name = fullPath; - entry.Name.replace ('\\', '/'); - entry.IsDirectory = isDirectory; + entry.IsDirectory = true; + entry.Name [entry.Name.size ()-1] = 0; + entry.Name.validate (); + } - // remove trailing slash - if (entry.Name.lastChar () == '/') - { - entry.IsDirectory = true; - entry.Name [entry.Name.size ()-1] = 0; - entry.Name.validate (); - } + if (this->m_ignoreCase) + entry.Name.make_lower (); - if (this->m_ignoreCase) - entry.Name.make_lower (); + entry.FullName = entry.Name; + irr::core::deletePathFromFilename (entry.Name); + + if (this->m_ignorePaths) entry.FullName = entry.Name; - irr::core::deletePathFromFilename (entry.Name); + this->m_files.push_back (entry); - if (this->m_ignorePaths) - entry.FullName = entry.Name; - - 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. - irr::u32 CFileList::getID (irr::u32 index) const - { - return (index < this->m_files.size ()) ? this->m_files [index].ID : 0; - } +irr::u32 CFileList::getID (irr::u32 index) const +{ + return (index < this->m_files.size ()) ? this->m_files [index].ID : 0; +} - bool CFileList::isDirectory (irr::u32 index) const - { - return (index < this->m_files.size ()) ? this->m_files [index].IsDirectory : false; - } +bool CFileList::isDirectory (irr::u32 index) const +{ + return (index < this->m_files.size ()) ? this->m_files [index].IsDirectory : false; +} //! Returns the size of a file - irr::u32 CFileList::getFileSize (irr::u32 index) const - { - return (index < this->m_files.size ()) ? this->m_files [index].Size : 0; - } +irr::u32 CFileList::getFileSize (irr::u32 index) const +{ + return (index < this->m_files.size ()) ? this->m_files [index].Size : 0; +} //! Returns the size of a file - irr::u32 CFileList::getFileOffset (irr::u32 index) const - { - return (index < this->m_files.size ()) ? this->m_files [index].Offset : 0; - } +irr::u32 CFileList::getFileOffset (irr::u32 index) const +{ + return (index < this->m_files.size ()) ? this->m_files [index].Offset : 0; +} //! 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; + // we only need FullName to be set for the search + entry.FullName = filename; + entry.IsDirectory = isDirectory; + + // exchange + entry.FullName.replace('\\', '/'); + + // remove trailing slash + if (entry.FullName.lastChar () == '/') { - SFileListEntry entry; - // we only need FullName to be set for the search - entry.FullName = filename; - entry.IsDirectory = isDirectory; - - // exchange - entry.FullName.replace('\\', '/'); - - // remove trailing slash - if (entry.FullName.lastChar () == '/') - { - entry.IsDirectory = true; - entry.FullName [entry.FullName.size ()-1] = 0; - entry.FullName.validate (); - } - - if (this->m_ignoreCase) - entry.FullName.make_lower (); - - if (this->m_ignorePaths) - irr::core::deletePathFromFilename (entry.FullName); - - return this->m_files.binary_search (entry); + entry.IsDirectory = true; + entry.FullName [entry.FullName.size ()-1] = 0; + entry.FullName.validate (); } + if (this->m_ignoreCase) + entry.FullName.make_lower (); + + if (this->m_ignorePaths) + irr::core::deletePathFromFilename (entry.FullName); + + return this->m_files.binary_search (entry); +} + //! Returns the base path of the file list - const irr::io::path& CFileList::getPath () const - { - return m_path; - } -}; +const irr::io::path& CFileList::getPath () const +{ + return m_path; +} diff --git a/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.cpp b/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.cpp index bfef8cb..18f86ea 100644 --- a/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.cpp +++ b/src/WallpaperEngine/Irrlicht/CImageLoaderTEX.cpp @@ -46,8 +46,8 @@ namespace WallpaperEngine::Irrlicht CImageLoaderTex::TextureContainer::~TextureContainer () { - std::vector ::const_iterator cur = this->mipmaps.begin (); - std::vector ::const_iterator end = this->mipmaps.end (); + auto cur = this->mipmaps.begin (); + auto end = this->mipmaps.end (); for (; cur != end; cur ++) { diff --git a/src/WallpaperEngine/Render/CCamera.cpp b/src/WallpaperEngine/Render/CCamera.cpp index 1d52d58..cd6445e 100644 --- a/src/WallpaperEngine/Render/CCamera.cpp +++ b/src/WallpaperEngine/Render/CCamera.cpp @@ -3,13 +3,14 @@ using namespace WallpaperEngine; 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_scene (scene) { 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 () @@ -17,17 +18,17 @@ CCamera::~CCamera () this->m_sceneCamera->remove (); } -irr::core::vector3df* CCamera::getCenter () +const irr::core::vector3df& CCamera::getCenter () const { return this->m_camera->getCenter (); } -irr::core::vector3df* CCamera::getEye () +const irr::core::vector3df& CCamera::getEye () const { return this->m_camera->getEye (); } -irr::core::vector3df* CCamera::getUp () +const irr::core::vector3df& CCamera::getUp () const { 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 orthogonalProjection; orthogonalProjection.buildProjectionMatrixOrthoLH ( width, height, - this->getCenter ()->Z, - this->getEye ()->Z + this->getCenter ().Z, + this->getEye ().Z ); this->m_sceneCamera->setProjectionMatrix (orthogonalProjection); diff --git a/src/WallpaperEngine/Render/CCamera.h b/src/WallpaperEngine/Render/CCamera.h index 98d8442..30ad469 100644 --- a/src/WallpaperEngine/Render/CCamera.h +++ b/src/WallpaperEngine/Render/CCamera.h @@ -11,17 +11,17 @@ namespace WallpaperEngine::Render class CCamera { public: - CCamera (CScene* scene, Core::Scenes::CCamera* camera); + CCamera (CScene* scene, const Core::Scenes::CCamera* camera); ~CCamera (); void setOrthogonalProjection (irr::f32 width, irr::f32 height); - irr::core::vector3df* getCenter (); - irr::core::vector3df* getEye (); - irr::core::vector3df* getUp (); + const irr::core::vector3df& getCenter () const; + const irr::core::vector3df& getEye () const; + const irr::core::vector3df& getUp () const; private: - Core::Scenes::CCamera* m_camera; + const Core::Scenes::CCamera* m_camera; irr::scene::ICameraSceneNode* m_sceneCamera; CScene* m_scene; }; diff --git a/src/WallpaperEngine/Render/CObject.cpp b/src/WallpaperEngine/Render/CObject.cpp index c9ea917..879f880 100644 --- a/src/WallpaperEngine/Render/CObject.cpp +++ b/src/WallpaperEngine/Render/CObject.cpp @@ -19,7 +19,7 @@ CObject::~CObject() { } -CScene* CObject::getScene () +CScene* CObject::getScene () const { return this->m_scene; } diff --git a/src/WallpaperEngine/Render/CObject.h b/src/WallpaperEngine/Render/CObject.h index 196c4d7..d6cdad5 100644 --- a/src/WallpaperEngine/Render/CObject.h +++ b/src/WallpaperEngine/Render/CObject.h @@ -21,11 +21,11 @@ namespace WallpaperEngine::Render protected: CObject (CScene* scene, std::string type, Core::CObject *object); - ~CObject (); + ~CObject () override; void OnRegisterSceneNode () override; - CScene* getScene (); + CScene* getScene () const; private: std::string m_type; diff --git a/src/WallpaperEngine/Render/CScene.cpp b/src/WallpaperEngine/Render/CScene.cpp index b71e697..cce0147 100644 --- a/src/WallpaperEngine/Render/CScene.cpp +++ b/src/WallpaperEngine/Render/CScene.cpp @@ -9,7 +9,7 @@ using namespace WallpaperEngine; using namespace WallpaperEngine::Render; -CScene::CScene (Core::CProject* project, Irrlicht::CContext* context) : +CScene::CScene (const Core::CProject* project, Irrlicht::CContext* context) : irr::scene::ISceneNode ( context->getDevice ()->getSceneManager ()->getRootSceneNode (), context->getDevice ()->getSceneManager () @@ -24,8 +24,8 @@ CScene::CScene (Core::CProject* project, Irrlicht::CContext* context) : this->m_scene->getOrthogonalProjection ()->getHeight () ); - std::vector::const_iterator cur = this->m_scene->getObjects ()->begin (); - std::vector::const_iterator end = this->m_scene->getObjects ()->end (); + auto cur = this->m_scene->getObjects ().begin (); + auto end = this->m_scene->getObjects ().end (); int highestId = 0; @@ -34,13 +34,13 @@ CScene::CScene (Core::CProject* project, Irrlicht::CContext* context) : if ((*cur)->getId () > highestId) highestId = (*cur)->getId (); - if ((*cur)->Is () == true) + if ((*cur)->is() == true) { - new Objects::CImage (this, (*cur)->As ()); + new Objects::CImage (this, (*cur)->as()); } - else if ((*cur)->Is () == true) + else if ((*cur)->is() == true) { - new Objects::CSound (this, (*cur)->As ()); + new Objects::CSound (this, (*cur)->as()); } } @@ -58,12 +58,12 @@ Irrlicht::CContext* CScene::getContext () return this->m_context; } -Core::CScene* CScene::getScene () +const Core::CScene* CScene::getScene () const { return this->m_scene; } -CCamera* CScene::getCamera () +CCamera* CScene::getCamera () const { return this->m_camera; } diff --git a/src/WallpaperEngine/Render/CScene.h b/src/WallpaperEngine/Render/CScene.h index cf0e63e..77d34fd 100644 --- a/src/WallpaperEngine/Render/CScene.h +++ b/src/WallpaperEngine/Render/CScene.h @@ -14,20 +14,20 @@ namespace WallpaperEngine::Render class CScene : public irr::scene::ISceneNode { public: - CScene (Core::CProject* project, Irrlicht::CContext* context); - ~CScene (); + CScene (const Core::CProject* project, Irrlicht::CContext* context); + ~CScene () override; Irrlicht::CContext* getContext (); - Core::CScene* getScene (); - CCamera* getCamera (); + const Core::CScene* getScene () const; + CCamera* getCamera () const; int nextId (); void render () override; const irr::core::aabbox3d& getBoundingBox() const override; void OnRegisterSceneNode () override; private: - Core::CProject* m_project; - Core::CScene* m_scene; + const Core::CProject* m_project; + const Core::CScene* m_scene; CCamera* m_camera; Irrlicht::CContext* m_context; irr::u32 m_nextId; diff --git a/src/WallpaperEngine/Render/Objects/CImage.cpp b/src/WallpaperEngine/Render/Objects/CImage.cpp index 0767c6d..96618ce 100644 --- a/src/WallpaperEngine/Render/Objects/CImage.cpp +++ b/src/WallpaperEngine/Render/Objects/CImage.cpp @@ -20,11 +20,11 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) : m_passes (0) { // TODO: INITIALIZE NEEDED EFFECTS AND PROPERLY CALCULATE THESE? - irr::f32 xright = this->m_image->getOrigin ()->X; - irr::f32 xleft = -this->m_image->getOrigin ()->X; - irr::f32 ztop = this->m_image->getOrigin ()->Y; - irr::f32 zbottom = -this->m_image->getOrigin ()->Y; - irr::f32 z = this->m_image->getOrigin ()->Z; + irr::f32 xright = this->m_image->getOrigin ().X; + irr::f32 xleft = -this->m_image->getOrigin ().X; + irr::f32 ztop = this->m_image->getOrigin ().Y; + irr::f32 zbottom = -this->m_image->getOrigin ().Y; + irr::f32 z = this->m_image->getOrigin ().Z; // top left this->m_vertex [0].Pos = irr::core::vector3df (xleft, ztop, z); @@ -59,11 +59,11 @@ void CImage::render() irr::video::IVideoDriver* driver = SceneManager->getVideoDriver (); - std::vector::const_iterator cur = this->m_materials.begin (); - std::vector::const_iterator end = this->m_materials.end (); + auto cur = this->m_materials.begin (); + auto end = this->m_materials.end (); - std::vector::const_iterator textureCur = this->m_renderTextures.begin (); - std::vector::const_iterator textureEnd = this->m_renderTextures.end (); + auto textureCur = this->m_renderTextures.begin (); + auto textureEnd = this->m_renderTextures.end (); for (; cur != end; cur ++) { @@ -87,26 +87,26 @@ void CImage::render() void CImage::generateMaterial () { - std::vector::const_iterator cur = this->m_image->getMaterial ()->getPasses ()->begin (); - std::vector::const_iterator end = this->m_image->getMaterial ()->getPasses ()->end (); + auto cur = this->m_image->getMaterial ()->getPasses ().begin (); + auto end = this->m_image->getMaterial ()->getPasses ().end (); for (; cur != end; cur++) { this->generatePass (*cur); } - std::vector::const_iterator effectCur = this->m_image->getEffects ()->begin (); - std::vector::const_iterator effectEnd = this->m_image->getEffects ()->end (); + auto effectCur = this->m_image->getEffects ().begin (); + auto effectEnd = this->m_image->getEffects ().end (); for (; effectCur != effectEnd; effectCur++) { - std::vector::const_iterator materialCur = (*effectCur)->getMaterials ()->begin (); - std::vector::const_iterator materialEnd = (*effectCur)->getMaterials ()->end (); + auto materialCur = (*effectCur)->getMaterials ().begin (); + auto materialEnd = (*effectCur)->getMaterials ().end (); for (; materialCur != materialEnd; materialCur++) { - cur = (*materialCur)->getPasses ()->begin (); - end = (*materialCur)->getPasses ()->end (); + cur = (*materialCur)->getPasses ().begin (); + end = (*materialCur)->getPasses ().end (); for (; cur != end; cur++) { @@ -121,8 +121,8 @@ void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass) std::vector* textures = pass->getTextures (); irr::video::SMaterial material; - std::vector::const_iterator texturesCur = textures->begin (); - std::vector::const_iterator texturesEnd = textures->end (); + auto texturesCur = textures->begin (); + auto texturesEnd = textures->end (); 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 () ); - //originalTexture->drop (); - this->m_renderTextures.push_back (texture); } else @@ -150,8 +148,6 @@ void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass) texture = this->getScene ()->getContext ()->getDevice ()->getVideoDriver ()->getTexture (texturepath); } - //texture->grab (); - material.setTexture (textureNumber, texture); } @@ -196,23 +192,23 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in irr::f32 g_Texture6 = 6; 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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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::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* pixelShader = this->m_pixelShaders.at (userData); - std::vector::const_iterator cur = vertexShader->getParameters ().begin (); - std::vector::const_iterator end = vertexShader->getParameters ().end (); + auto cur = vertexShader->getParameters ().begin (); + auto end = vertexShader->getParameters ().end (); for (; cur != end; cur ++) { - if ((*cur)->Is () == true) + if ((*cur)->is () == true) { services->setVertexShaderConstant ( (*cur)->getName ().c_str (), @@ -238,10 +234,10 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in ); } else if ( - (*cur)->Is () == true || - (*cur)->Is () == true || - (*cur)->Is () == true || - (*cur)->Is () == true) + (*cur)->is () == true || + (*cur)->is () == true || + (*cur)->is () == true || + (*cur)->is () == true) { services->setVertexShaderConstant ( (*cur)->getName ().c_str (), @@ -256,7 +252,7 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in for (; cur != end; cur ++) { - if ((*cur)->Is () == true) + if ((*cur)->is () == true) { services->setPixelShaderConstant ( (*cur)->getName ().c_str (), @@ -265,10 +261,10 @@ void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, in ); } else if ( - (*cur)->Is () == true || - (*cur)->Is () == true || - (*cur)->Is () == true || - (*cur)->Is () == true) + (*cur)->is () == true || + (*cur)->is () == true || + (*cur)->is () == true || + (*cur)->is () == true) { services->setPixelShaderConstant ( (*cur)->getName ().c_str (), diff --git a/src/WallpaperEngine/Render/Objects/CSound.cpp b/src/WallpaperEngine/Render/Objects/CSound.cpp index 02c7bc6..d38db69 100644 --- a/src/WallpaperEngine/Render/Objects/CSound.cpp +++ b/src/WallpaperEngine/Render/Objects/CSound.cpp @@ -18,8 +18,8 @@ CSound::CSound (CScene* scene, Core::Objects::CSound* sound) : void CSound::load () { - std::vector::const_iterator cur = this->m_sound->getSounds ()->begin (); - std::vector::const_iterator end = this->m_sound->getSounds ()->end (); + std::vector::const_iterator cur = this->m_sound->getSounds ().begin (); + std::vector::const_iterator end = this->m_sound->getSounds ().end (); for (; cur != end; cur ++) { @@ -31,7 +31,7 @@ void CSound::load () readfile->read (filebuffer, filesize); - sdlRwops = SDL_RWFromConstMem(filebuffer, filesize); + sdlRwops = SDL_RWFromConstMem (filebuffer, filesize); music = Mix_LoadMUS_RW (sdlRwops); readfile->drop (); diff --git a/src/WallpaperEngine/Render/Shaders/Compiler.cpp b/src/WallpaperEngine/Render/Shaders/Compiler.cpp index 27c1d16..1f6f3cd 100644 --- a/src/WallpaperEngine/Render/Shaders/Compiler.cpp +++ b/src/WallpaperEngine/Render/Shaders/Compiler.cpp @@ -19,13 +19,16 @@ namespace WallpaperEngine::Render::Shaders { - Compiler::Compiler (irr::io::path& file, Type type, std::map* combos, bool recursive) + Compiler::Compiler (irr::io::path& file, Type type, const std::map& 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 - if (recursive == false) + if (this->m_recursive == false) { // compatibility layer for OpenGL shaders this->m_content = "#version 120\n" @@ -47,8 +50,8 @@ namespace WallpaperEngine::Render::Shaders "#define ddy(x) dFdy(-(x))\n" "#define GLSL 1\n\n"; - std::map::const_iterator cur = this->m_combos->begin (); - std::map::const_iterator end = this->m_combos->end (); + auto cur = this->m_combos.begin (); + auto end = this->m_combos.end (); for (; cur != end; cur ++) { @@ -61,11 +64,6 @@ namespace WallpaperEngine::Render::Shaders } 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) @@ -126,8 +124,8 @@ namespace WallpaperEngine::Render::Shaders std::string Compiler::extractType (std::string::const_iterator& it) { - std::vector::const_iterator cur = sTypes.begin (); - std::vector::const_iterator end = sTypes.end (); + auto cur = sTypes.begin (); + auto end = sTypes.end (); while (cur != end) { @@ -227,8 +225,8 @@ namespace WallpaperEngine::Render::Shaders std::string Compiler::lookupReplaceSymbol (std::string symbol) { - std::map::const_iterator cur = sVariableReplacement.begin (); - std::map::const_iterator end = sVariableReplacement.end (); + auto cur = sVariableReplacement.begin (); + auto end = sVariableReplacement.end (); while (cur != end) { @@ -458,8 +456,8 @@ namespace WallpaperEngine::Render::Shaders void Compiler::parseComboConfiguration (const std::string& content) { json data = json::parse (content); - json::const_iterator combo = data.find ("combo"); - json::const_iterator defvalue = data.find ("default"); + auto combo = data.find ("combo"); + auto defvalue = data.find ("default"); // add line feed just in case this->m_compiledContent += "\n"; @@ -470,11 +468,11 @@ namespace WallpaperEngine::Render::Shaders } // check the combos - std::map::const_iterator entry = this->m_combos->find ((*combo).get ()); + std::map::const_iterator entry = this->m_combos.find ((*combo).get ()); // 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 - if (entry == this->m_combos->end ()) + if (entry == this->m_combos.end ()) { // if no combo is defined just load the default settings 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) { json data = json::parse (content); - json::const_iterator material = data.find ("material"); - json::const_iterator defvalue = data.find ("default"); - json::const_iterator range = data.find ("range"); + auto material = data.find ("material"); + auto defvalue = data.find ("default"); + auto range = data.find ("range"); // this is not a real parameter if (material == data.end () || defvalue == data.end ()) @@ -558,10 +556,10 @@ namespace WallpaperEngine::Render::Shaders this->m_parameters.push_back (parameter); } - Parameters::CShaderParameter* Compiler::findParameter (std::string identifier) + Parameters::CShaderParameter* Compiler::findParameter (const std::string& identifier) { - std::vector::const_iterator cur = this->m_parameters.begin (); - std::vector::const_iterator end = this->m_parameters.end (); + auto cur = this->m_parameters.begin (); + auto end = this->m_parameters.end (); for (; cur != end; cur ++) { @@ -574,7 +572,7 @@ namespace WallpaperEngine::Render::Shaders return nullptr; } - std::vector & Compiler::getParameters () + const std::vector & Compiler::getParameters () const { return this->m_parameters; } diff --git a/src/WallpaperEngine/Render/Shaders/Compiler.h b/src/WallpaperEngine/Render/Shaders/Compiler.h index 9140936..0c757d8 100644 --- a/src/WallpaperEngine/Render/Shaders/Compiler.h +++ b/src/WallpaperEngine/Render/Shaders/Compiler.h @@ -46,7 +46,7 @@ namespace WallpaperEngine::Render::Shaders * @param type The type of shader * @param recursive Whether the compiler should add base definitions or not */ - Compiler (irr::io::path& file, Type type, std::map* combos, bool recursive = false); + Compiler (irr::io::path& file, Type type, const std::map& combos, bool recursive = false); /** * Performs the actual pre-compilation/pre-processing over the shader files * 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 * @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 */ - std::vector & getParameters (); + const std::vector & getParameters () const; private: /** @@ -206,7 +206,7 @@ namespace WallpaperEngine::Render::Shaders /** * The combos the shader should be generated with */ - std::map * m_combos; + const std::map & m_combos; /** * Whether this compilation is a recursive one or not */ diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.cpp b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.cpp index 70e356b..5bdcfd6 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.cpp +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.cpp @@ -12,7 +12,7 @@ CShaderParameter::CShaderParameter (void* defaultValue, void* value, std::string } -void* CShaderParameter::getValue () +const void* CShaderParameter::getValue () const { if (this->m_value) return this->m_value; @@ -25,12 +25,12 @@ void CShaderParameter::setValue (void* value) this->m_value = value; } -std::string CShaderParameter::getIdentifierName () +const std::string& CShaderParameter::getIdentifierName () const { return this->m_identifierName; } -std::string CShaderParameter::getName () +const std::string& CShaderParameter::getName () const { return this->m_name; } diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h index 8cd91a8..49e8a3a 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h @@ -9,19 +9,19 @@ namespace WallpaperEngine::Render::Shaders::Parameters public: CShaderParameter (void* defaultValue, void* value, std::string type); - template const T* As () const { assert (Is ()); return (const T*) this; } - template T* As () { assert (Is ()); return (T*) this; } + template const T* as () const { assert (is ()); return (const T*) this; } + template T* as () { assert (is ()); return (T*) this; } - template bool Is () { return this->m_type == T::Type; } + template bool is () { return this->m_type == T::Type; } - std::string getIdentifierName (); - std::string getName (); + const std::string& getIdentifierName () const; + const std::string& getName () const; void setIdentifierName (std::string identifierName); void setName (std::string name); - void* getValue (); + const void* getValue () const; - virtual int getSize () = 0; + virtual const int getSize () const = 0; protected: void setValue (void* value); diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.cpp b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.cpp index aeee7f6..7faff21 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.cpp +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.cpp @@ -17,7 +17,7 @@ void CShaderParameterFloat::setValue (irr::f32 value) CShaderParameter::setValue (&this->m_value); } -int CShaderParameterFloat::getSize () +const int CShaderParameterFloat::getSize () const { return 1; } diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.h b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.h index a8d4307..8bfc3fe 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.h +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.h @@ -11,7 +11,7 @@ namespace WallpaperEngine::Render::Shaders::Parameters public: CShaderParameterFloat (irr::f32 defaultValue); - int getSize () override; + const int getSize () const override; void setValue (irr::f32 value); diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.cpp b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.cpp index 1e997e1..63b02b1 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.cpp +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.cpp @@ -16,7 +16,7 @@ void CShaderParameterInteger::setValue (irr::s32 value) CShaderParameter::setValue (&this->m_value); } -int CShaderParameterInteger::getSize () +const int CShaderParameterInteger::getSize () const { return 1; } diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.h b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.h index 79d750c..a16169a 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.h +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.h @@ -11,7 +11,7 @@ namespace WallpaperEngine::Render::Shaders::Parameters public: CShaderParameterInteger (irr::s32 defaultValue); - int getSize () override; + const int getSize () const override; static const std::string Type; diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.cpp b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.cpp index 0ffdb88..63e6b4d 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.cpp +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.cpp @@ -17,7 +17,7 @@ void CShaderParameterVector2::setValue (irr::core::vector2df value) CShaderParameter::setValue (&this->m_value); } -int CShaderParameterVector2::getSize () +const int CShaderParameterVector2::getSize () const { return 2; } diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.h b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.h index 7ce8b83..0e7e5b3 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.h +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.h @@ -11,7 +11,7 @@ namespace WallpaperEngine::Render::Shaders::Parameters public: CShaderParameterVector2 (const irr::core::vector2df& defaultValue); - int getSize () override; + const int getSize () const override; void setValue (irr::core::vector2df value); diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.cpp b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.cpp index e26191f..4425368 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.cpp +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.cpp @@ -16,7 +16,7 @@ void CShaderParameterVector3::setValue (irr::core::vector3df value) CShaderParameter::setValue (&this->m_value); } -int CShaderParameterVector3::getSize () +const int CShaderParameterVector3::getSize () const { return 3; } diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.h b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.h index 7216128..536bffc 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.h +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.h @@ -11,7 +11,7 @@ namespace WallpaperEngine::Render::Shaders::Parameters public: CShaderParameterVector3 (const irr::core::vector3df& defaultValue); - int getSize () override; + const int getSize () const override; void setValue (irr::core::vector3df value); diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.cpp b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.cpp index 75bc99e..de624aa 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.cpp +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.cpp @@ -16,7 +16,7 @@ void CShaderParameterVector4::setValue (irr::core::vector3df value) CShaderParameter::setValue (&this->m_value); } -int CShaderParameterVector4::getSize () +const int CShaderParameterVector4::getSize () const { return 4; } diff --git a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.h b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.h index b378f18..e98eb9f 100644 --- a/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.h +++ b/src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.h @@ -11,7 +11,7 @@ namespace WallpaperEngine::Render::Shaders::Parameters public: CShaderParameterVector4 (const irr::core::vector3df& defaultValue); - int getSize () override; + const int getSize () const override; void setValue (irr::core::vector3df value);