KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
UPopup_LevelSelect.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
4#include "ULevelSelectItem.h"
5#include "UPopupManager.h"
6#include "UTextureButton.h"
7#include "ALingoGameState.h"
8#include "GameLogging.h"
9#include "Components/HorizontalBox.h"
10#include "Components/Button.h"
11#include "Components/Spacer.h"
12
14{
15 Super::NativeConstruct();
16}
17
19{
20 if (Btn_Close)
21 {
22 Btn_Close->OnButtonClickedEvent.RemoveDynamic(this, &UPopup_LevelSelect::OnClickClose);
23 Btn_Close->OnButtonClickedEvent.AddDynamic(this, &UPopup_LevelSelect::OnClickClose);
24 }
25
26 // 기존 아이템들 제거
27 HorizontalBox->ClearChildren();
28
29 // 레벨 아이템들 생성 및 추가
30 for (int32 i = 0; i < LevelNames.Num(); ++i)
31 {
32 ULevelSelectItem* LevelItem = CreateWidget<ULevelSelectItem>(this, LevelSelectItemClass);
33 if (LevelItem)
34 {
35 // 레벨은 1부터 시작 (i+1)
36 int32 Level = i + 1;
37 FString LevelName = (i < LevelNames.Num()) ? LevelNames[i] : FString::Printf(TEXT("Level %d"), Level);
38
39 LevelItem->InitLevelItem(Level, LevelName, 3);
40
41 // 델리게이트 바인딩
42 LevelItem->OnLevelSelected.BindUObject(this, &UPopup_LevelSelect::OnLevelSelected);
43
44 HorizontalBox->AddChildToHorizontalBox(LevelItem);
45 }
46
47 // 마지막 항목이 아니면 Spacer 추가
48 if (i < LevelNames.Num() - 1)
49 {
50 USpacer* Spacer = NewObject<USpacer>(this);
51 if (Spacer)
52 {
53 Spacer->SetSize(FVector2D(45.0f, 0));
54 HorizontalBox->AddChildToHorizontalBox(Spacer);
55 }
56 }
57 }
58}
59
60void UPopup_LevelSelect::OnLevelSelected(int32 SelectedLevel)
61{
62 // GameState의 RoomLevel 설정 (Host만 팝업을 열므로 Host에서만 실행됨)
63 if (ALingoGameState* GameState = GetWorld()->GetGameState<ALingoGameState>())
64 {
65 GameState->SetRoomLevel(SelectedLevel);
66 }
67 else
68 {
69 PRINTLOG(TEXT("Failed to get ALingoGameState"));
70 }
71
73}
74
76{
77 // 팝업 닫힘 델리게이트 실행
78 if (OnPopupClosed.IsBound())
79 OnPopupClosed.Execute();
80
81 // PopupManager를 통해 팝업 닫기
82 if (UPopupManager* PopupMgr = UPopupManager::Get(GetWorld()))
83 {
84 PopupMgr->HideCurrentPopup();
85 }
86}
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
Definition GameLogging.h:30
레벨 선택 아이템 위젯
void InitLevelItem(int32 InLevel, const FString &InLevelName, int32 InPlayTime)
레벨 정보를 초기화하고 단어 그룹들을 생성
FOnLevelSelectedDelegate OnLevelSelected
레벨 선택 델리게이트
팝업 관리자
void OnLevelSelected(int32 SelectedLevel)
레벨 선택 이벤트 핸들러
virtual void NativeConstruct() override
TObjectPtr< class UTextureButton > Btn_Close
팝업 닫기 버튼 (우측 상단)
FOnPopupClosedDelegate OnPopupClosed
팝업이 닫힐 때 호출되는 델리게이트
TObjectPtr< class UHorizontalBox > HorizontalBox
레벨 아이템들이 배치될 Horizontal Box
TArray< FString > LevelNames
레벨 이름 배열
TSubclassOf< class ULevelSelectItem > LevelSelectItemClass
생성할 LevelSelectItem 위젯 클래스
void InitPopup()
팝업을 초기화하고 레벨 아이템들을 생성