KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
USpeakWidget.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#include "USpeakWidget.h"
4
5#include "ASpeakStageActor.h"
6#include "ALingoPlayerState.h"
7#include "Components/TextBlock.h"
8#include "GameLogging.h"
9
10USpeakWidget::USpeakWidget(const FObjectInitializer& ObjectInitializer)
11 : Super(ObjectInitializer)
12{
13}
14
16{
17 Super::NativeConstruct();
18
19 // 초기 상태: 모든 텍스트 초기화
21 {
22 CurrentQuestionText->SetText(FText::FromString(TEXT("[1/5] Please wait for your turn")));
23 }
24}
25
26//----------------------------------------------------------
27// Public Interface
28//----------------------------------------------------------
29
30void USpeakWidget::UpdateSpeakStage(ASpeakStageActor* SpeakStage, APlayerState* LocalPlayerState, int32 StepIndex)
31{
32 if (!SpeakStage)
33 {
34 PRINTLOG(TEXT("[SpeakWidget] UpdateSpeakStageUI - SpeakStage is null"));
35 return;
36 }
37
38 // 서버에서 전달받은 StepIndex를 사용하여 복제 타이밍 문제를 회피
39 const int32 TotalSteps = SpeakStage->GetTotalQuestions();
40
41 // PlayerState에서 직접 질문 가져오기
42 FString Question;
43 if (auto PS = Cast<ALingoPlayerState>(LocalPlayerState))
44 {
45 if (PS->SpeakScenarioData.speak_quest_data.IsValidIndex(StepIndex))
46 {
47 Question = PS->SpeakScenarioData.speak_quest_data[StepIndex].GetQuestionMessage();
48 }
49 }
50
51 if ( Question.IsEmpty())
52 {
54 PRINTLOG(TEXT("[SpeakWidget] Question is empty for StepIndex %d"), StepIndex);
55 return;
56 }
57
58 CurrentProgress->SetText(FText::FromString(FString::Printf(TEXT("%d/%d"), StepIndex + 1, TotalSteps )));
59 CurrentQuestionText->SetText( FText::FromString(*Question));
60
61 PRINTLOG(TEXT("[SpeakWidget] Updated to step %d/%d: %s"), StepIndex + 1, TotalSteps, *Question);
62}
63
65{
66 SetVisibility(bShow ? ESlateVisibility::Visible : ESlateVisibility::Collapsed );
67}
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
Definition GameLogging.h:30
Speak Stage 시스템
int32 GetTotalQuestions() const
void UpdateSpeakStage(class ASpeakStageActor *SpeakStage, class APlayerState *LocalPlayerState, int32 StepIndex)
SpeakStage 상태를 UI에 반영
TObjectPtr< class UTextBlock > CurrentQuestionText
void SetWidgetVisibility(bool bShow)
위젯 표시/숨김
TObjectPtr< class UTextBlock > CurrentProgress
USpeakWidget(const FObjectInitializer &ObjectInitializer)
생성자
virtual void NativeConstruct() override
위젯 초기화