/// <summary> /// Updates job preferences and ensures there is only one 'High' priority job at a time. /// </summary> /// <param name="job">The job</param> /// <param name="priority">The priority</param> /// <param name="entry">Entry reference to change dropdown boxes</param> public void OnPriorityChange(JobType job, Priority priority, JobListEntry entry) { Logger.Log($"Changed priority for {job} to {priority}.", Category.Jobs); if (priority == Priority.None) { // Only include jobs with a priority jobPreferences.Remove(job); } else { if (priority == Priority.High) { if (highEntry != null) { // Downgrade the previous High priority job to Medium highEntry.SetPriority(Priority.Medium); } highEntry = entry; } // Update job prefs with new priority if (!jobPreferences.ContainsKey(job)) { jobPreferences.Add(job, priority); } else { jobPreferences[job] = priority; } } Logger.Log("Current Job Preferences:\n" + string.Join("\n", jobPreferences.Select(a => $"{a.Key}: {a.Value}")), Category.Jobs); }
/// <summary> /// Resets all job priorities to 'None' /// </summary> public void ResetAllPriorities() { SetAllPriorities(Priority.None); highEntry = null; }