From: Ketmar Dark Date: Fri, 4 Aug 2017 03:52:28 +0000 (+0300) Subject: GUI: backspace clears keybinding (sorry, it is Teh Hack) X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=a24522eab25d5de62835ae64f6e2782dfac9fc88;p=d2df-sdl.git GUI: backspace clears keybinding (sorry, it is Teh Hack) --- diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index 48700f7..fbab591 100644 --- a/src/game/g_gui.pas +++ b/src/game/g_gui.pas @@ -19,7 +19,7 @@ unit g_gui; interface uses - e_graphics, e_input, g_playermodel, g_basic, MAPSTRUCT, wadreader; + e_graphics, e_input, e_log, g_playermodel, g_basic, MAPSTRUCT, wadreader; const MAINMENU_HEADER_COLOR: TRGB = (R:255; G:255; B:255); @@ -1496,7 +1496,7 @@ begin if FItems[FIndex].Control <> nil then FItems[FIndex].Control.OnMessage(Msg); end; - IK_RETURN, IK_KPRETURN: + IK_RETURN, IK_KPRETURN, IK_BACKSPACE: begin if FIndex <> -1 then begin @@ -2243,6 +2243,15 @@ begin end; procedure TGUIKeyRead.OnMessage(var Msg: TMessage); + procedure actDefCtl (); + begin + with FWindow do + if FDefControl <> '' then + SetActive(GetControl(FDefControl)) + else + SetActive(nil); + end; + begin inherited; @@ -2255,13 +2264,7 @@ begin case wParam of IK_ESCAPE: begin - if FIsQuery then - with FWindow do - if FDefControl <> '' then - SetActive(GetControl(FDefControl)) - else - SetActive(nil); - + if FIsQuery then actDefCtl(); FIsQuery := False; end; IK_RETURN, IK_KPRETURN: @@ -2278,28 +2281,34 @@ begin begin FKey := IK_ENTER; // FIsQuery := False; - - with FWindow do - if FDefControl <> '' then - SetActive(GetControl(FDefControl)) - else - SetActive(nil); + actDefCtl(); end; end; + IK_BACKSPACE: // clear keybinding if we aren't waiting for a key + begin + if not FIsQuery then + begin + FKey := 0; + actDefCtl(); + end; + end; end; MESSAGE_DIKEY: - if FIsQuery and (wParam <> IK_ENTER) and (wParam <> IK_KPRETURN) then // Not '' then - FKey := wParam; - FIsQuery := False; - - with FWindow do - if FDefControl <> '' then - SetActive(GetControl(FDefControl)) - else - SetActive(nil); + if not FIsQuery and (wParam = IK_BACKSPACE) then + begin + FKey := 0; + actDefCtl(); + end + else if FIsQuery and (wParam <> IK_ENTER) and (wParam <> IK_KPRETURN) then // Not '' then + FKey := wParam; + FIsQuery := False; + actDefCtl(); + end; end; end; end;