3
0

GameStateMainMenu.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <GameState/GameState.h>
  10. #include <GameStateSamples/GameStateLocalUserLobby.h>
  11. #include <AzCore/std/smart_ptr/unique_ptr.h>
  12. #include <ISystem.h>
  13. ////////////////////////////////////////////////////////////////////////////////////////////////////
  14. namespace GameStateSamples
  15. {
  16. ////////////////////////////////////////////////////////////////////////////////////////////////
  17. //! Game state that is active while displaying the main game menu (or another front-end menu).
  18. class GameStateMainMenu : public GameState::IGameState
  19. , public ISystemEventListener
  20. {
  21. public:
  22. ////////////////////////////////////////////////////////////////////////////////////////////
  23. // Allocator
  24. AZ_CLASS_ALLOCATOR(GameStateMainMenu, AZ::SystemAllocator);
  25. ////////////////////////////////////////////////////////////////////////////////////////////
  26. // Type Info
  27. AZ_RTTI(GameStateMainMenu, "{53EB59EC-77F1-4C8E-AC5F-B2A94F15AF31}", IGameState);
  28. ////////////////////////////////////////////////////////////////////////////////////////////
  29. //! Default constructor
  30. GameStateMainMenu() = default;
  31. ////////////////////////////////////////////////////////////////////////////////////////////
  32. //! Default destructor
  33. ~GameStateMainMenu() override = default;
  34. protected:
  35. ////////////////////////////////////////////////////////////////////////////////////////////
  36. //! \ref GameState::GameState::OnPushed
  37. void OnPushed() override;
  38. ////////////////////////////////////////////////////////////////////////////////////////////
  39. //! \ref GameState::GameState::OnPopped
  40. void OnPopped() override;
  41. ////////////////////////////////////////////////////////////////////////////////////////////
  42. //! \ref GameState::GameState::OnEnter
  43. void OnEnter() override;
  44. ////////////////////////////////////////////////////////////////////////////////////////////
  45. //! \ref GameState::GameState::OnExit
  46. void OnExit() override;
  47. ////////////////////////////////////////////////////////////////////////////////////////////
  48. //! \ref GameState::GameState::OnUpdate
  49. void OnUpdate() override;
  50. ////////////////////////////////////////////////////////////////////////////////////////////
  51. //! \ref ISystemEventListener::OnSystemEvent
  52. void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) override;
  53. ////////////////////////////////////////////////////////////////////////////////////////////
  54. //! Convenience functions to load and unload the main game menu UI canvas.
  55. ///@{
  56. virtual void LoadMainMenuCanvas();
  57. virtual void UnloadMainMenuCanvas();
  58. virtual const char* GetMainMenuCanvasAssetPath();
  59. ///@}
  60. ////////////////////////////////////////////////////////////////////////////////////////////
  61. //! Refresh the list of levels displayed in the main menu.
  62. virtual void RefreshLevelListDisplay();
  63. ////////////////////////////////////////////////////////////////////////////////////////////
  64. //! Load options from persistent storage, which is done upon first entry into the main menu.
  65. virtual void LoadGameOptionsFromPersistentStorage();
  66. protected:
  67. ////////////////////////////////////////////////////////////////////////////////////////////
  68. // Variables
  69. AZStd::unique_ptr<GameStateLocalUserLobby> m_localUserLobbySubState;
  70. AZ::EntityId m_mainMenuCanvasEntityId;
  71. bool m_shouldRefreshLevelListDisplay = false;
  72. };
  73. } // namespace GameStateSamples
  74. // Include the implementation inline so the class can be instantiated outside of the gem.
  75. #include <GameStateSamples/GameStateMainMenu.inl>