mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
Revert "Properly clamp volume value"
This partially reverts commit 95713ae439
.
# Conflicts:
# src/WallpaperEngine/Application/CApplicationContext.cpp
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
99a4935825
commit
3d8452ee9a
@ -4,9 +4,8 @@
|
|||||||
#include "WallpaperEngine/Logging/CLog.h"
|
#include "WallpaperEngine/Logging/CLog.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <getopt.h>
|
|
||||||
#include <glm/common.hpp>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
#define WORKSHOP_APP_ID 431960
|
#define WORKSHOP_APP_ID 431960
|
||||||
#define APP_DIRECTORY "wallpaper_engine"
|
#define APP_DIRECTORY "wallpaper_engine"
|
||||||
@ -14,23 +13,23 @@
|
|||||||
using namespace WallpaperEngine::Application;
|
using namespace WallpaperEngine::Application;
|
||||||
|
|
||||||
struct option long_options [] = {
|
struct option long_options [] = {
|
||||||
{"screen-root", required_argument, nullptr, 'r'},
|
{"screen-root", required_argument, 0, 'r'},
|
||||||
{"pkg", required_argument, nullptr, 'p'},
|
{"pkg", required_argument, 0, 'p'},
|
||||||
{"dir", required_argument, nullptr, 'd'},
|
{"dir", required_argument, 0, 'd'},
|
||||||
{"silent", no_argument, nullptr, 's'},
|
{"silent", no_argument, 0, 's'},
|
||||||
{"volume", required_argument, nullptr, 'v'},
|
{"volume", required_argument, 0, 'v'},
|
||||||
{"help", no_argument, nullptr, 'h'},
|
{"help", no_argument, 0, 'h'},
|
||||||
{"fps", required_argument, nullptr, 'f'},
|
{"fps", required_argument, 0, 'f'},
|
||||||
{"assets-dir", required_argument, nullptr, 'a'},
|
{"assets-dir", required_argument, 0, 'a'},
|
||||||
{"screenshot", required_argument, nullptr, 'c'},
|
{"screenshot", required_argument, 0, 'c'},
|
||||||
{"list-properties", no_argument, nullptr, 'l'},
|
{"list-properties", no_argument, 0, 'l'},
|
||||||
{"set-property", required_argument, nullptr, 'o'},
|
{"set-property", required_argument, 0, 'o'},
|
||||||
{nullptr, 0, nullptr, 0}
|
{nullptr, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string stringPathFixes(const std::string& s)
|
std::string stringPathFixes(const std::string& s)
|
||||||
{
|
{
|
||||||
if (s.empty ())
|
if (s.empty () == true)
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
std::string str (s);
|
std::string str (s);
|
||||||
@ -49,8 +48,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv[]) :
|
|||||||
maximumFPS (30),
|
maximumFPS (30),
|
||||||
audioVolume (128),
|
audioVolume (128),
|
||||||
audioEnabled (true),
|
audioEnabled (true),
|
||||||
onlyListProperties (false),
|
onlyListProperties (false)
|
||||||
screenshotFormat (FIF_UNKNOWN)
|
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
@ -97,7 +95,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv[]) :
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
maximumFPS = strtol (optarg, nullptr, 0);
|
maximumFPS = atoi (optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -105,20 +103,17 @@ CApplicationContext::CApplicationContext (int argc, char* argv[]) :
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
this->audioVolume = glm::clamp ((int) strtol (optarg, nullptr, 0), 0, 128);
|
this->audioVolume = std::max (atoi (optarg), 128);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
this->takeScreenshot = true;
|
this->takeScreenshot = true;
|
||||||
this->screenshot = stringPathFixes (optarg);
|
this->screenshot = stringPathFixes (optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->background.empty ())
|
if (this->background.empty () == true)
|
||||||
{
|
{
|
||||||
if (optind < argc && strlen (argv [optind]) > 0)
|
if (optind < argc && strlen (argv [optind]) > 0)
|
||||||
{
|
{
|
||||||
@ -126,7 +121,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv[]) :
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CApplicationContext::printHelp (argv [0]);
|
this->printHelp (argv [0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +141,7 @@ void CApplicationContext::validatePath ()
|
|||||||
|
|
||||||
void CApplicationContext::validateAssets ()
|
void CApplicationContext::validateAssets ()
|
||||||
{
|
{
|
||||||
if (!this->assets.empty ())
|
if (this->assets.empty () == false)
|
||||||
{
|
{
|
||||||
sLog.out ("Using wallpaper engine's assets at ", this->assets, " based on --assets-dir parameter");
|
sLog.out ("Using wallpaper engine's assets at ", this->assets, " based on --assets-dir parameter");
|
||||||
return;
|
return;
|
||||||
@ -166,10 +161,10 @@ void CApplicationContext::validateAssets ()
|
|||||||
|
|
||||||
void CApplicationContext::validateScreenshot ()
|
void CApplicationContext::validateScreenshot ()
|
||||||
{
|
{
|
||||||
if (!this->takeScreenshot)
|
if (this->takeScreenshot == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!this->screenshot.has_extension ())
|
if (this->screenshot.has_extension () == false)
|
||||||
sLog.exception ("Cannot determine screenshot format");
|
sLog.exception ("Cannot determine screenshot format");
|
||||||
|
|
||||||
std::string extension = this->screenshot.extension ();
|
std::string extension = this->screenshot.extension ();
|
||||||
@ -194,7 +189,7 @@ void CApplicationContext::printHelp (const char* route)
|
|||||||
sLog.out ("");
|
sLog.out ("");
|
||||||
sLog.out ("options:");
|
sLog.out ("options:");
|
||||||
sLog.out ("\t--silent\t\t\t\t\tMutes all the sound the wallpaper might produce");
|
sLog.out ("\t--silent\t\t\t\t\tMutes all the sound the wallpaper might produce");
|
||||||
sLog.out ("\t--volume <amount>\t\t\tSets the volume for all the sounds in the background (0 - 128)");
|
sLog.out ("\t--volume <amount>\t\t\tSets the volume for all the sounds in the background");
|
||||||
sLog.out ("\t--screen-root <screen name>\tDisplay as screen's background");
|
sLog.out ("\t--screen-root <screen name>\tDisplay as screen's background");
|
||||||
sLog.out ("\t--fps <maximum-fps>\t\t\tLimits the FPS to the given number, useful to keep battery consumption low");
|
sLog.out ("\t--fps <maximum-fps>\t\t\tLimits the FPS to the given number, useful to keep battery consumption low");
|
||||||
sLog.out ("\t--assets-dir <path>\t\t\tFolder where the assets are stored");
|
sLog.out ("\t--assets-dir <path>\t\t\tFolder where the assets are stored");
|
||||||
|
@ -409,7 +409,7 @@ CTexture::TextureHeader* CTexture::parseHeader (const char* fileData)
|
|||||||
mipmaps.emplace_back (parseMipmap (header, &fileData));
|
mipmaps.emplace_back (parseMipmap (header, &fileData));
|
||||||
|
|
||||||
// add the pixmaps back
|
// add the pixmaps back
|
||||||
header->images.insert_or_assign (image, mipmaps);
|
header->images.insert (std::pair <uint32_t, std::vector <TextureMipmap*>> (image, mipmaps));
|
||||||
|
|
||||||
pointer = reinterpret_cast <const uint32_t*> (fileData);
|
pointer = reinterpret_cast <const uint32_t*> (fileData);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@ using namespace WallpaperEngine::Assets;
|
|||||||
|
|
||||||
void CVirtualContainer::add (const std::string& filename, void* contents, uint32_t length)
|
void CVirtualContainer::add (const std::string& filename, void* contents, uint32_t length)
|
||||||
{
|
{
|
||||||
this->m_virtualFiles.insert_or_assign (filename, CFileEntry (contents, length));
|
this->m_virtualFiles.insert (
|
||||||
|
std::make_pair (filename, CFileEntry (contents, length))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVirtualContainer::add (const std::string& filename, const std::string& contents)
|
void CVirtualContainer::add (const std::string& filename, const std::string& contents)
|
||||||
|
@ -121,7 +121,7 @@ void CScene::insertObject (CObject* object)
|
|||||||
/// TODO: XXXHACK -- TO REMOVE WHEN PARTICLE SUPPORT IS PROPERLY IMPLEMENTED
|
/// TODO: XXXHACK -- TO REMOVE WHEN PARTICLE SUPPORT IS PROPERLY IMPLEMENTED
|
||||||
if (object != nullptr)
|
if (object != nullptr)
|
||||||
{
|
{
|
||||||
this->m_objects.insert_or_assign (object->getId (), object);
|
this->m_objects.insert (std::make_pair (object->getId (), object));
|
||||||
this->m_objectsByRenderOrder.emplace_back (object);
|
this->m_objectsByRenderOrder.emplace_back (object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ void CMaterial::insertPass (Materials::CPass* mass)
|
|||||||
|
|
||||||
void CMaterial::insertTextureBind (Effects::CBind* bind)
|
void CMaterial::insertTextureBind (Effects::CBind* bind)
|
||||||
{
|
{
|
||||||
this->m_textureBindings.insert_or_assign (bind->getIndex (), bind);
|
this->m_textureBindings.insert (std::make_pair (bind->getIndex (), bind));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMaterial::setTarget (const std::string& target)
|
void CMaterial::setTarget (const std::string& target)
|
||||||
|
@ -74,7 +74,7 @@ void CPass::insertCombo (const std::string& name, int value)
|
|||||||
std::string uppercase = std::string (name);
|
std::string uppercase = std::string (name);
|
||||||
|
|
||||||
std::transform (uppercase.begin (), uppercase.end (), uppercase.begin (), ::toupper);
|
std::transform (uppercase.begin (), uppercase.end (), uppercase.begin (), ::toupper);
|
||||||
this->m_combos.insert_or_assign (uppercase, value);
|
this->m_combos.insert (std::pair <std::string, int> (uppercase, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::string>& CPass::getTextures () const
|
const std::vector<std::string>& CPass::getTextures () const
|
||||||
@ -124,5 +124,5 @@ void CPass::setBlendingMode (const std::string& mode)
|
|||||||
|
|
||||||
void CPass::insertConstant (const std::string& name, CShaderConstant* constant)
|
void CPass::insertConstant (const std::string& name, CShaderConstant* constant)
|
||||||
{
|
{
|
||||||
this->m_constants.insert_or_assign (name, constant);
|
this->m_constants.insert (std::pair <std::string, CShaderConstant*> (name, constant));
|
||||||
}
|
}
|
@ -209,7 +209,7 @@ Render::CObject* CScene::createObject (Core::CObject* object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (renderObject != nullptr)
|
if (renderObject != nullptr)
|
||||||
this->m_objects.insert_or_assign (renderObject->getId (), renderObject);
|
this->m_objects.insert (std::make_pair (renderObject->getId (), renderObject));
|
||||||
|
|
||||||
return renderObject;
|
return renderObject;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ const ITexture* CTextureCache::resolve (const std::string& filename)
|
|||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTextureCache::store (const std::string& name, const ITexture* texture)
|
void CTextureCache::store (std::string name, const ITexture* texture)
|
||||||
{
|
{
|
||||||
this->m_textureCache.insert_or_assign (name, texture);
|
this->m_textureCache.insert_or_assign (name, texture);
|
||||||
}
|
}
|
@ -33,7 +33,7 @@ namespace WallpaperEngine::Render
|
|||||||
* @param name
|
* @param name
|
||||||
* @param texture
|
* @param texture
|
||||||
*/
|
*/
|
||||||
void store (const std::string& name, const ITexture* texture);
|
void store (std::string name, const ITexture* texture);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CRenderContext& m_context;
|
CRenderContext& m_context;
|
||||||
|
@ -346,7 +346,7 @@ CFBO* CWallpaper::createFBO (const std::string& name, ITexture::TextureFormat fo
|
|||||||
{
|
{
|
||||||
CFBO* fbo = new CFBO (name, format, flags, scale, realWidth, realHeight, textureWidth, textureHeight);
|
CFBO* fbo = new CFBO (name, format, flags, scale, realWidth, realHeight, textureWidth, textureHeight);
|
||||||
|
|
||||||
this->m_fbos.insert_or_assign (name, fbo);
|
this->m_fbos.insert (std::make_pair (name, fbo));
|
||||||
|
|
||||||
return fbo;
|
return fbo;
|
||||||
}
|
}
|
||||||
|
@ -492,14 +492,14 @@ void CPass::setupUniforms ()
|
|||||||
{
|
{
|
||||||
if (bindCur != bindEnd)
|
if (bindCur != bindEnd)
|
||||||
{
|
{
|
||||||
this->m_finalTextures.insert_or_assign ((*bindCur).first, nullptr);
|
this->m_finalTextures.insert (std::make_pair ((*bindCur).first, nullptr));
|
||||||
bindCur ++;
|
bindCur ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur != end)
|
if (cur != end)
|
||||||
{
|
{
|
||||||
if ((*cur) != nullptr)
|
if ((*cur) != nullptr)
|
||||||
this->m_finalTextures.insert_or_assign (index, *cur);
|
this->m_finalTextures.insert (std::make_pair (index, *cur));
|
||||||
|
|
||||||
index ++;
|
index ++;
|
||||||
cur ++;
|
cur ++;
|
||||||
@ -524,7 +524,7 @@ void CPass::setupUniforms ()
|
|||||||
else
|
else
|
||||||
textureRef = this->getMaterial ()->getImage ()->getScene ()->getContext ().resolveTexture (textureName);
|
textureRef = this->getMaterial ()->getImage ()->getScene ()->getContext ().resolveTexture (textureName);
|
||||||
|
|
||||||
this->m_finalTextures.insert_or_assign ((*fragCur).first, textureRef);
|
this->m_finalTextures.insert (std::make_pair ((*fragCur).first, textureRef));
|
||||||
}
|
}
|
||||||
catch (std::runtime_error& ex)
|
catch (std::runtime_error& ex)
|
||||||
{
|
{
|
||||||
@ -553,7 +553,7 @@ void CPass::setupUniforms ()
|
|||||||
else
|
else
|
||||||
textureRef = this->getMaterial ()->getImage ()->getScene ()->getContext ().resolveTexture (textureName);
|
textureRef = this->getMaterial ()->getImage ()->getScene ()->getContext ().resolveTexture (textureName);
|
||||||
|
|
||||||
this->m_finalTextures.insert_or_assign ((*vertCur).first, textureRef);
|
this->m_finalTextures.insert (std::make_pair ((*vertCur).first, textureRef));
|
||||||
}
|
}
|
||||||
catch (std::runtime_error& ex)
|
catch (std::runtime_error& ex)
|
||||||
{
|
{
|
||||||
@ -621,7 +621,9 @@ void CPass::addUniform (const std::string& name, UniformType type, T value)
|
|||||||
T* newValue = new T (value);
|
T* newValue = new T (value);
|
||||||
|
|
||||||
// uniform found, add it to the list
|
// uniform found, add it to the list
|
||||||
this->m_uniforms.insert_or_assign (name, new UniformEntry (id, name, type, newValue));
|
this->m_uniforms.insert (
|
||||||
|
std::make_pair (name, new UniformEntry (id, name, type, newValue))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -635,7 +637,9 @@ void CPass::addUniform (const std::string& name, UniformType type, T* value)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// uniform found, add it to the list
|
// uniform found, add it to the list
|
||||||
this->m_uniforms.insert_or_assign (name, new UniformEntry (id, name, type, value));
|
this->m_uniforms.insert (
|
||||||
|
std::make_pair (name, new UniformEntry (id, name, type, value))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -649,8 +653,8 @@ void CPass::addUniform (const std::string& name, UniformType type, T** value)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// uniform found, add it to the list
|
// uniform found, add it to the list
|
||||||
this->m_referenceUniforms.insert_or_assign (
|
this->m_referenceUniforms.insert (
|
||||||
name, new ReferenceUniformEntry (id, name, type, reinterpret_cast <const void**> (value))
|
std::make_pair (name, new ReferenceUniformEntry (id, name, type, reinterpret_cast <const void**> (value)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +679,7 @@ void CPass::setupTextures ()
|
|||||||
|
|
||||||
if (fbo != nullptr)
|
if (fbo != nullptr)
|
||||||
{
|
{
|
||||||
this->m_fbos.insert_or_assign (index, fbo);
|
this->m_fbos.insert (std::make_pair (index, fbo));
|
||||||
this->m_textures.emplace_back (
|
this->m_textures.emplace_back (
|
||||||
fbo
|
fbo
|
||||||
);
|
);
|
||||||
|
@ -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
|
// 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)
|
for (const auto& cur : *this->m_combos)
|
||||||
this->m_baseCombos.insert_or_assign(cur.first, cur.second);
|
this->m_baseCombos.insert (std::make_pair (cur.first, cur.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Compiler::peekString(std::string str, std::string::const_iterator& it)
|
bool Compiler::peekString(std::string str, std::string::const_iterator& it)
|
||||||
@ -579,7 +579,7 @@ namespace WallpaperEngine::Render::Shaders
|
|||||||
auto entry = this->m_combos->find ((*combo).get <std::string> ());
|
auto entry = this->m_combos->find ((*combo).get <std::string> ());
|
||||||
|
|
||||||
// add the combo to the found list
|
// add the combo to the found list
|
||||||
this->m_foundCombos->insert_or_assign (*combo, true);
|
this->m_foundCombos->insert (std::make_pair <std::string, int> (*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
|
// if the combo was not found in the predefined values this means that the default value in the JSON data can be used
|
||||||
// so only define the ones that are not already defined
|
// so only define the ones that are not already defined
|
||||||
@ -589,7 +589,7 @@ namespace WallpaperEngine::Render::Shaders
|
|||||||
if (defvalue == data.end ())
|
if (defvalue == data.end ())
|
||||||
{
|
{
|
||||||
// TODO: PROPERLY SUPPORT EMPTY COMBOS
|
// TODO: PROPERLY SUPPORT EMPTY COMBOS
|
||||||
this->m_combos->insert_or_assign (*combo, (int) defaultValue);
|
this->m_combos->insert (std::make_pair <std::string, int> (*combo, (int) defaultValue));
|
||||||
}
|
}
|
||||||
else if ((*defvalue).is_number_float ())
|
else if ((*defvalue).is_number_float ())
|
||||||
{
|
{
|
||||||
@ -597,7 +597,7 @@ namespace WallpaperEngine::Render::Shaders
|
|||||||
}
|
}
|
||||||
else if ((*defvalue).is_number_integer ())
|
else if ((*defvalue).is_number_integer ())
|
||||||
{
|
{
|
||||||
this->m_combos->insert_or_assign (*combo, (*defvalue).get <int> ());
|
this->m_combos->insert (std::make_pair <std::string, int> (*combo, (*defvalue).get <int> ()));
|
||||||
}
|
}
|
||||||
else if ((*defvalue).is_string ())
|
else if ((*defvalue).is_string ())
|
||||||
{
|
{
|
||||||
@ -697,16 +697,16 @@ namespace WallpaperEngine::Render::Shaders
|
|||||||
if (this->m_passTextures.size () > index && (!this->m_passTextures.at (index).empty() || textureName != data.end ()))
|
if (this->m_passTextures.size () > index && (!this->m_passTextures.at (index).empty() || textureName != data.end ()))
|
||||||
{
|
{
|
||||||
// add the new combo to the list
|
// add the new combo to the list
|
||||||
this->m_combos->insert_or_assign (*combo, 1);
|
this->m_combos->insert (std::make_pair <std::string, int> (*combo, 1));
|
||||||
|
|
||||||
// textures linked to combos need to be tracked too
|
// textures linked to combos need to be tracked too
|
||||||
if (this->m_foundCombos->find (*combo) == this->m_foundCombos->end ())
|
if (this->m_foundCombos->find (*combo) == this->m_foundCombos->end ())
|
||||||
this->m_foundCombos->insert_or_assign (*combo, true);
|
this->m_foundCombos->insert (std::make_pair <std::string, bool> (*combo, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textureName != data.end ())
|
if (textureName != data.end ())
|
||||||
this->m_textures.insert_or_assign (index, *textureName);
|
this->m_textures.insert (std::make_pair (index, *textureName));
|
||||||
|
|
||||||
// samplers are not saved, we can ignore them for now
|
// samplers are not saved, we can ignore them for now
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user