完善对话生成逻辑
This commit is contained in:
parent
5ce62f0bb5
commit
23b62b60a5
@ -188,8 +188,19 @@ void FAIGCModule::InitWebSocketManager()
|
|||||||
auto& Settings = *GetDefault<UAIGCSetting>();
|
auto& Settings = *GetDefault<UAIGCSetting>();
|
||||||
WebSocketManager = NewObject<UWebSocketManager>();
|
WebSocketManager = NewObject<UWebSocketManager>();
|
||||||
WebSocketManager->InitWebSocket(Settings.ServerIP);
|
WebSocketManager->InitWebSocket(Settings.ServerIP);
|
||||||
|
WebSocketManager->OnConnectDelegate.AddLambda([this](bool bSuccess)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!bSuccess)
|
||||||
|
{
|
||||||
|
WebSocketManager->ConditionalBeginDestroy();
|
||||||
|
WebSocketManager = nullptr;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//WebSocketManager->OnConnectDelegate.AddRaw(this, &FAIGCModule::OnWebSocketConnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#undef LOCTEXT_NAMESPACE
|
#undef LOCTEXT_NAMESPACE
|
||||||
|
|
||||||
IMPLEMENT_MODULE(FAIGCModule, AIGC)
|
IMPLEMENT_MODULE(FAIGCModule, AIGC)
|
@ -15,15 +15,6 @@ void SAIGCWindow::Construct(const FArguments& InArgs)
|
|||||||
{
|
{
|
||||||
ChildSlot[
|
ChildSlot[
|
||||||
SNew(SVerticalBox)
|
SNew(SVerticalBox)
|
||||||
+ SVerticalBox::Slot()
|
|
||||||
.AutoHeight()
|
|
||||||
.Padding(10)
|
|
||||||
[
|
|
||||||
SAssignNew(ServerIP, SConfigItem_Text)
|
|
||||||
.Title(LOCTEXT("Server", "服务器ip"))
|
|
||||||
.HintText(LOCTEXT("HintServer", "请输入服务器ip"))
|
|
||||||
.DefaultText(LOCTEXT("InputServer", "127.0.0.1"))
|
|
||||||
]
|
|
||||||
+ SVerticalBox::Slot()
|
+ SVerticalBox::Slot()
|
||||||
.AutoHeight()
|
.AutoHeight()
|
||||||
.Padding(10)
|
.Padding(10)
|
||||||
@ -36,35 +27,48 @@ void SAIGCWindow::Construct(const FArguments& InArgs)
|
|||||||
.AutoHeight()
|
.AutoHeight()
|
||||||
.Padding(10)
|
.Padding(10)
|
||||||
[
|
[
|
||||||
SAssignNew(NPCName1, SConfigItem_Text)
|
SAssignNew(NPCName1, SConfigItem_ComboBox<TSharedPtr<FCharacterInfo>>)
|
||||||
.Title(LOCTEXT("Name1", "名称1"))
|
.Title(LOCTEXT("Name1", "名称1"))
|
||||||
.HintText(LOCTEXT("HintName", "请输入名称"))
|
.OptionsSource(&CharacterInfos)
|
||||||
|
.Content()
|
||||||
|
[
|
||||||
|
SNew(STextBlock)
|
||||||
|
.Text_Lambda([this]() -> FText {
|
||||||
|
|
||||||
|
return FText::FromString(SelectedCharacter1.name);
|
||||||
|
})
|
||||||
|
]
|
||||||
|
.OnGenerateWidget_Lambda([this](TSharedPtr<FCharacterInfo> CharacterInfo) {
|
||||||
|
return SNew(STextBlock).Text(FText::FromString(CharacterInfo->name));
|
||||||
|
})
|
||||||
|
.OnSelectionChanged_Lambda([this](TSharedPtr<FCharacterInfo> CharacterInfo, ESelectInfo::Type)
|
||||||
|
{
|
||||||
|
SelectedCharacter1 = *CharacterInfo;
|
||||||
|
})
|
||||||
]
|
]
|
||||||
+ SVerticalBox::Slot()
|
+ SVerticalBox::Slot()
|
||||||
.AutoHeight()
|
.AutoHeight()
|
||||||
.Padding(10)
|
.Padding(10)
|
||||||
[
|
[
|
||||||
SAssignNew(NPCJob1, SConfigItem_Text)
|
SAssignNew(NPCName2, SConfigItem_ComboBox<TSharedPtr<FCharacterInfo>>)
|
||||||
.Title(LOCTEXT("Job1", "职业1"))
|
.Title(LOCTEXT("Name2", "名称2"))
|
||||||
.HintText(LOCTEXT("HintJon", "请输入职业"))
|
.OptionsSource(&CharacterInfos)
|
||||||
]
|
.Content()
|
||||||
+ SVerticalBox::Slot()
|
[
|
||||||
.AutoHeight()
|
SNew(STextBlock)
|
||||||
.Padding(10)
|
.Text_Lambda([this]() -> FText {
|
||||||
[
|
|
||||||
SAssignNew(NPCName2, SConfigItem_Text)
|
return FText::FromString(SelectedCharacter2.name);
|
||||||
.Title(LOCTEXT("Name2", "名称2"))
|
})
|
||||||
.HintText(LOCTEXT("HintName", "请输入名称"))
|
]
|
||||||
]
|
.OnGenerateWidget_Lambda([this](TSharedPtr<FCharacterInfo> CharacterInfo) {
|
||||||
|
return SNew(STextBlock).Text(FText::FromString(CharacterInfo->name));
|
||||||
+ SVerticalBox::Slot()
|
})
|
||||||
.AutoHeight()
|
.OnSelectionChanged_Lambda([this](TSharedPtr<FCharacterInfo> CharacterInfo, ESelectInfo::Type)
|
||||||
.Padding(10)
|
{
|
||||||
[
|
SelectedCharacter2 = *CharacterInfo;
|
||||||
SAssignNew(NPCJob2, SConfigItem_Text)
|
})
|
||||||
.Title(LOCTEXT("Job2", "职业2"))
|
]
|
||||||
.HintText(LOCTEXT("HintJon", "请输入职业"))
|
|
||||||
]
|
|
||||||
+ SVerticalBox::Slot()
|
+ SVerticalBox::Slot()
|
||||||
.AutoHeight()
|
.AutoHeight()
|
||||||
.Padding(10)
|
.Padding(10)
|
||||||
@ -111,14 +115,19 @@ EActiveTimerReturnType SAIGCWindow::OnPostPaint(double X, float Arg)
|
|||||||
if (ModulePtr)
|
if (ModulePtr)
|
||||||
{
|
{
|
||||||
UWebSocketManager* WebSocketManager = ModulePtr->GetWebSocketManager();
|
UWebSocketManager* WebSocketManager = ModulePtr->GetWebSocketManager();
|
||||||
if (!WebSocketManager)
|
if (!IsValid(WebSocketManager))
|
||||||
{
|
{
|
||||||
ModulePtr->InitWebSocketManager();
|
ModulePtr->InitWebSocketManager();
|
||||||
WebSocketManager = ModulePtr->GetWebSocketManager();
|
WebSocketManager = ModulePtr->GetWebSocketManager();
|
||||||
}
|
}
|
||||||
WebSocketManager->OnConnectDelegate.AddLambda([this](bool bSuccess)
|
else
|
||||||
|
{
|
||||||
|
WebSocketManager->SendData(FNetCommand::CharacterList, TEXT(""));
|
||||||
|
}
|
||||||
|
WebSocketManager->OnConnectDelegate.AddLambda([this, WebSocketManager](bool bSuccess)
|
||||||
{
|
{
|
||||||
GenerateButton->SetEnabled(bSuccess);
|
GenerateButton->SetEnabled(bSuccess);
|
||||||
|
WebSocketManager->SendData(FNetCommand::CharacterList, TEXT(""));
|
||||||
});
|
});
|
||||||
WebSocketManager->OnDataReceiveDelaget.AddRaw(this, &SAIGCWindow::HandleReceiveData);
|
WebSocketManager->OnDataReceiveDelaget.AddRaw(this, &SAIGCWindow::HandleReceiveData);
|
||||||
|
|
||||||
@ -131,11 +140,27 @@ void SAIGCWindow::OnAIGenerateClicked()
|
|||||||
{
|
{
|
||||||
GenerateButton->SetEnabled(false);
|
GenerateButton->SetEnabled(false);
|
||||||
RequireGenerateCount = GenerateCount->GetNumber();
|
RequireGenerateCount = GenerateCount->GetNumber();
|
||||||
UE_LOG(LogTemp, Warning, TEXT("生成次数 %d prompt:%s"), RequireGenerateCount, *GeneratePromptJson());
|
|
||||||
FAIGCModule* ModulePtr = FModuleManager::GetModulePtr<FAIGCModule>("AIGC");
|
FAIGCModule* ModulePtr = FModuleManager::GetModulePtr<FAIGCModule>("AIGC");
|
||||||
|
|
||||||
|
//生成ai 配置信息
|
||||||
|
FRequestAIChat RequestAIChat;
|
||||||
|
RequestAIChat.DialogScene =DialogScene->GetInputText();
|
||||||
|
RequestAIChat.GenerateCount = GenerateCount->GetNumber();
|
||||||
|
RequestAIChat.CharacterName.Add(SelectedCharacter1.name);
|
||||||
|
RequestAIChat.CharacterName.Add(SelectedCharacter2.name);
|
||||||
|
FString dataJson;
|
||||||
|
FJsonObjectConverter::UStructToJsonObjectString(
|
||||||
|
FRequestAIChat::StaticStruct(),
|
||||||
|
&RequestAIChat,
|
||||||
|
dataJson,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
//发送ai对话生成请求
|
||||||
if (ModulePtr)
|
if (ModulePtr)
|
||||||
{
|
{
|
||||||
ModulePtr->GetWebSocketManager()->SendData(FNetCommand::AiChatGenerate, GeneratePromptJson());
|
ModulePtr->GetWebSocketManager()->SendData(FNetCommand::AiChatGenerate, dataJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -143,60 +168,55 @@ void SAIGCWindow::OnAIGenerateClicked()
|
|||||||
|
|
||||||
void SAIGCWindow::HandleReceiveData(FNetProtocol protocol)
|
void SAIGCWindow::HandleReceiveData(FNetProtocol protocol)
|
||||||
{
|
{
|
||||||
// UE_LOG(LogTemp, Warning, TEXT("AI当前进度 %d/%d"), GeneratedCount, RequireGenerateCount);
|
if (protocol.cmd == FNetCommand::CharacterList)
|
||||||
// //添加数据到dataTable中
|
{
|
||||||
// if (AiMessages.Num() > 0)
|
|
||||||
// {
|
//解析json角色信息
|
||||||
// FAIGCModule* ModulePtr = FModuleManager::GetModulePtr<FAIGCModule>("AIGC");
|
FJsonObjectConverter::JsonObjectStringToUStruct<FCharacterArray>(
|
||||||
// if (ModulePtr) {
|
protocol.data,
|
||||||
// FString DataPath = FString::Printf(TEXT("/Game/Test/%s.%s"), *DataName->GetInputText(), *DataName->GetInputText());
|
&Characters,
|
||||||
// FString Final = "";
|
0, // 检查标志位
|
||||||
// for (auto message: AiMessages)
|
0 // 转换标志位
|
||||||
// {
|
);
|
||||||
// Final += message + TEXT("|");
|
CharacterInfos.Empty();
|
||||||
// }
|
for (auto Character: Characters.characterInfos)
|
||||||
// ModulePtr->CreateOrAddData(DataPath, Final);
|
{
|
||||||
// }
|
CharacterInfos.Add(MakeShareable(new FCharacterInfo(Character)));
|
||||||
// }
|
}
|
||||||
//
|
NPCName1->RefreshOptions();
|
||||||
// //是否生成足够数量
|
NPCName2->RefreshOptions();
|
||||||
// if (GeneratedCount < RequireGenerateCount)
|
}
|
||||||
// {
|
else if (protocol.cmd == FNetCommand::AiChatGenerate)
|
||||||
// GeneratedCount++;
|
{
|
||||||
// FAIGCModule* ModulePtr = FModuleManager::GetModulePtr<FAIGCModule>("AIGC");
|
if (protocol.status == -1)
|
||||||
// if (ModulePtr)
|
{
|
||||||
// {
|
//需要重新生成
|
||||||
// ModulePtr->GetWebSocketManager()->SendData(FNetCommand::AiChatGenerate, GeneratePromptJson());
|
GenerateButton->SetEnabled(true);
|
||||||
// }
|
UE_LOG(LogTemp, Error, TEXT("Chat Generate Failed reson = %s"), *protocol.message);
|
||||||
//
|
}
|
||||||
// }
|
else if (protocol.status == 0)
|
||||||
// else
|
{
|
||||||
// {
|
UE_LOG(LogTemp, Warning, TEXT("Chat Generate warning reson = %s"), *protocol.message);
|
||||||
// GeneratedCount = 0;
|
}
|
||||||
// GenerateButton->SetEnabled(true);
|
else if (protocol.status == 1)
|
||||||
// UE_LOG(LogTemp, Warning, TEXT("生成结束!"));
|
{
|
||||||
// }
|
UE_LOG(LogTemp, Warning, TEXT("Chat Generate success chat = %s"), *protocol.data);
|
||||||
|
FAIGCModule* ModulePtr = FModuleManager::GetModulePtr<FAIGCModule>("AIGC");
|
||||||
|
if (ModulePtr) {
|
||||||
|
FString DataPath = FString::Printf(TEXT("/Game/Test/%s.%s"), *DataName->GetInputText(), *DataName->GetInputText());
|
||||||
|
ModulePtr->CreateOrAddData(DataPath, protocol.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (protocol.status == 2)
|
||||||
|
{
|
||||||
|
//全部生成完成
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("Chat Generate has all generated"));
|
||||||
|
GenerateButton->SetEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FString SAIGCWindow::GeneratePromptJson()
|
|
||||||
{
|
|
||||||
FPrompt PromptData;
|
|
||||||
PromptData.DialogContent = FDialogContent(DialogScene->GetInputText());
|
|
||||||
PromptData.Persons.Add(FPersonInfo(NPCName1->GetInputText(), NPCJob1->GetInputText()));
|
|
||||||
PromptData.Persons.Add(FPersonInfo(NPCName2->GetInputText(), NPCJob2->GetInputText()));
|
|
||||||
// 结构体转JSON字符串
|
|
||||||
FString OutputString;
|
|
||||||
FJsonObjectConverter::UStructToJsonObjectString(
|
|
||||||
FPrompt::StaticStruct(),
|
|
||||||
&PromptData,
|
|
||||||
OutputString,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
return OutputString;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef LOCTEXT_NAMESPACE
|
#undef LOCTEXT_NAMESPACE
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
void SCharacterWindow::Construct(const FArguments& InArgs)
|
void SCharacterWindow::Construct(const FArguments& InArgs)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
ChildSlot[
|
ChildSlot[
|
||||||
SNew(SVerticalBox)
|
SNew(SVerticalBox)
|
||||||
+SVerticalBox::Slot()
|
+SVerticalBox::Slot()
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "Widget/ConfigItem_ComboBox.h"
|
||||||
|
|
@ -50,6 +50,7 @@ public:
|
|||||||
void CreateOrAddData(const FString& DataTablePath, const FString& RowValue);
|
void CreateOrAddData(const FString& DataTablePath, const FString& RowValue);
|
||||||
class UWebSocketManager* GetWebSocketManager();
|
class UWebSocketManager* GetWebSocketManager();
|
||||||
void InitWebSocketManager();
|
void InitWebSocketManager();
|
||||||
|
//void OnWebSocketConnect(bool bSuccess);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TSharedPtr<class FUICommandList> PluginCommands;
|
TSharedPtr<class FUICommandList> PluginCommands;
|
||||||
|
@ -3,49 +3,42 @@
|
|||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Definations.generated.h"
|
#include "Definations.generated.h"
|
||||||
|
|
||||||
|
// USTRUCT()
|
||||||
|
// struct FDialogContent
|
||||||
|
// {
|
||||||
|
// GENERATED_BODY()
|
||||||
|
// FDialogContent() {};
|
||||||
|
//
|
||||||
|
// FDialogContent(const FString& InDialogScene) : DialogScene(InDialogScene) {}
|
||||||
|
// UPROPERTY()
|
||||||
|
// FString DialogScene;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// USTRUCT()
|
||||||
|
// struct FPersonInfo
|
||||||
|
// {
|
||||||
|
// GENERATED_BODY()
|
||||||
|
// FPersonInfo() {}
|
||||||
|
// FPersonInfo(const FString& InName, const FString& InJob):
|
||||||
|
// Name(InName), Job(InJob){}
|
||||||
|
// UPROPERTY()
|
||||||
|
// FString Name;
|
||||||
|
// UPROPERTY()
|
||||||
|
// FString Job;
|
||||||
|
//
|
||||||
|
// };
|
||||||
USTRUCT()
|
USTRUCT()
|
||||||
struct FDialogContent
|
struct FRequestAIChat
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
FDialogContent() {};
|
|
||||||
|
|
||||||
FDialogContent(const FString& InDialogScene) : DialogScene(InDialogScene) {}
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString DialogScene;
|
FString DialogScene;
|
||||||
|
UPROPERTY()
|
||||||
|
int32 GenerateCount;
|
||||||
|
UPROPERTY()
|
||||||
|
TArray<FString> CharacterName;
|
||||||
};
|
};
|
||||||
|
|
||||||
USTRUCT()
|
|
||||||
struct FPersonInfo
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
FPersonInfo() {}
|
|
||||||
FPersonInfo(const FString& InName, const FString& InJob):
|
|
||||||
Name(InName), Job(InJob){}
|
|
||||||
UPROPERTY()
|
|
||||||
FString Name;
|
|
||||||
UPROPERTY()
|
|
||||||
FString Job;
|
|
||||||
|
|
||||||
};
|
|
||||||
USTRUCT()
|
|
||||||
struct FPrompt
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
UPROPERTY()
|
|
||||||
FDialogContent DialogContent;
|
|
||||||
UPROPERTY()
|
|
||||||
TArray<FPersonInfo> Persons;
|
|
||||||
};
|
|
||||||
|
|
||||||
USTRUCT()
|
|
||||||
struct FAIServerData
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
UPROPERTY()
|
|
||||||
int32 statusCode;
|
|
||||||
UPROPERTY()
|
|
||||||
TArray<FString> messages;
|
|
||||||
};
|
|
||||||
|
|
||||||
USTRUCT()
|
USTRUCT()
|
||||||
struct FCharacterInfo
|
struct FCharacterInfo
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "ConfigItem_ComboBox.h"
|
||||||
#include "ConfigItem_NumberSpin.h"
|
#include "ConfigItem_NumberSpin.h"
|
||||||
#include "ConfigItem_Text.h"
|
#include "ConfigItem_Text.h"
|
||||||
#include "Definations.h"
|
#include "Definations.h"
|
||||||
@ -26,19 +27,22 @@ public:
|
|||||||
void HandleReceiveData(FNetProtocol protocol);
|
void HandleReceiveData(FNetProtocol protocol);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FString GeneratePromptJson();
|
|
||||||
int32 RequireGenerateCount;
|
int32 RequireGenerateCount;
|
||||||
int32 GeneratedCount = 1;
|
int32 GeneratedCount = 1;
|
||||||
|
FCharacterArray Characters;
|
||||||
|
TArray<TSharedPtr<FCharacterInfo>> CharacterInfos;
|
||||||
|
FCharacterInfo SelectedCharacter1;
|
||||||
|
FCharacterInfo SelectedCharacter2;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TSharedPtr<SConfigItem_Text> ServerIP; //服务器IP
|
|
||||||
TSharedPtr<SConfigItem_Text> DataName; //datatable 名称
|
TSharedPtr<SConfigItem_Text> DataName; //datatable 名称
|
||||||
TSharedPtr<SConfigItem_Text> NPCName1; //npc1的名称
|
TSharedPtr<SConfigItem_ComboBox<TSharedPtr<FCharacterInfo>>> NPCName1; //npc1的名称
|
||||||
TSharedPtr<SConfigItem_Text> NPCJob1; //npc1的职业
|
TSharedPtr<SConfigItem_ComboBox<TSharedPtr<FCharacterInfo>>> NPCName2; //npc2的名称
|
||||||
TSharedPtr<SConfigItem_Text> NPCName2; //npc2的名称
|
|
||||||
TSharedPtr<SConfigItem_Text> NPCJob2; //npc2的职业
|
|
||||||
TSharedPtr<SConfigItem_Text> DialogScene; //对话场景
|
TSharedPtr<SConfigItem_Text> DialogScene; //对话场景
|
||||||
TSharedPtr<SConfigItem_NumberSpin<int32>> GenerateCount; //生成数目
|
TSharedPtr<SConfigItem_NumberSpin<int32>> GenerateCount; //生成数目
|
||||||
TSharedPtr<SButton> GenerateButton; //生成按钮
|
TSharedPtr<SButton> GenerateButton; //生成按钮
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
@ -0,0 +1,69 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
template <typename OptionType>
|
||||||
|
class AIGC_API SConfigItem_ComboBox: public SCompoundWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename TSlateDelegates<OptionType>::FOnGenerateWidget FOnGenerateWidget;
|
||||||
|
typedef typename TSlateDelegates<OptionType>::FOnSelectionChanged FOnSelectionChanged;
|
||||||
|
SLATE_BEGIN_ARGS( SConfigItem_ComboBox )
|
||||||
|
:_Title()
|
||||||
|
,_Content()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
SLATE_ARGUMENT(FText, Title) // 标题参数
|
||||||
|
SLATE_ITEMS_SOURCE_ARGUMENT( OptionType, OptionsSource ) //数据源
|
||||||
|
SLATE_EVENT(FOnGenerateWidget, OnGenerateWidget )
|
||||||
|
SLATE_EVENT( FOnSelectionChanged, OnSelectionChanged )
|
||||||
|
SLATE_NAMED_SLOT(FArguments, Content)//显示
|
||||||
|
|
||||||
|
SLATE_END_ARGS()
|
||||||
|
|
||||||
|
void Construct(const FArguments& InArgs)
|
||||||
|
{
|
||||||
|
//OptionSource = InArgs.GetOptionsSource();
|
||||||
|
ChildSlot
|
||||||
|
[
|
||||||
|
SNew(SHorizontalBox)
|
||||||
|
+ SHorizontalBox::Slot()
|
||||||
|
.AutoWidth()
|
||||||
|
.Padding(10, 0)
|
||||||
|
[
|
||||||
|
SNew(STextBlock)
|
||||||
|
.Text(InArgs._Title)
|
||||||
|
]
|
||||||
|
+ SHorizontalBox::Slot()
|
||||||
|
.FillWidth(1.0f)
|
||||||
|
.Padding(10, 0)
|
||||||
|
[
|
||||||
|
SAssignNew(ComboBox, SComboBox<OptionType>)
|
||||||
|
.OptionsSource(InArgs.GetOptionsSource())
|
||||||
|
.Content()
|
||||||
|
[
|
||||||
|
InArgs._Content.Widget
|
||||||
|
]
|
||||||
|
.OnGenerateWidget(InArgs._OnGenerateWidget)
|
||||||
|
.OnSelectionChanged(InArgs._OnSelectionChanged)
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
void RefreshOptions()
|
||||||
|
{
|
||||||
|
ComboBox->RefreshOptions();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
TSharedPtr<SComboBox<OptionType>> ComboBox;
|
||||||
|
//TArray<OptionType>* OptionSource; //数据源指针
|
||||||
|
// FOnGenerateWidget OnGenerateWidgetDelegate;
|
||||||
|
// FOnSelectionChanged OnSelectionChangedDelegate;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -25,6 +25,7 @@ public:
|
|||||||
|
|
||||||
void Construct(const FArguments& InArgs)
|
void Construct(const FArguments& InArgs)
|
||||||
{
|
{
|
||||||
|
InputValue = InArgs._MinNumber;
|
||||||
ChildSlot
|
ChildSlot
|
||||||
[
|
[
|
||||||
SNew(SHorizontalBox)
|
SNew(SHorizontalBox)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user