Improve profile deletion further

- Also adjust cv_currprofile in PR_DeleteProfile, instead of half-heartedly outside
- Make it clearer if you're going to destroy your current profile
- Add an "[In use]" identifier to the menu's visuals
This commit is contained in:
toaster 2022-09-04 21:44:39 +01:00
parent de5370b134
commit 49f7552009
3 changed files with 31 additions and 18 deletions

View file

@ -2852,7 +2852,11 @@ void M_DrawProfileErase(void)
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));
V_DrawString(x, y,
(i == optionsmenu.eraseprofilen ? highlightflags : 0)|V_ALLOWLOWERCASE,
va("%sPRF%03d - %s (%s)",
(cv_currprofile.value == i) ? "[In use] " : "",
i, pr->profilename, pr->playername));
y += SMALLLINEHEIGHT;
}
}

View file

@ -5536,14 +5536,13 @@ static void M_EraseProfileResponse(INT32 choice)
{
if (choice == MA_YES)
{
const boolean current = (optionsmenu.eraseprofilen == cv_currprofile.value); // has to be grabbed before deletion
S_StartSound(NULL, sfx_itrole); // bweh heh heh
PR_DeleteProfile(optionsmenu.eraseprofilen);
if (current)
// Did we bust our current profile..!?
if (cv_currprofile.value == -1)
{
CV_StealthSetValue(&cv_currprofile, -1);
F_StartIntro();
M_ClearMenus(true);
}
@ -5589,7 +5588,7 @@ void M_HandleProfileErase(INT32 choice)
else if (M_MenuConfirmPressed(pid))
{
if (optionsmenu.eraseprofilen == cv_currprofile.value)
M_StartMessage("This profile will be erased.\nAre you sure you want to proceed?\nDeleting this profile will also\nreturn you to the title screen.\n\n(Press A to confirm)", FUNCPTRCAST(M_EraseProfileResponse), MM_YESNO);
M_StartMessage("Your ""\x85""current profile""\x80"" will be erased.\nAre you sure you want to proceed?\nDeleting this profile will also\nreturn you to the title screen.\n\n(Press A to confirm)", FUNCPTRCAST(M_EraseProfileResponse), MM_YESNO);
else
M_StartMessage("This profile will be erased.\nAre you sure you want to proceed?\n\n(Press A to confirm)", FUNCPTRCAST(M_EraseProfileResponse), MM_YESNO);

View file

@ -117,30 +117,40 @@ boolean PR_DeleteProfile(INT32 num)
profilesList[i] = profilesList[i+1];
}
// Make sure to move cv_lastprofile (and title profile) values as well!
for (i = 0; i < MAXSPLITSCREENPLAYERS+1; i++)
// Make sure to move cv_lastprofile (and title/current profile) values as well!
for (i = 0; i < MAXSPLITSCREENPLAYERS+2; i++)
{
consvar_t *cv = (i == MAXSPLITSCREENPLAYERS) ? &cv_ttlprofilen : &cv_lastprofile[i];
INT32 profileset = cv->value;
consvar_t *cv;
if (profileset < num)
if (i < MAXSPLITSCREENPLAYERS)
cv = &cv_lastprofile[i];
else if (i == MAXSPLITSCREENPLAYERS)
cv = &cv_ttlprofilen;
else
cv = &cv_currprofile;
if (cv->value < num)
{
// Not affected.
continue;
}
if (profileset > num)
if (cv->value > num)
{
// Shift our lastprofile number down to match the new order.
profileset--;
}
else
{
// There's no hope for it. If we were on the deleted profile, default back to guest.
profileset = PROFILE_GUEST;
CV_StealthSetValue(cv, cv->value-1);
continue;
}
CV_StealthSetValue(cv, profileset);
if (cv != &cv_currprofile)
{
// There's no hope for it. If we were on the deleted profile, default back to guest.
CV_StealthSetValue(cv, PROFILE_GUEST);
continue;
}
// Oh boy, now we're really in for it.
CV_StealthSetValue(cv, -1);
}
}