Lots of Unicode usages, + title screen efficiency

This commit is contained in:
Julie Marchant 2019-06-04 19:10:24 -04:00
parent c665d2451d
commit 24e565680b
5 changed files with 48 additions and 41 deletions

View File

@ -85,7 +85,7 @@ Project: Starfighter depends on the following libraries to build:
* SDL2_image <http://www.libsdl.org/projects/SDL_image/>
* SDL2_mixer <http://www.libsdl.org/projects/SDL_mixer/>
* SDL2_ttf <http://www.libsdl.org/projects/SDL_ttf/>
* utf8proc <https://juliastrings.github.io/utf8proc/>
* Pango <https://www.pango.org/>
Once you have all dependencies installed, you can do the following from
a terminal window:

View File

@ -718,7 +718,7 @@ static void intermission_createCommsSurface(SDL_Surface *comms)
gfx_drawRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
gfx_renderString("+++ CURRENT MISSIONS (click for info) +++", -1, 15, FONT_GREEN, 0, comms);
gfx_renderUnicode("+++ CURRENT MISSIONS (click for info) +++", -1, 15, FONT_GREEN, 0, comms);
int yOffset;
@ -739,7 +739,7 @@ static int intermission_renderDialog(SDL_Surface *comms, int y, int face, const
{
int newY;
gfx_blit(gfx_faceSprites[face], 10, y, comms);
newY = gfx_renderString(string, 80, y, FONT_WHITE, 1, comms) + 25;
newY = gfx_renderUnicode(string, 80, y, FONT_WHITE, 1, comms) + 25;
if (newY < y + 60)
newY += (60 - (newY - y));
return newY;

View File

@ -394,23 +394,23 @@ void save_createSurface(SDL_Surface *savesSurface, int clickedSlot)
gfx_renderString("CANCEL", 150, 270, FONT_WHITE, 0, savesSurface);
gfx_renderString("DELETE", 270, 270, FONT_WHITE, 0, savesSurface);
gfx_renderString("SAVE will save the game", 17, 200, FONT_WHITE, 0,
gfx_renderUnicode("SAVE will save the game", 17, 200, FONT_WHITE, 0,
savesSurface);
gfx_renderString("CANCEL will unselect that slot", 17, 220,
gfx_renderUnicode("CANCEL will unselect that slot", 17, 220,
FONT_WHITE, 0, savesSurface);
gfx_renderString("DELETE will remove the save", 17, 240,
gfx_renderUnicode("DELETE will remove the save", 17, 240,
FONT_WHITE, 0, savesSurface);
break;
case -1:
gfx_renderString("First click a Save game slot to use", 17, 200,
gfx_renderUnicode("First click a Save game slot to use", 17, 200,
FONT_WHITE, 0, savesSurface);
break;
case -10:
gfx_renderString("Game Saved", 130, 200, FONT_WHITE, 0,
gfx_renderUnicode("Game Saved", 130, 200, FONT_WHITE, 0,
savesSurface);
break;
case -11:
gfx_renderString("Save Deleted", 130, 200, FONT_WHITE, 0,
gfx_renderUnicode("Save Deleted", 130, 200, FONT_WHITE, 0,
savesSurface);
break;
}

View File

@ -339,37 +339,37 @@ static void drawShop()
case -1:
break;
case -2:
gfx_renderString("You don't have enough money", 20, 30, FONT_WHITE,
gfx_renderUnicode("You don't have enough money", 20, 30, FONT_WHITE,
0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break;
case -3:
gfx_renderString("Cannot upgrade ship", 5, 22, FONT_WHITE, 0,
gfx_renderUnicode("Cannot upgrade ship", 5, 22, FONT_WHITE, 0,
gfx_shopSprites[SHOP_S_ITEM_INFO]);
gfx_renderString("Hardware capacity has been reached", 20, 38,
gfx_renderUnicode("Hardware capacity has been reached", 20, 38,
FONT_CYAN, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break;
case -4:
gfx_renderString("Ammunition limit reached", 20, 30, FONT_WHITE, 0,
gfx_renderUnicode("Ammunition limit reached", 20, 30, FONT_WHITE, 0,
gfx_shopSprites[SHOP_S_ITEM_INFO]);
break;
case -5:
gfx_renderString("You cannot sell that item", 20, 30, FONT_WHITE,
gfx_renderUnicode("You cannot sell that item", 20, 30, FONT_WHITE,
0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break;
case -6:
gfx_renderString("Nothing to sell", 20, 30, FONT_WHITE, 0,
gfx_renderUnicode("Nothing to sell", 20, 30, FONT_WHITE, 0,
gfx_shopSprites[SHOP_S_ITEM_INFO]);
break;
case -7:
gfx_renderString("Rockets cannot be bought for Laser or Charger Cannon",
gfx_renderUnicode("Rockets cannot be bought for Laser or Charger Cannon",
5, 30, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break;
case -8:
gfx_renderString("You already have that weapon", 20, 30,
gfx_renderUnicode("You already have that weapon", 20, 30,
FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break;
case -9:
gfx_renderString("This weapon's ammo limit has been reached", 20,
gfx_renderUnicode("This weapon's ammo limit has been reached", 20,
30, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break;
default:
@ -386,7 +386,7 @@ static void drawShop()
}
gfx_renderString(shopItems[shopSelectedItem].name, 5, 22,
FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
gfx_renderString(description, 20, 38, FONT_CYAN, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
gfx_renderUnicode(description, 20, 38, FONT_CYAN, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break;
}
}

View File

@ -190,6 +190,8 @@ int title_show()
int then;
int now;
int x;
int y;
int redGlow = 255;
int redDir = -2;
@ -199,6 +201,9 @@ int title_show()
int skip = 0;
int listLength = 6; // menu list length
int menuType = MENU_MAIN;
SDL_Surface *copyrightText;
SDL_Surface *infoText;
game_init();
@ -242,6 +247,18 @@ int title_show()
createCheatMenu();
copyrightText = gfx_createSurface(screen->w, 60);
gfx_renderString("Copyright Parallel Realities 2003",
5, 0, FONT_WHITE, 0, copyrightText);
gfx_renderString("Copyright Guus Sliepen, Astrid S. de Wijn and others 2012",
5, 20, FONT_WHITE, 0, copyrightText);
gfx_renderString("Copyright 2015-2019 Julie Marchant",
5, 40, FONT_WHITE, 0, copyrightText);
sprintf(buildVersion, "Version %s", VERSION );
infoText = gfx_createSurface(strlen(buildVersion) * 9 + 6, 20);
gfx_renderString(buildVersion, 0, 0, FONT_WHITE, 0, infoText);
// Set the star motion
engine.ssx = -0.5;
engine.ssy = 0;
@ -263,8 +280,6 @@ int title_show()
aliens[i].face = 0;
}
sprintf(buildVersion, "Version %s", VERSION );
SDL_Rect optionRec;
optionRec.x = screen->w / 2 - 110;
@ -327,8 +342,6 @@ int title_show()
if ((now - then >= 27500) || (skip))
{
screen_addBuffer(0, 0, screen->w, screen->h);
optionRec.x = screen->w / 2 - 110;
optionRec.y = screen->h / 3 + 26 + (20 * selectedOption);
if (menuType > MENU_MAIN)
@ -336,6 +349,7 @@ int title_show()
optionRec.y += 20;
screen_drawRect(optionRec.x, optionRec.y, optionRec.w, optionRec.h, redGlow, 0x00, 0x00);
screen_addBuffer(optionRec.x, optionRec.y, optionRec.w, optionRec.h);
switch(menuType)
{
@ -379,15 +393,15 @@ int title_show()
selectedOption = 4;
}
gfx_renderString("Copyright Parallel Realities 2003",
5, gfx_background->h - 60, FONT_WHITE, 0, gfx_background);
gfx_renderString("Copyright Guus Sliepen, Astrid S. de Wijn and others 2012",
5, gfx_background->h - 40, FONT_WHITE, 0, gfx_background);
gfx_renderString("Copyright 2015-2017 Julie Marchant",
5, gfx_background->h - 20, FONT_WHITE, 0, gfx_background);
gfx_renderString(buildVersion, gfx_background->w - 6 - strlen(buildVersion) * 9,
gfx_background->h - 20, FONT_WHITE, 0, gfx_background);
screen_addBuffer(0, 0, screen->w, screen->h);
x = 0;
y = screen->h - copyrightText->h;
screen_blit(copyrightText, x, y);
screen_addBuffer(x, y, copyrightText->w, copyrightText->h);
x = screen->w - infoText->w;
y = screen->h - infoText->h;
screen_blit(infoText, x, y);
screen_addBuffer(x, y, infoText->w, infoText->h);
}
}
@ -397,15 +411,6 @@ int title_show()
{
if ((now - then <= 27500) && (!skip))
{
gfx_renderString("Copyright Parallel Realities 2003",
5, screen->h - 60, FONT_WHITE, 0, gfx_background);
gfx_renderString("Copyright Guus Sliepen, Astrid S. de Wijn and others 2012",
5, screen->h - 40, FONT_WHITE, 0, gfx_background);
gfx_renderString("Copyright 2015-2019 Julie Marchant",
5, screen->h - 20, FONT_WHITE, 0, gfx_background);
gfx_renderString(buildVersion, screen->w - 6 - strlen(buildVersion) * 9,
screen->h - 20, FONT_WHITE, 0, gfx_background);
screen_addBuffer(0, screen->h - 40, screen->w, 40);
skip = 1;
}
else
@ -549,6 +554,8 @@ int title_show()
SDL_FreeSurface(prlogo);
SDL_FreeSurface(sflogo);
SDL_FreeSurface(copyrightText);
SDL_FreeSurface(infoText);
engine.keyState[KEY_FIRE] = 0;
engine.keyState[KEY_ALTFIRE] = 0;