// MissionReportDlg.cpp : implementation file
//

#include "stdafx.h"
#include "mw4gameed2.h"
#include "MissionReportDlg.h"
#include "GameInterface.h"


/////////////////////////////////////////////////////////////////////////////
// CMissionReportDlg dialog


CMissionReportDlg::CMissionReportDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMissionReportDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMissionReportDlg)
	m_RepEdit = _T("");
	//}}AFX_DATA_INIT
}


void CMissionReportDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMissionReportDlg)
	DDX_Control(pDX, IDC_REPEDIT, m_RepCtrl);
	DDX_Text(pDX, IDC_REPEDIT, m_RepEdit);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMissionReportDlg, CDialog)
	//{{AFX_MSG_MAP(CMissionReportDlg)
	ON_BN_CLICKED(IDC_EXIT, OnExit)
	ON_BN_CLICKED(IDC_SAVETOFILE, OnSavetofile)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMissionReportDlg message handlers

void CMissionReportDlg::OnOK() 
{
}

void CMissionReportDlg::OnCancel() 
{
//	CDialog::OnCancel();
}

BOOL CMissionReportDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CFont font;
	CDC* pDC=GetDC();
	font.CreatePointFont(90,"Courier New",pDC);
	m_RepCtrl.SetFont(&font);
	font.Detach();
	ReleaseDC(pDC);
	Report.GetReport(m_RepEdit);
	m_RepEdit.Replace("\n","\x0D\x0A");
	UpdateData(FALSE);

	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CMissionReportDlg::OnExit() 
{
		CDialog::OnOK();
}

void CMissionReportDlg::OnSavetofile() 
{
CFileDialog dlg1(FALSE,"Mission Reports",Report.GetMissionName()+".report",OFN_NOCHANGEDIR,"Reports (*.report)|*.report||",this);
	if(dlg1.DoModal()==IDOK)
	{
		FileStream file;
		file.Open(dlg1.GetPathName(),FileStream::WriteOnly);
		file<<(LPCSTR)m_RepEdit;
		file.Close();
	}	
	
}
