// ModifyAttribDlg.cpp : implementation file
//

#include "stdafx.h"
#include "animscript.h"
#include "ModifyAttribDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CModifyAttribDlg dialog


CModifyAttribDlg::CModifyAttribDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CModifyAttribDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CModifyAttribDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CModifyAttribDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CModifyAttribDlg)
	DDX_Control(pDX, IDC_LIST_ATTRIB, m_listAttrib);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CModifyAttribDlg, CDialog)
	//{{AFX_MSG_MAP(CModifyAttribDlg)
	ON_LBN_SELCHANGE(IDC_LIST_ATTRIB, OnSelchangeListAttrib)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CModifyAttribDlg message handlers
extern char g_szAttribTypeNames[][30];

BOOL CModifyAttribDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_iType = m_pAttribNode->m_iType;
	for (int x=0;x<4;x++)
	{
		int index = m_listAttrib.AddString(g_szAttribTypeNames[x]);
		m_listAttrib.SetItemData(index,x);
		if (x == m_iType)
			m_listAttrib.SetCurSel(index);
	}

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

void CModifyAttribDlg::OnSelchangeListAttrib() 
{
	int index = m_listAttrib.GetCurSel();
	m_iType = m_listAttrib.GetItemData(index);
	CString str;
	m_listAttrib.GetText(index,str);
	m_pAttribNode->m_strName = str;
}

void CModifyAttribDlg::OnOK() 
{
	m_pAttribNode->m_iType = m_iType;
	m_pAttribNode->m_strName = g_szAttribTypeNames[m_iType];
	CDialog::OnOK();
}
