diff --git a/src/game.c b/src/game.c index 29737d2..8dc12ab 100644 --- a/src/game.c +++ b/src/game.c @@ -1826,24 +1826,24 @@ static void game_doHud() fontColor = FONT_YELLOW; else fontColor = FONT_WHITE; - screen_blitTextInPlace(TS_TIME_T); + screen_blitText(TS_TIME_T, screen->w / 2 - 140, 20); sprintf(text, "%.2d:%.2d", engine.minutes, engine.seconds); - gfx_createTextObject(TS_TIME, text, screen->w / 2 + 10, 21, fontColor); - screen_blitTextInPlace(TS_TIME); + gfx_createTextObject(TS_TIME, text, 0, 0, fontColor); + screen_blitText(TS_TIME, screen->w / 2 + 10, 21); } if (game.area != MISN_INTERCEPTION) { - screen_blitTextInPlace(TS_OBJECTIVES_T); + screen_blitText(TS_OBJECTIVES_T, screen->w - 250, 20); sprintf(text, "%d", (mission.remainingObjectives1 + mission.remainingObjectives2)); - gfx_createTextObject(TS_OBJECTIVES, text, screen->w - 55, 21, FONT_WHITE); - screen_blitTextInPlace(TS_OBJECTIVES); + gfx_createTextObject(TS_OBJECTIVES, text, 0, 0, FONT_WHITE); + screen_blitText(TS_OBJECTIVES, screen->w - 55, 21); } - screen_blitTextInPlace(TS_CASH_T); // cash + screen_blitText(TS_CASH_T, 25, 20); sprintf(text, "%.6d", game.cash); - gfx_createTextObject(TS_CASH, text, 90, 21, FONT_WHITE); - screen_blitTextInPlace(TS_CASH); + gfx_createTextObject(TS_CASH, text, 0, 0, FONT_WHITE); + screen_blitText(TS_CASH, 90, 21); if (game.difficulty == DIFFICULTY_ORIGINAL) { @@ -1972,8 +1972,7 @@ static void game_doHud() { if (gfx_textSprites[i].life > 0) { - gfx_textSprites[i].y = screen->h - 75 - (i * 20); - screen_blitTextInPlace(i); + screen_blitText(i, -1, screen->h - 75 - (i * 20)); gfx_textSprites[i].life--; if (gfx_textSprites[i].life == 0) diff --git a/src/gfx.c b/src/gfx.c index 91d6483..5a5e089 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -361,8 +361,6 @@ void gfx_createTextObject(int index, const char *inString, int x, int y, int fon { gfx_textSprites[index].x = x; gfx_textSprites[index].y = y; - if (x == -1) - gfx_textSprites[index].x = (screen->w - gfx_textSprites[index].image->w) / 2; return; } @@ -375,8 +373,6 @@ void gfx_createTextObject(int index, const char *inString, int x, int y, int fon SDL_FreeSurface(gfx_textSprites[index].image); } gfx_textSprites[index].image = gfx_createTextSurface(inString, fontColor); - if (x == -1) - gfx_textSprites[index].x = (screen->w - gfx_textSprites[index].image->w) / 2; } SDL_Surface *gfx_createAlphaRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue) diff --git a/src/info.c b/src/info.c index 7f0eb08..c533e80 100644 --- a/src/info.c +++ b/src/info.c @@ -33,7 +33,7 @@ void info_clearLines() // from a to b void info_copyLine(int a, int b) { - gfx_createTextObject(b, gfx_textSprites[a].text, -1, 0, gfx_textSprites[a].fontColor); + gfx_createTextObject(b, gfx_textSprites[a].text, 0, 0, gfx_textSprites[a].fontColor); gfx_textSprites[b].life = gfx_textSprites[a].life; } @@ -65,6 +65,6 @@ void info_setLine(const char *in, int color) } } - gfx_createTextObject(index, in, -1, 0, color); + gfx_createTextObject(index, in, 0, 0, color); gfx_textSprites[index].life = 240; } diff --git a/src/mission.c b/src/mission.c index 46aa7b6..d07e5c3 100644 --- a/src/mission.c +++ b/src/mission.c @@ -1060,9 +1060,9 @@ void mission_showStartScreen() gfx_createTextObject(TS_TARGET_SID, "Sid", screen->w * 11 / 16 + 27, screen->h - 50, FONT_WHITE); gfx_createTextObject(TS_TARGET_PHOEBE, "Phoebe", screen->w * 11 / 16, screen->h - 50, FONT_WHITE); gfx_createTextObject(TS_TARGET_KLINE, "Kline", screen->w * 11 / 16 + 9, screen->h - 50, FONT_WHITE); - gfx_createTextObject(TS_CASH_T, "Cash: $", 25, 20, FONT_WHITE); - gfx_createTextObject(TS_OBJECTIVES_T, "Objectives Remaining:", screen->w - 250, 20, FONT_WHITE); - gfx_createTextObject(TS_TIME_T, "Time Remaining - ", screen->w / 2 - 140, 20, FONT_WHITE); + gfx_createTextObject(TS_CASH_T, "Cash: $", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_OBJECTIVES_T, "Objectives Remaining:", 0, 0, FONT_WHITE); + gfx_createTextObject(TS_TIME_T, "Time Remaining - ", 0, 0, FONT_WHITE); gfx_createTextObject(TS_POWER, "Power", screen->w / 32, screen->h - 30, FONT_WHITE); gfx_createTextObject(TS_OUTPUT, "Output", screen->w * 5 / 16, screen->h - 30, FONT_WHITE); gfx_createTextObject(TS_COOLER, "Cooler", screen->w * 97 / 160, screen->h - 30, FONT_WHITE); diff --git a/src/screen.c b/src/screen.c index e230dfe..f36b3f2 100644 --- a/src/screen.c +++ b/src/screen.c @@ -48,7 +48,11 @@ void screen_blitText(int i, int x, int y) // Legacy function; will be removed later void screen_blitTextInPlace(int i) { - screen_blit(gfx_textSprites[i].image, (int)gfx_textSprites[i].x, (int)gfx_textSprites[i].y); + int x = gfx_textSprites[i].x; + if (x == -1) + x = (screen->w - gfx_textSprites[i].image->w) / 2; + + screen_blit(gfx_textSprites[i].image, x, (int)gfx_textSprites[i].y); } int screen_renderString(const char *in, int x, int y, int fontColor) diff --git a/src/screen.h b/src/screen.h index c5407fc..40a090b 100644 --- a/src/screen.h +++ b/src/screen.h @@ -30,6 +30,7 @@ extern LinkedRect *screen_bufferHead; extern LinkedRect *screen_bufferTail; void screen_blit(SDL_Surface *image, int x, int y); +void screen_blitText(int i, int x, int y); void screen_blitTextInPlace(int i); int screen_renderString(const char *in, int x, int y, int fontColor); void screen_drawBackground();