Finishing from last night; thank my cable modem for going out in the

middle of a commit ...
This commit is contained in:
Glenn Maynard
2003-04-12 16:06:06 +00:00
parent e148806d1b
commit ae39d652fd
+19 -23
View File
@@ -38,7 +38,6 @@
#include "NoteSkinManager.h" #include "NoteSkinManager.h"
#include "PrefsManager.h" #include "PrefsManager.h"
#include "SongManager.h" #include "SongManager.h"
#include "PrefsManager.h"
#include "GameState.h" #include "GameState.h"
#include "AnnouncerManager.h" #include "AnnouncerManager.h"
#include "ScreenManager.h" #include "ScreenManager.h"
@@ -66,7 +65,7 @@ HWND g_hWndMain = NULL;
#endif #endif
static bool g_bHasFocus = true; static bool g_bHasFocus = true;
static bool g_bQuitting = false;
static void ChangeToDirOfExecutable(const char *argv0) static void ChangeToDirOfExecutable(const char *argv0)
{ {
@@ -108,10 +107,7 @@ void ApplyGraphicOptions()
void ExitGame() void ExitGame()
{ {
SDL_Event *event; g_bQuitting = true;
event = (SDL_Event *) malloc(sizeof(SDL_Event));
event->type = SDL_QUIT;
SDL_PushEvent(event);
} }
void ResetGame() void ResetGame()
@@ -303,6 +299,10 @@ int main(int argc, char* argv[])
PREFSMAN->m_bVsync ); PREFSMAN->m_bVsync );
TEXTUREMAN = new RageTextureManager( PREFSMAN->m_iTextureColorDepth, PREFSMAN->m_iUnloadTextureDelaySeconds, PREFSMAN->m_iMaxTextureResolution ); TEXTUREMAN = new RageTextureManager( PREFSMAN->m_iTextureColorDepth, PREFSMAN->m_iUnloadTextureDelaySeconds, PREFSMAN->m_iMaxTextureResolution );
/* Now that we've started DISPLAY, we can set up event masks. */
SDL_EventState(SDL_QUIT, SDL_ENABLE);
SDL_EventState(SDL_ACTIVEEVENT, SDL_ENABLE);
/* We might have a new window, so let's make sure window properties are still set. */ /* We might have a new window, so let's make sure window properties are still set. */
SDL_WM_SetCaption("StepMania", "StepMania"); SDL_WM_SetCaption("StepMania", "StepMania");
SetIcon(); SetIcon();
@@ -317,6 +317,9 @@ int main(int argc, char* argv[])
g_hWndMain = info.window; g_hWndMain = info.window;
#endif #endif
/* This initializes objects that change the SDL event mask, and has other
* dependencies on the SDL video subsystem, so it must be initialized after
* DISPLAY and setting the default SDL event mask. */
INPUTMAN = new RageInput(); INPUTMAN = new RageInput();
// These things depend on the TextureManager, so do them after! // These things depend on the TextureManager, so do them after!
@@ -422,10 +425,7 @@ bool HandleGlobalInputs( DeviceInput DeviceI, InputEventType type, GameInput Gam
INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_LALT)) ) INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_LALT)) )
{ {
// pressed Alt+F4 // pressed Alt+F4
SDL_Event *event; ExitGame();
event = (SDL_Event *) malloc(sizeof(SDL_Event));
event->type = SDL_QUIT;
SDL_PushEvent(event);
return true; return true;
} }
else else
@@ -504,23 +504,19 @@ static void HandleInputEvents(float fDeltaTime)
} }
} }
static bool HandleSDLEvents() static void HandleSDLEvents()
{ {
// process all queued events // process all queued events
SDL_Event event; SDL_Event event;
while(SDL_PollEvent(&event)) while(SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_QUITMASK|SDL_ACTIVEEVENTMASK))
{ {
if(INPUTMAN->FeedSDLEvent(event))
continue; /* it took care of it */
switch(event.type) switch(event.type)
{ {
case SDL_QUIT: case SDL_QUIT:
LOG->Trace("SDL_QUIT: shutting down"); LOG->Trace("SDL_QUIT: shutting down");
return false; /* exit the main loop */ ExitGame();
case SDL_VIDEORESIZE:
DISPLAY->ResolutionChanged(event.resize.w, event.resize.h);
break; break;
case SDL_ACTIVEEVENT: case SDL_ACTIVEEVENT:
{ {
/* We don't care about mouse focus. */ /* We don't care about mouse focus. */
@@ -540,17 +536,16 @@ static bool HandleSDLEvents()
} }
} }
} }
return true;
} }
static void GameLoop() static void GameLoop()
{ {
RageTimer timer; RageTimer timer;
while(1) while(!g_bQuitting)
{ {
if(!HandleSDLEvents()) /* This needs to be called before anything that handles SDL events. */
return; /* exit the main loop (quit) */ SDL_PumpEvents();
HandleSDLEvents();
/* /*
* Update * Update
@@ -566,6 +561,7 @@ static void GameLoop()
if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_BACKQUOTE) ) ) if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_BACKQUOTE) ) )
fDeltaTime /= 4; fDeltaTime /= 4;
DISPLAY->Update( fDeltaTime );
TEXTUREMAN->Update( fDeltaTime ); TEXTUREMAN->Update( fDeltaTime );
GAMESTATE->Update( fDeltaTime ); GAMESTATE->Update( fDeltaTime );
SCREENMAN->Update( fDeltaTime ); SCREENMAN->Update( fDeltaTime );