package zero1hd.polyjet.screens;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20;

import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.ui.stages.CreativeStage;
import zero1hd.polyjet.ui.stages.GamePlayArea;

public class CreativeDebugScreen extends ScreenAdapter {
	CreativeStage creative;
	GamePlayArea gamePlayArea;
	InputMultiplexer inputs;
	
	Preferences prefs;
	
	public CreativeDebugScreen(Polyjet core, MainMenu mainMenu) {
		gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
		creative = new CreativeStage(core, mainMenu, gamePlayArea);
		
		inputs = new InputMultiplexer(creative, gamePlayArea);
		
		this.prefs = core.getPrefs();
	}
	
	@Override
	public void show() {
		Gdx.input.setInputProcessor(inputs);
		gamePlayArea.loadShaders(prefs);
		super.show();
	}
	
	@Override
	public void render(float delta) {
		Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

		gamePlayArea.getViewport().apply();
		gamePlayArea.act();
		gamePlayArea.draw();
		
		creative.getViewport().apply();
		creative.act();
		creative.draw();
		super.render(delta);
	}
	
	@Override
	public void resize(int width, int height) {
		super.resize(width, height);
	}
	
	@Override
	public void dispose() {
		dispose();
		super.dispose();
	}
}
