|
@ -10,6 +10,10 @@ public class GameExplorer { |
|
|
private JPanel explorerPanel; |
|
|
private JPanel explorerPanel; |
|
|
private JPanel gamePanel; |
|
|
private JPanel gamePanel; |
|
|
private JPanel navigationPanel; |
|
|
private JPanel navigationPanel; |
|
|
|
|
|
private JPanel fleetstormPanel; |
|
|
|
|
|
private JPanel fourwinsPanel; |
|
|
|
|
|
private JPanel tictactoePanel; |
|
|
|
|
|
private JPanel leaderboardPanel; |
|
|
private JPanel border1; |
|
|
private JPanel border1; |
|
|
private JPanel border2; |
|
|
private JPanel border2; |
|
|
private JPanel border3; |
|
|
private JPanel border3; |
|
@ -26,6 +30,9 @@ public class GameExplorer { |
|
|
private Dimension btnSize; |
|
|
private Dimension btnSize; |
|
|
private GridBagConstraints gbc; |
|
|
private GridBagConstraints gbc; |
|
|
|
|
|
|
|
|
|
|
|
private enum Game { FLEETSTORM, FOURWINS, TICTACTOE, LEADERBOARD }; |
|
|
|
|
|
private Game actualGame; |
|
|
|
|
|
|
|
|
public GameExplorer() { |
|
|
public GameExplorer() { |
|
|
frame = new JFrame("1000 infomagische Spiele"); |
|
|
frame = new JFrame("1000 infomagische Spiele"); |
|
|
|
|
|
|
|
@ -157,11 +164,43 @@ public class GameExplorer { |
|
|
gamePanel.setLayout(new BorderLayout()); |
|
|
gamePanel.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
|
gamePanel.add(navigationPanel, BorderLayout.PAGE_START); |
|
|
gamePanel.add(navigationPanel, BorderLayout.PAGE_START); |
|
|
|
|
|
|
|
|
|
|
|
//use of dummy panels because real panels have not been implemented yet |
|
|
|
|
|
fleetstormPanel = new JPanel(); |
|
|
|
|
|
fleetstormPanel.setBackground(Color.BLUE); |
|
|
|
|
|
|
|
|
|
|
|
fourwinsPanel = new JPanel(); |
|
|
|
|
|
fourwinsPanel.setBackground(Color.GREEN); |
|
|
|
|
|
|
|
|
|
|
|
tictactoePanel = new JPanel(); |
|
|
|
|
|
tictactoePanel.setBackground(Color.YELLOW); |
|
|
|
|
|
|
|
|
|
|
|
leaderboardPanel = new JPanel(); |
|
|
|
|
|
leaderboardPanel.setBackground(Color.RED); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private class GameAction implements ActionListener { |
|
|
private class GameAction implements ActionListener { |
|
|
@Override |
|
|
@Override |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
//each button adds a different dummy panel to the gamePanel |
|
|
|
|
|
if (e.getSource() == fleetstormBtn) { |
|
|
|
|
|
actualGame = Game.FLEETSTORM; |
|
|
|
|
|
chosenGame.setText("Schiffe versenken"); |
|
|
|
|
|
gamePanel.add(fleetstormPanel, BorderLayout.CENTER); |
|
|
|
|
|
} else if (e.getSource() == fourwinsBtn) { |
|
|
|
|
|
actualGame = Game.FOURWINS; |
|
|
|
|
|
chosenGame.setText("Vier gewinnt"); |
|
|
|
|
|
gamePanel.add(fourwinsPanel, BorderLayout.CENTER); |
|
|
|
|
|
} else if (e.getSource() == tictactoeBtn) { |
|
|
|
|
|
actualGame = Game.TICTACTOE; |
|
|
|
|
|
chosenGame.setText("TicTacToe"); |
|
|
|
|
|
gamePanel.add(tictactoePanel, BorderLayout.CENTER); |
|
|
|
|
|
} else if (e.getSource() == leaderboardBtn) { |
|
|
|
|
|
actualGame = Game.LEADERBOARD; |
|
|
|
|
|
chosenGame.setText("Leaderboard"); |
|
|
|
|
|
gamePanel.add(leaderboardPanel, BorderLayout.CENTER); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
frame.remove(explorerPanel); |
|
|
frame.remove(explorerPanel); |
|
|
frame.add(gamePanel); |
|
|
frame.add(gamePanel); |
|
|
frame.revalidate(); |
|
|
frame.revalidate(); |
|
@ -172,6 +211,20 @@ public class GameExplorer { |
|
|
private class BackAction implements ActionListener { |
|
|
private class BackAction implements ActionListener { |
|
|
@Override |
|
|
@Override |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
switch (actualGame) { |
|
|
|
|
|
case FLEETSTORM: |
|
|
|
|
|
gamePanel.remove(fleetstormPanel); |
|
|
|
|
|
break; |
|
|
|
|
|
case FOURWINS: |
|
|
|
|
|
gamePanel.remove(fourwinsPanel); |
|
|
|
|
|
break; |
|
|
|
|
|
case TICTACTOE: |
|
|
|
|
|
gamePanel.remove(tictactoePanel); |
|
|
|
|
|
break; |
|
|
|
|
|
case LEADERBOARD: |
|
|
|
|
|
gamePanel.remove(leaderboardPanel); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
frame.remove(gamePanel); |
|
|
frame.remove(gamePanel); |
|
|
frame.add(explorerPanel); |
|
|
frame.add(explorerPanel); |
|
|
frame.revalidate(); |
|
|
frame.revalidate(); |
|
|