Add proof of concept upgrade screen
This is currently not functional and there is a lot of work still to do but I want this saved somewhere other than my pc
This commit is contained in:
parent
773338e912
commit
c9d10f86a4
BIN
Content/Weapons/Garlic/BP_GarlicWeapon.uasset
(Stored with Git LFS)
BIN
Content/Weapons/Garlic/BP_GarlicWeapon.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Widgets/LevelUp/BP_LevelUpWidget.uasset
(Stored with Git LFS)
BIN
Content/Widgets/LevelUp/BP_LevelUpWidget.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Widgets/LevelUp/BP_Test.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Widgets/LevelUp/BP_Test.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Widgets/LevelUp/BP_UpgradeButtonTemplate.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Widgets/LevelUp/BP_UpgradeButtonTemplate.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Widgets/LevelUp/Test.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Widgets/LevelUp/Test.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -7,6 +7,7 @@
|
||||
#include "GameFramework/Character.h"
|
||||
#include "VampireCharacter.generated.h"
|
||||
|
||||
class AWeapon;
|
||||
class UWeaponInventoryComponent;
|
||||
class UInputAction;
|
||||
class UHealthComponent;
|
||||
@ -22,7 +23,6 @@ public:
|
||||
UPaperFlipbookComponent* PaperFlipbookComponent;
|
||||
|
||||
FVector2D PreviousMovementDirection = FVector2d(1.0f, 0.0f);
|
||||
|
||||
protected:
|
||||
UPROPERTY()
|
||||
UHealthComponent* HealthComponent;
|
||||
|
@ -23,6 +23,15 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
||||
TObjectPtr<UWeaponDataAsset> WeaponDataAsset;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
||||
FText Name;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
||||
FText Description;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
||||
TObjectPtr<UTexture2D> Icon;
|
||||
|
||||
private:
|
||||
FTimerHandle WeaponTimerHandle;
|
||||
|
||||
|
@ -42,3 +42,8 @@ void UWeaponInventoryComponent::AddWeaponToInventory(TSubclassOf<AWeapon> Weapon
|
||||
weapon->AttachToActor(GetOwner(), FAttachmentTransformRules::KeepRelativeTransform);
|
||||
inventory.Add(weapon);
|
||||
}
|
||||
|
||||
TArray<AWeapon*> UWeaponInventoryComponent::GetInventory()
|
||||
{
|
||||
return inventory;
|
||||
}
|
||||
|
@ -36,4 +36,7 @@ public:
|
||||
|
||||
UFUNCTION()
|
||||
void AddWeaponToInventory(TSubclassOf<AWeapon> Weapon);
|
||||
|
||||
UFUNCTION()
|
||||
TArray<AWeapon*> GetInventory();
|
||||
};
|
||||
|
@ -5,7 +5,14 @@
|
||||
|
||||
#include "Blueprint/WidgetBlueprintLibrary.h"
|
||||
#include "Components/Button.h"
|
||||
#include "Components/ListView.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "UpgradeButtonDataObject.h"
|
||||
#include "EntitySystem/MovieSceneEntitySystemRunner.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "vampires/VampireCharacter.h"
|
||||
#include "vampires/Weapon.h"
|
||||
#include "vampires/WeaponInventoryComponent.h"
|
||||
|
||||
void ULevelUpWidget::NativeConstruct()
|
||||
{
|
||||
@ -16,6 +23,33 @@ void ULevelUpWidget::NativeConstruct()
|
||||
ResumeButton->OnClicked.AddUniqueDynamic(this, &ULevelUpWidget::ResumeButtonClicked);
|
||||
}
|
||||
|
||||
if (UpgradesListView)
|
||||
{
|
||||
ACharacter* Player = Cast<AVampireCharacter>( UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
|
||||
if (!Player) return;
|
||||
|
||||
UWeaponInventoryComponent* InventoryComponent = Player->GetComponentByClass<UWeaponInventoryComponent>();
|
||||
if (!InventoryComponent) return;
|
||||
|
||||
TArray<AWeapon*> Inventory = InventoryComponent->GetInventory();
|
||||
TArray<UUpgradeButtonDataObject*> upgradeItems;
|
||||
|
||||
UpgradesListView->ClearListItems();
|
||||
|
||||
for (AWeapon* weapon : Inventory)
|
||||
{
|
||||
UUpgradeButtonDataObject* Temp = NewObject<UUpgradeButtonDataObject>(this);
|
||||
Temp->SetData(weapon);
|
||||
upgradeItems.Add(Temp);
|
||||
}
|
||||
|
||||
UpgradesListView->SetListItems(upgradeItems);
|
||||
|
||||
// for (TSubclassOf<UUpgradeButtonDataObject> item : UpgradeItems)
|
||||
// {
|
||||
// upgradeItems.Add(NewObject<UUpgradeButtonDataObject>(this, item));
|
||||
// }
|
||||
}
|
||||
SetIsFocusable(true);
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,13 @@
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "LevelUpWidget.generated.h"
|
||||
|
||||
class UUpgradeButtonDataObject;
|
||||
class UListView;
|
||||
class UButton;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
UCLASS(Blueprintable)
|
||||
class VAMPIRES_API ULevelUpWidget : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
@ -20,8 +22,14 @@ public:
|
||||
UPROPERTY(BlueprintReadWrite, meta=(BindWidget))
|
||||
UButton* ResumeButton;
|
||||
|
||||
virtual void NativeConstruct() override;
|
||||
UPROPERTY(BlueprintReadWrite, meta=(BindWidget))
|
||||
UListView* UpgradesListView;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TArray<TSubclassOf<UUpgradeButtonDataObject>> UpgradeItems;
|
||||
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
26
Source/vampires/Widgets/UpgradeButtonDataObject.cpp
Normal file
26
Source/vampires/Widgets/UpgradeButtonDataObject.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UpgradeButtonDataObject.h"
|
||||
|
||||
#include "vampires/Weapon.h"
|
||||
|
||||
void UUpgradeButtonDataObject::SetData(AWeapon* Weapon)
|
||||
{
|
||||
WeaponName = Weapon->Name;
|
||||
Description = Weapon->Description;
|
||||
WeaponIcon = Weapon->Icon;
|
||||
WeaponInstance = Weapon;
|
||||
}
|
||||
|
||||
void UUpgradeButtonDataObject::SetData(TSubclassOf<AWeapon> Weapon)
|
||||
{
|
||||
AWeapon* temp = NewObject<AWeapon>(this, Weapon);
|
||||
if (temp)
|
||||
{
|
||||
WeaponName = temp->Name;
|
||||
Description = temp->Description;
|
||||
WeaponIcon = temp->Icon;
|
||||
WeaponTemplate = Weapon;
|
||||
}
|
||||
}
|
36
Source/vampires/Widgets/UpgradeButtonDataObject.h
Normal file
36
Source/vampires/Widgets/UpgradeButtonDataObject.h
Normal file
@ -0,0 +1,36 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "UpgradeButtonDataObject.generated.h"
|
||||
|
||||
class AWeapon;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(BlueprintType)
|
||||
class VAMPIRES_API UUpgradeButtonDataObject : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FText WeaponName;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FText Description;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<UTexture2D> WeaponIcon;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TSubclassOf<AWeapon> WeaponTemplate;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<AWeapon> WeaponInstance;
|
||||
|
||||
void SetData(AWeapon* Weapon);
|
||||
void SetData(TSubclassOf<AWeapon> Weapon);
|
||||
};
|
46
Source/vampires/Widgets/UpgradeButtonWidget.cpp
Normal file
46
Source/vampires/Widgets/UpgradeButtonWidget.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "UpgradeButtonWidget.h"
|
||||
|
||||
#include "UpgradeButtonDataObject.h"
|
||||
#include "Components/Button.h"
|
||||
#include "Components/Image.h"
|
||||
#include "Components/TextBlock.h"
|
||||
|
||||
void UUpgradeButtonWidget::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
if (Body)
|
||||
{
|
||||
Body->OnClicked.AddUniqueDynamic(this, &UUpgradeButtonWidget::OnClicked);
|
||||
}
|
||||
}
|
||||
|
||||
void UUpgradeButtonWidget::NativeOnListItemObjectSet(UObject* ListItemObject)
|
||||
{
|
||||
UUpgradeButtonDataObject* Item = Cast<UUpgradeButtonDataObject>(ListItemObject);
|
||||
|
||||
if (Item)
|
||||
{
|
||||
WeaponNameTextBlock->SetText(Item->WeaponName);
|
||||
DescriptionTextBlock->SetText(Item->Description);
|
||||
WeaponIcon->SetBrushFromTexture(Item->WeaponIcon);
|
||||
}
|
||||
|
||||
|
||||
switch (UpgradeType) {
|
||||
case Upgrade:
|
||||
UpgradeTypeIcon->SetBrushFromTexture(UpgradeIcon);
|
||||
break;
|
||||
case NewWeapon:
|
||||
UpgradeTypeIcon->SetBrushFromTexture(NewWeaponIcon);
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
||||
void UUpgradeButtonWidget::OnClicked()
|
||||
{
|
||||
}
|
63
Source/vampires/Widgets/UpgradeButtonWidget.h
Normal file
63
Source/vampires/Widgets/UpgradeButtonWidget.h
Normal file
@ -0,0 +1,63 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/IUserObjectListEntry.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "UpgradeButtonWidget.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum EUpgradeType
|
||||
{
|
||||
Upgrade,
|
||||
NewWeapon
|
||||
};
|
||||
|
||||
class UTextBlock;
|
||||
class UImage;
|
||||
class UButton;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class VAMPIRES_API UUpgradeButtonWidget : public UUserWidget, public IUserObjectListEntry
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly, meta=(BindWidget))
|
||||
TObjectPtr<UButton> Body;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, meta=(BindWidget))
|
||||
TObjectPtr<UImage> WeaponIcon;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, meta=(BindWidget))
|
||||
TObjectPtr<UTextBlock> WeaponNameTextBlock;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, meta=(BindWidget))
|
||||
TObjectPtr<UTextBlock> DescriptionTextBlock;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TObjectPtr<UTexture2D> UpgradeIcon;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TObjectPtr<UTexture2D> NewWeaponIcon;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TEnumAsByte<EUpgradeType> UpgradeType;
|
||||
|
||||
private:
|
||||
UPROPERTY(meta=(BindWidget))
|
||||
UImage* UpgradeTypeIcon;
|
||||
|
||||
protected:
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
virtual void NativeOnListItemObjectSet(UObject* ListItemObject) override;
|
||||
|
||||
private:
|
||||
UFUNCTION()
|
||||
virtual void OnClicked();
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user