Amélioration du code #2

This commit is contained in:
2024-11-17 14:06:57 +01:00
parent dec61876cf
commit a3b36b29db

View File

@@ -1,15 +1,18 @@
package fr.monkhanny.dorfromantik.controller; package fr.monkhanny.dorfromantik.controller;
import fr.monkhanny.dorfromantik.gui.GameModeSelectionPanel; import fr.monkhanny.dorfromantik.gui.GameModeSelectionPanel;
import fr.monkhanny.dorfromantik.game.Board;
import fr.monkhanny.dorfromantik.gui.MainMenu; import fr.monkhanny.dorfromantik.gui.MainMenu;
import fr.monkhanny.dorfromantik.game.Board;
import fr.monkhanny.dorfromantik.utils.Database; import fr.monkhanny.dorfromantik.utils.Database;
import fr.monkhanny.dorfromantik.Options;
import java.awt.event.ActionEvent; 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.sql.*;
import java.awt.Dimension;
import java.awt.Point;
public class GameModeController implements ActionListener { public class GameModeController implements ActionListener {
@@ -92,6 +95,16 @@ public class GameModeController implements ActionListener {
} }
private void startGame(String mode, long seed) { private void startGame(String mode, long seed) {
if (Options.FULL_SCREEN) {
gameFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); // Set frame to full screen
gameFrame.setUndecorated(true);
} else {
Dimension mainMenuSize = this.mainMenu.getSize();
Point mainMenuLocation = this.mainMenu.getLocation();
gameFrame.setSize(mainMenuSize);
gameFrame.setLocation(mainMenuLocation);
gameFrame.setUndecorated(false);
}
Board board = new Board(this.gameFrame,seed); Board board = new Board(this.gameFrame,seed);
this.gameFrame.setVisible(true); this.gameFrame.setVisible(true);
this.gameFrame.add(board); this.gameFrame.add(board);