Added a new screen_blitText function.
The old one still remains while I adapt the code to the new one. This is simply a decoupling of the absolute position of text from the creation of the text, to better facilitate position adaptation to changes in screen size. Position indicated at creation remains only for relative position (for use by e.g. credits and status lines).
This commit is contained in:
parent
3c866fe150
commit
0ac42df374
42
src/game.c
42
src/game.c
|
@ -1826,24 +1826,24 @@ static void game_doHud()
|
|||
fontColor = FONT_YELLOW;
|
||||
else
|
||||
fontColor = FONT_WHITE;
|
||||
screen_blitText(TS_TIME_T);
|
||||
screen_blitTextInPlace(TS_TIME_T);
|
||||
sprintf(text, "%.2d:%.2d", engine.minutes, engine.seconds);
|
||||
gfx_createTextObject(TS_TIME, text, screen->w / 2 + 10, 21, fontColor);
|
||||
screen_blitText(TS_TIME);
|
||||
screen_blitTextInPlace(TS_TIME);
|
||||
}
|
||||
|
||||
if (game.area != MISN_INTERCEPTION)
|
||||
{
|
||||
screen_blitText(TS_OBJECTIVES_T);
|
||||
screen_blitTextInPlace(TS_OBJECTIVES_T);
|
||||
sprintf(text, "%d", (mission.remainingObjectives1 + mission.remainingObjectives2));
|
||||
gfx_createTextObject(TS_OBJECTIVES, text, screen->w - 55, 21, FONT_WHITE);
|
||||
screen_blitText(TS_OBJECTIVES);
|
||||
screen_blitTextInPlace(TS_OBJECTIVES);
|
||||
}
|
||||
|
||||
screen_blitText(TS_CASH_T); // cash
|
||||
screen_blitTextInPlace(TS_CASH_T); // cash
|
||||
sprintf(text, "%.6d", game.cash);
|
||||
gfx_createTextObject(TS_CASH, text, 90, 21, FONT_WHITE);
|
||||
screen_blitText(TS_CASH);
|
||||
screen_blitTextInPlace(TS_CASH);
|
||||
|
||||
if (game.difficulty == DIFFICULTY_ORIGINAL)
|
||||
{
|
||||
|
@ -1877,12 +1877,12 @@ static void game_doHud()
|
|||
if (player.ammo[0] <= 25) fontColor = FONT_YELLOW;
|
||||
if (player.ammo[0] <= 10) fontColor = FONT_RED;
|
||||
}
|
||||
screen_blitText(TS_PLASMA_T);
|
||||
screen_blitTextInPlace(TS_PLASMA_T);
|
||||
sprintf(text, "%.3d", player.ammo[0]);
|
||||
gfx_createTextObject(TS_PLASMA, text, screen->w * 5 / 16 + 70, screen->h - 49, fontColor);
|
||||
screen_blitText(TS_PLASMA);
|
||||
screen_blitTextInPlace(TS_PLASMA);
|
||||
|
||||
screen_blitText(TS_AMMO_T);
|
||||
screen_blitTextInPlace(TS_AMMO_T);
|
||||
|
||||
if ((player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_LASER))
|
||||
{
|
||||
|
@ -1892,7 +1892,7 @@ static void game_doHud()
|
|||
fontColor = FONT_WHITE;
|
||||
sprintf(text, "%.2d", player.ammo[1]); // rocket ammo
|
||||
gfx_createTextObject(TS_AMMO, text, screen->w / 2 + 80, screen->h - 49, fontColor);
|
||||
screen_blitText(TS_AMMO);
|
||||
screen_blitTextInPlace(TS_AMMO);
|
||||
}
|
||||
|
||||
if (((player.weaponType[1] == W_CHARGER) || (player.weaponType[1] == W_LASER)) && (player.ammo[1] > 0))
|
||||
|
@ -1973,7 +1973,7 @@ static void game_doHud()
|
|||
if (gfx_textSprites[i].life > 0)
|
||||
{
|
||||
gfx_textSprites[i].y = screen->h - 75 - (i * 20);
|
||||
screen_blitText(i);
|
||||
screen_blitTextInPlace(i);
|
||||
gfx_textSprites[i].life--;
|
||||
|
||||
if (gfx_textSprites[i].life == 0)
|
||||
|
@ -2002,18 +2002,18 @@ static void game_doHud()
|
|||
{
|
||||
if (game.difficulty == DIFFICULTY_ORIGINAL)
|
||||
{
|
||||
screen_blitText(TS_TARGET);
|
||||
screen_blitTextInPlace(TS_TARGET);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (engine.targetIndex == ALIEN_SID)
|
||||
screen_blitText(TS_TARGET_SID);
|
||||
screen_blitTextInPlace(TS_TARGET_SID);
|
||||
else if (engine.targetIndex == ALIEN_PHOEBE)
|
||||
screen_blitText(TS_TARGET_PHOEBE);
|
||||
screen_blitTextInPlace(TS_TARGET_PHOEBE);
|
||||
else if (engine.targetIndex == ALIEN_KLINE)
|
||||
screen_blitText(TS_TARGET_KLINE);
|
||||
screen_blitTextInPlace(TS_TARGET_KLINE);
|
||||
else
|
||||
screen_blitText(TS_TARGET);
|
||||
screen_blitTextInPlace(TS_TARGET);
|
||||
}
|
||||
|
||||
bar.w = MAX(screen->w / 800, 1);
|
||||
|
@ -2036,7 +2036,7 @@ static void game_doHud()
|
|||
}
|
||||
}
|
||||
|
||||
screen_blitText(TS_POWER);
|
||||
screen_blitTextInPlace(TS_POWER);
|
||||
|
||||
bar.w = screen->w / 32;
|
||||
bar.h = 12;
|
||||
|
@ -2055,7 +2055,7 @@ static void game_doHud()
|
|||
bar.x += screen->w * 3 / 80;
|
||||
}
|
||||
|
||||
screen_blitText(TS_OUTPUT);
|
||||
screen_blitTextInPlace(TS_OUTPUT);
|
||||
|
||||
bar.w = screen->w / 32;
|
||||
bar.h = 12;
|
||||
|
@ -2076,7 +2076,7 @@ static void game_doHud()
|
|||
bar.x += screen->w * 3 / 80;
|
||||
}
|
||||
|
||||
screen_blitText(TS_COOLER);
|
||||
screen_blitTextInPlace(TS_COOLER);
|
||||
|
||||
bar.w = screen->w / 32;
|
||||
bar.h = 12;
|
||||
|
@ -2096,7 +2096,7 @@ static void game_doHud()
|
|||
bar.x += screen->w * 3 / 80;
|
||||
}
|
||||
|
||||
screen_blitText(TS_SHIELD);
|
||||
screen_blitTextInPlace(TS_SHIELD);
|
||||
if (player.shield < 1)
|
||||
return;
|
||||
|
||||
|
@ -2540,7 +2540,7 @@ int game_mainLoop()
|
|||
if (engine.paused)
|
||||
{
|
||||
gfx_createTextObject(TS_PAUSED, "PAUSED", -1, screen->h / 2, FONT_WHITE);
|
||||
screen_blitText(TS_PAUSED);
|
||||
screen_blitTextInPlace(TS_PAUSED);
|
||||
renderer_update();
|
||||
audio_pauseMusic();
|
||||
|
||||
|
|
|
@ -699,7 +699,7 @@ static void intermission_showStatus(SDL_Surface *infoSurface)
|
|||
{
|
||||
gfx_textSprites[i].y -= speed;
|
||||
if ((gfx_textSprites[i].y > 80) && (gfx_textSprites[i].y < 70 + infoSurface->h))
|
||||
screen_blitText(i);
|
||||
screen_blitTextInPlace(i);
|
||||
}
|
||||
|
||||
if (gfx_textSprites[TS_STATUS_FOOTER - 1].y < 65)
|
||||
|
@ -720,8 +720,8 @@ static void intermission_showStatus(SDL_Surface *infoSurface)
|
|||
|
||||
screen_drawRect(x, infoSurface->h + 70, infoSurface->w, 20, 0x00, 0x00, 0x99);
|
||||
|
||||
screen_blitText(TS_STATUS_HEADER);
|
||||
screen_blitText(TS_STATUS_FOOTER);
|
||||
screen_blitTextInPlace(TS_STATUS_HEADER);
|
||||
screen_blitTextInPlace(TS_STATUS_FOOTER);
|
||||
}
|
||||
|
||||
static void intermission_createCommsSurface(SDL_Surface *comms)
|
||||
|
@ -1449,7 +1449,7 @@ int intermission()
|
|||
engine.ssy /= 100;
|
||||
}
|
||||
|
||||
screen_blitText(TS_CURRENT_SYSTEM);
|
||||
screen_blitTextInPlace(TS_CURRENT_SYSTEM);
|
||||
|
||||
switch(section)
|
||||
{
|
||||
|
@ -1504,9 +1504,9 @@ int intermission()
|
|||
gfx_createTextObject(TS_DEST_PLANET, string, screen->w - 250, screen->h - 120, FONT_WHITE);
|
||||
}
|
||||
|
||||
screen_blitText(TS_CURRENT_PLANET);
|
||||
screen_blitTextInPlace(TS_CURRENT_PLANET);
|
||||
if (game.stationedPlanet != game.destinationPlanet)
|
||||
screen_blitText(TS_DEST_PLANET);
|
||||
screen_blitTextInPlace(TS_DEST_PLANET);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
@ -1547,9 +1547,9 @@ int intermission()
|
|||
intermission_showSystem(orbit_pos, 0);
|
||||
|
||||
screen_blit(intermission_planets[game.stationedPlanet].image, 150, screen->h - 90);
|
||||
screen_blitText(TS_CURRENT_PLANET);
|
||||
screen_blitTextInPlace(TS_CURRENT_PLANET);
|
||||
screen_blit(intermission_planets[game.destinationPlanet].image, screen->w - 150, screen->h - 90);
|
||||
screen_blitText(TS_DEST_PLANET);
|
||||
screen_blitTextInPlace(TS_DEST_PLANET);
|
||||
|
||||
game.distanceCovered += distance * (screen->w - 350) / 450.;
|
||||
destRect.w = (int)game.distanceCovered;
|
||||
|
@ -1606,9 +1606,9 @@ int intermission()
|
|||
(!intermission_planets[game.stationedPlanet].missionCompleted)))
|
||||
{
|
||||
if (game.stationedPlanet == game.destinationPlanet)
|
||||
screen_blitText(TS_INFO_START_MISSION);
|
||||
screen_blitTextInPlace(TS_INFO_START_MISSION);
|
||||
else
|
||||
screen_blitText(TS_INFO_GOTO);
|
||||
screen_blitTextInPlace(TS_INFO_GOTO);
|
||||
|
||||
if ((engine.keyState[KEY_FIRE]))
|
||||
{
|
||||
|
@ -1619,7 +1619,7 @@ int intermission()
|
|||
}
|
||||
else if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + w / 7, y, 32, 32))
|
||||
{
|
||||
screen_blitText(TS_INFO_MAP);
|
||||
screen_blitTextInPlace(TS_INFO_MAP);
|
||||
|
||||
if ((engine.keyState[KEY_FIRE]))
|
||||
{
|
||||
|
@ -1630,7 +1630,7 @@ int intermission()
|
|||
}
|
||||
else if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + 2 * w / 7, y, 32, 32))
|
||||
{
|
||||
screen_blitText(TS_INFO_STATUS);
|
||||
screen_blitTextInPlace(TS_INFO_STATUS);
|
||||
|
||||
if ((engine.keyState[KEY_FIRE]))
|
||||
{
|
||||
|
@ -1641,7 +1641,7 @@ int intermission()
|
|||
}
|
||||
else if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + 3 * w / 7, y, 32, 32))
|
||||
{
|
||||
screen_blitText(TS_INFO_SAVE_GAME);
|
||||
screen_blitTextInPlace(TS_INFO_SAVE_GAME);
|
||||
|
||||
if ((engine.keyState[KEY_FIRE]))
|
||||
{
|
||||
|
@ -1652,7 +1652,7 @@ int intermission()
|
|||
}
|
||||
else if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + 4 * w / 7, y, 32, 32))
|
||||
{
|
||||
screen_blitText(TS_INFO_SHOP);
|
||||
screen_blitTextInPlace(TS_INFO_SHOP);
|
||||
|
||||
if ((engine.keyState[KEY_FIRE]))
|
||||
{
|
||||
|
@ -1663,7 +1663,7 @@ int intermission()
|
|||
}
|
||||
else if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + 5 * w / 7, y, 32, 32))
|
||||
{
|
||||
screen_blitText(TS_INFO_COMMS);
|
||||
screen_blitTextInPlace(TS_INFO_COMMS);
|
||||
|
||||
if ((engine.keyState[KEY_FIRE]))
|
||||
{
|
||||
|
@ -1675,7 +1675,7 @@ int intermission()
|
|||
}
|
||||
else if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + 6 * w / 7, y, 32, 32))
|
||||
{
|
||||
screen_blitText(TS_INFO_OPTIONS);
|
||||
screen_blitTextInPlace(TS_INFO_OPTIONS);
|
||||
|
||||
if ((engine.keyState[KEY_FIRE]))
|
||||
{
|
||||
|
@ -1686,7 +1686,7 @@ int intermission()
|
|||
}
|
||||
else if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + w, y, 32, 32))
|
||||
{
|
||||
screen_blitText(TS_INFO_EXIT);
|
||||
screen_blitTextInPlace(TS_INFO_EXIT);
|
||||
|
||||
if ((engine.keyState[KEY_FIRE]))
|
||||
{
|
||||
|
|
12
src/screen.c
12
src/screen.c
|
@ -36,7 +36,17 @@ void screen_blit(SDL_Surface *image, int x, int y)
|
|||
gfx_blit(image, x, y, screen);
|
||||
}
|
||||
|
||||
void screen_blitText(int i)
|
||||
void screen_blitText(int i, int x, int y)
|
||||
{
|
||||
if (x == -1)
|
||||
x = (screen->w - gfx_textSprites[i].image->w) / 2;
|
||||
|
||||
screen_blit(gfx_textSprites[i].image,
|
||||
(x + (int)gfx_textSprites[i].x), (y +(int)gfx_textSprites[i].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);
|
||||
}
|
||||
|
|
|
@ -30,7 +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);
|
||||
void screen_blitTextInPlace(int i);
|
||||
int screen_renderString(const char *in, int x, int y, int fontColor);
|
||||
void screen_drawBackground();
|
||||
void screen_addBuffer(int x, int y, int w, int h);
|
||||
|
|
48
src/title.c
48
src/title.c
|
@ -41,24 +41,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
static int showGameMenu(int continueSaveSlot)
|
||||
{
|
||||
screen_blitText(TS_START_NEW_GAME);
|
||||
screen_blitText(TS_LOAD_GAME);
|
||||
screen_blitTextInPlace(TS_START_NEW_GAME);
|
||||
screen_blitTextInPlace(TS_LOAD_GAME);
|
||||
if (continueSaveSlot != -1)
|
||||
{
|
||||
screen_blitText(TS_CONTINUE_CURRENT_GAME);
|
||||
screen_blitTextInPlace(TS_CONTINUE_CURRENT_GAME);
|
||||
}
|
||||
screen_blitText(TS_OPTIONS);
|
||||
screen_blitText(TS_CREDITS);
|
||||
screen_blitTextInPlace(TS_OPTIONS);
|
||||
screen_blitTextInPlace(TS_CREDITS);
|
||||
if (engine.cheat)
|
||||
{
|
||||
gfx_textSprites[TS_QUIT].y = screen->h / 3 + 170;
|
||||
screen_blitText(TS_CHEAT_OPTIONS);
|
||||
screen_blitTextInPlace(TS_CHEAT_OPTIONS);
|
||||
}
|
||||
else
|
||||
{
|
||||
gfx_textSprites[TS_QUIT].y = screen->h / 3 + 150;
|
||||
}
|
||||
screen_blitText(TS_QUIT);
|
||||
screen_blitTextInPlace(TS_QUIT);
|
||||
|
||||
if (engine.cheat)
|
||||
return 7;
|
||||
|
@ -75,11 +75,11 @@ static int showLoadMenu()
|
|||
rtn++;
|
||||
if (gfx_textSprites[i].image != NULL)
|
||||
{
|
||||
screen_blitText(i);
|
||||
screen_blitTextInPlace(i);
|
||||
gfx_textSprites[TS_BACK_TO_MAIN_MENU].y = gfx_textSprites[i].y + 40;
|
||||
}
|
||||
}
|
||||
screen_blitText(TS_BACK_TO_MAIN_MENU);
|
||||
screen_blitTextInPlace(TS_BACK_TO_MAIN_MENU);
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
@ -110,9 +110,9 @@ static int showDifficultyMenu()
|
|||
{
|
||||
gfx_textSprites[TS_BACK_TO_MAIN_MENU].y = screen->h / 3 + 110;
|
||||
|
||||
screen_blitText(TS_START_GAME);
|
||||
screen_blitText(TS_DIFFICULTY);
|
||||
screen_blitText(TS_BACK_TO_MAIN_MENU);
|
||||
screen_blitTextInPlace(TS_START_GAME);
|
||||
screen_blitTextInPlace(TS_DIFFICULTY);
|
||||
screen_blitTextInPlace(TS_BACK_TO_MAIN_MENU);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
@ -152,11 +152,11 @@ static int showOptionsMenu()
|
|||
{
|
||||
gfx_textSprites[TS_BACK_TO_MAIN_MENU].y = screen->h / 3 + 150;
|
||||
|
||||
screen_blitText(TS_SOUND);
|
||||
screen_blitText(TS_MUSIC);
|
||||
screen_blitText(TS_FULLSCREEN);
|
||||
screen_blitText(TS_AUTOPAUSE);
|
||||
screen_blitText(TS_BACK_TO_MAIN_MENU);
|
||||
screen_blitTextInPlace(TS_SOUND);
|
||||
screen_blitTextInPlace(TS_MUSIC);
|
||||
screen_blitTextInPlace(TS_FULLSCREEN);
|
||||
screen_blitTextInPlace(TS_AUTOPAUSE);
|
||||
screen_blitTextInPlace(TS_BACK_TO_MAIN_MENU);
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
@ -196,11 +196,11 @@ static int showCheatMenu()
|
|||
{
|
||||
gfx_textSprites[TS_BACK_TO_MAIN_MENU].y = screen->h / 3 + 150;
|
||||
|
||||
screen_blitText(TS_UNLIMITED_SHIELD);
|
||||
screen_blitText(TS_UNLIMITED_AMMO);
|
||||
screen_blitText(TS_UNLIMITED_CASH);
|
||||
screen_blitText(TS_UNLIMITED_TIME);
|
||||
screen_blitText(TS_BACK_TO_MAIN_MENU);
|
||||
screen_blitTextInPlace(TS_UNLIMITED_SHIELD);
|
||||
screen_blitTextInPlace(TS_UNLIMITED_AMMO);
|
||||
screen_blitTextInPlace(TS_UNLIMITED_CASH);
|
||||
screen_blitTextInPlace(TS_UNLIMITED_TIME);
|
||||
screen_blitTextInPlace(TS_BACK_TO_MAIN_MENU);
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
@ -360,11 +360,11 @@ int title_show()
|
|||
}
|
||||
else if ((now - then > 9000) && (now - then < 15000) && (!skip))
|
||||
{
|
||||
screen_blitText(TS_PRESENTS);
|
||||
screen_blitTextInPlace(TS_PRESENTS);
|
||||
}
|
||||
else if ((now - then > 16000) && (now - then < 21000) && (!skip))
|
||||
{
|
||||
screen_blitText(TS_AN_SDL_GAME);
|
||||
screen_blitTextInPlace(TS_AN_SDL_GAME);
|
||||
}
|
||||
else if ((now - then > 25500) || (skip))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue