ajout JAVADOC pour le repertoire gui
This commit is contained in:
@@ -9,18 +9,67 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Panneau d'interface utilisateur pour afficher le tutoriel du jeu.
|
||||
* Permet de naviguer entre différentes étapes (texte et image)
|
||||
* et de retourner au menu principal via un bouton de retour.
|
||||
* @version 1.0
|
||||
* @author Lenny FOULOU, Moncef STITI
|
||||
*/
|
||||
public class TutorialPanel extends JPanel {
|
||||
|
||||
/**
|
||||
* Liste des étapes du tutoriel.
|
||||
*/
|
||||
private List<Step> steps;
|
||||
|
||||
/**
|
||||
* Index de l'étape actuellement affichée.
|
||||
*/
|
||||
private int currentStepIndex;
|
||||
|
||||
/**
|
||||
* Titre affiché en haut du panneau.
|
||||
*/
|
||||
private Title title;
|
||||
|
||||
/**
|
||||
* Texte décrivant l'étape actuelle.
|
||||
*/
|
||||
private JLabel stepText;
|
||||
|
||||
/**
|
||||
* Image associée à l'étape actuelle.
|
||||
*/
|
||||
private JLabel stepImage;
|
||||
|
||||
/**
|
||||
* Bouton pour naviguer vers l'étape suivante.
|
||||
*/
|
||||
private JButton nextButton;
|
||||
|
||||
/**
|
||||
* Bouton pour naviguer vers l'étape précédente.
|
||||
*/
|
||||
private JButton prevButton;
|
||||
|
||||
/**
|
||||
* Instance du menu principal pour gérer le retour.
|
||||
*/
|
||||
private MainMenu mainMenu;
|
||||
|
||||
/**
|
||||
* Fenêtre actuelle contenant ce panneau.
|
||||
*/
|
||||
private JFrame tutorialFrame;
|
||||
|
||||
/**
|
||||
* Constructeur pour initialiser le panneau avec les étapes et les composants nécessaires.
|
||||
*
|
||||
* @param steps Liste des étapes du tutoriel.
|
||||
* @param mainMenu Instance du menu principal pour gérer le retour.
|
||||
* @param tutorialFrame Fenêtre contenant ce panneau.
|
||||
*/
|
||||
public TutorialPanel(List<Step> steps, MainMenu mainMenu, JFrame tutorialFrame) {
|
||||
this.steps = steps;
|
||||
this.currentStepIndex = 0;
|
||||
@@ -108,6 +157,11 @@ public class TutorialPanel extends JPanel {
|
||||
updateStepDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Redéfinit la méthode de dessin pour inclure un arrière-plan personnalisé.
|
||||
*
|
||||
* @param g Le contexte graphique.
|
||||
*/
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g); // Appel à super pour s'assurer que le panneau est dessiné
|
||||
@@ -118,6 +172,9 @@ public class TutorialPanel extends JPanel {
|
||||
g.drawImage(image, 0, 0, getWidth(), getHeight(), this); // Dessiner l'image pour couvrir tout le panneau
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour l'affichage des informations pour l'étape actuelle.
|
||||
*/
|
||||
private void updateStepDisplay() {
|
||||
Step currentStep = steps.get(currentStepIndex);
|
||||
String formattedText = addLineBreaks(currentStep.getText(), 10); // Limite à 10 mots par ligne
|
||||
@@ -129,7 +186,11 @@ public class TutorialPanel extends JPanel {
|
||||
nextButton.setEnabled(currentStepIndex < steps.size() - 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applique un style personnalisé aux boutons.
|
||||
*
|
||||
* @param button Le bouton à styliser.
|
||||
*/
|
||||
private void styleButton(JButton button) {
|
||||
// Police et taille
|
||||
button.setFont(new Font("Arial", Font.BOLD, 18));
|
||||
@@ -149,6 +210,9 @@ public class TutorialPanel extends JPanel {
|
||||
button.addMouseListener(new TutorialButtonHoverListener(button, new Color(60,60,60), new Color(34,34,34)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Affiche l'étape précédente du tutoriel si possible.
|
||||
*/
|
||||
private void showPreviousStep() {
|
||||
if (currentStepIndex > 0) {
|
||||
currentStepIndex--;
|
||||
@@ -156,6 +220,9 @@ public class TutorialPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Affiche l'étape suivante du tutoriel si possible.
|
||||
*/
|
||||
private void showNextStep() {
|
||||
if (currentStepIndex < steps.size() - 1) {
|
||||
currentStepIndex++;
|
||||
@@ -163,6 +230,11 @@ public class TutorialPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée un bouton de retour avec une icône personnalisée.
|
||||
*
|
||||
* @return Le bouton de retour configuré.
|
||||
*/
|
||||
private JButton createReturnButtonWithIcon() {
|
||||
ImageIcon originalIcon = new ImageIcon(Images.EXIT_ICON.getImagePath());
|
||||
|
||||
@@ -180,6 +252,13 @@ public class TutorialPanel extends JPanel {
|
||||
return returnButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute des retours à la ligne pour limiter le nombre de mots par ligne dans un texte.
|
||||
*
|
||||
* @param text Texte à formater.
|
||||
* @param maxWordsPerLine Nombre maximal de mots par ligne.
|
||||
* @return Texte formaté avec des retours à la ligne.
|
||||
*/
|
||||
private String addLineBreaks(String text, int maxWordsPerLine) {
|
||||
String[] words = text.split(" ");
|
||||
StringBuilder formattedText = new StringBuilder("<html>");
|
||||
|
Reference in New Issue
Block a user