Did some more cleanup, removing more "shape" magic numbers.

This commit is contained in:
onpon4 2015-12-31 10:47:27 -05:00
parent 1d02b3c71e
commit 651a7f55fb
13 changed files with 245 additions and 210 deletions

View File

@ -100,6 +100,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MAX_FONTSHAPES 6 #define MAX_FONTSHAPES 6
#define MAX_SHOPSHAPES 6 #define MAX_SHOPSHAPES 6
#define MAX_CARGO 20 #define MAX_CARGO 20
#define MAX_INFOLINES 3
#define MAX_STATUSLINES 30
#define SHIP_HIT_INDEX 60 #define SHIP_HIT_INDEX 60
@ -261,7 +263,7 @@ enum {
CD_URSULA CD_URSULA
}; };
// Text shapes // Text shapes (main menu)
enum { enum {
TS_PRESENTS, TS_PRESENTS,
@ -291,6 +293,32 @@ enum {
TS_DIFFICULTY TS_DIFFICULTY
}; };
// Text shapes (intermission)
enum {
};
// Text shapes (mission)
enum {
TS_RADIO = MAX_INFOLINES,
TS_SHIELD,
TS_PLASMA_T,
TS_AMMO_T,
TS_TARGET,
TS_CASH_T,
TS_OBJECTIVES_T,
TS_TIME_T,
TS_POWER,
TS_OUTPUT,
TS_COOLER,
TS_PAUSED,
TS_TIME,
TS_PLASMA,
TS_AMMO,
TS_CASH,
TS_OBJECTIVES
};
// Menu types // Menu types
enum { enum {

View File

@ -1617,7 +1617,7 @@ static void game_doArrow(int i)
if (i != engine.targetIndex) if (i != engine.targetIndex)
return; return;
if (gfx_text[3].life > 0) if (gfx_text[TS_RADIO].life > 0)
return; return;
if (sxy == sx) { if (sxy == sx) {
@ -1649,24 +1649,24 @@ static void game_doHud()
fontColor = FONT_YELLOW; fontColor = FONT_YELLOW;
else else
fontColor = FONT_WHITE; fontColor = FONT_WHITE;
screen_blitText(10); // time remaining screen_blitText(TS_TIME_T);
sprintf(text, "%.2d:%.2d", engine.minutes, engine.seconds); sprintf(text, "%.2d:%.2d", engine.minutes, engine.seconds);
textSurface(30, text, 410, 21, fontColor); gfx_createTextObject(TS_TIME, text, 410, 21, fontColor);
screen_blitText(30); screen_blitText(TS_TIME);
} }
if (game.area != MISN_INTERCEPTION) if (game.area != MISN_INTERCEPTION)
{ {
screen_blitText(9); // mission objectives screen_blitText(TS_OBJECTIVES_T);
sprintf(text, "%d", (currentMission.remainingObjectives1 + currentMission.remainingObjectives2)); sprintf(text, "%d", (currentMission.remainingObjectives1 + currentMission.remainingObjectives2));
textSurface(39, text, 745, 21, FONT_WHITE); gfx_createTextObject(TS_OBJECTIVES, text, 745, 21, FONT_WHITE);
screen_blitText(39); screen_blitText(TS_OBJECTIVES);
} }
screen_blitText(8); // cash screen_blitText(TS_CASH_T); // cash
sprintf(text, "%.6d", game.cash); sprintf(text, "%.6d", game.cash);
textSurface(38, text, 90, 21, FONT_WHITE); gfx_createTextObject(TS_CASH, text, 90, 21, FONT_WHITE);
screen_blitText(38); screen_blitText(TS_CASH);
for (int i = 0; i < ALIEN_MAX; i++) for (int i = 0; i < ALIEN_MAX; i++)
game_doArrow(i); game_doArrow(i);
@ -1677,12 +1677,12 @@ static void game_doHud()
if (player.ammo[0] <= 25) fontColor = FONT_YELLOW; if (player.ammo[0] <= 25) fontColor = FONT_YELLOW;
if (player.ammo[0] <= 10) fontColor = FONT_RED; if (player.ammo[0] <= 10) fontColor = FONT_RED;
} }
screen_blitText(5); // plasma ammo screen_blitText(TS_PLASMA_T);
sprintf(text, "%.3d", player.ammo[0]); sprintf(text, "%.3d", player.ammo[0]);
textSurface(35, text, 320, 551, fontColor); gfx_createTextObject(TS_PLASMA, text, 320, 551, fontColor);
screen_blitText(35); screen_blitText(TS_PLASMA);
screen_blitText(6); screen_blitText(TS_AMMO_T);
if ((player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_LASER)) if ((player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_LASER))
{ {
@ -1691,8 +1691,8 @@ static void game_doHud()
else else
fontColor = FONT_WHITE; fontColor = FONT_WHITE;
sprintf(text, "%.3d", player.ammo[1]); // rocket ammo sprintf(text, "%.3d", player.ammo[1]); // rocket ammo
textSurface(36, text, 465, 551, fontColor); gfx_createTextObject(TS_AMMO, text, 465, 551, fontColor);
screen_blitText(36); screen_blitText(TS_AMMO);
} }
if (((player.weaponType[1] == W_CHARGER) || (player.weaponType[1] == W_LASER)) && (player.ammo[1] > 0)) if (((player.weaponType[1] == W_CHARGER) || (player.weaponType[1] == W_LASER)) && (player.ammo[1] > 0))
@ -1767,7 +1767,7 @@ static void game_doHud()
} }
} }
for (int i = 0 ; i < 3 ; i++) for (int i = 0 ; i < MAX_INFOLINES ; i++)
{ {
if (gfx_text[i].life > 0) if (gfx_text[i].life > 0)
{ {
@ -1777,18 +1777,20 @@ static void game_doHud()
if (gfx_text[i].life == 0) if (gfx_text[i].life == 0)
{ {
copyInfoLine(i + 1, i); for (int j = i ; j < MAX_INFOLINES - 1 ; j++)
copyInfoLine(i + 2, i + 1); {
gfx_text[2].life = 0; copyInfoLine(j + 1, j);
}
gfx_text[MAX_INFOLINES - 1].life = 0;
} }
} }
} }
// Show the radio message if there is one // Show the radio message if there is one
if (gfx_text[3].life > 0) if (gfx_text[TS_RADIO].life > 0)
{ {
screen_blit(messageBox, (800 - messageBox->w) / 2, 50); screen_blit(messageBox, (screen->w - messageBox->w) / 2, 50);
gfx_text[3].life--; gfx_text[TS_RADIO].life--;
} }
// Do the target's remaining shield (if required) // Do the target's remaining shield (if required)
@ -1796,7 +1798,7 @@ static void game_doHud()
{ {
if ((engine.targetIndex > -1) && (aliens[engine.targetIndex].shield > 0) && (engine.targetIndex > 9)) if ((engine.targetIndex > -1) && (aliens[engine.targetIndex].shield > 0) && (engine.targetIndex > 9))
{ {
screen_blitText(7); screen_blitText(TS_TARGET);
bar.w = 1; bar.w = 1;
bar.h = 12; bar.h = 12;
bar.x = 620; bar.x = 620;
@ -1816,7 +1818,7 @@ static void game_doHud()
} }
} }
screen_blitText(11); screen_blitText(TS_POWER);
bar.w = 25; bar.w = 25;
bar.h = 12; bar.h = 12;
@ -1835,7 +1837,7 @@ static void game_doHud()
bar.x += 30; bar.x += 30;
} }
screen_blitText(12); screen_blitText(TS_OUTPUT);
bar.w = 25; bar.w = 25;
bar.h = 12; bar.h = 12;
@ -1856,7 +1858,7 @@ static void game_doHud()
bar.x += 30; bar.x += 30;
} }
screen_blitText(13); screen_blitText(TS_COOLER);
bar.w = 25; bar.w = 25;
bar.h = 12; bar.h = 12;
@ -1876,7 +1878,7 @@ static void game_doHud()
bar.x += 30; bar.x += 30;
} }
screen_blitText(4); screen_blitText(TS_SHIELD);
if (player.shield < 1) if (player.shield < 1)
return; return;
@ -2250,8 +2252,8 @@ int game_mainLoop()
if (engine.paused) if (engine.paused)
{ {
textSurface(22, "PAUSED", -1, screen->h / 2, FONT_WHITE); gfx_createTextObject(TS_PAUSED, "PAUSED", -1, screen->h / 2, FONT_WHITE);
screen_blitText(22); screen_blitText(TS_PAUSED);
renderer_update(); renderer_update();
audio_pauseMusic(); audio_pauseMusic();

View File

@ -303,7 +303,7 @@ void gfx_drawCircle(int xc, int yc, int R, SDL_Surface *PIX, int col)
} }
} }
void blevelRect(SDL_Surface *dest, int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue) void gfx_drawRect(SDL_Surface *dest, int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue)
{ {
SDL_Rect r = {(int16_t)x, (int16_t)y, (uint16_t)w, (uint16_t)h}; SDL_Rect r = {(int16_t)x, (int16_t)y, (uint16_t)w, (uint16_t)h};
SDL_FillRect(dest, &r, SDL_MapRGB(screen->format, red, green, blue)); SDL_FillRect(dest, &r, SDL_MapRGB(screen->format, red, green, blue));
@ -314,12 +314,7 @@ void blevelRect(SDL_Surface *dest, int x, int y, int w, int h, Uint8 red, Uint8
gfx_drawLine(dest, x + w, y + 1, x + w, y + h, SDL_MapRGB(screen->format, 128, 128, 128)); gfx_drawLine(dest, x + w, y + 1, x + w, y + h, SDL_MapRGB(screen->format, 128, 128, 128));
} }
void blevelRect(int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue) SDL_Surface *gfx_createSurface(int width, int height)
{
blevelRect(screen, x, y, w, h, red, green, blue);
}
SDL_Surface *createSurface(int width, int height)
{ {
SDL_Surface *surface; SDL_Surface *surface;
Uint32 rmask, gmask, bmask, amask; Uint32 rmask, gmask, bmask, amask;
@ -348,23 +343,24 @@ SDL_Surface *createSurface(int width, int height)
return surface; return surface;
} }
SDL_Surface *textSurface(const char *inString, int color) SDL_Surface *gfx_createTextSurface(const char *inString, int color)
{ {
SDL_Surface *surface = createSurface(strlen(inString) * 9, 16); // XXX: Magic numbers
SDL_Surface *surface = gfx_createSurface(strlen(inString) * 9, 16);
gfx_renderString(inString, 1, 1, color, 0, surface); gfx_renderString(inString, 1, 1, color, 0, surface);
return gfx_setTransparent(surface); return gfx_setTransparent(surface);
} }
void textSurface(int index, const char *inString, int x, int y, int fontColor) void gfx_createTextObject(int index, const char *inString, int x, int y, int fontColor)
{ {
/* Shortcut: if we already rendered the same string in the same color, don't render it again. */ /* Shortcut: if we already rendered the same string in the same color, don't render it again. */
if(gfx_text[index].text && gfx_text[index].image && gfx_text[index].fontColor == fontColor && !strcmp(gfx_text[index].text, inString)) { if(gfx_text[index].text && gfx_text[index].image && gfx_text[index].fontColor == fontColor && !strcmp(gfx_text[index].text, inString)) {
gfx_text[index].x = x; gfx_text[index].x = x;
gfx_text[index].y = y; gfx_text[index].y = y;
if (x == -1) if (x == -1)
gfx_text[index].x = (800 - gfx_text[index].image->w) / 2; gfx_text[index].x = (screen->w - gfx_text[index].image->w) / 2;
return; return;
} }
@ -376,14 +372,14 @@ void textSurface(int index, const char *inString, int x, int y, int fontColor)
{ {
SDL_FreeSurface(gfx_text[index].image); SDL_FreeSurface(gfx_text[index].image);
} }
gfx_text[index].image = textSurface(inString, fontColor); gfx_text[index].image = gfx_createTextSurface(inString, fontColor);
if (x == -1) if (x == -1)
gfx_text[index].x = (800 - gfx_text[index].image->w) / 2; gfx_text[index].x = (screen->w - gfx_text[index].image->w) / 2;
} }
SDL_Surface *alphaRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue) SDL_Surface *alphaRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue)
{ {
SDL_Surface *surface = createSurface(width, height); SDL_Surface *surface = gfx_createSurface(width, height);
SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, red, green, blue)); SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, red, green, blue));
@ -403,18 +399,18 @@ void createMessageBox(SDL_Surface *face, const char *message, signed char transp
if (transparent) if (transparent)
messageBox = alphaRect(550, 60, 0x00, 0x00, 0x00); messageBox = alphaRect(550, 60, 0x00, 0x00, 0x00);
else else
messageBox = createSurface(550, 60); messageBox = gfx_createSurface(550, 60);
signed char x = 60; signed char x = 60;
if (face != NULL) if (face != NULL)
{ {
blevelRect(messageBox, 0, 0, messageBox->w - 1, messageBox->h - 1, 0x00, 0x00, 0xaa); gfx_drawRect(messageBox, 0, 0, messageBox->w - 1, messageBox->h - 1, 0x00, 0x00, 0xaa);
gfx_blit(face, 5, 5, messageBox); gfx_blit(face, 5, 5, messageBox);
} }
else else
{ {
blevelRect(messageBox, 0, 0, messageBox->w - 1, messageBox->h - 1, 0x00, 0x00, 0x00); gfx_drawRect(messageBox, 0, 0, messageBox->w - 1, messageBox->h - 1, 0x00, 0x00, 0x00);
x = 10; x = 10;
} }

View File

@ -38,11 +38,10 @@ int gfx_renderString(const char *in, int x, int y, int fontColor, int wrap, SDL_
void gfx_putPixel(SDL_Surface *surface, int x, int y, Uint32 pixel); void gfx_putPixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
void gfx_drawLine(SDL_Surface *dest, int x1, int y1, int x2, int y2, int col); void gfx_drawLine(SDL_Surface *dest, int x1, int y1, int x2, int y2, int col);
void gfx_drawCircle(int xc, int yc, int R, SDL_Surface *PIX, int col); void gfx_drawCircle(int xc, int yc, int R, SDL_Surface *PIX, int col);
extern void blevelRect(SDL_Surface *dest, int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue); void gfx_drawRect(SDL_Surface *dest, int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue);
extern void blevelRect(int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue); SDL_Surface *gfx_createSurface(int width, int height);
extern SDL_Surface *createSurface(int width, int height); SDL_Surface *gfx_createTextSurface(const char *inString, int color);
extern SDL_Surface *textSurface(const char *inString, int color); void gfx_createTextObject(int index, const char *inString, int x, int y, int fontColor);
extern void textSurface(int index, const char *inString, int x, int y, int fontColor);
extern SDL_Surface *alphaRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue); extern SDL_Surface *alphaRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue);
extern void createMessageBox(SDL_Surface *face, const char *message, signed char transparent); extern void createMessageBox(SDL_Surface *face, const char *message, signed char transparent);
extern void freeGraphics(); extern void freeGraphics();

