mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-03 20:26:05 +00:00
profiles may now be deleted from data options
This commit is contained in:
parent
51d21ec388
commit
d5d34f9b99
6 changed files with 165 additions and 1 deletions
12
src/k_menu.h
12
src/k_menu.h
|
|
@ -288,6 +288,9 @@ extern menu_t OPTIONS_DataDiscordDef;
|
|||
extern menuitem_t OPTIONS_DataErase[];
|
||||
extern menu_t OPTIONS_DataEraseDef;
|
||||
|
||||
extern menuitem_t OPTIONS_DataProfileErase[];
|
||||
extern menu_t OPTIONS_DataProfileEraseDef;
|
||||
|
||||
// EXTRAS
|
||||
extern menuitem_t EXTRAS_Main[];
|
||||
extern menu_t EXTRAS_MainDef;
|
||||
|
|
@ -449,6 +452,8 @@ extern boolean menuwipe;
|
|||
extern consvar_t cv_showfocuslost;
|
||||
extern consvar_t cv_chooseskin, cv_serversort;
|
||||
|
||||
void M_SetMenuDelay(UINT8 i);
|
||||
|
||||
void Moviemode_mode_Onchange(void);
|
||||
void Screenshot_option_Onchange(void);
|
||||
void Addons_option_Onchange(void);
|
||||
|
|
@ -702,6 +707,8 @@ extern struct optionsmenu_s {
|
|||
|
||||
UINT8 erasecontext;
|
||||
|
||||
UINT8 eraseprofilen;
|
||||
|
||||
// background:
|
||||
INT16 currcolour;
|
||||
INT16 lastcolour;
|
||||
|
|
@ -723,6 +730,7 @@ void M_OptionsChangeBGColour(INT16 newcolour); // changes the background colour
|
|||
|
||||
void M_HandleItemToggles(INT32 choice); // For item toggling
|
||||
void M_EraseData(INT32 choice); // For data erasing
|
||||
void M_CheckProfileData(INT32 choice); // check if we have profiles.
|
||||
|
||||
// profile selection menu
|
||||
void M_ProfileSelectInit(INT32 choice);
|
||||
|
|
@ -745,6 +753,9 @@ void M_ProfileTryController(INT32 choice);
|
|||
void M_VideoModeMenu(INT32 choice);
|
||||
void M_HandleVideoModes(INT32 ch);
|
||||
|
||||
// data stuff
|
||||
void M_HandleProfileErase(INT32 choice);
|
||||
|
||||
|
||||
// Extras menu:
|
||||
#define DF_ENCORE 0x40
|
||||
|
|
@ -884,6 +895,7 @@ void M_DrawEditProfile(void);
|
|||
void M_DrawProfileControls(void);
|
||||
void M_DrawVideoModes(void);
|
||||
void M_DrawItemToggles(void);
|
||||
void M_DrawProfileErase(void);
|
||||
extern tic_t shitsfree;
|
||||
|
||||
// Extras menu:
|
||||
|
|
|
|||
|
|
@ -1344,6 +1344,12 @@ menuitem_t OPTIONS_DataErase[] =
|
|||
{IT_SPACE | IT_NOTHING, NULL, NULL,
|
||||
NULL, {NULL}, 0, 0},
|
||||
|
||||
{IT_STRING | IT_CALL, "Erase Profile Data...", "Select a Profile to erase.",
|
||||
NULL, {.routine = M_CheckProfileData}, 0, 0},
|
||||
|
||||
{IT_SPACE | IT_NOTHING, NULL, NULL,
|
||||
NULL, {NULL}, 0, 0},
|
||||
|
||||
{IT_STRING | IT_CALL, "\x85\x45rase all Data", "Be careful! What's deleted is gone forever!",
|
||||
NULL, {.routine = M_EraseData}, 0, 0},
|
||||
|
||||
|
|
@ -1364,7 +1370,25 @@ menu_t OPTIONS_DataEraseDef = {
|
|||
NULL,
|
||||
};
|
||||
|
||||
menuitem_t OPTIONS_DataProfileErase[] =
|
||||
{
|
||||
{IT_NOTHING | IT_KEYHANDLER, NULL, NULL, NULL, {.routine = M_HandleProfileErase}, 0, 0},
|
||||
};
|
||||
|
||||
menu_t OPTIONS_DataProfileEraseDef = {
|
||||
sizeof (OPTIONS_DataProfileErase) / sizeof (menuitem_t),
|
||||
&OPTIONS_DataEraseDef,
|
||||
0,
|
||||
OPTIONS_DataProfileErase,
|
||||
48, 80,
|
||||
SKINCOLOR_BLUEBERRY, 0,
|
||||
2, 10,
|
||||
M_DrawProfileErase,
|
||||
M_OptionsTick,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
// extras menu
|
||||
menuitem_t EXTRAS_Main[] =
|
||||
|
|
|
|||
|
|
@ -2554,6 +2554,32 @@ void M_DrawGenericOptions(void)
|
|||
}
|
||||
}
|
||||
|
||||
// *Heavily* simplified version of the generic options menu, cattered only towards erasing profiles.
|
||||
void M_DrawProfileErase(void)
|
||||
{
|
||||
INT32 x = currentMenu->x - menutransition.tics*48, y = currentMenu->y-SMALLLINEHEIGHT, i, cursory = 0;
|
||||
UINT8 np = PR_GetNumProfiles();
|
||||
|
||||
M_DrawOptionsCogs();
|
||||
M_DrawMenuTooltips();
|
||||
M_DrawOptionsMovingButton();
|
||||
|
||||
for (i = 1; i < np; i++)
|
||||
{
|
||||
|
||||
profile_t *pr = PR_GetProfile(i);
|
||||
|
||||
if (i == optionsmenu.eraseprofilen)
|
||||
{
|
||||
cursory = y;
|
||||
V_DrawScaledPatch(x - 24, cursory, 0, W_CachePatchName("M_CURSOR", PU_CACHE));
|
||||
}
|
||||
|
||||
V_DrawString(x, y, i == optionsmenu.eraseprofilen ? highlightflags : 0, va("PRF%03d - %s (%s)", i, pr->profilename, pr->playername));
|
||||
y += SMALLLINEHEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
// Draws profile selection
|
||||
void M_DrawProfileSelect(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1132,7 +1132,7 @@ void M_GoBack(INT32 choice)
|
|||
//
|
||||
// M_Ticker
|
||||
//
|
||||
static void M_SetMenuDelay(UINT8 i)
|
||||
void M_SetMenuDelay(UINT8 i)
|
||||
{
|
||||
menucmd[i].delayCount++;
|
||||
if (menucmd[i].delayCount < 1)
|
||||
|
|
@ -4727,6 +4727,84 @@ void M_HandleItemToggles(INT32 choice)
|
|||
}
|
||||
}
|
||||
|
||||
// Check if we have any profile loaded.
|
||||
void M_CheckProfileData(INT32 choice)
|
||||
{
|
||||
UINT8 np = PR_GetNumProfiles();
|
||||
(void) choice;
|
||||
|
||||
if (np < 2)
|
||||
{
|
||||
S_StartSound(NULL, sfx_s3k7b);
|
||||
M_StartMessage("There are no custom Profiles.\n\n(Press any button)", NULL, MM_NOTHING);
|
||||
return;
|
||||
}
|
||||
|
||||
optionsmenu.eraseprofilen = 1;
|
||||
M_SetupNextMenu(&OPTIONS_DataProfileEraseDef, false);
|
||||
}
|
||||
|
||||
static void M_EraseProfileResponse(INT32 choice)
|
||||
{
|
||||
if (choice == MA_YES)
|
||||
{
|
||||
S_StartSound(NULL, sfx_itrole); // bweh heh heh
|
||||
|
||||
PR_DeleteProfile(optionsmenu.eraseprofilen);
|
||||
|
||||
if (optionsmenu.eraseprofilen == cv_currprofile.value)
|
||||
{
|
||||
CV_StealthSetValue(&cv_currprofile, -1);
|
||||
F_StartIntro();
|
||||
M_ClearMenus(true);
|
||||
}
|
||||
else
|
||||
optionsmenu.eraseprofilen = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void M_HandleProfileErase(INT32 choice)
|
||||
{
|
||||
const UINT8 pid = 0;
|
||||
const UINT8 np = PR_GetNumProfiles()-1;
|
||||
(void) choice;
|
||||
|
||||
if (menucmd[pid].dpad_ud > 0)
|
||||
{
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
optionsmenu.eraseprofilen++;
|
||||
|
||||
if (optionsmenu.eraseprofilen > np)
|
||||
optionsmenu.eraseprofilen = 1;
|
||||
|
||||
M_SetMenuDelay(pid);
|
||||
}
|
||||
else if (menucmd[pid].dpad_ud < 0)
|
||||
{
|
||||
S_StartSound(NULL, sfx_menu1);
|
||||
|
||||
if (optionsmenu.eraseprofilen == 1)
|
||||
optionsmenu.eraseprofilen = np;
|
||||
else
|
||||
optionsmenu.eraseprofilen--;
|
||||
|
||||
M_SetMenuDelay(pid);
|
||||
}
|
||||
else if (M_MenuBackPressed(pid))
|
||||
{
|
||||
M_GoBack(0);
|
||||
M_SetMenuDelay(pid);
|
||||
}
|
||||
else if (M_MenuConfirmPressed(pid))
|
||||
{
|
||||
if (optionsmenu.eraseprofilen == cv_currprofile.value)
|
||||
M_StartMessage("This profile and all of\nits data will be erased.\nAre you sure you want to proceed?\nAs this is your currently loaded Profile,\ndeleting this Profile would also\nreturn you to the Title Screen\n\n(Press A to confirm)", FUNCPTRCAST(M_EraseProfileResponse), MM_YESNO);
|
||||
else
|
||||
M_StartMessage("This profile and all of\nits data will be erased.\nAre you sure you want to proceed?\n\n(Press A to confirm)", FUNCPTRCAST(M_EraseProfileResponse), MM_YESNO);
|
||||
|
||||
M_SetMenuDelay(pid);
|
||||
}
|
||||
}
|
||||
|
||||
// Extras menu;
|
||||
// this is copypasted from the options menu but all of these are different functions in case we ever want it to look more unique
|
||||
|
|
|
|||
|
|
@ -80,6 +80,25 @@ profile_t* PR_GetProfile(INT32 num)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
boolean PR_DeleteProfile(INT32 num)
|
||||
{
|
||||
UINT8 i;
|
||||
if (num <= 0 || num > numprofiles)
|
||||
return false;
|
||||
|
||||
// If we're deleting inbetween profiles, move everything.
|
||||
if (num < numprofiles)
|
||||
for (i = num; i < numprofiles-1; i++)
|
||||
profilesList[i] = profilesList[i+1];
|
||||
|
||||
// In any case, delete the last profile as well.
|
||||
profilesList[numprofiles] = NULL;
|
||||
numprofiles--;
|
||||
|
||||
PR_SaveProfiles();
|
||||
return true;
|
||||
}
|
||||
|
||||
void PR_InitNewProfile(void)
|
||||
{
|
||||
char pname[PROFILENAMELEN+1] = "PRF";
|
||||
|
|
|
|||
|
|
@ -90,6 +90,11 @@ boolean PR_AddProfile(profile_t *p);
|
|||
// Returns a pointer to the profile you're asking for or NULL if the profile is uninitialized.
|
||||
profile_t* PR_GetProfile(INT32 num);
|
||||
|
||||
// PR_DeleteProfile(INT32 n)
|
||||
// Deletes the specified profile. n cannot be 0. Returns false if the profile couldn't be deleted, true otherwise.
|
||||
// This will also move every profile back accordingly to ensure the table has no empty profiles inbetween two valid profiles.
|
||||
boolean PR_DeleteProfile(INT32 n);
|
||||
|
||||
// PR_InitNewProfile(void)
|
||||
// Initializes the first new profile
|
||||
void PR_InitNewProfile(void);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue