Amélioration du code -> Suppression de code inutile
This commit is contained in:
@@ -43,7 +43,9 @@ public class Main {
|
|||||||
MusicPlayer.loadMusic(Musics.MAIN_MENU_MUSIC);
|
MusicPlayer.loadMusic(Musics.MAIN_MENU_MUSIC);
|
||||||
MusicPlayer.playMusic();
|
MusicPlayer.playMusic();
|
||||||
MainMenu mainMenu = new MainMenu();
|
MainMenu mainMenu = new MainMenu();
|
||||||
|
@SuppressWarnings("unused")
|
||||||
MainMenuResizeController MainMenuResizeController = new MainMenuResizeController(mainMenu);
|
MainMenuResizeController MainMenuResizeController = new MainMenuResizeController(mainMenu);
|
||||||
|
@SuppressWarnings("unused")
|
||||||
MainMenuButtonController MainMenuButtonController = new MainMenuButtonController(mainMenu,settingsFrame,howToPlayFrame,gameModeFrame,gameFrame);
|
MainMenuButtonController MainMenuButtonController = new MainMenuButtonController(mainMenu,settingsFrame,howToPlayFrame,gameModeFrame,gameFrame);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
package fr.monkhanny.dorfromantik.gui;
|
package fr.monkhanny.dorfromantik.controller;
|
||||||
|
|
||||||
import fr.monkhanny.dorfromantik.Options;
|
import fr.monkhanny.dorfromantik.Options;
|
||||||
|
|
||||||
|
@@ -10,7 +10,6 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.*;
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
|
|
||||||
@@ -66,15 +65,6 @@ public class GameModeController implements ActionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getSeedFromDatabase(long seriesId) {
|
|
||||||
try {
|
|
||||||
return this.database.getSeedBySeriesId(seriesId);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return -1; // Retourner une valeur par défaut si une erreur survient
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private long getSeedFromDatabaseByName(String modeName) {
|
private long getSeedFromDatabaseByName(String modeName) {
|
||||||
try {
|
try {
|
||||||
return this.database.getSeedByName(modeName);
|
return this.database.getSeedByName(modeName);
|
||||||
|
@@ -1,10 +1,8 @@
|
|||||||
package fr.monkhanny.dorfromantik.controller;
|
package fr.monkhanny.dorfromantik.controller;
|
||||||
|
|
||||||
import fr.monkhanny.dorfromantik.Options;
|
import fr.monkhanny.dorfromantik.Options;
|
||||||
import fr.monkhanny.dorfromantik.gui.SettingsPanel;
|
|
||||||
import fr.monkhanny.dorfromantik.gui.MainMenu;
|
import fr.monkhanny.dorfromantik.gui.MainMenu;
|
||||||
import fr.monkhanny.dorfromantik.gui.ButtonPanel;
|
import fr.monkhanny.dorfromantik.gui.ButtonPanel;
|
||||||
import fr.monkhanny.dorfromantik.listeners.CloseWindowListener;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@@ -35,21 +33,21 @@ public class MainMenuButtonController implements ActionListener {
|
|||||||
|
|
||||||
// Paramètrage de la fenêtre des paramètres
|
// Paramètrage de la fenêtre des paramètres
|
||||||
this.settingsFrame = settingsFrame;
|
this.settingsFrame = settingsFrame;
|
||||||
configureFrame(settingsFrame);
|
configureFrame(this.settingsFrame);
|
||||||
|
|
||||||
// Paramètrage de la fenêtre du tutoriel
|
// Paramètrage de la fenêtre du tutoriel
|
||||||
this.howToPlayFrame = howToPlayFrame;
|
this.howToPlayFrame = howToPlayFrame;
|
||||||
configureFrame(howToPlayFrame);
|
configureFrame(this.howToPlayFrame);
|
||||||
|
|
||||||
|
|
||||||
// Paramètrage de la fenêtre du jeu
|
// Paramètrage de la fenêtre du jeu
|
||||||
this.gameModeFrame = gameModeFrame;
|
this.gameModeFrame = gameModeFrame;
|
||||||
configureFrame(gameModeFrame);
|
configureFrame(this.gameModeFrame);
|
||||||
|
|
||||||
|
|
||||||
// Paramètrage de la fenêtre du jeu
|
// Paramètrage de la fenêtre du jeu
|
||||||
this.gameFrame = gameFrame;
|
this.gameFrame = gameFrame;
|
||||||
configureFrame(gameFrame);
|
configureFrame(this.gameFrame);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,8 +4,6 @@ import fr.monkhanny.dorfromantik.gui.ButtonPanel;
|
|||||||
import fr.monkhanny.dorfromantik.gui.ButtonHoverAnimator;
|
import fr.monkhanny.dorfromantik.gui.ButtonHoverAnimator;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
|
|
||||||
public class MainMenuMouseController {
|
public class MainMenuMouseController {
|
||||||
|
|
||||||
|
@@ -6,7 +6,6 @@ import fr.monkhanny.dorfromantik.gui.ButtonHoverAnimator;
|
|||||||
|
|
||||||
import java.awt.event.ComponentAdapter;
|
import java.awt.event.ComponentAdapter;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
import javax.swing.JButton;
|
|
||||||
|
|
||||||
public class MainMenuResizeHandler extends ComponentAdapter {
|
public class MainMenuResizeHandler extends ComponentAdapter {
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ public class TutorialController {
|
|||||||
steps.add(new Step("Étape n°3", "Explication de la troisième étape ici.", Images.TUTORIAL_GIF3.getImagePath()));
|
steps.add(new Step("Étape n°3", "Explication de la troisième étape ici.", Images.TUTORIAL_GIF3.getImagePath()));
|
||||||
steps.add(new Step("Étape n°4", "Explication de la quatrième étape ici.", Images.TUTORIAL_GIF4.getImagePath()));
|
steps.add(new Step("Étape n°4", "Explication de la quatrième étape ici.", Images.TUTORIAL_GIF4.getImagePath()));
|
||||||
|
|
||||||
tutorialPanel = new TutorialPanel(steps, mainMenu, tutorialFrame);
|
tutorialPanel = new TutorialPanel(steps, this.mainMenu, this.tutorialFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getTutorialPanel() {
|
public JPanel getTutorialPanel() {
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
package fr.monkhanny.dorfromantik.enums;
|
package fr.monkhanny.dorfromantik.enums;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
|
|
||||||
public enum Fonts {
|
public enum Fonts {
|
||||||
TITLE, BUTTON;
|
TITLE, BUTTON;
|
||||||
|
|
||||||
|
@@ -20,7 +20,6 @@ import java.awt.Graphics2D;
|
|||||||
|
|
||||||
// TEMPORAIRE :
|
// TEMPORAIRE :
|
||||||
import java.awt.event.MouseMotionAdapter; // Import pour MouseMotionAdapter
|
import java.awt.event.MouseMotionAdapter; // Import pour MouseMotionAdapter
|
||||||
import java.awt.event.MouseEvent; // Import pour MouseEvent
|
|
||||||
import java.awt.AlphaComposite;
|
import java.awt.AlphaComposite;
|
||||||
|
|
||||||
|
|
||||||
@@ -149,28 +148,6 @@ public class Board extends JPanel{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void adjustZoomAndPosition() {
|
|
||||||
// Calculer la largeur et la hauteur totales des tuiles (en fonction du nombre de tuiles)
|
|
||||||
int totalWidth = 0;
|
|
||||||
int totalHeight = 0;
|
|
||||||
|
|
||||||
// Trouver la plus grande étendue de tuiles sur l'axe X et Y
|
|
||||||
for (Tile tile : tiles) {
|
|
||||||
totalWidth = Math.max(totalWidth, tile.getXCoord() + tile.getRadius());
|
|
||||||
totalHeight = Math.max(totalHeight, tile.getYCoord() + tile.getRadius());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Définir l'offset pour centrer les tuiles sur le plateau après le dézoom
|
|
||||||
int targetOffsetX = (int) ((getWidth() - totalWidth * zoomFactor) / 2);
|
|
||||||
int targetOffsetY = (int) ((getHeight() - totalHeight * zoomFactor) / 2);
|
|
||||||
|
|
||||||
// Appliquer ces nouveaux offsets
|
|
||||||
setOffsetX(targetOffsetX);
|
|
||||||
setOffsetY(targetOffsetY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void handleMouseClick(java.awt.event.MouseEvent e) {
|
public void handleMouseClick(java.awt.event.MouseEvent e) {
|
||||||
// Récupérer les coordonnées du clic
|
// Récupérer les coordonnées du clic
|
||||||
Point clickedPoint = e.getPoint();
|
Point clickedPoint = e.getPoint();
|
||||||
@@ -306,7 +283,7 @@ public class Board extends JPanel{
|
|||||||
int targetOffsetX = (int) ((getWidth() - newlyPlacedTile.getRadius() * 2) / 2 - newlyPlacedTileX);
|
int targetOffsetX = (int) ((getWidth() - newlyPlacedTile.getRadius() * 2) / 2 - newlyPlacedTileX);
|
||||||
int targetOffsetY = (int) ((getHeight() - newlyPlacedTile.getRadius() * 2) / 2 - newlyPlacedTileY);
|
int targetOffsetY = (int) ((getHeight() - newlyPlacedTile.getRadius() * 2) / 2 - newlyPlacedTileY);
|
||||||
|
|
||||||
TilePanningTransition panningTransition = new TilePanningTransition(this, targetOffsetX, targetOffsetY, 50, 15);
|
TilePanningTransition panningTransition = new TilePanningTransition(this, targetOffsetX, targetOffsetY, 15);
|
||||||
panningTransition.start();
|
panningTransition.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,25 +2,22 @@ package fr.monkhanny.dorfromantik.game;
|
|||||||
|
|
||||||
import fr.monkhanny.dorfromantik.listeners.TilePanningActionListener;
|
import fr.monkhanny.dorfromantik.listeners.TilePanningActionListener;
|
||||||
|
|
||||||
import javax.swing.Timer;
|
|
||||||
|
|
||||||
public class TilePanningTransition {
|
public class TilePanningTransition {
|
||||||
private Board board;
|
private Board board;
|
||||||
private int targetOffsetX, targetOffsetY;
|
private int targetOffsetX, targetOffsetY;
|
||||||
private int speed;
|
|
||||||
private int steps;
|
private int steps;
|
||||||
|
|
||||||
public TilePanningTransition(Board board, int targetOffsetX, int targetOffsetY, int speed, int steps) {
|
public TilePanningTransition(Board board, int targetOffsetX, int targetOffsetY, int steps) {
|
||||||
this.board = board;
|
this.board = board;
|
||||||
this.targetOffsetX = targetOffsetX;
|
this.targetOffsetX = targetOffsetX;
|
||||||
this.targetOffsetY = targetOffsetY;
|
this.targetOffsetY = targetOffsetY;
|
||||||
this.speed = speed;
|
|
||||||
this.steps = steps;
|
this.steps = steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
// Créer un listener d'animation
|
// Créer un listener d'animation
|
||||||
TilePanningActionListener listener = new TilePanningActionListener(board, targetOffsetX, targetOffsetY, speed, steps);
|
TilePanningActionListener listener = new TilePanningActionListener(board, targetOffsetX, targetOffsetY, steps);
|
||||||
|
|
||||||
// Démarrer l'animation si aucune n'est en cours
|
// Démarrer l'animation si aucune n'est en cours
|
||||||
listener.startAnimation();
|
listener.startAnimation();
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
package fr.monkhanny.dorfromantik.gui;
|
package fr.monkhanny.dorfromantik.gui;
|
||||||
|
|
||||||
import fr.monkhanny.dorfromantik.Options;
|
import fr.monkhanny.dorfromantik.Options;
|
||||||
|
import fr.monkhanny.dorfromantik.controller.ButtonHoverAnimationListener;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
public class ButtonHoverAnimator {
|
public class ButtonHoverAnimator {
|
||||||
|
|
||||||
@@ -13,24 +12,23 @@ public class ButtonHoverAnimator {
|
|||||||
private final Color originalColor;
|
private final Color originalColor;
|
||||||
private static Font originalFont;
|
private static Font originalFont;
|
||||||
private Timer animationTimer;
|
private Timer animationTimer;
|
||||||
private float currentScale = 1.0f;
|
|
||||||
|
|
||||||
public ButtonHoverAnimator(JButton button) {
|
public ButtonHoverAnimator(JButton button) {
|
||||||
this.button = button;
|
this.button = button;
|
||||||
this.originalColor = button.getForeground();
|
this.originalColor = button.getForeground();
|
||||||
this.originalFont = button.getFont();
|
ButtonHoverAnimator.originalFont = button.getFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startAnimation(boolean entering) {
|
public void startAnimation(boolean entering) {
|
||||||
if (animationTimer != null && animationTimer.isRunning()) {
|
if (animationTimer != null && animationTimer.isRunning()) {
|
||||||
animationTimer.stop();
|
animationTimer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new ActionListener instance
|
// Create a new ActionListener instance
|
||||||
animationTimer = new Timer(Options.ANIMATION_DELAY, new ButtonHoverAnimationListener(entering, button, originalColor, originalFont));
|
animationTimer = new Timer(Options.ANIMATION_DELAY, new ButtonHoverAnimationListener(entering, button, originalColor, originalFont));
|
||||||
animationTimer.start();
|
animationTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateOriginalFont(float newFontSize) {
|
public static void updateOriginalFont(float newFontSize) {
|
||||||
originalFont = originalFont.deriveFont(newFontSize);
|
originalFont = originalFont.deriveFont(newFontSize);
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@ import fr.monkhanny.dorfromantik.components.Button;
|
|||||||
import fr.monkhanny.dorfromantik.controller.MainMenuMouseController;
|
import fr.monkhanny.dorfromantik.controller.MainMenuMouseController;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@@ -48,6 +47,7 @@ public class ButtonPanel extends JPanel {
|
|||||||
// Espacement extensible pour maintenir les icônes en bas
|
// Espacement extensible pour maintenir les icônes en bas
|
||||||
this.add(Box.createVerticalGlue());
|
this.add(Box.createVerticalGlue());
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
MainMenuMouseController gestionSouris = new MainMenuMouseController(this);
|
MainMenuMouseController gestionSouris = new MainMenuMouseController(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@ public class LeaderboardBarChartPanel extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
int barWidth = 30; // Largeur des barres
|
|
||||||
int spacing = 10; // Espacement entre les barres
|
int spacing = 10; // Espacement entre les barres
|
||||||
int barHeight = 20; // Hauteur de la barre
|
int barHeight = 20; // Hauteur de la barre
|
||||||
int totalBars = 10; // Nombre de tranches
|
int totalBars = 10; // Nombre de tranches
|
||||||
|
@@ -5,11 +5,10 @@ import fr.monkhanny.dorfromantik.utils.ImageLoader;
|
|||||||
import fr.monkhanny.dorfromantik.enums.Fonts;
|
import fr.monkhanny.dorfromantik.enums.Fonts;
|
||||||
import fr.monkhanny.dorfromantik.components.Title;
|
import fr.monkhanny.dorfromantik.components.Title;
|
||||||
import fr.monkhanny.dorfromantik.Options;
|
import fr.monkhanny.dorfromantik.Options;
|
||||||
|
import fr.monkhanny.dorfromantik.listeners.LeaderboardToggleActionListener;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
|
|
||||||
public class MainMenu extends JFrame {
|
public class MainMenu extends JFrame {
|
||||||
|
@@ -3,7 +3,6 @@ package fr.monkhanny.dorfromantik.gui;
|
|||||||
import fr.monkhanny.dorfromantik.Options;
|
import fr.monkhanny.dorfromantik.Options;
|
||||||
import fr.monkhanny.dorfromantik.components.Title;
|
import fr.monkhanny.dorfromantik.components.Title;
|
||||||
import fr.monkhanny.dorfromantik.listeners.*;
|
import fr.monkhanny.dorfromantik.listeners.*;
|
||||||
import fr.monkhanny.dorfromantik.utils.MusicPlayer;
|
|
||||||
import fr.monkhanny.dorfromantik.enums.Images;
|
import fr.monkhanny.dorfromantik.enums.Images;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
package fr.monkhanny.dorfromantik.gui;
|
package fr.monkhanny.dorfromantik.gui;
|
||||||
|
|
||||||
import fr.monkhanny.dorfromantik.components.Title;
|
import fr.monkhanny.dorfromantik.components.Title;
|
||||||
import fr.monkhanny.dorfromantik.gui.Step;
|
|
||||||
import fr.monkhanny.dorfromantik.gui.MainMenu;
|
|
||||||
import fr.monkhanny.dorfromantik.listeners.CloseButtonListener;
|
import fr.monkhanny.dorfromantik.listeners.CloseButtonListener;
|
||||||
import fr.monkhanny.dorfromantik.listeners.TutorialButtonHoverListener;
|
import fr.monkhanny.dorfromantik.listeners.TutorialButtonHoverListener;
|
||||||
import fr.monkhanny.dorfromantik.enums.Images;
|
import fr.monkhanny.dorfromantik.enums.Images;
|
||||||
|
@@ -3,7 +3,6 @@ package fr.monkhanny.dorfromantik.listeners;
|
|||||||
import fr.monkhanny.dorfromantik.game.Board;
|
import fr.monkhanny.dorfromantik.game.Board;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.Point;
|
|
||||||
|
|
||||||
public class GameMouseClickListener extends MouseAdapter {
|
public class GameMouseClickListener extends MouseAdapter {
|
||||||
private Board board;
|
private Board board;
|
||||||
|
@@ -2,9 +2,6 @@ package fr.monkhanny.dorfromantik.listeners;
|
|||||||
|
|
||||||
import fr.monkhanny.dorfromantik.game.Board;
|
import fr.monkhanny.dorfromantik.game.Board;
|
||||||
|
|
||||||
import java.awt.event.KeyAdapter;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
|
|
||||||
public class GameSpaceKeyListener extends java.awt.event.KeyAdapter {
|
public class GameSpaceKeyListener extends java.awt.event.KeyAdapter {
|
||||||
private Board board;
|
private Board board;
|
||||||
|
|
||||||
|
@@ -1,4 +1,8 @@
|
|||||||
package fr.monkhanny.dorfromantik.gui;
|
package fr.monkhanny.dorfromantik.listeners;
|
||||||
|
|
||||||
|
import fr.monkhanny.dorfromantik.gui.Leaderboard;
|
||||||
|
import fr.monkhanny.dorfromantik.gui.LeaderboardByTier;
|
||||||
|
import fr.monkhanny.dorfromantik.gui.LeaderboardWorldWide;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
@@ -9,7 +9,6 @@ import java.awt.event.ActionListener;
|
|||||||
public class TilePanningActionListener implements ActionListener {
|
public class TilePanningActionListener implements ActionListener {
|
||||||
private Board board;
|
private Board board;
|
||||||
private int targetOffsetX, targetOffsetY;
|
private int targetOffsetX, targetOffsetY;
|
||||||
private int speed; // Vitesse de la transition
|
|
||||||
private int steps; // Nombre d'étapes pour l'animation
|
private int steps; // Nombre d'étapes pour l'animation
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
|
|
||||||
@@ -19,11 +18,10 @@ public class TilePanningActionListener implements ActionListener {
|
|||||||
// Variables pour suivre l'état de l'animation
|
// Variables pour suivre l'état de l'animation
|
||||||
private int currentStep = 0;
|
private int currentStep = 0;
|
||||||
|
|
||||||
public TilePanningActionListener(Board board, int targetOffsetX, int targetOffsetY, int speed, int steps) {
|
public TilePanningActionListener(Board board, int targetOffsetX, int targetOffsetY, int steps) {
|
||||||
this.board = board;
|
this.board = board;
|
||||||
this.targetOffsetX = targetOffsetX;
|
this.targetOffsetX = targetOffsetX;
|
||||||
this.targetOffsetY = targetOffsetY;
|
this.targetOffsetY = targetOffsetY;
|
||||||
this.speed = speed;
|
|
||||||
this.steps = steps;
|
this.steps = steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user