2024-04-08 18:16:40 +02:00
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
|
2024-04-09 17:13:23 +02:00
|
|
|
|
2024-04-08 18:16:40 +02:00
|
|
|
/**
|
|
|
|
* Listener for button clicks in the menu.
|
|
|
|
* It performs different actions based on the button clicked.
|
|
|
|
*/
|
2024-04-09 17:13:23 +02:00
|
|
|
class HomeButtonClickListener implements ActionListener {
|
2024-04-08 18:16:40 +02:00
|
|
|
private Window window;
|
2024-04-09 17:13:23 +02:00
|
|
|
private DialogManager rulesDialogManager;
|
|
|
|
private DialogManager howToPlayDialogManager;
|
2024-04-08 18:16:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a ButtonClickListener with the specified window.
|
|
|
|
* @param window The window where the actions will be performed.
|
|
|
|
*/
|
2024-04-09 17:13:23 +02:00
|
|
|
public HomeButtonClickListener(Window window) {
|
2024-04-08 18:16:40 +02:00
|
|
|
this.window = window;
|
2024-04-09 17:13:23 +02:00
|
|
|
this.rulesDialogManager = new RulesDialogManager();
|
|
|
|
this.howToPlayDialogManager = new HowToPlayDialogManager();
|
2024-04-08 18:16:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs an action based on the button clicked.
|
|
|
|
* @param e The ActionEvent representing the button click.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
String buttonText = ((Button) e.getSource()).getText();
|
|
|
|
switch (buttonText) {
|
|
|
|
case "Jouer":
|
2024-04-09 17:13:23 +02:00
|
|
|
// à faire
|
2024-04-08 18:16:40 +02:00
|
|
|
break;
|
2024-04-09 12:55:46 +02:00
|
|
|
case "Règles":
|
2024-04-09 17:13:23 +02:00
|
|
|
rulesDialogManager.showDialog();
|
2024-04-08 18:16:40 +02:00
|
|
|
break;
|
2024-04-09 12:55:46 +02:00
|
|
|
case "Comment jouer ?":
|
2024-04-09 17:13:23 +02:00
|
|
|
howToPlayDialogManager.showDialog();
|
2024-04-08 18:16:40 +02:00
|
|
|
break;
|
|
|
|
case "Quitter":
|
|
|
|
System.exit(0); // Quitter le programme
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|