Files
ChildHood/Source/ChildHood/Collection/CollectionProgressWidget.h
T
2026-06-15 05:13:28 +08:00

73 lines
2.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ChildHood Project - 收集进度 UI 基类
// 对应技术方案: docs/technical/收集系统-技术方案.md 第3节(UCollectionProgressWidget)+ 第7节
// 职责:常驻进度 HUD(图标+品类名+进度文本)+ 数字弹性动画 + 完成金色变色
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "CollectionProgressWidget.generated.h"
class UTextBlock;
/**
* UCollectionProgressWidget — 收集进度常驻 HUD(执行案第三节「收集进度 UI」)。
*
* 显示格式:「📦 杂物 X/Y」,游戏开始后常驻左上角。
* 进度变化时数字弹性缩放;全部完成时文字变金色 + 完成动画。
*
* 绑定要求(蓝图 WBP_CollectionProgress 继承本类):
* - TextBlock 名 "ProgressTextBlock" — 进度文本(如 "📦 杂物 3/10")
* - WidgetAnimation 名 "BounceAnim" — 数字弹性动画(1.2x, 0.2s)
* - WidgetAnimation 名 "CompleteAnim" — 完成金色动画(1.4x, 0.5s)
*
* 布局要求:Anchors Top Left,距左/上各 3% 屏幕边距(执行案第三节)。
*/
UCLASS(Abstract, Blueprintable)
class UCollectionProgressWidget : public UUserWidget
{
GENERATED_BODY()
public:
/** 更新进度文本(格式:「📦 杂物 X/Y」)*/
UFUNCTION(BlueprintCallable, Category = "Collection|Progress")
void UpdateProgress(int32 Current, int32 Total);
/** 设为完成样式:文字变金色(全部收集完成时)*/
UFUNCTION(BlueprintCallable, Category = "Collection|Progress")
void SetCompleteStyle();
/** 播放数字弹性动画(单次新收集时)*/
UFUNCTION(BlueprintCallable, Category = "Collection|Progress")
void PlayBounceAnimation();
/** 播放完成动画(全部收集完成时,配合 SetCompleteStyle)*/
UFUNCTION(BlueprintCallable, Category = "Collection|Progress")
void PlayCompleteAnimation();
protected:
/** 进度文本 TextBlock,蓝图子类必须有同名 TextBlock */
UPROPERTY(meta = (BindWidget))
UTextBlock* ProgressTextBlock;
/** 数字弹性动画,蓝图子类必须有同名 WidgetAnimation */
UPROPERTY(meta = (BindWidgetAnim), Transient)
UWidgetAnimation* BounceAnim;
/** 完成金色动画,蓝图子类必须有同名 WidgetAnimation */
UPROPERTY(meta = (BindWidgetAnim), Transient)
UWidgetAnimation* CompleteAnim;
/** 正常文字颜色(白色)*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Collection|Progress")
FLinearColor NormalColor = FLinearColor::White;
/** 完成文字颜色(浅金色 #F0D060)*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Collection|Progress")
FLinearColor CompleteColor = FLinearColor(0.94f, 0.82f, 0.38f, 1.f);
virtual void NativeOnInitialized() override;
};