From 89cef3f9c96c163530bc6200e997038abd1ab13a Mon Sep 17 00:00:00 2001 From: danellos <6340021+danellos@users.noreply.github.com> Date: Mon, 15 Jul 2019 01:39:44 -0400 Subject: [PATCH] Note about NO selected by default; fixed a bug with Delete. --- SourceX/DiabloUI/selhero.cpp | 29 ++++++++++++++++------------- SourceX/DiabloUI/selyesno.cpp | 21 ++++++++++++++------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/SourceX/DiabloUI/selhero.cpp b/SourceX/DiabloUI/selhero.cpp index f5d543e2c..d4c7dfbc6 100644 --- a/SourceX/DiabloUI/selhero.cpp +++ b/SourceX/DiabloUI/selhero.cpp @@ -16,8 +16,9 @@ char selhero_Lable[32]; char selhero_Description[256]; int selhero_result; bool selhero_endMenu; -bool isMultiPlayer; -bool navigateConfirm; +bool selhero_isMultiPlayer; +bool selhero_navigateYesNo; +bool selhero_deleteEnabled; BOOL(*gfnHeroStats) (unsigned int, _uidefaultstats *); @@ -107,7 +108,7 @@ void selhero_List_Init() sprintf(listItems[i], "New Hero"); sprintf(title, "Single Player Characters"); - if (isMultiPlayer) { + if (selhero_isMultiPlayer) { sprintf(title, "Multi Player Characters"); } } @@ -119,6 +120,7 @@ void selhero_List_Focus(int value) memcpy(&selhero_heroInfo, &selhero_heros[value], sizeof(selhero_heroInfo)); selhero_SetStats(); SELLIST_DIALOG[8].flags = baseFlags | UIS_GOLD; + selhero_deleteEnabled = true; return; } @@ -129,11 +131,12 @@ void selhero_List_Focus(int value) sprintf(textStats[3], "--"); sprintf(textStats[4], "--"); SELLIST_DIALOG[8].flags = baseFlags | UIS_DISABLED; + selhero_deleteEnabled = false; } void selhero_List_DeleteConfirm(int value) { - navigateConfirm = true; + selhero_navigateYesNo = selhero_deleteEnabled; } void selhero_List_Select(int value) @@ -142,7 +145,7 @@ void selhero_List_Select(int value) UiInitList(0, 2, selhero_ClassSelector_Focus, selhero_ClassSelector_Select, selhero_ClassSelector_Esc, SELCLASS_DIALOG, size(SELCLASS_DIALOG)); memset(&selhero_heroInfo.name, 0, sizeof(selhero_heroInfo.name)); sprintf(title, "New Single Player Hero"); - if (isMultiPlayer) { + if (selhero_isMultiPlayer) { sprintf(title, "New Multi Player Hero"); } return; @@ -181,7 +184,7 @@ void selhero_ClassSelector_Focus(int value) void selhero_ClassSelector_Select(int value) { sprintf(title, "New Single Player Hero"); - if (isMultiPlayer) { + if (selhero_isMultiPlayer) { sprintf(title, "New Multi Player Hero"); } memset(selhero_heroInfo.name, '\0', sizeof(selhero_heroInfo.name)); @@ -249,7 +252,7 @@ BOOL UiSelHeroDialog( gfnHeroDelete = fnremove; LoadBackgroundArt("ui_art\\selhero.pcx"); - navigateConfirm = false; + selhero_navigateYesNo = false; selhero_SaveCount = 0; fninfo(SelHero_GetHeroInfo); @@ -261,18 +264,18 @@ BOOL UiSelHeroDialog( } selhero_endMenu = false; - while (!selhero_endMenu && !navigateConfirm) { + while (!selhero_endMenu && !selhero_navigateYesNo) { UiRenderItems(SELHERO_DIALOG, size(SELHERO_DIALOG)); UiRender(); } BlackPalette(); selhero_Free(); - if (navigateConfirm) { - if (!UiSelHeroDelYesNoDialog(gfnHeroDelete, &selhero_heroInfo, isMultiPlayer)) + if (selhero_navigateYesNo) { + if (!UiSelHeroDelYesNoDialog(gfnHeroDelete, &selhero_heroInfo, selhero_isMultiPlayer)) app_fatal("Unable to load Yes/No dialog"); } - } while (navigateConfirm); + } while (selhero_navigateYesNo); *dlgresult = selhero_result; strcpy(name, selhero_heroInfo.name); @@ -289,7 +292,7 @@ BOOL UiSelHeroSingDialog( char *name, int *difficulty) { - isMultiPlayer = false; + selhero_isMultiPlayer = false; return UiSelHeroDialog(fninfo, fncreate, fnstats, fnremove, dlgresult, name); } @@ -302,7 +305,7 @@ BOOL UiSelHeroMultDialog( BOOL *hero_is_created, char *name) { - isMultiPlayer = true; + selhero_isMultiPlayer = true; return UiSelHeroDialog(fninfo, fncreate, fnstats, fnremove, dlgresult, name); } } diff --git a/SourceX/DiabloUI/selyesno.cpp b/SourceX/DiabloUI/selyesno.cpp index ab1c2df79..d75d23b1d 100644 --- a/SourceX/DiabloUI/selyesno.cpp +++ b/SourceX/DiabloUI/selyesno.cpp @@ -9,15 +9,15 @@ _uiheroinfo selyesno_heroInfo; int selyesno_endMenu; BOOL(*selyesno_gfnRemove) (_uiheroinfo *); -char confirmationMessage[256]; +char selyesno_confirmationMessage[256]; char selyesno_title[32]; UI_Item DEL_SELYESNO_DIALOG[] = { { { 0, 0, 640, 480 }, UI_IMAGE, 0, 0, NULL, &ArtBackground }, { { 24, 161, 590, 35 }, UI_TEXT, UIS_CENTER | UIS_BIG, 0, selyesno_title }, - { { 100, 230, 280, 270 }, UI_TEXT, UIS_BIG, 0, confirmationMessage }, - { { 230, 390, 180, 35 }, UI_LIST, UIS_CENTER | UIS_BIG | UIS_GOLD, 1, "Yes" }, - { { 230, 426, 180, 35 }, UI_LIST, UIS_CENTER | UIS_BIG | UIS_GOLD, 0, "No" }, + { { 100, 230, 280, 270 }, UI_TEXT, UIS_BIG, 0, selyesno_confirmationMessage }, + { { 230, 390, 180, 35 }, UI_LIST, UIS_CENTER | UIS_BIG | UIS_GOLD, 0, "Yes" }, + { { 230, 426, 180, 35 }, UI_LIST, UIS_CENTER | UIS_BIG | UIS_GOLD, 1, "No" }, }; void selyesno_Free() @@ -28,7 +28,7 @@ void selyesno_Free() void selyesno_Select(int value) { - if (value == 1) + if (value == 0) selyesno_gfnRemove(&selyesno_heroInfo); selyesno_endMenu = true; @@ -54,11 +54,19 @@ BOOL UiSelHeroDelYesNoDialog( sprintf(selyesno_title, "Delete Single Player Hero"); } - sprintf(confirmationMessage, "Are you sure you want to delete the character \"%s\"?", selyesno_heroInfo.name); + sprintf(selyesno_confirmationMessage, "Are you sure you want to delete the character \"%s\"?", selyesno_heroInfo.name); WordWrap(&DEL_SELYESNO_DIALOG[2]); UiInitList(0, 1, NULL, selyesno_Select, selyesno_Esc, DEL_SELYESNO_DIALOG, size(DEL_SELYESNO_DIALOG), false, NULL); + // forcing the default selection to be "No", + // remove this code to be consistent with + // the retail v 1.09 game + SDL_Event sdlevent = {}; + sdlevent.type = SDL_KEYDOWN; + sdlevent.key.keysym.sym = SDLK_DOWN; + SDL_PushEvent(&sdlevent); + selyesno_endMenu = false; while (!selyesno_endMenu) { UiRenderItems(DEL_SELYESNO_DIALOG, size(DEL_SELYESNO_DIALOG)); @@ -70,5 +78,4 @@ BOOL UiSelHeroDelYesNoDialog( selyesno_Free(); return true; } - }