KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
Popup_QuestionnaireItem.cpp
이 파일의 문서화 페이지로 가기
1// Copyright (c) 2025 Doppleddiggong. All rights reserved. Unauthorized copying, modification, or distribution of this file, via any medium is strictly prohibited. Proprietary and confidential.
2
3
5
6#include "GameLogging.h"
7#include "NetworkData.h"
8#include "Popup_WriteBoard.h"
9#include "UImageButton.h"
10#include "UPopupManager.h"
11#include "Components/Button.h"
12#include "Components/TextBlock.h"
13#include "Components/WidgetSwitcher.h"
14
15
17{
18 Super::NativeConstruct();
19
20 if (Button_Answer)
21 {
22 Button_Answer->OnButtonClickedEvent.RemoveDynamic(this, &UPopup_QuestionnaireItem::OnClickButton);
23 Button_Answer->OnButtonClickedEvent.AddDynamic(this, &UPopup_QuestionnaireItem::OnClickButton);
24 }
25}
26
28{
29 this->QuestionData = Data;
30
31 // 질문 인덱스 설정 (예: "Question.01")
32 if (Text_Index)
33 {
34 FString IndexText = FString::Printf(TEXT("Q%d"), Data.Id);
35 Text_Index->SetText(FText::FromString(IndexText));
36 }
37
38 // FString Description = FString::Printf(TEXT("%s\n[%s]"),
39 // *Data.word_data.kor,
40 // *Data.word_data.eng);
41 //
42 // // 질문 내용 설정
43 // Text_Question->SetText(FText::FromString(Description));
44
45 Text_Question->SetText(FText::FromString(Data.word_data.eng));
46
47 // 초기 상태는 답변 안됨
48 SetAnswerState(false);
49}
50
52{
53 if (auto Popup = UPopupManager::ShowPopupAs<UPopup_WriteBoard>(GetWorld(), EPopupType::WriteBoard))
54 {
55 // TODO: 단어 수 및 글자 수 구하기
56 TArray<FString> Tokens;
57 QuestionData.answer_kor.ParseIntoArrayWS(Tokens);
58 // for (const auto& token : Tokens)
59 // {
60 // PRINT_STRING(TEXT("Question 글 : %s"), *token);
61 // }
62 // PRINT_STRING(TEXT("Question 단어 수 : %d"), Tokens.Num());
63 // PRINT_STRING(TEXT("Question 글자 수 : %d"), QuestionData.answer_kor.Len());
64 // PRINT_STRING(TEXT("Question 첫 단어 글자 수 : %d"), Tokens[0].Len());
65
66 Popup->InitPopup(QuestionData.Id, QuestionData);
67
68 // WriteBoard 팝업이 닫힐 때 답변 저장 완료를 감지하기 위해 델리게이트 바인딩
69 // 중복 바인딩 방지를 위해 먼저 제거 후 추가
70 Popup->OnCanvasSaved.RemoveDynamic(this, &UPopup_QuestionnaireItem::OnWriteBoardSaved);
71 Popup->OnCanvasSaved.AddDynamic(this, &UPopup_QuestionnaireItem::OnWriteBoardSaved);
72 }
73}
74
76{
77 // 답변이 저장되었으므로 상태 업데이트
78 SetAnswerState(true);
79}
80
82{
83 if (bIsAnswered != bAnswered)
84 {
85 bIsAnswered = bAnswered;
87
88 // 델리게이트 브로드캐스트
90 }
91}
92
94{
96 {
97 // bIsAnswered가 true이면 Image_Checker(인덱스 1) 표시, false이면 Text_Index(인덱스 0) 표시
98 WidgetSwitcher->SetActiveWidgetIndex(bIsAnswered ? 1 : 0);
99 }
100}
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
네트워크 요청과 응답에 사용되는 구조체 및 설정을 정의합니다.
FOnAnswerStateChanged OnAnswerStateChanged
답변 상태 변경 시 호출되는 델리게이트
bool bIsAnswered
답변 입력 여부
TObjectPtr< class UTextBlock > Text_Index
void UpdateWidgetSwitcher()
WidgetSwitcher 상태 업데이트
void InitItem(const FWriteQuestionData &Data)
질문 항목 초기화
void OnWriteBoardSaved()
WriteBoard 저장 완료 콜백
TObjectPtr< class UWidgetSwitcher > WidgetSwitcher
TObjectPtr< class UTextBlock > Text_Question
"What is your current country..." 같은 질문 내용
virtual void NativeConstruct() override
void SetAnswerState(bool bAnswered)
답변 상태 설정
TObjectPtr< class UImageButton > Button_Answer
Write 질문 및 정답 구조체입니다.
FWriteWordData word_data