Font Kerning Implementation

This commit is contained in:
cypress 2024-08-31 13:53:17 -07:00
parent 905f1c1feb
commit 2d29fa0af1
5 changed files with 198 additions and 118 deletions

View file

@ -291,7 +291,7 @@ void HUD_EndScreen (void)
l = scoreboardlines;
Draw_ColoredString((vid.width - 9*8)/2, 40, "GAME OVER", 255, 0, 0, 255, 1);
Draw_ColoredStringCentered(40, "GAME OVER", 255, 0, 0, 255, 1);
sprintf (str,"You survived %3i rounds", cl.stats[STAT_ROUNDS]);
Draw_String ((vid.width - strlen (str)*8)/2, 52, str);
@ -415,7 +415,7 @@ void HUD_Points (void)
}
Draw_Pic (x, y, sb_moneyback);
xplus = strlen(va("%i", current_points))*8;
xplus = getTextWidth(va("%i", current_points), 1);
Draw_String (((64 - xplus)/2)+5, y + 3, va("%i", current_points));
if (old_points != f)
@ -588,7 +588,7 @@ void HUD_MaxAmmo(void)
maxammoy -= cl.time * 0.003;
maxammoopac -= 5;
Draw_ColoredString(vid.width/2 - strlen("MAX AMMO!")*4, maxammoy, "MAX AMMO!", 255, 255, 255, maxammoopac, 1);
Draw_ColoredStringCentered(maxammoy, "MAX AMMO!", 255, 255, 255, maxammoopac, 1);
if (maxammoopac <= 0) {
domaxammo = false;
@ -630,7 +630,7 @@ void HUD_Rounds (void)
if (!value)
value = 255;
Draw_ColoredString(vid.width/2 - strlen("Round")*8, 80, "Round", 255, value, value, 255, 2);
Draw_ColoredStringCentered(80, "Round", 255, value, value, 255, 2);
value -= cl.time * 0.4;
@ -644,7 +644,7 @@ void HUD_Rounds (void)
// Now, fade out, and start fading worldtext in
// ~3s for fade out,
else if (textstate == 1) {
Draw_ColoredString(vid.width/2 - strlen("Round")*8, 80, "Round", 255, 0, 0, value, 2);
Draw_ColoredStringCentered(80, "Round", 255, 0, 0, value, 2);
HUD_WorldText(value2);
@ -1316,16 +1316,16 @@ void HUD_Ammo (void)
char* magstring;
int reslen;
reslen = strlen(va("/%i", cl.stats[STAT_AMMO]));
reslen = getTextWidth(va("/%i", cl.stats[STAT_AMMO]), 1);
//
// Magazine
//
magstring = va("%i", cl.stats[STAT_CURRENTMAG]);
if (GetLowAmmo(cl.stats[STAT_ACTIVEWEAPON], 1) >= cl.stats[STAT_CURRENTMAG]) {
Draw_ColoredString((422 -(reslen*8)) - strlen(magstring)*8, 247, magstring, 255, 0, 0, 255, 1);
Draw_ColoredString((422 -(reslen)) - getTextWidth(magstring, 1), 247, magstring, 255, 0, 0, 255, 1);
} else {
Draw_ColoredString((422 -(reslen*8)) - strlen(magstring)*8, 247, magstring, 255, 255, 255, 255, 1);
Draw_ColoredString((422 -(reslen)) - getTextWidth(magstring, 1), 247, magstring, 255, 255, 255, 255, 1);
}
//
@ -1333,9 +1333,9 @@ void HUD_Ammo (void)
//
magstring = va("/%i", cl.stats[STAT_AMMO]);
if (GetLowAmmo(cl.stats[STAT_ACTIVEWEAPON], 0) >= cl.stats[STAT_AMMO]) {
Draw_ColoredString(422 - strlen(magstring)*8, 247, magstring, 255, 0, 0, 255, 1);
Draw_ColoredString(422 - getTextWidth(magstring, 1), 247, magstring, 255, 0, 0, 255, 1);
} else {
Draw_ColoredString(422 - strlen(magstring)*8, 247, magstring, 255, 255, 255, 255, 1);
Draw_ColoredString(422 - getTextWidth(magstring, 1), 247, magstring, 255, 255, 255, 255, 1);
}
//
@ -1364,14 +1364,11 @@ void HUD_AmmoString (void)
int x;
if (0 < cl.stats[STAT_AMMO] && cl.stats[STAT_CURRENTMAG] >= 0) {
x = (vid.width - strlen("Reload")*8)/2;
Draw_ColoredString (x, 164, "Reload", 255, 255, 255, 255, 1);
Draw_ColoredStringCentered(164, "Reload", 255, 255, 255, 255, 1);
} else if (0 < cl.stats[STAT_CURRENTMAG]) {
x = (vid.width - strlen("LOW AMMO")*8)/2;
Draw_ColoredString (x, 164, "LOW AMMO", 255, 255, 0, 255, 1);
Draw_ColoredStringCentered(164, "LOW AMMO", 255, 255, 0, 255, 1);
} else {
x = (vid.width - strlen("NO AMMO")*8)/2;
Draw_ColoredString (x, 164, "NO AMMO", 255, 0, 0, 255, 1);
Draw_ColoredStringCentered(164, "NO AMMO", 255, 0, 0, 255, 1);
}
}
}
@ -1421,7 +1418,7 @@ void HUD_Weapon (void)
strcpy(str, pr_strings+sv_player->v.Weapon_Name);
l = strlen(str);
x_value = 422 - l*8;
x_value = 422 - getTextWidth(str, 1);
Draw_String (x_value, y_value, str);
}
@ -1435,17 +1432,20 @@ void HUD_BettyPrompt (void)
char str[64];
char str2[32];
strcpy(str, va("Double-tap %s then press %s\n", GetUseButtonL(), GetGrenadeButtonL()));
strcpy(str, va("Double-tap %s then press %s \n", GetUseButtonL(), GetGrenadeButtonL()));
strcpy(str2, "to place a Bouncing Betty\n");
int x, x2;
x = (vid.width - strlen(str)*8)/2;
x2 = (vid.width - strlen(str2)*8)/2;
int x;
x = (vid.width - getTextWidth(str, 1))/2;
Draw_String(x, 60, str);
Draw_String(x2, 70, str2);
Draw_Pic (x + 11*8, 60, GetButtonIcon("+use"));
Draw_Pic (x + 25*8, 60, GetButtonIcon("+grenade"));
Draw_ColoredStringCentered(60, str, 255, 255, 255, 255, 1);
Draw_ColoredStringCentered(70, str2, 255, 255, 255, 255, 1);
// Draw_Pic (x + 11*8, 60, GetButtonIcon("+use"));
// Draw_Pic (x + 25*8, 60, GetButtonIcon("+grenade"));
Draw_Pic (x + getTextWidth("Double-tap ", 1) - 4, 60, GetButtonIcon("+use"));
Draw_Pic (x + getTextWidth("Double-tap then press ", 1) - 4, 60, GetButtonIcon("+grenade"));
}
/*

View file

@ -29,6 +29,7 @@ void Draw_PicIndex (int x, int y, int width, int height, int texture_index);
void Draw_StretchPic (int x, int y, qpic_t *pic, int x_value, int y_value);
void Draw_ColorPic (int x, int y, qpic_t *pic, float r, float g , float b, float a);
void Draw_ColoredString (int x, int y, char *text, float r, float g, float b, float a, int scale);
void Draw_ColoredStringCentered(int y, char *text, float r, float g, float b, float a, int scale);
void Draw_TransPic (int x, int y, qpic_t *pic);
void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation);
void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha);
@ -38,6 +39,7 @@ void Draw_Fill (int x, int y, int w, int h, int c);
void Draw_FillByColor (int x, int y, int w, int h, unsigned int c);
void Draw_FadeScreen (void);
void Draw_String (int x, int y, char *str);
int getTextWidth(char *str, int scale);
//other
void Clear_LoadingFill (void);
@ -47,6 +49,7 @@ extern float loading_cur_step;
extern int loading_step;
extern char loading_name[32];
extern float loading_num_step;
extern int font_kerningamount[96];
qpic_t *Draw_CachePic (char *path);
qpic_t *Draw_CacheImg (char *path);

View file

@ -454,7 +454,7 @@ static void M_Start_Menu_Draw ()
// Fill black to make everything easier to see
Draw_FillByColor(0, 0, 480, 272, GU_RGBA(0, 0, 0, 102));
Draw_ColoredString((vid.width)/2 - 44, (vid.height - 64), "Press Start", 255, 0, 0, 255, 1);
Draw_ColoredStringCentered(vid.height - 64, "Press Start", 255, 0, 0, 255, 1);
}
void M_Start_Key (int key)
@ -599,7 +599,7 @@ void M_Main_Draw (void)
Draw_FillByColor(0, 0, 480, 272, GU_RGBA(0, 0, 0, 102));
// Version String
Draw_ColoredString((vid.width - (strlen(game_build_date) * 8)) + 4, 5, game_build_date, 255, 255, 255, 255, 1);
Draw_ColoredString((vid.width - getTextWidth(game_build_date, 1)) + 4, 5, game_build_date, 255, 255, 255, 255, 1);
// Header
Draw_ColoredString(10, 10, "MAIN MENU", 255, 255, 255, 255, 2);
@ -898,7 +898,7 @@ void M_Map_Draw (void)
if (m_map_cursor == i) {
if (custom_maps[i + multiplier].map_use_thumbnail == 1) {
Draw_PicIndex(256, 45, 175, 100, custom_maps[i + multiplier].thumbnail_index);
Draw_PicIndex(246, 45, 175, 100, custom_maps[i + multiplier].thumbnail_index);
}
if (custom_maps[i + multiplier].map_name_pretty != 0)
@ -908,55 +908,55 @@ void M_Map_Draw (void)
if (custom_maps[i + multiplier].map_desc_1 != 0) {
if (strcmp(custom_maps[i + multiplier].map_desc_1, " ") != 0) {
Draw_ColoredString(215, 155, custom_maps[i + multiplier].map_desc_1, 255, 255, 255, 255, 1);
Draw_ColoredString(235, 155, custom_maps[i + multiplier].map_desc_1, 255, 255, 255, 255, 1);
}
}
if (custom_maps[i + multiplier].map_desc_2 != 0) {
if (strcmp(custom_maps[i + multiplier].map_desc_2, " ") != 0) {
line_increment++;
Draw_ColoredString(215, 165, custom_maps[i + multiplier].map_desc_2, 255, 255, 255, 255, 1);
Draw_ColoredString(235, 165, custom_maps[i + multiplier].map_desc_2, 255, 255, 255, 255, 1);
}
}
if (custom_maps[i + multiplier].map_desc_3 != 0) {
if (strcmp(custom_maps[i + multiplier].map_desc_3, " ") != 0) {
line_increment++;
Draw_ColoredString(215, 175, custom_maps[i + multiplier].map_desc_3, 255, 255, 255, 255, 1);
Draw_ColoredString(235, 175, custom_maps[i + multiplier].map_desc_3, 255, 255, 255, 255, 1);
}
}
if (custom_maps[i + multiplier].map_desc_4 != 0) {
if (strcmp(custom_maps[i + multiplier].map_desc_4, " ") != 0) {
line_increment++;
Draw_ColoredString(215, 185, custom_maps[i + multiplier].map_desc_4, 255, 255, 255, 255, 1);
Draw_ColoredString(235, 185, custom_maps[i + multiplier].map_desc_4, 255, 255, 255, 255, 1);
}
}
if (custom_maps[i + multiplier].map_desc_5 != 0) {
if (strcmp(custom_maps[i + multiplier].map_desc_5, " ") != 0) {
line_increment++;
Draw_ColoredString(215, 195, custom_maps[i + multiplier].map_desc_5, 255, 255, 255, 255, 1);
Draw_ColoredString(235, 195, custom_maps[i + multiplier].map_desc_5, 255, 255, 255, 255, 1);
}
}
if (custom_maps[i + multiplier].map_desc_6 != 0) {
if (strcmp(custom_maps[i + multiplier].map_desc_6, " ") != 0) {
line_increment++;
Draw_ColoredString(215, 205, custom_maps[i + multiplier].map_desc_6, 255, 255, 255, 255, 1);
Draw_ColoredString(235, 205, custom_maps[i + multiplier].map_desc_6, 255, 255, 255, 255, 1);
}
}
if (custom_maps[i + multiplier].map_desc_7 != 0) {
if (strcmp(custom_maps[i + multiplier].map_desc_7, " ") != 0) {
line_increment++;
Draw_ColoredString(215, 215, custom_maps[i + multiplier].map_desc_7, 255, 255, 255, 255, 1);
Draw_ColoredString(235, 215, custom_maps[i + multiplier].map_desc_7, 255, 255, 255, 255, 1);
}
}
if (custom_maps[i + multiplier].map_desc_8 != 0) {
if (strcmp(custom_maps[i + multiplier].map_desc_8, " ") != 0) {
line_increment++;
Draw_ColoredString(215, 225, custom_maps[i + multiplier].map_desc_8, 255, 255, 255, 255, 1);
Draw_ColoredString(235, 225, custom_maps[i + multiplier].map_desc_8, 255, 255, 255, 255, 1);
}
}
if (custom_maps[i + multiplier].map_author != 0) {
if (strcmp(custom_maps[i + multiplier].map_author, " ") != 0) {
int y = 165 + (10 * line_increment);
Draw_ColoredString(215, y, custom_maps[i + multiplier].map_author, 255, 255, 0, 255, 1);
Draw_ColoredString(235, y, custom_maps[i + multiplier].map_author, 255, 255, 0, 255, 1);
}
}
} else {
@ -1142,42 +1142,42 @@ void M_SinglePlayer_Draw (void)
// Map description & pic
switch(m_singleplayer_cursor) {
case 0:
Draw_PicIndex(256, 45, 175, 100, menu_ndu);
Draw_ColoredString(215, 155, "Desolate bunker located on a Ge-", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 165, "rman airfield, stranded after a", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 175, "brutal plane crash surrounded by", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 185, "hordes of undead. Exploit myste-", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 195, "rious forces at play and hold o-", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 205, "ut against relentless waves. Der", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 215, "Anstieg ist jetzt. Will you fall", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 225, "to the overwhelming onslaught?", 255, 255, 255, 255, 1);
Draw_PicIndex(246, 45, 175, 100, menu_ndu);
Draw_ColoredString(235, 155, "Desolate bunker located on a Ge-", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 165, "rman airfield, stranded after a", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 175, "brutal plane crash surrounded by", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 185, "hordes of undead. Exploit myste-", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 195, "rious forces at play and hold o-", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 205, "ut against relentless waves. Der", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 215, "Anstieg ist jetzt. Will you fall", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 225, "to the overwhelming onslaught?", 255, 255, 255, 255, 1);
break;
case 1:
Draw_PicIndex(256, 45, 175, 100, menu_wh2);
Draw_ColoredString(215, 155, "Four nameless marines find them-", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 165, "selves at a forsaken warehouse,", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 175, "or is it something more? Fight", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 185, "your way to uncovering its sec-", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 195, "rets, though you may not like", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 205, "what you find..", 255, 255, 255, 255, 1);
Draw_PicIndex(246, 45, 175, 100, menu_wh2);
Draw_ColoredString(235, 155, "Four nameless marines find them-", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 165, "selves at a forsaken warehouse,", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 175, "or is it something more? Fight", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 185, "your way to uncovering its sec-", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 195, "rets, though you may not like", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 205, "what you find..", 255, 255, 255, 255, 1);
break;
case 2:
Draw_PicIndex(256, 45, 175, 100, menu_wh);
Draw_ColoredString(215, 155, "Old Warehouse full of Zombies!", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 165, "Fight your way to the Power", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 175, "Switch through the Hordes!", 255, 255, 255, 255, 1);
Draw_PicIndex(246, 45, 175, 100, menu_wh);
Draw_ColoredString(235, 155, "Old Warehouse full of Zombies!", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 165, "Fight your way to the Power", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 175, "Switch through the Hordes!", 255, 255, 255, 255, 1);
break;
case 3:
Draw_PicIndex(256, 45, 175, 100, menu_ch);
Draw_ColoredString(215, 155, "No Santa this year. Though we're", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 165, "sure you will get presents from", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 175, "the undead! Will you accept them?", 255, 255, 255, 255, 1);
Draw_PicIndex(246, 45, 175, 100, menu_ch);
Draw_ColoredString(235, 155, "No Santa this year. Though we're", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 165, "sure you will get presents from", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 175, "the undead! Will you accept them?", 255, 255, 255, 255, 1);
break;
case 4:
Draw_PicIndex(256, 45, 175, 100, menu_custom);
Draw_ColoredString(215, 155, "Custom Maps made by Community", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 165, "Members on the Fourm and on", 255, 255, 255, 255, 1);
Draw_ColoredString(215, 175, "GitHub Discussions!", 255, 255, 255, 255, 1);
Draw_PicIndex(246, 45, 175, 100, menu_custom);
Draw_ColoredString(235, 155, "Custom Maps made by Community", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 165, "Members on the Fourm and on", 255, 255, 255, 255, 1);
Draw_ColoredString(235, 175, "GitHub Discussions!", 255, 255, 255, 255, 1);
break;
}
}

View file

@ -504,6 +504,40 @@ static void R_CreateDlightImage( void )
ref_texture = GL_LoadTexture ("reftexture", DLIGHT_SIZE, DLIGHT_SIZE, (byte*)data, qfalse, GU_LINEAR, 0);
}
// ! " # $ % & ' ( ) * _ , - . / 0
// 1 2 3 4 5 6 7 8 9 : ; < = > ? @
// A B C D E F G H I J K L M N O P
// Q R S T U V W X Y Z [ \ ] ^ _ `
// a b c d e f g h i j k l m n o p
// q r s t u v w x y z { | } ~
int font_kerningamount[96];
void InitKerningMap(void)
{
// Initialize the kerning amount as 8px for each
// char in the event we cant load the file.
for(int i = 0; i < 96; i++) {
font_kerningamount[i] = 8;
}
FILE *kerning_map = fopen(va("%s/gfx/kerning_map.txt", com_gamedir), "r");
if (kerning_map == NULL) {
return;
}
char buffer[1024];
if (fgets(buffer, sizeof(buffer), kerning_map) != NULL) {
char *token = strtok(buffer, ",");
int i = 0;
while (token != NULL && i < 96) {
font_kerningamount[i++] = atoi(token);
token = strtok(NULL, ",");
}
}
fclose(kerning_map);
}
/*
===============
Draw_Init
@ -530,6 +564,8 @@ void Draw_Init (void)
Sys_Error ("Could not load charset, make sure you have every folder and file installed properly\nDouble check that all of your files are in their correct places\nAnd that you have installed the game properly.\nRefer to the readme.txt file for help\n");
Clear_LoadingFill ();
InitKerningMap();
}
@ -583,7 +619,6 @@ void Draw_Character (int x, int y, int num)
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices);
}
/*
================
Draw_CharacterRGBA
@ -650,8 +685,16 @@ void Draw_String (int x, int y, char *str)
while (*str)
{
Draw_Character (x, y, *str);
str++;
// Hooray for variable-spacing!
if (*str == ' ')
x += 4;
else if ((int)*str < 33 || (int)*str > 126)
x += 8;
else
x += (font_kerningamount[(int)(*str - 33)] + 1);
str++;
}
}
@ -1017,8 +1060,7 @@ void Draw_LoadingFill(void)
default: text = "Initializing.."; break;
}
l = strlen (text);
Draw_String((vid.width - l*8)/2, y, text);
Draw_ColoredStringCentered(y, text, 255, 255, 255, 255, 1);
loading_cur_step_bk = loading_cur_step;
}
@ -1514,7 +1556,14 @@ void Draw_ColoredString(int x, int y, char *text, float r, float g, float b, flo
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices);
}
x += 8*scale;
// Hooray for variable-spacing!
if (*text == ' ')
x += 4 * scale;
else if ((int)*text < 33 || (int)*text > 126)
x += 8 * scale;
else
x += (font_kerningamount[(int)(*text - 33)] + 1) * scale;
}
if (!white)
@ -1524,6 +1573,29 @@ void Draw_ColoredString(int x, int y, char *text, float r, float g, float b, flo
sceGuTexFunc(GU_TFX_REPLACE , GU_TCC_RGBA);
}
int getTextWidth(char *str, int scale)
{
int width = 0;
for (int i = 0; i < strlen(str); i++) {
// Hooray for variable-spacing!
if (str[i] == ' ')
width += 4 * scale;
else if ((int)str[i] < 33 || (int)str[i] > 126)
width += 8 * scale;
else
width += (font_kerningamount[(int)(str[i] - 33)] + 1) * scale;
}
return width;
}
void Draw_ColoredStringCentered(int y, char *str, float r, float g, float b, float a, int scale)
{
Draw_ColoredString((vid.width - getTextWidth(str, scale))/2, y, str, r, g, b, a, scale);
}
//=============================================================================
#ifdef NAA
//font.c : font.raw

View file

@ -214,10 +214,19 @@ void SCR_DrawCenterString (void)
for (l=0 ; l<40 ; l++)
if (start[l] == '\n' || !start[l])
break;
x = (vid.width - l*8)/2;
for (j=0 ; j<l ; j++, x+=8)
x = (vid.width - getTextWidth(start, 1))/2;
for (j=0 ; j<l ; j++)
{
Draw_Character (x, y, start[j]);
// Hooray for variable-spacing!
if (start[j] == ' ')
x += 4;
else if ((int)start[j] < 33 || (int)start[j] > 126)
x += 8;
else
x += (font_kerningamount[(int)(start[j] - 33)] + 1);
if (!remaining--)
return;
}
@ -418,37 +427,37 @@ void SCR_UsePrint (int type, int cost, int weapon)
case 1://door
strcpy(s, va("Hold %s to open Door\n", GetUseButtonL()));
strcpy(c, va("[Cost: %i]\n", cost));
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 2://debris
strcpy(s, va("Hold %s to remove Debris\n", GetUseButtonL()));
strcpy(c, va("[Cost: %i]\n", cost));
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 3://ammo
strcpy(s, va("Hold %s to buy Ammo for %s\n", GetUseButtonL(), pr_strings+sv_player->v.Weapon_Name_Touch));
strcpy(c, va("[Cost: %i]\n", cost));
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 4://weapon
strcpy(s, va("Hold %s to buy %s\n", GetUseButtonL(), pr_strings+sv_player->v.Weapon_Name_Touch));
strcpy(c, va("[Cost: %i]\n", cost));
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 5://window
strcpy(s, va("Hold %s to Rebuild Barrier\n", GetUseButtonL()));
strcpy(c, "");
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 6://box
strcpy(s, va("Hold %s for Mystery Box\n", GetUseButtonL()));
strcpy(c, va("[Cost: %i]\n", cost));
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 7://box take
strcpy(s, va("Hold %s for %s\n", GetUseButtonL(), pr_strings+sv_player->v.Weapon_Name_Touch));
strcpy(c, "");
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 8://power
strcpy(s, "The Power must be Activated first\n");
@ -458,37 +467,37 @@ void SCR_UsePrint (int type, int cost, int weapon)
case 9://perk
strcpy(s, va("Hold %s to buy %s\n", GetUseButtonL(), GetPerkName(weapon)));
strcpy(c, va("[Cost: %i]\n", cost));
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 10://turn on power
strcpy(s, va("Hold %s to Turn On the Power\n", GetUseButtonL()));
strcpy(c, "");
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 11://turn on trap
strcpy(s, va("Hold %s to Activate the Trap\n", GetUseButtonL()));
strcpy(c, va("[Cost: %i]\n", cost));
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 12://PAP
strcpy(s, va("Hold %s to Pack-a-Punch\n", GetUseButtonL()));
strcpy(c, va("[Cost: %i]\n", cost));
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 13://revive
strcpy(s, va("Hold %s to Fix your Code.. :)\n", GetUseButtonL()));
strcpy(c, "");
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 14://use teleporter (free)
strcpy(s, va("Hold %s to use Teleporter\n", GetUseButtonL()));
strcpy(c, "");
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 15://use teleporter (cost)
strcpy(s, va("Hold %s to use Teleporter\n", GetUseButtonL()));
strcpy(c, va("[Cost: %i]\n", cost));
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 16://tp cooldown
strcpy(s, "Teleporter is cooling down\n");
@ -498,7 +507,7 @@ void SCR_UsePrint (int type, int cost, int weapon)
case 17://link
strcpy(s, va("Hold %s to initiate link to pad\n", GetUseButtonL()));
strcpy(c, "");
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 18://no link
strcpy(s, "Link not active\n");
@ -508,12 +517,12 @@ void SCR_UsePrint (int type, int cost, int weapon)
case 19://finish link
strcpy(s, va("Hold %s to link pad with core\n", GetUseButtonL()));
strcpy(c, "");
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
case 20://buyable ending
strcpy(s, va("Hold %s to End the Game\n", GetUseButtonL()));
strcpy(c, va("[Cost: %i]\n", cost));
button_pic_x = 5;
button_pic_x = getTextWidth("Hold ", 1);
break;
default:
Con_Printf ("No type defined in engine for useprint\n");
@ -528,23 +537,21 @@ void SCR_UsePrint (int type, int cost, int weapon)
void SCR_DrawUseString (void)
{
int l, l2;
int x, x2, y;
int y;
int x;
if (cl.stats[STAT_HEALTH] < 0)
return;
// the finale prints the characters one at a time
y = 182;
l = strlen (scr_usestring);
x = (vid.width - l*8)/2;
x = (vid.width - getTextWidth(scr_usestring, 1))/2;
l2 = strlen (scr_usestring2);
x2 = (vid.width - l2*8)/2;
Draw_ColoredStringCentered(y, scr_usestring, 255, 255, 255, 255, 1);
Draw_ColoredStringCentered(y + 10, scr_usestring2, 255, 255, 255, 255, 1);
Draw_String (x, y, scr_usestring);
Draw_String (x2, y + 10, scr_usestring2);
Draw_Pic (x + button_pic_x*8, y, GetButtonIcon("+use"));
if (button_pic_x != 100)
Draw_Pic (x + button_pic_x, y, GetButtonIcon("+use"));
}
void SCR_CheckDrawUseString (void)
@ -884,7 +891,6 @@ SCR_DrawLoadScreen
*/
double loadingtimechange;
int loadingdot;
int loadingtextwidth;
char *lodinglinetext;
qpic_t *awoo;
char *ReturnLoadingtex (void)
@ -1109,12 +1115,11 @@ void SCR_DrawLoadScreen (void)
if (loadingtimechange < Sys_FloatTime ())
{
lodinglinetext = ReturnLoadingtex();
loadingtextwidth = strlen(lodinglinetext)*8;
loadingtimechange = Sys_FloatTime () + 5;
}
if (key_dest == key_game) {
Draw_ColoredString(240 - loadingtextwidth/2, 256, lodinglinetext, 255, 255, 255, 255, 1);
Draw_ColoredStringCentered(256, lodinglinetext, 255, 255, 255, 255, 1);
if (strcmp(lodinglinetext, "Please help me find the meaning of . Thanks.") == 0) {
Draw_Pic(335, 255, awoo);