Space Plunder
Loading...
Searching...
No Matches
ULevelSelectionWidget Class Reference

#include <LevelSelectionWidget.h>

Inheritance diagram for ULevelSelectionWidget:
UMenuSystemWidget UBaseActivatableWidget

Public Member Functions

 ULevelSelectionWidget (const FObjectInitializer &ObjectInitializer)
 
virtual void NativePreConstruct () override
 
virtual void NativeConstruct () override
 
void SelectIndex (const uint32 Index, const FGameLevel &GameLevel)
 
void SetMode (const EGameplayMode Mode, const bool bDebugLevels=false)
 
void SetLevelList (const TArray< FGameLevel > &GameLevels)
 
void GetLastSelectedLevel ()
 
virtual UWidget * NativeGetDesiredFocusTarget () const override
 
- Public Member Functions inherited from UMenuSystemWidget
 UMenuSystemWidget (const FObjectInitializer &ObjectInitializer)
 
virtual bool NativeOnHandleBackAction () override
 
void SetMenuInterface (IMenuSystem *Interface)
 
void Setup ()
 
virtual void OpenConfirmationMessage (const FModalData &ModalData)
 
virtual void SetServerList (const TArray< FServerRow > &ServerInfo)
 
void SetOwnerWidget (UUserWidget *Owner)
 
UUserWidget * GetOwnerWidget () const
 
void WidgetVisibilityChanged (ESlateVisibility SlateVisibility)
 
bool GetIsOnlineGame () const
 
bool GetIsPublicMatch () const
 
virtual bool GetDebuggingMode () const
 
virtual FString GetPlayerUserName () const
 
virtual bool GetIsPlayerLoggedIn () const
 
virtual FString GetCurrentSessionName () const
 
virtual EOnlineSubsystem GetOnlineSubsystem () const
 

Protected Member Functions

virtual bool Initialize () override
 
void OnBackButtonClicked ()
 
void UpdateLevelSelection ()
 
- Protected Member Functions inherited from UMenuSystemWidget
virtual void ModalButtonSelected (const int32 Index)
 
void OnModalButtonSelectedEvent (const int32 Index)
 
virtual void ModalClosed ()
 
void OnModalClosedEvent ()
 
class UModalMenuSystemWidgetGetCurrentModal () const
 
void SetModalSlot (UPanelWidget *PanelWidget)
 
void SetNotificationSlot (UPanelWidget *PanelWidget)
 
- Protected Member Functions inherited from UBaseActivatableWidget
void LogDebugError (const FString &Message) const
 
void LogDebugError (const FString &Message, const int32 Value) const
 
void LogDebugError (const FString &Message, const float Value) const
 
void LogDebugWarning (const FString &Message) const
 
void LogDebugWarning (const FString &Message, const int32 Value) const
 
void LogDebugWarning (const FString &Message, const float Value) const
 
void LogDebugMessage (const FString &Message, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const int32 Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const float Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const bool bValue, const bool bWarning, const bool bError) const
 
void LogOnScreenMessage (const int32 Key, const FString &Message, FColor Color=FColor::Green) const
 
void SetCategoryName (const FLogCategoryBase &Category)
 

Protected Attributes

TOptional< uint32 > SelectedIndex
 
FGameLevel SelectedGameLevel
 
class UPanelWidget * LevelList = nullptr
 
class UButton * CloseButton = nullptr
 
- Protected Attributes inherited from UMenuSystemWidget
IMenuSystemMenuInterface = nullptr
 
class IModalInterfaceModalInterface = nullptr
 
bool bIsController = false
 
bool bIsKeyboard = false
 
bool bMouse = false
 
- Protected Attributes inherited from UBaseActivatableWidget
bool bDebuggingMode = false
 

Private Attributes

EGameplayMode GameplayMode = EGameplayMode::Multiplayer
 
TSubclassOf< class UUserWidget > LevelSelectSingleClass
 

Additional Inherited Members

- Public Attributes inherited from UMenuSystemWidget
FOnMenuBackButtonSelected OnMenuBackButtonSelected
 

Detailed Description

This is a menu system widget used for level selection.

Constructor & Destructor Documentation

◆ ULevelSelectionWidget()

ULevelSelectionWidget::ULevelSelectionWidget ( const FObjectInitializer & ObjectInitializer)
13 : Super(ObjectInitializer)
14{
15 const ConstructorHelpers::FClassFinder<UUserWidget> LevelSelectSingleBP(TEXT("/MenuSystem/Widgets/CommonUI/WBP_LevelSelectionSingle"));
16 if (!ensure(LevelSelectSingleBP.Class != nullptr)) return;
17 LevelSelectSingleClass = LevelSelectSingleBP.Class;
18
19}
TSubclassOf< class UUserWidget > LevelSelectSingleClass
Definition LevelSelectionWidget.h:68

