class UMenuBasicOptionsClientWindow expands UWindowDialogClientWindow;

// Auto Aim
var UWindowCheckbox AutoAimCheck;
var localized string[128] AutoAimText;

// Joystick
var UWindowCheckbox JoystickCheck;
var UMenuLabelControl JoystickLabel;
var localized string[128] JoystickText;

// Mouse Sensitivity
//var UWindowEditControl SensitivityEdit;
var UMenuLabelControl SensitivityLabel;
var localized string[128] SensitivityText;

// Invert Mouse
var UWindowCheckbox InvertMouseCheck;
var UMenuLabelControl InvertMouseLabel;
var localized string[128] InvertMouseText;

// Look Spring
var UWindowCheckbox LookSpringCheck;
var UMenuLabelControl LookSpringLabel;
var localized string[128] LookSpringText;

// Always Mouselook
var UWindowCheckbox MouselookCheck;
var UMenuLabelControl MouselookLabel;
var localized string[128] MouselookText;

// Auto Slope
var UWindowCheckbox AutoSlopeCheck;
var UMenuLabelControl AutoSlopeLabel;
var localized string[128] AutoSlopeText;

// Weapon Flash
var UWindowCheckbox WeaponFlashCheck;
var UMenuLabelControl WeaponFlashLabel;
var localized string[128] WeaponFlashText;

// Crosshair
var UMenuLabelControl CrosshairLabel;
var localized string[128] CrosshairText;

// Weapon Hand
//var UWindowEditControl WeaponHandEdit;
var UMenuLabelControl WeaponHandLabel;
var localized string[128] WeaponHandText;

// Dodging
var UWindowCheckbox DodgingCheck;
var UMenuLabelControl DodgingLabel;
var localized string[128] DodgingText;

// HUD Config
//var UWindowEditControl HUDConfigEdit;
var UMenuLabelControl HUDConfigLabel;
var localized string[128] HUDConfigText;

// View Bob
//var UWindowEditControl ViewBobEdit;
var UMenuLabelControl ViewBobLabel;
var localized string[128] ViewBobText;

