KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
UChatWidget 클래스 참조

#include <ChatWidget.h>

+ UChatWidget에 대한 상속 다이어그램 :
+ UChatWidget에 대한 협력 다이어그램:

Public 멤버 함수

 UChatWidget (const FObjectInitializer &ObjectInitializer)
 
void FocusInput ()
 
virtual void NativeConstruct () override
 
virtual void NativeTick (const FGeometry &MyGeometry, float InDeltaTime) override
 
void OnInputFocusChanged (bool bHasFocus)
 
void SendMessage (FResponseUserMe sendUser, FText inMessage, int32 PlayerIndex)
 

Protected 속성

TObjectPtr< class UChatInputBoxChatInputBox
 
TSubclassOf< class UChatBoxWidgetLeftChatBoxWidgetClass
 
TSubclassOf< class UChatBoxWidgetRightChatBoxWidgetClass
 
TObjectPtr< class UScrollBox > ScrollBox_ChatBox
 
TObjectPtr< class USizeBox > SizeBox_Chat
 
TObjectPtr< class USpacer > Spacer_Content
 
TObjectPtr< class UVerticalBox > VerticalBox_Content
 

Private 멤버 함수

class UChatBoxWidgetCreateChatBox (bool bIsSender)
 
void OnFadeOutTimerComplete ()
 
void StartFadeOutTimer ()
 

Private 속성

float AutoHideDelay = 5.0f
 
bool bIsFading = false
 
float CurrentOpacity = 1.0f
 
FTimerHandle FadeOutTimerHandle
 
float FadeSpeed = 2.0f
 
float TargetOpacity = 1.0f
 

상세한 설명

ChatWidget.h 파일의 13 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ UChatWidget()

UChatWidget::UChatWidget ( const FObjectInitializer &  ObjectInitializer)

ChatWidget.cpp 파일의 17 번째 라인에서 정의되었습니다.

17 : Super(ObjectInitializer)
18{
19 ConstructorHelpers::FClassFinder<UChatBoxWidget> LeftChatBoxWidgetClassRef(TEXT("/Game/CustomContents/UI/Widgets/Chat/WBP_LeftChatMessage.WBP_LeftChatMessage_C"));
20 if (LeftChatBoxWidgetClassRef.Succeeded())
21 {
22 LeftChatBoxWidgetClass = LeftChatBoxWidgetClassRef.Class;
23 }
24 ConstructorHelpers::FClassFinder<UChatBoxWidget> RightChatBoxWidgetClassRef(TEXT("/Game/CustomContents/UI/Widgets/Chat/WBP_RightChatMessage.WBP_RightChatMessage_C"));
25 if (RightChatBoxWidgetClassRef.Succeeded())
26 {
27 RightChatBoxWidgetClass = RightChatBoxWidgetClassRef.Class;
28 }
29}
TSubclassOf< class UChatBoxWidget > RightChatBoxWidgetClass
Definition ChatWidget.h:49
TSubclassOf< class UChatBoxWidget > LeftChatBoxWidgetClass
Definition ChatWidget.h:46

다음을 참조함 : LeftChatBoxWidgetClass, RightChatBoxWidgetClass.

멤버 함수 문서화

◆ CreateChatBox()

UChatBoxWidget * UChatWidget::CreateChatBox ( bool  bIsSender)
private

ChatWidget.cpp 파일의 213 번째 라인에서 정의되었습니다.

214{
215 return CreateWidget<UChatBoxWidget>(GetWorld(), bIsSender? LeftChatBoxWidgetClass : RightChatBoxWidgetClass );
216}

다음을 참조함 : LeftChatBoxWidgetClass, RightChatBoxWidgetClass.

다음에 의해서 참조됨 : SendMessage().

+ 이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ FocusInput()

void UChatWidget::FocusInput ( )

ChatWidget.cpp 파일의 148 번째 라인에서 정의되었습니다.

