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.
51 lines
1.7 KiB
C++
51 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Blueprint/UserWidget.h"
|
|
#include "MenuScreenWidget.generated.h"
|
|
|
|
class UMenuButtonWidget;
|
|
class UMenuManagerSubsystem;
|
|
|
|
/**
|
|
* Base class for a full-screen menu (Main Menu, In-Game Menu, Options, Credits, ...).
|
|
* Subclass this for each new screen: add whatever BindWidgetOptional buttons/controls it
|
|
* needs, bind them to BlueprintCallable functions in NativeConstruct (see UMainMenuWidget),
|
|
* and push the screen via GetMenuManager()->PushScreen() or the OpenScreen() helper below.
|
|
* A BackButton is wired up automatically if the widget layout provides one.
|
|
*/
|
|
UCLASS(abstract)
|
|
class UMenuScreenWidget : public UUserWidget
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
/** Pops this screen off the menu stack. Bound automatically to BackButton if present. */
|
|
UFUNCTION(BlueprintCallable, Category = "Menu")
|
|
void Close();
|
|
|
|
/** Pushes another screen on top of this one (e.g. Options, Credits). */
|
|
UFUNCTION(BlueprintCallable, Category = "Menu")
|
|
UMenuScreenWidget* OpenScreen(TSubclassOf<UMenuScreenWidget> ScreenClass);
|
|
|
|
/**
|
|
* Called by the menu manager right before this screen is removed from the stack,
|
|
* regardless of what triggered the pop (Close(), an input toggle, ClearStack(), ...).
|
|
* Override to clean up screen-specific state (e.g. UInGameMenuWidget unpausing).
|
|
*/
|
|
virtual void NotifyScreenClosing() {}
|
|
|
|
protected:
|
|
virtual void NativeConstruct() override;
|
|
|
|
UFUNCTION(BlueprintPure, Category = "Menu")
|
|
UMenuManagerSubsystem* GetMenuManager() const;
|
|
|
|
UFUNCTION()
|
|
void HandleBackClicked();
|
|
|
|
/** Optional - present on any screen that just needs a simple "go back" button (Options, Credits, ...). */
|
|
UPROPERTY(BlueprintReadOnly, meta = (BindWidgetOptional = true))
|
|
TObjectPtr<UMenuButtonWidget> BackButton;
|
|
};
|