function Created()
{
	local bool bJoystick;
	local int CheckWidth, CheckPos;

	CheckWidth = WinWidth - 100;
	CheckPos = (WinWidth - CheckWidth)/2;

	// Auto Aim
	AutoAimCheck = UWindowCheckbox(CreateWindow(class'UWindowCheckbox', CheckPos, 20, CheckWidth, 1));
	AutoAimCheck.Register(Self);
	if (Root.PlayerOwner.MyAutoAim < 1.0)
		AutoAimCheck.bChecked = true;
	AutoAimCheck.SetText(AutoAimText);
	AutoAimCheck.SetFont(Root.TahomaFont);

	// Joystick
	JoystickCheck = UWindowCheckbox(CreateWindow(class'UWindowCheckbox', CheckPos, 40, CheckWidth, 1));
	JoystickCheck.Register(Self);
	bJoystick =	bool(Root.PlayerOwner.ConsoleCommand("get windrv.windowsclient usejoystick"));
	if (bJoystick)
		JoystickCheck.bChecked = true;
	JoystickCheck.SetText(JoystickText);
	JoystickCheck.SetFont(Root.TahomaFont);

	// Mouse Sensitivity
	SensitivityLabel = UMenuLabelControl(CreateWindow(class'UMenuLabelControl', CheckPos, 60, CheckWidth, 1));
	SensitivityLabel.SetText(SensitivityText);
	SensitivityLabel.SetFont(Root.TahomaFont);

	// Invert Mouse
	InvertMouseCheck = UWindowCheckbox(CreateWindow(class'UWindowCheckbox', CheckPos, 80, CheckWidth, 1));
	InvertMouseCheck.Register(self);
	if (Root.PlayerOwner.bInvertMouse)
		InvertMouseCheck.bChecked = true;
	InvertMouseCheck.SetText(InvertMouseText);
	InvertMouseCheck.SetFont(Root.TahomaFont);

	// Look Spring
	LookSpringCheck = UWindowCheckbox(CreateWindow(class'UWindowCheckbox', CheckPos, 100, CheckWidth, 1));
	LookSpringCheck.Register(self);
	if (Root.PlayerOwner.bSnapToLevel)
		LookSpringCheck.bChecked = true;
	LookSpringCheck.SetText(LookSpringText);
	LookSpringCheck.SetFont(Root.TahomaFont);

	// Always Mouselook
	MouselookCheck = UWindowCheckbox(CreateWindow(class'UWindowCheckbox', CheckPos, 120, CheckWidth, 1));
	MouselookCheck.Register(self);
	if (Root.PlayerOwner.bAlwaysMouselook)
		MouselookCheck.bChecked = true;
	MouselookCheck.SetText(MouselookText);
	MouselookCheck.SetFont(Root.TahomaFont);

	// Auto Slope
	AutoSlopeCheck = UWindowCheckbox(CreateWindow(class'UWindowCheckbox', CheckPos, 140, CheckWidth, 1));
	AutoSlopeCheck.Register(self);
	if (Root.PlayerOwner.bLookUpStairs)
		AutoSlopeCheck.bChecked = true;
	AutoSlopeCheck.SetText(AutoSlopeText);
	AutoSlopeCheck.SetFont(Root.TahomaFont);

	// Weapon Flash
	WeaponFlashCheck = UWindowCheckbox(CreateWindow(class'UWindowCheckbox', CheckPos, 160, CheckWidth, 1));
	WeaponFlashCheck.Register(self);
	if (!Root.PlayerOwner.bNoFlash)
		WeaponFlashCheck.bChecked = true;
	WeaponFlashCheck.SetText(WeaponFlashText);
	WeaponFlashCheck.SetFont(Root.TahomaFont);
	
	// Crosshair
	CrosshairLabel = UMenuLabelControl(CreateWindow(class'UMenuLabelControl', CheckPos, 180, CheckWidth, 1));
	CrosshairLabel.SetText(CrosshairText);
	CrosshairLabel.SetFont(Root.TahomaFont);
	
	// Weapon Hand
	WeaponHandLabel = UMenuLabelControl(CreateWindow(class'UMenuLabelControl', CheckPos, 200, CheckWidth, 1));
	WeaponHandLabel.SetText(WeaponHandText);
	WeaponHandLabel.SetFont(Root.TahomaFont);

	// Dodging
	DodgingCheck = UWindowCheckbox(CreateWindow(class'UWindowCheckbox', CheckPos, 220, CheckWidth, 1));
	DodgingCheck.Register(self);
	if (Root.PlayerOwner.DodgeClickTime > 0)
		DodgingCheck.bChecked = true;
	DodgingCheck.SetText(DodgingText);
	DodgingCheck.SetFont(Root.TahomaFont);

	// HUD Config
	HUDConfigLabel = UMenuLabelControl(CreateWindow(class'UMenuLabelControl', CheckPos, 240, CheckWidth, 1));
	HUDConfigLabel.SetText(HUDConfigText);
	HUDConfigLabel.SetFont(Root.TahomaFont);

	// View Bob
	ViewBobLabel = UMenuLabelControl(CreateWindow(class'UMenuLabelControl', CheckPos, 260, CheckWidth, 1));
	ViewBobLabel.SetText(ViewBobText);
	ViewBobLabel.SetFont(Root.TahomaFont);
}

function Paint(Canvas C, float X, float Y)
{
	Super.Paint(C, X, Y);
}

function BeforePaint(Canvas C, float X, float Y)
{
	local int CheckWidth, CheckPos;

	CheckWidth = WinWidth - 100;
	CheckPos = (WinWidth - CheckWidth)/2;

	AutoAimCheck.SetSize(CheckWidth, 1);
	AutoAimCheck.WinLeft = CheckPos;

	JoystickCheck.SetSize(CheckWidth, 1);
	JoystickCheck.WinLeft = CheckPos;

	SensitivityLabel.SetSize(CheckWidth, 1);
	SensitivityLabel.WinLeft = CheckPos;

	InvertMouseCheck.SetSize(CheckWidth, 1);
	InvertMouseCheck.WinLeft = CheckPos;

	LookSpringCheck.SetSize(CheckWidth, 1);
	LookSpringCheck.WinLeft = CheckPos;

	MouselookCheck.SetSize(CheckWidth, 1);
	MouselookCheck.WinLeft = CheckPos;

	AutoSlopeCheck.SetSize(CheckWidth, 1);
	AutoSlopeCheck.WinLeft = CheckPos;

	WeaponFlashCheck.SetSize(CheckWidth, 1);
	WeaponFlashCheck.WinLeft = CheckPos;

	CrosshairLabel.SetSize(CheckWidth, 1);
	CrosshairLabel.WinLeft = CheckPos;

	WeaponHandLabel.SetSize(CheckWidth, 1);
	WeaponHandLabel.WinLeft = CheckPos;

	DodgingCheck.SetSize(CheckWidth, 1);
	DodgingCheck.WinLeft = CheckPos;

	HUDConfigLabel.SetSize(CheckWidth, 1);
	HUDConfigLabel.WinLeft = CheckPos;

	ViewBobLabel.SetSize(CheckWidth, 1);
	ViewBobLabel.WinLeft = CheckPos;
}

