#include "StdAfx.h"
#include "VPinMAME.h"

#include "Controller.h"
#include "VPinMAMEDisclaimerDlg.h"
#include "ControllerOptions.h"

#include "resource.h"

#include <atlwin.h>

class CDisclaimerDlg : public CDialogImpl<CDisclaimerDlg> {
public:
	BEGIN_MSG_MAP(CDisclaimerDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_ID_HANDLER(IDOK, OnOK)
		COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
	END_MSG_MAP()

	enum { IDD = IDD_DISCLAIMERDLG };

private:
	Controller*	m_pController;

	LRESULT OnInitDialog(UINT, WPARAM, LPARAM lParam, BOOL&) {
		CenterWindow();
		m_pController = (Controller*) lParam;
		if ( !m_pController )
			return 1;

		SetDlgItemText(IDC_DISGAMESPEC, m_pController->m_ControllerOptions.szDescription);
		return 1;
	}

	LRESULT OnOK(WORD, UINT, HWND, BOOL&) {
		EndDialog(IsDlgButtonChecked(IDC_YESIAM)?IDOK:IDCANCEL);
		return 0;
	}

	LRESULT OnCancel(WORD, UINT, HWND, BOOL&) {
		EndDialog(IDCANCEL);
		return 0;
	}
};

BOOL ShowDisclaimer(HWND hParentWnd, Controller* pController) { 
	CDisclaimerDlg DisclaimerDlg;
	return DisclaimerDlg.DoModal(hParentWnd, (LPARAM) pController)==IDOK;
}
