special index's 0=blank, 1=hole, 2=hole, 3=moveable-block, 4=mine, 5=blowmine,
+ * 6=BIGmine, 7=blownmine2 8=blue-T-source, 9= blue-T-destination, 10=red-T-source, 11=
+ * red-T-destination, 12=yellow-T-source, 13= yellow-T-destination, 14=green-T-source,
+ * 15= green-T-destination, 16=fullbricks, 17=threequarterbricks, 18=halfbricks,
+ * 19=quarterbricks, 20=magnet-attract, 21=magnet-repel, 22=moveableblock?, 23=
+ * greenmoveableblock
+ */
+
+ // first check if we're combining 2 elements, then element+special.
+ return isNoSpecial == 1
+ ? this.combineElementAndElement(shapeIndex, foregroundElementIndex, backgroundElementIndex)
+ : (isNoSpecial == 2 ? this.combineElementAndSpecial(shapeIndex, foregroundElementIndex) : null);
+ }
}
private int[] combineElementAndElement(int shapeMaskIndex, int firstElementIndex, int secondElementIndex) {
- int[][] shapeMask = this.getShapePixelMask(shapeMaskIndex);
- int[] foregroundElement = getPixels(this.elements[firstElementIndex], 15, 15);
- int[] backgroundElement = getPixels(this.elements[secondElementIndex], 15, 15);
- return this.combineShapeAndTwoElements(shapeMask, foregroundElement, backgroundElement);
+ int[][] shapeMask = this.getShapePixelMask(shapeMaskIndex);
+ int[] foregroundElement = getPixels(this.elements[firstElementIndex], 15, 15);
+ int[] backgroundElement = getPixels(this.elements[secondElementIndex], 15, 15);
+ return this.combineShapeAndTwoElements(shapeMask, foregroundElement, backgroundElement);
}
private int[] combineElementAndSpecial(int specialIndex, int backgroundIndex) {
- int[][] specialMask = this.getSpecialPixels(specialIndex);
- int[] backgroundElement = getPixels(this.elements[backgroundIndex], 15, 15);
- int[] specialPixels = getPixels(this.specials[specialIndex], 15, 15);
- return this.combineShapeAndTwoElements(specialMask, backgroundElement, specialPixels);
+ int[][] specialMask = this.getSpecialPixels(specialIndex);
+ int[] backgroundElement = getPixels(this.elements[backgroundIndex], 15, 15);
+ int[] specialPixels = getPixels(this.specials[specialIndex], 15, 15);
+ return this.combineShapeAndTwoElements(specialMask, backgroundElement, specialPixels);
}
/**
* Creates a pixel mask, 1=white, 2=black as shown
+ *
* @param pixelMaskIndex Index of the Shape
* @return 2d array of 1's and 2's representing the pixel mask
*/
- private int[][] getShapePixelMask(int pixelMaskIndex) {
- if(this.pixelshapeMasks[pixelMaskIndex] == null) {
- int[] var2 = getPixels(this.shapes[pixelMaskIndex], 15, 15);
- this.pixelshapeMasks[pixelMaskIndex] = this.createShapeMask(var2);
- }
+ private int[][] getShapePixelMask(int pixelMaskIndex) {
+ if (this.pixelshapeMasks[pixelMaskIndex] == null) {
+ int[] var2 = getPixels(this.shapes[pixelMaskIndex], 15, 15);
+ this.pixelshapeMasks[pixelMaskIndex] = this.createShapeMask(var2);
+ }
- return this.pixelshapeMasks[pixelMaskIndex];
- }
+ return this.pixelshapeMasks[pixelMaskIndex];
+ }
private int[][] getSpecialPixels(int specialIndex) {
- if(this.specialPixelMasks[specialIndex] == null) {
- int[] specialPixels = getPixels(this.specials[specialIndex], 15, 15);
- this.specialPixelMasks[specialIndex] = this.createShapeMask(specialPixels);
- }
+ if (this.specialPixelMasks[specialIndex] == null) {
+ int[] specialPixels = getPixels(this.specials[specialIndex], 15, 15);
+ this.specialPixelMasks[specialIndex] = this.createShapeMask(specialPixels);
+ }
- return this.specialPixelMasks[specialIndex];
+ return this.specialPixelMasks[specialIndex];
}
private int[][] createShapeMask(int[] var1) {
- int[][] result = new int[15][15];
+ int[][] result = new int[15][15];
- for(int y = 0; y < 15; ++y) {
- for(int x = 0; x < 15; ++x) {
- int currentPixel = var1[y * 15 + x] & 16777215;
- result[x][y] = currentPixel == 13421823?1:2;
- }
- }
+ for (int y = 0; y < 15; ++y) {
+ for (int x = 0; x < 15; ++x) {
+ int currentPixel = var1[y * 15 + x] & 16777215;
+ result[x][y] = currentPixel == 13421823 ? 1 : 2;
+ }
+ }
- return result;
+ return result;
}
private int[] combineShapeAndTwoElements(int[][] var1, int[] var2, int[] var3) {
- int[] var4 = new int[225];
+ int[] var4 = new int[225];
- for(int var5 = 0; var5 < 15; ++var5) {
- for(int var6 = 0; var6 < 15; ++var6) {
- int var7 = 16777215;
- if(var1[var6][var5] == 1) {
- var7 = var2[var5 * 15 + var6];
- }
+ for (int var5 = 0; var5 < 15; ++var5) {
+ for (int var6 = 0; var6 < 15; ++var6) {
+ int var7 = 16777215;
+ if (var1[var6][var5] == 1) {
+ var7 = var2[var5 * 15 + var6];
+ }
- if(var1[var6][var5] == 2) {
- var7 = var3[var5 * 15 + var6];
- }
+ if (var1[var6][var5] == 2) {
+ var7 = var3[var5 * 15 + var6];
+ }
- var4[var5 * 15 + var6] = var7;
- }
- }
+ var4[var5 * 15 + var6] = var7;
+ }
+ }
- return var4;
+ return var4;
}
-
public int getWidth(Image var1) {
return var1.getWidth(frame);
}
@@ -166,7 +166,7 @@ public Image getImage(String var1) {
try {
result = ImageIO.read(getClass().getResourceAsStream("/" + var1 + ".gif"));
} catch (Exception e) {
- e.printStackTrace();
+ e.printStackTrace();
}
return result;
}
@@ -191,8 +191,8 @@ public Image createImage(int[] imageData, int width, int heigh, Component var4)
return var5;
}
-
- private Image[] parseSpriteSheet(String spriteSheetName, int spriteCount, int spritesPerRow, int spriteWidth, int spriteHeight) {
+ private Image[] parseSpriteSheet(
+ String spriteSheetName, int spriteCount, int spritesPerRow, int spriteWidth, int spriteHeight) {
Image spriteSheet = getImage(spriteSheetName);
int sheetWidth = getWidth(spriteSheet);
int sheetHeight = getHeight(spriteSheet);
@@ -208,7 +208,12 @@ private Image[] parseSpriteSheet(String spriteSheetName, int spriteCount, int sp
for (int var15 = 0; var15 < spriteHeight; ++var15) {
for (int var16 = 0; var16 < spriteWidth; ++var16) {
- var14[var15 * spriteWidth + var16] = var9[(var12 * spriteHeight + var12 + 1 + var15) * sheetWidth + var13 * spriteWidth + var13 + 1 + var16];
+ var14[var15 * spriteWidth + var16] = var9[
+ (var12 * spriteHeight + var12 + 1 + var15) * sheetWidth
+ + var13 * spriteWidth
+ + var13
+ + 1
+ + var16];
}
}
diff --git a/editor/src/main/java/org/moparforia/editor/Tile.java b/editor/src/main/java/org/moparforia/editor/Tile.java
index e173f027..c6f0c44a 100644
--- a/editor/src/main/java/org/moparforia/editor/Tile.java
+++ b/editor/src/main/java/org/moparforia/editor/Tile.java
@@ -2,21 +2,17 @@
public class Tile {
- /**
- * Sprite index of the shape mask.
- */
+ /** Sprite index of the shape mask. */
private int shapeIndex;
- /**
- * Sprite index of the foreground Element tile.
- */
+
+ /** Sprite index of the foreground Element tile. */
private int backgroundElementIndex;
- /**
- * Sprite index of the background Element tile (only used when two are layered I THINK)...
- */
+
+ /** Sprite index of the background Element tile (only used when two are layered I THINK)... */
private int foregroundElementIndex;
+
/**
- * Code for whether we're drawing a special sprite or just two elements together.
- * 1=normal
+ * Code for whether we're drawing a special sprite or just two elements together. 1=normal
* 2=special.
*/
private int isSpecial;
@@ -57,17 +53,18 @@ public boolean isStartPosition() {
}
public boolean isHole() {
- return isSpecial() && shapeIndex == 1 ;
+ return isSpecial() && shapeIndex == 1;
}
public boolean isPassable() {
- return !(!isSpecial() && (backgroundElementIndex == 12 ||
- backgroundElementIndex ==13 ||
- (backgroundElementIndex >=16 && backgroundElementIndex <=18) ));
+ return !(!isSpecial()
+ && (backgroundElementIndex == 12
+ || backgroundElementIndex == 13
+ || (backgroundElementIndex >= 16 && backgroundElementIndex <= 18)));
}
public Tile clone() {
- return new Tile(shapeIndex,backgroundElementIndex,foregroundElementIndex,isSpecial);
+ return new Tile(shapeIndex, backgroundElementIndex, foregroundElementIndex, isSpecial);
}
@Override
@@ -86,8 +83,17 @@ public boolean equals(Object o) {
@Override
public String toString() {
- return "tilecode:" + getTileCode() + " shape:" + shapeIndex + " back:" + backgroundElementIndex + " " +
- "fore:"+foregroundElementIndex+" special:"+isSpecial;
+ return "tilecode:"
+ + getTileCode()
+ + " shape:"
+ + shapeIndex
+ + " back:"
+ + backgroundElementIndex
+ + " "
+ + "fore:"
+ + foregroundElementIndex
+ + " special:"
+ + isSpecial;
}
public int getTileCode() {
diff --git a/editor/src/main/java/org/moparforia/editor/TrackEditor.java b/editor/src/main/java/org/moparforia/editor/TrackEditor.java
index e8e37ea4..a06a0173 100644
--- a/editor/src/main/java/org/moparforia/editor/TrackEditor.java
+++ b/editor/src/main/java/org/moparforia/editor/TrackEditor.java
@@ -4,14 +4,6 @@
package org.moparforia.editor;
-import org.moparforia.shared.tracks.Track;
-import org.moparforia.shared.tracks.TrackCategory;
-import org.moparforia.shared.tracks.filesystem.FileSystemTrackManager;
-import org.moparforia.shared.tracks.parsers.VersionedTrackFileParser;
-
-import javax.swing.*;
-import javax.swing.border.TitledBorder;
-import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -20,6 +12,13 @@
import java.io.*;
import java.nio.file.Path;
import java.util.ArrayList;
+import javax.swing.*;
+import javax.swing.border.TitledBorder;
+import javax.swing.filechooser.FileFilter;
+import org.moparforia.shared.tracks.Track;
+import org.moparforia.shared.tracks.TrackCategory;
+import org.moparforia.shared.tracks.filesystem.FileSystemTrackManager;
+import org.moparforia.shared.tracks.parsers.VersionedTrackFileParser;
/**
* @author Johan Ljungberg
@@ -109,7 +108,6 @@ public void mouseClicked(MouseEvent e) {
newTile.setShapeIndex(index);
break;
case 1:
-
if (SwingUtilities.isLeftMouseButton(e)) {
newTile.setBackground(index);
backSelection.setIcon(icon);
@@ -132,26 +130,29 @@ public void mouseClicked(MouseEvent e) {
@Override
public void mousePressed(MouseEvent e) {
- //To change body of implemented methods use File | Settings | File Templates.
+ // To change body of implemented methods use File | Settings | File
+ // Templates.
}
@Override
public void mouseReleased(MouseEvent e) {
- //To change body of implemented methods use File | Settings | File Templates.
+ // To change body of implemented methods use File | Settings | File
+ // Templates.
}
@Override
public void mouseEntered(MouseEvent e) {
- //To change body of implemented methods use File | Settings | File Templates.
+ // To change body of implemented methods use File | Settings | File
+ // Templates.
}
@Override
public void mouseExited(MouseEvent e) {
- //To change body of implemented methods use File | Settings | File Templates.
+ // To change body of implemented methods use File | Settings | File
+ // Templates.
}
});
-
panel.add(button);
}
if (groupIndex == 0) {
@@ -208,8 +209,11 @@ private void menuOpenActionPerformed(ActionEvent e) {
Map m = new MapDecompressor().decompress(currentTrack.getMap());
TrackCategory category = TrackCategory.UNKNOWN;
if (!currentTrack.getCategories().isEmpty()) {
- // Oneliner to get one random category from loaded set, editor cannot work wiht multiple categories yet
- category = currentTrack.getCategories().stream().reduce((t, u) -> t).orElse(TrackCategory.UNKNOWN);
+ // Oneliner to get one random category from loaded set, editor cannot work wiht
+ // multiple categories yet
+ category = currentTrack.getCategories().stream()
+ .reduce((t, u) -> t)
+ .orElse(TrackCategory.UNKNOWN);
}
mapCanvas.updateProperties(currentTrack.getName(), category.getId());
mapCanvas.setMap(m);
@@ -223,12 +227,20 @@ private void menuOpenActionPerformed(ActionEvent e) {
private void menuSaveActionPerformed(ActionEvent e) {
if (!isValidTrack(mapCanvas.getMap())) {
- JOptionPane.showMessageDialog(this, "The current track is impassable, please ensure there is a starting position, finishing hole and a valid path between.", "Error", JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(
+ this,
+ "The current track is impassable, please ensure there is a starting position, finishing hole and a valid path between.",
+ "Error",
+ JOptionPane.ERROR_MESSAGE);
return;
}
if (mapCanvas.getTrackName().equals("") || mapCanvas.getTrackCategory() == 0) {
- JOptionPane.showMessageDialog(this, "You need to specify a Track Name and/or Category before saving!", "Error", JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(
+ this,
+ "You need to specify a Track Name and/or Category before saving!",
+ "Error",
+ JOptionPane.ERROR_MESSAGE);
new TrackPropertiesDialog(this).setVisible(true);
menuSaveActionPerformed(e);
return;
@@ -288,10 +300,10 @@ public static boolean isValidTrack(Map m) {
if (!containsHole || (startX.isEmpty() && startY.isEmpty())) {
return false; // if there is no hole or starting positions, ITS NOT VALID!
}
- for(int i = 0; i < startX.size(); i++) {
- System.out.println(startX.get(i)+" "+startY.get(i));
- boolean[][] visited = new boolean[tiles.length][tiles[0].length];
- if(!traverseTrack(m, visited, startX.get(i), startY.get(i))) {
+ for (int i = 0; i < startX.size(); i++) {
+ System.out.println(startX.get(i) + " " + startY.get(i));
+ boolean[][] visited = new boolean[tiles.length][tiles[0].length];
+ if (!traverseTrack(m, visited, startX.get(i), startY.get(i))) {
return false; // if any starting positions don't work, then bye bye.
}
}
@@ -359,20 +371,19 @@ private void initComponents() {
toggleCircle = new JToggleButton();
toggleFill = new JToggleButton();
-
- //======== this ========
+ // ======== this ========
setTitle("Playforia Minigolf Track Editor (BETA)");
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
- //======== menuBar ========
+ // ======== menuBar ========
{
- //======== menuFile ========
+ // ======== menuFile ========
{
menuFile.setText("File");
- //---- menuNew ----
+ // ---- menuNew ----
menuNew.setText("New");
menuNew.addActionListener(new ActionListener() {
@Override
@@ -383,7 +394,7 @@ public void actionPerformed(ActionEvent e) {
menuFile.add(menuNew);
menuFile.addSeparator();
- //---- menuOpen ----
+ // ---- menuOpen ----
menuOpen.setText("Open");
menuOpen.addActionListener(new ActionListener() {
@Override
@@ -393,7 +404,7 @@ public void actionPerformed(ActionEvent e) {
});
menuFile.add(menuOpen);
- //---- menuSave ----
+ // ---- menuSave ----
menuSave.setText("Save");
menuSave.addActionListener(new ActionListener() {
@Override
@@ -404,7 +415,7 @@ public void actionPerformed(ActionEvent e) {
menuFile.add(menuSave);
menuFile.addSeparator();
- //---- menuQuit ----
+ // ---- menuQuit ----
menuQuit.setText("Quit");
menuQuit.addActionListener(new ActionListener() {
@Override
@@ -416,11 +427,11 @@ public void actionPerformed(ActionEvent e) {
}
menuBar.add(menuFile);
- //======== menuTrack ========
+ // ======== menuTrack ========
{
menuTrack.setText("Track");
- //---- menuPreferences ----
+ // ---- menuPreferences ----
menuPreferences.setText("Preferences");
menuPreferences.addActionListener(new ActionListener() {
@Override
@@ -432,11 +443,11 @@ public void actionPerformed(ActionEvent e) {
}
menuBar.add(menuTrack);
- //======== menuView ========
+ // ======== menuView ========
{
menuView.setText("View");
- //---- menuGrid ----
+ // ---- menuGrid ----
menuGrid.setText("Grid");
menuGrid.setSelected(true);
menuGrid.addActionListener(new ActionListener() {
@@ -451,7 +462,7 @@ public void actionPerformed(ActionEvent e) {
}
setJMenuBar(menuBar);
- //======== trackCanvas ========
+ // ======== trackCanvas ========
{
trackCanvas.setPreferredSize(new Dimension(735, 375));
trackCanvas.setLayout(null);
@@ -468,38 +479,37 @@ public void actionPerformed(ActionEvent e) {
preferredSize.height += insets.bottom;
trackCanvas.setMinimumSize(preferredSize);
trackCanvas.setPreferredSize(preferredSize);
-
}
}
contentPane.add(trackCanvas, BorderLayout.CENTER);
- //======== canvasPanel ========
+ // ======== canvasPanel ========
{
canvasPanel.setBorder(new TitledBorder("Palette"));
canvasPanel.setLayout(new BorderLayout());
}
contentPane.add(canvasPanel, BorderLayout.SOUTH);
- //======== maskPanel ========
+ // ======== maskPanel ========
{
maskPanel.setFloatable(false);
maskPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 1));
maskPanel.setPreferredSize(new Dimension(16, 80));
- //---- togglePencil ----
+ // ---- togglePencil ----
togglePencil.setIcon(new ImageIcon(getClass().getResource("/pencil_icon&16.png")));
maskPanel.add(togglePencil);
- //---- toggleRectangle ----
+ // ---- toggleRectangle ----
toggleRectangle.setIcon(new ImageIcon(getClass().getResource("/playback_stop_icon&16.png")));
maskPanel.add(toggleRectangle);
- //---- toggleCircle ----
+ // ---- toggleCircle ----
toggleCircle.setIcon(new ImageIcon(getClass().getResource("/playback_rec_icon&16.png")));
toggleCircle.setEnabled(false);
maskPanel.add(toggleCircle);
- //---- toggleFill ----
+ // ---- toggleFill ----
toggleFill.setIcon(new ImageIcon(getClass().getResource("/fill_icon&16.png")));
toggleFill.setEnabled(false);
maskPanel.add(toggleFill, BorderLayout.NORTH);
diff --git a/editor/src/main/java/org/moparforia/editor/TrackPropertiesDialog.java b/editor/src/main/java/org/moparforia/editor/TrackPropertiesDialog.java
index 3d9a14e5..ddb05298 100644
--- a/editor/src/main/java/org/moparforia/editor/TrackPropertiesDialog.java
+++ b/editor/src/main/java/org/moparforia/editor/TrackPropertiesDialog.java
@@ -4,12 +4,11 @@
package org.moparforia.editor;
-import org.moparforia.shared.tracks.TrackCategory;
-
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
+import org.moparforia.shared.tracks.TrackCategory;
/**
* @author Johan Ljungberg
@@ -27,16 +26,18 @@ public TrackPropertiesDialog(Dialog owner) {
}
private void loadValues() {
- textTrackName.setText(((TrackEditor)getOwner()).getMapCanvas().getTrackName());
+ textTrackName.setText(((TrackEditor) getOwner()).getMapCanvas().getTrackName());
comboTrackCategory.setSelectedIndex(TrackCategory.BASIC.getId());
}
private void okButtonActionPerformed(ActionEvent e) {
- if(textTrackName.getText().equals("")) {
+ if (textTrackName.getText().equals("")) {
JOptionPane.showMessageDialog(this, "Track name cannot be empty!", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
- ((TrackEditor)getOwner()).getMapCanvas().updateProperties(textTrackName.getText(), comboTrackCategory.getSelectedIndex() + 1);
+ ((TrackEditor) getOwner())
+ .getMapCanvas()
+ .updateProperties(textTrackName.getText(), comboTrackCategory.getSelectedIndex() + 1);
this.dispose();
}
@@ -58,7 +59,7 @@ private void initComponents() {
okButton = new JButton();
cancelButton = new JButton();
- //======== this ========
+ // ======== this ========
setTitle("Track Properties");
setAlwaysOnTop(true);
setResizable(false);
@@ -67,62 +68,55 @@ private void initComponents() {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
- //======== dialogPane ========
+ // ======== dialogPane ========
{
dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
dialogPane.setLayout(new BorderLayout());
- //======== contentPanel ========
+ // ======== contentPanel ========
{
contentPanel.setLayout(new GridLayout(0, 1));
- //======== panel2 ========
+ // ======== panel2 ========
{
panel2.setLayout(new FlowLayout());
- //---- label3 ----
+ // ---- label3 ----
label3.setText("Track Name:");
panel2.add(label3);
- //---- textTrackName ----
+ // ---- textTrackName ----
textTrackName.setPreferredSize(new Dimension(200, 20));
panel2.add(textTrackName);
}
contentPanel.add(panel2);
- //======== panel1 ========
+ // ======== panel1 ========
{
panel1.setLayout(new FlowLayout());
- //---- label2 ----
+ // ---- label2 ----
label2.setText("Track Category");
panel1.add(label2);
- //---- comboTrackCategory ----
+ // ---- comboTrackCategory ----
comboTrackCategory.setPreferredSize(new Dimension(200, 20));
- comboTrackCategory.setModel(new DefaultComboBoxModel<>(new String[] {
- "Basic",
- "Traditional",
- "Modern",
- "Hole In One",
- "Short",
- "Long",
- "Custom"
- }));
+ comboTrackCategory.setModel(new DefaultComboBoxModel<>(
+ new String[] {"Basic", "Traditional", "Modern", "Hole In One", "Short", "Long", "Custom"}));
panel1.add(comboTrackCategory);
}
contentPanel.add(panel1);
}
dialogPane.add(contentPanel, BorderLayout.CENTER);
- //======== buttonBar ========
+ // ======== buttonBar ========
{
buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
buttonBar.setLayout(new GridBagLayout());
- ((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80};
- ((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0};
+ ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80};
+ ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0};
- //---- okButton ----
+ // ---- okButton ----
okButton.setText("OK");
okButton.addActionListener(new ActionListener() {
@Override
@@ -130,11 +124,22 @@ public void actionPerformed(ActionEvent e) {
okButtonActionPerformed(e);
}
});
- buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH,
- new Insets(0, 0, 0, 5), 0, 0));
-
- //---- cancelButton ----
+ buttonBar.add(
+ okButton,
+ new GridBagConstraints(
+ 1,
+ 0,
+ 1,
+ 1,
+ 0.0,
+ 0.0,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.BOTH,
+ new Insets(0, 0, 0, 5),
+ 0,
+ 0));
+
+ // ---- cancelButton ----
cancelButton.setText("Cancel");
cancelButton.addActionListener(new ActionListener() {
@Override
@@ -142,9 +147,20 @@ public void actionPerformed(ActionEvent e) {
cancelButtonActionPerformed(e);
}
});
- buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH,
- new Insets(0, 0, 0, 0), 0, 0));
+ buttonBar.add(
+ cancelButton,
+ new GridBagConstraints(
+ 2,
+ 0,
+ 1,
+ 1,
+ 0.0,
+ 0.0,
+ GridBagConstraints.CENTER,
+ GridBagConstraints.BOTH,
+ new Insets(0, 0, 0, 0),
+ 0,
+ 0));
}
dialogPane.add(buttonBar, BorderLayout.SOUTH);
}
diff --git a/editor/src/main/java/org/moparforia/editor/util/RectangleDragSelector.java b/editor/src/main/java/org/moparforia/editor/util/RectangleDragSelector.java
index 0e5f1ec4..51b26e68 100644
--- a/editor/src/main/java/org/moparforia/editor/util/RectangleDragSelector.java
+++ b/editor/src/main/java/org/moparforia/editor/util/RectangleDragSelector.java
@@ -2,11 +2,7 @@
import java.awt.*;
-/**
- * User: Johan
- * Date: 2013-07-31
- * Time: 11:23
- */
+/** User: Johan Date: 2013-07-31 Time: 11:23 */
public class RectangleDragSelector {
private int x1, x2, y1, y2;
diff --git a/pom.xml b/pom.xml
index 131d755f..d2fec17d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,17 +1,17 @@
-
+
V >=2 A {AUTHOR OF TRACK} N {NAME OF TRACK} T data C {CategoryId}, {CategoryId}, ... I {NUMBER
+ * OF PLAYERS TO COMPLETE},{NUMBER OF STROKES},{BEST NUMBER OF STROKES},{NUMBER OF PEOPLE THAT GOT
+ * BEST STROKE} B {FIRST BEST PAR PLAYER},{UNIX TIMESTAMP OF FIRST BEST PAR}000 L {LAST BEST PAR
+ * PLAYER},{UNIX TIMESTAMP OF LAST BEST PAR}000 R {RATING: 0},{RATING: 1},{RATING: 2},{RATING:
+ * 3},{RATING: 4},{RATING: 5},{RATING: 6},{RATING: 7},{RATING: 8},{RATING: 9},{RATING: 10}
*/
public class VersionedTrackFileParser extends GenericTrackParser implements TrackParser {
public static final int DEFAULT_ALLOWED_FILE_VERSION = 2;
@@ -36,8 +30,7 @@ public class VersionedTrackFileParser extends GenericTrackParser implements Trac
protected static final Map oakpark.trackset should be ignored because it didnt contain any loaded tracks
* birchwood.trackset should have only 2 tracks
*/
- @Test
- void testSimpleSetLoad() throws IOException, URISyntaxException, TrackLoadException {
- extension.copyAll();
-
- manager.load(tracksLocation);
- assertEquals(1, manager.getTrackSets().size());
- TrackSet birchwood = manager.getTrackSet("Birchwood");
+ @Test
+ void testSimpleSetLoad() throws IOException, URISyntaxException, TrackLoadException {
+ extension.copyAll();
- assertEquals(2, birchwood.getTracks().size());
- assertEquals("Birchwood", birchwood.getName());
- assertEquals(TrackSetDifficulty.EASY, birchwood.getDifficulty());
+ manager.load(tracksLocation);
+ assertEquals(1, manager.getTrackSets().size());
+ TrackSet birchwood = manager.getTrackSet("Birchwood");
- }
+ assertEquals(2, birchwood.getTracks().size());
+ assertEquals("Birchwood", birchwood.getName());
+ assertEquals(TrackSetDifficulty.EASY, birchwood.getDifficulty());
+ }
- @Test
- void testLoad() throws IOException, URISyntaxException, TrackLoadException {
- extension.copyAll();
+ @Test
+ void testLoad() throws IOException, URISyntaxException, TrackLoadException {
+ extension.copyAll();
- manager.load(tracksLocation);
- assertEquals(17, manager.getTracks().size());
- assertEquals(1, manager.getTrackSets().size());
+ manager.load(tracksLocation);
+ assertEquals(17, manager.getTracks().size());
+ assertEquals(1, manager.getTrackSets().size());
- assertEquals(6, manager.findAllByCategory(TrackCategory.MODERN).size());
- assertEquals(17, manager.findAllByCategory(TrackCategory.ALL).size());
- assertEquals(2, manager.findAllByCategory(TrackCategory.SHORT).size());
- assertEquals(3, manager.findAllByCategory(TrackCategory.TRADITIONAL).size());
- assertEquals(2 ,manager.findAllByCategory(TrackCategory.HIO).size());
- assertEquals(3, manager.findAllByCategory(TrackCategory.BASIC).size());
+ assertEquals(6, manager.findAllByCategory(TrackCategory.MODERN).size());
+ assertEquals(17, manager.findAllByCategory(TrackCategory.ALL).size());
+ assertEquals(2, manager.findAllByCategory(TrackCategory.SHORT).size());
+ assertEquals(3, manager.findAllByCategory(TrackCategory.TRADITIONAL).size());
+ assertEquals(2, manager.findAllByCategory(TrackCategory.HIO).size());
+ assertEquals(3, manager.findAllByCategory(TrackCategory.BASIC).size());
- assert manager.isLoaded();
- }
+ assert manager.isLoaded();
+ }
@Test
void testRandomTracksIncorrectLimit() {
- assertThrows(IllegalArgumentException.class, () -> manager.getRandomTracks(0, TrackCategory.ALL));
- assertThrows(IllegalArgumentException.class, () -> manager.getRandomTracks(-1, TrackCategory.ALL));
+ assertThrows(IllegalArgumentException.class, () -> manager.getRandomTracks(0, TrackCategory.ALL));
+ assertThrows(IllegalArgumentException.class, () -> manager.getRandomTracks(-1, TrackCategory.ALL));
}
@Test
@@ -78,14 +75,15 @@ void testRandomTracks() throws IOException, URISyntaxException, TrackLoadExcepti
manager.load(tracksLocation);
assertEquals(3, manager.getRandomTracks(3, TrackCategory.MODERN).size());
assertEquals(6, manager.getRandomTracks(50, TrackCategory.MODERN).size());
- }
+ }
/**
- * This means that if randomTracks is called on a category that doesn't have any tracks it will return empty list
+ * This means that if randomTracks is called on a category that doesn't have any tracks it will
+ * return empty list
*/
- @Test
- void testRandomTracksEmpty() throws TrackLoadException {
- manager.load(tracksLocation);
- assertEquals(0, manager.getRandomTracks(50, TrackCategory.BASIC).size());
- }
+ @Test
+ void testRandomTracksEmpty() throws TrackLoadException {
+ manager.load(tracksLocation);
+ assertEquals(0, manager.getRandomTracks(50, TrackCategory.BASIC).size());
+ }
}
diff --git a/shared/src/test/java/org/moparforia/shared/tracks/filesystem/VersionTest.java b/shared/src/test/java/org/moparforia/shared/tracks/filesystem/VersionTest.java
index b1c480d0..46111f05 100644
--- a/shared/src/test/java/org/moparforia/shared/tracks/filesystem/VersionTest.java
+++ b/shared/src/test/java/org/moparforia/shared/tracks/filesystem/VersionTest.java
@@ -1,5 +1,9 @@
package org.moparforia.shared.tracks.filesystem;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.moparforia.shared.tracks.TrackLoadException;
@@ -7,11 +11,6 @@
import org.moparforia.shared.tracks.TracksLocation;
import org.moparforia.shared.tracks.util.FileSystemExtension;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class VersionTest {
@RegisterExtension
final FileSystemExtension extension = new FileSystemExtension("v2/invalid");
@@ -26,5 +25,4 @@ void testTrackManagerInvalidVersions() throws IOException, URISyntaxException, T
assertEquals(1, manager.getTracks().size());
}
-
}
diff --git a/shared/src/test/java/org/moparforia/shared/tracks/parsers/TrackConverterTest.java b/shared/src/test/java/org/moparforia/shared/tracks/parsers/TrackConverterTest.java
index 719a676c..38af07e8 100644
--- a/shared/src/test/java/org/moparforia/shared/tracks/parsers/TrackConverterTest.java
+++ b/shared/src/test/java/org/moparforia/shared/tracks/parsers/TrackConverterTest.java
@@ -1,5 +1,12 @@
package org.moparforia.shared.tracks.parsers;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.moparforia.shared.tracks.Track;
@@ -8,22 +15,9 @@
import org.moparforia.shared.tracks.stats.TrackStats;
import org.moparforia.shared.tracks.util.FileSystemExtension;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
class TrackConverterTest {
- private final String[] DIRS = new String[]{
- "tracks/modern",
- "tracks/traditional",
- "tracks/short",
- "tracks/long",
- "tracks/basic",
- "tracks/hio",
+ private final String[] DIRS = new String[] {
+ "tracks/modern", "tracks/traditional", "tracks/short", "tracks/long", "tracks/basic", "tracks/hio",
};
@RegisterExtension
@@ -37,7 +31,6 @@ void testConvertTracks() throws IOException, URISyntaxException {
FileSystemStatsManager statsManager = new FileSystemStatsManager();
TracksLocation tracksLocation = new TracksLocation(this.extension.getFileSystem(), "tracks");
-
Path tracks = extension.getFileSystem().getPath("tracks");
List