mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 05:46:48 +08:00
Compare commits
3 Commits
79886ecc89
...
c3381c348d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c3381c348d | ||
![]() |
f74527d23b | ||
![]() |
5b65abe7b9 |
@ -269,6 +269,8 @@ add_executable(
|
||||
|
||||
src/WallpaperEngine/Assets/AssetLoadException.cpp
|
||||
src/WallpaperEngine/Assets/AssetLoadException.h
|
||||
src/WallpaperEngine/Assets/AssetLocator.cpp
|
||||
src/WallpaperEngine/Assets/AssetLocator.h
|
||||
|
||||
src/WallpaperEngine/FileSystem/Container.h
|
||||
src/WallpaperEngine/FileSystem/Container.cpp
|
||||
|
@ -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;
|
||||
|
@ -29,6 +29,7 @@ float g_Time;
|
||||
float g_TimeLast;
|
||||
float g_Daytime;
|
||||
|
||||
using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::Application;
|
||||
using namespace WallpaperEngine::Data::Model;
|
||||
using namespace WallpaperEngine::FileSystem;
|
||||
@ -40,10 +41,10 @@ WallpaperApplication::WallpaperApplication (ApplicationContext& context) :
|
||||
this->setupBrowser();
|
||||
}
|
||||
|
||||
ContainerUniquePtr WallpaperApplication::setupContainer (const std::string& bg) const {
|
||||
AssetLocatorUniquePtr WallpaperApplication::setupAssetLocator (const std::string& bg) const {
|
||||
auto container = std::make_unique <Container> ();
|
||||
|
||||
std::filesystem::path path (bg);
|
||||
const std::filesystem::path path = bg;
|
||||
|
||||
container->mount (path, "/");
|
||||
try {
|
||||
@ -193,7 +194,7 @@ ContainerUniquePtr WallpaperApplication::setupContainer (const std::string& bg)
|
||||
"}"
|
||||
);
|
||||
|
||||
return container;
|
||||
return std::make_unique <AssetLocator> (std::move (container));
|
||||
}
|
||||
|
||||
void WallpaperApplication::loadBackgrounds () {
|
||||
@ -214,7 +215,7 @@ void WallpaperApplication::loadBackgrounds () {
|
||||
}
|
||||
|
||||
ProjectUniquePtr WallpaperApplication::loadBackground (const std::string& bg) {
|
||||
auto container = this->setupContainer (bg);
|
||||
auto container = this->setupAssetLocator (bg);
|
||||
auto json = WallpaperEngine::Data::JSON::JSON::parse (container->readString ("project.json"));
|
||||
|
||||
return WallpaperEngine::Data::Parsers::ProjectParser::parse (json, std::move(container));
|
||||
@ -401,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
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "WallpaperEngine/Application/ApplicationContext.h"
|
||||
#include "WallpaperEngine/Assets/AssetLocator.h"
|
||||
|
||||
#include "WallpaperEngine/Render/CWallpaper.h"
|
||||
#include "WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.h"
|
||||
@ -16,6 +17,7 @@
|
||||
#include "WallpaperEngine/Data/Model/Types.h"
|
||||
|
||||
namespace WallpaperEngine::Application {
|
||||
using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::Data::Model;
|
||||
/**
|
||||
* Small wrapper class over the actual wallpaper's main application skeleton
|
||||
@ -53,12 +55,11 @@ class WallpaperApplication {
|
||||
|
||||
private:
|
||||
/**
|
||||
* Sets up a combined container for the given background, adding default files and directories to the list
|
||||
* Sets up an asset locator for the given background
|
||||
*
|
||||
* @param container
|
||||
* @param bg
|
||||
*/
|
||||
ContainerUniquePtr setupContainer (const std::string& bg) const;
|
||||
AssetLocatorUniquePtr setupAssetLocator (const std::string& bg) const;
|
||||
/**
|
||||
* Loads projects based off the settings
|
||||
*/
|
||||
|
@ -1,10 +1,6 @@
|
||||
#include "AssetLoadException.h"
|
||||
|
||||
using namespace WallpaperEngine::Render;
|
||||
using namespace WallpaperEngine::Assets;
|
||||
|
||||
AssetLoadException::AssetLoadException (const std::string& filename, const std::string& extrainfo) :
|
||||
m_message ("Cannot find file " + filename + ": " + extrainfo) {}
|
||||
|
||||
const char* AssetLoadException::what () const noexcept {
|
||||
return this->m_message.c_str ();
|
||||
}
|
||||
AssetLoadException::AssetLoadException (const std::filesystem::filesystem_error& filesystem_error) noexcept
|
||||
: std::filesystem::filesystem_error (filesystem_error) {}
|
||||
|
@ -1,16 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
// TODO: REWRITE THIS ONE TO MAKE MORE SENSE, IT REALLY MEANS "FILE-RELATED EXCEPTION"
|
||||
namespace WallpaperEngine::Render {
|
||||
class AssetLoadException final : public std::exception {
|
||||
namespace WallpaperEngine::Assets {
|
||||
class AssetLoadException final : public std::filesystem::filesystem_error {
|
||||
public:
|
||||
explicit AssetLoadException (const std::string& filename, const std::string& extrainfo = "");
|
||||
[[nodiscard]] const char* what () const noexcept override;
|
||||
|
||||
private:
|
||||
std::string m_message {};
|
||||
using std::filesystem::filesystem_error::filesystem_error;
|
||||
explicit AssetLoadException (const std::filesystem::filesystem_error& filesystem_error) noexcept;
|
||||
};
|
||||
} // namespace WallpaperEngine::Assets
|
99
src/WallpaperEngine/Assets/AssetLocator.cpp
Normal file
99
src/WallpaperEngine/Assets/AssetLocator.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
#include "AssetLocator.h"
|
||||
|
||||
#include "AssetLoadException.h"
|
||||
|
||||
using namespace WallpaperEngine::Assets;
|
||||
|
||||
AssetLocator::AssetLocator (ContainerUniquePtr filesystem) : m_filesystem (std::move (filesystem)) {}
|
||||
|
||||
std::string AssetLocator::shader (const std::filesystem::path& filename) const {
|
||||
try {
|
||||
std::filesystem::path shader = filename;
|
||||
|
||||
// detect workshop shaders and check if there's a
|
||||
if (auto it = shader.begin (); *it++ == "workshop") {
|
||||
const std::filesystem::path workshopId = *it++;
|
||||
|
||||
if (++it != shader.end ()) {
|
||||
const std::filesystem::path& shaderfile = *it;
|
||||
|
||||
try {
|
||||
shader = std::filesystem::path ("zcompat") / "scene" / "shaders" / workshopId / shaderfile;
|
||||
// replace the old path with the new one
|
||||
std::string contents = this->m_filesystem->readString (shader);
|
||||
|
||||
sLog.out ("Replaced ", filename, " with compat ", shader);
|
||||
|
||||
return contents;
|
||||
} catch (std::filesystem::filesystem_error&) {
|
||||
// these exceptions can be ignored because the replacement file might not exist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this->m_filesystem->readString ("shaders" / filename);
|
||||
} catch (std::filesystem::filesystem_error& base) {
|
||||
throw AssetLoadException (base);
|
||||
}
|
||||
}
|
||||
|
||||
std::string AssetLocator::fragmentShader (const std::filesystem::path& filename) const {
|
||||
auto final = filename;
|
||||
|
||||
final.replace_extension ("frag");
|
||||
|
||||
return this->shader (final);
|
||||
}
|
||||
|
||||
std::string AssetLocator::vertexShader (const std::filesystem::path& filename) const {
|
||||
auto final = filename;
|
||||
|
||||
final.replace_extension ("vert");
|
||||
|
||||
return this->shader (final);
|
||||
}
|
||||
|
||||
std::string AssetLocator::includeShader (const std::filesystem::path& filename) const {
|
||||
auto final = filename;
|
||||
|
||||
final.replace_extension ("h");
|
||||
|
||||
return this->shader (final);
|
||||
}
|
||||
|
||||
std::string AssetLocator::readString (const std::filesystem::path& filename) const {
|
||||
try {
|
||||
return this->m_filesystem->readString (filename);
|
||||
} catch (std::filesystem::filesystem_error& base) {
|
||||
throw AssetLoadException (base);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ReadStreamSharedPtr AssetLocator::texture (const std::filesystem::path& filename) const {
|
||||
auto final = filename;
|
||||
|
||||
final.replace_extension ("tex");
|
||||
|
||||
try {
|
||||
return this->m_filesystem->read (final);
|
||||
} catch (std::filesystem::filesystem_error& base) {
|
||||
throw AssetLoadException (base);
|
||||
}
|
||||
}
|
||||
|
||||
ReadStreamSharedPtr AssetLocator::read (const std::filesystem::path& path) const {
|
||||
try {
|
||||
return this->m_filesystem->read (path);
|
||||
} catch (std::filesystem::filesystem_error& base) {
|
||||
throw AssetLoadException (base);
|
||||
}
|
||||
}
|
||||
|
||||
std::filesystem::path AssetLocator::physicalPath (const std::filesystem::path& path) const {
|
||||
try {
|
||||
return this->m_filesystem->physicalPath (path);
|
||||
} catch (std::filesystem::filesystem_error& base) {
|
||||
throw AssetLoadException (base);
|
||||
}
|
||||
}
|
27
src/WallpaperEngine/Assets/AssetLocator.h
Normal file
27
src/WallpaperEngine/Assets/AssetLocator.h
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "WallpaperEngine/FileSystem/Container.h"
|
||||
|
||||
namespace WallpaperEngine::Assets {
|
||||
using namespace WallpaperEngine::FileSystem;
|
||||
using namespace WallpaperEngine::Data::Model;
|
||||
class AssetLocator {
|
||||
public:
|
||||
explicit AssetLocator (ContainerUniquePtr filesystem);
|
||||
|
||||
std::string vertexShader (const std::filesystem::path& filename) const;
|
||||
std::string fragmentShader (const std::filesystem::path& filename) const;
|
||||
std::string includeShader (const std::filesystem::path& filename) const;
|
||||
ReadStreamSharedPtr texture (const std::filesystem::path& filename) const;
|
||||
std::string readString (const std::filesystem::path& filename) const;
|
||||
ReadStreamSharedPtr read (const std::filesystem::path& path) const;
|
||||
std::filesystem::path physicalPath (const std::filesystem::path& path) const;
|
||||
|
||||
private:
|
||||
std::string shader (const std::filesystem::path& filename) const;
|
||||
|
||||
ContainerUniquePtr m_filesystem;
|
||||
};
|
||||
|
||||
using AssetLocatorUniquePtr = std::unique_ptr<AssetLocator>;
|
||||
}
|
@ -35,7 +35,6 @@ enum DepthwriteMode {
|
||||
};
|
||||
|
||||
struct MaterialPass {
|
||||
// TODO: WRITE ENUMS FOR THESE
|
||||
/** Blending mode */
|
||||
BlendingMode blending;
|
||||
/** Culling mode */
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -4,9 +4,10 @@
|
||||
#include <memory>
|
||||
|
||||
#include "Types.h"
|
||||
#include "WallpaperEngine/FileSystem/Container.h"
|
||||
#include "WallpaperEngine/Assets/AssetLocator.h"
|
||||
|
||||
namespace WallpaperEngine::Data::Model {
|
||||
using namespace WallpaperEngine::Assets;
|
||||
/**
|
||||
* Represents a wallpaper engine project
|
||||
*/
|
||||
@ -30,7 +31,7 @@ struct Project {
|
||||
Properties properties;
|
||||
/** The wallpaper this project defines */
|
||||
WallpaperUniquePtr wallpaper;
|
||||
/** VFS to access the project's files */
|
||||
ContainerUniquePtr container;
|
||||
/** Abstraction over asset loading to provide access to them */
|
||||
AssetLocatorUniquePtr assetLocator;
|
||||
};
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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>;
|
||||
|
@ -10,7 +10,7 @@ using namespace WallpaperEngine::Data::Parsers;
|
||||
using namespace WallpaperEngine::Data::Model;
|
||||
|
||||
EffectUniquePtr EffectParser::load (const Project& project, const std::string& filename) {
|
||||
const auto effectJson = JSON::parse (project.container->readString (filename));
|
||||
const auto effectJson = JSON::parse (project.assetLocator->readString (filename));
|
||||
|
||||
return parse (effectJson, project);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ using namespace WallpaperEngine::Data::Parsers;
|
||||
using namespace WallpaperEngine::Data::Model;
|
||||
|
||||
MaterialUniquePtr MaterialParser::load (const Project& project, const std::string& filename) {
|
||||
const auto materialJson = JSON::parse (project.container->readString (filename));
|
||||
const auto materialJson = JSON::parse (project.assetLocator->readString (filename));
|
||||
|
||||
return parse (materialJson, filename);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ using namespace WallpaperEngine::Data::Parsers;
|
||||
using namespace WallpaperEngine::Data::Model;
|
||||
|
||||
ModelUniquePtr ModelParser::load (const Project& project, const std::string& filename) {
|
||||
const auto model = JSON::parse (project.container->readString (filename));
|
||||
const auto model = JSON::parse (project.assetLocator->readString (filename));
|
||||
|
||||
return parse (model, project, filename);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ using namespace WallpaperEngine::Data::Parsers;
|
||||
|
||||
static int backgroundId = 0;
|
||||
|
||||
ProjectUniquePtr ProjectParser::parse (const JSON& data, ContainerUniquePtr container) {
|
||||
ProjectUniquePtr ProjectParser::parse (const JSON& data, AssetLocatorUniquePtr container) {
|
||||
const auto general = data.optional ("general");
|
||||
const auto workshopId = data.optional ("workshopid");
|
||||
auto actualWorkshopId = std::to_string (--backgroundId);
|
||||
@ -38,7 +38,7 @@ ProjectUniquePtr ProjectParser::parse (const JSON& data, ContainerUniquePtr cont
|
||||
.workshopId = actualWorkshopId,
|
||||
.supportsAudioProcessing = general.has_value () && general.value ().optional ("supportsaudioprocessing", false),
|
||||
.properties = parseProperties (general),
|
||||
.container = std::move(container),
|
||||
.assetLocator = std::move(container),
|
||||
});
|
||||
|
||||
result->wallpaper = WallpaperParser::parse (data.require ("file", "Project's main file missing"), *result);
|
||||
|
@ -4,10 +4,12 @@
|
||||
|
||||
#include "WallpaperEngine/Data/JSON.h"
|
||||
#include "WallpaperEngine/Data/Model/Project.h"
|
||||
#include "WallpaperEngine/Assets/AssetLocator.h"
|
||||
|
||||
namespace WallpaperEngine::Data::Parsers {
|
||||
using JSON = WallpaperEngine::Data::JSON::JSON;
|
||||
|
||||
using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::Data::Model;
|
||||
|
||||
/**
|
||||
@ -15,7 +17,7 @@ using namespace WallpaperEngine::Data::Model;
|
||||
*/
|
||||
class ProjectParser {
|
||||
public:
|
||||
static ProjectUniquePtr parse (const JSON& data, ContainerUniquePtr container);
|
||||
static ProjectUniquePtr parse (const JSON& data, AssetLocatorUniquePtr container);
|
||||
|
||||
private:
|
||||
static Project::Type parseType (const std::string& type);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ WallpaperUniquePtr WallpaperParser::parse (const JSON& file, Project& project) {
|
||||
}
|
||||
|
||||
SceneUniquePtr WallpaperParser::parseScene (const JSON& file, Project& project) {
|
||||
const auto scene = JSON::parse (project.container->readString (file));
|
||||
const auto scene = JSON::parse (project.assetLocator->readString (file));
|
||||
const auto camera = scene.require ("camera", "Scenes must have a camera section");
|
||||
const auto general = scene.require ("general", "Scenes must have a general section");
|
||||
const auto projection = general.require ("orthogonalprojection", "General section must have orthogonal projection info");
|
||||
|
@ -57,7 +57,7 @@ std::filesystem::path DirectoryAdapter::physicalPath (const std::filesystem::pat
|
||||
auto finalpath = std::filesystem::canonical(this->basepath / path);
|
||||
|
||||
if (finalpath.string ().find (this->basepath.string ()) != 0) {
|
||||
throw Render::AssetLoadException ("Cannot find file", path);
|
||||
throw std::filesystem::filesystem_error ("Cannot find file", path, std::error_code ());
|
||||
}
|
||||
|
||||
return finalpath;
|
||||
|
@ -45,7 +45,7 @@ bool PackageAdapter::exists (const std::filesystem::path& path) const {
|
||||
}
|
||||
|
||||
std::filesystem::path PackageAdapter::physicalPath (const std::filesystem::path& path) const {
|
||||
throw Render::AssetLoadException ("Package adapter does not support realpath", path);
|
||||
throw std::filesystem::filesystem_error ("Package adapter does not support realpath", path, std::error_code ());
|
||||
}
|
||||
|
||||
bool PackageFactory::handlesMountpoint (const std::filesystem::path& path) const {
|
||||
|
@ -22,7 +22,7 @@ bool VirtualAdapter::exists (const std::filesystem::path& path) const {
|
||||
}
|
||||
|
||||
std::filesystem::path VirtualAdapter::physicalPath (const std::filesystem::path& path) const {
|
||||
throw Render::AssetLoadException ("Virtual adapter does not support realpath", path);
|
||||
throw std::filesystem::filesystem_error ("Virtual adapter does not support realpath", path, std::error_code ());
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,7 +23,7 @@ struct VirtualAdapter final : Adapter {
|
||||
[[nodiscard]] std::filesystem::path physicalPath (const std::filesystem::path& path) const override;
|
||||
|
||||
void add (const std::filesystem::path& path, const char* data);
|
||||
void add (const std::filesystem::path& path, const JSON& contents);
|
||||
void add (const std::filesystem::path& path, const JSON& data);
|
||||
void add (const std::filesystem::path& path, const std::string& data);
|
||||
void add (const std::filesystem::path& path, MemoryStreamSharedPtr stream);
|
||||
|
||||
|
@ -81,7 +81,6 @@ std::filesystem::path Container::physicalPath (const std::filesystem::path& path
|
||||
return this->resolveAdapterForFile (path).physicalPath (normalized);
|
||||
}
|
||||
|
||||
|
||||
AdapterSharedPtr Container::mount (const std::filesystem::path& path, const std::filesystem::path& mountPoint) {
|
||||
// check if any adapter can handle the path
|
||||
for (const auto& factory : this->m_factories) {
|
||||
@ -92,7 +91,8 @@ AdapterSharedPtr Container::mount (const std::filesystem::path& path, const std:
|
||||
return this->m_mountpoints.emplace_back (mountPoint, factory->create (path)).second;
|
||||
}
|
||||
|
||||
sLog.exception("The specified mount (", path, ") cannot be handled by any of the filesystem adapters");
|
||||
throw std::filesystem::filesystem_error (
|
||||
"The specified mount cannot be handled by any of the filesystem adapters", path, std::error_code ());
|
||||
}
|
||||
|
||||
VirtualAdapter& Container::getVFS () const {
|
||||
@ -120,5 +120,5 @@ Adapter& Container::resolveAdapterForFile (const std::filesystem::path& path) co
|
||||
return this->resolveAdapterForFile ("/" + normalized.string());
|
||||
}
|
||||
|
||||
throw Render::AssetLoadException ("Cannot find requested file ", path);
|
||||
throw std::filesystem::filesystem_error ("Cannot find requested file in any of the mountpoints", path, std::error_code ());
|
||||
}
|
||||
|
@ -67,4 +67,6 @@ class Container {
|
||||
/** Virtual file system adapter */
|
||||
std::shared_ptr<VirtualAdapter> m_vfs;
|
||||
};
|
||||
|
||||
using ContainerUniquePtr = std::unique_ptr<Container>;
|
||||
}
|
@ -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;
|
||||
|
@ -15,8 +15,8 @@ Wallpapers::CScene& CObject::getScene () const {
|
||||
return this->m_scene;
|
||||
}
|
||||
|
||||
const Container& CObject::getContainer () const {
|
||||
return this->getScene ().getContainer ();
|
||||
const AssetLocator& CObject::getAssetLocator () const {
|
||||
return this->getScene ().getAssetLocator ();
|
||||
}
|
||||
|
||||
int CObject::getId () const {
|
||||
|
@ -36,7 +36,7 @@ class CObject : public Helpers::ContextAware {
|
||||
virtual void render () = 0;
|
||||
|
||||
[[nodiscard]] Wallpapers::CScene& getScene () const;
|
||||
[[nodiscard]] const Container& getContainer () const;
|
||||
[[nodiscard]] const AssetLocator& getAssetLocator () const;
|
||||
[[nodiscard]] int getId () const;
|
||||
|
||||
protected:
|
||||
|
@ -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) {
|
||||
|
@ -45,8 +45,8 @@ CWallpaper::CWallpaper (
|
||||
|
||||
CWallpaper::~CWallpaper () = default;
|
||||
|
||||
const Container& CWallpaper::getContainer () const {
|
||||
return *this->m_wallpaperData.project.container;
|
||||
const AssetLocator& CWallpaper::getAssetLocator () const {
|
||||
return *this->m_wallpaperData.project.assetLocator;
|
||||
}
|
||||
|
||||
const Wallpaper& CWallpaper::getWallpaperData () const {
|
||||
|
@ -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> ()) {
|
||||
@ -65,7 +70,7 @@ class CWallpaper : public Helpers::ContextAware, public FBOProvider {
|
||||
/**
|
||||
* @return The container to resolve files for this wallpaper
|
||||
*/
|
||||
[[nodiscard]] const Container& getContainer () const;
|
||||
[[nodiscard]] const AssetLocator& getAssetLocator () const;
|
||||
|
||||
/**
|
||||
* @return The current audio context for this wallpaper
|
||||
|
@ -39,7 +39,7 @@ X11FullScreenDetector::X11FullScreenDetector (
|
||||
try {
|
||||
// attempt casting to CGLFWOpenGLDriver, this will throw if it's not possible
|
||||
// so we can gracely handle the error
|
||||
dynamic_cast <GLFWOpenGLDriver&> (this->m_driver);
|
||||
std::ignore = dynamic_cast <GLFWOpenGLDriver&> (this->m_driver);
|
||||
} catch (std::exception&) {
|
||||
sLog.exception ("X11 FullScreen Detector initialized with the wrong video driver... This is a bug...");
|
||||
}
|
||||
|
@ -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
|
||||
@ -44,10 +44,9 @@ std::shared_ptr<CFBO> FBOProvider::alias (const std::string& newName, const std:
|
||||
}
|
||||
|
||||
std::shared_ptr<CFBO> FBOProvider::find (const std::string& name) const {
|
||||
const auto it = this->m_fbos.find (name);
|
||||
|
||||
if (it != this->m_fbos.end ())
|
||||
if (const auto it = this->m_fbos.find (name); it != this->m_fbos.end ()) {
|
||||
return it->second;
|
||||
}
|
||||
|
||||
if (this->m_parent == nullptr) {
|
||||
return nullptr;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -23,7 +23,7 @@ CSound::~CSound() {
|
||||
void CSound::load () {
|
||||
for (const auto& cur : this->m_sound.sounds) {
|
||||
uint32_t filesize = 0;
|
||||
auto filebuffer = this->getContainer ().read (cur);
|
||||
auto filebuffer = this->getAssetLocator ().read (cur);
|
||||
auto stream = new Audio::AudioStream (this->getScene ().getAudioContext (), filebuffer, filesize);
|
||||
|
||||
stream->setRepeat (this->m_sound.playbackmode.has_value() && this->m_sound.playbackmode == "loop");
|
||||
|
@ -427,16 +427,16 @@ void CPass::setupShaders () {
|
||||
// TODO: USED TO BUILD THE TEXTURES LATER
|
||||
// use the combos copied from the pass so it includes the texture format
|
||||
this->m_shader = new Render::Shaders::Shader (
|
||||
this->m_image.getContainer (), this->m_pass.shader, this->m_combos, this->m_override.combos,
|
||||
this->m_image.getAssetLocator (), this->m_pass.shader, this->m_combos, this->m_override.combos,
|
||||
this->m_pass.textures, this->m_override.textures, this->m_override.constants
|
||||
);
|
||||
|
||||
const auto shaders = Shaders::GLSLContext::get ().toGlsl (
|
||||
const auto [vertex, fragment] = Shaders::GLSLContext::get ().toGlsl (
|
||||
this->m_shader->vertex (), this->m_shader->fragment ());
|
||||
|
||||
// compile the shaders
|
||||
const GLuint vertexShaderID = compileShader (shaders.first.c_str (), GL_VERTEX_SHADER);
|
||||
const GLuint fragmentShaderID = compileShader (shaders.second.c_str (), GL_FRAGMENT_SHADER);
|
||||
const GLuint vertexShaderID = compileShader (vertex.c_str (), GL_VERTEX_SHADER);
|
||||
const GLuint fragmentShaderID = compileShader (fragment.c_str (), GL_FRAGMENT_SHADER);
|
||||
// create the final program
|
||||
this->m_programID = glCreateProgram ();
|
||||
// link the shaders together
|
||||
|
@ -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
|
||||
|
@ -105,15 +105,15 @@ TBuiltInResource BuiltInResource = {
|
||||
.maxTaskWorkGroupSizeZ_NV = 1,
|
||||
.maxMeshViewCountNV = 4,
|
||||
.limits = {
|
||||
.nonInductiveForLoops = 1,
|
||||
.whileLoops = 1,
|
||||
.doWhileLoops = 1,
|
||||
.generalUniformIndexing = 1,
|
||||
.generalAttributeMatrixVectorIndexing = 1,
|
||||
.generalVaryingIndexing = 1,
|
||||
.generalSamplerIndexing = 1,
|
||||
.generalVariableIndexing = 1,
|
||||
.generalConstantMatrixVectorIndexing = 1,
|
||||
.nonInductiveForLoops = true,
|
||||
.whileLoops = true,
|
||||
.doWhileLoops = true,
|
||||
.generalUniformIndexing = true,
|
||||
.generalAttributeMatrixVectorIndexing = true,
|
||||
.generalVaryingIndexing = true,
|
||||
.generalSamplerIndexing = true,
|
||||
.generalVariableIndexing = true,
|
||||
.generalConstantMatrixVectorIndexing = true,
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -10,62 +10,24 @@
|
||||
|
||||
#include "GLSLContext.h"
|
||||
#include "WallpaperEngine/Assets/AssetLoadException.h"
|
||||
#include "WallpaperEngine/Assets/AssetLocator.h"
|
||||
#include "WallpaperEngine/FileSystem/Container.h"
|
||||
|
||||
using namespace WallpaperEngine::Render;
|
||||
using namespace WallpaperEngine::Assets;
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders {
|
||||
// TODO: MOVE THIS INTO AN ASSET RESOLVER OR SOMETHING SIMILAR AS IT DOESN'T REALLY BELONG HERE BUT GETS THE CHANGESET OUT
|
||||
std::string readShader (const std::filesystem::path& filename, const Container& container) {
|
||||
std::filesystem::path shader = filename;
|
||||
auto it = shader.begin ();
|
||||
|
||||
// detect workshop shaders and check if there's a
|
||||
if (*it++ == "workshop") {
|
||||
const std::filesystem::path workshopId = *it++;
|
||||
|
||||
if (++it != shader.end ()) {
|
||||
const std::filesystem::path& shaderfile = *it;
|
||||
|
||||
try {
|
||||
shader = std::filesystem::path ("zcompat") / "scene" / "shaders" / workshopId / shaderfile;
|
||||
// replace the old path with the new one
|
||||
std::string contents = container.readString (shader);
|
||||
|
||||
sLog.out ("Replaced ", filename, " with compat ", shader);
|
||||
|
||||
return contents;
|
||||
} catch (AssetLoadException&) { }
|
||||
}
|
||||
}
|
||||
|
||||
return container.readString ("shaders" / filename);
|
||||
}
|
||||
|
||||
std::string readVertex (const std::filesystem::path& filename, const Container& container) {
|
||||
std::filesystem::path shader = filename;
|
||||
shader.replace_extension (".vert");
|
||||
return readShader (shader, container);
|
||||
}
|
||||
|
||||
std::string readFragment (const std::filesystem::path& filename, const Container& container) {
|
||||
std::filesystem::path shader = filename;
|
||||
shader.replace_extension (".frag");
|
||||
return readShader (shader, container);
|
||||
}
|
||||
|
||||
Shader::Shader (
|
||||
const Container& container, std::string filename,
|
||||
const AssetLocator& assetLocator, std::string filename,
|
||||
const ComboMap& combos, const ComboMap& overrideCombos,
|
||||
const TextureMap& textures, const TextureMap& overrideTextures,
|
||||
const ShaderConstantMap& constants
|
||||
) :
|
||||
m_vertex (
|
||||
GLSLContext::UnitType_Vertex, filename, readVertex (filename, container),
|
||||
container, constants, textures, overrideTextures, combos, overrideCombos),
|
||||
GLSLContext::UnitType_Vertex, filename, assetLocator.vertexShader (filename),
|
||||
assetLocator, constants, textures, overrideTextures, combos, overrideCombos),
|
||||
m_fragment (
|
||||
GLSLContext::UnitType_Fragment, filename, readFragment (filename, container),
|
||||
container, constants, textures, overrideTextures, combos, overrideCombos),
|
||||
GLSLContext::UnitType_Fragment, filename, assetLocator.fragmentShader (filename),
|
||||
assetLocator, constants, textures, overrideTextures, combos, overrideCombos),
|
||||
m_file (std::move (filename)),
|
||||
m_combos (combos),
|
||||
m_overrideCombos (overrideCombos),
|
||||
@ -76,7 +38,6 @@ Shader::Shader (
|
||||
this->m_fragment.linkToUnit (&this->m_vertex);
|
||||
}
|
||||
|
||||
|
||||
const std::string& Shader::vertex () {
|
||||
return this->m_vertex.compile ();
|
||||
}
|
||||
@ -97,7 +58,7 @@ const std::map<std::string, int>& Shader::getCombos () const {
|
||||
return this->m_combos;
|
||||
}
|
||||
|
||||
Shader::ParameterSearchResult Shader::findParameter (const std::string& name) {
|
||||
Shader::ParameterSearchResult Shader::findParameter (const std::string& name) const {
|
||||
Variables::ShaderVariable* vertex = nullptr;
|
||||
Variables::ShaderVariable* fragment = nullptr;
|
||||
|
||||
|
@ -31,7 +31,7 @@ class Shader {
|
||||
* the pre-processing and compilation of the shader, adding
|
||||
* required definitions if needed
|
||||
*
|
||||
* @param container The container to use for file lookup
|
||||
* @param assetLocator The asset locator where to ask for assets for
|
||||
* @param filename The file to load
|
||||
* @param combos Settings for the shader
|
||||
* @param overrideCombos List of override combos to use
|
||||
@ -40,7 +40,7 @@ class Shader {
|
||||
* @param constants Default values for shader variables
|
||||
*/
|
||||
Shader (
|
||||
const Container& container, std::string filename,
|
||||
const AssetLocator& assetLocator, std::string filename,
|
||||
const ComboMap& combos, const ComboMap& overrideCombos,
|
||||
const TextureMap& textures, const TextureMap& overrideTextures,
|
||||
const ShaderConstantMap& constants);
|
||||
@ -70,7 +70,7 @@ class Shader {
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] ParameterSearchResult findParameter (const std::string& name);
|
||||
[[nodiscard]] ParameterSearchResult findParameter (const std::string& name) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -53,7 +53,7 @@ using namespace WallpaperEngine::Data::Builders;
|
||||
using namespace WallpaperEngine::Render::Shaders;
|
||||
|
||||
ShaderUnit::ShaderUnit (
|
||||
GLSLContext::UnitType type, std::string file, std::string content, const Container& container,
|
||||
GLSLContext::UnitType type, std::string file, std::string content, const AssetLocator& assetLocator,
|
||||
const ShaderConstantMap& constants, const TextureMap& passTextures, const TextureMap& overrideTextures,
|
||||
const ComboMap& combos, const ComboMap& overrideCombos
|
||||
) :
|
||||
@ -66,7 +66,7 @@ ShaderUnit::ShaderUnit (
|
||||
m_passTextures (passTextures),
|
||||
m_overrideTextures (overrideTextures),
|
||||
m_link (nullptr),
|
||||
m_container (container) {
|
||||
m_assetLocator (assetLocator) {
|
||||
// pre-process the shader so the units are clear
|
||||
this->preprocess ();
|
||||
}
|
||||
@ -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_container.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_container.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, "//");
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "GLSLContext.h"
|
||||
#include "WallpaperEngine/Data/JSON.h"
|
||||
#include "WallpaperEngine/Assets/AssetLocator.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
@ -13,7 +14,7 @@
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders {
|
||||
using JSON = WallpaperEngine::Data::JSON::JSON;
|
||||
using namespace WallpaperEngine::FileSystem;
|
||||
using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::Data::Model;
|
||||
|
||||
/**
|
||||
@ -22,7 +23,7 @@ using namespace WallpaperEngine::Data::Model;
|
||||
class ShaderUnit {
|
||||
public:
|
||||
ShaderUnit (
|
||||
GLSLContext::UnitType type, std::string file, std::string content, const Container& container,
|
||||
GLSLContext::UnitType type, std::string file, std::string content, const AssetLocator& assetLocator,
|
||||
const ShaderConstantMap& constants, const TextureMap& passTextures,
|
||||
const TextureMap& overrideTextures, const ComboMap& combos, const ComboMap& overrideCombos);
|
||||
~ShaderUnit () = default;
|
||||
@ -158,6 +159,6 @@ class ShaderUnit {
|
||||
/**
|
||||
* The container to source files from
|
||||
*/
|
||||
const Container& m_container;
|
||||
const AssetLocator& m_assetLocator;
|
||||
};
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ std::shared_ptr<const TextureProvider> TextureCache::resolve (const std::string&
|
||||
// search for the texture in all the different containers just in case
|
||||
for (const auto& [name, project] : this->getContext ().getApp ().getBackgrounds ()) {
|
||||
try {
|
||||
auto contents = project->container->read (finalFilename);
|
||||
auto contents = project->assetLocator->read (finalFilename);
|
||||
auto stream = BinaryReader (contents);
|
||||
|
||||
auto parsedTexture = TextureParser::parse (stream);
|
||||
@ -39,7 +39,7 @@ std::shared_ptr<const TextureProvider> TextureCache::resolve (const std::string&
|
||||
}
|
||||
}
|
||||
|
||||
throw AssetLoadException (filename, "Cannot find file");
|
||||
throw AssetLoadException ("Cannot find file", filename, std::error_code ());
|
||||
}
|
||||
|
||||
void TextureCache::store (const std::string& name, std::shared_ptr<const TextureProvider> texture) {
|
||||
|
@ -57,7 +57,7 @@ CVideo::CVideo (
|
||||
sLog.exception ("Failed to initialize MPV's GL context");
|
||||
|
||||
const std::filesystem::path videopath =
|
||||
this->getVideo ().project.container->physicalPath (this->getVideo ().filename);
|
||||
this->getVideo ().project.assetLocator->physicalPath (this->getVideo ().filename);
|
||||
|
||||
// build the path to the video file
|
||||
const char* command [] = {"loadfile", videopath.c_str (), nullptr};
|
||||
|
@ -9,7 +9,7 @@ namespace WallpaperEngine::Render::Wallpapers {
|
||||
class CVideo final : public CWallpaper {
|
||||
public:
|
||||
CVideo (
|
||||
const Wallpaper& video, RenderContext& context, AudioContext& audioContext,
|
||||
const Wallpaper& wallpaper, RenderContext& context, AudioContext& audioContext,
|
||||
const WallpaperState::TextureUVsScaling& scalingMode,
|
||||
const uint32_t& clampMode);
|
||||
|
||||
|
@ -7,12 +7,11 @@
|
||||
|
||||
#include "WallpaperEngine/Data/Model/Project.h"
|
||||
|
||||
using namespace WallpaperEngine::Render;
|
||||
using namespace WallpaperEngine::WebBrowser::CEF;
|
||||
|
||||
WPSchemeHandler::WPSchemeHandler(const Project& project) :
|
||||
m_project (project),
|
||||
m_container (*this->m_project.container) {
|
||||
m_assetLoader (*this->m_project.assetLocator) {
|
||||
}
|
||||
|
||||
bool WPSchemeHandler::Open(CefRefPtr<CefRequest> request,
|
||||
@ -48,7 +47,7 @@ bool WPSchemeHandler::Open(CefRefPtr<CefRequest> request,
|
||||
this->m_mimeType = mime;
|
||||
}
|
||||
|
||||
this->m_contents = this->m_container.read (file);
|
||||
this->m_contents = this->m_assetLoader.read (file);
|
||||
callback->Continue ();
|
||||
} catch (AssetLoadException&) {
|
||||
#if !NDEBUG
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "WallpaperEngine/FileSystem/Container.h"
|
||||
#include "WallpaperEngine/Assets/AssetLocator.h"
|
||||
|
||||
#include "include/cef_resource_handler.h"
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
@ -13,7 +13,7 @@ struct Project;
|
||||
|
||||
namespace WallpaperEngine::WebBrowser::CEF {
|
||||
|
||||
using namespace WallpaperEngine::FileSystem;
|
||||
using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::Data::Model;
|
||||
|
||||
/**
|
||||
@ -39,7 +39,7 @@ class WPSchemeHandler : public CefResourceHandler {
|
||||
private:
|
||||
const Project& m_project;
|
||||
|
||||
const Container& m_container;
|
||||
const AssetLocator& m_assetLoader;
|
||||
ReadStreamSharedPtr m_contents = nullptr;
|
||||
std::string m_mimeType;
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "include/cef_scheme.h"
|
||||
|
||||
namespace WallpaperEngine::Data::Model {
|
||||
class Project;
|
||||
struct Project;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::WebBrowser::CEF {
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
shopt -s globstar
|
||||
clang-tidy --format-style file src/**/*.cpp -p cmake-build-debug
|
||||
clang-tidy --format-style file src/WallpaperEngine/**/*.cpp src/*.cpp src/Steam/**/*.cpp -p cmake-build-debug
|
Loading…
Reference in New Issue
Block a user