Procházet zdrojové kódy

Fix the GameStateSamples Gem and remove an unused variable from DebugConsole.h (#3347)

Signed-off-by: bosnichd <[email protected]>
bosnichd před 4 roky
rodič
revize
cef82f0313

+ 0 - 1
Gems/AtomLyIntegration/ImguiAtom/Code/Source/DebugConsole.h

@@ -122,7 +122,6 @@ namespace AZ
         int m_currentHistoryIndex = -1; //!< The current index into the input history when browsing.
         int m_maxEntriesToDisplay = DefaultMaxEntriesToDisplay; //!< The maximum entries to display.
         int m_maxInputHistorySize = DefaultMaxInputHistorySize; //!< The maximum input history size.
-        int m_logLevelToSet = 0; //!< The minimum log level to set (see AZ::LogLevel).
         bool m_isShowing = false; //!< Is the debug console currently being displayed?
         bool m_autoScroll = true; //!< Should we auto-scroll as new entries are added?
         bool m_forceScroll = false; //!< Do we need to force scroll after input entered?

+ 2 - 4
Gems/GameState/Code/CMakeLists.txt

@@ -17,8 +17,8 @@ ly_add_target(
         PUBLIC
             Include
     BUILD_DEPENDENCIES
-        PRIVATE
-            Legacy::CryCommon
+        PUBLIC
+            AZ::AzCore
 )
 
 ly_add_target(
@@ -33,7 +33,6 @@ ly_add_target(
             Include
     BUILD_DEPENDENCIES
         PRIVATE
-            Legacy::CryCommon
             Gem::GameState.Static
 )
 
@@ -58,7 +57,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
         BUILD_DEPENDENCIES
             PRIVATE
                 AZ::AzTest
-                Legacy::CryCommon
                 Gem::GameState.Static
     )
     ly_add_googletest(

+ 5 - 3
Gems/GameStateSamples/Code/CMakeLists.txt

@@ -21,6 +21,7 @@ ly_add_target(
         INTERFACE
             Gem::GameState
             Gem::LocalUser
+            Gem::LyShine.Static
             Gem::SaveData.Static
             Gem::MessagePopup.Static
             Legacy::CryCommon
@@ -47,6 +48,7 @@ ly_add_target(
         Gem::LmbrCentral
 )
 
-# Clients and Servers use the above module.  There is no editor or tools module required.
-ly_create_alias(NAME GameStateSamples.Clients  NAMESPACE Gem TARGETS GameStateSamples)
-ly_create_alias(NAME GameStateSamples.Servers  NAMESPACE Gem TARGETS GameStateSamples)
+# Clients and Servers use the above module, and it contains assets so is needed by builders.
+ly_create_alias(NAME GameStateSamples.Clients  NAMESPACE Gem TARGETS Gem::GameStateSamples)
+ly_create_alias(NAME GameStateSamples.Servers  NAMESPACE Gem TARGETS Gem::GameStateSamples)
+ly_create_alias(NAME GameStateSamples.Builders NAMESPACE Gem TARGETS Gem::UiBasics.Builders Gem::LyShineExamples.Builders)

+ 18 - 0
Gems/GameStateSamples/Code/Source/GameStateSamplesModule.cpp

@@ -7,6 +7,7 @@
  */
 
 #include <AzCore/Component/ComponentApplicationBus.h>
+#include <AzCore/Component/TickBus.h>
 #include <AzCore/Memory/SystemAllocator.h>
 #include <AzCore/Module/Module.h>
 #include <AzCore/std/smart_ptr/make_shared.h>
@@ -55,6 +56,7 @@ namespace GameStateSamples
     //!
     class GameStateSamplesModule
         : public CryHooksModule
+        , public AZ::TickBus::Handler
         , public GameOptionRequestBus::Handler
     {
     public:
@@ -86,6 +88,22 @@ namespace GameStateSamples
         {
             CryHooksModule::OnCrySystemInitialized(system, systemInitParams);
 
+            AZ::TickBus::Handler::BusConnect();
+        }
+
+        void OnTick([[maybe_unused]]float deltaTime, [[maybe_unused]]AZ::ScriptTimePoint scriptTimePoint) override
+        {
+            // Ideally this would be called at startup (either above in OnCrySystemInitialized, or better during AZ system component
+            // initialisation), but because the initial game state depends on loading a UI canvas using LYShine we need to wait until
+            // the first tick, because LyShine in turn is not properly initialized until UiRenderer::OnBootstrapSceneReady has been
+            // called, which doesn't happen until a queued tick event that gets called right at the end of initialisation before we
+            // enter the main game loop.
+            CreateAndPushInitialGameState();
+            AZ::TickBus::Handler::BusDisconnect();
+        }
+
+        void CreateAndPushInitialGameState()
+        {
             REGISTER_INT("sys_primaryUserSelectionEnabled", 2, VF_NULL,
                          "Controls whether the game forces selection of a primary user at startup.\n"
                          "0 : Skip selection of a primary user at startup on all platform.\n"