settings.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 the optional full-estate activity SDK generator. */
  13. struct ActivitySdkGenerationSettings final {
  14. /** Allows generation work to be requested. Off unless the settings file opts in. */
  15. bool enabled{false};
  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 = 13;
  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. /** Completes released exotic weapon catalysts while resolving client item state. */
  33. bool completeExoticCatalysts{true};
  34. /** Core-owned sink and channel policy. */
  35. log::Settings logging;
  36. /** Core-owned boot gate for activity SDK generation. */
  37. ActivitySdkGenerationSettings activitySdkGeneration;
  38. /** Options used only by the Client layer. */
  39. client::Settings client;
  40. /** Options used only by the Server layer. */
  41. server::Settings server;
  42. /** Options used only by the Steam compatibility layer. */
  43. steam::Settings steam;
  44. /** Complete authored account State, or an empty account. */
  45. state::AccountState initialAccount;
  46. /** Small local destination fallback published when State starts. */
  47. state::activity::defaults::ActivityDefaults initialActivityDefaults;
  48. /** Authored acquired-flag and objective policy published into the account object. */
  49. state::unlocks::Table initialUnlocks;
  50. /** Authored family-5 unlock overrides. Only the two override lists are authored here. */
  51. state::Family5State initialFamily5;
  52. };
  53. /** @return The complete default settings. */
  54. [[nodiscard]] Settings defaults() noexcept;
  55. /**
  56. * Parses supported JSON settings on top of the defaults.
  57. * @param json Complete settings text.
  58. * @param output Receives the settings only after the whole document is valid.
  59. * @return True when the document matches the supported settings.
  60. */
  61. [[nodiscard]] bool parse(std::string_view json, Settings& output) noexcept;
  62. /**
  63. * Loads the settings file next to the module when it is there.
  64. * @param module Loaded DLL, used to find the settings path.
  65. * @return True when defaults or a valid settings file are active.
  66. */
  67. [[nodiscard]] bool initialize(void* module) noexcept;
  68. /** Resets active settings to the fixed defaults. */
  69. void shutdown() noexcept;
  70. /** @return Active read-only Core settings. */
  71. [[nodiscard]] const Settings& get() noexcept;
  72. } // namespace sunrise::core::settings