KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
UPopup_Interview.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
4#include "UPopup_Interview.h"
5
6#include "APlayerControl.h"
8#include "NetworkData.h"
9#include "Components/Button.h"
10#include "Components/ScrollBox.h"
11#include "Components/VerticalBox.h"
12#include "Components/Spacer.h"
13#include "Components/TextBlock.h"
14#include "UPopupManager.h"
15#include "GameLogging.h"
16#include "UBroadcastManager.h"
17#include "UImageButton.h"
18#include "UTextureButton.h"
20#include "UDialogManager.h"
21#include "ULingoGameHelper.h"
22
24{
25 Super::NativeConstruct();
26}
27
29{
30 // 중복 바인딩 방지: 기존 바인딩 제거 후 재바인딩
31 if (Btn_Close)
32 {
33 Btn_Close->OnButtonClickedEvent.RemoveDynamic(this, &UPopup_Interview::OnClickClose);
34 Btn_Close->OnButtonClickedEvent.AddDynamic(this, &UPopup_Interview::OnClickClose);
35 }
36
37 if (Btn_Submit)
38 {
39 Btn_Submit->OnButtonClickedEvent.RemoveDynamic(this, &UPopup_Interview::OnClickSubmit);
40 Btn_Submit->OnButtonClickedEvent.AddDynamic(this, &UPopup_Interview::OnClickSubmit);
41 }
42
43 // 질문 데이터 저장
44 SavedQuestions = InterviewData.Questions;
45
46 // 기존 항목 제거
47 VerticalBox->ClearChildren();
48
49 // 각 질문에 대해 항목 위젯 생성
50 for (int32 i = 0; i < InterviewData.Questions.Num(); ++i)
51 {
52 const FInterviewQuestionData& QuestionData = InterviewData.Questions[i];
53
54 // 인터뷰 항목 위젯 생성
55 UPopup_InterviewItem* ItemWidget = CreateWidget<UPopup_InterviewItem>(
56 GetWorld(), InterviewItemClass);
57 ItemWidget->InitItem(QuestionData);
58 VerticalBox->AddChildToVerticalBox(ItemWidget);
59
60 // 마지막 항목이 아니면 Spacer 추가
61 if (i < InterviewData.Questions.Num() - 1)
62 {
63 USpacer* Spacer = NewObject<USpacer>(this);
64 if (Spacer)
65 {
66 Spacer->SetSize(FVector2D(1.0f, ItemSpacing));
67 VerticalBox->AddChildToVerticalBox(Spacer);
68 }
69 }
70 }
71}
72
74{
75 // PopupManager를 통해 팝업 닫기 (마우스 커서 처리 포함)
76 if (UPopupManager* PopupMgr = UPopupManager::Get(GetWorld()))
77 {
78 PopupMgr->HideCurrentPopup();
79 }
80}
81
83{
84 // 모든 답변 수집 및 검증
85 TArray<FInterviewAnswerData> AnswerDataList;
86 const TArray<UWidget*>& Children = VerticalBox->GetAllChildren();
87
88 for (int32 i = 0; i < Children.Num(); i++)
89 {
90 if (UPopup_InterviewItem* Item = Cast<UPopup_InterviewItem>(Children[i]))
91 {
92 FString Answer = Item->GetAnswer().TrimStartAndEnd();
93
94 // 빈 답변 체크
95 if (Answer.IsEmpty())
96 {
97 // Toast 메시지로 알림
98 if (UDialogManager* DialogMgr = UDialogManager::Get(GetWorld()))
99 {
100 FString Message = FString::Printf(TEXT("Question is not answered. Please fill in all answers."));
101 DialogMgr->ShowToast(Message);
102 }
103 return;
104 }
105
106 auto AnswerData = Item->GetAnswerData( ULingoGameHelper::GetUserId(GetWorld()));
107
108 // 답변 데이터 생성
109 AnswerDataList.Add(AnswerData);
110 }
111 }
112
113 // 네트워크 전송
114 if (UKLingoNetworkSystem* LingoNetworkSystem = UKLingoNetworkSystem::Get(GetWorld()))
115 {
117 Request.answer = AnswerDataList;
118
119 LingoNetworkSystem->RequestInterviewAnswer( Request,
120 FResponseInterviewAnswerDelegate::CreateUObject(this, &UPopup_Interview::OnResponseInterviewAnswer));
121 }
122}
123
125{
126 if (bWasSuccessful)
127 {
128 PRINTLOG(TEXT("--- Interview Answer SUCCESS ---"));
129
130 // 성공 시 토스트 메시지 표시
131 UBroadcastManager::Get(GetWorld())->SendTutorMessage( FText::FromString(TEXT("Interview answers submitted successfully!")));
132
133 // 팝업 닫기
134 if (UPopupManager* PopupMgr = UPopupManager::Get(GetWorld()))
135 PopupMgr->HideCurrentPopup();
136 }
137 else
138 {
139 PRINTLOG(TEXT("--- Interview Answer FAILED ---"));
140
141 // 실패 시 메시지 표시
142 UPopupManager::Get(GetWorld())->ShowMsgBox(TEXT("Notice"), TEXT("Failed to submit interview answers. Please try again."),
143 EMsgBoxType::OK, FOnMsgBoxOkDelegate());
144 }
145}
APlayerControl 선언에 대한 Doxygen 주석을 제공합니다.
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
Definition GameLogging.h:30
네트워크 요청과 응답에 사용되는 구조체 및 설정을 정의합니다.
UDialogManager 클래스를 선언합니다.
KLingo API 요청을 담당하는 서브시스템을 선언합니다.
토스트 메시지와 같은 간단한 다이얼로그 위젯의 표시를 관리하는 LocalPlayer 서브시스템입니다.
KLingo 서버와의 HTTP 요청을 중재하는 게임 인스턴스 서브시스템입니다.
static int32 GetUserId(const UObject *WorldContextObject)
팝업 관리자
void InitItem(const FInterviewQuestionData &Data)
질문 항목 초기화
void OnResponseInterviewAnswer(FResponseInterviewAnswer &ResponseData, bool bWasSuccessful)
TObjectPtr< class UVerticalBox > VerticalBox
인터뷰 항목들이 추가될 VerticalBox
TSubclassOf< class UPopup_InterviewItem > InterviewItemClass
팝업 내에서 표시될 인터뷰 항목 위젯 클래스
TArray< FInterviewQuestionData > SavedQuestions
저장된 인터뷰 질문 데이터
void InitPopup(const FResponseInterviewHello &InterviewData)
팝업 초기화 (필요 시 API 확장)
virtual void NativeConstruct() override
TObjectPtr< class UTextureButton > Btn_Close
닫기 버튼
TObjectPtr< class UImageButton > Btn_Submit
제출 버튼
float ItemSpacing
인터뷰 항목 간 간격 (Spacer Height)
TArray< FInterviewAnswerData > answer
TArray< FInterviewQuestionData > Questions