diff --git a/cicaprojekt/ApplicationFrame.java b/cicaprojekt/ApplicationFrame.java index d997c82..dfb04e8 100644 --- a/cicaprojekt/ApplicationFrame.java +++ b/cicaprojekt/ApplicationFrame.java @@ -6,13 +6,14 @@ import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.File; +import java.io.IOException; public class ApplicationFrame implements Runnable { private JFrame jframe; private JPanel mapselectorpanel; - private JPanel gamepanel; + private Display gamepanel; private JList filelist; @@ -20,6 +21,12 @@ public class ApplicationFrame implements Runnable @Override public void mouseClicked(MouseEvent e) { jframe.remove(mapselectorpanel); + File dungeonSource = ((JList) e.getComponent()).getSelectedValue(); + try { + setGameParams(dungeonSource); + } catch (IOException e1) { + JOptionPane.showMessageDialog(null, "Nem sikerült ciát nyitni! :("); + } jframe.add(gamepanel); jframe.revalidate(); } @@ -47,7 +54,7 @@ public class ApplicationFrame implements Runnable filelist.addMouseListener(new ListMouseHandler()); mapselectorpanel.add(filelist); - gamepanel = new JPanel(); + jframe.add(mapselectorpanel); @@ -58,4 +65,12 @@ public class ApplicationFrame implements Runnable public void run() { jframe.setVisible(true); } + + private void setGameParams(File dungeonFile) throws IOException { + gamepanel = new Display(); + Game.instance.setDisplay(gamepanel); + Game.instance.setDungeon(new Dungeon()); + Game.instance.startGame(dungeonFile); + + } }