Skip to content

Commit

Permalink
Allow initializing ParticleParameters with a single value that will t…
Browse files Browse the repository at this point in the history
…hen be assigned as both min and max value.

Fix SpritesheetImportPanel size so that the content is no longer cropped out.
Fixed the spritesheet preview for non whole-numbered scaling ratios.
  • Loading branch information
nightm4re94 committed Sep 7, 2020
1 parent 963a0ab commit 1296cfa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public class ParticleParameter implements Serializable {
public ParticleParameter() {
}

public ParticleParameter(final float value) {
this.setMinValue(value);
this.setMaxValue(value);
}

public ParticleParameter(final float minValue, final float maxValue) {
this.setMinValue(minValue);
this.setMaxValue(maxValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public SpritesheetImportPanel(SpritesheetResource... infos) {
public SpritesheetImportPanel() {
this.controller = new AnimationController();
fileListModel = new DefaultListModel<>();
setPreferredSize(new Dimension(454, 392));
setLayout(new BorderLayout(0, 0));
setPreferredSize(new Dimension(500, 400));
setLayout(new BorderLayout(10, 10));

fileList = new JList<>();
fileList.setCellRenderer(new DefaultListCellRenderer() {
Expand Down Expand Up @@ -323,11 +323,11 @@ private void updatePreview(SpriteFileWrapper file) {
this.labelImage.setIcon(file.getIcon());
this.controller.getAll().clear();

int factor = PREVIEW_SIZE / Math.max(file.getSpriteWidth(), file.getSpriteHeight());
double factor = (double) PREVIEW_SIZE / Math.max(file.getSpriteWidth(), file.getSpriteHeight());

BufferedImage img = Imaging.scale(file.getImage(), factor, true);

Spritesheet sprite = new Spritesheet(img, file.getName() + "-preview", file.getSpriteWidth() * factor, file.getSpriteHeight() * factor);
Spritesheet sprite = new Spritesheet(img, file.getName() + "-preview", (int) (file.getSpriteWidth() * factor), (int) (file.getSpriteHeight() * factor));
Animation newAnim = new Animation(sprite, true, file.keyFrames);

this.controller.setDefault(newAnim);
Expand Down

0 comments on commit 1296cfa

Please sign in to comment.