Removed the second "drawString" function.

It wasn't very useful. All it did was offer the option to center
text and take away the option to wrap text. I've moved the text
centering option to gfx_renderString and replaced all uses of this
function with that function.
This commit is contained in:
onpon4 2015-11-06 10:12:57 -05:00
parent 7c67112a8b
commit 67d464433d
6 changed files with 92 additions and 88 deletions

View File

@ -174,6 +174,9 @@ static int gfx_renderStringBase(const char *in, int x, int y, int fontColor, sig
int gfx_renderString(const char *in, int x, int y, int fontColor, int wrap, SDL_Surface *dest)
{
if (x == -1)
x = (dest->w - (strlen(in) * 9)) / 2;
gfx_renderStringBase(in, x, y - 1, FONT_OUTLINE, wrap, dest);
gfx_renderStringBase(in, x, y + 1, FONT_OUTLINE, wrap, dest);
gfx_renderStringBase(in, x, y + 2, FONT_OUTLINE, wrap, dest);
@ -183,17 +186,8 @@ int gfx_renderString(const char *in, int x, int y, int fontColor, int wrap, SDL_
return gfx_renderStringBase(in, x, y, fontColor, wrap, dest);
}
int drawString(const char *in, int x, int y, int fontColor, SDL_Surface *dest)
{
if (x == -1)
x = (dest->w - (strlen(in) * 9)) / 2;
return gfx_renderString(in, x, y, fontColor, 0, dest);
}
int drawString(const char *in, int x, int y, int fontColor)
{
if (x == -1)
x = (screen->w - (strlen(in) * 9)) / 2;
return gfx_renderString(in, x, y, fontColor, 0, screen);
}
@ -411,7 +405,7 @@ SDL_Surface *textSurface(const char *inString, int color)
{
SDL_Surface *surface = createSurface(strlen(inString) * 9, 16);
drawString(inString, 1, 1, color, surface);
gfx_renderString(inString, 1, 1, color, 0, surface);
return gfx_setTransparent(surface);
}

View File

@ -35,7 +35,6 @@ void gfx_init();
SDL_Surface *gfx_setTransparent(SDL_Surface *sprite);
void gfx_blit(SDL_Surface *image, int x, int y, SDL_Surface *dest);
int gfx_renderString(const char *in, int x, int y, int fontColor, int wrap, SDL_Surface *dest);
extern int drawString(const char *in, int x, int y, int fontColor, SDL_Surface *dest);
extern int drawString(const char *in, int x, int y, int fontColor);
extern void drawBackGround();
extern void clearScreen(Uint32 color);

View File

@ -354,9 +354,9 @@ static void intermission_updateCommsSurface(SDL_Surface *comms)
blevelRect(comms, 0, 10, comms->w - 1, 55, 0x00, 0x22, 0x00);
gfx_blit(shape[FACE_CHRIS], 20, 15, comms);
drawString("Chris Bainfield", 80, 15, FONT_WHITE, comms);
gfx_renderString("Chris Bainfield", 80, 15, FONT_WHITE, 0, comms);
sprintf(string, "Current Location: %s", systemPlanet[game.stationedPlanet].name);
drawString(string, 80, 35, FONT_WHITE, comms);
gfx_renderString(string, 80, 35, FONT_WHITE, 0, comms);
}
static void intermission_createCommsSurface(SDL_Surface *comms)
@ -365,7 +365,7 @@ static void intermission_createCommsSurface(SDL_Surface *comms)
blevelRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
drawString("+++ RECEIVED MESSAGES +++", 115, 80, FONT_GREEN, comms);
gfx_renderString("+++ RECEIVED MESSAGES +++", 115, 80, FONT_GREEN, 0, comms);
int yOffset;
@ -376,9 +376,9 @@ static void intermission_createCommsSurface(SDL_Surface *comms)
yOffset = systemPlanet[i].messageSlot * 60;
blevelRect(comms, 0, 105 + yOffset, comms->w - 1, 55, 0x00, 0x00, 0x77);
gfx_blit(shape[systemPlanet[i].faceImage], 20, 110 + yOffset, comms);
drawString(systemPlanet[i].from, 80, 110 + yOffset, FONT_WHITE, comms);
drawString(systemPlanet[i].subject, 80, 130 + yOffset, FONT_CYAN, comms);
drawString("INCOMPLETE", 350, 110 + yOffset, FONT_RED, 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("INCOMPLETE", 350, 110 + yOffset, FONT_RED, 0, comms);
}
}
@ -419,7 +419,7 @@ static void intermission_createMissionDetailSurface(SDL_Surface *comms, int miss
strcpy(name, "Error");
}
sprintf(string, "+++ Communication with %s +++", name);
drawString(string, -1, 20, FONT_GREEN, comms);
gfx_renderString(string, -1, 20, FONT_GREEN, 0, comms);
while (fscanf(fp, "%[^\n]%*c", string) == 1)
{
@ -478,7 +478,7 @@ static void intermission_createOptions(SDL_Surface *optionsSurface)
blevelRect(optionsSurface, 0, 0, optionsSurface->w - 2, optionsSurface->h - 2, 0x00, 0x00, 0x44);
drawString("++ OPTIONS ++", 105, 8, FONT_WHITE, optionsSurface);
gfx_renderString("++ OPTIONS ++", 105, 8, FONT_WHITE, 0, optionsSurface);
blevelRect(optionsSurface, 190, 45, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 250, 45, 50, 22, 0x00, 0x00, 0x00);
@ -487,9 +487,9 @@ static void intermission_createOptions(SDL_Surface *optionsSurface)
blevelRect(optionsSurface, 190, 45, 50, 22, 0xff, 0x00, 0x00);
else
blevelRect(optionsSurface, 250, 45, 50, 22, 0xff, 0x00, 0x00);
drawString("ON", 207, 50, FONT_WHITE, optionsSurface);
drawString("OFF", 263, 50, FONT_WHITE, optionsSurface);
drawString("SOUND", 30, 50, FONT_WHITE, optionsSurface);
gfx_renderString("ON", 207, 50, FONT_WHITE, 0, optionsSurface);
gfx_renderString("OFF", 263, 50, FONT_WHITE, 0, optionsSurface);
gfx_renderString("SOUND", 30, 50, FONT_WHITE, 0, optionsSurface);
blevelRect(optionsSurface, 190, 95, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 250, 95, 50, 22, 0x00, 0x00, 0x00);
@ -498,9 +498,9 @@ static void intermission_createOptions(SDL_Surface *optionsSurface)
blevelRect(optionsSurface, 190, 95, 50, 22, 0xff, 0x00, 0x00);
else
blevelRect(optionsSurface, 250, 95, 50, 22, 0xff, 0x00, 0x00);
drawString("ON", 207, 100, FONT_WHITE, optionsSurface);
drawString("OFF", 263, 100, FONT_WHITE, optionsSurface);
drawString("MUSIC", 30, 100, FONT_WHITE, optionsSurface);
gfx_renderString("ON", 207, 100, FONT_WHITE, 0, optionsSurface);
gfx_renderString("OFF", 263, 100, FONT_WHITE, 0, optionsSurface);
gfx_renderString("MUSIC", 30, 100, FONT_WHITE, 0, optionsSurface);
blevelRect(optionsSurface, 190, 145, 50, 22, 0x00, 0x00, 0x00);
blevelRect(optionsSurface, 250, 145, 50, 22, 0x00, 0x00, 0x00);
@ -509,9 +509,9 @@ static void intermission_createOptions(SDL_Surface *optionsSurface)
blevelRect(optionsSurface, 190, 145, 50, 22, 0xff, 0x00, 0x00);
else
blevelRect(optionsSurface, 250, 145, 50, 22, 0xff, 0x00, 0x00);
drawString("ON", 207, 150, FONT_WHITE, optionsSurface);
drawString("OFF", 263, 150, FONT_WHITE, optionsSurface);
drawString("FULLSCREEN", 30, 150, FONT_WHITE, optionsSurface);
gfx_renderString("ON", 207, 150, FONT_WHITE, 0, optionsSurface);
gfx_renderString("OFF", 263, 150, FONT_WHITE, 0, optionsSurface);
gfx_renderString("FULLSCREEN", 30, 150, FONT_WHITE, 0, optionsSurface);
}
static void intermission_doOptions(SDL_Surface *optionsSurface)

