RoveSoSimulator
Loading...
Searching...
No Matches
RoveSoSimulatorUIManager.h
1#pragma once
2
3#include "Blueprint/UserWidget.h"
4#include "Containers/StaticArray.h"
5#include "Core/RoveSoSimulatorInputManager.h"
6#include "HAL/Platform.h"
7#include "UObject/ObjectMacros.h"
8#include "UObject/ObjectPtr.h"
9#include "Containers/StaticArray.h"
10#include "RoveSoSimulatorUIManager.generated.h"
11
12class UObject;
13
14class UInputAction;
15struct FInputActionValue;
16class UEnhancedInputComponent;
17
18class ARoveSoSimulatorPlayerController;
19class URoveSoSimulatorInputManager;
20class UUIWidget;
21
22UENUM(BlueprintType)
23enum class EUIWidget : uint8 { // DO NOT REORDER 0-3
24 SimHUD,
25 PauseMenu,
26 MainMenu/* ,
27 HelpMenu,
28 KeybindsMenu,
29 MapSettingsMenu,
30 ApplicationSettingsMenu */
31};
32
33/**
34 * @brief Manager which handles all UI elements through UIWidgets and private state
35 */
36UCLASS(Abstract, Blueprintable, BlueprintType)
37class URoveSoSimulatorUIManager : public UObject
38{
39 GENERATED_BODY()
40
41public:
42 UFUNCTION()
43 ARoveSoSimulatorPlayerController* GetPlayerController() { return PlayerController; }
44 UFUNCTION()
45 void SetPlayerController(ARoveSoSimulatorPlayerController* newPlayerController);
46 UFUNCTION()
47 void SetupInputBindings(URoveSoSimulatorInputManager* inputManager);
48
49 // UIWidget Functions, widgets should attempt to use these functions when possible
50
51 UFUNCTION()
52 // Transition back to the previous widget, irrespective of heirarchy levels.
53 void UIWidgetBack();
54 UFUNCTION()
55 // Close this widget, returning up one hierarchy level.
56 void UIWidgetReturn();
57 UFUNCTION()
58 // Transition to the provided widget, maintaining the same heirarchy level.
59 void UIWidgetTransition(EUIWidget widget);
60 UFUNCTION()
61 // Open the provided widget, dropping down one heirarchy level.
62 void UIWidgetOpen(EUIWidget widget);
63 UFUNCTION()
64 // Close the simulator and optionally return from the current widget before doing so.
65 void UIExitRoveSoSimulator(bool widgetReturn = false);
66
67private:
68 URoveSoSimulatorUIManager();
69 void SwitchToWidget(EUIWidget widget);
70 EUIWidget CurrentUIWidget;
71 uint32 UIWidgetHistory; // Because EUIWidget derives from uint8, a four-deep history can easily be stored within a uint32 via bitshifting
72 EUIWidget UIWidgetHeirarchy[8];
73 uint8 CurrentHeirarchyLevel;
74 UPROPERTY()
75 TArray<TObjectPtr<UUIWidget>> UIWidgetInstances;
76
77 UPROPERTY()
78 ARoveSoSimulatorPlayerController* PlayerController;
79 UPROPERTY(EditDefaultsOnly, Category = "UI Setup")
80 EUIWidget StartingWidget;
81 UPROPERTY(EditDefaultsOnly, Category="UIWidget")
82 TMap<EUIWidget, TSubclassOf<UUIWidget>> UIWidgetClasses;
83};