From faaddcfd2851a7c709c805ea8d9d5138fcd5c10e Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 31 Dec 2019 05:47:03 +0100 Subject: [PATCH] Allow controller events to also interupt attract mode --- SourceX/DiabloUI/diabloui.cpp | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index 4a7ec05bb..66745300c 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -189,6 +189,29 @@ void selhero_CatToName(char *in_buf, char *out_buf, int cnt) void UiFocusNavigation(SDL_Event *event) { + switch (event->type) { + case SDL_KEYUP: + case SDL_MOUSEBUTTONUP: + case SDL_MOUSEMOTION: +#ifndef USE_SDL1 + case SDL_MOUSEWHEEL: +#endif + case SDL_JOYBUTTONUP: + case SDL_JOYAXISMOTION: + case SDL_JOYBALLMOTION: + case SDL_JOYHATMOTION: +#ifndef USE_SDL1 + case SDL_FINGERUP: + case SDL_FINGERMOTION: + case SDL_CONTROLLERBUTTONUP: + case SDL_CONTROLLERAXISMOTION: + case SDL_WINDOWEVENT: +#endif + case SDL_SYSWMEVENT: + mainmenu_restart_repintro(); + break; + } + switch (GetMenuAction(*event)) { case MenuAction::SELECT: UiFocusNavigationSelect(); @@ -217,36 +240,6 @@ void UiFocusNavigation(SDL_Event *event) break; } - switch (event->type) { - case SDL_KEYUP: - case SDL_MOUSEBUTTONUP: - case SDL_MOUSEMOTION: -#ifndef USE_SDL1 - case SDL_MOUSEWHEEL: -#endif - case SDL_JOYBUTTONUP: - case SDL_JOYAXISMOTION: - case SDL_JOYBALLMOTION: - case SDL_JOYHATMOTION: -#ifndef USE_SDL1 - case SDL_FINGERUP: - case SDL_FINGERMOTION: - case SDL_CONTROLLERBUTTONUP: - case SDL_CONTROLLERAXISMOTION: -#endif - case SDL_SYSWMEVENT: - mainmenu_restart_repintro(); - break; -#ifndef USE_SDL1 - case SDL_WINDOWEVENT: - if (event->window.event == SDL_WINDOWEVENT_SHOWN) - gbActive = true; - else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) - gbActive = false; - break; -#endif - } - if (SDL_IsTextInputActive()) { switch (event->type) { case SDL_KEYDOWN: { @@ -317,6 +310,13 @@ void UiHandleEvents(SDL_Event *event) InitController(); return; } + + if (event->type == SDL_WINDOWEVENT) { + if (event->window.event == SDL_WINDOWEVENT_SHOWN) + gbActive = true; + else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) + gbActive = false; + } #endif }