View File

@ -178,11 +178,11 @@ void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot)
blevelRect(savesSurface, 5, y, 338, 25, 0x99, 0x00, 0x00);
else
blevelRect(savesSurface, 5, y, 338, 25, 0x00, 0x00, 0x99);
drawString(saveSlot[i], 70, y + 5, FONT_WHITE, savesSurface);
gfx_renderString(saveSlot[i], 70, y + 5, FONT_WHITE, 0, savesSurface);
y += 30;
}
drawString("*** HELP ***", 120, 170, FONT_WHITE, savesSurface);
gfx_renderString("*** HELP ***", 120, 170, FONT_WHITE, 0, savesSurface);
switch (clickedSlot)
{
@ -194,25 +194,28 @@ void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot)
blevelRect(savesSurface, 5, 265, 100, 25, 0x00, 0x99, 0x00);
blevelRect(savesSurface, 125, 265, 100, 25, 0x99, 0x99, 0x00);
blevelRect(savesSurface, 243, 265, 100, 25, 0x99, 0x00, 0x00);
drawString("SAVE", 40, 270, FONT_WHITE, savesSurface);
drawString("CANCEL", 150, 270, FONT_WHITE, savesSurface);
drawString("DELETE", 270, 270, FONT_WHITE, savesSurface);
gfx_renderString("SAVE", 40, 270, FONT_WHITE, 0, savesSurface);
gfx_renderString("CANCEL", 150, 270, FONT_WHITE, 0, savesSurface);
gfx_renderString("DELETE", 270, 270, FONT_WHITE, 0, savesSurface);
drawString("SAVE will save the game", 17, 200, FONT_WHITE, savesSurface);
drawString("CANCEL will unselect that slot", 17, 220, FONT_WHITE,
savesSurface);
drawString("DELETE will remove the save", 17, 240, FONT_WHITE,
gfx_renderString("SAVE will save the game", 17, 200, FONT_WHITE, 0,
savesSurface);
gfx_renderString("CANCEL will unselect that slot", 17, 220,
FONT_WHITE, 0, savesSurface);
gfx_renderString("DELETE will remove the save", 17, 240,
FONT_WHITE, 0, savesSurface);
break;
case -1:
drawString("First click a Save game slot to use", 17, 200,
FONT_WHITE, savesSurface);
gfx_renderString("First click a Save game slot to use", 17, 200,
FONT_WHITE, 0, savesSurface);
break;
case -10:
drawString("Game Saved", 130, 200, FONT_WHITE, savesSurface);
gfx_renderString("Game Saved", 130, 200, FONT_WHITE, 0,
savesSurface);
break;
case -11:
drawString("Save Deleted", 130, 200, FONT_WHITE, savesSurface);
gfx_renderString("Save Deleted", 130, 200, FONT_WHITE, 0,
savesSurface);
break;
}

