Made auto-pausing an option.
This commit is contained in:
parent
e4664b9b1a
commit
533d74447f
|
@ -273,6 +273,7 @@ enum {
|
||||||
TS_SOUND,
|
TS_SOUND,
|
||||||
TS_MUSIC,
|
TS_MUSIC,
|
||||||
TS_FULLSCREEN,
|
TS_FULLSCREEN,
|
||||||
|
TS_AUTOPAUSE,
|
||||||
TS_BACK_TO_MAIN_MENU,
|
TS_BACK_TO_MAIN_MENU,
|
||||||
TS_SAVESLOT_0,
|
TS_SAVESLOT_0,
|
||||||
TS_SAVESLOT_1,
|
TS_SAVESLOT_1,
|
||||||
|
|
11
src/init.cpp
11
src/init.cpp
|
@ -146,7 +146,10 @@ void initSystem()
|
||||||
}
|
}
|
||||||
|
|
||||||
char filename[PATH_MAX];
|
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;
|
FILE *fp;
|
||||||
sprintf(filename, "%sconf", engine.userHomeDirectory);
|
sprintf(filename, "%sconf", engine.userHomeDirectory);
|
||||||
|
@ -154,7 +157,7 @@ void initSystem()
|
||||||
|
|
||||||
if (fp != NULL)
|
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);
|
printf("Warning: Config file \"%s\" is not correctly formatted\n", filename);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
@ -162,6 +165,7 @@ void initSystem()
|
||||||
engine.fullScreen = fullScreen;
|
engine.fullScreen = fullScreen;
|
||||||
engine.useSound = useSound;
|
engine.useSound = useSound;
|
||||||
engine.useMusic = useMusic;
|
engine.useMusic = useMusic;
|
||||||
|
engine.autoPause = autoPause;
|
||||||
|
|
||||||
screen = SDL_CreateRGBSurface(0, screenWidth, screenHeight, 32, 0xff0000, 0xff00, 0xff, 0xff000000);
|
screen = SDL_CreateRGBSurface(0, screenWidth, screenHeight, 32, 0xff0000, 0xff00, 0xff, 0xff000000);
|
||||||
|
|
||||||
|
@ -259,7 +263,8 @@ void cleanUp()
|
||||||
fp = fopen(filename, "wb");
|
fp = fopen(filename, "wb");
|
||||||
if (fp != NULL)
|
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);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -252,8 +252,9 @@ void getPlayerInput()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
if(engine.event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
if (engine.autoPause &&
|
||||||
engine.paused = 1;
|
(engine.event.window.event == SDL_WINDOWEVENT_FOCUS_LOST))
|
||||||
|
engine.paused = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,6 +301,7 @@ struct Engine {
|
||||||
bool useSound;
|
bool useSound;
|
||||||
bool useMusic;
|
bool useMusic;
|
||||||
bool fullScreen;
|
bool fullScreen;
|
||||||
|
bool autoPause;
|
||||||
|
|
||||||
char userHomeDirectory[1024];
|
char userHomeDirectory[1024];
|
||||||
|
|
||||||
|
|
|
@ -106,18 +106,24 @@ static void createOptionsMenu()
|
||||||
textSurface(TS_FULLSCREEN, "FULLSCREEN - ON", -1, 390, FONT_WHITE);
|
textSurface(TS_FULLSCREEN, "FULLSCREEN - ON", -1, 390, FONT_WHITE);
|
||||||
else
|
else
|
||||||
textSurface(TS_FULLSCREEN, "FULLSCREEN - OFF", -1, 390, FONT_WHITE);
|
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()
|
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_SOUND);
|
||||||
blitText(TS_MUSIC);
|
blitText(TS_MUSIC);
|
||||||
blitText(TS_FULLSCREEN);
|
blitText(TS_FULLSCREEN);
|
||||||
|
blitText(TS_AUTOPAUSE);
|
||||||
blitText(TS_BACK_TO_MAIN_MENU);
|
blitText(TS_BACK_TO_MAIN_MENU);
|
||||||
|
|
||||||
return 4;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createCheatMenu()
|
static void createCheatMenu()
|
||||||
|
@ -480,6 +486,10 @@ int doTitle()
|
||||||
(engine.fullScreen ?
|
(engine.fullScreen ?
|
||||||
SDL_WINDOW_FULLSCREEN_DESKTOP : 0));
|
SDL_WINDOW_FULLSCREEN_DESKTOP : 0));
|
||||||
}
|
}
|
||||||
|
else if (selectedOption == 4)
|
||||||
|
{
|
||||||
|
engine.autoPause = !engine.autoPause;
|
||||||
|
}
|
||||||
else if (selectedOption == listLength)
|
else if (selectedOption == listLength)
|
||||||
{
|
{
|
||||||
menuType = MENU_MAIN;
|
menuType = MENU_MAIN;
|
||||||
|
|
Loading…
Reference in New Issue