Files
EnglewoodLAB/Assets/Scripts/UI/TopMenuPanel.cs
2026-03-09 17:00:30 +09:00

177 lines
6.6 KiB
C#

using Cysharp.Threading.Tasks;
using EnglewoodLAB.Constants;
using EnglewoodLAB.Modal;
using EnglewoodLAB.UI;
using EnglewoodLAB.UI.Command;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UVC.UI.Menu;
using UVC.UI.Modal;
using UVC.UI.Toolbar.Model;
using UVC.UI.ToolBar;
using UVC.UI.Window.PropertyWindow;
namespace EnglewoodLAB
{
public class TopMenuPanel : UIPanel
{
[SerializeField]
private TopMenuController topMenu;
[SerializeField]
private Toolbox topToolBox;
[SerializeField]
private PropertyWindow propertyWindow;
public PropertyWindow PropertyWindow { get => propertyWindow; }
public override async UniTask Init()
{
propertyWindow = FindAnyObjectByType<PropertyWindow>(FindObjectsInactive.Include);
topMenu = transform.GetComponentInChildren<TopMenuController>();
topToolBox = transform.GetComponentInChildren<Toolbox>();
//사용자 설정 정보 생성 및 컨텐츠 추가
SetSettingContent();
SetupTopMenu();
SetupToolBox();
await UniTask.CompletedTask;
}
private ContentModalView contentModalView;
private async void SetSettingContent()
{
//메인 설정창 패널
var modalCotents = new ModalContent($"{ResourceURL.UIPrefabFolderPath}ContentModalView")
{
Title = "사용자 설정",
ConfirmButtonText = "저장",
CancelButtonText = "취소",
ShowCancelButton = true,
ShowConfirmButton = true,
ShowCloseButton = true,
};
var canvas = FindObjectsByType<Canvas>(FindObjectsSortMode.None);
var popup = canvas.FirstOrDefault(x => x.name.Equals("PopupCanvas"));
var asset = Resources.Load<ContentModalView>(modalCotents.PrefabPath);
if (asset == null)
{
Debug.LogError($"[TopMenuPanel] Failed to load 'ContentModalView' prefab from Resources. Path was: '{modalCotents.PrefabPath}'. Please check the path and ensure the prefab exists.", this.gameObject);
return;
}
contentModalView = Instantiate<ContentModalView>(asset, popup.transform);
await contentModalView.OnOpen(modalCotents);
//설정 아이템 추가
//기본정보 , 정보 표시 관리 , 단축키 설정, 알람 설정 , 그래픽 옵션 , 마우스 옵션 창이 들어갈거임
List<ModalContent> modalContents = new();
//ModalContent baseInfo = new("ModalView/SettingModalView")
//{
// Title = "기본 정보",
// ShowCancelButton = false,
// ShowConfirmButton = false,
// ShowCloseButton = false,
//};
//modalContents.Add(baseInfo);
ModalContent Info = new($"{ResourceURL.UIPrefabFolderPath}SettingModalView")
{
Title = "정보 표시 관리",
ImagePath = "",
ShowCancelButton = false,
ShowConfirmButton = false,
ShowCloseButton = false,
};
modalContents.Add(Info);
//ModalContent shorCutInfo = new("ModalView/SettingModalView")
//{
// Title = "단축키 설정",
// ShowCancelButton = false,
// ShowConfirmButton = false,
// ShowCloseButton = false,
//};
//modalContents.Add(shorCutInfo);
ModalContent alarmInfo = new($"{ResourceURL.UIPrefabFolderPath}SettingModalView")
{
Title = "알람 설정",
ImagePath = "",
ShowCancelButton = false,
ShowConfirmButton = false,
ShowCloseButton = false,
};
modalContents.Add(alarmInfo);
ModalContent graphicnfo = new($"{ResourceURL.UIPrefabFolderPath}SettingModalView")
{
Title = "그래픽 옵션",
ImagePath = "",
ShowCancelButton = false,
ShowConfirmButton = false,
ShowCloseButton = false,
};
modalContents.Add(graphicnfo);
ModalContent mouseInfo = new($"{ResourceURL.UIPrefabFolderPath}SettingModalView")
{
Title = "마우스 옵션",
ImagePath = "",
ShowCancelButton = false,
ShowConfirmButton = false,
ShowCloseButton = false,
};
modalContents.Add(mouseInfo);
contentModalView.AddContent(modalContents);
}
private void SetupTopMenu()
{
if (topMenu == null)
{
Debug.LogWarning("TopMenuController is not assigned in SceneMain.");
return;
}
topMenu.AddMenuItem(new MenuItemData("MachineList", "설비목록", new OpenOverviewPanelCommand()));
topMenu.AddMenuItem(new MenuItemData("OverView", "OverView", new OpenOverviewPanelCommand()));
topMenu.AddMenuItem(new MenuItemData("ManufactoringOrder", "제조지시현황", new OpenManufactoringOrderPanelCommand()));
topMenu.AddMenuItem(new MenuItemData("ChargePackagingOrder", "충포장지시현황", new OpenChargePackagingOrderPanelCommand()));
topMenu.Initialize();
}
private void SetupToolBox()
{
var toolbarModel = new ToolbarModel();
// --- 툴바 모델 구성 시작 ---
// 플레이백
toolbarModel.AddStandardButton("플레이백",
$"{ResourceURL.UISpriteFolderPath}ic-playback",
new OpenPlaybackListPanelCommand()
);
// 금일 계획 현황
toolbarModel.AddStandardButton("금일 계획 현황",
$"{ResourceURL.UISpriteFolderPath}ic-report",
null // TODO: 새로운 함수 만들어야 함.
);
// 알림 목록
toolbarModel.AddStandardButton("알림 목록",
$"{ResourceURL.UISpriteFolderPath}ic-alarm",
new OpenAlarmHistoryPanelCommand(propertyWindow)
);
// 종료
toolbarModel.AddStandardButton("종료",
$"{ResourceURL.UISpriteFolderPath}ic-out",
null // TODO: 새로운 함수 만들어야 함.
);
topToolBox.SetData(toolbarModel);
topToolBox.Initialize();
}
}
}