From 981665bcd007edcc23b238ff7d2cb403523bc8a3 Mon Sep 17 00:00:00 2001 From: rkfg Date: Thu, 17 Mar 2016 15:07:43 +0300 Subject: [PATCH] Remove adjust parameter. --- .../generator/RatioAdjustingSliderPanel.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/deck/generator/RatioAdjustingSliderPanel.java b/Mage.Client/src/main/java/mage/client/deck/generator/RatioAdjustingSliderPanel.java index b1c07c9aca..d7401fd06d 100644 --- a/Mage.Client/src/main/java/mage/client/deck/generator/RatioAdjustingSliderPanel.java +++ b/Mage.Client/src/main/java/mage/client/deck/generator/RatioAdjustingSliderPanel.java @@ -55,12 +55,10 @@ public class RatioAdjustingSliderPanel extends JPanel { // Slider stores its initial value to revert to when reset private int defaultValue; - private boolean adjust; - public JStorageSlider(int min, int max, int value, boolean adjust) { + public JStorageSlider(int min, int max, int value) { super(min, max, value); defaultValue = value; - this.adjust = adjust; setMinorTickSpacing(5); setMajorTickSpacing(10); setPaintTicks(true); @@ -72,10 +70,6 @@ public class RatioAdjustingSliderPanel extends JPanel { this.setValue(defaultValue); } - public boolean isAdjust() { - return adjust; - } - } private class AdjustingSliderGroup { @@ -92,10 +86,8 @@ public class RatioAdjustingSliderPanel extends JPanel { fireSliderChangedEvent((JStorageSlider) e.getSource()); } }); - if (slider.isAdjust()) { - adjustableCount++; - } } + adjustableCount = storageSliders.size() - 1; } public void fireSliderChangedEvent(JStorageSlider source) { @@ -108,7 +100,7 @@ public class RatioAdjustingSliderPanel extends JPanel { private void updateSliderPosition(JStorageSlider source) { int maximum = MAXIMUM; - int excess = 100; + int excess = MAXIMUM; int sign = 0; for (JStorageSlider slider : storageSliders) { excess -= slider.getValue(); @@ -122,7 +114,7 @@ public class RatioAdjustingSliderPanel extends JPanel { for (int i = storageSliders.size() - 1; i >= 0; i--) { JStorageSlider slider = storageSliders.get(i); int value = slider.getValue(); - if (slider != source && slider.isAdjust()) { + if (slider != source && maximum < MAXIMUM) { slider.setMaximum(maximum); if (excess >= addition) { value += addition * sign; @@ -154,9 +146,9 @@ public class RatioAdjustingSliderPanel extends JPanel { private void initPanel() { // Create three sliders with default values - creatureSlider = new JStorageSlider(0, MAXIMUM, DeckGeneratorPool.DEFAULT_CREATURE_PERCENTAGE, true); - nonCreatureSlider = new JStorageSlider(0, MAXIMUM, DeckGeneratorPool.DEFAULT_NON_CREATURE_PERCENTAGE, true); - landSlider = new JStorageSlider(0, MAXIMUM, DeckGeneratorPool.DEFAULT_LAND_PERCENTAGE, false); + creatureSlider = new JStorageSlider(0, MAXIMUM, DeckGeneratorPool.DEFAULT_CREATURE_PERCENTAGE); + nonCreatureSlider = new JStorageSlider(0, MAXIMUM, DeckGeneratorPool.DEFAULT_NON_CREATURE_PERCENTAGE); + landSlider = new JStorageSlider(0, MAXIMUM, DeckGeneratorPool.DEFAULT_LAND_PERCENTAGE); sg = new AdjustingSliderGroup(creatureSlider, nonCreatureSlider, landSlider);