// DlgTriggerProperty.cpp : implementation file // #include "stdafx.h" #include "worldcreator.h" #include "DlgTriggerProperty.h" #include #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // const char * strEventMusicPlay = "Play Music"; const char * strEventMusicPlayOnce = "Play Music Once"; const char * strEventShowMessage = "Show Message"; const char * strEventShowEffect = "Show Effect"; ///////////////////////////////////////////////////////////////////////////// // CDlgTriggerProperty dialog CDlgTriggerProperty::CDlgTriggerProperty(CWnd* pParent /*=NULL*/) : CDialog(CDlgTriggerProperty::IDD, pParent) , m_iCurSel( 0 ) , m_iEventType( -1 ) { //{{AFX_DATA_INIT(CDlgTriggerProperty) m_strEventArg = _T(""); //}}AFX_DATA_INIT } void CDlgTriggerProperty::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDlgTriggerProperty) DDX_Control(pDX, IDC_COMBO_EVENTTYPE, m_EventType); DDX_Text(pDX, IDC_EDIT_EVENTARG, m_strEventArg); //}}AFX_DATA_MAP } int CDlgTriggerProperty::EventType() { int curSel = m_EventType.GetCurSel(); if( curSel == CB_ERR ) return -1; CString str; m_EventType.GetLBText( curSel, str ); if( str == strEventMusicPlay ) { return 0; } else if( str == strEventShowMessage ) { return 1; } else if( str == strEventMusicPlayOnce ) { return 2; } else if( str == strEventShowEffect ) { return 3; } else return -1; } void CDlgTriggerProperty::SetEventType( int eventType ) { m_iCurSel = eventType; } BEGIN_MESSAGE_MAP(CDlgTriggerProperty, CDialog) //{{AFX_MSG_MAP(CDlgTriggerProperty) ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDlgTriggerProperty message handlers void CDlgTriggerProperty::ConfirmSoundDirectory( CString & strFilename, CString & strFilenameSrc ) { char szPathName[256], szSoundFilePath[256]; strcpy( szPathName, strFilenameSrc ); strlwr( szPathName ); strcpy( szSoundFilePath, SOUNDFILEPATH ); strlwr( szSoundFilePath ); char * pFinded = strstr( szPathName, szSoundFilePath ); if( pFinded == NULL ) { char szMsg[256]; sprintf( szMsg, "»ç¿îµå È­ÀÏÀº %sÀÇ ÇÏÀ§ µð·ºÅ丮¿¡ ÀÖ¾î¾ß¸¸ ÇÕ´Ï´Ù.", szSoundFilePath ); MessageBox( szMsg ); } else { pFinded += strlen( szSoundFilePath ); strFilename = pFinded; } } void CDlgTriggerProperty::OnButtonBrowse() { const char * filter = "All Files (*.*)|*.*|Effect Script Files (*.esf)|*.esf|Wave Files (*.wav)|*.wav|OGG Files (*.ogg)|*.ogg||"; CFileDialog FileDlg( TRUE, "*.*", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter, this ); FileDlg.m_ofn.lpstrInitialDir = SOUNDFILEPATH; if( FileDlg.DoModal() == IDOK ) { CString ext = FileDlg.GetFileExt(); ext.MakeLower(); if( ext == "wav" || ext == "ogg" ) ConfirmSoundDirectory( m_strEventArg, FileDlg.GetPathName() ); else m_strEventArg = FileDlg.GetFileName(); UpdateData( FALSE ); } } BOOL CDlgTriggerProperty::OnInitDialog() { CDialog::OnInitDialog(); m_EventType.AddString( strEventMusicPlay ); m_EventType.AddString( strEventShowMessage ); m_EventType.AddString( strEventMusicPlayOnce ); m_EventType.AddString( strEventShowEffect ); m_EventType.SetCurSel( m_iCurSel ); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDlgTriggerProperty::OnOK() { m_iEventType = EventType(); CDialog::OnOK(); }