Ajouts d'une page de tutoriel pour savoir comment jouer. ATTENTION, IL FAUT RAJOUTER LE BACKGROUND DE FOND

This commit is contained in:
2024-11-13 20:10:27 +01:00
parent 8a27da6bd1
commit b3d49aea11
10 changed files with 193 additions and 6 deletions

View File

@@ -17,8 +17,9 @@ public class MainMenuButtonController implements ActionListener {
private MainMenu mainMenu;
private JFrame settingsFrame;
private JFrame howToPlayFrame;
public MainMenuButtonController(MainMenu mainMenu, JFrame settingsFrame) {
public MainMenuButtonController(MainMenu mainMenu, JFrame settingsFrame, JFrame howToPlayFrame) {
this.mainMenu = mainMenu;
// Ajouter les écouteurs d'événements sur les boutons
ButtonPanel buttonPanel = mainMenu.getButtonPanel();
@@ -34,6 +35,11 @@ public class MainMenuButtonController implements ActionListener {
this.settingsFrame = settingsFrame;
this.settingsFrame.setLocationRelativeTo(null);
this.settingsFrame.setVisible(false);
// Créer la fenêtre du tutoriel
this.howToPlayFrame = howToPlayFrame;
this.howToPlayFrame.setLocationRelativeTo(null);
this.howToPlayFrame.setVisible(false);
}
@Override
@@ -72,11 +78,23 @@ public class MainMenuButtonController implements ActionListener {
// Logic to continue the game
}
private void showHowToPlay() {
System.out.println("Afficher comment jouer...");
// Logic to show how to play
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
this.mainMenu.setVisible(false);
// Afficher la fenêtre des paramètres
this.howToPlayFrame.setVisible(true);
}
private void exitGame() {
System.exit(0); // Fermer l'application
}

View File

@@ -0,0 +1,27 @@
package fr.monkhanny.dorfromantik.controller;
import fr.monkhanny.dorfromantik.gui.TutorialPanel;
import fr.monkhanny.dorfromantik.gui.Step;
import fr.monkhanny.dorfromantik.enums.Images;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
public class TutorialController {
private TutorialPanel tutorialPanel;
public TutorialController() {
List<Step> steps = new ArrayList<>();
steps.add(new Step("Étape 1", "Explication de la première étape.", Images.TUTORIAL_GIF1.getImagePath()));
steps.add(new Step("Étape 2", "Explication de la deuxième étape.", Images.TUTORIAL_GIF2.getImagePath()));
steps.add(new Step("Étape 3", "Explication de la troisième étape.", Images.TUTORIAL_GIF3.getImagePath()));
steps.add(new Step("Étape 4", "Explication de la quatrième étape.", Images.TUTORIAL_GIF4.getImagePath()));
tutorialPanel = new TutorialPanel(steps);
}
public JPanel getTutorialPanel() {
return tutorialPanel;
}
}