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