diff --git a/TestV2/ressources/images/Tutorial/Gif1.gif b/TestV2/ressources/images/Tutorial/Gif1.gif new file mode 100644 index 0000000..f985094 Binary files /dev/null and b/TestV2/ressources/images/Tutorial/Gif1.gif differ diff --git a/TestV2/ressources/images/Tutorial/Gif2.gif b/TestV2/ressources/images/Tutorial/Gif2.gif new file mode 100644 index 0000000..c208dad Binary files /dev/null and b/TestV2/ressources/images/Tutorial/Gif2.gif differ diff --git a/TestV2/ressources/images/Tutorial/Gif3.gif b/TestV2/ressources/images/Tutorial/Gif3.gif new file mode 100644 index 0000000..b951744 Binary files /dev/null and b/TestV2/ressources/images/Tutorial/Gif3.gif differ diff --git a/TestV2/ressources/images/Tutorial/Gif4.gif b/TestV2/ressources/images/Tutorial/Gif4.gif new file mode 100644 index 0000000..512511d Binary files /dev/null and b/TestV2/ressources/images/Tutorial/Gif4.gif differ diff --git a/TestV2/src/fr/monkhanny/dorfromantik/Main.java b/TestV2/src/fr/monkhanny/dorfromantik/Main.java index d121acf..87c616a 100644 --- a/TestV2/src/fr/monkhanny/dorfromantik/Main.java +++ b/TestV2/src/fr/monkhanny/dorfromantik/Main.java @@ -7,6 +7,7 @@ import fr.monkhanny.dorfromantik.utils.MusicPlayer; import fr.monkhanny.dorfromantik.enums.Musics; import fr.monkhanny.dorfromantik.listeners.SettingsWindowListener; import fr.monkhanny.dorfromantik.gui.SettingsPanel; +import fr.monkhanny.dorfromantik.controller.TutorialController; import javax.swing.JFrame; @@ -26,12 +27,15 @@ public class Main { // Créer la fenêtre des paramètres JFrame settingsFrame = new JFrame("Paramètres"); + // Créer la fenêtre du tutoriel + JFrame howToPlayFrame = new JFrame("Tutoriel"); + // Menu principal MusicPlayer.loadMusic(Musics.MAIN_MENU_MUSIC); MusicPlayer.playMusic(); MainMenu mainMenu = new MainMenu(); MainMenuResizeController MainMenuResizeController = new MainMenuResizeController(mainMenu); - MainMenuButtonController MainMenuButtonController = new MainMenuButtonController(mainMenu,settingsFrame); + MainMenuButtonController MainMenuButtonController = new MainMenuButtonController(mainMenu,settingsFrame,howToPlayFrame); // Fenêtre des paramètres @@ -41,5 +45,11 @@ public class Main { settingsFrame.add(settingsPanel); settingsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + // Fenêtre du tutoriel + TutorialController tutorialController = new TutorialController(); + howToPlayFrame.addWindowListener(windowListener); + howToPlayFrame.add(tutorialController.getTutorialPanel()); + howToPlayFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + } } diff --git a/TestV2/src/fr/monkhanny/dorfromantik/controller/MainMenuButtonController.java b/TestV2/src/fr/monkhanny/dorfromantik/controller/MainMenuButtonController.java index 611d3ed..8112540 100644 --- a/TestV2/src/fr/monkhanny/dorfromantik/controller/MainMenuButtonController.java +++ b/TestV2/src/fr/monkhanny/dorfromantik/controller/MainMenuButtonController.java @@ -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 } diff --git a/TestV2/src/fr/monkhanny/dorfromantik/controller/TutorialController.java b/TestV2/src/fr/monkhanny/dorfromantik/controller/TutorialController.java new file mode 100644 index 0000000..95fab47 --- /dev/null +++ b/TestV2/src/fr/monkhanny/dorfromantik/controller/TutorialController.java @@ -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 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; + } +} diff --git a/TestV2/src/fr/monkhanny/dorfromantik/enums/Images.java b/TestV2/src/fr/monkhanny/dorfromantik/enums/Images.java index 86ecb05..78ed6c5 100644 --- a/TestV2/src/fr/monkhanny/dorfromantik/enums/Images.java +++ b/TestV2/src/fr/monkhanny/dorfromantik/enums/Images.java @@ -2,7 +2,7 @@ package fr.monkhanny.dorfromantik.enums; public enum Images { - SETTINGS_ICON, EXIT_ICON; + SETTINGS_ICON, EXIT_ICON, TUTORIAL_GIF1, TUTORIAL_GIF2, TUTORIAL_GIF3, TUTORIAL_GIF4; public String getImagePath() { switch (this) { @@ -10,6 +10,14 @@ public enum Images { return "./ressources/images/Icone/SettingsIcon.png"; case EXIT_ICON: return "./ressources/images/Icone/ExitIcon.png"; + case TUTORIAL_GIF1: + return "./ressources/images/Tutorial/Gif1.gif"; + case TUTORIAL_GIF2: + return "./ressources/images/Tutorial/Gif2.gif"; + case TUTORIAL_GIF3: + return "./ressources/images/Tutorial/Gif3.gif"; + case TUTORIAL_GIF4: + return "./ressources/images/Tutorial/Gif4.gif"; default: throw new IllegalArgumentException("Unexpected value: " + this); } diff --git a/TestV2/src/fr/monkhanny/dorfromantik/gui/Step.java b/TestV2/src/fr/monkhanny/dorfromantik/gui/Step.java new file mode 100644 index 0000000..7ef7c2a --- /dev/null +++ b/TestV2/src/fr/monkhanny/dorfromantik/gui/Step.java @@ -0,0 +1,25 @@ +package fr.monkhanny.dorfromantik.gui; + +public class Step { + private String title; + private String text; + private String imagePath; + + public Step(String title, String text, String imagePath) { + this.title = title; + this.text = text; + this.imagePath = imagePath; + } + + public String getText() { + return text; + } + + public String getImagePath() { + return imagePath; + } + + public String getTitle() { + return title; + } +} diff --git a/TestV2/src/fr/monkhanny/dorfromantik/gui/TutorialPanel.java b/TestV2/src/fr/monkhanny/dorfromantik/gui/TutorialPanel.java new file mode 100644 index 0000000..fd8a4a6 --- /dev/null +++ b/TestV2/src/fr/monkhanny/dorfromantik/gui/TutorialPanel.java @@ -0,0 +1,99 @@ +package fr.monkhanny.dorfromantik.gui; + +import fr.monkhanny.dorfromantik.components.Title; +import fr.monkhanny.dorfromantik.controller.TutorialController; +import fr.monkhanny.dorfromantik.gui.Step; + +import javax.swing.*; +import java.awt.*; +import java.util.List; + +public class TutorialPanel extends JPanel { + + private List steps; + private int currentStepIndex; + + private Title title; + private JLabel stepText; + private JLabel stepImage; + private JButton nextButton; + private JButton prevButton; + + public TutorialPanel(List steps) { + this.steps = steps; + this.currentStepIndex = 0; + + // Setup the panel layout + setLayout(new BorderLayout()); + + // Background setup + setupBackground(); + + // Setup the title + title = new Title("Tutoriel", 70f, Color.BLACK); + add(title, BorderLayout.NORTH); + + // Step text and image container + JPanel stepContainer = new JPanel(); + stepContainer.setLayout(new BoxLayout(stepContainer, BoxLayout.Y_AXIS)); // Vertical BoxLayout + stepText = new JLabel(); + stepText.setFont(new Font("Arial", Font.PLAIN, 18)); + stepText.setForeground(Color.WHITE); + stepImage = new JLabel(); + + // Center the text and the image + stepText.setAlignmentX(Component.CENTER_ALIGNMENT); // Center the text horizontally + stepImage.setAlignmentX(Component.CENTER_ALIGNMENT); // Center the image horizontally + + // Add components to the stepContainer + stepContainer.add(stepText); + stepContainer.add(Box.createVerticalStrut(10)); // Optional space between text and image + stepContainer.add(stepImage); + add(stepContainer, BorderLayout.CENTER); + + // Navigation buttons + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new FlowLayout()); + prevButton = new JButton("Précédent"); + nextButton = new JButton("Suivant"); + prevButton.addActionListener(e -> showPreviousStep()); + nextButton.addActionListener(e -> showNextStep()); + buttonPanel.add(prevButton); + buttonPanel.add(nextButton); + add(buttonPanel, BorderLayout.SOUTH); + + // Initial step display + updateStepDisplay(); + } + + private void setupBackground() { + JLabel background = new JLabel(new ImageIcon("./ressources/images/MainMenu/backgroundBlured.jpg")); + background.setLayout(null); + background.setBounds(0, 0, getWidth(), getHeight()); + add(background, BorderLayout.CENTER); + } + + private void updateStepDisplay() { + Step currentStep = steps.get(currentStepIndex); + stepText.setText(currentStep.getText()); + stepImage.setIcon(new ImageIcon(currentStep.getImagePath())); + stepImage.setHorizontalAlignment(JLabel.CENTER); + stepImage.setVerticalAlignment(JLabel.CENTER); + prevButton.setEnabled(currentStepIndex > 0); + nextButton.setEnabled(currentStepIndex < steps.size() - 1); + } + + private void showPreviousStep() { + if (currentStepIndex > 0) { + currentStepIndex--; + updateStepDisplay(); + } + } + + private void showNextStep() { + if (currentStepIndex < steps.size() - 1) { + currentStepIndex++; + updateStepDisplay(); + } + } +}