Exemplo n.º 1
0
        public static GuiNode TryParse(ConfigNode node)
        {
            if (node != null)
            {
                var appLauncher = AppLauncherNode.TryParse(node.GetNode("APPLAUNCHER"))
                                  ?? AppLauncherNode.GetDefault();
                var toolbar = ToolbarNode.TryParse(node.GetNode("TOOLBAR"))
                              ?? ToolbarNode.GetDefault();
                var contextMenu = Gui.ContextMenuNode.TryParse(node.GetNode("CONTEXT_MENU"))
                                  ?? Gui.ContextMenuNode.GetDefault();

                return(new GuiNode(appLauncher, toolbar, contextMenu));
            }

            return(null);
        }
        private List <UIComponent> GetComponentChainRecursive(ToolbarNode node, List <string> names)
        {
            if (names.Count == 0)
            {
                return(new List <UIComponent>());
            }
            string currentName = names[0];

            if (node.options.ContainsKey(currentName))
            {
                var nextTreeNode = node.options[currentName];
                var chain        = GetComponentChainRecursive(nextTreeNode, names.GetRange(1, names.Count - 1));
                chain.Insert(0, nextTreeNode.component);
                return(chain);
            }
            else
            {
                throw new Exception(currentName + " does not exist in " + node.name);
            }
        }
        private MainToolstripNavigator()
        {
            var mainToolStrip = Singleton <GameMainToolbar> .instance.component as UITabstrip;
            Dictionary <string, ToolbarNode> firstOptions = new Dictionary <string, ToolbarNode>();

            mainToolbarRoot = new ToolbarNode(mainToolStrip.name, mainToolStrip, firstOptions);
            foreach (var tab in mainToolStrip.tabs)
            {
                if (tab.name.Contains("Separator") ||
                    tab.name.Equals("Money") ||
                    tab.name.Equals("Policies"))
                {
                    continue;
                }
                Dictionary <string, ToolbarNode> secondOptions = new Dictionary <string, ToolbarNode>();
                ToolbarNode oneDeep = new ToolbarNode(tab.name, tab, secondOptions);
                firstOptions[tab.name] = oneDeep;

                var subPanelType = Type.GetType(tab.name + "GroupPanel, Assembly-CSharp");
                var subPanel     = mainToolStrip.GetComponentInContainer(tab, subPanelType) as GeneratedGroupPanel;
                var subTabStrip  = subPanelType
                                   .GetField("m_Strip", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy)
                                   .GetValue(subPanel) as UITabstrip;
                foreach (var subTab in subTabStrip.components)
                {
                    Dictionary <string, ToolbarNode> thirdOptions = new Dictionary <string, ToolbarNode>();
                    ToolbarNode twoDeep = new ToolbarNode(tab.name, tab, thirdOptions);
                    secondOptions[subTab.name] = twoDeep;

                    var subsubType  = Type.GetType(tab.name + "Panel, Assembly-CSharp");
                    var subsubPanel = subTabStrip.GetComponentInContainer(subTab, subsubType) as GeneratedScrollPanel;
                    foreach (var component in subsubPanel.childComponents)
                    {
                        ToolbarNode threeDeep = new ToolbarNode(component.name, component, null);
                        thirdOptions[component.name] = threeDeep;
                    }
                }
            }
        }
Exemplo n.º 4
0
 public ToolBarTree DockNode(ToolbarNode node)
 {
     Nodes.Add(node);
     return(this);
 }
Exemplo n.º 5
0
 public static GuiNode GetDefault()
 => new GuiNode(AppLauncherNode.GetDefault(), ToolbarNode.GetDefault(), Gui.ContextMenuNode.GetDefault());
Exemplo n.º 6
0
 private GuiNode(AppLauncherNode appLauncher, ToolbarNode toolbar, Gui.ContextMenuNode contextMenu)
 {
     AppLauncher = appLauncher;
     Toolbar     = toolbar;
     ContextMenu = contextMenu;
 }