|
|
@ -5,6 +5,9 @@ import java.awt.event.*; |
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
|
|
|
import de.tims.player_management.Player; |
|
|
|
import de.tims.player_management.PlayerManager; |
|
|
|
|
|
|
|
public class GameExplorer { |
|
|
|
|
|
|
|
private JFrame frame; |
|
|
@ -29,6 +32,7 @@ public class GameExplorer { |
|
|
|
private JButton leaderboardBtn; |
|
|
|
private JButton backBtn; |
|
|
|
private JLabel username; |
|
|
|
private JLabel loginWarning; |
|
|
|
private JLabel chosenGame; |
|
|
|
private JTextField usernameInput; |
|
|
|
private Dimension minSize; |
|
|
@ -36,10 +40,16 @@ public class GameExplorer { |
|
|
|
private Dimension btnSize; |
|
|
|
private GridBagConstraints gbc; |
|
|
|
|
|
|
|
private static final String playerFile = "src/main/java/resources/player_data.csv"; |
|
|
|
|
|
|
|
private enum Game { FLEETSTORM, FOURWINS, TICTACTOE, LEADERBOARD }; |
|
|
|
private Game actualGame; |
|
|
|
private PlayerManager manager; |
|
|
|
private Player actualPlayer; |
|
|
|
|
|
|
|
public GameExplorer() { |
|
|
|
manager = new PlayerManager(); |
|
|
|
|
|
|
|
frame = new JFrame("1000 infomagische Spiele"); |
|
|
|
|
|
|
|
minSize = new Dimension(400, 300); |
|
|
@ -141,7 +151,9 @@ public class GameExplorer { |
|
|
|
|
|
|
|
loginBtn = new JButton("Login"); |
|
|
|
loginBtn.setPreferredSize(loginBtnSize); |
|
|
|
loginBtn.addActionListener(new LoginAction()); |
|
|
|
username = new JLabel("Name eingeben:"); |
|
|
|
loginWarning = new JLabel(); |
|
|
|
usernameInput = new JTextField(8); |
|
|
|
|
|
|
|
gbc.weighty = 0; |
|
|
@ -157,8 +169,13 @@ public class GameExplorer { |
|
|
|
|
|
|
|
gbc.gridx = 0; |
|
|
|
gbc.gridy = 2; |
|
|
|
gbc.insets = new Insets(5, 0, 0, 0); |
|
|
|
gbc.insets = new Insets(5, 0, 5, 0); |
|
|
|
loginPanel.add(loginBtn, gbc); |
|
|
|
|
|
|
|
gbc.gridx = 0; |
|
|
|
gbc.gridy = 3; |
|
|
|
gbc.insets = new Insets(5, 0, 0, 0); |
|
|
|
loginPanel.add(loginWarning, gbc); |
|
|
|
} |
|
|
|
|
|
|
|
private void buildNavigationPanel() { |
|
|
@ -213,6 +230,30 @@ public class GameExplorer { |
|
|
|
leaderboardPanel.setBackground(Color.RED); |
|
|
|
} |
|
|
|
|
|
|
|
private class LoginAction implements ActionListener { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String userInput = usernameInput.getText(); |
|
|
|
|
|
|
|
if (!userInput.equals("")) { |
|
|
|
loginWarning.setText(""); |
|
|
|
|
|
|
|
manager.loadPlayers(playerFile); |
|
|
|
actualPlayer = manager.selectPlayer(userInput); |
|
|
|
|
|
|
|
frame.remove(loginPanel); |
|
|
|
frame.add(explorerPanel); |
|
|
|
frame.revalidate(); |
|
|
|
frame.repaint(); |
|
|
|
|
|
|
|
System.out.println("Actual Player: " + actualPlayer.getName() + ", Points: " + actualPlayer.getPoints()); |
|
|
|
} else { |
|
|
|
loginWarning.setText("Kein Name eingegeben!"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private class GameAction implements ActionListener { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|