Fixed some graphical problems.

Problem 1: fullscreen switching was leaving artifacts. Fixed by
drawing all black when switching fullscreen (and switching fullscreen
is now handled by its own function).

Problem 2: the mission briefing screen would distort if you changed
fullscreen during it. Fixed by redrawing the screen (it was previously
only drawn once).
This commit is contained in:
Julie Marchant 2019-05-30 12:01:42 -04:00
parent 04033b332e
commit 7296b8ab76
5 changed files with 50 additions and 44 deletions

View File

@ -322,6 +322,17 @@ void engine_setMode()
SDL_JoystickOpen(0); SDL_JoystickOpen(0);
} }
void engine_setFullscreen(int value)
{
engine.fullScreen = value;
// Clear the screen (prevents artifacts)
screen_clear(black);
renderer_update();
SDL_SetWindowFullscreen(window, engine.fullScreen ? FULLSCREEN : 0);
}
void engine_resetLists() void engine_resetLists()
{ {
Object *ob, *ob2; Object *ob, *ob2;

View File

@ -112,6 +112,7 @@ void engine_warn(const char *msg);
void engine_error(const char *msg); void engine_error(const char *msg);
void engine_setupConfigDirectory(); void engine_setupConfigDirectory();
void engine_setMode(); void engine_setMode();
void engine_setFullscreen(int value);
void engine_resetLists(); void engine_resetLists();
void engine_cleanup(); void engine_cleanup();

View File

@ -1198,8 +1198,7 @@ static void intermission_doOptions(SDL_Surface *optionsSurface, int x, int y)
{ {
if (!engine.fullScreen) if (!engine.fullScreen)
{ {
SDL_SetWindowFullscreen(window, FULLSCREEN); engine_setFullscreen(1);
engine.fullScreen = 1;
} }
} }
@ -1207,8 +1206,7 @@ static void intermission_doOptions(SDL_Surface *optionsSurface, int x, int y)
{ {
if (engine.fullScreen) if (engine.fullScreen)
{ {
SDL_SetWindowFullscreen(window, 0); engine_setFullscreen(0);
engine.fullScreen = 0;
} }
} }

View File

@ -1045,44 +1045,6 @@ void mission_showStartScreen()
screen_clear(black); screen_clear(black);
renderer_update(); renderer_update();
if (game.area != MISN_INTERCEPTION)
{
screen_clear(black);
mission_drawScreen();
if (mission.timeLimit1[0] > 0)
{
char temp[50];
if (game.area != MISN_MARS)
sprintf(temp, "TIME LIMIT: %d minutes", mission.timeLimit1[0]);
else
sprintf(temp, "SURVIVAL FOR %d minutes", mission.timeLimit1[0]);
screen_renderString(temp, -1, screen->h / 2 + 195, FONT_RED);
}
switch (game.area)
{
case MISN_URUSOR:
case MISN_DORIM:
case MISN_SIVEDI:
case MISN_ALMARTHA:
case MISN_ELLESH:
case MISN_MARS:
case MISN_VENUS:
screen_renderString("Phoebe Lexx will not be present", screen->w / 2 - 240, screen->h / 2 + 115, FONT_WHITE);
if (game.hasWingMate2)
screen_renderString("Ursula Lexx will not be present", screen->w / 2 - 240, screen->h / 2 + 145, FONT_WHITE);
break;
}
if ((game.area == MISN_URUSOR) ||
(game.area == MISN_POSWIC) ||
(game.area == MISN_EARTH))
screen_renderString("Sid Wilson will join you on this mission", screen->w / 2 - 240, screen->h / 2 + 175, FONT_WHITE);
renderer_update();
}
gfx_loadSprites(); gfx_loadSprites();
gfx_createTextObject(TS_SHIELD, "Shield", screen->w / 32, screen->h - 50, FONT_WHITE); gfx_createTextObject(TS_SHIELD, "Shield", screen->w / 32, screen->h - 50, FONT_WHITE);
gfx_createTextObject(TS_PLASMA_T, "Plasma:", screen->w * 5 / 16, screen->h - 50, FONT_WHITE); gfx_createTextObject(TS_PLASMA_T, "Plasma:", screen->w * 5 / 16, screen->h - 50, FONT_WHITE);
@ -1118,6 +1080,41 @@ void mission_showStartScreen()
while (1) while (1)
{ {
screen_clear(black);
mission_drawScreen();
if (mission.timeLimit1[0] > 0)
{
char temp[50];
if (game.area != MISN_MARS)
sprintf(temp, "TIME LIMIT: %d minutes", mission.timeLimit1[0]);
else
sprintf(temp, "SURVIVAL FOR %d minutes", mission.timeLimit1[0]);
screen_renderString(temp, -1, screen->h / 2 + 195, FONT_RED);
}
switch (game.area)
{
case MISN_URUSOR:
case MISN_DORIM:
case MISN_SIVEDI:
case MISN_ALMARTHA:
case MISN_ELLESH:
case MISN_MARS:
case MISN_VENUS:
screen_renderString("Phoebe Lexx will not be present", screen->w / 2 - 240, screen->h / 2 + 115, FONT_WHITE);
if (game.hasWingMate2)
screen_renderString("Ursula Lexx will not be present", screen->w / 2 - 240, screen->h / 2 + 145, FONT_WHITE);
break;
}
if ((game.area == MISN_URUSOR) ||
(game.area == MISN_POSWIC) ||
(game.area == MISN_EARTH))
screen_renderString("Sid Wilson will join you on this mission", screen->w / 2 - 240, screen->h / 2 + 175, FONT_WHITE);
renderer_update();
game_delayFrame(); game_delayFrame();
player_getInput(); player_getInput();
if ((engine.keyState[KEY_FIRE]) || (engine.keyState[KEY_ALTFIRE]) || if ((engine.keyState[KEY_FIRE]) || (engine.keyState[KEY_ALTFIRE]) ||

View File

@ -341,8 +341,7 @@ void player_getInput()
if (engine.keyState[KEY_FULLSCREEN]) if (engine.keyState[KEY_FULLSCREEN])
{ {
engine.fullScreen = !engine.fullScreen; engine_setFullscreen(!engine.fullScreen);
SDL_SetWindowFullscreen(window, engine.fullScreen ? FULLSCREEN : 0);
engine.keyState[KEY_FULLSCREEN] = 0; engine.keyState[KEY_FULLSCREEN] = 0;
} }
} }