From 7296b8ab76ffe28c125370fbf10ee12c762453b0 Mon Sep 17 00:00:00 2001 From: Julie Marchant Date: Thu, 30 May 2019 12:01:42 -0400 Subject: [PATCH] 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). --- src/engine.c | 11 +++++++ src/engine.h | 1 + src/intermission.c | 6 ++-- src/mission.c | 73 ++++++++++++++++++++++------------------------ src/player.c | 3 +- 5 files changed, 50 insertions(+), 44 deletions(-) diff --git a/src/engine.c b/src/engine.c index 4523dc9..2abcf79 100644 --- a/src/engine.c +++ b/src/engine.c @@ -322,6 +322,17 @@ void engine_setMode() 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() { Object *ob, *ob2; diff --git a/src/engine.h b/src/engine.h index 9c2fd54..e495f88 100644 --- a/src/engine.h +++ b/src/engine.h @@ -112,6 +112,7 @@ void engine_warn(const char *msg); void engine_error(const char *msg); void engine_setupConfigDirectory(); void engine_setMode(); +void engine_setFullscreen(int value); void engine_resetLists(); void engine_cleanup(); diff --git a/src/intermission.c b/src/intermission.c index 0bad28f..2e171da 100644 --- a/src/intermission.c +++ b/src/intermission.c @@ -1198,8 +1198,7 @@ static void intermission_doOptions(SDL_Surface *optionsSurface, int x, int y) { if (!engine.fullScreen) { - SDL_SetWindowFullscreen(window, FULLSCREEN); - engine.fullScreen = 1; + engine_setFullscreen(1); } } @@ -1207,8 +1206,7 @@ static void intermission_doOptions(SDL_Surface *optionsSurface, int x, int y) { if (engine.fullScreen) { - SDL_SetWindowFullscreen(window, 0); - engine.fullScreen = 0; + engine_setFullscreen(0); } } diff --git a/src/mission.c b/src/mission.c index 3822948..46aa7b6 100644 --- a/src/mission.c +++ b/src/mission.c @@ -1045,44 +1045,6 @@ void mission_showStartScreen() screen_clear(black); 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_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); @@ -1118,6 +1080,41 @@ void mission_showStartScreen() 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(); player_getInput(); if ((engine.keyState[KEY_FIRE]) || (engine.keyState[KEY_ALTFIRE]) || diff --git a/src/player.c b/src/player.c index a4590a0..0afc34f 100644 --- a/src/player.c +++ b/src/player.c @@ -341,8 +341,7 @@ void player_getInput() if (engine.keyState[KEY_FULLSCREEN]) { - engine.fullScreen = !engine.fullScreen; - SDL_SetWindowFullscreen(window, engine.fullScreen ? FULLSCREEN : 0); + engine_setFullscreen(!engine.fullScreen); engine.keyState[KEY_FULLSCREEN] = 0; } }