diff --git a/Stub/DiabloUI/credits.cpp b/Stub/DiabloUI/credits.cpp index dd05a6dac..61dc7c5e8 100644 --- a/Stub/DiabloUI/credits.cpp +++ b/Stub/DiabloUI/credits.cpp @@ -467,7 +467,7 @@ char *the_long_credits[] = { NULL }; -void credts_Loade() +void credts_Load() { LoadBackgroundArt("ui_art\\credits.pcx"); } @@ -527,7 +527,7 @@ void credts_Render() BOOL __stdcall UiCreditsDialog(int a1) { - credts_Loade(); + credts_Load(); creditEnd = false; lineCount = CREDIT_LINES; diff --git a/Stub/DiabloUI/diabloui.cpp b/Stub/DiabloUI/diabloui.cpp index 8b981234d..65389cfc7 100644 --- a/Stub/DiabloUI/diabloui.cpp +++ b/Stub/DiabloUI/diabloui.cpp @@ -1,9 +1,7 @@ #include "../../types.h" TTF_Font *font; -int SelectedItemMax = 0; -int MenuItem[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -int PreviousItem[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +int SelectedItemMax = 1; int submenu = 0; BYTE *FontTables[4]; Art ArtFonts[4][2]; @@ -120,13 +118,68 @@ void __cdecl UiDestroy() font = NULL; } +void UiFocuse(int itemIndex, bool wrap) +{ + SelectedItem = itemIndex; + + if (!wrap) { + if (SelectedItem < 1) { + SelectedItem = 1; + return; + } else if (SelectedItem > SelectedItemMax) { + SelectedItem = SelectedItemMax ?: 1; + return; + } + } else if (SelectedItem < 1) { + SelectedItem = SelectedItemMax ?: 1; + } else if (SelectedItem > SelectedItemMax) { + SelectedItem = 1; + } + + UiPlayMoveSound(); +} + +bool UiFocuseNavigation(SDL_Event *event, bool wrap) +{ + switch (event->key.keysym.sym) { + case SDLK_UP: + UiFocuse(SelectedItem - 1, wrap); + return true; + case SDLK_DOWN: + UiFocuse(SelectedItem + 1, wrap); + return true; + case SDLK_TAB: + if (SDL_GetModState() & (KMOD_LSHIFT | KMOD_RSHIFT)) + UiFocuse(SelectedItem - 1, wrap); + else + UiFocuse(SelectedItem + 1, wrap); + return true; + case SDLK_PAGEUP: + SelectedItem = 1; + return true; + case SDLK_PAGEDOWN: + SelectedItem = SelectedItemMax; + return true; + } + + return false; +} + void SetMenu(int MenuId) { UiPlaySelectSound(); submenu = MenuId; SelectedItem = 1; - SelectedItemMax = MenuItem[MenuId]; + switch (MenuId) { + case SELHERO_CLASSES: + case SELHERO_DIFFICULTY: + SelectedItemMax = 3; + break; + default: + SelectedItemMax = 1; + break; + } } bool IsInsideRect(const SDL_Event *event, const SDL_Rect *rect) @@ -135,23 +188,6 @@ bool IsInsideRect(const SDL_Event *event, const SDL_Rect *rect) return SDL_PointInRect(&point, rect); } -void InitHiracy() -{ - MenuItem[SINGLEPLAYER_LOAD] = 1; - MenuItem[SINGLEPLAYER_CLASSES] = 3; - MenuItem[MULTIPLAYER_CONNECTIONS] = 3; - MenuItem[MULTIPLAYER_LOBBY] = 2; - MenuItem[MULTIPLAYER_DIFFICULTY] = 3; - MenuItem[MULTIPLAYER_BNET_GATEWAYS] = 3; - - PreviousItem[SINGLEPLAYER_CLASSES] = SINGLEPLAYER_LOAD; - PreviousItem[SINGLEPLAYER_NAME] = SINGLEPLAYER_CLASSES; - PreviousItem[MULTIPLAYER_CONNECTIONS] = MAINMENU; - PreviousItem[MULTIPLAYER_DIFFICULTY] = MULTIPLAYER_LOBBY; - PreviousItem[MULTIPLAYER_BNET_GATEWAYS] = MULTIPLAYER_CONNECTIONS; - PreviousItem[MULTIPLAYER_ERROR] = MAINMENU; -} - void LoadArt(char *pszFile, Art *art, int frames, PALETTEENTRY *pPalette) { if (art == NULL || art->data != NULL) @@ -227,7 +263,6 @@ void InitFont() void UiInitialize() { - InitHiracy(); LoadUiGFX(); ShowCursor(FALSE); InitFont(); @@ -321,7 +356,6 @@ void UiPlaySelectSound() gfnSoundFunction("sfx\\items\\titlslct.wav"); } - void __stdcall UiMessageBoxCallback(HWND hWnd, char *lpText, LPCSTR lpCaption, UINT uType) { UNIMPLEMENTED(); @@ -380,7 +414,7 @@ void DrawArt(int screenX, int screenY, Art *art, int nFrame, int drawW) BYTE *dst = (BYTE *)&gpBuffer->row[screenY].pixels[screenX]; drawW = drawW ?: art->width; - for (int i = 0; i < art->height && i + screenY < SCREEN_HEIGHT; i++, src += art->width, dst += 768) { + for (int i = 0; i < art->height && i + screenY < SCREEN_HEIGHT; i++, src += art->width, dst += ROW_PITCH) { for (int j = 0; j < art->width && j + screenX < SCREEN_WIDTH; j++) { if (j < drawW && (!art->masked || src[j] != art->mask)) dst[j] = src[j]; diff --git a/Stub/DiabloUI/mainmenu.cpp b/Stub/DiabloUI/mainmenu.cpp index 3935925e5..c41fe0973 100644 --- a/Stub/DiabloUI/mainmenu.cpp +++ b/Stub/DiabloUI/mainmenu.cpp @@ -27,7 +27,7 @@ void mainmenu_Render(char *name) DrawArtStr(17, 444, AFT_SMALL, AFC_SILVER, name); } -void mainmenu_Loade() +void mainmenu_Load() { char *pszFile = "ui_art\\mainmenu.pcx"; if (false) //DiabloUI_GetSpawned() @@ -44,7 +44,7 @@ void mainmenu_Free() BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int a4) { gfnSoundFunction = fnSound; - mainmenu_Loade(); + mainmenu_Load(); SelectedItem = 1; SelectedItemMax = 5; @@ -73,21 +73,9 @@ BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSo while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: - switch (event.key.keysym.sym) { - case SDLK_UP: - SelectedItem--; - if (SelectedItem < MAINMENU_SINGLE_PLAYER) { - SelectedItem = SelectedItemMax; - } - fnSound("sfx\\items\\titlemov.wav"); - break; - case SDLK_DOWN: - SelectedItem++; - if (SelectedItem > SelectedItemMax) { - SelectedItem = MAINMENU_SINGLE_PLAYER; - } - fnSound("sfx\\items\\titlemov.wav"); + if (UiFocuseNavigation(&event, true)) break; + switch (event.key.keysym.sym) { case SDLK_ESCAPE: *pdwResult = MAINMENU_EXIT_DIABLO; UiPlaySelectSound(); diff --git a/Stub/DiabloUI/progress.cpp b/Stub/DiabloUI/progress.cpp index 03b80df14..f3bc906bf 100644 --- a/Stub/DiabloUI/progress.cpp +++ b/Stub/DiabloUI/progress.cpp @@ -8,7 +8,7 @@ SDL_Surface *msgSurface; SDL_Surface *cancleSurface; int textWidth; -void progress_Loade(char *msg) +void progress_Load(char *msg) { LoadBackgroundArt("ui_art\\black.pcx"); LoadArt("ui_art\\spopup.pcx", &ArtPopupSm); @@ -68,7 +68,7 @@ void progress_Render(BYTE progress) int __stdcall UiProgressDialog(HWND window, char *msg, int enable, int(__cdecl *fnfunc)(), int rate) { - progress_Loade(msg); + progress_Load(msg); bool endMenu = false; int progress = 0; @@ -76,9 +76,7 @@ int __stdcall UiProgressDialog(HWND window, char *msg, int enable, int(__cdecl * SDL_Event event; while (!endMenu && progress < 100) { CapFPS(); - progress = fnfunc(); - progress_Render(progress); DrawMouse(); SetFadeLevel(256); @@ -86,6 +84,17 @@ int __stdcall UiProgressDialog(HWND window, char *msg, int enable, int(__cdecl * while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: + switch (event.key.keysym.sym) { + case SDLK_ESCAPE: + case SDLK_RETURN: + case SDLK_KP_ENTER: + case SDLK_SPACE: + break; + default: + continue; + } + endMenu = true; + break; case SDL_MOUSEBUTTONDOWN: endMenu = true; break; @@ -95,7 +104,6 @@ int __stdcall UiProgressDialog(HWND window, char *msg, int enable, int(__cdecl * } } BlackPalette(); - progress_Free(); return progress == 100; diff --git a/Stub/DiabloUI/sdlrender.h b/Stub/DiabloUI/sdlrender.h index d3db927f3..7529aa955 100644 --- a/Stub/DiabloUI/sdlrender.h +++ b/Stub/DiabloUI/sdlrender.h @@ -50,8 +50,6 @@ extern int SelectedItemMax; extern int SCREEN_WIDTH; extern int SCREEN_HEIGHT; -extern int MenuItem[10]; -extern int PreviousItem[10]; extern int submenu; typedef enum TXT_JUST { @@ -82,5 +80,7 @@ void DrawSelector(int x, int y, int width, int padding, int spacing, int size = void LoadArt(char *pszFile, Art *art, int frames = 1, PALETTEENTRY *pPalette = NULL); void LoadBackgroundArt(char *pszFile); void SetMenu(int MenuId); +void UiFocuse(int move, bool wrap = false); +bool UiFocuseNavigation(SDL_Event *event, bool wrap = false); void UiPlayMoveSound(); void UiPlaySelectSound(); diff --git a/Stub/DiabloUI/selconn.cpp b/Stub/DiabloUI/selconn.cpp index c49d98c2b..841204ea5 100644 --- a/Stub/DiabloUI/selconn.cpp +++ b/Stub/DiabloUI/selconn.cpp @@ -50,7 +50,7 @@ void selconn_Render() DrawArtStr(476, 429, AFT_BIG, AFC_GOLD, "Cancel"); } -void selconn_Loade() +void selconn_Load() { LoadBackgroundArt("ui_art\\selconn.pcx"); SelectedItem = 1; @@ -63,10 +63,15 @@ void selconn_Free() ArtBackground.data = NULL; } -int __stdcall UiSelectProvider(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, - _SNETVERSIONDATA *file_info, int *type) +int __stdcall UiSelectProvider( + int a1, + _SNETPROGRAMDATA *client_info, + _SNETPLAYERDATA *user_info, + _SNETUIDATA *ui_info, + _SNETVERSIONDATA *file_info, + int *type) { - selconn_Loade(); + selconn_Load(); SDL_Event event; @@ -81,26 +86,10 @@ int __stdcall UiSelectProvider(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYE while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: - switch (event.key.keysym.sym) { - case SDLK_UP: - SelectedItem--; - if (SelectedItem < MAINMENU_SINGLE_PLAYER) { - SelectedItem = SelectedItemMax; - } - UiPlayMoveSound(); - break; - case SDLK_DOWN: - SelectedItem++; - if (SelectedItem > SelectedItemMax) { - SelectedItem = MAINMENU_SINGLE_PLAYER; - } - UiPlayMoveSound(); + if (UiFocuseNavigation(&event)) break; + switch (event.key.keysym.sym) { case SDLK_ESCAPE: - if (PreviousItem[submenu]) { - SetMenu(PreviousItem[submenu]); - break; - } rv = false; endMenu = true; break; @@ -133,7 +122,7 @@ int __stdcall UiSelectProvider(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYE } selconn_Free(); endMenu = SNetInitializeProvider('SCBL', client_info, user_info, ui_info, file_info); - selconn_Loade(); + selconn_Load(); break; } break; diff --git a/Stub/DiabloUI/selhero.cpp b/Stub/DiabloUI/selhero.cpp index 6bb9d7cd7..2b4c6b595 100644 --- a/Stub/DiabloUI/selhero.cpp +++ b/Stub/DiabloUI/selhero.cpp @@ -160,7 +160,7 @@ BOOL __stdcall SelHero_GetHeroInfo(_uiheroinfo *pInfo) return TRUE; } -void selhero_Loade(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *))) +void selhero_Load(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *))) { LoadBackgroundArt("ui_art\\selhero.pcx"); @@ -188,117 +188,150 @@ void selhero_setDefaultStats(BOOL(__stdcall *fnstats)(unsigned int, _uidefaultst heroInfo.vitality = defaults.vitality; } +bool selhero_Event(bool *aborted) +{ + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_KEYDOWN: + if (UiFocuseNavigation(&event)) + break; + switch (event.key.keysym.sym) { + case SDLK_ESCAPE: + *aborted = true; + return true; + case SDLK_RETURN: + case SDLK_KP_ENTER: + case SDLK_SPACE: + if (SelectedItem == SelectedItemMax) { + memset(&heroInfo.name, 0, sizeof(heroInfo.name)); + SetMenu(SELHERO_CLASSES); + break; + } + return true; + } + break; + case SDL_QUIT: + exit(0); + } + } + + return false; +} + +bool selhero_Event_ClassSelector(bool *aborted) +{ + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_KEYDOWN: + if (UiFocuseNavigation(&event, true)) + break; + switch (event.key.keysym.sym) { + case SDLK_ESCAPE: + if (selhero_SaveCount) { + SetMenu(SELHERO_LOAD); + SelectedItemMax = 1 + selhero_SaveCount; + break; + } + *aborted = true; + return true; + case SDLK_RETURN: + case SDLK_KP_ENTER: + case SDLK_SPACE: + SetMenu(SELHERO_NAME); + break; + } + break; + case SDL_QUIT: + exit(0); + } + } + + return false; +} + +bool selhero_Event_Name() +{ + int nameLen; + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_KEYDOWN: + switch (event.key.keysym.sym) { + case SDLK_ESCAPE: + SetMenu(SELHERO_CLASSES); + break; + case SDLK_BACKSPACE: + case SDLK_LEFT: + nameLen = strlen(heroInfo.name); + if (nameLen > 0) { + heroInfo.name[nameLen - 1] = '\0'; + } + break; + case SDLK_RETURN: + case SDLK_KP_ENTER: + return true; + default: + char letter = event.key.keysym.sym; + if (int(letter) > 96 && int(letter) < 123 || int(letter) == 32) { + nameLen = strlen(heroInfo.name); + if (nameLen < 15) { + heroInfo.name[nameLen] = letter; + } + } + break; + } + break; + case SDL_QUIT: + exit(0); + } + } + + return false; +} + bool UiSelHeroDialog( BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(__stdcall *fnremove)(_uiheroinfo *), BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), bool multiPlayer) { - MenuItem[SINGLEPLAYER_LOAD] = 1 + selhero_SaveCount; + bool aborted = false; + bool endMenu = false; - submenu = SINGLEPLAYER_LOAD; + SelectedItem = 1; + submenu = SELHERO_LOAD; + SelectedItemMax = 1 + selhero_SaveCount; if (!selhero_SaveCount) { - PreviousItem[SINGLEPLAYER_CLASSES] = 0; - submenu = SINGLEPLAYER_CLASSES; + submenu = SELHERO_CLASSES; + SelectedItemMax = 3; } - SelectedItem = 1; - SelectedItemMax = MenuItem[submenu]; - - int nameLen; - SDL_Event event; - - while (1) { + while (endMenu == false) { CapFPS(); switch (submenu) { - case SINGLEPLAYER_LOAD: + case SELHERO_LOAD: selhero_Render(multiPlayer); + endMenu = selhero_Event(&aborted); break; - case SINGLEPLAYER_CLASSES: + case SELHERO_CLASSES: selhero_setDefaultStats(fnstats); selhero_Render_ClassSelector(multiPlayer); + endMenu = selhero_Event_ClassSelector(&aborted); break; - case SINGLEPLAYER_NAME: + case SELHERO_NAME: selhero_Render_Name(multiPlayer); + endMenu = selhero_Event_Name(); break; } DrawMouse(); UiFadeIn(); - - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_KEYDOWN: - switch (event.key.keysym.sym) { - case SDLK_ESCAPE: - if (PreviousItem[submenu]) { - SetMenu(PreviousItem[submenu]); - break; - } - - return FALSE; - case SDLK_BACKSPACE: - nameLen = strlen(heroInfo.name); - if (nameLen > 0) { - heroInfo.name[nameLen - 1] = '\0'; - } - break; - case SDLK_UP: - SelectedItem--; - if (SelectedItem < 1) { - SelectedItem = SelectedItemMax ? SelectedItemMax : 1; - } - UiPlayMoveSound(); - break; - case SDLK_DOWN: - SelectedItem++; - if (SelectedItem > SelectedItemMax) { - SelectedItem = 1; - } - UiPlayMoveSound(); - break; - case SDLK_RETURN: - case SDLK_KP_ENTER: - case SDLK_SPACE: - switch (submenu) { - case SINGLEPLAYER_LOAD: - if (SelectedItem == SelectedItemMax) { - memset(&heroInfo.name, 0, sizeof(heroInfo.name)); - SetMenu(SINGLEPLAYER_CLASSES); - break; - } - - return true; - case SINGLEPLAYER_CLASSES: - SetMenu(SINGLEPLAYER_NAME); - break; - case SINGLEPLAYER_NAME: - return true; - } - break; - default: - if (submenu != SINGLEPLAYER_NAME) { - break; - } - - char letter = event.key.keysym.sym; - if (int(letter) > 96 && int(letter) < 123 || int(letter) == 32) { - nameLen = strlen(heroInfo.name); - if (nameLen < 15) { - heroInfo.name[nameLen] = letter; - } - } - break; - } - break; - case SDL_QUIT: - exit(0); - } - } } - return TRUE; + return aborted; } BOOL __stdcall UiSelHeroSingDialog( @@ -310,8 +343,8 @@ BOOL __stdcall UiSelHeroSingDialog( char *name, int *difficulty) { - selhero_Loade(fninfo); - if (!UiSelHeroDialog(fncreate, fnremove, fnstats, false)) { + selhero_Load(fninfo); + if (UiSelHeroDialog(fncreate, fnremove, fnstats, false)) { *dlgresult = EXIT_MENU; } else { strcpy(name, heroInfo.name); @@ -333,7 +366,7 @@ BOOL __stdcall UiSelHeroSingDialog( // MULTI PLAYER // ////////////////////////////////////////// -void selhero_multi_Loade() +void selhero_multi_Load() { LoadBackgroundArt("ui_art\\selgame.pcx"); } @@ -364,6 +397,81 @@ void selhero_Render_DifficultySelection() } } +bool selhero_Event_GameSelection(int *dlgresult) +{ + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_KEYDOWN: + if (UiFocuseNavigation(&event)) + break; + switch (event.key.keysym.sym) { + case SDLK_ESCAPE: + *dlgresult = EXIT_MENU; + return true; + case SDLK_RETURN: + case SDLK_KP_ENTER: + case SDLK_SPACE: + SetMenu(SELHERO_DIFFICULTY); + break; + } + break; + case SDL_QUIT: + exit(0); + } + } + + return false; +} + +bool selhero_Event_DifficultySelection(int *dlgresult) +{ + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_KEYDOWN: + if (UiFocuseNavigation(&event, true)) + break; + switch (event.key.keysym.sym) { + case SDLK_ESCAPE: + SetMenu(SELHERO_SELECT_GAME); + break; + case SDLK_RETURN: + case SDLK_KP_ENTER: + case SDLK_SPACE: + *dlgresult = NEW_GAME; + return true; + } + break; + case SDL_MOUSEBUTTONDOWN: + if (event.button.button == SDL_BUTTON_LEFT) { + SDL_Rect CreateHeroCancelBox; + CreateHeroCancelBox.y = 550; + CreateHeroCancelBox.x = 675; + CreateHeroCancelBox.w = 100; + CreateHeroCancelBox.h = 30; + + SDL_Rect NormalSelectBox; + NormalSelectBox.x = 280; + NormalSelectBox.y = 350; + NormalSelectBox.w = 300; + NormalSelectBox.h = 30; + + if (IsInsideRect(&event, &NormalSelectBox)) { + gnDifficulty = DIFF_NORMAL; + *dlgresult = LOAD_GAME; + } + break; + } + break; + case SDL_QUIT: + exit(0); + } + } + + return false; +} + void selhero_Render_GameSelection() { DrawArt(0, 0, &ArtBackground); @@ -395,112 +503,45 @@ BOOL __stdcall UiSelHeroMultDialog( { *hero_is_created = false; - selhero_Loade(fninfo); - bool playerSelected = UiSelHeroDialog(fncreate, fnremove, fnstats, true); + selhero_Load(fninfo); + bool abort = UiSelHeroDialog(fncreate, fnremove, fnstats, true); BlackPalette(); selhero_Free(); - if (!playerSelected) { + if (abort) { *dlgresult = EXIT_MENU; return TRUE; } strcpy(name, heroInfo.name); - selhero_multi_Loade(); + selhero_multi_Load(); - submenu = MULTIPLAYER_LOBBY; + submenu = SELHERO_SELECT_GAME; SelectedItem = 1; - SelectedItemMax = MenuItem[submenu]; - SDL_Event event; + SelectedItemMax = 2; - int endMenu = false; + bool endMenu = false; while (endMenu == false) { CapFPS(); switch (submenu) { - case MULTIPLAYER_LOBBY: + case SELHERO_SELECT_GAME: selhero_Render_GameSelection(); + endMenu = selhero_Event_GameSelection(dlgresult); break; - case MULTIPLAYER_DIFFICULTY: + case SELHERO_DIFFICULTY: selhero_Render_DifficultySelection(); + endMenu = selhero_Event_DifficultySelection(dlgresult); break; } DrawMouse(); UiFadeIn(); + } - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_KEYDOWN: - switch (event.key.keysym.sym) { - case SDLK_ESCAPE: - if (PreviousItem[submenu]) { - SetMenu(PreviousItem[submenu]); - break; - } - - *dlgresult = EXIT_MENU; - endMenu = true; - case SDLK_UP: - SelectedItem--; - if (SelectedItem < 1) { - SelectedItem = SelectedItemMax ? SelectedItemMax : 1; - } - UiPlayMoveSound(); - break; - case SDLK_DOWN: - SelectedItem++; - if (SelectedItem > SelectedItemMax) { - SelectedItem = 1; - } - UiPlayMoveSound(); - break; - case SDLK_RETURN: - case SDLK_KP_ENTER: - case SDLK_SPACE: - switch (submenu) { - case MULTIPLAYER_LOBBY: - SetMenu(MULTIPLAYER_DIFFICULTY); - break; - case MULTIPLAYER_DIFFICULTY: - strcpy(name, heroInfo.name); - *dlgresult = NEW_GAME; - endMenu = true; - break; - } - break; - } - break; - case SDL_MOUSEBUTTONDOWN: - if (event.button.button == SDL_BUTTON_LEFT) { - SDL_Rect CreateHeroCancelBox; - CreateHeroCancelBox.y = 550; - CreateHeroCancelBox.x = 675; - CreateHeroCancelBox.w = 100; - CreateHeroCancelBox.h = 30; - - switch (submenu) { - case MULTIPLAYER_DIFFICULTY: - SDL_Rect NormalSelectBox; - NormalSelectBox.x = 280; - NormalSelectBox.y = 350; - NormalSelectBox.w = 300; - NormalSelectBox.h = 30; - - if (IsInsideRect(&event, &NormalSelectBox)) { - strcpy(name, heroInfo.name); - gnDifficulty = DIFF_NORMAL; - *dlgresult = LOAD_GAME; - } - break; - } - } - break; - case SDL_QUIT: - exit(0); - } - } + if (*dlgresult != EXIT_MENU) { + strcpy(name, heroInfo.name); } BlackPalette(); diff --git a/Stub/DiabloUI/title.cpp b/Stub/DiabloUI/title.cpp index b22457959..e63e04628 100644 --- a/Stub/DiabloUI/title.cpp +++ b/Stub/DiabloUI/title.cpp @@ -8,7 +8,7 @@ void title_Render() DrawLogo(182, LOGO_BIG); } -void title_Loade() +void title_Load() { LoadBackgroundArt("ui_art\\title.pcx"); } @@ -21,7 +21,7 @@ void title_Free() BOOL __stdcall UiTitleDialog(int a1) { - title_Loade(); + title_Load(); bool endMenu = false; int timeOut = SDL_GetTicks() + 7000; @@ -34,7 +34,13 @@ BOOL __stdcall UiTitleDialog(int a1) while (SDL_PollEvent(&event)) { switch (event.type) { - case SDL_KEYDOWN: // all except arrow + case SDL_KEYDOWN: + if (event.key.keysym.sym == SDLK_UP + || event.key.keysym.sym == SDLK_UP + || event.key.keysym.sym == SDLK_LEFT + || event.key.keysym.sym == SDLK_RIGHT) { + break; + } case SDL_MOUSEBUTTONDOWN: endMenu = true; break; diff --git a/enums.h b/enums.h index d38b8ee19..8d2e06a5a 100644 --- a/enums.h +++ b/enums.h @@ -2254,17 +2254,11 @@ typedef enum _mainmenu_selections { typedef enum menus { - MAINMENU, - SINGLEPLAYER_LOAD, - SINGLEPLAYER_CLASSES, - SINGLEPLAYER_NAME, - MULTIPLAYER_CONNECTIONS, - MULTIPLAYER_CONNECTION, - MULTIPLAYER_LOBBY, - MULTIPLAYER_DIFFICULTY, - MULTIPLAYER_BNET_GATEWAYS, - MULTIPLAYER_ERROR, - CREDIT, + SELHERO_LOAD, + SELHERO_CLASSES, + SELHERO_NAME, + SELHERO_SELECT_GAME, + SELHERO_DIFFICULTY, } menus; typedef enum dlgresults diff --git a/structs.h b/structs.h index 5df54d3a2..b3d4e7860 100644 --- a/structs.h +++ b/structs.h @@ -1304,7 +1304,7 @@ typedef struct _SNETUIDATA { const struct _SNETPLAYERDATA *, const struct _SNETUIDATA *, const struct _SNETVERSIONDATA *, - DWORD provider, /* e.g. 'IPXN', 'BNET' etc. */ + DWORD provider, /* e.g. 'BNET', 'IPXN', 'MODM', 'SCBL' */ char *, DWORD, /* character name will be copied here */ char *, DWORD, /* character "description" will be copied here (used to advertise games) */ BOOL * /* new character? - unsure about this */