1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Convert timer stuff to SDL timer

This commit is contained in:
Mathieu Schroeter 2017-01-30 21:51:32 +01:00
parent 36b44d9578
commit 795875e6a4

View File

@ -380,18 +380,6 @@ LRESULT CALLBACK WindowProc2 (HWND hWnd, UINT message,
switch( message )
{
case WM_TIMER:
case WM_UPDATE:
if ( !g_pEvent->IsMovie() ) // pas de film en cours ?
{
if ( g_bActive )
{
UpdateFrame();
}
g_pPixmap->Display();
}
break;
case WM_CREATE:
hInstance = ((LPCREATESTRUCT)lParam)->hInstance;
return 0;
@ -464,7 +452,11 @@ LRESULT CALLBACK WindowProc2 (HWND hWnd, UINT message,
break;
}
if (event && event->type == SDL_WINDOWEVENT)
if (event)
{
switch (event->type)
{
case SDL_WINDOWEVENT:
{
switch (event->window.event)
{
@ -499,6 +491,28 @@ LRESULT CALLBACK WindowProc2 (HWND hWnd, UINT message,
if (g_pSound != NULL) g_pSound->SuspendMusic ();
return 0;
}
break;
}
case SDL_USEREVENT:
{
switch (event->user.code)
{
case WM_TIMER:
case WM_UPDATE:
if (!g_pEvent->IsMovie ()) // pas de film en cours ?
{
if (g_bActive)
{
UpdateFrame ();
}
g_pPixmap->Display ();
}
break;
}
break;
}
}
}
return DefWindowProc(hWnd, message, wParam, lParam);
@ -555,7 +569,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
RegisterClass(&wc);
SDL_SetMainReady ();
auto res = SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO);
auto res = SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
if (res < 0)
return false;
@ -825,7 +839,12 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
return false;
}
SetTimer(g_hWnd, 1, g_timerInterval, NULL);
SDL_TimerID my_timer_id = SDL_AddTimer (g_timerInterval, [] (Uint32 interval, void *param) -> Uint32
{
CEvent::PushUserEvent (WM_UPDATE);
return interval;
}, nullptr);
while (SDL_TRUE)
{