Made auto-pausing an option.

This commit is contained in:
onpon4 2015-05-21 18:49:04 -04:00
parent e4664b9b1a
commit 533d74447f
5 changed files with 25 additions and 7 deletions

View File

@ -273,6 +273,7 @@ enum {
TS_SOUND,
TS_MUSIC,
TS_FULLSCREEN,
TS_AUTOPAUSE,
TS_BACK_TO_MAIN_MENU,
TS_SAVESLOT_0,
TS_SAVESLOT_1,

View File

@ -146,7 +146,10 @@ void initSystem()
}
char filename[PATH_MAX];
int fullScreen = 0, useSound = 1, useMusic = 1;
int fullScreen = 0;
int useSound = 1;
int useMusic = 1;
int autoPause = 0;
FILE *fp;
sprintf(filename, "%sconf", engine.userHomeDirectory);
@ -154,7 +157,7 @@ void initSystem()
if (fp != NULL)
{
if (fscanf(fp, "%d %d %d", &fullScreen, &useSound, &useMusic) < 3)
if (fscanf(fp, "%d %d %d %d", &fullScreen, &useSound, &useMusic, &autoPause) < 4)
printf("Warning: Config file \"%s\" is not correctly formatted\n", filename);
fclose(fp);
}
@ -162,6 +165,7 @@ void initSystem()
engine.fullScreen = fullScreen;
engine.useSound = useSound;
engine.useMusic = useMusic;
engine.autoPause = autoPause;
screen = SDL_CreateRGBSurface(0, screenWidth, screenHeight, 32, 0xff0000, 0xff00, 0xff, 0xff000000);
@ -259,7 +263,8 @@ void cleanUp()
fp = fopen(filename, "wb");
if (fp != NULL)
{
fprintf(fp, "%d %d %d\n", engine.fullScreen, engine.useSound, engine.useMusic);
fprintf(fp, "%d %d %d %d\n", engine.fullScreen, engine.useSound,
engine.useMusic, engine.autoPause);
fclose(fp);
}
else

View File

@ -252,8 +252,9 @@ void getPlayerInput()
break;
case SDL_WINDOWEVENT:
if(engine.event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
engine.paused = 1;
if (engine.autoPause &&
(engine.event.window.event == SDL_WINDOWEVENT_FOCUS_LOST))
engine.paused = true;
break;
}

View File

@ -301,6 +301,7 @@ struct Engine {
bool useSound;
bool useMusic;
bool fullScreen;
bool autoPause;
char userHomeDirectory[1024];

View File

@ -106,18 +106,24 @@ static void createOptionsMenu()
textSurface(TS_FULLSCREEN, "FULLSCREEN - ON", -1, 390, FONT_WHITE);
else
textSurface(TS_FULLSCREEN, "FULLSCREEN - OFF", -1, 390, FONT_WHITE);
if (engine.autoPause)
textSurface(TS_AUTOPAUSE, "AUTOPAUSE - ON", -1, 410, FONT_WHITE);
else
textSurface(TS_AUTOPAUSE, "AUTOPAUSE - OFF", -1, 410, FONT_WHITE);
}
static signed char showOptionsMenu()
{
textShape[TS_BACK_TO_MAIN_MENU].y = 430;
textShape[TS_BACK_TO_MAIN_MENU].y = 450;
blitText(TS_SOUND);
blitText(TS_MUSIC);
blitText(TS_FULLSCREEN);
blitText(TS_AUTOPAUSE);
blitText(TS_BACK_TO_MAIN_MENU);
return 4;
return 5;
}
static void createCheatMenu()
@ -480,6 +486,10 @@ int doTitle()
(engine.fullScreen ?
SDL_WINDOW_FULLSCREEN_DESKTOP : 0));
}
else if (selectedOption == 4)
{
engine.autoPause = !engine.autoPause;
}
else if (selectedOption == listLength)
{
menuType = MENU_MAIN;