KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
UPopup_InputMsg.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_InputMsg.h"
5
6#include "GameLogging.h"
7#include "UDialogManager.h"
8#include "UHoverButton.h"
9#include "UImageButton.h"
11#include "UPopupManager.h"
12#include "UTextureButton.h"
13
14#include "Components/EditableTextBox.h"
15#include "Components/TextBlock.h"
16#include "Kismet/GameplayStatics.h"
17
19{
20 Super::NativeConstruct();
21}
22
23void UPopup_InputMsg::SetTitle(const FString& InTitle) { Txt_Title->SetText(FText::FromString(InTitle)); }
24void UPopup_InputMsg::SetDesc(const FString& InDescription) { Txt_Desc->SetText(FText::FromString(InDescription)); }
25
27{
28 const FString InputString = Edit_Name->GetText().ToString();
29
30 if ( PopupType == EPopupType::Login )
31 RequestUserToken(InputString);
32 else
33 RequestUserRegister(InputString);
34
35 // PopupManager를 통해 팝업 닫기 (마우스 커서 처리 포함)
36 if (UPopupManager* PopupMgr = UPopupManager::Get(GetWorld()))
37 {
38 PopupMgr->HideCurrentPopup();
39 }
40}
41
43{
44 // PopupManager를 통해 팝업 닫기 (마우스 커서 처리 포함)
45 if (UPopupManager* PopupMgr = UPopupManager::Get(GetWorld()))
46 {
47 PopupMgr->HideCurrentPopup();
48 }
49}
50
51void UPopup_InputMsg::InitPopup(const EPopupType InPopupType )
52{
53 // 중복 바인딩 방지: 기존 바인딩 제거 후 재바인딩
54 if (Btn_Close)
55 {
58 }
59 if (Btn_Ok)
60 {
63 }
64 if (Btn_Cancel)
65 {
68 }
69
70 this->PopupType = InPopupType;
71
72 if ( PopupType == EPopupType::Login )
73 {
74 this->SetTitle("Login");
75 this->SetDesc("Please enter your registered name below.");
76 }
77 else
78 {
79 this->SetTitle("Registeration");
80 this->SetDesc("Please enter your name below.");
81 }
82}
83
84void UPopup_InputMsg::RequestUserRegister(const FString& UserInput)
85{
86 if (UserInput.IsEmpty())
87 return;
88
89 if (auto KLingoNetwork = UKLingoNetworkSystem::Get(GetWorld()))
90 {
91 PRINTLOG(TEXT("[TEST] RequestUserRegister - UserName: %s"), *UserInput);
92 KLingoNetwork->RequestUserRegister(
93 UserInput,
94 FResponseUserRegisterDelegate::CreateUObject(this,
96 );
97 }
98 else
99 {
100 PRINTLOG(TEXT("UKLingoNetworkSystem not found!"));
101 }
102}
103
104void UPopup_InputMsg::RequestUserToken(const FString& UserInput)
105{
106 if (UserInput.IsEmpty())
107 return;
108
109 if (auto KLingoNetwork = UKLingoNetworkSystem::Get(GetWorld()))
110 {
111 PRINTLOG(TEXT("[TEST] RequestUserToken - UserName: %s"), *UserInput);
112 KLingoNetwork->RequestUserToken(
113 UserInput,
114 FResponseUserTokenDelegate::CreateUObject(this, &UPopup_InputMsg::OnResponseUserToken)
115 );
116 }
117 else
118 {
119 PRINTLOG(TEXT("UKLingoNetworkSystem not found!"));
120 }
121}
122
124{
125 if (bWasSuccessful)
126 {
127 PRINTLOG(TEXT("--- User Register SUCCESS ---"));
128 ResponseData.PrintData();
129
130 // 가입 성공 시 토큰 발급
131 RequestUserToken(ResponseData.username);
132 }
133 else
134 {
135 PRINTLOG(TEXT("--- User Register FAILED ---"));
136 }
137}
138
139void UPopup_InputMsg::OnResponseUserToken(FResponseUserToken& ResponseData, bool bWasSuccessful)
140{
141 if (bWasSuccessful)
142 {
143 PRINTLOG(TEXT("--- User Token SUCCESS ---"));
145 }
146 else
147 {
148 PRINTLOG(TEXT("--- User Token FAILED ---"));
149 }
150}
151
153{
154 if (auto KLingoNetwork = UKLingoNetworkSystem::Get(GetWorld()))
155 {
156 KLingoNetwork->RequestUserMe( FResponseUserMeDelegate::CreateUObject(this, &UPopup_InputMsg::OnResponseUserMe) );
157 }
158 else
159 {
160 PRINTLOG(TEXT("UKLingoNetworkSystem not found!"));
161 }
162}
163
164void UPopup_InputMsg::OnResponseUserMe(FResponseUserMe& ResponseData, bool bWasSuccessful)
165{
166 if (bWasSuccessful)
167 {
168 PRINTLOG(TEXT("--- User Me SUCCESS ---"));
169
170 // 로비맵으로 (Seamless Travel로 PlayerState 유지)
171 if (UWorld* World = GetWorld())
172 {
173 UDialogManager::Get(GetWorld())->ShowToast(TEXT("Login Success"));
174
175 World->ServerTravel(TEXT("/Game/CustomContents/Maps/LobbyMap?listen"), true, false);
176 }
177 }
178 else
179 {
180 PRINTLOG(TEXT("--- User Token FAILED ---"));
181 }
182}
EPopupType
팝업 타입 정의
Definition EPopupType.h:14
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
Definition GameLogging.h:30
UDialogManager 클래스를 선언합니다.
KLingo API 요청을 담당하는 서브시스템을 선언합니다.
EPopupType PopupType
Definition UBasePopup.h:34
FOnImageButtonClickedEvent OnButtonClickedEvent
버튼 클릭 시 발생하는 이벤트
팝업 관리자
void SetTitle(const FString &InTitle)
void OnResponseUserMe(FResponseUserMe &ResponseData, bool bWasSuccessful)
class UTextBlock * Txt_Desc
void OnResponseUserToken(FResponseUserToken &ResponseData, bool bWasSuccessful)
class UTextureButton * Btn_Close
void SetDesc(const FString &InDescription)
void RequestUserToken(const FString &UserInput)
class UTextBlock * Txt_Title
void InitPopup(const EPopupType PopupType)
class UImageButton * Btn_Cancel
void RequestUserRegister(const FString &UserInput)
virtual void NativeConstruct() override
class UEditableTextBox * Edit_Name
class UImageButton * Btn_Ok
void OnResponseUserRegister(FResponseUserRegister &ResponseData, bool bWasSuccessful)
FOnTextureButtonClickedEvent OnButtonClickedEvent
버튼 클릭 이벤트
void PrintData() const
디버그 로그에 응답 내용을 출력합니다.