// EditSkillDlg.cpp : implementation file
//

#include "stdafx.h"
#include "mw4gameed.h"
#include "EditSkillDlg.hpp"

#include <Adept\Entity.hpp>
#include <mw4\AI.hpp>

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

/////////////////////////////////////////////////////////////////////////////
// EditSkillDlg dialog


EditSkillsDlg::EditSkillsDlg(Entity* entity, CWnd* pParent /*=NULL*/)
	: CDialog(EditSkillsDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(EditSkillDlg)
	pilotSkill = -1;
	gunnerySkill = -1;
	eliteSkill = -1;
	minHeatSkill = -1;
	maxHeatSkill = -1;
	sensor = -1;
	blind = -1;
	longrange = -1;
	shortrange = -1;
	//}}AFX_DATA_INIT

	m_entity = entity;
}


void EditSkillsDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(EditSkillDlg)
	DDX_Text(pDX, IDC_EDIT1, pilotSkill);
	DDX_Text(pDX, IDC_EDIT2, gunnerySkill);
	DDX_Text(pDX, IDC_EDIT3, eliteSkill);
	DDX_Text(pDX, IDC_EDIT4, minHeatSkill);
	DDX_Text(pDX, IDC_EDIT5, maxHeatSkill);
	DDX_Text(pDX, IDC_EDIT6, sensor);
	DDX_Text(pDX, IDC_EDIT7, blind);
	DDX_Text(pDX, IDC_EDIT8, longrange);
	DDX_Text(pDX, IDC_EDIT9, shortrange);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(EditSkillsDlg, CDialog)
	//{{AFX_MSG_MAP(EditSkillDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// EditSkillDlg message handlers

BOOL EditSkillsDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	MWObject *obj;

	obj = Cast_Object (MWObject *,m_entity);

	pilotSkill = obj->m_AI->RootPilotSkill ();
	gunnerySkill = obj->m_AI->RootGunnerySkill ();
	eliteSkill = obj->m_AI->RootEliteSkill ();
	minHeatSkill = obj->m_AI->RootMinHeatSkill ();
	maxHeatSkill = obj->m_AI->RootMaxHeatSkill ();
	sensor = obj->m_AI->RootSensorSkill ();
	blind = obj->m_AI->RootBlindFightingSkill ();
	longrange = obj->m_AI->RootLongRangeGunnerySkill ();
	shortrange = obj->m_AI->RootShortRangeGunnerySkill ();

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

void EditSkillsDlg::OnOK()
{
	UpdateData(TRUE);

	MWObject *obj;

	obj = Cast_Object (MWObject *,m_entity);
	obj->m_AI->PilotSkill(pilotSkill);
	obj->m_AI->GunnerySkill(gunnerySkill);
	obj->m_AI->EliteSkill(eliteSkill);
	obj->m_AI->MinHeatSkill(minHeatSkill);
	obj->m_AI->MaxHeatSkill(maxHeatSkill);
	obj->m_AI->SensorSkill(sensor);
	obj->m_AI->BlindFightingSkill(blind);
	obj->m_AI->LongRangeGunnerySkill(longrange);
	obj->m_AI->ShortRangeGunnerySkill(shortrange);
	
	CDialog::OnOK();
}
