mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-28 05:11:34 +00:00
Start on the replay hut menu!
This commit is contained in:
parent
6cc875bb50
commit
1602b0e3d9
3 changed files with 154 additions and 38 deletions
|
@ -368,9 +368,10 @@ void searchfilemenu(char *tempname)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean preparefilemenu(boolean samedepth)
|
boolean preparefilemenu(boolean samedepth, boolean replayhut)
|
||||||
{
|
{
|
||||||
(void)samedepth;
|
(void)samedepth;
|
||||||
|
(void)replayhut;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,9 +438,10 @@ void searchfilemenu(char *tempname)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean preparefilemenu(boolean samedepth)
|
boolean preparefilemenu(boolean samedepth, boolean replayhut)
|
||||||
{
|
{
|
||||||
(void)samedepth;
|
(void)samedepth;
|
||||||
|
(void)replayhut;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +712,7 @@ void searchfilemenu(char *tempname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean preparefilemenu(boolean samedepth)
|
boolean preparefilemenu(boolean samedepth, boolean replayhut)
|
||||||
{
|
{
|
||||||
DIR *dirhandle;
|
DIR *dirhandle;
|
||||||
struct dirent *dent;
|
struct dirent *dent;
|
||||||
|
@ -758,10 +760,14 @@ boolean preparefilemenu(boolean samedepth)
|
||||||
else // is a file or directory
|
else // is a file or directory
|
||||||
{
|
{
|
||||||
if (!S_ISDIR(fsstat.st_mode)) // file
|
if (!S_ISDIR(fsstat.st_mode)) // file
|
||||||
{
|
|
||||||
if (!cv_addons_showall.value)
|
|
||||||
{
|
{
|
||||||
size_t len = strlen(dent->d_name)+1;
|
size_t len = strlen(dent->d_name)+1;
|
||||||
|
if (replayhut)
|
||||||
|
{
|
||||||
|
if (strcasecmp(".lmp", dent->d_name+len-5)) continue; // Not a replay
|
||||||
|
}
|
||||||
|
else if (!cv_addons_showall.value)
|
||||||
|
{
|
||||||
UINT8 ext;
|
UINT8 ext;
|
||||||
for (ext = 0; ext < NUM_EXT_TABLE; ext++)
|
for (ext = 0; ext < NUM_EXT_TABLE; ext++)
|
||||||
if (!strcasecmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0]))) break; // extension comparison
|
if (!strcasecmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0]))) break; // extension comparison
|
||||||
|
@ -829,6 +835,14 @@ boolean preparefilemenu(boolean samedepth)
|
||||||
if (!S_ISDIR(fsstat.st_mode)) // file
|
if (!S_ISDIR(fsstat.st_mode)) // file
|
||||||
{
|
{
|
||||||
if (!((numfolders+pos) < sizecoredirmenu)) continue; // crash prevention
|
if (!((numfolders+pos) < sizecoredirmenu)) continue; // crash prevention
|
||||||
|
|
||||||
|
if (replayhut)
|
||||||
|
{
|
||||||
|
if (strcasecmp(".lmp", dent->d_name+len-5)) continue; // Not a replay
|
||||||
|
ext = EXT_TXT; // This isn't used anywhere but better safe than sorry for messing with this...
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (; ext < NUM_EXT_TABLE; ext++)
|
for (; ext < NUM_EXT_TABLE; ext++)
|
||||||
if (!strcasecmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0]))) break; // extension comparison
|
if (!strcasecmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0]))) break; // extension comparison
|
||||||
if (ext == NUM_EXT_TABLE && !cv_addons_showall.value) continue; // not an addfile-able (or exec-able) file
|
if (ext == NUM_EXT_TABLE && !cv_addons_showall.value) continue; // not an addfile-able (or exec-able) file
|
||||||
|
@ -862,6 +876,7 @@ boolean preparefilemenu(boolean samedepth)
|
||||||
|
|
||||||
if (!strcmp(dent->d_name, configfile))
|
if (!strcmp(dent->d_name, configfile))
|
||||||
ext |= EXT_LOADED;
|
ext |= EXT_LOADED;
|
||||||
|
}
|
||||||
|
|
||||||
folder = 0;
|
folder = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,6 @@ typedef enum
|
||||||
|
|
||||||
void closefilemenu(boolean validsize);
|
void closefilemenu(boolean validsize);
|
||||||
void searchfilemenu(char *tempname);
|
void searchfilemenu(char *tempname);
|
||||||
boolean preparefilemenu(boolean samedepth);
|
boolean preparefilemenu(boolean samedepth, boolean replayhut);
|
||||||
|
|
||||||
#endif // __FILESRCH_H__
|
#endif // __FILESRCH_H__
|
||||||
|
|
115
src/m_menu.c
115
src/m_menu.c
|
@ -336,6 +336,10 @@ static patch_t *addonsp[NUM_EXT+5];
|
||||||
|
|
||||||
#define numaddonsshown 4
|
#define numaddonsshown 4
|
||||||
|
|
||||||
|
// Replay hut
|
||||||
|
static void M_ReplayHut(INT32 choice);
|
||||||
|
static void M_DrawReplayHut(void);
|
||||||
|
|
||||||
// Drawing functions
|
// Drawing functions
|
||||||
static void M_DrawGenericMenu(void);
|
static void M_DrawGenericMenu(void);
|
||||||
static void M_DrawCenteredMenu(void);
|
static void M_DrawCenteredMenu(void);
|
||||||
|
@ -526,6 +530,13 @@ static menuitem_t MISC_AddonsMenu[] =
|
||||||
{IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleAddons, 0}, // dummy menuitem for the control func
|
{IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleAddons, 0}, // dummy menuitem for the control func
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static menuitem_t MISC_ReplayHutMenu[] =
|
||||||
|
{
|
||||||
|
{IT_SUBMENU |IT_STRING, NULL, "Replay Options...", NULL, 0},
|
||||||
|
|
||||||
|
{IT_KEYHANDLER|IT_NOTHING, NULL, "", NULL, 20}, // Dummy menuitem for the replay list
|
||||||
|
};
|
||||||
|
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
// Pause Menu Mode Attacking Edition
|
// Pause Menu Mode Attacking Edition
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
|
@ -700,7 +711,7 @@ static menuitem_t SR_MainMenu[] =
|
||||||
{
|
{
|
||||||
{IT_STRING|IT_SUBMENU, NULL, "Unlockables", &SR_UnlockChecklistDef, 0},
|
{IT_STRING|IT_SUBMENU, NULL, "Unlockables", &SR_UnlockChecklistDef, 0},
|
||||||
{IT_CALL|IT_STRING|IT_CALL_NOTMODIFIED, NULL, "Statistics", M_Statistics, 10},
|
{IT_CALL|IT_STRING|IT_CALL_NOTMODIFIED, NULL, "Statistics", M_Statistics, 10},
|
||||||
{IT_CALL|IT_STRING, NULL, "Replay Hut", M_Statistics, 20},
|
{IT_CALL|IT_STRING, NULL, "Replay Hut", M_ReplayHut, 20},
|
||||||
{IT_DISABLED, NULL, "", NULL, 0}, // Custom1
|
{IT_DISABLED, NULL, "", NULL, 0}, // Custom1
|
||||||
{IT_DISABLED, NULL, "", NULL, 0}, // Custom2
|
{IT_DISABLED, NULL, "", NULL, 0}, // Custom2
|
||||||
{IT_DISABLED, NULL, "", NULL, 0}, // Custom3
|
{IT_DISABLED, NULL, "", NULL, 0}, // Custom3
|
||||||
|
@ -1583,6 +1594,18 @@ menu_t MISC_AddonsDef =
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
menu_t MISC_ReplayHutDef =
|
||||||
|
{
|
||||||
|
"M_REPLAY",
|
||||||
|
sizeof (MISC_ReplayHutMenu)/sizeof (menuitem_t),
|
||||||
|
&MainDef,
|
||||||
|
MISC_ReplayHutMenu,
|
||||||
|
M_DrawReplayHut,
|
||||||
|
30, 80,
|
||||||
|
0,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
menu_t MAPauseDef = PAUSEMENUSTYLE(MAPauseMenu, 40, 72);
|
menu_t MAPauseDef = PAUSEMENUSTYLE(MAPauseMenu, 40, 72);
|
||||||
menu_t SPauseDef = PAUSEMENUSTYLE(SPauseMenu, 40, 72);
|
menu_t SPauseDef = PAUSEMENUSTYLE(SPauseMenu, 40, 72);
|
||||||
menu_t MPauseDef = PAUSEMENUSTYLE(MPauseMenu, 40, 72);
|
menu_t MPauseDef = PAUSEMENUSTYLE(MPauseMenu, 40, 72);
|
||||||
|
@ -4471,7 +4494,7 @@ static void M_Addons(INT32 choice)
|
||||||
else
|
else
|
||||||
--menupathindex[menudepthleft];
|
--menupathindex[menudepthleft];
|
||||||
|
|
||||||
if (!preparefilemenu(false))
|
if (!preparefilemenu(false, false))
|
||||||
{
|
{
|
||||||
M_StartMessage(va("No files/folders found.\n\n%s\n\n(Press a key)\n", (recommendedflags == V_SKYMAP ? LOCATIONSTRING2 : LOCATIONSTRING1)),NULL,MM_NOTHING);
|
M_StartMessage(va("No files/folders found.\n\n%s\n\n(Press a key)\n", (recommendedflags == V_SKYMAP ? LOCATIONSTRING2 : LOCATIONSTRING1)),NULL,MM_NOTHING);
|
||||||
return;
|
return;
|
||||||
|
@ -4595,7 +4618,7 @@ static void M_AddonsClearName(INT32 choice)
|
||||||
// returns whether to do message draw
|
// returns whether to do message draw
|
||||||
static boolean M_AddonsRefresh(void)
|
static boolean M_AddonsRefresh(void)
|
||||||
{
|
{
|
||||||
if ((refreshdirmenu & REFRESHDIR_NORMAL) && !preparefilemenu(true))
|
if ((refreshdirmenu & REFRESHDIR_NORMAL) && !preparefilemenu(true, false))
|
||||||
{
|
{
|
||||||
UNEXIST;
|
UNEXIST;
|
||||||
if (refreshdirname)
|
if (refreshdirname)
|
||||||
|
@ -4844,7 +4867,7 @@ static void M_HandleAddons(INT32 choice)
|
||||||
if (dirmenu && dirmenu[dir_on[menudepthleft]])
|
if (dirmenu && dirmenu[dir_on[menudepthleft]])
|
||||||
tempname = Z_StrDup(dirmenu[dir_on[menudepthleft]]+DIR_STRING); // don't need to I_Error if can't make - not important, just QoL
|
tempname = Z_StrDup(dirmenu[dir_on[menudepthleft]]+DIR_STRING); // don't need to I_Error if can't make - not important, just QoL
|
||||||
#if 0 // much slower
|
#if 0 // much slower
|
||||||
if (!preparefilemenu(true))
|
if (!preparefilemenu(true, false))
|
||||||
{
|
{
|
||||||
UNEXIST;
|
UNEXIST;
|
||||||
return;
|
return;
|
||||||
|
@ -4898,13 +4921,13 @@ static void M_HandleAddons(INT32 choice)
|
||||||
menupathindex[--menudepthleft] = strlen(menupath);
|
menupathindex[--menudepthleft] = strlen(menupath);
|
||||||
menupath[menupathindex[menudepthleft]] = 0;
|
menupath[menupathindex[menudepthleft]] = 0;
|
||||||
|
|
||||||
if (!preparefilemenu(false))
|
if (!preparefilemenu(false, false))
|
||||||
{
|
{
|
||||||
S_StartSound(NULL, sfx_s224);
|
S_StartSound(NULL, sfx_s224);
|
||||||
M_StartMessage(va("%c%s\x80\nThis folder is empty.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), M_AddonsHeaderPath()),NULL,MM_NOTHING);
|
M_StartMessage(va("%c%s\x80\nThis folder is empty.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), M_AddonsHeaderPath()),NULL,MM_NOTHING);
|
||||||
menupath[menupathindex[++menudepthleft]] = 0;
|
menupath[menupathindex[++menudepthleft]] = 0;
|
||||||
|
|
||||||
if (!preparefilemenu(true))
|
if (!preparefilemenu(true, false))
|
||||||
{
|
{
|
||||||
UNEXIST;
|
UNEXIST;
|
||||||
return;
|
return;
|
||||||
|
@ -4927,7 +4950,7 @@ static void M_HandleAddons(INT32 choice)
|
||||||
case EXT_UP:
|
case EXT_UP:
|
||||||
S_StartSound(NULL, sfx_menu1);
|
S_StartSound(NULL, sfx_menu1);
|
||||||
menupath[menupathindex[++menudepthleft]] = 0;
|
menupath[menupathindex[++menudepthleft]] = 0;
|
||||||
if (!preparefilemenu(false))
|
if (!preparefilemenu(false, false))
|
||||||
{
|
{
|
||||||
UNEXIST;
|
UNEXIST;
|
||||||
return;
|
return;
|
||||||
|
@ -4984,6 +5007,84 @@ static void M_HandleAddons(INT32 choice)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- REPLAY HUT -----
|
||||||
|
|
||||||
|
static INT16 replayOn = 0;
|
||||||
|
|
||||||
|
static void M_ReplayHut(INT32 choice)
|
||||||
|
{
|
||||||
|
(void)choice;
|
||||||
|
|
||||||
|
snprintf(menupath, 1024, "%s"PATHSEP"replay"PATHSEP"online"PATHSEP, srb2home);
|
||||||
|
menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath);
|
||||||
|
|
||||||
|
if (!preparefilemenu(false, true))
|
||||||
|
{
|
||||||
|
M_StartMessage("No replays found.\n\n(Press a key)\n", NULL, MM_NOTHING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dir_on[menudepthleft] = 0;
|
||||||
|
|
||||||
|
M_SetupNextMenu(&MISC_ReplayHutDef);
|
||||||
|
G_SetGamestate(GS_TIMEATTACK);
|
||||||
|
|
||||||
|
S_ChangeMusicInternal("replst", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void M_DrawReplayHut(void)
|
||||||
|
{
|
||||||
|
INT32 x, y, cursory = 0;
|
||||||
|
INT16 i;
|
||||||
|
|
||||||
|
(void)cursory;
|
||||||
|
|
||||||
|
V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_CACHE));
|
||||||
|
M_DrawMenuTitle();
|
||||||
|
|
||||||
|
// Draw menu choices
|
||||||
|
x = currentMenu->x;
|
||||||
|
y = currentMenu->y;
|
||||||
|
|
||||||
|
if (itemOn == currentMenu->numitems-1)
|
||||||
|
{
|
||||||
|
INT32 maxy;
|
||||||
|
// Scroll menu items if needed
|
||||||
|
cursory = y + currentMenu->menuitems[currentMenu->numitems-1].alphaKey + replayOn*10;
|
||||||
|
maxy = y + currentMenu->menuitems[currentMenu->numitems-1].alphaKey + sizedirmenu*10;
|
||||||
|
|
||||||
|
if (cursory > maxy - 70)
|
||||||
|
cursory = maxy - 70;
|
||||||
|
|
||||||
|
if (cursory > 130)
|
||||||
|
y -= (cursory-130);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw static menu items
|
||||||
|
for (i = 0; i < currentMenu->numitems-1; i++)
|
||||||
|
{
|
||||||
|
if (i == itemOn)
|
||||||
|
cursory = y;
|
||||||
|
|
||||||
|
if ((currentMenu->menuitems[i].status & IT_DISPLAY)==IT_STRING)
|
||||||
|
V_DrawString(x, y + currentMenu->menuitems[i].alphaKey, 0, currentMenu->menuitems[i].text);
|
||||||
|
else
|
||||||
|
V_DrawString(x, y + currentMenu->menuitems[i].alphaKey, highlightflags, currentMenu->menuitems[i].text);
|
||||||
|
}
|
||||||
|
|
||||||
|
y += currentMenu->menuitems[currentMenu->numitems-1].alphaKey;
|
||||||
|
|
||||||
|
for (i = 0; i < (INT16)sizedirmenu; i++)
|
||||||
|
{
|
||||||
|
V_DrawString(x, y+i*10, V_ALLOWLOWERCASE, dirmenu[i]+DIR_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw the cursor
|
||||||
|
V_DrawScaledPatch(currentMenu->x - 24, cursory, 0,
|
||||||
|
W_CachePatchName("M_CURSOR", PU_CACHE));
|
||||||
|
V_DrawString(currentMenu->x, cursory, highlightflags, currentMenu->menuitems[itemOn].text);
|
||||||
|
}
|
||||||
|
|
||||||
static void M_PandorasBox(INT32 choice)
|
static void M_PandorasBox(INT32 choice)
|
||||||
{
|
{
|
||||||
(void)choice;
|
(void)choice;
|
||||||
|
|
Loading…
Reference in a new issue