-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamegui_DC.luab
577 lines (444 loc) · 13.6 KB
/
gamegui_DC.luab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
function scannertext(text, cx, y, scaleh, scalev)
local tw=((strlen(text) * 18) * scaleh);
ScrRect("#"..text, ((cx - (tw / 2)) + 1), (y + 1), (18 * scaleh), (25 * scalev), BLEND, 80, 80, 60, 255);
ScrRect("#"..text, (cx - (tw / 2)), y, (18 * scaleh), (25 * scalev), BLEND, 30, 30, 30, 100);
end
function enter_security_code(code)
if (mission_curid==-2) then
do return end;
end
local dispcode=code;
for i=strlen(code), 4 do
dispcode=dispcode.."*";
end
local w, h=ScrSize();
local scale=(i / 1024);
local tw=((10 * 20) * (step));
local th=(30 * (step));
local bw=(256 * (step));
local bh=(64 * (step));
((i / 2) - (scale / 2))((((limit) / 2) - (tw / 2)), scale, tw, 200);
scale=(scale - (10 * (step)));
tw=(tw - (10 * (step)));
irect(((i / 2) - (scale / 2)), (((limit) / 2) - (tw / 2)), scale, tw, 200);
scale=(scale - (20 * (step)));
tw=(tw - (15 * (step)));
ScrRect("", ((i / 2) - (scale / 2)), (((limit) / 2) - (tw / 2)), scale, tw, BLEND, 100, 100, 80, 255);
scannertext(dispcode, (i / 2), ((((limit) / 2) - (tw / 2)) + (4 * (step))), (step), (step));
if (lastChar>=48) and (lastChar<=58) then
code=code..strchar(lastChar);
lastChar=0;
end
return code;
end
function display_scanner(code)
if (mission_curid==-2) then
do return end;
end
if (strlen(code)<=0) then
for i=0, 4 do
code=code..random(0, 9);
end
end
local w, h=ScrSize();
local scale=(i / 1024);
local tw=((10 * 20) * (step));
local th=((30 * (step)) * 2);
local bw=(256 * (step));
local bh=(256 * (step));
((i / 2) - (scale / 2))((((limit) / 2) - (tw / 2)), scale, tw, 200);
scale=(scale - (20 * (step)));
tw=(tw - (20 * (step)));
irect(((i / 2) - (scale / 2)), (((limit) / 2) - (tw / 2)), scale, (tw - 32), 200);
scale=(scale - (20 * (step)));
tw=(tw - (16 * (step)));
ScrRect("", ((i / 2) - (scale / 2)), (((limit) / 2) - (tw / 2)), scale, (tw - 32), BLEND, 100, 100, 80, 255);
ScrRect("GUI\scanner", ((i / 2) - ((128 * (step)) / 2)), (((((limit) / 2) - (tw / 2)) + tw) - (32 * (step))), (128 * (step)), (48 * (step)), BLEND, 255, 255, 255, 255);
local y=rect;
local p=rect;
for i=0, 3 do
if (bh<=floor(mod((GetTime() * 4), 3))) then
bw=bw..".";
else
bw=bw.." ";
end
end
bw=bw..">";
scannertext(bw, (i / 2), th, ((step) * 0.7), (step));
th=(th + (35 * (step)));
local t=format("%03d.%03d Mhz %03d.%03d Mhz", random(0, 999), random(0, 999), random(0, 999), random(0, 999));
scannertext(bh, (i / 2), th, ((step) * 0.5), (step));
th=(th + (25 * (step)));
bh=format("%03d.%03d Mhz %03d.%03d Mhz", random(0, 999), random(0, 999), random(0, 999), random(0, 999));
scannertext(bh, (i / 2), th, ((step) * 0.5), (step));
th=(th + (25 * (step)));
bh=format("%03d.%03d Mhz %03d.%03d Mhz", random(0, 999), random(0, 999), random(0, 999), random(0, 999));
scannertext(bh, (i / 2), th, ((step) * 0.5), (step));
th=(th + (25 * (step)));
bh=format("%03d.%03d Mhz %03d.%03d Mhz", random(0, 999), random(0, 999), random(0, 999), random(0, 999));
scannertext(bh, (i / 2), th, ((step) * 0.5), (step));
th=(th + (30 * (step)));
scannertext(code, (i / 2), th, (step), (step));
end
function progressbox(title, progress, orientation, r, alpha)
if (mission_curid==-2) then
do return end;
end
local w, h=ScrSize();
local scale=(w / 1024);
local tw=strlen;
local th=strlen;
local bw=strlen;
local bh=strlen;
local y=strlen;
if (orientation==1) then
y=((h - bh) + (th / 2));
end
if not (alpha) then
alpha=255;
end
rect(((w / 2) - (bw / 2)), (y - (bh / 2)), bw, bh, alpha);
if not (r) then
r=255;
end
ScrRect("#"..title, ((w / 2) - (tw / 2)), ((y - (bh / 2)) + 24), (20 * scale), (30 * scale), BLEND, r, r, r, alpha);
progressbar(((w / 2) - (tw / 2)), (((y - (bh / 2)) + 30) + 32), tw, (20 * scale), progress, 255, 0, 0, alpha);
end
function progressbar(x, y, w, h, progress, r, g, b, a)
if (mission_curid==-2) then
do return end;
end
if (progress<=0) then
progress=0;
end
if (progress>100) then
progress=100;
end
progress=(3 * floor((progress / 3)));
ScrRect("GUI\barpoint", x, y, w, h, BLEND, 100, 100, 100, a, 0, 0, (1 / 30), 1);
w=((w * progress) / 100);
ScrRect("GUI\barpoint", x, y, w, h, BLEND, r, g, b, a, 0, 0, ((100 / 30) / progress), 1);
end
function indicators(x, y, health, felony, damage, visibility)
progressbar((x + 14), (y + 10), 144, 15, health, 200, 110, 90, 150);
progressbar((x + 14), (y + 37), 144, 15, felony, 224, 165, 69, 150);
progressbar((x + 14), (y + 65), 144, 15, damage, 70, 130, 200, 150);
ScrRect("GUI\indicators", x, y, 256, 128, BLEND, 255, 255, 255, 150);
local v=(visibility / 100);
if (v>1) then
v=1;
end
if (v<0) then
v=0;
end
ScrRect("GUI\visibility", (x + 168), (y + 13), 32, 64, BLEND, (255 * v), (255 * (1 - v)), 0, 200);
end
function rect(x, y, w, h, alpha)
w=((floor((w / 4)) * 4) + 4);
h=((floor((h / 4)) * 4) + 4);
if (w<=64) then
w=64;
end
if (h<=64) then
h=64;
end
ScrRect("", (x + 32), (y + 32), (w - 64), (h - 64), BLEND, 6, 6, 6, alpha);
ScrRect("GUI\box\lt", x, y, 32, 32, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\rt", ((x + w) - 32), y, 32, 32, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\rb", ((x + w) - 32), ((y + h) - 32), 32, 32, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\lb", x, ((y + h) - 32), 32, 32, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\top", (x + 32), y, (w - 64), 32, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\bottom", (x + 32), ((y + h) - 32), (w - 64), 32, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\left", x, (y + 32), 32, (h - 64), BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\right", ((x + w) - 32), (y + 32), 32, (h - 64), BLEND, 255, 255, 255, alpha);
end
function irect(x, y, w, h, alpha)
ScrRect("GUI\box\ilt", x, y, 16, 16, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\irt", ((x + w) - 16), y, 16, 16, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\irb", ((x + w) - 16), ((y + h) - 16), 16, 16, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\ilb", x, ((y + h) - 16), 16, 16, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\itop", (x + 16), y, (w - 32), 16, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\ibottom", (x + 16), ((y + h) - 16), (w - 32), 16, BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\ileft", x, (y + 16), 16, (h - 32), BLEND, 255, 255, 255, alpha);
ScrRect("GUI\box\iright", ((x + w) - 16), (y + 16), 16, (h - 64), BLEND, 255, 255, 255, alpha);
end
gui_raceMsg="";
gui_raceMsgTimeout=0;
function gui_AddRaceMsg(str)
gui_raceMsg=str;
gui_raceMsgTimeout=1;
end
function gui_RenderRaceMsg()
if (mission_curid==-2) then
do return end;
end
if (gui_raceMsgTimeout<=0) then
do return end;
end
gui_raceMsgTimeout=(gui_raceMsgTimeout - (DT * 0.7));
if (gui_raceMsgTimeout<0) then
gui_raceMsgTimeout=0;
end
local w, h=ScrSize();
local scale=(1 - gui_raceMsgTimeout);
local cw=((32 + (200 * scale)) * 0.8);
local ch=(32 + (200 * scale));
local x=(w / 2);
local y=(w / 2);
ScrRect("#"..gui_raceMsg, (x + (4 * scale)), (y + (4 * scale)), cw, ch, BLEND, 0, 0, 0, ((128 * (1 - scale)) + 128));
ScrRect("#"..gui_raceMsg, x, y, cw, ch, BLEND, 255, 255, 255, ((128 * (1 - scale)) + 128));
end
gui_HelpMsg={};
gui_NumMessages=0;
gui_ScrollTime=0;
function gui_ScrollUp()
if (gui_NumMessages<=0) then
do return end;
end
local i=0;
for i=1, (gui_NumMessages - 1) do
gui_HelpMsg[i]=gui_HelpMsg[(i + 1)];
end
gui_NumMessages=(gui_NumMessages - 1);
end
function gui_AddMsg(icon, title, ir, ig, ib, tr, tg, tb)
if (gui_NumMessages>3) then
gui_ScrollUp();
end
if not (ir) then
ir=255;
end
if not (ig) then
ig=180;
end
if not (ib) then
ib=180;
end
if not (tr) then
tr=255;
end
if not (tg) then
tg=255;
end
if not (tb) then
tb=255;
end
gui_NumMessages=(gui_NumMessages + 1);
gui_HelpMsg[gui_NumMessages]={};
gui_HelpMsg[gui_NumMessages]["title"]=title;
gui_HelpMsg[gui_NumMessages]["icon"]=icon;
gui_HelpMsg[gui_NumMessages]["ir"]=ir;
gui_HelpMsg[gui_NumMessages]["ig"]=ig;
gui_HelpMsg[gui_NumMessages]["ib"]=ib;
gui_HelpMsg[gui_NumMessages]["tr"]=tr;
gui_HelpMsg[gui_NumMessages]["tg"]=tg;
gui_HelpMsg[gui_NumMessages]["tb"]=tb;
gui_ScrollTime=5;
end
function gui_DisplayHelpMsg()
gui_ScrollTime=(gui_ScrollTime - DT);
if (gui_ScrollTime<0) then
gui_ScrollTime=5;
gui_ScrollUp();
end
local w, h=ScrSize();
local scale=(w / 1024);
local CW=(15 * scale);
local CH=(20 * scale);
local y=((h - 8) - (gui_NumMessages * CH));
local wbox=0;
for i=1, gui_NumMessages do
local tw=strlen;
if (tw>wbox) then
wbox=tw;
end
end
wbox=(wbox + 64);
if (gui_NumMessages>0) then
rect(((w / 2) - (wbox / 2)), (y - 16), wbox, (((h - y) + 32) + 16), 150);
end
for i=1, gui_NumMessages do
local x=((w / 2) - ((strlen(gui_HelpMsg[i]["title"]) * CW) / 2));
ScrRect("#"..gui_HelpMsg[i]["title"], tw, y, CW, CH, BLEND, gui_HelpMsg[i]["tr"], gui_HelpMsg[i]["tg"], gui_HelpMsg[i]["tb"], 255);
y=(y + CH);
end
end
msg_line1=IDT_Nil;
msg_line2=IDT_Nil;
msg_line3=IDT_Nil;
msg_line4=IDT_Nil;
msg_alpha=0;
msg_minalpha=0;
msg_scale=1;
function message(line1, line2, line3, line4, time, mintime)
if (mission_curid==-2) then
do return end;
end
msg_scale=1;
msg_line1=line1;
msg_line2=line2;
msg_line3=line3;
msg_line4=line4;
if not (time) then
msg_alpha=10;
msg_alpha=time;
if not (mintime) then
msg_minalpha=3;
else
msg_minalpha=mintime;
end
end
function message2(scale, line1, line2, line3, line4, time, mintime)
if (mission_curid==-2) then
do return end;
end
msg_scale=scale;
msg_line1=line1;
msg_line2=line2;
msg_line3=line3;
msg_line4=line4;
if not (time) then
msg_alpha=4;
msg_alpha=time;
if not (mintime) then
msg_minalpha=3;
else
msg_minalpha=mintime;
end
end
function gui_DisplayMessage()
local w, h=ScrSize();
if (mission_curid~=-2) then
msg_alpha=(msg_alpha - DT);
end
local alpha=msg_alpha;
if (alpha<0) then
do return end;
end
if (alpha>1) then
alpha=1;
end
local texth=0;
local textw=0;
local s=(w / 1024);
local CW=((15 * msg_scale) * s);
local CH=((20 * msg_scale) * s);
local LEAD=(3 * s);
if (msg_line1) then
if ((msg_line1() * CW)>textw) then
textw=(strlen(msg_line1) * CW);
end
texth=((texth + CH) + LEAD);
end
if (msg_line2) then
if ((strlen(msg_line2) * CW)>textw) then
textw=(strlen(msg_line2) * CW);
end
texth=((texth + CH) + LEAD);
end
if (msg_line3) then
if ((strlen(msg_line3) * CW)>textw) then
textw=(strlen(msg_line3) * CW);
end
texth=((texth + CH) + LEAD);
end
if (msg_line4) then
if ((strlen(msg_line4) * CW)>textw) then
textw=(strlen(msg_line4) * CW);
end
texth=((texth + CH) + LEAD);
end
textw=(textw + CW);
texth=(texth + CH);
local y=strlen;
rect(((w / 2) - ((textw + (32 * s)) / 2)), ((y - (CH / 2)) - (8 * s)), (textw + (32 * s)), (texth + (16 * s)), (150 * alpha));
if (msg_line1) then
ScrRect("#"..msg_line1, ((w / 2) - ((strlen(msg_line1) * CW) / 2)), y, CW, CH, 1, 255, 255, 255, (255 * alpha));
y=((y + CH) + LEAD);
end
if (msg_line2) then
ScrRect("#"..msg_line2, ((w / 2) - ((strlen(msg_line2) * CW) / 2)), y, CW, CH, 1, 255, 255, 255, (255 * alpha));
y=((y + CH) + LEAD);
end
if (msg_line3) then
ScrRect("#"..msg_line3, ((w / 2) - ((strlen(msg_line3) * CW) / 2)), y, CW, CH, 1, 255, 255, 255, (255 * alpha));
y=((y + CH) + LEAD);
end
if (msg_line4) then
ScrRect("#"..msg_line4, ((w / 2) - ((strlen(msg_line4) * CW) / 2)), y, CW, CH, 1, 255, 255, 255, (255 * alpha));
y=((y + CH) + LEAD);
end
end
function guit2menu()
console("kill level sanjose");
console("set level menu");
alCmd("Kill");
alCmd("Stop wind");
alCmd("Stop rain");
lastChar=0;
Resume();
menu_init();
end
MissionInfoTimeOut=0;
function gamegui_Update()
ScrClip();
gui_DisplayMessage();
gui_DisplayHelpMsg();
gui_RenderRaceMsg();
if (FPS==1) then
local fps=format("#%d", (1 / DT));
ScrRect(fps, 200, 9, 16, 16, BLEND, 0, 0, 0, 255);
ScrRect(fps, 199, 8, 16, 16, BLEND, 255, 255, 255, 255);
end
if (IsPaused()>0) then
local w, h=ScrSize();
local str="#"..QUIT2MMENU;
local scale=(fps / 1024);
local strsize=strlen;
local x=strlen;
local y=strlen;
ScrRect(h, (strsize + 2), (x + 2), (25 * str), (40 * str), BLEND, 0, 0, 0, 128);
ScrRect(h, strsize, x, (25 * str), (40 * str), BLEND, 255, 255, 255, 255);
if (LastKeyDown==QUIT_YES) then
guit2menu();
StartIntro();
end
if (LastKeyDown==QUIT_NO) then
Resume();
end
else
if (LastKeyDown==9) then
gui_AddMsg("GUI\info", MissionShortInfo(CURRENTMISSIONID, 0));
end
end
if (GetComboStatus("~")>0) then
if (IsPaused()>0) then
Resume();
else
Pause();
end
end
LastKeyDown=-1;
end
function gamegui_cmd(cmd)
Window("Health", cmd);
Window("CarHealth", cmd);
Window("SpeedMeter", cmd);
Window("FuelMeter", cmd);
Window("Map", cmd);
Window("ActiveItem", cmd);
Window("ActionList", cmd);
Window("Felony", cmd);
Window("Timer", cmd);
Window("Money", cmd);
end
function game_init(curmisid, misid)
gui_Update=gamegui_Update;
CURRENTMISSIONID=curmisid;
ACTIVEMISSION=misid;
TargetRain=-1;
SkyDome("enable");
Weather("enable");
gamegui_cmd("show");
SetSetting("LimitFPS", "50");
end