Commit 2348118f authored by Thomas Dupriez's avatar Thomas Dupriez

Some cleanup ep2

parent f16d0f12
......@@ -11,8 +11,6 @@ import javax.swing.*;
* The gui changes what it displays by swapping GUIPanels in the mainFrame.
*/
public abstract class GUIPanel extends JPanel implements PanelAbstraction{
//The following line is commented because KeyListener does not seem to work in a JPanel
//Private KeyListenerForGUIPanel associatedKeyHandler;
//Store the graphicsMaster that created the guiPanel (there should be only one GraphicsMaster instanciation per application,
// this variable is just there to give the guiPanel the right to call the method changeGUIStateTo de graphicsMaster)
......@@ -24,66 +22,6 @@ public abstract class GUIPanel extends JPanel implements PanelAbstraction{
public GUIPanel(GraphicsMaster graphicsMaster) {
this.graphicsMaster = graphicsMaster;
//The following 2 lines are commented because KeyListener does not seem to work in a JPanel
//associatedKeyHandler = new KeyListenerForGUIPanel(this);
setFocusable(true);
}
/**
* This method is called by the gui before displaying the panel
*/
//abstract void initialise();
/**
* This method is called by the gui after this panel is no more displayed
*/
//abstract void finalise();
/**
* Define here what should happen if a key is pressed while this panel has the focus
* @param e
*/
//abstract void keyPressedHandler(KeyEvent e);
//Example of a body one could give to the keyPressedHandler method when implementing a guiPanel
//if(e.getKeyCode() == 27) { // 27 -> Escape
// System.out.println("Escape has been pressed");
//}
/**
* Define here what should happen if a key is released while this panel has the focus
* @param e
*/
//abstract void keyReleasedHandler(KeyEvent e);
/**
* Define here what should happen if a key is typed while this panel has the focus
* @param e
*/
//abstract void keyTypedHandler(KeyEvent e);
}
// The following code is commented because KeyListener does not seem to work on a JPanel
///**
// * This class detects the KeyEvents coming from the keyboard (KeyPressed, KeyReleased and KeyTyped) when the guiPanel
// * it is associated with has the focus, and call the corresponding KeyEvent handler of the associated guiPanel
// */
//class KeyListenerForGUIPanel implements KeyListener {
//
// private guiPanel associatedGUIPanel;
//
// KeyListenerForGUIPanel(guiPanel associatedGUIPanel) {
// this.associatedGUIPanel = associatedGUIPanel;
// }
//
// public final void keyPressed(KeyEvent e) {
// associatedGUIPanel.keyPressedHandler(e);
// }
//
// public final void keyReleased(KeyEvent e) {
// associatedGUIPanel.keyReleasedHandler(e);
// }
//
// public final void keyTyped(KeyEvent e) {
// associatedGUIPanel.keyTypedHandler(e);
// }
//}
}
\ No newline at end of file
......@@ -32,8 +32,4 @@ public class GamePanelMapPoint {
public int getY() {
return Y;
}
//TODO: Useful?
public GraphicsMapPoint getGraphicsMapPoint() {
return graphicsMapPoint;
}
}
......@@ -5,7 +5,7 @@ import java.io.Serializable;
/**
* Created by dupriez on 03/11/15.
* Represents a basic sprite with no animation.
* Represents a basic sprite with no animation (just an image in fact).
*/
public class Sprite implements Serializable, Displayable{
......
......@@ -31,11 +31,9 @@ public abstract class SpriteLoader {
Sprite newSprite = null;
//The sprite asked is not in the map, so we load it and add it to the map
try {
// newSprite = new Sprite(ImageIO.read(new File(path)));
URL url=UsedForLoadingSprites.getInstance().getClass().getResource(path);
if(url==null)
throw new IllegalStateException("Missing sprite :"+path+ "!");
//System.out.println(url);
newSprite = new Sprite(ImageIO.read(url));
} catch (IOException e) {
Logging.getInstance().getLogger().severe(e.getMessage());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment