client_ui_module_runtime.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "client_ui_module_runtime.h"
  2. #include <string_view>
  3. #include "../../../core/ui/modules/registry/ui_module_registry.h"
  4. #include "../../../core/ui/modules/ui_module_descriptor.h"
  5. #include "../mission_launch/mission_launch_panel.h"
  6. #include "../movement/movement_panel.h"
  7. #include "../player/player_panel.h"
  8. namespace sunrise::client::ui::runtime {
  9. namespace {
  10. /** Namespaced stable IDs prevent Client modules from colliding with Server modules. */
  11. constexpr std::string_view kMovementStableId = "client.movement";
  12. constexpr std::string_view kPlayerStableId = "client.player";
  13. /** Short menu label for the shared teleport and noclip page. */
  14. constexpr std::string_view kMovementDisplayName = "Movement";
  15. /** Short menu label for the player page. */
  16. constexpr std::string_view kPlayerDisplayName = "Player";
  17. core::ui::modules::registry::PageRegistration g_movementPage;
  18. core::ui::modules::registry::PageRegistration g_playerPage;
  19. core::ui::modules::registry::PageRegistration g_activityLauncherPage;
  20. } // namespace
  21. /** @return True when the Client modules own their Core UI registry slots. */
  22. bool initialize() noexcept {
  23. // Registered after movement, which is the order the menu lists them in.
  24. const bool movementOwned = g_movementPage.acquire(
  25. core::ui::modules::Owner::client, kMovementStableId, kMovementDisplayName, &movement::draw);
  26. const bool playerOwned = g_playerPage.acquire(
  27. core::ui::modules::Owner::client, kPlayerStableId, kPlayerDisplayName, &player::draw);
  28. const bool launcherOwned = g_activityLauncherPage.acquire(core::ui::modules::Owner::client,
  29. "client.mission_launch",
  30. "Activity Launcher",
  31. &mission_launch::draw);
  32. return movementOwned && playerOwned && launcherOwned;
  33. }
  34. /** Removes the Client modules from the Core UI registry. */
  35. void shutdown() noexcept {
  36. g_activityLauncherPage.release();
  37. g_playerPage.release();
  38. g_movementPage.release();
  39. }
  40. } // namespace sunrise::client::ui::runtime