Example #1
0
        public static void TakePriority(int priority, PriorityBox p, bool addition)
        {
            if (p.Priority == priority)
                return;
            // The new priority is larger than the privious
            if (p.Priority < priority)
            {
                foreach (PriorityBox pb in _priorityBoxes)
                {
                    if (pb == p)
                        continue;

                    if (pb.Priority > p.Priority && pb.Priority <= priority)
                        pb.ChangePriority(pb.Priority - 1);
                }
            }

            if (p.Priority > priority)
            {
                foreach (PriorityBox pb in _priorityBoxes)
                {
                    if (pb == p)
                        continue;

                    if (pb.Priority >= priority && pb.Priority < p.Priority)
                        pb.ChangePriority(pb.Priority + 1);
                }
            }

            if (priority >= _priorityBoxes.Count && addition == false)
                p.ChangePriority(_priorityBoxes.Count-1);
            else
                p.ChangePriority(priority);
        }
Example #2
0
        public static void AddPriorityBox(string name)
        {
            PriorityBox p = new PriorityBox(name);
            TakePriority(0, p, true);
            _priorityBoxes.Add(p);

            GuiSystem.AddGuiComponent(p);
        }