Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
311 lines
7.9 KiB
C++
311 lines
7.9 KiB
C++
// SoundPropertyDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "worldcreator.h"
|
|
#include "SoundPropertyDlg.h"
|
|
|
|
#include <AmbienceStruct.h>
|
|
#include <BaseDataDefine.h>
|
|
|
|
#include <list>
|
|
#include <string.h>
|
|
#include <algorithm>
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSoundPropertyDlg dialog
|
|
|
|
#define TRIGGER_IN "들어갈 때만"
|
|
#define TRIGGER_OUT "나갈때만"
|
|
#define TRIGGER_IN_OUT "둘 다"
|
|
#define ENABLE3DSOUND "Enable 3D Sound"
|
|
#define DISABLE3DSOUND "Disable 3D Sound"
|
|
|
|
using namespace std;
|
|
|
|
CSoundPropertyDlg::CSoundPropertyDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CSoundPropertyDlg::IDD, pParent)
|
|
, m_pSoundAsset( new SSoundAsset )
|
|
|
|
{
|
|
//{{AFX_DATA_INIT(CSoundPropertyDlg)
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
CSoundPropertyDlg::~CSoundPropertyDlg()
|
|
{
|
|
delete m_pSoundAsset;
|
|
}
|
|
|
|
void CSoundPropertyDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CSoundPropertyDlg)
|
|
DDX_Control(pDX, IDC_NAME, m_editName);
|
|
DDX_Control(pDX, IDC_COMBO_TRIGGERTYPE, m_TriggerType);
|
|
DDX_Control(pDX, IDC_COMBO_STEREO, m_Stereo);
|
|
DDX_Control(pDX, IDC_LIST_WAVFILELIST, m_WavFileList);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CSoundPropertyDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CSoundPropertyDlg)
|
|
ON_BN_CLICKED(IDC_BUTTON_DELETESOUND, OnButtonDeletesound)
|
|
ON_BN_CLICKED(IDC_BUTTON_INSERTSOUND, OnButtonInsertsound)
|
|
ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST_WAVFILELIST, OnEndlabeleditListWavfilelist)
|
|
ON_BN_CLICKED(IDC_BUTTON_SETSOUND, OnButtonSetsound)
|
|
ON_NOTIFY(NM_DBLCLK, IDC_LIST_WAVFILELIST, OnDblclkListWavfilelist)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSoundPropertyDlg message handlers
|
|
|
|
extern const char * FloatToChar( float fvalue );
|
|
|
|
float CharToFloat( const char * szStr )
|
|
{
|
|
float fvalue = 0.0f;
|
|
if( szStr != NULL )
|
|
sscanf( szStr, "%f", &fvalue );
|
|
return fvalue;
|
|
}
|
|
|
|
BOOL CSoundPropertyDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
DWORD dwStyle;
|
|
dwStyle = m_WavFileList.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE, 0 ,0);
|
|
dwStyle |= LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES;
|
|
m_WavFileList.SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE, 0,dwStyle );
|
|
|
|
m_TriggerType.InsertString( 0, TRIGGER_IN );
|
|
m_TriggerType.InsertString( 1, TRIGGER_OUT );
|
|
m_TriggerType.InsertString( 2, TRIGGER_IN_OUT );
|
|
m_Stereo.InsertString( 0, ENABLE3DSOUND );
|
|
m_Stereo.InsertString( 1, DISABLE3DSOUND );
|
|
|
|
m_WavFileList.InsertColumn( 0, "시간", LVCFMT_LEFT, 80 );
|
|
m_WavFileList.InsertColumn( 1, "사운드 화일", LVCFMT_LEFT, 300 );
|
|
|
|
m_editName.SetWindowText( m_pSoundAsset->m_Name.c_str() );
|
|
m_TriggerType.SetCurSel( m_pSoundAsset->m_eTrigger );
|
|
m_Stereo.SetCurSel( m_pSoundAsset->m_b3DSound ? 0 : 1 );
|
|
|
|
int ItemNum = m_WavFileList.GetItemCount();
|
|
if( m_pSoundAsset->m_pWaveFileList )
|
|
{
|
|
WAVEFILELIST * pWaveFileList = m_pSoundAsset->m_pWaveFileList;
|
|
|
|
for( WAVEFILELIST::iterator i = pWaveFileList->begin(); i != pWaveFileList->end(); i++ )
|
|
{
|
|
m_WavFileList.InsertItem( ItemNum, FloatToChar( i->first ) );
|
|
m_WavFileList.SetItemText( ItemNum++, 1, i->second.c_str() );
|
|
}
|
|
}
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CSoundPropertyDlg::Init( const SSoundAsset & SoundAsset )
|
|
{
|
|
*m_pSoundAsset = SoundAsset;
|
|
}
|
|
|
|
void CSoundPropertyDlg::GetInfo( SSoundAsset & SoundAsset )
|
|
{
|
|
SoundAsset = *m_pSoundAsset;
|
|
}
|
|
|
|
bool std::greater<WAVEFILE>::operator()( const WAVEFILE & x, const WAVEFILE & y ) const
|
|
{
|
|
return x.first < y.first; //오름차순으로 정렬되도록 하기 위해 >의 반대인 <으로 했음
|
|
}
|
|
|
|
void CSoundPropertyDlg::OnOK()
|
|
{
|
|
CString str;
|
|
m_editName.GetWindowText( str );
|
|
m_pSoundAsset->m_Name = (const char*)str;
|
|
|
|
int curSel = m_TriggerType.GetCurSel();
|
|
if( curSel < 0 || curSel > 2 )
|
|
curSel = 0;
|
|
|
|
SSoundAsset::eTrigger Trigger[3] = { SSoundAsset::T_IN, SSoundAsset::T_OUT, SSoundAsset::T_IN_OUT };
|
|
m_pSoundAsset->m_eTrigger = Trigger[ curSel ];
|
|
|
|
m_pSoundAsset->m_b3DSound = m_Stereo.GetCurSel() == 1 ? false : true;
|
|
|
|
if( m_pSoundAsset->m_pWaveFileList )
|
|
{
|
|
WAVEFILELIST * pWaveFileList = m_pSoundAsset->m_pWaveFileList;
|
|
pWaveFileList->clear();
|
|
|
|
int nItem = m_WavFileList.GetItemCount();
|
|
|
|
for( int i = 0; i < nItem; i++ )
|
|
{
|
|
CString Time = m_WavFileList.GetItemText( i, 0 );
|
|
CString WavFile = m_WavFileList.GetItemText( i, 1 );
|
|
float fTime = CharToFloat( Time );
|
|
|
|
pWaveFileList->push_back( WAVEFILE( fTime, WavFile.GetBuffer( 0 ) ) );
|
|
|
|
std::greater<WAVEFILE> compareFunc;
|
|
pWaveFileList->sort( compareFunc );
|
|
}
|
|
|
|
}
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
typedef WAVEFILELIST::iterator ITERATOR;
|
|
|
|
ITERATOR GetIterator( WAVEFILELIST & WavFileList, int index )
|
|
{
|
|
int c = 0;
|
|
for( ITERATOR i = WavFileList.begin(); i != WavFileList.end(); i++ )
|
|
{
|
|
if( c >= index )
|
|
{
|
|
return i;
|
|
}
|
|
c++;
|
|
}
|
|
return WavFileList.end();
|
|
}
|
|
|
|
void CSoundPropertyDlg::OnButtonInsertsound()
|
|
{
|
|
int Sel = m_WavFileList.GetNextItem( -1, LVNI_SELECTED );
|
|
if( Sel < 0 )
|
|
Sel = 0;
|
|
|
|
ITERATOR iter = GetIterator( *m_pSoundAsset->m_pWaveFileList, Sel );
|
|
if( m_WavFileList.InsertItem( Sel, "0.0" ) == -1 )
|
|
{
|
|
MessageBox( "리스트에서 Wave화일을 삽입하는데 실패했습니다!! ( at CSoundPropertyDlg::OnButtonInsertsound() )" );
|
|
return;
|
|
}
|
|
|
|
m_pSoundAsset->m_pWaveFileList->insert( iter, WAVEFILE( 0.0f, "" ) );
|
|
}
|
|
|
|
void CSoundPropertyDlg::OnButtonDeletesound()
|
|
{
|
|
int Sel = m_WavFileList.GetNextItem( -1, LVNI_SELECTED );
|
|
if( Sel < 0 )
|
|
Sel = 0;
|
|
|
|
ITERATOR iter = GetIterator( *m_pSoundAsset->m_pWaveFileList, Sel );
|
|
if( iter != m_pSoundAsset->m_pWaveFileList->end() )
|
|
{
|
|
if( !m_WavFileList.DeleteItem( Sel ) )
|
|
{
|
|
MessageBox( "리스트에서 Wave화일을 지우는데 실패했습니다. (at CSoundPropertyDlg::OnButtonInsertsound() )" );
|
|
return;
|
|
}
|
|
|
|
m_pSoundAsset->m_pWaveFileList->erase( iter );
|
|
}
|
|
}
|
|
|
|
bool CSoundPropertyDlg::IsExist( float fTime )
|
|
{
|
|
for( WAVEFILELIST::iterator i = m_pSoundAsset->m_pWaveFileList->begin(); i != m_pSoundAsset->m_pWaveFileList->end(); i++ )
|
|
{
|
|
if( i->first == fTime )
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void CSoundPropertyDlg::OnEndlabeleditListWavfilelist(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
|
|
|
|
int Sel = m_WavFileList.GetNextItem( -1, LVNI_SELECTED );
|
|
if( Sel < 0 )
|
|
return;
|
|
|
|
ITERATOR iter = GetIterator( *m_pSoundAsset->m_pWaveFileList, Sel );
|
|
if( iter == m_pSoundAsset->m_pWaveFileList->end() )
|
|
return;
|
|
|
|
CString Label = m_WavFileList.GetItemText( Sel, 0 );
|
|
float fTime = CharToFloat( pDispInfo->item.pszText );
|
|
|
|
if( IsExist( fTime ) )
|
|
{
|
|
MessageBox( "이미 이 시간으로 설정된 것이 있습니다." );
|
|
*pResult = 0;
|
|
return;
|
|
}
|
|
|
|
if( fTime < 0.0f || fTime > 24.0f )
|
|
{
|
|
MessageBox( "0.0 ~ 24.0 사이의 실수를 입력해줘잉~" );
|
|
*pResult = 0;
|
|
}
|
|
else
|
|
{
|
|
iter->first = fTime;
|
|
*pResult = 1;
|
|
}
|
|
}
|
|
|
|
void CSoundPropertyDlg::OnButtonSetsound()
|
|
{
|
|
int Sel = m_WavFileList.GetNextItem( -1, LVNI_SELECTED );
|
|
if( Sel < 0 )
|
|
return;
|
|
|
|
ITERATOR iter = GetIterator( *m_pSoundAsset->m_pWaveFileList, Sel );
|
|
if( iter == m_pSoundAsset->m_pWaveFileList->end() )
|
|
return;
|
|
|
|
CFileDialog FileDlg( TRUE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST
|
|
, "Ogg Files (*.ogg)|*.ogg|Wave Files (*.wav)|*.wav|All Files (*.*)|*.*||"
|
|
, this );
|
|
|
|
if( FileDlg.DoModal() == IDOK )
|
|
{
|
|
char szPathName[256], szSoundFilePath[256];
|
|
strcpy( szPathName, FileDlg.GetPathName() );
|
|
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 );
|
|
m_WavFileList.SetItemText( Sel, 1, pFinded );
|
|
iter->second = pFinded;
|
|
}
|
|
}
|
|
}
|
|
|
|
void CSoundPropertyDlg::OnDblclkListWavfilelist(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
OnButtonSetsound();
|
|
*pResult = 0;
|
|
} |