Ajouts d'une page de tutoriel pour savoir comment jouer. ATTENTION, IL FAUT RAJOUTER LE BACKGROUND DE FOND
This commit is contained in:
25
TestV2/src/fr/monkhanny/dorfromantik/gui/Step.java
Normal file
25
TestV2/src/fr/monkhanny/dorfromantik/gui/Step.java
Normal file
@@ -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;
|
||||
}
|
||||
}
|
99
TestV2/src/fr/monkhanny/dorfromantik/gui/TutorialPanel.java
Normal file
99
TestV2/src/fr/monkhanny/dorfromantik/gui/TutorialPanel.java
Normal file
@@ -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<Step> steps;
|
||||
private int currentStepIndex;
|
||||
|
||||
private Title title;
|
||||
private JLabel stepText;
|
||||
private JLabel stepImage;
|
||||
private JButton nextButton;
|
||||
private JButton prevButton;
|
||||
|
||||
public TutorialPanel(List<Step> 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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user