forked from nukebloodaxe/ironseed_fpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.pas
3102 lines (3040 loc) · 85.4 KB
/
display.pas
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
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit display;
(********************************************************************
This file is part of Ironseed.
Ironseed is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Ironseed is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Ironseed. If not, see <https://www.gnu.org/licenses/>.
********************************************************************)
{*********************************************
Ship Display Control unit for IronSeed
Copyright:
1994 Channel 7, Destiny: Virtual
2013 y-salnikov
2020 Matija Nalis <[email protected]>
**********************************************}
interface
procedure displayoptions(com: integer);
procedure displaystarmap;
procedure displaystatus;
procedure displaysysteminfo(com: integer);
procedure displayshieldopts(com: integer);
procedure displayweaponinfo(com: integer);
procedure displaydamagecontrol(com: integer);
procedure displaylogs(com: integer);
procedure displaysystem(com: integer);
procedure displayship2(x1,y1: integer);
procedure displayshipinfo;
procedure checkstats;
procedure targetplanet(xt,yt: integer);
procedure displayconfigure(com: integer);
procedure findgunnode(x,y:integer);
procedure displaybotinfo(com: integer);
procedure displayhistorymap;
procedure displayshortscan;
procedure displaylongscan;
function checkloc(l: integer): boolean;
implementation
uses utils_, data, gmouse, journey, utils, usecode, saveload, utils2, comm, modplay, math;
const
batmax=32000;
shdbut2: buttype = (11,7,8);
shdbut: buttype = (9,12,12);
shdbut3: buttype = (11,8,12);
conbut: buttype= (10,7,12);
conbut2: buttype= (11,8,12);
botbut0: buttype= (14,15,16);
botbut1: buttype= (11,14,12);
botbut2: buttype= (11,16,12);
logbut1: buttype= (23,25,12);
logbut2: buttype= (23,25,6);
var
a,b,i,j,index,c1,c2: integer;
procedure displayoptions(com: integer);
var s: string[5];
begin
case com of
0:;
1,6: case viewindex of
2: begin
if ship.options[OPT_TIMESLICE]>1 then dec(ship.options[OPT_TIMESLICE]);
tslice:=ship.options[OPT_TIMESLICE];
end;
3: begin
ship.options[OPT_SOUND]:=0;
stopmod;
end;
9: begin
if ship.options[OPT_VOLUME]>1 then dec(ship.options[OPT_VOLUME]);
setmodvolume;
end;
else if ship.options[viewindex]>0 then dec(ship.options[viewindex]);
end;
2,7: case viewindex of
1: if ship.options[OPT_SCREENSAVER]<1 then inc(ship.options[OPT_SCREENSAVER]);
2: begin
if ship.options[OPT_TIMESLICE]<250 then inc(ship.options[OPT_TIMESLICE]);
tslice:=ship.options[OPT_TIMESLICE];
end;
4: if ship.options[OPT_DIFFICULTY]<2 then inc(ship.options[OPT_DIFFICULTY]);
5: if ship.options[OPT_MSGS]<2 then inc(ship.options[OPT_MSGS]);
7: if ship.options[OPT_FONT]<2 then inc(ship.options[OPT_FONT]);
9: begin
if ship.options[OPT_VOLUME]<64 then inc(ship.options[OPT_VOLUME]);
setmodvolume;
end;
else if ship.options[viewindex]=0 then ship.options[viewindex]:=1;
end;
3: if viewindex=1 then viewindex:=9 else dec(viewindex);
4: if viewindex=9 then viewindex:=1 else inc(viewindex);
5: begin
removerightside(true);
exit;
end;
end;
tcolor:=191;
mousehide;
if viewindex=1 then bkcolor:=179 else bkcolor:=5;
if ship.options[OPT_SCREENSAVER]=0 then printxy(251,37,'Off') else printxy(251,37,' On');
if viewindex=2 then bkcolor:=179 else bkcolor:=5;
str(ship.options[OPT_TIMESLICE]:3,s);
printxy(251,46,s);
if viewindex=3 then bkcolor:=179 else bkcolor:=5;
if ship.options[OPT_SOUND]=1 then printxy(251,55,' On') else printxy(251,55,'Off');
if viewindex=4 then bkcolor:=179 else bkcolor:=5;
case ship.options[OPT_DIFFICULTY] of
0: s:='Min';
1: s:='Avg';
2: s:='Max';
end;
printxy(251,64,s);
if viewindex=5 then bkcolor:=179 else bkcolor:=5;
case ship.options[OPT_MSGS] of
2: s:=' All';
1: s:='Some';
0: s:='None';
end;
printxy(246,73,s);
if viewindex=6 then bkcolor:=179 else bkcolor:=5;
if ship.options[OPT_ANIMATION]=1 then printxy(251,82,' On') else printxy(251,82,'Off');
if viewindex=7 then bkcolor:=179 else bkcolor:=5;
case ship.options[OPT_FONT] of
0: s:=' Iron';
1: s:='Clean';
2: s:='Block';
end;
printxy(241,91,s);
if viewindex=8 then bkcolor:=179 else bkcolor:=5;
if ship.options[OPT_AUTOSAVE]=1 then printxy(251,100,' On') else printxy(251,100,'Off');
str(ship.options[OPT_VOLUME]:3,s);
if viewindex=9 then bkcolor:=179 else bkcolor:=5;
printxy(251,109,s);
mouseshow;
bkcolor:=3;
end;
procedure displaydamagecontrol(com: integer);
var s: string[11];
begin
mousehide;
case com of
0:;
1: if viewlevel=2 then
begin
viewlevel:=1;
for i:=37 to 114 do
scr_fillchar(screen[i,166],113,5);
screen[44,165]:=10;
screen[45,279]:=2;
setcolor(2);
line(166,63,278,63);
line(166,90,278,90);
setcolor(10);
line(166,64,278,64);
line(166,91,278,91);
screen[63,165]:=6;
screen[90,165]:=6;
screen[64,279]:=6;
screen[91,279]:=6;
with ship.engrteam[viewindex] do
begin
case job of
0:;
1..7: if ship.damages[job]=0 then job:=0;
8: if ship.hullintegrity=ship.hullmax then job:=0;
end;
if job=0 then timeleft:=0;
end;
tcolor:=191;
bkcolor:=5;
printxy(168,27,'Damage Control Teams');
end;
2: if (viewlevel=1) and (ship.engrteam[viewindex].job<9) then
begin
viewlevel:=2;
for i:=37 to 114 do
scr_fillchar(screen[i,166],113,5);
screen[63,165]:=10;
screen[90,165]:=10;
screen[64,279]:=2;
screen[91,279]:=2;
setcolor(10);
line(166,45,278,45);
setcolor(2);
line(165,44,278,44);
screen[44,165]:=6;
screen[45,279]:=6;
bkcolor:=5;
tcolor:=191;
printxy(186,109,teamdata[15]);
str(viewindex:2,s);
printxy(168,27,'Engineering Team '+s+' ');
tcolor:=186;
printxy(243,37,'Damage');
printxy(161,37,'Team');
printxy(186,37,'Option');
end;
3: if viewlevel=1 then
begin
if viewindex=1 then viewindex:=3 else dec(viewindex);
end
else if ship.engrteam[viewindex].jobtype=JOBTYPE_REPAIR then
begin
i:=ship.engrteam[viewindex].job;
bkcolor:=5;
printxy(159+6*viewindex,46+i*7,' ');
if ship.engrteam[viewindex].job=0 then ship.engrteam[viewindex].job:=8
else dec(ship.engrteam[viewindex].job);
with ship.engrteam[viewindex] do
case job of
0: timeleft:=0;
1..7: if ship.damages[job]>0 then timeleft:=ship.damages[job]*70+random(30);
8: if ship.hullintegrity<ship.hullmax then timeleft:=(ship.hullmax-ship.hullintegrity)*30+random(40);
end;
end;
4: if viewlevel=1 then
begin
if viewindex=3 then viewindex:=1 else inc(viewindex);
end
else if ship.engrteam[viewindex].jobtype=JOBTYPE_REPAIR then
begin
i:=ship.engrteam[viewindex].job;
bkcolor:=5;
printxy(159+6*viewindex,46+i*7,' ');
if ship.engrteam[viewindex].job=8 then ship.engrteam[viewindex].job:=0
else inc(ship.engrteam[viewindex].job);
with ship.engrteam[viewindex] do
case job of
0: timeleft:=0;
1..7: if ship.damages[job]>0 then timeleft:=ship.damages[job]*70+random(30);
8: if ship.hullintegrity<ship.hullmax then timeleft:=(ship.hullmax-ship.hullintegrity)*30+random(40);
end;
end;
5: begin
removerightside(true);
mouseshow;
exit;
end;
6,7,8: begin
if viewlevel=1 then
begin
viewindex:=com-5;
viewlevel:=2;
for i:=37 to 114 do
scr_fillchar(screen[i,166],113,5);
screen[63,165]:=10;
screen[90,165]:=10;
screen[64,279]:=2;
screen[91,279]:=2;
setcolor(10);
line(166,45,278,45);
setcolor(2);
line(165,44,278,44);
screen[44,165]:=6;
screen[45,279]:=6;
bkcolor:=5;
tcolor:=191;
printxy(186,109,teamdata[15]);
str(viewindex:2,s);
printxy(168,27,'Engineering Team '+s+' ');
tcolor:=186;
printxy(243,37,'Damage');
printxy(161,37,'Team');
printxy(186,37,'Option');
end
else if viewlevel=2 then
begin
bkcolor:=5;
tcolor:=191;
printxy(186,109,teamdata[15]);
str((com-5):2,s);
printxy(168,27,'Engineering Team '+s+' ');
with ship.engrteam[viewindex] do
begin
case job of
0:;
1..7: if ship.damages[job]=0 then job:=0;
8: if ship.hullintegrity=ship.hullmax then job:=0;
end;
if job=0 then timeleft:=0;
end;
viewindex:=com-5;
end;
end;
end;
tcolor:=191;
bkcolor:=5;
case viewlevel of
1: begin
if viewindex=1 then bkcolor:=179 else bkcolor:=5;
printxy(163,39,'Engineering Team 1');
if viewindex=2 then bkcolor:=179 else bkcolor:=5;
printxy(163,66,'Engineering Team 2');
if viewindex=3 then bkcolor:=179 else bkcolor:=5;
printxy(163,93,'Engineering Team 3');
setcolor(184);
for j:=1 to 3 do
line(168,20+27*j,258,20+27*j);
bkcolor:=5;
for j:=1 to 3 do
with ship.engrteam[j] do
begin
if job=0 then printxy(169,22+j*27,teamdata[0]+' ')
else
begin
case jobtype of
JOBTYPE_REPAIR: s:='Repair ';
JOBTYPE_INSTALL: s:='Install ';
JOBTYPE_REMOVE: s:='Remove ';
JOBTYPE_CREATE: s:='Create ';
JOBTYPE_DECOMPOSE: s:='Disjoin ';
JOBTYPE_RESEARCH: s:='Research ';
end;
case job of
0..100: i:=job;
ID_DIRK..1499: i:=10; { weapons }
ID_REFLECTIVEHULL..1999: i:=9; { shields }
ID_NOTHING..2999: i:=11; { devices }
ID_UNKNOWN_COMPONENT..3999: i:=12; { components }
ID_UNKNOWN_MATERIAL..4999: i:=13; { materials }
ID_ARTIFACT_OFFSET..ID_LAST_ARTIFACT: i:=14; { artifacts }
end;
printxy(169,22+j*27,s+teamdata[i]);
end;
if timeleft=0 then
begin
s:='Completed ';
printxy(175,28+j*27,s);
end
else if timeleft<0 then
begin
tcolor:=94;
printxy(175,28+j*27,'Overdue ');
tcolor:=191;
end
else
begin
str(timeleft:6,s);
{str(extra div 256,s2);}
printxy(175,28+j*27,s+' Mins'{+s2});
end;
end;
end;
2: begin
if ship.engrteam[viewindex].job=0 then bkcolor:=179 else
bkcolor:=5;
printxy(186,46,teamdata[0]);
for j:=1 to 7 do
begin
if ship.engrteam[viewindex].job=j then bkcolor:=179
else bkcolor:=5;
str(ship.damages[j]:3,s);
printxy(186,46+j*7,teamdata[j]);
printxy(258,46+j*7,s);
end;
if ship.engrteam[viewindex].job=8 then bkcolor:=179 else
bkcolor:=5;
str(ship.hullmax-ship.hullintegrity:4,s);
printxy(186,102,teamdata[8]);
printxy(253,102,s);
for i:=46 to 114 do
scr_fillchar(screen[i,170],17,5);
for j:=1 to 3 do
begin
if ship.engrteam[j].jobtype>JOBTYPE_REPAIR then i:=9
else i:=ship.engrteam[j].job;
tcolor:=61;
bkcolor:=5;
printxy(159+6*j,46+i*7,chr(j+48));
end;
end;
end;
mouseshow;
bkcolor:=3;
end;
procedure showshdicon(shd: integer);
begin
assert (shd >= ID_NOSHIELD);
case shd of
ID_NOSHIELD: begin
for i:=0 to 19 do
scr_fillchar(screen[89+i,172],20,0);
end;
ID_REFLECTIVEHULL..1519:
begin
readweaicon(shd-ID_SHIELDS_OFFSET-2); { NOSHIELD / noweapon do not have icons, so -2 }
for i:=0 to 19 do
scrto_move(tempicon^[i],screen[89+i,172],5*4);
end;
end;
end;
procedure setupshieldinfo(shd: integer);
begin
assert (shd >= ID_NOSHIELD);
for i:=37 to 114 do
scr_fillchar(screen[i,166],113,5);
setcolor(184);
line(168,44,232,44);
revgraybutton(171,88,192,109);
setcolor(10);
line(166,53,278,53);
line(166,83,278,83);
line(220,53,220,81);
setcolor(2);
line(166,52,278,52);
line(166,82,278,82);
line(219,54,219,82);
screen[53,279]:=6;
screen[83,279]:=6;
screen[52,165]:=6;
screen[82,165]:=6;
screen[82,220]:=6;
screen[53,219]:=6;
revgraybutton(204,86,271,111);
if viewlevel<3 then
printxy(163,37,'Active Shield')
else printxy(163,37,'Target Shield');
printxy(163,54,'Sys Damage');
printxy(163,61,'Max Energy');
printxy(163,68,'Protection');
printxy(163,75,'Cargo Size');
printxy(194,87,'P');
printxy(194,93,'P');
printxy(193,99,'I');
printxy(194,105,'E');
showshdicon(shd);
end;
procedure displayshieldinfo(shd: integer);
var str1: string[5];
begin
tcolor:=31;
if shd>ID_NOSHIELD then printxy(174,45,cargo[shd-ID_SHIELDS_OFFSET].name)
else printxy(174,45,'None ');
if ship.damages[DMG_SHIELD]>0 then
begin
str(ship.damages[DMG_SHIELD]:5,str1);
printxy(218,54,str1+'% ');
end
else printxy(218,54,' None');
if shd>ID_NOSHIELD then
begin
str(weapons[shd-ID_SHIELDS_OFFSET].energy:5,str1);
printxy(218,61,str1+' GW ');
str(weapons[shd-ID_SHIELDS_OFFSET].damage:5,str1);
printxy(218,68,str1+' GJ ');
for j:=1 to 4 do
begin
y:=round(weapons[shd-ID_SHIELDS_OFFSET].dmgtypes[j]*0.66);
for i:=-2 to 3 do
begin
if i>0 then x:=100-i
else x:=100+i;
scr_fillchar(screen[83+i+j*6,205],y,x);
if y<66 then
scr_fillchar(screen[83+i+j*6,205+y],66-y,0);
end;
end;
end
else
begin
printxy(218,61,' None');
printxy(218,68,' None');
for i:=87 to 110 do
scr_fillchar(screen[i,205],65,2);
end;
if shd>ID_REFLECTIVEHULL then { some energy&space-using shield installed }
begin
j:=1;
while cargo[j].index<>shd
do inc(j);
if j<114 then
begin
i:=cargo[j].size div 10;
str(i:5,str1);
printxy(218,75,str1+' Cu.M');
end;
end
else printxy(218,75,' None');
end;
procedure removeshieldinfo;
begin
for i:=37 to 114 do
scr_fillchar(screen[i,166],113,5);
screen[52,165]:=10;
screen[82,165]:=10;
screen[53,279]:=2;
screen[83,279]:=2;
showpanel(shdbut);
printxy(168,27,'Shield Configuration');
printxy(163,37,'Active Shield');
setcolor(184);
line(168,44,232,44);
tcolor:=31;
if ship.shield>ID_NOSHIELD then printxy(174,45,cargo[ship.shield-ID_SHIELDS_OFFSET].name)
else printxy(174,45,'None ');
tcolor:=191;
for j:=1 to 3 do
begin
setcolor(2);
line(172,51+j*18,274,51+j*18);
line(172,51+j*18,172,57+j*18);
setcolor(10);
line(172,57+j*18,273,57+j*18);
line(274,51+j*18,274,57+j*18);
screen[51+j*18,274]:=4;
screen[57+j*18,172]:=4;
end;
end;
procedure displayshieldopts(com: integer);
var str1: string[5];
begin
tcolor:=191;
bkcolor:=5;
mousehide;
if ship.shield=ID_REFLECTIVEHULL then
for i:=1 to 3 do ship.shieldopt[i]:=100-ship.damages[DMG_SHIELD];
if ship.shield<=ID_NOSHIELD then
for i:=1 to 3 do ship.shieldopt[i]:=0;
case com of
0:;
1: if viewlevel=0 then { left }
begin
if ship.shield>ID_REFLECTIVEHULL then dec(ship.shieldopt[viewindex],min(5, ship.shieldopt[viewindex]))
end
else if viewlevel=3 then
begin
viewlevel:=2;
for i:=37 to 114 do
scr_fillchar(screen[i,166],113,5);
showpanel(shdbut3);
screen[52,165]:=10;
screen[82,165]:=10;
screen[53,279]:=2;
screen[83,279]:=2;
printxy(170,27,'Installable Shields');
end;
2: if viewlevel=0 then { right }
begin
if ship.shield>ID_REFLECTIVEHULL then inc(ship.shieldopt[viewindex],min(5, 100-ship.shieldopt[viewindex]))
end
else if (viewlevel=2) and (viewindex2>0) then
begin
viewlevel:=3;
setupshieldinfo(ship.cargo[viewindex2]);
end;
3: if viewlevel>1 then { up }
begin
dec(viewindex2);
while (viewindex2>0) and ((ship.cargo[viewindex2]<ID_NOSHIELD) or (ship.cargo[viewindex2]>ID_LAST_SHIELD)) do dec(viewindex2);
if viewindex2=0 then viewindex2:=250;
while (viewindex2>0) and ((ship.cargo[viewindex2]<ID_NOSHIELD) or (ship.cargo[viewindex2]>ID_LAST_SHIELD)) do dec(viewindex2);
if (viewindex2>0) and (viewlevel=3) then showshdicon(ship.cargo[viewindex2]);
end
else if viewindex=1 then viewindex:=3 else dec(viewindex);
4: if viewlevel>1 then { down }
begin
inc(viewindex2);
while (viewindex2<251) and ((ship.cargo[viewindex2]<ID_NOSHIELD) or (ship.cargo[viewindex2]>ID_LAST_SHIELD)) do inc(viewindex2);
if viewindex2=251 then viewindex2:=1;
while (viewindex2<251) and ((ship.cargo[viewindex2]<ID_NOSHIELD) or (ship.cargo[viewindex2]>ID_LAST_SHIELD)) do inc(viewindex2);
if viewindex2=251 then viewindex2:=0;
if (viewindex2>0) and (viewlevel=3) then showshdicon(ship.cargo[viewindex2]);
end
else if viewindex=3 then viewindex:=1 else inc(viewindex);
5: begin
mouseshow;
removerightside(true);
exit;
end;
6: case viewlevel of
0: begin
viewlevel:=1;
printxy(165,27,' Shield Statistics ');
setupshieldinfo(ship.shield);
showpanel(shdbut2);
end;
1,2,3:
begin
viewlevel:=0;
removeshieldinfo;
end;
end;
7: begin
i:=0;
for j:=1 to 3 do
if ((ship.engrteam[j].jobtype>=JOBTYPE_INSTALL) and (ship.engrteam[j].jobtype<=JOBTYPE_REMOVE)
and (ship.engrteam[j].job>=ID_NOSHIELD) and (ship.engrteam[j].job<=ID_LAST_SHIELD)) then i:=1;
if i=1 then
begin
tcolor:=94;
bkcolor:=3;
println;
print('ENGINEERING: Already working on a shield.');
end
else if (viewlevel=1) and (ship.shield>ID_REFLECTIVEHULL) then { noshield and reflective hull can't be removed }
begin { want to remove shield }
mouseshow;
if yesnorequest('Remove this shield?',0,31) then
begin
j:=1;
while (ship.engrteam[j].job<>0) and (j<4) do inc(j);
if j=4 then
begin
println;
tcolor:=94;
print('ENGINEERING: No team available.');
end
else
begin { there is engineering team available, start removing shield }
addcargo(ship.shield, true);
ship.engrteam[j].job:=ship.shield;
ship.engrteam[j].jobtype:=JOBTYPE_REMOVE;
ship.engrteam[j].timeleft:=1000;
ship.shield:=ID_REFLECTIVEHULL; // NB not fair but simple - we get reflective hull even if didn't have it before, if we remove any other shield... oh well..
mousehide;
showshdicon(ship.shield);
mouseshow;
for i:=1 to 3 do ship.shieldopt[i]:=0;
end;
end;
mousehide;
end
else if (viewlevel>1) and (ship.shield<=ID_REFLECTIVEHULL) and (viewindex2>0) then
begin { want to install shield }
mouseshow;
if yesnorequest('Install this shield?',0,31) then
begin
j:=1;
while (ship.engrteam[j].job<>0) and (j<4) do inc(j);
if j=4 then
begin
println;
tcolor:=94;
print('ENGINEERING: No team available.');
end
else
begin { there is engineering team available, start installing shield }
ship.engrteam[j].job:=ship.cargo[viewindex2];
removecargo(ship.cargo[viewindex2]);
ship.engrteam[j].jobtype:=JOBTYPE_INSTALL;
ship.engrteam[j].timeleft:=1000;
end;
end;
mousehide;
end
else if (viewlevel>1) and (viewindex2>0) then
begin
tcolor:=94;
bkcolor:=3;
println;
print('ENGINEERING: We must remove the old shield first.');
end;
bkcolor:=5;
tcolor:=191;
end;
8: if viewlevel=1 then
begin
viewlevel:=2;
for i:=37 to 114 do
scr_fillchar(screen[i,166],113,5);
showpanel(shdbut3);
screen[52,165]:=10;
screen[82,165]:=10;
screen[53,279]:=2;
screen[83,279]:=2;
printxy(170,27,'Installable Shields');
viewindex2:=1;
while (viewindex2<251) and ((ship.cargo[viewindex2]<ID_NOSHIELD) or (ship.cargo[viewindex2]>ID_LAST_SHIELD)) do inc(viewindex2);
if viewindex2=251 then viewindex2:=0;
end;
end;
case viewlevel of
0: begin
tcolor:=31;
if ship.shield>ID_NOSHIELD then printxy(174,45,cargo[ship.shield-ID_SHIELDS_OFFSET].name)
else printxy(174,45,'None ');
tcolor:=191;
str(ship.damages[DMG_SHIELD]:3,str1);
printxy(163,53,'System Damage:'+str1+'%');
if viewindex=1 then bkcolor:=179 else bkcolor:=5;
printxy(163,61,'Rest Mode');
if viewindex=2 then bkcolor:=179 else bkcolor:=5;
printxy(163,79,'Alert Mode');
if viewindex=3 then bkcolor:=179 else bkcolor:=5;
printxy(163,97,'Combat Mode');
for j:=1 to 3 do
for i:=-2 to 2 do
begin
if i>0 then setcolor(40-i)
else setcolor(40+i);
line(173,54+i+j*18,173+ship.shieldopt[j],54+i+j*18);
end;
setfillstyle(1,2);
for j:=1 to 3 do
if ship.shieldopt[j]<100 then
bar(174+ship.shieldopt[j],52+j*18,274,57+j*18);
end;
1: displayshieldinfo(ship.shield);
2: begin
if (viewindex2>0) and ((ship.cargo[viewindex2]<ID_NOSHIELD) or (ship.cargo[viewindex2]>=ID_NOTHING)) then
displayshieldopts(4);
x:=viewindex2+1;
y:=7;
repeat
while (x<251) and ((ship.cargo[x]<ID_NOSHIELD) or (ship.cargo[x]>ID_LAST_SHIELD)) do inc(x);
if x<251 then
begin
inc(y);
printxy(167,31+y*6,cargo[ship.cargo[x]-ID_SHIELDS_OFFSET].name);
end;
inc(x);
until (y=13) or (x>250);
if y<13 then
for j:=38+y*6 to 116 do
scr_fillchar(screen[j,166],113,5);
x:=viewindex2;
y:=8;
repeat
while (x>0) and ((ship.cargo[x]<ID_NOSHIELD) or (ship.cargo[x]>ID_LAST_SHIELD)) do dec(x);
if x=viewindex2 then bkcolor:=179 else bkcolor:=5;
if x>0 then
begin
dec(y);
printxy(167,31+y*6,cargo[ship.cargo[x]-ID_SHIELDS_OFFSET].name);
end;
dec(x);
until (y=1) or (x<1);
if y>1 then
for j:=37 to 31+y*6 do
scr_fillchar(screen[j,166],113,5);
end;
3: begin
if (ship.cargo[viewindex2]<ID_NOSHIELD) or (ship.cargo[viewindex2]>=ID_NOTHING) then
displayshieldopts(4);
if viewindex2>0 then displayshieldinfo(ship.cargo[viewindex2]);
end;
end;
mouseshow;
bkcolor:=3;
{ engineering / shield display checks }
if ship.shield<=ID_REFLECTIVEHULL then exit;
if ship.damages[DMG_SHIELD]>25 then
begin
tcolor:=94;
println;
ship.shieldlevel:=0;
if ship.damages[DMG_SHIELD]>59 then
begin
print('COMPUTER: Shield integrity compromised...needs repair.');
exit;
end
else
begin
print('Shield unstable...');
if (random(40)+20)<ship.damages[DMG_SHIELD] then
begin
print('COMPUTER: Failed to adjust shield.');
exit;
end;
end;
end;
if alert=ALRT_REST then
ship.shieldlevel:=ship.shieldopt[SHLD_LOWERED_WANT]
else if alert=ALRT_ALERT then
ship.shieldlevel:=ship.shieldopt[SHLD_ALERT_WANT]
else if alert=ALRT_COMBAT then
ship.shieldlevel:=ship.shieldopt[SHLD_COMBAT_WANT];
end;
procedure setupweaponinfo;
begin
for i:=37 to 114 do
scr_fillchar(screen[i,166],113,5);
revgraybutton(171,88,192,109);
setcolor(10);
line(166,53,278,53);
line(166,83,278,83);
line(220,53,220,81);
setcolor(2);
line(166,52,278,52);
line(166,82,278,82);
line(219,54,219,82);
screen[53,279]:=6;
screen[83,279]:=6;
screen[52,165]:=6;
screen[82,165]:=6;
screen[82,220]:=6;
screen[53,219]:=6;
revgraybutton(204,86,271,111);
if viewlevel<3 then
printxy(163,37,'Active Weapon')
else printxy(163,37,'Target Shield');
printxy(175,54,'Range');
printxy(163,61,'Max Energy');
printxy(173,68,'Damage');
printxy(163,75,'Cargo Size');
printxy(194,87,'P');
printxy(194,93,'P');
printxy(193,99,'I');
printxy(194,105,'E');
end;
procedure displayweaponstats(weap: integer);
var str1: string[5];
begin
tcolor:=31;
if weap>0 then printxy(174,45,cargo[weap].name)
else printxy(174,45,cargo[58].name);
if weap>0 then
begin
str((weapons[weap].range div 1000):3,str1);
printxy(228,54,str1+' KKM ');
str(weapons[weap].energy:5,str1);
printxy(218,61,str1+' GW ');
str(weapons[weap].damage:4,str1);
printxy(223,68,str1+' GJ ');
j:=1;
while cargo[j].index<>(weap+ID_DIRK-1)
do inc(j);
if j<114 then
begin
i:=cargo[j].size div 10;
str(i:5,str1);
printxy(218,75,str1+' Cu.M');
end;
for j:=1 to 4 do
begin
y:=round(weapons[weap].dmgtypes[j]*0.66);
for i:=-2 to 3 do
begin
if i>0 then x:=100-i
else x:=100+i;
scr_fillchar(screen[83+i+j*6,205],y,x);
if y<66 then
scr_fillchar(screen[83+i+j*6,205+y],66-y,0);
end;
end;
end
else
begin
printxy(218,54,' None');
printxy(218,61,' None');
printxy(218,68,' None');
printxy(218,75,' None');
for i:=87 to 110 do
scr_fillchar(screen[i,205],66,2);
end;
end;
procedure getweaponicons(x1,y1,weap,node: integer);
var j: integer;
begin;
b:=-1;
for j:=1 to 3 do
if (ship.engrteam[j].job>=ID_DIRK) and (ship.engrteam[j].job<ID_NOSHIELD-1) and
(ship.engrteam[j].jobtype=JOBTYPE_INSTALL) and ((ship.engrteam[j].extra and 15)=node) then
begin
for i:=0 to 19 do
scr_fillchar(screen[y1+i,x1],20,84);
exit;
end;
if weap=0 then
begin
for i:=0 to 19 do
scr_fillchar(screen[y1+i,x1],20,5);
exit;
end;
b:=1;
readweaicon(weap-1);
end;
procedure showweaponicon(x1,y1,weap,node: integer);
begin
getweaponicons(x1,y1,weap,node);
if b<0 then exit;
for i:=0 to 19 do
scrto_move(tempicon^[i],screen[y1+i,x1],5*4);
end;
procedure sideshowweaponicon(x1,y1,weap,node: integer);
var j: integer;
begin
getweaponicons(x1,y1,weap,node);
if b<0 then exit;
for i:=0 to 19 do
for j:=0 to 19 do
screen[y1+j,x1+i]:=tempicon^[i,j];
end;
procedure backshowweaponicon(x1,y1,weap,node: integer);
var j: integer;
begin
getweaponicons(x1,y1,weap,node);
if b<0 then exit;
for i:=0 to 19 do
for j:=0 to 19 do
screen[y1+j,x1+19-i]:=tempicon^[i,j];
end;
procedure revshowweaponicon(x1,y1,weap,node: integer);
begin
getweaponicons(x1,y1,weap,node);
if b<0 then exit;
for i:=0 to 19 do
scrto_move(tempicon^[19-i],screen[y1+i,x1],5*4);
end;
procedure displayweaponinfo(com: integer);
begin
tcolor:=191;
bkcolor:=5;
mousehide;
case com of
0:;
1: if viewlevel=1 then
begin
printxy(168,27,'Gun Node Information');
viewlevel:=0;
for i:=37 to 114 do
scr_fillchar(screen[i,166],113,5);
screen[52,165]:=10;
screen[82,165]:=10;
screen[53,279]:=2;
screen[83,279]:=2;
end;
2: if (viewlevel=0) and (viewindex>0) then
begin
setupweaponinfo;
showweaponicon(172,89,ship.gunnodes[viewindex],viewindex);
printxy(165,27,' Weapons Information ');
viewlevel:=1;
end;
3: if viewindex>0 then
begin
dec(viewindex);
while (viewindex>0) and (ship.gunnodes[viewindex]=0) do dec(viewindex);
if viewindex=0 then
begin
viewindex:=10;
while (viewindex>0) and (ship.gunnodes[viewindex]=0) do dec(viewindex);
end;
if (viewlevel=1) and (viewindex>0) then showweaponicon(172,89,ship.gunnodes[viewindex],viewindex);
end;
4: if viewindex>0 then
begin
inc(viewindex);
while (viewindex<11) and (ship.gunnodes[viewindex]=0) do inc(viewindex);
if viewindex=11 then
begin
viewindex:=1;
while (viewindex<11) and (ship.gunnodes[viewindex]=0) do inc(viewindex);
if viewindex=11 then viewindex:=0;
end;
if (viewlevel=1) and (viewindex>0) then showweaponicon(172,89,ship.gunnodes[viewindex],viewindex);
end;
5: begin
removerightside(true);
mouseshow;
exit;
end;
end;
case viewlevel of
0: begin
y:=1;
for j:=1 to 10 do
begin
if viewindex=j then bkcolor:=179 else bkcolor:=5;
if ship.gunnodes[j]>0 then
begin
printxy(167,31+7*y,cargo[ship.gunnodes[j]].name);
inc(y);
end;
end;
end;