From 4d108930a94f44dbc916d1116eab8421e669e4b6 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 2 Feb 2021 19:58:07 -0500 Subject: [PATCH] Update position nums to use additive Looks far more colorful this way! By default it is additive... but like SMK, there is a map header option for subtractive, intended for maps with white roads. --- src/dehacked.c | 8 ++++++++ src/doomstat.h | 1 + src/k_hud.c | 49 ++++++++++++++++++++++++++++++++++++------------- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 57571b0c0..445e790a6 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2031,6 +2031,13 @@ static void readlevelheader(MYFILE *f, INT32 num) else mapheaderinfo[num-1]->levelflags &= ~LF_SECTIONRACE; } + else if (fastcmp(word, "SUBTRACTNUM")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_SUBTRACTNUM; + else + mapheaderinfo[num-1]->levelflags &= ~LF_SUBTRACTNUM; + } // Individual triggers for menu flags else if (fastcmp(word, "HIDDEN")) @@ -11254,6 +11261,7 @@ struct { {"LF_SCRIPTISFILE",LF_SCRIPTISFILE}, {"LF_NOZONE",LF_NOZONE}, {"LF_SECTIONRACE",LF_SECTIONRACE}, + {"LF_SUBTRACTNUM",LF_SUBTRACTNUM}, // And map flags {"LF2_HIDEINMENU",LF2_HIDEINMENU}, {"LF2_HIDEINSTATS",LF2_HIDEINSTATS}, diff --git a/src/doomstat.h b/src/doomstat.h index 038944ef1..691d29fa1 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -408,6 +408,7 @@ typedef struct #define LF_SCRIPTISFILE (1<<0) ///< True if the script is a file, not a lump. #define LF_NOZONE (1<<1) ///< Don't include "ZONE" on level title #define LF_SECTIONRACE (1<<2) ///< Section race level +#define LF_SUBTRACTNUM (1<<3) ///< Use subtractive position number (for bright levels) #define LF2_HIDEINMENU (1<<0) ///< Hide in the multiplayer menu #define LF2_HIDEINSTATS (1<<1) ///< Hide in the statistics screen diff --git a/src/k_hud.c b/src/k_hud.c index 55f84ca4c..2d1c5ed6b 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1415,17 +1415,26 @@ static void K_DrawKartPositionNum(INT32 num) fixed_t scale = FRACUNIT; patch_t *localpatch = kp_positionnum[0][0]; INT32 fx = 0, fy = 0, fflags = 0; + INT32 addOrSub = V_ADDTRANS; boolean flipdraw = false; // flip the order we draw it in for MORE splitscreen bs. fun. boolean flipvdraw = false; // used only for 2p splitscreen so overtaking doesn't make 1P's position fly off the screen. boolean overtake = false; + if ((mapheaderinfo[gamemap - 1]->levelflags & LF_SUBTRACTNUM) == LF_SUBTRACTNUM) + { + addOrSub = V_SUBTRANS; + } + if (stplyr->kartstuff[k_positiondelay] || stplyr->exiting) { scale *= 2; overtake = true; // this is used for splitscreen stuff in conjunction with flipdraw. } + if (r_splitscreen) + { scale /= 2; + } W = FixedMul(W<>FRACBITS; @@ -1472,38 +1481,46 @@ static void K_DrawKartPositionNum(INT32 num) } // Special case for 0 - if (!num) + if (num <= 0) { - V_DrawFixedPatch(fx<= 0); // This function does not draw negative numbers - // Draw the number while (num) { if (win) // 1st place winner? You get rainbows!! + { localpatch = kp_winnernum[(leveltime % (NUMWINFRAMES*3)) / 3]; + } else if (stplyr->laps >= cv_numlaps.value || stplyr->exiting) // Check for the final lap, or won { - // Alternate frame every three frames - switch (leveltime % 9) + boolean useRedNums = K_IsPlayerLosing(stplyr); + + if (addOrSub == V_SUBTRANS) { - case 1: case 2: case 3: - if (K_IsPlayerLosing(stplyr)) + // Subtracting RED will look BLUE, and vice versa. + useRedNums = !useRedNums; + } + + // Alternate frame every three frames + switch ((leveltime % 9) / 3) + { + case 0: + if (useRedNums == true) localpatch = kp_positionnum[num % 10][4]; else localpatch = kp_positionnum[num % 10][1]; break; - case 4: case 5: case 6: - if (K_IsPlayerLosing(stplyr)) + case 1: + if (useRedNums == true) localpatch = kp_positionnum[num % 10][5]; else localpatch = kp_positionnum[num % 10][2]; break; - case 7: case 8: case 9: - if (K_IsPlayerLosing(stplyr)) + case 2: + if (useRedNums == true) localpatch = kp_positionnum[num % 10][6]; else localpatch = kp_positionnum[num % 10][3]; @@ -1514,9 +1531,15 @@ static void K_DrawKartPositionNum(INT32 num) } } else + { localpatch = kp_positionnum[num % 10][0]; + } - V_DrawFixedPatch((fx<width)*scale/2) : 0), (fy<height)*scale/2) : 0), scale, V_HUDTRANSHALF|V_SLIDEIN|fflags, localpatch, NULL); + V_DrawFixedPatch( + (fx<width)*scale/2) : 0), + (fy<height)*scale/2) : 0), + scale, addOrSub|V_SLIDEIN|fflags, localpatch, NULL + ); // ^ if we overtake as p1 or p3 in splitscren, we shift it so that it doesn't go off screen. // ^ if we overtake as p1 in 2p splits, shift vertically so that this doesn't happen either.