diff --git a/cicaprojekt/Application.java b/cicaprojekt/Application.java index 6041399..87f9505 100644 --- a/cicaprojekt/Application.java +++ b/cicaprojekt/Application.java @@ -2,10 +2,11 @@ package cicaprojekt; public class Application { + public static final ApplicationFrame frameInstance = new ApplicationFrame(); + public static void main(String[] args) { - ApplicationFrame af = new ApplicationFrame(); - af.init(); - af.run(); + frameInstance.init(); + frameInstance.run(); } } diff --git a/cicaprojekt/ApplicationFrame.java b/cicaprojekt/ApplicationFrame.java index 3ae2a3a..3ca48de 100644 --- a/cicaprojekt/ApplicationFrame.java +++ b/cicaprojekt/ApplicationFrame.java @@ -40,6 +40,24 @@ public class ApplicationFrame implements Runnable jframe.setMinimumSize(new Dimension(600, 400)); jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + initMapselector(); + + jframe.add(mapselectorpanel); + } + + public void backToMapSelection() { + jframe.remove(gamepanel); + initMapselector(); + jframe.add(mapselectorpanel); + jframe.revalidate(); + } + + @Override + public void run() { + jframe.setVisible(true); + } + + private void initMapselector() { mapselectorpanel = new JPanel(); DefaultListModel dungeonslist = new DefaultListModel<>(); @@ -58,14 +76,6 @@ public class ApplicationFrame implements Runnable filelist.addMouseListener(new ListMouseHandler()); mapselectorpanel.add(filelist); - - - jframe.add(mapselectorpanel); - } - - @Override - public void run() { - jframe.setVisible(true); } private void setGameParams(File dungeonFile) throws IOException { diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index ff9b040..cf49ac2 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -58,6 +58,28 @@ public class Game { } public void stopGame(GameoverCause cause) { + switch (cause){ + + case TIMEOUT: + JOptionPane.showMessageDialog(null, "Time is up! Anubis has enslaved the world by now.", + "Game over", + JOptionPane.INFORMATION_MESSAGE, + new ImageIcon("Anubis.png")); + Application.frameInstance.backToMapSelection(); + break; + case ONEILLWON: + JOptionPane.showMessageDialog(null, "Colonel O'Neill won!", "Game over", + JOptionPane.INFORMATION_MESSAGE, + new ImageIcon("Deal_with_iit.png")); + Application.frameInstance.backToMapSelection(); + break; + case JAFFAWON: + JOptionPane.showMessageDialog(null, "Jaffa won!", "Game over", + JOptionPane.INFORMATION_MESSAGE, + new ImageIcon("Deal_with_iit.png")); + Application.frameInstance.backToMapSelection(); + break; + } } public void moveONeill(Direction direction) {