From 19dceafb7d7f7ffa5b8fa892636a7d7528f07d35 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Tue, 7 Dec 2021 12:19:31 +0100 Subject: [PATCH] Major improvement of windows (in terms of cpu, disk and ram performances), move ClientEventHandler.java to listener package --- .../ClientEventHandler.java | 3 +- .../java/fr/lnl/game/client/view/Cell.java | 30 +++++++++++-------- .../java/fr/lnl/game/client/view/Window.java | 1 + 3 files changed, 19 insertions(+), 15 deletions(-) rename client/src/main/java/fr/lnl/game/client/{view => listener}/ClientEventHandler.java (83%) diff --git a/client/src/main/java/fr/lnl/game/client/view/ClientEventHandler.java b/client/src/main/java/fr/lnl/game/client/listener/ClientEventHandler.java similarity index 83% rename from client/src/main/java/fr/lnl/game/client/view/ClientEventHandler.java rename to client/src/main/java/fr/lnl/game/client/listener/ClientEventHandler.java index 47d8d9a..7c3d7ca 100644 --- a/client/src/main/java/fr/lnl/game/client/view/ClientEventHandler.java +++ b/client/src/main/java/fr/lnl/game/client/listener/ClientEventHandler.java @@ -1,6 +1,5 @@ -package fr.lnl.game.client.view; +package fr.lnl.game.client.listener; -import fr.lnl.game.client.listener.ButtonListener; import fr.lnl.game.server.listener.ModelListener; import javafx.event.ActionEvent; import javafx.event.EventHandler; diff --git a/client/src/main/java/fr/lnl/game/client/view/Cell.java b/client/src/main/java/fr/lnl/game/client/view/Cell.java index 623bfe0..a0d129a 100644 --- a/client/src/main/java/fr/lnl/game/client/view/Cell.java +++ b/client/src/main/java/fr/lnl/game/client/view/Cell.java @@ -10,14 +10,18 @@ import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; - - -/*classe qui a pour but de générer chaque case de la grid et de vérifier les entités présentes dessus -(Mur,Joueur,Energie,bombe,etc..) -*/ - +/** + * classe qui a pour but de générer chaque case de la grid et de vérifier les entités présentes dessus + * (Mur, Joueur, Energie, Bombe, etc.) + */ public class Cell extends Rectangle { + private static Image PLAYER_IMAGE = new Image("player.png"); + private static Image ENERGY_BALL_IMAGE = new Image("energyBall.png"); + private static Image BOMB_IMAGE = new Image("bomb.jpg"); + private static Image MINE_IMAGE = new Image("mine.webp"); + private static Image WALL_IMAGE = new Image("wall.jpg"); + public Cell(int x, int y){ setWidth(Window.cellSize); setHeight(Window.cellSize); @@ -30,20 +34,20 @@ public class Cell extends Rectangle { public static StackPane setImageObject(Object object){ StackPane sp = new StackPane(); - String in; + Image in; if(object instanceof Player){ - in = "player.png"; + in = PLAYER_IMAGE; } else if(object instanceof EnergyBall){ - in = "energyBall.png"; + in = ENERGY_BALL_IMAGE; } else if(object instanceof Bomb){ - in = "bomb.jpg"; + in = BOMB_IMAGE; } else if(object instanceof Mine){ - in = "mine.webp"; + in = MINE_IMAGE; } else{ - in = "wall.jpg"; + in = WALL_IMAGE; } - ImageView iv = new ImageView(new Image(in)); + ImageView iv = new ImageView(in); iv.setFitHeight(40); iv.setFitWidth(40); sp.getChildren().add(iv); diff --git a/client/src/main/java/fr/lnl/game/client/view/Window.java b/client/src/main/java/fr/lnl/game/client/view/Window.java index 31ebf7f..d821314 100644 --- a/client/src/main/java/fr/lnl/game/client/view/Window.java +++ b/client/src/main/java/fr/lnl/game/client/view/Window.java @@ -1,6 +1,7 @@ package fr.lnl.game.client.view; import fr.lnl.game.client.listener.ButtonListener; +import fr.lnl.game.client.listener.ClientEventHandler; import fr.lnl.game.server.games.Game; import fr.lnl.game.server.games.grid.Grid; import fr.lnl.game.server.games.grid.elements.*;