Finished nametags

This commit is contained in:
Sally Coolatta 2020-06-03 23:29:43 -04:00
parent 390191c85a
commit a3ec4f22a1
5 changed files with 225 additions and 171 deletions

View file

@ -54,6 +54,7 @@
#include "s_sound.h" // song credits
#include "k_kart.h"
#include "k_color.h"
// coords are scaled
#define HU_INPUTX 0
@ -739,168 +740,27 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
const char *prefix = "", *cstart = "", *cend = "", *adminchar = "\x82~\x83", *remotechar = "\x82@\x83", *fmt2, *textcolor = "\x80";
char *tempchar = NULL;
// player is a spectator?
if (players[playernum].spectator)
if (players[playernum].spectator)
{
cstart = "\x86"; // grey name
textcolor = "\x86";
// grey text
cstart = textcolor = "\x86";
}
else if (target == -1) // say team
{
if (players[playernum].ctfteam == 1) // red
if (players[playernum].ctfteam == 1)
{
cstart = "\x85";
textcolor = "\x85";
// red text
cstart = textcolor = "\x85";
}
else // blue
else
{
cstart = "\x84";
textcolor = "\x84";
// blue text
cstart = textcolor = "\x84";
}
}
else
{
const UINT8 color = players[playernum].skincolor;
cstart = "\x83";
switch (color)
{
case SKINCOLOR_WHITE:
case SKINCOLOR_SILVER:
case SKINCOLOR_SLATE:
cstart = "\x80"; // White
break;
case SKINCOLOR_GREY:
case SKINCOLOR_NICKEL:
case SKINCOLOR_BLACK:
case SKINCOLOR_SKUNK:
case SKINCOLOR_PLATINUM:
case SKINCOLOR_JET:
cstart = "\x86"; // V_GRAYMAP
break;
case SKINCOLOR_SEPIA:
case SKINCOLOR_BEIGE:
case SKINCOLOR_CARAMEL:
case SKINCOLOR_PEACH:
case SKINCOLOR_BROWN:
case SKINCOLOR_LEATHER:
case SKINCOLOR_RUST:
case SKINCOLOR_WRISTWATCH:
cstart = "\x8e"; // V_BROWNMAP
break;
case SKINCOLOR_FAIRY:
case SKINCOLOR_PINK:
case SKINCOLOR_ROSE:
case SKINCOLOR_LEMONADE:
case SKINCOLOR_LILAC:
case SKINCOLOR_BLOSSOM:
case SKINCOLOR_TAFFY:
cstart = "\x8d"; // V_PINKMAP
break;
case SKINCOLOR_CINNAMON:
case SKINCOLOR_RUBY:
case SKINCOLOR_RASPBERRY:
case SKINCOLOR_RED:
case SKINCOLOR_CRIMSON:
case SKINCOLOR_MAROON:
case SKINCOLOR_SCARLET:
case SKINCOLOR_KETCHUP:
cstart = "\x85"; // V_REDMAP
break;
case SKINCOLOR_DAWN:
case SKINCOLOR_SUNSLAM:
case SKINCOLOR_CREAMSICLE:
case SKINCOLOR_ORANGE:
case SKINCOLOR_ROSEWOOD:
case SKINCOLOR_TANGERINE:
cstart = "\x87"; // V_ORANGEMAP
break;
case SKINCOLOR_TAN:
case SKINCOLOR_CREAM:
cstart = "\x8f"; // V_TANMAP
break;
case SKINCOLOR_GOLD:
case SKINCOLOR_ROYAL:
case SKINCOLOR_BRONZE:
case SKINCOLOR_COPPER:
case SKINCOLOR_THUNDER:
cstart = "\x8A"; // V_GOLDMAP
break;
case SKINCOLOR_POPCORN:
case SKINCOLOR_YELLOW:
case SKINCOLOR_MUSTARD:
case SKINCOLOR_BANANA:
case SKINCOLOR_OLIVE:
case SKINCOLOR_CROCODILE:
cstart = "\x82"; // V_YELLOWMAP
break;
case SKINCOLOR_ARTICHOKE:
case SKINCOLOR_PERIDOT:
case SKINCOLOR_VOMIT:
case SKINCOLOR_GARDEN:
case SKINCOLOR_LIME:
case SKINCOLOR_HANDHELD:
case SKINCOLOR_TEA:
case SKINCOLOR_PISTACHIO:
case SKINCOLOR_MOSS:
case SKINCOLOR_CAMOUFLAGE:
case SKINCOLOR_MINT:
case SKINCOLOR_GREEN:
case SKINCOLOR_PINETREE:
case SKINCOLOR_TURTLE:
case SKINCOLOR_SWAMP:
case SKINCOLOR_DREAM:
case SKINCOLOR_PLAGUE:
case SKINCOLOR_EMERALD:
case SKINCOLOR_ALGAE:
cstart = "\x83"; // V_GREENMAP
break;
case SKINCOLOR_AQUAMARINE:
case SKINCOLOR_TURQUOISE:
case SKINCOLOR_TEAL:
cstart = "\x8b"; // V_AQUAMAP
break;
case SKINCOLOR_PIGEON:
case SKINCOLOR_ROBIN:
case SKINCOLOR_CYAN:
case SKINCOLOR_JAWZ:
case SKINCOLOR_CERULEAN:
case SKINCOLOR_NAVY:
case SKINCOLOR_SAPPHIRE:
cstart = "\x88"; // V_SKYMAP
break;
case SKINCOLOR_STEEL:
case SKINCOLOR_ULTRAMARINE:
case SKINCOLOR_PERIWINKLE:
case SKINCOLOR_BLUE:
case SKINCOLOR_MIDNIGHT:
case SKINCOLOR_BLUEBERRY:
case SKINCOLOR_NOVA:
cstart = "\x84"; // V_BLUEMAP
break;
case SKINCOLOR_THISTLE:
case SKINCOLOR_PURPLE:
case SKINCOLOR_PASTEL:
cstart = "\x81"; // V_PURPLEMAP
break;
case SKINCOLOR_MAGENTA:
case SKINCOLOR_FUCHSIA:
case SKINCOLOR_MOONSET:
case SKINCOLOR_VIOLET:
cstart = "\x8c"; // V_MAGENTAMAP
break;
case SKINCOLOR_DUSK:
case SKINCOLOR_TOXIC:
case SKINCOLOR_MAUVE:
case SKINCOLOR_LAVENDER:
case SKINCOLOR_BYZANTIUM:
case SKINCOLOR_POMEGRANATE:
cstart = "\x89"; // V_LAVENDERMAP
break;
default:
break;
}
cstart = "\x80" + (K_SkincolorToTextColor(players[playernum].skincolor) >> V_CHARCOLORSHIFT);
}
prefix = cstart;
@ -910,6 +770,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
tempchar = (char *)Z_Calloc(strlen(cstart) + strlen(adminchar) + 1, PU_STATIC, NULL);
else if (IsPlayerAdmin(playernum))
tempchar = (char *)Z_Calloc(strlen(cstart) + strlen(remotechar) + 1, PU_STATIC, NULL);
if (tempchar)
{
if (playernum == serverplayer)

View file

@ -380,12 +380,160 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = {
{ 0, 0, 96, 96, 97, 98, 98, 99, 81, 81, 69, 71, 73, 75, 77, 79}, // SKINCOLOR_CSUPER5
};
/*--------------------------------------------------
INT32 K_SkincolorToTextColor(UINT8 skincolor)
See header file for description.
--------------------------------------------------*/
INT32 K_SkincolorToTextColor(UINT8 skincolor)
{
INT32 textcolor = 0;
switch (skincolor)
{
default: // default to white?
case SKINCOLOR_WHITE:
case SKINCOLOR_SILVER:
case SKINCOLOR_SLATE:
textcolor = 0; // No color is white
break;
case SKINCOLOR_GREY:
case SKINCOLOR_NICKEL:
case SKINCOLOR_BLACK:
case SKINCOLOR_SKUNK:
case SKINCOLOR_PLATINUM:
case SKINCOLOR_JET:
textcolor = V_GRAYMAP;
break;
case SKINCOLOR_SEPIA:
case SKINCOLOR_BEIGE:
case SKINCOLOR_CARAMEL:
case SKINCOLOR_PEACH:
case SKINCOLOR_BROWN:
case SKINCOLOR_LEATHER:
case SKINCOLOR_RUST:
case SKINCOLOR_WRISTWATCH:
textcolor = V_BROWNMAP;
break;
case SKINCOLOR_FAIRY:
case SKINCOLOR_PINK:
case SKINCOLOR_ROSE:
case SKINCOLOR_LEMONADE:
case SKINCOLOR_LILAC:
case SKINCOLOR_BLOSSOM:
case SKINCOLOR_TAFFY:
textcolor = V_PINKMAP;
break;
case SKINCOLOR_CINNAMON:
case SKINCOLOR_RUBY:
case SKINCOLOR_RASPBERRY:
case SKINCOLOR_RED:
case SKINCOLOR_CRIMSON:
case SKINCOLOR_MAROON:
case SKINCOLOR_SCARLET:
case SKINCOLOR_KETCHUP:
textcolor = V_REDMAP;
break;
case SKINCOLOR_DAWN:
case SKINCOLOR_SUNSLAM:
case SKINCOLOR_CREAMSICLE:
case SKINCOLOR_ORANGE:
case SKINCOLOR_ROSEWOOD:
case SKINCOLOR_TANGERINE:
textcolor = V_ORANGEMAP;
break;
case SKINCOLOR_TAN:
case SKINCOLOR_CREAM:
textcolor = V_TANMAP;
break;
case SKINCOLOR_GOLD:
case SKINCOLOR_ROYAL:
case SKINCOLOR_BRONZE:
case SKINCOLOR_COPPER:
case SKINCOLOR_THUNDER:
textcolor = V_GOLDMAP;
break;
case SKINCOLOR_POPCORN:
case SKINCOLOR_YELLOW:
case SKINCOLOR_MUSTARD:
case SKINCOLOR_BANANA:
case SKINCOLOR_OLIVE:
case SKINCOLOR_CROCODILE:
textcolor = V_YELLOWMAP;
break;
case SKINCOLOR_ARTICHOKE:
case SKINCOLOR_PERIDOT:
case SKINCOLOR_VOMIT:
case SKINCOLOR_GARDEN:
case SKINCOLOR_LIME:
case SKINCOLOR_HANDHELD:
case SKINCOLOR_TEA:
case SKINCOLOR_PISTACHIO:
case SKINCOLOR_MOSS:
case SKINCOLOR_CAMOUFLAGE:
case SKINCOLOR_MINT:
case SKINCOLOR_GREEN:
case SKINCOLOR_PINETREE:
case SKINCOLOR_TURTLE:
case SKINCOLOR_SWAMP:
case SKINCOLOR_DREAM:
case SKINCOLOR_PLAGUE:
case SKINCOLOR_EMERALD:
case SKINCOLOR_ALGAE:
textcolor = V_GREENMAP;
break;
case SKINCOLOR_AQUAMARINE:
case SKINCOLOR_TURQUOISE:
case SKINCOLOR_TEAL:
textcolor = V_AQUAMAP;
break;
case SKINCOLOR_PIGEON:
case SKINCOLOR_ROBIN:
case SKINCOLOR_CYAN:
case SKINCOLOR_JAWZ:
case SKINCOLOR_CERULEAN:
case SKINCOLOR_NAVY:
case SKINCOLOR_SAPPHIRE:
textcolor = V_SKYMAP;
break;
case SKINCOLOR_STEEL:
case SKINCOLOR_ULTRAMARINE:
case SKINCOLOR_PERIWINKLE:
case SKINCOLOR_BLUE:
case SKINCOLOR_MIDNIGHT:
case SKINCOLOR_BLUEBERRY:
case SKINCOLOR_NOVA:
textcolor = V_BLUEMAP;
break;
case SKINCOLOR_THISTLE:
case SKINCOLOR_PURPLE:
case SKINCOLOR_PASTEL:
textcolor = V_PURPLEMAP;
break;
case SKINCOLOR_MAGENTA:
case SKINCOLOR_FUCHSIA:
case SKINCOLOR_MOONSET:
case SKINCOLOR_VIOLET:
textcolor = V_MAGENTAMAP;
break;
case SKINCOLOR_DUSK:
case SKINCOLOR_TOXIC:
case SKINCOLOR_MAUVE:
case SKINCOLOR_LAVENDER:
case SKINCOLOR_BYZANTIUM:
case SKINCOLOR_POMEGRANATE:
textcolor = V_LAVENDERMAP;
break;
}
return textcolor;
}
/*--------------------------------------------------
UINT8 K_ColorRelativeLuminance(UINT8 r, UINT8 g, UINT8 b)
See header file for description.
--------------------------------------------------*/
UINT8 K_ColorRelativeLuminance(UINT8 r, UINT8 g, UINT8 b)
{
UINT32 redweight = 1063 * r;
@ -400,7 +548,6 @@ UINT8 K_ColorRelativeLuminance(UINT8 r, UINT8 g, UINT8 b)
See header file for description.
--------------------------------------------------*/
void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor)
{
INT32 i;
@ -444,14 +591,11 @@ void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor)
}
}
/** \brief Generates a translation colormap for Kart, to replace R_GenerateTranslationColormap in r_draw.c
/*--------------------------------------------------
void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color)
\param dest_colormap colormap to populate
\param skinnum number of skin, TC_DEFAULT or TC_BOSS
\param color translation color
\return void
*/
See header file for description.
--------------------------------------------------*/
void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color)
{
INT32 i;
@ -505,12 +649,11 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color)
}
}
/** \brief Pulls kart color by name, to replace R_GetColorByName in r_draw.c
/*--------------------------------------------------
UINT8 K_GetKartColorByName(const char *name)
\param name color name
\return 0
*/
See header file for description.
--------------------------------------------------*/
UINT8 K_GetKartColorByName(const char *name)
{
UINT8 color = (UINT8)atoi(name);

View file

@ -23,6 +23,21 @@ extern UINT8 colortranslations[MAXTRANSLATIONS][16];
extern const char *KartColor_Names[MAXSKINCOLORS];
extern const UINT8 KartColor_Opposite[MAXSKINCOLORS*2];
/*--------------------------------------------------
INT32 K_SkincolorToTextColor(UINT8 skincolor);
Gives you the "text" color (V_ constants) from a skincolor (SKINCOLOR_ constants).
Used primarily by the chat system.
Input Arguments:-
skincolor - SKINCOLOR_ constant
Return:-
V_ constant for font coloring
--------------------------------------------------*/
INT32 K_SkincolorToTextColor(UINT8 skincolor);
/*--------------------------------------------------
UINT8 K_ColorRelativeLuminance(UINT8 r, UINT8 g, UINT8 b);

View file

@ -10176,7 +10176,7 @@ static void K_drawKartPlayerCheck(void)
static void K_drawKartNameTags(void)
{
const fixed_t maxdistance = 4096*mapobjectscale;
const fixed_t maxdistance = 8192*mapobjectscale;
camera_t *thiscam;
vertex_t c;
UINT8 cnum = 0;
@ -10247,7 +10247,7 @@ static void K_drawKartNameTags(void)
}
}
if (j < r_splitscreen)
if (j <= r_splitscreen)
{
// Is a player that's being shown on this computer
continue;
@ -10286,14 +10286,46 @@ static void K_drawKartNameTags(void)
V_DrawFixedPatch(x, y, FRACUNIT, V_HUDTRANS, kp_rival[blink], NULL);
}
}
else
else if (netgame)
{
if ((ntplayer->kartstuff[k_position] >= stplyr->kartstuff[k_position]-1)
&& (ntplayer->kartstuff[k_position] <= stplyr->kartstuff[k_position]+1))
&& (ntplayer->kartstuff[k_position] <= stplyr->kartstuff[k_position]+2))
{
//INT32 namelen = V_ThinStringWidth(str, V_6WIDTHSPACE);
INT32 namelen = V_ThinStringWidth(player_names[i], V_6WIDTHSPACE|V_ALLOWLOWERCASE);
INT32 clr = K_SkincolorToTextColor(ntplayer->skincolor);
UINT8 *colormap = V_GetStringColormap(clr);
INT32 barx = 0, bary = 0, barw = 0;
V_DrawFixedPatch(x, y, FRACUNIT, V_HUDTRANS, kp_nametagstem, NULL);
// Since there's no "V_DrawFixedFill", and I don't feel like making it,
// fuck it, we're gonna just V_NOSCALESTART hack it
barw = (namelen * vid.dupx);
barx = (x * vid.dupx) / FRACUNIT;
bary = (y * vid.dupy) / FRACUNIT;
barx += (6 * vid.dupx);
bary -= (16 * vid.dupx);
// Center it if necessary
if (vid.width != BASEVIDWIDTH * vid.dupx)
{
barx += (vid.width - (BASEVIDWIDTH * vid.dupx)) / 2;
}
if (vid.height != BASEVIDHEIGHT * vid.dupy)
{
bary += (vid.height - (BASEVIDHEIGHT * vid.dupy)) / 2;
}
V_DrawFill(barx, bary, barw, (3 * vid.dupy), colormap[31]|V_NOSCALESTART);
V_DrawFill(barx, bary + vid.dupy, barw, vid.dupy, colormap[0]|V_NOSCALESTART);
// END DRAWFILL DUMBNESS
// Draw the stem
V_DrawFixedPatch(x, y, FRACUNIT, 0, kp_nametagstem, colormap);
// Draw the name itself
V_DrawThinStringAtFixed(x + (5*FRACUNIT), y - (26*FRACUNIT), V_6WIDTHSPACE|V_ALLOWLOWERCASE|clr, player_names[i]);
}
}
}

View file

@ -225,6 +225,9 @@ void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *st
#define V_DrawStringAtFixed( x,y,option,string ) \
V__DrawOneScaleString (x,y,FRACUNIT,option,HU_FONT,string)
#define V_DrawThinStringAtFixed( x,y,option,string ) \
V__DrawOneScaleString (x,y,FRACUNIT,option,TINY_FONT,string)
// Draw tall nums, used for menu, HUD, intermission
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num);
void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits);