File size: 3,993 Bytes
7fd553e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "LyraActivatableWidget.h"
#include "Containers/Ticker.h"
#include "GameplayTagContainer.h"

#include "LyraHUDLayout.generated.h"

class UCommonActivatableWidget;
class UObject;
class ULyraControllerDisconnectedScreen;

/**

 * ULyraHUDLayout

 *

 *	Widget used to lay out the player's HUD (typically specified by an Add Widgets action in the experience)

 */
UCLASS(Abstract, BlueprintType, Blueprintable, Meta = (DisplayName = "Lyra HUD Layout", Category = "Lyra|HUD"))
class ULyraHUDLayout : public ULyraActivatableWidget
{
	GENERATED_BODY()

public:

	ULyraHUDLayout(const FObjectInitializer& ObjectInitializer);

	virtual void NativeOnInitialized() override;
	virtual void NativeDestruct() override;

protected:
	void HandleEscapeAction();
	
	/** 

	* Callback for when controllers are disconnected. This will check if the player now has 

	* no mapped input devices to them, which would mean that they can't play the game.

	* 

	* If this is the case, then call DisplayControllerDisconnectedMenu.

	*/
	void HandleInputDeviceConnectionChanged(EInputDeviceConnectionState NewConnectionState, FPlatformUserId PlatformUserId, FInputDeviceId InputDeviceId);

	/**

	* Callback for when controllers change their owning platform user. We will use this to check

	* if we no longer need to display the "Controller Disconnected" menu

	*/
	void HandleInputDevicePairingChanged(FInputDeviceId InputDeviceId, FPlatformUserId NewUserPlatformId, FPlatformUserId OldUserPlatformId);
	
	/**

	* Notify this widget that the state of controllers for the player have changed. Queue a timer for next tick to 

	* process them and see if we need to show/hide the "controller disconnected" widget.

	*/
	void NotifyControllerStateChangeForDisconnectScreen();

	/**

	 * This will check the state of the connected controllers to the player. If they do not have

	 * any controllers connected to them, then we should display the Disconnect menu. If they do have

	 * controllers connected to them, then we can hide the disconnect menu if its showing.

	 */
	virtual void ProcessControllerDevicesHavingChangedForDisconnectScreen();

	/**

     * Returns true if this platform supports a "controller disconnected" screen. 

     */
    virtual bool ShouldPlatformDisplayControllerDisconnectScreen() const;
	
	/**

	* Pushes the ControllerDisconnectedMenuClass to the Menu layer (UI.Layer.Menu)

	*/
	UFUNCTION(BlueprintNativeEvent, Category="Controller Disconnect Menu")
	void DisplayControllerDisconnectedMenu();

	/**

	* Hides the controller disconnected menu if it is active.

	*/
	UFUNCTION(BlueprintNativeEvent, Category="Controller Disconnect Menu")
	void HideControllerDisconnectedMenu();
	
	/**

	 * The menu to be displayed when the user presses the "Pause" or "Escape" button 

	 */
	UPROPERTY(EditDefaultsOnly)
	TSoftClassPtr<UCommonActivatableWidget> EscapeMenuClass;

	/** 

	* The widget which should be presented to the user if all of their controllers are disconnected.

	*/
	UPROPERTY(EditDefaultsOnly, Category="Controller Disconnect Menu")
	TSubclassOf<ULyraControllerDisconnectedScreen> ControllerDisconnectedScreen;

	/**

	 * The platform tags that are required in order to show the "Controller Disconnected" screen.

	 *

	 * If these tags are not set in the INI file for this platform, then the controller disconnect screen

	 * will not ever be displayed. 

	 */
	UPROPERTY(EditDefaultsOnly, Category="Controller Disconnect Menu")
	FGameplayTagContainer PlatformRequiresControllerDisconnectScreen;

	/** Pointer to the active "Controller Disconnected" menu if there is one. */
	UPROPERTY(Transient)
	TObjectPtr<UCommonActivatableWidget> SpawnedControllerDisconnectScreen;

	/** Handle from the FSTicker for when we want to process the controller state of our player */
	FTSTicker::FDelegateHandle RequestProcessControllerStateHandle;
};