// ObjectiveDLG.cpp : implementation file
//

#include "stdafx.h"
#include "mw4gameed.h"
#include "ObjectiveDLG.h"
#include <MW4\Objective.hpp>

using namespace MechWarrior4;

/////////////////////////////////////////////////////////////////////////////
// ObjectiveDLG dialog


ObjectiveDLG::ObjectiveDLG(Objective* entity,CWnd* pParent /*=NULL*/)
	: CDialog(ObjectiveDLG::IDD, pParent)
{
	//{{AFX_DATA_INIT(ObjectiveDLG)
	m_Visible = FALSE;
	m_State = FALSE;
	m_Description = _T("");
	m_Failed = _T("");
	m_Incomplete = _T("");
	m_Success = _T("");
	m_Primary = FALSE;
	m_HelpMessage = FALSE;
	m_Objective = entity;
	//}}AFX_DATA_INIT
}


void ObjectiveDLG::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(ObjectiveDLG)
	DDX_Check(pDX, IDC_VisibleObjective, m_Visible);
	DDX_Check(pDX, IDC_StateObjective, m_State);
	DDX_Text(pDX, IDC_DESCEDIT, m_Description);
	DDV_MaxChars(pDX, m_Description, 255);
	DDX_Text(pDX, IDC_FAILEDIT, m_Failed);
	DDV_MaxChars(pDX, m_Failed, 255);
	DDX_Text(pDX, IDC_INCEDIT, m_Incomplete);
	DDV_MaxChars(pDX, m_Incomplete, 255);
	DDX_Text(pDX, IDC_SUCCESSEDIT, m_Success);
	DDV_MaxChars(pDX, m_Success, 255);
	DDX_Check(pDX, IDC_PrimaryObjective, m_Primary);
	DDX_Check(pDX, IDC_HELPOBJETIVE, m_HelpMessage);

	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(ObjectiveDLG, CDialog)
	//{{AFX_MSG_MAP(ObjectiveDLG)
	ON_BN_CLICKED(IDC_StateObjective, OnStateObjective)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// ObjectiveDLG message handlers

void ObjectiveDLG::OnStateObjective() 
{
	// TODO: Add your control notification handler code here

}

BOOL ObjectiveDLG::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here

	m_Visible = m_Objective->m_VisibleObjective;
	m_Primary = m_Objective->m_Primary;
	m_State = m_Objective->m_ObjectiveState;
	m_HelpMessage = m_Objective->m_HelpMessage;

	m_Description = m_Objective->m_DescriptionText;
	m_Failed = m_Objective->m_FailText;
	m_Success = m_Objective->m_SucceedText;
	m_Incomplete = m_Objective->m_NeutralText;

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

void ObjectiveDLG::OnOK() 
{
	// TODO: Add extra validation here

	UpdateData(TRUE);

	Check_Object (m_Objective);
#pragma warning (disable:4800)
	m_Objective->m_VisibleObjective = (bool) m_Visible;
	m_Objective->m_Primary = (bool) m_Primary;
	m_Objective->m_HelpMessage = (bool) m_HelpMessage;
#pragma warning (default:4800)
	m_Objective->m_ObjectiveState = m_State;

	Str_Copy (m_Objective->m_FailText,((LPCTSTR) m_Failed),sizeof (m_Objective->m_FailText));
	Str_Copy (m_Objective->m_SucceedText,((LPCTSTR) m_Success),sizeof (m_Objective->m_SucceedText));
	Str_Copy (m_Objective->m_NeutralText,((LPCTSTR) m_Incomplete),sizeof (m_Objective->m_NeutralText));
	Str_Copy (m_Objective->m_DescriptionText,((LPCTSTR) m_Description),sizeof (m_Objective->m_DescriptionText));
	
	CDialog::OnOK();
}
