Correction de l'arrière plan dans comment jouer.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
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.*;
|
||||
@@ -23,54 +22,76 @@ public class TutorialPanel extends JPanel {
|
||||
this.steps = steps;
|
||||
this.currentStepIndex = 0;
|
||||
|
||||
// Setup the panel layout
|
||||
// Utiliser BorderLayout pour la disposition principale
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
// Background setup
|
||||
setupBackground();
|
||||
|
||||
// Setup the title
|
||||
title = new Title("Tutoriel", 70f, Color.BLACK);
|
||||
// Création du titre centré en haut
|
||||
title = new Title("Comment jouer ?", 70f, Color.WHITE);
|
||||
title.setHorizontalAlignment(JLabel.CENTER);
|
||||
title.setOpaque(false);
|
||||
add(title, BorderLayout.NORTH);
|
||||
|
||||
// Step text and image container
|
||||
// Conteneur principal pour les étapes, centré
|
||||
JPanel centerPanel = new JPanel();
|
||||
centerPanel.setLayout(new GridBagLayout());
|
||||
centerPanel.setOpaque(false); // Rendre le conteneur transparent
|
||||
|
||||
// Utiliser GridBagConstraints pour centrer le contenu verticalement
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc.insets = new Insets(10, 0, 10, 0);
|
||||
|
||||
// Conteneur pour le texte et l'image
|
||||
JPanel stepContainer = new JPanel();
|
||||
stepContainer.setLayout(new BoxLayout(stepContainer, BoxLayout.Y_AXIS)); // Vertical BoxLayout
|
||||
stepContainer.setLayout(new BoxLayout(stepContainer, BoxLayout.Y_AXIS));
|
||||
stepContainer.setOpaque(false); // Transparent
|
||||
|
||||
stepText = new JLabel();
|
||||
stepText.setFont(new Font("Arial", Font.PLAIN, 18));
|
||||
stepText.setFont(new Font("Arial", Font.BOLD, 28));
|
||||
stepText.setForeground(Color.WHITE);
|
||||
stepText.setAlignmentX(Component.CENTER_ALIGNMENT); // Centrer le texte horizontalement
|
||||
|
||||
stepImage = new JLabel();
|
||||
stepImage.setAlignmentX(Component.CENTER_ALIGNMENT); // Centrer l'image horizontalement
|
||||
|
||||
// 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
|
||||
// Ajouter les composants au conteneur d'étapes
|
||||
stepContainer.add(stepText);
|
||||
stepContainer.add(Box.createVerticalStrut(10)); // Optional space between text and image
|
||||
stepContainer.add(Box.createVerticalStrut(10)); // Espace entre texte et image
|
||||
stepContainer.add(stepImage);
|
||||
add(stepContainer, BorderLayout.CENTER);
|
||||
|
||||
// Navigation buttons
|
||||
// Ajouter le conteneur d'étapes au centre du panel
|
||||
centerPanel.add(stepContainer, gbc);
|
||||
add(centerPanel, BorderLayout.CENTER);
|
||||
|
||||
// Panneau pour les boutons de navigation
|
||||
JPanel buttonPanel = new JPanel();
|
||||
buttonPanel.setLayout(new FlowLayout());
|
||||
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); // Centrer les boutons
|
||||
buttonPanel.setOpaque(false); // Transparent
|
||||
|
||||
prevButton = new JButton("Précédent");
|
||||
nextButton = new JButton("Suivant");
|
||||
prevButton.addActionListener(e -> showPreviousStep());
|
||||
nextButton.addActionListener(e -> showNextStep());
|
||||
buttonPanel.add(prevButton);
|
||||
buttonPanel.add(nextButton);
|
||||
|
||||
// Ajouter le panneau des boutons en bas
|
||||
add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
// Initial step display
|
||||
// Affichage initial de l'étape
|
||||
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);
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g); // Appel à super pour s'assurer que le panneau est dessiné
|
||||
|
||||
// Dessin de l'image de fond pour couvrir tout le panneau
|
||||
ImageIcon backgroundImage = new ImageIcon("./ressources/images/MainMenu/backgroundBlured.jpg");
|
||||
Image image = backgroundImage.getImage();
|
||||
g.drawImage(image, 0, 0, getWidth(), getHeight(), this); // Dessiner l'image pour couvrir tout le panneau
|
||||
}
|
||||
|
||||
private void updateStepDisplay() {
|
||||
|
Reference in New Issue
Block a user