Complete overhaul of Application & ApplicationFrame so that game can end
This commit is contained in:
parent
5585028819
commit
3be072e282
@ -2,10 +2,11 @@ package cicaprojekt;
|
|||||||
|
|
||||||
public class Application
|
public class Application
|
||||||
{
|
{
|
||||||
|
public static final ApplicationFrame frameInstance = new ApplicationFrame();
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
ApplicationFrame af = new ApplicationFrame();
|
frameInstance.init();
|
||||||
af.init();
|
frameInstance.run();
|
||||||
af.run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,24 @@ public class ApplicationFrame implements Runnable
|
|||||||
jframe.setMinimumSize(new Dimension(600, 400));
|
jframe.setMinimumSize(new Dimension(600, 400));
|
||||||
jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
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();
|
mapselectorpanel = new JPanel();
|
||||||
|
|
||||||
DefaultListModel<File> dungeonslist = new DefaultListModel<>();
|
DefaultListModel<File> dungeonslist = new DefaultListModel<>();
|
||||||
@ -58,14 +76,6 @@ public class ApplicationFrame implements Runnable
|
|||||||
filelist.addMouseListener(new ListMouseHandler());
|
filelist.addMouseListener(new ListMouseHandler());
|
||||||
|
|
||||||
mapselectorpanel.add(filelist);
|
mapselectorpanel.add(filelist);
|
||||||
|
|
||||||
|
|
||||||
jframe.add(mapselectorpanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
jframe.setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setGameParams(File dungeonFile) throws IOException {
|
private void setGameParams(File dungeonFile) throws IOException {
|
||||||
|
@ -58,6 +58,28 @@ public class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stopGame(GameoverCause cause) {
|
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) {
|
public void moveONeill(Direction direction) {
|
||||||
|
Loading…
Reference in New Issue
Block a user