Instantly share code, notes, and snippets.
Last active
August 29, 2015 14:24
-
Save error454/6f08cd2a5d11d576298d to your computer and use it in GitHub Desktop.
TMap Crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2015 Hypercane Studios | |
#include "SpaceGame.h" | |
#include "BaseNavigableMenuStructure.h" | |
UBaseNavigableMenuStructure::UBaseNavigableMenuStructure(const FObjectInitializer& ObjectInitializer) | |
: Super(ObjectInitializer) | |
{ | |
Up = nullptr; | |
Down = nullptr; | |
Left = nullptr; | |
Right = nullptr; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2015 Hypercane Studios | |
#pragma once | |
#include "UMG.h" | |
#include "BaseNavigableMenuStructure.generated.h" | |
/** | |
* | |
*/ | |
UCLASS() | |
class SPACEGAME_API UBaseNavigableMenuStructure : public UObject | |
{ | |
GENERATED_BODY() | |
public: | |
UBaseNavigableMenuStructure(const FObjectInitializer& ObjectInitializer); | |
// Item above you | |
UPROPERTY() | |
UWidget* Up; | |
// Item below you | |
UPROPERTY() | |
UWidget* Down; | |
// Item to the left of you | |
UPROPERTY() | |
UWidget* Left; | |
// Item to the right of you | |
UPROPERTY() | |
UWidget* Right; | |
// The index of this entry in the InventoryArray | |
UPROPERTY() | |
int32 InventoryArrayIndex; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "SpaceGame.h" | |
#include "GamepadNavigableUserWidget.h" | |
void UGamepadNavigableUserWidget::NativeConstruct() | |
{ | |
Super::NativeConstruct(); | |
for (auto& MenuX : BlueprintDefinedMenuNavigation) | |
{ | |
UWidget* menuItem = WidgetTree->FindWidget(MenuX.MenuItem); | |
UWidget* left = WidgetTree->FindWidget(MenuX.Left); | |
UWidget* right = WidgetTree->FindWidget(MenuX.Right); | |
UWidget* up = WidgetTree->FindWidget(MenuX.Up); | |
UWidget* down = WidgetTree->FindWidget(MenuX.Down); | |
UBaseNavigableMenuStructure* navigation = NewObject<UBaseNavigableMenuStructure>(UBaseNavigableMenuStructure::StaticClass()); | |
navigation->Up = up; | |
navigation->Down = down; | |
navigation->Left = left; | |
navigation->Right = right; | |
NavigationMap.Add(menuItem, navigation); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2015 Hypercane Studios | |
#pragma once | |
#include "Blueprint/UserWidget.h" | |
#include "UMG.h" | |
#include "BaseNavigableMenuStructure.h" | |
#include "GamepadNavigableUserWidget.generated.h" | |
// This struct is used to define a menu item via blueprint | |
USTRUCT(Blueprintable) | |
struct FMenuNavigationStructure | |
{ | |
GENERATED_USTRUCT_BODY() | |
// The name of this menu item | |
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Navigation") | |
FName MenuItem; | |
// The name of the menu item above this item (or None) | |
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Navigation") | |
FName Up; | |
// The name of the menu item below this item (or None) | |
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Navigation") | |
FName Down; | |
// The name of the menu item left of this item (or None) | |
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Navigation") | |
FName Left; | |
// The name of the menu item right of this item (or None) | |
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Navigation") | |
FName Right; | |
}; | |
UCLASS() | |
class SPACEGAME_API UGamepadNavigableUserWidget : public UUserWidget | |
{ | |
GENERATED_BODY() | |
public: | |
virtual void NativeConstruct() override; | |
// This allows defining menu layout from blueprint | |
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "HUD") | |
TArray<FMenuNavigationStructure> BlueprintDefinedMenuNavigation; | |
// Used to hold the navigation map for the menu | |
UPROPERTY() | |
TMap<UWidget*, UBaseNavigableMenuStructure*> NavigationMap; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment