package zero1hd.rhythmbullet.desktop;

import org.lwjgl.opengl.Display;

import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;

import zero1hd.rhythmbullet.util.ScreenConfiguration;

public class DesktopScreenConfiguration implements ScreenConfiguration {
	private LwjglApplicationConfiguration configuration;
	private boolean vSync;
	
	public DesktopScreenConfiguration(LwjglApplicationConfiguration configuration) {
		this.configuration = configuration;
		vSync = configuration.vSyncEnabled;
	}
	
	@Override
	public void setFramesPerSecond(int fps) {
		configuration.foregroundFPS = fps;
	}


	@Override
	public int getTargetFramesPerSecond() {
		return configuration.foregroundFPS;
	}

	@Override
	public void setVsync(boolean useVsync) {
		configuration.vSyncEnabled = useVsync;
		Display.setVSyncEnabled(useVsync);
	}

	@Override
	public boolean getVsync() {
		return vSync;
	}

	@Override
	public int getScreenWidth() {
		return Display.getDesktopDisplayMode().getWidth();
	}

	@Override
	public int getScreenHeight() {
		return Display.getDesktopDisplayMode().getHeight();
	}

	@Override
	public int getWindowPosX() {
		return Display.getX();
	}

	@Override
	public int getWindowPosY() {
		return Display.getY();
	}

	@Override
	public void setWindowLocationX(int x) {
		Display.setLocation(x, getWindowPosY());
	}

	@Override
	public void setWindowLocationY(int y) {
		Display.setLocation(getWindowPosX(), y);
	}
	
	@Override
	public void setWindowLocation(int x, int y) {
		Display.setLocation(x, y);
	}
	
	@Override
	public void queueBorderless(boolean borderless) {
		System.setProperty("org.lwjgl.opengl.Window.undecorated", String.valueOf(borderless));
	}
}
