2025-08-31 15:59:08 +08:00

58 lines
1.4 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "ProjectFish/DataAsset/BagConfigAsset.h"
/**
*
*/
DECLARE_DELEGATE_OneParam(FOnSkillSelected, int32);
class SSkillListWidget : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SSkillListWidget) {}
SLATE_ARGUMENT(UBagConfigAsset*, BagConfig)
SLATE_EVENT(FOnSkillSelected, OnSkillSelected)
SLATE_END_ARGS()
void Construct(const FArguments& InArgs);
// // 设置背包类
// void SetBagClass(UBagConfigAsset* InBagClass);
// 刷新技能列表
void RefreshSkillList();
//
// // 获取选中的技能索引
// int32 GetSelectedSkillIndex() const { return SelectedSkillIndex; }
//
// // 设置选中的技能
// void SetSelectedSkill(int32 SkillIndex);
private:
// 背包类引用
TWeakObjectPtr<UBagConfigAsset> BagConfig;
// 回调委托
FOnSkillSelected OnSkillSelected;
// 选中的技能索引
int32 SelectedSkillIndex;
// UI组件
TSharedPtr<class SListView<TSharedPtr<int32>>> SkillListView;
TArray<TSharedPtr<int32>> SkillIndices;
// 列表项生成函数
TSharedRef<ITableRow> OnGenerateSkillRow(TSharedPtr<int32> SkillIndex, const TSharedRef<STableViewBase>& OwnerTable);
// 选择改变回调
void OnSkillSelectionChanged(TSharedPtr<int32> SelectedItem, ESelectInfo::Type SelectInfo);
// 创建技能显示文本
FText GetSkillDisplayText(int32 SkillIndex) const;
};