Commit 2c6a98dd authored by Thomas Dupriez's avatar Thomas Dupriez

Added a GameOver panel to the swing gui

parent b0fc6083
......@@ -34,7 +34,8 @@ public abstract class GraphicsMasterAbstraction {
MULTIPLAYER_GAME_CREATION,
SINGLEPLAYER_GAME_CREATION,
MULTIPLAYER_CHARACTER_CHOICE,
SINGLEPLAYER_CHARACTER_CHOICE}
SINGLEPLAYER_CHARACTER_CHOICE,
GAME_OVER}
//This map indicates to graphicsMaster which guiPanel is associated to each GUIState, it is filled in Graphicsmaster's constructor
protected HashMap<GUIStates, PanelAbstraction> mapGUIStatesToGUIPanel = new HashMap<>();
//The current state of the GUI
......
......@@ -54,6 +54,8 @@ public class GraphicsMaster extends GraphicsMasterAbstraction {
mapGUIStatesToGUIPanel.put(GUIStates.SINGLEPLAYER_GAME_CREATION, new SinglePlayer_GameCreationPanel(this));
mapGUIStatesToGUIPanel.put(GUIStates.SINGLEPLAYER_CHARACTER_CHOICE, new SinglePlayer_CharacterChoicePanel(this));
mapGUIStatesToGUIPanel.put(GUIStates.SINGLEPLAYER_LOADGAME, new SinglePlayer_LoadGamePanel(this));
mapGUIStatesToGUIPanel.put(GUIStates.GAME_OVER, new GameOverPanel(this));
}
public static void build() {
......@@ -83,6 +85,7 @@ public class GraphicsMaster extends GraphicsMasterAbstraction {
//mf.addKeyListener(mainFrameKeyListener);
//mf.revalidate();
//mf.setVisible(true);
changeGUIStateTo(GUIStates.MAIN_MENU);
}
});
......
package graphics.guiSkeleton.guiPanel.menuPanel;
import graphics.graphical_abstraction.GraphicsMasterAbstraction;
import graphics.guiSkeleton.GUIColorsAndFonts;
import graphics.guiSkeleton.GraphicsMaster;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.MenuPanel;
import graphics.ingame_input_listener.Input;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by dupriez on 01/01/16.
*/
public class GameOverPanel extends MenuPanel {
public GameOverPanel(GraphicsMaster graphicsMaster) {
super(graphicsMaster);
JLabel sorryLabel = new JLabel("sorry, you died...");
sorryLabel.setFont(GUIColorsAndFonts.smallFont1);
sorryLabel.setForeground(GUIColorsAndFonts.fontColor1);
setTitlePanel("Game Over");
addToCentralColumn(sorryLabel,1,1);
addToCentralColumn(ButtonMaker.makeButton("Return to main menu", returnButtonActionListener),1,1);
GraphicsMasterAbstraction.getInstance().changeGUIStateTo(GraphicsMasterAbstraction.GUIStates.GAME_OVER);
}
private ActionListener returnButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.MAIN_MENU);
}
};
@Override
public void initialise() {
}
@Override
public void finalise() {
}
@Override
public void keyPressedHandler(Input e) {
}
@Override
public void keyReleasedHandler(Input e) {
}
@Override
public void keyTypedHandler(Input e) {
}
}
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