//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 ControlsDisplayCenterButton(name, callback)
{
	this.__proto__ = new Button(name, callback);
	
	this.DrawText = function(selected)
	{
		var displayText = "Display Controls";
		
		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 = gControlsDisplaySetting;
		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 ControlsDisplayButton()
{
	function ControlsDisplay(dir)
	{
	
		if(dir == 1)
		{
			switch(gControlsDisplaySetting)
			{
				case EControlsDisplaySetting.Never:
					gControlsDisplaySetting = EControlsDisplaySetting.Tutorial;
					break;
				case EControlsDisplaySetting.Tutorial:
					gControlsDisplaySetting = EControlsDisplaySetting.Always;
					break;
				case EControlsDisplaySetting.Always:
					gControlsDisplaySetting = EControlsDisplaySetting.Never;
					break;
			}
		}
		else
		{
			switch(gControlsDisplaySetting)
			{
				case EControlsDisplaySetting.Never:
					gControlsDisplaySetting = EControlsDisplaySetting.Always;
					break;
				case EControlsDisplaySetting.Tutorial:
					gControlsDisplaySetting = EControlsDisplaySetting.Never;
					break;
				case EControlsDisplaySetting.Always:
					gControlsDisplaySetting = EControlsDisplaySetting.Tutorial;
					break;
			}
		}
		gControlsOverlay.Init();
		gStorage.setItem("options", "display", "controls", gControlsDisplaySetting);
	}

	this.__proto__ = new TripleButton("controlsdisplay",
		new Button("<", function()
		{
			ControlsDisplay(-1);
			gOptionsMenu.Redraw();
		}),
		new ControlsDisplayCenterButton(name, function(){
			ControlsDisplay(1);
			gOptionsMenu.Redraw();
		}),
		new Button(">", function()
		{
			ControlsDisplay(1);
			gOptionsMenu.Redraw();
		})
	);
}
