From: DeaDDooMER Date: Fri, 2 Mar 2018 16:56:31 +0000 (+0300) Subject: Added vertical offset for virtual keyboard X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=b3e0744eff5ea17aaa2be71bde9bddba7f8d4f60;p=d2df-sdl.git Added vertical offset for virtual keyboard --- diff --git a/src/game/g_language.pas b/src/game/g_language.pas index 5bb1e5a..18d0d72 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -209,6 +209,7 @@ type I_MENU_CONTROL_TOUCH, I_MENU_CONTROL_TOUCH_FIRE, I_MENU_CONTROL_TOUCH_SIZE, + I_MENU_CONTROL_TOUCH_OFFSET, I_MENU_CONTROL_GLOBAL, I_MENU_CONTROL_SCREENSHOT, @@ -991,6 +992,8 @@ const 'Ñòðåëÿòü ââåðõ/âíèç:'), ('MENU CONTROL TOUCH SIZE', 'Button size:', 'Ðàçìåð êíîïîê:'), + ('MENU CONTROL TOUCH OFFSET', 'Vertical offset:', + 'Âåðòèêàëüíîå ñìåùåíèå:'), ('MENU CONTROL GLOBAL', 'Global Controls', 'ÎÁÙÅÅ ÓÏÐÀÂËÅÍÈÅ'), diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 35a4a0b..629c38c 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -263,6 +263,7 @@ begin menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu')); g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5; g_touch_fire := TGUISwitch(menu.GetControl('swTouchFire')).ItemIndex = 1; + g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5; end; menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu')); @@ -459,6 +460,7 @@ begin TGUIScroll(menu.GetControl('scTouchSize')).Value := Round((g_touch_size - 0.5) * 10); with TGUISwitch(menu.GetControl('swTouchFire')) do if g_touch_fire then ItemIndex := 1 else ItemIndex := 0; + TGUIScroll(menu.GetControl('scTouchOffset')).Value := Round(g_touch_offset / 5); end; menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu')); @@ -1291,6 +1293,7 @@ var begin menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu')); g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5; + g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5; end; procedure ProcOptionsPlayersMIMenu(); @@ -2836,6 +2839,12 @@ begin AddItem(_lc[I_MENU_NO]); AddItem(_lc[I_MENU_YES]); end; + with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do + begin + Name := 'scTouchOffset'; + Max := 20; + OnChange := ProcChangeTouchSettings; + end; end; Menu.DefControl := 'mOptionsControlsTouchMenu'; g_GUI_AddWindow(Menu); diff --git a/src/game/g_options.pas b/src/game/g_options.pas index 7b2a13c..0397f37 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -169,6 +169,7 @@ begin g_dbg_scale := 1.0; g_touch_size := 1.0; g_touch_fire := True; + g_touch_offset := 50; for i := 0 to e_MaxJoys-1 do e_JoystickDeadzones[i] := 8192; @@ -424,6 +425,7 @@ begin g_touch_size := Max(config.ReadInt('Touch', 'Size', 10) / 10, 0.1); g_touch_fire := config.ReadBool('Touch', 'Fire', True); + g_touch_offset := Max(Min(config.ReadInt('Touch', 'Offset', 50), 100), 0); g_GFX_SetMax(Min(config.ReadInt('Game', 'MaxParticles', 1000), 50000)); g_Shells_SetMax(Min(config.ReadInt('Game', 'MaxShells', 300), 600)); @@ -667,6 +669,7 @@ begin config.WriteInt('Touch', 'Size', Round(g_touch_size * 10)); config.WriteBool('Touch', 'Fire', g_touch_fire); + config.WriteInt('Touch', 'Offset', Round(g_touch_offset)); with config do case gGibsCount of diff --git a/src/game/g_touch.pas b/src/game/g_touch.pas index 8519f0d..d98d2df 100644 --- a/src/game/g_touch.pas +++ b/src/game/g_touch.pas @@ -22,8 +22,9 @@ interface SDL2; var - g_touch_size: Single; - g_touch_fire: Boolean; + g_touch_size: Single = 1.0; + g_touch_offset: Single = 50; + g_touch_fire: Boolean = True; procedure g_Touch_Init; procedure g_Touch_ShowKeyboard(yes: Boolean); @@ -84,21 +85,21 @@ implementation end else begin - x := 0; y := 0; w := sz; h := sz; + x := 0; y := Round(sh * g_touch_offset / 100); w := sz; h := sz; case key of - VK_LSTRAFE: begin x := 0; y := sh div 2 - h div 2; w := w div 2 end; - VK_LEFT: begin x := w div 2; y := sh div 2 - h div 2 end; - VK_RIGHT: begin x := w div 2 + 1*w;y := sh div 2 - h div 2 end; - VK_RSTRAFE: begin x := w div 2 + 2*w;y := sh div 2 - h div 2; w := w div 2 end; - VK_UP: begin x := sw - w - 1; y := sh div 2 - h div 2 - h end; - VK_FIRE: begin x := sw - 1*w - 1; y := sh div 2 - h div 2 end; - VK_DOWN: begin x := sw - w - 1; y := sh div 2 - h div 2 + h end; - VK_NEXT: begin x := sw - 2*w - 1; y := sh div 2 - h div 2 - h end; - VK_JUMP: begin x := sw - 2*w - 1; y := sh div 2 - h div 2 end; - VK_PREV: begin x := sw - 3*w - 1; y := sh div 2 - h div 2 - h end; - VK_OPEN: begin x := sw - 3*w - 1; y := sh div 2 - h div 2 end; + VK_LSTRAFE: begin x := 0; y := y - h div 2; w := w div 2 end; + VK_LEFT: begin x := w div 2; y := y - h div 2 end; + VK_RIGHT: begin x := w div 2 + 1*w; y := y - h div 2 end; + VK_RSTRAFE: begin x := w div 2 + 2*w; y := y - h div 2; w := w div 2 end; + VK_UP: begin x := sw - w - 1; y := y - h div 2 - h end; + VK_FIRE: begin x := sw - 1*w - 1; y := y - h div 2 end; + VK_DOWN: begin x := sw - w - 1; y := y - h div 2 + h end; + VK_NEXT: begin x := sw - 2*w - 1; y := y - h div 2 - h end; + VK_JUMP: begin x := sw - 2*w - 1; y := y - h div 2 end; + VK_PREV: begin x := sw - 3*w - 1; y := y - h div 2 - h end; + VK_OPEN: begin x := sw - 3*w - 1; y := y - h div 2 end; else - w := sz div 2; h := sz div 2; + x := 0; y := 0; w := sz div 2; h := sz div 2; case key of VK_0: begin x := sw div 2 - w div 2 - 5*w - 1; y := sh - 1*h - 1 end; VK_1: begin x := sw div 2 - w div 2 - 4*w - 1; y := sh - 1*h - 1 end; @@ -317,6 +318,7 @@ initialization conRegVar('touch_enable', @enabled, 'enable/disable virtual buttons', 'draw buttons'); conRegVar('touch_fire', @g_touch_fire, 'enable/disable fire when press virtual up/down', 'fire when press up/down'); conRegVar('touch_size', @g_touch_size, 0.1, 10, 'size of virtual buttons', 'button size'); + conRegVar('touch_offset', @g_touch_offset, 0, 100, '', ''); conRegVar('touch_alt', @jab, 'althernative virtual buttons layout', 'althernative layout'); end.