KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
LobbyWidget.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 "LobbyWidget.h"
5
6#include "SessionInfoWidget.h"
7#include "UDialogManager.h"
8#include "UHoverButton.h"
9#include "UImageButton.h"
10#include "ULingoGameInstance.h"
11#include "ULingoGameHelper.h"
12#include "UTextureButton.h"
13#include "Components/Button.h"
14#include "Components/EditableTextBox.h"
15#include "Components/ScrollBox.h"
16#include "Components/TextBlock.h"
17#include "Components/WidgetSwitcher.h"
18
20{
21 Super::NativeConstruct();
22
23 // 마우스 커서 표시
25
26 GI = Cast<ULingoGameInstance>(GetGameInstance());
27 // 중복 바인딩 방지
28 GI->onFindComplete.Unbind();
30
31 // Lobby Canvas - 중복 바인딩 방지
32 if (Btn_Host)
33 {
36 }
37 if (Btn_Join)
38 {
41 }
42 if (Btn_LogOut)
43 {
46 }
47
48 // Create Canvas - 중복 바인딩 방지
49 if (Btn_Create)
50 {
53 }
55 {
56 EdtTxt_SessionName->OnTextChanged.RemoveDynamic(this, &ULobbyWidget::OnValueChangedSessionName);
57 EdtTxt_SessionName->OnTextChanged.AddDynamic(this, &ULobbyWidget::OnValueChangedSessionName);
58 }
59 if (Btn_Back1)
60 {
63 }
64
65 // Join Canvas - 중복 바인딩 방지
66 if (Btn_Update)
67 {
70 }
71 if (Btn_Back2)
72 {
75 }
76}
77
79{
80 // 세션 생성 화면으로 이동
81 widgetSwitcher->SetActiveWidgetIndex(1);
82}
83
85{
86 // 세션 조회 화면으로 이동
87 widgetSwitcher->SetActiveWidgetIndex(2);
88 // 최초 업데이트
90}
91
93{
94 UDialogManager::Get(GetWorld())->ShowToast(TEXT("OnLogOutClicked"));
95}
96
98{
99 // 세션 이름
100 FString sessionName = EdtTxt_SessionName->GetText().ToString();
101 // 세션 생성
102 GI->CreateMySession(sessionName);
103
104 UDialogManager::Get(GetWorld())->ShowToast(TEXT("Room created successfully"));
105}
106
108{
109 // text 값의 길이에 따른 생성 버튼 활성 / 비활성
110 // text.IsEmpty()
111 Btn_Create->SetIsEnabled(Text.ToString().Len() > 0);
112}
113
115{
116 widgetSwitcher->SetActiveWidgetIndex(0);
117}
118
120{
121 Scrl_SessionList->ClearChildren();
122 // 버튼 비활성화
123 Txt_Update->SetText(FText::FromString(TEXT("Updating ...")));
124 Btn_Update->SetIsEnabled(false);
125
127}
128
129void ULobbyWidget::OnFindComplete(int32 idx, FString sessionName)
130{
131 if (idx == -1)
132 {
133 // 조회 버튼 문구 변경
134 Txt_Update->SetText(FText::FromString(TEXT("Update Session")));
135 // 조회 버튼 활성화
136 Btn_Update->SetIsEnabled(true);
137 }
138 else
139 {
140 // sessionInfoWidget 만들자.
141 USessionInfoWidget* item = CreateWidget<USessionInfoWidget>(GetWorld(), sessionInfoWidget);
142 // 만들어진 item 을 scrollSessionList 에 추가
143 Scrl_SessionList->AddChild(item);
144 // 만들어지 item 정보 설정
145 item->SetSessionInfo(idx, sessionName);
146 }
147}
UDialogManager 클래스를 선언합니다.
FOnHoverButtonClickedEvent OnButtonClickedEvent
FOnImageButtonClickedEvent OnButtonClickedEvent
버튼 클릭 시 발생하는 이벤트
static void ShowMouseCursor(const UObject *WorldContextObject)
마우스 커서를 표시하고 게임+UI 입력 모드로 설정합니다.
void CreateMySession(FString displayName)
FFindComplete onFindComplete
void OnFindComplete(int32 idx, FString sessionName)
void OnBackPressed()
virtual void NativeConstruct() override
void OnValueChangedSessionName(const FText &Text)
void OnCreateClicked()
class UTextureButton * Btn_Update
Definition LobbyWidget.h:73
class UHoverButton * Btn_Back1
Definition LobbyWidget.h:56
void OnLogOutClicked()
class UScrollBox * Scrl_SessionList
Definition LobbyWidget.h:70
class UHoverButton * Btn_Host
Definition LobbyWidget.h:30
class UHoverButton * Btn_Join
Definition LobbyWidget.h:33
void OnJoinClicked()
class UTextBlock * Txt_Update
Definition LobbyWidget.h:76
class UWidgetSwitcher * widgetSwitcher
Definition LobbyWidget.h:25
class ULingoGameInstance * GI
Definition LobbyWidget.h:22
class UHoverButton * Btn_Back2
Definition LobbyWidget.h:79
class UImageButton * Btn_Create
Definition LobbyWidget.h:53
class UEditableTextBox * EdtTxt_SessionName
Definition LobbyWidget.h:50
TSubclassOf< class USessionInfoWidget > sessionInfoWidget
Definition LobbyWidget.h:83
class UHoverButton * Btn_LogOut
Definition LobbyWidget.h:36
void OnHostClicked()
void SetSessionInfo(int32 idx, FString sessionName)
FOnTextureButtonClickedEvent OnButtonClickedEvent
버튼 클릭 이벤트