Member Function Documentation

◆ GetLastSelectedLevel()

void ULevelSelectionWidget::GetLastSelectedLevel ( )
120{
121 if(GetGameInstance() != nullptr)
122 {
123 const ILevelSelectInterface* LevelSelectInterface = Cast<ILevelSelectInterface>(GetGameInstance());
124 if(LevelSelectInterface != nullptr)
125 {
126 const FGameLevel LastSelectedLevel = LevelSelectInterface->GetSelectedLevel(GameplayMode);
127 if(LastSelectedLevel.IsValid())
128 {
129 SelectedGameLevel = LastSelectedLevel;
130 }
131 }
132 }
133}
Definition LevelSelectInterface.h:22
virtual FGameLevel GetSelectedLevel(const EGameplayMode GameMode) const =0
FGameLevel SelectedGameLevel
Definition LevelSelectionWidget.h:52
EGameplayMode GameplayMode
Definition LevelSelectionWidget.h:66
Definition MenuData.h:115
bool IsValid() const
Definition MenuData.h:150

◆ Initialize()

bool ULevelSelectionWidget::Initialize ( )
overrideprotectedvirtual

Reimplemented from UMenuSystemWidget.

81{
82 const bool Success = Super::Initialize();
83 if(!Success) return false;
84 if (!ensure(LevelList != nullptr)) return false;
85 if (!ensure(CloseButton != nullptr)) return false;
86
87
88 CloseButton->OnClicked.AddUniqueDynamic(this, &ULevelSelectionWidget::OnBackButtonClicked);
89 return true;
90}
class UPanelWidget * LevelList
Definition LevelSelectionWidget.h:60
class UButton * CloseButton
Definition LevelSelectionWidget.h:62
void OnBackButtonClicked()
Definition LevelSelectionWidget.cpp:168

◆ NativeConstruct()

void ULevelSelectionWidget::NativeConstruct ( )
overridevirtual

Reimplemented from UMenuSystemWidget.

27{
28 Super::NativeConstruct();
30}
void GetLastSelectedLevel()
Definition LevelSelectionWidget.cpp:119

◆ NativeGetDesiredFocusTarget()

UWidget * ULevelSelectionWidget::NativeGetDesiredFocusTarget ( ) const
overridevirtual
136{
137 for(int32 i = 0; i < LevelList->GetChildrenCount(); i++)
138 {
139 ULevelSelectionSingleWidget* LevelSelection = Cast<ULevelSelectionSingleWidget>(LevelList->GetChildAt(i));
140 if(LevelSelection != nullptr)
141 {
142 if(LevelSelection->IsVisible() /*&& !LevelSelection->GetIsDisabled()*/)
143 {
144 return LevelSelection;
145 }
146 }
147 }
148 return Super::NativeGetDesiredFocusTarget();
149}
Definition LevelSelectionSingleWidget.h:15

◆ NativePreConstruct()

void ULevelSelectionWidget::NativePreConstruct ( )
overridevirtual
22{
23 Super::NativePreConstruct();
24}

◆ OnBackButtonClicked()

void ULevelSelectionWidget::OnBackButtonClicked ( )
protected
169{
170 if(SelectedGameLevel.IsValid() && GetGameInstance() != nullptr)
171 {
172 ILevelSelectInterface* LevelSelectInterface = Cast<ILevelSelectInterface>(GetGameInstance());
173 if(LevelSelectInterface != nullptr)
174 {
175 LevelSelectInterface->SetSelectedLevel(SelectedGameLevel, GameplayMode);
176 }
177 }
178 OnMenuBackButtonSelected.Broadcast(false);
179 SetVisibility(ESlateVisibility::Collapsed);
180}
virtual void SetSelectedLevel(const FGameLevel GameLevel, const EGameplayMode GameMode)=0
FOnMenuBackButtonSelected OnMenuBackButtonSelected
Definition MenuSystemWidget.h:24

◆ SelectIndex()

void ULevelSelectionWidget::SelectIndex ( const uint32 Index,
const FGameLevel & GameLevel )
33{
34 SelectedIndex = Index;
35 SelectedGameLevel = GameLevel;
37}
TOptional< uint32 > SelectedIndex
Definition LevelSelectionWidget.h:51
void UpdateLevelSelection()
Definition LevelSelectionWidget.cpp:182

◆ SetLevelList()

