package speiger.src.coreengine.rendering.inputOld.events;

import speiger.src.coreengine.rendering.inputOld.window.ScaledResolution;
import speiger.src.coreengine.utils.eventbus.Event;

public abstract class MouseEvent extends Event
{
	final long windowId;
	int mouseX;
	int mouseY;
	final int originX;
	final int originY;
	
	public MouseEvent(long windowId, int x, int y) {
		this.windowId = windowId;
		mouseX = x;
		mouseY = y;
		originX = x;
		originY = y;
	}
	
	public long getWindowId() { return windowId; }
	public int getX() { return mouseX; }
	public int getY() { return mouseY; }
	public void setX(int x) { mouseX = x; }
	public void setY(int y) { mouseY = y; }
	public int getOriginX() { return originX; }
	public int getOriginY() { return originY; }
	
	public void convertToOrigin() {
		mouseX = originX;
		mouseY = originY;
	}
	
	public void convertToScreenCoords(ScaledResolution res) {
		res.getScaledMouseEvent(this);
	}
	
	@Override
	public boolean isCancelable() { return true; }
	public boolean isForced() { return false; }
	
	public static class MouseClickEvent extends MouseEvent {
		final int button;
		final boolean press;
		
		public MouseClickEvent(long windowId, int x, int y, int button, boolean press) {
			super(windowId, x, y);
			this.button = button;
			this.press = press;
		}
		
		//Forced so Buttons are always released. Maybe gets disabled. Not sure yet
		@Override
		public boolean isForced() { return !press; }
		public int getButton() { return button; }
		public boolean isPress() { return press; }
	}
	
	public static class MouseMoveEvent extends MouseEvent {
		final int xMove;
		final int yMove;
		
		public MouseMoveEvent(long windowId, int x, int y, int xMove, int yMove) {
			super(windowId, x, y);
			this.xMove = xMove;
			this.yMove = yMove;
		}
		
		public int getXMove() { return xMove; }
		public int getYMove() { return yMove; }
	}
	
	public static class MouseScrollEvent extends MouseEvent {
		final int scrollX;
		final int scrollY;
		
		public MouseScrollEvent(long windowId, int x, int y, int scrollX, int scrollY) {
			super(windowId, x, y);
			this.scrollX = scrollX;
			this.scrollY = scrollY;
		}
		
		public int getScrollX() { return scrollX; }
		public int getScrollY() { return scrollY; }
	}
}