149{
150 ChatInputBox->SetInputFocus(true);
151
152 // 입력 포커스를 얻을 때 완전히 보이게 하고 타이머 중단
153 TargetOpacity = 1.0f;
154 CurrentOpacity = 1.0f;
155 SetRenderOpacity(1.0f);
156 bIsFading = false;
157
158 // 타이머 중단
159 if (GetWorld() && GetWorld()->GetTimerManager().IsTimerActive(FadeOutTimerHandle))
160 {
161 GetWorld()->GetTimerManager().ClearTimer(FadeOutTimerHandle);
162 }
163}
TObjectPtr< class UChatInputBox > ChatInputBox
Definition ChatWidget.h:42
float CurrentOpacity
Definition ChatWidget.h:61
FTimerHandle FadeOutTimerHandle
Definition ChatWidget.h:57
float TargetOpacity
Definition ChatWidget.h:62
bool bIsFading
Definition ChatWidget.h:60

다음을 참조함 : bIsFading, ChatInputBox, CurrentOpacity, FadeOutTimerHandle, TargetOpacity.

◆ NativeConstruct()

void UChatWidget::NativeConstruct ( )
overridevirtual

ChatWidget.cpp 파일의 31 번째 라인에서 정의되었습니다.

32{
33 Super::NativeConstruct();
34
35 SetIsFocusable(true);
36
37 // 초기 상태는 페이드아웃 (약간 투명하게)
38 SetRenderOpacity(0.2f);
39 CurrentOpacity = 0.2f;
40 TargetOpacity = 0.2f;
41
42 // ChatInputBox에 자신을 설정
43 if (ChatInputBox)
44 {
45 ChatInputBox->SetOwningChatWidget(this);
46 }
47}

다음을 참조함 : ChatInputBox, CurrentOpacity, TargetOpacity.

◆ NativeTick()

void UChatWidget::NativeTick ( const FGeometry &  MyGeometry,
float  InDeltaTime 
)
overridevirtual

ChatWidget.cpp 파일의 49 번째 라인에서 정의되었습니다.

50{
51 Super::NativeTick(MyGeometry, InDeltaTime);
52
53 // 페이드 처리
55 {
56 // 부드럽게 Opacity 변경
57 float Delta = FadeSpeed * InDeltaTime;
59 {
60 CurrentOpacity = FMath::Max(CurrentOpacity - Delta, TargetOpacity);
61 }
62 else
63 {
64 CurrentOpacity = FMath::Min(CurrentOpacity + Delta, TargetOpacity);
65 }
66
67 SetRenderOpacity(CurrentOpacity);
68
69 // 목표 도달 시 페이드 종료
70 if (FMath::IsNearlyEqual(CurrentOpacity, TargetOpacity, 0.01f))
71 {
72 bIsFading = false;
73 }
74 }
75}
float FadeSpeed
Definition ChatWidget.h:65

다음을 참조함 : bIsFading, CurrentOpacity, FadeSpeed, TargetOpacity.

◆ OnFadeOutTimerComplete()

void UChatWidget::OnFadeOutTimerComplete ( )
private

ChatWidget.cpp 파일의 202 번째 라인에서 정의되었습니다.

203{
204 // 입력창에 포커스가 있으면 페이드아웃하지 않음
205 if (ChatInputBox && ChatInputBox->HasKeyboardFocus())
206 return;
207
208 // 페이드아웃 시작
209 TargetOpacity = 0.2f; // 완전히 투명하게 하지 않고 약간 보이게
210 bIsFading = true;
211}

다음을 참조함 : bIsFading, ChatInputBox, TargetOpacity.

다음에 의해서 참조됨 : StartFadeOutTimer().

+ 이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ OnInputFocusChanged()

void UChatWidget::OnInputFocusChanged ( bool  bHasFocus)

ChatWidget.cpp 파일의 165 번째 라인에서 정의되었습니다.

166{
167 if (bHasFocus)
168 {
169 // 포커스를 얻으면 완전히 보이게 하고 타이머 중단
170 TargetOpacity = 1.0f;
171 CurrentOpacity = 1.0f;
172 SetRenderOpacity(1.0f);
173 bIsFading = false;
174
175 if (GetWorld() && GetWorld()->GetTimerManager().IsTimerActive(FadeOutTimerHandle))
176 {
177 GetWorld()->GetTimerManager().ClearTimer(FadeOutTimerHandle);
178 }
179 }
180 else
181 {
182 // 포커스를 잃으면 5초 후 페이드아웃 시작
184 }
185}
void StartFadeOutTimer()

다음을 참조함 : bIsFading, CurrentOpacity, FadeOutTimerHandle, StartFadeOutTimer(), TargetOpacity.

+ 이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ SendMessage()

