chore: some cleanup everywhere

This commit is contained in:
Almamu 2025-09-13 20:17:47 +02:00
parent 5b65abe7b9
commit f74527d23b
15 changed files with 47 additions and 70 deletions

View File

@ -6,20 +6,18 @@
#include <sstream> #include <sstream>
#include <sys/stat.h> #include <sys/stat.h>
const char* assets_default_paths [] = { std::vector<std::string> appDirectoryPaths = {
".steam/steam/steamapps/common", ".steam/steam/steamapps/common",
".local/share/Steam/steamapps/common", ".local/share/Steam/steamapps/common",
".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common", ".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common",
"snap/steam/common/.local/share/Steam/steamapps/common", "snap/steam/common/.local/share/Steam/steamapps/common",
nullptr
}; };
const char* workshop_content_default_paths [] = { std::vector<std::string> workshopDirectoryPaths = {
".local/share/Steam/steamapps/workshop/content", ".local/share/Steam/steamapps/workshop/content",
".steam/steam/steamapps/workshop/content", ".steam/steam/steamapps/workshop/content",
".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/workshop/content", ".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/workshop/content",
"snap/steam/common/.local/share/Steam/steamapps/workshop/content", "snap/steam/common/.local/share/Steam/steamapps/workshop/content",
nullptr
}; };
std::filesystem::path detectHomepath () { std::filesystem::path detectHomepath () {
@ -33,14 +31,14 @@ std::filesystem::path detectHomepath () {
if (!std::filesystem::is_directory (path)) if (!std::filesystem::is_directory (path))
sLog.exception ("Cannot find home directory for current user, ", home, " is not a directory"); sLog.exception ("Cannot find home directory for current user, ", home, " is not a directory");
return home; return path;
} }
std::filesystem::path Steam::FileSystem::workshopDirectory (int appID, const std::string& contentID) { std::filesystem::path Steam::FileSystem::workshopDirectory (int appID, const std::string& contentID) {
auto homepath = detectHomepath (); auto homepath = detectHomepath ();
for (const char** current = workshop_content_default_paths; *current != nullptr; current++) { for (const auto& current : workshopDirectoryPaths) {
auto currentpath = std::filesystem::path (homepath) / *current / std::to_string (appID) / contentID; auto currentpath = std::filesystem::path (homepath) / current / std::to_string (appID) / contentID;
if (!std::filesystem::exists (currentpath) || !std::filesystem::is_directory (currentpath)) if (!std::filesystem::exists (currentpath) || !std::filesystem::is_directory (currentpath))
continue; continue;
@ -54,8 +52,8 @@ std::filesystem::path Steam::FileSystem::workshopDirectory (int appID, const std
std::filesystem::path Steam::FileSystem::appDirectory (const std::string& appDirectory, const std::string& path) { std::filesystem::path Steam::FileSystem::appDirectory (const std::string& appDirectory, const std::string& path) {
auto homepath = detectHomepath (); auto homepath = detectHomepath ();
for (const char** current = assets_default_paths; *current != nullptr; current++) { for (const auto& current : appDirectoryPaths) {
auto currentpath = std::filesystem::path (homepath) / *current / appDirectory / path; auto currentpath = std::filesystem::path (homepath) / current / appDirectory / path;
if (!std::filesystem::exists (currentpath) || !std::filesystem::is_directory (currentpath)) if (!std::filesystem::exists (currentpath) || !std::filesystem::is_directory (currentpath))
continue; continue;

View File

@ -402,16 +402,13 @@ void WallpaperApplication::show () {
static struct tm* timeinfo; static struct tm* timeinfo;
if (this->m_context.settings.general.dumpStructure) { if (this->m_context.settings.general.dumpStructure) {
// TODO: REWRITE TO USE THE NEW DUMPER auto prettyPrinter = Data::Dumpers::StringPrinter ();
/*
auto prettyPrinter = PrettyPrinter::CPrettyPrinter ();
for (const auto& [background, info] : this->m_renderContext->getWallpapers ()) { for (const auto& [background, info] : this->m_renderContext->getWallpapers ()) {
prettyPrinter.printWallpaper (*info); prettyPrinter.printWallpaper (info->getWallpaperData ());
} }
std::cout << prettyPrinter.str () << std::endl; std::cout << prettyPrinter.str () << std::endl;
*/
} }
#if DEMOMODE #if DEMOMODE

View File

@ -35,7 +35,6 @@ enum DepthwriteMode {
}; };
struct MaterialPass { struct MaterialPass {
// TODO: WRITE ENUMS FOR THESE
/** Blending mode */ /** Blending mode */
BlendingMode blending; BlendingMode blending;
/** Culling mode */ /** Culling mode */

View File

@ -22,8 +22,6 @@ struct ObjectData {
std::vector <int> dependencies; std::vector <int> dependencies;
}; };
//TODO: CHECK IF THE SEMANTICS FOR MEMORY ARE RIGHT HERE
/** /**
* Base class for all objects, represents a single object in the scene * Base class for all objects, represents a single object in the scene
* *

View File

@ -33,9 +33,9 @@ class Property : public DynamicValue, public TypeCaster, public PropertyData {
virtual void update(const std::string& value) = 0; virtual void update(const std::string& value) = 0;
}; };
class PropertySlider : public Property, SliderData { class PropertySlider final : public Property, SliderData {
public: public:
PropertySlider (PropertyData data, SliderData sliderData, float value) : Property (std::move(data)), SliderData (sliderData) { PropertySlider (PropertyData data, SliderData sliderData, const float value) : Property (std::move(data)), SliderData (std::move (sliderData)) {
this->update (value); this->update (value);
} }
@ -45,9 +45,9 @@ class PropertySlider : public Property, SliderData {
} }
}; };
class PropertyBoolean : public Property { class PropertyBoolean final : public Property {
public: public:
explicit PropertyBoolean (PropertyData data, bool value) : Property (std::move(data)) { explicit PropertyBoolean (PropertyData data, const bool value) : Property (std::move(data)) {
this->update (value); this->update (value);
} }
@ -57,9 +57,9 @@ class PropertyBoolean : public Property {
} }
}; };
class PropertyColor : public Property { class PropertyColor final : public Property {
public: public:
explicit PropertyColor (PropertyData data, std::string value) : Property (std::move(data)) { explicit PropertyColor (PropertyData data, const std::string& value) : Property (std::move(data)) {
this->PropertyColor::update (value); this->PropertyColor::update (value);
} }
@ -70,7 +70,7 @@ class PropertyColor : public Property {
// TODO: ENSURE ALL THIS PARSING IS CORRECT // TODO: ENSURE ALL THIS PARSING IS CORRECT
if (copy.find (',') != std::string::npos) { if (copy.find (',') != std::string::npos) {
// replace comma separator with spaces so it's // replace comma separator with spaces so it's
std::replace (copy.begin (), copy.end (), ',', ' '); std::ranges::replace (copy, ',', ' ');
} }
// hex colors should be converted to int colors // hex colors should be converted to int colors
@ -110,9 +110,9 @@ class PropertyColor : public Property {
} }
}; };
class PropertyCombo : public Property, ComboData { class PropertyCombo final : public Property, ComboData {
public: public:
PropertyCombo (PropertyData data, ComboData comboData, std::string value) : Property (std::move(data)), ComboData (std::move(comboData)) { PropertyCombo (PropertyData data, ComboData comboData, const std::string& value) : Property (std::move(data)), ComboData (std::move(comboData)) {
this->PropertyCombo::update (value); this->PropertyCombo::update (value);
} }
@ -122,7 +122,7 @@ class PropertyCombo : public Property, ComboData {
} }
}; };
class PropertyText : public Property { class PropertyText final : public Property {
public: public:
explicit PropertyText (PropertyData data) : Property (std::move(data)) {} explicit PropertyText (PropertyData data) : Property (std::move(data)) {}
@ -136,9 +136,9 @@ class PropertyText : public Property {
} }
}; };
class PropertySceneTexture : public Property { class PropertySceneTexture final : public Property {
public: public:
explicit PropertySceneTexture (PropertyData data, std::string value) : Property (std::move(data)) { explicit PropertySceneTexture (PropertyData data, const std::string& value) : Property (std::move(data)) {
this->PropertySceneTexture::update (value); this->PropertySceneTexture::update (value);
} }

View File

@ -5,10 +5,6 @@
#include <string> #include <string>
#include <memory> #include <memory>
namespace WallpaperEngine::FileSystem {
class Container;
}
namespace WallpaperEngine::Data::Model { namespace WallpaperEngine::Data::Model {
struct Project; struct Project;
class Wallpaper; class Wallpaper;
@ -40,13 +36,11 @@ using PropertySharedPtr = std::shared_ptr <Property>;
using Properties = std::map <std::string, PropertySharedPtr>; using Properties = std::map <std::string, PropertySharedPtr>;
using DynamicValueUniquePtr = std::unique_ptr <DynamicValue>; using DynamicValueUniquePtr = std::unique_ptr <DynamicValue>;
using UserSettingUniquePtr = std::unique_ptr <UserSetting>; using UserSettingUniquePtr = std::unique_ptr <UserSetting>;
// TODO: UP TO THIS POINT
using ShaderConstantMap = std::map <std::string, UserSettingUniquePtr>; using ShaderConstantMap = std::map <std::string, UserSettingUniquePtr>;
using ProjectUniquePtr = std::unique_ptr <Project>; using ProjectUniquePtr = std::unique_ptr <Project>;
using WallpaperUniquePtr = std::unique_ptr <Wallpaper>; using WallpaperUniquePtr = std::unique_ptr <Wallpaper>;
using ContainerUniquePtr = std::unique_ptr <FileSystem::Container>;
using SceneUniquePtr = std::unique_ptr <Scene>; using SceneUniquePtr = std::unique_ptr <Scene>;
using WebUniquePtr = std::unique_ptr <Web>; using WebUniquePtr = std::unique_ptr <Web>;
using VideoUniquePtr = std::unique_ptr <Video>; using VideoUniquePtr = std::unique_ptr <Video>;

View File

@ -7,7 +7,7 @@ using namespace WallpaperEngine::Data::Parsers;
using namespace WallpaperEngine::Data::Builders; using namespace WallpaperEngine::Data::Builders;
UserSettingUniquePtr UserSettingParser::parse (const json& data, const Properties& properties) { UserSettingUniquePtr UserSettingParser::parse (const json& data, const Properties& properties) {
DynamicValueUniquePtr value = std::make_unique <DynamicValue> (); auto value = std::make_unique <DynamicValue> ();
PropertySharedPtr property; PropertySharedPtr property;
std::optional<ConditionInfo> condition; std::optional<ConditionInfo> condition;
auto valueIt = data; auto valueIt = data;
@ -25,9 +25,8 @@ UserSettingUniquePtr UserSettingParser::parse (const json& data, const Propertie
if (user.has_value () && !user->is_null ()) { if (user.has_value () && !user->is_null ()) {
std::string source; std::string source;
const auto& it = *user;
if (it.is_string ()) { if (const auto& it = *user; it.is_string ()) {
source = it; source = it;
} else { } else {
condition = ConditionInfo { condition = ConditionInfo {
@ -38,9 +37,7 @@ UserSettingUniquePtr UserSettingParser::parse (const json& data, const Propertie
source = condition.value ().name; source = condition.value ().name;
} }
const auto propertyIt = properties.find (source); if (const auto propertyIt = properties.find (source); propertyIt != properties.end ()) {
if (propertyIt != properties.end ()) {
property = propertyIt->second; property = propertyIt->second;
} }
} }

View File

@ -67,4 +67,6 @@ class Container {
/** Virtual file system adapter */ /** Virtual file system adapter */
std::shared_ptr<VirtualAdapter> m_vfs; std::shared_ptr<VirtualAdapter> m_vfs;
}; };
using ContainerUniquePtr = std::unique_ptr<Container>;
} }

View File

@ -13,8 +13,6 @@ class CFBO final : public TextureProvider {
uint32_t realWidth, uint32_t realHeight, uint32_t textureWidth, uint32_t textureHeight); uint32_t realWidth, uint32_t realHeight, uint32_t textureWidth, uint32_t textureHeight);
~CFBO () override; ~CFBO () override;
// TODO: ADD DESTRUCTOR TO FREE RESOURCES
[[nodiscard]] const std::string& getName () const; [[nodiscard]] const std::string& getName () const;
[[nodiscard]] const float& getScale () const; [[nodiscard]] const float& getScale () const;
[[nodiscard]] TextureFormat getFormat () const override; [[nodiscard]] TextureFormat getFormat () const override;

View File

@ -110,24 +110,17 @@ void CTexture::setupResolution () {
GLint CTexture::setupInternalFormat () { GLint CTexture::setupInternalFormat () {
if (this->m_header->freeImageFormat != FIF_UNKNOWN) { if (this->m_header->freeImageFormat != FIF_UNKNOWN) {
return GL_RGBA8; return GL_RGBA8;
// set some extra information too as it's used for image sizing }
// this ensures that a_TexCoord uses the full image instead of just part of it
// TODO: MAYBE IT'S BETTER TO CREATE A TEXTURE OF THE GIVEN SIZE AND COPY OVER WHAT WE READ FROM THE FILE? // detect the image format and hand it to openGL to be used
/*this->m_header->width = this->m_header->mipmaps [0]->width; switch (this->m_header->format) {
this->m_header->height = this->m_header->mipmaps [0]->height; case TextureFormat_DXT5: return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
this->m_header->textureWidth = this->m_header->mipmaps [0]->width; case TextureFormat_DXT3: return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break;
this->m_header->textureHeight = this->m_header->mipmaps [0]->height;*/ case TextureFormat_DXT1: return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
} else { case TextureFormat_ARGB8888: return GL_RGBA8; break;
// detect the image format and hand it to openGL to be used case TextureFormat_R8: return GL_R8; break;
switch (this->m_header->format) { case TextureFormat_RG88: return GL_RG8; break;
case TextureFormat_DXT5: return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break; default: sLog.exception ("Cannot determine texture format");
case TextureFormat_DXT3: return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break;
case TextureFormat_DXT1: return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
case TextureFormat_ARGB8888: return GL_RGBA8; break;
case TextureFormat_R8: return GL_R8; break;
case TextureFormat_RG88: return GL_RG8; break;
default: sLog.exception ("Cannot determine texture format");
}
} }
} }

View File

@ -14,6 +14,10 @@
#include "FBOProvider.h" #include "FBOProvider.h"
#include "WallpaperState.h" #include "WallpaperState.h"
namespace WallpaperEngine::Application {
class WallpaperApplication;
}
namespace WallpaperEngine::WebBrowser { namespace WallpaperEngine::WebBrowser {
class WebBrowserContext; class WebBrowserContext;
} }
@ -29,6 +33,7 @@ using namespace WallpaperEngine::Data::Model;
using namespace WallpaperEngine::FileSystem; using namespace WallpaperEngine::FileSystem;
class CWallpaper : public Helpers::ContextAware, public FBOProvider { class CWallpaper : public Helpers::ContextAware, public FBOProvider {
friend class WallpaperEngine::Application::WallpaperApplication;
public: public:
template <class T> [[nodiscard]] const T* as () const { template <class T> [[nodiscard]] const T* as () const {
if (is <T> ()) { if (is <T> ()) {

View File

@ -9,7 +9,7 @@ FBOProvider::FBOProvider (const FBOProvider* parent) :
m_parent (parent) {} m_parent (parent) {}
std::shared_ptr<CFBO> FBOProvider::create(const FBO& base, uint32_t flags, glm::vec2 size) { std::shared_ptr<CFBO> FBOProvider::create(const FBO& base, uint32_t flags, const glm::vec2 size) {
return this->m_fbos[base.name] = std::make_shared <CFBO> ( return this->m_fbos[base.name] = std::make_shared <CFBO> (
base.name, base.name,
// TODO: PROPERLY DETERMINE FBO FORMAT BASED ON THE STRING // TODO: PROPERLY DETERMINE FBO FORMAT BASED ON THE STRING

View File

@ -485,7 +485,6 @@ void CImage::render () {
const auto end = this->m_passes.end (); const auto end = this->m_passes.end ();
for (; cur != end; ++cur) { for (; cur != end; ++cur) {
// TODO: PROPERLY CHECK EFFECT'S VISIBILITY AND TAKE IT INTO ACCOUNT
if (std::next (cur) == end) if (std::next (cur) == end)
glColorMask (true, true, true, false); glColorMask (true, true, true, false);

View File

@ -23,10 +23,9 @@ void RenderContext::render (Drivers::Output::OutputViewport* viewport) {
#endif /* DEBUG */ #endif /* DEBUG */
// search the background in the viewport selection // search the background in the viewport selection
const auto ref = this->m_wallpapers.find (viewport->name);
// render the background // render the background
if (ref != this->m_wallpapers.end ()) if (const auto ref = this->m_wallpapers.find (viewport->name); ref != this->m_wallpapers.end ())
ref->second->render (viewport->viewport, this->getOutput ().renderVFlip ()); ref->second->render (viewport->viewport, this->getOutput ().renderVFlip ());
#if !NDEBUG #if !NDEBUG

View File

@ -152,8 +152,7 @@ void ShaderUnit::preprocessIncludes () {
content += "// begin of include from file "; content += "// begin of include from file ";
content += filename; content += filename;
content += "\n"; content += "\n";
// TODO: MOVE SHADER PATH FROM HERE TO SOMEWHERE LIKE AN ASSET RESOLVER OR SOMETHING LIKE THAT content += this->m_assetLocator.includeShader (filename);
content += this->m_assetLocator.readString (std::filesystem::path("shaders") / filename);
content += "\n// end of included from file "; content += "\n// end of included from file ";
content += filename; content += filename;
content += "\n"; content += "\n";
@ -192,8 +191,7 @@ void ShaderUnit::preprocessIncludes () {
content = "// begin of include from file "; content = "// begin of include from file ";
content += filename; content += filename;
content += "\n"; content += "\n";
// TODO: MOVE SHADER PATH FROM HERE TO SOMEWHERE LIKE AN ASSET RESOLVER OR SOMETHING LIKE THAT content += this->m_assetLocator.includeShader (filename);
content += this->m_assetLocator.readString (std::filesystem::path("shaders") / filename);
content += "\n// end of included from file "; content += "\n// end of included from file ";
content += filename; content += filename;
content += "\n"; content += "\n";
@ -313,7 +311,7 @@ void ShaderUnit::preprocessRequires () {
// comment out requires // comment out requires
while((start = this->m_preprocessed.find("#require", end)) != std::string::npos) { while((start = this->m_preprocessed.find("#require", end)) != std::string::npos) {
// TODO: CHECK FOR ERRORS HERE // TODO: CHECK FOR ERRORS HERE
size_t lineEnd = this->m_preprocessed.find_first_of('\n', start); const size_t lineEnd = this->m_preprocessed.find_first_of('\n', start);
sLog.out("Shader has a require block ", this->m_preprocessed.substr (start, lineEnd - start)); sLog.out("Shader has a require block ", this->m_preprocessed.substr (start, lineEnd - start));
// replace the first two letters with a comment so the filelength doesn't change // replace the first two letters with a comment so the filelength doesn't change
this->m_preprocessed = this->m_preprocessed.replace(start, 2, "//"); this->m_preprocessed = this->m_preprocessed.replace(start, 2, "//");