Files
o3de/Gems/GameStateSamples/Code/Include/GameStateSamples/GameStatePrimaryUserSelection.h
T
2021-03-08 14:30:57 -08:00

103 lines
5.3 KiB
C++

/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <GameState/GameState.h>
#include <AzFramework/Input/Events/InputChannelEventListener.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace GameStateSamples
{
////////////////////////////////////////////////////////////////////////////////////////////////
//! Game state that is active while waiting to determine who the primary user is.
class GameStatePrimaryUserSelection : public GameState::IGameState
, public AzFramework::InputChannelEventListener
{
public:
////////////////////////////////////////////////////////////////////////////////////////////
// Allocator
AZ_CLASS_ALLOCATOR(GameStatePrimaryUserSelection, AZ::SystemAllocator, 0);
////////////////////////////////////////////////////////////////////////////////////////////
// Type Info
AZ_RTTI(GameStatePrimaryUserSelection, "{953A3CBD-92BD-4B9A-9FD2-C1DC6E9A8BF8}", IGameState);
////////////////////////////////////////////////////////////////////////////////////////////
//! Default constructor
GameStatePrimaryUserSelection() = default;
////////////////////////////////////////////////////////////////////////////////////////////
//! Default destructor
~GameStatePrimaryUserSelection() override = default;
protected:
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameState::OnPushed
void OnPushed() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameState::OnPopped
void OnPopped() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameState::OnEnter
void OnEnter() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameState::OnExit
void OnExit() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref AzFramework::InputChannelEventListener::GetPriority
AZ::s32 GetPriority() const override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref AzFramework::InputChannelEventListener::OnInputChannelEventFiltered
//! Used to detect the press of a button / key that will identify the primary user. If you
//! override this class and wish to detect the primary user through another means, or want
//! the UI displayed to process input, you should override this function to do nothing and
//! handle setting the primary user yourself, before transitioning to the next game state.
bool OnInputChannelEventFiltered(const AzFramework::InputChannel & inputChannel) override;
////////////////////////////////////////////////////////////////////////////////////////////
//! Convenience function to set the primary local user and transition to the next game state
//! \param[in] localUserId The local user id to set as the primary user
virtual void SetPrimaryLocalUser(AzFramework::LocalUserId localUserId);
////////////////////////////////////////////////////////////////////////////////////////////
//! Convenience function to push the default primary user monitor game state.
//! Override if you wish to push a different primary user monitor game state.
virtual void PushPrimaryUserMonitorGameState();
////////////////////////////////////////////////////////////////////////////////////////////
//! Convenience function to push the default main menu game state.
//! Override if you wish to push a different main menu game state.
virtual void PushMainMenuGameState();
////////////////////////////////////////////////////////////////////////////////////////////
//! Convenience functions to load and unload the primary user selection UI canvas.
///@{
virtual void LoadPrimaryUserSelectionCanvas();
virtual void UnloadPrimaryUserSelectionCanvas();
virtual const char* GetPrimaryUserSelectionCanvasAssetPath();
protected:
////////////////////////////////////////////////////////////////////////////////////////////
// Variables
AZ::EntityId m_primaryUserSelectionCanvasEntityId; //!< Id of the UI canvas being displayed
};
} // namespace GameStateSamples
// Include the implementation inline so the class can be instantiated outside of the gem.
#include <GameStateSamples/GameStatePrimaryUserSelection.inl>