View File

@ -42,7 +42,7 @@ static void intermission_setStatusLines()
sprintf(string, "System : %s", systemNames[game.system]); sprintf(string, "System : %s", systemNames[game.system]);
textSurface(0, string, 0, 0, FONT_WHITE); gfx_createTextObject(0, string, 0, 0, FONT_WHITE);
signed char total = 0; signed char total = 0;
signed char completed = 0; signed char completed = 0;
@ -65,86 +65,86 @@ static void intermission_setStatusLines()
} }
for (int i = 0 ; i < 30 ; i++) for (int i = 0 ; i < 30 ; i++)
textSurface(i, "", 0, 0, FONT_WHITE); gfx_createTextObject(i, "", 0, 0, FONT_WHITE);
sprintf(string, "Missions Completed : %d/%d", completed, total); sprintf(string, "Missions Completed : %d/%d", completed, total);
textSurface(1, string, 0, 0, FONT_WHITE); gfx_createTextObject(1, string, 0, 0, FONT_WHITE);
sprintf(string, "Shots Fired : %d", game.shots); sprintf(string, "Shots Fired : %d", game.shots);
textSurface(2, string, 0, 0, FONT_WHITE); gfx_createTextObject(2, string, 0, 0, FONT_WHITE);
sprintf(string, "Hits Scored : %d", game.hits); sprintf(string, "Hits Scored : %d", game.hits);
textSurface(3, string, 0, 0, FONT_WHITE); gfx_createTextObject(3, string, 0, 0, FONT_WHITE);
sprintf(string, "Accuracy : %d%%", game.accuracy); sprintf(string, "Accuracy : %d%%", game.accuracy);
textSurface(4, string, 0, 0, FONT_WHITE); gfx_createTextObject(4, string, 0, 0, FONT_WHITE);
sprintf(string, "Enemies Killed by Others : %d", game.totalOtherKills); sprintf(string, "Enemies Killed by Others : %d", game.totalOtherKills);
textSurface(5, string, 0, 0, FONT_WHITE); gfx_createTextObject(5, string, 0, 0, FONT_WHITE);
sprintf(string, "Total Cash Earned : %d", game.cashEarned); sprintf(string, "Total Cash Earned : %d", game.cashEarned);
textSurface(6, string, 0, 0, FONT_WHITE); gfx_createTextObject(6, string, 0, 0, FONT_WHITE);
textSurface(7, "*** Chris ***", 0, 0, FONT_WHITE); gfx_createTextObject(7, "*** Chris ***", 0, 0, FONT_WHITE);
sprintf(string, "Enemies Killed : %d", game.totalKills); sprintf(string, "Enemies Killed : %d", game.totalKills);
textSurface(8, string, 0, 0, FONT_WHITE); gfx_createTextObject(8, string, 0, 0, FONT_WHITE);
sprintf(string, "Shield Restores Picked Up : %d", game.shieldPickups); sprintf(string, "Shield Restores Picked Up : %d", game.shieldPickups);
textSurface(9, string, 0, 0, FONT_WHITE); gfx_createTextObject(9, string, 0, 0, FONT_WHITE);
sprintf(string, "Plasma Cells Picked Up : %d", game.cellPickups); sprintf(string, "Plasma Cells Picked Up : %d", game.cellPickups);
textSurface(10, string, 0, 0, FONT_WHITE); gfx_createTextObject(10, string, 0, 0, FONT_WHITE);
sprintf(string, "Rockets Picked Up : %d", game.rocketPickups); sprintf(string, "Rockets Picked Up : %d", game.rocketPickups);
textSurface(11, string, 0, 0, FONT_WHITE); gfx_createTextObject(11, string, 0, 0, FONT_WHITE);
sprintf(string, "Powerups Picked Up : %d", game.rocketPickups); sprintf(string, "Powerups Picked Up : %d", game.rocketPickups);
textSurface(12, string, 0, 0, FONT_WHITE); gfx_createTextObject(12, string, 0, 0, FONT_WHITE);
sprintf(string, "Mines Destroyed : %d", game.minesKilled); sprintf(string, "Mines Destroyed : %d", game.minesKilled);
textSurface(13, string, 0, 0, FONT_WHITE); gfx_createTextObject(13, string, 0, 0, FONT_WHITE);
sprintf(string, "Slaves Rescued : %d", game.slavesRescued); sprintf(string, "Slaves Rescued : %d", game.slavesRescued);
textSurface(14, string, 0, 0, FONT_WHITE); gfx_createTextObject(14, string, 0, 0, FONT_WHITE);
sprintf(string, "Cargo Picked Up : %d", game.cargoPickups); sprintf(string, "Cargo Picked Up : %d", game.cargoPickups);
textSurface(15, string, 0, 0, FONT_WHITE); gfx_createTextObject(15, string, 0, 0, FONT_WHITE);
if (game.hasWingMate1) if (game.hasWingMate1)
{ {
textSurface(16, "*** Phoebe ***", 0, 0, FONT_WHITE); gfx_createTextObject(16, "*** Phoebe ***", 0, 0, FONT_WHITE);
sprintf(string, "Enemies Killed : %d", game.wingMate1Kills); sprintf(string, "Enemies Killed : %d", game.wingMate1Kills);
textSurface(17, string, 0, 0, FONT_WHITE); gfx_createTextObject(17, string, 0, 0, FONT_WHITE);
sprintf(string, "Ejections : %d", game.wingMate1Ejects); sprintf(string, "Ejections : %d", game.wingMate1Ejects);
textSurface(18, string, 0, 0, FONT_WHITE); gfx_createTextObject(18, string, 0, 0, FONT_WHITE);
} }
if (game.hasWingMate2) if (game.hasWingMate2)
{ {
textSurface(19, "*** Ursula ***", 0, 0, FONT_WHITE); gfx_createTextObject(19, "*** Ursula ***", 0, 0, FONT_WHITE);
sprintf(string, "Enemies Killed : %d", game.wingMate2Kills); sprintf(string, "Enemies Killed : %d", game.wingMate2Kills);
textSurface(20, string, 0, 0, FONT_WHITE); gfx_createTextObject(20, string, 0, 0, FONT_WHITE);
sprintf(string, "Ejections : %d", game.wingMate2Ejects); sprintf(string, "Ejections : %d", game.wingMate2Ejects);
textSurface(21, string, 0, 0, FONT_WHITE); gfx_createTextObject(21, string, 0, 0, FONT_WHITE);
} }
signed char percentage = 0; signed char percentage = 0;
if ((game.secondaryMissions > 0) && (game.secondaryMissionsCompleted > 0)) if ((game.secondaryMissions > 0) && (game.secondaryMissionsCompleted > 0))
percentage = (game.secondaryMissionsCompleted / game.secondaryMissions) * 100; percentage = (game.secondaryMissionsCompleted / game.secondaryMissions) * 100;
sprintf(string, "Seconday Missions Completed : %d / %d (%d%%)", game.secondaryMissionsCompleted, game.secondaryMissions, percentage); sprintf(string, "Seconday Missions Completed : %d / %d (%d%%)", game.secondaryMissionsCompleted, game.secondaryMissions, percentage);
textSurface(24, string, 0, 0, FONT_WHITE); gfx_createTextObject(24, string, 0, 0, FONT_WHITE);
int timeTaken = game.timeTaken; int timeTaken = game.timeTaken;
snprintf(string, sizeof string, "Total Time : %2d:%02d:%02d", timeTaken / 3600, (timeTaken / 60) % 60, timeTaken % 60); snprintf(string, sizeof string, "Total Time : %2d:%02d:%02d", timeTaken / 3600, (timeTaken / 60) % 60, timeTaken % 60);
textSurface(26, string, -1, 0, FONT_WHITE); gfx_createTextObject(26, string, -1, 0, FONT_WHITE);
textSurface(27, "Current Status", -1, 0, FONT_WHITE); gfx_createTextObject(27, "Current Status", -1, 0, FONT_WHITE);
gfx_text[0].y = 400; gfx_text[0].y = 400;
gfx_text[0].x = 150; gfx_text[0].x = 150;
@ -337,9 +337,9 @@ static void intermission_showStatus(SDL_Surface *infoSurface)
} }
} }
blevelRect(100, 80, 600, 20, 0x00, 0x00, 0x99); screen_drawRect(100, 80, 600, 20, 0x00, 0x00, 0x99);
blevelRect(100, 400, 600, 20, 0x00, 0x00, 0x99); screen_drawRect(100, 400, 600, 20, 0x00, 0x00, 0x99);
screen_blitText(26); screen_blitText(26);
screen_blitText(27); screen_blitText(27);
@ -352,7 +352,7 @@ static void intermission_updateCommsSurface(SDL_Surface *comms)
char string[255]; char string[255];
blevelRect(comms, 0, 10, comms->w - 1, 55, 0x00, 0x22, 0x00); gfx_drawRect(comms, 0, 10, comms->w - 1, 55, 0x00, 0x22, 0x00);
gfx_blit(shape[FACE_CHRIS], 20, 15, comms); gfx_blit(shape[FACE_CHRIS], 20, 15, comms);
gfx_renderString("Chris Bainfield", 80, 15, FONT_WHITE, 0, comms); gfx_renderString("Chris Bainfield", 80, 15, FONT_WHITE, 0, comms);
sprintf(string, "Current Location: %s", systemPlanet[game.stationedPlanet].name); sprintf(string, "Current Location: %s", systemPlanet[game.stationedPlanet].name);
@ -363,7 +363,7 @@ static void intermission_createCommsSurface(SDL_Surface *comms)
{ {
engine.commsSection = 0; engine.commsSection = 0;
blevelRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25); gfx_drawRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
gfx_renderString("+++ RECEIVED MESSAGES +++", 115, 80, FONT_GREEN, 0, comms); gfx_renderString("+++ RECEIVED MESSAGES +++", 115, 80, FONT_GREEN, 0, comms);
@ -374,7 +374,7 @@ static void intermission_createCommsSurface(SDL_Surface *comms)
if ((systemPlanet[i].messageSlot != -1) && (systemPlanet[i].missionCompleted == 0)) if ((systemPlanet[i].messageSlot != -1) && (systemPlanet[i].missionCompleted == 0))
{ {
yOffset = systemPlanet[i].messageSlot * 60; yOffset = systemPlanet[i].messageSlot * 60;
blevelRect(comms, 0, 105 + yOffset, comms->w - 1, 55, 0x00, 0x00, 0x77); gfx_drawRect(comms, 0, 105 + yOffset, comms->w - 1, 55, 0x00, 0x00, 0x77);
gfx_blit(shape[systemPlanet[i].faceImage], 20, 110 + yOffset, comms); gfx_blit(shape[systemPlanet[i].faceImage], 20, 110 + yOffset, comms);
gfx_renderString(systemPlanet[i].from, 80, 110 + yOffset, FONT_WHITE, 0, comms); gfx_renderString(systemPlanet[i].from, 80, 110 + yOffset, FONT_WHITE, 0, comms);
gfx_renderString(systemPlanet[i].subject, 80, 130 + yOffset, FONT_CYAN, 0, comms); gfx_renderString(systemPlanet[i].subject, 80, 130 + yOffset, FONT_CYAN, 0, comms);
@ -407,7 +407,7 @@ static void intermission_createMissionDetailSurface(SDL_Surface *comms, int miss
if (mission == -1) if (mission == -1)
return; return;
blevelRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25); gfx_drawRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
sprintf(string, "data/brief%d.txt", mission); sprintf(string, "data/brief%d.txt", mission);
@ -440,7 +440,7 @@ static void intermission_createMissionDetailSurface(SDL_Surface *comms, int miss
fclose(fp); fclose(fp);
blevelRect(comms, 5, comms->h - 28, 180, 20, 0x25, 0x00, 0x00); gfx_drawRect(comms, 5, comms->h - 28, 180, 20, 0x25, 0x00, 0x00);
gfx_renderString("RETURN TO MESSAGES", 15, comms->h - 25, FONT_WHITE, 1, comms); gfx_renderString("RETURN TO MESSAGES", 15, comms->h - 25, FONT_WHITE, 1, comms);
engine.commsSection = 1; engine.commsSection = 1;
@ -476,39 +476,39 @@ static void intermission_createOptions(SDL_Surface *optionsSurface)
{ {
SDL_FillRect(optionsSurface, NULL, black); SDL_FillRect(optionsSurface, NULL, black);
blevelRect(optionsSurface, 0, 0, optionsSurface->w - 2, optionsSurface->h - 2, 0x00, 0x00, 0x44); gfx_drawRect(optionsSurface, 0, 0, optionsSurface->w - 2, optionsSurface->h - 2, 0x00, 0x00, 0x44);
gfx_renderString("++ OPTIONS ++", 105, 8, FONT_WHITE, 0, optionsSurface); gfx_renderString("++ OPTIONS ++", 105, 8, FONT_WHITE, 0, optionsSurface);
blevelRect(optionsSurface, 190, 45, 50, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 190, 45, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 250, 45, 50, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 250, 45, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 20, 45, 150, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 20, 45, 150, 22, 0x00, 0x00, 0x00);
if (engine.useSound) if (engine.useSound)
blevelRect(optionsSurface, 190, 45, 50, 22, 0xff, 0x00, 0x00); gfx_drawRect(optionsSurface, 190, 45, 50, 22, 0xff, 0x00, 0x00);
else else
blevelRect(optionsSurface, 250, 45, 50, 22, 0xff, 0x00, 0x00); gfx_drawRect(optionsSurface, 250, 45, 50, 22, 0xff, 0x00, 0x00);
gfx_renderString("ON", 207, 50, FONT_WHITE, 0, optionsSurface); gfx_renderString("ON", 207, 50, FONT_WHITE, 0, optionsSurface);
gfx_renderString("OFF", 263, 50, FONT_WHITE, 0, optionsSurface); gfx_renderString("OFF", 263, 50, FONT_WHITE, 0, optionsSurface);
gfx_renderString("SOUND", 30, 50, FONT_WHITE, 0, optionsSurface); gfx_renderString("SOUND", 30, 50, FONT_WHITE, 0, optionsSurface);
blevelRect(optionsSurface, 190, 95, 50, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 190, 95, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 250, 95, 50, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 250, 95, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 20, 95, 150, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 20, 95, 150, 22, 0x00, 0x00, 0x00);
if (engine.useMusic) if (engine.useMusic)
blevelRect(optionsSurface, 190, 95, 50, 22, 0xff, 0x00, 0x00); gfx_drawRect(optionsSurface, 190, 95, 50, 22, 0xff, 0x00, 0x00);
else else
blevelRect(optionsSurface, 250, 95, 50, 22, 0xff, 0x00, 0x00); gfx_drawRect(optionsSurface, 250, 95, 50, 22, 0xff, 0x00, 0x00);
gfx_renderString("ON", 207, 100, FONT_WHITE, 0, optionsSurface); gfx_renderString("ON", 207, 100, FONT_WHITE, 0, optionsSurface);
gfx_renderString("OFF", 263, 100, FONT_WHITE, 0, optionsSurface); gfx_renderString("OFF", 263, 100, FONT_WHITE, 0, optionsSurface);
gfx_renderString("MUSIC", 30, 100, FONT_WHITE, 0, optionsSurface); gfx_renderString("MUSIC", 30, 100, FONT_WHITE, 0, optionsSurface);
blevelRect(optionsSurface, 190, 145, 50, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 190, 145, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 250, 145, 50, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 250, 145, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 20, 145, 150, 22, 0x00, 0x00, 0x00); gfx_drawRect(optionsSurface, 20, 145, 150, 22, 0x00, 0x00, 0x00);
if (engine.fullScreen) if (engine.fullScreen)
blevelRect(optionsSurface, 190, 145, 50, 22, 0xff, 0x00, 0x00); gfx_drawRect(optionsSurface, 190, 145, 50, 22, 0xff, 0x00, 0x00);
else else
blevelRect(optionsSurface, 250, 145, 50, 22, 0xff, 0x00, 0x00); gfx_drawRect(optionsSurface, 250, 145, 50, 22, 0xff, 0x00, 0x00);
gfx_renderString("ON", 207, 150, FONT_WHITE, 0, optionsSurface); gfx_renderString("ON", 207, 150, FONT_WHITE, 0, optionsSurface);
gfx_renderString("OFF", 263, 150, FONT_WHITE, 0, optionsSurface); gfx_renderString("OFF", 263, 150, FONT_WHITE, 0, optionsSurface);
gfx_renderString("FULLSCREEN", 30, 150, FONT_WHITE, 0, optionsSurface); gfx_renderString("FULLSCREEN", 30, 150, FONT_WHITE, 0, optionsSurface);
@ -630,9 +630,9 @@ int intermission()
intermission_setSystemPlanets(); intermission_setSystemPlanets();
SDL_Surface *statsSurface = alphaRect(600, 330, 0x00, 0x00, 0x99); SDL_Surface *statsSurface = alphaRect(600, 330, 0x00, 0x00, 0x99);
SDL_Surface *savesSurface = createSurface(350, 300); SDL_Surface *savesSurface = gfx_createSurface(350, 300);
SDL_Surface *optionsSurface = createSurface(320, 240); SDL_Surface *optionsSurface = gfx_createSurface(320, 240);
SDL_Surface *commsSurface = createSurface(450, 400); SDL_Surface *commsSurface = gfx_createSurface(450, 400);
createSavesSurface(savesSurface, -1); createSavesSurface(savesSurface, -1);
intermission_createOptions(optionsSurface); intermission_createOptions(optionsSurface);
@ -672,30 +672,30 @@ int intermission()
textObject iconInfo[12]; textObject iconInfo[12];
iconInfo[0].image = textSurface("Start Next Mission", FONT_WHITE); iconInfo[0].image = gfx_createTextSurface("Start Next Mission", FONT_WHITE);
iconInfo[1].image = textSurface("View System Map", FONT_WHITE); iconInfo[1].image = gfx_createTextSurface("View System Map", FONT_WHITE);
iconInfo[2].image = textSurface("Current Status", FONT_WHITE); iconInfo[2].image = gfx_createTextSurface("Current Status", FONT_WHITE);
iconInfo[3].image = textSurface("Save Game", FONT_WHITE); iconInfo[3].image = gfx_createTextSurface("Save Game", FONT_WHITE);
iconInfo[4].image = textSurface("Upgrade FIREFLY", FONT_WHITE); iconInfo[4].image = gfx_createTextSurface("Upgrade FIREFLY", FONT_WHITE);
iconInfo[5].image = textSurface("Comms", FONT_WHITE); iconInfo[5].image = gfx_createTextSurface("Comms", FONT_WHITE);
iconInfo[6].image = textSurface("Options", FONT_WHITE); iconInfo[6].image = gfx_createTextSurface("Options", FONT_WHITE);
iconInfo[7].image = textSurface("Exit to Title Screen", FONT_WHITE); iconInfo[7].image = gfx_createTextSurface("Exit to Title Screen", FONT_WHITE);
sprintf(string, "System : %s", systemNames[game.system]); sprintf(string, "System : %s", systemNames[game.system]);
iconInfo[8].image = textSurface(string, FONT_WHITE); iconInfo[8].image = gfx_createTextSurface(string, FONT_WHITE);
sprintf(string, "Stationed At: %s", systemPlanet[game.stationedPlanet].name); sprintf(string, "Stationed At: %s", systemPlanet[game.stationedPlanet].name);
iconInfo[9].image = textSurface(string, FONT_WHITE); iconInfo[9].image = gfx_createTextSurface(string, FONT_WHITE);
if (game.destinationPlanet > -1) if (game.destinationPlanet > -1)
sprintf(string, "Destination: %s", systemPlanet[game.destinationPlanet].name); sprintf(string, "Destination: %s", systemPlanet[game.destinationPlanet].name);
else else
strcpy(string, "Destination: None"); strcpy(string, "Destination: None");
iconInfo[10].image = textSurface(string, FONT_WHITE); iconInfo[10].image = gfx_createTextSurface(string, FONT_WHITE);
for (int i = 0 ; i < 9 ; i++) for (int i = 0 ; i < 9 ; i++)
iconInfo[i].x = (800 - iconInfo[i].image->w) / 2; iconInfo[i].x = (800 - iconInfo[i].image->w) / 2;
iconInfo[11].image = textSurface("Go to Destination Planet", FONT_WHITE); iconInfo[11].image = gfx_createTextSurface("Go to Destination Planet", FONT_WHITE);
bool rescreen_drawBackground = true; bool rescreen_drawBackground = true;
@ -777,10 +777,10 @@ int intermission()
distance = 1; distance = 1;
SDL_FreeSurface(iconInfo[9].image); SDL_FreeSurface(iconInfo[9].image);
iconInfo[9].image = textSurface(systemPlanet[game.stationedPlanet].name, FONT_WHITE); iconInfo[9].image = gfx_createTextSurface(systemPlanet[game.stationedPlanet].name, FONT_WHITE);
SDL_FreeSurface(iconInfo[10].image); SDL_FreeSurface(iconInfo[10].image);
iconInfo[10].image = textSurface(systemPlanet[game.destinationPlanet].name, FONT_WHITE); iconInfo[10].image = gfx_createTextSurface(systemPlanet[game.destinationPlanet].name, FONT_WHITE);
section = 8; section = 8;
@ -812,14 +812,14 @@ int intermission()
{ {
sprintf(string, "Stationed At: %s", systemPlanet[game.stationedPlanet].name); sprintf(string, "Stationed At: %s", systemPlanet[game.stationedPlanet].name);
SDL_FreeSurface(iconInfo[9].image); SDL_FreeSurface(iconInfo[9].image);
iconInfo[9].image = textSurface(string, FONT_WHITE); iconInfo[9].image = gfx_createTextSurface(string, FONT_WHITE);
intermission_updateCommsSurface(commsSurface); intermission_updateCommsSurface(commsSurface);
} }
else else
{ {
sprintf(string, "Destination: %s", systemPlanet[game.destinationPlanet].name); sprintf(string, "Destination: %s", systemPlanet[game.destinationPlanet].name);
SDL_FreeSurface(iconInfo[10].image); SDL_FreeSurface(iconInfo[10].image);
iconInfo[10].image = textSurface(string, FONT_WHITE); iconInfo[10].image = gfx_createTextSurface(string, FONT_WHITE);
} }
} }
@ -877,7 +877,7 @@ int intermission()
strcpy(game.stationedName, strcpy(game.stationedName,
systemPlanet[game.stationedPlanet].name); systemPlanet[game.stationedPlanet].name);
SDL_FreeSurface(iconInfo[9].image); SDL_FreeSurface(iconInfo[9].image);
iconInfo[9].image = textSurface(string, FONT_WHITE); iconInfo[9].image = gfx_createTextSurface(string, FONT_WHITE);
intermission_updateCommsSurface(commsSurface); intermission_updateCommsSurface(commsSurface);
section = 1; section = 1;
rescreen_drawBackground = true; rescreen_drawBackground = true;

View File

@ -49,7 +49,7 @@ int initSaveSlots()
{ {
sprintf(saveSlot[i], (i == 0 ? "AUTOSAVE (Empty)" : "Empty")); sprintf(saveSlot[i], (i == 0 ? "AUTOSAVE (Empty)" : "Empty"));
if (engine.gameSection == SECTION_TITLE) if (engine.gameSection == SECTION_TITLE)
textSurface(TS_SAVESLOT_0 + i, saveSlot[i], -1, imagePos, gfx_createTextObject(TS_SAVESLOT_0 + i, saveSlot[i], -1, imagePos,
FONT_WHITE); FONT_WHITE);
} }
else else
@ -72,7 +72,7 @@ int initSaveSlots()
} }
if (engine.gameSection == SECTION_TITLE) if (engine.gameSection == SECTION_TITLE)
textSurface(TS_SAVESLOT_0 + i, saveSlot[i], -1, gfx_createTextObject(TS_SAVESLOT_0 + i, saveSlot[i], -1,
imagePos, FONT_WHITE); imagePos, FONT_WHITE);
if (stat(fileName, &fileInfo) != -1) if (stat(fileName, &fileInfo) != -1)
@ -170,14 +170,14 @@ void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot)
{ {
int y = 10; int y = 10;
blevelRect(savesSurface, 0, 0, 348, 298, 0x00, 0x00, 0x00); gfx_drawRect(savesSurface, 0, 0, 348, 298, 0x00, 0x00, 0x00);
for (int i = 1 ; i <= 5 ; i++) for (int i = 1 ; i <= 5 ; i++)
{ {
if (clickedSlot == i) if (clickedSlot == i)
blevelRect(savesSurface, 5, y, 338, 25, 0x99, 0x00, 0x00); gfx_drawRect(savesSurface, 5, y, 338, 25, 0x99, 0x00, 0x00);
else else
blevelRect(savesSurface, 5, y, 338, 25, 0x00, 0x00, 0x99); gfx_drawRect(savesSurface, 5, y, 338, 25, 0x00, 0x00, 0x99);
gfx_renderString(saveSlot[i], 70, y + 5, FONT_WHITE, 0, savesSurface); gfx_renderString(saveSlot[i], 70, y + 5, FONT_WHITE, 0, savesSurface);
y += 30; y += 30;
} }
@ -191,9 +191,9 @@ void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot)
case 3: case 3:
case 4: case 4:
case 5: case 5:
blevelRect(savesSurface, 5, 265, 100, 25, 0x00, 0x99, 0x00); gfx_drawRect(savesSurface, 5, 265, 100, 25, 0x00, 0x99, 0x00);
blevelRect(savesSurface, 125, 265, 100, 25, 0x99, 0x99, 0x00); gfx_drawRect(savesSurface, 125, 265, 100, 25, 0x99, 0x99, 0x00);
blevelRect(savesSurface, 243, 265, 100, 25, 0x99, 0x00, 0x00); gfx_drawRect(savesSurface, 243, 265, 100, 25, 0x99, 0x00, 0x00);
gfx_renderString("SAVE", 40, 270, FONT_WHITE, 0, savesSurface); gfx_renderString("SAVE", 40, 270, FONT_WHITE, 0, savesSurface);
gfx_renderString("CANCEL", 150, 270, FONT_WHITE, 0, savesSurface); gfx_renderString("CANCEL", 150, 270, FONT_WHITE, 0, savesSurface);
gfx_renderString("DELETE", 270, 270, FONT_WHITE, 0, savesSurface); gfx_renderString("DELETE", 270, 270, FONT_WHITE, 0, savesSurface);

View File

@ -30,7 +30,7 @@ void clearInfoLines()
// from a to b // from a to b
void copyInfoLine(int a, int b) void copyInfoLine(int a, int b)
{ {
textSurface(b, gfx_text[a].text, -1, 0, gfx_text[a].fontColor); gfx_createTextObject(b, gfx_text[a].text, -1, 0, gfx_text[a].fontColor);
gfx_text[b].life = gfx_text[a].life; gfx_text[b].life = gfx_text[a].life;
} }
@ -44,7 +44,7 @@ void setInfoLine(const char *in, int color)
{ {
int index = -1; int index = -1;
for (int i = 0 ; i < 3 ; i++) for (int i = 0 ; i < MAX_INFOLINES ; i++)
{ {
if ((gfx_text[i].life == 0) && (index == -1)) if ((gfx_text[i].life == 0) && (index == -1))
{ {
@ -55,12 +55,14 @@ void setInfoLine(const char *in, int color)
// Bump down // Bump down
if (index == -1) if (index == -1)
{ {
index = 2; index = MAX_INFOLINES - 1;
copyInfoLine(1, 0); for (int i = 1 ; i < MAX_INFOLINES ; i++)
copyInfoLine(2, 1); {
copyInfoLine(i, i - 1);
}
} }
textSurface(index, in, -1, 0, color); gfx_createTextObject(index, in, -1, 0, color);
gfx_text[index].life = 240; gfx_text[index].life = 240;
} }
@ -71,11 +73,11 @@ Phoebe or Ursula's banter to interrupt an important message
*/ */
void setRadioMessage(signed char face, const char *in, int priority) void setRadioMessage(signed char face, const char *in, int priority)
{ {
if ((gfx_text[3].life > 0) && (priority == 0)) if ((gfx_text[TS_RADIO].life > 0) && (priority == 0))
return; return;
textSurface(3, in, -1, 50, FONT_WHITE); gfx_createTextObject(TS_RADIO, in, -1, 50, FONT_WHITE);
gfx_text[3].life = 240; gfx_text[TS_RADIO].life = 240;
SDL_Surface *faceShape = NULL; SDL_Surface *faceShape = NULL;
if (face > -1) if (face > -1)

View File

@ -713,8 +713,8 @@ static void drawBriefScreen()
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, i, 0)); SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, i, 0));
} }
blevelRect(140, 70, 500, 20, 0x00, 0x77, 0x00); screen_drawRect(140, 70, 500, 20, 0x00, 0x77, 0x00);
blevelRect(140, 90, 500, 130, 0x00, 0x33, 0x00); screen_drawRect(140, 90, 500, 130, 0x00, 0x33, 0x00);
screen_renderString("Primary Objectives", 150, 74, FONT_WHITE); screen_renderString("Primary Objectives", 150, 74, FONT_WHITE);
for (int i = 0 ; i < 3 ; i++) for (int i = 0 ; i < 3 ; i++)
@ -727,8 +727,8 @@ static void drawBriefScreen()
if (currentMission.secondaryType[0] != NONE) if (currentMission.secondaryType[0] != NONE)
{ {
blevelRect(140, 230, 500, 20, 0x00, 0x77, 0x77); screen_drawRect(140, 230, 500, 20, 0x00, 0x77, 0x77);
blevelRect(140, 250, 500, 130, 0x00, 0x33, 0x33); screen_drawRect(140, 250, 500, 130, 0x00, 0x33, 0x33);
screen_renderString("Secondary Objectives", 150, 234, FONT_WHITE); screen_renderString("Secondary Objectives", 150, 234, FONT_WHITE);
for (int i = 0 ; i < 3 ; i++) for (int i = 0 ; i < 3 ; i++)
@ -741,8 +741,8 @@ static void drawBriefScreen()
} }
} }
blevelRect(140, 390, 500, 20, 0x77, 0x77, 0x00); screen_drawRect(140, 390, 500, 20, 0x77, 0x77, 0x00);
blevelRect(140, 410, 500, 130, 0x33, 0x33, 0x00); screen_drawRect(140, 410, 500, 130, 0x33, 0x33, 0x00);
screen_renderString("Additional Information", 150, 394, FONT_WHITE); screen_renderString("Additional Information", 150, 394, FONT_WHITE);
} }
@ -795,23 +795,23 @@ void missionBriefScreen()
} }
loadGameGraphics(); loadGameGraphics();
textSurface(4, "Shield", 25, 550, FONT_WHITE); gfx_createTextObject(TS_SHIELD, "Shield", 25, 550, FONT_WHITE);
textSurface(5, "Plasma:", 250, 550, FONT_WHITE); gfx_createTextObject(TS_PLASMA_T, "Plasma:", 250, 550, FONT_WHITE);
if (player.weaponType[1] == W_CHARGER) if (player.weaponType[1] == W_CHARGER)
textSurface(6, "Charge", 385, 550, FONT_WHITE); gfx_createTextObject(TS_AMMO_T, "Charge", 385, 550, FONT_WHITE);
else if (player.weaponType[1] == W_LASER) else if (player.weaponType[1] == W_LASER)
textSurface(6, "Heat", 405, 550, FONT_WHITE); gfx_createTextObject(TS_AMMO_T, "Heat", 405, 550, FONT_WHITE);
else else
textSurface(6, "Rockets:", 385, 550, FONT_WHITE); gfx_createTextObject(TS_AMMO_T, "Rockets:", 385, 550, FONT_WHITE);
textSurface(7, "Target", 550, 550, FONT_WHITE); gfx_createTextObject(TS_TARGET, "Target", 550, 550, FONT_WHITE);
textSurface(8, "Cash: $", 25, 20, FONT_WHITE); gfx_createTextObject(TS_CASH_T, "Cash: $", 25, 20, FONT_WHITE);
textSurface(9, "Objectives Remaining:", 550, 20, FONT_WHITE); gfx_createTextObject(TS_OBJECTIVES_T, "Objectives Remaining:", 550, 20, FONT_WHITE);
textSurface(10, "Time Remaining - ", 260, 20, FONT_WHITE); gfx_createTextObject(TS_TIME_T, "Time Remaining - ", 260, 20, FONT_WHITE);
textSurface(11, "Power", 25, 570, FONT_WHITE); gfx_createTextObject(TS_POWER, "Power", 25, 570, FONT_WHITE);
textSurface(12, "Output", 250, 570, FONT_WHITE); gfx_createTextObject(TS_OUTPUT, "Output", 250, 570, FONT_WHITE);
textSurface(13, "Cooler", 485, 570, FONT_WHITE); gfx_createTextObject(TS_COOLER, "Cooler", 485, 570, FONT_WHITE);
audio_playRandomTrack(); audio_playRandomTrack();
if (game.area != MISN_INTERCEPTION) if (game.area != MISN_INTERCEPTION)