void UChatWidget::SendMessage ( FResponseUserMe  sendUser,
FText  inMessage,
int32  PlayerIndex 
)

ChatWidget.cpp 파일의 77 번째 라인에서 정의되었습니다.

78{
79 auto* PC = Cast<APlayerControl>(GetWorld()->GetFirstPlayerController<APlayerController>());
80 if (!PC)
81 {
82 PRINTLOG(TEXT("Cannot get playercontroller"));
83 }
84
85 // 메시지 받은 플레이어 정보 가져오기
86 FResponseUserMe info = PC->GetUserInfo();
87 bool bIsSender = (info.id == sendUser.id);
88
89 // ChatBox 생성
90 UChatBoxWidget* newChat = CreateChatBox(bIsSender);
91 newChat->SetMessage(inMessage);
92
93 newChat->SetPlayerProfile(
94 sendUser.GetChatProfileBg(PlayerIndex),
95 sendUser.GetChatProfileTextureType(PlayerIndex));
96
97 newChat->SetPlayerName(FText::FromString(sendUser.username));
98 newChat->SetMessage(inMessage);
99 newChat->SetChatBubbleColor(bIsSender);
100
101 // ChatBox에 추가 & 정렬
102 VerticalBox_Content->AddChild(newChat);
103
104 UScrollBoxSlot* parentSlot = Cast<UScrollBoxSlot>(newChat->Slot);
105 if (parentSlot)
106 {
107 parentSlot->SetHorizontalAlignment((bIsSender ? HAlign_Left : HAlign_Right));
108 }
109
110 // 위젯의 레이아웃을 강제로 갱신하여 정확한 크기 계산
111 newChat->ForceLayoutPrepass();
112
113 // 부모 위젯들의 레이아웃을 무효화하여 다음 틱에 재계산
114 VerticalBox_Content->InvalidateLayoutAndVolatility();
115 ScrollBox_ChatBox->InvalidateLayoutAndVolatility();
116
117 // 현재 스크롤 값 & 마지막 스크롤 값
118 float scrollOffset = ScrollBox_ChatBox->GetScrollOffset();
119 float scrollOffsetOfEnd = ScrollBox_ChatBox->GetScrollOffsetOfEnd();
120
121 if (bIsSender || scrollOffset == scrollOffsetOfEnd)
122 {
123 // 레이아웃 갱신 후 스크롤 (타이머 사용)
124 FTimerHandle ScrollTimerHandle;
125 GetWorld()->GetTimerManager().SetTimer(ScrollTimerHandle, [this, newChat]()
126 {
127 // 마지막 위젯을 뷰에 표시
128 ScrollBox_ChatBox->ScrollWidgetIntoView(newChat, true, EDescendantScrollDestination::BottomOrRight);
129
130 // 추가로 ScrollToEnd도 실행
131 ScrollBox_ChatBox->ScrollToEnd();
132 }, 0.1f, false);
133 }
134
135 UWidgetBlueprintLibrary::SetFocusToGameViewport();
136 PC->SetInputMode(FInputModeGameOnly());
137 PC->SetShowMouseCursor(false);
138
139 // 채팅창을 완전히 보이게 하고 5초 후 페이드아웃 타이머 시작
140 TargetOpacity = 1.0f;
141 CurrentOpacity = 1.0f;
142 SetRenderOpacity(1.0f);
143 bIsFading = false;
144
146}
#define PRINTLOG(fmt,...)
Definition GameLogging.h:30
void SetMessage(FText InMessage)
void SetPlayerName(FText InPlayerName)
void SetPlayerProfile(FLinearColor InBgColor, EResourceTextureType InProfileType)
void SetChatBubbleColor(bool IsMine) const
class UChatBoxWidget * CreateChatBox(bool bIsSender)
TObjectPtr< class UScrollBox > ScrollBox_ChatBox
Definition ChatWidget.h:36
TObjectPtr< class UVerticalBox > VerticalBox_Content
Definition ChatWidget.h:30
FLinearColor GetChatProfileBg(int player_index) const
EResourceTextureType GetChatProfileTextureType(int player_index) const

