Amélioration du code
This commit is contained in:
@@ -7,12 +7,10 @@ import javax.swing.*;
|
||||
public class BarChartPanel extends JPanel {
|
||||
private List<Integer> groupAverages;
|
||||
private int highlightedGroup;
|
||||
private JPanel mainPanel; // Store reference to mainPanel
|
||||
|
||||
public BarChartPanel(List<Integer> groupAverages, int highlightedGroup, JPanel mainPanel) {
|
||||
this.groupAverages = groupAverages;
|
||||
this.highlightedGroup = highlightedGroup;
|
||||
this.mainPanel = mainPanel;
|
||||
|
||||
// Rendre le fond transparent et ajouter une bordure noire
|
||||
setBackground(new Color(0, 0, 0, 0)); // Fond transparent
|
||||
|
@@ -9,7 +9,6 @@ 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.controller.GameModeController;
|
||||
import fr.monkhanny.dorfromantik.utils.Database;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@@ -13,16 +13,10 @@ import java.util.ArrayList;
|
||||
|
||||
public class GameOver extends JPanel {
|
||||
private JFrame gameFrame;
|
||||
private int finalScore;
|
||||
private Database database;
|
||||
private MainMenu mainMenu;
|
||||
|
||||
public GameOver(JFrame gameFrame, int finalScore, Database database, MainMenu mainMenu) {
|
||||
this.gameFrame = gameFrame;
|
||||
this.gameFrame.setTitle("Partie terminée - Dorfromantik");
|
||||
this.mainMenu = mainMenu;
|
||||
this.finalScore = finalScore;
|
||||
this.database = database;
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
|
@@ -8,8 +8,6 @@ import javax.swing.JFrame;
|
||||
|
||||
public class MainMenuButtonListener implements ActionListener {
|
||||
private JFrame gameFrame;
|
||||
private Game game;
|
||||
private EscapeMenu escapeMenu;
|
||||
|
||||
public MainMenuButtonListener(JFrame gameFrame) {
|
||||
this.gameFrame = gameFrame;
|
||||
|
@@ -7,21 +7,17 @@ import java.awt.event.KeyEvent;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
public class PauseGame extends KeyAdapter {
|
||||
private JFrame gameFrame;
|
||||
private Game game;
|
||||
private EscapeMenu escapeMenu;
|
||||
private ResumeButtonListener resumeButtonListener;
|
||||
private QuitButtonListener quitButtonListener;
|
||||
private SettingsButtonListener settingsButtonListener;
|
||||
|
||||
public PauseGame(JFrame gameFrame, Game game) {
|
||||
this.gameFrame = gameFrame;
|
||||
this.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(gameFrame,this.escapeMenu);
|
||||
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
|
||||
}
|
||||
|
@@ -11,12 +11,10 @@ import java.awt.RadialGradientPaint;
|
||||
public class RemainingTilesIndicator {
|
||||
private int remainingTiles;
|
||||
private int maxTiles;
|
||||
private final int maxHeight;
|
||||
|
||||
public RemainingTilesIndicator(int maxTiles) {
|
||||
this.maxTiles = maxTiles;
|
||||
this.remainingTiles = maxTiles;
|
||||
this.maxHeight = 0;
|
||||
}
|
||||
|
||||
public void setRemainingTiles(int remainingTiles) {
|
||||
@@ -32,9 +30,6 @@ public class RemainingTilesIndicator {
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setStroke(new BasicStroke(2)); // Appliquer un contour légèrement plus épais
|
||||
|
||||
// Calcul de la hauteur totale de la pile
|
||||
int totalHeight = maxTiles * (tileHeight + gap);
|
||||
|
||||
// Dessiner chaque hexagone, à partir du bas de la fenêtre
|
||||
for (int i = 0; i < remainingTiles; i++) {
|
||||
int currentY = y + (maxTiles - remainingTiles + i) * (tileHeight + gap); // Positionnement fixe
|
||||
|
@@ -2,16 +2,13 @@ package fr.monkhanny.dorfromantik.game;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import fr.monkhanny.dorfromantik.Options;
|
||||
|
||||
public class ResumeButtonListener implements ActionListener {
|
||||
private JFrame gameFrame;
|
||||
private EscapeMenu escapeMenu;
|
||||
|
||||
public ResumeButtonListener(JFrame gameFrame, EscapeMenu escapeMenu) {
|
||||
this.gameFrame = gameFrame;
|
||||
public ResumeButtonListener(EscapeMenu escapeMenu) {
|
||||
this.escapeMenu = escapeMenu;
|
||||
}
|
||||
|
||||
|
@@ -6,8 +6,6 @@ import fr.monkhanny.dorfromantik.gui.SettingsPanel;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
|
||||
public class SettingsButtonListener implements ActionListener {
|
||||
private JFrame gameFrame;
|
||||
|
Reference in New Issue
Block a user