//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

function AutoAdjustCenterButton(name, callback)
{
	this.__proto__ = new Button(name, callback);
	
	this.DrawText = function(selected)
	{
		var displayText = "Auto Adjust 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 = gAutoAdjustPerformance ? "Enabled" : "Disabled";
		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 AutoAdjustButton()
{
	function ToggleAutoAdjust()
	{
		gAutoAdjustPerformance = !gAutoAdjustPerformance;
		gStorage.setItem("options", "performance", "auto", gAutoAdjustPerformance ? 1 : 0);
	}
	this.__proto__ = new TripleButton("autoAdjust",
		new Button("<", function()
		{
			ToggleAutoAdjust();
			gOptionsMenu.Redraw();
		}),
		new AutoAdjustCenterButton(name, function(){
			ToggleAutoAdjust();
			gOptionsMenu.Redraw();
		}),
		new Button(">", function()
		{
			ToggleAutoAdjust();
			gOptionsMenu.Redraw();
		})
	);
}
