diff --git a/LUASTUFF.md b/LUASTUFF.md index 2ccd71dcb..05ca33bd0 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -2,7 +2,7 @@ ## mobj.localskin and player.localskin fields -Allow reading and assigning localskins to players. Local skins for other objects aren't supported currently. +Allow reading and assigning localskins. ## mobj.rollsum field @@ -20,9 +20,38 @@ Changes vote background texture prefix (game looks for PREFIX + "W" or "C" (depe ## hud.add(fn, "vote") and hud.add(fn, "intermission") Hud hooks for vote screen and intermission screen. They only get drawer (`v`) as argument. -To check if those hooks are available, check if globals FEATURE\_VOTEHUD and FEATURE\_INERMISSIONHUD +To check if those hooks are available, check if globals FEATURE\_VOTEHUD and FEATURE\_INTERMISSIONHUD exist. +## x, y = hud.getOffsets(item) + +Returns the values of the given HUD item's `xoffset`/`yoffset` cvars. +Available for any HUD item with offset cvars. + +## x, y, flags = v.getDrawInfo(item) + +Returns the X, Y and flags where the given HUD item will be drawn for the current displayplayer. +Available for `item`, `gametypeinfo` and `minimap`. + +## patch, colormap = v.getColorHudPatch(item) + +Returns the patch and colormap to use for the given HUD item. Colorization is based on the user's settings. +Available for `item` and `itemmul`. +Extra arguments for some items: +### item +* `small`: true for small item box, false for big item box. +* `dark`: true to darken item box. Depends on `darkitembox`. +### itemmul +* `small`: true for small sticker, false for big sticker. + +## hudcolor = v.getHudColor() + +Returns the displayplayer's HUD color. + +## colorize = v.useColorHud() + +Returns true if colorization is enabled, false otherwise. + ## mobj.spritexscale, mobj.spriteyscale, mobj.spritexoffset, mobj.spriteyoffset, mobj.rollangle, mobj.sloperoll, mobj.rollmodel fields Same fields as in SRB2 2.2 diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 8ff2ca972..ee0fd0b85 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -234,7 +234,7 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t } if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { - if ((option & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) + if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); else if (option & V_SNAPTOBOTTOM) cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); @@ -385,7 +385,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal } if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { - if ((option & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) + if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); else if (option & V_SNAPTOBOTTOM) cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); diff --git a/src/k_kart.c b/src/k_kart.c index 920a607fb..82228dd9e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7500,7 +7500,7 @@ static void K_initKartHUD(void) ITEM2_X = BASEVIDWIDTH-39 + cv_item_xoffset.value; ITEM2_Y = -8 + cv_item_yoffset.value; - LAPS2_X = BASEVIDWIDTH-40 + cv_laps_xoffset.value; + LAPS2_X = BASEVIDWIDTH-3 + cv_laps_xoffset.value; LAPS2_Y = (BASEVIDHEIGHT/2)-13 + cv_laps_yoffset.value; POSI2_X = BASEVIDWIDTH -4 + cv_posi_xoffset.value; @@ -7567,6 +7567,91 @@ INT32 K_calcSplitFlags(INT32 snapflags) return (splitflags|snapflags); } +void K_getItemBoxDrawinfo(drawinfo_t *out) +{ + INT32 fx, fy, fflags; + + // pain and suffering defined below + if (splitscreen < 2) // don't change shit for THIS splitscreen. + { + fx = ITEM_X; + fy = ITEM_Y; + fflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); + } + else // now we're having a fun game. + { + if (!(stplyrnum & 1)) // If we are P1 or P3... + { + fx = ITEM_X; + fy = ITEM_Y; + fflags = V_SNAPTOLEFT|(stplyrnum & 2 ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P3 to the bottom. + } + else // else, that means we're P2 or P4. + { + fx = ITEM2_X; + fy = ITEM2_Y; + fflags = V_SNAPTORIGHT|(stplyrnum & 2 ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P4 to the bottom + } + } + + out->x = fx; + out->y = fy; + out->flags = fflags; +} + +void K_getLapsDrawinfo(drawinfo_t *out) +{ + INT32 fx, fy, fflags; + + // pain and suffering defined below + if (splitscreen < 2) // don't change shit for THIS splitscreen. + { + fx = LAPS_X; + fy = LAPS_Y; + fflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); + } + else + { + if (!(stplyrnum & 1)) // If we are P1 or P3... + { + fx = LAPS_X; + fy = LAPS_Y; + fflags = V_SNAPTOLEFT|(stplyrnum & 2 ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. + } + else // else, that means we're P2 or P4. + { + fx = LAPS2_X; + fy = LAPS2_Y; + fflags = V_SNAPTORIGHT|(stplyrnum & 2 ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom + } + } + + out->x = fx; + out->y = fy; + out->flags = fflags; +} + +void K_getMinimapDrawinfo(drawinfo_t *out) +{ + INT32 fx = MINI_X, fy = MINI_Y, fflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) + + out->x = fx; + out->y = fy; + out->flags = fflags; +} + +patch_t *K_getItemBoxPatch(boolean small, boolean dark) +{ + UINT8 ofs = (cv_darkitembox.value && dark ? 1 : 0) + (small ? 2 : 0); + return (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[ofs] : kp_itembg[ofs]; +} + +patch_t *K_getItemMulPatch(boolean small) +{ + UINT8 ofs = small ? 1 : 0; + return K_UseColorHud() ? kp_itemmulstickerclr[ofs] : kp_itemmulsticker[ofs]; +} + static void K_drawKartStats(void) { INT32 x, y, spdoffset, flags; @@ -7692,12 +7777,8 @@ static void K_drawKartItem(void) const UINT8 offset = ((splitscreen > 1) ? 1 : 0); patch_t *localpatch = kp_nodraw; patch_t *localbg; - - if (cv_colorizeditembox.value && K_UseColorHud()) - localbg = ((offset) ? kp_itembgclr[2] : kp_itembgclr[0]); - else - localbg = ((offset) ? kp_itembg[2] : kp_itembg[0]); - + boolean dark = false; + patch_t *localinv = ((offset) ? kp_invincibility[((leveltime % (6*3)) / 3) + 7] : kp_invincibility[(leveltime % (7*3)) / 3]); INT32 fx = 0, fy = 0, fflags = 0; // final coords for hud and flags... //INT32 splitflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); @@ -7708,9 +7789,9 @@ static void K_drawKartItem(void) UINT8 localcolor = SKINCOLOR_NONE; SINT8 colormode = TC_RAINBOW; UINT8 *colmap = NULL; - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - - boolean flipamount = false; // Used for 3P/4P splitscreen to flip item amount stuff + UINT8 *colormap = NULL; + + boolean flipamount = splitscreen > 1 && stplyrnum & 1; // Used for 3P/4P splitscreen to flip item amount stuff if (stplyr->kartstuff[k_itemroulette]) { @@ -7857,8 +7938,7 @@ static void K_drawKartItem(void) break; case KITEM_INVINCIBILITY: localpatch = localinv; - if (cv_darkitembox.value) - localbg = (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[offset + 1] : kp_itembg[offset + 1]; + dark = true; break; case KITEM_BANANA: localpatch = kp_banana[offset]; @@ -7880,8 +7960,7 @@ static void K_drawKartItem(void) break; case KITEM_SPB: localpatch = kp_selfpropelledbomb[offset]; - if (cv_darkitembox.value) - localbg = (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[offset + 1] : kp_itembg[offset + 1]; + dark = true; break; case KITEM_GROW: localpatch = kp_grow[offset]; @@ -7891,8 +7970,7 @@ static void K_drawKartItem(void) break; case KITEM_THUNDERSHIELD: localpatch = kp_thundershield[offset]; - if (cv_darkitembox.value) - localbg = (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[offset + 1] : kp_itembg[offset + 1]; + dark = true; break; case KITEM_HYUDORO: localpatch = kp_hyudoro[offset]; @@ -7933,47 +8011,25 @@ static void K_drawKartItem(void) } } - // pain and suffering defined below - if (splitscreen < 2) // don't change shit for THIS splitscreen. - { - fx = ITEM_X; - fy = ITEM_Y; - fflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); - } - else // now we're having a fun game. - { - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... - { - fx = ITEM_X; - fy = ITEM_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - fx = ITEM2_X; - fy = ITEM2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P4 to the bottom - flipamount = true; - } - } + localbg = K_getItemBoxPatch((boolean)offset, dark); + drawinfo_t info; + K_getItemBoxDrawinfo(&info); + fx = info.x; + fy = info.y; + fflags = info.flags; if (localcolor != SKINCOLOR_NONE) colmap = R_GetTranslationColormap(colormode, localcolor, GTC_CACHE); + if (K_UseColorHud()) + colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - - if (cv_colorizeditembox.value && K_UseColorHud()) - V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, localbg,colormap); - else - V_DrawScaledPatch(fx, fy, V_HUDTRANS|fflags, localbg); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, localbg, cv_colorizeditembox.value ? colormap : NULL); // Then, the numbers: if (stplyr->kartstuff[k_itemamount] >= numberdisplaymin && !stplyr->kartstuff[k_itemroulette]) { - if (!K_UseColorHud()) - V_DrawScaledPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), kp_itemmulsticker[offset]); - else //Colourized hud - V_DrawMappedPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), kp_itemmulstickerclr[offset], colormap); // flip this graphic for p2 and p4 in split and shift it. - + localbg = K_getItemMulPatch((boolean)offset); + V_DrawMappedPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), localbg, colormap); // flip this graphic for p2 and p4 in split and shift it. V_DrawFixedPatch(fx< 1 && stplyrnum & 1; // used for 3p or 4p INT32 stringw = 0; // used with the above - + + drawinfo_t info; + K_getLapsDrawinfo(&info); + fx = info.x; + fy = info.y; + fflags = info.flags; + if (splitscreen > 1) { - // pain and suffering defined below - if (splitscreen < 2) // don't change shit for THIS splitscreen. - { - fx = LAPS_X; - fy = LAPS_Y; - fflags = splitflags; - } - else - { - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... - { - fx = LAPS_X; - fy = LAPS_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - fx = LAPS2_X; - fy = LAPS2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom - flipstring = true; // make the string right aligned and other shit - } - } - if (stplyr->exiting) // draw stuff as god intended. { V_DrawScaledPatch(fx, fy, V_HUDTRANS|fflags, kp_splitlapflag); @@ -8617,8 +8655,8 @@ static void K_drawKartLaps(void) { stringw = V_StringWidth(va("%d/%d", stplyr->laps+1, cv_numlaps.value), 0); - V_DrawScaledPatch(BASEVIDWIDTH-stringw-16, fy, V_HUDTRANS|fflags, kp_splitlapflag); - V_DrawRightAlignedString(BASEVIDWIDTH-3, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); + V_DrawScaledPatch(fx-stringw-13, fy, V_HUDTRANS|fflags, kp_splitlapflag); + V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); } else // draw stuff NORMALLY. { @@ -8631,23 +8669,23 @@ static void K_drawKartLaps(void) if (!K_UseColorHud()) { if (K_BigLapSticker()) - V_DrawScaledPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2 : kp_lapstickerbig)); + V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2 : kp_lapstickerbig)); else - V_DrawScaledPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, kp_lapsticker); + V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, kp_lapsticker); } else //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); if (K_BigLapSticker()) - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2clr : kp_lapstickerbigclr), colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2clr : kp_lapstickerbigclr), colormap); else - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, kp_lapstickerclr, colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, kp_lapstickerclr, colormap); } if (stplyr->exiting) - V_DrawKartString(LAPS_X+33, LAPS_Y+3, V_HUDTRANS|splitflags, "FIN"); + V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, "FIN"); else - V_DrawKartString(LAPS_X+33, LAPS_Y+3, V_HUDTRANS|splitflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); + V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); } } @@ -8799,31 +8837,22 @@ static void K_drawKartSpeedometer(void) static void K_drawKartBumpersOrKarma(void) { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); - INT32 fx = 0, fy = 0, fflags = 0; - boolean flipstring = false; // same as laps, used for splitscreen + INT32 fx, fy, fflags; + boolean flipstring = splitscreen > 1 && stplyrnum & 1; // same as laps, used for splitscreen INT32 stringw = 0; // used with the above + drawinfo_t info; + K_getLapsDrawinfo(&info); + fx = info.x; + fy = info.y; + fflags = info.flags; + if (splitscreen > 1) { - // we will reuse lap coords here since it's essentially the same shit. - - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... - { - fx = LAPS_X; - fy = LAPS_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - fx = LAPS2_X; - fy = LAPS2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom - flipstring = true; - } - if (stplyr->kartstuff[k_bumper] <= 0) { + if (flipstring) + fx -= 37; V_DrawMappedPatch(fx, fy-1, V_HUDTRANS|fflags, kp_splitkarmabomb, colormap); V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, va("%d/2", stplyr->kartstuff[k_comebackpoints])); } @@ -8833,8 +8862,8 @@ static void K_drawKartBumpersOrKarma(void) { stringw = V_StringWidth(va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value), 0); - V_DrawMappedPatch(BASEVIDWIDTH-stringw-16, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); - V_DrawRightAlignedString(BASEVIDWIDTH-3, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); + V_DrawMappedPatch(fx-stringw-13, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); + V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); } else // draw bumpers normally. { @@ -8847,17 +8876,17 @@ static void K_drawKartBumpersOrKarma(void) { if (stplyr->kartstuff[k_bumper] <= 0) { - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, (K_UseColorHud() ? kp_karmastickerclr : kp_karmasticker), colormap); - V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|splitflags, va("%d/2", stplyr->kartstuff[k_comebackpoints])); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_karmastickerclr : kp_karmasticker), colormap); + V_DrawKartString(fx+47, fy+3, V_HUDTRANS|fflags, va("%d/2", stplyr->kartstuff[k_comebackpoints])); } else { if (stplyr->kartstuff[k_bumper] > 9 && cv_kartbumpers.value > 9) - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, (K_UseColorHud() ? kp_bumperstickerwideclr : kp_bumperstickerwide), colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_bumperstickerwideclr : kp_bumperstickerwide), colormap); else - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, (K_UseColorHud() ? kp_bumperstickerclr : kp_bumpersticker), colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_bumperstickerclr : kp_bumpersticker), colormap); - V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|splitflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); + V_DrawKartString(fx+47, fy+3, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); } } } @@ -9120,7 +9149,7 @@ static void K_drawKartMinimap(void) patch_t *AutomapPic; INT32 i = 0; INT32 x, y; - INT32 minimaptrans, splitflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) + INT32 minimaptrans, splitflags; SINT8 localplayers[4]; SINT8 numlocalplayers = 0; @@ -9139,8 +9168,12 @@ static void K_drawKartMinimap(void) else return; // no pic, just get outta here - x = MINI_X - (AutomapPic->width/2); - y = MINI_Y - (AutomapPic->height/2); + drawinfo_t info; + K_getMinimapDrawinfo(&info); + x = info.x - (AutomapPic->width/2); + y = info.y - (AutomapPic->height/2); + splitflags = info.flags; + if (timeinmap > 105) { diff --git a/src/k_kart.h b/src/k_kart.h index 803594790..cb9b9eced 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -18,6 +18,7 @@ void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor); void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, boolean local); UINT8 K_GetKartColorByName(const char *name); UINT8 K_GetHudColor(void); +boolean K_UseColorHud(void); void K_RegisterKartStuff(void); @@ -96,5 +97,18 @@ void K_drawKartHUD(void); void K_drawKartFreePlay(UINT32 flashtime); void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UINT8 mode); +typedef struct +{ + INT32 x; + INT32 y; + INT32 flags; +} drawinfo_t; + +patch_t *K_getItemBoxPatch(boolean small, boolean dark); +patch_t *K_getItemMulPatch(boolean small); +void K_getItemBoxDrawinfo(drawinfo_t *out); +void K_getLapsDrawinfo(drawinfo_t *out); +void K_getMinimapDrawinfo(drawinfo_t *out); + // ========================================================================= #endif // __K_KART__ diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index c7b1ec38e..d58360186 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -24,6 +24,7 @@ #include "v_video.h" #include "w_wad.h" #include "z_zone.h" +#include "k_kart.h" #include "lua_script.h" #include "lua_libs.h" @@ -169,6 +170,58 @@ static const char *const camera_opt[] = { "pnum", NULL}; +enum hudpatch { + hudpatch_item = 0, + hudpatch_itemmul +}; + +static const char *const hud_patch_options[] = { + "item", + "itemmul", + NULL}; + +enum hudoffsets { + hudoffsets_item = 0, + hudoffsets_time, + hudoffsets_gametypeinfo, + hudoffsets_countdown, + hudoffsets_speedometer, + hudoffsets_position, + hudoffsets_minirankings, + hudoffsets_startcountdown, + hudoffsets_check, + hudoffsets_minimap, + hudoffsets_wanted, + hudoffsets_statdisplay +}; + +static const char *const hud_offsets_options[] = { + "item", + "time", + "gametypeinfo", + "countdown", + "speedometer", + "position", + "minirankings", + "startcountdown", + "check", + "minimap", + "wanted", + "statdisplay", + NULL}; + +enum huddrawinfo { + huddrawinfo_item = 0, + huddrawinfo_gametypeinfo, + huddrawinfo_minimap +}; + +static const char *const hud_drawinfo_options[] = { + "item", + "gametypeinfo", + "minimap", + NULL}; + static int lib_getHudInfo(lua_State *L) { UINT32 i; @@ -744,7 +797,6 @@ static int libd_drawStretched(lua_State *L) return 0; } - static int libd_drawNum(lua_State *L) { INT32 x, y, flags, num; @@ -1007,6 +1059,54 @@ static int libd_getColormap(lua_State *L) return 1; } +static int libd_getColorHudPatch(lua_State *L) +{ + HUDONLY + enum hudpatch option = luaL_checkoption(L, 1, NULL, hud_patch_options); + patch_t *patch; + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + boolean small, dark; + + switch (option) { + case hudpatch_item: + small = lua_optboolean(L, 2); + dark = lua_optboolean(L, 3); + patch = K_getItemBoxPatch(small, dark); + if (!cv_colorizeditembox.value) + colormap = NULL; + break; + case hudpatch_itemmul: + small = lua_optboolean(L, 2); + patch = K_getItemMulPatch(small); + break; + default: + return 0; // you shouldn't be here + } + + LUA_PushUserdata(L, patch, META_PATCH); + if (colormap && K_UseColorHud()) + LUA_PushUserdata(L, colormap, META_COLORMAP); + else + lua_pushnil(L); + + return 2; +} + +static int libd_getHudColor(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, K_GetHudColor()); + return 1; +} + +static int libd_useColorHud(lua_State *L) +{ + HUDONLY + lua_pushboolean(L, K_UseColorHud()); + return 1; +} + + static int libd_width(lua_State *L) { HUDONLY @@ -1057,6 +1157,26 @@ static int libd_getlocaltransflag(lua_State *L) return 1; } +static int libd_getDrawInfo(lua_State *L) +{ + HUDONLY + enum huddrawinfo option = luaL_checkoption(L, 1, NULL, hud_drawinfo_options); + drawinfo_t info; + + switch(option) { + case huddrawinfo_item: K_getItemBoxDrawinfo(&info); break; + case huddrawinfo_gametypeinfo: K_getLapsDrawinfo(&info); break; + case huddrawinfo_minimap: K_getMinimapDrawinfo(&info); break; + default: + return 0; // unreachable + } + + lua_pushinteger(L, info.x); + lua_pushinteger(L, info.y); + lua_pushinteger(L, info.flags); + return 3; +} + static luaL_Reg lib_draw[] = { {"patchExists", libd_patchExists}, {"cachePatch", libd_cachePatch}, @@ -1080,6 +1200,10 @@ static luaL_Reg lib_draw[] = { {"renderer", libd_renderer}, {"localTransFlag", libd_getlocaltransflag}, {"drawOnMinimap", libd_drawOnMinimap}, + {"getColorHudPatch", libd_getColorHudPatch}, + {"getDrawInfo", libd_getDrawInfo}, + {"getHudColor", libd_getHudColor}, + {"useColorHud", libd_useColorHud}, {NULL, NULL} }; @@ -1170,12 +1294,44 @@ static int lib_hudsetvotebackground(lua_State *L) return 0; } +static int lib_hudgetoffsets(lua_State *L) +{ + enum hudoffsets option = luaL_checkoption(L, 1, NULL, hud_offsets_options); + INT32 ofx, ofy; + +#define OFS(it) ofx = cv_##it##_xoffset.value; ofy = cv_##it##_yoffset.value; break; +#define OFY(it) ofx = 0; ofy = cv_##it##_yoffset.value; break; + switch(option) { + case hudoffsets_item: OFS(item) + case hudoffsets_time: OFS(time) + case hudoffsets_gametypeinfo: OFS(laps) + case hudoffsets_countdown: OFS(dnft) + case hudoffsets_speedometer: OFS(speed) + case hudoffsets_position: OFS(posi) + case hudoffsets_minirankings: OFS(face) + case hudoffsets_startcountdown: OFS(stcd) + case hudoffsets_check: OFY(chek) + case hudoffsets_minimap: OFS(mini) + case hudoffsets_wanted: OFS(want) + case hudoffsets_statdisplay: OFS(stat) + default: + return 0; // unreachable + } +#undef OFS +#undef OFY + + lua_pushinteger(L, ofx); + lua_pushinteger(L, ofy); + return 2; +} + static luaL_Reg lib_hud[] = { {"enable", lib_hudenable}, {"disable", lib_huddisable}, {"enabled", lib_hudenabled}, {"add", lib_hudadd}, {"setVoteBackground", lib_hudsetvotebackground}, + {"getOffsets", lib_hudgetoffsets}, {NULL, NULL} }; diff --git a/src/p_enemy.c b/src/p_enemy.c index e617cfbce..cde88e607 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -33,7 +33,6 @@ boolean LUA_CallAction(const char *action, mobj_t *actor); #endif -player_t *stplyr; INT32 var1; INT32 var2; diff --git a/src/p_local.h b/src/p_local.h index df8df412e..e93d4b411 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -306,9 +306,6 @@ void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration); // P_ENEMY // -// main player in game -extern player_t *stplyr; // for splitscreen correct palette changes and overlay - // Is there a better place for these? extern INT32 var1; extern INT32 var2; diff --git a/src/st_stuff.c b/src/st_stuff.c index b4b4a3d49..e7352186b 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -150,6 +150,10 @@ static patch_t *hud_tv2; static patch_t *envelope; #endif +// current player for overlay drawing +player_t *stplyr; +UINT8 stplyrnum; + // SRB2kart hudinfo_t hudinfo[NUMHUDITEMS] = @@ -2223,6 +2227,7 @@ void ST_Drawer(void) for (i = 0; i <= splitscreen; i++) { stplyr = &players[displayplayers[i]]; + stplyrnum = i; ST_overlayDrawer(); } diff --git a/src/st_stuff.h b/src/st_stuff.h index 0dffa46c3..d46688e8f 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -68,6 +68,8 @@ boolean ST_SameTeam(player_t *a, player_t *b); extern boolean st_overlay; // sb overlay on or off when fullscreen extern INT32 st_palette; // 0 is default, any others are special palettes. +extern player_t *stplyr; // for splitscreen correct palette changes and overlay +extern UINT8 stplyrnum; extern lumpnum_t st_borderpatchnum; // patches, also used in intermission