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_image <http://www.libsdl.org/projects/SDL_image/>
* SDL2_mixer <http://www.libsdl.org/projects/SDL_mixer/> * SDL2_mixer <http://www.libsdl.org/projects/SDL_mixer/>
* SDL2_ttf <http://www.libsdl.org/projects/SDL_ttf/> * 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 Once you have all dependencies installed, you can do the following from
a terminal window: 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_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; int yOffset;
@ -739,7 +739,7 @@ static int intermission_renderDialog(SDL_Surface *comms, int y, int face, const
{ {
int newY; int newY;
gfx_blit(gfx_faceSprites[face], 10, y, comms); 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) if (newY < y + 60)
newY += (60 - (newY - y)); newY += (60 - (newY - y));
return newY; 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("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);
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); savesSurface);
gfx_renderString("CANCEL will unselect that slot", 17, 220, gfx_renderUnicode("CANCEL will unselect that slot", 17, 220,
FONT_WHITE, 0, savesSurface); 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); FONT_WHITE, 0, savesSurface);
break; break;
case -1: 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); FONT_WHITE, 0, savesSurface);
break; break;
case -10: case -10:
gfx_renderString("Game Saved", 130, 200, FONT_WHITE, 0, gfx_renderUnicode("Game Saved", 130, 200, FONT_WHITE, 0,
savesSurface); savesSurface);
break; break;
case -11: case -11:
gfx_renderString("Save Deleted", 130, 200, FONT_WHITE, 0, gfx_renderUnicode("Save Deleted", 130, 200, FONT_WHITE, 0,
savesSurface); savesSurface);
break; break;
} }

View File

@ -339,37 +339,37 @@ static void drawShop()
case -1: case -1:
break; break;
case -2: 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]); 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break; break;
case -3: 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_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]); FONT_CYAN, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break; break;
case -4: 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]); gfx_shopSprites[SHOP_S_ITEM_INFO]);
break; break;
case -5: 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]); 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break; break;
case -6: 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]); gfx_shopSprites[SHOP_S_ITEM_INFO]);
break; break;
case -7: 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]); 5, 30, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break; break;
case -8: 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]); FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break; break;
case -9: 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]); 30, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]);
break; break;
default: default:
@ -386,7 +386,7 @@ static void drawShop()
} }
gfx_renderString(shopItems[shopSelectedItem].name, 5, 22, gfx_renderString(shopItems[shopSelectedItem].name, 5, 22,
FONT_WHITE, 0, gfx_shopSprites[SHOP_S_ITEM_INFO]); 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; break;
} }
} }

View File

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