import javax.swing.*;
import java.awt.*;

public class MainFrame extends JFrame {

    private CardLayout cardLayout;
    private JPanel mainPanel;

    public MainFrame() {
        setTitle("Spiel UI mit CardLayout");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(1500, 1000);
        setLocationRelativeTo(null);

        // CardLayout und Hauptpanel erstellen
        cardLayout = new CardLayout();
        mainPanel = new JPanel(cardLayout);

        // Verschiedene Panels erstellen und hinzufügen
        MainMenuView mainMenuView = new MainMenuView(this);
        startLocalGame localGame = new startLocalGame(this);
        startMultiplayerGame multiplayerGame = new startMultiplayerGame(this);
        coinToss coinToss = new coinToss(this);

        mainPanel.add(mainMenuView, "MainMenu");
        mainPanel.add(localGame, "LocalGame");
        mainPanel.add(multiplayerGame, "MultiplayerGame");
        mainPanel.add(coinToss, "coinToss");

        // Hauptpanel in JFrame hinzufügen
        add(mainPanel);

        // Hauptmenü anzeigen
        cardLayout.show(mainPanel, "MainMenu");
    }

    // Methode, um die Ansicht zu wechseln
    public void showPanel(String panelName) {
        cardLayout.show(mainPanel, panelName);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            MainFrame frame = new MainFrame();
            frame.setVisible(true);
        });
    }
}