author | unc0rr |
Sun, 21 Sep 2014 00:37:50 +0400 | |
branch | qmlfrontend |
changeset 10418 | 091d2c0216c3 |
parent 10354 | 56bd029245fc |
child 10625 | 125e120165aa |
permissions | -rw-r--r-- |
9287 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
9998 | 3 |
* Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com> |
9287 | 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:
10015
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
9287 | 17 |
*) |
18 |
||
19 |
{$INCLUDE "options.inc"} |
|
20 |
||
21 |
unit uVisualGearsList; |
|
22 |
interface |
|
23 |
uses uTypes; |
|
24 |
||
25 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; inline; |
|
26 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord): PVisualGear; inline; |
|
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
27 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean): PVisualGear; inline; |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
28 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean; Layer: LongInt): PVisualGear; |
9287 | 29 |
procedure DeleteVisualGear(Gear: PVisualGear); |
30 |
function VisualGearByUID(uid : Longword) : PVisualGear; |
|
31 |
||
10015 | 32 |
const |
9287 | 33 |
cExplFrameTicks = 110; |
34 |
||
35 |
var VGCounter: LongWord; |
|
36 |
VisualGearLayers: array[0..6] of PVisualGear; |
|
37 |
||
38 |
implementation |
|
10354 | 39 |
uses uCollisions, uFloat, uVariables, uConsts, uTextures, uVisualGearsHandlers; |
9287 | 40 |
|
41 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; inline; |
|
42 |
begin |
|
10352 | 43 |
// adjust some visual gear types if underwater |
10354 | 44 |
if CheckCoordInWater(X, Y) and ((Kind = vgtBeeTrace) or (Kind = vgtSmokeTrace) or (Kind = vgtEvilTrace)) then |
10352 | 45 |
Kind:= vgtBubble; |
46 |
||
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
47 |
AddVisualGear:= AddVisualGear(X, Y, Kind, 0, false, -1); |
9287 | 48 |
end; |
49 |
||
50 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord): PVisualGear; inline; |
|
51 |
begin |
|
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
52 |
AddVisualGear:= AddVisualGear(X, Y, Kind, State, false, -1); |
9287 | 53 |
end; |
54 |
||
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
55 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean): PVisualGear; inline; |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
56 |
begin |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
57 |
AddVisualGear:= AddVisualGear(X, Y, Kind, State, Critical, -1); |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
58 |
end; |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
59 |
|
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
60 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean; Layer: LongInt): PVisualGear; |
9287 | 61 |
var gear: PVisualGear; |
62 |
t: Longword; |
|
63 |
sp: real; |
|
64 |
begin |
|
65 |
AddVisualGear:= nil; |
|
66 |
if ((GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) or fastScrolling) and // we are scrolling now |
|
67 |
((Kind <> vgtCloud) and (not Critical)) then |
|
68 |
exit; |
|
69 |
||
70 |
if ((cReducedQuality and rqAntiBoom) <> 0) and |
|
71 |
(not Critical) and |
|
72 |
(not (Kind in |
|
73 |
[vgtTeamHealthSorter, |
|
74 |
vgtSmallDamageTag, |
|
75 |
vgtSpeechBubble, |
|
76 |
vgtHealthTag, |
|
77 |
vgtExplosion, |
|
78 |
vgtSmokeTrace, |
|
79 |
vgtEvilTrace, |
|
80 |
vgtNote, |
|
81 |
vgtSmoothWindBar])) then |
|
10015 | 82 |
|
9287 | 83 |
exit; |
84 |
||
85 |
inc(VGCounter); |
|
86 |
New(gear); |
|
87 |
FillChar(gear^, sizeof(TVisualGear), 0); |
|
88 |
gear^.X:= real(X); |
|
89 |
gear^.Y:= real(Y); |
|
90 |
gear^.Kind := Kind; |
|
9960 | 91 |
gear^.doStep:= doStepVGHandlers[Kind]; |
9287 | 92 |
gear^.Tint:= $FFFFFFFF; |
93 |
gear^.uid:= VGCounter; |
|
94 |
||
95 |
with gear^ do |
|
96 |
case Kind of |
|
97 |
vgtFlake: |
|
98 |
begin |
|
99 |
Timer:= 0; |
|
100 |
tdX:= 0; |
|
101 |
tdY:= 0; |
|
102 |
Scale:= 1.0; |
|
103 |
if SuddenDeathDmg then |
|
104 |
begin |
|
105 |
FrameTicks:= random(vobSDFrameTicks); |
|
106 |
Frame:= random(vobSDFramesCount); |
|
107 |
end |
|
108 |
else |
|
109 |
begin |
|
110 |
FrameTicks:= random(vobFrameTicks); |
|
111 |
Frame:= random(vobFramesCount); |
|
112 |
end; |
|
113 |
Angle:= random(360); |
|
114 |
dx:= 0.0000038654705 * random(10000); |
|
115 |
dy:= 0.000003506096 * random(7000); |
|
116 |
if random(2) = 0 then |
|
117 |
dx := -dx; |
|
118 |
if SuddenDeathDmg then |
|
119 |
dAngle:= (random(2) * 2 - 1) * (vobSDVelocity + random(vobSDVelocity)) / 1000 |
|
120 |
else |
|
121 |
dAngle:= (random(2) * 2 - 1) * (vobVelocity + random(vobVelocity)) / 1000 |
|
122 |
end; |
|
123 |
vgtCloud: |
|
124 |
begin |
|
125 |
Frame:= random(4); |
|
126 |
dx:= 0.5 + 0.1 * random(5); // how much the cloud will be affected by wind |
|
127 |
timer:= random(4096); |
|
128 |
Scale:= 1.0 |
|
129 |
end; |
|
130 |
vgtExplPart, |
|
131 |
vgtExplPart2: |
|
132 |
begin |
|
133 |
t:= random(1024); |
|
134 |
sp:= 0.001 * (random(95) + 70); |
|
135 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
136 |
dy:= hwFloat2Float(AngleCos(t)) * sp; |
|
137 |
if random(2) = 0 then |
|
138 |
dx := -dx; |
|
139 |
if random(2) = 0 then |
|
140 |
dy := -dy; |
|
141 |
Frame:= 7 - random(3); |
|
142 |
FrameTicks:= cExplFrameTicks |
|
143 |
end; |
|
144 |
vgtFire: |
|
145 |
begin |
|
146 |
t:= random(1024); |
|
147 |
sp:= 0.001 * (random(85) + 95); |
|
148 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
149 |
dy:= hwFloat2Float(AngleCos(t)) * sp; |
|
150 |
if random(2) = 0 then |
|
151 |
dx := -dx; |
|
152 |
if random(2) = 0 then |
|
153 |
dy := -dy; |
|
154 |
FrameTicks:= 650 + random(250); |
|
155 |
Frame:= random(8) |
|
156 |
end; |
|
157 |
vgtEgg: |
|
158 |
begin |
|
159 |
t:= random(1024); |
|
160 |
sp:= 0.001 * (random(85) + 95); |
|
161 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
162 |
dy:= hwFloat2Float(AngleCos(t)) * sp; |
|
163 |
if random(2) = 0 then |
|
164 |
dx := -dx; |
|
165 |
if random(2) = 0 then |
|
166 |
dy := -dy; |
|
167 |
FrameTicks:= 650 + random(250); |
|
168 |
Frame:= 1 |
|
169 |
end; |
|
170 |
vgtShell: FrameTicks:= 500; |
|
171 |
vgtSmallDamageTag: |
|
172 |
begin |
|
173 |
gear^.FrameTicks:= 1100 |
|
174 |
end; |
|
175 |
vgtBubble: |
|
176 |
begin |
|
177 |
dx:= 0.0000038654705 * random(10000); |
|
178 |
dy:= 0; |
|
179 |
if random(2) = 0 then |
|
180 |
dx := -dx; |
|
181 |
FrameTicks:= 250 + random(1751); |
|
182 |
Frame:= random(5) |
|
183 |
end; |
|
184 |
vgtSteam: |
|
185 |
begin |
|
186 |
dx:= 0.0000038654705 * random(10000); |
|
187 |
dy:= 0.001 * (random(85) + 95); |
|
188 |
if random(2) = 0 then |
|
189 |
dx := -dx; |
|
190 |
Frame:= 7 - random(3); |
|
191 |
FrameTicks:= cExplFrameTicks * 2; |
|
192 |
end; |
|
193 |
vgtAmmo: |
|
194 |
begin |
|
195 |
alpha:= 1.0; |
|
196 |
scale:= 1.0 |
|
197 |
end; |
|
198 |
vgtSmokeWhite, |
|
199 |
vgtSmoke: |
|
200 |
begin |
|
201 |
Scale:= 1.0; |
|
202 |
dx:= 0.0002 * (random(45) + 10); |
|
203 |
dy:= 0.0002 * (random(45) + 10); |
|
204 |
if random(2) = 0 then |
|
205 |
dx := -dx; |
|
206 |
Frame:= 7 - random(2); |
|
207 |
FrameTicks:= cExplFrameTicks * 2; |
|
208 |
end; |
|
209 |
vgtDust: |
|
210 |
begin |
|
211 |
dx:= 0.005 * (random(15) + 10); |
|
212 |
dy:= 0.001 * (random(40) + 20); |
|
213 |
if random(2) = 0 then dx := -dx; |
|
214 |
if random(2) = 0 then Tag:= 1 |
|
215 |
else Tag:= -1; |
|
216 |
Frame:= 7 - random(2); |
|
217 |
FrameTicks:= random(20) + 15; |
|
218 |
end; |
|
219 |
vgtSplash: |
|
220 |
begin |
|
221 |
dx:= 0; |
|
222 |
dy:= 0; |
|
223 |
FrameTicks:= 740; |
|
224 |
Frame:= 19; |
|
225 |
Scale:= 0.75; |
|
226 |
Timer:= 1; |
|
227 |
end; |
|
228 |
vgtDroplet: |
|
229 |
begin |
|
230 |
dx:= 0.001 * (random(180) - 90); |
|
231 |
dy:= -0.001 * (random(160) + 40); |
|
232 |
FrameTicks:= 250 + random(1751); |
|
233 |
Frame:= random(3) |
|
234 |
end; |
|
235 |
vgtBeeTrace: |
|
236 |
begin |
|
237 |
FrameTicks:= 1000; |
|
238 |
Frame:= random(16); |
|
239 |
end; |
|
240 |
vgtSmokeRing: |
|
241 |
begin |
|
242 |
dx:= 0; |
|
243 |
dy:= 0; |
|
244 |
FrameTicks:= 600; |
|
245 |
Timer:= 0; |
|
246 |
Frame:= 0; |
|
247 |
scale:= 0.6; |
|
248 |
alpha:= 1; |
|
249 |
angle:= random(360); |
|
250 |
end; |
|
251 |
vgtFeather: |
|
252 |
begin |
|
253 |
t:= random(1024); |
|
254 |
sp:= 0.001 * (random(85) + 95); |
|
255 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
256 |
dy:= hwFloat2Float(AngleCos(t)) * sp; |
|
257 |
if random(2) = 0 then |
|
258 |
dx := -dx; |
|
259 |
if random(2) = 0 then |
|
260 |
dy := -dy; |
|
261 |
FrameTicks:= 650 + random(250); |
|
262 |
Frame:= 1 |
|
263 |
end; |
|
264 |
vgtHealthTag: |
|
265 |
begin |
|
266 |
Frame:= 0; |
|
267 |
Timer:= 1500; |
|
268 |
dY:= -0.08; |
|
269 |
dX:= 0; |
|
270 |
//gear^.Z:= 2002; |
|
271 |
end; |
|
272 |
vgtSmokeTrace, |
|
273 |
vgtEvilTrace: |
|
274 |
begin |
|
275 |
gear^.X:= gear^.X - 16; |
|
276 |
gear^.Y:= gear^.Y - 16; |
|
277 |
gear^.State:= 8; |
|
278 |
//gear^.Z:= cSmokeZ |
|
279 |
end; |
|
280 |
vgtBigExplosion: |
|
281 |
begin |
|
282 |
gear^.Angle:= random(360); |
|
283 |
end; |
|
284 |
vgtChunk: |
|
285 |
begin |
|
286 |
gear^.Frame:= random(4); |
|
287 |
t:= random(1024); |
|
288 |
sp:= 0.001 * (random(85) + 47); |
|
289 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
290 |
dy:= hwFloat2Float(AngleCos(t)) * sp * -2; |
|
291 |
if random(2) = 0 then |
|
292 |
dx := -dx; |
|
293 |
end; |
|
10015 | 294 |
vgtNote: |
9287 | 295 |
begin |
296 |
dx:= 0.005 * (random(15) + 10); |
|
297 |
dy:= -0.001 * (random(40) + 20); |
|
298 |
if random(2) = 0 then |
|
299 |
dx := -dx; |
|
300 |
Frame:= random(4); |
|
301 |
FrameTicks:= random(2000) + 1500; |
|
302 |
end; |
|
303 |
vgtBulletHit: |
|
304 |
begin |
|
305 |
dx:= 0; |
|
306 |
dy:= 0; |
|
307 |
FrameTicks:= 350; |
|
308 |
Frame:= 7; |
|
309 |
Angle:= 0; |
|
310 |
end; |
|
10015 | 311 |
vgtSmoothWindBar: |
9287 | 312 |
begin |
313 |
Angle:= hwFloat2Float(cMaxWindSpeed)*2 / 1440; // seems rate below is supposed to change wind bar at 1px per 10ms. Max time, 1440ms. This tries to match the rate of change |
|
314 |
Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); |
|
315 |
end; |
|
316 |
vgtStraightShot: |
|
317 |
begin |
|
318 |
Angle:= 0; |
|
319 |
Scale:= 1.0; |
|
320 |
dx:= 0.001 * random(45); |
|
321 |
dy:= 0.001 * (random(20) + 25); |
|
322 |
State:= ord(sprHealth); |
|
323 |
if random(2) = 0 then |
|
324 |
dx := -dx; |
|
325 |
Frame:= 0; |
|
326 |
FrameTicks:= random(750) + 1250; |
|
327 |
State:= ord(sprSnowDust); |
|
328 |
end; |
|
10251
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
329 |
vgtNoPlaceWarn: |
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
330 |
begin |
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
331 |
FrameTicks:= 2000; |
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
332 |
Tint:= $FF0000FF; |
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
333 |
Scale:= 1.0; |
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
334 |
end; |
9287 | 335 |
end; |
336 |
||
337 |
if State <> 0 then |
|
338 |
gear^.State:= State; |
|
339 |
||
340 |
case Gear^.Kind of |
|
341 |
vgtFlake: if cFlattenFlakes then |
|
342 |
gear^.Layer:= 0 |
|
10015 | 343 |
else if random(3) = 0 then |
9287 | 344 |
begin |
345 |
gear^.Scale:= 0.5; |
|
346 |
gear^.Layer:= 0 // 33% - far back |
|
347 |
end |
|
348 |
else if random(3) = 0 then |
|
349 |
begin |
|
350 |
gear^.Scale:= 0.8; |
|
351 |
gear^.Layer:= 4 // 22% - mid-distance |
|
352 |
end |
|
353 |
else if random(3) <> 0 then |
|
354 |
gear^.Layer:= 5 // 30% - just behind land |
|
355 |
else if random(2) = 0 then |
|
356 |
gear^.Layer:= 6 // 7% - just in front of land |
|
357 |
else |
|
358 |
begin |
|
359 |
gear^.Scale:= 1.5; |
|
360 |
gear^.Layer:= 2; // 7% - close up |
|
361 |
end; |
|
362 |
||
363 |
vgtCloud: if cFlattenClouds then gear^.Layer:= 5 |
|
364 |
else if random(3) = 0 then |
|
365 |
begin |
|
366 |
gear^.Scale:= 0.25; |
|
367 |
gear^.Layer:= 0 |
|
368 |
end |
|
369 |
else if random(2) = 0 then |
|
370 |
gear^.Layer:= 5 |
|
371 |
else |
|
372 |
begin |
|
373 |
gear^.Scale:= 0.4; |
|
374 |
gear^.Layer:= 4 |
|
375 |
end; |
|
10251
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
376 |
vgtNoPlaceWarn: gear^.Layer:= 6; |
9287 | 377 |
|
378 |
// 0: this layer is very distant in the background when in stereo |
|
379 |
vgtTeamHealthSorter, |
|
380 |
vgtSmoothWindBar: gear^.Layer:= 0; |
|
381 |
||
382 |
||
383 |
// 1: this layer is on the land level (which is close but behind the screen plane) when stereo |
|
384 |
vgtSmokeTrace, |
|
385 |
vgtEvilTrace, |
|
386 |
vgtLineTrail, |
|
387 |
vgtSmoke, |
|
388 |
vgtSmokeWhite, |
|
389 |
vgtDust, |
|
390 |
vgtFire, |
|
391 |
vgtSplash, |
|
392 |
vgtDroplet, |
|
393 |
vgtBubble: gear^.Layer:= 1; |
|
394 |
||
395 |
// 3: this layer is on the screen plane (depth = 0) when stereo |
|
396 |
vgtSpeechBubble, |
|
397 |
vgtSmallDamageTag, |
|
398 |
vgtHealthTag, |
|
399 |
vgtStraightShot, |
|
400 |
vgtChunk: gear^.Layer:= 3; |
|
401 |
||
402 |
// 2: this layer is outside the screen when stereo |
|
403 |
vgtExplosion, |
|
404 |
vgtBigExplosion, |
|
405 |
vgtExplPart, |
|
406 |
vgtExplPart2, |
|
407 |
vgtSteam, |
|
408 |
vgtAmmo, |
|
409 |
vgtShell, |
|
410 |
vgtFeather, |
|
411 |
vgtEgg, |
|
412 |
vgtBeeTrace, |
|
413 |
vgtSmokeRing, |
|
414 |
vgtNote, |
|
415 |
vgtBulletHit, |
|
416 |
vgtCircle: gear^.Layer:= 2 |
|
417 |
end; |
|
418 |
||
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
419 |
if Layer <> -1 then gear^.Layer:= Layer; |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
420 |
|
9287 | 421 |
if VisualGearLayers[gear^.Layer] <> nil then |
422 |
begin |
|
423 |
VisualGearLayers[gear^.Layer]^.PrevGear:= gear; |
|
424 |
gear^.NextGear:= VisualGearLayers[gear^.Layer] |
|
425 |
end; |
|
426 |
VisualGearLayers[gear^.Layer]:= gear; |
|
427 |
||
428 |
AddVisualGear:= gear; |
|
429 |
end; |
|
430 |
||
431 |
procedure DeleteVisualGear(Gear: PVisualGear); |
|
432 |
begin |
|
433 |
FreeTexture(Gear^.Tex); |
|
434 |
Gear^.Tex:= nil; |
|
435 |
||
436 |
if Gear^.NextGear <> nil then |
|
437 |
Gear^.NextGear^.PrevGear:= Gear^.PrevGear; |
|
438 |
if Gear^.PrevGear <> nil then |
|
439 |
Gear^.PrevGear^.NextGear:= Gear^.NextGear |
|
440 |
else |
|
441 |
VisualGearLayers[Gear^.Layer]:= Gear^.NextGear; |
|
442 |
||
443 |
if lastVisualGearByUID = Gear then |
|
444 |
lastVisualGearByUID:= nil; |
|
445 |
||
446 |
Dispose(Gear); |
|
447 |
end; |
|
448 |
||
449 |
function VisualGearByUID(uid : Longword) : PVisualGear; |
|
450 |
var vg: PVisualGear; |
|
451 |
i: LongWord; |
|
452 |
begin |
|
453 |
VisualGearByUID:= nil; |
|
454 |
if uid = 0 then |
|
455 |
exit; |
|
456 |
if (lastVisualGearByUID <> nil) and (lastVisualGearByUID^.uid = uid) then |
|
457 |
begin |
|
458 |
VisualGearByUID:= lastVisualGearByUID; |
|
459 |
exit |
|
460 |
end; |
|
461 |
// search in an order that is more likely to return layers they actually use. Could perhaps track statistically AddVisualGear in uScript, since that is most likely the ones they want |
|
462 |
for i:= 2 to 5 do |
|
463 |
begin |
|
464 |
vg:= VisualGearLayers[i mod 4]; |
|
465 |
while vg <> nil do |
|
466 |
begin |
|
467 |
if vg^.uid = uid then |
|
468 |
begin |
|
469 |
lastVisualGearByUID:= vg; |
|
470 |
VisualGearByUID:= vg; |
|
471 |
exit |
|
472 |
end; |
|
473 |
vg:= vg^.NextGear |
|
474 |
end |
|
475 |
end |
|
476 |
end; |
|
477 |
||
478 |
||
479 |
end. |