| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using System; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | [CreateAssetMenu(menuName = "Config/WindowConfig")] |
| | | public class WindowConfig : ScriptableObject |
| | |
| | | [NonSerialized] public List<string> childWindows = new List<string>(); |
| | | |
| | | static WindowConfig config; |
| | | static WindowConfig Get() |
| | | public static async UniTask<WindowConfig> Get() |
| | | { |
| | | if (config == null) |
| | | { |
| | | config = BuiltInLoader.LoadScriptableObject<WindowConfig>("WindowConfig"); |
| | | config = await BuiltInLoader.LoadScriptableObjectAsync<WindowConfig>("WindowConfig"); |
| | | foreach (var table in config.windows) |
| | | { |
| | | var children = config.parentChildrenTable[table.parent] = new List<string>(); |
| | |
| | | { |
| | | children.Add(info.window); |
| | | } |
| | | |
| | | config.childWindows.AddRange(children); |
| | | } |
| | | } |
| | | |
| | | return config; |
| | | |
| | | } |
| | | |
| | | public static void Release() |
| | |
| | | config = null; |
| | | } |
| | | |
| | | public static bool FindParentWindow(string child, out string parent) |
| | | public static async UniTask<(bool found, string parent)> FindParentWindow(string child) |
| | | { |
| | | foreach (var table in Get().windows) |
| | | var cfg = await Get(); |
| | | foreach (var table in cfg.windows) |
| | | { |
| | | foreach (var orderTable in table.orderTables) |
| | | { |
| | | if (orderTable.window == child) |
| | | { |
| | | parent = table.parent; |
| | | return true; |
| | | return (true, table.parent); |
| | | } |
| | | } |
| | | } |
| | | |
| | | parent = string.Empty; |
| | | return false; |
| | | return (false, string.Empty); |
| | | } |
| | | |
| | | public static List<string> GetChildWindows(string parent) |
| | | public static async UniTask<List<string>> GetChildWindows(string parent) |
| | | { |
| | | if (Get().parentChildrenTable.ContainsKey(parent)) |
| | | var cfg = await Get(); |
| | | if (cfg.parentChildrenTable.ContainsKey(parent)) |
| | | { |
| | | return Get().parentChildrenTable[parent]; |
| | | return cfg.parentChildrenTable[parent]; |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | public static bool IsParentWindow(string name) |
| | | public static async UniTask<bool> IsParentWindow(string name) |
| | | { |
| | | foreach (var window in Get().windows) |
| | | var cfg = await Get(); |
| | | foreach (var window in cfg.windows) |
| | | { |
| | | if (window.parent == name) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | public static bool IsChildWindow(string name) |
| | | public static async UniTask<bool> IsChildWindow(string name) |
| | | { |
| | | return Get().childWindows.Contains(name); |
| | | var cfg = await Get(); |
| | | return cfg.childWindows.Contains(name); |
| | | } |
| | | |
| | | public static WindowLevel GetWindowLevel(string name) |
| | | public static async UniTask<WindowLevel> GetWindowLevel(string name) |
| | | { |
| | | foreach (var window in Get().windows) |
| | | var cfg = await Get(); |
| | | foreach (var window in cfg.windows) |
| | | { |
| | | if (window.parent == name) |
| | | { |
| | | return window.level; |
| | | } |
| | | } |
| | | |
| | | return WindowLevel.None; |
| | | } |
| | | |
| | | public static string GetWindowPattern(string name) |
| | | public static async UniTask<string> GetWindowPattern(string name) |
| | | { |
| | | foreach (var window in Get().windows) |
| | | var cfg = await Get(); |
| | | foreach (var window in cfg.windows) |
| | | { |
| | | if (window.parent == name) |
| | | { |
| | | return window.pattern; |
| | | } |
| | | } |
| | | |
| | | return string.Empty; |
| | | } |
| | | |
| | | public static List<OrderTable> GetWindowFunctionInfos(string parent) |
| | | public static async UniTask<List<OrderTable>> GetWindowFunctionInfos(string parent) |
| | | { |
| | | foreach (var table in Get().windows) |
| | | var cfg = await Get(); |
| | | foreach (var table in cfg.windows) |
| | | { |
| | | if (table.parent == parent) |
| | | { |
| | | return new List<OrderTable>(table.orderTables); |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | public static string GetTitleIconKey(string name) |
| | | public static async UniTask<string> GetTitleIconKey(string name) |
| | | { |
| | | foreach (var window in Get().windows) |
| | | var cfg = await Get(); |
| | | foreach (var window in cfg.windows) |
| | | { |
| | | if (window.parent == name) |
| | | { |
| | | return window.titleIconKey; |
| | | } |
| | | } |
| | | |
| | | return string.Empty; |
| | | } |
| | | |