#nullable enable using Cysharp.Threading.Tasks; using System.Collections.Generic; using UnityEngine; using UVC.Factory.Component; using UVC.UI.Commands; using UVC.UI.List.ComponentList; using UVC.UI.Menu; using UVC.UI.Tab; namespace Simulator.LNB { public class LNBExplorer : MonoBehaviour, ITabContent { // 이 창이 실제로 제어할 리스트 UI 컴포넌트를 가리킵니다. [Tooltip("실제 데이터 리스트를 표시하는 ComponentList UI 컴포넌트입니다.")] [SerializeField] protected ComponentList? componentList = null; private string category = "ALL"; /// /// 이 컴포넌트가 처음 초기화될 때 호출됩니다. (SingletonScene의 일부) /// 'componentList' 변수에 필요한 컴포넌트를 찾아 할당하는 역할을 합니다. /// protected void Start() { if (componentList == null) { componentList = GetComponentInChildren(); } if (componentList == null) { Debug.LogError("InfiniteScroll component is not assigned or found in Children."); return; } } /// /// 리스트에 표시할 데이터를 설정하고 UI를 구성합니다. /// FactoryObjectManager로부터 모든 객체 정보를 가져와 리스트에 넘겨줍니다. /// public void SetupData() { // 팩토리 내 모든 객체 정보를 카테고리별로 정렬하여 가져옵니다. var infos = FactoryObjectManager.Instance.GetFactoryObjectInfosByCategory(); // 가져온 데이터를 ComponentList 컴포넌트에 전달하여 실제 UI 리스트를 생성하도록 합니다. if (category != "ALL" && infos.ContainsKey(category)) { var filteredInfos = new SortedDictionary> { { category, infos[category] } }; componentList?.SetupData(filteredInfos); return; } componentList?.SetupData(infos); } /// /// '필터' 버튼을 클릭했을 때 호출되는 메서드입니다. /// 사용자가 쉽게 검색할 수 있도록 도와주는 필터 키워드 메뉴를 보여줍니다. /// public void ShowFilter() { Debug.Log("필터 버튼 클릭됨."); // 컨텍스트 메뉴에 표시할 항목들을 정의합니다. var menuItems = new List { // "카테고리" 메뉴: 클릭 시 검색창에 "@Category "를 자동으로 입력해줍니다. // 생성자: (itemId, displayName, command, commandParameter) new ContextMenuItemData("Menu1", "카테고리", new ActionCommand(()=>{ componentList?.SetSearchText("@Category "); })), new ContextMenuItemData(isSeparator: true), // 구분선 추가 new ContextMenuItemData("Menu2", "구역", new ActionCommand(()=>{ componentList?.SetSearchText("@Area "); })), new ContextMenuItemData(isSeparator: true), // 구분선 추가 new ContextMenuItemData("Menu3", "층", new ActionCommand(()=>{ componentList?.SetSearchText("@Floor "); })), }; // ContextMenuManager를 통해 마우스 위치에 메뉴를 표시합니다. ContextMenuManager.Instance.ShowMenu(menuItems, Input.mousePosition); } /// /// 새로고침 버튼 클릭 시 호출됩니다. /// 리스트의 모든 데이터를 지우고 SetupData를 다시 호출하여 목록을 갱신합니다. /// public void Refresh() { SetupData(); } /// /// 탭 콘텐츠에 데이터를 전달합니다. /// /// 전달할 데이터 객체 public void SetContentData(object? data) { Debug.Log($"TabContentComponentList: SetContentData called. data:{data}"); category = data as string ?? "ALL"; SetupData(); } /// /// 탭 전환 시 데이터가 있는 경우 전달 되는 데이터. SetContentData 이후 호출 됨 /// /// 전달할 데이터 객체 public void UpdateContentData(object? data) { } /// /// 닫힐 때 실행되는 로직을 처리합니다. /// /// 비동기 닫기 작업을 나타내는 입니다. public UniTask OnCloseAsync() { Debug.Log("TabContentComponentList: OnClose called"); return UniTask.CompletedTask; } } }