Compare commits
No commits in common. "680b6b3d870d613342322919c5e4c2f4749eedb8" and "37dd8f735ee733d97cb3fdb4d01faec8e0152c49" have entirely different histories.
680b6b3d87
...
37dd8f735e
Binary file not shown.
Binary file not shown.
@ -100,9 +100,6 @@ ManualIPAddress=
|
|||||||
+ClassRedirects=(OldName="/Script/ProjectFish.PlayerInventorySubsystem",NewName="/Script/ProjectFish.FishingRodConfigSubsystem")
|
+ClassRedirects=(OldName="/Script/ProjectFish.PlayerInventorySubsystem",NewName="/Script/ProjectFish.FishingRodConfigSubsystem")
|
||||||
+ClassRedirects=(OldName="/Script/ProjectFish.SimpleMapSystem",NewName="/Script/ProjectFish.FishingMapSubSystem")
|
+ClassRedirects=(OldName="/Script/ProjectFish.SimpleMapSystem",NewName="/Script/ProjectFish.FishingMapSubSystem")
|
||||||
+ClassRedirects=(OldName="/Script/ProjectFish.FishingMapSystem",NewName="/Script/ProjectFish.FishingMapSubSystem")
|
+ClassRedirects=(OldName="/Script/ProjectFish.FishingMapSystem",NewName="/Script/ProjectFish.FishingMapSubSystem")
|
||||||
+ClassRedirects=(OldName="/Script/ProjectFish.BagShapeAsset",NewName="/Script/ProjectFish.ShapeAsset")
|
|
||||||
+ClassRedirects=(OldName="/Script/ProjectFishEditor.BagShapeFactory",NewName="/Script/ProjectFishEditor.ShapeFactory")
|
|
||||||
+ClassRedirects=(OldName="/Script/ProjectFishEditor.BagShapeAssetThumbnailRenderer",NewName="/Script/ProjectFishEditor.ShapeAssetThumbnailRenderer")
|
|
||||||
|
|
||||||
[/Script/Engine.CollisionProfile]
|
[/Script/Engine.CollisionProfile]
|
||||||
-Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision",bCanModify=False)
|
-Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision",bCanModify=False)
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectFish/Content/UI/Ready/UMG_ReadyWIndow.uasset
Normal file
BIN
ProjectFish/Content/UI/Ready/UMG_ReadyWIndow.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -40,9 +40,7 @@
|
|||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACoreUObject_002Fd_003APublic_002Fd_003AUObject_002Ff_003AUnrealType_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACoreUObject_002Fd_003APublic_002Fd_003AUObject_002Ff_003AUnrealType_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACoreUObject_002Fd_003APublic_002Fd_003AUObject_002Ff_003AUObjectArray_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACoreUObject_002Fd_003APublic_002Fd_003AUObject_002Ff_003AUObjectArray_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACoreUObject_002Fd_003APublic_002Fd_003AUObject_002Ff_003AUObjectBase_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACoreUObject_002Fd_003APublic_002Fd_003AUObject_002Ff_003AUObjectBase_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACore_002Fd_003APublic_002Fd_003ATemplates_002Ff_003ASharedPointer_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACore_002Fd_003APublic_002Fd_003ATemplates_002Ff_003ATuple_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003ACore_002Fd_003APublic_002Fd_003ATemplates_002Ff_003ATuple_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003AClasses_002Fd_003AEngine_002Ff_003AEngine_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003AClasses_002Fd_003AGameFramework_002Ff_003ACharacterMovementComponent_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003AClasses_002Fd_003AGameFramework_002Ff_003ACharacterMovementComponent_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003APrivate_002Fd_003AComponents_002Ff_003ACharacterMovementComponent_002Ecpp/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003APrivate_002Fd_003AComponents_002Ff_003ACharacterMovementComponent_002Ecpp/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003APrivate_002Ff_003AGameplayStatics_002Ecpp/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=72263A5F_002DD5F9_002D3915_002D8DA0_002DCD45C38A70E5_002Fdl_003ASource_003AF_0021_003FEpic_003FUE_005F5_002E5_003FEngine_003FSource_002Fd_003ARuntime_002Fd_003AEngine_002Fd_003APrivate_002Ff_003AGameplayStatics_002Ecpp/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
|||||||
@ -1,117 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "ContainerInfo.h"
|
|
||||||
|
|
||||||
#include "Engine/AssetManager.h"
|
|
||||||
#include "Engine/StreamableManager.h"
|
|
||||||
|
|
||||||
// void UContainerInfo::InitContainer(FPrimaryAssetId ContainerShapeId)
|
|
||||||
// {
|
|
||||||
// //加载形状资源
|
|
||||||
// TSharedPtr<FStreamableHandle> LoadHandle = GEngine->AssetManager->LoadPrimaryAsset(ContainerShapeId);
|
|
||||||
// if (LoadHandle.IsValid())
|
|
||||||
// {
|
|
||||||
// // 等待加载完成,这会阻塞线程
|
|
||||||
// LoadHandle->WaitUntilComplete();
|
|
||||||
//
|
|
||||||
// // 加载完成后,通过句柄获取资源
|
|
||||||
// UObject* LoadedObject = LoadHandle->GetLoadedAsset();
|
|
||||||
// if (LoadedObject)
|
|
||||||
// {
|
|
||||||
// ContainerShape = Cast<UShapeAsset>(LoadedObject);
|
|
||||||
// for (int x = 0; x < ContainerShape->GetShapeWidth(); x++)
|
|
||||||
// {
|
|
||||||
// for (int y = 0; y < ContainerShape->GetShapeHeight(); y++)
|
|
||||||
// {
|
|
||||||
// SlotInUsing.Add(FIntPoint(x, y), false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// LoadHandle->ReleaseHandle();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
void UContainerInfo::InitContainerByShape(UShapeAsset* InContainerShape)
|
|
||||||
{
|
|
||||||
ContainerShape = InContainerShape;
|
|
||||||
for (int x = 0; x < ContainerShape->GetShapeWidth(); x++)
|
|
||||||
{
|
|
||||||
for (int y = 0; y < ContainerShape->GetShapeHeight(); y++)
|
|
||||||
{
|
|
||||||
SlotInUsing.Add(FIntPoint(x, y), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UContainerInfo::AddContainerItem(FContainerItem Item, FIntPoint Position)
|
|
||||||
{
|
|
||||||
if (IsItemInContainerShape(Item, Position))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (IsItemOverlapOtherItem(Item, Position))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Items.Add(Position, Item);
|
|
||||||
//设置容器指定位置的占用状态
|
|
||||||
for (int x = 0; x < Item.GetItemWIdth(); x++)
|
|
||||||
{
|
|
||||||
for (int y = 0; y < Item.GetItemHeight(); y++)
|
|
||||||
{
|
|
||||||
if (Item.IsSlotUsing(FIntPoint(x, y)))
|
|
||||||
{
|
|
||||||
SlotInUsing.Add(FIntPoint(x + Position.X, y + Position.Y), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UContainerInfo::IsItemOverlapOtherItem(FContainerItem NewItem, FIntPoint Position)
|
|
||||||
{
|
|
||||||
|
|
||||||
for (int x = 0; x < NewItem.GetItemWIdth(); x++)
|
|
||||||
{
|
|
||||||
for (int y = 0; y < NewItem.GetItemHeight(); y++)
|
|
||||||
{
|
|
||||||
if (NewItem.IsSlotUsing(Position))
|
|
||||||
{
|
|
||||||
if (!ContainerShape->IsSlotActive(Position.X + x, Position.Y + y) ||
|
|
||||||
SlotInUsing.Find(FIntPoint(x + Position.X, y + Position.Y)))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UContainerInfo::IsItemInContainerShape(FContainerItem NewItem, FIntPoint Position)
|
|
||||||
{
|
|
||||||
for (int x = 0; x < NewItem.GetItemWIdth(); x++)
|
|
||||||
{
|
|
||||||
for (int y = 0; y < NewItem.GetItemHeight(); y++)
|
|
||||||
{
|
|
||||||
if ( (x + Position.X) > 0 && (x + Position.X) < ContainerShape->GetShapeWidth() &&
|
|
||||||
(y + Position.Y) > 0 && (y + Position.Y) < ContainerShape->GetShapeHeight()
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (!ContainerShape->IsSlotActive(Position.X + x, Position.Y + y))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@ -1,112 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "ProjectFish/DataAsset/FishingRewardDataAsset.h"
|
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
|
||||||
#include "UObject/Object.h"
|
|
||||||
#include "ContainerInfo.generated.h"
|
|
||||||
|
|
||||||
UENUM(BlueprintType)
|
|
||||||
enum class EItemDegreeType: uint8
|
|
||||||
{
|
|
||||||
Zero,
|
|
||||||
Ninety UMETA(DisplayName = "90度"),
|
|
||||||
OneEighty UMETA(DisplayName = "180度"),
|
|
||||||
TwentySeven UMETA(DisplayName = "270度"),
|
|
||||||
};
|
|
||||||
//仓库物品
|
|
||||||
|
|
||||||
class UShapeAsset;
|
|
||||||
|
|
||||||
USTRUCT(BlueprintType)
|
|
||||||
struct FContainerItem
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
public:
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
||||||
EItemDegreeType DegreeType;
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
||||||
UFishingRewardDataAsset* RewardItem;
|
|
||||||
|
|
||||||
//旋转后的水平宽度
|
|
||||||
int32 GetItemWIdth()
|
|
||||||
{
|
|
||||||
return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? RewardItem->RewardShape->GetShapeHeight()
|
|
||||||
: RewardItem->RewardShape->GetShapeWidth();
|
|
||||||
}
|
|
||||||
//旋转后的垂直高度
|
|
||||||
int32 GetItemHeight()
|
|
||||||
{
|
|
||||||
return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? RewardItem->RewardShape->GetShapeWidth()
|
|
||||||
: RewardItem->RewardShape->GetShapeHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsSlotUsing(FIntPoint Position)
|
|
||||||
{
|
|
||||||
FIntPoint BeforeRotationPos;
|
|
||||||
switch (DegreeType)
|
|
||||||
{
|
|
||||||
case EItemDegreeType::Zero:
|
|
||||||
BeforeRotationPos = Position;
|
|
||||||
break;
|
|
||||||
case EItemDegreeType::Ninety:
|
|
||||||
{
|
|
||||||
BeforeRotationPos.X = Position.Y;
|
|
||||||
BeforeRotationPos.Y = GetItemWIdth() - Position.X - 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EItemDegreeType::OneEighty:
|
|
||||||
{
|
|
||||||
BeforeRotationPos.X = GetItemWIdth() - Position.X - 1;
|
|
||||||
BeforeRotationPos.Y = GetItemHeight() - Position.Y- 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EItemDegreeType::TwentySeven:
|
|
||||||
{
|
|
||||||
BeforeRotationPos.X = Position.X;
|
|
||||||
BeforeRotationPos.Y = GetItemHeight() - Position.Y- 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RewardItem->RewardShape->IsSlotActive(BeforeRotationPos.X, BeforeRotationPos.Y);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 仓库
|
|
||||||
*/
|
|
||||||
UCLASS(BlueprintType)
|
|
||||||
class PROJECTFISH_API UContainerInfo : public UObject
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
// UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
|
||||||
// void InitContainer(FPrimaryAssetId ContainerShapeId);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
|
||||||
void InitContainerByShape(UShapeAsset* InContainerShape);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure)
|
|
||||||
bool AddContainerItem(FContainerItem Item, FIntPoint Position);
|
|
||||||
|
|
||||||
private:
|
|
||||||
//要添加的物品是否会覆盖其他物品
|
|
||||||
bool IsItemOverlapOtherItem(FContainerItem Item, FIntPoint Position);
|
|
||||||
//要添加的物品是否在容器范围内
|
|
||||||
bool IsItemInContainerShape(FContainerItem Item, FIntPoint Position);
|
|
||||||
|
|
||||||
public:
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
||||||
TMap<FIntPoint, FContainerItem> Items;
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
||||||
UShapeAsset* ContainerShape;
|
|
||||||
|
|
||||||
private:
|
|
||||||
TMap<FIntPoint, bool> SlotInUsing;
|
|
||||||
};
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "PlayerInfoSaveGame.h"
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "GameFramework/SaveGame.h"
|
|
||||||
#include "ProjectFish/Definations.h"
|
|
||||||
#include "PlayerInfoSaveGame.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS()
|
|
||||||
class PROJECTFISH_API UPlayerInfoSaveGame : public USaveGame
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
public:
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "船只资源"))
|
|
||||||
FPrimaryAssetId ShipAssetID;
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "船只等级"))
|
|
||||||
int32 ShipLevel;
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "船舱信息"))
|
|
||||||
class UContainerInfo* ShipContainer;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "仓库资源"))
|
|
||||||
FPrimaryAssetId PlayerContainerAssetID;
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "仓库等级"))
|
|
||||||
int32 PlayerContainerLevel;
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "玩家仓库信息"))
|
|
||||||
class UContainerInfo* PlayerContainer;
|
|
||||||
|
|
||||||
};
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "BagConfigAsset.h"
|
#include "BagConfigAsset.h"
|
||||||
|
|
||||||
#include "ShapeAsset.h"
|
#include "BagShapeAsset.h"
|
||||||
|
|
||||||
|
|
||||||
bool UBagConfigAsset::AddSkill(USkillAsset* SkillObject, int32 PositionX, int32 PositionY)
|
bool UBagConfigAsset::AddSkill(USkillAsset* SkillObject, int32 PositionX, int32 PositionY)
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
#include "SkillAsset.h"
|
#include "SkillAsset.h"
|
||||||
#include "BagConfigAsset.generated.h"
|
#include "BagConfigAsset.generated.h"
|
||||||
|
|
||||||
class UShapeAsset;
|
class UBagShapeAsset;
|
||||||
|
|
||||||
//背包中摆放的技能信息
|
//背包中摆放的技能信息
|
||||||
USTRUCT(BlueprintType)
|
USTRUCT(BlueprintType)
|
||||||
@ -66,7 +66,7 @@ class PROJECTFISH_API UBagConfigAsset : public UDataAsset
|
|||||||
public:
|
public:
|
||||||
// 背包形状资源引用
|
// 背包形状资源引用
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BagConfig")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "BagConfig")
|
||||||
TObjectPtr<UShapeAsset> BagShapeAsset;
|
TObjectPtr<UBagShapeAsset> BagShapeAsset;
|
||||||
|
|
||||||
// 背包中放置的技能列表
|
// 背包中放置的技能列表
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "BagConfig")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "BagConfig")
|
||||||
|
|||||||
56
ProjectFish/Source/ProjectFish/DataAsset/BagShapeAsset.cpp
Normal file
56
ProjectFish/Source/ProjectFish/DataAsset/BagShapeAsset.cpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "BagShapeAsset.h"
|
||||||
|
|
||||||
|
UBagShapeAsset::UBagShapeAsset()
|
||||||
|
{
|
||||||
|
|
||||||
|
InitializeBagShape();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UBagShapeAsset::InitializeBagShape()
|
||||||
|
{
|
||||||
|
BagSlots.Empty();
|
||||||
|
for (int x = 0; x < BagWidth; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < BagHeight; y++)
|
||||||
|
{
|
||||||
|
BagSlots.Add(FBagSlot(x, y, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UBagShapeAsset::IsSlotActive(int32 X, int32 Y) const
|
||||||
|
{
|
||||||
|
if (X < 0 || X >= BagWidth || Y < 0 || Y >= BagHeight)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (auto BagSlot: BagSlots)
|
||||||
|
{
|
||||||
|
if (BagSlot.X == X && BagSlot.Y == Y)
|
||||||
|
return BagSlot.bIsActive;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UBagShapeAsset::SetSlotActive(int32 X, int32 Y, bool Active)
|
||||||
|
{
|
||||||
|
if (X < 0 || X >= BagWidth || Y < 0 || Y >= BagHeight)
|
||||||
|
return;
|
||||||
|
int SlotIndex = FIndSlotIndex(X, Y);
|
||||||
|
if (SlotIndex != INDEX_NONE)
|
||||||
|
{
|
||||||
|
BagSlots[SlotIndex].bIsActive = Active;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 UBagShapeAsset::FIndSlotIndex(int32 X, int32 Y) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < BagSlots.Num(); i++)
|
||||||
|
{
|
||||||
|
if (BagSlots[i].X == X && BagSlots[i].Y == Y)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return INDEX_NONE;
|
||||||
|
}
|
||||||
63
ProjectFish/Source/ProjectFish/DataAsset/BagShapeAsset.h
Normal file
63
ProjectFish/Source/ProjectFish/DataAsset/BagShapeAsset.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 "Engine/DataAsset.h"
|
||||||
|
#include "BagShapeAsset.generated.h"
|
||||||
|
|
||||||
|
USTRUCT(BlueprintType)
|
||||||
|
struct FBagSlot
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
int32 X;
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
int32 Y;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
bool bIsActive;
|
||||||
|
FBagSlot()
|
||||||
|
{
|
||||||
|
X = 0;
|
||||||
|
Y = 0;
|
||||||
|
bIsActive = false;
|
||||||
|
}
|
||||||
|
FBagSlot(int32 InX, int32 InY, bool InIsActive)
|
||||||
|
{
|
||||||
|
X = InX;
|
||||||
|
Y = InY;
|
||||||
|
bIsActive = InIsActive;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS(BlueprintType)
|
||||||
|
class PROJECTFISH_API UBagShapeAsset : public UDataAsset
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
public:
|
||||||
|
UBagShapeAsset();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="BagShape")
|
||||||
|
void InitializeBagShape();
|
||||||
|
|
||||||
|
UFUNCTION(Blueprintable, BlueprintPure, Category="BagShape")
|
||||||
|
bool IsSlotActive(int32 X, int32 Y) const;
|
||||||
|
|
||||||
|
UFUNCTION(Blueprintable, Category="BagShape")
|
||||||
|
void SetSlotActive(int32 X, int32 Y, bool Active);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32 FIndSlotIndex(int32 X, int32 Y) const;
|
||||||
|
public:
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "BagShape", meta = (ClampMin = "1", ClampMax = "10"))
|
||||||
|
int32 BagWidth;
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "BagShape", meta = (ClampMin = "1", ClampMax = "10"))
|
||||||
|
int32 BagHeight;
|
||||||
|
|
||||||
|
//存储格子状态
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="BagShape")
|
||||||
|
TArray<FBagSlot> BagSlots;
|
||||||
|
};
|
||||||
@ -8,7 +8,7 @@
|
|||||||
#include "FishInfoConfigAsset.generated.h"
|
#include "FishInfoConfigAsset.generated.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 敌人 鱼的信息配置
|
*
|
||||||
*/
|
*/
|
||||||
UCLASS(BlueprintType)
|
UCLASS(BlueprintType)
|
||||||
class PROJECTFISH_API UFishInfoConfigAsset : public UDataAsset
|
class PROJECTFISH_API UFishInfoConfigAsset : public UDataAsset
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "ShapeAsset.h"
|
|
||||||
#include "Engine/DataAsset.h"
|
#include "Engine/DataAsset.h"
|
||||||
#include "FishingRewardDataAsset.generated.h"
|
#include "FishingRewardDataAsset.generated.h"
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ enum class ERewardRarityType: uint8
|
|||||||
Rare UMETA(DisplayName = "稀有"),
|
Rare UMETA(DisplayName = "稀有"),
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* 鱼获配置
|
*
|
||||||
*/
|
*/
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class PROJECTFISH_API UFishingRewardDataAsset : public UPrimaryDataAsset
|
class PROJECTFISH_API UFishingRewardDataAsset : public UPrimaryDataAsset
|
||||||
@ -31,9 +30,6 @@ public:
|
|||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获重量"))
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获重量"))
|
||||||
float RewardWeight;
|
float RewardWeight;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获形状"))
|
|
||||||
class UShapeAsset* RewardShape;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获稀有度"))
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fishing Reward Data" , meta = (ToolTip = "鱼获稀有度"))
|
||||||
ERewardRarityType RewardRarityType;
|
ERewardRarityType RewardRarityType;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,56 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "ShapeAsset.h"
|
|
||||||
|
|
||||||
UShapeAsset::UShapeAsset()
|
|
||||||
{
|
|
||||||
|
|
||||||
InitializeShape();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UShapeAsset::InitializeShape()
|
|
||||||
{
|
|
||||||
Slots.Empty();
|
|
||||||
for (int x = 0; x < ShapeWidth; x++)
|
|
||||||
{
|
|
||||||
for (int y = 0; y < ShapeHeight; y++)
|
|
||||||
{
|
|
||||||
Slots.Add(FShapeSlot(x, y, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UShapeAsset::IsSlotActive(int32 X, int32 Y) const
|
|
||||||
{
|
|
||||||
if (X < 0 || X >= ShapeWidth || Y < 0 || Y >= ShapeHeight)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (auto BagSlot: Slots)
|
|
||||||
{
|
|
||||||
if (BagSlot.X == X && BagSlot.Y == Y)
|
|
||||||
return BagSlot.bIsActive;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UShapeAsset::SetSlotActive(int32 X, int32 Y, bool Active)
|
|
||||||
{
|
|
||||||
if (X < 0 || X >= ShapeWidth || Y < 0 || Y >= ShapeHeight)
|
|
||||||
return;
|
|
||||||
int SlotIndex = FIndSlotIndex(X, Y);
|
|
||||||
if (SlotIndex != INDEX_NONE)
|
|
||||||
{
|
|
||||||
Slots[SlotIndex].bIsActive = Active;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 UShapeAsset::FIndSlotIndex(int32 X, int32 Y) const
|
|
||||||
{
|
|
||||||
for (int i = 0; i < Slots.Num(); i++)
|
|
||||||
{
|
|
||||||
if (Slots[i].X == X && Slots[i].Y == Y)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
return INDEX_NONE;
|
|
||||||
}
|
|
||||||
@ -1,70 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "Engine/DataAsset.h"
|
|
||||||
#include "ShapeAsset.generated.h"
|
|
||||||
|
|
||||||
USTRUCT(BlueprintType)
|
|
||||||
struct FShapeSlot
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
||||||
int32 X;
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
||||||
int32 Y;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "该槽位是否为激活状态"))
|
|
||||||
bool bIsActive;
|
|
||||||
FShapeSlot()
|
|
||||||
{
|
|
||||||
X = 0;
|
|
||||||
Y = 0;
|
|
||||||
bIsActive = false;
|
|
||||||
}
|
|
||||||
FShapeSlot(int32 InX, int32 InY, bool InIsActive)
|
|
||||||
{
|
|
||||||
X = InX;
|
|
||||||
Y = InY;
|
|
||||||
bIsActive = InIsActive;
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS(BlueprintType)
|
|
||||||
class PROJECTFISH_API UShapeAsset : public UDataAsset
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
public:
|
|
||||||
UShapeAsset();
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="Shape")
|
|
||||||
void InitializeShape();
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, Category="Shape")
|
|
||||||
int32 GetShapeWidth() { return ShapeWidth; }
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, Category="Shape")
|
|
||||||
int32 GetShapeHeight() { return ShapeHeight; }
|
|
||||||
|
|
||||||
UFUNCTION(Blueprintable, BlueprintPure, Category="Shape")
|
|
||||||
bool IsSlotActive(int32 X, int32 Y) const;
|
|
||||||
|
|
||||||
UFUNCTION(Blueprintable, Category="Shape")
|
|
||||||
void SetSlotActive(int32 X, int32 Y, bool Active);
|
|
||||||
|
|
||||||
private:
|
|
||||||
int32 FIndSlotIndex(int32 X, int32 Y) const;
|
|
||||||
public:
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shape", meta = (ClampMin = "1", ClampMax = "10"))
|
|
||||||
int32 ShapeWidth;
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shape", meta = (ClampMin = "1", ClampMax = "10"))
|
|
||||||
int32 ShapeHeight;
|
|
||||||
|
|
||||||
//存储格子状态
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Shape")
|
|
||||||
TArray<FShapeSlot> Slots;
|
|
||||||
};
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "ShipConfigAsset.h"
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "ShapeAsset.h"
|
|
||||||
#include "Engine/DataAsset.h"
|
|
||||||
#include "ShipConfigAsset.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS()
|
|
||||||
class PROJECTFISH_API UShipConfigAsset : public UPrimaryDataAsset
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
public:
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Ship")
|
|
||||||
FText ShipName;
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Ship", meta=(ToolTip = "等级对应的船舱形状"))
|
|
||||||
TArray<UShapeAsset*> Level_ShipShapes;
|
|
||||||
|
|
||||||
};
|
|
||||||
@ -5,7 +5,6 @@
|
|||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "GameplayTagContainer.h"
|
#include "GameplayTagContainer.h"
|
||||||
#include "PawnWithSkill.h"
|
#include "PawnWithSkill.h"
|
||||||
#include "DataAsset/ShapeAsset.h"
|
|
||||||
#include "UObject/Object.h"
|
#include "UObject/Object.h"
|
||||||
#include "Definations.generated.h"
|
#include "Definations.generated.h"
|
||||||
|
|
||||||
@ -461,7 +460,3 @@ struct FSimpleConnection
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
#include "GameFramework/SpringArmComponent.h"
|
#include "GameFramework/SpringArmComponent.h"
|
||||||
#include "Kismet/KismetMathLibrary.h"
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
#include "ProjectFish/Gameplay/Components/ShipSpringArmComponent.h"
|
#include "ProjectFish/Components/ShipSpringArmComponent.h"
|
||||||
#include "ProjectFish/Settings/GameConfigSettings.h"
|
#include "ProjectFish/Settings/GameConfigSettings.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -113,7 +113,7 @@ protected:
|
|||||||
class UBagConfigAsset* DefaultPlayerBag;
|
class UBagConfigAsset* DefaultPlayerBag;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true", ToolTip = "鱼竿装备槽形状"))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true", ToolTip = "鱼竿装备槽形状"))
|
||||||
class UShapeAsset* FishingRodShape;
|
class UBagShapeAsset* FishingRodShape;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -4,9 +4,9 @@
|
|||||||
#include "FishingRodConfigSubsystem.h"
|
#include "FishingRodConfigSubsystem.h"
|
||||||
|
|
||||||
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
void UFishingRodConfigSubsystem::CreateFishingRodInventory(class UShapeAsset* FishingRodShape, class UBagConfigAsset* PlayerBagConfig)
|
void UFishingRodConfigSubsystem::CreateFishingRodInventory(class UBagShapeAsset* FishingRodShape, class UBagConfigAsset* PlayerBagConfig)
|
||||||
{
|
{
|
||||||
//鱼竿的技能配置资源
|
//鱼竿的技能配置资源
|
||||||
fishingRodInventoryConfig = NewObject<UBagConfigAsset>(this);
|
fishingRodInventoryConfig = NewObject<UBagConfigAsset>(this);
|
||||||
@ -36,8 +36,8 @@ bool UFishingRodConfigSubsystem::AddSkillByConfig(USkillAsset* SkillAsset, UBagC
|
|||||||
bool UFishingRodConfigSubsystem::AddSkillToPlayerInventory(USkillAsset* SkillAsset)
|
bool UFishingRodConfigSubsystem::AddSkillToPlayerInventory(USkillAsset* SkillAsset)
|
||||||
{
|
{
|
||||||
|
|
||||||
int32 width = playerInventoryConfig->BagShapeAsset->ShapeWidth;
|
int32 width = playerInventoryConfig->BagShapeAsset->BagWidth;
|
||||||
int32 height = playerInventoryConfig->BagShapeAsset->ShapeHeight;
|
int32 height = playerInventoryConfig->BagShapeAsset->BagHeight;
|
||||||
for (int x = 0; x < width; x++)
|
for (int x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class PROJECTFISH_API UFishingRodConfigSubsystem : public UGameInstanceSubsystem
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
UFUNCTION(BlueprintCallable, Category = "PlayerInventorySubsystem")
|
UFUNCTION(BlueprintCallable, Category = "PlayerInventorySubsystem")
|
||||||
void CreateFishingRodInventory(class UShapeAsset* FishingRodShape, class UBagConfigAsset* PlayerBagConfig);
|
void CreateFishingRodInventory(class UBagShapeAsset* FishingRodShape, class UBagConfigAsset* PlayerBagConfig);
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, Category = "PlayerInventorySubsystem")
|
UFUNCTION(BlueprintPure, Category = "PlayerInventorySubsystem")
|
||||||
UBagConfigAsset* GetFishingRodInventory();
|
UBagConfigAsset* GetFishingRodInventory();
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "GameInfoManager.h"
|
|
||||||
|
|
||||||
#include "Kismet/GameplayStatics.h"
|
|
||||||
|
|
||||||
FString UGameInfoManager::SaveGameSlotName = TEXT("GameInfo");
|
|
||||||
void UGameInfoManager::Initialize(FSubsystemCollectionBase& Collection)
|
|
||||||
{
|
|
||||||
Super::Initialize(Collection);
|
|
||||||
if (!LoadGameInfo())
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Warning, TEXT("本地存档不存在加载失败"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UGameInfoManager::SaveGameInfo()
|
|
||||||
{
|
|
||||||
if (IsValid(PlayerInfo.Get()))
|
|
||||||
{
|
|
||||||
if (UGameplayStatics::SaveGameToSlot(PlayerInfo.Get(), SaveGameSlotName, 0))
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Warning, TEXT("存档保存成功"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Warning, TEXT("存档保存失败"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UE_LOG(LogTemp, Warning, TEXT("存档保存失败, PlayerInfo为空"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UGameInfoManager::LoadGameInfo()
|
|
||||||
{
|
|
||||||
if (UGameplayStatics::DoesSaveGameExist(SaveGameSlotName, 0))
|
|
||||||
{
|
|
||||||
PlayerInfo = Cast<UPlayerInfoSaveGame>(UGameplayStatics::LoadGameFromSlot(SaveGameSlotName, 0));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "ProjectFish/Data/PlayerInfoSaveGame.h"
|
|
||||||
#include "Subsystems/GameInstanceSubsystem.h"
|
|
||||||
#include "GameInfoManager.generated.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS()
|
|
||||||
class PROJECTFISH_API UGameInfoManager : public UGameInstanceSubsystem
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
public:
|
|
||||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void SaveGameInfo();
|
|
||||||
bool LoadGameInfo();
|
|
||||||
protected:
|
|
||||||
UPROPERTY(BlueprintReadOnly)
|
|
||||||
TSoftObjectPtr<class UPlayerInfoSaveGame> PlayerInfo;
|
|
||||||
static FString SaveGameSlotName;
|
|
||||||
};
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "SkillEffect_EnhanceFishRod.h"
|
#include "SkillEffect_EnhanceFishRod.h"
|
||||||
|
|
||||||
#include "ProjectFish/Gameplay/Components/FishingRodComponent.h"
|
#include "ProjectFish/Components/FishingRodComponent.h"
|
||||||
#include "ProjectFish/Skill/Skill.h"
|
#include "ProjectFish/Skill/Skill.h"
|
||||||
|
|
||||||
void USkillEffect_EnhanceFishRod::Execute(const FSkillContext& context)
|
void USkillEffect_EnhanceFishRod::Execute(const FSkillContext& context)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
#include "ProjectFish/ProjectFishGameMode.h"
|
#include "ProjectFish/ProjectFishGameMode.h"
|
||||||
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
USkillManager::USkillManager()
|
USkillManager::USkillManager()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
#include "FishFunctionLibrary.h"
|
#include "FishFunctionLibrary.h"
|
||||||
|
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
#include "ProjectFish/Data/ContainerInfo.h"
|
|
||||||
|
|
||||||
void UFishFunctionLibrary::OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName, TMap<FString, FString> OptionsPaairs)
|
void UFishFunctionLibrary::OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName, TMap<FString, FString> OptionsPaairs)
|
||||||
{
|
{
|
||||||
@ -15,13 +14,3 @@ void UFishFunctionLibrary::OpenLevelWithOptions(const UObject* WorldContextObjec
|
|||||||
}
|
}
|
||||||
UGameplayStatics::OpenLevel(WorldContextObject, LevelName, true,OptionStr);
|
UGameplayStatics::OpenLevel(WorldContextObject, LevelName, true,OptionStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 UFishFunctionLibrary::GetContainerItemWiidth(const UObject* WorldContextObject, FContainerItem ContainerItem)
|
|
||||||
{
|
|
||||||
return ContainerItem.GetItemWIdth();
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 UFishFunctionLibrary::GetContainerItemHeight(const UObject* WorldContextObject, FContainerItem ContainerItem)
|
|
||||||
{
|
|
||||||
return ContainerItem.GetItemWIdth();
|
|
||||||
}
|
|
||||||
|
|||||||
@ -17,10 +17,4 @@ class PROJECTFISH_API UFishFunctionLibrary : public UBlueprintFunctionLibrary
|
|||||||
public:
|
public:
|
||||||
UFUNCTION(BlueprintCallable, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject"))
|
UFUNCTION(BlueprintCallable, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject"))
|
||||||
static void OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName,TMap<FString, FString> OptionsPaairs);
|
static void OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName,TMap<FString, FString> OptionsPaairs);
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject"))
|
|
||||||
static int32 GetContainerItemWiidth(const UObject* WorldContextObject, FContainerItem ContainerItem);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject"))
|
|
||||||
static int32 GetContainerItemHeight(const UObject* WorldContextObject, FContainerItem ContainerItem);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1,41 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "AssetActions/BagShapeAssetTypeAction.h"
|
||||||
|
|
||||||
|
#include "AssetEditor/BagShapeAssetEditor.h"
|
||||||
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
|
|
||||||
|
UClass* FBagShapeAssetTypeAction::GetSupportedClass() const
|
||||||
|
{
|
||||||
|
return UBagShapeAsset::StaticClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FBagShapeAssetTypeAction::OpenAssetEditor(const TArray<UObject*>& InObjects,
|
||||||
|
TSharedPtr<IToolkitHost> EditWithinLevelEditor)
|
||||||
|
{
|
||||||
|
EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone;
|
||||||
|
|
||||||
|
for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt)
|
||||||
|
{
|
||||||
|
if (UBagShapeAsset* BagShapeAsset = Cast<UBagShapeAsset>(*ObjIt))
|
||||||
|
{
|
||||||
|
TSharedRef<FBagShapeAssetEditor> EditorToolkit = MakeShareable(new FBagShapeAssetEditor());
|
||||||
|
EditorToolkit->Initialize(Mode, EditWithinLevelEditor, BagShapeAsset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32 FBagShapeAssetTypeAction::GetCategories()
|
||||||
|
{
|
||||||
|
//系统原有
|
||||||
|
//return EAssetTypeCategories::Gameplay;
|
||||||
|
return MyAssetCategory;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FBagShapeAssetTypeAction::GetActions(const TArray<UObject*>& InObjects, struct FToolMenuSection& Section)
|
||||||
|
{
|
||||||
|
FAssetTypeActions_Base::GetActions(InObjects, Section);
|
||||||
|
}
|
||||||
@ -1,41 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "AssetActions/ShapeAssetTypeAction.h"
|
|
||||||
|
|
||||||
#include "AssetEditor/ShapeAssetEditor.h"
|
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
|
||||||
|
|
||||||
|
|
||||||
UClass* FShapeAssetTypeAction::GetSupportedClass() const
|
|
||||||
{
|
|
||||||
return UShapeAsset::StaticClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FShapeAssetTypeAction::OpenAssetEditor(const TArray<UObject*>& InObjects,
|
|
||||||
TSharedPtr<IToolkitHost> EditWithinLevelEditor)
|
|
||||||
{
|
|
||||||
EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone;
|
|
||||||
|
|
||||||
for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt)
|
|
||||||
{
|
|
||||||
if (UShapeAsset* BagShapeAsset = Cast<UShapeAsset>(*ObjIt))
|
|
||||||
{
|
|
||||||
TSharedRef<FShapeAssetEditor> EditorToolkit = MakeShareable(new FShapeAssetEditor());
|
|
||||||
EditorToolkit->Initialize(Mode, EditWithinLevelEditor, BagShapeAsset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint32 FShapeAssetTypeAction::GetCategories()
|
|
||||||
{
|
|
||||||
//系统原有
|
|
||||||
//return EAssetTypeCategories::Gameplay;
|
|
||||||
return MyAssetCategory;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FShapeAssetTypeAction::GetActions(const TArray<UObject*>& InObjects, struct FToolMenuSection& Section)
|
|
||||||
{
|
|
||||||
FAssetTypeActions_Base::GetActions(InObjects, Section);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "AssetEditor/BagShapeAssetEditor.h"
|
||||||
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
#include "Widgets/BagShapeEditorWidget.h"
|
||||||
|
|
||||||
|
const FName FBagShapeAssetEditor::BagShapeEditorTabId(TEXT("BagShapeEditor"));
|
||||||
|
|
||||||
|
void FBagShapeAssetEditor::Initialize(const EToolkitMode::Type Mode,
|
||||||
|
const TSharedPtr<class IToolkitHost>& InitToolkitHost, UBagShapeAsset* InBagShapeAsset)
|
||||||
|
{
|
||||||
|
BagShapeAsset = InBagShapeAsset;
|
||||||
|
|
||||||
|
const TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout("Standalone_BagShapeAssetEditor_Layout_v1")
|
||||||
|
->AddArea
|
||||||
|
(
|
||||||
|
FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
|
||||||
|
->Split
|
||||||
|
(
|
||||||
|
FTabManager::NewStack()
|
||||||
|
->SetSizeCoefficient(1.0f)
|
||||||
|
->AddTab(BagShapeEditorTabId, ETabState::OpenedTab)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
FAssetEditorToolkit::InitAssetEditor(Mode, InitToolkitHost, TEXT("BagShapeAssetEditorApp"), StandaloneDefaultLayout, true, true, InBagShapeAsset);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FName FBagShapeAssetEditor::GetToolkitFName() const
|
||||||
|
{
|
||||||
|
return FName("BagShapeEditor");
|
||||||
|
}
|
||||||
|
|
||||||
|
FText FBagShapeAssetEditor::GetBaseToolkitName() const
|
||||||
|
{
|
||||||
|
return FText::FromString("Base BagShapeEditor");
|
||||||
|
}
|
||||||
|
|
||||||
|
FString FBagShapeAssetEditor::GetWorldCentricTabPrefix() const
|
||||||
|
{
|
||||||
|
return TEXT("ShapeTab");
|
||||||
|
}
|
||||||
|
|
||||||
|
FLinearColor FBagShapeAssetEditor::GetWorldCentricTabColorScale() const
|
||||||
|
{
|
||||||
|
//return FLinearColor::White;
|
||||||
|
return FLinearColor(1.f, 0.8f, 0.45f, 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FBagShapeAssetEditor::RegisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
|
||||||
|
{
|
||||||
|
WorkspaceMenuCategory = tabManager->AddLocalWorkspaceMenuCategory( FText::FromString("BagShape"));
|
||||||
|
|
||||||
|
tabManager->RegisterTabSpawner(BagShapeEditorTabId, FOnSpawnTab::CreateSP(this, &FBagShapeAssetEditor::SpawnBagShapeEditorTab))
|
||||||
|
.SetDisplayName( FText::FromString("BagShapeEditor"))
|
||||||
|
.SetGroup(WorkspaceMenuCategory.ToSharedRef());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FBagShapeAssetEditor::UnregisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
|
||||||
|
{
|
||||||
|
tabManager->UnregisterTabSpawner(BagShapeEditorTabId);
|
||||||
|
}
|
||||||
|
|
||||||
|
TSharedRef<SDockTab> FBagShapeAssetEditor::SpawnBagShapeEditorTab(const FSpawnTabArgs& Args)
|
||||||
|
{
|
||||||
|
return SNew(SDockTab)
|
||||||
|
.TabRole(ETabRole::PanelTab)
|
||||||
|
[
|
||||||
|
SNew(SBagShapeEditorWidget)
|
||||||
|
.BagShapeAsset(BagShapeAsset)
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -1,74 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "AssetEditor/ShapeAssetEditor.h"
|
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
|
||||||
#include "Widgets/BagShapeEditorWidget.h"
|
|
||||||
|
|
||||||
const FName FShapeAssetEditor::ShapeEditorTabId(TEXT("BagShapeEditor"));
|
|
||||||
|
|
||||||
void FShapeAssetEditor::Initialize(const EToolkitMode::Type Mode,
|
|
||||||
const TSharedPtr<class IToolkitHost>& InitToolkitHost, UShapeAsset* InBagShapeAsset)
|
|
||||||
{
|
|
||||||
ShapeAsset = InBagShapeAsset;
|
|
||||||
|
|
||||||
const TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout("Standalone_BagShapeAssetEditor_Layout_v1")
|
|
||||||
->AddArea
|
|
||||||
(
|
|
||||||
FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
|
|
||||||
->Split
|
|
||||||
(
|
|
||||||
FTabManager::NewStack()
|
|
||||||
->SetSizeCoefficient(1.0f)
|
|
||||||
->AddTab(ShapeEditorTabId, ETabState::OpenedTab)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
FAssetEditorToolkit::InitAssetEditor(Mode, InitToolkitHost, TEXT("BagShapeAssetEditorApp"), StandaloneDefaultLayout, true, true, InBagShapeAsset);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
FName FShapeAssetEditor::GetToolkitFName() const
|
|
||||||
{
|
|
||||||
return FName("ShapeEditor");
|
|
||||||
}
|
|
||||||
|
|
||||||
FText FShapeAssetEditor::GetBaseToolkitName() const
|
|
||||||
{
|
|
||||||
return FText::FromString("Base ShapeEditor");
|
|
||||||
}
|
|
||||||
|
|
||||||
FString FShapeAssetEditor::GetWorldCentricTabPrefix() const
|
|
||||||
{
|
|
||||||
return TEXT("ShapeTab");
|
|
||||||
}
|
|
||||||
|
|
||||||
FLinearColor FShapeAssetEditor::GetWorldCentricTabColorScale() const
|
|
||||||
{
|
|
||||||
//return FLinearColor::White;
|
|
||||||
return FLinearColor(1.f, 0.8f, 0.45f, 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FShapeAssetEditor::RegisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
|
|
||||||
{
|
|
||||||
WorkspaceMenuCategory = tabManager->AddLocalWorkspaceMenuCategory( FText::FromString("BagShape"));
|
|
||||||
|
|
||||||
tabManager->RegisterTabSpawner(ShapeEditorTabId, FOnSpawnTab::CreateSP(this, &FShapeAssetEditor::SpawnBagShapeEditorTab))
|
|
||||||
.SetDisplayName( FText::FromString("BagShapeEditor"))
|
|
||||||
.SetGroup(WorkspaceMenuCategory.ToSharedRef());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FShapeAssetEditor::UnregisterTabSpawners(const TSharedRef<FTabManager>& tabManager)
|
|
||||||
{
|
|
||||||
tabManager->UnregisterTabSpawner(ShapeEditorTabId);
|
|
||||||
}
|
|
||||||
|
|
||||||
TSharedRef<SDockTab> FShapeAssetEditor::SpawnBagShapeEditorTab(const FSpawnTabArgs& Args)
|
|
||||||
{
|
|
||||||
return SNew(SDockTab)
|
|
||||||
.TabRole(ETabRole::PanelTab)
|
|
||||||
[
|
|
||||||
SNew(SShapeEditorWidget)
|
|
||||||
.BagShapeAsset(ShapeAsset)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "Factory/BagShapeFactory.h"
|
||||||
|
|
||||||
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
|
UBagShapeFactory::UBagShapeFactory()
|
||||||
|
{
|
||||||
|
SupportedClass = UBagShapeAsset::StaticClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
UObject* UBagShapeFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
UBagShapeAsset* NewBagShapeAsset = NewObject<UBagShapeAsset>(InParent, Class, Name, Flags | RF_Transactional);
|
||||||
|
if (NewBagShapeAsset)
|
||||||
|
{
|
||||||
|
NewBagShapeAsset->BagWidth = 5;
|
||||||
|
NewBagShapeAsset->BagHeight = 5;
|
||||||
|
NewBagShapeAsset->InitializeBagShape();
|
||||||
|
}
|
||||||
|
return NewBagShapeAsset;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UBagShapeFactory::ShouldShowInNewMenu() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@ -1,30 +0,0 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
|
||||||
|
|
||||||
|
|
||||||
#include "Factory/ShapeFactory.h"
|
|
||||||
|
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
|
||||||
|
|
||||||
UShapeFactory::UShapeFactory()
|
|
||||||
{
|
|
||||||
SupportedClass = UShapeAsset::StaticClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
UObject* UShapeFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
UShapeAsset* NewBagShapeAsset = NewObject<UShapeAsset>(InParent, Class, Name, Flags | RF_Transactional);
|
|
||||||
if (NewBagShapeAsset)
|
|
||||||
{
|
|
||||||
NewBagShapeAsset->ShapeWidth = 5;
|
|
||||||
NewBagShapeAsset->ShapeHeight = 5;
|
|
||||||
NewBagShapeAsset->InitializeShape();
|
|
||||||
}
|
|
||||||
return NewBagShapeAsset;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UShapeFactory::ShouldShowInNewMenu() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@ -3,10 +3,10 @@
|
|||||||
#include "AssetTypeActions_Base.h"
|
#include "AssetTypeActions_Base.h"
|
||||||
#include "DataTableRowSelectorCustomization.h"
|
#include "DataTableRowSelectorCustomization.h"
|
||||||
#include "AssetActions/BagConfigAssetTypeAction.h"
|
#include "AssetActions/BagConfigAssetTypeAction.h"
|
||||||
#include "AssetActions/ShapeAssetTypeAction.h"
|
#include "AssetActions/BagShapeAssetTypeAction.h"
|
||||||
#include "AssetRegistry/AssetRegistryModule.h"
|
#include "AssetRegistry/AssetRegistryModule.h"
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
#include "../Public/Thumbnail/ShapeAssetThumbnailRenderer.h"
|
#include "../Public/Thumbnail/BagShapeAssetThumbnailRenderer.h"
|
||||||
#include "../Public/Thumbnail/BagConfigThumbnailRenderer.h"
|
#include "../Public/Thumbnail/BagConfigThumbnailRenderer.h"
|
||||||
#include "AssetActions/SkillAssetTypeAction.h"
|
#include "AssetActions/SkillAssetTypeAction.h"
|
||||||
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
||||||
@ -44,7 +44,7 @@ void FProjectFishEditorModule::RegisterAssetTypeActions()
|
|||||||
//注册背包形状的菜单
|
//注册背包形状的菜单
|
||||||
EAssetTypeCategories::Type BogShapeAssetCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("BagShape")), FText::FromString(TEXT("BagSystem")));
|
EAssetTypeCategories::Type BogShapeAssetCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("BagShape")), FText::FromString(TEXT("BagSystem")));
|
||||||
//BagShape
|
//BagShape
|
||||||
TSharedRef<FAssetTypeActions_Base> BagShapeAction = MakeShareable(new FShapeAssetTypeAction(BogShapeAssetCategory));
|
TSharedRef<FAssetTypeActions_Base> BagShapeAction = MakeShareable(new FBagShapeAssetTypeAction(BogShapeAssetCategory));
|
||||||
AssetTools.RegisterAssetTypeActions(BagShapeAction);
|
AssetTools.RegisterAssetTypeActions(BagShapeAction);
|
||||||
CreatedAssetTypeActions.Add(BagShapeAction);
|
CreatedAssetTypeActions.Add(BagShapeAction);
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ void FProjectFishEditorModule::UnregisterAssetTypeActions()
|
|||||||
|
|
||||||
void FProjectFishEditorModule::RegisterThumbnailRenderers()
|
void FProjectFishEditorModule::RegisterThumbnailRenderers()
|
||||||
{
|
{
|
||||||
UThumbnailManager::Get().RegisterCustomRenderer(UShapeAsset::StaticClass(), UShapeAssetThumbnailRenderer::StaticClass());
|
UThumbnailManager::Get().RegisterCustomRenderer(UBagShapeAsset::StaticClass(), UBagShapeAssetThumbnailRenderer::StaticClass());
|
||||||
UThumbnailManager::Get().RegisterCustomRenderer(UBagConfigAsset::StaticClass(), UBagConfigThumbnailRenderer::StaticClass());
|
UThumbnailManager::Get().RegisterCustomRenderer(UBagConfigAsset::StaticClass(), UBagConfigThumbnailRenderer::StaticClass());
|
||||||
RefreshExistingAssetThumbnails();
|
RefreshExistingAssetThumbnails();
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ void FProjectFishEditorModule::UnregisterThumbnailRenderers()
|
|||||||
{
|
{
|
||||||
if (UObjectInitialized())
|
if (UObjectInitialized())
|
||||||
{
|
{
|
||||||
UThumbnailManager::Get().UnregisterCustomRenderer(UShapeAsset::StaticClass());
|
UThumbnailManager::Get().UnregisterCustomRenderer(UBagShapeAsset::StaticClass());
|
||||||
UThumbnailManager::Get().UnregisterCustomRenderer(UBagConfigAsset::StaticClass());
|
UThumbnailManager::Get().UnregisterCustomRenderer(UBagConfigAsset::StaticClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ void FProjectFishEditorModule::RefreshExistingAssetThumbnails()
|
|||||||
|
|
||||||
// 查找所有BagShapeAsset资产
|
// 查找所有BagShapeAsset资产
|
||||||
TArray<FAssetData> BagShapeAssetList;
|
TArray<FAssetData> BagShapeAssetList;
|
||||||
AssetRegistry.GetAssetsByClass(UShapeAsset::StaticClass()->GetClassPathName(), BagShapeAssetList);
|
AssetRegistry.GetAssetsByClass(UBagShapeAsset::StaticClass()->GetClassPathName(), BagShapeAssetList);
|
||||||
|
|
||||||
// 查找所有BagClass资产
|
// 查找所有BagClass资产
|
||||||
TArray<FAssetData> BagConfigAssetList;
|
TArray<FAssetData> BagConfigAssetList;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include "CanvasItem.h"
|
#include "CanvasItem.h"
|
||||||
#include "CanvasTypes.h"
|
#include "CanvasTypes.h"
|
||||||
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
bool UBagConfigThumbnailRenderer::CanVisualizeAsset(UObject* Object)
|
bool UBagConfigThumbnailRenderer::CanVisualizeAsset(UObject* Object)
|
||||||
{
|
{
|
||||||
@ -43,7 +43,7 @@ void UBagConfigThumbnailRenderer::DrawBag(UBagConfigAsset* BagConfig, FCanvas* C
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UShapeAsset* BagShapeAsset = BagConfig->BagShapeAsset;
|
UBagShapeAsset* BagShapeAsset = BagConfig->BagShapeAsset;
|
||||||
|
|
||||||
// Clear the background
|
// Clear the background
|
||||||
FCanvasBoxItem BackgroundBox(FVector2D(X, Y), FVector2D(Width, Height));
|
FCanvasBoxItem BackgroundBox(FVector2D(X, Y), FVector2D(Width, Height));
|
||||||
@ -52,19 +52,19 @@ void UBagConfigThumbnailRenderer::DrawBag(UBagConfigAsset* BagConfig, FCanvas* C
|
|||||||
|
|
||||||
// Calculate the best fit scale with spacing for separators
|
// Calculate the best fit scale with spacing for separators
|
||||||
float SeparatorWidth = 2.0f; // White separator width
|
float SeparatorWidth = 2.0f; // White separator width
|
||||||
float Scale = GetBestFitScale(BagShapeAsset->ShapeWidth, BagShapeAsset->ShapeHeight, Width, Height);
|
float Scale = GetBestFitScale(BagShapeAsset->BagWidth, BagShapeAsset->BagHeight, Width, Height);
|
||||||
float CellSize = Scale - SeparatorWidth; // Reduce cell size to make room for separators
|
float CellSize = Scale - SeparatorWidth; // Reduce cell size to make room for separators
|
||||||
|
|
||||||
// Calculate starting position to center the grid (including separators)
|
// Calculate starting position to center the grid (including separators)
|
||||||
float GridWidth = BagShapeAsset->ShapeWidth * Scale - SeparatorWidth;
|
float GridWidth = BagShapeAsset->BagWidth * Scale - SeparatorWidth;
|
||||||
float GridHeight = BagShapeAsset->ShapeHeight * Scale - SeparatorWidth;
|
float GridHeight = BagShapeAsset->BagHeight * Scale - SeparatorWidth;
|
||||||
float StartX = X + (Width - GridWidth) * 0.5f;
|
float StartX = X + (Width - GridWidth) * 0.5f;
|
||||||
float StartY = Y + (Height - GridHeight) * 0.5f;
|
float StartY = Y + (Height - GridHeight) * 0.5f;
|
||||||
|
|
||||||
// Draw the bag slots (background) with separators
|
// Draw the bag slots (background) with separators
|
||||||
for (int32 GridY = 0; GridY < BagShapeAsset->ShapeHeight; GridY++)
|
for (int32 GridY = 0; GridY < BagShapeAsset->BagHeight; GridY++)
|
||||||
{
|
{
|
||||||
for (int32 GridX = 0; GridX < BagShapeAsset->ShapeWidth; GridX++)
|
for (int32 GridX = 0; GridX < BagShapeAsset->BagWidth; GridX++)
|
||||||
{
|
{
|
||||||
float CellStartX = StartX + GridX * Scale;
|
float CellStartX = StartX + GridX * Scale;
|
||||||
float CellStartY = StartY + GridY * Scale;
|
float CellStartY = StartY + GridY * Scale;
|
||||||
@ -81,7 +81,7 @@ void UBagConfigThumbnailRenderer::DrawBag(UBagConfigAsset* BagConfig, FCanvas* C
|
|||||||
|
|
||||||
// Draw white separators
|
// Draw white separators
|
||||||
// Vertical separators
|
// Vertical separators
|
||||||
for (int32 GridX = 1; GridX < BagShapeAsset->ShapeWidth; GridX++)
|
for (int32 GridX = 1; GridX < BagShapeAsset->BagWidth; GridX++)
|
||||||
{
|
{
|
||||||
float SeparatorX = StartX + GridX * Scale - SeparatorWidth;
|
float SeparatorX = StartX + GridX * Scale - SeparatorWidth;
|
||||||
FCanvasTileItem VerticalSeparator(FVector2D(SeparatorX, StartY), FVector2D(SeparatorWidth, GridHeight), FLinearColor::White);
|
FCanvasTileItem VerticalSeparator(FVector2D(SeparatorX, StartY), FVector2D(SeparatorWidth, GridHeight), FLinearColor::White);
|
||||||
@ -90,7 +90,7 @@ void UBagConfigThumbnailRenderer::DrawBag(UBagConfigAsset* BagConfig, FCanvas* C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Horizontal separators
|
// Horizontal separators
|
||||||
for (int32 GridY = 1; GridY < BagShapeAsset->ShapeHeight; GridY++)
|
for (int32 GridY = 1; GridY < BagShapeAsset->BagHeight; GridY++)
|
||||||
{
|
{
|
||||||
float SeparatorY = StartY + GridY * Scale - SeparatorWidth;
|
float SeparatorY = StartY + GridY * Scale - SeparatorWidth;
|
||||||
FCanvasTileItem HorizontalSeparator(FVector2D(StartX, SeparatorY), FVector2D(GridWidth, SeparatorWidth), FLinearColor::White);
|
FCanvasTileItem HorizontalSeparator(FVector2D(StartX, SeparatorY), FVector2D(GridWidth, SeparatorWidth), FLinearColor::White);
|
||||||
@ -111,10 +111,10 @@ void UBagConfigThumbnailRenderer::DrawBag(UBagConfigAsset* BagConfig, FCanvas* C
|
|||||||
Canvas->DrawItem(OuterBorder);
|
Canvas->DrawItem(OuterBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
float UBagConfigThumbnailRenderer::GetBestFitScale(int32 ShapeWidth, int32 ShapeHeight, uint32 CanvasWidth,
|
float UBagConfigThumbnailRenderer::GetBestFitScale(int32 BagWidth, int32 BagHeight, uint32 CanvasWidth,
|
||||||
uint32 CanvasHeight) const
|
uint32 CanvasHeight) const
|
||||||
{
|
{
|
||||||
if (ShapeWidth == 0 || ShapeHeight == 0)
|
if (BagWidth == 0 || BagHeight == 0)
|
||||||
{
|
{
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
@ -123,8 +123,8 @@ float UBagConfigThumbnailRenderer::GetBestFitScale(int32 ShapeWidth, int32 Shape
|
|||||||
float PaddedWidth = CanvasWidth * 0.85f;
|
float PaddedWidth = CanvasWidth * 0.85f;
|
||||||
float PaddedHeight = CanvasHeight * 0.85f;
|
float PaddedHeight = CanvasHeight * 0.85f;
|
||||||
|
|
||||||
float ScaleX = PaddedWidth / ShapeWidth;
|
float ScaleX = PaddedWidth / BagWidth;
|
||||||
float ScaleY = PaddedHeight / ShapeHeight;
|
float ScaleY = PaddedHeight / BagHeight;
|
||||||
|
|
||||||
// Use the smaller scale to ensure everything fits
|
// Use the smaller scale to ensure everything fits
|
||||||
float Scale = FMath::Min(ScaleX, ScaleY);
|
float Scale = FMath::Min(ScaleX, ScaleY);
|
||||||
|
|||||||
@ -1,21 +1,21 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
#include "ProjectFishEditor/Public/Thumbnail/ShapeAssetThumbnailRenderer.h"
|
#include "ProjectFishEditor/Public/Thumbnail/BagShapeAssetThumbnailRenderer.h"
|
||||||
|
|
||||||
#include "CanvasItem.h"
|
#include "CanvasItem.h"
|
||||||
#include "CanvasTypes.h"
|
#include "CanvasTypes.h"
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
bool UShapeAssetThumbnailRenderer::CanVisualizeAsset(UObject* Object)
|
bool UBagShapeAssetThumbnailRenderer::CanVisualizeAsset(UObject* Object)
|
||||||
{
|
{
|
||||||
return Cast<UShapeAsset>(Object) != nullptr;
|
return Cast<UBagShapeAsset>(Object) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UShapeAssetThumbnailRenderer::Draw(UObject* Object, int32 X, int32 Y, uint32 Width, uint32 Height,
|
void UBagShapeAssetThumbnailRenderer::Draw(UObject* Object, int32 X, int32 Y, uint32 Width, uint32 Height,
|
||||||
FRenderTarget* RenderTarget, FCanvas* Canvas, bool bAdditionalViewFamily)
|
FRenderTarget* RenderTarget, FCanvas* Canvas, bool bAdditionalViewFamily)
|
||||||
{
|
{
|
||||||
UShapeAsset* BagShapeAsset = Cast<UShapeAsset>(Object);
|
UBagShapeAsset* BagShapeAsset = Cast<UBagShapeAsset>(Object);
|
||||||
if (!BagShapeAsset || !Canvas)
|
if (!BagShapeAsset || !Canvas)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -24,7 +24,7 @@ void UShapeAssetThumbnailRenderer::Draw(UObject* Object, int32 X, int32 Y, uint3
|
|||||||
DrawBagShape(BagShapeAsset, Canvas, X, Y, Width, Height);
|
DrawBagShape(BagShapeAsset, Canvas, X, Y, Width, Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UShapeAssetThumbnailRenderer::DrawBagShape(UShapeAsset* BagShapeAsset, FCanvas* Canvas, int32 X, int32 Y,
|
void UBagShapeAssetThumbnailRenderer::DrawBagShape(UBagShapeAsset* BagShapeAsset, FCanvas* Canvas, int32 X, int32 Y,
|
||||||
uint32 Width, uint32 Height)
|
uint32 Width, uint32 Height)
|
||||||
{
|
{
|
||||||
if (!BagShapeAsset || !Canvas)
|
if (!BagShapeAsset || !Canvas)
|
||||||
@ -39,19 +39,19 @@ void UShapeAssetThumbnailRenderer::DrawBagShape(UShapeAsset* BagShapeAsset, FCan
|
|||||||
|
|
||||||
// Calculate the best fit scale with spacing for separators
|
// Calculate the best fit scale with spacing for separators
|
||||||
float SeparatorWidth = 2.0f; // White separator width
|
float SeparatorWidth = 2.0f; // White separator width
|
||||||
float Scale = GetBestFitScale(BagShapeAsset->ShapeWidth, BagShapeAsset->ShapeHeight, Width, Height);
|
float Scale = GetBestFitScale(BagShapeAsset->BagWidth, BagShapeAsset->BagHeight, Width, Height);
|
||||||
float CellSize = Scale - SeparatorWidth; // Reduce cell size to make room for separators
|
float CellSize = Scale - SeparatorWidth; // Reduce cell size to make room for separators
|
||||||
|
|
||||||
// Calculate starting position to center the grid (including separators)
|
// Calculate starting position to center the grid (including separators)
|
||||||
float GridWidth = BagShapeAsset->ShapeWidth * Scale - SeparatorWidth;
|
float GridWidth = BagShapeAsset->BagWidth * Scale - SeparatorWidth;
|
||||||
float GridHeight = BagShapeAsset->ShapeHeight * Scale - SeparatorWidth;
|
float GridHeight = BagShapeAsset->BagHeight * Scale - SeparatorWidth;
|
||||||
float StartX = X + (Width - GridWidth) * 0.5f;
|
float StartX = X + (Width - GridWidth) * 0.5f;
|
||||||
float StartY = Y + (Height - GridHeight) * 0.5f;
|
float StartY = Y + (Height - GridHeight) * 0.5f;
|
||||||
|
|
||||||
// Draw the bag slots (background) with separators
|
// Draw the bag slots (background) with separators
|
||||||
for (int32 GridY = 0; GridY < BagShapeAsset->ShapeHeight; GridY++)
|
for (int32 GridY = 0; GridY < BagShapeAsset->BagHeight; GridY++)
|
||||||
{
|
{
|
||||||
for (int32 GridX = 0; GridX < BagShapeAsset->ShapeWidth; GridX++)
|
for (int32 GridX = 0; GridX < BagShapeAsset->BagWidth; GridX++)
|
||||||
{
|
{
|
||||||
float CellStartX = StartX + GridX * Scale;
|
float CellStartX = StartX + GridX * Scale;
|
||||||
float CellStartY = StartY + GridY * Scale;
|
float CellStartY = StartY + GridY * Scale;
|
||||||
@ -92,7 +92,7 @@ void UShapeAssetThumbnailRenderer::DrawBagShape(UShapeAsset* BagShapeAsset, FCan
|
|||||||
// Canvas->DrawItem(OuterBorder);
|
// Canvas->DrawItem(OuterBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
float UShapeAssetThumbnailRenderer::GetBestFitScale(int32 BagWidth, int32 BagHeight, uint32 CanvasWidth,
|
float UBagShapeAssetThumbnailRenderer::GetBestFitScale(int32 BagWidth, int32 BagHeight, uint32 CanvasWidth,
|
||||||
uint32 CanvasHeight) const
|
uint32 CanvasHeight) const
|
||||||
{
|
{
|
||||||
if (BagWidth == 0 || BagHeight == 0)
|
if (BagWidth == 0 || BagHeight == 0)
|
||||||
@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
#include "PropertyCustomizationHelpers.h"
|
#include "PropertyCustomizationHelpers.h"
|
||||||
#include "Framework/Notifications/NotificationManager.h"
|
#include "Framework/Notifications/NotificationManager.h"
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
#include "Widgets/BagConfigGridWidget.h"
|
#include "Widgets/BagConfigGridWidget.h"
|
||||||
#include "Widgets/ShapeGridWidget.h"
|
#include "Widgets/BagShapeGridWidget.h"
|
||||||
#include "Widgets/SkillListWidget.h"
|
#include "Widgets/SkillListWidget.h"
|
||||||
#include "Widgets/Notifications/SNotificationList.h"
|
#include "Widgets/Notifications/SNotificationList.h"
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ void SBagConfigEditorWidget::Construct(const FArguments& InArgs)
|
|||||||
return BagConfig.IsValid() && BagConfig->BagShapeAsset ?
|
return BagConfig.IsValid() && BagConfig->BagShapeAsset ?
|
||||||
BagConfig->BagShapeAsset->GetPathName() : FString();
|
BagConfig->BagShapeAsset->GetPathName() : FString();
|
||||||
})
|
})
|
||||||
.AllowedClass(UShapeAsset::StaticClass())
|
.AllowedClass(UBagShapeAsset::StaticClass())
|
||||||
.OnObjectChanged(this, &SBagConfigEditorWidget::OnBagShapeAssetChanged)
|
.OnObjectChanged(this, &SBagConfigEditorWidget::OnBagShapeAssetChanged)
|
||||||
.DisplayUseSelected(true)
|
.DisplayUseSelected(true)
|
||||||
.DisplayBrowse(true)
|
.DisplayBrowse(true)
|
||||||
@ -167,8 +167,8 @@ void SBagConfigEditorWidget::Construct(const FArguments& InArgs)
|
|||||||
{
|
{
|
||||||
return FText::FromString(FString::Printf(TEXT("Bag: %s (%dx%d)"),
|
return FText::FromString(FString::Printf(TEXT("Bag: %s (%dx%d)"),
|
||||||
*BagConfig->BagShapeAsset->GetName(),
|
*BagConfig->BagShapeAsset->GetName(),
|
||||||
BagConfig->BagShapeAsset->ShapeWidth,
|
BagConfig->BagShapeAsset->BagWidth,
|
||||||
BagConfig->BagShapeAsset->ShapeHeight));
|
BagConfig->BagShapeAsset->BagHeight));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.Font(FCoreStyle::GetDefaultFontStyle("Bold", 12))
|
.Font(FCoreStyle::GetDefaultFontStyle("Bold", 12))
|
||||||
@ -284,7 +284,7 @@ void SBagConfigEditorWidget::OnBagShapeAssetChanged(const FAssetData& AssetData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取新选择的BagShapeAsset
|
// 获取新选择的BagShapeAsset
|
||||||
UShapeAsset* NewBagShapeAsset = Cast<UShapeAsset>(AssetData.GetAsset());
|
UBagShapeAsset* NewBagShapeAsset = Cast<UBagShapeAsset>(AssetData.GetAsset());
|
||||||
|
|
||||||
// 如果选择了不同的资源,清空现有技能并更新引用
|
// 如果选择了不同的资源,清空现有技能并更新引用
|
||||||
if (BagConfig->BagShapeAsset != NewBagShapeAsset)
|
if (BagConfig->BagShapeAsset != NewBagShapeAsset)
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "Widgets/BagConfigGridWidget.h"
|
#include "Widgets/BagConfigGridWidget.h"
|
||||||
|
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
const float SBagConfigGridWidget::CellSize = 32.0f;
|
const float SBagConfigGridWidget::CellSize = 32.0f;
|
||||||
const float SBagConfigGridWidget::CellSpacing = 2.0f;
|
const float SBagConfigGridWidget::CellSpacing = 2.0f;
|
||||||
@ -130,12 +130,12 @@ int32 SBagConfigGridWidget::OnPaint(const FPaintArgs& Args, const FGeometry& All
|
|||||||
return LayerId;
|
return LayerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
UShapeAsset* BagShapeAsset = BagConfig->BagShapeAsset;
|
UBagShapeAsset* BagShapeAsset = BagConfig->BagShapeAsset;
|
||||||
|
|
||||||
// 绘制背包格子
|
// 绘制背包格子
|
||||||
for (int32 Y = 0; Y < BagShapeAsset->ShapeHeight; Y++)
|
for (int32 Y = 0; Y < BagShapeAsset->BagHeight; Y++)
|
||||||
{
|
{
|
||||||
for (int32 X = 0; X < BagShapeAsset->ShapeWidth; X++)
|
for (int32 X = 0; X < BagShapeAsset->BagWidth; X++)
|
||||||
{
|
{
|
||||||
FVector2D CellPos = GetCellPosition(X, Y);
|
FVector2D CellPos = GetCellPosition(X, Y);
|
||||||
FVector2D CellSizeVec(CellSize, CellSize);
|
FVector2D CellSizeVec(CellSize, CellSize);
|
||||||
@ -251,10 +251,10 @@ FVector2D SBagConfigGridWidget::ComputeDesiredSize(float X) const
|
|||||||
return FVector2D(100, 100);
|
return FVector2D(100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
UShapeAsset* BagShapeAsset = BagConfig->BagShapeAsset;
|
UBagShapeAsset* BagShapeAsset = BagConfig->BagShapeAsset;
|
||||||
return FVector2D(
|
return FVector2D(
|
||||||
BagShapeAsset->ShapeWidth * (CellSize + CellSpacing) - CellSpacing,
|
BagShapeAsset->BagWidth * (CellSize + CellSpacing) - CellSpacing,
|
||||||
BagShapeAsset->ShapeHeight * (CellSize + CellSpacing) - CellSpacing
|
BagShapeAsset->BagHeight * (CellSize + CellSpacing) - CellSpacing
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,8 +273,8 @@ bool SBagConfigGridWidget::IsValidGridPosition(int32 X, int32 Y) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return X >= 0 && X < BagConfig->BagShapeAsset->ShapeWidth &&
|
return X >= 0 && X < BagConfig->BagShapeAsset->BagWidth &&
|
||||||
Y >= 0 && Y < BagConfig->BagShapeAsset->ShapeHeight;
|
Y >= 0 && Y < BagConfig->BagShapeAsset->BagHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLinearColor SBagConfigGridWidget::GetCellColor(int32 X, int32 Y) const
|
FLinearColor SBagConfigGridWidget::GetCellColor(int32 X, int32 Y) const
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include "EditorStyleSet.h"
|
#include "EditorStyleSet.h"
|
||||||
|
|
||||||
|
|
||||||
void SShapeEditorWidget::Construct(const FArguments& InArgs)
|
void SBagShapeEditorWidget::Construct(const FArguments& InArgs)
|
||||||
{
|
{
|
||||||
BagShapeAsset = InArgs._BagShapeAsset;
|
BagShapeAsset = InArgs._BagShapeAsset;
|
||||||
|
|
||||||
@ -38,9 +38,9 @@ void SShapeEditorWidget::Construct(const FArguments& InArgs)
|
|||||||
.HAlign(HAlign_Center)
|
.HAlign(HAlign_Center)
|
||||||
.VAlign(VAlign_Center)
|
.VAlign(VAlign_Center)
|
||||||
[
|
[
|
||||||
SAssignNew(GridWidget, SShapeGridWidget)
|
SAssignNew(GridWidget, SBagShapeGridWidget)
|
||||||
.BagShapeAsset(BagShapeAsset.Get())
|
.BagShapeAsset(BagShapeAsset.Get())
|
||||||
.OnSlotClicked(this, &SShapeEditorWidget::OnSlotClicked)
|
.OnSlotClicked(this, &SBagShapeEditorWidget::OnSlotClicked)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -48,7 +48,7 @@ void SShapeEditorWidget::Construct(const FArguments& InArgs)
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
void SShapeEditorWidget::RefreshGrid()
|
void SBagShapeEditorWidget::RefreshGrid()
|
||||||
{
|
{
|
||||||
if (GridWidget.IsValid())
|
if (GridWidget.IsValid())
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ void SShapeEditorWidget::RefreshGrid()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TSharedRef<SWidget> SShapeEditorWidget::CreateSizeControls()
|
TSharedRef<SWidget> SBagShapeEditorWidget::CreateSizeControls()
|
||||||
{
|
{
|
||||||
return SNew(SBorder)
|
return SNew(SBorder)
|
||||||
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
|
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
|
||||||
@ -93,8 +93,8 @@ TSharedRef<SWidget> SShapeEditorWidget::CreateSizeControls()
|
|||||||
SNew(SSpinBox<int32>)
|
SNew(SSpinBox<int32>)
|
||||||
.MinValue(1)
|
.MinValue(1)
|
||||||
.MaxValue(10)
|
.MaxValue(10)
|
||||||
.Value(this, &SShapeEditorWidget::GetShapeWidth)
|
.Value(this, &SBagShapeEditorWidget::GetBagWidth)
|
||||||
.OnValueChanged(this, &SShapeEditorWidget::OnWidthChanged)
|
.OnValueChanged(this, &SBagShapeEditorWidget::OnWidthChanged)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
+ SHorizontalBox::Slot()
|
+ SHorizontalBox::Slot()
|
||||||
@ -114,47 +114,47 @@ TSharedRef<SWidget> SShapeEditorWidget::CreateSizeControls()
|
|||||||
SNew(SSpinBox<int32>)
|
SNew(SSpinBox<int32>)
|
||||||
.MinValue(1)
|
.MinValue(1)
|
||||||
.MaxValue(10)
|
.MaxValue(10)
|
||||||
.Value(this, &SShapeEditorWidget::GetShapeHeight)
|
.Value(this, &SBagShapeEditorWidget::GetBagHeight)
|
||||||
.OnValueChanged(this, &SShapeEditorWidget::OnHeightChanged)
|
.OnValueChanged(this, &SBagShapeEditorWidget::OnHeightChanged)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 SShapeEditorWidget::GetShapeWidth() const
|
int32 SBagShapeEditorWidget::GetBagWidth() const
|
||||||
{
|
{
|
||||||
return BagShapeAsset.IsValid() ? BagShapeAsset->ShapeWidth : 5;
|
return BagShapeAsset.IsValid() ? BagShapeAsset->BagWidth : 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 SShapeEditorWidget::GetShapeHeight() const
|
int32 SBagShapeEditorWidget::GetBagHeight() const
|
||||||
{
|
{
|
||||||
return BagShapeAsset.IsValid() ? BagShapeAsset->ShapeHeight : 5;
|
return BagShapeAsset.IsValid() ? BagShapeAsset->BagHeight : 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SShapeEditorWidget::OnWidthChanged(int32 NewWidth)
|
void SBagShapeEditorWidget::OnWidthChanged(int32 NewWidth)
|
||||||
{
|
{
|
||||||
if (BagShapeAsset.IsValid() && NewWidth != BagShapeAsset->ShapeWidth)
|
if (BagShapeAsset.IsValid() && NewWidth != BagShapeAsset->BagWidth)
|
||||||
{
|
{
|
||||||
BagShapeAsset->ShapeWidth = NewWidth;
|
BagShapeAsset->BagWidth = NewWidth;
|
||||||
BagShapeAsset->InitializeShape();
|
BagShapeAsset->InitializeBagShape();
|
||||||
BagShapeAsset->MarkPackageDirty();
|
BagShapeAsset->MarkPackageDirty();
|
||||||
RefreshGrid();
|
RefreshGrid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SShapeEditorWidget::OnHeightChanged(int32 NewHeight)
|
void SBagShapeEditorWidget::OnHeightChanged(int32 NewHeight)
|
||||||
{
|
{
|
||||||
if (BagShapeAsset.IsValid() && NewHeight != BagShapeAsset->ShapeHeight)
|
if (BagShapeAsset.IsValid() && NewHeight != BagShapeAsset->BagHeight)
|
||||||
{
|
{
|
||||||
BagShapeAsset->ShapeHeight = NewHeight;
|
BagShapeAsset->BagHeight = NewHeight;
|
||||||
BagShapeAsset->InitializeShape();
|
BagShapeAsset->InitializeBagShape();
|
||||||
BagShapeAsset->MarkPackageDirty();
|
BagShapeAsset->MarkPackageDirty();
|
||||||
RefreshGrid();
|
RefreshGrid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TSharedRef<SWidget> SShapeEditorWidget::CreateGridControls()
|
TSharedRef<SWidget> SBagShapeEditorWidget::CreateGridControls()
|
||||||
{
|
{
|
||||||
return SNew(SBorder)
|
return SNew(SBorder)
|
||||||
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
|
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
|
||||||
@ -167,7 +167,7 @@ TSharedRef<SWidget> SShapeEditorWidget::CreateGridControls()
|
|||||||
[
|
[
|
||||||
SNew(SButton)
|
SNew(SButton)
|
||||||
.Text(FText::FromString("All Enable"))
|
.Text(FText::FromString("All Enable"))
|
||||||
.OnClicked(this, &SShapeEditorWidget::OnAllEnableClicked)
|
.OnClicked(this, &SBagShapeEditorWidget::OnAllEnableClicked)
|
||||||
]
|
]
|
||||||
+ SHorizontalBox::Slot()
|
+ SHorizontalBox::Slot()
|
||||||
.AutoWidth()
|
.AutoWidth()
|
||||||
@ -175,17 +175,17 @@ TSharedRef<SWidget> SShapeEditorWidget::CreateGridControls()
|
|||||||
[
|
[
|
||||||
SNew(SButton)
|
SNew(SButton)
|
||||||
.Text(FText::FromString("All Disable"))
|
.Text(FText::FromString("All Disable"))
|
||||||
.OnClicked(this, &SShapeEditorWidget::OnAllDisableClicked)
|
.OnClicked(this, &SBagShapeEditorWidget::OnAllDisableClicked)
|
||||||
]
|
]
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
FReply SShapeEditorWidget::OnAllEnableClicked()
|
FReply SBagShapeEditorWidget::OnAllEnableClicked()
|
||||||
{
|
{
|
||||||
if (BagShapeAsset.IsValid())
|
if (BagShapeAsset.IsValid())
|
||||||
{
|
{
|
||||||
BagShapeAsset->InitializeShape();
|
BagShapeAsset->InitializeBagShape();
|
||||||
BagShapeAsset->MarkPackageDirty();
|
BagShapeAsset->MarkPackageDirty();
|
||||||
RefreshGrid();
|
RefreshGrid();
|
||||||
RefreshThumbnail();
|
RefreshThumbnail();
|
||||||
@ -193,13 +193,13 @@ FReply SShapeEditorWidget::OnAllEnableClicked()
|
|||||||
return FReply::Handled();
|
return FReply::Handled();
|
||||||
}
|
}
|
||||||
|
|
||||||
FReply SShapeEditorWidget::OnAllDisableClicked()
|
FReply SBagShapeEditorWidget::OnAllDisableClicked()
|
||||||
{
|
{
|
||||||
if (BagShapeAsset.IsValid())
|
if (BagShapeAsset.IsValid())
|
||||||
{
|
{
|
||||||
for (int32 X = 0; X < BagShapeAsset->ShapeWidth; X++)
|
for (int32 X = 0; X < BagShapeAsset->BagWidth; X++)
|
||||||
{
|
{
|
||||||
for (int32 Y = 0; Y < BagShapeAsset->ShapeHeight; Y++)
|
for (int32 Y = 0; Y < BagShapeAsset->BagHeight; Y++)
|
||||||
{
|
{
|
||||||
BagShapeAsset->SetSlotActive(X, Y, false);
|
BagShapeAsset->SetSlotActive(X, Y, false);
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ FReply SShapeEditorWidget::OnAllDisableClicked()
|
|||||||
return FReply::Handled();
|
return FReply::Handled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SShapeEditorWidget::OnSlotClicked(int32 X, int32 Y)
|
void SBagShapeEditorWidget::OnSlotClicked(int32 X, int32 Y)
|
||||||
{
|
{
|
||||||
if (!BagShapeAsset.IsValid())
|
if (!BagShapeAsset.IsValid())
|
||||||
{
|
{
|
||||||
@ -234,7 +234,7 @@ void SShapeEditorWidget::OnSlotClicked(int32 X, int32 Y)
|
|||||||
RefreshThumbnail();
|
RefreshThumbnail();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SShapeEditorWidget::RefreshThumbnail()
|
void SBagShapeEditorWidget::RefreshThumbnail()
|
||||||
{
|
{
|
||||||
if (!BagShapeAsset.IsValid())
|
if (!BagShapeAsset.IsValid())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,23 +1,23 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
#include "Widgets/ShapeGridWidget.h"
|
#include "Widgets/BagShapeGridWidget.h"
|
||||||
|
|
||||||
const float SShapeGridWidget::CellSize = 32.0f;
|
const float SBagShapeGridWidget::CellSize = 32.0f;
|
||||||
const float SShapeGridWidget::SeparatorWidth = 2.0f;
|
const float SBagShapeGridWidget::SeparatorWidth = 2.0f;
|
||||||
void SShapeGridWidget::Construct(const FArguments& InArgs)
|
void SBagShapeGridWidget::Construct(const FArguments& InArgs)
|
||||||
{
|
{
|
||||||
BagShapeAsset = InArgs._BagShapeAsset;
|
BagShapeAsset = InArgs._BagShapeAsset;
|
||||||
OnSlotClicked = InArgs._OnSlotClicked;
|
OnSlotClicked = InArgs._OnSlotClicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SShapeGridWidget::UpdateBagShapeAsset(UShapeAsset* InBagShapeAsset)
|
void SBagShapeGridWidget::UpdateBagShapeAsset(UBagShapeAsset* InBagShapeAsset)
|
||||||
{
|
{
|
||||||
BagShapeAsset = InBagShapeAsset;
|
BagShapeAsset = InBagShapeAsset;
|
||||||
Invalidate(EInvalidateWidget::Paint);
|
Invalidate(EInvalidateWidget::Paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
FReply SShapeGridWidget::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
FReply SBagShapeGridWidget::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
||||||
{
|
{
|
||||||
if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton && BagShapeAsset.IsValid())
|
if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton && BagShapeAsset.IsValid())
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ FReply SShapeGridWidget::OnMouseButtonDown(const FGeometry& MyGeometry, const FP
|
|||||||
return FReply::Unhandled();
|
return FReply::Unhandled();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 SShapeGridWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry,
|
int32 SBagShapeGridWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry,
|
||||||
const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId,
|
const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId,
|
||||||
const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
|
const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
|
||||||
{
|
{
|
||||||
@ -48,8 +48,8 @@ int32 SShapeGridWidget::OnPaint(const FPaintArgs& Args, const FGeometry& Allotte
|
|||||||
|
|
||||||
// Calculate grid dimensions with separators
|
// Calculate grid dimensions with separators
|
||||||
float Scale = CellSize + SeparatorWidth;
|
float Scale = CellSize + SeparatorWidth;
|
||||||
float GridWidth = BagShapeAsset->ShapeWidth * Scale - SeparatorWidth;
|
float GridWidth = BagShapeAsset->BagWidth * Scale - SeparatorWidth;
|
||||||
float GridHeight = BagShapeAsset->ShapeHeight * Scale - SeparatorWidth;
|
float GridHeight = BagShapeAsset->BagHeight * Scale - SeparatorWidth;
|
||||||
|
|
||||||
// Center the grid in the available space
|
// Center the grid in the available space
|
||||||
FVector2D GridStartPos = FVector2D(
|
FVector2D GridStartPos = FVector2D(
|
||||||
@ -68,9 +68,9 @@ int32 SShapeGridWidget::OnPaint(const FPaintArgs& Args, const FGeometry& Allotte
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Draw cells
|
// Draw cells
|
||||||
for (int32 Y = 0; Y < BagShapeAsset->ShapeHeight; Y++)
|
for (int32 Y = 0; Y < BagShapeAsset->BagHeight; Y++)
|
||||||
{
|
{
|
||||||
for (int32 X = 0; X < BagShapeAsset->ShapeWidth; X++)
|
for (int32 X = 0; X < BagShapeAsset->BagWidth; X++)
|
||||||
{
|
{
|
||||||
FVector2D CellPos = GridStartPos + FVector2D(X * Scale, Y * Scale);
|
FVector2D CellPos = GridStartPos + FVector2D(X * Scale, Y * Scale);
|
||||||
bool bIsActive = BagShapeAsset->IsSlotActive(X, Y);
|
bool bIsActive = BagShapeAsset->IsSlotActive(X, Y);
|
||||||
@ -89,7 +89,7 @@ int32 SShapeGridWidget::OnPaint(const FPaintArgs& Args, const FGeometry& Allotte
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw vertical separators
|
// Draw vertical separators
|
||||||
for (int32 X = 1; X < BagShapeAsset->ShapeWidth; X++)
|
for (int32 X = 1; X < BagShapeAsset->BagWidth; X++)
|
||||||
{
|
{
|
||||||
float SeparatorX = GridStartPos.X + X * Scale - SeparatorWidth;
|
float SeparatorX = GridStartPos.X + X * Scale - SeparatorWidth;
|
||||||
FSlateDrawElement::MakeBox(
|
FSlateDrawElement::MakeBox(
|
||||||
@ -103,7 +103,7 @@ int32 SShapeGridWidget::OnPaint(const FPaintArgs& Args, const FGeometry& Allotte
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw horizontal separators
|
// Draw horizontal separators
|
||||||
for (int32 Y = 1; Y < BagShapeAsset->ShapeHeight; Y++)
|
for (int32 Y = 1; Y < BagShapeAsset->BagHeight; Y++)
|
||||||
{
|
{
|
||||||
float SeparatorY = GridStartPos.Y + Y * Scale - SeparatorWidth;
|
float SeparatorY = GridStartPos.Y + Y * Scale - SeparatorWidth;
|
||||||
FSlateDrawElement::MakeBox(
|
FSlateDrawElement::MakeBox(
|
||||||
@ -129,7 +129,7 @@ int32 SShapeGridWidget::OnPaint(const FPaintArgs& Args, const FGeometry& Allotte
|
|||||||
return LayerId + 4;
|
return LayerId + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
FVector2D SShapeGridWidget::ComputeDesiredSize(float X) const
|
FVector2D SBagShapeGridWidget::ComputeDesiredSize(float X) const
|
||||||
{
|
{
|
||||||
if (!BagShapeAsset.IsValid())
|
if (!BagShapeAsset.IsValid())
|
||||||
{
|
{
|
||||||
@ -138,12 +138,12 @@ FVector2D SShapeGridWidget::ComputeDesiredSize(float X) const
|
|||||||
|
|
||||||
float Scale = CellSize + SeparatorWidth;
|
float Scale = CellSize + SeparatorWidth;
|
||||||
return FVector2D(
|
return FVector2D(
|
||||||
BagShapeAsset->ShapeWidth * Scale - SeparatorWidth + 20.0f, // Add padding
|
BagShapeAsset->BagWidth * Scale - SeparatorWidth + 20.0f, // Add padding
|
||||||
BagShapeAsset->ShapeHeight * Scale - SeparatorWidth + 20.0f
|
BagShapeAsset->BagHeight * Scale - SeparatorWidth + 20.0f
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
FVector2D SShapeGridWidget::GetGridCellFromPosition(const FVector2D& Position) const
|
FVector2D SBagShapeGridWidget::GetGridCellFromPosition(const FVector2D& Position) const
|
||||||
{
|
{
|
||||||
if (!BagShapeAsset.IsValid())
|
if (!BagShapeAsset.IsValid())
|
||||||
{
|
{
|
||||||
@ -151,8 +151,8 @@ FVector2D SShapeGridWidget::GetGridCellFromPosition(const FVector2D& Position) c
|
|||||||
}
|
}
|
||||||
|
|
||||||
float Scale = CellSize + SeparatorWidth;
|
float Scale = CellSize + SeparatorWidth;
|
||||||
float GridWidth = BagShapeAsset->ShapeWidth * Scale - SeparatorWidth;
|
float GridWidth = BagShapeAsset->BagWidth * Scale - SeparatorWidth;
|
||||||
float GridHeight = BagShapeAsset->ShapeHeight * Scale - SeparatorWidth;
|
float GridHeight = BagShapeAsset->BagHeight * Scale - SeparatorWidth;
|
||||||
|
|
||||||
FVector2D GridStartPos = FVector2D(
|
FVector2D GridStartPos = FVector2D(
|
||||||
(GetCachedGeometry().GetLocalSize().X - GridWidth) * 0.5f,
|
(GetCachedGeometry().GetLocalSize().X - GridWidth) * 0.5f,
|
||||||
@ -167,11 +167,11 @@ FVector2D SShapeGridWidget::GetGridCellFromPosition(const FVector2D& Position) c
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SShapeGridWidget::IsValidGridPosition(int32 X, int32 Y) const
|
bool SBagShapeGridWidget::IsValidGridPosition(int32 X, int32 Y) const
|
||||||
{
|
{
|
||||||
if (!BagShapeAsset.IsValid())
|
if (!BagShapeAsset.IsValid())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return X >= 0 && X < BagShapeAsset->ShapeWidth && Y >= 0 && Y < BagShapeAsset->ShapeHeight;
|
return X >= 0 && X < BagShapeAsset->BagWidth && Y >= 0 && Y < BagShapeAsset->BagHeight;
|
||||||
}
|
}
|
||||||
@ -8,14 +8,14 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class PROJECTFISHEDITOR_API FShapeAssetTypeAction: public FAssetTypeActions_Base
|
class PROJECTFISHEDITOR_API FBagShapeAssetTypeAction: public FAssetTypeActions_Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FShapeAssetTypeAction(EAssetTypeCategories::Type InAssetCategory)
|
FBagShapeAssetTypeAction(EAssetTypeCategories::Type InAssetCategory)
|
||||||
{
|
{
|
||||||
MyAssetCategory = InAssetCategory;
|
MyAssetCategory = InAssetCategory;
|
||||||
}
|
}
|
||||||
virtual FText GetName() const override {return FText::FromString("Shape Asset");}
|
virtual FText GetName() const override {return FText::FromString("Bag Shape");}
|
||||||
virtual FColor GetTypeColor() const override { return FColor(129, 196, 115); }
|
virtual FColor GetTypeColor() const override { return FColor(129, 196, 115); }
|
||||||
virtual UClass* GetSupportedClass() const override;
|
virtual UClass* GetSupportedClass() const override;
|
||||||
virtual void OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<IToolkitHost> EditWithinLevelEditor = TSharedPtr<IToolkitHost>()) override;
|
virtual void OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<IToolkitHost> EditWithinLevelEditor = TSharedPtr<IToolkitHost>()) override;
|
||||||
@ -7,10 +7,10 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class PROJECTFISHEDITOR_API FShapeAssetEditor: public FAssetEditorToolkit
|
class PROJECTFISHEDITOR_API FBagShapeAssetEditor: public FAssetEditorToolkit
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Initialize(const EToolkitMode::Type Mode, const TSharedPtr<class IToolkitHost>& InitToolkitHost, class UShapeAsset* InBagShapeAsset);
|
void Initialize(const EToolkitMode::Type Mode, const TSharedPtr<class IToolkitHost>& InitToolkitHost, class UBagShapeAsset* InBagShapeAsset);
|
||||||
|
|
||||||
// IAssetEditorInstance interface
|
// IAssetEditorInstance interface
|
||||||
virtual FName GetToolkitFName() const override;
|
virtual FName GetToolkitFName() const override;
|
||||||
@ -25,9 +25,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
TSharedRef<SDockTab> SpawnBagShapeEditorTab(const FSpawnTabArgs& Args);
|
TSharedRef<SDockTab> SpawnBagShapeEditorTab(const FSpawnTabArgs& Args);
|
||||||
|
|
||||||
class UShapeAsset* ShapeAsset;
|
class UBagShapeAsset* BagShapeAsset;
|
||||||
/** Tab IDs */
|
/** Tab IDs */
|
||||||
static const FName ShapeEditorTabId;
|
static const FName BagShapeEditorTabId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -4,17 +4,17 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Factories/Factory.h"
|
#include "Factories/Factory.h"
|
||||||
#include "ShapeFactory.generated.h"
|
#include "BagShapeFactory.generated.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class PROJECTFISHEDITOR_API UShapeFactory : public UFactory
|
class PROJECTFISHEDITOR_API UBagShapeFactory : public UFactory
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
UShapeFactory();
|
UBagShapeFactory();
|
||||||
|
|
||||||
//interface
|
//interface
|
||||||
virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
|
virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
|
||||||
@ -4,13 +4,13 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "ThumbnailRendering/DefaultSizedThumbnailRenderer.h"
|
#include "ThumbnailRendering/DefaultSizedThumbnailRenderer.h"
|
||||||
#include "ShapeAssetThumbnailRenderer.generated.h"
|
#include "BagShapeAssetThumbnailRenderer.generated.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class PROJECTFISHEDITOR_API UShapeAssetThumbnailRenderer : public UDefaultSizedThumbnailRenderer
|
class PROJECTFISHEDITOR_API UBagShapeAssetThumbnailRenderer : public UDefaultSizedThumbnailRenderer
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
@ -19,7 +19,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/** Draw the bag shape on canvas */
|
/** Draw the bag shape on canvas */
|
||||||
void DrawBagShape(class UShapeAsset* BagShapeAsset, FCanvas* Canvas, int32 X, int32 Y, uint32 Width, uint32 Height);
|
void DrawBagShape(class UBagShapeAsset* BagShapeAsset, FCanvas* Canvas, int32 X, int32 Y, uint32 Width, uint32 Height);
|
||||||
|
|
||||||
/** Get the best fit scale for the bag shape */
|
/** Get the best fit scale for the bag shape */
|
||||||
float GetBestFitScale(int32 BagWidth, int32 BagHeight, uint32 CanvasWidth, uint32 CanvasHeight) const;
|
float GetBestFitScale(int32 BagWidth, int32 BagHeight, uint32 CanvasWidth, uint32 CanvasHeight) const;
|
||||||
@ -3,17 +3,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "ShapeGridWidget.h"
|
#include "BagShapeGridWidget.h"
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class PROJECTFISHEDITOR_API SShapeEditorWidget: public SCompoundWidget
|
class PROJECTFISHEDITOR_API SBagShapeEditorWidget: public SCompoundWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SLATE_BEGIN_ARGS(SShapeEditorWidget) {}
|
SLATE_BEGIN_ARGS(SBagShapeEditorWidget) {}
|
||||||
SLATE_ARGUMENT(UShapeAsset*, BagShapeAsset)
|
SLATE_ARGUMENT(UBagShapeAsset*, BagShapeAsset)
|
||||||
SLATE_END_ARGS()
|
SLATE_END_ARGS()
|
||||||
void Construct(const FArguments& InArgs);
|
void Construct(const FArguments& InArgs);
|
||||||
|
|
||||||
@ -24,9 +24,9 @@ private:
|
|||||||
//背包大小UI
|
//背包大小UI
|
||||||
TSharedRef<SWidget> CreateSizeControls();
|
TSharedRef<SWidget> CreateSizeControls();
|
||||||
/** Get the current bag width */
|
/** Get the current bag width */
|
||||||
int32 GetShapeWidth() const;
|
int32 GetBagWidth() const;
|
||||||
/** Get the current bag height */
|
/** Get the current bag height */
|
||||||
int32 GetShapeHeight() const;
|
int32 GetBagHeight() const;
|
||||||
/** Handle width spin box value change */
|
/** Handle width spin box value change */
|
||||||
void OnWidthChanged(int32 NewWidth);
|
void OnWidthChanged(int32 NewWidth);
|
||||||
/** Handle height spin box value change */
|
/** Handle height spin box value change */
|
||||||
@ -43,6 +43,6 @@ private:
|
|||||||
//刷新图标
|
//刷新图标
|
||||||
void RefreshThumbnail();
|
void RefreshThumbnail();
|
||||||
private:
|
private:
|
||||||
TWeakObjectPtr<class UShapeAsset> BagShapeAsset;
|
TWeakObjectPtr<class UBagShapeAsset> BagShapeAsset;
|
||||||
TSharedPtr<SShapeGridWidget> GridWidget;
|
TSharedPtr<SBagShapeGridWidget> GridWidget;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,23 +3,23 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "ProjectFish/DataAsset/ShapeAsset.h"
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||||||
|
|
||||||
DECLARE_DELEGATE_TwoParams(FOnSlotClicked, int32, int32);
|
DECLARE_DELEGATE_TwoParams(FOnSlotClicked, int32, int32);
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SShapeGridWidget : public SCompoundWidget
|
class SBagShapeGridWidget : public SCompoundWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SLATE_BEGIN_ARGS(SShapeGridWidget) {}
|
SLATE_BEGIN_ARGS(SBagShapeGridWidget) {}
|
||||||
SLATE_ARGUMENT(UShapeAsset*, BagShapeAsset)
|
SLATE_ARGUMENT(UBagShapeAsset*, BagShapeAsset)
|
||||||
SLATE_EVENT(FOnSlotClicked, OnSlotClicked)
|
SLATE_EVENT(FOnSlotClicked, OnSlotClicked)
|
||||||
SLATE_END_ARGS()
|
SLATE_END_ARGS()
|
||||||
|
|
||||||
void Construct(const FArguments& InArgs);
|
void Construct(const FArguments& InArgs);
|
||||||
|
|
||||||
void UpdateBagShapeAsset(UShapeAsset* InBagShapeAsset);
|
void UpdateBagShapeAsset(UBagShapeAsset* InBagShapeAsset);
|
||||||
|
|
||||||
// SWidget interface
|
// SWidget interface
|
||||||
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
||||||
@ -31,7 +31,7 @@ private:
|
|||||||
static const float CellSize;
|
static const float CellSize;
|
||||||
static const float SeparatorWidth;
|
static const float SeparatorWidth;
|
||||||
|
|
||||||
TWeakObjectPtr<UShapeAsset> BagShapeAsset;
|
TWeakObjectPtr<UBagShapeAsset> BagShapeAsset;
|
||||||
FOnSlotClicked OnSlotClicked;
|
FOnSlotClicked OnSlotClicked;
|
||||||
|
|
||||||
FVector2D GetGridCellFromPosition(const FVector2D& Position) const;
|
FVector2D GetGridCellFromPosition(const FVector2D& Position) const;
|
||||||
Loading…
x
Reference in New Issue
Block a user