summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 20b4de5)
raw | patch | inline | side by side (parent: 20b4de5)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 13 Feb 2023 14:06:11 +0000 (17:06 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 09:10:55 +0000 (12:10 +0300) |
src/game/Doom2DF.lpr | patch | blob | history | |
src/game/renders/opengl/r_render.pas | patch | blob | history | |
src/game/renders/opengl/r_touch.pas | [new file with mode: 0644] | patch | blob |
diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr
index f6d74ef47817bbd53f03b639790d6f52499d23ec..f0c3a90a2bc108c090755d66697d701e8cce893b 100644 (file)
--- a/src/game/Doom2DF.lpr
+++ b/src/game/Doom2DF.lpr
r_fonts in 'renders/opengl/r_fonts.pas',
r_common in 'renders/opengl/r_common.pas',
r_console in 'renders/opengl/r_console.pas',
- r_gui in 'renders/opengl/r_gui.pas',
+ {$IFDEF ENABLE_MENU}
+ r_gui in 'renders/opengl/r_gui.pas',
+ {$ENDIF}
r_loadscreen in 'renders/opengl/r_loadscreen.pas',
+ {$IFDEF ENABLE_TOUCH}
+ r_touch in 'renders/opengl/r_touch.pas',
+ {$ENDIF}
{$IFDEF ENABLE_HOLMES}
r_fui_gfx_gl in 'renders/opengl/r_fui_gfx_gl.pas',
r_holmes in 'renders/opengl/r_holmes.pas',
index 202500d6170fbe92ddd1416d47811ce01e071656..80783b6d7f82784d21db3a21ab4e1b90d29e7719 100644 (file)
{$IFDEF ENABLE_SYSTEM}
g_system,
{$ENDIF}
+ {$IFDEF ENABLE_TOUCH}
+ r_touch,
+ {$ENDIF}
{$IFDEF ENABLE_HOLMES}
r_holmes,
{$ENDIF}
r_Holmes_DrawUI;
{$ENDIF}
- // TODO draw touch screen controls
+ {$IFDEF ENABLE_TOUCH}
+ r_Touch_Draw;
+ {$ENDIF}
sys_Repaint;
end;
{$IFDEF ENABLE_TOUCH}
procedure r_Render_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean);
begin
- // TODO implement touchscreen
- founded := False;
+ r_Touch_GetKeyRect(key, x, y, w, h, founded)
end;
{$ENDIF}
diff --git a/src/game/renders/opengl/r_touch.pas b/src/game/renders/opengl/r_touch.pas
--- /dev/null
@@ -0,0 +1,185 @@
+(* Copyright (C) Doom 2D: Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$INCLUDE ../../../shared/a_modes.inc}
+unit r_touch;
+
+interface
+
+ procedure r_Touch_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean);
+ procedure r_Touch_Draw;
+
+implementation
+
+ uses
+ {$IFDEF USE_SDL2}
+ SDL2,
+ {$ENDIF}
+ SysUtils,
+ e_input, g_options, g_system, g_game,
+ r_common, r_draw
+ ;
+
+
+ function GetKeyName (key: Integer): String;
+ begin
+ case key of
+ VK_SHOWKBD: result := 'KBD';
+ VK_HIDEKBD: result := 'KBD';
+ VK_LEFT: result := 'LEFT';
+ VK_RIGHT: result := 'RIGHT';
+ VK_UP: result := 'UP';
+ VK_DOWN: result := 'DOWN';
+ VK_FIRE: result := 'FIRE';
+ VK_OPEN: result := 'OPEN';
+ VK_JUMP: result := 'JUMP';
+ VK_CHAT: result := 'CHAT';
+ VK_ESCAPE: result := 'ESC';
+ VK_0: result := '0';
+ VK_1: result := '1';
+ VK_2: result := '2';
+ VK_3: result := '3';
+ VK_4: result := '4';
+ VK_5: result := '5';
+ VK_6: result := '6';
+ VK_7: result := '7';
+ VK_8: result := '8';
+ VK_9: result := '9';
+ VK_A: result := '10';
+ VK_B: result := '11';
+ VK_C: result := '12';
+ VK_D: result := '13';
+ VK_E: result := '14';
+ VK_F: result := '15';
+ VK_CONSOLE: result := 'CON';
+ VK_STATUS: result := 'STAT';
+ VK_TEAM: result := 'TEAM';
+ VK_PREV: result := '<PREW';
+ VK_NEXT: result := 'NEXT>';
+ VK_LSTRAFE: result := '<';
+ VK_RSTRAFE: result := '>';
+ else
+ if (key > 0) and (key < e_MaxInputKeys) then
+ result := e_KeyNames[key]
+ else
+ result := '<' + IntToStr(key) + '>'
+ end
+ end;
+
+ procedure r_Touch_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean);
+ var
+ sw, sh, sz: Integer;
+ dpi: Single;
+
+ procedure S (xx, yy, ww, hh: Single);
+ begin
+ x := Trunc(xx);
+ y := Trunc(yy);
+ w := Trunc(ww);
+ h := Trunc(hh);
+ founded := true;
+ end;
+
+ begin
+ founded := false;
+ {$IF DEFINED(USE_SDL2) AND NOT DEFINED(SDL2_NODPI)}
+ if SDL_GetDisplayDPI(0, @dpi, nil, nil) <> 0 then
+ dpi := 96;
+ {$ELSE}
+ dpi := 96;
+ {$ENDIF}
+
+ sz := Trunc(g_touch_size * dpi); sw := gScreenWidth; sh := gScreenHeight;
+ x := 0; y := Round(sh * g_touch_offset / 100);
+ w := sz; h := sz;
+
+ if sys_IsTextInputActive() then
+ case key of
+ VK_HIDEKBD: S(sw - (sz/2), 0, sz / 2, sz / 2);
+ end
+ else if g_touch_alt then
+ case key of
+ (* top ------- x ------------------------------- y w ----- h -- *)
+ VK_CONSOLE: S(0, 0, sz / 2, sz / 2);
+ VK_ESCAPE: S(sw - 1*(sz/2) - 1, 0, sz / 2, sz / 2);
+ VK_SHOWKBD: S(sw - 2*(sz/2) - 1, 0, sz / 2, sz / 2);
+ VK_CHAT: S(sw / 2 - (sz/2) / 2 - (sz/2) - 1, 0, sz / 2, sz / 2);
+ VK_STATUS: S(sw / 2 - (sz/2) / 2 - 1, 0, sz / 2, sz / 2);
+ VK_TEAM: S(sw / 2 - (sz/2) / 2 + (sz/2) - 1, 0, sz / 2, sz / 2);
+ (* left --- x - y -------------- w - h --- *)
+ VK_PREV: S(0, sh - 3.0*sz - 1, sz, sz / 2);
+ VK_LEFT: S(0, sh - 2.0*sz - 1, sz, sz * 2);
+ VK_RIGHT: S(sz, sh - 2.0*sz - 1, sz, sz * 2);
+ (* right - x ------------ y -------------- w - h -- *)
+ VK_NEXT: S(sw - 1*sz - 1, sh - 3.0*sz - 1, sz, sz / 2);
+ VK_UP: S(sw - 2*sz - 1, sh - 2.0*sz - 1, sz, sz / 2);
+ VK_FIRE: S(sw - 2*sz - 1, sh - 1.5*sz - 1, sz, sz);
+ VK_DOWN: S(sw - 2*sz - 1, sh - 0.5*sz - 1, sz, sz / 2);
+ VK_JUMP: S(sw - 1*sz - 1, sh - 2.0*sz - 1, sz, sz);
+ VK_OPEN: S(sw - 1*sz - 1, sh - 1.0*sz - 1, sz, sz);
+ end
+ else
+ case key of
+ (* left ----- x ----- y -------------- w ----- h -- *)
+ VK_ESCAPE: S(0.0*sz, y - 1*sz - sz/2, sz, sz / 2);
+ VK_LSTRAFE: S(0.0*sz, y - 0*sz - sz/2, sz / 2, sz);
+ VK_LEFT: S(0.5*sz, y - 0*sz - sz/2, sz, sz);
+ VK_RIGHT: S(1.5*sz, y - 0*sz - sz/2, sz, sz);
+ VK_RSTRAFE: S(2.5*sz, y - 0*sz - sz/2, sz / 2, sz);
+ (* right - x ------------ y --------------- w - h *)
+ VK_UP: S(sw - 1*sz - 1, y - 1*sz - sz/2, sz, sz);
+ VK_FIRE: S(sw - 1*sz - 1, y - 0*sz - sz/2, sz, sz);
+ VK_DOWN: S(sw - 1*sz - 1, y - -1*sz - sz/2, sz, sz);
+ VK_NEXT: S(sw - 2*sz - 1, y - 1*sz - sz/2, sz, sz);
+ VK_JUMP: S(sw - 2*sz - 1, y - 0*sz - sz/2, sz, sz);
+ VK_PREV: S(sw - 3*sz - 1, y - 1*sz - sz/2, sz, sz);
+ VK_OPEN: S(sw - 3*sz - 1, y - 0*sz - sz/2, sz, sz);
+ (* bottom ---- x -------------------------- y ---------------- w ----- h -- *)
+ VK_CHAT: S(sw/2 - sz/4 - 2*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
+ VK_CONSOLE: S(sw/2 - sz/4 - 1*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
+ VK_STATUS: S(sw/2 - sz/4 - 0*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
+ VK_TEAM: S(sw/2 - sz/4 - -1*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
+ VK_SHOWKBD: S(sw/2 - sz/4 - -2*(sz/2) - 1, sh - 2*(sz/2) - 1, sz / 2, sz / 2);
+ VK_0: S(sw/2 - sz/4 - 5*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
+ VK_1: S(sw/2 - sz/4 - 4*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
+ VK_2: S(sw/2 - sz/4 - 3*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
+ VK_3: S(sw/2 - sz/4 - 2*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
+ VK_4: S(sw/2 - sz/4 - 1*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
+ VK_5: S(sw/2 - sz/4 - 0*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
+ VK_6: S(sw/2 - sz/4 - -1*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
+ VK_7: S(sw/2 - sz/4 - -2*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
+ VK_8: S(sw/2 - sz/4 - -3*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
+ VK_9: S(sw/2 - sz/4 - -4*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
+ VK_A: S(sw/2 - sz/4 - -5*(sz/2) - 1, sh - 1*(sz/2) - 1, sz / 2, sz / 2);
+ end
+ end;
+
+ procedure r_Touch_Draw;
+ var i, x, y, w, h: Integer; founded: Boolean;
+ begin
+ if g_touch_enabled then
+ begin
+ for i := VK_FIRSTKEY to VK_LASTKEY do
+ begin
+ r_Touch_GetKeyRect(i, x, y, w, h, founded);
+ if founded then
+ begin
+ r_Draw_Rect(x, y, x + w, y + h, 0, 255, 0, 225);
+ r_Draw_Text(GetKeyName(i), x, y, 255, 255, 255, 225, stdfont);
+ end
+ end
+ end
+ end;
+
+end.