8#include "Algo/Reverse.h"
10void UChatHistorySystem::SaveChatHistory(
const FString& Question,
const FString& Answer)
15 PRINTLOG(TEXT(
"[ChatHistory] Invalid UserId: %d"), UserId);
24 NewItem.
Index = CurrentCount;
30 const FString JsonString = NewItem.
ToJson();
33 const FString ItemKey = FString::Printf(TEXT(
"ChatHistory_%d"), CurrentCount);
40int32 UChatHistorySystem::LoadAllChatHistory(TArray<FChatHistoryItem>& OutHistoryList)
42 OutHistoryList.Empty();
58 for (int32 i = 0; i < Count; ++i)
60 const FString ItemKey = FString::Printf(TEXT(
"ChatHistory_%d"), i);
63 if (!JsonString.IsEmpty())
68 OutHistoryList.Add(Item);
74 Algo::Reverse(OutHistoryList);
76 return OutHistoryList.Num();
79void UChatHistorySystem::ClearChatHistory()
91 for (int32 i = 0; i < Count; ++i)
93 const FString ItemKey = FString::Printf(TEXT(
"ChatHistory_%d"), i);
101int32 UChatHistorySystem::GetHistoryCount()
const
113int32 UChatHistorySystem::GetNextIndex()
const
116 return GetHistoryCount();
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
Chat 대화 기록을 GConfig를 이용하여 관리하는 컴포넌트입니다.
static FString GetUserString(int32 UserId, const FString &Key, const FString &DefaultValue=TEXT(""))
유저별 문자열 설정 읽기
static void SetUserString(int32 UserId, const FString &Key, const FString &Value, bool bAutoSave=true)
유저별 문자열 설정 저장
static int32 GetUserInt(int32 UserId, const FString &Key, int32 DefaultValue=0)
유저별 정수 설정 읽기
static void DeleteUserKey(int32 UserId, const FString &Key, bool bAutoSave=true)
유저별 키 삭제
static void SetUserInt(int32 UserId, const FString &Key, int32 Value, bool bAutoSave=true)
유저별 정수 설정 저장
static int32 GetUserId(const UObject *WorldContextObject)
채팅 히스토리 한 항목을 보관하는 구조체입니다.
static bool FromJson(const FString &JsonString, FChatHistoryItem &OutItem)
JSON 문자열을 구조체로 변환합니다.
FString Timestamp
저장 시간 문자열입니다.
FString ToJson() const
구조체를 JSON 문자열로 변환합니다.
static FString CurrentTimestamp()
현재 로컬 타임스탬프를 문자열로 반환합니다.
FString Question
질문 텍스트입니다.