KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
ULoadingCircleManager.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
8
9#include "FComponentHelper.h"
10#include "GameLogging.h"
11#include "ULoadginCircle.h"
12#include "UBroadcastManager.h"
13
14#include "GameFramework/PlayerController.h"
15#include "Engine/LocalPlayer.h"
16#include "Engine/GameInstance.h"
17#include "Engine/GameViewportClient.h"
18#include "Blueprint/UserWidget.h"
19#include "Engine/Engine.h"
20#include "Engine/World.h"
21#include "Onepiece/Onepiece.h"
22
23#define LOADINGCIRCLEWIDGET_PATH TEXT("/Game/CustomContents/UI/WBP_LoadingCircle.WBP_LoadingCircle_C")
24
29
31{
32 if (World == nullptr || !World->IsGameWorld())
33 return;
34
35 // 위젯이 유효하고 같은 월드이며, 뷰포트에 추가되어 있는지 확인
36 if (IsValid(CircleWidget) &&
37 CircleWidget->GetWorld() == World &&
38 CircleWidget->IsInViewport())
39 {
40 return;
41 }
42
43 // 기존 위젯이 있으면 정리
44 if (CircleWidget)
45 {
46 if (CircleWidget->IsInViewport())
47 CircleWidget->RemoveFromParent();
48
49 CircleWidget = nullptr;
50 }
51
52 ULocalPlayer* LocalPlayer = GetLocalPlayer();
53 if (LocalPlayer == nullptr)
54 return;
55
56 APlayerController* PC = LocalPlayer->GetPlayerController(World);
57 if (PC == nullptr)
58 return;
59
61 return;
62
63 ULoadginCircle* NewWidget = CreateWidget<ULoadginCircle>(PC, CircleWidgetClass);
64 if (!NewWidget)
65 return;
66
67 // Game Viewport에 추가하여 레벨 전환 시에도 유지
69 CircleWidget = NewWidget;
70
71 // 위젯 재생성 시 현재 카운트에 따라 표시 상태 복원
72 if (LoadingCount > 0)
73 {
75 }
76 else
77 {
78 CircleWidget->Hide();
79 }
80}
81
83{
85
86 PRINTLOG(TEXT("[LoadingCircleManager] Show - Count: %d → %d"), LoadingCount - 1, LoadingCount);
87
88 if (UWorld* World = GetWorld())
89 {
91
92 if (CircleWidget && LoadingCount > 0)
93 {
94 CircleWidget->Show();
95 }
96 else if (!CircleWidget)
97 {
98 PRINTLOG(TEXT("[LoadingCircleManager] Show FAILED - Widget is nullptr!"));
99 }
100 }
101}
102
104{
105 const int32 OldCount = LoadingCount;
106 LoadingCount = FMath::Max(0, LoadingCount - 1);
107
108 PRINTLOG(TEXT("[LoadingCircleManager] Hide - Count: %d → %d"), OldCount, LoadingCount);
109
110 if (OldCount == 0)
111 {
112 PRINTLOG(TEXT("[LoadingCircleManager] WARNING: Hide called but count was already 0!"));
113 }
114
115 if (UWorld* World = GetWorld())
116 {
118
119 if (CircleWidget)
120 {
121 if (LoadingCount == 0)
122 {
123 CircleWidget->Hide();
124 }
125 }
126 else
127 {
128 PRINTLOG(TEXT("[LoadingCircleManager] Hide FAILED - Widget is nullptr!"));
129 }
130 }
131}
132
134{
135 return LoadingCount;
136}
137
139{
140 if (bShow)
141 {
142 Show();
143 }
144 else
145 {
146 Hide();
147 }
148}
FComponentHelper 구조체를 선언합니다.
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
Definition GameLogging.h:30
ULoadginCircle 클래스를 선언합니다.
#define LOADINGCIRCLEWIDGET_PATH
ULoadingCircleManager 클래스를 선언합니다.
네트워크 대기 상태를 표시하는 로딩 서클 위젯입니다.
void Show()
로딩 서클을 표시합니다.
void AddToGameViewport(int32 ZOrder)
위젯을 Game Viewport에 추가하여 레벨 전환 시에도 유지되도록 합니다.
void EnsureWidgetForWorld(UWorld *World)
현재 월드에 위젯이 없으면 생성하고 Game Viewport에 부착합니다.
TObjectPtr< class ULoadginCircle > CircleWidget
void Show()
로딩 카운트를 증가시킵니다.
void LoadingCircle(bool bShow)
로딩 서클을 표시하거나 숨깁니다.
TSubclassOf< class ULoadginCircle > CircleWidgetClass
int32 LoadingCount
Manager가 관리하는 로딩 카운트 (위젯 재생성 시에도 유지됨)
void Hide()
로딩 카운트를 감소시킵니다.
int32 GetLoadingCount() const
현재 로딩 카운트를 반환합니다.
static const int32 LoadingCircle
Definition Onepiece.h:12
static T * LoadAsset(const TCHAR *Path)