63. Ghost Globe
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include "GasaEngineMinimal.h"
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "Components/OverlaySlot.h"
|
||||
#include "Blueprint/WidgetBlueprintGeneratedClass.h"
|
||||
#include "Blueprint/WidgetTree.h"
|
||||
#include "TimerManager.h"
|
||||
#include "Extensions/WidgetBlueprintGeneratedClassExtension.h"
|
||||
|
||||
#if WITH_EDITOR
|
||||
@ -61,6 +62,11 @@ void UGlobeProgressBar::GenerateDesignerWidgetTemplate()
|
||||
#endif
|
||||
}
|
||||
|
||||
void UGlobeProgressBar::GhostPercentUpdateViaTimer()
|
||||
{
|
||||
GhostTargetPercent = Bar->GetPercent();
|
||||
}
|
||||
|
||||
#pragma region Bindings
|
||||
void UGlobeProgressBar::SetBezelStyle(FSlateBrush brush)
|
||||
{
|
||||
@ -78,6 +84,11 @@ void UGlobeProgressBar::SetBarStyle(FProgressBarStyle style)
|
||||
Bar->SetWidgetStyle( style );
|
||||
}
|
||||
|
||||
void UGlobeProgressBar::SetGhostBarStyle(FProgressBarStyle style)
|
||||
{
|
||||
GhostBar->SetWidgetStyle( style );
|
||||
}
|
||||
|
||||
void UGlobeProgressBar::SetGlassPadding(FMargin margin)
|
||||
{
|
||||
UOverlaySlot* GlassSlot = CastChecked<UOverlaySlot>(Glass->Slot);
|
||||
@ -91,7 +102,26 @@ void UGlobeProgressBar::SetGlassStyle(FSlateBrush brush)
|
||||
|
||||
void UGlobeProgressBar::SetPercentage(float CurrentValue, float MaxValue)
|
||||
{
|
||||
Bar->SetPercent( MaxValue > 0.f ? CurrentValue / MaxValue : 0.f );
|
||||
float PreviousValue = Bar->GetPercent();
|
||||
float CurrentValueClamped = MaxValue > 0.f ? CurrentValue / MaxValue : 0.f;
|
||||
Bar->SetPercent( CurrentValueClamped );
|
||||
|
||||
UWorld* World = GetWorld();
|
||||
FTimerManager& TM = World->GetTimerManager();
|
||||
|
||||
if ( CurrentValueClamped < PreviousValue )
|
||||
{
|
||||
// Timer will auto-clear previous set delay
|
||||
TM.SetTimer( GhostPercentChangeTimer, this, & UGlobeProgressBar::GhostPercentUpdateViaTimer, GhostPercentChangeDelay );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( TM.TimerExists( GhostPercentChangeTimer ))
|
||||
TM.ClearTimer( GhostPercentChangeTimer );
|
||||
|
||||
GhostBar->SetPercent( CurrentValueClamped );
|
||||
GhostTargetPercent = CurrentValueClamped;
|
||||
}
|
||||
}
|
||||
|
||||
void UGlobeProgressBar::SetSize(float width, float height)
|
||||
@ -131,10 +161,31 @@ void UGlobeProgressBar::NativePreConstruct()
|
||||
|
||||
DesiredFocusWidget.Resolve(WidgetTree);
|
||||
|
||||
// Basic initialization
|
||||
{
|
||||
GhostTargetPercent = Bar->GetPercent();
|
||||
GhostBar->SetPercent( GhostTargetPercent );
|
||||
}
|
||||
|
||||
// Blueprint Callback
|
||||
PreConstruct(bIsDesignTime);
|
||||
}
|
||||
|
||||
void UGlobeProgressBar::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
|
||||
{
|
||||
Super::NativeTick(MyGeometry, InDeltaTime);
|
||||
|
||||
UWorld* World = GetWorld();
|
||||
FTimerManager& TM = World->GetTimerManager();
|
||||
|
||||
// Ghost Percent Interpolation
|
||||
if ( ! TM.TimerExists( GhostPercentChangeTimer ))
|
||||
{
|
||||
float NextPercent = FMath::FInterpTo( GhostBar->GetPercent(), GhostTargetPercent, InDeltaTime, GhostPercentInterpolationSpeed );
|
||||
GhostBar->SetPercent( NextPercent );
|
||||
}
|
||||
}
|
||||
|
||||
void UGlobeProgressBar::Serialize(FArchive& Ar)
|
||||
{
|
||||
Super::Serialize(Ar);
|
||||
@ -145,3 +196,4 @@ void UGlobeProgressBar::Serialize(FStructuredArchive::FRecord Record)
|
||||
Super::Serialize(Record);
|
||||
}
|
||||
#pragma endregion UserWidget
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include "GasaCommon.h"
|
||||
#include "GasaUserWidget.h"
|
||||
@ -15,6 +15,20 @@ public:
|
||||
// Just learning: https://benui.ca/unreal/build-widgets-in-editor/?utm_medium=social&utm_source=Discord
|
||||
UFUNCTION(CallInEditor, Category="Generate Designer Widget Template")
|
||||
void GenerateDesignerWidgetTemplate();
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Globe")
|
||||
float GhostTargetPercent;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Globe")
|
||||
float GhostPercentInterpolationSpeed;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Globe")
|
||||
float GhostPercentChangeDelay;
|
||||
|
||||
FTimerHandle GhostPercentChangeTimer;
|
||||
|
||||
UFUNCTION()
|
||||
void GhostPercentUpdateViaTimer();
|
||||
|
||||
#pragma region Bindings
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
|
||||
@ -26,12 +40,15 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
|
||||
UGasaImage* Bezel;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
|
||||
UGasaProgressBar* GhostBar;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
|
||||
UGasaProgressBar* Bar;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
|
||||
UGasaImage* Glass;
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Globe")
|
||||
void SetBezelStyle(FSlateBrush brush);
|
||||
|
||||
@ -41,6 +58,9 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category="Globe")
|
||||
void SetBarStyle(FProgressBarStyle style);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Globe")
|
||||
void SetGhostBarStyle(FProgressBarStyle style);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Globe")
|
||||
void SetGlassPadding( FMargin margin );
|
||||
|
||||
@ -64,6 +84,8 @@ public:
|
||||
|
||||
#pragma region UserWidget
|
||||
void NativePreConstruct() override;
|
||||
|
||||
void NativeTick(const FGeometry& MyGeometry, float InDeltaTime);
|
||||
#pragma endregion UserWidget
|
||||
|
||||
#pragma region Object
|
||||
|
@ -9933,8 +9933,7 @@ namespace parser
|
||||
param->Name = get_cached_string( name );
|
||||
|
||||
param->PostNameMacro = post_name_macro;
|
||||
|
||||
param->ValueType = type;
|
||||
param->ValueType = type;
|
||||
|
||||
if ( value )
|
||||
param->Value = value;
|
||||
|
Reference in New Issue
Block a user