// AblMemDlg.cpp : implementation file
//

#include "stdafx.h"
#include "mw4gameed.h"
#include "AblMemDlg.h"

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

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

/////////////////////////////////////////////////////////////////////////////
// AblMemDlg dialog


AblMemDlg::AblMemDlg(Entity* entity, CWnd* pParent /*=NULL*/)
	: CDialog(AblMemDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(AblMemDlg)
	m_Mem0 = 0.0f;
	m_Mem1 = 0.0f;
	m_Mem2 = 0.0f;
	m_Mem3 = 0.0f;
	m_Mem4 = 0.0f;
	m_Mem5 = 0.0f;
	m_Mem6 = 0.0f;
	m_Mem7 = 0.0f;
	m_Mem8 = 0.0f;
	m_Mem9 = 0.0f;
	//}}AFX_DATA_INIT

	m_entity = entity;
}


void AblMemDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(AblMemDlg)
	DDX_Text(pDX, IDC_EDIT1, m_Mem0);
	DDX_Text(pDX, IDC_EDIT2, m_Mem1);
	DDX_Text(pDX, IDC_EDIT3, m_Mem2);
	DDX_Text(pDX, IDC_EDIT4, m_Mem3);
	DDX_Text(pDX, IDC_EDIT5, m_Mem4);
	DDX_Text(pDX, IDC_EDIT6, m_Mem5);
	DDX_Text(pDX, IDC_EDIT7, m_Mem6);
	DDX_Text(pDX, IDC_EDIT8, m_Mem7);
	DDX_Text(pDX, IDC_EDIT9, m_Mem8);
	DDX_Text(pDX, IDC_EDIT10, m_Mem9);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(AblMemDlg, CDialog)
	//{{AFX_MSG_MAP(AblMemDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// AblMemDlg message handlers

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

	obj = Cast_Object (MWObject *,m_entity);

	m_Mem0 = obj->m_AI->RealMemory(0);
	m_Mem1 = obj->m_AI->RealMemory(1);
	m_Mem2 = obj->m_AI->RealMemory(2);
	m_Mem3 = obj->m_AI->RealMemory(3);
	m_Mem4 = obj->m_AI->RealMemory(4);
	m_Mem5 = obj->m_AI->RealMemory(5);
	m_Mem6 = obj->m_AI->RealMemory(6);
	m_Mem7 = obj->m_AI->RealMemory(7);
	m_Mem8 = obj->m_AI->RealMemory(8);
	m_Mem9 = obj->m_AI->RealMemory(9);

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

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

	MWObject *obj;

	obj = Cast_Object (MWObject *,m_entity);
	obj->m_AI->RealMemory(0,m_Mem0);
	obj->m_AI->RealMemory(1,m_Mem1);
	obj->m_AI->RealMemory(2,m_Mem2);
	obj->m_AI->RealMemory(3,m_Mem3);
	obj->m_AI->RealMemory(4,m_Mem4);
	obj->m_AI->RealMemory(5,m_Mem5);
	obj->m_AI->RealMemory(6,m_Mem6);
	obj->m_AI->RealMemory(7,m_Mem7);
	obj->m_AI->RealMemory(8,m_Mem8);
	obj->m_AI->RealMemory(9,m_Mem9);
	
	CDialog::OnOK();
}
