feat(attributes/ui): toast "LEVEL UP!" no HUD via S_LEVEL_UP delegate
- UZMMOHudWidget ganha LevelUpToastContainer (BindWidgetOptional UWidget) e LevelUpToastText (BindWidgetOptional UTextBlock) — both Collapsed por default; HandleLevelUp os mostra com text "LEVEL UP! Lv N" e dispara timer FTimerHandle pra esconder após LevelUpToastDurationSec (2.5s). - WBP_HUD: Border escuro semi-transparente (R=0.05,G=0.04,B=0.10,A=0.85) com TextBlock dourado (R=1.0,G=0.85,B=0.30) fonte 32, slot top-center com padding top=120, visibility default Collapsed. - Snapshot pós-level-up (vem logo após S_LEVEL_UP) atualiza HP/SP/level via HpSpBar automaticamente — toast é só feedback visual instantâneo. Polish futuro (não desta frente): SFX cue + particle aura dourada + animação de fade in/out via UMG.
This commit is contained in:
Binary file not shown.
@@ -1,9 +1,12 @@
|
|||||||
#include "ZMMOHudWidget.h"
|
#include "ZMMOHudWidget.h"
|
||||||
|
|
||||||
|
#include "Components/TextBlock.h"
|
||||||
|
#include "Components/Widget.h"
|
||||||
#include "CommonInputTypeEnum.h" // ECommonInputMode
|
#include "CommonInputTypeEnum.h" // ECommonInputMode
|
||||||
#include "Engine/World.h"
|
#include "Engine/World.h"
|
||||||
#include "GameFramework/PlayerController.h"
|
#include "GameFramework/PlayerController.h"
|
||||||
#include "GameFramework/PlayerState.h"
|
#include "GameFramework/PlayerState.h"
|
||||||
|
#include "TimerManager.h"
|
||||||
#include "ZMMO.h"
|
#include "ZMMO.h"
|
||||||
#include "ZMMOAttributeComponent.h"
|
#include "ZMMOAttributeComponent.h"
|
||||||
#include "ZMMOHudHpSpWidget.h"
|
#include "ZMMOHudHpSpWidget.h"
|
||||||
@@ -32,6 +35,8 @@ void UZMMOHudWidget::NativeOnActivated()
|
|||||||
// HUD nao intercepta cliques — mouse passa direto pro Pawn (camera, etc.).
|
// HUD nao intercepta cliques — mouse passa direto pro Pawn (camera, etc.).
|
||||||
// Sub-widgets que precisam de click (futuro: hotkeys) podem override.
|
// Sub-widgets que precisam de click (futuro: hotkeys) podem override.
|
||||||
SetVisibility(ESlateVisibility::HitTestInvisible);
|
SetVisibility(ESlateVisibility::HitTestInvisible);
|
||||||
|
// Toast comeca escondido — so' aparece em HandleLevelUp.
|
||||||
|
HideLevelUpToast();
|
||||||
BindToLocalPlayer();
|
BindToLocalPlayer();
|
||||||
UE_LOG(LogZMMO, Log, TEXT("ZMMOHudWidget activated (HpSpBar=%s)"),
|
UE_LOG(LogZMMO, Log, TEXT("ZMMOHudWidget activated (HpSpBar=%s)"),
|
||||||
HpSpBar ? *HpSpBar->GetName() : TEXT("none"));
|
HpSpBar ? *HpSpBar->GetName() : TEXT("none"));
|
||||||
@@ -115,8 +120,39 @@ void UZMMOHudWidget::HandleHpSpChanged(int32 Hp, int32 Sp)
|
|||||||
|
|
||||||
void UZMMOHudWidget::HandleLevelUp(int32 NewBaseLevel, int32 StatusPointDelta)
|
void UZMMOHudWidget::HandleLevelUp(int32 NewBaseLevel, int32 StatusPointDelta)
|
||||||
{
|
{
|
||||||
// Snapshot subsequente do AttributeSystem vai disparar HandleAttributesChanged
|
// Snapshot subsequente atualiza HpSpBar (level/maxhp/maxsp). Aqui mostra
|
||||||
// e atualizar HpSpBar->LevelText. Aqui e' o ponto pra efeitos visuais
|
// toast visual instantaneo. StatusPointDelta nao usado no texto (UI mostra
|
||||||
// instantaneos (toast "LEVEL UP", confetti, sound). V1 noop — UI pode
|
// no StatusWindow). Polish futuro: SFX + particle aura.
|
||||||
// hook via Blueprint depois.
|
UE_LOG(LogZMMO, Log, TEXT("[HUD] LEVEL UP! newLevel=%d +sp=%d"), NewBaseLevel, StatusPointDelta);
|
||||||
|
ShowLevelUpToast(NewBaseLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UZMMOHudWidget::ShowLevelUpToast(int32 NewBaseLevel)
|
||||||
|
{
|
||||||
|
if (LevelUpToastText)
|
||||||
|
{
|
||||||
|
LevelUpToastText->SetText(FText::FromString(
|
||||||
|
FString::Printf(TEXT("LEVEL UP! Lv %d"), NewBaseLevel)));
|
||||||
|
}
|
||||||
|
if (LevelUpToastContainer)
|
||||||
|
{
|
||||||
|
LevelUpToastContainer->SetVisibility(ESlateVisibility::HitTestInvisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancela timer anterior (caso level up duplo em sequencia) + agenda hide.
|
||||||
|
if (UWorld* World = GetWorld())
|
||||||
|
{
|
||||||
|
World->GetTimerManager().ClearTimer(LevelUpToastHideTimer);
|
||||||
|
World->GetTimerManager().SetTimer(LevelUpToastHideTimer,
|
||||||
|
FTimerDelegate::CreateUObject(this, &UZMMOHudWidget::HideLevelUpToast),
|
||||||
|
LevelUpToastDurationSec, /*loop*/ false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UZMMOHudWidget::HideLevelUpToast()
|
||||||
|
{
|
||||||
|
if (LevelUpToastContainer)
|
||||||
|
{
|
||||||
|
LevelUpToastContainer->SetVisibility(ESlateVisibility::Collapsed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
#include "CommonActivatableWidget.h"
|
#include "CommonActivatableWidget.h"
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "Engine/TimerHandle.h"
|
||||||
#include "ZMMOAttributeTypes.h"
|
#include "ZMMOAttributeTypes.h"
|
||||||
#include "ZMMOHudWidget.generated.h"
|
#include "ZMMOHudWidget.generated.h"
|
||||||
|
|
||||||
|
class UTextBlock;
|
||||||
|
class UWidget;
|
||||||
class UZMMOAttributeComponent;
|
class UZMMOAttributeComponent;
|
||||||
class UZMMOHudHpSpWidget;
|
class UZMMOHudHpSpWidget;
|
||||||
|
|
||||||
@@ -71,6 +74,22 @@ protected:
|
|||||||
UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional), Category = "Zeus|HUD")
|
UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional), Category = "Zeus|HUD")
|
||||||
UZMMOHudHpSpWidget* HpSpBar = nullptr;
|
UZMMOHudHpSpWidget* HpSpBar = nullptr;
|
||||||
|
|
||||||
|
/// Container do toast "LEVEL UP!" (Fase 3). Hidden por default; em
|
||||||
|
/// `HandleLevelUp` vira visivel por `LevelUpToastDurationSec` segundos
|
||||||
|
/// (ver `Show/HideLevelUpToast`). WBP_HUD coloca um Border + Image + TextBlock
|
||||||
|
/// dentro deste container; este C++ controla apenas o lifecycle visivel/hidden.
|
||||||
|
UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional), Category = "Zeus|HUD|LevelUp")
|
||||||
|
UWidget* LevelUpToastContainer = nullptr;
|
||||||
|
|
||||||
|
/// Texto exibido no toast — formato "LEVEL UP! Lv X" (X = novo level).
|
||||||
|
/// Tambem BindWidgetOptional; WBP_HUD pode usar texto estatico no design.
|
||||||
|
UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional), Category = "Zeus|HUD|LevelUp")
|
||||||
|
UTextBlock* LevelUpToastText = nullptr;
|
||||||
|
|
||||||
|
/// Duracao do toast em segundos. Configuravel no BP filho.
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category = "Zeus|HUD|LevelUp")
|
||||||
|
float LevelUpToastDurationSec = 2.5f;
|
||||||
|
|
||||||
// === Futuros sub-widgets ===
|
// === Futuros sub-widgets ===
|
||||||
// UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional)) UZMMOHudPlayerInfoWidget* PlayerInfo = nullptr;
|
// UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional)) UZMMOHudPlayerInfoWidget* PlayerInfo = nullptr;
|
||||||
// UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional)) UZMMOHudMinimapWidget* Minimap = nullptr;
|
// UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional)) UZMMOHudMinimapWidget* Minimap = nullptr;
|
||||||
@@ -99,4 +118,9 @@ private:
|
|||||||
|
|
||||||
UPROPERTY(Transient)
|
UPROPERTY(Transient)
|
||||||
TWeakObjectPtr<UZMMOAttributeComponent> BoundComponent;
|
TWeakObjectPtr<UZMMOAttributeComponent> BoundComponent;
|
||||||
|
|
||||||
|
void ShowLevelUpToast(int32 NewBaseLevel);
|
||||||
|
void HideLevelUpToast();
|
||||||
|
|
||||||
|
FTimerHandle LevelUpToastHideTimer;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user