package client.window;

import client.Client;

public enum Button implements Input {
	MOUSE_LEFT("lmb", "Linke Maustaste"),
	MOUSE_RIGHT("rmb", "Rechte Maustaste"),
	MOUSE_MIDDLE("mmb", "Mausrad-Taste"),
	MOUSE_BTN_X("xmb", "Maus Seite 1"),
	MOUSE_BTN_Y("ymb", "Maus Seite 2"),
	MOUSE_BTN_A("m6", "Maustaste 6"),
	MOUSE_BTN_B("m7", "Maustaste 7"),
	MOUSE_BTN_C("m8", "Maustaste 8");
	
	private static int buttons;
	
	private final String id;
	private final String name;
	
	private boolean down;
	
	public static boolean isMouseDown() {
		return buttons != 0;
	}
	
	private Button(String id, String name) {
		this.id = id;
		this.name = name;
	}

	public String getName() {
		return this.id;
	}

	public String getDisplay() {
		return this.name;
	}

	public boolean read() {
		return Client.CLIENT.open == null && this.down;
	}
	
	public void setDown(boolean down) {
		this.down = down;
		buttons = (buttons & ~(1 << this.ordinal())) | (down ? 1 << this.ordinal() : 0);
	}
	
	public boolean isDown() {
		return this.down;
	}
}
