Files
KingshearthLegacy/Source/KingshearthLegacy/UI/Menu/MenuButtonWidget.h
T
Dolobarsch b55eda5e51 Neues Menüsystem implementiert
Ein flexibles Menüsystem wurde hinzugefügt, das ein Hauptmenü und ein In-Game-Menü umfasst. Das Hauptmenü bietet Optionen wie "Neues Spiel starten", "Optionen" und "Credits". Das In-Game-Menü ermöglicht Pausenfunktionen wie "Fortsetzen", "Optionen" und "Zum Desktop beenden".

Neue Klassen wurden eingeführt, darunter `MenuManagerSubsystem` zur Verwaltung von Menübildschirmen, `MenuScreenWidget` als Basisklasse für Menüs sowie spezifische Widgets wie `MainMenuWidget`, `InGameMenuWidget` und `OptionsMenuWidget`.

Zusätzlich wurden stilisierte Schaltflächen (`MenuButtonWidget`) und ein neuer `MenuPlayerController` für menübasierte Levels implementiert. Änderungen an `KingshearthLegacyPlayerController` ermöglichen die Steuerung des In-Game-Menüs. Binäre Assets für Menüs und UI wurden hinzugefügt.
2026-09-05 00:33:04 +02:00

71 lines
2.2 KiB
C++

#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "MenuButtonWidget.generated.h"
class UButton;
class UBorder;
class UTextBlock;
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnMenuButtonClicked);
/**
* Styled menu button (WBP_Button): DefaultButton wraps ButtonBackground/ButtonText/Highlight.
* Bind to OnClicked instead of reaching into DefaultButton - callers shouldn't need to know
* this is built out of a Button + two Borders + a TextBlock. Label/BackgroundColor/HighlightColor
* are instance-editable, so a widget that places a WBP_Button just configures it in its Details
* panel (no per-instance Blueprint graph needed).
*/
UCLASS(abstract)
class UMenuButtonWidget : public UUserWidget
{
GENERATED_BODY()
public:
/** Fired when the button is clicked. */
UPROPERTY(BlueprintAssignable, Category = "Button")
FOnMenuButtonClicked OnClicked;
/** Text shown on the button. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Button")
FText Label;
/** ButtonBackground tint while idle. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Button|Style")
FLinearColor BackgroundColor = FLinearColor(0.03f, 0.03f, 0.03f, 0.75f);
/** Highlight tint shown while hovered/focused. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Button|Style")
FLinearColor HighlightColor = FLinearColor(1.0f, 0.85f, 0.3f, 1.0f);
/** Pushes Label/BackgroundColor/HighlightColor onto the bound widgets. Runs in the Designer too, so edits preview live. */
UFUNCTION(BlueprintCallable, Category = "Button")
void RefreshStyle();
protected:
virtual void NativePreConstruct() override;
virtual void NativeConstruct() override;
UFUNCTION()
void HandleClicked();
UFUNCTION()
void HandleHovered();
UFUNCTION()
void HandleUnhovered();
UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional = true))
TObjectPtr<UButton> DefaultButton;
UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional = true))
TObjectPtr<UBorder> ButtonBackground;
UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional = true))
TObjectPtr<UTextBlock> ButtonText;
UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional = true))
TObjectPtr<UBorder> Highlight;
};