void WINAPI GetModuleInfo(ModuleInfo *info, ClientInfo *client_info) { info->event_mask = EVENT_REDRAW | EVENT_RESIZE | EVENT_KEY | EVENT_MOUSECLICK | EVENT_SETFOCUS; info->priority = PRIORITY_NORMAL; info->module_id = MODULE_OFFLINE_ID; cinfo = client_info; // Save client info for our use later showing_splash = False; if (cinfo->config->quickstart) { OfflineConnect(); } else { // Only show logo the first time in (at startup) if (*(cinfo->first_load)) IntroInit(); else IntroShowSplash(); } }
/************************************************************************* * Main entrypoint for debug build *************************************************************************/ int WINAPI WinMain(HINSTANCE instance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; g_hInstance = GetModuleHandle(0); OutputDebugString("Starting...\n"); if (!WindowOpen()) { OutputDebugString("Failed to open window\n"); WindowClose(); return 0; } if (FAILED(InitDevice())) { CleanupDevice(); return 0; } IntroInit(); InitSound(); while (!g_done) { g_currentFrame++; g_lastTime = g_currentTime; g_currentPos = BASS_ChannelGetPosition(g_stream, BASS_POS_BYTE); g_currentTime = BASS_ChannelBytes2Seconds(g_stream, g_currentPos); if (g_pause) { Sleep(100); } while (PeekMessage(&msg,0,0,0,PM_REMOVE)) { if (msg.message == WM_QUIT) { g_done = true; } TranslateMessage(&msg); DispatchMessage(&msg); if (WM_KEYDOWN == msg.message && VK_SPACE == LOWORD(msg.wParam)) { if (!g_pause) { BASS_ChannelPause(g_stream); g_pause = true; } else { BASS_ChannelPlay(g_stream, false); g_pause = false; } } if (WM_KEYDOWN == msg.message && VK_LEFT == LOWORD(msg.wParam)) { if (g_pause) { BASS_ChannelSetPosition(g_stream, g_currentPos-44100, BASS_POS_BYTE); } else { BASS_ChannelSetPosition(g_stream, g_currentPos-44100*4, BASS_POS_BYTE); } } if (WM_KEYDOWN == msg.message && VK_RIGHT == LOWORD(msg.wParam)) { if (g_pause) { BASS_ChannelSetPosition(g_stream, g_currentPos+44100, BASS_POS_BYTE); } else { BASS_ChannelSetPosition(g_stream, g_currentPos+44100*4, BASS_POS_BYTE); } } if (WM_KEYDOWN == msg.message && VK_DOWN == LOWORD(msg.wParam)) { BASS_ChannelSetPosition(g_stream, g_currentPos-44100*20, BASS_POS_BYTE); } if (WM_KEYDOWN == msg.message && VK_UP == LOWORD(msg.wParam)) { BASS_ChannelSetPosition(g_stream, g_currentPos+44100*20, BASS_POS_BYTE); } if (WM_KEYDOWN == msg.message && VK_F1 == LOWORD(msg.wParam)) { g_repeatStart = g_currentPos; g_repeatEnd = LONG_MAX; } if (WM_KEYDOWN == msg.message && VK_F2 == LOWORD(msg.wParam)) { g_repeatEnd = g_currentPos; } if (WM_KEYDOWN == msg.message && VK_RETURN == LOWORD(msg.wParam)) { g_repeatStart = 0; g_repeatEnd = LONG_MAX; } } IntroLoop((long)(g_currentTime*44100.0)); UpdateTitle(); if (g_currentPos > g_repeatEnd) { BASS_ChannelSetPosition(g_stream, g_repeatStart, BASS_POS_BYTE); } BASS_Update(0); } BASS_StreamFree(g_stream); BASS_Free(); WindowClose(); return 0; }
void WINAPI EntryPoint() #endif { #ifdef ALLOW_WINDOWED // gs_WindowInfos.bFullscreen = MessageBox( 0, "Fullscreen?", pWindowClass, MB_YESNO | MB_ICONQUESTION ) == IDYES; gs_WindowInfos.bFullscreen = false; #endif int ErrorCode = 0; if ( (ErrorCode = WindowInit()) ) { WindowExit(); MessageBox( 0, pMessageError, 0, MB_OK | MB_ICONEXCLAMATION ); ExitProcess( ErrorCode ); } IntroProgressDelegate Progress = { &gs_WindowInfos, ShowProgress }; if ( (ErrorCode = IntroInit( Progress )) ) { WindowExit(); MessageBox( 0, pMessageError, 0, MB_OK | MB_ICONEXCLAMATION ); ExitProcess( -ErrorCode ); } // Start the music #ifdef MUSIC gs_Music.Play(); #endif ////////////////////////////////////////////////////////////////////////// // Run the message loop ! bool bFinished = false; float StartTime = 0.001f * timeGetTime(); float LastTime = 0.0f; while ( !bFinished ) { float Time = 0.001f * timeGetTime() - StartTime; float DeltaTime = Time - LastTime; LastTime = Time; // Process Windows messages MSG msg; while ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) { if ( msg.message == WM_QUIT ) { bFinished = true; break; } DispatchMessage( &msg ); } #ifndef NDEBUG // Show FPS DrawTime( Time ); HandleEvents(); #endif #ifdef SURE_DEBUG // Check for hash collisions => We must never have too many of them ! ASSERT( DictionaryU32::ms_MaxCollisionsCount < 2, "Too many collisions in hash tables! Either increase size or use different hashing scheme!" ); // Reload in-file constants ReloadChangedTweakableValues(); // Reload modified shaders WatchIncludesModifications(); Shader::WatchShadersModifications(); ComputeShader::WatchShadersModifications(); #endif // Run the intro bFinished |= !IntroDo( Time, DeltaTime ); // This was in iQ's framework, I don't know what it's for. I believe it's useful when using OpenGL but with DirectX it makes everything slow as hell (attempts to load/unload DLLs every frame) ! // I left it here so everyone knows it must NOT be called... // SwapBuffers( gs_WindowInfos.hDC ); } // ////////////////////////////////////////////////////////////////////////// // Stop the music #ifdef MUSIC gs_Music.Stop(); #endif IntroExit(); WindowExit(); // Clean exit... ExitProcess( 0 ); }