Compare commits
2 Commits
86ee892770
...
a7be395f72
Author | SHA1 | Date | |
---|---|---|---|
a7be395f72 | |||
8b2a3375cb |
118
Makefile
118
Makefile
@@ -1,42 +1,94 @@
|
|||||||
PACKAGE = fr.monkhanny.dorfromantik
|
# Définition des variables
|
||||||
ENTRY = Main
|
JC = javac
|
||||||
SOURCEDIR = ./src/fr/monkhanny/dorfromantik/
|
JVM = java
|
||||||
BUILDDIR = ./build/
|
JCFLAGS = -d build -classpath "libs/mariadb-client.jar" -sourcepath src -encoding UTF-8
|
||||||
DOCDIR = ./doc/
|
JVMFLAGS = -classpath ".:libs/mariadb-client.jar:build"
|
||||||
JARNAME = dorfromantik.jar
|
JARNAME = dorfromantik.jar
|
||||||
CLASSP = ./libs/*:$(BUILDDIR)
|
ENTRY = fr.monkhanny.dorfromantik.Main
|
||||||
MANIFESTPATH = Manifest.MF
|
PACKAGE = build/fr/monkhanny/dorfromantik
|
||||||
SOURCEDIR = ./src/
|
SRC = src/fr/monkhanny/dorfromantik
|
||||||
|
|
||||||
SOURCES := $(shell find $(SOURCEDIR) -name '*.java')
|
# Compilation des fichiers .java
|
||||||
|
${PACKAGE}/Main.class: ${SRC}/Main.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/Main.java
|
||||||
|
|
||||||
all:
|
${PACKAGE}/Options.class: ${SRC}/Options.java
|
||||||
@make clean
|
${JC} ${JCFLAGS} ${SRC}/Options.java
|
||||||
@make compile
|
|
||||||
@make jar
|
|
||||||
@make run
|
|
||||||
|
|
||||||
compile:
|
# Compilation des composants
|
||||||
@echo "Compiling..."
|
${PACKAGE}/components/Button.class: ${SRC}/components/Button.java
|
||||||
@javac -cp $(CLASSP) -d $(BUILDDIR) $(SOURCES) -Xlint:unchecked -Xlint:deprecation
|
${JC} ${JCFLAGS} ${SRC}/components/Button.java
|
||||||
@echo "Done."
|
|
||||||
|
|
||||||
run:
|
${PACKAGE}/components/Title.class: ${SRC}/components/Title.java
|
||||||
@echo "Running..."
|
${JC} ${JCFLAGS} ${SRC}/components/Title.java
|
||||||
@java -cp $(CLASSP):$(JARNAME) fr.monkhanny.dorfromantik.Main
|
|
||||||
@echo "Done."
|
# Compilation des contrôleurs
|
||||||
|
${PACKAGE}/controller/ButtonHoverAnimationListener.class: ${SRC}/controller/ButtonHoverAnimationListener.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/controller/ButtonHoverAnimationListener.java
|
||||||
|
|
||||||
|
${PACKAGE}/controller/GameModeController.class: ${SRC}/controller/GameModeController.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/controller/GameModeController.java
|
||||||
|
|
||||||
|
# Compilation des énumérations
|
||||||
|
${PACKAGE}/enums/Biome.class: ${SRC}/enums/Biome.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/enums/Biome.java
|
||||||
|
|
||||||
|
${PACKAGE}/enums/Fonts.class: ${SRC}/enums/Fonts.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/enums/Fonts.java
|
||||||
|
|
||||||
|
# Compilation des classes liées au jeu
|
||||||
|
${PACKAGE}/game/BarChartPanel.class: ${SRC}/game/BarChartPanel.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/game/BarChartPanel.java
|
||||||
|
|
||||||
|
${PACKAGE}/game/Board.class: ${SRC}/game/Board.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/game/Board.java
|
||||||
|
|
||||||
|
${PACKAGE}/game/Game.class: ${SRC}/game/Game.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/game/Game.java
|
||||||
|
|
||||||
|
# Compilation des interfaces graphiques
|
||||||
|
${PACKAGE}/gui/ButtonPanel.class: ${SRC}/gui/ButtonPanel.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/gui/ButtonPanel.java
|
||||||
|
|
||||||
|
${PACKAGE}/gui/Leaderboard.class: ${SRC}/gui/Leaderboard.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/gui/Leaderboard.java
|
||||||
|
|
||||||
|
# Compilation des listeners
|
||||||
|
${PACKAGE}/listeners/CloseButtonListener.class: ${SRC}/listeners/CloseButtonListener.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/listeners/CloseButtonListener.java
|
||||||
|
|
||||||
|
${PACKAGE}/listeners/GameArrowKeyListener.class: ${SRC}/listeners/GameArrowKeyListener.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/listeners/GameArrowKeyListener.java
|
||||||
|
|
||||||
|
# Compilation des utils
|
||||||
|
${PACKAGE}/utils/Database.class: ${SRC}/utils/Database.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/utils/Database.java
|
||||||
|
|
||||||
|
${PACKAGE}/utils/FontLoader.class: ${SRC}/utils/FontLoader.java
|
||||||
|
${JC} ${JCFLAGS} ${SRC}/utils/FontLoader.java
|
||||||
|
|
||||||
|
# Cibles supplémentaires
|
||||||
|
run:
|
||||||
|
${JVM} ${JVMFLAGS} ${ENTRY}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo "Cleaning up..."
|
@echo "Nettoyage de build et doc"
|
||||||
@rm -rf $(BUILDDIR)* $(DOCDIR)*
|
rm -rf build
|
||||||
@echo "Done."
|
rm -rf doc
|
||||||
|
|
||||||
javadoc:
|
|
||||||
@echo "Generating javadoc..."
|
|
||||||
@javadoc -d $(DOCDIR) -sourcepath src -subpackages $(PACKAGE)
|
|
||||||
@echo "Done."
|
|
||||||
|
|
||||||
|
# Génération du fichier .jar
|
||||||
jar:
|
jar:
|
||||||
@echo "Creating jar..."
|
@echo "Création du fichier .jar"
|
||||||
@jar cfm $(JARNAME) $(MANIFESTPATH) -C $(BUILDDIR) fr/monkhanny/dorfromantik ressources
|
jar cvfm ${JARNAME} Manifest.MF -C build/ . -C libs/ .
|
||||||
@echo "Done."
|
|
||||||
|
# Extraction des fichiers MariaDB
|
||||||
|
extract-mariadb:
|
||||||
|
rm -rf build/org
|
||||||
|
unzip -qo libs/mariadb-client.jar -d build
|
||||||
|
rm -rf build/Version.java.template
|
||||||
|
rm -rf build/META-INF
|
||||||
|
|
||||||
|
# Documentation JavaDoc
|
||||||
|
javadoc:
|
||||||
|
@echo "Génération de la documentation JavaDoc"
|
||||||
|
javadoc -d doc -sourcepath src -subpackages fr.monkhanny.dorfromantik -classpath libs/mariadb-client.jar
|
||||||
|
@@ -11,7 +11,6 @@ import fr.monkhanny.dorfromantik.controller.TutorialController;
|
|||||||
import fr.monkhanny.dorfromantik.controller.GameModeController;
|
import fr.monkhanny.dorfromantik.controller.GameModeController;
|
||||||
import fr.monkhanny.dorfromantik.gui.GameModeSelectionPanel;
|
import fr.monkhanny.dorfromantik.gui.GameModeSelectionPanel;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -2,6 +2,7 @@ package fr.monkhanny.dorfromantik.controller;
|
|||||||
|
|
||||||
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.GameWindowCloseListener;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@@ -75,6 +76,8 @@ public class MainMenuButtonController implements ActionListener {
|
|||||||
|
|
||||||
this.gameFrame = gameFrame;
|
this.gameFrame = gameFrame;
|
||||||
configureFrame(this.gameFrame);
|
configureFrame(this.gameFrame);
|
||||||
|
this.gameFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
|
this.gameFrame.addWindowListener(new GameWindowCloseListener(this.gameFrame));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -3,6 +3,7 @@ package fr.monkhanny.dorfromantik.gui;
|
|||||||
import fr.monkhanny.dorfromantik.utils.FontManager;
|
import fr.monkhanny.dorfromantik.utils.FontManager;
|
||||||
import fr.monkhanny.dorfromantik.utils.ImageLoader;
|
import fr.monkhanny.dorfromantik.utils.ImageLoader;
|
||||||
import fr.monkhanny.dorfromantik.enums.Fonts;
|
import fr.monkhanny.dorfromantik.enums.Fonts;
|
||||||
|
import fr.monkhanny.dorfromantik.listeners.GameWindowCloseListener;
|
||||||
import fr.monkhanny.dorfromantik.components.Title;
|
import fr.monkhanny.dorfromantik.components.Title;
|
||||||
import fr.monkhanny.dorfromantik.Options;
|
import fr.monkhanny.dorfromantik.Options;
|
||||||
|
|
||||||
@@ -49,7 +50,8 @@ public class MainMenu extends JFrame {
|
|||||||
|
|
||||||
// Paramétrage de la fenêtre principale
|
// Paramétrage de la fenêtre principale
|
||||||
this.setTitle("Dorfromantik - Menu Principal");
|
this.setTitle("Dorfromantik - Menu Principal");
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
|
this.addWindowListener(new GameWindowCloseListener(this));
|
||||||
super.setIconImage(ImageLoader.APPLICATION_ICON);
|
super.setIconImage(ImageLoader.APPLICATION_ICON);
|
||||||
this.setMinimumSize(Options.MINIMUM_FRAME_SIZE);
|
this.setMinimumSize(Options.MINIMUM_FRAME_SIZE);
|
||||||
this.setSize(1200, 800);
|
this.setSize(1200, 800);
|
||||||
|
@@ -0,0 +1,53 @@
|
|||||||
|
package fr.monkhanny.dorfromantik.listeners;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gestionnaire pour la fermeture de la fenêtre de jeu avec confirmation.
|
||||||
|
* Ce gestionnaire affiche une boîte de dialogue de confirmation avant de quitter le jeu.
|
||||||
|
*
|
||||||
|
* @version 1.0
|
||||||
|
* @author Moncef STITI
|
||||||
|
*/
|
||||||
|
public class GameWindowCloseListener extends WindowAdapter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fenêtre à gérer.
|
||||||
|
*/
|
||||||
|
private final JFrame frame;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur pour initialiser le gestionnaire avec la fenêtre cible.
|
||||||
|
*
|
||||||
|
* @param frame La fenêtre à gérer
|
||||||
|
*/
|
||||||
|
public GameWindowCloseListener(JFrame frame) {
|
||||||
|
this.frame = frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Méthode appelée lorsque la fenêtre est en cours de fermeture.
|
||||||
|
* Affiche une boîte de dialogue de confirmation avant de quitter le jeu.
|
||||||
|
*
|
||||||
|
* @param e l'événement de fermeture de la fenêtre.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void windowClosing(WindowEvent e) {
|
||||||
|
Object[] options = {"Oui", "Non"}; // Options personnalisées en français
|
||||||
|
int choice = JOptionPane.showOptionDialog(
|
||||||
|
frame,
|
||||||
|
"Êtes-vous sûr de vouloir quitter le jeu ?", // Message
|
||||||
|
"Quitter le jeu", // Titre
|
||||||
|
JOptionPane.YES_NO_OPTION, // Type d'option
|
||||||
|
JOptionPane.QUESTION_MESSAGE, // Icône
|
||||||
|
null, // Icône personnalisée (null pour l'icône par défaut)
|
||||||
|
options, // Options de boutons personnalisées
|
||||||
|
options[1] // Valeur par défaut ("Non")
|
||||||
|
);
|
||||||
|
if (choice == JOptionPane.YES_OPTION) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user