diff --git a/.classpath b/.classpath index 315bd1e..93ed671 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,10 @@ - + + + + + diff --git a/src/thbt/webng/com/AboutDialog.java b/src/thbt/webng/com/AboutDialog.java index 36faf1e..713832d 100644 --- a/src/thbt/webng/com/AboutDialog.java +++ b/src/thbt/webng/com/AboutDialog.java @@ -17,7 +17,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; -import thbt.webng.com.game.common.WindowUtil; +import thbt.webng.com.game.util.WindowUtil; /** * Puzzle about dialog @@ -102,10 +102,10 @@ public void mouseExited(MouseEvent e) { setResizable(false); } - private static final String VERSION = "1.1.0"; + private static final String VERSION = "1.0.0"; /** * My home page address */ - private static final String THBT_WEB_ADDRESS = "https://github.com/hoaftq"; + private static final String THBT_WEB_ADDRESS = "https://github.com/hoaftq/Lines-98"; private static final long serialVersionUID = 1L; } diff --git a/src/thbt/webng/com/GameFrame.java b/src/thbt/webng/com/GameFrame.java index ac375c5..3779a34 100644 --- a/src/thbt/webng/com/GameFrame.java +++ b/src/thbt/webng/com/GameFrame.java @@ -14,13 +14,13 @@ import thbt.webng.com.game.GameBoard; import thbt.webng.com.game.GamePanel; -import thbt.webng.com.game.common.WindowUtil; +import thbt.webng.com.game.info.GameInfoBoard; +import thbt.webng.com.game.info.HighScoreDialog; +import thbt.webng.com.game.info.PlayerScore; +import thbt.webng.com.game.info.PlayerScoreHistory; import thbt.webng.com.game.option.GameType; -import thbt.webng.com.game.option.OptionDialog; -import thbt.webng.com.game.status.GameInfoBoard; -import thbt.webng.com.game.status.HighScoreDialog; -import thbt.webng.com.game.status.PlayerScore; -import thbt.webng.com.game.status.PlayerScoreHistory; +import thbt.webng.com.game.option.OptionsDialog; +import thbt.webng.com.game.util.WindowUtil; public class GameFrame extends JFrame { @@ -95,7 +95,7 @@ private void addGameMenu() { JMenuItem optionsMenuItem = new JMenuItem("Options", 'O'); gameMenu.add(optionsMenuItem); optionsMenuItem.addActionListener((e) -> { - OptionDialog optionDialog = new OptionDialog(this); + OptionsDialog optionDialog = new OptionsDialog(this); optionDialog.setVisible(true); gamePanel.repaint(); }); diff --git a/src/thbt/webng/com/game/Ball.java b/src/thbt/webng/com/game/Ball.java index 734dbe1..11ad759 100644 --- a/src/thbt/webng/com/game/Ball.java +++ b/src/thbt/webng/com/game/Ball.java @@ -3,9 +3,9 @@ import java.awt.Color; import java.util.List; -import thbt.webng.com.game.common.PrimitiveBall; -import thbt.webng.com.game.option.GameInfo; +import thbt.webng.com.game.option.GameOptions; import thbt.webng.com.game.sound.SoundManager; +import thbt.webng.com.game.util.PrimitiveBall; public class Ball extends PrimitiveBall { @@ -67,7 +67,7 @@ public void select() { top += 2; } else { isUpDirect = !isUpDirect; - if (GameInfo.getCurrentInstance().isBallJumpingSound()) { + if (GameOptions.getCurrentInstance().isBallJumpingSound()) { SoundManager.playJumSound(); } } @@ -76,7 +76,7 @@ public void select() { square.repaint(); try { - Thread.sleep(GameInfo.getCurrentInstance().getJumpValue()); + Thread.sleep(GameOptions.getCurrentInstance().getJumpValue()); } catch (InterruptedException e) { e.printStackTrace(); } @@ -123,7 +123,7 @@ public static void growBall(final List squareList) { } try { - Thread.sleep(GameInfo.getCurrentInstance().getAppearanceValue()); + Thread.sleep(GameOptions.getCurrentInstance().getAppearanceValue()); } catch (InterruptedException e) { e.printStackTrace(); } @@ -147,7 +147,7 @@ public static void hideBall(final List squareList) { } try { - Thread.sleep(GameInfo.getCurrentInstance().getExplosionValue()); + Thread.sleep(GameOptions.getCurrentInstance().getExplosionValue()); } catch (InterruptedException e) { e.printStackTrace(); } @@ -158,7 +158,7 @@ public static void hideBall(final List squareList) { square.repaint(); } - if (GameInfo.getCurrentInstance().isDestroySound()) { + if (GameOptions.getCurrentInstance().isDestroySound()) { SoundManager.playDestroySound(); } } diff --git a/src/thbt/webng/com/game/GameBoard.java b/src/thbt/webng/com/game/GameBoard.java index b9bbd3c..4e906ff 100644 --- a/src/thbt/webng/com/game/GameBoard.java +++ b/src/thbt/webng/com/game/GameBoard.java @@ -9,12 +9,12 @@ import java.util.Queue; import java.util.Random; -import thbt.webng.com.game.common.ColorUtil; -import thbt.webng.com.game.option.GameInfo; +import thbt.webng.com.game.info.GameInfoBoard; +import thbt.webng.com.game.option.GameOptions; import thbt.webng.com.game.option.GameType; import thbt.webng.com.game.option.NextBallDisplayType; import thbt.webng.com.game.sound.SoundManager; -import thbt.webng.com.game.status.GameInfoBoard; +import thbt.webng.com.game.util.ColorUtil; public class GameBoard { @@ -34,9 +34,9 @@ public GameBoard(GamePanel gamePanel) { public void draw(Graphics g) { gameInfoBoard.draw(g); - boolean displayGrowingBalls = GameInfo.getCurrentInstance() + boolean displayGrowingBalls = GameOptions.getCurrentInstance() .getNextBallDisplayType() == NextBallDisplayType.ShowBoth - || GameInfo.getCurrentInstance().getNextBallDisplayType() == NextBallDisplayType.ShowOnField; + || GameOptions.getCurrentInstance().getNextBallDisplayType() == NextBallDisplayType.ShowOnField; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { squareArray[i][j].draw(g, displayGrowingBalls); @@ -67,13 +67,13 @@ public void newGame(GameType gameType) { gameInfoBoard.getScore().setScore(0); gameInfoBoard.setClockState(true); - GameInfo.getCurrentInstance().setGameType(gameType); + GameOptions.getCurrentInstance().setGameType(gameType); gamePanel.repaint(); } public void newGame() { - newGame(GameInfo.getCurrentInstance().getDefaultGameType()); + newGame(GameOptions.getCurrentInstance().getDefaultGameType()); } public Square getSquare(Position pos) { @@ -158,7 +158,7 @@ public boolean moveTo(final Position positionTo) { selectedPos = null; squareFrom.setBall(null); - if (GameInfo.getCurrentInstance().isMovementSound()) { + if (GameOptions.getCurrentInstance().isMovementSound()) { SoundManager.playMoveSound(); } @@ -397,9 +397,9 @@ private List getNeighborsSquare(Position2 pos) { } private List getCompleteSquare(Position pos) { - if (GameInfo.getCurrentInstance().getGameType() == GameType.LINE) { + if (GameOptions.getCurrentInstance().getGameType() == GameType.LINE) { return getLinesComplete(pos); - } else if (GameInfo.getCurrentInstance().getGameType() == GameType.SQUARE) { + } else if (GameOptions.getCurrentInstance().getGameType() == GameType.SQUARE) { return getSquaresComplete(pos); } else { return getBlocksComplete(pos); diff --git a/src/thbt/webng/com/game/status/Digit.java b/src/thbt/webng/com/game/info/Digit.java similarity index 98% rename from src/thbt/webng/com/game/status/Digit.java rename to src/thbt/webng/com/game/info/Digit.java index 699bcd3..277832a 100644 --- a/src/thbt/webng/com/game/status/Digit.java +++ b/src/thbt/webng/com/game/info/Digit.java @@ -1,4 +1,4 @@ -package thbt.webng.com.game.status; +package thbt.webng.com.game.info; import java.awt.Color; import java.awt.Graphics; diff --git a/src/thbt/webng/com/game/status/DigitalClock.java b/src/thbt/webng/com/game/info/DigitalClock.java similarity index 98% rename from src/thbt/webng/com/game/status/DigitalClock.java rename to src/thbt/webng/com/game/info/DigitalClock.java index d642f1a..c7159cd 100644 --- a/src/thbt/webng/com/game/status/DigitalClock.java +++ b/src/thbt/webng/com/game/info/DigitalClock.java @@ -1,4 +1,4 @@ -package thbt.webng.com.game.status; +package thbt.webng.com.game.info; import java.awt.Graphics; diff --git a/src/thbt/webng/com/game/status/GameInfoBoard.java b/src/thbt/webng/com/game/info/GameInfoBoard.java similarity index 89% rename from src/thbt/webng/com/game/status/GameInfoBoard.java rename to src/thbt/webng/com/game/info/GameInfoBoard.java index 98bd695..816c846 100644 --- a/src/thbt/webng/com/game/status/GameInfoBoard.java +++ b/src/thbt/webng/com/game/info/GameInfoBoard.java @@ -1,4 +1,4 @@ -package thbt.webng.com.game.status; +package thbt.webng.com.game.info; import java.awt.Color; import java.awt.Font; @@ -7,7 +7,7 @@ import javax.swing.Timer; import thbt.webng.com.game.GamePanel; -import thbt.webng.com.game.option.GameInfo; +import thbt.webng.com.game.option.GameOptions; import thbt.webng.com.game.option.NextBallDisplayType; public class GameInfoBoard { @@ -39,7 +39,7 @@ public void draw(Graphics g) { highestScore.draw(g); score.draw(g); - NextBallDisplayType displayType = GameInfo.getCurrentInstance().getNextBallDisplayType(); + NextBallDisplayType displayType = GameOptions.getCurrentInstance().getNextBallDisplayType(); if (displayType == NextBallDisplayType.ShowBoth || displayType == NextBallDisplayType.ShowOnTop) { nextBallBoard.draw(g); } @@ -75,7 +75,7 @@ public void setClockState(boolean isRun) { } private void drawGameType(Graphics g) { - String gameTypeString = GameInfo.getCurrentInstance().getGameType().toString().toUpperCase(); + String gameTypeString = GameOptions.getCurrentInstance().getGameType().toString().toUpperCase(); g.setFont(g.getFont().deriveFont(Font.BOLD, 7f)); diff --git a/src/thbt/webng/com/game/status/HighScoreDialog.java b/src/thbt/webng/com/game/info/HighScoreDialog.java similarity index 96% rename from src/thbt/webng/com/game/status/HighScoreDialog.java rename to src/thbt/webng/com/game/info/HighScoreDialog.java index 8cdadef..6cef5ad 100644 --- a/src/thbt/webng/com/game/status/HighScoreDialog.java +++ b/src/thbt/webng/com/game/info/HighScoreDialog.java @@ -1,4 +1,4 @@ -package thbt.webng.com.game.status; +package thbt.webng.com.game.info; import java.awt.BorderLayout; import java.security.InvalidParameterException; @@ -14,7 +14,7 @@ import javax.swing.table.AbstractTableModel; import javax.swing.table.DefaultTableCellRenderer; -import thbt.webng.com.game.common.WindowUtil; +import thbt.webng.com.game.util.WindowUtil; public class HighScoreDialog extends JDialog { diff --git a/src/thbt/webng/com/game/status/NextBallBoard.java b/src/thbt/webng/com/game/info/NextBallBoard.java similarity index 92% rename from src/thbt/webng/com/game/status/NextBallBoard.java rename to src/thbt/webng/com/game/info/NextBallBoard.java index c2bda6d..f3c0953 100644 --- a/src/thbt/webng/com/game/status/NextBallBoard.java +++ b/src/thbt/webng/com/game/info/NextBallBoard.java @@ -1,9 +1,9 @@ -package thbt.webng.com.game.status; +package thbt.webng.com.game.info; import java.awt.Color; import java.awt.Graphics; -import thbt.webng.com.game.common.PrimitiveBall; +import thbt.webng.com.game.util.PrimitiveBall; public class NextBallBoard { diff --git a/src/thbt/webng/com/game/status/PlayerScore.java b/src/thbt/webng/com/game/info/PlayerScore.java similarity index 95% rename from src/thbt/webng/com/game/status/PlayerScore.java rename to src/thbt/webng/com/game/info/PlayerScore.java index 8e7a62c..14f82ee 100644 --- a/src/thbt/webng/com/game/status/PlayerScore.java +++ b/src/thbt/webng/com/game/info/PlayerScore.java @@ -1,4 +1,4 @@ -package thbt.webng.com.game.status; +package thbt.webng.com.game.info; import java.io.Serializable; diff --git a/src/thbt/webng/com/game/status/PlayerScoreHistory.java b/src/thbt/webng/com/game/info/PlayerScoreHistory.java similarity index 94% rename from src/thbt/webng/com/game/status/PlayerScoreHistory.java rename to src/thbt/webng/com/game/info/PlayerScoreHistory.java index 4f1f2df..bcb8331 100644 --- a/src/thbt/webng/com/game/status/PlayerScoreHistory.java +++ b/src/thbt/webng/com/game/info/PlayerScoreHistory.java @@ -1,4 +1,4 @@ -package thbt.webng.com.game.status; +package thbt.webng.com.game.info; import java.util.ArrayList; import java.util.Comparator; @@ -6,7 +6,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import thbt.webng.com.game.common.StorageUtil; +import thbt.webng.com.game.util.StorageUtil; public class PlayerScoreHistory { diff --git a/src/thbt/webng/com/game/status/Score.java b/src/thbt/webng/com/game/info/Score.java similarity index 96% rename from src/thbt/webng/com/game/status/Score.java rename to src/thbt/webng/com/game/info/Score.java index d1a33df..aa02784 100644 --- a/src/thbt/webng/com/game/status/Score.java +++ b/src/thbt/webng/com/game/info/Score.java @@ -1,4 +1,4 @@ -package thbt.webng.com.game.status; +package thbt.webng.com.game.info; import java.awt.Graphics; public class Score { diff --git a/src/thbt/webng/com/game/option/GameInfo.java b/src/thbt/webng/com/game/option/GameOptions.java similarity index 86% rename from src/thbt/webng/com/game/option/GameInfo.java rename to src/thbt/webng/com/game/option/GameOptions.java index 1ba89d6..f6c43f3 100644 --- a/src/thbt/webng/com/game/option/GameInfo.java +++ b/src/thbt/webng/com/game/option/GameOptions.java @@ -2,9 +2,9 @@ import java.io.Serializable; -import thbt.webng.com.game.common.StorageUtil; +import thbt.webng.com.game.util.StorageUtil; -public class GameInfo implements Cloneable, Serializable { +public class GameOptions implements Cloneable, Serializable { private static final long serialVersionUID = -4449406179310549758L; @@ -88,18 +88,18 @@ public void setMovementSound(boolean movementSound) { this.movementSound = movementSound; } - public static GameInfo getCurrentInstance() { + public static GameOptions getCurrentInstance() { return currentInstance; } - public static void setCurrentInstance(GameInfo gameInfo) { + public static void setCurrentInstance(GameOptions gameInfo) { currentInstance = gameInfo; StorageUtil.save(currentInstance, CONFIG_FILE_NAME); } @Override - protected GameInfo clone() { - GameInfo gi = new GameInfo(); + protected GameOptions clone() { + GameOptions gi = new GameOptions(); gi.setGameType(gameType); gi.setDefaultGameType(defaultGameType); gi.setNextBallDisplayType(nextBallDisplayType); @@ -127,9 +127,9 @@ protected GameInfo clone() { private boolean destroySound = true; private boolean movementSound = true; - private static GameInfo currentInstance; + private static GameOptions currentInstance; private final static String CONFIG_FILE_NAME = "Config"; static { - currentInstance = StorageUtil.load(CONFIG_FILE_NAME).orElse(new GameInfo()); + currentInstance = StorageUtil.load(CONFIG_FILE_NAME).orElse(new GameOptions()); } } diff --git a/src/thbt/webng/com/game/option/OptionDialog.java b/src/thbt/webng/com/game/option/OptionsDialog.java similarity index 94% rename from src/thbt/webng/com/game/option/OptionDialog.java rename to src/thbt/webng/com/game/option/OptionsDialog.java index 44b158e..d3b07ab 100644 --- a/src/thbt/webng/com/game/option/OptionDialog.java +++ b/src/thbt/webng/com/game/option/OptionsDialog.java @@ -21,13 +21,13 @@ import javax.swing.JPanel; import javax.swing.JRadioButton; -import thbt.webng.com.game.common.WindowUtil; +import thbt.webng.com.game.util.WindowUtil; -public class OptionDialog extends JDialog implements ActionListener, ItemListener { +public class OptionsDialog extends JDialog implements ActionListener, ItemListener { private static final long serialVersionUID = -3458511180350780500L; - private GameInfo gameInfo = GameInfo.getCurrentInstance().clone(); + private GameOptions gameInfo = GameOptions.getCurrentInstance().clone(); private JRadioButton lineButton; @@ -47,7 +47,7 @@ public class OptionDialog extends JDialog implements ActionListener, ItemListene private JButton okButton; - public OptionDialog(JFrame owner) { + public OptionsDialog(JFrame owner) { super(owner, "Options", true); JPanel optionPane = new JPanel(); @@ -132,7 +132,7 @@ public void actionPerformed(ActionEvent e) { } else if (e.getSource() == nextBallDisplayComboBox) { gameInfo.setNextBallDisplayType((NextBallDisplayType) nextBallDisplayComboBox.getSelectedItem()); } else if (e.getSource() == okButton) { - GameInfo.setCurrentInstance(gameInfo); + GameOptions.setCurrentInstance(gameInfo); setVisible(false); dispose(); } else if (e.getSource() == cancelButton) { diff --git a/src/thbt/webng/com/game/common/ColorUtil.java b/src/thbt/webng/com/game/util/ColorUtil.java similarity index 91% rename from src/thbt/webng/com/game/common/ColorUtil.java rename to src/thbt/webng/com/game/util/ColorUtil.java index a9d1542..1d5ec97 100644 --- a/src/thbt/webng/com/game/common/ColorUtil.java +++ b/src/thbt/webng/com/game/util/ColorUtil.java @@ -1,4 +1,4 @@ -package thbt.webng.com.game.common; +package thbt.webng.com.game.util; import java.awt.Color; import java.util.Random; diff --git a/src/thbt/webng/com/game/common/PrimitiveBall.java b/src/thbt/webng/com/game/util/PrimitiveBall.java similarity index 98% rename from src/thbt/webng/com/game/common/PrimitiveBall.java rename to src/thbt/webng/com/game/util/PrimitiveBall.java index f4e24f0..1859ac3 100644 --- a/src/thbt/webng/com/game/common/PrimitiveBall.java +++ b/src/thbt/webng/com/game/util/PrimitiveBall.java @@ -1,4 +1,4 @@ -package thbt.webng.com.game.common; +package thbt.webng.com.game.util; import java.awt.Color; import java.awt.GradientPaint; diff --git a/src/thbt/webng/com/game/common/StorageUtil.java b/src/thbt/webng/com/game/util/StorageUtil.java similarity index 95% rename from src/thbt/webng/com/game/common/StorageUtil.java rename to src/thbt/webng/com/game/util/StorageUtil.java index e13631b..b75b3d5 100644 --- a/src/thbt/webng/com/game/common/StorageUtil.java +++ b/src/thbt/webng/com/game/util/StorageUtil.java @@ -1,4 +1,4 @@ -package thbt.webng.com.game.common; +package thbt.webng.com.game.util; import java.io.FileInputStream; import java.io.FileOutputStream; diff --git a/src/thbt/webng/com/game/common/WindowUtil.java b/src/thbt/webng/com/game/util/WindowUtil.java similarity index 96% rename from src/thbt/webng/com/game/common/WindowUtil.java rename to src/thbt/webng/com/game/util/WindowUtil.java index 610595c..e460460 100644 --- a/src/thbt/webng/com/game/common/WindowUtil.java +++ b/src/thbt/webng/com/game/util/WindowUtil.java @@ -1,4 +1,4 @@ -package thbt.webng.com.game.common; +package thbt.webng.com.game.util; import java.awt.Component; import java.awt.Dimension;