From 40dfe8c0b146bc5ee8fa561eb87c9d7d3e05742d Mon Sep 17 00:00:00 2001 From: Sheepit Renderfarm Date: Sat, 29 May 2021 15:14:00 +0000 Subject: [PATCH] Fix: reverse order of priority to be more user friendly --- .../standalone/swing/SwingTooltips.java | 2 +- .../standalone/swing/activity/Settings.java | 32 ++++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/com/sheepit/client/standalone/swing/SwingTooltips.java b/src/com/sheepit/client/standalone/swing/SwingTooltips.java index 3909d20..8f7a3d5 100644 --- a/src/com/sheepit/client/standalone/swing/SwingTooltips.java +++ b/src/com/sheepit/client/standalone/swing/SwingTooltips.java @@ -16,7 +16,7 @@ public enum SwingTooltips { MEMORY("How much RAM Sheepit may use. This isn't a 100% safe limit, since Blender can erroneously use more, \n" + "but Sheepit will try its best to give you jobs that require less than what you've entered here."), - PRIORITY("Which priority in your system the rendering process should have. Note that minus 19 is the highest, 19 is the lowest."), + PRIORITY("Which priority in your system the rendering process should have."), MINIMIZE_TO_SYSTRAY("Whether Sheepit should vanish into your system tray (the icons next to the clock in the bottom right) when you minimize the window."), diff --git a/src/com/sheepit/client/standalone/swing/activity/Settings.java b/src/com/sheepit/client/standalone/swing/activity/Settings.java index 6f8435f..87222f8 100644 --- a/src/com/sheepit/client/standalone/swing/activity/Settings.java +++ b/src/com/sheepit/client/standalone/swing/activity/Settings.java @@ -428,14 +428,26 @@ public class Settings implements Activity { parent.getContentPane().add(compute_devices_panel, constraints); // priority + // ui display low -> high but the actual values are reversed + // -19 is highest priority boolean high_priority_support = os.getSupportHighPriority(); priority = new JSlider(high_priority_support ? -19 : 0, 19); - priority.setMajorTickSpacing(19); + Hashtable labelTablePriority = new Hashtable<>(); + labelTablePriority.put(high_priority_support ? -19 : 0, new JLabel("Low")); + labelTablePriority.put(19, new JLabel("High")); + priority.setLabelTable(labelTablePriority); + priority.setMinorTickSpacing(1); priority.setPaintTicks(true); priority.setPaintLabels(true); - priority.setValue(config.getPriority()); - JLabel priorityLabel = new JLabel(high_priority_support ? "Priority (High <-> Low):" : "Priority (Normal <-> Low):"); + if (high_priority_support) { + // inverse + priority.setValue(-1 * config.getPriority()); + } + else { + priority.setValue(19 - config.getPriority()); + } + JLabel priorityLabel = new JLabel("Priority"); priorityLabel.setToolTipText(SwingTooltips.PRIORITY.getText()); boolean showPrioritySlider = os.checkNiceAvailability(); @@ -770,7 +782,17 @@ public class Settings implements Activity { config.setMaxRenderTime(max_rendertime); } - config.setUsePriority(priority.getValue()); + // ui display low -> high but the actual values are reversed + // -19 is highest priority + OS os = OS.getOS(); + boolean high_priority_support = os.getSupportHighPriority(); + if (high_priority_support) { + // inverse + config.setUsePriority(-1 * priority.getValue()); + } + else { + config.setUsePriority(19 - priority.getValue()); + } String proxyText = null; if (proxy != null) { @@ -801,7 +823,7 @@ public class Settings implements Activity { parent.setSettingsLoader( new SettingsLoader(config.getConfigFilePath(), login.getText(), new String(password.getPassword()), proxyText, hostnameText, method, selected_gpu, renderbucket_size, cpu_cores, max_ram, max_rendertime, cachePath, autoSignIn.isSelected(), useSysTray.isSelected(), - GuiSwing.type, themeOptionsGroup.getSelection().getActionCommand(), priority.getValue())); + GuiSwing.type, themeOptionsGroup.getSelection().getActionCommand(), config.getPriority())); // wait for successful authentication (to store the public key) // or do we already have one?