package fr.monkhanny.dorfromantik.controller;

import fr.monkhanny.dorfromantik.gui.ButtonPanel;
import fr.monkhanny.dorfromantik.gui.ButtonHoverAnimator;

import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class MainMenuMouseController {

    private final ButtonPanel buttonPanel;

    public MainMenuMouseController(ButtonPanel buttonPanel) {
        this.buttonPanel = buttonPanel;
        initMouseListeners();
    }

    private void initMouseListeners() {
        addButtonHoverListener(buttonPanel.getNewGameButton());
        addButtonHoverListener(buttonPanel.getContinueGameButton());
        addButtonHoverListener(buttonPanel.getHowToPlayButton());
        addButtonHoverListener(buttonPanel.getSettingsButton());
        addButtonHoverListener(buttonPanel.getExitButton());
    }

    private void addButtonHoverListener(JButton button) {
        ButtonHoverAnimator animator = new ButtonHoverAnimator(button);
        button.addMouseListener(new ButtonHoverListener(animator));
    }
}
