From 848c446ee5294ee5334d1aba0f542b5b59ebf9c1 Mon Sep 17 00:00:00 2001 From: Lenny FOULOU Date: Sat, 16 Nov 2024 00:42:03 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/fr/monkhanny/dorfromantik/Main.java | 10 ++++-- .../controller/MainMenuButtonController.java | 36 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/TestV2/src/fr/monkhanny/dorfromantik/Main.java b/TestV2/src/fr/monkhanny/dorfromantik/Main.java index 6980157..b60f67c 100644 --- a/TestV2/src/fr/monkhanny/dorfromantik/Main.java +++ b/TestV2/src/fr/monkhanny/dorfromantik/Main.java @@ -8,6 +8,8 @@ import fr.monkhanny.dorfromantik.enums.Musics; import fr.monkhanny.dorfromantik.listeners.CloseWindowListener; import fr.monkhanny.dorfromantik.gui.SettingsPanel; import fr.monkhanny.dorfromantik.controller.TutorialController; +import fr.monkhanny.dorfromantik.controller.GameModeController; +import fr.monkhanny.dorfromantik.gui.GameModeSelectionPanel; import javax.swing.JFrame; @@ -54,8 +56,10 @@ public class Main { howToPlayFrame.addWindowListener(howToPlayWindowListener); howToPlayFrame.add(tutorialController.getTutorialPanel()); - // Fenêtre du jeu - gameFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - + // Fenêtre du choix des modes de jeu + GameModeController gameModeController = new GameModeController(); + GameModeSelectionPanel gameModeSelectionPanel = new GameModeSelectionPanel(gameModeController); + gameModeController.setGameModeSelectionPanel(gameModeSelectionPanel); + gameFrame.add(gameModeSelectionPanel); } } diff --git a/TestV2/src/fr/monkhanny/dorfromantik/controller/MainMenuButtonController.java b/TestV2/src/fr/monkhanny/dorfromantik/controller/MainMenuButtonController.java index c7940c6..ea6873f 100644 --- a/TestV2/src/fr/monkhanny/dorfromantik/controller/MainMenuButtonController.java +++ b/TestV2/src/fr/monkhanny/dorfromantik/controller/MainMenuButtonController.java @@ -5,7 +5,6 @@ import fr.monkhanny.dorfromantik.gui.SettingsPanel; import fr.monkhanny.dorfromantik.gui.MainMenu; import fr.monkhanny.dorfromantik.gui.ButtonPanel; import fr.monkhanny.dorfromantik.listeners.CloseWindowListener; -import fr.monkhanny.dorfromantik.gui.GameModeSelectionPanel; import javax.swing.*; import java.awt.event.ActionEvent; @@ -19,9 +18,9 @@ public class MainMenuButtonController implements ActionListener { private JFrame settingsFrame; private JFrame howToPlayFrame; - private JFrame gameFrame; + private JFrame gameModeFrame; - public MainMenuButtonController(MainMenu mainMenu, JFrame settingsFrame, JFrame howToPlayFrame, JFrame gameFrame) { + public MainMenuButtonController(MainMenu mainMenu, JFrame settingsFrame, JFrame howToPlayFrame, JFrame gameModeFrame) { this.mainMenu = mainMenu; // Ajouter les écouteurs d'événements sur les boutons ButtonPanel buttonPanel = mainMenu.getButtonPanel(); @@ -46,10 +45,10 @@ public class MainMenuButtonController implements ActionListener { this.howToPlayFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // 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); + this.gameModeFrame = gameModeFrame; + this.gameModeFrame.setLocationRelativeTo(null); + this.gameModeFrame.setVisible(false); + this.gameModeFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } @@ -80,22 +79,19 @@ public class MainMenuButtonController implements ActionListener { } public void startNewGame() { - // Créer un contrôleur pour le mode de jeu - GameModeController gameModeController = new GameModeController(); + // 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(); - // Créer le panneau de sélection de mode de jeu - GameModeSelectionPanel gameModeSelectionPanel = new GameModeSelectionPanel(gameModeController); + // 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); - // Associer le panneau au contrôleur - gameModeController.setGameModeSelectionPanel(gameModeSelectionPanel); + // Cacher la fenêtre du menu principal + this.mainMenu.setVisible(false); - // Créer une nouvelle fenêtre pour la sélection de mode de jeu - JFrame gameModeFrame = new JFrame("Sélectionnez un mode de jeu"); - gameModeFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - gameModeFrame.setSize(600, 400); - gameModeFrame.setLocationRelativeTo(null); - gameModeFrame.add(gameModeSelectionPanel); - gameModeFrame.setVisible(true); + // Afficher la fenêtre des paramètres + this.gameModeFrame.setVisible(true); }