示例#1
0
        static MenuState ShowPermissionLimits()
        {
            Refresh("Rank List > Rank {0} ({1} of {2}) > Permission Limits",
                    currentRank.Name, currentRank.Index + 1, RankManager.Ranks.Count);

            TextMenu menu = new TextMenu();
            int      i    = 1;

            Permission[] limits = LimitedPermissions.Where(perm => currentRank.Can(perm)).ToArray();

            int maxPermLength = limits.Max(perm => perm.ToString().Length);

            foreach (Permission perm in limits)
            {
                string text;
                string permName = perm.ToString().PadLeft(maxPermLength, '.');
                if (currentRank.HasLimitSet(perm))
                {
                    Rank limit = currentRank.GetLimit(perm);
                    text = String.Format("{0} - {1}", permName, limit.Name);
                }
                else
                {
                    text = String.Format("{0} - (own rank)", permName);
                }
                menu.AddOption(i, text, perm);
                i++;
            }
            menu.Column = Column.Right;
            TextOption optionBack  = menu.AddOption("B", "Back to rank " + currentRank.Name);
            TextOption optionReset = menu.AddOption("R", "Reset limits.");

            menu.AddSpacer();
            TextOption optionNextUp = null, optionNextDown = null;

            if (currentRank.NextRankUp != null)
            {
                optionNextUp = menu.AddOption("U", "Go to next rank up", currentRank.NextRankUp);
            }
            if (currentRank.NextRankDown != null)
            {
                optionNextDown = menu.AddOption("D", "Go to next rank down", currentRank.NextRankDown);
            }

            TextOption choice = menu.Show();

            if (choice == optionBack)
            {
                return(MenuState.RankDetails);
            }
            else if (choice == optionReset)
            {
                if (TextMenu.ShowYesNo("Reset all permission limits for rank {0} to \"own rank\"?",
                                       currentRank.Name))
                {
                    foreach (Permission perm in LimitedPermissions)
                    {
                        currentRank.ResetLimit(perm);
                    }
                }
            }
            else if (choice == optionNextDown || choice == optionNextUp)
            {
                currentRank = (Rank)choice.Tag;
            }
            else
            {
                currentPermission = (Permission)choice.Tag;
                return(MenuState.PermissionLimitDetails);
            }
            return(MenuState.PermissionLimits);
        }
示例#2
0
        static MenuState ShowRankDetails()
        {
            Refresh("Rank List > Rank {0} ({1} of {2})",
                    currentRank.Name, currentRank.Index + 1, RankManager.Ranks.Count);

            TextMenu menu = new TextMenu();

            TextOption optionName = menu.AddOption(1, "Name: \"" + currentRank.Name + "\"");

            TextOption optionColor = menu.AddOption(2, "Color: " + Color.GetName(currentRank.Color));

            optionColor.ForeColor = Color.ToConsoleColor(currentRank.Color);

            TextOption optionPrefix = menu.AddOption(3, "Prefix: \"" + currentRank.Prefix + "\"");

            TextOption optionHasReservedSlot = menu.AddOption(4, "HasReservedSlot: " + currentRank.HasReservedSlot);

            TextOption optionAllowSecurityCircumvention = menu.AddOption(5,
                                                                         "AllowSecurityCircumvention: " +
                                                                         currentRank.AllowSecurityCircumvention);

            TextOption optionIdleKickTimer = menu.AddOption(6, "IdleKickTimer: " + currentRank.IdleKickTimer);

            TextOption optionDrawLimit        = menu.AddOption(7, "DrawLimit: " + currentRank.DrawLimit);
            TextOption optionFillLimit        = menu.AddOption(8, "FillLimit: " + currentRank.FillLimit);
            TextOption optionCopySlots        = menu.AddOption(9, "CopySlots: " + currentRank.CopySlots);
            TextOption optionAntiGriefBlocks  = menu.AddOption(10, "AntiGriefBlocks: " + currentRank.AntiGriefBlocks);
            TextOption optionAntiGriefSeconds = menu.AddOption(11, "AntiGriefSeconds: " + currentRank.AntiGriefSeconds);

            menu.Column = Column.Right;

            TextOption optionBack = menu.AddOption("B", "Back to rank list");

            menu.AddSpacer();
            TextOption optionPermissions      = menu.AddOption("P", "Permissions");
            TextOption optionPermissionLimits = null;

            if (LimitedPermissions.Any(perm => currentRank.Can(perm)))
            {
                optionPermissionLimits = menu.AddOption("L", "Permission limits");
            }

            menu.AddSpacer();
            TextOption optionNextUp = null, optionNextDown = null;

            if (currentRank.NextRankUp != null)
            {
                optionNextUp = menu.AddOption("U", "Go to next rank up", currentRank.NextRankUp);
            }
            if (currentRank.NextRankDown != null)
            {
                optionNextDown = menu.AddOption("D", "Go to next rank down", currentRank.NextRankDown);
            }

            TextOption choice = menu.Show();

            if (choice == optionBack)
            {
                return(MenuState.Ranks);
            }
            else if (choice == optionPermissions)
            {
                return(MenuState.Permissions);
            }
            else if (choice == optionPermissionLimits)
            {
                return(MenuState.PermissionLimits);
            }
            else if (choice == optionNextDown || choice == optionNextUp)
            {
                currentRank = (Rank)choice.Tag;
            }

            return(MenuState.RankDetails);
        }