movement_settings_store.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include <cstdint>
  3. namespace sunrise::client::movement {
  4. /** Default distance, in world units along the camera's forward vector. */
  5. inline constexpr float kDefaultDistance = 10.0F;
  6. /** Smallest offered distance. Zero would leave the key bound to nothing visible. */
  7. inline constexpr float kMinimumDistance = 1.0F;
  8. /** Largest offered distance. Past this a press reliably lands through a wall or the floor. */
  9. inline constexpr float kMaximumDistance = 100.0F;
  10. /** No key is bound until one is picked, so a fresh install cannot fire a movement feature. */
  11. inline constexpr std::uint32_t kNoKey = 0;
  12. /** Space is the stock jump binding, and the one the sword skate fix has to watch to do anything. */
  13. inline constexpr std::uint32_t kDefaultJumpKey = 0x20;
  14. /** Runtime movement configuration. This module owns it; Core settings do not carry it. */
  15. struct Settings {
  16. bool enabled{false};
  17. float distance{kDefaultDistance};
  18. std::uint32_t virtualKey{kNoKey};
  19. bool noclipEnabled{false};
  20. std::uint32_t noclipToggleKey{kNoKey};
  21. bool swordSkateEnabled{false};
  22. /** The player's jump key. The refusal is only cleared on the tick this key goes down. */
  23. std::uint32_t swordSkateJumpKey{kDefaultJumpKey};
  24. };
  25. /**
  26. * Resolves the configuration file and loads it when one exists.
  27. * @param module Loaded DLL used to resolve the owned artifact directory.
  28. */
  29. void initialize(void* module) noexcept;
  30. /** Drops the runtime configuration and the resolved file path. */
  31. void shutdown() noexcept;
  32. /** @return One lock-consistent copy of the current configuration. */
  33. [[nodiscard]] Settings get() noexcept;
  34. /**
  35. * Publishes one configuration and writes it straight to disk.
  36. * @param settings Candidate configuration, refused when a field is out of range.
  37. * @return True when the value was published. A failed write is logged, not returned.
  38. */
  39. bool publish(const Settings& settings) noexcept;
  40. } // namespace sunrise::client::movement