//Copyright (C) Ben Parbury - All Rights Reserved. Unauthorized copying of this file, via any medium is strictly prohibited. Written by Ben Parbury <ben@gridlockinteractive.com> 2014


var gQualityNames = new Array("Incredible!", "Performant", "Fast", "Faster", "Fastest")
var gQualityValues = new Array(1, 1.25, 1.5, 1.75, 2)
var storedZoom = gStorage.getItem("options", "graphics", "zoom");
var gQualitySetting = storedZoom ? Math.max(gQualityValues.indexOf(parseFloat(storedZoom)), 0) : 0;

function QualityCenterButton(name, callback)
{
	this.__proto__ = new Button(name, callback);
	
	this.DrawText = function(selected)
	{
		var displayText = "Quality";
		
		var additional = this.mouseDown ? 1 : 0;
		gDraw.menu.font	 = GetFont(this.fontSize * 0.5);
		gDraw.menu.textAlign	 = 'center';
		gDraw.menu.textBaseline	 = 'bottom';
		gDraw.menu.fillTextShadow(displayText, this.x + additional, this.y + additional - (kTileSize * 0.2), this.GetTextColor(!this.locked), this.GetTextColor(this.locked));
		
		var settingText = gQualityNames[gQualitySetting]
		gDraw.menu.font	 = GetFont(this.fontSize * 0.7);
		gDraw.menu.textBaseline	 = 'top';
		gDraw.menu.fillTextShadow(settingText, this.x + additional, this.y + additional, this.GetTextColor(!this.locked), this.GetTextColor(this.locked));
	}
}

function QualityButton()
{
	this.__proto__ = new TripleButton("quality",
		new Button("<", function()
		{
			gQualitySetting++;
			if(gQualitySetting >= (gQualityValues.length))
			{
				gQualitySetting = 0;
			}
			gOptionsMenu.Redraw();
		}),
		new QualityCenterButton(name, function(){
			gQualitySetting--;
			if(gQualitySetting < 0)
			{
				gQualitySetting = (gQualityValues.length) - 1;
			}
			gOptionsMenu.Redraw();
		}),
		new Button(">", function()
		{
			gQualitySetting--;
			if(gQualitySetting < 0)
			{
				gQualitySetting = (gQualityValues.length) - 1;
			}
			gOptionsMenu.Redraw();
		})
	);
}
