package fr.monkhanny.dorfromantik.listeners;

import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;

import fr.monkhanny.dorfromantik.enums.Sounds;
import fr.monkhanny.dorfromantik.utils.MusicPlayer;

public class GameModeHoverEffectMouseListener extends MouseAdapter {
    private Color defaultColor;
    private Color hoverColor;
    private Color clickColor;

    public GameModeHoverEffectMouseListener(Color defaultColor, Color hoverColor, Color clickColor) {
        this.defaultColor = defaultColor;
        this.hoverColor = hoverColor;
        this.clickColor = clickColor;
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        if (e.getSource() instanceof JButton button) {
            button.setBackground(hoverColor);
            MusicPlayer.loadSound(Sounds.SOUNDS1);  // Charge le son
            MusicPlayer.playSound();                // Joue le son
        }
    }

    @Override
    public void mouseExited(MouseEvent e) {
        if (e.getSource() instanceof JButton button) {
            button.setBackground(defaultColor);
        }
    }

    @Override
    public void mousePressed(MouseEvent e) {
        if (e.getSource() instanceof JButton button) {
            button.setBackground(clickColor);
        }
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        if (e.getSource() instanceof JButton button) {
            button.setBackground(hoverColor);
        }
    }
}
