diff --git a/.gitignore b/.gitignore index 888c120..a2705b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ cmake-build-debug* -assets.zip -.idea -assets/ -assets_old/ \ No newline at end of file +.idea \ No newline at end of file diff --git a/src/WallpaperEngine/Application/CApplicationContext.cpp b/src/WallpaperEngine/Application/CApplicationContext.cpp index ebe2c14..8d9b07e 100644 --- a/src/WallpaperEngine/Application/CApplicationContext.cpp +++ b/src/WallpaperEngine/Application/CApplicationContext.cpp @@ -4,8 +4,9 @@ #include "WallpaperEngine/Logging/CLog.h" #include -#include #include +#include +#include #define WORKSHOP_APP_ID 431960 #define APP_DIRECTORY "wallpaper_engine" @@ -103,7 +104,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv[]) : break; case 'v': - this->audioVolume = std::max (atoi (optarg), 128); + this->audioVolume = glm::clamp (atoi (optarg), 0, 128); break; case 'c': @@ -189,7 +190,7 @@ void CApplicationContext::printHelp (const char* route) sLog.out (""); sLog.out ("options:"); sLog.out ("\t--silent\t\t\t\t\tMutes all the sound the wallpaper might produce"); - sLog.out ("\t--volume \t\t\tSets the volume for all the sounds in the background"); + sLog.out ("\t--volume \t\t\tSets the volume for all the sounds in the background (0 - 128)"); sLog.out ("\t--screen-root \tDisplay as screen's background"); sLog.out ("\t--fps \t\t\tLimits the FPS to the given number, useful to keep battery consumption low"); sLog.out ("\t--assets-dir \t\t\tFolder where the assets are stored"); diff --git a/src/WallpaperEngine/Assets/CTexture.cpp b/src/WallpaperEngine/Assets/CTexture.cpp index 52011e3..ba12e2f 100644 --- a/src/WallpaperEngine/Assets/CTexture.cpp +++ b/src/WallpaperEngine/Assets/CTexture.cpp @@ -394,7 +394,7 @@ CTexture::TextureHeader* CTexture::parseHeader (const char* fileData) mipmaps.emplace_back (parseMipmap (header, &fileData)); // add the pixmaps back - header->images.insert (std::pair > (image, mipmaps)); + header->images.insert_or_assign (image, mipmaps); pointer = reinterpret_cast (fileData); } diff --git a/src/WallpaperEngine/Assets/CVirtualContainer.cpp b/src/WallpaperEngine/Assets/CVirtualContainer.cpp index 7849314..475bec7 100644 --- a/src/WallpaperEngine/Assets/CVirtualContainer.cpp +++ b/src/WallpaperEngine/Assets/CVirtualContainer.cpp @@ -7,9 +7,7 @@ using namespace WallpaperEngine::Assets; void CVirtualContainer::add (const std::string& filename, void* contents, uint32_t length) { - this->m_virtualFiles.insert ( - std::make_pair (filename, CFileEntry (contents, length)) - ); + this->m_virtualFiles.insert_or_assign (filename, CFileEntry (contents, length)); } void CVirtualContainer::add (const std::string& filename, const std::string& contents) diff --git a/src/WallpaperEngine/Core/CScene.cpp b/src/WallpaperEngine/Core/CScene.cpp index 6cc02a4..c5f3b94 100644 --- a/src/WallpaperEngine/Core/CScene.cpp +++ b/src/WallpaperEngine/Core/CScene.cpp @@ -121,7 +121,7 @@ void CScene::insertObject (CObject* object) /// TODO: XXXHACK -- TO REMOVE WHEN PARTICLE SUPPORT IS PROPERLY IMPLEMENTED if (object != nullptr) { - this->m_objects.insert (std::make_pair (object->getId (), object)); + this->m_objects.insert_or_assign (object->getId (), object); this->m_objectsByRenderOrder.emplace_back (object); } } diff --git a/src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp b/src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp index 43d6daf..091c7b1 100644 --- a/src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp +++ b/src/WallpaperEngine/Core/Objects/Images/CMaterial.cpp @@ -56,7 +56,7 @@ void CMaterial::insertPass (Materials::CPass* mass) void CMaterial::insertTextureBind (Effects::CBind* bind) { - this->m_textureBindings.insert (std::make_pair (bind->getIndex (), bind)); + this->m_textureBindings.insert_or_assign (bind->getIndex (), bind); } void CMaterial::setTarget (const std::string& target) diff --git a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp b/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp index db55dda..49df3af 100644 --- a/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp +++ b/src/WallpaperEngine/Core/Objects/Images/Materials/CPass.cpp @@ -85,7 +85,7 @@ void CPass::insertCombo (const std::string& name, int value) std::string uppercase = std::string (name); std::transform (uppercase.begin (), uppercase.end (), uppercase.begin (), ::toupper); - this->m_combos.insert (std::pair (uppercase, value)); + this->m_combos.insert_or_assign (uppercase, value); } const std::vector& CPass::getTextures () const @@ -135,5 +135,5 @@ void CPass::setBlendingMode (std::string mode) void CPass::insertConstant (const std::string& name, CShaderConstant* constant) { - this->m_constants.insert (std::pair (name, constant)); + this->m_constants.insert_or_assign (name, constant); } \ No newline at end of file diff --git a/src/WallpaperEngine/Render/CScene.cpp b/src/WallpaperEngine/Render/CScene.cpp index 8d068f0..407fb41 100644 --- a/src/WallpaperEngine/Render/CScene.cpp +++ b/src/WallpaperEngine/Render/CScene.cpp @@ -206,7 +206,7 @@ Render::CObject* CScene::createObject (Core::CObject* object) } if (renderObject != nullptr) - this->m_objects.insert (std::make_pair (renderObject->getId (), renderObject)); + this->m_objects.insert_or_assign (renderObject->getId (), renderObject); return renderObject; } diff --git a/src/WallpaperEngine/Render/CTextureCache.cpp b/src/WallpaperEngine/Render/CTextureCache.cpp index b2c1002..451abac 100644 --- a/src/WallpaperEngine/Render/CTextureCache.cpp +++ b/src/WallpaperEngine/Render/CTextureCache.cpp @@ -20,16 +20,12 @@ const ITexture* CTextureCache::resolve (const std::string& filename) const ITexture* texture = this->m_context->getContainer ()->readTexture (filename); - this->m_textureCache.insert ( - std::make_pair (filename, texture) - ); + this->store (filename, texture); return texture; } -void CTextureCache::store (std::string name, const ITexture* texture) +void CTextureCache::store (const std::string& name, const ITexture* texture) { - this->m_textureCache.insert ( - std::make_pair (name, texture) - ); + this->m_textureCache.insert_or_assign (name, texture); } \ No newline at end of file diff --git a/src/WallpaperEngine/Render/CTextureCache.h b/src/WallpaperEngine/Render/CTextureCache.h index d8e0ae5..d0cbe5e 100644 --- a/src/WallpaperEngine/Render/CTextureCache.h +++ b/src/WallpaperEngine/Render/CTextureCache.h @@ -33,7 +33,7 @@ namespace WallpaperEngine::Render * @param name * @param texture */ - void store (std::string name, const ITexture* texture); + void store (const std::string& name, const ITexture* texture); private: CRenderContext* m_context; diff --git a/src/WallpaperEngine/Render/CWallpaper.cpp b/src/WallpaperEngine/Render/CWallpaper.cpp index b7673bf..6a2727e 100644 --- a/src/WallpaperEngine/Render/CWallpaper.cpp +++ b/src/WallpaperEngine/Render/CWallpaper.cpp @@ -339,7 +339,7 @@ CFBO* CWallpaper::createFBO (const std::string& name, ITexture::TextureFormat fo { CFBO* fbo = new CFBO (name, format, flags, scale, realWidth, realHeight, textureWidth, textureHeight); - this->m_fbos.insert (std::make_pair (name, fbo)); + this->m_fbos.insert_or_assign (name, fbo); return fbo; } diff --git a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp index cced1d2..7b084dd 100644 --- a/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp +++ b/src/WallpaperEngine/Render/Objects/Effects/CPass.cpp @@ -494,14 +494,14 @@ void CPass::setupUniforms () { if (bindCur != bindEnd) { - this->m_finalTextures.insert (std::make_pair ((*bindCur).first, nullptr)); + this->m_finalTextures.insert_or_assign ((*bindCur).first, nullptr); bindCur ++; } if (cur != end) { if ((*cur) != nullptr) - this->m_finalTextures.insert (std::make_pair (index, *cur)); + this->m_finalTextures.insert_or_assign (index, *cur); index ++; cur ++; @@ -526,7 +526,7 @@ void CPass::setupUniforms () else textureRef = this->getMaterial ()->getImage ()->getScene ()->getContext ()->resolveTexture (textureName); - this->m_finalTextures.insert (std::make_pair ((*fragCur).first, textureRef)); + this->m_finalTextures.insert_or_assign ((*fragCur).first, textureRef); } catch (std::runtime_error& ex) { @@ -555,7 +555,7 @@ void CPass::setupUniforms () else textureRef = this->getMaterial ()->getImage ()->getScene ()->getContext ()->resolveTexture (textureName); - this->m_finalTextures.insert (std::make_pair ((*vertCur).first, textureRef)); + this->m_finalTextures.insert_or_assign ((*vertCur).first, textureRef); } catch (std::runtime_error& ex) { @@ -623,9 +623,7 @@ void CPass::addUniform (const std::string& name, UniformType type, T value) T* newValue = new T (value); // uniform found, add it to the list - this->m_uniforms.insert ( - std::make_pair (name, new UniformEntry (id, name, type, newValue)) - ); + this->m_uniforms.insert_or_assign (name, new UniformEntry (id, name, type, newValue)); } template @@ -639,9 +637,7 @@ void CPass::addUniform (const std::string& name, UniformType type, T* value) return; // uniform found, add it to the list - this->m_uniforms.insert ( - std::make_pair (name, new UniformEntry (id, name, type, value)) - ); + this->m_uniforms.insert_or_assign (name, new UniformEntry (id, name, type, value)); } template @@ -655,8 +651,8 @@ void CPass::addUniform (const std::string& name, UniformType type, T** value) return; // uniform found, add it to the list - this->m_referenceUniforms.insert ( - std::make_pair (name, new ReferenceUniformEntry (id, name, type, reinterpret_cast (value))) + this->m_referenceUniforms.insert_or_assign ( + name, new ReferenceUniformEntry (id, name, type, reinterpret_cast (value)) ); } @@ -681,7 +677,7 @@ void CPass::setupTextures () if (fbo != nullptr) { - this->m_fbos.insert (std::make_pair (index, fbo)); + this->m_fbos.insert_or_assign (index, fbo); this->m_textures.emplace_back ( fbo ); diff --git a/src/WallpaperEngine/Render/Shaders/Compiler.cpp b/src/WallpaperEngine/Render/Shaders/Compiler.cpp index 4e582ee..07aa242 100644 --- a/src/WallpaperEngine/Render/Shaders/Compiler.cpp +++ b/src/WallpaperEngine/Render/Shaders/Compiler.cpp @@ -56,7 +56,7 @@ namespace WallpaperEngine::Render::Shaders // clone the combos into the baseCombos to keep track of values that must be embedded no matter what for (const auto& cur : *this->m_combos) - this->m_baseCombos.insert (std::make_pair (cur.first, cur.second)); + this->m_baseCombos.insert_or_assign(cur.first, cur.second); } bool Compiler::peekString(std::string str, std::string::const_iterator& it) @@ -572,7 +572,7 @@ namespace WallpaperEngine::Render::Shaders std::map::const_iterator entry = this->m_combos->find ((*combo).get ()); // add the combo to the found list - this->m_foundCombos->insert (std::make_pair (*combo, true)); + this->m_foundCombos->insert_or_assign (*combo, true); // 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 @@ -582,7 +582,7 @@ namespace WallpaperEngine::Render::Shaders if (defvalue == data.end ()) { // TODO: PROPERLY SUPPORT EMPTY COMBOS - this->m_combos->insert (std::make_pair (*combo, (int) defaultValue)); + this->m_combos->insert_or_assign (*combo, (int) defaultValue); } else if ((*defvalue).is_number_float ()) { @@ -590,7 +590,7 @@ namespace WallpaperEngine::Render::Shaders } else if ((*defvalue).is_number_integer ()) { - this->m_combos->insert (std::make_pair (*combo, (*defvalue).get ())); + this->m_combos->insert_or_assign (*combo, (*defvalue).get ()); } else if ((*defvalue).is_string ()) { @@ -691,17 +691,17 @@ namespace WallpaperEngine::Render::Shaders if (this->m_passTextures.size () > index && (this->m_passTextures.at (index) != "" || textureName != data.end ())) { // add the new combo to the list - this->m_combos->insert (std::make_pair (*combo, 1)); + this->m_combos->insert_or_assign (*combo, 1); // textures linked to combos need to be tracked too if (this->m_foundCombos->find (*combo) == this->m_foundCombos->end ()) - this->m_foundCombos->insert (std::make_pair (*combo, true)); + this->m_foundCombos->insert_or_assign (*combo, true); } } if (textureName != data.end ()) - this->m_textures.insert (std::make_pair (index, *textureName)); + this->m_textures.insert_or_assign (index, *textureName); // samplers are not saved, we can ignore them for now return;