Exemplo n.º 1
0
 public ResearchSelectPanel()
 {
     _instance = this;
 }
Exemplo n.º 2
0
        public void DoClick()
        {
            if (Event.current.button == 0)
            {
                if (ResearchSelectPanel.selected == this)
                {
                    ResearchWindow.Instance.CenterOn(this);
                }
                else
                {
                    ResearchSelectPanel.Select(this);
                }
            }
            else if (Event.current.button == 1)
            {
                var options = new List <FloatMenuOption>();
                options.Add(new FloatMenuOption("Open in Def Explorer...", () => ClickHandler(), MenuOptionPriority.High, null));
                if (ResearchSelectPanel.selected != null)
                {
                    if (ResearchSelectPanel.selected == this)
                    {
                    }
                    else
                    {
                        if (GetPrereqs().Contains(ResearchSelectPanel.selected))
                        { // this is a direct child for selected, can remove child
                            options.Add(new FloatMenuOption("Remove Child from " + ResearchSelectPanel.selected.Label, () => ResearchProjectEditor.RemoveChild(node: ResearchSelectPanel.selected, child: this), MenuOptionPriority.Default, null));
                        }
                        else if (!AllChildren.Contains(ResearchSelectPanel.selected)) // this is not a prereq for selected or a direct child, can add child
                        {
                            options.Add(new FloatMenuOption("Add Child to " + ResearchSelectPanel.selected.Label, () => ResearchProjectEditor.AddChild(node: ResearchSelectPanel.selected, child: this), MenuOptionPriority.Default, null));
                        }
                        else // this is a prereq, can't add child
                        {
                            options.Add(new FloatMenuOption("(Can't add child, would create cycle)", null, MenuOptionPriority.Default, null));
                        }

                        if (Children.Contains(ResearchSelectPanel.selected)) // this is a direct prereq for selected, can remove prereq
                        {
                            options.Add(new FloatMenuOption("Remove Prerequisite from " + ResearchSelectPanel.selected.Label, () => ResearchProjectEditor.RemovePrereq(node: ResearchSelectPanel.selected, prereq: this), MenuOptionPriority.Default, null));
                        }
                        else if (!GetPrereqsRecursive().Contains(ResearchSelectPanel.selected)) // this is not a child for selected or a direct prereq, can add prereq
                        {
                            options.Add(new FloatMenuOption("Add Prerequisite to " + ResearchSelectPanel.selected.Label, () => ResearchProjectEditor.AddPrereq(node: ResearchSelectPanel.selected, prereq: this), MenuOptionPriority.Default, null));
                        }
                        else
                        {
                            options.Add(new FloatMenuOption("(Can't add prerequisite, would create cycle)", null, MenuOptionPriority.High, null));
                        }
                    }
                }
                options.Add(new FloatMenuOption("Delete Research Project", () => ResearchProjectEditor.Delete(this), MenuOptionPriority.Low, null));

                /*
                 * if (options.Count == 0) // can't do anything with this KEKWait
                 * {
                 *  options.Add(new FloatMenuOption("(No actions available)", null, MenuOptionPriority.Default, null));
                 * }
                 */
                options.Add(new FloatMenuOption("Set tech level...", () => ResearchProjectEditor.SetTechLevel(this), MenuOptionPriority.Low, null));
                options.Add(new FloatMenuOption("Set techprint count...", () => ResearchProjectEditor.SetTechprintCount(this), MenuOptionPriority.Low, null));
                Find.WindowStack.Add(new FloatMenu(options));
                //Event.current.Use();
            }
        }