From 0e0d41376fb07fe414900eec22acf149055b9e6b Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 1 Feb 2019 22:43:08 +0100 Subject: [PATCH] Enum for dlgresult --- Source/mainmenu.cpp | 6 +++--- Stub/DiabloUI/selhero.cpp | 8 +++++--- enums.h | 7 +++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index af5503d83..d0d090080 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -35,7 +35,7 @@ int __stdcall mainmenu_select_hero_dialog( BOOL *multi) { BOOL hero_is_created = TRUE; - int dlgresult = 0; + int dlgresult = NEW_GAME; if (gbMaxPlayers == 1) { if (!UiSelHeroSingDialog( pfile_ui_set_hero_infos, @@ -48,7 +48,7 @@ int __stdcall mainmenu_select_hero_dialog( TermMsg("Unable to display SelHeroSing"); - if (dlgresult == 2) + if (dlgresult == LOAD_GAME) gbLoadGame = TRUE; else gbLoadGame = FALSE; @@ -63,7 +63,7 @@ int __stdcall mainmenu_select_hero_dialog( gszHero)) { TermMsg("Can't load multiplayer dialog"); } - if (dlgresult == 4) { + if (dlgresult == EXIT_MENU) { SErrSetLastError(1223); return 0; } diff --git a/Stub/DiabloUI/selhero.cpp b/Stub/DiabloUI/selhero.cpp index a4c365212..b18f8ebc0 100644 --- a/Stub/DiabloUI/selhero.cpp +++ b/Stub/DiabloUI/selhero.cpp @@ -251,7 +251,7 @@ BOOL __stdcall UiSelHeroSingDialog( break; } - *dlgresult = 4; + *dlgresult = EXIT_MENU; endMenu = true; break; case SDLK_BACKSPACE: @@ -281,6 +281,8 @@ BOOL __stdcall UiSelHeroSingDialog( case SINGLEPLAYER_LOAD: if (SelectedItem == SelectedItemMax) { SetMenu(SINGLEPLAYER_CLASSES); + } else { + *dlgresult = LOAD_GAME; } break; case SINGLEPLAYER_CLASSES: @@ -365,7 +367,7 @@ BOOL __stdcall UiSelHeroSingDialog( const char *test_name = chr_name_str; if (!StartNewGame) { - *dlgresult = 2; // This means load game + *dlgresult = LOAD_GAME; } strcpy(name, test_name); } @@ -420,7 +422,7 @@ BOOL __stdcall UiSelHeroMultDialog( break; } - *dlgresult = 4; + *dlgresult = EXIT_MENU; return TRUE; case SDLK_UP: SelectedItem--; diff --git a/enums.h b/enums.h index f5d4828eb..d38b8ee19 100644 --- a/enums.h +++ b/enums.h @@ -2267,6 +2267,13 @@ typedef enum menus CREDIT, } menus; +typedef enum dlgresults +{ + NEW_GAME = 0, + LOAD_GAME = 2, + EXIT_MENU = 4, +} dlgresults; + typedef enum panel_button_id { PANBTN_CHARINFO = 0, PANBTN_QLOG = 1,