void ULevelSelectionWidget::SetLevelList ( const TArray< FGameLevel > & GameLevels)
94{
95 LevelList->ClearChildren();
96 uint32 i = 0;
97 for(const auto GameLevel : GameLevels)
98 {
99 if(GameLevel.IsValid())
100 {
101 ULevelSelectionSingleWidget* LevelSelectSingle = CreateWidget<ULevelSelectionSingleWidget>(GetOwningPlayer(), LevelSelectSingleClass);
102 if(LevelSelectSingle != nullptr)
103 {
104 if(i == 0)
105 {
106 LevelSelectSingle->SetFocus();
107 LevelSelectSingle->SetKeyboardFocus();
108 }
109 LevelSelectSingle->Setup(this, i);
110 LevelSelectSingle->SetGameLevelData(GameLevel);
111 ++i;
112 LevelList->AddChild(LevelSelectSingle);
113 }
114 }
115 }
116 // SetFocusToFirstVisibleOption();
117}
void Setup(class ULevelSelectionWidget *Parent, const uint32 Index)
Definition LevelSelectionSingleWidget.cpp:10
void SetGameLevelData(const FGameLevel &GameLevel)
Definition LevelSelectionSingleWidget.cpp:62

◆ SetMode()

void ULevelSelectionWidget::SetMode ( const EGameplayMode Mode,
const bool bDebugLevels = false )
40{
41 GameplayMode = Mode;
42 //- Get Game Levels //
43 TArray<FGameLevel> AllGameLevels;
44 TArray<FGameLevel> NewLevels;
45 switch (GameplayMode)
46 {
48 NewLevels = UMenuBPLib::GetAllCampaignLevels(GetOwningPlayer(), bDebugLevels);
49 for(auto GameLevel : NewLevels)
50 {
51 AllGameLevels.AddUnique(GameLevel);
52 }
53 break;
55 NewLevels = UMenuBPLib::GetAllHordeLevels(GetOwningPlayer(), bDebugLevels);
56 for(auto GameLevel : NewLevels)
57 {
58 AllGameLevels.AddUnique(GameLevel);
59 }
60 break;
62 NewLevels = UMenuBPLib::GetAllGameLevels(GetOwningPlayer(), bDebugLevels);
63 for(auto GameLevel : NewLevels)
64 {
65 AllGameLevels.AddUnique(GameLevel);
66 }
67 break;
69 default:
70 NewLevels = UMenuBPLib::GetAllMultiplayerLevels(GetOwningPlayer(), bDebugLevels);
71 for(auto GameLevel : NewLevels)
72 {
73 AllGameLevels.AddUnique(GameLevel);
74 }
75 break;
76 }
77 SetLevelList(AllGameLevels);
78}
void SetLevelList(const TArray< FGameLevel > &GameLevels)
Definition LevelSelectionWidget.cpp:93
static TArray< FGameLevel > GetAllHordeLevels(const UObject *WorldContextObject, const bool bIncludeDebugLevels=false)
Definition MenuBPLib.cpp:139
static TArray< FGameLevel > GetAllMultiplayerLevels(const UObject *WorldContextObject, const bool bIncludeDebugLevels=false)
Definition MenuBPLib.cpp:124
static TArray< FGameLevel > GetAllCampaignLevels(const UObject *WorldContextObject, const bool bIncludeDebugLevels=false)
Definition MenuBPLib.cpp:110
static TArray< FGameLevel > GetAllGameLevels(const UObject *WorldContextObject, const bool bIncludeDebugLevels=false)
Definition MenuBPLib.cpp:81

◆ UpdateLevelSelection()

void ULevelSelectionWidget::UpdateLevelSelection ( )
protected
183{
184 for (int32 i = 0; i < LevelList->GetChildrenCount(); ++i)
185 {
186 ULevelSelectionSingleWidget* LevelSelection = Cast<ULevelSelectionSingleWidget>(LevelList->GetChildAt(i));
187 if(LevelSelection != nullptr)
188 {
189 const bool bIsSelected = (SelectedIndex.IsSet() && SelectedIndex.GetValue() == i);
190 LevelSelection->SetAsSelected(bIsSelected);
191 }
192 }
193}
void SetAsSelected(const bool bIsSelected)
Definition LevelSelectionSingleWidget.cpp:34

Member Data Documentation

◆ CloseButton

class UButton* ULevelSelectionWidget::CloseButton = nullptr
protected

◆ GameplayMode

EGameplayMode ULevelSelectionWidget::GameplayMode = EGameplayMode::Multiplayer
private

◆ LevelList

class UPanelWidget* ULevelSelectionWidget::LevelList = nullptr
protected

◆ LevelSelectSingleClass

TSubclassOf<class UUserWidget> ULevelSelectionWidget::LevelSelectSingleClass
private

◆ SelectedGameLevel

FGameLevel ULevelSelectionWidget::SelectedGameLevel
protected

◆ SelectedIndex

TOptional<uint32> ULevelSelectionWidget::SelectedIndex
protected

The documentation for this class was generated from the following files: