using System.Collections; 
 | 
using System.Collections.Generic; 
 | 
using UnityEngine; 
 | 
using System; 
 | 
  
 | 
[CreateAssetMenu(menuName = "Config/WindowConfig")] 
 | 
public class WindowConfig : ScriptableObject 
 | 
{ 
 | 
    public WindowTable[] windows; 
 | 
  
 | 
    [NonSerialized] public Dictionary<string, List<string>> parentChildrenTable = new Dictionary<string, List<string>>(); 
 | 
    [NonSerialized] public List<string> childWindows = new List<string>(); 
 | 
  
 | 
    static WindowConfig config; 
 | 
    static WindowConfig Get() 
 | 
    { 
 | 
        if (config == null) 
 | 
        { 
 | 
            config = BuiltInLoader.LoadScriptableObject<WindowConfig>("WindowConfig"); 
 | 
            foreach (var table in config.windows) 
 | 
            { 
 | 
                var children = config.parentChildrenTable[table.parent] = new List<string>(); 
 | 
                foreach (var info in table.orderTables) 
 | 
                { 
 | 
                    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) 
 | 
    { 
 | 
        foreach (var table in Get().windows) 
 | 
        { 
 | 
            foreach (var orderTable in table.orderTables) 
 | 
            { 
 | 
                if (orderTable.window == child) 
 | 
                { 
 | 
                    parent = table.parent; 
 | 
                    return true; 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
  
 | 
        parent = string.Empty; 
 | 
        return false; 
 | 
    } 
 | 
  
 | 
    public static List<string> GetChildWindows(string parent) 
 | 
    { 
 | 
        if (Get().parentChildrenTable.ContainsKey(parent)) 
 | 
        { 
 | 
            return Get().parentChildrenTable[parent]; 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            return null; 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public static bool IsParentWindow(string name) 
 | 
    { 
 | 
        foreach (var window in Get().windows) 
 | 
        { 
 | 
            if (window.parent == name) 
 | 
            { 
 | 
                return true; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        return false; 
 | 
    } 
 | 
  
 | 
    public static bool IsChildWindow(string name) 
 | 
    { 
 | 
        return Get().childWindows.Contains(name); 
 | 
    } 
 | 
  
 | 
    public static WindowLevel GetWindowLevel(string name) 
 | 
    { 
 | 
        foreach (var window in Get().windows) 
 | 
        { 
 | 
            if (window.parent == name) 
 | 
            { 
 | 
                return window.level; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        return WindowLevel.None; 
 | 
    } 
 | 
  
 | 
    public static string GetWindowPattern(string name) 
 | 
    { 
 | 
        foreach (var window in Get().windows) 
 | 
        { 
 | 
            if (window.parent == name) 
 | 
            { 
 | 
                return window.pattern; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        return string.Empty; 
 | 
    } 
 | 
  
 | 
    public static List<OrderTable> GetWindowFunctionInfos(string parent) 
 | 
    { 
 | 
        foreach (var table in Get().windows) 
 | 
        { 
 | 
            if (table.parent == parent) 
 | 
            { 
 | 
                return new List<OrderTable>(table.orderTables); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        return null; 
 | 
    } 
 | 
  
 | 
    public static string GetTitleIconKey(string name) 
 | 
    { 
 | 
        foreach (var window in Get().windows) 
 | 
        { 
 | 
            if (window.parent == name) 
 | 
            { 
 | 
                return window.titleIconKey; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        return string.Empty; 
 | 
    } 
 | 
  
 | 
    [Serializable] 
 | 
    public struct WindowTable 
 | 
    { 
 | 
        public string parent; 
 | 
        public string titleIconKey; 
 | 
        public WindowLevel level; 
 | 
        public string pattern; 
 | 
        public OrderTable[] orderTables; 
 | 
    } 
 | 
  
 | 
    [Serializable] 
 | 
    public struct OrderTable 
 | 
    { 
 | 
        public int order; 
 | 
        public int functionId; 
 | 
        public int redPointId; 
 | 
        public string titleKey; 
 | 
        public string window; 
 | 
    } 
 | 
  
 | 
    public enum WindowLevel 
 | 
    { 
 | 
        None, 
 | 
        OneLevel, 
 | 
        SecondLevel, 
 | 
        ThirdLevel, 
 | 
    } 
 | 
  
 | 
} 
 |