Modification des settings : ajout du focus mode
This commit is contained in:
@@ -64,15 +64,21 @@ public class SettingsPanel extends JPanel {
|
||||
JPanel mainPanel = new JPanel(new GridBagLayout());
|
||||
mainPanel.setOpaque(false);
|
||||
|
||||
// Section Musique
|
||||
JSlider musicSlider = new JSlider(0, 100, Options.MUSIC_MUTED ? 0 : Options.MUSIC_VOLUME);
|
||||
JPanel musicPanel = createSoundPanel("Musique", musicSlider, new MusicVolumeChangeListener(musicSlider), new MuteCheckBoxListener("Musique"));
|
||||
mainPanel.add(musicPanel, createGridBagConstraints(0, 0, 1));
|
||||
|
||||
// Section SFX
|
||||
JSlider sfxSlider = new JSlider(0, 100, Options.SOUNDS_MUTED ? 0 : Options.SOUNDS_VOLUME);
|
||||
JPanel sfxPanel = createSoundPanel("SFX", sfxSlider, new SoundsVolumeChangeListener(sfxSlider), new MuteCheckBoxListener("SFX"));
|
||||
mainPanel.add(sfxPanel, createGridBagConstraints(0, 1, 1));
|
||||
|
||||
mainPanel.add(Box.createVerticalStrut(30), createGridBagConstraints(0, 2, 1));
|
||||
// Section Auto Focus
|
||||
JPanel autoFocusPanel = createAutoFocusPanel();
|
||||
mainPanel.add(autoFocusPanel, createGridBagConstraints(0, 2, 1));
|
||||
|
||||
mainPanel.add(Box.createVerticalStrut(30), createGridBagConstraints(0, 3, 1));
|
||||
this.add(mainPanel, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
@@ -84,7 +90,7 @@ public class SettingsPanel extends JPanel {
|
||||
// Titre de la section (ex: "Musique" ou "SFX")
|
||||
JLabel titleLabel = new JLabel(labelText);
|
||||
titleLabel.setFont(new Font("Roboto", Font.BOLD, 30));
|
||||
titleLabel.setAlignmentX(Component.LEFT_ALIGNMENT); // Alignement à gauche
|
||||
titleLabel.setAlignmentX(Component.CENTER_ALIGNMENT); // Alignement à gauche
|
||||
panel.add(titleLabel);
|
||||
panel.add(Box.createVerticalStrut(10)); // Espacement vertical
|
||||
|
||||
@@ -135,6 +141,52 @@ public class SettingsPanel extends JPanel {
|
||||
return panel;
|
||||
}
|
||||
|
||||
private JPanel createAutoFocusPanel() {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); // Disposition verticale
|
||||
panel.setOpaque(false); // Assurer que le fond est transparent
|
||||
|
||||
// Titre de la section
|
||||
JLabel titleLabel = new JLabel("Focus Automatique");
|
||||
titleLabel.setFont(new Font("Roboto", Font.BOLD, 30));
|
||||
titleLabel.setAlignmentX(Component.CENTER_ALIGNMENT); // Aligner le texte au centre
|
||||
panel.add(titleLabel);
|
||||
panel.add(Box.createVerticalStrut(10)); // Espacement vertical
|
||||
|
||||
// Panneau contenant texte et case à cocher sur la même ligne
|
||||
JPanel checkBoxPanel = new JPanel();
|
||||
checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.X_AXIS)); // Disposition horizontale
|
||||
checkBoxPanel.setOpaque(false); // Assurer que le fond est transparent
|
||||
|
||||
// Texte explicatif avant la case à cocher
|
||||
JLabel descriptionLabel = new JLabel("Gestion du focus automatique :");
|
||||
descriptionLabel.setFont(new Font("Roboto", Font.PLAIN, 18));
|
||||
descriptionLabel.setAlignmentX(Component.LEFT_ALIGNMENT); // Aligner à gauche
|
||||
checkBoxPanel.add(descriptionLabel); // Ajouter le texte dans le panneau
|
||||
|
||||
// Ajouter un espace flexible entre le texte et la case à cocher
|
||||
checkBoxPanel.add(Box.createHorizontalGlue()); // Cela pousse la case à cocher vers la droite
|
||||
|
||||
// Case à cocher
|
||||
JCheckBox autoFocusCheckBox = new JCheckBox();
|
||||
autoFocusCheckBox.setFont(new Font("Roboto", Font.PLAIN, 18));
|
||||
autoFocusCheckBox.setFocusPainted(false);
|
||||
autoFocusCheckBox.setOpaque(false);
|
||||
autoFocusCheckBox.setBorderPainted(false);
|
||||
autoFocusCheckBox.setMargin(new Insets(5, 5, 5, 5));
|
||||
autoFocusCheckBox.setSelected(Options.AUTO_FOCUS); // État initial selon la valeur actuelle de AUTO_FOCUS
|
||||
autoFocusCheckBox.addActionListener(e -> {
|
||||
Options.AUTO_FOCUS = autoFocusCheckBox.isSelected(); // Mettre à jour la variable auto-focus
|
||||
});
|
||||
|
||||
checkBoxPanel.add(autoFocusCheckBox); // Ajouter la case à cocher
|
||||
|
||||
// Ajouter le panneau contenant texte + case à cocher
|
||||
panel.add(checkBoxPanel);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
private JPanel createSliderPanel(JSlider volumeSlider) {
|
||||
JPanel sliderPanel = new JPanel(new BorderLayout());
|
||||
|
Reference in New Issue
Block a user