// GameOptions.cpp : implementation file
//

#include "stdafx.h"
#include "Noughts.h"
#include "GameOptions.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CGameOptions dialog


CGameOptions::CGameOptions(CWnd* pParent /*=NULL*/)
	: CDialog(CGameOptions::IDD, pParent)
{
	
	//{{AFX_DATA_INIT(CGameOptions)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CGameOptions::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Check(pDX, IDC_NOSWAP, noswap);

	CButton* radio = (CButton*) GetDlgItem(IDC_RADIO1);
	if (!player1) radio->SetCheck(TRUE); else radio->SetCheck(0);
	radio = (CButton*) GetDlgItem(IDC_RADIO2);
	if (player1==1) radio->SetCheck(TRUE); else radio->SetCheck(0);
	radio = (CButton*) GetDlgItem(IDC_RADIO3);
	if (player1==2) radio->SetCheck(TRUE); else radio->SetCheck(0);

	radio = (CButton*) GetDlgItem(IDC_RADIO4);
	if (!player2) radio->SetCheck(TRUE); else radio->SetCheck(0);
	radio = (CButton*) GetDlgItem(IDC_RADIO5);
	if (player2==1) radio->SetCheck(TRUE); else radio->SetCheck(0);
	radio = (CButton*) GetDlgItem(IDC_RADIO6);
	if (player2==2) radio->SetCheck(TRUE); else radio->SetCheck(0);


	//{{AFX_DATA_MAP(CGameOptions)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CGameOptions, CDialog)
	//{{AFX_MSG_MAP(CGameOptions)
	ON_BN_CLICKED(IDC_OK, OnOk)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
	ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
	ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
	ON_BN_CLICKED(IDC_RADIO6, OnRadio6)
	ON_BN_CLICKED(IDC_CANCEL, OnCancel)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGameOptions message handlers

afx_msg void CGameOptions::OnOk() 
{
	CDialog::OnOK();
	EndDialog(IDOK);
}

BOOL CGameOptions::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDialog::Create(IDD, pParentWnd);
}

void CGameOptions::OnCancel() 
{
	CDialog::OnCancel();
	// TODO: Add your control notification handler code here
	EndDialog(IDCANCEL);
}

afx_msg void CGameOptions::OnRadio1() 
{
	CButton* radio = (CButton*) GetDlgItem(IDC_RADIO1);
	radio->SetCheck(TRUE);
	radio = (CButton*) GetDlgItem(IDC_RADIO2);
	radio->SetCheck(0);
	radio = (CButton*) GetDlgItem(IDC_RADIO3);
	radio->SetCheck(0);
	player1=0;
}

afx_msg void CGameOptions::OnRadio2() 
{
	CButton* radio = (CButton*) GetDlgItem(IDC_RADIO2);
	radio->SetCheck(TRUE);
	radio = (CButton*) GetDlgItem(IDC_RADIO1);
	radio->SetCheck(0);
	radio = (CButton*) GetDlgItem(IDC_RADIO3);
	radio->SetCheck(0);
	player1=1;
}

afx_msg void CGameOptions::OnRadio3() 
{
	CButton* radio = (CButton*) GetDlgItem(IDC_RADIO3);
	radio->SetCheck(TRUE);
	radio = (CButton*) GetDlgItem(IDC_RADIO1);
	radio->SetCheck(0);
	radio = (CButton*) GetDlgItem(IDC_RADIO2);
	radio->SetCheck(0);
	player1=2;
}

afx_msg void CGameOptions::OnRadio4() 
{
	CButton* radio = (CButton*) GetDlgItem(IDC_RADIO4);
	radio->SetCheck(TRUE);
	radio = (CButton*) GetDlgItem(IDC_RADIO5);
	radio->SetCheck(0);
	radio = (CButton*) GetDlgItem(IDC_RADIO6);
	radio->SetCheck(0);
	player2=0;
}

void CGameOptions::OnRadio5() 
{
	CButton* radio = (CButton*) GetDlgItem(IDC_RADIO5);
	radio->SetCheck(TRUE);
	radio = (CButton*) GetDlgItem(IDC_RADIO4);
	radio->SetCheck(0);
	radio = (CButton*) GetDlgItem(IDC_RADIO6);
	radio->SetCheck(0);
	player2=1;	
}

void CGameOptions::OnRadio6() 
{
	CButton* radio = (CButton*) GetDlgItem(IDC_RADIO6);
	radio->SetCheck(TRUE);
	radio = (CButton*) GetDlgItem(IDC_RADIO5);
	radio->SetCheck(0);
	radio = (CButton*) GetDlgItem(IDC_RADIO4);
	radio->SetCheck(0);
	player2=2;
}
