CApplicationContext.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #pragma once
  2. #include <filesystem>
  3. #include <map>
  4. #include <string>
  5. #include <vector>
  6. #include <glm/vec4.hpp>
  7. #include <FreeImage.h>
  8. #include "CApplicationState.h"
  9. #include "WallpaperEngine/Assets/ITexture.h"
  10. #include "WallpaperEngine/Render/CWallpaperState.h"
  11. namespace WallpaperEngine::Application {
  12. /**
  13. * Application information as parsed off the command line arguments
  14. */
  15. class CApplicationContext {
  16. public:
  17. CApplicationContext (int argc, char* argv []);
  18. enum WINDOW_MODE {
  19. /** Default window mode */
  20. NORMAL_WINDOW = 0,
  21. /** Draw to the window server desktop */
  22. DESKTOP_BACKGROUND = 1,
  23. /** Explicit window mode with specified geometry */
  24. EXPLICIT_WINDOW = 2,
  25. };
  26. struct {
  27. /**
  28. * General settings
  29. */
  30. struct {
  31. /** If the user requested a list of properties for the given background */
  32. bool onlyListProperties;
  33. /** The path to the assets folder */
  34. std::filesystem::path assets;
  35. /** Background to load (provided as the final argument) as fallback for multi-screen setups */
  36. std::filesystem::path defaultBackground;
  37. /** The backgrounds specified for different screens */
  38. std::map<std::string, std::filesystem::path> screenBackgrounds;
  39. /** Properties to change values for */
  40. std::map<std::string, std::string> properties;
  41. /** The scaling mode for different screens */
  42. std::map<std::string, WallpaperEngine::Render::CWallpaperState::TextureUVsScaling> screenScalings;
  43. } general;
  44. /**
  45. * Render settings
  46. */
  47. struct {
  48. /** The mode to run the background in */
  49. WINDOW_MODE mode;
  50. /** Maximum FPS */
  51. int maximumFPS;
  52. /** Indicates if pausing should happen when something goes fullscreen */
  53. bool pauseOnFullscreen;
  54. struct {
  55. /** The window size used in explicit window */
  56. glm::ivec4 geometry;
  57. WallpaperEngine::Assets::ITexture::TextureFlags clamp;
  58. WallpaperEngine::Render::CWallpaperState::TextureUVsScaling scalingMode;
  59. } window;
  60. } render;
  61. /**
  62. * Audio settings
  63. */
  64. struct {
  65. /** If the audio system is enabled */
  66. bool enabled;
  67. /** Sound volume (0-128) */
  68. int volume;
  69. /** If the audio must be muted if something else is playing sound */
  70. bool automute;
  71. /** If audio processing can be enabled or not */
  72. bool audioprocessing;
  73. } audio;
  74. /**
  75. * Mouse input settings
  76. */
  77. struct {
  78. /** If the mouse movement is enabled */
  79. bool enabled;
  80. } mouse;
  81. /**
  82. * Screenshot settings
  83. */
  84. struct {
  85. /** If an screenshot should be taken */
  86. bool take;
  87. /** The path to where the screenshot must be saved */
  88. std::filesystem::path path;
  89. /** The image format */
  90. FREE_IMAGE_FORMAT format;
  91. } screenshot;
  92. } settings;
  93. CApplicationState state;
  94. private:
  95. /**
  96. * Validates the assets folder and ensures a valid one is present
  97. */
  98. void validateAssets ();
  99. /**
  100. * Validates the screenshot settings
  101. */
  102. void validateScreenshot ();
  103. /**
  104. * Validates a background parameter and returns the real bgIdOrPath to it
  105. *
  106. * @param bgIdOrPath
  107. * @return
  108. */
  109. static std::filesystem::path translateBackground (const std::string& bgIdOrPath);
  110. /**
  111. * Prints the normal help message
  112. */
  113. static void printHelp (const char* route);
  114. };
  115. } // namespace WallpaperEngine::Application