-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patham_map.pas
1974 lines (1724 loc) · 50 KB
/
am_map.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
//------------------------------------------------------------------------------
//
// FPCDoom - Port of Doom to Free Pascal Compiler
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 2004-2007 by Jim Valavanis
// Copyright (C) 2017-2022 by Jim Valavanis
//
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
// DESCRIPTION:
// AutoMap module.
//
//------------------------------------------------------------------------------
// E-Mail: [email protected]
// Site : https://sourceforge.net/projects/fpcdoom/
//------------------------------------------------------------------------------
{$I FPCDoom.inc}
unit am_map;
interface
uses
d_fpc,
z_memory,
doomdef,
doomdata,
d_player,
r_defs,
d_event,
st_stuff,
p_local,
w_wad,
m_cheat,
i_system,
m_fixed;
const
AM_MSGHEADER = (Ord('a') shl 24) + (Ord('m') shl 16);
AM_MSGENTERED = AM_MSGHEADER or (Ord('e') shl 8);
AM_MSGEXITED = AM_MSGHEADER or (Ord('x') shl 8);
const
REDS = 256 - (5 * 16);
REDRANGE = 16;
BLUES = (256 - (4 * 16)) + 8;
BLUERANGE = 8;
GREENS = 7 * 16;
GREENRANGE = 16;
GRAYS = 6 * 16;
GRAYSRANGE = 16;
BROWNS = 4 * 16;
BROWNRANGE = 16;
YELLOWS = (256 - 32) + 7;
YELLOWRANGE = 1;
WHITE = 256 - 47;
{ Automap colors }
YOURCOLORS = WHITE;
WALLCOLORS = REDS;
WALLRANGE = REDRANGE;
TSWALLCOLORS = GRAYS;
TSWALLRANGE = GRAYSRANGE;
FDWALLCOLORS = BROWNS;
FDWALLRANGE = BROWNRANGE;
CDWALLCOLORS = YELLOWS;
CDWALLRANGE = YELLOWRANGE;
THINGCOLORS = GREENS;
THINGRANGE = GREENRANGE;
SECRETWALLCOLORS = WALLCOLORS;
SECRETWALLRANGE = WALLRANGE;
GRIDCOLORS = GRAYS + (GRAYSRANGE div 2);
GRIDRANGE = 0;
XHAIRCOLORS = GRAYS;
AM_PANDOWNKEY = KEY_DOWNARROW;
AM_PANUPKEY = KEY_UPARROW;
AM_PANRIGHTKEY = KEY_RIGHTARROW;
AM_PANLEFTKEY = KEY_LEFTARROW;
AM_ZOOMINKEY = '=';
AM_ZOOMINKEY2 = '+';
AM_ZOOMOUTKEY = '-';
AM_TONGLEKEY = KEY_TAB;
AM_GOBIGKEY = '0';
AM_FOLLOWKEY = 'f';
AM_GRIDKEY = 'g';
AM_ROTATEKEY = 'r';
AM_MARKKEY = 'm';
AM_CLEARMARKKEY = 'c';
AM_NUMMARKPOINTS = 10;
// scale on entry
INITSCALEMTOF = FRACUNIT div 5;
// how much the automap moves window per tic in frame-buffer coordinates }
// moves 140 pixels in 1 second }
F_PANINC = 4;
//==============================================================================
//
// M_ZOOMIN
//
// How much zoom-in per tic
//
//==============================================================================
function M_ZOOMIN: integer;
//==============================================================================
//
// M_ZOOMOUT
//
// How much zoom-out per tic
//
//==============================================================================
function M_ZOOMOUT: integer;
// Translates between frame-buffer and map distances
//==============================================================================
//
// FTOM
//
//==============================================================================
function FTOM(x: integer): integer;
//==============================================================================
//
// MTOF
//
//==============================================================================
function MTOF(x: integer): integer;
// Translates between frame-buffer and map coordinates
//==============================================================================
//
// CXMTOF
//
//==============================================================================
function CXMTOF(x: integer): integer;
//==============================================================================
//
// CYMTOF
//
//==============================================================================
function CYMTOF(y: integer): integer;
{ the following is crap }
const
LINE_NEVERSEE = ML_DONTDRAW;
type
fpoint_t = record
x: integer;
y: integer;
end;
Pfpoint_t = ^fpoint_t;
fline_t = record
a: fpoint_t;
b: fpoint_t;
end;
Pfline_t = ^fline_t;
mpoint_t = record
x: fixed_t;
y: fixed_t;
end;
Pmpoint_t = ^mpoint_t;
mline_t = record
a: mpoint_t;
b: mpoint_t;
end;
Pmline_t = ^mline_t;
mline_tArray = packed array[0..$FFFF] of mline_t;
Pmline_tArray = ^mline_tArray;
islope_t = record
slp: fixed_t;
islp: fixed_t;
end;
Pislope_t = ^islope_t;
//
// The vector graphics for the automap.
// A line drawing of the player pointing right,
// starting from the middle.
//
const
NUMPLYRLINES = 7;
var
player_arrow: array[0..NUMPLYRLINES - 1] of mline_t;
const
NUMCHEATPLYRLINES = 16;
var
cheat_player_arrow: array[0..NUMCHEATPLYRLINES - 1] of mline_t;
const
NUMTRIANGLEGUYLINES = 3;
var
triangle_guy: array[0..NUMTRIANGLEGUYLINES - 1] of mline_t;
const
NUMTHINTRIANGLEGUYLINES = 3;
var
thintriangle_guy: array[0..NUMTHINTRIANGLEGUYLINES - 1] of mline_t;
type
automapstate_t = (am_inactive, am_only, am_overlay, AM_NUMSTATES);
var
am_cheating: integer = 0;
automapgrid: boolean = false;
leveljuststarted: integer = 1; // kluge until AM_LevelInit() is called
amstate: automapstate_t = am_inactive;
// location of window on screen
f_x: integer;
f_y: integer;
// size of window on screen
f_w: integer;
f_h: integer;
fb: PByteArray; // pseudo-frame buffer
fb32: PLongWordArray; // pseudo-frame buffer
amclock: integer;
m_paninc: mpoint_t; // how far the window pans each tic (map coords)
mtof_zoommul: fixed_t; // how far the window zooms in each tic (map coords)
ftom_zoommul: fixed_t; // how far the window zooms in each tic (fb coords)
m_x, m_y: fixed_t; // LL x,y where the window is on the map (map coords)
m_x2, m_y2: fixed_t; // UR x,y where the window is on the map (map coords)
//
// width/height of window on map (map coords)
//
m_w: fixed_t;
m_h: fixed_t;
// based on level size
min_x: fixed_t;
min_y: fixed_t;
max_x: fixed_t;
max_y: fixed_t;
max_w: fixed_t; // max_x-min_x,
max_h: fixed_t; // max_y-min_y
// based on player size
min_w: fixed_t;
min_h: fixed_t;
min_scale_mtof: fixed_t; // used to tell when to stop zooming out
max_scale_mtof: fixed_t; // used to tell when to stop zooming in
// old stuff for recovery later
old_m_w, old_m_h: fixed_t;
old_m_x, old_m_y: fixed_t;
// old location used by the Follower routine
f_oldloc: mpoint_t;
// used by MTOF to scale from map-to-frame-buffer coords
scale_mtof: fixed_t = INITSCALEMTOF;
// used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof)
scale_ftom: fixed_t;
plr: Pplayer_t; // the player represented by an arrow
var
marknums: array[0..9] of Ppatch_t; // numbers used for marking by the automap
markpoints: array[0..AM_NUMMARKPOINTS - 1] of mpoint_t; // where the points are
markpointnum: integer = 0; // next point to be assigned
followplayer: boolean = true; // specifies whether to follow the player around
const
cheat_amap_seq: string = Chr($b2) + Chr($26) + Chr($26) + Chr($2e) + Chr($ff); // iddt
var
cheat_amap: cheatseq_t;
stopped: boolean = true;
//==============================================================================
//
// AM_Responder
//
//==============================================================================
function AM_Responder(ev: Pevent_t): boolean;
//==============================================================================
// AM_Ticker
//
// Called by main loop.
//
//==============================================================================
procedure AM_Ticker;
//==============================================================================
// AM_Drawer
//
// Called by main loop,
// called instead of view drawer if automap active.
//
//==============================================================================
procedure AM_Drawer;
//==============================================================================
//
// AM_Init
//
//==============================================================================
procedure AM_Init;
//==============================================================================
// AM_Stop
//
// Called to force the automap to quit
// if the level is completed while it is up.
//
//==============================================================================
procedure AM_Stop;
//==============================================================================
//
// AM_Start
//
//==============================================================================
procedure AM_Start;
var
allowautomapoverlay: boolean;
allowautomaprotate: boolean;
implementation
uses
tables,
c_cmds,
d_english,
g_game,
r_data,
r_hires,
r_draw,
r_mirror,
p_mobj_h,
p_setup,
v_video;
//==============================================================================
//
// CmdAllowautomapoverlay
//
//==============================================================================
procedure CmdAllowautomapoverlay(const parm: string);
begin
allowautomapoverlay := C_BoolEval(parm, allowautomapoverlay);
if not allowautomapoverlay and (amstate = am_overlay) then
amstate := am_inactive;
end;
//==============================================================================
// M_ZOOMIN
//
// how much zoom-in per tic
//
//==============================================================================
function M_ZOOMIN: integer;
begin
result := Trunc(1.02 * FRACUNIT);
end;
//==============================================================================
// M_ZOOMOUT
//
// how much zoom-out per tic
//
//==============================================================================
function M_ZOOMOUT: integer;
begin
result := Trunc(FRACUNIT / 1.02);
end;
//==============================================================================
//
// FTOM
//
//==============================================================================
function FTOM(x: integer): integer;
begin
result := FixedMul(x * FRACUNIT, scale_ftom);
end;
//==============================================================================
//
// MTOF
//
//==============================================================================
function MTOF(x: integer): integer;
begin
result := FixedInt(FixedMul(x, scale_mtof));
end;
//==============================================================================
//
// CXMTOF
//
//==============================================================================
function CXMTOF(x: integer): integer;
begin
result := f_x + MTOF(x - m_x);
end;
//==============================================================================
//
// CYMTOF
//
//==============================================================================
function CYMTOF(y: integer): integer;
begin
result := f_y + (f_h - MTOF(y - m_y));
end;
//==============================================================================
// AM_getIslope
//
//==============================================================================
procedure AM_getIslope(ml: Pmline_t; _is: Pislope_t);
var
dx, dy: integer;
begin
dx := ml.b.x - ml.a.x;
dy := ml.a.y - ml.b.y;
if dy = 0 then
begin
if dx < 0 then
_is.islp := -MAXINT
else
_is.islp := MAXINT;
end
else
_is.islp := FixedDiv(dx, dy);
if dx = 0 then
begin
if dy < 0 then
_is.slp := -MAXINT
else
_is.slp := MAXINT;
end
else
_is.slp := FixedDiv(dy, dx);
end;
//==============================================================================
// AM_activateNewScale
//
//==============================================================================
procedure AM_activateNewScale;
begin
m_x := m_x + m_w div 2;
m_y := m_y + m_h div 2;
m_w := FTOM(f_w);
m_h := FTOM(f_h);
m_x := m_x - m_w div 2;
m_y := m_y - m_h div 2;
m_x2 := m_x + m_w;
m_y2 := m_y + m_h;
end;
//==============================================================================
// AM_saveScaleAndLoc
//
//==============================================================================
procedure AM_saveScaleAndLoc;
begin
old_m_x := m_x;
old_m_y := m_y;
old_m_w := m_w;
old_m_h := m_h;
end;
//==============================================================================
// AM_restoreScaleAndLoc
//
//==============================================================================
procedure AM_restoreScaleAndLoc;
begin
m_w := old_m_w;
m_h := old_m_h;
if not followplayer then
begin
m_x := old_m_x;
m_y := old_m_y;
end
else
begin
m_x := plr.mo.x - m_w div 2;
m_y := plr.mo.y - m_h div 2;
end;
m_x2 := m_x + m_w;
m_y2 := m_y + m_h;
// Change the scaling multipliers
scale_mtof := FixedDiv(f_w * FRACUNIT, m_w);
scale_ftom := FixedDiv(FRACUNIT, scale_mtof);
end;
//==============================================================================
// AM_addMark
//
// adds a marker at the current location
//
//==============================================================================
procedure AM_addMark;
begin
markpoints[markpointnum].x := m_x + m_w div 2;
markpoints[markpointnum].y := m_y + m_h div 2;
markpointnum := (markpointnum + 1) mod AM_NUMMARKPOINTS;
end;
//==============================================================================
// AM_findMinMaxBoundaries
//
// Determines bounding box of all vertices,
// sets global variables controlling zoom range.
//
//==============================================================================
procedure AM_findMinMaxBoundaries;
var
i: integer;
a, b: fixed_t;
pvi: Pvertex_t;
begin
min_x := MAXINT;
min_y := MAXINT;
max_x := -MAXINT;
max_y := -MAXINT;
pvi := @vertexes[0];
for i := 0 to numvertexes - 1 do
begin
if pvi.x < min_x then
min_x := pvi.x
else if pvi.x > max_x then
max_x := pvi.x;
if pvi.y < min_y then
min_y := pvi.y
else if pvi.y > max_y then
max_y := pvi.y;
inc(pvi);
end;
max_w := max_x - min_x;
max_h := max_y - min_y;
min_w := 10 * PLAYERRADIUS; // const? never changed?
min_h := 10 * PLAYERRADIUS;
a := FixedDiv(f_w * FRACUNIT, max_w);
b := FixedDiv(f_h * FRACUNIT, max_h);
if a < b then
min_scale_mtof := a
else
min_scale_mtof := b;
max_scale_mtof := FixedDiv(f_h * FRACUNIT, 10 * PLAYERRADIUS);
end;
//==============================================================================
// AM_changeWindowLoc
//
//==============================================================================
procedure AM_changeWindowLoc;
begin
if (m_paninc.x <> 0) or (m_paninc.y <> 0) then
begin
followplayer := false;
f_oldloc.x := MAXINT;
end;
m_x := m_x + m_paninc.x;
m_y := m_y + m_paninc.y;
if m_x + m_w div 2 > max_x then
m_x := max_x - m_w div 2
else if m_x + m_w div 2 < min_x then
m_x := min_x - m_w div 2;
if m_y + m_h div 2 > max_y then
m_y := max_y - m_h div 2
else if m_y + m_h div 2 < min_y then
m_y := min_y - m_h div 2;
m_x2 := m_x + m_w;
m_y2 := m_y + m_h;
end;
//
//
//
var
st_notify_AM_initVariables: event_t;
//==============================================================================
//
// AM_initVariables
//
//==============================================================================
procedure AM_initVariables;
var
pnum: integer;
i: integer;
begin
fb := screens[SCN_FG];
fb32 := screen32;
f_oldloc.x := MAXINT;
amclock := 0;
m_paninc.x := 0;
m_paninc.y := 0;
ftom_zoommul := FRACUNIT;
mtof_zoommul := FRACUNIT;
m_w := FTOM(f_w);
m_h := FTOM(f_h);
if gamestate = gs_level then
begin
// find player to center on initially
pnum := consoleplayer;
if not playeringame[pnum] then
begin
pnum := -1;
for i := 0 to MAXPLAYERS - 1 do
if playeringame[i] then
begin
pnum := i;
break;
end;
end;
if pnum >= 0 then
begin
plr := @players[pnum];
if plr.mo <> nil then
begin
m_x := plr.mo.x - m_w div 2;
m_y := plr.mo.y - m_h div 2;
end;
end;
end;
AM_changeWindowLoc;
// for saving & restoring
//AM_saveScaleAndLoc;
old_m_x := m_x;
old_m_y := m_y;
old_m_w := m_w;
old_m_h := m_h;
// inform the status bar of the change
ST_Responder(@st_notify_AM_initVariables);
end;
//==============================================================================
// AM_loadPics
//
//==============================================================================
procedure AM_loadPics;
var
i: integer;
namebuf: string;
begin
for i := 0 to AM_NUMMARKPOINTS - 1 do
begin
sprintf(namebuf, 'AMMNUM%d', [i]);
marknums[i] := W_CacheLumpName(namebuf, PU_STATIC);
end;
end;
//==============================================================================
//
// AM_unloadPics
//
//==============================================================================
procedure AM_unloadPics;
var
i: integer;
begin
for i := 0 to AM_NUMMARKPOINTS - 1 do
Z_ChangeTag(marknums[i], PU_CACHE);
end;
//==============================================================================
//
// AM_clearMarks
//
//==============================================================================
procedure AM_clearMarks;
var
i: integer;
begin
for i := 0 to AM_NUMMARKPOINTS - 1 do
markpoints[i].x := -1; // means empty
markpointnum := 0;
end;
//==============================================================================
// AM_LevelInit
//
// should be called at the start of every level
// right now, i figure it out myself
//
//==============================================================================
procedure AM_LevelInit;
begin
leveljuststarted := 0;
f_x := 0;
f_y := 0;
f_w := SCREENWIDTH;
f_h := V_PreserveY(ST_Y);
AM_clearMarks;
AM_findMinMaxBoundaries;
scale_mtof := FixedDiv(min_scale_mtof, Trunc(0.7 * FRACUNIT));
if scale_mtof > max_scale_mtof then
scale_mtof := min_scale_mtof;
scale_ftom := FixedDiv(FRACUNIT, scale_mtof);
end;
//
//
//
var
st_notify_AM_Stop: event_t;
//==============================================================================
//
// AM_Stop
//
//==============================================================================
procedure AM_Stop;
begin
if not stopped then
begin
AM_unloadPics;
ST_Responder(@st_notify_AM_Stop);
stopped := true;
end;
end;
//
//
//
var
lastlevel: integer = -1;
lastepisode: integer = -1;
lastscreenwidth: integer = -1;
lastscreenheight: integer = -1;
//==============================================================================
//
// AM_Start
//
//==============================================================================
procedure AM_Start;
begin
AM_Stop;
stopped := false;
if (lastlevel <> gamemap) or (lastepisode <> gameepisode) or
(lastscreenwidth <> SCREENWIDTH) or (lastscreenheight <> SCREENHEIGHT) then
begin
AM_LevelInit;
lastlevel := gamemap;
lastepisode := gameepisode;
lastscreenwidth := SCREENWIDTH;
lastscreenheight := SCREENHEIGHT;
end;
AM_initVariables;
AM_loadPics;
end;
//==============================================================================
// AM_minOutWindowScale
//
// set the window scale to the maximum size
//
//==============================================================================
procedure AM_minOutWindowScale;
begin
scale_mtof := min_scale_mtof;
scale_ftom := FixedDiv(FRACUNIT, scale_mtof);
AM_activateNewScale;
end;
//==============================================================================
// AM_maxOutWindowScale
//
// set the window scale to the minimum size
//
//==============================================================================
procedure AM_maxOutWindowScale;
begin
scale_mtof := max_scale_mtof;
scale_ftom := FixedDiv(FRACUNIT, scale_mtof);
AM_activateNewScale;
end;
//
// Handle events (user inputs) in automap mode
//
var
bigstate: boolean = false;
//==============================================================================
//
// AM_Responder
//
//==============================================================================
function AM_Responder(ev: Pevent_t): boolean;
var
_message: string;
begin
result := false;
if not allowautomapoverlay then
if amstate = am_overlay then
amstate := am_inactive;
if amstate = am_inactive then
begin
if (ev._type = ev_keydown) and (ev.data1 = AM_TONGLEKEY) then
begin
if allowautomapoverlay then
amstate := automapstate_t((Ord(amstate) + 1) mod Ord(AM_NUMSTATES))
else
begin
if amstate = am_inactive then
amstate := am_only
else
amstate := am_inactive
end;
AM_Start;
viewactive := false;
result := true;
end;
end
else if ev._type = ev_keydown then
begin
result := true;
case ev.data1 of
AM_PANRIGHTKEY: // pan right
begin
if not followplayer then
m_paninc.x := FTOM(F_PANINC)
else
result := false;
end;
AM_PANLEFTKEY: // pan left
begin
if not followplayer then
m_paninc.x := -FTOM(F_PANINC)
else
result := false;
end;
AM_PANUPKEY: // pan up
begin
if not followplayer then
m_paninc.y := FTOM(F_PANINC)
else
result := false;
end;
AM_PANDOWNKEY: // pan down
begin
if not followplayer then
m_paninc.y := -FTOM(F_PANINC)
else
result := false;
end;
Ord(AM_ZOOMOUTKEY): // zoom out
begin
mtof_zoommul := M_ZOOMOUT;
ftom_zoommul := M_ZOOMIN;
end;
Ord(AM_ZOOMINKEY),
Ord(AM_ZOOMINKEY2): // zoom in
begin
mtof_zoommul := M_ZOOMIN;
ftom_zoommul := M_ZOOMOUT;
end;
AM_TONGLEKEY:
begin
amstate := automapstate_t((Ord(amstate) + 1) mod Ord(AM_NUMSTATES));
if amstate <> am_only then
begin
bigstate := false;
viewactive := true;
if amstate = am_inactive then
AM_Stop;
end;
end;
Ord(AM_GOBIGKEY):
begin
bigstate := not bigstate;
if bigstate then
begin
AM_saveScaleAndLoc;
AM_minOutWindowScale;
end
else
AM_restoreScaleAndLoc;
end;
Ord(AM_FOLLOWKEY):
begin
followplayer := not followplayer;
f_oldloc.x := MAXINT;
if followplayer then
plr._message := AMSTR_FOLLOWON
else
plr._message := AMSTR_FOLLOWOFF;
end;
Ord(AM_GRIDKEY):
begin
automapgrid := not automapgrid;
if automapgrid then
plr._message := AMSTR_GRIDON
else
plr._message := AMSTR_GRIDOFF;
end;
Ord(AM_ROTATEKEY):
begin
allowautomaprotate := not allowautomaprotate;
if allowautomaprotate then
plr._message := AMSTR_ROTATEON
else
plr._message := AMSTR_ROTATEOFF;
end;
Ord(AM_MARKKEY):
begin
sprintf(_message, '%s %d', [AMSTR_MARKEDSPOT, markpointnum]);
plr._message := _message;
AM_addMark;
end;
Ord(AM_CLEARMARKKEY):
begin
AM_clearMarks;
plr._message := AMSTR_MARKSCLEARED;
end
else
begin
result := false;
end;
end;
end
else if ev._type = ev_keyup then
begin