示例#1
0
        // Token: 0x06000008 RID: 8 RVA: 0x00002164 File Offset: 0x00000364
        public static FloatMenuOption MakeMenuItemForLabel([NotNull] string label, [NotNull] List <FloatMenuOption> fmo)
        {
            List <FloatMenuOption> options = fmo.ToList <FloatMenuOption>();
            bool isSingle = options.Count == 1 && !label.Contains(" ►");
            FloatMenuOptionNoClose floatMenuOptionNoClose = new FloatMenuOptionNoClose(label, delegate()
            {
                if (isSingle && !options[0].Disabled)
                {
                    Action action = options[0].action;
                    if (action != null)
                    {
                        Tools.CloseLabelMenu(true);
                        action();
                        return;
                    }
                }
                else
                {
                    int i = 0;
                    List <FloatMenuOption> actions = new List <FloatMenuOption>();
                    CollectionExtensions.Do <FloatMenuOption>(fmo, delegate(FloatMenuOption menuOption)
                    {
                        string label2  = menuOption.Label;
                        Action action2 = delegate()
                        {
                            //FloatMenuOption menuOption = menuOption;
                            Tools.actionMenu.Close(true);
                            Tools.CloseLabelMenu(true);
                            menuOption.action();
                        };
                        //int i = i;
                        i++;
                        FloatMenuOption item = new FloatMenuOption(label2, action2, (MenuOptionPriority)i, menuOption.mouseoverGuiAction, menuOption.revalidateClickTarget, menuOption.extraPartWidth, menuOption.extraPartOnGUI, null);
                        actions.Add(item);
                    });
                    Tools.actionMenu = new FloatMenuNested(actions, null);
                    Find.WindowStack.Add(Tools.actionMenu);
                }
            }, isSingle ? options[0].extraPartWidth : 0f, isSingle ? options[0].extraPartOnGUI : null);

            floatMenuOptionNoClose.Disabled = options.All((FloatMenuOption o) => o.Disabled);
            return(floatMenuOptionNoClose);
        }
示例#2
0
        public static FloatMenuOption MakeMenuItemForLabel([NotNull] string label, [NotNull] List <FloatMenuOption> fmo)
        {
            // List<SortByWhat> sortByWhats = fmo.Keys.ToList();
            List <FloatMenuOption> options = fmo.ToList();
            string labelFixed = label;
            bool   isSingle   = options.Count == 1 && !labelFixed.Contains(NestedString);



            FloatMenuOptionNoClose option = new FloatMenuOptionNoClose(
                labelFixed,
                () =>
            {
                if (isSingle && options[0].Disabled == false)
                {
                    Action action = options[0].action;
                    if (action == null)
                    {
                        return;
                    }

                    CloseLabelMenu(true);
                    action();
                }
                else
                {
                    int i = 0;
                    List <FloatMenuOption> actions =
                        new List <FloatMenuOption>();
                    fmo.Do(
                        menuOption =>
                    {
                        FloatMenuOption
                        floatMenuOption =
                            new FloatMenuOption(
                                menuOption
                                .Label,
                                () =>
                        {
                            FloatMenuOption
                            pawnOption
                                =
                                    menuOption;
                            actionMenu
                            .Close();
                            CloseLabelMenu(true);
                            pawnOption
                            .action();
                        },
                                (MenuOptionPriority
                                )i++,
                                menuOption
                                .mouseoverGuiAction,
                                menuOption
                                .revalidateClickTarget,
                                menuOption
                                .extraPartWidth,
                                menuOption
                                .extraPartOnGUI);
                        actions.Add(floatMenuOption);
                    });
                    actionMenu =
                        new FloatMenuNested(actions, null);
                    Find.WindowStack.Add(actionMenu);
                }
            },
                isSingle ? options[0].extraPartWidth : 0f,
                isSingle ? options[0].extraPartOnGUI : null)
            {
                Disabled = options.All(o => o.Disabled),
            };

            return(option);
        }