summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 271f8f0)
raw | patch | inline | side by side (parent: 271f8f0)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 1 Mar 2018 18:26:32 +0000 (21:26 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 17 Mar 2018 00:04:27 +0000 (02:04 +0200) |
index f325846ba8e51bba6ceb4f836a4729feac8e7ca3..5bb1e5ac53dea314205b1aadb7f957d56ece3635 100644 (file)
--- a/src/game/g_language.pas
+++ b/src/game/g_language.pas
I_MENU_CONTROL_JOYSTICKS,
I_MENU_CONTROL_DEADZONE,
+ I_MENU_CONTROL_TOUCH,
+ I_MENU_CONTROL_TOUCH_FIRE,
+ I_MENU_CONTROL_TOUCH_SIZE,
+
I_MENU_CONTROL_GLOBAL,
I_MENU_CONTROL_SCREENSHOT,
I_MENU_CONTROL_STAT,
('MENU CONTROL DEADZONE', 'Joystick %d Deadzone',
'̸ðòâàÿ çîíà äæîéñòèêà %d'),
+ ('MENU CONTROL TOCUH', 'Touchscreen Settings',
+ 'Íàñòðîéêè ñåíñðíîãî ýêðàíà'),
+ ('MENU CONTROL TOUCH FIRE', 'Shoot Up/Down:',
+ 'Ñòðåëÿòü ââåðõ/âíèç:'),
+ ('MENU CONTROL TOUCH SIZE', 'Button size:',
+ 'Ðàçìåð êíîïîê:'),
+
('MENU CONTROL GLOBAL', 'Global Controls',
'ÎÁÙÅÅ ÓÏÐÀÂËÅÍÈÅ'),
('MENU CONTROL SCREENSHOT', 'Screenshot:',
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index 960eb9eeafaccd3325d119a7a042c03b5cfd796f..b564911086e54da4c1b0ad284666578146efd1e2 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
e_graphics, e_input, g_game, g_console, g_gui,
e_sound, g_options, g_sound, g_player, g_basic,
g_weapons, SysUtils, g_triggers, MAPDEF, g_map,
- g_menu, g_language, g_net, g_holmes,
+ g_menu, g_language, g_net, g_holmes, g_touch,
utils, conbuf, envvars, fui_wadread, fui_style,
fui_gfx_gl, xparser;
e_WriteLog('Init Input', TMsgType.Notify);
e_InitInput();
+ g_Touch_Init;
if (e_JoysticksAvailable > 0) then
e_WriteLog('Input: Joysticks available.', TMsgType.Notify)
diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas
index 3056950af666495842af15a008ba3f4cc2ac211c..35a4a0b473d3f03bd102de176efe607f010f89b4 100644 (file)
--- a/src/game/g_menu.pas
+++ b/src/game/g_menu.pas
e_log, SysUtils, CONFIG, g_playermodel, DateUtils, sdl2,
MAPDEF, Math, g_saveload,
e_texture, g_language,
- g_net, g_netmsg, g_netmaster, g_items, e_input,
+ g_net, g_netmsg, g_netmaster, g_items, e_input, g_touch,
utils, wadreader;
gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
- g_dbg_scale := TGUIScroll(menu.GetControl('swScaleFactor')).Value + 1;
+ g_dbg_scale := TGUIScroll(menu.GetControl('scScaleFactor')).Value + 1;
menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
end;
end;
+ if SDL_GetNumTouchDevices() > 0 then
+ 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;
+ end;
+
menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text);
end;
end;
+ if SDL_GetNumTouchDevices() > 0 then
+ begin
+ menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
+ 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;
+ end;
+
menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
with menu, gGameControls.GameControls do
begin
with TGUISwitch(menu.GetControl('swChatBubble')) do
ItemIndex := gChatBubble;
- TGUIScroll(menu.GetControl('swScaleFactor')).Value := Round(g_dbg_scale - 1);
+ TGUIScroll(menu.GetControl('scScaleFactor')).Value := Round(g_dbg_scale - 1);
menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
menu: TGUIMenu;
begin
menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
- g_dbg_scale := TGUIScroll(menu.GetControl('swScaleFactor')).Value + 1;
+ g_dbg_scale := TGUIScroll(menu.GetControl('scScaleFactor')).Value + 1;
+end;
+
+procedure ProcChangeTouchSettings(Sender: TGUIControl);
+var
+ menu: TGUIMenu;
+begin
+ menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
+ g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
end;
procedure ProcOptionsPlayersMIMenu();
end;
with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
begin
- Name := 'swScaleFactor';
+ Name := 'scScaleFactor';
Max := 10;
OnChange := ProcChangeGameSettings;
end;
AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
{AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
- AddSpace();
if e_JoysticksAvailable <> 0 then
+ begin
+ AddSpace();
AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
+ end;
+ if SDL_GetNumTouchDevices() > 0 then
+ begin
+ AddSpace();
+ AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
+ end;
end;
Menu.DefControl := 'mOptionsControlsMenu';
g_GUI_AddWindow(Menu);
Menu.DefControl := 'mOptionsControlsJoystickMenu';
g_GUI_AddWindow(Menu);
+ Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
+ with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
+ begin
+ Name := 'mOptionsControlsTouchMenu';
+ with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
+ begin
+ Name := 'scTouchSize';
+ Max := 20;
+ OnChange := ProcChangeTouchSettings;
+ end;
+ with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
+ begin
+ Name := 'swTouchFire';
+ AddItem(_lc[I_MENU_NO]);
+ AddItem(_lc[I_MENU_YES]);
+ end;
+ end;
+ Menu.DefControl := 'mOptionsControlsTouchMenu';
+ g_GUI_AddWindow(Menu);
+
Menu := TGUIWindow.Create('OptionsPlayersMenu');
with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
begin
diff --git a/src/game/g_options.pas b/src/game/g_options.pas
index a1397a80e949d2b70bfb89ad91b13b4c4db316b6..3d2fed9b9cf7b2c04d3cb5b6e02aed017616a05d 100644 (file)
--- a/src/game/g_options.pas
+++ b/src/game/g_options.pas
{$ENDIF}
e_log, e_input, g_window, g_sound, g_gfx, g_player, Math,
g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
- g_items, wadreader, e_graphics;
+ g_items, wadreader, e_graphics, g_touch;
procedure g_Options_SetDefault();
var
gShowMessages := True;
gRevertPlayers := False;
g_dbg_scale := 1.0;
+ g_touch_size := 1.0;
+ g_touch_fire := True;
for i := 0 to e_MaxJoys-1 do
e_JoystickDeadzones[i] := 8192;
for i := 0 to e_MaxJoys-1 do
e_JoystickDeadzones[i] := config.ReadInt('Joysticks', 'Deadzone' + IntToStr(i), 8192);
+ g_touch_size := Max(config.ReadInt('Touch', 'Size', 10) / 10, 0.1);
+ g_touch_fire := config.ReadBool('Touch', 'Fire', True);
+
g_GFX_SetMax(Min(config.ReadInt('Game', 'MaxParticles', 1000), 50000));
g_Shells_SetMax(Min(config.ReadInt('Game', 'MaxShells', 300), 600));
g_Gibs_SetMax(Min(config.ReadInt('Game', 'MaxGibs', 150), 500));
for i := 0 to e_MaxJoys-1 do
config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
+ config.WriteInt('Touch', 'Size', Round(g_touch_size * 10));
+ config.WriteBool('Touch', 'Fire', g_touch_fire);
+
with config do
case gGibsCount of
0: config.WriteInt('Game', 'GibsCount', 0);
diff --git a/src/game/g_touch.pas b/src/game/g_touch.pas
index 52167bd57b0b8f099ef43732fc0a0f9171071a33..8519f0d4c1dc3dc7d120103e1df23ecb49b50dc7 100644 (file)
--- a/src/game/g_touch.pas
+++ b/src/game/g_touch.pas
uses
SDL2;
+ var
+ g_touch_size: Single;
+ g_touch_fire: Boolean;
+
+ procedure g_Touch_Init;
procedure g_Touch_ShowKeyboard(yes: Boolean);
procedure g_Touch_HandleEvent(const ev: TSDL_TouchFingerEvent);
procedure g_Touch_Draw;
var
jab: Boolean;
- size: Single;
enabled: Boolean;
- angleFireEnabled, angleFire: Boolean;
+ angleFire: Boolean;
keyFinger: array [VK_FIRSTKEY..VK_LASTKEY] of Integer;
procedure GetKeyRect(key: Word; out x, y, w, h: Integer; out founded: Boolean);
dpi := 96;
founded := true;
- sz := Trunc(size * dpi);
+ sz := Trunc(g_touch_size * dpi);
sw := gScreenWidth; sh := gScreenHeight;
if jab then
begin
result := founded and (xx >= x) and (yy >= y) and (xx <= x + w) and (yy <= y + h);
end;
+ procedure g_Touch_Init;
+ begin
+{$IFNDEF HEADLESS}
+ enabled := SDL_GetNumTouchDevices() > 0
+{$ENDIF}
+ end;
+
procedure g_Touch_ShowKeyboard(yes: Boolean);
begin
{$IFNDEF HEADLESS}
end;
(* emulate up+fire / donw+fire *)
- if angleFireEnabled and (gGameSettings.GameType <> GT_NONE) then
+ if g_touch_fire and (gGameSettings.GameType <> GT_NONE) then
begin
if keyFinger[VK_UP] <> 0 then
begin
end;
initialization
-{$IFDEF ANDROID}
- enabled := true;
-{$ENDIF}
- size := 1;
- angleFire := true;
conRegVar('touch_enable', @enabled, 'enable/disable virtual buttons', 'draw buttons');
- conRegVar('touch_anglefire', @angleFireEnabled, 'enable/disable fire when press virtual up/down', 'fire when press up/down');
- conRegVar('touch_size', @size, 0.1, 10, 'size of virtual buttons', 'button size');
+ 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_alt', @jab, 'althernative virtual buttons layout', 'althernative layout');
end.