Suppression de toutes mes fiertés
This commit is contained in:
@@ -64,6 +64,7 @@ public class GameOver extends JPanel {
|
||||
// Grouping information and funny quote
|
||||
try {
|
||||
long seriesId = Options.SEED; // Get the correct seriesId
|
||||
database.addScore(seriesId, finalScore);
|
||||
List<Integer> allScores = database.getScoresBySeriesId(seriesId);
|
||||
|
||||
// Calculate the groups
|
||||
@@ -137,12 +138,25 @@ public class GameOver extends JPanel {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Input panel for username and submission
|
||||
JPanel inputPanel = createInputPanel();
|
||||
mainPanel.add(inputPanel);
|
||||
|
||||
// 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, null, null);
|
||||
returnButton.addActionListener(listener);
|
||||
|
||||
// Ajouter le bouton au panneau principal
|
||||
mainPanel.add(returnButton);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -163,74 +177,4 @@ public class GameOver extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private JPanel createInputPanel() {
|
||||
JPanel inputPanel = new JPanel();
|
||||
inputPanel.setLayout(new BoxLayout(inputPanel, BoxLayout.Y_AXIS));
|
||||
inputPanel.setOpaque(false);
|
||||
|
||||
// Username label and text field
|
||||
JPanel namePanel = new JPanel();
|
||||
namePanel.setOpaque(false);
|
||||
JLabel nameLabel = new JLabel("Entrez votre pseudo :");
|
||||
nameLabel.setForeground(Color.WHITE);
|
||||
nameLabel.setFont(Fonts.SCORE.getFont(24));
|
||||
namePanel.add(nameLabel);
|
||||
|
||||
JTextField nameField = new JTextField(20);
|
||||
nameField.setFont(Fonts.SCORE.getFont(18));
|
||||
nameField.setPreferredSize(new Dimension(250, 40));
|
||||
nameField.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
|
||||
nameField.setText("Anonyme");
|
||||
namePanel.add(nameField);
|
||||
|
||||
inputPanel.add(namePanel);
|
||||
|
||||
// Spacer between name field and button
|
||||
inputPanel.add(Box.createVerticalStrut(20));
|
||||
|
||||
// Add flexible space at the bottom to push the button down
|
||||
inputPanel.add(Box.createVerticalGlue());
|
||||
|
||||
// Submit button
|
||||
JButton submitButton = new JButton("Soumettre");
|
||||
submitButton.setFont(Fonts.BUTTON.getFont(24)); // Using the BUTTON font
|
||||
submitButton.setBackground(new Color(0, 255, 0));
|
||||
submitButton.setForeground(Color.WHITE);
|
||||
submitButton.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
|
||||
submitButton.setPreferredSize(new Dimension(150, 50));
|
||||
|
||||
// Center the button horizontally using BoxLayout
|
||||
submitButton.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
inputPanel.add(submitButton);
|
||||
|
||||
// Action to handle score submission
|
||||
submitButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String username = nameField.getText().trim();
|
||||
if (username.isEmpty()) {
|
||||
username = "Anonyme"; // Default to "Anonyme" if no name is given
|
||||
}
|
||||
|
||||
// Save the score to the database
|
||||
try {
|
||||
long seriesId = Options.SEED; // Replace with the appropriate series ID
|
||||
database.addScore(username, seriesId, finalScore);
|
||||
|
||||
// Débloquer les récompenses pour ce joueur
|
||||
database.unlockRewards(username, finalScore);
|
||||
|
||||
JOptionPane.showMessageDialog(gameFrame, "Score enregistré et récompenses débloquées !");
|
||||
} catch (Exception ex) {
|
||||
JOptionPane.showMessageDialog(gameFrame, "Erreur lors de l'enregistrement du score : " + ex.getMessage());
|
||||
}
|
||||
|
||||
// Fermer la fenêtre de jeu
|
||||
Main.resetGame();
|
||||
}
|
||||
});
|
||||
return inputPanel;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user