Amélioration du code
This commit is contained in:
BIN
TestV2/libs/mariadb-client.jar
Normal file
BIN
TestV2/libs/mariadb-client.jar
Normal file
Binary file not shown.
@@ -55,4 +55,6 @@ public class Options {
|
||||
public static boolean AUTO_FOCUS = true;
|
||||
|
||||
public static final int MAX_TILE_NUMBER = 50;
|
||||
|
||||
public static boolean FULL_SCREEN = false;
|
||||
}
|
||||
|
@@ -35,30 +35,31 @@ public class MainMenuButtonController implements ActionListener {
|
||||
|
||||
// Paramètrage de la fenêtre des paramètres
|
||||
this.settingsFrame = settingsFrame;
|
||||
this.settingsFrame.setLocationRelativeTo(null);
|
||||
this.settingsFrame.setVisible(false);
|
||||
this.settingsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
configureFrame(settingsFrame);
|
||||
|
||||
// Paramètrage de la fenêtre du tutoriel
|
||||
this.howToPlayFrame = howToPlayFrame;
|
||||
this.howToPlayFrame.setLocationRelativeTo(null);
|
||||
this.howToPlayFrame.setVisible(false);
|
||||
this.howToPlayFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
configureFrame(howToPlayFrame);
|
||||
|
||||
|
||||
// Paramètrage de la fenêtre du jeu
|
||||
this.gameModeFrame = gameModeFrame;
|
||||
this.gameModeFrame.setLocationRelativeTo(null);
|
||||
this.gameModeFrame.setVisible(false);
|
||||
this.gameModeFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
configureFrame(gameModeFrame);
|
||||
|
||||
|
||||
// Paramètrage de la fenêtre du jeu
|
||||
this.gameFrame = gameFrame;
|
||||
this.gameFrame.setLocationRelativeTo(null);
|
||||
this.gameFrame.setVisible(false);
|
||||
this.gameFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
configureFrame(gameFrame);
|
||||
|
||||
}
|
||||
|
||||
private void configureFrame(JFrame frame) {
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(false);
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String command = e.getActionCommand();
|
||||
@@ -86,21 +87,8 @@ public class MainMenuButtonController implements ActionListener {
|
||||
}
|
||||
|
||||
public void startNewGame() {
|
||||
// Récupérer la taille et la position de la fenêtre du menu principal
|
||||
Dimension mainMenuSize = this.mainMenu.getSize();
|
||||
Point mainMenuLocation = this.mainMenu.getLocation();
|
||||
|
||||
// Ajuster la fenêtre des paramètres pour qu'elle ait la même taille et position
|
||||
this.gameModeFrame.setSize(mainMenuSize);
|
||||
this.gameModeFrame.setLocation(mainMenuLocation);
|
||||
|
||||
this.gameFrame.setSize(mainMenuSize);
|
||||
this.gameFrame.setLocation(mainMenuLocation);
|
||||
|
||||
// Cacher la fenêtre du menu principal
|
||||
adjustFrameDisplay(this.gameModeFrame);
|
||||
this.mainMenu.setVisible(false);
|
||||
|
||||
// Afficher la fenêtre des paramètres
|
||||
this.gameModeFrame.setVisible(true);
|
||||
}
|
||||
|
||||
@@ -110,18 +98,8 @@ public class MainMenuButtonController implements ActionListener {
|
||||
}
|
||||
|
||||
public void showHowToPlay() {
|
||||
// Récupérer la taille et la position de la fenêtre du menu principal
|
||||
Dimension mainMenuSize = this.mainMenu.getSize();
|
||||
Point mainMenuLocation = this.mainMenu.getLocation();
|
||||
|
||||
// Ajuster la fenêtre des paramètres pour qu'elle ait la même taille et position
|
||||
this.howToPlayFrame.setSize(mainMenuSize);
|
||||
this.howToPlayFrame.setLocation(mainMenuLocation);
|
||||
|
||||
// Cacher la fenêtre du menu principal
|
||||
adjustFrameDisplay(this.howToPlayFrame);
|
||||
this.mainMenu.setVisible(false);
|
||||
|
||||
// Afficher la fenêtre des paramètres
|
||||
this.howToPlayFrame.setVisible(true);
|
||||
}
|
||||
|
||||
@@ -131,18 +109,23 @@ public class MainMenuButtonController implements ActionListener {
|
||||
}
|
||||
|
||||
private void openSettings() {
|
||||
adjustFrameDisplay(this.settingsFrame);
|
||||
this.mainMenu.setVisible(false);
|
||||
this.settingsFrame.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
private void adjustFrameDisplay(JFrame frame) {
|
||||
if (Options.FULL_SCREEN) {
|
||||
frame.setExtendedState(JFrame.MAXIMIZED_BOTH); // Mettre la fenêtre en plein écran
|
||||
frame.setUndecorated(true); // Retirer la décoration de la fenêtre
|
||||
} else {
|
||||
// Récupérer la taille et la position de la fenêtre du menu principal
|
||||
Dimension mainMenuSize = this.mainMenu.getSize();
|
||||
Point mainMenuLocation = this.mainMenu.getLocation();
|
||||
|
||||
// Ajuster la fenêtre des paramètres pour qu'elle ait la même taille et position
|
||||
this.settingsFrame.setSize(mainMenuSize);
|
||||
this.settingsFrame.setLocation(mainMenuLocation);
|
||||
|
||||
// Cacher la fenêtre du menu principal
|
||||
this.mainMenu.setVisible(false);
|
||||
|
||||
// Afficher la fenêtre des paramètres
|
||||
this.settingsFrame.setVisible(true);
|
||||
frame.setSize(mainMenuSize);
|
||||
frame.setLocation(mainMenuLocation);
|
||||
frame.setUndecorated(false); // Restaurer la décoration si nécessaire
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user