package speiger.src.coreengine;

import java.nio.file.Path;

import org.lwjgl.glfw.GLFW;

import speiger.src.coreengine.application.Application;
import speiger.src.coreengine.rendering.inputOld.events.KeyEvent.KeyPressEvent;
import speiger.src.coreengine.rendering.inputOld.window.Window;
import speiger.src.coreengine.rendering.inputOld.window.WindowProvider;

public class Testing extends Application {
	public static void main(String... args) {
		System.out.println((int)1E-6F);
		new Testing().run();
	}
	
	
	@Override
	public String getMainWindowName() { return "Testing"; }
	
	@Override
	public boolean initUI() {
		return true;
	}
	
	
	
	@Override
	public Window createWindow(WindowProvider provider) throws Exception {
		return provider.createBuilder().setWidth(250).setHeight(250).setName("Testing").build();
	}
	
	@Override
	public void init(Path file) {
		eventBus.register(KeyPressEvent.class, this::addKeyPressed);
	}

	@Override
	public void update() {
	}

	@Override
	public void render(float particalTicks) {
	}

	@Override
	public void destroy() {
		
	}
	
	public void addKeyPressed(KeyPressEvent event) {
		if(event.key == GLFW.GLFW_KEY_F12) {
			getUiManager().getDebug().toggleDebug();
			event.cancel();
		}
		else if(event.key == GLFW.GLFW_KEY_PAGE_DOWN) {
			mainWindow.setAntiAliasing(Math.max(0, mainWindow.getAntiAliasingLevel()-1));
			event.cancel();
			System.out.println("AA: "+mainWindow.getAntiAliasingLevel());
		}
		else if(event.key == GLFW.GLFW_KEY_PAGE_UP) {
			mainWindow.setAntiAliasing(Math.min(4, mainWindow.getAntiAliasingLevel()+1));
			event.cancel();
			System.out.println("AA: "+mainWindow.getAntiAliasingLevel());
		}
	}
}
