Merge remote-tracking branch 'origin/Gwendal' into Thibaut
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
package org.Views;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.Models.Grille;
|
||||
@@ -15,18 +10,14 @@ import org.Models.PieceCourante;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Toolkit;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class VueGrille extends JFrame implements Observer, Runnable {
|
||||
public class VueGrille extends JPanel implements Observer, Runnable {
|
||||
private JPanel grillePanel;
|
||||
private Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
private double tailleJPanelX = screenSize.getHeight() / 4;
|
||||
private double tailleJPanelY = screenSize.getHeight() / 2;
|
||||
|
||||
private Grille grille;
|
||||
private Jeu jeu;
|
||||
@@ -34,12 +25,18 @@ public class VueGrille extends JFrame implements Observer, Runnable {
|
||||
|
||||
private boolean afficherFenetreFinPartie = false;
|
||||
|
||||
private Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
private double tailleJFrameX = screenSize.getHeight() / 2;
|
||||
private double tailleJFrameY = screenSize.getHeight();
|
||||
|
||||
public VueGrille(Grille grille, Jeu jeu) {
|
||||
this.grille = grille;
|
||||
this.jeu = jeu;
|
||||
setLayout(new BorderLayout());
|
||||
grillePanel = new JPanel(new GridLayout(grille.getNbLignes(), grille.getNbColonnes()));
|
||||
setSize((int) tailleJPanelX, (int) tailleJPanelY);
|
||||
setContentPane(grillePanel);
|
||||
setSize((int) tailleJFrameX, (int) tailleJFrameY);
|
||||
System.err.println("taille " + tailleJFrameX + " " + tailleJFrameY);
|
||||
add(this.grillePanel, BorderLayout.CENTER);
|
||||
initialiserVueGrille();
|
||||
|
||||
grille.addObserver(this);
|
||||
@@ -57,10 +54,6 @@ public class VueGrille extends JFrame implements Observer, Runnable {
|
||||
grillePanel.add(caseG);
|
||||
}
|
||||
}
|
||||
setVisible(true);
|
||||
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setTitle("TETRIS");
|
||||
}
|
||||
|
||||
public synchronized void updateGrille() {
|
||||
@@ -104,32 +97,8 @@ public class VueGrille extends JFrame implements Observer, Runnable {
|
||||
repaint();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void afficherFinPartie() {
|
||||
JDialog gameOverDialog = new JDialog(this, "Partie terminée", true);
|
||||
gameOverDialog.setLayout(new BorderLayout());
|
||||
|
||||
gameOverDialog.setUndecorated(true);
|
||||
|
||||
gameOverDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
|
||||
|
||||
JLabel gameOverLabel = new JLabel("GAME OVER", JLabel.CENTER);
|
||||
gameOverLabel.setFont(new Font("Arial", Font.BOLD, 50));
|
||||
gameOverLabel.setForeground(Color.RED);
|
||||
gameOverLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
||||
|
||||
gameOverDialog.add(gameOverLabel, BorderLayout.CENTER);
|
||||
|
||||
JButton quitButton = new JButton("Quitter");
|
||||
quitButton.addActionListener(e -> System.exit(0));
|
||||
|
||||
JPanel buttonPanel = new JPanel();
|
||||
buttonPanel.add(quitButton);
|
||||
gameOverDialog.add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
gameOverDialog.pack();
|
||||
gameOverDialog.setLocationRelativeTo(this);
|
||||
gameOverDialog.setVisible(true);
|
||||
System.err.println("FIN PARTIE"); // TODO : gerer affichage ?
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user