diff --git a/build.gradle.kts b/build.gradle.kts
index 1bc2ffb..c1029c2 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,7 +4,7 @@ plugins {
}
group = "com.kagof"
-version = "1.4.1"
+version = "1.4.2"
repositories {
mavenCentral()
diff --git a/changenotes.html b/changenotes.html
index 79b11e9..003a729 100644
--- a/changenotes.html
+++ b/changenotes.html
@@ -1,5 +1,10 @@
- -
+
- 1.4.2
+
+ - Yet another fix for configuration state persistence
+
+
+ - 1.4.1
- Fixes issue with config state deserialization (thanks @TheFreezingChicken for the bug report)
diff --git a/src/main/java/com/kagof/intellij/plugins/pokeprogress/PokemonPicker.java b/src/main/java/com/kagof/intellij/plugins/pokeprogress/PokemonPicker.java
index aae3b29..27bf97b 100644
--- a/src/main/java/com/kagof/intellij/plugins/pokeprogress/PokemonPicker.java
+++ b/src/main/java/com/kagof/intellij/plugins/pokeprogress/PokemonPicker.java
@@ -27,7 +27,7 @@ public static Pokemon get() {
}
private static List getEnabledPokemonNumbers(final PokemonProgressState state) {
- return state.getPokemonNumbersEnabled().entrySet().stream().filter(Map.Entry::getValue).map(Map.Entry::getKey).collect(Collectors.toList());
+ return state.pokemonNumbersEnabled.entrySet().stream().filter(Map.Entry::getValue).map(Map.Entry::getKey).collect(Collectors.toList());
}
}
diff --git a/src/main/java/com/kagof/intellij/plugins/pokeprogress/PokemonProgressBarUi.java b/src/main/java/com/kagof/intellij/plugins/pokeprogress/PokemonProgressBarUi.java
index 5b9b79a..efc4bed 100644
--- a/src/main/java/com/kagof/intellij/plugins/pokeprogress/PokemonProgressBarUi.java
+++ b/src/main/java/com/kagof/intellij/plugins/pokeprogress/PokemonProgressBarUi.java
@@ -47,7 +47,7 @@ public class PokemonProgressBarUi extends BasicProgressBarUI {
private volatile float velocity = 0;
public PokemonProgressBarUi(final Pokemon pokemon) {
- this(pokemon, () -> PokemonProgressState.getInstance().getInitialVelocity(), () -> PokemonProgressState.getInstance().getAcceleration());
+ this(pokemon, () -> PokemonProgressState.getInstance().initialVelocity, () -> PokemonProgressState.getInstance().acceleration);
}
public PokemonProgressBarUi(final Pokemon pokemon, final Supplier initialVelocity, final Supplier acceleration) {
@@ -180,7 +180,7 @@ private void drawTypePaint(final int height, final int progress, final Graphics2
}
private void setToolTipText() {
- if (PokemonProgressState.getInstance().isAddToolTips() && StringUtil.isEmptyOrSpaces(progressBar.getToolTipText())) {
+ if (PokemonProgressState.getInstance().addToolTips && StringUtil.isEmptyOrSpaces(progressBar.getToolTipText())) {
progressBar.setToolTipText(pokemon.getNameWithNumber());
}
}
@@ -198,7 +198,7 @@ private void drawBorder(final RoundRectangle2D rectangle, final Graphics2D graph
}
private void drawPokemonIcon(final int amountFull, final Graphics2D graphics2D, final Shape clip) {
- if (!PokemonProgressState.getInstance().isDrawSprites()) {
+ if (!PokemonProgressState.getInstance().drawSprites) {
return;
}
final Shape previousClip = graphics2D.getClip();
diff --git a/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressConfigurable.java b/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressConfigurable.java
index 0004380..01f8825 100644
--- a/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressConfigurable.java
+++ b/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressConfigurable.java
@@ -24,21 +24,21 @@ public JComponent createComponent() {
@Override
public boolean isModified() {
final PokemonProgressState state = PokemonProgressState.getInstance();
- return component != null && (!state.getPokemonNumbersEnabled().equals(component.getEnabledNumberMap())
- || state.isDrawSprites() != component.getDrawSprites().isSelected()
- || state.isAddToolTips() != component.getAddToolTips().isSelected()
- || state.getInitialVelocity() != component.getInitialVelocity().getValue() / 100f
- || state.getAcceleration() != component.getAcceleration().getValue() / 100f);
+ return component != null && (!state.pokemonNumbersEnabled.equals(component.getEnabledNumberMap())
+ || state.drawSprites != component.getDrawSprites().isSelected()
+ || state.addToolTips != component.getAddToolTips().isSelected()
+ || state.initialVelocity != component.getInitialVelocity().getValue() / 100f
+ || state.acceleration != component.getAcceleration().getValue() / 100f);
}
@Override
public void apply() {
final PokemonProgressState state = PokemonProgressState.getInstance();
- state.setPokemonNumbersEnabled(component.getEnabledNumberMap());
- state.setDrawSprites(component.getDrawSprites().isSelected());
- state.setAddToolTips(component.getAddToolTips().isSelected());
- state.setInitialVelocity(component.getInitialVelocity().getValue() / 100f);
- state.setAcceleration(component.getAcceleration().getValue() / 100f);
+ state.pokemonNumbersEnabled = component.getEnabledNumberMap();
+ state.drawSprites = component.getDrawSprites().isSelected();
+ state.addToolTips = component.getAddToolTips().isSelected();
+ state.initialVelocity = component.getInitialVelocity().getValue() / 100f;
+ state.acceleration = component.getAcceleration().getValue() / 100f;
}
@Override
diff --git a/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressConfigurationComponent.java b/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressConfigurationComponent.java
index ee39504..d67c658 100644
--- a/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressConfigurationComponent.java
+++ b/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressConfigurationComponent.java
@@ -99,11 +99,11 @@ void createUi() {
void updateUi(final PokemonProgressState state) {
if (state != null) {
- initialVelocity.setValue((int) (state.getInitialVelocity() * 100));
- acceleration.setValue((int) (state.getAcceleration() * 100));
- drawSprites.setSelected(state.isDrawSprites());
- addToolTips.setSelected(state.isAddToolTips());
- state.getPokemonNumbersEnabled()
+ initialVelocity.setValue((int) (state.initialVelocity * 100));
+ acceleration.setValue((int) (state.acceleration * 100));
+ drawSprites.setSelected(state.drawSprites);
+ addToolTips.setSelected(state.addToolTips);
+ state.pokemonNumbersEnabled
.forEach((pokemon, enabled) -> checkboxes.computeIfPresent(pokemon, (p, check) -> {
check.setSelected(enabled);
return check;
diff --git a/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressState.java b/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressState.java
index fd07b5d..9bcbef3 100644
--- a/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressState.java
+++ b/src/main/java/com/kagof/intellij/plugins/pokeprogress/configuration/PokemonProgressState.java
@@ -1,6 +1,5 @@
package com.kagof.intellij.plugins.pokeprogress.configuration;
-import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -19,12 +18,12 @@
storages = {@Storage("PokemonProgress.xml")}
)
public class PokemonProgressState implements PersistentStateComponent {
- private float initialVelocity = 1.0f;
- private float acceleration = 0.4f;
- private Map pokemonNumbersEnabled = Pokemon.DEFAULT_POKEMON.keySet().stream()
+ public float initialVelocity = 1.0f;
+ public float acceleration = 0.4f;
+ public Map pokemonNumbersEnabled = Pokemon.DEFAULT_POKEMON.keySet().stream()
.collect(Collectors.toMap(Function.identity(), p -> true));
- private boolean drawSprites = true;
- private boolean addToolTips = true;
+ public boolean drawSprites = true;
+ public boolean addToolTips = true;
public static PokemonProgressState getInstance() {
return ServiceManager.getService(PokemonProgressState.class);
@@ -38,45 +37,7 @@ public PokemonProgressState getState() {
@Override
public void loadState(@NotNull final PokemonProgressState state) {
XmlSerializerUtil.copyBean(state, this);
- }
-
- public float getInitialVelocity() {
- return initialVelocity;
- }
-
- public void setInitialVelocity(final float initialVelocity) {
- this.initialVelocity = initialVelocity;
- }
-
- public float getAcceleration() {
- return acceleration;
- }
-
- public void setAcceleration(final float acceleration) {
- this.acceleration = acceleration;
- }
-
- public Map getPokemonNumbersEnabled() {
- return new HashMap<>(pokemonNumbersEnabled);
- }
-
- public void setPokemonNumbersEnabled(final Map pokemonNumbersEnabled) {
- this.pokemonNumbersEnabled = pokemonNumbersEnabled;
- }
-
- public boolean isDrawSprites() {
- return drawSprites;
- }
-
- public void setDrawSprites(final boolean drawSprites) {
- this.drawSprites = drawSprites;
- }
-
- public boolean isAddToolTips() {
- return addToolTips;
- }
-
- public void setAddToolTips(final boolean addToolTips) {
- this.addToolTips = addToolTips;
+ System.out.print("loading state: ");
+ System.out.println(this);
}
}
diff --git a/src/test/java/com/kagof/intellij/plugins/pokeprogress/TestProgressBar.java b/src/test/java/com/kagof/intellij/plugins/pokeprogress/TestProgressBar.java
index 54c98cf..230112b 100644
--- a/src/test/java/com/kagof/intellij/plugins/pokeprogress/TestProgressBar.java
+++ b/src/test/java/com/kagof/intellij/plugins/pokeprogress/TestProgressBar.java
@@ -52,8 +52,8 @@ public TestProgressBar() {
private void setUpMockApplication() {
final PokemonProgressState state = new PokemonProgressState();
- state.setDrawSprites(true);
- state.setAddToolTips(false);
+ state.drawSprites = true;
+ state.addToolTips = false;
final Disposable parent = () -> { /*do nothing*/ };
final MockApplication application = MockApplication.setUp(parent);
application.registerService(PokemonProgressState.class, state);