int WINAPI wWinMain(HINSTANCE _hInstance, HINSTANCE _hPrevInstance, LPWSTR _lpCmdLine, int _nCmdShow) { _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); srand((unsigned)time(0)); // Load config into config file class g_configFile = new ConfigFile(); g_configFile->load(); // Init window HWND hwnd = 0; if((hwnd = InitWindow(_hInstance, _nCmdShow, g_configFile->getScreenSize())) == 0) { return 0; } initSoundEngine(); setMusicVolume(g_configFile->getMusicVolume()); setSoundVolume(g_configFile->getSoundVolume()); ClientHandler* clientHandler = new ClientHandler(hwnd); HRESULT hr = clientHandler->run(); delete clientHandler; deleteSoundEngine(); return hr; }
void SoundProcessor::setSoundConfiguration(const boost::shared_ptr<const SoundConfiguration> soundConfiguration) { this->soundConfiguration = soundConfiguration; // ------ SOUND ENGINE ------- if((soundConfiguration->isSound() || soundConfiguration->isMusic()) && (!soundInitialized)) { try { initSoundEngine(); } catch(SDLException e) { soundInitialized = false; toInfoLog(TextStorage::instance().get(IDS::START_INIT_NOSOUND_TEXT_ID)->getText()); } } else if(!soundConfiguration->isSound() && !soundConfiguration->isMusic() && soundInitialized) { // sound was deactivated releaseSoundEngine(); } else if(!soundInitialized) { if(!soundConfiguration->isMusic()) { stopMusic(); } if(soundConfiguration->isSound()) { process(); } else { clearSoundChannels(); } #ifdef _FMOD_SOUND soundEngine->update(); #endif } clearSoundsToPlay(); }
int main( int argc, char** argv ) { QApplication app( argc, argv ); Config* config = new Config( &app ); // If we can't process the command-line or set up the database // there's no point continuing if ( !processCommandLine() || !setupDatabase() ) return 0; QDeclarativeView view; view.connect( view.engine(), SIGNAL(quit()), SLOT(close()) ); view.setResizeMode( QDeclarativeView::SizeRootObjectToView ); // Register custom types for access to certail enums from QML qmlRegisterType< SoundEngine >( "net.randalflagg.llamaui", 1, 0, "SoundEngine" ); qmlRegisterType< KeyboardMap >( "net.randalflagg.llamaui", 1, 0, "KeyboardMap" ); qmlRegisterType< SystemProcess >( "net.randalflagg.llamaui", 1, 0, "SystemProcess" ); QDeclarativeContext* rootContext = view.rootContext(); // Initalise the keyboard key/action mapper if ( !initKeyboardMap( rootContext ) ) return 0; rootContext->setContextProperty( "config", config ); initSoundEngine( rootContext ); initGameMenu( rootContext ); initEmulatorMenu( rootContext ); initSystemMenu( rootContext ); initGameLauncher( rootContext ); // Create the interface QDir dir( Config::instance()->value( "paths", "qmlDir" ).toString() ); view.setSource( QUrl::fromLocalFile( dir.absoluteFilePath( "main.qml" ) ) ); view.showFullScreen(); // Hide the mouse cursor app.setOverrideCursor( QCursor( Qt::BlankCursor ) ); return app.exec(); }
SoundProcessor::SoundProcessor(const boost::shared_ptr<const SoundConfiguration> soundConfiguration): soundConfiguration(soundConfiguration), soundInitialized(false) #ifdef _FMOD_SOUND ,soundEngine(NULL), musicChannel(NULL) #endif { // ------ INIT SOUND ENGINE ------- if(soundConfiguration->isSound() || soundConfiguration->isMusic()) { try { initSoundEngine(); soundInitialized = true; } catch(SDLException e) { toDebugLog("Could not initialize sound engine."); soundInitialized = false; } } else { toInfoLog(TextStorage::instance().get(IDS::START_INIT_NOSOUND_TEXT_ID)->getText()); } // ------ END INIT SOUND ENGINE ------- printSoundInformation(); }