function Notify(UWindowDialogControl C, byte E)
{
	
	switch(E)
	{
	case DE_Change:
		switch(C)
		{
		case AutoAimCheck:
			AutoAimChecked();
			break;
		case JoystickCheck:
			JoystickChecked();
			break;
		case InvertMouseCheck:
			InvertMouseChecked();
			break;
		case LookSpringCheck:
			LookSpringChecked();
			break;
		case MouselookCheck:
			MouselookChecked();
			break;
		case AutoSlopeCheck:
			AutoSlopeChecked();
			break;
		case WeaponFlashCheck:
			WeaponFlashChecked();
		case DodgingCheck:
			DodgingChecked();
		}
	}

}

/*
 * Message Crackers
 */

function AutoAimChecked()
{
	if(AutoAimCheck.bChecked)
	{
		Root.PlayerOwner.ChangeAutoAim(0.93);
	} else {
		Root.PlayerOwner.ChangeAutoAim(1.0);
	}
}

function JoystickChecked()
{
	if(JoystickCheck.bChecked)
	{
		Root.PlayerOwner.ConsoleCommand("set windrv.windowsclient usejoystick 1");
	} else {
		Root.PlayerOwner.ConsoleCommand("set windrv.windowsclient usejoystick 0");
	}
}

function InvertMouseChecked()
{
	if(InvertMouseCheck.bChecked)
	{
		Root.PlayerOwner.bInvertMouse = true;
	} else {
		Root.PlayerOwner.bInvertMouse = false;
	}
}

function LookSpringChecked()
{
	if(LookSpringCheck.bChecked)
	{
		Root.PlayerOwner.bSnapToLevel = true;
	} else {
		Root.PlayerOwner.bSnapToLevel = false;
	}
}

function MouselookChecked()
{
	if(MouselookCheck.bChecked)
	{
		Root.PlayerOwner.bAlwaysMouseLook = true;
	} else {
		Root.PlayerOwner.bAlwaysMouseLook = false;
	}
}

function AutoSlopeChecked()
{
	if(AutoSlopeCheck.bChecked)
	{
		Root.PlayerOwner.bLookUpStairs = true;
	} else {
		Root.PlayerOwner.bLookUpStairs = false;
	}
}

function WeaponFlashChecked()
{
	if(WeaponFlashCheck.bChecked)
	{
		Root.PlayerOwner.bNoFlash = false;
	} else {
		Root.PlayerOwner.bNoFlash = true;
	}
}

function DodgingChecked()
{
	if(DodgingCheck.bChecked)
	{
		Root.PlayerOwner.ChangeDodgeClickTime(0.25);
	} else {
		Root.PlayerOwner.ChangeDodgeClickTime(-1.0);
	}
}

defaultproperties
{
	NumOptions=13
	NumVisible=8
	AutoAimText="Auto Aim"
	JoystickText="Joystick"
	SensitivityText="Mouse Sensitivity"
	InvertMouseText="Invert Mouse"
	LookSpringText="Look Spring"
	MouselookText="Always Mouselook"
	AutoSlopeText="Auto Slope"
	WeaponFlashText="Weapon Flash"
	CrosshairText="Crosshair"
	WeaponHandText="Weapon Hand"
	DodgingText="Dodging"
	HUDConfigText="HUD Configuration"
	ViewBobText="View Bob"
}
