author | Wuzzy <Wuzzy2@mail.ru> |
Sun, 29 Sep 2019 22:23:00 +0200 | |
changeset 15435 | e9fd2527a457 |
parent 14538 | 1dab5d92aca7 |
child 15900 | 128ace913837 |
permissions | -rw-r--r-- |
5621 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
6700 | 3 |
* Copyright (c) 2012 Richard Deurwaarder <xeli@xelification.com> |
5621 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9521
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
5621 | 17 |
*) |
18 |
||
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
19 |
{$INCLUDE "options.inc"} |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
20 |
|
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
21 |
unit uTouch; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
22 |
|
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
23 |
interface |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
24 |
|
14538
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
25 |
uses SysUtils, uUtils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, GLUnit, uTypes, uCaptions, uWorld, uGearsHedgehog; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
26 |
|
5609
9d66611e4d0a
Introduced a Touch_Finger type to replace the arrays with coords, makes cleaner code
Xeli
parents:
5605
diff
changeset
|
27 |
|
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
28 |
procedure initModule; |
7850 | 29 |
procedure freeModule; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
30 |
|
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
31 |
procedure ProcessTouch; |
6961
d5ac09894a1b
hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons
Xeli
parents:
6957
diff
changeset
|
32 |
procedure NewTurnBeginning; |
d5ac09894a1b
hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons
Xeli
parents:
6957
diff
changeset
|
33 |
|
9379 | 34 |
procedure onTouchDown(x, y: Single; pointerId: TSDL_FingerId); |
35 |
procedure onTouchMotion(x, y, dx, dy: Single; pointerId: TSDL_FingerId); |
|
36 |
procedure onTouchUp(x, y: Single; pointerId: TSDL_FingerId); |
|
37 |
||
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
38 |
function convertToCursorX(x: LongInt): LongInt; |
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
39 |
function convertToCursorY(y: LongInt): LongInt; |
9379 | 40 |
|
6693 | 41 |
function addFinger(x,y: Longword; id: TSDL_FingerId): PTouch_Data; |
42 |
function updateFinger(x,y,dx,dy: Longword; id: TSDL_FingerId): PTouch_Data; |
|
43 |
procedure deleteFinger(id: TSDL_FingerId); |
|
9379 | 44 |
|
6693 | 45 |
procedure onTouchClick(finger: TTouch_Data); |
46 |
procedure onTouchDoubleClick(finger: TTouch_Data); |
|
6712
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
47 |
procedure onTouchLongClick(finger: TTouch_Data); |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
48 |
|
6693 | 49 |
function findFinger(id: TSDL_FingerId): PTouch_Data; |
50 |
procedure aim(finger: TTouch_Data); |
|
51 |
function isOnCrosshair(finger: TTouch_Data): boolean; |
|
52 |
function isOnCurrentHog(finger: TTouch_Data): boolean; |
|
6702 | 53 |
procedure convertToWorldCoord(var x,y: LongInt; finger: TTouch_Data); |
54 |
procedure convertToFingerCoord(var x,y: LongInt; oldX, oldY: LongInt); |
|
6693 | 55 |
function fingerHasMoved(finger: TTouch_Data): boolean; |
6702 | 56 |
function calculateDelta(finger1, finger2: TTouch_Data): LongInt; |
6693 | 57 |
function getSecondFinger(finger: TTouch_Data): PTouch_Data; |
58 |
function isOnRect(rect: TSDL_Rect; finger: TTouch_Data): boolean; |
|
6703 | 59 |
function isOnRect(x,y,w,h: LongInt; finger: TTouch_Data): boolean; |
6723
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
60 |
function isOnWidget(widget: TOnScreenWidget; finger: TTouch_Data): boolean; |
6693 | 61 |
procedure printFinger(finger: TTouch_Data); |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
62 |
implementation |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
63 |
|
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
64 |
const |
6712
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
65 |
clickTime = 200; |
11088
378882cc9148
- Fix for uTouch.pas:365: 34: Identifier not found "nilFingerId"
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
66 |
nilFingerId = High(TSDL_FingerId); |
7185
92a045156255
Android: first attempt at using the density call from java
Xeli
parents:
7105
diff
changeset
|
67 |
baseRectSize = 96; |
5828
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
68 |
|
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
69 |
var |
7185
92a045156255
Android: first attempt at using the density call from java
Xeli
parents:
7105
diff
changeset
|
70 |
rectSize, halfRectSize: LongInt; |
92a045156255
Android: first attempt at using the density call from java
Xeli
parents:
7105
diff
changeset
|
71 |
|
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
72 |
pointerCount : Longword; |
6693 | 73 |
fingers: array of TTouch_Data; |
5605
31bd6e30df02
Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents:
5599
diff
changeset
|
74 |
moveCursor : boolean; |
5617
88f43becefe3
added low jump, you can low-jump by double tapping the right or left side of the screen
Xeli
parents:
5615
diff
changeset
|
75 |
invertCursor : boolean; |
88f43becefe3
added low jump, you can low-jump by double tapping the right or left side of the screen
Xeli
parents:
5615
diff
changeset
|
76 |
|
8330 | 77 |
//Pinch to zoom |
6702 | 78 |
pinchSize : LongInt; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
79 |
baseZoomValue: GLFloat; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
80 |
|
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
81 |
//aiming |
6703 | 82 |
aimingCrosshair: boolean; |
8330 | 83 |
aimingUp, aimingDown: boolean; |
5605
31bd6e30df02
Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents:
5599
diff
changeset
|
84 |
targetAngle: LongInt; |
31bd6e30df02
Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents:
5599
diff
changeset
|
85 |
|
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
86 |
buttonsDown: Longword; |
6957 | 87 |
targetting, targetted: boolean; //true when targetting an airstrike or the like |
5609
9d66611e4d0a
Introduced a Touch_Finger type to replace the arrays with coords, makes cleaner code
Xeli
parents:
5605
diff
changeset
|
88 |
|
9379 | 89 |
procedure onTouchDown(x, y: Single; pointerId: TSDL_FingerId); |
8330 | 90 |
var |
6693 | 91 |
finger: PTouch_Data; |
14538
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
92 |
xr, yr, tmp: LongWord; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
93 |
begin |
9379 | 94 |
xr:= round(x * cScreenWidth); |
95 |
yr:= round(y * cScreenHeight); |
|
96 |
||
97 |
finger:= addFinger(xr, yr, pointerId); |
|
6703 | 98 |
|
99 |
inc(buttonsDown);//inc buttonsDown, if we don't see a button down we'll dec it |
|
100 |
||
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
101 |
if isOnCrosshair(finger^) then |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
102 |
begin |
6703 | 103 |
aimingCrosshair:= true; |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
104 |
aim(finger^); |
6703 | 105 |
moveCursor:= false; |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
106 |
exit; |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
107 |
end; |
5605
31bd6e30df02
Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents:
5599
diff
changeset
|
108 |
|
6723
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
109 |
if isOnWidget(fireButton, finger^) then |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
110 |
begin |
6957 | 111 |
ParseTeamCommand('+attack'); |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
112 |
moveCursor:= false; |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
113 |
finger^.pressedWidget:= @fireButton; |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
114 |
exit; |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
115 |
end; |
6723
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
116 |
if isOnWidget(arrowLeft, finger^) then |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
117 |
begin |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
118 |
ParseTeamCommand('+left'); |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
119 |
moveCursor:= false; |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
120 |
finger^.pressedWidget:= @arrowLeft; |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
121 |
exit; |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
122 |
end; |
6723
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
123 |
if isOnWidget(arrowRight, finger^) then |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
124 |
begin |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
125 |
ParseTeamCommand('+right'); |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
126 |
moveCursor:= false; |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
127 |
finger^.pressedWidget:= @arrowRight; |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
128 |
exit; |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
129 |
end; |
6723
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
130 |
if isOnWidget(arrowUp, finger^) then |
6806
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
131 |
begin |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
132 |
ParseTeamCommand('+up'); |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
133 |
aimingUp:= true; |
6806
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
134 |
moveCursor:= false; |
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
135 |
finger^.pressedWidget:= @arrowUp; |
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
136 |
exit; |
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
137 |
end; |
6723
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
138 |
if isOnWidget(arrowDown, finger^) then |
6806
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
139 |
begin |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
140 |
ParseTeamCommand('+down'); |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
141 |
aimingDown:= true; |
6806
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
142 |
moveCursor:= false; |
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
143 |
finger^.pressedWidget:= @arrowDown; |
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
144 |
exit; |
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
145 |
end; |
6640 | 146 |
|
6723
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
147 |
if isOnWidget(pauseButton, finger^) then |
6806
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
148 |
begin |
14304
055eae933482
Touch: Parse pause command when tapping pause button instead of toggling pause directly
Wuzzy <Wuzzy2@mail.ru>
parents:
13642
diff
changeset
|
149 |
ParseTeamCommand('pause'); |
6806
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
150 |
moveCursor:= false; |
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
151 |
finger^.pressedWidget:= @pauseButton; |
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
152 |
exit; |
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
153 |
end; |
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
154 |
|
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
155 |
if isOnWidget(utilityWidget, finger^) then |
cdfb6c7099e5
first part of the utilitywidget (grenade timer/swap hogs) code
Xeli
parents:
6723
diff
changeset
|
156 |
begin |
6957 | 157 |
finger^.pressedWidget:= @utilityWidget; |
158 |
moveCursor:= false; |
|
6956 | 159 |
if(CurrentHedgehog <> nil) then |
160 |
begin |
|
161 |
if Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable <> 0 then |
|
14538
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
162 |
begin |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
163 |
tmp:= HHGetTimerMsg(CurrentHedgehog^.Gear); |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
164 |
if tmp <> MSGPARAM_INVALID then |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
165 |
ParseTeamCommand('/timer ' + inttostr(tmp mod 5 + 1)); |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
166 |
end; |
6956 | 167 |
end; |
6957 | 168 |
exit; |
8330 | 169 |
end; |
14538
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
170 |
|
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
171 |
if isOnWidget(utilityWidget2, finger^) then |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
172 |
begin |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
173 |
finger^.pressedWidget:= @utilityWidget2; |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
174 |
moveCursor:= false; |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
175 |
if(CurrentHedgehog <> nil) then |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
176 |
begin |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
177 |
if Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_SetBounce <> 0 then |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
178 |
begin |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
179 |
tmp := HHGetBouncinessMsg(CurrentHedgehog^.Gear); |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
180 |
if tmp <> MSGPARAM_INVALID then |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
181 |
begin |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
182 |
ParseTeamCommand('+precise'); |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
183 |
ParseTeamCommand('timer ' + inttostr(tmp mod 5 + 1)); |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
184 |
bounceButtonPressed:= true; |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
185 |
end; |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
186 |
end; |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
187 |
end; |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
188 |
exit; |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
189 |
end; |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
190 |
|
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
191 |
dec(buttonsDown);//no buttonsDown, undo the inc() above |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
192 |
if buttonsDown = 0 then |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
193 |
begin |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
194 |
moveCursor:= true; |
6951
a37e470c8694
- changed targetting, to launch an airstrike move the cursor/pointer to a location and then press the firebutton
Xeli
parents:
6950
diff
changeset
|
195 |
case pointerCount of |
a37e470c8694
- changed targetting, to launch an airstrike move the cursor/pointer to a location and then press the firebutton
Xeli
parents:
6950
diff
changeset
|
196 |
1: |
6957 | 197 |
targetting:= not(targetted) and (CurrentHedgehog <> nil) and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0); |
6951
a37e470c8694
- changed targetting, to launch an airstrike move the cursor/pointer to a location and then press the firebutton
Xeli
parents:
6950
diff
changeset
|
198 |
2: |
a37e470c8694
- changed targetting, to launch an airstrike move the cursor/pointer to a location and then press the firebutton
Xeli
parents:
6950
diff
changeset
|
199 |
begin |
a37e470c8694
- changed targetting, to launch an airstrike move the cursor/pointer to a location and then press the firebutton
Xeli
parents:
6950
diff
changeset
|
200 |
moveCursor:= false; |
a37e470c8694
- changed targetting, to launch an airstrike move the cursor/pointer to a location and then press the firebutton
Xeli
parents:
6950
diff
changeset
|
201 |
pinchSize := calculateDelta(finger^, getSecondFinger(finger^)^); |
a37e470c8694
- changed targetting, to launch an airstrike move the cursor/pointer to a location and then press the firebutton
Xeli
parents:
6950
diff
changeset
|
202 |
baseZoomValue := ZoomValue |
a37e470c8694
- changed targetting, to launch an airstrike move the cursor/pointer to a location and then press the firebutton
Xeli
parents:
6950
diff
changeset
|
203 |
end; |
a37e470c8694
- changed targetting, to launch an airstrike move the cursor/pointer to a location and then press the firebutton
Xeli
parents:
6950
diff
changeset
|
204 |
end; |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
205 |
end; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
206 |
end; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
207 |
|
9379 | 208 |
procedure onTouchMotion(x, y, dx, dy: Single; pointerId: TSDL_FingerId); |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
209 |
var |
6693 | 210 |
finger, secondFinger: PTouch_Data; |
9379 | 211 |
currentPinchDelta, zoom : Single; |
212 |
xr, yr, dxr, dyr: LongWord; |
|
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
213 |
begin |
9379 | 214 |
xr:= round(x * cScreenWidth); |
215 |
yr:= round(y * cScreenHeight); |
|
216 |
dxr:= round(dx * cScreenWidth); |
|
217 |
dyr:= round(dy * cScreenHeight); |
|
218 |
||
219 |
finger:= updateFinger(xr, yr, dxr, dyr, pointerId); |
|
220 |
if finger = nil then |
|
221 |
exit; |
|
5733
5ab22736bdb6
Fixed a major bug (related to pointers) which also solves the stuttering when zooming in and out
Xeli
parents:
5621
diff
changeset
|
222 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
223 |
if moveCursor then |
5828
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
224 |
begin |
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
225 |
if invertCursor then |
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
226 |
begin |
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
227 |
CursorPoint.X := CursorPoint.X - finger^.dx; |
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
228 |
CursorPoint.Y := CursorPoint.Y + finger^.dy; |
5828
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
229 |
end |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
230 |
else |
5828
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
231 |
begin |
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
232 |
CursorPoint.X := CursorPoint.X + finger^.dx; |
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
233 |
CursorPoint.Y := CursorPoint.Y - finger^.dy; |
5828
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
234 |
end; |
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
235 |
exit //todo change into switch rather than ugly ifs |
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
236 |
end; |
8330 | 237 |
|
238 |
if aimingCrosshair then |
|
5828
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
239 |
begin |
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
240 |
aim(finger^); |
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
241 |
exit |
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
242 |
end; |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
243 |
|
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
244 |
if (buttonsDown = 0) and (pointerCount = 2) then |
5828
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
245 |
begin |
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
246 |
secondFinger := getSecondFinger(finger^); |
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
247 |
currentPinchDelta := calculateDelta(finger^, secondFinger^) - pinchSize; |
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
248 |
zoom := currentPinchDelta/cScreenWidth; |
6702 | 249 |
ZoomValue := baseZoomValue - (zoom * cMinMaxZoomLevelDelta); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
250 |
if ZoomValue < cMaxZoomLevel then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
251 |
ZoomValue := cMaxZoomLevel; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
252 |
if ZoomValue > cMinZoomLevel then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
253 |
ZoomValue := cMinZoomLevel; |
5828
667fb58d7f18
Changed firebutton, parameters in uTouch might need to be tweaked some more
Xeli
parents:
5733
diff
changeset
|
254 |
end; |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
255 |
|
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
256 |
end; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
257 |
|
9379 | 258 |
procedure onTouchUp(x,y: Single; pointerId: TSDL_FingerId); |
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
259 |
var |
6693 | 260 |
finger: PTouch_Data; |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
261 |
widget: POnScreenWidget; |
9379 | 262 |
xr, yr: LongWord; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
263 |
begin |
9379 | 264 |
xr:= round(x * cScreenWidth); |
265 |
yr:= round(y * cScreenHeight); |
|
266 |
||
267 |
finger:= updateFinger(xr, yr, 0, 0, pointerId); |
|
268 |
if finger = nil then |
|
269 |
exit; |
|
270 |
||
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
271 |
//Check for onTouchClick event |
6712
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
272 |
if not(fingerHasMoved(finger^)) then |
6950
f34ff54b0cbd
-Fixed FingerHasMoved function, still might need a little tweaking
Xeli
parents:
6949
diff
changeset
|
273 |
begin |
6712
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
274 |
if (RealTicks - finger^.timeSinceDown) < clickTime then |
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
275 |
onTouchClick(finger^) |
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
276 |
else |
9379 | 277 |
onTouchLongClick(finger^); |
6950
f34ff54b0cbd
-Fixed FingerHasMoved function, still might need a little tweaking
Xeli
parents:
6949
diff
changeset
|
278 |
end; |
5605
31bd6e30df02
Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents:
5599
diff
changeset
|
279 |
|
6703 | 280 |
if aimingCrosshair then |
281 |
begin |
|
282 |
aimingCrosshair:= false; |
|
7022 | 283 |
ParseTeamCommand('-up'); |
284 |
ParseTeamCommand('-down'); |
|
6703 | 285 |
dec(buttonsDown); |
286 |
end; |
|
287 |
||
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
288 |
widget:= finger^.pressedWidget; |
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
289 |
if (buttonsDown > 0) and (widget <> nil) then |
5605
31bd6e30df02
Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents:
5599
diff
changeset
|
290 |
begin |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
291 |
dec(buttonsDown); |
8330 | 292 |
|
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
293 |
if widget = @arrowLeft then |
6949
615cc50903c8
remove last boolean keys references and using only ParseCommand in uTouch now
Xeli
parents:
6919
diff
changeset
|
294 |
ParseTeamCommand('-left'); |
8330 | 295 |
|
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
296 |
if widget = @arrowRight then |
6949
615cc50903c8
remove last boolean keys references and using only ParseCommand in uTouch now
Xeli
parents:
6919
diff
changeset
|
297 |
ParseTeamCommand('-right'); |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
298 |
|
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
299 |
if widget = @arrowUp then |
6949
615cc50903c8
remove last boolean keys references and using only ParseCommand in uTouch now
Xeli
parents:
6919
diff
changeset
|
300 |
ParseTeamCommand('-up'); |
6640 | 301 |
|
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
302 |
if widget = @arrowDown then |
6949
615cc50903c8
remove last boolean keys references and using only ParseCommand in uTouch now
Xeli
parents:
6919
diff
changeset
|
303 |
ParseTeamCommand('-down'); |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
304 |
|
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
305 |
if widget = @fireButton then |
6957 | 306 |
ParseTeamCommand('-attack'); |
8330 | 307 |
|
6957 | 308 |
if widget = @utilityWidget then |
6962 | 309 |
if (CurrentHedgehog <> nil)then |
310 |
if(Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0)then |
|
311 |
begin |
|
312 |
ParseTeamCommand('put'); |
|
313 |
targetted:= true; |
|
314 |
end |
|
7105 | 315 |
else if (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amSwitch) then |
6962 | 316 |
ParseTeamCommand('switch') |
317 |
else WriteLnToConsole(inttostr(ord(Ammoz[CurrentHedgehog^.CurAmmoType].NameId)) + ' ' + inttostr(ord(sidSwitch))); |
|
6640 | 318 |
end; |
8330 | 319 |
|
6951
a37e470c8694
- changed targetting, to launch an airstrike move the cursor/pointer to a location and then press the firebutton
Xeli
parents:
6950
diff
changeset
|
320 |
if targetting then |
13642
3d14950641a4
Refactor text color variable names, export 2 color values to Lua
Wuzzy <Wuzzy2@mail.ru>
parents:
11821
diff
changeset
|
321 |
AddCaption(trmsg[sidPressTarget], capcolDefault, capgrpAmmoInfo); |
8330 | 322 |
|
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
323 |
deleteFinger(pointerId); |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
324 |
end; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
325 |
|
6693 | 326 |
procedure onTouchDoubleClick(finger: TTouch_Data); |
5617
88f43becefe3
added low jump, you can low-jump by double tapping the right or left side of the screen
Xeli
parents:
5615
diff
changeset
|
327 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
328 |
finger := finger;//avoid compiler hint |
5617
88f43becefe3
added low jump, you can low-jump by double tapping the right or left side of the screen
Xeli
parents:
5615
diff
changeset
|
329 |
end; |
88f43becefe3
added low jump, you can low-jump by double tapping the right or left side of the screen
Xeli
parents:
5615
diff
changeset
|
330 |
|
6712
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
331 |
procedure onTouchLongClick(finger: TTouch_Data); |
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
332 |
begin |
6723
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
333 |
if isOnWidget(jumpWidget, finger) then |
6950
f34ff54b0cbd
-Fixed FingerHasMoved function, still might need a little tweaking
Xeli
parents:
6949
diff
changeset
|
334 |
begin |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
335 |
ParseTeamCommand('ljump'); |
6950
f34ff54b0cbd
-Fixed FingerHasMoved function, still might need a little tweaking
Xeli
parents:
6949
diff
changeset
|
336 |
exit; |
f34ff54b0cbd
-Fixed FingerHasMoved function, still might need a little tweaking
Xeli
parents:
6949
diff
changeset
|
337 |
end; |
6712
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
338 |
end; |
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
339 |
|
6693 | 340 |
procedure onTouchClick(finger: TTouch_Data); |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
341 |
begin |
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
342 |
|
6648
025473a2c420
prevent the cursor from being shown on the mobile version, and close the menu on tap when the tap is not on the ammo menu
Xeli
parents:
6640
diff
changeset
|
343 |
if bShowAmmoMenu then |
8330 | 344 |
begin |
6683
75a1d84ac606
small refactoring to touch screen buttons, use a record to store values, added 'offset' fields to adjust active button area
koda
parents:
6676
diff
changeset
|
345 |
if isOnRect(AmmoRect, finger) then |
6648
025473a2c420
prevent the cursor from being shown on the mobile version, and close the menu on tap when the tap is not on the ammo menu
Xeli
parents:
6640
diff
changeset
|
346 |
begin |
025473a2c420
prevent the cursor from being shown on the mobile version, and close the menu on tap when the tap is not on the ammo menu
Xeli
parents:
6640
diff
changeset
|
347 |
CursorPoint.X:= finger.x; |
025473a2c420
prevent the cursor from being shown on the mobile version, and close the menu on tap when the tap is not on the ammo menu
Xeli
parents:
6640
diff
changeset
|
348 |
CursorPoint.Y:= finger.y; |
8330 | 349 |
ParseTeamCommand('put'); |
6648
025473a2c420
prevent the cursor from being shown on the mobile version, and close the menu on tap when the tap is not on the ammo menu
Xeli
parents:
6640
diff
changeset
|
350 |
end |
025473a2c420
prevent the cursor from being shown on the mobile version, and close the menu on tap when the tap is not on the ammo menu
Xeli
parents:
6640
diff
changeset
|
351 |
else |
025473a2c420
prevent the cursor from being shown on the mobile version, and close the menu on tap when the tap is not on the ammo menu
Xeli
parents:
6640
diff
changeset
|
352 |
bShowAmmoMenu:= false; |
025473a2c420
prevent the cursor from being shown on the mobile version, and close the menu on tap when the tap is not on the ammo menu
Xeli
parents:
6640
diff
changeset
|
353 |
exit; |
5589 | 354 |
end; |
355 |
||
6723
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
356 |
if isOnCurrentHog(finger) or isOnWidget(AMWidget, finger) then |
5595 | 357 |
begin |
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
358 |
bShowAmmoMenu := true; |
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
359 |
exit; |
5595 | 360 |
end; |
6712
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
361 |
|
6723
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
362 |
if isOnWidget(jumpWidget, finger) then |
6712
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
363 |
begin |
8330 | 364 |
ParseTeamCommand('hjump'); |
6712
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
365 |
exit; |
c582869fbe7f
changed jumping, on x button tap is high jump, on longpress + release is low jump (read: it only does a low jump when you release)
Xeli
parents:
6707
diff
changeset
|
366 |
end; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
367 |
end; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
368 |
|
6693 | 369 |
function addFinger(x,y: Longword; id: TSDL_FingerId): PTouch_Data; |
8330 | 370 |
var |
5609
9d66611e4d0a
Introduced a Touch_Finger type to replace the arrays with coords, makes cleaner code
Xeli
parents:
5605
diff
changeset
|
371 |
xCursor, yCursor, index : LongInt; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
372 |
begin |
11799 | 373 |
// check array size |
374 |
// note: pointerCount will be incremented later, |
|
375 |
// so at this point it's the index of the new entry |
|
376 |
if Length(fingers) <= pointerCount then |
|
11780 | 377 |
begin |
378 |
setLength(fingers, Length(fingers)*2); |
|
379 |
for index := Length(fingers) div 2 to (Length(fingers)-1) do |
|
380 |
fingers[index].id := nilFingerId; |
|
381 |
end; |
|
8330 | 382 |
|
11780 | 383 |
xCursor := convertToCursorX(x); |
384 |
yCursor := convertToCursorY(y); |
|
8330 | 385 |
|
11780 | 386 |
//on removing fingers, all fingers are moved to the left |
387 |
//with dynamic arrays being zero based, the new position of the finger is the old pointerCount |
|
388 |
fingers[pointerCount].id := id; |
|
389 |
fingers[pointerCount].historicalX := xCursor; |
|
390 |
fingers[pointerCount].historicalY := yCursor; |
|
391 |
fingers[pointerCount].x := xCursor; |
|
392 |
fingers[pointerCount].y := yCursor; |
|
393 |
fingers[pointerCount].dx := 0; |
|
394 |
fingers[pointerCount].dy := 0; |
|
395 |
fingers[pointerCount].timeSinceDown:= RealTicks; |
|
396 |
fingers[pointerCount].pressedWidget:= nil; |
|
8330 | 397 |
|
11780 | 398 |
addFinger:= @fingers[pointerCount]; |
399 |
inc(pointerCount); |
|
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
400 |
end; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
401 |
|
9379 | 402 |
function updateFinger(x, y, dx, dy: Longword; id: TSDL_FingerId): PTouch_Data; |
403 |
var finger : PTouch_Data; |
|
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
404 |
begin |
11780 | 405 |
finger:= findFinger(id); |
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
406 |
|
11780 | 407 |
if finger <> nil then |
408 |
begin |
|
409 |
finger^.x:= convertToCursorX(x); |
|
410 |
finger^.y:= convertToCursorY(y); |
|
411 |
finger^.dx:= dx; |
|
412 |
finger^.dy:= dy; |
|
413 |
end |
|
414 |
else |
|
415 |
WriteLnToConsole('finger ' + inttostr(id) + ' not found'); |
|
416 |
updateFinger:= finger |
|
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
417 |
end; |
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
418 |
|
6693 | 419 |
procedure deleteFinger(id: TSDL_FingerId); |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
420 |
var |
6228
1b7d4d7d162b
added lines to avoid compiler hints, is this really the way we want to do it though? ;/
Xeli
parents:
6029
diff
changeset
|
421 |
index : Longword; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
422 |
begin |
8330 | 423 |
|
11780 | 424 |
dec(pointerCount); |
425 |
for index := 0 to pointerCount do |
|
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
426 |
begin |
11780 | 427 |
if fingers[index].id = id then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
428 |
begin |
11780 | 429 |
//put the last finger into the spot of the finger to be removed, |
430 |
//so that all fingers are packed to the far left |
|
431 |
if pointerCount <> index then |
|
432 |
begin |
|
433 |
fingers[index].id := fingers[pointerCount].id; |
|
434 |
fingers[index].x := fingers[pointerCount].x; |
|
435 |
fingers[index].y := fingers[pointerCount].y; |
|
436 |
fingers[index].historicalX := fingers[pointerCount].historicalX; |
|
437 |
fingers[index].historicalY := fingers[pointerCount].historicalY; |
|
438 |
fingers[index].timeSinceDown := fingers[pointerCount].timeSinceDown; |
|
439 |
fingers[index].pressedWidget := fingers[pointerCount].pressedWidget; |
|
8330 | 440 |
|
11780 | 441 |
fingers[pointerCount].id := nilFingerId; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
442 |
end |
11780 | 443 |
else |
444 |
fingers[index].id := nilFingerId; |
|
445 |
break; |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
446 |
end; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
447 |
end; |
5609
9d66611e4d0a
Introduced a Touch_Finger type to replace the arrays with coords, makes cleaner code
Xeli
parents:
5605
diff
changeset
|
448 |
|
5589 | 449 |
end; |
450 |
||
6961
d5ac09894a1b
hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons
Xeli
parents:
6957
diff
changeset
|
451 |
procedure NewTurnBeginning; |
d5ac09894a1b
hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons
Xeli
parents:
6957
diff
changeset
|
452 |
begin |
d5ac09894a1b
hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons
Xeli
parents:
6957
diff
changeset
|
453 |
targetted:= false; |
d5ac09894a1b
hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons
Xeli
parents:
6957
diff
changeset
|
454 |
targetting:= false; |
7022 | 455 |
SetUtilityWidgetState(amNothing); |
6961
d5ac09894a1b
hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons
Xeli
parents:
6957
diff
changeset
|
456 |
end; |
d5ac09894a1b
hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons
Xeli
parents:
6957
diff
changeset
|
457 |
|
d5ac09894a1b
hide utilitywidget when changing turns, this also fixes some inconsistency when using targetting weapons
Xeli
parents:
6957
diff
changeset
|
458 |
|
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
459 |
procedure ProcessTouch; |
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
460 |
var |
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
461 |
deltaAngle: LongInt; |
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
462 |
begin |
8330 | 463 |
invertCursor := not(bShowAmmoMenu or targetting); |
6705
d2e95dcf2bb0
stop the crosshair from twitching when it's not supposed to move + fix aimingUp/Down booleans
Xeli
parents:
6704
diff
changeset
|
464 |
if aimingCrosshair then |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
465 |
if CurrentHedgehog^.Gear <> nil then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
466 |
begin |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
467 |
deltaAngle:= CurrentHedgehog^.Gear^.Angle - targetAngle; |
8330 | 468 |
if (deltaAngle > -5) and (deltaAngle < 5) then |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
469 |
begin |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
470 |
if(aimingUp)then |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
471 |
begin |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
472 |
aimingUp:= false; |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
473 |
ParseTeamCommand('-up'); |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
474 |
end; |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
475 |
if(aimingDown)then |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
476 |
begin |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
477 |
aimingDown:= false; |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
478 |
ParseTeamCommand('-down'); |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
479 |
end |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
480 |
end |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
481 |
else |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
482 |
begin |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
483 |
if (deltaAngle < 0) then |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
484 |
begin |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
485 |
if aimingUp then |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
486 |
begin |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
487 |
aimingUp:= false; |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
488 |
ParseTeamCommand('-up'); |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
489 |
end; |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
490 |
if(aimingDown)then |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
491 |
begin |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
492 |
aimingDown:= true; |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
493 |
ParseTeamCommand('-down'); |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
494 |
end |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
495 |
end |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
496 |
else |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
497 |
begin |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
498 |
if aimingDown then |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
499 |
begin |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
500 |
ParseTeamCommand('-down'); |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
501 |
aimingDown:= false; |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
502 |
end; |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
503 |
if aimingUp then |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
504 |
begin |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
505 |
aimingUp:= true; |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
506 |
ParseTeamCommand('+up'); |
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
507 |
end; |
8330 | 508 |
end; |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
509 |
end; |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
510 |
end |
8330 | 511 |
else |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
512 |
begin |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
513 |
if aimingUp then |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
514 |
begin |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
515 |
ParseTeamCommand('-up'); |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
516 |
aimingUp:= false; |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
517 |
end; |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
518 |
if aimingDown then |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
519 |
begin |
6919
bf7433e62b9c
in uTouch dont use bools to represent keystrokes, but issue ParseCommands
Xeli
parents:
6808
diff
changeset
|
520 |
ParseTeamCommand('-down'); |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
521 |
aimingDown:= false; |
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
522 |
end; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
523 |
end; |
14538
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
524 |
|
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
525 |
if bounceButtonPressed then |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
526 |
begin |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
527 |
ParseTeamCommand('-precise'); |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
528 |
bounceButtonPressed:= false; |
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
529 |
end; |
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
530 |
end; |
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
531 |
|
6693 | 532 |
function findFinger(id: TSDL_FingerId): PTouch_Data; |
5733
5ab22736bdb6
Fixed a major bug (related to pointers) which also solves the stuttering when zooming in and out
Xeli
parents:
5621
diff
changeset
|
533 |
var |
5ab22736bdb6
Fixed a major bug (related to pointers) which also solves the stuttering when zooming in and out
Xeli
parents:
5621
diff
changeset
|
534 |
index: LongWord; |
5609
9d66611e4d0a
Introduced a Touch_Finger type to replace the arrays with coords, makes cleaner code
Xeli
parents:
5605
diff
changeset
|
535 |
begin |
11777
77afc967f38e
fix memory corruptions caused by outofbounds-writes in uTouch
sheepluva
parents:
11592
diff
changeset
|
536 |
for index:= 0 to (Length(fingers)-1) do |
8330 | 537 |
if fingers[index].id = id then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
538 |
begin |
9379 | 539 |
findFinger:= @fingers[index]; |
540 |
exit; |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
541 |
end; |
9379 | 542 |
findFinger:= nil; |
5609
9d66611e4d0a
Introduced a Touch_Finger type to replace the arrays with coords, makes cleaner code
Xeli
parents:
5605
diff
changeset
|
543 |
end; |
9d66611e4d0a
Introduced a Touch_Finger type to replace the arrays with coords, makes cleaner code
Xeli
parents:
5605
diff
changeset
|
544 |
|
6693 | 545 |
procedure aim(finger: TTouch_Data); |
8330 | 546 |
var |
6702 | 547 |
hogX, hogY, touchX, touchY, deltaX, deltaY: LongInt; |
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
548 |
begin |
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
549 |
if CurrentHedgehog^.Gear <> nil then |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
550 |
begin |
6702 | 551 |
touchX := 0;//avoid compiler hint |
552 |
touchY := 0; |
|
553 |
hogX := hwRound(CurrentHedgehog^.Gear^.X); |
|
554 |
hogY := hwRound(CurrentHedgehog^.Gear^.Y); |
|
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
555 |
|
5609
9d66611e4d0a
Introduced a Touch_Finger type to replace the arrays with coords, makes cleaner code
Xeli
parents:
5605
diff
changeset
|
556 |
convertToWorldCoord(touchX, touchY, finger); |
6702 | 557 |
deltaX := abs(TouchX-HogX); |
558 |
deltaY := TouchY-HogY; |
|
8330 | 559 |
|
6703 | 560 |
targetAngle:= (Round(DeltaY / sqrt(sqr(deltaX) + sqr(deltaY)) * 2048) + 2048) div 2; |
6651
4103354b7599
fixed aiming by touching the crosshair, made it compatible with the aiming buttons and disabled camera movement when touching buttons + some formatting fixes
Xeli
parents:
6648
diff
changeset
|
561 |
end; //if CurrentHedgehog^.Gear <> nil |
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
562 |
end; |
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
563 |
|
6693 | 564 |
// These 4 convertToCursor functions convert xy coords from the SDL coordinate system to our CursorPoint coor system: |
9379 | 565 |
// - the SDL coordinate system is proportional to the screen and values are normalized in the onTouch* functions |
6693 | 566 |
// - the CursorPoint coordinate system goes from -cScreenWidth/2 to cScreenWidth/2 on the x axis |
567 |
// and 0 to cScreenHeight on the x axis, (-cScreenWidth, cScreenHeight) being top left. |
|
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
568 |
function convertToCursorX(x: LongInt): LongInt; |
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
569 |
begin |
9379 | 570 |
convertToCursorX:= x - cScreenWidth shr 1; |
6625
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
571 |
end; |
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
572 |
|
2d8c5815292f
some refactoring + you can now tap on the ammo menu to select a weapon
Xeli
parents:
6580
diff
changeset
|
573 |
function convertToCursorY(y: LongInt): LongInt; |
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
574 |
begin |
9379 | 575 |
convertToCursorY:= cScreenHeight - y; |
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
576 |
end; |
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
577 |
|
6693 | 578 |
function isOnCrosshair(finger: TTouch_Data): boolean; |
5615
104f69e798bb
changed aiming to be triggered when touching the crosshair
Xeli
parents:
5609
diff
changeset
|
579 |
var |
9379 | 580 |
x, y: LongInt; |
5615
104f69e798bb
changed aiming to be triggered when touching the crosshair
Xeli
parents:
5609
diff
changeset
|
581 |
begin |
9379 | 582 |
x:= 0; |
583 |
y:= 0; |
|
6702 | 584 |
convertToFingerCoord(x, y, CrosshairX, CrosshairY); |
9379 | 585 |
isOnCrosshair:= isOnRect(x - HalfRectSize, y - HalfRectSize, RectSize, RectSize, finger); |
5615
104f69e798bb
changed aiming to be triggered when touching the crosshair
Xeli
parents:
5609
diff
changeset
|
586 |
end; |
104f69e798bb
changed aiming to be triggered when touching the crosshair
Xeli
parents:
5609
diff
changeset
|
587 |
|
6693 | 588 |
function isOnCurrentHog(finger: TTouch_Data): boolean; |
5595 | 589 |
var |
9379 | 590 |
x, y: LongInt; |
5595 | 591 |
begin |
9379 | 592 |
x:= 0; |
593 |
y:= 0; |
|
594 |
convertToFingerCoord(x, y, hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y)); |
|
595 |
isOnCurrentHog:= isOnRect(x - HalfRectSize, y - HalfRectSize, RectSize, RectSize, finger); |
|
5938
c186c454779d
isOnCurrentHog and isOnCrosshair now look at the distance relative to the screen rather than world coords, this means that zooming out doesn't make it harder to touch the hog or crosshair
Xeli
parents:
5828
diff
changeset
|
596 |
end; |
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
597 |
|
9379 | 598 |
procedure convertToFingerCoord(var x, y : LongInt; oldX, oldY: LongInt); |
5938
c186c454779d
isOnCurrentHog and isOnCrosshair now look at the distance relative to the screen rather than world coords, this means that zooming out doesn't make it harder to touch the hog or crosshair
Xeli
parents:
5828
diff
changeset
|
599 |
begin |
6702 | 600 |
x := oldX + WorldDx; |
9379 | 601 |
y := cScreenHeight - oldY - WorldDy; |
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
602 |
end; |
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
603 |
|
6702 | 604 |
procedure convertToWorldCoord(var x,y: LongInt; finger: TTouch_Data); |
5599
2e4b90f33a83
aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents:
5595
diff
changeset
|
605 |
begin |
9379 | 606 |
x := finger.x - WorldDx; |
607 |
y := cScreenHeight - finger.y - WorldDy; |
|
5595 | 608 |
end; |
609 |
||
5589 | 610 |
//Method to calculate the distance this finger has moved since the downEvent |
6693 | 611 |
function fingerHasMoved(finger: TTouch_Data): boolean; |
5589 | 612 |
begin |
6950
f34ff54b0cbd
-Fixed FingerHasMoved function, still might need a little tweaking
Xeli
parents:
6949
diff
changeset
|
613 |
fingerHasMoved := trunc(sqrt(sqr(finger.X-finger.historicalX) + sqr(finger.y-finger.historicalY))) > 30; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
614 |
end; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
615 |
|
6702 | 616 |
function calculateDelta(finger1, finger2: TTouch_Data): LongInt; inline; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
617 |
begin |
6702 | 618 |
calculateDelta := Round(sqrt(sqr(finger2.x-finger1.x) + sqr(finger2.y-finger1.y))); |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
619 |
end; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
620 |
|
6693 | 621 |
// Under the premise that all pointer ids in pointerIds:TSDL_FingerId are packed to the far left. |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
622 |
// If the pointer to be ignored is not pointerIds[0] the second must be there |
6693 | 623 |
function getSecondFinger(finger: TTouch_Data): PTouch_Data; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
624 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
625 |
if fingers[0].id = finger.id then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
626 |
getSecondFinger := @fingers[1] |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
627 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6344
diff
changeset
|
628 |
getSecondFinger := @fingers[0]; |
5733
5ab22736bdb6
Fixed a major bug (related to pointers) which also solves the stuttering when zooming in and out
Xeli
parents:
5621
diff
changeset
|
629 |
end; |
5ab22736bdb6
Fixed a major bug (related to pointers) which also solves the stuttering when zooming in and out
Xeli
parents:
5621
diff
changeset
|
630 |
|
6693 | 631 |
function isOnRect(rect: TSDL_Rect; finger: TTouch_Data): boolean; |
6698 | 632 |
begin |
6703 | 633 |
isOnRect:= isOnRect(rect.x, rect.y, rect.w, rect.h, finger); |
634 |
end; |
|
635 |
||
636 |
function isOnRect(x,y,w,h: LongInt; finger: TTouch_Data): boolean; |
|
637 |
begin |
|
638 |
isOnRect:= (finger.x > x) and |
|
639 |
(finger.x < x + w) and |
|
640 |
(cScreenHeight - finger.y > y) and |
|
641 |
(cScreenHeight - finger.y < y + h); |
|
6640 | 642 |
end; |
643 |
||
6723
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
644 |
function isOnWidget(widget: TOnScreenWidget; finger: TTouch_Data): boolean; |
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
645 |
begin |
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
646 |
isOnWidget:= widget.show and isOnRect(widget.active, finger); |
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
647 |
end; |
b77e2d4d664b
check if the widget is shown before checking if the finger is on the widget
Xeli
parents:
6716
diff
changeset
|
648 |
|
6693 | 649 |
procedure printFinger(finger: TTouch_Data); |
5733
5ab22736bdb6
Fixed a major bug (related to pointers) which also solves the stuttering when zooming in and out
Xeli
parents:
5621
diff
changeset
|
650 |
begin |
9379 | 651 |
WriteLnToConsole(Format('id: %d, x: %d y: %d (rel x: %d rel y: %d), time: %d', |
652 |
[finger.id, finger.x, finger.y, finger.historicalX, finger.historicalY, finger.timeSinceDown])); |
|
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
653 |
end; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
654 |
|
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
655 |
procedure initModule; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
656 |
var |
6228
1b7d4d7d162b
added lines to avoid compiler hints, is this really the way we want to do it though? ;/
Xeli
parents:
6029
diff
changeset
|
657 |
index: Longword; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
658 |
begin |
6701
58a43c2064ad
the onScreenwidgets are multitouch now, frequently (alternating) tapping left and right still causes it to bug though, but you have to try hard to duplicate it, works ok for now
Xeli
parents:
6700
diff
changeset
|
659 |
buttonsDown:= 0; |
9379 | 660 |
pointerCount:= 0; |
14538
1dab5d92aca7
Add button to set bounciness in touch interface
Wuzzy <Wuzzy2@mail.ru>
parents:
14305
diff
changeset
|
661 |
bounceButtonPressed:= false; |
5605
31bd6e30df02
Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents:
5599
diff
changeset
|
662 |
|
5733
5ab22736bdb6
Fixed a major bug (related to pointers) which also solves the stuttering when zooming in and out
Xeli
parents:
5621
diff
changeset
|
663 |
setLength(fingers, 4); |
11777
77afc967f38e
fix memory corruptions caused by outofbounds-writes in uTouch
sheepluva
parents:
11592
diff
changeset
|
664 |
for index := 0 to (Length(fingers)-1) do |
11778 | 665 |
fingers[index].id := nilFingerId; |
7185
92a045156255
Android: first attempt at using the density call from java
Xeli
parents:
7105
diff
changeset
|
666 |
|
9377 | 667 |
rectSize:= baseRectSize; |
9379 | 668 |
halfRectSize:= baseRectSize shr 1; |
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
669 |
end; |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
670 |
|
7850 | 671 |
procedure freeModule; |
672 |
begin |
|
673 |
end; |
|
674 |
||
5579
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
675 |
begin |
3176ee8a9d94
uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff
changeset
|
676 |
end. |