88 lines
3.1 KiB
Java
88 lines
3.1 KiB
Java
|
package fr.monkhanny.dorfromantik.gui;
|
||
|
|
||
|
import fr.monkhanny.dorfromantik.utils.FontManager;
|
||
|
import fr.monkhanny.dorfromantik.components.Button;
|
||
|
import fr.monkhanny.dorfromantik.controller.MainMenuMouseController;
|
||
|
|
||
|
import javax.swing.*;
|
||
|
import java.util.List;
|
||
|
import java.util.Arrays;
|
||
|
|
||
|
|
||
|
public class ButtonPanel extends JPanel {
|
||
|
|
||
|
private JButton newGameButton;
|
||
|
private JButton continueGameButton;
|
||
|
private JButton howToPlayButton;
|
||
|
private JButton settingsButton;
|
||
|
private JButton exitButton;
|
||
|
|
||
|
public ButtonPanel(float fontSize) {
|
||
|
// Paramétrage de l'apparence du panneau
|
||
|
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||
|
this.setOpaque(false); // Rendre le panneau transparent
|
||
|
this.setBorder(BorderFactory.createEmptyBorder(50, 30, 30, 30)); // Marge à gauche et en bas
|
||
|
|
||
|
// Espacement vertical extensible pour centrer les boutons principaux verticalement
|
||
|
this.add(Box.createVerticalGlue());
|
||
|
|
||
|
// Créer les boutons avec un style personnalisé
|
||
|
newGameButton = Button.createCustomTextButton("Jouer", fontSize);
|
||
|
continueGameButton = Button.createCustomTextButton("Récompenses", fontSize);
|
||
|
howToPlayButton = Button.createCustomTextButton("Comment jouer ?", fontSize);
|
||
|
settingsButton = Button.createCustomTextButton("Paramètres", fontSize);
|
||
|
exitButton = Button.createCustomTextButton("Quitter", fontSize);
|
||
|
|
||
|
// Ajouter les boutons au panneau
|
||
|
this.add(newGameButton);
|
||
|
this.add(Box.createVerticalStrut(10)); // Espace entre les boutons
|
||
|
this.add(continueGameButton);
|
||
|
this.add(Box.createVerticalStrut(10));
|
||
|
this.add(howToPlayButton);
|
||
|
this.add(Box.createVerticalStrut(10));
|
||
|
this.add(settingsButton);
|
||
|
this.add(Box.createVerticalStrut(10));
|
||
|
this.add(exitButton);
|
||
|
|
||
|
// Espacement extensible pour maintenir les icônes en bas
|
||
|
this.add(Box.createVerticalGlue());
|
||
|
|
||
|
@SuppressWarnings("unused")
|
||
|
MainMenuMouseController gestionSouris = new MainMenuMouseController(this);
|
||
|
}
|
||
|
|
||
|
public JButton getNewGameButton() {
|
||
|
return newGameButton;
|
||
|
}
|
||
|
|
||
|
public JButton getContinueGameButton() {
|
||
|
return continueGameButton;
|
||
|
}
|
||
|
|
||
|
public JButton getHowToPlayButton() {
|
||
|
return howToPlayButton;
|
||
|
}
|
||
|
|
||
|
public JButton getSettingsButton() {
|
||
|
return settingsButton;
|
||
|
}
|
||
|
|
||
|
public JButton getExitButton() {
|
||
|
return exitButton;
|
||
|
}
|
||
|
|
||
|
public List<JButton> getButtons() {
|
||
|
return Arrays.asList(newGameButton, continueGameButton, howToPlayButton, settingsButton, exitButton);
|
||
|
}
|
||
|
|
||
|
public void updateButtonFonts(int windowWidth) {
|
||
|
// Mettre à jour la police des boutons avec la taille ajustée
|
||
|
float newFontSize = windowWidth / 30f;
|
||
|
newGameButton.setFont(FontManager.getTitleFont(newFontSize));
|
||
|
continueGameButton.setFont(FontManager.getTitleFont(newFontSize));
|
||
|
howToPlayButton.setFont(FontManager.getTitleFont(newFontSize));
|
||
|
settingsButton.setFont(FontManager.getTitleFont(newFontSize));
|
||
|
exitButton.setFont(FontManager.getTitleFont(newFontSize));
|
||
|
}
|
||
|
}
|