clean and fixup addon menu

Hopefully should finally fix addons not showing as loaded sometimes and other issues with warning windows being unclosable, etc

lets pray this doesent cause any issues....

add a tickroutine for menus aswell, which will be called in M_Ticker

courtesy of Ring Racers
https://gitlab.com/kart-krew-dev/ring-racers/-/commit/bc9f9d740a0262c249917a37e250ef0209185b12
https://gitlab.com/kart-krew-dev/ring-racers/-/commit/8312f12d6cae934ae8de7e46da231c311f4b4fde
https://gitlab.com/kart-krew-dev/ring-racers/-/commit/6e671d4894e56cd3af09d6e9af2635f030817361
This commit is contained in:
Alug committed 2025-11-25 17:42:01 +01:00
1 parent ee0e4836f5
commit 7f671e4e30
5 files changed
+108 -65

No files matched your search

+3
View File
@@ -53,6 +53,8 @@
#include "m_perfstats.h"
#include "d_main.h"
#include "r_fps.h"
#include "filesrch.h" // refreshdirmenu
// cl loading screen
#include "v_video.h"
@@ -7195,6 +7197,7 @@ void NetUpdate(void)
I_lock_mutex(&m_menu_mutex);
#endif
M_Ticker();
refreshdirmenu = 0;
#ifdef HAVE_THREADS
I_unlock_mutex(m_menu_mutex);
#endif
+1 -3
View File
@@ -70,7 +70,7 @@
#include "fastcmp.h"
#include "r_fps.h" // Frame interpolation/uncapped
#include "keys.h"
#include "filesrch.h" // refreshdirmenu, pathisdirectory
#include "filesrch.h" // pathisdirectory
#include "d_protocol.h"
#include "m_perfstats.h"
#include "k_kart.h"
@@ -725,8 +725,6 @@ void D_SRB2Loop(void)
renderisnewtic = (realtics > 0 || singletics);
refreshdirmenu = 0; // not sure where to put this, here as good as any?
if (renderisnewtic)
{
// don't skip more than 10 frames at a time
+72 -62
View File
@@ -299,14 +299,14 @@ static void M_AddonsInternal();
static void M_Addons(INT32 choice);
static void M_LocalSkins(INT32 choice);
static void M_AddonsOptions(INT32 choice);
#define addonmenusize 9 // number of items actually displayed in the addons menu view, formerly (2*numaddonsshown + 1)
#define numaddonsshown 4 // number of items to each side of the currently selected item, unless at top/bottom ends of directory
static void M_CustomCvarMenu(INT32 choice);
static patch_t *addonsp[NUM_EXT+5];
static void M_DeleteProtocol(void);
#define numaddonsshown 4
// Replay hut
static void M_HandleReplayHutList(INT32 choice);
static void M_HutCheckReplays(size_t maxnum);
@@ -368,6 +368,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice);
static void M_HandleVideoMode(INT32 choice);
static void M_ResetCvars(void);
static void M_HandleMonitorToggles(INT32 choice);
static void M_AddonsRefresh(void);
// Consvar onchange functions
static void Nextmap_OnChange(void);
@@ -1702,6 +1703,9 @@ void M_Ticker(void)
if (dedicated)
return;
if (currentMenu->tickroutine)
currentMenu->tickroutine();
if (menuactive)
I_HandleControllerHatRepeat();
@@ -2799,6 +2803,7 @@ menu_t MessageDef =
NULL, // previous menu (TO HACK)
MessageMenu, // menuitem_t ->
M_DrawMessageMenu, // drawing routine ->
NULL, // ticker routine
0, 0, // x, y (TO HACK)
0, // lastOn, flags (TO HACK)
NULL,
@@ -3233,8 +3238,8 @@ static void M_AddonsClearName(INT32 choice)
M_StopMessage(choice);
}
// returns whether to do message draw
static boolean M_AddonsRefresh(void)
// Handles messages for addon errors.
static void M_AddonsRefresh(void)
{
if ((refreshdirmenu & REFRESHDIR_NORMAL) && !preparefilemenu(true, false))
{
@@ -3243,7 +3248,7 @@ static boolean M_AddonsRefresh(void)
{
CLEARNAME;
}
return true;
return;
}
if (!majormods && prevmajormods)
@@ -3292,14 +3297,14 @@ static boolean M_AddonsRefresh(void)
if (message)
{
M_StartMessage(message, M_AddonsClearName, MM_EVENTHANDLER);
return true;
return;
}
S_StartSound(NULL, sfx_s221);
CLEARNAME;
}
return false;
return;
}
static tic_t addons_scrolltic = 0; // maybe not the best place but e
@@ -3307,19 +3312,13 @@ static tic_t addons_scrolltic = 0; // maybe not the best place but e
static void M_DrawAddons(void)
{
INT32 x, y;
ssize_t i, m;
size_t i, m;
size_t t, b; // top and bottom item #s to draw in directory
const UINT8 *flashcol = NULL;
UINT8 hilicol;
if (renderisnewtic) addons_scrolltic++;
// hack - need to refresh at end of frame to handle addfile...
if (refreshdirmenu & M_AddonsRefresh())
{
M_DrawMessageMenu();
return;
}
if (Playing())
{
if (browselocalskins)
@@ -3349,57 +3348,69 @@ static void M_DrawAddons(void)
hilicol = V_GetStringColormap(highlightflags)[120];
#define boxwidth (MAXSTRINGLENGTH*8+6)
// draw the file path and the top white + black lines of the box
V_DrawString(x-21, (y - 16) + (lsheadingheight - 12), highlightflags|V_ALLOWLOWERCASE, M_AddonsHeaderPath());
V_DrawFill(x-21, (y - 16) + (lsheadingheight - 3), MAXSTRINGLENGTH*8+6, 1, hilicol);
V_DrawFill(x-21, (y - 16) + (lsheadingheight - 2), MAXSTRINGLENGTH*8+6, 1, 30);
V_DrawFill(x-21, (y - 16) + (lsheadingheight - 3), boxwidth, 1, hilicol);
V_DrawFill(x-21, (y - 16) + (lsheadingheight - 2), boxwidth, 1, 30);
m = (BASEVIDHEIGHT - currentMenu->y + 2) - (y - 1);
V_DrawFill(x - 21, y - 1, MAXSTRINGLENGTH*8+6, m, 239);
V_DrawFill(x-21, y - 1, boxwidth, m, 239);
// scrollbar!
if (sizedirmenu <= (2*numaddonsshown + 1))
i = 0;
// The directory is too small for a scrollbar, so just draw a tall white line
if (sizedirmenu <= addonmenusize)
{
t = 0; // first item
b = sizedirmenu - 1; // last item
i = 0; // "scrollbar" at "top" position
}
else
{
ssize_t q = m;
m = ((2*numaddonsshown + 1) * m)/sizedirmenu;
size_t q = m;
m = (addonmenusize * m)/sizedirmenu; // height of scroll bar
if (dir_on[menudepthleft] <= numaddonsshown) // all the way up
i = 0;
else if (sizedirmenu <= (dir_on[menudepthleft] + numaddonsshown + 1)) // all the way down
i = q-m;
else
i = ((dir_on[menudepthleft] - numaddonsshown) * (q-m))/(sizedirmenu - (2*numaddonsshown + 1));
{
t = 0; // first item
b = addonmenusize - 1; //9th item
i = 0; // scrollbar at top position
}
else if (dir_on[menudepthleft] >= sizedirmenu - (numaddonsshown + 1)) // all the way down
{
t = sizedirmenu - addonmenusize; // # 9th last
b = sizedirmenu - 1; // last item
i = q-m; // scrollbar at bottom position
}
else // somewhere in the middle
{
t = dir_on[menudepthleft] - numaddonsshown; // 4 items above
b = dir_on[menudepthleft] + numaddonsshown; // 4 items below
i = (t * (q-m))/(sizedirmenu - addonmenusize); // calculate position of scrollbar
}
}
V_DrawFill(x + MAXSTRINGLENGTH*8+5 - 21, (y - 1) + i, 1, m, hilicol);
// draw the scrollbar!
V_DrawFill((x-21) + boxwidth-1, (y - 1) + i, 1, m, hilicol);
// get bottom...
m = dir_on[menudepthleft] + numaddonsshown + 1;
if (m > (ssize_t)sizedirmenu)
m = sizedirmenu;
#undef boxwidth
// then compute top and adjust bottom if needed!
if (m < (2*numaddonsshown + 1))
{
m = min(sizedirmenu, 2*numaddonsshown + 1);
i = 0;
}
else
i = m - (2*numaddonsshown + 1);
if (i != 0)
// draw up arrow that bobs up and down
if (t != 0)
V_DrawString(19, y+4 - (skullAnimCounter/5), highlightflags, "\x1A");
// make the selection box flash yellow
if (skullAnimCounter < 4)
flashcol = V_GetStringColormap(highlightflags);
for (; i < m; i++)
// draw icons and item names
for (i = t; i <= b; i++)
{
UINT32 flags = V_ALLOWLOWERCASE;
#define MAXADDONNAME 31
char scrollbuf[MAXADDONNAME+1] = {0};
if (y > BASEVIDHEIGHT) break;
if (y > BASEVIDHEIGHT)
break;
if (dirmenu[i])
#define type (UINT8)(dirmenu[i][DIR_TYPE])
{
@@ -3412,37 +3423,30 @@ static void M_DrawAddons(void)
else
V_DrawSmallScaledPatch(x-(16+4), y, 0, addonsp[(type & ~EXT_LOADED)]);
if ((size_t)i == dir_on[menudepthleft])
// draw selection box for the item currently selected
if (i == dir_on[menudepthleft])
{
V_DrawFixedPatch((x-(16+4))<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, 0, addonsp[NUM_EXT+1], flashcol);
flags = V_ALLOWLOWERCASE|highlightflags;
}
// draw name of the item, use ... if too long
#define charsonside 14
if (dirmenu[i][DIR_LEN] > MAXADDONNAME)
{
if ((size_t)i == dir_on[menudepthleft])
{
M_ScrollString(dirmenu[i]+DIR_STRING, dirmenu[i][DIR_LEN]-1, scrollbuf, MAXADDONNAME, addons_scrolltic);
}
else
strncpy(scrollbuf, va("%.*s...%s", charsonside, dirmenu[i]+DIR_STRING, dirmenu[i]+DIR_STRING+dirmenu[i][DIR_LEN]-(charsonside+1)), MAXADDONNAME);
V_DrawString(x, y+4, flags, scrollbuf);
}
if (dirmenu[i][DIR_LEN] > (charsonside*2 + 3))
V_DrawString(x, y+4, flags, va("%.*s...%s", charsonside, dirmenu[i]+DIR_STRING, dirmenu[i]+DIR_STRING+dirmenu[i][DIR_LEN]-(charsonside+1)));
#undef charsonside
else
V_DrawString(x, y+4, flags, dirmenu[i]+DIR_STRING);
#undef MAXADDONNAME
}
#undef type
y += 16;
}
if (m != (ssize_t)sizedirmenu)
// draw down arrow that bobs down and up
if (b != sizedirmenu)
V_DrawString(19, y-12 + (skullAnimCounter/5), highlightflags, "\x1B");
// draw search box
y = BASEVIDHEIGHT - currentMenu->y + 1;
M_DrawTextBox(x - (21 + 5), y, MAXSTRINGLENGTH, 1);
@@ -3452,15 +3456,21 @@ static void M_DrawAddons(void)
else
V_DrawString(x - 18, y + 8, V_ALLOWLOWERCASE|V_TRANSLUCENT, "Type to search...");
// draw search icon
x -= (21 + 5 + 16);
V_DrawSmallScaledPatch(x, y + 4, (menusearch.length ? 0 : V_TRANSLUCENT), addonsp[NUM_EXT+3]);
// draw save icon
x = BASEVIDWIDTH - x - 16;
V_DrawSmallScaledPatch(x, y + 4, ((!majormods) ? 0 : V_TRANSLUCENT), addonsp[NUM_EXT+4]);
if (modifiedgame)
V_DrawSmallScaledPatch(x, y + 4, 0, addonsp[NUM_EXT+2]);
// no space on alot of resolutions
//m = numwadfiles-(mainwads+2+1);
//V_DrawCenteredString(BASEVIDWIDTH/2, y+24, (majormods ? highlightflags : V_TRANSLUCENT), va("%d ADD-ON%s LOADED", (int)m, (m == 1) ? "" : "S")); //+2 for music, sounds, +1 for main.kart
V_DrawThinString(0, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("END Key - Add addon to autoload"));
}
+8
View File
@@ -204,6 +204,7 @@ typedef struct menu_s
struct menu_s *prevMenu; // previous menu
menuitem_t *menuitems; // menu items
void (*drawroutine)(void); // draw routine
void (*tickroutine)(void); // ticker routine
INT16 x, y; // x, y of menu
INT16 lastOn; // last item user was on in menu
boolean (*quitroutine)(void); // called before quit a menu return true if we can
@@ -328,6 +329,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
prev,\
source,\
M_DrawGenericMenu,\
NULL,\
x, y,\
0,\
NULL,\
@@ -341,6 +343,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
prev,\
source,\
M_DrawGenericScrollMenu,\
NULL,\
x, y,\
0,\
NULL,\
@@ -355,6 +358,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
NULL,\
source,\
M_DrawPauseMenu,\
NULL,\
x, y,\
0,\
NULL,\
@@ -368,6 +372,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
prev,\
source,\
M_DrawCenteredMenu,\
NULL,\
BASEVIDWIDTH/2, y,\
0,\
NULL,\
@@ -381,6 +386,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
prev,\
source,\
M_DrawServerMenu,\
NULL,\
24,40,\
0,\
NULL,\
@@ -394,6 +400,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
prev,\
source,\
M_DrawControl,\
NULL,\
26, 40,\
0,\
NULL,\
@@ -407,6 +414,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
NULL,\
source,\
M_DrawImageDef,\
NULL,\
0, 0,\
0,\
NULL,\
+24
View File
@@ -2223,6 +2223,7 @@ menu_t MISC_AddonsDef =
&OP_DataOptionsDef,
MISC_AddonsMenu,
M_DrawAddons,
M_AddonsRefresh,
50, 28,
0,
NULL,
@@ -2236,6 +2237,7 @@ menu_t MISC_ReplayHutDef =
NULL,
MISC_ReplayHutMenu,
M_DrawReplayHut,
NULL,
30, 80,
0,
M_QuitReplayHut,
@@ -2249,6 +2251,7 @@ menu_t MISC_ReplayOptionsDef =
&OP_DataOptionsDef,
MISC_ReplayOptionsMenu,
M_DrawGenericMenu,
NULL,
27, 40,
0,
NULL,
@@ -2262,6 +2265,7 @@ menu_t MISC_ReplayStartDef =
&MISC_ReplayHutDef,
MISC_ReplayStartMenu,
M_DrawReplayStartMenu,
NULL,
30, 90,
0,
NULL,
@@ -2274,6 +2278,7 @@ menu_t PlaybackMenuDef = {
NULL,
PlaybackMenu,
M_DrawPlaybackMenu,
NULL,
//BASEVIDWIDTH/2 - 94, 2,
BASEVIDWIDTH/2 - 88, 2,
0,
@@ -2316,6 +2321,7 @@ menu_t SR_UnlockChecklistDef =
&SR_MainDef,
SR_UnlockChecklistMenu,
M_DrawChecklist,
NULL,
280, 185,
0,
NULL,
@@ -2329,6 +2335,7 @@ menu_t SR_MusicTestDef =
&OP_SoundOptionsDef,
SR_MusicTestMenu,
M_DrawMusicTest,
NULL,
60, 150,
0,
NULL,
@@ -2345,6 +2352,7 @@ menu_t SP_LevelStatsDef =
&SR_MainDef,
SP_LevelStatsMenu,
M_DrawLevelStats,
NULL,
280, 185,
0,
NULL,
@@ -2358,6 +2366,7 @@ static menu_t SP_TimeAttackDef =
&MainDef, // Doesn't matter.
SP_TimeAttackMenu,
M_DrawTimeAttackMenu,
NULL,
34, 40,
0,
M_QuitTimeAttackMenu,
@@ -2370,6 +2379,7 @@ static menu_t SP_ReplayDef =
&SP_TimeAttackDef,
SP_ReplayMenu,
M_DrawTimeAttackMenu,
NULL,
34, 40,
0,
NULL,
@@ -2382,6 +2392,7 @@ static menu_t SP_GuestReplayDef =
&SP_TimeAttackDef,
SP_GuestReplayMenu,
M_DrawTimeAttackMenu,
NULL,
34, 40,
0,
NULL,
@@ -2394,6 +2405,7 @@ static menu_t SP_GhostDef =
&SP_TimeAttackDef,
SP_GhostMenu,
M_DrawTimeAttackMenu,
NULL,
34, 40,
0,
NULL,
@@ -2408,6 +2420,7 @@ menu_t MP_MainDef =
&MainDef,
MP_MainMenu,
M_DrawMPMainMenu,
NULL,
42, 30,
0,
M_CancelConnect,
@@ -2425,6 +2438,7 @@ menu_t MP_ConnectDef =
&MP_MainDef,
MP_ConnectMenu,
M_DrawConnectMenu,
NULL,
27,24,
0,
M_CancelConnect,
@@ -2438,6 +2452,7 @@ menu_t MP_PlayerSetupDef =
&MP_MainDef,
MP_PlayerSetupMenu,
M_DrawSetupMultiPlayerMenu,
NULL,
36, 14,
0,
M_QuitMultiPlayerMenu,
@@ -2452,6 +2467,7 @@ menu_t OP_MainDef =
&MainDef,
OP_MainMenu,
M_DrawGenericMenu,
NULL,
60, 25,
0,
NULL,
@@ -2474,6 +2490,7 @@ menu_t OP_JoystickSetDef =
&OP_Joystick1Def,
OP_JoystickSetMenu,
M_DrawJoystick,
NULL,
50, 40,
0,
NULL,
@@ -2487,6 +2504,7 @@ menu_t OP_VideoOptionsDef =
&OP_MainDef,
OP_VideoOptionsMenu,
M_DrawVideoMenu,
NULL,
30, 15,
0,
NULL,
@@ -2500,6 +2518,7 @@ menu_t OP_VideoModeDef =
&OP_VideoOptionsDef,
OP_VideoModeMenu,
M_DrawVideoMode,
NULL,
48, 26,
0,
NULL,
@@ -2513,6 +2532,7 @@ menu_t OP_ColorOptionsDef =
&OP_VideoOptionsDef,
OP_ColorOptionsMenu,
M_DrawColorMenu,
NULL,
30, 30,
0,
NULL,
@@ -2526,6 +2546,7 @@ menu_t OP_SoundOptionsDef =
&OP_MainDef,
OP_SoundOptionsMenu,
M_DrawSkyRoom,
NULL,
30, 20,
0,
NULL,
@@ -2540,6 +2561,7 @@ menu_t OP_HUDOptionsDef =
&OP_MainDef,
OP_HUDOptionsMenu,
M_DrawHUDOptions,
NULL,
30, 20,
0,
NULL,
@@ -2569,6 +2591,7 @@ menu_t OP_MonitorToggleDef =
&OP_GameOptionsDef,
OP_MonitorToggleMenu,
M_DrawMonitorToggles,
NULL,
47, 30,
0,
NULL,
@@ -2616,6 +2639,7 @@ menu_t OP_ForkedBirdDef = {
&OP_MainDef,
OP_ForkedBirdMenu,
M_DrawLocalSkinMenu,
NULL,
30, 6,
0,
NULL,