From dbf81afaefeb52e53d2b8af3a782277229c5adaa Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Wed, 9 Oct 2019 22:52:33 +0300 Subject: [PATCH] fix regresion: holmes with sdl2 --- src/game/Doom2DF.lpr | 12 +++++++++++ src/game/g_main.pas | 20 ++++++++++++++---- src/game/g_window.pas | 8 -------- src/game/sdl/g_system.pas | 5 +++-- src/game/sdl2/g_system.pas | 42 ++++++++++++++++++++++++++++++++++---- 5 files changed, 69 insertions(+), 18 deletions(-) diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index 7934ed1..7f869f1 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -57,6 +57,18 @@ {$ERROR Sound driver not selected. Use -dUSE_SOUNDSTUB or -dUSE_SDLMIXER or -dUSE_FMOD or -dUSE_OPENAL} {$ENDIF} +{$IFDEF ENABLE_HOLMES} + {$IFDEF HEADLESS} + {$ERROR Holmes in HEADLESS mode has no sense} + {$ENDIF} + {$IFNDEF USE_SDL2} + {$ERROR Holmes supported only with SDL2} + {$ENDIF} + {$IFDEF USE_GLES1} + {$ERROR Holmes not supported with GLES} + {$ENDIF} +{$ENDIF} + uses {$IFDEF ANDROID} ctypes, diff --git a/src/game/g_main.pas b/src/game/g_main.pas index 222002b..7d0dfb2 100644 --- a/src/game/g_main.pas +++ b/src/game/g_main.pas @@ -38,7 +38,7 @@ implementation uses {$INCLUDE ../nogl/noGLuses.inc} {$IFDEF ENABLE_HOLMES} - g_holmes, fui_wadread, fui_style, fui_gfx_gl, + g_holmes, sdlcarcass, fui_ctls, fui_wadread, fui_style, fui_gfx_gl, {$ENDIF} wadreader, e_log, g_window, e_graphics, e_input, g_game, g_console, g_gui, @@ -143,15 +143,27 @@ begin end; end; g_holmes_imfunctional := not flexloaded; + + if (not g_holmes_imfunctional) then + begin + uiInitialize(); + uiContext.font := 'win14'; + end; + + if assigned(oglInitCB) then oglInitCB; {$ENDIF} //g_Res_CreateDatabases(); // it will be done before connecting to the server for the first time e_WriteLog('Entering SDLMain', TMsgType.Notify); -{$WARNINGS OFF} - SDLMain(); -{$WARNINGS ON} + {$WARNINGS OFF} + SDLMain(); + {$WARNINGS ON} + + {$IFDEF ENABLE_HOLMES} + if assigned(oglDeinitCB) then oglDeinitCB; + {$ENDIF} sys_Final; end; diff --git a/src/game/g_window.pas b/src/game/g_window.pas index 992c023..002e51a 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -258,14 +258,6 @@ var begin {$IFDEF HEADLESS} e_NoGraphics := true; -{$ELSE} - {$IFDEF ENABLE_HOLMES} - if (not g_holmes_imfunctional) then - begin - uiInitialize(); - uiContext.font := 'win14'; - end; - {$ENDIF} {$ENDIF} idx := 1; diff --git a/src/game/sdl/g_system.pas b/src/game/sdl/g_system.pas index 21501c6..4120c02 100644 --- a/src/game/sdl/g_system.pas +++ b/src/game/sdl/g_system.pas @@ -40,8 +40,8 @@ interface implementation uses - SysUtils, SDL, GL, Math, - e_log, e_graphics, e_input, + SysUtils, SDL, Math, + e_log, e_graphics, e_input, e_sound, g_options, g_window, g_console, g_game, g_menu, g_gui, g_main; const @@ -429,6 +429,7 @@ implementation SDL_JOYAXISMOTION: HandleJoyAxis(ev.jaxis); SDL_JOYHATMOTION: HandleJoyHat(ev.jhat); SDL_VIDEOEXPOSE: sys_Repaint; + SDL_ACTIVEEVENT: e_MuteChannels((ev.active.gain = 0) and gMuteWhenInactive); end end end; diff --git a/src/game/sdl2/g_system.pas b/src/game/sdl2/g_system.pas index afc1899..3e55f45 100644 --- a/src/game/sdl2/g_system.pas +++ b/src/game/sdl2/g_system.pas @@ -40,10 +40,12 @@ interface implementation uses - SysUtils, SDL2, GL, Math, - e_log, e_graphics, e_input, - g_touch, - g_options, g_window, g_console, g_game, g_menu, g_gui, g_main; + SysUtils, SDL2, Math, + e_log, e_graphics, e_input, e_sound, + {$IFDEF ENABLE_HOLMES} + g_holmes, sdlcarcass, fui_ctls, + {$ENDIF} + g_touch, g_options, g_window, g_console, g_game, g_menu, g_gui, g_main; const GameTitle = 'Doom 2D: Forever (SDL 2)'; @@ -87,11 +89,15 @@ implementation g_Game_SetupScreenSize; g_Menu_Reset; g_Game_ClearLoading; + {$IFDEF ENABLE_HOLMES} + if assigned(oglInitCB) then oglInitCB; + {$ENDIF} end; function InitWindow (w, h, bpp: Integer; fullScreen: Boolean): Boolean; var flags: UInt32; begin + // note: on window close make: if assigned(oglDeinitCB) then oglDeinitCB; e_LogWritefln('InitWindow %s %s %s %s', [w, h, bpp, fullScreen]); result := false; if window = nil then @@ -345,6 +351,22 @@ implementation SDL_WINDOWEVENT_RESIZED: UpdateSize(ev.data1, ev.data2); SDL_WINDOWEVENT_EXPOSED: sys_Repaint; SDL_WINDOWEVENT_CLOSE: result := true; + SDL_WINDOWEVENT_FOCUS_LOST, SDL_WINDOWEVENT_MINIMIZED: + begin + e_UnpressAllKeys; + if gMuteWhenInactive then + e_MuteChannels(true); + {$IFDEF ENABLE_HOLMES} + if assigned(winBlurCB) then winBlurCB; + {$ENDIF} + end; + SDL_WINDOWEVENT_FOCUS_GAINED, SDL_WINDOWEVENT_MAXIMIZED, SDL_WINDOWEVENT_RESTORED: + begin + e_MuteChannels(false); + {$IFDEF ENABLE_HOLMES} + if assigned(winFocusCB) then winFocusCB; + {$ENDIF} + end; end end; @@ -355,6 +377,14 @@ implementation down := (ev.type_ = SDL_KEYDOWN); if key = SDL_SCANCODE_AC_BACK then key := SDL_SCANCODE_ESCAPE; + {$IFDEF ENABLE_HOLMES} + if fuiOnSDLEvent(PSDL_Event(@ev)^) then + begin + // event eaten, but... + if not down then e_KeyUpDown(key, false); + exit; + end; + {$ENDIF} if ev._repeat = 0 then begin if g_dbg_input then @@ -398,6 +428,9 @@ implementation SDL_JOYDEVICEREMOVED: HandleJoyRemove(ev.jdevice); SDL_TEXTINPUT: HandleTextInput(ev.text); SDL_FINGERMOTION, SDL_FINGERDOWN, SDL_FINGERUP: g_Touch_HandleEvent(ev.tfinger); + {$IFDEF ENABLE_HOLMES} + SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEWHEEL, SDL_MOUSEMOTION: fuiOnSDLEvent(ev); + {$ENDIF} end end end; @@ -430,6 +463,7 @@ implementation ok := InitWindow(gScreenWidth, gScreenHeight, gBPP, gFullscreen); if not ok then raise Exception.Create('SDL: Failed to set videomode: ' + SDL_GetError); + SDL_ShowCursor(SDL_DISABLE); end; procedure sys_Final; -- 2.29.2