feat(collection): P-013收集系统三层架构解耦实现
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
// ChildHood Project - 收集完成提示 UI 实现
|
||||
// 三段时序:淡入 → 停留 → 淡出 → 移除(自管理,HUDComponent 按需创建后无需追踪)
|
||||
|
||||
#include "Collection/CollectionCompleteWidget.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "Engine/World.h"
|
||||
#include "TimerManager.h"
|
||||
|
||||
void UCollectionCompleteWidget::NativeOnInitialized()
|
||||
{
|
||||
Super::NativeOnInitialized();
|
||||
}
|
||||
|
||||
void UCollectionCompleteWidget::ShowComplete(const FString& Text, float DisplayDuration, float InFadeOutDuration)
|
||||
{
|
||||
CachedFadeOutDuration = InFadeOutDuration;
|
||||
|
||||
if (CompleteTextBlock)
|
||||
{
|
||||
CompleteTextBlock->SetText(FText::FromString(Text));
|
||||
}
|
||||
|
||||
// 淡入
|
||||
if (FadeInAnim)
|
||||
{
|
||||
PlayAnimation(FadeInAnim);
|
||||
}
|
||||
|
||||
// 停留时长后触发淡出
|
||||
if (UWorld* World = GetWorld())
|
||||
{
|
||||
World->GetTimerManager().SetTimer(StayTimerHandle, [this]()
|
||||
{
|
||||
StartFadeOut();
|
||||
}, DisplayDuration, false);
|
||||
}
|
||||
}
|
||||
|
||||
void UCollectionCompleteWidget::StartFadeOut()
|
||||
{
|
||||
if (FadeOutAnim)
|
||||
{
|
||||
PlayAnimation(FadeOutAnim);
|
||||
}
|
||||
|
||||
if (UWorld* World = GetWorld())
|
||||
{
|
||||
World->GetTimerManager().SetTimer(FadeOutTimerHandle, [this]()
|
||||
{
|
||||
OnFadeOutComplete();
|
||||
}, CachedFadeOutDuration, false);
|
||||
}
|
||||
}
|
||||
|
||||
void UCollectionCompleteWidget::OnFadeOutComplete()
|
||||
{
|
||||
RemoveFromParent();
|
||||
}
|
||||
Reference in New Issue
Block a user