From d48b08856e43ccadd779c54f3da863c697fd6051 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Thu, 31 Aug 2023 10:42:43 +0200 Subject: [PATCH 1/4] Support for Animated Votingscreens i hate the interpolation i hate it no idea honestly if those play correctly atm but atleast they dont freak out with uncapped https://gitlab.com/blondedradio/srb-2-k-cep/-/commit/776a547087cdef46b2bdbfc3ddc9d4d963bbea4b --- src/y_inter.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 115 insertions(+), 8 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 3fb2d3aa3..16a5dae72 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -116,6 +116,18 @@ static INT32 intertic; static INT32 endtic = -1; static INT32 sorttic = -1; +patch_t *animVoteFramesPatches = NULL; +// VEXTRN - Vote (V) Extra (EXT) Race (R) Normal (N - Normal sized patch) +// VEXTBN - Vote (V) Extra (EXT) Battle (B) Normal (N - Normal sized patch) +// VEXTBW - Vote (V) Extra (EXT) Battle (B) Normal (W - Wide patch used in software) +// VEXTRW - Vote (V) Extra (EXT) Race (R) Normal (W - Wide patch used in software) +char animPrefix[] = "INTSC"; +char animWidePrefix[] = "INTSW"; + +INT32 currentAnimFrame = 0; +static INT32 foundAnimVoteFrames = 0; +static INT32 foundAnimVoteWideFrames = 0; + intertype_t intertype = int_none; @@ -325,6 +337,44 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) } } +// +// Y_AnimatedVoteScreenCheck +// +// Check if the lumps exist (checking for VEXTR(N|W)xx for race and VEXTRB(N|W)xx for battle) +void Y_AnimatedVoteScreenCheck(void) +{ + char tmpPrefix[] = "INTS"; + if(G_BattleGametype()) { + strcpy(animPrefix, "BTLSC"); + strcpy(animWidePrefix, "BTLSW"); + + strcpy(tmpPrefix, "BTLS"); + } + boolean stopSearching = false; + + foundAnimVoteFrames = 0; + foundAnimVoteWideFrames = 0; + currentAnimFrame = 0; + + INT32 i = 1; + while(!stopSearching){ + boolean normalLumpExists = W_LumpExists(va("%sC%d", tmpPrefix, i)); + boolean wideLumpExists = W_LumpExists(va("%sW%d", tmpPrefix, i)); + + if(normalLumpExists || wideLumpExists){ + if(normalLumpExists){ + foundAnimVoteFrames++; + } + if(wideLumpExists){ + foundAnimVoteWideFrames++; + } + } else { // If we don't find at least frame 1 (e.g VEXTRN1), let's just stop looking + stopSearching = true; + } + i++; + } +} + // // Y_IntermissionDrawer // @@ -978,6 +1028,41 @@ static void Y_UnloadData(void) // SRB2Kart: Voting! +// Y_DrawAnimatedVoteScreenPatch +// +// Draw animated patch based on frame counter on vote screen +// +void Y_DrawAnimatedVoteScreenPatch(boolean widePatch){ + char tempAnimPrefix[7]; + (widePatch) ? strcpy(tempAnimPrefix, animWidePrefix) : strcpy(tempAnimPrefix, animPrefix); + INT32 tempFoundAnimVoteFrames = (widePatch) ? foundAnimVoteWideFrames : foundAnimVoteFrames; + INT32 flags = V_SNAPTOBOTTOM | V_SNAPTOTOP; + UINT8 patchframe = (votetic / 4) % 16; + + // Just in case someone provides LESS widescreen frames than normal frames or vice versa, reset the frame counter to 0 + if(widePatch) { + if(currentAnimFrame > foundAnimVoteWideFrames-1){ + currentAnimFrame = 0; + } + } else { + if(currentAnimFrame > foundAnimVoteFrames-1){ + currentAnimFrame = 0; + } + } + + /*patch_t *currPatch = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame+1), PU_CACHE); + V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(currPatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) + (vid.height / vid.dupy) - SHORT(currPatch->height), + V_SNAPTOTOP|V_SNAPTOLEFT, currPatch); + if(votetic % 3 == 0 && !paused){*/ + + { + currentAnimFrame = (currentAnimFrame+1 > tempFoundAnimVoteFrames-1) ? 0 : currentAnimFrame + 1; // jeez no fucking idea how to make this shit not go nuts with interpolation + patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, patchframe + 1), PU_CACHE); + V_DrawScaledPatch(160 - (background->width / 2), (200 - (background->height)), flags, background); + } +} + // // Y_VoteDrawer // @@ -1006,14 +1091,34 @@ void Y_VoteDrawer(void) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - if (widebgpatch && rendermode == render_soft && vid.width / vid.dupx > 320) - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(widebgpatch->width)/2), - (vid.height / vid.dupy) - SHORT(widebgpatch->height), - V_SNAPTOTOP|V_SNAPTOLEFT, widebgpatch); - else - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(bgpatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) - (vid.height / vid.dupy) - SHORT(bgpatch->height), - V_SNAPTOTOP|V_SNAPTOLEFT, bgpatch); + if (widebgpatch && rendermode == render_soft && vid.width / vid.dupx > 320) { + + if(foundAnimVoteWideFrames == 0){ + V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(widebgpatch->width)/2), + (vid.height / vid.dupy) - SHORT(widebgpatch->height), + V_SNAPTOTOP|V_SNAPTOLEFT, widebgpatch); + } else { + // patch_t *currPatch = W_CachePatchName(va("%s%d", animPrefix, currentAnimFrame+1), PU_CACHE); + // V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(currPatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) + // (vid.height / vid.dupy) - SHORT(currPatch->height), + // V_SNAPTOTOP|V_SNAPTOLEFT, currPatch); + // if(votetic % 4 == 0 && !paused){ + // currentAnimFrame = (currentAnimFrame+1 > foundAnimVoteFrames-1) ? 0 : currentAnimFrame + 1; + // } + Y_DrawAnimatedVoteScreenPatch(true); + } + } else { + if(foundAnimVoteFrames == 0) { + V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(bgpatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) + (vid.height / vid.dupy) - SHORT(bgpatch->height), + V_SNAPTOTOP|V_SNAPTOLEFT, bgpatch); + } else { + Y_DrawAnimatedVoteScreenPatch(false); + } + + + } + for (i = 0; i < 4; i++) // First, we need to figure out the height of this thing... { @@ -1487,6 +1592,8 @@ void Y_StartVote(void) I_Error("voteendtic is dirty"); #endif + Y_AnimatedVoteScreenCheck(); + widebgpatch = W_CachePatchName(((prefgametype == GT_MATCH) ? "BATTLSCW" : "INTERSCW"), PU_STATIC); bgpatch = W_CachePatchName(((prefgametype == GT_MATCH) ? "BATTLSCR" : "INTERSCR"), PU_STATIC); cursor = W_CachePatchName("M_CURSOR", PU_STATIC); From ca9277366cdb9eeff329d5e72a259e9c42be8bfb Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Fri, 1 Sep 2023 19:43:24 +0200 Subject: [PATCH 2/4] anim screen stuff --- src/y_inter.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 16a5dae72..41c96c9ce 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -171,6 +171,7 @@ typedef struct static y_votelvlinfo levelinfo[5]; static y_voteclient voteclient; static INT32 votetic; +static INT32 lastvotetic; static INT32 voteendtic = -1; static patch_t *cursor = NULL; static patch_t *cursor1 = NULL; @@ -1037,7 +1038,6 @@ void Y_DrawAnimatedVoteScreenPatch(boolean widePatch){ (widePatch) ? strcpy(tempAnimPrefix, animWidePrefix) : strcpy(tempAnimPrefix, animPrefix); INT32 tempFoundAnimVoteFrames = (widePatch) ? foundAnimVoteWideFrames : foundAnimVoteFrames; INT32 flags = V_SNAPTOBOTTOM | V_SNAPTOTOP; - UINT8 patchframe = (votetic / 4) % 16; // Just in case someone provides LESS widescreen frames than normal frames or vice versa, reset the frame counter to 0 if(widePatch) { @@ -1057,10 +1057,12 @@ void Y_DrawAnimatedVoteScreenPatch(boolean widePatch){ if(votetic % 3 == 0 && !paused){*/ { - currentAnimFrame = (currentAnimFrame+1 > tempFoundAnimVoteFrames-1) ? 0 : currentAnimFrame + 1; // jeez no fucking idea how to make this shit not go nuts with interpolation - patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, patchframe + 1), PU_CACHE); + patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_CACHE); V_DrawScaledPatch(160 - (background->width / 2), (200 - (background->height)), flags, background); } + if (lastvotetic != votetic && lastvotetic % 2 == 0) { + currentAnimFrame = (currentAnimFrame+1 > tempFoundAnimVoteFrames-1) ? 0 : currentAnimFrame + 1; // jeez no fucking idea how to make this shit not go nuts with interpolation + } } // @@ -1336,6 +1338,8 @@ void Y_VoteDrawer(void) V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol, va("Vote ends in %d", tickdown)); } + + lastvotetic = votetic; #ifdef HAVE_BLUA if (renderisnewtic) From 7f05d27f42a437e28f293829e849c5fbdfc7dfb6 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 5 Sep 2023 12:47:49 +0300 Subject: [PATCH 3/4] Allow lua to change vote background via hud.setVoteBackground --- src/lua_hudlib.c | 36 ++++++++++++++++++++++++++++++++++++ src/y_inter.c | 23 +++++++++++++++++------ src/y_inter.h | 1 + 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 470fad9b7..bd3fb19c8 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -15,6 +15,7 @@ #include "r_defs.h" #include "r_local.h" #include "st_stuff.h" // hudinfo[] +#include "y_inter.h" #include "g_game.h" #include "i_video.h" // rendermode #include "p_local.h" // camera_t @@ -966,11 +967,46 @@ static int lib_hudadd(lua_State *L) return 0; } +static int lib_hudsetvotebackground(lua_State *L) +{ + if (lua_isnoneornil(L, 1)) + { + if (luaVoteScreen) + { + free(luaVoteScreen); + } + + luaVoteScreen = NULL; + + return 0; + } + + const char *prefix = luaL_checkstring(L, 1); + + if (strlen(prefix) != 4) + { + return luaL_argerror(L, 1, "prefix should 4 characters wide"); + } + + if (!luaVoteScreen) + { + luaVoteScreen = (char*)malloc(5); + luaVoteScreen[4] = 0; + } + + strncpy(luaVoteScreen, prefix, 4); + + strupr(luaVoteScreen); + + return 0; +} + static luaL_Reg lib_hud[] = { {"enable", lib_hudenable}, {"disable", lib_huddisable}, {"enabled", lib_hudenabled}, {"add", lib_hudadd}, + {"setVoteBackground", lib_hudsetvotebackground}, {NULL, NULL} }; diff --git a/src/y_inter.c b/src/y_inter.c index 41c96c9ce..bda60dde2 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -123,6 +123,7 @@ patch_t *animVoteFramesPatches = NULL; // VEXTRW - Vote (V) Extra (EXT) Race (R) Normal (W - Wide patch used in software) char animPrefix[] = "INTSC"; char animWidePrefix[] = "INTSW"; +char *luaVoteScreen = NULL; INT32 currentAnimFrame = 0; static INT32 foundAnimVoteFrames = 0; @@ -345,14 +346,24 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) void Y_AnimatedVoteScreenCheck(void) { char tmpPrefix[] = "INTS"; - if(G_BattleGametype()) { - strcpy(animPrefix, "BTLSC"); - strcpy(animWidePrefix, "BTLSW"); - - strcpy(tmpPrefix, "BTLS"); - } boolean stopSearching = false; + if (luaVoteScreen) + { + strncpy(tmpPrefix, luaVoteScreen, 4); + } + else + { + if(G_BattleGametype()) { + strcpy(tmpPrefix, "BTLS"); + } + } + + strncpy(animPrefix, tmpPrefix, 4); + animPrefix[4] = 'C'; + strncpy(animWidePrefix, tmpPrefix, 4); + animWidePrefix[4] = 'W'; + foundAnimVoteFrames = 0; foundAnimVoteWideFrames = 0; currentAnimFrame = 0; diff --git a/src/y_inter.h b/src/y_inter.h index 6162dc282..ee320d474 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -10,6 +10,7 @@ /// \brief Tally screens, or "Intermissions" as they were formally called in Doom extern boolean usebuffer; +extern char *luaVoteScreen; void Y_IntermissionDrawer(void); void Y_Ticker(void); From 35cfdea9e71209e1987435a6c1284295035232e2 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Mon, 11 Sep 2023 15:55:59 +0200 Subject: [PATCH 4/4] allow opengl to also use widescreen backgrounds for votes thanks kk for locking this to software mode only despite this working without issues in opengl aswell --- src/y_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index bda60dde2..c20ef30e3 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1104,7 +1104,7 @@ void Y_VoteDrawer(void) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - if (widebgpatch && rendermode == render_soft && vid.width / vid.dupx > 320) { + if (widebgpatch && vid.width / vid.dupx > 320) { if(foundAnimVoteWideFrames == 0){ V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(widebgpatch->width)/2),