package zero1hd.polyjet.ui.builders;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.utils.Align;

public class GraphicsTable extends Table {
	private Label title;
	
	private SetResolutionButton 
	_3840x2160,
	_2560x1440,
	_1920x1200,
	_1920x1080,
	_1280x800,
	_1280x720,
	_1366x768,
	_800x480;
	
	
	public GraphicsTable(Skin skin, final Preferences pref) {
		align(Align.center);
		defaults().space(10f);
		
		title = new Label("Optimized Resolutions", skin);
		add(title).left();
		row();
		
		
		TextButton fullscreen = new TextButton("Fullscreen", skin);
		fullscreen.addListener(new ChangeListener() {
			
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				if (!Gdx.graphics.isFullscreen()) {
					Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
					pref.putBoolean("fullscreen", true);
					pref.flush();
				}
			}
		});
		add(fullscreen).fillX();
		row();
		
		_3840x2160 = new SetResolutionButton(3840, 2160, skin, pref);
		add(_3840x2160).fillX();
		row();
		
		_2560x1440 = new SetResolutionButton(2560, 1440, skin, pref);
		add(_2560x1440).fillX();
		row();
		
		_1920x1200 = new SetResolutionButton(1920, 1200, skin, pref);
		add(_1920x1200).fillX();
		row();
		
		_1920x1080 = new SetResolutionButton(1920, 1080, skin, pref);
		add(_1920x1080).fillX();
		row();
		
		_1280x800 = new SetResolutionButton(1280, 800, skin, pref);
		add(_1280x800).fillX();
		row();
		
		_1280x720 = new SetResolutionButton(1280, 720, skin, pref);
		add(_1280x720).fillX();
		row();
		
		_1366x768 = new SetResolutionButton(1366, 768, skin, pref);
		add(_1366x768).fillX();
		row();
		
		_800x480 = new SetResolutionButton(800, 480, skin, pref);
		add(_800x480).fillX();
		row();
	}
}