View File

@ -28,7 +28,7 @@ static void drawSecondaryWeaponSurface()
{
char description[50] = "";
drawString("Secondary Weapon", 10, 3, FONT_WHITE, shopSurface[2]);
gfx_renderString("Secondary Weapon", 10, 3, FONT_WHITE, 0, shopSurface[2]);
switch (player.weaponType[1])
{
@ -60,13 +60,13 @@ static void drawSecondaryWeaponSurface()
strcpy(description, "Type : Mcr Homing Missiles");
break;
}
drawString(description, 10, 22, FONT_WHITE, shopSurface[2]);
gfx_renderString(description, 10, 22, FONT_WHITE, 0, shopSurface[2]);
if ((player.weaponType[1] != W_LASER) &&
(player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_NONE))
{
sprintf(description, "Capacity : %d", game.maxRocketAmmo);
drawString(description, 10, 37, FONT_WHITE, shopSurface[2]);
gfx_renderString(description, 10, 37, FONT_WHITE, 0, shopSurface[2]);
}
}
@ -199,28 +199,28 @@ static void drawShop()
char description[100];
strcpy(description, "");
drawString("Primary Weapon", 10, 3, FONT_WHITE, shopSurface[0]);
gfx_renderString("Primary Weapon", 10, 3, FONT_WHITE, 0, shopSurface[0]);
sprintf(description, "Plasma Cannons : %d", game.minPlasmaOutput);
drawString(description, 10, 22, FONT_WHITE, shopSurface[0]);
gfx_renderString(description, 10, 22, FONT_WHITE, 0, shopSurface[0]);
sprintf(description, "Plasma Power : Stage %d",
game.minPlasmaDamage);
drawString(description, 10, 37, FONT_WHITE, shopSurface[0]);
gfx_renderString(description, 10, 37, FONT_WHITE, 0, shopSurface[0]);
sprintf(description, "Cooler : Stage %d",
game.minPlasmaRate);
drawString(description, 10, 52, FONT_WHITE, shopSurface[0]);
gfx_renderString(description, 10, 52, FONT_WHITE, 0, shopSurface[0]);
drawString("Powerup Weapon", 10, 3, FONT_WHITE, shopSurface[1]);
gfx_renderString("Powerup Weapon", 10, 3, FONT_WHITE, 0, shopSurface[1]);
sprintf(description, "Plasma Output : Stage %d",
game.maxPlasmaOutput);
drawString(description, 10, 22, FONT_WHITE, shopSurface[1]);
gfx_renderString(description, 10, 22, FONT_WHITE, 0, shopSurface[1]);
sprintf(description, "Plasma Condensor : Stage %d",
game.maxPlasmaDamage);
drawString(description, 10, 37, FONT_WHITE, shopSurface[1]);
gfx_renderString(description, 10, 37, FONT_WHITE, 0, shopSurface[1]);
sprintf(description, "Liquid Nitrogen : Stage %d",
game.maxPlasmaRate);
drawString(description, 10, 52, FONT_WHITE, shopSurface[1]);
gfx_renderString(description, 10, 52, FONT_WHITE, 0, shopSurface[1]);
sprintf(description, "Plasma Capacity : %d", game.maxPlasmaAmmo);
drawString(description, 10, 67, FONT_WHITE, shopSurface[1]);
gfx_renderString(description, 10, 67, FONT_WHITE, 0, shopSurface[1]);
drawSecondaryWeaponSurface();
@ -228,12 +228,12 @@ static void drawShop()
blevelRect(shopSurface[3], 0, 0, 600, 120, 0x00, 0x00, 0x22);
drawString("Temporary Weapons", 10, 2, FONT_WHITE, shopSurface[3]);
drawString("Ammo and Storage", 260, 2, FONT_WHITE, 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]);
drawString("Primary Weapons", 10, 62, FONT_WHITE, shopSurface[3]);
gfx_renderString("Primary Weapons", 10, 62, FONT_WHITE, 0, shopSurface[3]);
drawString("Secondary Weapons", 260, 62, FONT_WHITE, shopSurface[3]);
gfx_renderString("Secondary Weapons", 260, 62, FONT_WHITE, 0, shopSurface[3]);
signed char icons = MAX_SHOPITEMS;
@ -251,54 +251,56 @@ static void drawShop()
}
sprintf(description, "Shield Units : %d", player.maxShield);
drawString(description, 10, 4, FONT_WHITE, shopSurface[4]);
gfx_renderString(description, 10, 4, FONT_WHITE, 0, shopSurface[4]);
sprintf(description, "Cash : $%d", game.cash);
drawString(description, 10, 80, FONT_WHITE, shopSurface[4]);
gfx_renderString(description, 10, 80, FONT_WHITE, 0, shopSurface[4]);
sprintf(description, "Plasma Cells : %.3d", player.ammo[0]);
drawString(description, 430, 4, FONT_WHITE, shopSurface[4]);
gfx_renderString(description, 430, 4, FONT_WHITE, 0, shopSurface[4]);
sprintf(description, "Rockets : %.3d", player.ammo[1]);
drawString(description, 475, 80, FONT_WHITE, shopSurface[4]);
gfx_renderString(description, 475, 80, FONT_WHITE, 0, shopSurface[4]);
shopSurface[5] = createSurface(601, 56);
blevelRect(shopSurface[5], 0, 0, 600, 35, 0x00, 0x99, 0x00);
blevelRect(shopSurface[5], 0, 20, 600, 35, 0x00, 0x33, 0x00);
drawString("Information", 5, 4, FONT_WHITE, shopSurface[5]);
gfx_renderString("Information", 5, 4, FONT_WHITE, 0, shopSurface[5]);
switch (shopSelectedItem)
{
case -1:
break;
case -2:
drawString("You don't have enough money", 20, 30, FONT_WHITE,
shopSurface[5]);
gfx_renderString("You don't have enough money", 20, 30, FONT_WHITE,
0, shopSurface[5]);
break;
case -3:
drawString("Cannot upgrade ship", 5, 22, FONT_WHITE, shopSurface[5]);
drawString("Hardware capacity has been reached", 20, 38, FONT_CYAN,
gfx_renderString("Cannot upgrade ship", 5, 22, FONT_WHITE, 0,
shopSurface[5]);
gfx_renderString("Hardware capacity has been reached", 20, 38,
FONT_CYAN, 0, shopSurface[5]);
break;
case -4:
drawString("Ammunition limit reached", 20, 30, FONT_WHITE,
gfx_renderString("Ammunition limit reached", 20, 30, FONT_WHITE, 0,
shopSurface[5]);
break;
case -5:
drawString("You cannot sell that item", 20, 30, FONT_WHITE,
shopSurface[5]);
gfx_renderString("You cannot sell that item", 20, 30, FONT_WHITE,
0, shopSurface[5]);
break;
case -6:
drawString("Nothing to sell", 20, 30, FONT_WHITE, shopSurface[5]);
break;
case -7:
drawString("Rockets cannot be bought for Laser or Charger Cannon",
5, 30, FONT_WHITE, shopSurface[5]);
break;
case -8:
drawString("You already have that weapon", 20, 30, FONT_WHITE,
gfx_renderString("Nothing to sell", 20, 30, FONT_WHITE, 0,
shopSurface[5]);
break;
case -7:
gfx_renderString("Rockets cannot be bought for Laser or Charger Cannon",
5, 30, FONT_WHITE, 0, shopSurface[5]);
break;
case -8:
gfx_renderString("You already have that weapon", 20, 30,
FONT_WHITE, 0, shopSurface[5]);
break;
case -9:
drawString("This weapon's ammo limit has been reached", 20, 30,
FONT_WHITE, shopSurface[5]);
gfx_renderString("This weapon's ammo limit has been reached", 20,
30, FONT_WHITE, 0, shopSurface[5]);
break;
default:
if (shopItems[shopSelectedItem].price != 0)
@ -312,9 +314,9 @@ static void drawShop()
sprintf(description, "%s (N/A)",
shopItems[shopSelectedItem].description);
}
drawString(shopItems[shopSelectedItem].name, 5, 22, FONT_WHITE,
shopSurface[5]);
drawString(description, 20, 38, FONT_CYAN, shopSurface[5]);
gfx_renderString(shopItems[shopSelectedItem].name, 5, 22,
FONT_WHITE, 0, shopSurface[5]);
gfx_renderString(description, 20, 38, FONT_CYAN, 0, shopSurface[5]);
break;
}
}

View File

@ -368,9 +368,12 @@ int doTitle()
if (!skip)
{
drawString("Copyright Parallel Realities 2003", 5, 560, FONT_WHITE, background);
drawString("Copyright Guus Sliepen, Astrid S. de Wijn and others 2012", 5, 580, FONT_WHITE, background);
drawString(buildVersion, 794 - strlen(buildVersion) * 9, 580, FONT_WHITE, background);
gfx_renderString("Copyright Parallel Realities 2003", 5,
560, FONT_WHITE, 0, background);
gfx_renderString("Copyright Guus Sliepen, Astrid S. de Wijn and others 2012",
5, 580, FONT_WHITE, 0, background);
gfx_renderString(buildVersion, 794 - strlen(buildVersion) * 9,
580, FONT_WHITE, 0, background);
screen_addBuffer(0, 560, 800, 40);
skip = true;
}
@ -390,9 +393,12 @@ int doTitle()
{
if ((now - then <= 27500) && (!skip))
{
drawString("Copyright Parallel Realities 2003", 5, 560, FONT_WHITE, background);
drawString("Copyright Guus Sliepen, Astrid S. de Wijn and others 2012", 5, 580, FONT_WHITE, background);
drawString(buildVersion, 794 - strlen(buildVersion) * 9, 580, FONT_WHITE, background);
gfx_renderString("Copyright Parallel Realities 2003", 5, 560,
FONT_WHITE, 0, background);
gfx_renderString("Copyright Guus Sliepen, Astrid S. de Wijn and others 2012",
5, 580, FONT_WHITE, 0, background);
gfx_renderString(buildVersion, 794 - strlen(buildVersion) * 9,
580, FONT_WHITE, 0, background);
screen_addBuffer(0, 560, 800, 40);
skip = true;
}