Loading jeuAssemblage/output.png −415 B (257 B) Loading image diff... jeuAssemblage/src/main/App.java +25 −3 Changes for jeuAssemblage/src/main/App.java: 25 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ package main; import java.io.File; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import bot.strategy.AbstractStrategyAI; Loading @@ -10,13 +13,32 @@ import model.SeedUtils; import view.MainFrame; public class App { private static JFrame frame = null; public static void main(String[] args) throws Exception { //PlayBoard p = PlayBoard.constructPlayBoard(SeedUtils.generateRandomSeed(), 8, 8, 4); //new AbstractStrategyAI(p); SwingUtilities.invokeLater(() -> { new MainFrame(); frame = new MainFrame(); }); JPanel panel = new JPanel(); JButton btn = new JButton("REBOOT"); btn.addActionListener(e -> { frame.dispose(); SwingUtilities.invokeLater(() -> { frame = new MainFrame(); }); }); panel.add(btn); JFrame rebootFrame = new JFrame(); rebootFrame.setContentPane(panel); rebootFrame.pack(); rebootFrame.setVisible(true); } } jeuAssemblage/src/model/PlayBoard.java +4 −3 Changes for jeuAssemblage/src/model/PlayBoard.java: 4 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -485,7 +485,7 @@ public class PlayBoard extends AbstractListenableHM implements Listener, IPlayBo PieceFactory pieceFactory = pieceFactorys.get(random.nextInt(pieceFactorys.size())); Piece piece = pieceFactory.createPiece(0); /* Color color = null; if (true == colorList.isEmpty()) { Loading @@ -494,9 +494,10 @@ public class PlayBoard extends AbstractListenableHM implements Listener, IPlayBo color = colorList.remove(random.nextInt(colorList.size())); playBoard.piecesImagesMap.put(playBoard.getPieceId(piece), PieceRenderUtils.createCellImage(color)); */ playBoard.randomlyPlacePiece(piece); playBoard.piecesImagesMap.put(playBoard.getPieceId(piece), PieceRenderUtils.createCellImage(color)); // TODO: REFAIRE CETTE MERDE } return playBoard; Loading jeuAssemblage/src/view/component/GamePanel.java +2 −2 Changes for jeuAssemblage/src/view/component/GamePanel.java: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -29,12 +29,12 @@ public class GamePanel extends JPanel { this.setLayout(null); this.timerPanel = new TimerPanel(timer, new Runnable() { this.timerPanel = new TimerPanel(mainFrame, timer, new Runnable() { @Override public void run() { mainFrame.setContentPane(new SoloGameFinishScreen(playBoard)); mainFrame.setContentPane(new SoloGameFinishScreen(mainFrame, playBoard)); } }); this.pieceBoard = new PieceBoard(playBoard); Loading jeuAssemblage/src/view/component/GameSummary.java +38 −36 Changes for jeuAssemblage/src/view/component/GameSummary.java: 38 added lines, 36 removed lines. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import view.utils.SwingUtils; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Point; import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.awt.Color; Loading @@ -36,55 +37,56 @@ public class GameSummary extends JPanel { SwingUtils.drawDebugBounds(this, g); // int[] areaInformation = this.controller.areaInfomartion(); Point upperLeftCorner = playBoard.getUpperLeftPieceCorner(); Point lowerRightCorner = playBoard.getLowerRightPieceCorner(); // int xBegin = areaInformation[0]; // int yBegin = areaInformation[1]; // int xEnd = areaInformation[2]; // int yEnd = areaInformation[3]; int xBegin = upperLeftCorner.x; int yBegin = upperLeftCorner.y; int xEnd = lowerRightCorner.x + 1; int yEnd = lowerRightCorner.y + 1; // int componentSize = (int) Math.min( // getHeightTimesPourcent(this, 0.95f) / ((yEnd - yBegin) * 1d), // getWidthTimesPourcent(this, 0.95f) / ((xEnd - xBegin) * 1d) // ); int componentSize = (int) Math.min( getHeightTimesPourcent(this, 0.95f) / ((yEnd - yBegin) * 1d), getWidthTimesPourcent(this, 0.95f) / ((xEnd - xBegin) * 1d) ); // double paddingWidth = this.getWidth () - (componentSize * ((xEnd - xBegin) * 1d)); // double paddingHeight = this.getHeight() - (componentSize * ((yEnd - yBegin) * 1d)); double paddingWidth = this.getWidth () - (componentSize * ((xEnd - xBegin) * 1d)); double paddingHeight = this.getHeight() - (componentSize * ((yEnd - yBegin) * 1d)); // Graphics2D g2d = (Graphics2D) g; // g2d.setColor(Color.WHITE); // int[][] matrices = this.controller.getPlayBoard(); Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.WHITE); int[][] matrices = playBoard.getBoardArray(); // for ( int i = yBegin; i < yEnd; i++) { for ( int i = yBegin; i < yEnd; i++) { // int y = (i - yBegin) * componentSize + (int) paddingHeight / 2; int y = (i - yBegin) * componentSize + (int) paddingHeight / 2; // for ( int j = xBegin; j < xEnd; j++) { for ( int j = xBegin; j < xEnd; j++) { // int x = (j - xBegin) * componentSize + (int) paddingWidth / 2; // Rectangle2D shape = new Rectangle2D.Double(x,y, componentSize, componentSize); int x = (j - xBegin) * componentSize + (int) paddingWidth / 2; Rectangle2D shape = new Rectangle2D.Double(x,y, componentSize, componentSize); // if (matrices[i][j] != 0) { if (matrices[i][j] != 0) { // Piece p = this.controller.getPieceById(matrices[i][j]); Piece p = playBoard.getPieceById(matrices[i][j]); // Image img = this.controller.getImageById(p.getInstanceId()); Image img = playBoard.getCellImageByPieceId(matrices[i][j]); // g2d.drawImage( // img, // x + 1, // y + 1, // componentSize, // componentSize, // null // ); // } // else { g2d.drawImage( img, x + 1, y + 1, componentSize, componentSize, null ); } else { // g2d.draw(shape); // } // } // } g2d.draw(shape); } } } } Loading Loading
jeuAssemblage/src/main/App.java +25 −3 Changes for jeuAssemblage/src/main/App.java: 25 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ package main; import java.io.File; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import bot.strategy.AbstractStrategyAI; Loading @@ -10,13 +13,32 @@ import model.SeedUtils; import view.MainFrame; public class App { private static JFrame frame = null; public static void main(String[] args) throws Exception { //PlayBoard p = PlayBoard.constructPlayBoard(SeedUtils.generateRandomSeed(), 8, 8, 4); //new AbstractStrategyAI(p); SwingUtilities.invokeLater(() -> { new MainFrame(); frame = new MainFrame(); }); JPanel panel = new JPanel(); JButton btn = new JButton("REBOOT"); btn.addActionListener(e -> { frame.dispose(); SwingUtilities.invokeLater(() -> { frame = new MainFrame(); }); }); panel.add(btn); JFrame rebootFrame = new JFrame(); rebootFrame.setContentPane(panel); rebootFrame.pack(); rebootFrame.setVisible(true); } }
jeuAssemblage/src/model/PlayBoard.java +4 −3 Changes for jeuAssemblage/src/model/PlayBoard.java: 4 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -485,7 +485,7 @@ public class PlayBoard extends AbstractListenableHM implements Listener, IPlayBo PieceFactory pieceFactory = pieceFactorys.get(random.nextInt(pieceFactorys.size())); Piece piece = pieceFactory.createPiece(0); /* Color color = null; if (true == colorList.isEmpty()) { Loading @@ -494,9 +494,10 @@ public class PlayBoard extends AbstractListenableHM implements Listener, IPlayBo color = colorList.remove(random.nextInt(colorList.size())); playBoard.piecesImagesMap.put(playBoard.getPieceId(piece), PieceRenderUtils.createCellImage(color)); */ playBoard.randomlyPlacePiece(piece); playBoard.piecesImagesMap.put(playBoard.getPieceId(piece), PieceRenderUtils.createCellImage(color)); // TODO: REFAIRE CETTE MERDE } return playBoard; Loading
jeuAssemblage/src/view/component/GamePanel.java +2 −2 Changes for jeuAssemblage/src/view/component/GamePanel.java: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -29,12 +29,12 @@ public class GamePanel extends JPanel { this.setLayout(null); this.timerPanel = new TimerPanel(timer, new Runnable() { this.timerPanel = new TimerPanel(mainFrame, timer, new Runnable() { @Override public void run() { mainFrame.setContentPane(new SoloGameFinishScreen(playBoard)); mainFrame.setContentPane(new SoloGameFinishScreen(mainFrame, playBoard)); } }); this.pieceBoard = new PieceBoard(playBoard); Loading
jeuAssemblage/src/view/component/GameSummary.java +38 −36 Changes for jeuAssemblage/src/view/component/GameSummary.java: 38 added lines, 36 removed lines. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import view.utils.SwingUtils; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Point; import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.awt.Color; Loading @@ -36,55 +37,56 @@ public class GameSummary extends JPanel { SwingUtils.drawDebugBounds(this, g); // int[] areaInformation = this.controller.areaInfomartion(); Point upperLeftCorner = playBoard.getUpperLeftPieceCorner(); Point lowerRightCorner = playBoard.getLowerRightPieceCorner(); // int xBegin = areaInformation[0]; // int yBegin = areaInformation[1]; // int xEnd = areaInformation[2]; // int yEnd = areaInformation[3]; int xBegin = upperLeftCorner.x; int yBegin = upperLeftCorner.y; int xEnd = lowerRightCorner.x + 1; int yEnd = lowerRightCorner.y + 1; // int componentSize = (int) Math.min( // getHeightTimesPourcent(this, 0.95f) / ((yEnd - yBegin) * 1d), // getWidthTimesPourcent(this, 0.95f) / ((xEnd - xBegin) * 1d) // ); int componentSize = (int) Math.min( getHeightTimesPourcent(this, 0.95f) / ((yEnd - yBegin) * 1d), getWidthTimesPourcent(this, 0.95f) / ((xEnd - xBegin) * 1d) ); // double paddingWidth = this.getWidth () - (componentSize * ((xEnd - xBegin) * 1d)); // double paddingHeight = this.getHeight() - (componentSize * ((yEnd - yBegin) * 1d)); double paddingWidth = this.getWidth () - (componentSize * ((xEnd - xBegin) * 1d)); double paddingHeight = this.getHeight() - (componentSize * ((yEnd - yBegin) * 1d)); // Graphics2D g2d = (Graphics2D) g; // g2d.setColor(Color.WHITE); // int[][] matrices = this.controller.getPlayBoard(); Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.WHITE); int[][] matrices = playBoard.getBoardArray(); // for ( int i = yBegin; i < yEnd; i++) { for ( int i = yBegin; i < yEnd; i++) { // int y = (i - yBegin) * componentSize + (int) paddingHeight / 2; int y = (i - yBegin) * componentSize + (int) paddingHeight / 2; // for ( int j = xBegin; j < xEnd; j++) { for ( int j = xBegin; j < xEnd; j++) { // int x = (j - xBegin) * componentSize + (int) paddingWidth / 2; // Rectangle2D shape = new Rectangle2D.Double(x,y, componentSize, componentSize); int x = (j - xBegin) * componentSize + (int) paddingWidth / 2; Rectangle2D shape = new Rectangle2D.Double(x,y, componentSize, componentSize); // if (matrices[i][j] != 0) { if (matrices[i][j] != 0) { // Piece p = this.controller.getPieceById(matrices[i][j]); Piece p = playBoard.getPieceById(matrices[i][j]); // Image img = this.controller.getImageById(p.getInstanceId()); Image img = playBoard.getCellImageByPieceId(matrices[i][j]); // g2d.drawImage( // img, // x + 1, // y + 1, // componentSize, // componentSize, // null // ); // } // else { g2d.drawImage( img, x + 1, y + 1, componentSize, componentSize, null ); } else { // g2d.draw(shape); // } // } // } g2d.draw(shape); } } } } Loading