84 lines
2.5 KiB
C++
84 lines
2.5 KiB
C++
// Project Lab - NHTV Igad
|
|
|
|
#pragma once
|
|
|
|
#include "MenuAction.h"
|
|
#include "Blueprint/UserWidget.h"
|
|
#include "MenuItemBase.generated.h"
|
|
|
|
DECLARE_DYNAMIC_DELEGATE_OneParam(FOverlayItemClosed, int32, choice);
|
|
|
|
extern TSubclassOf<class UMenuButton> defaultButtonClass;
|
|
extern TSubclassOf<class UMenuSlider> defaultSliderClass;
|
|
|
|
/**
|
|
* Base class for a menu item with controller navigation/input support
|
|
*/
|
|
UCLASS()
|
|
class UNREALPROJECT_API UMenuItemBase : public UUserWidget
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
void NativeConstruct() override;
|
|
void NativeDestruct() override;
|
|
|
|
// Called when the item's menu has focus every frame
|
|
virtual void FocusTick(float DeltaTime);
|
|
|
|
UFUNCTION(BlueprintCallable, Category="MenuItem")
|
|
virtual void NativeOnSelectionChanged(bool selected, bool controller);
|
|
|
|
// Shows a message box and fires a delegate when the user chooses an option
|
|
UFUNCTION(BlueprintCallable, Category = "SubMenu")
|
|
class UMsgBoxInfo* ShowMessageBox(FOverlayItemClosed cb, FString caption, FString message, TArray<FString> options, FString defaultOption);
|
|
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSelectionChanged, bool, selected);
|
|
UPROPERTY(BlueprintAssignable, Category = "MenuItem")
|
|
FSelectionChanged onSelectionChanged;
|
|
|
|
// UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "MenuItem")
|
|
int32 priority;
|
|
|
|
UPROPERTY(BlueprintReadOnly)
|
|
int32 index;
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "MenuItem")
|
|
bool IsSelected() const;
|
|
UFUNCTION(BlueprintCallable, Category = "MenuItem")
|
|
class USubMenu* GetSubMenu() const;
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "MenuItem")
|
|
bool HasFocus() const;
|
|
|
|
DECLARE_DYNAMIC_DELEGATE(FMenuAction);
|
|
UFUNCTION(BlueprintCallable, Category = "MenuItem")
|
|
void AddActionBinding(EMenuActionBinding binding, FMenuAction action);
|
|
UFUNCTION(BlueprintCallable, Category = "MenuItem")
|
|
void ClearActionBinding(EMenuActionBinding binding);
|
|
|
|
UFUNCTION(BlueprintNativeEvent, Category = "MenuItem")
|
|
void OnMenuAction(EMenuActionBinding binding);
|
|
virtual void NativeOnMenuAction(EMenuActionBinding binding);
|
|
|
|
UFUNCTION(BlueprintNativeEvent, Category = "MenuItem")
|
|
FText GetDescription();
|
|
UFUNCTION(BlueprintNativeEvent, Category = "MenuItem")
|
|
FText GetTitle();
|
|
|
|
UPROPERTY(BlueprintReadOnly, Category="MenuItem")
|
|
bool blockInput;
|
|
|
|
private:
|
|
|
|
bool m_selected;
|
|
friend class APlayerControllerBase;
|
|
friend class USubMenu;
|
|
|
|
TMultiMap<EMenuActionBinding, FMenuAction> m_actionBindings;
|
|
|
|
protected:
|
|
UPROPERTY()
|
|
class USubMenu* m_subMenu;
|
|
};
|