다음을 참조함 : bIsFading, CreateChatBox(), CurrentOpacity, FResponseUserMe::GetChatProfileBg(), FResponseUserMe::GetChatProfileTextureType(), FResponseUserMe::id, PRINTLOG, ScrollBox_ChatBox, UChatBoxWidget::SetChatBubbleColor(), UChatBoxWidget::SetMessage(), UChatBoxWidget::SetPlayerName(), UChatBoxWidget::SetPlayerProfile(), StartFadeOutTimer(), TargetOpacity, FResponseUserMe::username, VerticalBox_Content.

+ 이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ StartFadeOutTimer()

void UChatWidget::StartFadeOutTimer ( )
private

ChatWidget.cpp 파일의 187 번째 라인에서 정의되었습니다.

188{
189 if (!GetWorld())
190 return;
191
192 // 기존 타이머가 있으면 취소
193 if (GetWorld()->GetTimerManager().IsTimerActive(FadeOutTimerHandle))
194 {
195 GetWorld()->GetTimerManager().ClearTimer(FadeOutTimerHandle);
196 }
197
198 // 5초 후 페이드아웃 시작
199 GetWorld()->GetTimerManager().SetTimer(FadeOutTimerHandle, this, &UChatWidget::OnFadeOutTimerComplete, AutoHideDelay, false);
200}
void OnFadeOutTimerComplete()
float AutoHideDelay
Definition ChatWidget.h:68

다음을 참조함 : AutoHideDelay, FadeOutTimerHandle, OnFadeOutTimerComplete().

다음에 의해서 참조됨 : OnInputFocusChanged(), SendMessage().

+ 이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
+ 이 함수를 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ AutoHideDelay

float UChatWidget::AutoHideDelay = 5.0f
private

ChatWidget.h 파일의 68 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : StartFadeOutTimer().

◆ bIsFading

bool UChatWidget::bIsFading = false
private

ChatWidget.h 파일의 60 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : FocusInput(), NativeTick(), OnFadeOutTimerComplete(), OnInputFocusChanged(), SendMessage().

◆ ChatInputBox

TObjectPtr<class UChatInputBox> UChatWidget::ChatInputBox
protected

ChatWidget.h 파일의 42 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : FocusInput(), NativeConstruct(), OnFadeOutTimerComplete().

◆ CurrentOpacity

float UChatWidget::CurrentOpacity = 1.0f
private

ChatWidget.h 파일의 61 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : FocusInput(), NativeConstruct(), NativeTick(), OnInputFocusChanged(), SendMessage().

◆ FadeOutTimerHandle

FTimerHandle UChatWidget::FadeOutTimerHandle
private

ChatWidget.h 파일의 57 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : FocusInput(), OnInputFocusChanged(), StartFadeOutTimer().

◆ FadeSpeed

float UChatWidget::FadeSpeed = 2.0f
private

ChatWidget.h 파일의 65 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : NativeTick().

◆ LeftChatBoxWidgetClass

TSubclassOf<class UChatBoxWidget> UChatWidget::LeftChatBoxWidgetClass
protected

ChatWidget.h 파일의 46 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : UChatWidget(), CreateChatBox().

◆ RightChatBoxWidgetClass

TSubclassOf<class UChatBoxWidget> UChatWidget::RightChatBoxWidgetClass
protected

ChatWidget.h 파일의 49 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : UChatWidget(), CreateChatBox().

◆ ScrollBox_ChatBox

TObjectPtr<class UScrollBox> UChatWidget::ScrollBox_ChatBox
protected

ChatWidget.h 파일의 36 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : SendMessage().

◆ SizeBox_Chat

TObjectPtr<class USizeBox> UChatWidget::SizeBox_Chat
protected

ChatWidget.h 파일의 33 번째 라인에서 정의되었습니다.

◆ Spacer_Content

TObjectPtr<class USpacer> UChatWidget::Spacer_Content
protected

ChatWidget.h 파일의 39 번째 라인에서 정의되었습니다.

◆ TargetOpacity

float UChatWidget::TargetOpacity = 1.0f
private

ChatWidget.h 파일의 62 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : FocusInput(), NativeConstruct(), NativeTick(), OnFadeOutTimerComplete(), OnInputFocusChanged(), SendMessage().

◆ VerticalBox_Content

TObjectPtr<class UVerticalBox> UChatWidget::VerticalBox_Content
protected

ChatWidget.h 파일의 30 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : SendMessage().


이 클래스에 대한 문서화 페이지는 다음의 파일들로부터 생성되었습니다.: