package fr.monkhanny.dorfromantik;

import fr.monkhanny.dorfromantik.gui.MainMenu;
import fr.monkhanny.dorfromantik.controller.MainMenuResizeController;
import fr.monkhanny.dorfromantik.controller.MainMenuButtonController;
import fr.monkhanny.dorfromantik.utils.MusicPlayer;
import fr.monkhanny.dorfromantik.enums.Musics;
import fr.monkhanny.dorfromantik.listeners.SettingsWindowListener;
import fr.monkhanny.dorfromantik.gui.SettingsPanel;
import fr.monkhanny.dorfromantik.controller.TutorialController;


import javax.swing.JFrame;

/**
 * Classe principale du jeu
 * @version 1.0
 * @author Moncef STITI
 * @see MainMenu
 * @see MainMenuResizeController
 */
public class Main {
  /**
   * Méthode principale du jeu
   * @param args Tableau de String contenant les arguments passé en paramètre au programme
   */
  public static void main(String[] args) {
    // Créer la fenêtre des paramètres
    JFrame settingsFrame = new JFrame("Paramètres");

    // Créer la fenêtre du tutoriel
    JFrame howToPlayFrame = new JFrame("Comment jouer ?");

    // Menu principal
    MusicPlayer.loadMusic(Musics.MAIN_MENU_MUSIC);
    MusicPlayer.playMusic();
    MainMenu mainMenu = new MainMenu();
    MainMenuResizeController MainMenuResizeController = new MainMenuResizeController(mainMenu);
    MainMenuButtonController MainMenuButtonController = new MainMenuButtonController(mainMenu,settingsFrame,howToPlayFrame);


    // Fenêtre des paramètres
    SettingsWindowListener windowListener = new SettingsWindowListener(mainMenu, settingsFrame);
    SettingsPanel settingsPanel = new SettingsPanel(mainMenu, settingsFrame);
    settingsFrame.addWindowListener(windowListener);
    settingsFrame.add(settingsPanel);
    settingsFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    // Fenêtre du tutoriel
    TutorialController tutorialController = new TutorialController();
    howToPlayFrame.addWindowListener(windowListener);
    howToPlayFrame.add(tutorialController.getTutorialPanel());
    howToPlayFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

  }
}
