diff --git a/source/draw.h b/source/draw.h index 8e1a33c..2c0e361 100644 --- a/source/draw.h +++ b/source/draw.h @@ -52,9 +52,11 @@ extern float loading_cur_step; extern int loading_step; extern char loading_name[32]; extern float loading_num_step; +extern int font_kerningamount[96]; void Draw_ColoredString (int x, int y, const char *str, float r, float g, float b, float a); void Draw_ColoredStringScale (int x, int y, const char *str, float r, float g, float b, float a, float s); +void Draw_ColoredStringCentered(int y, char *text, float r, float g, float b, float a, float s); qpic_t *Draw_PicFromWad (const char *name); qpic_t *Draw_CachePic (const char *path); void Draw_NewGame (void); @@ -62,6 +64,7 @@ void Draw_NewGame (void); void GL_SetCanvas (canvastype newcanvas); //johnfitz void Clear_LoadingFill (void); gltexture_t *loadtextureimage (char* filename); +float getTextWidth(char *str, float scale); #endif /* _QUAKE_DRAW_H */ diff --git a/source/gl_draw.c b/source/gl_draw.c index 88038c0..519c5b8 100644 --- a/source/gl_draw.c +++ b/source/gl_draw.c @@ -448,6 +448,40 @@ void Draw_NewGame (void) menu_numcachepics = 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 -- johnfitz -- rewritten @@ -478,6 +512,7 @@ void Draw_Init (void) // load game pics Draw_LoadPics (); Clear_LoadingFill (); + InitKerningMap(); } //============================================================================== @@ -682,10 +717,20 @@ void Draw_ColoredStringScale (int x, int y, const char *str, float r, float g, f while (*str) { + if (*str != 32) //don't waste verts on spaces Draw_CharacterQuadScale (x, y, *str, s); + + // Hooray for variable-spacing! + if (*str == ' ') + x += 4 * s; + else if ((int)*str < 33 || (int)*str > 126) + x += 8 * s; + else + x += (font_kerningamount[(int)(*str - 33)] + 1) * s; + str++; - x += 8*s; + //x += 8*s; } glEnd (); @@ -696,41 +741,36 @@ void Draw_ColoredStringScale (int x, int y, const char *str, float r, float g, f glColor4f (1,1,1,1); } - -/* -================ -Draw_ColoredString - -Assume that all rgba values are divided by 255 already -================ -*/ -void Draw_ColoredString (int x, int y, const char *str, float r, float g, float b, float a) +float getTextWidth(char *str, float scale) { - if (y <= -8) - return; // totally off screen + float width = 0; - glEnable (GL_BLEND); - glColor4f(r, g, b, a); - glDisable (GL_ALPHA_TEST); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + 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; + } - GL_Bind (char_texture); - glBegin (GL_QUADS); + return width; +} - while (*str) - { - if (*str != 32) //don't waste verts on spaces - Draw_CharacterQuad (x, y, *str); - str++; - x += 8; - } - glEnd (); +void Draw_ColoredStringCentered(int y, char *str, float r, float g, float b, float a, float s) +{ - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glEnable(GL_ALPHA_TEST); - glDisable (GL_BLEND); - glColor4f (1,1,1,1); +#ifdef VITA + + Draw_ColoredStringScale((int)((vid.width - getTextWidth(str, s))/2), y, str, r, g, b, a, s); + +#else + + Draw_ColoredStringScale((int)((640 - getTextWidth(str, s))/2), y, str, r, g, b, a, s); + +#endif // VITA } @@ -1084,7 +1124,6 @@ void Draw_LoadingFill(void) #endif // VITA - int l; char str[64]; char* text; @@ -1110,15 +1149,17 @@ void Draw_LoadingFill(void) default: text = "Initializing.."; break; } - l = strlen (text); - #ifdef VITA - Draw_ColoredStringScale((vid.width - l*16)/2, y, text, 1, 1, 1, 1, 2.0f); + Draw_ColoredStringCentered(y, text, 1, 1, 1, 1, 2.0f); + + //Draw_ColoredStringScale((vid.width - l*16)/2, y, text, 1, 1, 1, 1, 2.0f); #else - Draw_String((640 - l*8)/2, y, text); + Draw_ColoredStringCentered(y, text, 1, 1, 1, 1, 1.0f); + + //Draw_String((640 - l*8)/2, y, text); #endif // VITA diff --git a/source/gl_hud.c b/source/gl_hud.c index 3c876e9..e699d08 100644 --- a/source/gl_hud.c +++ b/source/gl_hud.c @@ -322,8 +322,8 @@ void HUD_EndScreen (void) #ifdef VITA - Draw_ColoredStringScale(vid.width/2 - strlen("GAME OVER")*16, 110, "GAME OVER", 1, 1, 1, 1, 4.0f); - Draw_ColoredStringScale(vid.width/2 - strlen(str)*8, 150, str, 1, 1, 1, 1, 2.0f); + Draw_ColoredStringCentered(110, "GAME OVER", 1, 1, 1, 1, 4.0f); + Draw_ColoredStringCentered(150, str, 1, 1, 1, 1, 2.0f); Draw_ColoredStringScale(vid.width/2 + 40, 185, "Points", 1, 1, 1, 1, 2.0f); Draw_ColoredStringScale(vid.width/2 + 240, 185, "Kills", 1, 1, 1, 1, 2.0f); @@ -354,8 +354,8 @@ void HUD_EndScreen (void) #else - Draw_ColoredStringScale(vid.width/4 - strlen("GAME OVER")*8, vid.height*3/4 - 98, "GAME OVER", 1, 1, 1, 1, 2.0f); - Draw_ColoredStringScale(vid.width/4 - strlen(str)*6, vid.height*3/4 - 70, str, 1, 1, 1, 1, 1.5f); + Draw_ColoredStringCentered(vid.height*3/4 - 98, "GAME OVER", 1, 1, 1, 1, 2.0f); + Draw_ColoredStringCentered(vid.height*3/4 - 70, str, 1, 1, 1, 1, 1.5f); Draw_ColoredStringScale(vid.width/4 + 35, vid.height*3/4 - 40, "Points", 1, 1, 1, 1, 1.25f); Draw_ColoredStringScale(vid.width/4 + 130, vid.height*3/4 - 40, "Kills", 1, 1, 1, 1, 1.25f); @@ -507,7 +507,7 @@ void HUD_Points (void) point_x_offset = 5; #else x_position = 5; - point_x_offset = 4; + point_x_offset = 6; #endif // VITA } else { @@ -530,11 +530,11 @@ void HUD_Points (void) #endif // VITA #ifdef VITA - xplus = HUD_itoa (f, str)*16; - Draw_ColoredStringScale (((160 - xplus)/2)-point_x_offset, 413 - (35 * i), va("%i", current_points[i]), r, g, b, 1, 2.0f); //2x Scale/White + xplus = getTextWidth(va("%i", current_points), 1.0f); + Draw_ColoredStringScale (((195 - xplus)/2)-point_x_offset, 413 - (35 * i), va("%i", current_points[i]), r, g, b, 1, 2.0f); //2x Scale/White #else - xplus = HUD_itoa (f, str)*12; - Draw_ColoredStringScale (((111 - xplus)/2)-point_x_offset, 633 - (24 * i), va("%i", current_points[i]), r, g, b, 1, 1.5f); + xplus = getTextWidth(va("%i", current_points), 1.0f) - 2; + Draw_ColoredStringScale (((145 - xplus)/2)-point_x_offset, 633 - (24 * i), va("%i", current_points[i]), r, g, b, 1, 1.5f); #endif // VITA if (old_points[i] != f) @@ -542,17 +542,17 @@ void HUD_Points (void) if (f > old_points[i]) { #ifdef VITA - HUD_Parse_Point_Change(f - old_points[i], 0, 80 - (xplus), 415 - (35 * i)); + HUD_Parse_Point_Change(f - old_points[i], 0, 45 - (xplus), 415 - (35 * i)); #else - HUD_Parse_Point_Change(f - old_points[i], 0, 140 - (xplus), y - (28 * i)); + HUD_Parse_Point_Change(f - old_points[i], 0, 145 - (xplus), y - (28 * i)); #endif // VITA } else { #ifdef VITA - HUD_Parse_Point_Change(old_points[i] - f, 1, 80 - (xplus), 415 - (35 * i)); + HUD_Parse_Point_Change(old_points[i] - f, 1, 45 - (xplus), 415 - (35 * i)); #else - HUD_Parse_Point_Change(old_points[i] - f, 1, 140 - (xplus), y - (28 * i)); + HUD_Parse_Point_Change(old_points[i] - f, 1, 145 - (xplus), y - (28 * i)); #endif // VITA } old_points[i] = f; @@ -659,15 +659,7 @@ void HUD_MaxAmmo(void) maxammoy -= cl.time * 0.003; maxammoopac -= cl.time * 0.05; -#ifdef VITA - - Draw_ColoredStringScale(vid.width/2 - strlen("MAX AMMO!")*8, maxammoy, "MAX AMMO!", 255, 255, 255, maxammoopac/255, 2.0f); - -#else - - Draw_ColoredStringScale(vid.width/4 - strlen("MAX AMMO!")*8, maxammoy, "MAX AMMO!", 255, 255, 255, maxammoopac/255, 2.0f); - -#endif // VITA + Draw_ColoredStringCentered(maxammoy, "MAX AMMO!", 1, 1, 1, maxammoopac/255, 2.0f); if (maxammoopac <= 0) { domaxammo = false; @@ -794,11 +786,11 @@ void HUD_Rounds (void) #ifdef VITA - Draw_ColoredStringScale(vid.width/2 - strlen("Round")*16, 160, "Round", 1, value/255, value/255, 1, 4.0f); + Draw_ColoredStringCentered(160, "Round", 1, value/255, value/255, 1, 4.0f); #else - Draw_ColoredStringScale(vid.width/4 - strlen("Round")*8, vid.height*3/4 - sb_round[0]->height - 10, "Round", 1, value/255, value/255, 1, 2.0f); + Draw_ColoredStringCentered(vid.height*3/4 - sb_round[0]->height - 10, "Round", 1, value/255, value/255, 1, 2.0f); #endif // VITA @@ -817,11 +809,11 @@ void HUD_Rounds (void) #ifdef VITA - Draw_ColoredStringScale(vid.width/2 - strlen("Round")*16, 160, "Round", 1, 0, 0, value/255, 4.0f); + Draw_ColoredStringCentered(160, "Round", 1, 0, 0, value/255, 4.0f); #else - Draw_ColoredStringScale(vid.width/4 - strlen("Round")*8, vid.height*3/4 - sb_round[0]->height - 10, "Round", 1, 0, 0, value/255, 2.0f); + Draw_ColoredStringCentered(vid.height*3/4 - sb_round[0]->height - 10, "Round", 1, 0, 0, value/255, 2.0f); #endif // VITA @@ -1752,21 +1744,21 @@ void HUD_Ammo (void) #else float scale = 1.25f; - y_value = vid.height - 3 - fragpic->height; + y_value = vid.height - fragpic->height; x_value = 575; #endif // VITA - reslen = strlen(va("/%i", cl.stats[STAT_AMMO])); + reslen = getTextWidth(va("/%i", cl.stats[STAT_AMMO]), scale); // // Magazine // magstring = va("%i", cl.stats[STAT_CURRENTMAG]); if (GetLowAmmo(cl.stats[STAT_ACTIVEWEAPON], 1) >= cl.stats[STAT_CURRENTMAG]) { - Draw_ColoredStringScale((x_value - (reslen*8*scale)) - strlen(magstring)*8*scale, y_value, magstring, 1, 0, 0, 1, scale); + Draw_ColoredStringScale((x_value - reslen) - getTextWidth(magstring, scale), y_value, magstring, 1, 0, 0, 1, scale); } else { - Draw_ColoredStringScale((x_value - (reslen*8*scale)) - strlen(magstring)*8*scale, y_value, magstring, 1, 1, 1, 1, scale); + Draw_ColoredStringScale((x_value - reslen) - getTextWidth(magstring, scale), y_value, magstring, 1, 1, 1, 1, scale); } // @@ -1774,9 +1766,9 @@ void HUD_Ammo (void) // magstring = va("/%i", cl.stats[STAT_AMMO]); if (GetLowAmmo(cl.stats[STAT_ACTIVEWEAPON], 0) >= cl.stats[STAT_AMMO]) { - Draw_ColoredStringScale(x_value - strlen(magstring)*8*scale, y_value, magstring, 1, 0, 0, 1, scale); + Draw_ColoredStringScale(x_value - getTextWidth(magstring, scale), y_value, magstring, 1, 0, 0, 1, scale); } else { - Draw_ColoredStringScale(x_value - strlen(magstring)*8*scale, y_value, magstring, 1, 1, 1, 1, scale); + Draw_ColoredStringScale(x_value - getTextWidth(magstring, scale), y_value, magstring, 1, 1, 1, 1, scale); } // @@ -1785,9 +1777,9 @@ void HUD_Ammo (void) if (IsDualWeapon(cl.stats[STAT_ACTIVEWEAPON])) { magstring = va("%i", cl.stats[STAT_CURRENTMAG2]); if (GetLowAmmo(cl.stats[STAT_ACTIVEWEAPON], 0) >= cl.stats[STAT_CURRENTMAG2]) { - Draw_ColoredStringScale(x_value - 34*scale - strlen(magstring)*8*scale, y_value, magstring, 1, 0, 0, 1, scale); + Draw_ColoredStringScale(x_value - 34*scale - getTextWidth(magstring, scale), y_value, magstring, 1, 0, 0, 1, scale); } else { - Draw_ColoredStringScale(x_value - 34*scale - strlen(magstring)*8*scale, y_value, magstring, 1, 1, 1, 1, scale); + Draw_ColoredStringScale(x_value - 34*scale - getTextWidth(magstring, scale), y_value, magstring, 1, 1, 1, 1, scale); } } } @@ -1806,21 +1798,21 @@ void HUD_AmmoString (void) { if (0 < cl.stats[STAT_AMMO] && cl.stats[STAT_CURRENTMAG] >= 0) { #ifdef VITA - Draw_ColoredStringScale ((vid.width)/2 - 43, (vid.height)/2 + 34, "Reload", 1, 1, 1, 1, 2.0f); + Draw_ColoredStringCentered((vid.height)/2 + 34, "Reload", 1, 1, 1, 1, 2.0f); #else - Draw_ColoredStringScale(vid.width/4 - strlen("Reload")*6, (vid.height)*3/4 + 40, "Reload", 1, 1, 1, 1, 1.5f); + Draw_ColoredStringCentered((vid.height)*3/4 + 44, "Reload", 1, 1, 1, 1, 1.5f); #endif } else if (0 < cl.stats[STAT_CURRENTMAG]) { #ifdef VITA - Draw_ColoredStringScale ((vid.width)/2 - 73, (vid.height)/2 + 34, "LOW AMMO", 1, 1, 0, 1, 2.5f); + Draw_ColoredStringCentered((vid.height)/2 + 34, "LOW AMMO", 1, 1, 0, 1, 2.0f); #else - Draw_ColoredStringScale(vid.width/4 - strlen("LOW AMMO")*6, (vid.height)*3/4 + 40, "LOW AMMO", 1, 1, 0, 1, 1.5f); + Draw_ColoredStringCentered((vid.height)*3/4 + 44, "LOW AMMO", 1, 1, 0, 1, 1.5f); #endif } else { #ifdef VITA - Draw_ColoredStringScale ((vid.width)/2 - 66, (vid.height)/2 + 34, "NO AMMO", 1, 0, 0, 1, 2.5f); + Draw_ColoredStringCentered((vid.height)/2 + 34, "NO AMMO", 1, 0, 0, 1, 2.0f); #else - Draw_ColoredStringScale(vid.width/4 - strlen("NO AMMO")*6, (vid.height)*3/4 + 40, "NO AMMO", 1, 0, 0, 1, 1.5f); + Draw_ColoredStringCentered((vid.height)*3/4 + 44, "NO AMMO", 1, 0, 0, 1, 1.5f); #endif } } @@ -1858,11 +1850,11 @@ void HUD_Grenades (void) else Draw_ColoredStringScale (x_value + 36, y_value + 44, va ("%i",cl.stats[STAT_PRIGRENADES]), 1, 1, 1, 1, 2.0f); #else - Draw_StretchPic (x_value - 24, y_value, fragpic, 26, 26); + Draw_StretchPic (x_value - 24, y_value, fragpic, 32, 32); if (cl.stats[STAT_PRIGRENADES] <= 0) - Draw_ColoredStringScale (x_value + 15 - 24, y_value + 18, va ("%i",cl.stats[STAT_PRIGRENADES]), 1, 0, 0, 1, 1.25f); + Draw_ColoredStringScale (x_value + 15 - 20, y_value + 20, va ("%i",cl.stats[STAT_PRIGRENADES]), 1, 0, 0, 1, 1.25f); else - Draw_ColoredStringScale (x_value + 15 - 24, y_value + 18, va ("%i",cl.stats[STAT_PRIGRENADES]), 1, 1, 1, 1, 1.25f); + Draw_ColoredStringScale (x_value + 15 - 20, y_value + 20, va ("%i",cl.stats[STAT_PRIGRENADES]), 1, 1, 1, 1, 1.25f); #endif } if (cl.stats[STAT_GRENADES] & UI_BETTY) @@ -1875,11 +1867,11 @@ void HUD_Grenades (void) Draw_ColoredStringScale (x_value + fragpic->width + 46, y_value + 44, va ("%i",cl.stats[STAT_SECGRENADES]), 1, 1, 1, 1, 2.0f); } #else - Draw_StretchPic (x_value, y_value, bettypic, 26, 26); + Draw_StretchPic (x_value, y_value, bettypic, 32, 32); if (cl.stats[STAT_SECGRENADES] <= 0) { - Draw_ColoredStringScale (x_value + 15, y_value + 18, va ("%i",cl.stats[STAT_SECGRENADES]), 1, 0, 0, 1, 1.25f); + Draw_ColoredStringScale (x_value + 15, y_value + 20, va ("%i",cl.stats[STAT_SECGRENADES]), 1, 0, 0, 1, 1.25f); } else { - Draw_ColoredStringScale (x_value + 15, y_value + 18, va ("%i",cl.stats[STAT_SECGRENADES]), 1, 1, 1, 1, 1.25f); + Draw_ColoredStringScale (x_value + 15, y_value + 20, va ("%i",cl.stats[STAT_SECGRENADES]), 1, 1, 1, 1, 1.25f); } #endif } @@ -2013,10 +2005,10 @@ void HUD_Weapon (void) //strcpy(str, GetWeaponName(cl.stats[STAT_ACTIVEWEAPON])); l = strlen(str); #ifdef VITA - x_value = vid.width - fragpic->width - 65 - l*16; + x_value = vid.width - fragpic->width - 65 - getTextWidth(str, 2.0f); Draw_ColoredStringScale (x_value, y_value, str, 1, 1, 1, 1, 2.0f); #else - x_value = vid.width/2 - 63 - l*10; + x_value = vid.width/2 - 63 - getTextWidth(str, 1.25f); Draw_ColoredStringScale (x_value, y_value, str, 1, 1, 1, 1, 1.25f); #endif } diff --git a/source/gl_screen.c b/source/gl_screen.c index 7e28186..5b2974a 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -322,6 +322,16 @@ void SCR_UsePrint (int type, int cost, int weapon) char s[128]; char c[128]; +#ifdef VITA + + float scale = 2.0f; + +#else + + float scale = 1.25f; + +#endif // VITA + switch (type) { case 0://clear @@ -329,42 +339,42 @@ void SCR_UsePrint (int type, int cost, int weapon) strcpy(c, ""); break; case 1://door - strcpy(s, va("Hold %s to open Door\n", GetUseButtonL())); + 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 ", scale); break; case 2://debris - strcpy(s, va("Hold %s to remove Debris\n", GetUseButtonL())); + 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 ", scale); break; case 3://ammo strcpy(w, cl.touchname); - strcpy(s, va("Hold %s to buy Ammo for %s\n", GetUseButtonL(), w)); + strcpy(s, va("Hold %s to buy Ammo for %s\n", GetUseButtonL(), w)); strcpy(c, va("[Cost: %i]\n", cost)); - button_pic_x = 5; + button_pic_x = getTextWidth("Hold ", scale); break; case 4://weapon strcpy(w, cl.touchname); - strcpy(s, va("Hold %s to buy %s\n", GetUseButtonL(), w)); + strcpy(s, va("Hold %s to buy %s\n", GetUseButtonL(), w)); strcpy(c, va("[Cost: %i]\n", cost)); - button_pic_x = 5; + button_pic_x = getTextWidth("Hold ", scale); break; case 5://window - strcpy(s, va("Hold %s to Rebuild Barrier\n", GetUseButtonL())); + strcpy(s, va("Hold %s to Rebuild Barrier\n", GetUseButtonL())); strcpy(c, ""); - button_pic_x = 5; + button_pic_x = getTextWidth("Hold ", scale); break; case 6://box - strcpy(s, va("Hold %s for Mystery Box\n", GetUseButtonL())); + 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 ", scale); break; case 7://box take strcpy(w, cl.touchname); - strcpy(s, va("Hold %s for %s\n", GetUseButtonL(), w)); + strcpy(s, va("Hold %s for %s\n", GetUseButtonL(), w)); strcpy(c, ""); - button_pic_x = 5; + button_pic_x = getTextWidth("Hold ", scale); break; case 8://power strcpy(s, "The Power must be Activated first\n"); @@ -372,39 +382,39 @@ void SCR_UsePrint (int type, int cost, int weapon) button_pic_x = 100; break; case 9://perk - strcpy(s, va("Hold %s to buy %s\n", GetUseButtonL(), GetPerkName(weapon))); + 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 ", scale); break; case 10://turn on power - strcpy(s, va("Hold %s to Turn On the Power\n", GetUseButtonL())); + strcpy(s, va("Hold %s to Turn On the Power\n", GetUseButtonL())); strcpy(c, ""); - button_pic_x = 5; + button_pic_x = getTextWidth("Hold ", scale); break; case 11://turn on trap - strcpy(s, va("Hold %s to Activate the Trap\n", GetUseButtonL())); + 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 ", scale); break; case 12://PAP - strcpy(s, va("Hold %s to Pack-a-Punch\n", GetUseButtonL())); + 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 ", scale); break; case 13://revive - strcpy(s, va("Hold %s to Fix your Code.. :)\n", GetUseButtonL())); + strcpy(s, va("Hold %s to Fix your Code.. :)\n", GetUseButtonL())); strcpy(c, ""); - button_pic_x = 5; + button_pic_x = getTextWidth("Hold ", scale); break; case 14://use teleporter (free) - strcpy(s, va("Hold %s to use Teleporter\n", GetUseButtonL())); + strcpy(s, va("Hold %s to use Teleporter\n", GetUseButtonL())); strcpy(c, ""); - button_pic_x = 5; + button_pic_x = getTextWidth("Hold ", scale); break; case 15://use teleporter (cost) - strcpy(s, va("Hold %s to use Teleporter\n", GetUseButtonL())); + 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 ", scale); break; case 16://tp cooldown strcpy(s, "Teleporter is cooling down\n"); @@ -412,9 +422,9 @@ void SCR_UsePrint (int type, int cost, int weapon) button_pic_x = 100; break; case 17://link - strcpy(s, va("Hold %s to initiate link to pad\n", GetUseButtonL())); + strcpy(s, va("Hold %s to initiate link to pad\n", GetUseButtonL())); strcpy(c, ""); - button_pic_x = 5; + button_pic_x = getTextWidth("Hold ", scale); break; case 18://no link strcpy(s, "Link not active\n"); @@ -422,14 +432,14 @@ void SCR_UsePrint (int type, int cost, int weapon) button_pic_x = 100; break; case 19://finish link - strcpy(s, va("Hold %s to link pad with core\n", GetUseButtonL())); + strcpy(s, va("Hold %s to link pad with core\n", GetUseButtonL())); strcpy(c, ""); - button_pic_x = 5; + button_pic_x = getTextWidth("Hold ", scale); break; case 20://buyable ending - strcpy(s, va("Hold %s to End the Game\n", GetUseButtonL())); + 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 ", scale); break; default: Con_Printf ("No type defined in engine for useprint\n"); @@ -443,8 +453,7 @@ void SCR_UsePrint (int type, int cost, int weapon) void SCR_DrawUseString (void) { - int l, l2; - int x, x2, y; + int x, y; if (cl.stats[STAT_HEALTH] < 0) { return; @@ -452,32 +461,41 @@ void SCR_DrawUseString (void) #ifdef VITA - float scale = 1.0f; + float scale = 2.0f; + y = vid.height * 0.65; #else float scale = 1.25f; + y = vid.height * 0.85; #endif // VITA - // The scale is double, so basically subtract the difference here... - y = vid.height*0.85; - l = strlen (scr_usestring); - x = ((vid.width/2 - l*8*scale)/2); - l2 = strlen (scr_usestring2); - x2 = ((vid.width/2 - l2*8*scale)/2); - #ifdef VITA - GL_SetCanvas(CANVAS_HUD); -#else - GL_SetCanvas(CANVAS_USEPRINT); -#endif - Draw_ColoredStringScale(x, y, scr_usestring, 1, 1, 1, 1, scale); - Draw_ColoredStringScale(x2, y + 12*scale, scr_usestring2, 1, 1, 1, 1, scale); + x = (vid.width - getTextWidth(scr_usestring, scale))/2; + +#else + x = (640 - getTextWidth(scr_usestring, scale))/2; + GL_SetCanvas(CANVAS_USEPRINT); + +#endif // VITA + + Draw_ColoredStringCentered(y, scr_usestring, 1, 1, 1, 1, scale); + Draw_ColoredStringCentered(y + 12 * scale, scr_usestring2, 1, 1, 1, 1, scale); GL_SetCanvas(CANVAS_DEFAULT); - Draw_Pic (x*2 + button_pic_x*16*scale, y*0.8125, GetButtonIcon("+use")); + +#ifdef VITA + + Draw_Pic ((x + button_pic_x), y - 8, GetButtonIcon("+use")); + +#else + + Draw_Pic (x*2 + button_pic_x*scale + 26, y*0.8125, GetButtonIcon("+use")); + +#endif // VITA + } void SCR_CheckDrawUseString (void) @@ -575,16 +593,16 @@ void SCR_DrawCenterString (void) //actually do the drawing #ifndef VITA - int scale = 8; + int scale = 1; #else - int scale = 16; + int scale = 2; #endif // VITA - x = (320 - l*scale)/2; //johnfitz -- 320x200 coordinate system - for (j=0 ; j 126) + x += 8 * scale; + else + x += (font_kerningamount[(int)(start[j] - 33)] + 1) * scale; + if (!remaining--) return; } - y += scale; + y += scale * 8; while (*start && *start != '\n') start++; @@ -1086,7 +1112,6 @@ SCR_DrawLoadScreen double loadingtimechange; int loadingdot; -int loadingtextwidth; char *lodinglinetext; qpic_t *awoo; char *ReturnLoadingtex (void) @@ -1387,22 +1412,21 @@ void SCR_DrawLoadScreen (void) if (loadingtimechange < Sys_DoubleTime ()) { lodinglinetext = ReturnLoadingtex(); - loadingtextwidth = strlen(lodinglinetext); //strlen(lodinglinetext)*8 loadingtimechange = Sys_DoubleTime () + 5; } if (key_dest == key_game) { + #ifdef VITA - Draw_ColoredStringScale((vid.width - loadingtextwidth*16)/2, 544 - 16 - 8, lodinglinetext, 255, 255, 255, 255, 2.0f); - //if (strcmp(lodinglinetext, "Please help me find the meaning of . Thanks.") == 0) { - //Draw_Pic(335, 255, awoo); + Draw_ColoredStringCentered(544 - 16 - 8, lodinglinetext, 1, 1, 1, 1, 2.0f); + #else - Draw_ColoredStringScale((640 - loadingtextwidth*10)/2, 342, lodinglinetext, 255, 255, 255, 255, 1.25f); - //if (strcmp(lodinglinetext, "Please help me find the meaning of . Thanks.") == 0) - //Draw_StretchPic(335, 337, awoo, 17, 17); + Draw_ColoredStringCentered(342, lodinglinetext, 1, 1, 1, 1, 1.25f); + #endif // VITA + } } diff --git a/source/menu.c b/source/menu.c index 1aeca07..ddcbd09 100644 --- a/source/menu.c +++ b/source/menu.c @@ -214,7 +214,7 @@ int menu_offset_y; #define MENU_INITVARS() int y = 0; menu_offset_y = y + 70; #define DRAW_HEADER(title) Draw_ColoredStringScale(10, y + 10, title, 1, 1, 1, 1, 4.0f); -#define DRAW_VERSIONSTRING() Draw_ColoredStringScale(vid.width - (strlen(game_build_date) * 16), y + 5, game_build_date, 1, 1, 1, 1, 2.0f); +#define DRAW_VERSIONSTRING() Draw_ColoredStringScale(vid.width - getTextWidth(game_build_date, 2), y + 5, game_build_date, 1, 1, 1, 1, 2.0f); #define DRAW_MENUOPTION(id, txt, cursor, divider) { \ menu_offset_y += OFFSET_SPACING; \ if (cursor == id) \ @@ -243,9 +243,9 @@ int menu_offset_y; else \ Draw_ColoredStringScale(10, 500, "Back", 1, 1, 1, 1, 2.0f); \ } -#define DRAW_MAPTHUMB(img) Draw_StretchPic(x_map_info_disp + 252, y + 68, img, 450, 255); -#define DRAW_MAPDESC(id, txt) Draw_ColoredStringScale(x_map_info_disp + 217, y + 329 + (18 * id), txt, 1, 1, 1, 1, 2.0f); -#define DRAW_MAPAUTHOR(id, txt) Draw_ColoredStringScale(x_map_info_disp + 217, y + 329 + (18 * id), txt, 1, 1, 0, 1, 2.0f); +#define DRAW_MAPTHUMB(img) Draw_StretchPic(x_map_info_disp + 245, y + 68, img, 450, 255); +#define DRAW_MAPDESC(id, txt) Draw_ColoredStringScale(x_map_info_disp + 245, y + 329 + (18 * id), txt, 1, 1, 1, 1, 2.0f); +#define DRAW_MAPAUTHOR(id, txt) Draw_ColoredStringScale(x_map_info_disp + 245, y + 329 + (18 * id), txt, 1, 1, 0, 1, 2.0f); #define DRAW_CREDITLINE(id, txt) Draw_ColoredStringScale(10, menu_offset_y + (OFFSET_SPACING * id), txt, 1, 1, 1, 1, 2.0f); #define DRAW_SETTINGSVALUE(id, txt) Draw_ColoredStringScale(400, y + 70 + (OFFSET_SPACING * (id + 1)), txt, 1, 1, 1, 1, 2.0f); #define DRAW_SLIDER(id, r) M_DrawSlider(408, y + 70 + (OFFSET_SPACING * (id + 1)), r, 2.0f); @@ -256,7 +256,7 @@ int menu_offset_y; #define MENU_INITVARS() int y = vid.height * 0.5; menu_offset_y = y + 55; #define DRAW_HEADER(title) Draw_ColoredStringScale(10, y + 10, title, 1, 1, 1, 1, 3.0f); -#define DRAW_VERSIONSTRING() Draw_ColoredString(635 - (strlen(game_build_date) * 8), y + 10, game_build_date, 1, 1, 1, 1); +#define DRAW_VERSIONSTRING() Draw_ColoredStringScale(635 - getTextWidth(game_build_date, 1), y + 10, game_build_date, 1, 1, 1, 1, 1.0f); #define DRAW_MENUOPTION(id, txt, cursor, divider) { \ menu_offset_y += OFFSET_SPACING; \ if (cursor == id) \ @@ -285,8 +285,8 @@ int menu_offset_y; else \ Draw_ColoredStringScale(10, y + 335, "Back", 1, 1, 1, 1, 1.5f); \ } -#define DRAW_MAPTHUMB(img) Draw_StretchPic(x_map_info_disp + 290, y + 45, img, 300, 170); -#define DRAW_MAPDESC(id, txt) Draw_ColoredStringScale(x_map_info_disp + 280, y + 218 + (15 * id), txt, 1, 1, 1, 1, 1.25f); +#define DRAW_MAPTHUMB(img) Draw_StretchPic(x_map_info_disp + 280, y + 45, img, 280, 160); +#define DRAW_MAPDESC(id, txt) Draw_ColoredStringScale(x_map_info_disp + 280, y + 218 + (15 * id), txt, 1, 1, 1, 1, 1.45f); #define DRAW_MAPAUTHOR(id, txt) Draw_ColoredStringScale(x_map_info_disp + 280, y + 218 + (15 * id), txt, 1, 1, 0, 1, 1.25f); #define DRAW_CREDITLINE(id, txt) Draw_ColoredStringScale(10, menu_offset_y + ((OFFSET_SPACING - 2) * id), txt, 1, 1, 1, 1, 1.25f); #define DRAW_SETTINGSVALUE(id, txt) Draw_ColoredStringScale(300, y + 55 + (OFFSET_SPACING * (id + 1)), txt, 1, 1, 1, 1, 1.5f); @@ -667,24 +667,24 @@ void M_Main_Draw (void) #ifdef VITA Draw_SubPic(915, 510, 26, 26, 32, 0, 64, 32, social_badges); // YouTube - Draw_ColoredStringScale(840, 510 + 6, "@nzpteam", 1, 1, 0, 1, 1.0f); + Draw_ColoredStringScale(848, 510 + 6, "@nzpteam", 1, 1, 0, 1, 1.0f); Draw_SubPic(915, 510 - 26 - 5, 26, 26, 0, 32, 32, 64, social_badges); // Twitter Draw_ColoredStringScale(840, 510 - 25, "/NZPTeam", 1, 1, 0, 1, 1.0f); Draw_SubPic(915, 510 - 52 - 10, 26, 26, 32, 32, 64, 64, social_badges); // Patreon - Draw_ColoredStringScale(792, 510 - 52 - 3, "/cypressimplex", 1, 1, 0, 1, 1.0f); + Draw_ColoredStringScale(818, 510 - 52 - 3, "/cypressimplex", 1, 1, 0, 1, 1.0f); #else Draw_SubPic(610, y + 330, 22, 22, 32, 0, 64, 32, social_badges); // YouTube - Draw_ColoredStringScale(542, y + 337, "@nzpteam", 1, 1, 0, 1, 1.0f); + Draw_ColoredStringScale(548, y + 337, "@nzpteam", 1, 1, 0, 1, 1.0f); Draw_SubPic(610, y + 302, 22, 22, 0, 32, 32, 64, social_badges); // Twitter Draw_ColoredStringScale(542, y + 309, "/NZPTeam", 1, 1, 0, 1, 1.0f); Draw_SubPic(610, y + 274, 22, 22, 32, 32, 64, 64, social_badges); // Patreon - Draw_ColoredStringScale(494, y + 280, "/cypressimplex", 1, 1, 0, 1, 1.0f); + Draw_ColoredStringScale(520, y + 280, "/cypressimplex", 1, 1, 0, 1, 1.0f); #endif // VITA @@ -941,9 +941,6 @@ void M_SinglePlayer_Draw (void) // Fill black to make everything easier to see Draw_FillByColor(0, 0, 1280, 720, 0, 0, 0, 0.4); - // Version String - DRAW_VERSIONSTRING(); - // Header DRAW_HEADER("SOLO"); @@ -1388,9 +1385,6 @@ void M_Achievement_Draw (void) // Fill black to make everything easier to see Draw_FillByColor(0, 0, 960, 544, 0, 0, 0, 1); - // Version String - //DRAW_VERSIONSTRING(); - if (!m_achievement_selected) { Draw_FillByColor(15, 8, 225, 12, 204, 0, 0, 150); @@ -1557,9 +1551,6 @@ void M_Menu_Maps_Draw (void) // Fill black to make everything easier to see Draw_FillByColor(0, 0, 1280, 720, 0, 0, 0, 0.4); - // Version String - DRAW_VERSIONSTRING(); - // Header DRAW_HEADER("CUSTOM MAPS"); @@ -2510,9 +2501,6 @@ void M_Options_Draw (void) // Fill black to make everything easier to see Draw_FillByColor(0, 0, 1280, 720, 0, 0, 0, 0.4); - // Version String - DRAW_VERSIONSTRING(); - // Header DRAW_HEADER("SETTINGS"); @@ -3378,13 +3366,13 @@ void M_Credits_Draw (void) DRAW_CREDITLINE(11, "Blubswillrule, Biodude, Cypress, Marty P."); DRAW_CREDITLINE(12, ""); DRAW_CREDITLINE(13, "Special Thanks:"); - DRAW_CREDITLINE(14, "- Spike, Eukara: FTEQW"); - DRAW_CREDITLINE(15, "- Shpuld: CleanQC4FTE"); - DRAW_CREDITLINE(16, "- Crow_Bar, st1x51: dQuake(plus)"); - DRAW_CREDITLINE(17, "- fgsfdsfgs: Quakespasm-NX"); - DRAW_CREDITLINE(18, "- Rinnegatamante: Initial VITA Port, VITA Auto-Updater"); - DRAW_CREDITLINE(19, "- Azenn: GFX Help"); - DRAW_CREDITLINE(20, "- BCDeshiG: Extensive Testing"); + DRAW_CREDITLINE(14, "- Spike, Eukara: [FTEQW]"); + DRAW_CREDITLINE(15, "- Shpuld: [CleanQC4FTE]"); + DRAW_CREDITLINE(16, "- Crow_Bar, st1x51: [dQuake(plus)]"); + DRAW_CREDITLINE(17, "- fgsfdsfgs: [Quakespasm-NX]"); + DRAW_CREDITLINE(18, "- Rinnegatamante: [Initial VITA Port, VITA Auto-Updater]"); + DRAW_CREDITLINE(19, "- Azenn: [GFX Help]"); + DRAW_CREDITLINE(20, "- BCDeshiG: [Extensive Testing]"); DRAW_BACKBUTTON(0, 0); }