Rangement
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
package fr.monkhanny.dorfromantik.game;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import javax.swing.*;
|
||||
|
||||
public class BarChartPanel extends JPanel {
|
||||
private List<Integer> groupAverages;
|
||||
private int highlightedGroup;
|
||||
|
||||
public BarChartPanel(List<Integer> groupAverages, int highlightedGroup, JPanel mainPanel) {
|
||||
this.groupAverages = groupAverages;
|
||||
this.highlightedGroup = highlightedGroup;
|
||||
|
||||
// Rendre le fond transparent et ajouter une bordure noire
|
||||
setBackground(new Color(0, 0, 0, 0)); // Fond transparent
|
||||
setAlignmentX(Component.CENTER_ALIGNMENT); // Centrer horizontalement
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
int barWidth = width / (groupAverages.size() + 1); // Espacement entre les groupes
|
||||
int maxScore = groupAverages.stream().max(Integer::compare).orElse(0);
|
||||
|
||||
// Dessiner les barres et leurs étiquettes (moyennes des scores)
|
||||
for (int i = 0; i < groupAverages.size(); i++) {
|
||||
int barHeight = (int) ((double) groupAverages.get(i) / maxScore * (height - 50)); // Ajuster la hauteur des barres
|
||||
int xPosition = (i + 1) * barWidth; // Espacement entre les groupes
|
||||
|
||||
// Appliquer une couleur de barre (mettre en évidence le groupe du joueur en rouge, les autres en bleu)
|
||||
if (i == highlightedGroup) {
|
||||
g.setColor(new Color(204, 0, 0)); // Couleur rouge pour le groupe du joueur
|
||||
} else {
|
||||
g.setColor(new Color(0, 0, 204)); // Bleu pour les autres groupes
|
||||
}
|
||||
|
||||
// Ajouter des ombres à la barre pour un effet 3D
|
||||
g.fillRect(xPosition, height - barHeight - 30, barWidth - 5, barHeight);
|
||||
g.setColor(new Color(0, 0, 0, 60)); // Ombre
|
||||
g.fillRect(xPosition + 2, height - barHeight - 28, barWidth - 5, barHeight);
|
||||
|
||||
// Dessiner le texte (moyenne) au-dessus de chaque barre
|
||||
String avgScoreText = String.valueOf(groupAverages.get(i));
|
||||
FontMetrics metrics = g.getFontMetrics();
|
||||
int textWidth = metrics.stringWidth(avgScoreText);
|
||||
int textX = xPosition + (barWidth - textWidth) / 2; // Centrer le texte
|
||||
int textY = height - barHeight - 35; // Placer le texte juste au-dessus de la barre
|
||||
|
||||
g.setColor(Color.BLACK); // Couleur du texte
|
||||
g.drawString(avgScoreText, textX, textY);
|
||||
|
||||
// Ajouter un label pour préciser que c'est la "moyenne"
|
||||
g.setFont(new Font("Arial", Font.ITALIC, 12)); // Police italique plus petite pour le label "Moyenne"
|
||||
String label = "Score moyen : ";
|
||||
int labelWidth = metrics.stringWidth(label);
|
||||
g.drawString(label, xPosition + (barWidth - labelWidth) / 2, textY - 15); // Placer "Moyenne" au-dessus du score
|
||||
|
||||
// Dessiner l'étiquette de groupe (Groupe 1, Groupe 2, ...)
|
||||
String groupLabel = "Groupe " + (i + 1);
|
||||
g.setColor(Color.BLACK);
|
||||
g.setFont(new Font("Arial", Font.PLAIN, 14)); // Police plus petite pour les étiquettes
|
||||
int groupLabelWidth = g.getFontMetrics().stringWidth(groupLabel);
|
||||
g.drawString(groupLabel, xPosition + (barWidth - groupLabelWidth) / 2, height - 10); // Positionner l'étiquette sous la barre
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -9,6 +9,8 @@ import fr.monkhanny.dorfromantik.Options;
|
||||
import fr.monkhanny.dorfromantik.enums.Biome;
|
||||
import fr.monkhanny.dorfromantik.enums.Fonts;
|
||||
import fr.monkhanny.dorfromantik.enums.TileOrientation;
|
||||
import fr.monkhanny.dorfromantik.gui.GameControlsMenu;
|
||||
import fr.monkhanny.dorfromantik.gui.GameOver;
|
||||
import fr.monkhanny.dorfromantik.utils.Database;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,7 +41,7 @@ public class Board extends JPanel{
|
||||
private Database database;
|
||||
private RemainingTilesIndicator remainingTilesIndicator;
|
||||
private ScoreDisplay scoreDisplay;
|
||||
private ControlsMenu controlsMenu;
|
||||
private GameControlsMenu controlsMenu;
|
||||
|
||||
|
||||
// Constructeur avec seed
|
||||
@@ -82,7 +84,7 @@ public class Board extends JPanel{
|
||||
this.addMouseMotionListener(new CustomMouseMotionAdapter(this));
|
||||
|
||||
// Ajouter le menu des contrôles
|
||||
controlsMenu = new ControlsMenu();
|
||||
controlsMenu = new GameControlsMenu();
|
||||
setLayout(null); // Utiliser un layout absolu pour placer le menu
|
||||
|
||||
// Ajouter le menu au panneau principal
|
||||
@@ -93,7 +95,7 @@ public class Board extends JPanel{
|
||||
gameFrame.addKeyListener(new CustomKeyAdapter(this));
|
||||
}
|
||||
|
||||
public ControlsMenu getControlsMenu() {
|
||||
public GameControlsMenu getControlsMenu() {
|
||||
return controlsMenu;
|
||||
}
|
||||
|
||||
|
@@ -1,104 +0,0 @@
|
||||
package fr.monkhanny.dorfromantik.game;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.net.URL;
|
||||
|
||||
public class ControlsMenu extends JPanel {
|
||||
private boolean isVisible = true;
|
||||
|
||||
// Chemin de base pour les icônes
|
||||
private static final String ICON_PATH = "/ressources/images/Icone/Keyboard-Mouse/";
|
||||
|
||||
public ControlsMenu() {
|
||||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // Mise en page verticale
|
||||
setBackground(new Color(0, 0, 0, 150)); // Fond semi-transparent
|
||||
|
||||
// Augmenter la taille du menu
|
||||
setPreferredSize(new Dimension(350, 400)); // Taille du menu augmentée
|
||||
|
||||
// Ajouter des instructions avec des icônes pour chaque touche
|
||||
add(createPanel("Cacher/Montrer ce menu", "t.png"));
|
||||
add(createPanelWithMultipleIcons("Zoom avant/arrière", "ctrl.png", "mouse-middle.png"));
|
||||
add(createPanel("Déplacer le plateau", "keyboard-arrows.png"));
|
||||
add(createPanel("Ajuster la vue", "space.png"));
|
||||
add(createPanel("Placer une tuile", "mouse-left.png"));
|
||||
add(createPanel("Afficher le menu de pause", "esc.png"));
|
||||
|
||||
// Rendre le texte plus lisible
|
||||
setForeground(Color.WHITE);
|
||||
}
|
||||
|
||||
// Crée un JPanel avec l'icône et le texte aligné horizontalement
|
||||
private JPanel createPanel(String text, String iconName) {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5)); // Alignement à gauche
|
||||
panel.setOpaque(false); // Transparent pour le fond
|
||||
|
||||
// Ajouter l'icône redimensionnée
|
||||
JLabel iconLabel = new JLabel(loadIcon(iconName));
|
||||
panel.add(iconLabel);
|
||||
|
||||
// Ajouter le texte avec une taille de police plus grande
|
||||
JLabel textLabel = new JLabel(text);
|
||||
textLabel.setForeground(Color.WHITE);
|
||||
textLabel.setFont(new Font("Arial", Font.PLAIN, 18)); // Augmenter la taille de la police
|
||||
panel.add(textLabel);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
// Crée un JPanel avec plusieurs icônes et un texte, en ajoutant un "+" entre les icônes
|
||||
private JPanel createPanelWithMultipleIcons(String text, String... iconNames) {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5)); // Alignement à gauche
|
||||
panel.setOpaque(false); // Transparent pour le fond
|
||||
|
||||
// Ajouter les icônes et le signe "+" entre elles
|
||||
for (int i = 0; i < iconNames.length; i++) {
|
||||
JLabel iconLabel = new JLabel(loadIcon(iconNames[i]));
|
||||
panel.add(iconLabel);
|
||||
|
||||
// Si ce n'est pas la dernière icône, ajouter un "+" entre les icônes
|
||||
if (i < iconNames.length - 1) {
|
||||
JLabel plusLabel = new JLabel("+");
|
||||
plusLabel.setForeground(Color.WHITE); // Vous pouvez aussi styliser le "+"
|
||||
panel.add(plusLabel);
|
||||
}
|
||||
}
|
||||
|
||||
// Ajouter le texte avec une taille de police plus grande
|
||||
JLabel textLabel = new JLabel(text);
|
||||
textLabel.setForeground(Color.WHITE);
|
||||
textLabel.setFont(new Font("Arial", Font.PLAIN, 18)); // Augmenter la taille de la police
|
||||
panel.add(textLabel);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
// Charge l'icône depuis le répertoire spécifié et la redimensionne
|
||||
private ImageIcon loadIcon(String iconName) {
|
||||
// Utilisation de getClass().getResource() pour charger l'icône depuis le classpath
|
||||
URL iconURL = getClass().getResource(ICON_PATH + iconName);
|
||||
if (iconURL != null) {
|
||||
ImageIcon icon = new ImageIcon(iconURL);
|
||||
Image img = icon.getImage();
|
||||
// Redimensionner l'image à une taille plus grande
|
||||
Image scaledImg = img.getScaledInstance(55, 55, Image.SCALE_SMOOTH); // Augmenter la taille des icônes
|
||||
return new ImageIcon(scaledImg);
|
||||
} else {
|
||||
System.out.println("Icone non trouvée : " + iconName);
|
||||
return new ImageIcon();
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleVisibility() {
|
||||
isVisible = !isVisible;
|
||||
setVisible(isVisible);
|
||||
}
|
||||
|
||||
public void setControlsMenuVisible(boolean visible) {
|
||||
isVisible = visible;
|
||||
setVisible(visible);
|
||||
}
|
||||
}
|
@@ -1,176 +0,0 @@
|
||||
package fr.monkhanny.dorfromantik.game;
|
||||
|
||||
import fr.monkhanny.dorfromantik.utils.Database;
|
||||
import fr.monkhanny.dorfromantik.gui.MainMenu;
|
||||
import fr.monkhanny.dorfromantik.Options;
|
||||
import fr.monkhanny.dorfromantik.enums.Fonts;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GameOver extends JPanel {
|
||||
private JFrame gameFrame;
|
||||
|
||||
public GameOver(JFrame gameFrame, int finalScore, Database database, MainMenu mainMenu) {
|
||||
this.gameFrame = gameFrame;
|
||||
this.gameFrame.setTitle("Partie terminée - Dorfromantik");
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
// Background image setup
|
||||
JLabel background = new JLabel(new ImageIcon("./ressources/images/MainMenu/backgroundBlured.jpg"));
|
||||
background.setLayout(new BorderLayout());
|
||||
this.add(background, BorderLayout.CENTER);
|
||||
|
||||
// Main content panel
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
|
||||
mainPanel.setOpaque(false);
|
||||
background.add(mainPanel, BorderLayout.CENTER);
|
||||
|
||||
// Title for the Game Over message
|
||||
JLabel titleLabel = new JLabel("Partie terminée !");
|
||||
titleLabel.setFont(Fonts.TITLE.getFont(48)); // Using the TITLE font
|
||||
titleLabel.setForeground(Color.WHITE);
|
||||
titleLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
mainPanel.add(titleLabel);
|
||||
|
||||
// Spacer
|
||||
mainPanel.add(Box.createVerticalStrut(30));
|
||||
|
||||
// Display the final score
|
||||
JLabel scoreLabel = new JLabel("Votre score est de : " + finalScore);
|
||||
scoreLabel.setFont(Fonts.SCORE.getFont(36)); // Using the SCORE font
|
||||
scoreLabel.setForeground(Color.WHITE);
|
||||
scoreLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
scoreLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); // Padding
|
||||
scoreLabel.setOpaque(true);
|
||||
scoreLabel.setBackground(new Color(0, 0, 0, 100)); // Background color with transparency
|
||||
mainPanel.add(scoreLabel);
|
||||
|
||||
// Spacer
|
||||
mainPanel.add(Box.createVerticalStrut(30));
|
||||
|
||||
// Grouping information and funny quote
|
||||
try {
|
||||
long seriesId = Options.SEED; // Get the correct seriesId
|
||||
database.addScore(seriesId, finalScore);
|
||||
List<Integer> allScores = database.getScoresBySeriesId(seriesId);
|
||||
|
||||
// Check if there are enough players to form groups
|
||||
int totalPlayers = allScores.size();
|
||||
if (totalPlayers >= 100) {
|
||||
int groupSize = totalPlayers / 10;
|
||||
int playerGroup = 0;
|
||||
|
||||
// Group data for bar chart
|
||||
List<Integer> groupAverages = new ArrayList<>();
|
||||
|
||||
// Calculate which group the player's score falls into and the average score for each group
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int startIdx = i * groupSize;
|
||||
int endIdx = Math.min((i + 1) * groupSize, totalPlayers);
|
||||
if (startIdx < totalPlayers) {
|
||||
List<Integer> groupScores = allScores.subList(startIdx, endIdx);
|
||||
int groupSum = 0;
|
||||
for (int score : groupScores) {
|
||||
groupSum += score;
|
||||
}
|
||||
groupAverages.add(groupSum / groupScores.size());
|
||||
if (scoreInGroup(allScores, finalScore, startIdx, endIdx)) {
|
||||
playerGroup = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Group information panel
|
||||
JPanel groupPanel = new JPanel();
|
||||
groupPanel.setOpaque(false);
|
||||
groupPanel.setLayout(new BoxLayout(groupPanel, BoxLayout.Y_AXIS));
|
||||
|
||||
JLabel groupTitleLabel = new JLabel("Vous êtes dans le groupe " + playerGroup + "/10 !");
|
||||
groupTitleLabel.setFont(Fonts.SCORE.getFont(24));
|
||||
groupTitleLabel.setForeground(Color.WHITE);
|
||||
groupTitleLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
groupPanel.add(groupTitleLabel);
|
||||
|
||||
BarChartPanel barChartPanel = new BarChartPanel(groupAverages, playerGroup - 1, mainPanel);
|
||||
barChartPanel.setPreferredSize(new Dimension(700, 400));
|
||||
barChartPanel.setAlignmentX(Component.CENTER_ALIGNMENT); // Centrer horizontalement
|
||||
groupPanel.add(barChartPanel);
|
||||
|
||||
groupPanel.add(Box.createVerticalStrut(30));
|
||||
|
||||
// Show a funny quote based on the group
|
||||
String funnyQuote = getFunnyQuote(playerGroup);
|
||||
JLabel quoteLabel = new JLabel(funnyQuote);
|
||||
quoteLabel.setFont(Fonts.SCORE.getFont(24));
|
||||
quoteLabel.setForeground(Color.WHITE);
|
||||
quoteLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
groupPanel.add(quoteLabel);
|
||||
|
||||
// Add group information panel
|
||||
mainPanel.add(groupPanel);
|
||||
} else {
|
||||
// No groups, display a simple message instead
|
||||
JLabel noGroupsLabel = new JLabel("Pas mal !");
|
||||
noGroupsLabel.setFont(Fonts.SCORE.getFont(24));
|
||||
noGroupsLabel.setForeground(Color.WHITE);
|
||||
noGroupsLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
mainPanel.add(noGroupsLabel);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Spacer
|
||||
mainPanel.add(Box.createVerticalStrut(30));
|
||||
|
||||
// Bouton pour retourner au menu principal
|
||||
JButton returnButton = new JButton("Retour au Menu Principal");
|
||||
returnButton.setFont(Fonts.BUTTON.getFont(24));
|
||||
returnButton.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
returnButton.setFocusPainted(false); // Optionnel : pour un style plus propre
|
||||
returnButton.setBackground(new Color(0, 0, 0)); // Couleur d'arrière-plan du bouton
|
||||
returnButton.setForeground(Color.BLACK); // Couleur du texte du bouton
|
||||
|
||||
// Ajouter un listener d'action au bouton
|
||||
MainMenuButtonListener listener = new MainMenuButtonListener(gameFrame);
|
||||
returnButton.addActionListener(listener);
|
||||
|
||||
// Ajouter le bouton au panneau principal
|
||||
mainPanel.add(returnButton);
|
||||
}
|
||||
|
||||
|
||||
private boolean scoreInGroup(List<Integer> allScores, int finalScore, int startIdx, int endIdx) {
|
||||
for (int i = startIdx; i < endIdx; i++) {
|
||||
if (allScores.get(i) == finalScore) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getFunnyQuote(int playerGroup) {
|
||||
// A list of funny and motivational quotes based on the group
|
||||
switch (playerGroup) {
|
||||
case 1: return "Vous êtes officiellement un génie ! Peut-être même un super-héros...!";
|
||||
case 2: return "Pas mal ! Mais vous n'êtes pas encore le roi du monde... ou du moins de ce jeu !";
|
||||
case 3: return "Vous êtes sur la bonne voie, mais vous avez encore un peu de chemin à parcourir !";
|
||||
case 4: return "Il est encore temps d'appeler un coach pour vous aider... ou de tricher !";
|
||||
case 5: return "Vous êtes dans la bonne direction, mais votre GPS semble un peu perdu !";
|
||||
case 6: return "Vous n'êtes pas loin du sommet, mais le sommet semble être dans un autre pays !";
|
||||
case 7: return "C'est un bon début ! Peut-être qu'un peu de café améliorerait encore la situation ?!";
|
||||
case 8: return "Sur le chemin de la gloire, mais vous êtes encore coincé dans les bouchons...";
|
||||
case 9: return "Félicitations ! Mais peut-être que vous voudriez réessayer sans les lunettes de soleil ?";
|
||||
case 10: return "L'important c'est de participer, non ? Mais vous pourriez essayer de jouer les yeux ouvert la prochaine fois !";
|
||||
default: return "Hé, on progresse ! Peut-être qu'un jour, vous dominerez le monde... ou du moins ce jeu !";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package fr.monkhanny.dorfromantik.game;
|
||||
|
||||
import fr.monkhanny.dorfromantik.Main;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
public class MainMenuButtonListener implements ActionListener {
|
||||
private JFrame gameFrame;
|
||||
|
||||
public MainMenuButtonListener(JFrame gameFrame) {
|
||||
this.gameFrame = gameFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
this.gameFrame.setVisible(false);
|
||||
Main.resetGame();
|
||||
}
|
||||
}
|
@@ -1,6 +1,9 @@
|
||||
package fr.monkhanny.dorfromantik.game;
|
||||
|
||||
import fr.monkhanny.dorfromantik.Options;
|
||||
import fr.monkhanny.dorfromantik.listeners.GameQuitButtonListener;
|
||||
import fr.monkhanny.dorfromantik.listeners.GameResumeButtonListener;
|
||||
import fr.monkhanny.dorfromantik.listeners.GameSettingsButtonListener;
|
||||
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
@@ -8,18 +11,18 @@ import javax.swing.JFrame;
|
||||
|
||||
public class PauseGame extends KeyAdapter {
|
||||
private EscapeMenu escapeMenu;
|
||||
private ResumeButtonListener resumeButtonListener;
|
||||
private QuitButtonListener quitButtonListener;
|
||||
private SettingsButtonListener settingsButtonListener;
|
||||
private GameResumeButtonListener resumeButtonListener;
|
||||
private GameQuitButtonListener quitButtonListener;
|
||||
private GameSettingsButtonListener settingsButtonListener;
|
||||
|
||||
public PauseGame(JFrame gameFrame, Game game) {
|
||||
// Initialiser escapeMenu ici avant de le passer à SettingsButtonListener
|
||||
this.escapeMenu = new EscapeMenu(gameFrame, game); // Initialisation ici
|
||||
this.escapeMenu.setVisible(false);
|
||||
this.escapeMenu.setAlwaysOnTop(true);
|
||||
this.resumeButtonListener = new ResumeButtonListener(this.escapeMenu);
|
||||
this.quitButtonListener = new QuitButtonListener();; // Initialisé après la création de escapeMenu
|
||||
this.settingsButtonListener = new SettingsButtonListener(gameFrame, this.escapeMenu); // Passer escapeMenu correctement
|
||||
this.resumeButtonListener = new GameResumeButtonListener(this.escapeMenu);
|
||||
this.quitButtonListener = new GameQuitButtonListener();; // Initialisé après la création de escapeMenu
|
||||
this.settingsButtonListener = new GameSettingsButtonListener(gameFrame, this.escapeMenu); // Passer escapeMenu correctement
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,18 +0,0 @@
|
||||
package fr.monkhanny.dorfromantik.game;
|
||||
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class QuitButtonListener implements ActionListener {
|
||||
|
||||
public QuitButtonListener() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// Quitter
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package fr.monkhanny.dorfromantik.game;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import fr.monkhanny.dorfromantik.Options;
|
||||
|
||||
public class ResumeButtonListener implements ActionListener {
|
||||
private EscapeMenu escapeMenu;
|
||||
|
||||
public ResumeButtonListener(EscapeMenu escapeMenu) {
|
||||
this.escapeMenu = escapeMenu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// Cacher le menu de pause
|
||||
escapeMenu.setVisible(false);
|
||||
Options.isPaused = false; // Mettre à jour l'état du jeu pour qu'il ne soit plus en pause
|
||||
}
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
package fr.monkhanny.dorfromantik.game;
|
||||
|
||||
import fr.monkhanny.dorfromantik.Options;
|
||||
import fr.monkhanny.dorfromantik.gui.SettingsPanel;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
public class SettingsButtonListener implements ActionListener {
|
||||
private JFrame gameFrame;
|
||||
private JFrame settingsFrame;
|
||||
private SettingsPanel settingsPanel;
|
||||
private EscapeMenu escapeMenu;
|
||||
|
||||
public SettingsButtonListener(JFrame gameFrame, EscapeMenu escapeMenu) {
|
||||
this.gameFrame = gameFrame;
|
||||
this.escapeMenu = escapeMenu;
|
||||
this.settingsFrame = new JFrame("Paramètres - Dorfromantik");
|
||||
this.settingsPanel = new SettingsPanel(Options.mainMenu, settingsFrame);
|
||||
this.settingsPanel.setReturnButtonVisible(false); // On cache le bouton de retour au menu principal
|
||||
|
||||
// Ajouter le WindowListener pour réafficher la gameFrame lors de la fermeture de settingsFrame
|
||||
this.settingsFrame.addWindowListener(new SettingsWindowListener(gameFrame));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (escapeMenu != null) { // Vérifier si escapeMenu est non nul
|
||||
escapeMenu.setVisible(false);
|
||||
}
|
||||
|
||||
// Obtenir la taille et la position de la gameFrame
|
||||
int width = gameFrame.getWidth() - 50;
|
||||
int height = gameFrame.getHeight() - 50;
|
||||
int x = gameFrame.getX();
|
||||
int y = gameFrame.getY();
|
||||
|
||||
// Appliquer ces dimensions et position à settingsFrame
|
||||
settingsFrame.setSize(width, height);
|
||||
settingsFrame.setLocation(x, y);
|
||||
|
||||
// Ajouter le panneau des paramètres si ce n'est pas déjà fait
|
||||
settingsFrame.add(this.settingsPanel);
|
||||
|
||||
// Cacher la gameFrame et afficher settingsFrame
|
||||
settingsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
settingsFrame.setVisible(true);
|
||||
Options.isPaused = false;
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
package fr.monkhanny.dorfromantik.game;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
|
||||
public class SettingsWindowListener implements WindowListener {
|
||||
private JFrame gameFrame;
|
||||
|
||||
public SettingsWindowListener(JFrame gameFrame) {
|
||||
this.gameFrame = gameFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
// Rien à faire ici
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
// Réafficher la gameFrame
|
||||
gameFrame.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
// Rien à faire ici
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowIconified(WindowEvent e) {
|
||||
// Rien à faire ici
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
// Rien à faire ici
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowActivated(WindowEvent e) {
|
||||
// Rien à faire ici
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
// Rien à faire ici
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user