mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 09:35:25 +00:00
Compare commits
2 Commits
1e5fca94a2
...
956d6b764c
Author | SHA1 | Date | |
---|---|---|---|
|
956d6b764c | ||
|
b9ab8feb16 |
@ -20,3 +20,20 @@ FStevesBalancedRandomStream UStevesBPL::MakeBalancedRandomStream(int64 Seed)
|
||||
{
|
||||
return FStevesBalancedRandomStream(Seed);
|
||||
}
|
||||
|
||||
void UStevesBPL::AddViewOriginToStreaming(const FVector& ViewOrigin,
|
||||
float ScreenWidth,
|
||||
float FOV,
|
||||
float BoostFactor,
|
||||
bool bOverrideLocation,
|
||||
float Duration,
|
||||
AActor* ActorToBoost)
|
||||
{
|
||||
IStreamingManager::Get().AddViewInformation(ViewOrigin,
|
||||
ScreenWidth,
|
||||
ScreenWidth / FMath::Tan(FMath::DegreesToRadians(FOV * 0.5f)),
|
||||
BoostFactor,
|
||||
bOverrideLocation,
|
||||
Duration,
|
||||
ActorToBoost);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ void UMenuBase::AddedToStack(UMenuStack* Parent)
|
||||
ParentStack = MakeWeakObjectPtr(Parent);
|
||||
|
||||
Open(false);
|
||||
OnAddedToStack(Parent);
|
||||
}
|
||||
|
||||
|
||||
@ -45,11 +46,22 @@ void UMenuBase::InputModeChanged(EInputMode OldMode, EInputMode NewMode)
|
||||
}
|
||||
}
|
||||
|
||||
bool UMenuBase::IsTopOfStack() const
|
||||
{
|
||||
if (ParentStack.IsValid())
|
||||
{
|
||||
return ParentStack->GetTopMenu() == this;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void UMenuBase::RemovedFromStack(UMenuStack* Parent)
|
||||
{
|
||||
// This works whether embedded or not
|
||||
RemoveFromParent();
|
||||
PreviousFocusWidget.Reset();
|
||||
OnRemovedFromStack(Parent);
|
||||
}
|
||||
|
||||
void UMenuBase::SupercededInStack(UMenuBase* ByMenu)
|
||||
@ -66,12 +78,13 @@ void UMenuBase::SupercededInStack(UMenuBase* ByMenu)
|
||||
if (bHideWhenSuperceded)
|
||||
SetVisibility(ESlateVisibility::Collapsed);
|
||||
}
|
||||
OnSupercededInStack(ByMenu);
|
||||
}
|
||||
|
||||
void UMenuBase::RegainedFocusInStack()
|
||||
{
|
||||
Open(true);
|
||||
|
||||
OnRegainedFocusInStack();
|
||||
}
|
||||
|
||||
void UMenuBase::EmbedInParent()
|
||||
@ -156,3 +169,19 @@ bool UMenuBase::ValidateClose_Implementation(bool bWasCancel)
|
||||
// Default always pass
|
||||
return true;
|
||||
}
|
||||
|
||||
void UMenuBase::OnSupercededInStack_Implementation(UMenuBase* ByMenu)
|
||||
{
|
||||
}
|
||||
|
||||
void UMenuBase::OnRegainedFocusInStack_Implementation()
|
||||
{
|
||||
}
|
||||
|
||||
void UMenuBase::OnAddedToStack_Implementation(UMenuStack* Parent)
|
||||
{
|
||||
}
|
||||
|
||||
void UMenuBase::OnRemovedFromStack_Implementation(UMenuStack* Parent)
|
||||
{
|
||||
}
|
||||
|
@ -269,6 +269,15 @@ void UMenuStack::RemoveFromParent()
|
||||
|
||||
}
|
||||
|
||||
UMenuBase* UMenuStack::GetTopMenu() const
|
||||
{
|
||||
if (Menus.Num() > 0)
|
||||
{
|
||||
return Menus.Top();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UMenuStack::UMenuStack()
|
||||
{
|
||||
// Default to enabling automatic focus for menus (can still be overridden in serialized properties)
|
||||
|
@ -75,4 +75,27 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category="StevesUEHelpers|Random")
|
||||
static FVector BalancedRandomPointInBox(const FStevesBalancedRandomStream& Stream, const FVector& Min, const FVector& Max) { return Stream.RandPointInBox(FBox(Min, Max)); }
|
||||
|
||||
|
||||
/**
|
||||
* Let the content streaming system know that there is a viewpoint other than a possessed camera that should be taken
|
||||
* into account when deciding what to stream in. This can be useful when you're using a scene capture component,
|
||||
* which if it's capturing a scene that isn't close to a player, can result in blurry textures.
|
||||
* @param ViewOrigin The world space view point
|
||||
* @param ScreenWidth The width in pixels of the screen being rendered
|
||||
* @param FOV Horizontal field of view, in degrees
|
||||
* @param BoostFactor How much to boost the LOD by (1 being normal, higher being higher detail)
|
||||
* @param bOverrideLocation Whether this is an override location, which forces the streaming system to ignore all other regular locations
|
||||
* @param Duration How long the streaming system should keep checking this location (in seconds). 0 means just for the next Tick.
|
||||
* @param ActorToBoost Optional pointer to an actor who's textures should have their streaming priority boosted
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="StevesUEHelpers|Streaming")
|
||||
static void AddViewOriginToStreaming(const FVector& ViewOrigin,
|
||||
float ScreenWidth,
|
||||
float FOV,
|
||||
float BoostFactor = 1.0f,
|
||||
bool bOverrideLocation = false,
|
||||
float Duration = 0.0f,
|
||||
AActor* ActorToBoost = nullptr);
|
||||
|
||||
|
||||
};
|
||||
|
@ -62,6 +62,19 @@ protected:
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
bool ValidateClose(bool bWasCancel);
|
||||
|
||||
/// Called when this menu is superceded by another menu being pushed on to this stack
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
void OnSupercededInStack(UMenuBase* ByMenu);
|
||||
/// Called when this menu is superceded by another menu being pushed on to this stack
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
void OnRegainedFocusInStack();
|
||||
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
void OnAddedToStack(UMenuStack* Parent);
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
void OnRemovedFromStack(UMenuStack* Parent);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -96,4 +109,9 @@ public:
|
||||
void SupercededInStack(UMenuBase* ByMenu);
|
||||
void RegainedFocusInStack();
|
||||
void InputModeChanged(EInputMode OldMode, EInputMode NewMode);
|
||||
|
||||
/// Return whether this menu is currently at the top of the menu stack
|
||||
/// Note: if this menu is not owned by a stack, will always return true
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool IsTopOfStack() const;
|
||||
};
|
||||
|
@ -139,6 +139,9 @@ public:
|
||||
virtual void PopMenuIfTop(UMenuBase* UiMenuBase, bool bWasCancel);
|
||||
virtual void RemoveFromParent() override;
|
||||
|
||||
/// Return the menu which is currently top of the stack
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UMenuBase* GetTopMenu() const;
|
||||
|
||||
UMenuStack();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user