View File

@ -79,7 +79,7 @@ void loadGameGraphics()
{ {
if (shipShape[i - SHIP_HIT_INDEX] == NULL) if (shipShape[i - SHIP_HIT_INDEX] == NULL)
continue; continue;
shipShape[i] = createSurface(shipShape[i - SHIP_HIT_INDEX]->w, shipShape[i] = gfx_createSurface(shipShape[i - SHIP_HIT_INDEX]->w,
shipShape[i - SHIP_HIT_INDEX]->h); shipShape[i - SHIP_HIT_INDEX]->h);
SDL_SetSurfaceBlendMode(shipShape[i - SHIP_HIT_INDEX], SDL_BLENDMODE_NONE); SDL_SetSurfaceBlendMode(shipShape[i - SHIP_HIT_INDEX], SDL_BLENDMODE_NONE);
gfx_blit(shipShape[i - SHIP_HIT_INDEX], 0, 0, shipShape[i]); gfx_blit(shipShape[i - SHIP_HIT_INDEX], 0, 0, shipShape[i]);

View File

@ -117,3 +117,8 @@ void screen_clear(Uint32 color)
{ {
SDL_FillRect(screen, NULL, color); SDL_FillRect(screen, NULL, color);
} }
void screen_drawRect(int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue)
{
gfx_drawRect(screen, x, y, w, h, red, green, blue);
}

View File

@ -34,5 +34,6 @@ void screen_addBuffer(int x, int y, int w, int h);
void screen_flushBuffer(); void screen_flushBuffer();
void screen_unBuffer(); void screen_unBuffer();
void screen_clear(Uint32 color); void screen_clear(Uint32 color);
void screen_drawRect(int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue);
#endif #endif

View File

@ -153,16 +153,16 @@ static void drawShop()
} }
for (int i = 0 ; i < 3 ; i++) for (int i = 0 ; i < 3 ; i++)
shopSurface[i] = createSurface(246, 91); shopSurface[i] = gfx_createSurface(246, 91);
for (int i = 0 ; i < 3 ; i++) for (int i = 0 ; i < 3 ; i++)
{ {
blevelRect(shopSurface[i], 0, 0, 245, 90, 0x00, 0x00, 0x55); gfx_drawRect(shopSurface[i], 0, 0, 245, 90, 0x00, 0x00, 0x55);
blevelRect(shopSurface[i], 0, 0, 245, 20, 0x00, 0x00, 0x99); gfx_drawRect(shopSurface[i], 0, 0, 245, 20, 0x00, 0x00, 0x99);
} }
shopSurface[4] = alphaRect(601, 101, 0x00, 0x00, 0x00); shopSurface[4] = alphaRect(601, 101, 0x00, 0x00, 0x00);
blevelRect(shopSurface[4], 0, 0, 600, 100, 0x00, 0x00, 0x33); gfx_drawRect(shopSurface[4], 0, 0, 600, 100, 0x00, 0x00, 0x33);
switch (shopSelectedItem) switch (shopSelectedItem)
{ {
@ -177,22 +177,22 @@ static void drawShop()
case 1: case 1:
case 2: case 2:
case 8: case 8:
blevelRect(shopSurface[1], 0, 0, 245, 90, 0x55, 0x00, 0x00); gfx_drawRect(shopSurface[1], 0, 0, 245, 90, 0x55, 0x00, 0x00);
blevelRect(shopSurface[1], 0, 0, 245, 20, 0x99, 0x00, 0x00); gfx_drawRect(shopSurface[1], 0, 0, 245, 20, 0x99, 0x00, 0x00);
break; break;
case 3: case 3:
case 4: case 4:
blevelRect(shopSurface[4], 0, 0, 600, 100, 0x33, 0x00, 0x00); gfx_drawRect(shopSurface[4], 0, 0, 600, 100, 0x33, 0x00, 0x00);
break; break;
case 5: case 5:
case 6: case 6:
case 7: case 7:
blevelRect(shopSurface[0], 0, 0, 245, 90, 0x55, 0x00, 0x00); gfx_drawRect(shopSurface[0], 0, 0, 245, 90, 0x55, 0x00, 0x00);
blevelRect(shopSurface[0], 0, 0, 245, 20, 0x99, 0x00, 0x00); gfx_drawRect(shopSurface[0], 0, 0, 245, 20, 0x99, 0x00, 0x00);
break; break;
default: default:
blevelRect(shopSurface[2], 0, 0, 245, 90, 0x55, 0x00, 0x00); gfx_drawRect(shopSurface[2], 0, 0, 245, 90, 0x55, 0x00, 0x00);
blevelRect(shopSurface[2], 0, 0, 245, 20, 0x99, 0x00, 0x00); gfx_drawRect(shopSurface[2], 0, 0, 245, 20, 0x99, 0x00, 0x00);
break; break;
} }
@ -224,9 +224,9 @@ static void drawShop()
drawSecondaryWeaponSurface(); drawSecondaryWeaponSurface();
shopSurface[3] = createSurface(601, 121); shopSurface[3] = gfx_createSurface(601, 121);
blevelRect(shopSurface[3], 0, 0, 600, 120, 0x00, 0x00, 0x22); gfx_drawRect(shopSurface[3], 0, 0, 600, 120, 0x00, 0x00, 0x22);
gfx_renderString("Temporary Weapons", 10, 2, FONT_WHITE, 0, shopSurface[3]); gfx_renderString("Temporary Weapons", 10, 2, FONT_WHITE, 0, shopSurface[3]);
gfx_renderString("Ammo and Storage", 260, 2, FONT_WHITE, 0, shopSurface[3]); gfx_renderString("Ammo and Storage", 260, 2, FONT_WHITE, 0, shopSurface[3]);
@ -259,9 +259,9 @@ static void drawShop()
sprintf(description, "Rockets : %.3d", player.ammo[1]); sprintf(description, "Rockets : %.3d", player.ammo[1]);
gfx_renderString(description, 475, 80, FONT_WHITE, 0, shopSurface[4]); gfx_renderString(description, 475, 80, FONT_WHITE, 0, shopSurface[4]);
shopSurface[5] = createSurface(601, 56); shopSurface[5] = gfx_createSurface(601, 56);
blevelRect(shopSurface[5], 0, 0, 600, 35, 0x00, 0x99, 0x00); gfx_drawRect(shopSurface[5], 0, 0, 600, 35, 0x00, 0x99, 0x00);
blevelRect(shopSurface[5], 0, 20, 600, 35, 0x00, 0x33, 0x00); gfx_drawRect(shopSurface[5], 0, 20, 600, 35, 0x00, 0x33, 0x00);
gfx_renderString("Information", 5, 4, FONT_WHITE, 0, shopSurface[5]); gfx_renderString("Information", 5, 4, FONT_WHITE, 0, shopSurface[5]);
switch (shopSelectedItem) switch (shopSelectedItem)

