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 <sys/stat.h>
const char* assets_default_paths [] = {
std::vector<std::string> appDirectoryPaths = {
".steam/steam/steamapps/common",
".local/share/Steam/steamapps/common",
".var/app/com.valvesoftware.Steam/.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",
".steam/steam/steamapps/workshop/content",
".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/workshop/content",
"snap/steam/common/.local/share/Steam/steamapps/workshop/content",
nullptr
};
std::filesystem::path detectHomepath () {
@ -33,14 +31,14 @@ std::filesystem::path detectHomepath () {
if (!std::filesystem::is_directory (path))
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) {
auto homepath = detectHomepath ();
for (const char** current = workshop_content_default_paths; *current != nullptr; current++) {
auto currentpath = std::filesystem::path (homepath) / *current / std::to_string (appID) / contentID;
for (const auto& current : workshopDirectoryPaths) {
auto currentpath = std::filesystem::path (homepath) / current / std::to_string (appID) / contentID;
if (!std::filesystem::exists (currentpath) || !std::filesystem::is_directory (currentpath))
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) {
auto homepath = detectHomepath ();
for (const char** current = assets_default_paths; *current != nullptr; current++) {
auto currentpath = std::filesystem::path (homepath) / *current / appDirectory / path;
for (const auto& current : appDirectoryPaths) {
auto currentpath = std::filesystem::path (homepath) / current / appDirectory / path;
if (!std::filesystem::exists (currentpath) || !std::filesystem::is_directory (currentpath))
continue;

View File

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

View File

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

View File

@ -22,8 +22,6 @@ struct ObjectData {
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
*

View File

@ -33,9 +33,9 @@ class Property : public DynamicValue, public TypeCaster, public PropertyData {
virtual void update(const std::string& value) = 0;
};
class PropertySlider : public Property, SliderData {
class PropertySlider final : public Property, SliderData {
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);
}
@ -45,9 +45,9 @@ class PropertySlider : public Property, SliderData {
}
};
class PropertyBoolean : public Property {
class PropertyBoolean final : public Property {
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);
}
@ -57,9 +57,9 @@ class PropertyBoolean : public Property {
}
};
class PropertyColor : public Property {
class PropertyColor final : public Property {
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);
}
@ -70,7 +70,7 @@ class PropertyColor : public Property {
// TODO: ENSURE ALL THIS PARSING IS CORRECT
if (copy.find (',') != std::string::npos) {
// 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
@ -110,9 +110,9 @@ class PropertyColor : public Property {
}
};
class PropertyCombo : public Property, ComboData {
class PropertyCombo final : public Property, ComboData {
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);
}
@ -122,7 +122,7 @@ class PropertyCombo : public Property, ComboData {
}
};
class PropertyText : public Property {
class PropertyText final : public Property {
public:
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:
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);
}

View File

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

View File

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

View File

@ -67,4 +67,6 @@ class Container {
/** Virtual file system adapter */
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);
~CFBO () override;
// TODO: ADD DESTRUCTOR TO FREE RESOURCES
[[nodiscard]] const std::string& getName () const;
[[nodiscard]] const float& getScale () const;
[[nodiscard]] TextureFormat getFormat () const override;

View File

@ -110,14 +110,8 @@ void CTexture::setupResolution () {
GLint CTexture::setupInternalFormat () {
if (this->m_header->freeImageFormat != FIF_UNKNOWN) {
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?
/*this->m_header->width = this->m_header->mipmaps [0]->width;
this->m_header->height = this->m_header->mipmaps [0]->height;
this->m_header->textureWidth = this->m_header->mipmaps [0]->width;
this->m_header->textureHeight = this->m_header->mipmaps [0]->height;*/
} else {
}
// detect the image format and hand it to openGL to be used
switch (this->m_header->format) {
case TextureFormat_DXT5: return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
@ -128,7 +122,6 @@ GLint CTexture::setupInternalFormat () {
case TextureFormat_RG88: return GL_RG8; break;
default: sLog.exception ("Cannot determine texture format");
}
}
}
void CTexture::setupOpenGLParameters (uint32_t textureID) {

View File

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

View File

@ -9,7 +9,7 @@ FBOProvider::FBOProvider (const FBOProvider* 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> (
base.name,
// 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 ();
for (; cur != end; ++cur) {
// TODO: PROPERLY CHECK EFFECT'S VISIBILITY AND TAKE IT INTO ACCOUNT
if (std::next (cur) == end)
glColorMask (true, true, true, false);

View File

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

View File

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