#pragma once #include "WallpaperEngine/Application/CApplicationContext.h" #include "WallpaperEngine/Assets/CCombinedContainer.h" #include "WallpaperEngine/Core/CProject.h" #include "WallpaperEngine/Render/CWallpaper.h" #include "WallpaperEngine/Render/CRenderContext.h" #include "WallpaperEngine/Render/Drivers/CX11OpenGLDriver.h" #ifdef ENABLE_WAYLAND #include "WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.h" #endif #include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h" #ifdef ENABLE_WAYLAND #include "WallpaperEngine/Render/Drivers/Detectors/CWaylandFullScreenDetector.h" #endif #include "WallpaperEngine/Render/Drivers/Output/CGLFWWindowOutput.h" #include "WallpaperEngine/Render/Drivers/Output/CX11Output.h" #ifdef ENABLE_WAYLAND #include "WallpaperEngine/Render/Drivers/Output/CWaylandOutput.h" #endif #include "WallpaperEngine/Audio/Drivers/CSDLAudioDriver.h" #include "WallpaperEngine/Input/CInputContext.h" namespace WallpaperEngine::Application { /** * Small wrapper class over the actual wallpaper's main application skeleton * * @author Alexis Maiquez */ class CWallpaperApplication { public: explicit CWallpaperApplication (CApplicationContext& context); /** * Shows the application until it's closed */ void show (); /** * Handles a OS signal sent to this PID * * @param signal */ void signal (int signal); /** * @return Maps screens to loaded backgrounds */ [[nodiscard]] const std::map & getBackgrounds () const; /** * @return The default background to use if no specific project is loaded */ [[nodiscard]] Core::CProject* getDefaultBackground () const; /** * @return The current application context */ [[nodiscard]] CApplicationContext& getContext () const; /** * Renders a frame */ void renderFrame(); /** * Gets the output */ WallpaperEngine::Render::Drivers::Output::COutput* getOutput() const; private: /** * Sets up a combined container for the given background, adding default files and directories to the list * * @param container * @param bg */ void setupContainer (CCombinedContainer& container, const std::string& bg) const; /** * Loads projects based off the settings */ void loadBackgrounds (); /** * Loads the given project * * @param bg * @return */ Core::CProject* loadBackground (const std::string& bg); /** * Prepares all background's values and updates their properties if required */ void setupProperties (); /** * Updates the properties for the given background based on the current context * * @param project */ void setupPropertiesForProject (Core::CProject* project); /** * Takes an screenshot of the background and saves it to the specified path * * @param context * @param filename * @param format */ static void takeScreenshot (const Render::CRenderContext& context, const std::filesystem::path& filename, FREE_IMAGE_FORMAT format); /** The default background to display if no specific background was loaded */ Core::CProject* m_defaultBackground; /** The application context that contains the current app settings */ CApplicationContext& m_context; /** Maps screens to backgrounds */ std::map m_backgrounds; std::unique_ptr videoDriver; std::unique_ptr inputContext; WallpaperEngine::Render::Drivers::Output::COutput* output; std::unique_ptr fullscreenDetector; std::unique_ptr audioDriver; std::unique_ptr context; std::unique_ptr audioContext; }; }