40 lines
1.2 KiB
C
40 lines
1.2 KiB
C
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||
|
|
|
||
|
|
#pragma once
|
||
|
|
|
||
|
|
#include "CoreMinimal.h"
|
||
|
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
||
|
|
|
||
|
|
DECLARE_DELEGATE_TwoParams(FOnSlotClicked, int32, int32);
|
||
|
|
/**
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
class SBagShapeGridWidget : public SCompoundWidget
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
SLATE_BEGIN_ARGS(SBagShapeGridWidget) {}
|
||
|
|
SLATE_ARGUMENT(UBagShapeAsset*, BagShapeAsset)
|
||
|
|
SLATE_EVENT(FOnSlotClicked, OnSlotClicked)
|
||
|
|
SLATE_END_ARGS()
|
||
|
|
|
||
|
|
void Construct(const FArguments& InArgs);
|
||
|
|
|
||
|
|
void UpdateBagShapeAsset(UBagShapeAsset* InBagShapeAsset);
|
||
|
|
|
||
|
|
// SWidget interface
|
||
|
|
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
|
||
|
|
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect,
|
||
|
|
FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
|
||
|
|
virtual FVector2D ComputeDesiredSize(float) const override;
|
||
|
|
|
||
|
|
private:
|
||
|
|
static const float CellSize;
|
||
|
|
static const float SeparatorWidth;
|
||
|
|
|
||
|
|
TWeakObjectPtr<UBagShapeAsset> BagShapeAsset;
|
||
|
|
FOnSlotClicked OnSlotClicked;
|
||
|
|
|
||
|
|
FVector2D GetGridCellFromPosition(const FVector2D& Position) const;
|
||
|
|
bool IsValidGridPosition(int32 X, int32 Y) const;
|
||
|
|
};
|