63. Ghost Globe

This commit is contained in:
Edward R. Gonzalez 2024-10-19 21:33:20 -04:00
parent 014925b5c6
commit 3a3f0c0271
9 changed files with 108 additions and 12 deletions

View File

@ -9,7 +9,8 @@
"_DEBUG", "_DEBUG",
"UNICODE", "UNICODE",
"_UNICODE", "_UNICODE",
"GASA_INTELLISENSE_DIRECTIVES=1" "GASA_INTELLISENSE_DIRECTIVES=1",
"WITH_EDITOR=1",
], ],
"windowsSdkVersion": "10.0.22621.0", "windowsSdkVersion": "10.0.22621.0",
"compilerPath": "cl.exe" "compilerPath": "cl.exe"

20
GASATHON.code-workspace Normal file
View File

@ -0,0 +1,20 @@
{
"folders": [
{
"path": "."
},
{
"path": "../Surgo/UE"
}
],
"settings": {
"autoHide.autoHideSideBar": false,
"autoHide.autoHidePanel": false,
"files.associations": {
"*.rmd": "markdown",
"*.ipp": "cpp",
"__hash_table": "cpp",
"string": "cpp"
}
}
}

Binary file not shown.

View File

@ -210,8 +210,7 @@
"SupportedTargetPlatforms": [ "SupportedTargetPlatforms": [
"Win64", "Win64",
"Linux", "Linux",
"Android", "Android"
"VisionOS"
] ]
}, },
{ {
@ -293,8 +292,7 @@
"SupportedTargetPlatforms": [ "SupportedTargetPlatforms": [
"Win64", "Win64",
"Linux", "Linux",
"Android", "Android"
"VisionOS"
] ]
}, },
{ {
@ -340,6 +338,10 @@
{ {
"Name": "LiveUpdateForSlate", "Name": "LiveUpdateForSlate",
"Enabled": true "Enabled": true
},
{
"Name": "SunPosition",
"Enabled": true
} }
] ]
} }

View File

@ -1,4 +1,4 @@
#pragma once #pragma once
#include "GasaEngineMinimal.h" #include "GasaEngineMinimal.h"

View File

@ -8,6 +8,7 @@
#include "Components/OverlaySlot.h" #include "Components/OverlaySlot.h"
#include "Blueprint/WidgetBlueprintGeneratedClass.h" #include "Blueprint/WidgetBlueprintGeneratedClass.h"
#include "Blueprint/WidgetTree.h" #include "Blueprint/WidgetTree.h"
#include "TimerManager.h"
#include "Extensions/WidgetBlueprintGeneratedClassExtension.h" #include "Extensions/WidgetBlueprintGeneratedClassExtension.h"
#if WITH_EDITOR #if WITH_EDITOR
@ -61,6 +62,11 @@ void UGlobeProgressBar::GenerateDesignerWidgetTemplate()
#endif #endif
} }
void UGlobeProgressBar::GhostPercentUpdateViaTimer()
{
GhostTargetPercent = Bar->GetPercent();
}
#pragma region Bindings #pragma region Bindings
void UGlobeProgressBar::SetBezelStyle(FSlateBrush brush) void UGlobeProgressBar::SetBezelStyle(FSlateBrush brush)
{ {
@ -78,6 +84,11 @@ void UGlobeProgressBar::SetBarStyle(FProgressBarStyle style)
Bar->SetWidgetStyle( style ); Bar->SetWidgetStyle( style );
} }
void UGlobeProgressBar::SetGhostBarStyle(FProgressBarStyle style)
{
GhostBar->SetWidgetStyle( style );
}
void UGlobeProgressBar::SetGlassPadding(FMargin margin) void UGlobeProgressBar::SetGlassPadding(FMargin margin)
{ {
UOverlaySlot* GlassSlot = CastChecked<UOverlaySlot>(Glass->Slot); UOverlaySlot* GlassSlot = CastChecked<UOverlaySlot>(Glass->Slot);
@ -91,7 +102,26 @@ void UGlobeProgressBar::SetGlassStyle(FSlateBrush brush)
void UGlobeProgressBar::SetPercentage(float CurrentValue, float MaxValue) 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) void UGlobeProgressBar::SetSize(float width, float height)
@ -131,10 +161,31 @@ void UGlobeProgressBar::NativePreConstruct()
DesiredFocusWidget.Resolve(WidgetTree); DesiredFocusWidget.Resolve(WidgetTree);
// Basic initialization
{
GhostTargetPercent = Bar->GetPercent();
GhostBar->SetPercent( GhostTargetPercent );
}
// Blueprint Callback // Blueprint Callback
PreConstruct(bIsDesignTime); 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) void UGlobeProgressBar::Serialize(FArchive& Ar)
{ {
Super::Serialize(Ar); Super::Serialize(Ar);
@ -145,3 +196,4 @@ void UGlobeProgressBar::Serialize(FStructuredArchive::FRecord Record)
Super::Serialize(Record); Super::Serialize(Record);
} }
#pragma endregion UserWidget #pragma endregion UserWidget

View File

@ -1,4 +1,4 @@
#pragma once #pragma once
#include "GasaCommon.h" #include "GasaCommon.h"
#include "GasaUserWidget.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 // Just learning: https://benui.ca/unreal/build-widgets-in-editor/?utm_medium=social&utm_source=Discord
UFUNCTION(CallInEditor, Category="Generate Designer Widget Template") UFUNCTION(CallInEditor, Category="Generate Designer Widget Template")
void GenerateDesignerWidgetTemplate(); 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 #pragma region Bindings
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe") UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
@ -26,12 +40,15 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe") UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
UGasaImage* Bezel; UGasaImage* Bezel;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
UGasaProgressBar* GhostBar;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe") UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
UGasaProgressBar* Bar; UGasaProgressBar* Bar;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe") UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidgetOptional), Category="Globe")
UGasaImage* Glass; UGasaImage* Glass;
UFUNCTION(BlueprintCallable, Category="Globe") UFUNCTION(BlueprintCallable, Category="Globe")
void SetBezelStyle(FSlateBrush brush); void SetBezelStyle(FSlateBrush brush);
@ -41,6 +58,9 @@ public:
UFUNCTION(BlueprintCallable, Category="Globe") UFUNCTION(BlueprintCallable, Category="Globe")
void SetBarStyle(FProgressBarStyle style); void SetBarStyle(FProgressBarStyle style);
UFUNCTION(BlueprintCallable, Category="Globe")
void SetGhostBarStyle(FProgressBarStyle style);
UFUNCTION(BlueprintCallable, Category="Globe") UFUNCTION(BlueprintCallable, Category="Globe")
void SetGlassPadding( FMargin margin ); void SetGlassPadding( FMargin margin );
@ -64,6 +84,8 @@ public:
#pragma region UserWidget #pragma region UserWidget
void NativePreConstruct() override; void NativePreConstruct() override;
void NativeTick(const FGeometry& MyGeometry, float InDeltaTime);
#pragma endregion UserWidget #pragma endregion UserWidget
#pragma region Object #pragma region Object

View File

@ -9933,8 +9933,7 @@ namespace parser
param->Name = get_cached_string( name ); param->Name = get_cached_string( name );
param->PostNameMacro = post_name_macro; param->PostNameMacro = post_name_macro;
param->ValueType = type;
param->ValueType = type;
if ( value ) if ( value )
param->Value = value; param->Value = value;

Binary file not shown.