diff --git a/src/d_main.c b/src/d_main.c index 3353651ad..43bceeca0 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1070,6 +1070,7 @@ static boolean AddIWAD(void) } } +// extra graphic patches for saturn specific thingies boolean found_extra_kart; boolean found_extra2_kart; @@ -1077,8 +1078,9 @@ boolean snw_speedo; // snowy speedometer check boolean clr_hud; // colour hud check boolean big_lap; // bigger lap counter boolean big_lap_color; // bigger lap counter but colour -boolean kartzspeedo; // kartZ speedometer -boolean statdp; // New stat +boolean kartzspeedo; // kartZ speedo +boolean statdp; // stat display for extended player setup +boolean nametaggfx; // Nametag stuffs static void IdentifyVersion(void) { @@ -1468,6 +1470,10 @@ void D_SRB2Main(void) if (W_CheckMultipleLumps("K_STATNB", "K_STATN1", "K_STATN2", "K_STATN3", "K_STATN4", \ "K_STATN5", "K_STATN6", NULL)) statdp = true; + + // Nametag stuffs + if (W_CheckMultipleLumps("NTLINE", "NTLINEV", "NTSP", "NTWH", NULL)) + nametaggfx = true; } // diff --git a/src/d_main.h b/src/d_main.h index 4214e06a4..909c1b7fb 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -31,9 +31,10 @@ extern boolean found_extra2_kart; // for use in k_kart.c extern boolean snw_speedo; // snowy speedometer check extern boolean clr_hud; // colour hud check extern boolean big_lap; // bigger lap counter -extern boolean big_lap_color; //bigger lap counter but colour -extern boolean kartzspeedo; //kartZ speedo -extern boolean statdp; //stat display for extended player setup +extern boolean big_lap_color; // bigger lap counter but colour +extern boolean kartzspeedo; // kartZ speedo +extern boolean statdp; // stat display for extended player setup +extern boolean nametaggfx; // Nametag stuffs extern boolean autoloading; extern boolean autoloaded; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9eec0ce9b..42e6f8c53 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -505,6 +505,34 @@ consvar_t cv_mute = {"mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_OnChange, consvar_t cv_sleep = {"cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL, -1, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t nametagtrans_cons_t[] = { + {0, "Never"}, {1, "Far only"}, {2, "Dynamic"}, {3, "Always"}, {4, "HUD Trans."}, {0, NULL}}; +/*static CV_PossibleValue_t nametagscaling_cons_t[] = { + {0, "MIN"}, {320, "MAX"}, {0, NULL}};*/ +static CV_PossibleValue_t nametagdistance_cons_t[] = { + {0, "MIN"}, {640, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t nametagmaxplayer_cons_t[] = { + {1, "MIN"}, {MAXPLAYERS, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t nametagsize_cons_t[] = { + {0, "Off"}, {1, "Small"}, {2, "Minimal"}, {0, NULL}}; +static CV_PossibleValue_t nametagrestat_cons_t[] = { + {0, "Off"}, {1, "Restat"}, {2, "Always"}, {0, NULL}}; + +consvar_t cv_nametag = {"kartnametag", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagtrans = {"kartnametagtransparency", "Dynamic", CV_SAVE, nametagtrans_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagfacerank = {"kartnametagfacerank", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagrestat = {"kartnametagrestat", "Restat", CV_SAVE, nametagrestat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagdist = {"kartnametagdist", "320", CV_SAVE, nametagdistance_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagmaxplayers = {"kartnametagmaxplayers", "3", CV_SAVE, nametagmaxplayer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagmaxlenght = {"kartnametagmaxlenght", "12", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +//consvar_t cv_nametagscaling = {"nametagscaling", "160", CV_SAVE, nametagscaling_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showownnametag = {"kartnametagshowown", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_smallnametags = {"kartnametagsmall", "Off", CV_SAVE, nametagsize_cons_t, Nametag_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametaghop = {"kartnametaghop", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nametagscore = {"kartnametagscore", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shownametagfinish = {"kartshownametagfinished", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t skinselectspin_cons_t[] = { {0, "Off"}, {1, "Slow"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"}, {8, "8"}, {9, "9"}, {10, "Fast"}, {SKINSELECTSPIN_PAIN, "Pain"}, {0, NULL}}; consvar_t cv_skinselectspin = {"skinselectspin", "5", CV_SAVE, skinselectspin_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1070,6 +1098,21 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_scr_height); CV_RegisterVar(&cv_soundtest); + + CV_RegisterVar(&cv_nametag); + CV_RegisterVar(&cv_nametagtrans); + CV_RegisterVar(&cv_nametagfacerank); + CV_RegisterVar(&cv_nametagmaxplayers); + CV_RegisterVar(&cv_nametagmaxlenght); + //CV_RegisterVar(&cv_nametagscaling); + CV_RegisterVar(&cv_nametagdist); + CV_RegisterVar(&cv_showownnametag); + CV_RegisterVar(&cv_smallnametags); + CV_RegisterVar(&cv_nametagrestat); + CV_RegisterVar(&cv_nametaghop); + CV_RegisterVar(&cv_nametagscore); + CV_RegisterVar(&cv_shownametagfinish); + CV_RegisterVar(&cv_shownametagspectator); CV_RegisterVar(&cv_perfstats); CV_RegisterVar(&cv_ps_thinkframe_page); @@ -1087,8 +1130,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_speed); CV_RegisterVar(&cv_opflags); CV_RegisterVar(&cv_mapthingnum); -// CV_RegisterVar(&cv_grid); -// CV_RegisterVar(&cv_snapto); + //CV_RegisterVar(&cv_grid); + //CV_RegisterVar(&cv_snapto); // add cheat commands COM_AddCommand("noclip", Command_CheatNoClip_f); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index ab79e5901..ff0cd0db9 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -173,6 +173,21 @@ extern consvar_t cv_skipmapcheck; extern consvar_t cv_sleep; +extern consvar_t cv_nametag; +extern consvar_t cv_nametagtrans; +extern consvar_t cv_nametagfacerank; +extern consvar_t cv_nametagmaxplayers; +extern consvar_t cv_nametagmaxlenght; +//extern consvar_t cv_nametagscaling; +extern consvar_t cv_nametagdist; +extern consvar_t cv_showownnametag; +extern consvar_t cv_smallnametags; +extern consvar_t cv_nametagrestat; +extern consvar_t cv_nametaghop; +extern consvar_t cv_nametagscore; +extern consvar_t cv_shownametagfinish; +extern consvar_t cv_shownametagspectator; + #define SKINSELECTSPIN_PAIN 25 extern consvar_t cv_skinselectspin; diff --git a/src/k_kart.c b/src/k_kart.c index 6befed280..6f583e689 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5,16 +5,27 @@ /// All of the SRB2kart-unique stuff. #include "doomdef.h" +#include "doomstat.h" +#include "doomtype.h" +#include "command.h" +#include "d_netcmd.h" +#include "d_player.h" #include "hu_stuff.h" #include "g_game.h" +#include "m_fixed.h" #include "m_random.h" #include "m_menu.h" // ffdhidshfuisduifigergho9igj89dgodhfih AAAAAAAAAA #include "p_local.h" #include "p_slopes.h" +#include "r_defs.h" #include "r_draw.h" #include "r_local.h" +#include "r_state.h" +#include "r_things.h" #include "s_sound.h" +#include "screen.h" #include "st_stuff.h" +#include "tables.h" #include "v_video.h" #include "z_zone.h" #include "m_misc.h" @@ -25,6 +36,12 @@ #include "lua_hook.h" // For MobjDamage and ShouldDamage #include "d_main.h" // found_extra_kart +#include "i_video.h" + +#ifdef HWRENDER +#include "hardware/hw_main.h" +#endif + // Hud offset cvars #define IMPL_HUD_OFFSET_X(name)\ consvar_t cv_##name##_xoffset = {"hud_" #name "_xoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -6989,6 +7006,11 @@ static patch_t *kp_lapanim_number[10][3]; static patch_t *kp_lapanim_emblem[2]; static patch_t *kp_lapanim_hand[3]; +static patch_t *nametagpic; +static patch_t *nametagline; +static patch_t *nametagspeed; +static patch_t *nametagweight; + static patch_t *kp_yougotem; static patch_t *skp_smallsticker; @@ -7020,7 +7042,7 @@ void K_LoadKartHUDGraphics(void) kp_lapstickerbig2 = W_CachePatchName("K_STLA2B", PU_HUDGFX); } - //Colourized hud + // Colourized hud if (clr_hud) { kp_timestickerclr = W_CachePatchName("K_SCTIME", PU_HUDGFX); @@ -7046,7 +7068,7 @@ void K_LoadKartHUDGraphics(void) skp_smallstickerclr = W_CachePatchName("SC_SMSTC", PU_HUDGFX); } - //KartZ speedo + // KartZ speedo if (kartzspeedo) { kp_kartzspeedo[0] = W_CachePatchName("K_KZSP1", PU_HUDGFX); @@ -7075,7 +7097,17 @@ void K_LoadKartHUDGraphics(void) kp_kartzspeedo[23] = W_CachePatchName("K_KZSP24", PU_HUDGFX); kp_kartzspeedo[24] = W_CachePatchName("K_KZSP25", PU_HUDGFX); } - + + // Nametags + if (nametaggfx) + { + + nametagpic = W_CachePatchName("NTLINE", PU_HUDGFX); + nametagline = W_CachePatchName("NTLINEV", PU_HUDGFX); + nametagspeed = W_CachePatchName("NTSP", PU_HUDGFX); + nametagweight = W_CachePatchName("NTWH", PU_HUDGFX); + } + // Starting countdown kp_startcountdown[0] = W_CachePatchName("K_CNT3A", PU_HUDGFX); kp_startcountdown[1] = W_CachePatchName("K_CNT2A", PU_HUDGFX); @@ -8828,6 +8860,389 @@ static void K_drawKartBumpersOrKarma(void) } } +// converts mobj coordinates into screen coordinates +// NOTE: use with V_NOSCALESTART! +// Code updated in Lua by GenericHeroGuy for libSG +// Badly ported to C by NepDisk and acutally made to work and fixed by Indev!(Thanks so much!) +// original code by Lat' +static void K_GetScreenCoords(vector2_t *vec, player_t *player, camera_t *came, mobj_t *target, fixed_t hofs, boolean dontclip) +{ + fixed_t camx, camy, camz; + angle_t camangle, camaiming; + fixed_t distfact; + fixed_t dist; + fixed_t xres; + fixed_t yres; + fixed_t fov; + fixed_t fovratio; + fixed_t offset; + boolean srcflip; + boolean targflip; + fixed_t y; + fixed_t x; + + // In case of early return we can check if those are negative + vec->x = -1; + vec->y = -1; + + // this should never happen but its also kart so ¯\_(ツ)_/¯ + if (!player || !target || !came) + return; + + if (player->awayviewtics) { + camx = player->awayviewmobj->x; + camy = player->awayviewmobj->y; + camz = player->awayviewmobj->z; + camangle = player->awayviewmobj->angle; + camaiming = player->awayviewaiming; + } + else if (came->chase) { + camx = came->x; + camy = came->y; + camz = came->z + (player->mo->eflags & MFE_VERTICALFLIP && came->height); + camangle = came->angle; + camaiming = came->aiming; + } + else { + camx = player->mo->x; + camy = player->mo->y; + camz = player->viewz; + camangle = player->mo->angle; + camaiming = player->aiming; + } + + xres = vid.width<<(FRACBITS-1); + yres = vid.height<<(FRACBITS-1); + fov = FixedDiv(xres, FINETANGENT(((FixedAngle(cv_fov.value/2)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095)); + + // X coordinate + // get difference between camangle and angle towards target + x = (INT32)camangle - (INT32)R_PointToAngle2(camx, camy, target->x, target->y); + + distfact = FINECOSINE((x>>ANGLETOFINESHIFT) & FINEMASK); + if (!distfact) distfact = 1; + + if (encoremode) + x = -x; + if (x < (fixed_t)ANGLE_270 || x > (fixed_t)ANGLE_90) + return; + + // flipping + targflip = target->eflags & MFE_VERTICALFLIP; + srcflip = player->pflags & PF_FLIPCAM && player->mo->eflags & MFE_VERTICALFLIP; + + // Y coordinate + // getting the angle difference here is a bit more involved... + // start by getting the height difference between the camera and target + y = camz - target->z - (targflip ? target->height/1.5 : 0); // for some reason needs to be divided by 1.5 idk + if (hofs) + y = y - (targflip ? -hofs : hofs); + + // then get the distance between camera and target + dist = R_PointToDist2(camx, camy, target->x, target->y); + +#ifdef HWRENDER + // NOW we can get the angle differnce + if (rendermode == render_opengl && cv_grshearing.value == 0) + { + angle_t yang = R_PointToAngle2(0, 0, dist, y); // not perspective + x = FixedMul(x, FINECOSINE((yang>>ANGLETOFINESHIFT) & FINEMASK)); // perspective + y = -camaiming - FixedDiv(yang, distfact); + + if (y < (fixed_t)ANGLE_270 || y > (fixed_t)ANGLE_90) // clip points behind the camera + return; + if (splitscreen == 1) // multiply by 1.25 for 2P splitscreen + y = y + (y/4) ; + if (srcflip) // flipcam + y = -y; + + y = FixedMul(FINETANGENT((((angle_t)(-y)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), fov) + yres; // project the angle to get our final Y coordinate + } + else +#endif + { + fovratio = FixedDiv(90*FRACUNIT, 180*FRACUNIT - FixedMul(cv_fov.value, 4*FRACUNIT/3)-FRACUNIT*-30); + + y = FixedDiv(y, FixedMul(dist, distfact)); + if (srcflip) + y = -y; // flipcam + if (y != INT32_MIN) // I_Error(): FixedDiv: divide by zero + y = FixedMul(FixedDiv(y, fovratio), xres) + yres; + //else print("NOPE!") + + offset = FixedMul(FINETANGENT(((camaiming+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), xres); + // this isn't fovtan... what am i even doing anymore + if (splitscreen == 1) + offset = 17*offset/10; + // OpenGL with software perspective is miscentered on non-16:10 resolutions +#ifdef HWRENDER + if (rendermode == render_opengl) + offset = FixedMul(offset, FixedDiv(104857, FixedDiv(xres, yres))); +#endif + // thanks fickle + offset = FixedDiv(offset, fovratio); + if (srcflip) + offset = -offset; // flipcam + y = y + offset; + } + + // project the angle to get our final X coordinate + x = FixedMul(FINETANGENT(((x+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), fov); + x = x + xres; + + // now clip in screen-space + if (!dontclip && (x < 0 || x > xres*2 || y < 0 || y > yres*2)) + return; + + // adjust coords for splitscreen + if (splitscreen == 1){ // 2P + y = y>>1; + if (splitindex) + y = y + yres; + } + if (splitscreen >= 2) { // 3P or 4P + x = x>>1; + y = y>>1; + if (splitindex & 1) + x = x + xres; + if (splitindex >= 2) + y = y + yres; + } + + vec->y = y; + vec->x = x; +} + +//Slighty fixed by Alug and further rewritten by NepDisk +//Decided to port and highly modify sunflower version for the main nametag drawing with additions by NepDisk. My previous one was broken anyway due to the changed screencoords and noscalestart +static void K_drawNameTags(void) +{ + UINT8 i,j; + INT32 trans = 0; + vector2_t pos = {0}; + fixed_t tagwidth; + fixed_t tagwidthsmall; + fixed_t namex,namey; + int dup = 0; + int tagcolor = 0; + int vflags = 0; + int flipped = 0; + int tagsdisplayed = 0; + char *tag; + patch_t *icon; + INT32 hudtransflag = V_LocalTransFlag(); + boolean flipcam; + + if (!stplyr->mo || (stplyr->spectator && !cv_shownametagspectator.value) || splitscreen || (stplyr->exiting && !cv_shownametagfinish.value)) + return; + + // True if currently viewed player is flipped and has flipcam on + flipcam = (stplyr->pflags & PF_FLIPCAM) && (stplyr->mo->eflags & MFE_VERTICALFLIP); + + for (i = 0; i < MAXPLAYERS; i++) + { + UINT8 *cm; + fixed_t distance = 0; + fixed_t maxdistance = (10*cv_nametagdist.value)* mapobjectscale; + flipped = 0; + fixed_t z; + + if (i > PLAYERSMASK) + continue; + if (!players[i].mo || P_MobjWasRemoved(players[i].mo) || players[i].spectator || !playeringame[i]) + continue; + if (i == displayplayers[0] && !cv_showownnametag.value && !(leveltime < 130)) + continue; + if (!(i == displayplayers[0]) && leveltime < starttime) + continue; + if (players[i].kartstuff[k_hyudorotimer]) // player is invisible + continue; + distance = R_PointToDist(players[i].mo->x, players[i].mo->y); + if (distance > maxdistance) + continue; + if (!P_CheckSight(stplyr->mo, players[i].mo)) + continue; + + switch (cv_nametagtrans.value) + { + case 0: + trans = 0; + break; + case 1: + if (distance > (maxdistance*3/4)) + trans = V_60TRANS; + else + trans = 0; + break; + case 2: + if (distance > (maxdistance*3/1)) + trans = V_90TRANS; + else if (distance > (maxdistance*3/2)) + trans = V_80TRANS; + else if (distance > (maxdistance*3/3)) + trans = V_60TRANS; + else if (distance > (maxdistance*3/4)) + trans = V_40TRANS; + else if (distance > (maxdistance*3/5)) + trans = V_20TRANS; + else + trans = 0; + break; + case 3: + trans = V_40TRANS; + break; + case 4: + trans = hudtransflag; + break; + default: + break; + } + + dup = vid.dupx; + + // If flipcam is on, other player is flipped relative to us when we have different + // verticalflip flag value. Otherwise, they are simply flipped when verticalflip flag says + // so + if (flipcam) + flipped = (players[i].mo->eflags & MFE_VERTICALFLIP) != (stplyr->mo->eflags & MFE_VERTICALFLIP); + else + flipped = players[i].mo->eflags & MFE_VERTICALFLIP; + + z = players[i].mo->height; + + //Saltyhop hehe + if (cv_saltyhop.value && cv_nametaghop.value) + z += players[i].mo->spriteyoffset; + + K_GetScreenCoords(&pos, stplyr, camera, players[i].mo, z, false); + + //Check for negative screencoords + if (pos.x == -1 || pos.y == -1) + continue; + + tagsdisplayed += 1; + + if (tagsdisplayed > cv_nametagmaxplayers.value) + break; + + namex = pos.x>>FRACBITS; + namey = pos.y>>FRACBITS; + + tag = va("%s%s ", HU_SkinColorToConsoleColor(players[i].mo->color),player_names[i]); + icon = R_GetSkinFaceMini(players[i].mo->player); + + cm = R_GetTranslationColormap(players[i].skin, players[i].mo->color, GTC_CACHE); + tagcolor = colortranslations[players[i].mo->color][7]; + vflags = trans | V_NOSCALESTART; + tagwidth = cv_smallnametags.value ? dup*V_SmallStringWidth(player_names[i], V_ALLOWLOWERCASE) : dup*V_ThinStringWidth(player_names[i], V_ALLOWLOWERCASE); + tagwidthsmall = cv_smallnametags.value ? V_SmallStringWidth(player_names[i], V_ALLOWLOWERCASE) : V_ThinStringWidth(player_names[i], V_ALLOWLOWERCASE); + + if (cv_smallnametags.value == 2 || cv_smallnametags.value == 1 || !nametaggfx) + { + if (flipped) + namey += dup*5; + else // small offset + namey -= dup*3; + + if (nametaggfx && cv_smallnametags.value == 1) + { + if (cv_nametagfacerank.value) + tagwidthsmall += icon->width - dup; + + // Have to draw the nametag using patches here since drawfill can't draw at this scale... + if (!flipped) + V_DrawFixedPatch(namex<height/2)<width/2); // add offset to other stuff + } + + //Name + V_DrawSmallString(namex, namey, V_ALLOWLOWERCASE | vflags, tag); + + if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) + { + V_DrawSmallString(namex, namey - dup*5, vflags, va("\x84S%d ", players[i].kartspeed)); + V_DrawSmallString(namex + dup*10, namey - dup*5, vflags, va("\x87W%d ", players[i].kartweight)); + } + + if (cv_nametagscore.value) + { + if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) + V_DrawSmallString(namex, namey - dup*10, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + else + V_DrawSmallString(namex, namey - dup*5, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + } + } + else + { + if (cv_nametagfacerank.value) + tagwidth += dup*(icon->width+1); + + if (flipped) + { + for (j = 0; j < 4; j++) + { + V_DrawFill(namex, namey, dup*3, dup*4, 31 | vflags); + V_DrawFill(namex+dup, namey, dup, dup*4, tagcolor | vflags); + namey += dup*4; + namex += dup; + } + namey -= dup*3; + V_DrawFill(namex, namey+dup*2, dup, dup, 31 | vflags); // a single black pixel + V_DrawFill(namex+dup, namey, tagwidth, dup*3, 31 | vflags); + V_DrawFill(namex+dup, namey+dup, tagwidth - dup, dup, tagcolor | vflags); + namex += dup*2; + } + else + { + for (j = 0; j < 4; j++) + { + namey -= dup*4; + V_DrawFill(namex, namey, dup*3, dup*4, 31 | vflags); + V_DrawFill(namex+dup, namey, dup, dup*4, tagcolor | vflags); + namex += dup; + } + V_DrawFill(namex, namey, dup, dup, 31 | vflags); + V_DrawFill(namex+dup, namey, tagwidth - dup*2, dup*3, 31 | vflags); + V_DrawFill(namex+dup, namey+dup, tagwidth - dup*3, dup, tagcolor | vflags); + } + + if (cv_nametagfacerank.value) + { + V_DrawMappedPatch(namex, namey - dup*(icon->height+1), vflags, icon, cm); + namex += dup*(icon->height+1); // add offset to other stuff + } + + V_DrawThinString(namex, namey - dup*10, V_ALLOWLOWERCASE | vflags, tag); + + if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) + { + V_DrawScaledPatch(namex, namey - dup*20, vflags, nametagspeed); + V_DrawScaledPatch(namex + dup*18, namey - dup*20, vflags, nametagweight); + V_DrawString(namex + dup*9, namey - dup*19, V_ALLOWLOWERCASE | vflags, va("\x84%d ", players[i].kartspeed)); + V_DrawString(namex + dup*27, namey - dup*19, V_ALLOWLOWERCASE | vflags, va("\x87%d ", players[i].kartweight)); + } + + if (cv_nametagscore.value) + { + if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) + V_DrawSmallString(namex, namey - dup*25, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + else + V_DrawSmallString(namex, namey - dup*15, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + } + } + } +} + static fixed_t K_FindCheckX(fixed_t px, fixed_t py, angle_t ang, fixed_t mx, fixed_t my) { fixed_t dist, x; @@ -9902,6 +10317,12 @@ void K_drawKartHUD(void) // Draw the item window if (LUA_HudEnabled(hud_item) && !freecam) K_drawKartItem(); + + if (cv_nametag.value) + { + if (LUA_HudEnabled(hud_nametags)) + K_drawNameTags(); + } // If not splitscreen, draw... if (!splitscreen && !demo.title) diff --git a/src/k_kart.h b/src/k_kart.h index 803594790..35f132610 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -81,6 +81,7 @@ void K_CalculateBattleWanted(void); void K_CheckBumpers(void); void K_CheckSpectateStatus(void); void K_UpdateSpectateGrief(void); +void K_AutoAdjustNameTagPos(void); // sound stuff for lua void K_PlayAttackTaunt(mobj_t *source); diff --git a/src/lua_hud.h b/src/lua_hud.h index db759bbfa..19edfab77 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -32,6 +32,7 @@ enum hud { hud_wanted, hud_speedometer, hud_statdisplay, + hud_nametags, hud_freeplay, hud_rankings, // Tab rankings diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 5b2f64b54..80280f424 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -55,6 +55,7 @@ static const char *const hud_disable_options[] = { "wanted", "speedometer", "statdisplay", + "nametags", "freeplay", "rankings", NULL}; diff --git a/src/m_menu.c b/src/m_menu.c index 922841404..40f9933a5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -358,12 +358,16 @@ menu_t OP_SaturnCreditsDef; // Bird menu_t OP_BirdDef; + // Stuff, yknow. menu_t OP_ForkedBirdDef; menu_t OP_LocalSkinDef; menu_t OP_TiltDef; menu_t OP_AdvancedBirdDef; +// Chaotic +menu_t OP_NametagDef; + #define numaddonsshown 4 // Replay hut @@ -457,6 +461,7 @@ static CV_PossibleValue_t map_cons_t[] = { {0, NULL} }; consvar_t cv_nextmap = {"nextmap", "1", CV_HIDEN|CV_CALL, map_cons_t, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_nextmapaddon = {"nextmapaddon", "1", CV_HIDEN|CV_CALL, NULL, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t skins_cons_t[MAXSKINS+1] = {{1, DEFAULTSKIN}}; consvar_t cv_chooseskin = {"chooseskin", DEFAULTSKIN, CV_HIDEN|CV_CALL, skins_cons_t, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -1077,7 +1082,7 @@ enum // Prefix: OP_ static menuitem_t OP_MainMenu[] = { - {IT_SUBMENU|IT_STRING, NULL, "Control Setup...", &OP_ControlsDef, 0}, + {IT_SUBMENU|IT_STRING, NULL, "Control Setup...", &OP_ControlsDef, 0}, {IT_SUBMENU|IT_STRING, NULL, "Video Options...", &OP_VideoOptionsDef, 20}, {IT_SUBMENU|IT_STRING, NULL, "Sound Options...", &OP_SoundOptionsDef, 30}, @@ -1086,15 +1091,15 @@ static menuitem_t OP_MainMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Gameplay Options...", &OP_GameOptionsDef, 60}, {IT_SUBMENU|IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 70}, - {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 90}, + {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 90}, {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 110}, {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 120}, {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 140}, - {IT_SUBMENU|IT_STRING, NULL, "Bird", &OP_BirdDef, 150}, - {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 160}, + {IT_SUBMENU|IT_STRING, NULL, "Bird", &OP_BirdDef, 150}, + {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 160}, }; static menuitem_t OP_ControlsMenu[] = @@ -1971,13 +1976,14 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 70}, {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 80}, {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 85}, - - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 95}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 90}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 105}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 110}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 105}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 120}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 115}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 120}, + + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 130}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -1997,6 +2003,7 @@ static const char* OP_SaturnTooltips[] = "Minimize the player icons on the minimap.", "Show the big Cecho Messages.", "Show Localskin Menus.", + "Nametag Options.", "Disables the flicker effect on Midnight Channel.", "Options for sprite distortion effects.", "Move position of HUD elements.", @@ -2018,6 +2025,9 @@ enum sm_lapemblem, sm_mapnames, sm_smallmap, + sm_cechotogle, + sm_showlocalskin, + sm_nametagmen, sm_pisschannel, sm_distortionmenu, sm_hudoffsets, @@ -2214,6 +2224,60 @@ static menuitem_t OP_ForkedBirdMenu[] = {IT_STRING | IT_CVAR, NULL, "Lua Immersion", &cv_luaimmersion, 170}, }; +static menuitem_t OP_NametagMenu[] = +{ + {IT_HEADER, NULL, "Nametag", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Nametag", &cv_nametag, 10}, + {IT_STRING | IT_CVAR, NULL, "Show Char image in Nametag", &cv_nametagfacerank, 20}, + {IT_STRING | IT_CVAR, NULL, "Show Own Nametag", &cv_showownnametag, 30}, + {IT_STRING | IT_CVAR, NULL, "Nametag Max distance", &cv_nametagdist, 40}, + {IT_STRING | IT_CVAR, NULL, "Nametag Max Display Players", &cv_nametagmaxplayers, 50}, + {IT_STRING | IT_CVAR, NULL, "Nametag Transparency", &cv_nametagtrans, 60}, + {IT_STRING | IT_CVAR, NULL, "Nametag Score", &cv_nametagscore, 70}, + {IT_STRING | IT_CVAR, NULL, "Nametag Restat", &cv_nametagrestat, 80}, + {IT_STRING | IT_CVAR, NULL, "Nametag Hop", &cv_nametaghop, 90}, + {IT_STRING | IT_CVAR, NULL, "Small Nametags", &cv_smallnametags, 100}, + {IT_STRING | IT_CVAR, NULL, "Show Nametags after Race finish", &cv_shownametagfinish, 110}, + {IT_STRING | IT_CVAR, NULL, "Show Nametags in Spectator Mode", &cv_shownametagspectator, 130}, + //{IT_STRING | IT_CVAR, NULL, "Nametag Scaling", &cv_nametagscaling, 70} +}; + +static const char* OP_NametagTooltips[] = +{ + NULL, + "Enable nametags in game.", + "Show character icon in nametag.", + "Show your own nametag in game.", + "Distance nametags are visible.", + "Maximum amount of nametags on screen.", + "Transparency of nametags.", + "Show player score in nametag.", + "Show stats in nametags.", + "Enable Saltyhop support for nametags.", + "Alternative smaller nametags.", + "Show Nametags after Race finish.", + "Show Nametags when you are spectating.", +}; + +enum +{ + nt_header, + nt_nametag, + nt_ntchar, + nt_owntag, + nt_maxdist, + nt_maxplayer, + nt_nttrans, + nt_ntpscore, + nt_ntrestat, + nt_nthop, + nt_smol, + nt_finish, + nt_spec, +}; + + + static menuitem_t OP_TiltMenu[] = { {IT_STRING | IT_CVAR, NULL, "Camera Tilting", &cv_tilting, 0}, @@ -2766,6 +2830,8 @@ menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnDe menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 10); menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30); +menu_t OP_NametagDef = DEFAULTMENUSTYLE(NULL, OP_NametagMenu, &OP_SaturnDef, 30, 60); + menu_t OP_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60); menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60); @@ -3107,6 +3173,12 @@ void Saturn_menu_Onchange(void) OP_SaturnMenu[sm_colorhud_customcolor].status = status; } +void Nametag_menu_Onchange(void) +{ + if (cv_smallnametags.value || (!nametaggfx)) + OP_NametagMenu[nt_ntchar].status = IT_GRAYEDOUT; +} + // ========================================================================== // END ORGANIZATION STUFF. // ========================================================================== @@ -4359,6 +4431,9 @@ void M_Init(void) OP_SaturnMenu[sm_coloritem].status = IT_GRAYEDOUT; OP_SaturnMenu[sm_colorhud_customcolor].status = IT_GRAYEDOUT; } + + if (!nametaggfx) + OP_NametagMenu[nt_ntchar].status = IT_GRAYEDOUT; #ifndef NONET CV_RegisterVar(&cv_serversort); @@ -4812,11 +4887,9 @@ static void M_DrawGenericMenu(void) W_CachePatchName("M_CURSOR", PU_CACHE)); V_DrawString(currentMenu->x, cursory, lowercase|highlightflags, currentMenu->menuitems[itemOn].text); } - - + // dumb hack // tooltips - if (currentMenu == &OP_ControlsDef) { if (!(OP_ControlsTooltips[itemOn] == NULL)) @@ -4826,7 +4899,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - + if (currentMenu == &OP_MouseOptionsDef) { if (!(OP_MouseTooltips[itemOn] == NULL)) @@ -4836,7 +4909,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - + if (currentMenu == &OP_VideoOptionsDef) { if (!(OP_VideoTooltips[itemOn] == NULL)) @@ -4846,7 +4919,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - + if (currentMenu == &OP_SoundOptionsDef) { if (!(OP_SoundTooltips[itemOn] == NULL)) @@ -4856,7 +4929,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - + if (currentMenu == &OP_SoundAdvancedDef) { if (!(OP_SoundAdvancedTooltips[itemOn] == NULL)) @@ -4866,7 +4939,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - + if (currentMenu == &OP_ExpOptionsDef) { if (!(OP_ExpTooltips[itemOn] == NULL)) @@ -4876,7 +4949,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - + if (currentMenu == &OP_ChatOptionsDef) { if (!(OP_ChatOptionsTooltips[itemOn] == NULL)) @@ -4887,8 +4960,6 @@ static void M_DrawGenericMenu(void) } } - - if (currentMenu == &OP_GameOptionsDef) { if (!(OP_GameTooltips[itemOn] == NULL)) @@ -4898,8 +4969,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - - + if (currentMenu == &OP_ServerOptionsDef) { if (!(OP_ServerOptionsTooltips[itemOn] == NULL)) @@ -4909,8 +4979,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - - + if (currentMenu == &OP_AdvServerOptionsDef) { if (!(OP_AdvServerOptionsTooltips[itemOn] == NULL)) @@ -4921,9 +4990,6 @@ static void M_DrawGenericMenu(void) } } - - - if (currentMenu == &OP_PlayerDistortDef) { if (!(OP_PlayerDistortTooltips[itemOn] == NULL)) @@ -4933,10 +4999,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - - - - + if (currentMenu == &OP_SaturnCreditsDef) // C: { if (!(OP_CreditTooltips[itemOn] == NULL)) @@ -4946,7 +5009,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - + if (currentMenu == &OP_BirdDef) { if (!(OP_BirdTooltips[itemOn] == NULL)) @@ -4956,7 +5019,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - + if (currentMenu == &OP_TiltDef) { if (!(OP_TiltTooltips[itemOn] == NULL)) @@ -4966,7 +5029,7 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } - + if (currentMenu == &OP_AdvancedBirdDef) { if (!(OP_AdvancedBirdTooltips[itemOn] == NULL)) @@ -4977,7 +5040,15 @@ static void M_DrawGenericMenu(void) } } - + if (currentMenu == &OP_NametagDef) + { + if (!(OP_NametagTooltips[itemOn] == NULL)) + { + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_NametagTooltips[itemOn], 30, coolalphatimer); + if (coolalphatimer > 0 && interpTimerHackAllow) + coolalphatimer--; + } + } } static void M_DrawGenericBackgroundMenu(void) @@ -4988,8 +5059,6 @@ static void M_DrawGenericBackgroundMenu(void) #define scrollareaheight 72 - - // note that alphakey is multiplied by 2 for scrolling menus to allow greater usage in UINT8 range. static void M_DrawGenericScrollMenu(void) { @@ -5135,8 +5204,6 @@ static void M_DrawGenericScrollMenu(void) } #endif - - if (currentMenu == &OP_SaturnDef) { if (!(OP_SaturnTooltips[itemOn] == NULL)) diff --git a/src/m_menu.h b/src/m_menu.h index 8d1ebb723..3b0bb3049 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -276,6 +276,9 @@ void Bird_menu_Onchange(void); // Saturn menu updating void Saturn_menu_Onchange(void); +// Nametags Menu updating +void Nametag_menu_Onchange(void); + void M_ReplayHut(INT32 choice); void M_SetPlaybackMenuPointer(void); diff --git a/src/p_sight.c b/src/p_sight.c index f6fa5775f..b482403cb 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -169,6 +169,7 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) return true; } + // // P_CrossSubsector // @@ -492,4 +493,4 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2) // the head node is the last node output return P_CrossBSPNode((INT32)numnodes - 1, &los); -} +} \ No newline at end of file diff --git a/src/v_video.c b/src/v_video.c index db9b38081..2d968bcc9 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2328,6 +2328,109 @@ void V_DrawCenteredSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const V_DrawSmallStringAtFixed(x, y, option, string); } +void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + fixed_t cx = x, cy = y; + INT32 w, c, dupx, dupy, scrwidth, center = 0, left = 0; + const char *ch = string; + INT32 spacewidth = 4, charwidth = 0; + INT32 charflags = 0; + const UINT8 *colormap = NULL; + INT32 lowercase = (option & V_ALLOWLOWERCASE); + option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE... + + if (option & V_NOSCALESTART) + { + dupx = vid.dupx; + dupy = vid.dupy; + scrwidth = vid.width; + } + else + { + dupx = dupy = 1; + scrwidth = vid.width/vid.dupx; + left = (scrwidth - BASEVIDWIDTH)/2; + scrwidth -= left; + } + + switch (option & V_SPACINGMASK) + { + case V_MONOSPACE: + spacewidth = 8; + /* FALLTHRU */ + case V_OLDSPACING: + charwidth = 8; + break; + case V_6WIDTHSPACE: + spacewidth = 6; + default: + break; + } + + charflags = (option & V_CHARCOLORMASK); + colormap = V_GetStringColormap(charflags); + + for (;;ch++) + { + if (!*ch) + break; + if (*ch & 0x80) //color parsing -x 2.16.09 + { + // manually set flags override color codes + if (!(option & V_CHARCOLORMASK)) + { + charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; + colormap = V_GetStringColormap(charflags); + } + continue; + } + if (*ch == '\n') + { + cx = x; + + if (option & V_RETURN8) + cy += (8*dupy)<= HU_FONTSIZE || !tny_font[c]) + { + cx += (spacewidth * dupx)<width)*(dupx/2); + } + else + w = SHORT(tny_font[c]->width) * dupx; + + if ((cx>>FRACBITS) > scrwidth) + break; + if ((cx>>FRACBITS)+left + w < 0) //left boundary check + { + cx += w<