GameSession starting added
Users can now start game by clicking on the mapname.
This commit is contained in:
parent
cf52cb6cba
commit
969b80c8eb
@ -6,13 +6,14 @@ import java.awt.*;
|
|||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ApplicationFrame implements Runnable
|
public class ApplicationFrame implements Runnable
|
||||||
{
|
{
|
||||||
private JFrame jframe;
|
private JFrame jframe;
|
||||||
|
|
||||||
private JPanel mapselectorpanel;
|
private JPanel mapselectorpanel;
|
||||||
private JPanel gamepanel;
|
private Display gamepanel;
|
||||||
|
|
||||||
private JList<File> filelist;
|
private JList<File> filelist;
|
||||||
|
|
||||||
@ -20,6 +21,12 @@ public class ApplicationFrame implements Runnable
|
|||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
jframe.remove(mapselectorpanel);
|
jframe.remove(mapselectorpanel);
|
||||||
|
File dungeonSource = ((JList<File>) e.getComponent()).getSelectedValue();
|
||||||
|
try {
|
||||||
|
setGameParams(dungeonSource);
|
||||||
|
} catch (IOException e1) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Nem sikerült ciát nyitni! :(");
|
||||||
|
}
|
||||||
jframe.add(gamepanel);
|
jframe.add(gamepanel);
|
||||||
jframe.revalidate();
|
jframe.revalidate();
|
||||||
}
|
}
|
||||||
@ -47,7 +54,7 @@ public class ApplicationFrame implements Runnable
|
|||||||
filelist.addMouseListener(new ListMouseHandler());
|
filelist.addMouseListener(new ListMouseHandler());
|
||||||
|
|
||||||
mapselectorpanel.add(filelist);
|
mapselectorpanel.add(filelist);
|
||||||
gamepanel = new JPanel();
|
|
||||||
|
|
||||||
jframe.add(mapselectorpanel);
|
jframe.add(mapselectorpanel);
|
||||||
|
|
||||||
@ -58,4 +65,12 @@ public class ApplicationFrame implements Runnable
|
|||||||
public void run() {
|
public void run() {
|
||||||
jframe.setVisible(true);
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user