author | koda |
Sun, 19 Sep 2010 17:23:48 +0200 | |
changeset 3886 | 4f052bf1f1a9 |
parent 3874 | 57e7327d5817 |
child 3904 | 22e4d74240e5 |
permissions | -rw-r--r-- |
2690 | 1 |
(* |
2 |
* PascalExports.pas |
|
3 |
* hwengine |
|
4 |
* |
|
5 |
* Created by Vittorio on 09/01/10. |
|
6 |
* Copyright 2009 __MyCompanyName__. All rights reserved. |
|
7 |
* |
|
8 |
*) |
|
9 |
||
10 |
||
11 |
{$INCLUDE "options.inc"} |
|
12 |
||
13 |
unit PascalExports; |
|
14 |
||
15 |
interface |
|
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3662
diff
changeset
|
16 |
uses uKeys, GLunit, uWorld, uMisc, uConsole, uTeams, uConsts, uChat, uGears, uSound, hwengine; |
2690 | 17 |
|
2924 | 18 |
{$INCLUDE "config.inc"} |
2691 | 19 |
|
2690 | 20 |
implementation |
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2799
diff
changeset
|
21 |
{$IFDEF HWLIBRARY} |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
22 |
var cZoomVal: GLfloat; |
3635
38d3e31556d3
improvements to touch interface (tap to select weap, don't move camera for spourious taps, ask for confirmation when using click-weapons)
koda
parents:
3626
diff
changeset
|
23 |
|
3063 | 24 |
// retrieve protocol information |
3650 | 25 |
procedure HW_versionInfo(netProto: PShortInt; versionStr: PPChar); cdecl; export; |
2691 | 26 |
begin |
3245
252be02536ab
fix an error in passing strings between ObjC and Pascal
koda
parents:
3063
diff
changeset
|
27 |
// http://bugs.freepascal.org/view.php?id=16156 |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
28 |
if netProto <> nil then netProto^:= cNetProtoVersion; |
3245
252be02536ab
fix an error in passing strings between ObjC and Pascal
koda
parents:
3063
diff
changeset
|
29 |
if versionStr <> nil then versionStr^:= cVersionString; |
2691 | 30 |
end; |
31 |
||
2690 | 32 |
procedure HW_click; cdecl; export; |
33 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
34 |
leftClick:= true; |
2690 | 35 |
end; |
36 |
||
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
37 |
procedure HW_ammoMenu; cdecl; export; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
38 |
begin |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
39 |
rightClick:= true; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
40 |
end; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
41 |
|
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
42 |
procedure HW_zoomSet(value: GLfloat); cdecl; export; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
43 |
begin |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
44 |
cZoomVal:= value; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
45 |
ZoomValue:= value; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
46 |
end; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
47 |
|
2690 | 48 |
procedure HW_zoomIn; cdecl; export; |
49 |
begin |
|
3523 | 50 |
if wheelDown = false then |
51 |
wheelUp:= true; |
|
2690 | 52 |
end; |
53 |
||
54 |
procedure HW_zoomOut; cdecl; export; |
|
55 |
begin |
|
3523 | 56 |
if wheelUp = false then |
57 |
wheelDown:= true; |
|
2690 | 58 |
end; |
59 |
||
60 |
procedure HW_zoomReset; cdecl; export; |
|
61 |
begin |
|
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
62 |
ZoomValue:= cZoomVal; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
63 |
//middleClick:= true; |
3672
f225b94a4411
shrink confirmation button, double tap resets zoom and centers hog
koda
parents:
3668
diff
changeset
|
64 |
// center the camera at current hog |
f225b94a4411
shrink confirmation button, double tap resets zoom and centers hog
koda
parents:
3668
diff
changeset
|
65 |
if CurrentHedgehog <> nil then |
f225b94a4411
shrink confirmation button, double tap resets zoom and centers hog
koda
parents:
3668
diff
changeset
|
66 |
followGear:= CurrentHedgehog^.Gear; |
2690 | 67 |
end; |
68 |
||
3680 | 69 |
function HW_zoomFactor: GLfloat; cdecl; export; |
70 |
begin |
|
71 |
exit( ZoomValue / cDefaultZoomLevel ); |
|
72 |
end; |
|
73 |
||
74 |
function HW_zoomLevel: LongInt; cdecl; export; |
|
75 |
begin |
|
76 |
exit( trunc((ZoomValue - cDefaultZoomLevel) / cZoomDelta) ); |
|
77 |
end; |
|
78 |
||
3626 | 79 |
procedure HW_walkingKeysUp; cdecl; export; |
80 |
begin |
|
81 |
leftKey:= false; |
|
82 |
rightKey:= false; |
|
83 |
upKey:= false; |
|
84 |
downKey:= false; |
|
3649 | 85 |
preciseKey:= false; |
3626 | 86 |
end; |
87 |
||
88 |
procedure HW_otherKeysUp; cdecl; export; |
|
89 |
begin |
|
90 |
spaceKey:= false; |
|
91 |
enterKey:= false; |
|
92 |
backspaceKey:= false; |
|
93 |
end; |
|
94 |
||
2690 | 95 |
procedure HW_allKeysUp; cdecl; export; |
96 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
97 |
// set all keys to released |
3040
3e7f4a30e18a
Insert commit message here (to get along with palewolf)
koda
parents:
3015
diff
changeset
|
98 |
uKeys.initModule; |
2690 | 99 |
end; |
100 |
||
101 |
procedure HW_walkLeft; cdecl; export; |
|
102 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
103 |
leftKey:= true; |
2690 | 104 |
end; |
105 |
||
106 |
procedure HW_walkRight; cdecl; export; |
|
107 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
108 |
rightKey:= true; |
2690 | 109 |
end; |
110 |
||
3649 | 111 |
procedure HW_preciseSet(status:boolean); cdecl; export; |
112 |
begin |
|
113 |
preciseKey:= status; |
|
114 |
end; |
|
115 |
||
2690 | 116 |
procedure HW_aimUp; cdecl; export; |
117 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
118 |
upKey:= true; |
2690 | 119 |
end; |
120 |
||
121 |
procedure HW_aimDown; cdecl; export; |
|
122 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
123 |
downKey:= true; |
2690 | 124 |
end; |
125 |
||
126 |
procedure HW_shoot; cdecl; export; |
|
127 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
128 |
spaceKey:= true; |
2690 | 129 |
end; |
130 |
||
3015 | 131 |
procedure HW_jump; cdecl; export; |
132 |
begin |
|
133 |
enterKey:= true; |
|
134 |
end; |
|
135 |
||
136 |
procedure HW_backjump; cdecl; export; |
|
137 |
begin |
|
138 |
backspaceKey:= true; |
|
139 |
end; |
|
140 |
||
3651 | 141 |
procedure HW_tab; cdecl; export; |
142 |
begin |
|
143 |
tabKey:= true; |
|
144 |
end; |
|
145 |
||
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2716
diff
changeset
|
146 |
procedure HW_chat; cdecl; export; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2716
diff
changeset
|
147 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
148 |
chatAction:= true; |
2754
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2716
diff
changeset
|
149 |
end; |
ad4f81fbfb76
touchinput works, invisible buttons added and initial support for chat
koda
parents:
2716
diff
changeset
|
150 |
|
3648 | 151 |
procedure HW_chatEnd; cdecl; export; |
152 |
begin |
|
153 |
KeyPressChat(27); // esc - cleans buffer |
|
154 |
KeyPressChat(13); // enter - removes chat |
|
155 |
end; |
|
156 |
||
2805 | 157 |
procedure HW_pause; cdecl; export; |
158 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
159 |
pauseAction:= true; |
2805 | 160 |
end; |
161 |
||
3063 | 162 |
procedure HW_terminate(closeFrontend: boolean); cdecl; export; |
163 |
begin |
|
164 |
isTerminated:= true; |
|
165 |
if closeFrontend then alsoShutdownFrontend:= true; |
|
166 |
end; |
|
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3347
diff
changeset
|
167 |
|
3789
c3eb56754e92
added a smaller version of forts, fixed a couple of regressions
koda
parents:
3779
diff
changeset
|
168 |
procedure HW_dismissReady; cdecl; export; |
c3eb56754e92
added a smaller version of forts, fixed a couple of regressions
koda
parents:
3779
diff
changeset
|
169 |
begin |
c3eb56754e92
added a smaller version of forts, fixed a couple of regressions
koda
parents:
3779
diff
changeset
|
170 |
ReadyTimeLeft:= 0; |
c3eb56754e92
added a smaller version of forts, fixed a couple of regressions
koda
parents:
3779
diff
changeset
|
171 |
end; |
c3eb56754e92
added a smaller version of forts, fixed a couple of regressions
koda
parents:
3779
diff
changeset
|
172 |
|
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3347
diff
changeset
|
173 |
procedure HW_setLandscape(landscape: boolean); cdecl; export; |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3347
diff
changeset
|
174 |
begin |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3347
diff
changeset
|
175 |
if landscape then |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3347
diff
changeset
|
176 |
begin |
3463 | 177 |
cOffsetY:= 0; |
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3347
diff
changeset
|
178 |
end |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3347
diff
changeset
|
179 |
else |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3347
diff
changeset
|
180 |
begin |
3463 | 181 |
cOffsetY:= 120; |
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3347
diff
changeset
|
182 |
end; |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3347
diff
changeset
|
183 |
end; |
3551 | 184 |
|
185 |
procedure HW_setCursor(x,y: LongInt); cdecl; export; |
|
186 |
begin |
|
187 |
CursorPoint.X:= x; |
|
188 |
CursorPoint.Y:= y; |
|
189 |
end; |
|
190 |
||
3661 | 191 |
procedure HW_getCursor(x,y: PLongInt); cdecl; export; |
192 |
begin |
|
193 |
x^:= CursorPoint.X; |
|
194 |
y^:= CursorPoint.Y; |
|
195 |
end; |
|
196 |
||
3637
0db298524c3d
implement the check on the type of ammo requiring a second tap to confirm
koda
parents:
3635
diff
changeset
|
197 |
function HW_isAmmoOpen: boolean; cdecl; export; |
3551 | 198 |
begin |
199 |
exit(bShowAmmoMenu); |
|
200 |
end; |
|
3637
0db298524c3d
implement the check on the type of ammo requiring a second tap to confirm
koda
parents:
3635
diff
changeset
|
201 |
|
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
202 |
function HW_isPaused: boolean; cdecl; export; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
203 |
begin |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
204 |
exit( isPaused ); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
205 |
end; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
206 |
|
3779
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3778
diff
changeset
|
207 |
function HW_isWaiting: boolean; cdecl; export; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3778
diff
changeset
|
208 |
begin |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3778
diff
changeset
|
209 |
exit( ReadyTimeLeft > 0 ); |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3778
diff
changeset
|
210 |
end; |
3351a017d4ad
tap to dismiss 'get ready', add a toggle to enable/disable it
koda
parents:
3778
diff
changeset
|
211 |
|
3637
0db298524c3d
implement the check on the type of ammo requiring a second tap to confirm
koda
parents:
3635
diff
changeset
|
212 |
function HW_isWeaponRequiringClick: boolean; cdecl; export; |
0db298524c3d
implement the check on the type of ammo requiring a second tap to confirm
koda
parents:
3635
diff
changeset
|
213 |
begin |
3739 | 214 |
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.BotLevel = 0) then |
3662
a44406f4369b
polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents:
3661
diff
changeset
|
215 |
exit( (CurrentHedgehog^.Gear^.State and gstHHChooseTarget) <> 0 ) |
a44406f4369b
polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents:
3661
diff
changeset
|
216 |
else |
a44406f4369b
polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents:
3661
diff
changeset
|
217 |
exit(false); |
3637
0db298524c3d
implement the check on the type of ammo requiring a second tap to confirm
koda
parents:
3635
diff
changeset
|
218 |
end; |
0db298524c3d
implement the check on the type of ammo requiring a second tap to confirm
koda
parents:
3635
diff
changeset
|
219 |
|
3650 | 220 |
function HW_isWeaponTimerable: boolean; cdecl; export; |
221 |
begin |
|
3739 | 222 |
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then |
3874 | 223 |
exit( (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable) <> 0) |
3739 | 224 |
else |
225 |
exit(false); |
|
3650 | 226 |
end; |
227 |
||
3651 | 228 |
function HW_isWeaponSwitch: boolean cdecl; export; |
229 |
begin |
|
3739 | 230 |
if (CurAmmoGear <> nil) and (CurrentHedgehog^.BotLevel = 0) then |
3697 | 231 |
exit(CurAmmoGear^.AmmoType = amSwitch) |
3651 | 232 |
else |
233 |
exit(false) |
|
234 |
end; |
|
235 |
||
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
236 |
function HW_isWeaponRope: boolean cdecl; export; |
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3662
diff
changeset
|
237 |
begin |
3739 | 238 |
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then |
3874 | 239 |
exit (CurrentHedgehog^.CurAmmoType = amRope) |
3739 | 240 |
else |
241 |
exit(false); |
|
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3662
diff
changeset
|
242 |
end; |
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3662
diff
changeset
|
243 |
|
3650 | 244 |
procedure HW_setGrenadeTime(time: LongInt); cdecl; export; |
245 |
begin |
|
246 |
ParseCommand('/timer ' + inttostr(time), true); |
|
247 |
end; |
|
248 |
||
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
249 |
procedure HW_setPianoSound(snd: LongInt); cdecl; export; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
250 |
begin |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
251 |
// this most likely won't work in network game |
3739 | 252 |
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) |
3874 | 253 |
and (CurrentHedgehog^.CurAmmoType = amPiano) then |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
254 |
case snd of |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
255 |
0: PlaySound(sndPiano0); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
256 |
1: PlaySound(sndPiano1); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
257 |
2: PlaySound(sndPiano2); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
258 |
3: PlaySound(sndPiano3); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
259 |
4: PlaySound(sndPiano4); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
260 |
5: PlaySound(sndPiano5); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
261 |
6: PlaySound(sndPiano6); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
262 |
7: PlaySound(sndPiano7); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
263 |
else PlaySound(sndPiano8); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
264 |
end; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
265 |
end; |
2690 | 266 |
{$ENDIF} |
267 |
||
268 |
end. |
|
269 |