From 49f75520092a5abb39b80bde50705506c6eea022 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 4 Sep 2022 21:44:39 +0100 Subject: [PATCH] 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 --- src/k_menudraw.c | 6 +++++- src/k_menufunc.c | 7 +++---- src/k_profiles.c | 36 +++++++++++++++++++++++------------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 71beb1cc4..062eec3b2 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -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; } } diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 7608ccaab..e1e14c8ef 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -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); diff --git a/src/k_profiles.c b/src/k_profiles.c index 5067b98ae..5f50d189f 100644 --- a/src/k_profiles.c +++ b/src/k_profiles.c @@ -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); } }