Skip to content

Commit

Permalink
Merge pull request #66 from kagof/release/1.7.0
Browse files Browse the repository at this point in the history
Release/1.7.0
  • Loading branch information
kagof authored Jan 29, 2022
2 parents 6e5b4fa + 21c6506 commit 4e15db3
Show file tree
Hide file tree
Showing 61 changed files with 368 additions and 112 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Set the plugin version env var
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand All @@ -35,9 +35,8 @@ jobs:
uses: ChrisCarini/[email protected]
with:
ide-versions: |
ideaIC:2019.3.5
ideaIC:2020.3
ideaIC:2021.2
ideaIC:2021.3.2
ideaIC:LATEST-EAP-SNAPSHOT
- name: Sync master branch verification results to gist
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Preferably you should be using [signed commits](https://help.github.com/en/artic
* Please also do your best to follow the existing code style. You may be asked to refactor your code if it does not match the existing style, in the interest of consistency.
* please branch off of [develop](https://github.com/kagof/intellij-pokemon-progress/tree/develop), and open pull requests to that branch as well, unless doing an "urgent" bugfix (to be decided by the maintainer), in which case PRs should be based off of [master](https://github.com/kagof/intellij-pokemon-progress/tree/master).
* if adding a new Pokémon:
* please maintain numerical ordering in the [Readme](README.md), [plugin.xml](src/main/resources/META-INF/plugin.xml), and [Pokemon.java](src/main/java/com/kagof/intellij/plugins/pokeprogress/Pokemon.java)
* please maintain numerical ordering in the [Readme](README.md), [plugin.xml](src/main/resources/META-INF/plugin.xml), and [Pokemon.java](src/main/java/com/kagof/intellij/plugins/pokeprogress/Pokemon.java). If regional variants are being used, they should be grouped with their generation, but maintain order within that generation.
* [editSprite.sh](editSprite.sh) can be used to generate the required gifs from existing png images
* [DocumentGenerator.java](src/test/java/com/kagof/intellij/plugins/pokeprogress/DocumentationGenerator.java) can be used to generate the new lines in [`README.md`](README.md), and update the [family photo](eg/family.gif) used in both the README and [`description.html`](./description.html). Simply run the `updateReadme()` and `updateFamilyPicture()` tests to do so.
* [TestProgressBar.java](src/test/java/com/kagof/intellij/plugins/pokeprogress/TestProgressBar.java)) is very useful when tweaking sprite positioning & sizing (Thanks to @Paola351 for the initial implementation of this!)
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

![All](eg/family.gif)

This is [a plugin](https://plugins.jetbrains.com/plugin/15090-pokemon-progress/versions) for [JetBrains IntelliJ IDEA](https://www.jetbrains.com/idea/) (And other compatible IDEs), which replaces your progress bars with a (random) Pokémon. The color of the progress bar fill is based on that Pokémon's type(s).
This is [a plugin](https://plugins.jetbrains.com/plugin/15090-pokemon-progress/versions) for [JetBrains IntelliJ IDEA](https://www.jetbrains.com/idea/) (And other compatible IDEs), which replaces your progress bars with a (random) Pokémon. The color of the progress bar fill is based on that Pokémon's type(s). Preferences are located under `Preferences > Appearance & Behaviour > Pokémon Progress`.

## Included Pokémon

Expand Down Expand Up @@ -130,6 +130,9 @@ This is [a plugin](https://plugins.jetbrains.com/plugin/15090-pokemon-progress/v

### Generation VIII

* ![Galarian Articuno (#144)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/galarian_articuno.gif) Galarian Articuno (#144) ![Galarian Articuno (#144)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/galarian_articuno_r.gif)
* ![Galarian Zapdos (#145)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/galarian_zapdos.gif) Galarian Zapdos (#145) ![Galarian Zapdos (#145)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/galarian_zapdos_r.gif)
* ![Galarian Moltres (#146)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/galarian_moltres.gif) Galarian Moltres (#146) ![Galarian Moltres (#146)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/galarian_moltres_r.gif)
* ![Grookey (#810)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/grookey.gif) Grookey (#810) ![Grookey (#810)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/grookey_r.gif)
* ![Rillaboom (#812)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/rillaboom.gif) Rillaboom (#812) ![Rillaboom (#812)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/rillaboom_r.gif)
* ![Scorbunny (#813)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/scorbunny.gif) Scorbunny (#813) ![Scorbunny (#813)](src/main/resources/com/kagof/intellij/plugins/pokeprogress/sprites/scorbunny_r.gif)
Expand Down
8 changes: 6 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "com.kagof"
version = "1.6.0"
version = "1.7.0"

repositories {
mavenCentral()
Expand All @@ -17,7 +17,11 @@ dependencies {

// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = "2020.1"
version = "2021.1"
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}

tasks.getByName<org.jetbrains.intellij.tasks.PublishTask>("publishPlugin") {
Expand Down
14 changes: 14 additions & 0 deletions changenotes.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<ul>
<li><b><a href="https://github.com/kagof/intellij-pokemon-progress/releases/tag/1.7.0">1.7.0</a></b>
<!--1.7.0-->
<ul>
<li>Updates minimum IDEA version to 2021.1, and now builds with Java 11 instead of 8</li>
<li>Adds select/deselect checkboxes for entire generations (thanks @chylex)</li>
<li>Adds new flat paint themes (thanks @chylex)</li>
<li>Adds a randomize button to the preview panel</li>
<li>Uses the new flat theme for the family photo</li>
<li>Changes the Pokémon models to work with regional variants</li>
<li>Fixes a bug where tooltips were saying the wrong Pokémon</li>
<li>new Gen VIII: Galarian Articuno, Galarian Zapdos, Galarian Moltres</li>
</ul>
<!--/1.7.0-->
</li>
<li><b><a href="https://github.com/kagof/intellij-pokemon-progress/releases/tag/1.6.0">1.6.0</a></b>
<!--1.6.0-->
<ul>
Expand Down
2 changes: 1 addition & 1 deletion description.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Replaces your IDE's progress bars with random Pok&eacute;mon. The chosen Pok&eacute;mon are configurable, though all are used by default. Pok&eacute;mon sprites may also be turned off to only use the type colours, for a more professional look.
Replaces your IDE's progress bars with random Pok&eacute;mon. The configuration lives under Preferences > Appearance & Behaviour > Pok&eacute;mon Progress. The chosen Pok&eacute;mon are configurable, though all are used by default. Different trail paint themes may be chosen. Pok&eacute;mon sprites may also be turned off to only use the type colours, for a more professional look.
<br>
<img src="https://raw.githubusercontent.com/kagof/intellij-pokemon-progress/master/eg/example.gif">
<br>
Expand Down
Binary file modified eg/family.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@
import java.util.stream.Collectors;

import com.kagof.intellij.plugins.pokeprogress.configuration.PokemonProgressState;
import com.kagof.intellij.plugins.pokeprogress.model.Pokemon;

public class PokemonPicker {
private static final Random RANDOM = new Random();

@SuppressWarnings("ConstantConditions")
public static Pokemon get() {
if (Pokemon.TARGET != null) {
return Pokemon.TARGET;
}

final List<String> enabledPokemonNumbers = Optional.ofNullable(PokemonProgressState.getInstance())
final List<String> enabledPokemonIds = Optional.ofNullable(PokemonProgressState.getInstance())
.map(PokemonPicker::getEnabledPokemonNumbers)
.orElse(null);
if (enabledPokemonNumbers == null || enabledPokemonNumbers.isEmpty()) {
if (enabledPokemonIds == null || enabledPokemonIds.isEmpty()) {
return Pokemon.MISSINGNO;
}
return Pokemon.getByNumber(enabledPokemonNumbers.get(RANDOM.nextInt(enabledPokemonNumbers.size())));
return Pokemon.getById(enabledPokemonIds.get(RANDOM.nextInt(enabledPokemonIds.size())));
}

private static List<String> getEnabledPokemonNumbers(final PokemonProgressState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.LinearGradientPaint;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.RoundRectangle2D;
import java.util.function.BooleanSupplier;
import java.util.function.Supplier;

import javax.swing.Icon;
Expand All @@ -23,23 +25,29 @@
import org.jetbrains.annotations.NotNull;

import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.JBColor;
import com.intellij.ui.scale.JBUIScale;
import com.intellij.util.ui.GraphicsUtil;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import com.kagof.intellij.plugins.pokeprogress.configuration.PokemonProgressState;
import com.kagof.intellij.plugins.pokeprogress.model.Pokemon;
import com.kagof.intellij.plugins.pokeprogress.paint.PaintTheme;
import com.kagof.intellij.plugins.pokeprogress.paint.PaintThemes;

public class PokemonProgressBarUi extends BasicProgressBarUI {
private static final String DEBUGGING_ENV_VAR = "POKEMON_PROGRESS_DEBUG";

private final Pokemon pokemon;
private final Icon iconForward;
private final Icon iconReversed;
private final Supplier<Float> initialVelocity;
private final Supplier<Float> acceleration;
private final Supplier<Boolean> transparencyOnIndeterminate;
private final Supplier<Boolean> transparencyOnDeterminate;
private final Supplier<Boolean> drawSprites;
private final Supplier<Boolean> addToolTips;
private final Supplier<PaintTheme> theme;
private final BooleanSupplier transparencyOnIndeterminate;
private final BooleanSupplier transparencyOnDeterminate;
private final BooleanSupplier drawSprites;
private final BooleanSupplier addToolTips;

private volatile int pos = 0;
private volatile float velocity = 0;
Expand All @@ -48,6 +56,7 @@ public PokemonProgressBarUi(final Pokemon pokemon) {
this(pokemon,
() -> PokemonProgressState.getInstance().initialVelocity,
() -> PokemonProgressState.getInstance().acceleration,
() -> PaintThemes.getByIdOrDefault(PokemonProgressState.getInstance().theme),
() -> PokemonProgressState.getInstance().transparencyOnIndeterminate,
() -> PokemonProgressState.getInstance().transparencyOnDeterminate,
() -> PokemonProgressState.getInstance().drawSprites,
Expand All @@ -57,16 +66,18 @@ public PokemonProgressBarUi(final Pokemon pokemon) {
public PokemonProgressBarUi(final Pokemon pokemon,
final Supplier<Float> initialVelocity,
final Supplier<Float> acceleration,
final Supplier<Boolean> transparencyOnIndeterminate,
final Supplier<Boolean> transparencyOnDeterminate,
final Supplier<Boolean> drawSprites,
final Supplier<Boolean> addToolTips) {
final Supplier<PaintTheme> theme,
final BooleanSupplier transparencyOnIndeterminate,
final BooleanSupplier transparencyOnDeterminate,
final BooleanSupplier drawSprites,
final BooleanSupplier addToolTips) {
super();
this.pokemon = pokemon;
iconForward = PokemonResourceLoader.getIcon(pokemon);
iconReversed = PokemonResourceLoader.getReversedIcon(pokemon);
this.initialVelocity = initialVelocity;
this.acceleration = acceleration;
this.theme = theme;
this.transparencyOnIndeterminate = transparencyOnIndeterminate;
this.transparencyOnDeterminate = transparencyOnDeterminate;
this.drawSprites = drawSprites;
Expand Down Expand Up @@ -132,7 +143,7 @@ private void paint(final Graphics g, final JComponent c, final boolean determina
}

final int amountFull;
if (Pokemon.DEBUGGING) {
if (System.getenv().containsKey(DEBUGGING_ENV_VAR)) {
amountFull = barRectWidth / 2;
} else {
amountFull = determinate ? getAmountFull(border, barRectWidth, barRectHeight) : pos;
Expand Down Expand Up @@ -185,14 +196,14 @@ private void drawTypePaint(final int width, final int height, final int progress
final Shape clip = graphics2D.getClip();
final boolean movingRight = velocity >= 0;

graphics2D.setPaint(Painter.getTypePaint(pokemon, height));
graphics2D.setPaint(theme.get().getPaint(pokemon.getTypes(), 0, height));
graphics2D.setClip(movingRight ? new Rectangle(progress, height)
: new Rectangle(progress, 0, progressBar.getWidth(), height));
graphics2D.fill(rectangle);

if ((progressBar.isIndeterminate() && transparencyOnIndeterminate.get())
|| (!progressBar.isIndeterminate() && transparencyOnDeterminate.get())) {
graphics2D.setPaint(Painter.getTransparencyPaint(progressBar.getBackground(), width, movingRight));
if ((progressBar.isIndeterminate() && transparencyOnIndeterminate.getAsBoolean())
|| (!progressBar.isIndeterminate() && transparencyOnDeterminate.getAsBoolean())) {
graphics2D.setPaint(getTransparencyPaint(progressBar.getBackground(), width, movingRight));
graphics2D.setClip(movingRight ? new Rectangle(progress, height)
: new Rectangle(progress, 0, progressBar.getWidth(), height));
graphics2D.fill(rectangle);
Expand All @@ -202,8 +213,15 @@ private void drawTypePaint(final int width, final int height, final int progress
graphics2D.setClip(clip);
}

private static Paint getTransparencyPaint(final Color backgroundColor, final int width, final boolean movingRight) {
final JBColor transparent = new JBColor(new Color(0, 0, 0, 0), new Color(0, 0, 0, 0));
return new LinearGradientPaint(0, JBUIScale.scale(2f), width, JBUIScale.scale(2f),
new float[] {0, 1}, new Color[] {movingRight ? backgroundColor : transparent,
movingRight ? transparent : backgroundColor});
}

private void setToolTipText() {
if (addToolTips.get() && StringUtil.isEmptyOrSpaces(progressBar.getToolTipText())) {
if (addToolTips.getAsBoolean()) {
progressBar.setToolTipText(pokemon.getNameWithNumber());
}
}
Expand All @@ -221,7 +239,7 @@ private void drawBorder(final RoundRectangle2D rectangle, final Graphics2D graph
}

private void drawPokemonIcon(final int amountFull, final Graphics2D graphics2D, final Shape clip) {
if (!drawSprites.get()) {
if (!drawSprites.getAsBoolean()) {
return;
}
final Shape previousClip = graphics2D.getClip();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.kagof.intellij.plugins.pokeprogress.model.Pokemon;

public final class PokemonResourceLoader {
private static final String SPRITE_RESOURCE_PATH = "com/kagof/intellij/plugins/pokeprogress/sprites/";
Expand All @@ -29,11 +30,11 @@ public static Icon getReversedIcon(final Pokemon pokemon) {
}

public static String getIconPath(final Pokemon pokemon) {
return SPRITE_RESOURCE_PATH + pokemon.getName() + ".gif";
return SPRITE_RESOURCE_PATH + pokemon.getName().replace(' ', '_') + ".gif";
}

public static String getReversedIconPath(final Pokemon pokemon) {
return SPRITE_RESOURCE_PATH + pokemon.getName() + "_r.gif";
return SPRITE_RESOURCE_PATH + pokemon.getName().replace(' ', '_') + "_r.gif";
}

private static Icon getIconInternal(final String resourceName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.kagof.intellij.plugins.pokeprogress.configuration;

import java.util.Objects;

import javax.swing.JComponent;

import org.jetbrains.annotations.Nls;
Expand All @@ -25,6 +27,7 @@ public JComponent createComponent() {
public boolean isModified() {
final PokemonProgressState state = PokemonProgressState.getInstance();
return component != null && (!state.pokemonNumbersEnabled.equals(component.getEnabledNumberMap())
|| !Objects.equals(state.theme, component.getTheme().getItemAt(component.getTheme().getSelectedIndex()).getId())
|| state.drawSprites != component.getDrawSprites().isSelected()
|| state.addToolTips != component.getAddToolTips().isSelected()
|| state.transparencyOnIndeterminate != component.getIndeterminateTransparency().isSelected()
Expand All @@ -37,6 +40,7 @@ public boolean isModified() {
public void apply() {
final PokemonProgressState state = PokemonProgressState.getInstance();
state.pokemonNumbersEnabled = component.getEnabledNumberMap();
state.theme = component.getTheme().getItemAt(component.getTheme().getSelectedIndex()).getId();
state.drawSprites = component.getDrawSprites().isSelected();
state.addToolTips = component.getAddToolTips().isSelected();
state.transparencyOnIndeterminate = component.getIndeterminateTransparency().isSelected();
Expand Down
Loading

0 comments on commit 4e15db3

Please sign in to comment.