View File

@ -65,18 +65,18 @@ static signed char showLoadMenu()
static void createDifficultyMenu() static void createDifficultyMenu()
{ {
textSurface(TS_START_GAME, "START GAME", -1, 350, FONT_WHITE); gfx_createTextObject(TS_START_GAME, "START GAME", -1, 350, FONT_WHITE);
if (game.difficulty == DIFFICULTY_EASY) if (game.difficulty == DIFFICULTY_EASY)
textSurface(TS_DIFFICULTY, "DIFFICULTY - EASY", -1, 370, FONT_WHITE); gfx_createTextObject(TS_DIFFICULTY, "DIFFICULTY - EASY", -1, 370, FONT_WHITE);
else if (game.difficulty == DIFFICULTY_HARD) else if (game.difficulty == DIFFICULTY_HARD)
textSurface(TS_DIFFICULTY, "DIFFICULTY - HARD", -1, 370, FONT_WHITE); gfx_createTextObject(TS_DIFFICULTY, "DIFFICULTY - HARD", -1, 370, FONT_WHITE);
else if (game.difficulty == DIFFICULTY_NIGHTMARE) else if (game.difficulty == DIFFICULTY_NIGHTMARE)
textSurface(TS_DIFFICULTY, "DIFFICULTY - NIGHTMARE!", -1, 370, FONT_WHITE); gfx_createTextObject(TS_DIFFICULTY, "DIFFICULTY - NIGHTMARE!", -1, 370, FONT_WHITE);
else if (game.difficulty == DIFFICULTY_ORIGINAL) else if (game.difficulty == DIFFICULTY_ORIGINAL)
textSurface(TS_DIFFICULTY, "DIFFICULTY - ORIGINAL", -1, 370, FONT_WHITE); gfx_createTextObject(TS_DIFFICULTY, "DIFFICULTY - ORIGINAL", -1, 370, FONT_WHITE);
else else
textSurface(TS_DIFFICULTY, "DIFFICULTY - NORMAL", -1, 370, FONT_WHITE); gfx_createTextObject(TS_DIFFICULTY, "DIFFICULTY - NORMAL", -1, 370, FONT_WHITE);
} }
static signed char showDifficultyMenu() static signed char showDifficultyMenu()
@ -93,24 +93,24 @@ static signed char showDifficultyMenu()
static void createOptionsMenu() static void createOptionsMenu()
{ {
if (engine.useSound) if (engine.useSound)
textSurface(TS_SOUND, "SOUND - ON", -1, 350, FONT_WHITE); gfx_createTextObject(TS_SOUND, "SOUND - ON", -1, 350, FONT_WHITE);
else else
textSurface(TS_SOUND, "SOUND - OFF", -1, 350, FONT_WHITE); gfx_createTextObject(TS_SOUND, "SOUND - OFF", -1, 350, FONT_WHITE);
if (engine.useMusic) if (engine.useMusic)
textSurface(TS_MUSIC, "MUSIC - ON", -1, 370, FONT_WHITE); gfx_createTextObject(TS_MUSIC, "MUSIC - ON", -1, 370, FONT_WHITE);
else else
textSurface(TS_MUSIC, "MUSIC - OFF", -1, 370, FONT_WHITE); gfx_createTextObject(TS_MUSIC, "MUSIC - OFF", -1, 370, FONT_WHITE);
if (engine.fullScreen) if (engine.fullScreen)
textSurface(TS_FULLSCREEN, "FULLSCREEN - ON", -1, 390, FONT_WHITE); gfx_createTextObject(TS_FULLSCREEN, "FULLSCREEN - ON", -1, 390, FONT_WHITE);
else else
textSurface(TS_FULLSCREEN, "FULLSCREEN - OFF", -1, 390, FONT_WHITE); gfx_createTextObject(TS_FULLSCREEN, "FULLSCREEN - OFF", -1, 390, FONT_WHITE);
if (engine.autoPause) if (engine.autoPause)
textSurface(TS_AUTOPAUSE, "AUTOPAUSE - ON", -1, 410, FONT_WHITE); gfx_createTextObject(TS_AUTOPAUSE, "AUTOPAUSE - ON", -1, 410, FONT_WHITE);
else else
textSurface(TS_AUTOPAUSE, "AUTOPAUSE - OFF", -1, 410, FONT_WHITE); gfx_createTextObject(TS_AUTOPAUSE, "AUTOPAUSE - OFF", -1, 410, FONT_WHITE);
} }
static signed char showOptionsMenu() static signed char showOptionsMenu()
@ -129,31 +129,31 @@ static signed char showOptionsMenu()
static void createCheatMenu() static void createCheatMenu()
{ {
if (engine.cheatShield) if (engine.cheatShield)
textSurface(TS_UNLIMITED_SHIELD, "UNLIMITED SHIELD - ON", -1, 350, gfx_createTextObject(TS_UNLIMITED_SHIELD, "UNLIMITED SHIELD - ON", -1, 350,
FONT_WHITE); FONT_WHITE);
else else
textSurface(TS_UNLIMITED_SHIELD, "UNLIMITED SHIELD - OFF", -1, 350, gfx_createTextObject(TS_UNLIMITED_SHIELD, "UNLIMITED SHIELD - OFF", -1, 350,
FONT_WHITE); FONT_WHITE);
if (engine.cheatAmmo) if (engine.cheatAmmo)
textSurface(TS_UNLIMITED_AMMO, "UNLIMITED AMMO - ON", -1, 370, gfx_createTextObject(TS_UNLIMITED_AMMO, "UNLIMITED AMMO - ON", -1, 370,
FONT_WHITE); FONT_WHITE);
else else
textSurface(TS_UNLIMITED_AMMO, "UNLIMITED AMMO - OFF", -1, 370, gfx_createTextObject(TS_UNLIMITED_AMMO, "UNLIMITED AMMO - OFF", -1, 370,
FONT_WHITE); FONT_WHITE);
if (engine.cheatCash) if (engine.cheatCash)
textSurface(TS_UNLIMITED_CASH, "UNLIMITED CASH - ON", -1, 390, gfx_createTextObject(TS_UNLIMITED_CASH, "UNLIMITED CASH - ON", -1, 390,
FONT_WHITE); FONT_WHITE);
else else
textSurface(TS_UNLIMITED_CASH, "UNLIMITED CASH - OFF", -1, 390, gfx_createTextObject(TS_UNLIMITED_CASH, "UNLIMITED CASH - OFF", -1, 390,
FONT_WHITE); FONT_WHITE);
if (engine.cheatTime) if (engine.cheatTime)
textSurface(TS_UNLIMITED_TIME, "UNLIMITED TIME - ON", -1, 410, gfx_createTextObject(TS_UNLIMITED_TIME, "UNLIMITED TIME - ON", -1, 410,
FONT_WHITE); FONT_WHITE);
else else
textSurface(TS_UNLIMITED_TIME, "UNLIMITED TIME - OFF", -1, 410, gfx_createTextObject(TS_UNLIMITED_TIME, "UNLIMITED TIME - OFF", -1, 410,
FONT_WHITE); FONT_WHITE);
} }
@ -208,19 +208,19 @@ int doTitle()
int sfx = ((screen->w - sflogo->w) / 2); int sfx = ((screen->w - sflogo->w) / 2);
int sfy = ((screen->h - sflogo->h) / 2); int sfy = ((screen->h - sflogo->h) / 2);
textSurface(TS_PRESENTS, "PRESENTS", -1, 300, FONT_WHITE); gfx_createTextObject(TS_PRESENTS, "PRESENTS", -1, 300, FONT_WHITE);
textSurface(TS_AN_SDL_GAME, "AN SDL GAME", -1, 300, FONT_WHITE); gfx_createTextObject(TS_AN_SDL_GAME, "AN SDL GAME", -1, 300, FONT_WHITE);
textSurface(TS_START_NEW_GAME, "START NEW GAME", -1, 350, FONT_WHITE); gfx_createTextObject(TS_START_NEW_GAME, "START NEW GAME", -1, 350, FONT_WHITE);
textSurface(TS_LOAD_GAME, "LOAD GAME", -1, 370, FONT_WHITE); gfx_createTextObject(TS_LOAD_GAME, "LOAD GAME", -1, 370, FONT_WHITE);
textSurface(TS_CONTINUE_CURRENT_GAME, "CONTINUE CURRENT GAME", -1, 390, gfx_createTextObject(TS_CONTINUE_CURRENT_GAME, "CONTINUE CURRENT GAME", -1, 390,
FONT_WHITE); FONT_WHITE);
textSurface(TS_OPTIONS, "OPTIONS", -1, 410, FONT_WHITE); gfx_createTextObject(TS_OPTIONS, "OPTIONS", -1, 410, FONT_WHITE);
textSurface(TS_CHEAT_OPTIONS, "CHEAT OPTIONS", -1, 430, FONT_WHITE); gfx_createTextObject(TS_CHEAT_OPTIONS, "CHEAT OPTIONS", -1, 430, FONT_WHITE);
textSurface(TS_QUIT, "QUIT", -1, 430, FONT_WHITE); gfx_createTextObject(TS_QUIT, "QUIT", -1, 430, FONT_WHITE);
createOptionsMenu(); createOptionsMenu();
createDifficultyMenu(); createDifficultyMenu();
textSurface(TS_BACK_TO_MAIN_MENU, "BACK TO MAIN MENU", -1, 0, FONT_WHITE); gfx_createTextObject(TS_BACK_TO_MAIN_MENU, "BACK TO MAIN MENU", -1, 0, FONT_WHITE);
createCheatMenu(); createCheatMenu();
@ -317,7 +317,7 @@ int doTitle()
{ {
screen_addBuffer(0, 0, screen->w, screen->h); screen_addBuffer(0, 0, screen->w, screen->h);
blevelRect(optionRec.x, optionRec.y, optionRec.w, optionRec.h, redGlow, 0x00, 0x00); screen_drawRect(optionRec.x, optionRec.y, optionRec.w, optionRec.h, redGlow, 0x00, 0x00);
switch(menuType) switch(menuType)
{ {
@ -577,16 +577,16 @@ void showStory()
fp = fopen("data/intro.txt", "rb"); fp = fopen("data/intro.txt", "rb");
int i = 0; int index = 0;
int nextPos = -1; int nextPos = -1;
char string[255]; char string[255];
while (fscanf(fp, "%d %[^\n]%*c", &nextPos, string) == 2) while (fscanf(fp, "%d %[^\n]%*c", &nextPos, string) == 2)
{ {
y += nextPos; y += nextPos;
textSurface(i, string, -1, y, FONT_WHITE); gfx_createTextObject(index, string, -1, y, FONT_WHITE);
i++; index++;
} }
fclose(fp); fclose(fp);
@ -608,6 +608,8 @@ void showStory()
if ((engine.keyState[KEY_FIRE] || engine.keyState[KEY_ALTFIRE])) if ((engine.keyState[KEY_FIRE] || engine.keyState[KEY_ALTFIRE]))
break; break;
// XXX: The fact that it's line 8 that's watched is completely
// arbitrary. It might be prudent to replace this with something else.
if (gfx_text[8].y > (screen->h / 2) + 150) if (gfx_text[8].y > (screen->h / 2) + 150)
{ {
for (int i = 0 ; i < 9 ; i++) for (int i = 0 ; i < 9 ; i++)
@ -710,7 +712,7 @@ void doCredits()
while (fscanf(fp, "%d %[^\n]%*c", &yPos, text) == 2) while (fscanf(fp, "%d %[^\n]%*c", &yPos, text) == 2)
{ {
lastCredit++; lastCredit++;
credit[lastCredit].image = textSurface(text, FONT_WHITE); credit[lastCredit].image = gfx_createTextSurface(text, FONT_WHITE);
credit[lastCredit].x = (screen->w - credit[lastCredit].image->w) / 2; credit[lastCredit].x = (screen->w - credit[lastCredit].image->w) / 2;
yPos2 += yPos; yPos2 += yPos;
credit[lastCredit].y = yPos2; credit[lastCredit].y = yPos2;