void cmd_cmbExtra_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox box = (ComboBox)sender;

            if (commandItems.SupressEvents)
            {
                return;
            }
            GuiRank rank = (GuiRank)box.SelectedItem;

            if (rank == null)
            {
                return;
            }

            int boxIdx             = Array.IndexOf <ComboBox>(commandExtraBoxes, box);
            CommandExtraPerms orig = extraPermsList[boxIdx];
            CommandExtraPerms copy = LookupExtraPerms(orig.CmdName, orig.Num);

            if (copy == null)
            {
                copy = orig.Copy();
                commandExtraPermsChanged.Add(copy);
            }
            copy.MinRank = rank.Permission;
        }
Ejemplo n.º 2
0
        public void OnSpecificChanged(ComboBox box)
        {
            GuiRank rank = (GuiRank)box.SelectedItem;

            if (rank == null || SupressEvents)
            {
                return;
            }
            ItemPerms curPerms = GetCurPerms();

            List <LevelPermission> perms;

            ComboBox[] boxes;
            int        boxIdx = Array.IndexOf <ComboBox>(AllowBoxes, box);

            if (boxIdx == -1)
            {
                if (curPerms.Disallowed == null)
                {
                    curPerms.Disallowed = new List <LevelPermission>();
                }

                perms  = curPerms.Disallowed;
                boxes  = DisallowBoxes;
                boxIdx = Array.IndexOf <ComboBox>(DisallowBoxes, box);
            }
            else
            {
                if (curPerms.Allowed == null)
                {
                    curPerms.Allowed = new List <LevelPermission>();
                }

                perms = curPerms.Allowed;
                boxes = AllowBoxes;
            }

            if (rank.Permission == LevelPermission.Null)
            {
                if (boxIdx >= perms.Count)
                {
                    return;
                }
                perms.RemoveAt(boxIdx);

                SupressEvents = true;
                SetSpecificPerms(perms, boxes);
                SupressEvents = false;
            }
            else
            {
                SetSpecific(boxes, boxIdx, perms, rank);
            }
        }
Ejemplo n.º 3
0
        public void OnMinRankChanged(ComboBox box)
        {
            GuiRank rank = (GuiRank)box.SelectedItem;

            if (rank == null || SupressEvents)
            {
                return;
            }
            ItemPerms curPerms = GetCurPerms();

            curPerms.MinRank = rank.Permission;
        }
Ejemplo n.º 4
0
        internal static void SetSelectedRank(ComboBox box, LevelPermission perm)
        {
            List <GuiRank> ranks = (List <GuiRank>)box.DataSource;
            GuiRank        rank  = ranks.Find(r => r.Permission == perm);

            if (rank == null)
            {
                box.SelectedIndex = 1;
            }
            else
            {
                box.SelectedItem = rank;
            }
        }
Ejemplo n.º 5
0
        internal static LevelPermission GetSelectedRank(ComboBox box, LevelPermission defPerm)
        {
            GuiRank rank = (GuiRank)box.SelectedItem;

            return(rank == null ? defPerm : rank.Permission);
        }
Ejemplo n.º 6
0
        static void SetSpecific(ComboBox[] boxes, int boxIdx, List <LevelPermission> perms, GuiRank rank)
        {
            if (boxIdx < perms.Count)
            {
                perms[boxIdx] = rank.Permission;
            }
            else
            {
                perms.Add(rank.Permission);
            }

            // Activate next box
            if (boxIdx < boxes.Length - 1 && !boxes[boxIdx + 1].Visible)
            {
                SetAddRank(boxes[boxIdx + 1]);
            }
        }