public static void AddPriorityBox(string name, GlobalJobType type) { PriorityBox p = new PriorityBox(name, type, OnPriorityChanged); TakePriority(0, p, true); _priorityBoxes.Add(p); _priorityBoxesDic.Add(name, p); GuiSystem.AddGuiComponent(p); }
private static void UpdatePriorityList(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); }
public static void TakePriority(int priority, PriorityBox p, bool addition) { UpdatePriorityList(priority, p, addition); }