package client.gui.element;

import client.gui.Formatter;
import client.window.Button;

public class ActButton extends Element {
	private final ButtonCallback func;
	
	public ActButton(int x, int y, int w, int h, ButtonCallback callback, Formatter<ActButton> formatter) {
		super(x, y, w, h, formatter);
		this.func = callback;
		this.formatText();
	}
	
	public ActButton(int x, int y, int w, int h, ButtonCallback callback, String text) {
		super(x, y, w, h, null);
		this.func = callback;
		this.setText(text);
	}
	
	public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) {
		this.func.use(this, (ctrl || (btn == Button.MOUSE_MIDDLE)) ? PressType.TERTIARY : ((shift || (btn == Button.MOUSE_RIGHT)) ? PressType.SECONDARY : PressType.PRIMARY));
		this.formatText();
		this.playSound();
	}
}
