package zero1hd.rhythmbullet.desktop.graphics.ui.components;

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 GraphicsOptions extends Table {
	private Label resolutions;
	
	private ResolutionButton 
	_3840x2160,
	_2560x1440,
	_1920x1200,
	_1920x1080,
	_1280x800,
	_1280x720,
	_1366x768;
	
	
	public GraphicsOptions(Skin skin, final Preferences prefs) {
		align(Align.center);
		defaults().space(10f);
		resolutions = new Label("Resolutions: ", skin);
		add(resolutions).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());
					prefs.putBoolean("fullscreen", true);
					prefs.flush();
				}
			}
		});
		add(fullscreen).fillX();
		row();
		
		_3840x2160 = new ResolutionButton(3840, 2160, skin, prefs);
		add(_3840x2160).fillX();
		row();
		
		_2560x1440 = new ResolutionButton(2560, 1440, skin, prefs);
		add(_2560x1440).fillX();
		row();
		
		_1920x1200 = new ResolutionButton(1920, 1200, skin, prefs);
		add(_1920x1200).fillX();
		row();
		
		_1920x1080 = new ResolutionButton(1920, 1080, skin, prefs);
		add(_1920x1080).fillX();
		row();
		
		_1280x800 = new ResolutionButton(1280, 800, skin, prefs);
		add(_1280x800).fillX();
		row();
		
		_1366x768 = new ResolutionButton(1366, 768, skin, prefs);
		add(_1366x768).fillX();
		row();
		
		_1280x720 = new ResolutionButton(1280, 720, skin, prefs);
		add(_1280x720).fillX();
		row();
		pack();
	}
}
