2010-09-29 17:29:43 +08:00
|
|
|
|
// Application main form file.
|
|
|
|
|
|
|
|
|
|
// Original file name: TestAudioEngineMainForm.cpp
|
|
|
|
|
// Generated by TOPS Builder:Project wizard,Date:2010-9-29
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "TestAudioEngineMainForm.h"
|
|
|
|
|
#include "testaudioengine_res_def.h"
|
|
|
|
|
#include "TestAudioEngineUnicodeScript_str.h"
|
2010-11-11 11:53:04 +08:00
|
|
|
|
#include "SimpleAudioEngine.h"
|
2010-09-29 17:29:43 +08:00
|
|
|
|
#include <cassert>
|
|
|
|
|
|
2010-11-12 11:51:17 +08:00
|
|
|
|
extern const AppResourceEntry TestAudioEngineResourceEntry;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@warning <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ľṹ<EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>FileName<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ԭʼ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD>ļ<EFBFBD>ֻ֧<EFBFBD><EFBFBD> wav <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
const T_SoundResInfo SoundResInfo[] =
|
|
|
|
|
{
|
|
|
|
|
{ "background.mp3", TESTAU_ID_RAWDATA_background },
|
|
|
|
|
{ "Effect1.wav", TESTAU_ID_RAWDATA_Effect1 },
|
|
|
|
|
{ "Effect2.wav", TESTAU_ID_RAWDATA_Effect2 },
|
|
|
|
|
};
|
2010-09-29 17:29:43 +08:00
|
|
|
|
|
|
|
|
|
TMainForm::TMainForm(TApplication * pApp):TWindow(pApp)
|
|
|
|
|
, m_nEffect1ID(0)
|
|
|
|
|
, m_nEffect2ID(0)
|
|
|
|
|
{
|
|
|
|
|
Create(TESTAU_ID_Form1002);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TMainForm::~TMainForm()
|
|
|
|
|
{
|
2010-11-16 15:12:09 +08:00
|
|
|
|
SimpleAudioEngine::sharedEngine()->release();
|
2010-09-29 17:29:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Boolean TMainForm::EventHandler(TApplication * pApp, EventType * pEvent)
|
|
|
|
|
{
|
|
|
|
|
Boolean bHandled = FALSE;
|
|
|
|
|
|
|
|
|
|
switch(pEvent->eType)
|
|
|
|
|
{
|
|
|
|
|
case EVENT_WinInit:
|
|
|
|
|
{
|
2010-11-16 15:12:09 +08:00
|
|
|
|
SimpleAudioEngine::sharedEngine()->setResourceEntry(&TestAudioEngineResourceEntry);
|
|
|
|
|
SimpleAudioEngine::sharedEngine()->setSoundResInfo(SoundResInfo, sizeof(SoundResInfo) / sizeof(T_SoundResInfo));
|
2010-09-29 17:29:43 +08:00
|
|
|
|
bHandled = TRUE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_WinPaint:
|
|
|
|
|
{
|
|
|
|
|
DrawWindow();
|
|
|
|
|
bHandled = TRUE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_CtrlSelect:
|
|
|
|
|
{
|
|
|
|
|
//switch(pEvent->sParam1)
|
|
|
|
|
//{
|
|
|
|
|
//case RES_SYSTEM_WINDOW_TITLE_BUTTON_ID:
|
|
|
|
|
// bHandled = TRUE;
|
|
|
|
|
// break;
|
|
|
|
|
//}
|
|
|
|
|
bHandled = CtrlSelected(pApp, pEvent);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EVENT_WinClose:
|
|
|
|
|
{
|
|
|
|
|
// Stop the application since the main form has been closed
|
|
|
|
|
pApp->SendStopEvent();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (FALSE == bHandled)
|
|
|
|
|
{
|
|
|
|
|
return TWindow::EventHandler(pApp,pEvent);
|
|
|
|
|
}
|
|
|
|
|
return bHandled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Boolean TMainForm::CtrlSelected(TApplication * pApp, EventType * pEvent)
|
|
|
|
|
{
|
|
|
|
|
Boolean bHandled = FALSE;
|
2010-11-16 15:12:09 +08:00
|
|
|
|
SimpleAudioEngine* pAudioEngine = SimpleAudioEngine::sharedEngine();
|
2010-09-29 17:29:43 +08:00
|
|
|
|
|
|
|
|
|
switch (pEvent->sParam1)
|
|
|
|
|
{
|
|
|
|
|
case TESTAU_ID_Form1002_PlayBack:
|
|
|
|
|
// play background music
|
|
|
|
|
pAudioEngine->SetBackgroundMusicVolume(30);
|
2010-11-12 11:51:17 +08:00
|
|
|
|
pAudioEngine->playBackgroundMusic(SoundResInfo[0].FileName, true);
|
2010-09-29 17:29:43 +08:00
|
|
|
|
bHandled = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TESTAU_ID_Form1002_StopBack:
|
|
|
|
|
// stop background music
|
|
|
|
|
pAudioEngine->stopBackgroundMusic();
|
|
|
|
|
bHandled = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TESTAU_ID_Form1002_LoadEffect:
|
|
|
|
|
// load effect1
|
2010-11-12 11:51:17 +08:00
|
|
|
|
m_nEffect1ID = pAudioEngine->preloadEffect(SoundResInfo[1].FileName);
|
2010-09-29 17:29:43 +08:00
|
|
|
|
assert(m_nEffect1ID > 0);
|
|
|
|
|
bHandled = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TESTAU_ID_Form1002_UnLoadBtn:
|
|
|
|
|
// unload effect1
|
|
|
|
|
pAudioEngine->unloadEffect(m_nEffect1ID);
|
|
|
|
|
m_nEffect1ID = 0;
|
|
|
|
|
bHandled = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TESTAU_ID_Form1002_PlayLoaded:
|
|
|
|
|
// play loaded effect1
|
|
|
|
|
if (m_nEffect1ID == 0)
|
|
|
|
|
{
|
|
|
|
|
pApp->MessageBox(UnloadedTip, FailedTitle, WMB_OKCANCEL);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pAudioEngine->SetEffectsVolume(30);
|
2010-11-12 11:51:17 +08:00
|
|
|
|
pAudioEngine->playPreloadedEffect(m_nEffect1ID);
|
2010-09-29 17:29:43 +08:00
|
|
|
|
}
|
|
|
|
|
bHandled = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case TESTAU_ID_Form1002_PlayEffect:
|
|
|
|
|
// play effect2
|
|
|
|
|
pAudioEngine->SetEffectsVolume(30);
|
2010-11-12 11:51:17 +08:00
|
|
|
|
m_nEffect2ID = pAudioEngine->playEffect(SoundResInfo[2].FileName);
|
|
|
|
|
assert(m_nEffect2ID > 0);
|
2010-09-29 17:29:43 +08:00
|
|
|
|
bHandled = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bHandled;
|
|
|
|
|
}
|