mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 09:35:25 +00:00
Give menus the option to veto closure
This commit is contained in:
parent
4f25ffed56
commit
b601b16764
@ -94,6 +94,7 @@ void UMenuBase::Open(bool bIsRegain)
|
|||||||
auto PC = GetOwningPlayer();
|
auto PC = GetOwningPlayer();
|
||||||
switch (InputModeSetting)
|
switch (InputModeSetting)
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
case EInputModeChange::DoNotChange:
|
case EInputModeChange::DoNotChange:
|
||||||
break;
|
break;
|
||||||
case EInputModeChange::UIOnly:
|
case EInputModeChange::UIOnly:
|
||||||
@ -109,6 +110,7 @@ void UMenuBase::Open(bool bIsRegain)
|
|||||||
|
|
||||||
switch (MousePointerVisibility)
|
switch (MousePointerVisibility)
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
case EMousePointerVisibilityChange::DoNotChange:
|
case EMousePointerVisibilityChange::DoNotChange:
|
||||||
break;
|
break;
|
||||||
case EMousePointerVisibilityChange::Visible:
|
case EMousePointerVisibilityChange::Visible:
|
||||||
@ -121,6 +123,7 @@ void UMenuBase::Open(bool bIsRegain)
|
|||||||
|
|
||||||
switch (GamePauseSetting)
|
switch (GamePauseSetting)
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
case EGamePauseChange::DoNotChange:
|
case EGamePauseChange::DoNotChange:
|
||||||
break;
|
break;
|
||||||
case EGamePauseChange::Paused:
|
case EGamePauseChange::Paused:
|
||||||
@ -134,3 +137,19 @@ void UMenuBase::Open(bool bIsRegain)
|
|||||||
TakeFocusIfDesired();
|
TakeFocusIfDesired();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UMenuBase::RequestClose(bool bWasCancel)
|
||||||
|
{
|
||||||
|
if (ValidateClose(bWasCancel))
|
||||||
|
{
|
||||||
|
Close(bWasCancel);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UMenuBase::ValidateClose_Implementation(bool bWasCancel)
|
||||||
|
{
|
||||||
|
// Default always pass
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -149,7 +149,12 @@ bool UMenuStack::HandleKeyDownEvent(const FKeyEvent& InKeyEvent)
|
|||||||
if (BackKeys.Contains(Key))
|
if (BackKeys.Contains(Key))
|
||||||
{
|
{
|
||||||
// This is "Back"
|
// This is "Back"
|
||||||
PopMenu(true);
|
// Request close but allow veto
|
||||||
|
if (Menus.Num() > 0)
|
||||||
|
{
|
||||||
|
auto Top = Menus.Last();
|
||||||
|
Top->RequestClose(true);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (InstantCloseKeys.Contains(Key))
|
else if (InstantCloseKeys.Contains(Key))
|
||||||
|
@ -59,6 +59,8 @@ protected:
|
|||||||
|
|
||||||
virtual void EmbedInParent();
|
virtual void EmbedInParent();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintNativeEvent)
|
||||||
|
bool ValidateClose(bool bWasCancel);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,12 +72,21 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void Open(bool bIsRegainedFocus = false);
|
void Open(bool bIsRegainedFocus = false);
|
||||||
/**
|
/**
|
||||||
* @brief Close this menu.
|
* @brief Request this menu to close. The menu can veto this request.
|
||||||
|
* @param bWasCancel Set this to true if the reason for closure was a cancellation action
|
||||||
|
* @return True if the request was approved
|
||||||
|
*/
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
bool RequestClose(bool bWasCancel);
|
||||||
|
/**
|
||||||
|
* @brief Close this menu. This ALWAYS closes the menu, if you want it to be able to veto it, call RequestClose
|
||||||
* @param bWasCancel Set this to true if the reason for closure was a cancellation action
|
* @param bWasCancel Set this to true if the reason for closure was a cancellation action
|
||||||
*/
|
*/
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void Close(bool bWasCancel);
|
void Close(bool bWasCancel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TWeakObjectPtr<UMenuStack> GetParentStack() const { return ParentStack; }
|
TWeakObjectPtr<UMenuStack> GetParentStack() const { return ParentStack; }
|
||||||
virtual bool IsRequestingFocus_Implementation() const override { return bRequestFocus; }
|
virtual bool IsRequestingFocus_Implementation() const override { return bRequestFocus; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user