package de.eightbitboy.ecorealms.control;

import java.util.ArrayList;
import java.util.List;

import de.eightbitboy.ecorealms.map.Position;

public class ControlActionMapping {

	public enum Action {
		LMB,
		RMB;

		public ActionInformation info() {
			return ControlActionMapping.getActionInformation();
		}
	}

	public class ActionInformation {
		public Position mousePositionOnMap = new Position(0, 0);

		void reset() {
			mousePositionOnMap = new Position(0, 0);
		}
	}

	public interface ActionListener {
		void action(Action action);
	}

	private static final ControlActionMapping INSTANCE = new ControlActionMapping();

	private List<ActionListener> listeners = new ArrayList<ActionListener>();

	private ActionInformation actionInformation = new ActionInformation();

	private ControlActionMapping() {
	}

	public static ControlActionMapping getInstance() {
		return INSTANCE;
	}

	public static void subscribe(ActionListener listener) {
		INSTANCE.listeners.add(listener);
	}

	public static ActionInformation getActionInformation() {
		return INSTANCE.actionInformation;
	}

	public void setMousePositionOnMap(Position position) {
		actionInformation.mousePositionOnMap = position;
	}

	void update() {
		actionInformation.reset();
	}
}

@@ -53,25 +53,23 @@
 va.util.
-ArrayList
+EnumMap
 ;%0Aimport
@@ -79,20 +79,19 @@
 va.util.
-List
+Map
 ;%0A%0Aimpor
@@ -629,21 +629,28 @@
 private 
-List%3C
+Map%3CAction, 
 ActionLi
@@ -677,18 +677,24 @@
 new 
-ArrayList%3C
+EnumMap%3CAction, 
 Acti
@@ -705,16 +705,28 @@
 stener%3E(
+Action.class
 );%0A%0A%09pri
@@ -937,16 +937,31 @@
 bscribe(
+Action action, 
 ActionLi
@@ -981,16 +981,18 @@
 er) %7B%0A%09%09
+//
 INSTANCE

Use EnumMap