settings.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include <string_view>
  3. #include "../../state/account/account_state.h"
  4. #include "../../state/activity/defaults/definition.h"
  5. #include "../../state/investment/investment.h"
  6. #include "../../state/unlocks/definition.h"
  7. #include "../logging/log.h"
  8. #include "client/definition.h"
  9. #include "server/definition.h"
  10. #include "steam/definition.h"
  11. namespace sunrise::core::settings {
  12. /** Boot policy for generating the activity SDK required by host roster construction. */
  13. struct ActivitySdkGenerationSettings final {
  14. /** On by default like the bundled file, so a file without this block still generates. */
  15. bool enabled{true};
  16. /** Writes the sdk/lua declaration tree. On by default, and only runs when generation does. */
  17. bool luaDeclarations{true};
  18. };
  19. /**
  20. * Layout version of the settings file this build writes and expects.
  21. * Raise it when a key is renamed, removed, changes meaning, or must take a new default. Adding a
  22. * key needs no raise, because a missing key already takes its default.
  23. */
  24. inline constexpr std::uint32_t kSettingsVersion = 16;
  25. /** Parsed read-only process settings. */
  26. struct Settings {
  27. /**
  28. * Layout version the file was written against. Zero means the key was missing, which is
  29. * every file written before versioning. Checked against kSettingsVersion at load.
  30. */
  31. std::uint32_t version{};
  32. /**
  33. * Completes released exotic weapon catalysts while resolving client item state.
  34. * Authored under `state.investment`, with the rest of the investment content policy.
  35. */
  36. bool completeExoticCatalysts{true};
  37. /** Core-owned sink and channel policy. */
  38. log::Settings logging;
  39. /** Core-owned boot gate for activity SDK generation. */
  40. ActivitySdkGenerationSettings activitySdkGeneration;
  41. /** Options used only by the Client layer. */
  42. client::Settings client;
  43. /** Options used only by the Server layer. */
  44. server::Settings server;
  45. /** Options used only by the Steam compatibility layer. */
  46. steam::Settings steam;
  47. /** Complete authored account State, or an empty account. */
  48. state::AccountState initialAccount;
  49. /** Small local destination fallback published when State starts. */
  50. state::activity::defaults::ActivityDefaults initialActivityDefaults;
  51. /** Authored acquired-flag and objective policy published into the account object. */
  52. state::unlocks::Table initialUnlocks;
  53. /** Authored family-5 unlock overrides. Only the two override lists are authored here. */
  54. state::Family5State initialFamily5;
  55. };
  56. /** @return The complete default settings. */
  57. [[nodiscard]] Settings defaults() noexcept;
  58. /**
  59. * Parses supported JSON settings on top of the defaults.
  60. * @param json Complete settings text.
  61. * @param output Receives the settings only after the whole document is valid.
  62. * @return True when the document matches the supported settings.
  63. */
  64. [[nodiscard]] bool parse(std::string_view json, Settings& output) noexcept;
  65. /**
  66. * Loads the settings file next to the module when it is there.
  67. * @param module Loaded DLL, used to find the settings path.
  68. * @return True when defaults or a valid settings file are active.
  69. */
  70. [[nodiscard]] bool initialize(void* module) noexcept;
  71. /** Resets active settings to the fixed defaults. */
  72. void shutdown() noexcept;
  73. /** @return Active read-only Core settings. */
  74. [[nodiscard]] const Settings& get() noexcept;
  75. } // namespace sunrise::core::settings