Loading jeuAssemblage/resources/blank_cursor.png 0 → 100644 +6.62 KiB Loading image diff... jeuAssemblage/src/model/PlayBoard.java +3 −0 Changes for jeuAssemblage/src/model/PlayBoard.java: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -285,6 +285,9 @@ public class PlayBoard { } private boolean canBeAddedToBoard(Piece p, int x, int y) { System.out.println("x : " + x + " y : " + y); if ( x + p.getWidth() > this.playBoard.length ) return false; if ( y + p.getHeight() > this.playBoard[0].length) return false; Loading jeuAssemblage/src/view/MainFrame.java +29 −1 Changes for jeuAssemblage/src/view/MainFrame.java: 29 added lines, 1 removed line. Original line number Diff line number Diff line package view; import java.awt.Container; import java.awt.Cursor; import java.awt.Image; import java.awt.Point; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import com.formdev.flatlaf.FlatDarkLaf; Loading @@ -13,6 +19,23 @@ import view.screen.MainScreen; public class MainFrame extends JFrame { public static final Cursor DEFAULT_BLANK_CURSOR; static { Toolkit toolkit = Toolkit.getDefaultToolkit(); try { BufferedImage bi; bi = ImageIO.read(MainFrame.class.getResourceAsStream("/assets/blank_cursor.png")); Image img = bi.getScaledInstance(30, 30, Image.SCALE_SMOOTH); DEFAULT_BLANK_CURSOR = toolkit.createCustomCursor(img, new Point(6, 3), "sheeeesh"); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Cannot load blank cursor"); } } private static MainFrame instance; public static MainFrame getInstance() { Loading @@ -29,6 +52,7 @@ public class MainFrame extends JFrame { FlatDarkLaf.setup(); this.setFrameIcon(); this.setCursor(DEFAULT_BLANK_CURSOR); this.setSize(1200, 800); this.setVisible(true); Loading @@ -36,14 +60,18 @@ public class MainFrame extends JFrame { } private void setFrameIcon() { try { InputStream stream = MainFrame.class.getResourceAsStream("/assets/icon.png"); // Scale down the image Image image = ImageIO.read(stream).getScaledInstance(25, 25, Image.SCALE_SMOOTH); setIconImage(image); } catch (Exception e) { } catch (Exception e) { e.printStackTrace(); } } Loading jeuAssemblage/src/view/component/board/Grid.java +9 −7 Changes for jeuAssemblage/src/view/component/board/Grid.java: 9 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -47,14 +47,14 @@ public class Grid extends JPanel { getWidthTimesPourcent(this,0.95f)/(this.controller.getWidthBoard()*1d) ); double paddingWidth = this.getWidth () - (componentSize * this.controller.getWidthBoard ()); double paddingHeight = this.getHeight() - (componentSize * this.controller.getHeightBoard()); int paddingWidth = this.getWidth () - (componentSize * this.controller.getWidthBoard ()); int paddingHeight = this.getHeight() - (componentSize * this.controller.getHeightBoard()); xGridDeb = (int) (paddingWidth / 2); yGridFin = (int) (paddingHeight / 2); xGridDeb = paddingWidth / 2; yGridDeb = paddingHeight / 2; xGridFin = (int) (getWidth() - paddingWidth / 2); yGridFin = (int) (getHeight() - paddingHeight / 2); xGridFin = getWidth() - paddingWidth / 2; yGridFin = getHeight() - paddingHeight / 2; Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.WHITE); Loading @@ -63,7 +63,7 @@ public class Grid extends JPanel { for ( int i = 0; i < matrices.length; i++) { int y = i * componentSize + (int) paddingHeight / 2; int y = i * componentSize + paddingHeight / 2; for ( int j = 0; j < matrices[i].length; j++) { Loading Loading @@ -159,6 +159,8 @@ public class Grid extends JPanel { int x = (int) ((e.getX() - xGridDeb) / ((xGridFin - xGridDeb) / grille[0].length)); int y = (int) ((e.getY() - yGridDeb) / ((yGridFin - yGridDeb) / grille.length)); System.out.println("Click on : " + x + " " + y); int pieceId = grille[y][x]; if (pieceId == 0 || (controller.getSelectedPiece() != null && pieceId == controller.getSelectedPiece().getInstanceId())) { Loading Loading
jeuAssemblage/src/model/PlayBoard.java +3 −0 Changes for jeuAssemblage/src/model/PlayBoard.java: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -285,6 +285,9 @@ public class PlayBoard { } private boolean canBeAddedToBoard(Piece p, int x, int y) { System.out.println("x : " + x + " y : " + y); if ( x + p.getWidth() > this.playBoard.length ) return false; if ( y + p.getHeight() > this.playBoard[0].length) return false; Loading
jeuAssemblage/src/view/MainFrame.java +29 −1 Changes for jeuAssemblage/src/view/MainFrame.java: 29 added lines, 1 removed line. Original line number Diff line number Diff line package view; import java.awt.Container; import java.awt.Cursor; import java.awt.Image; import java.awt.Point; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import com.formdev.flatlaf.FlatDarkLaf; Loading @@ -13,6 +19,23 @@ import view.screen.MainScreen; public class MainFrame extends JFrame { public static final Cursor DEFAULT_BLANK_CURSOR; static { Toolkit toolkit = Toolkit.getDefaultToolkit(); try { BufferedImage bi; bi = ImageIO.read(MainFrame.class.getResourceAsStream("/assets/blank_cursor.png")); Image img = bi.getScaledInstance(30, 30, Image.SCALE_SMOOTH); DEFAULT_BLANK_CURSOR = toolkit.createCustomCursor(img, new Point(6, 3), "sheeeesh"); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Cannot load blank cursor"); } } private static MainFrame instance; public static MainFrame getInstance() { Loading @@ -29,6 +52,7 @@ public class MainFrame extends JFrame { FlatDarkLaf.setup(); this.setFrameIcon(); this.setCursor(DEFAULT_BLANK_CURSOR); this.setSize(1200, 800); this.setVisible(true); Loading @@ -36,14 +60,18 @@ public class MainFrame extends JFrame { } private void setFrameIcon() { try { InputStream stream = MainFrame.class.getResourceAsStream("/assets/icon.png"); // Scale down the image Image image = ImageIO.read(stream).getScaledInstance(25, 25, Image.SCALE_SMOOTH); setIconImage(image); } catch (Exception e) { } catch (Exception e) { e.printStackTrace(); } } Loading
jeuAssemblage/src/view/component/board/Grid.java +9 −7 Changes for jeuAssemblage/src/view/component/board/Grid.java: 9 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -47,14 +47,14 @@ public class Grid extends JPanel { getWidthTimesPourcent(this,0.95f)/(this.controller.getWidthBoard()*1d) ); double paddingWidth = this.getWidth () - (componentSize * this.controller.getWidthBoard ()); double paddingHeight = this.getHeight() - (componentSize * this.controller.getHeightBoard()); int paddingWidth = this.getWidth () - (componentSize * this.controller.getWidthBoard ()); int paddingHeight = this.getHeight() - (componentSize * this.controller.getHeightBoard()); xGridDeb = (int) (paddingWidth / 2); yGridFin = (int) (paddingHeight / 2); xGridDeb = paddingWidth / 2; yGridDeb = paddingHeight / 2; xGridFin = (int) (getWidth() - paddingWidth / 2); yGridFin = (int) (getHeight() - paddingHeight / 2); xGridFin = getWidth() - paddingWidth / 2; yGridFin = getHeight() - paddingHeight / 2; Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.WHITE); Loading @@ -63,7 +63,7 @@ public class Grid extends JPanel { for ( int i = 0; i < matrices.length; i++) { int y = i * componentSize + (int) paddingHeight / 2; int y = i * componentSize + paddingHeight / 2; for ( int j = 0; j < matrices[i].length; j++) { Loading Loading @@ -159,6 +159,8 @@ public class Grid extends JPanel { int x = (int) ((e.getX() - xGridDeb) / ((xGridFin - xGridDeb) / grille[0].length)); int y = (int) ((e.getY() - yGridDeb) / ((yGridFin - yGridDeb) / grille.length)); System.out.println("Click on : " + x + " " + y); int pieceId = grille[y][x]; if (pieceId == 0 || (controller.getSelectedPiece() != null && pieceId == controller.getSelectedPiece().getInstanceId())) { Loading