Revert to old wad read/write method
[d2df-editor.git] / src / editor / g_map.pas
bloba93a75af45ac2396fb8f48f8849aeb24d50824eb
1 Unit g_map;
3 {$INCLUDE ../shared/a_modes.inc}
5 Interface
7 Uses
8 LCLIntf, LCLType, g_basic, e_graphics, MAPREADER, MAPSTRUCT,
9 MAPWRITER, e_log, MAPDEF, utils;
11 Type
12 TMapObject = record
13 ObjectType: Byte;
14 ID: DWORD;
15 Live: Boolean;
16 end;
18 TPanel = record
19 TextureID: DWORD;
20 TextureWidth,
21 TextureHeight: Word;
22 X, Y: Integer;
23 Width, Height: Word;
24 PanelType: Word;
25 Alpha: Byte;
26 Blending: Boolean;
27 TextureName: String;
28 end;
30 TItem = record
31 X, Y: Integer;
32 ItemType: Byte;
33 OnlyDM: Boolean;
34 Fall: Boolean;
35 end;
37 TArea = record
38 X, Y: Integer;
39 AreaType: Byte;
40 Direction: TDirection;
41 end;
43 TMonster = record
44 X, Y: Integer;
45 MonsterType: Byte;
46 Direction: TDirection;
47 end;
49 TTrigger = record
50 X, Y: Integer;
51 Width, Height: Word;
52 Enabled: Boolean;
53 TexturePanel: Integer;
54 TriggerType: Byte;
55 ActivateType: Byte;
56 Key: Byte;
57 Data: TTriggerData;
58 end;
60 TMapInfo = record
61 FileName: String;
62 MapName: String;
63 Name: String;
64 Description: String;
65 Author: String;
66 MusicName: String;
67 SkyName: String;
68 Height: Word;
69 Width: Word;
70 end;
72 TMonsterSizeDelta = record
73 X, Y: Integer;
74 Width: Word;
75 end;
77 const
78 OBJECT_PANEL = 1;
79 OBJECT_ITEM = 2;
80 OBJECT_MONSTER = 3;
81 OBJECT_AREA = 4;
82 OBJECT_TRIGGER = 5;
84 COLOR_EDGE: Integer = $000000;
85 ALPHA_EDGE: Byte = 96;
86 ALPHA_LINE: Byte = 208;
87 ALPHA_AREA: Byte = 96;
89 TEXTURE_NAME_WATER = '_water_0';
90 TEXTURE_NAME_ACID1 = '_water_1';
91 TEXTURE_NAME_ACID2 = '_water_2';
92 TEXTURE_SPECIAL_NONE = DWORD(-1);
93 TEXTURE_SPECIAL_WATER = DWORD(-2);
94 TEXTURE_SPECIAL_ACID1 = DWORD(-3);
95 TEXTURE_SPECIAL_ACID2 = DWORD(-4);
96 TEXTURE_SPECIAL_NOTEXTURE = DWORD(-8);
98 ItemSize: Array [ITEM_MEDKIT_SMALL..ITEM_MAX] of Array [0..1] of Byte =
99 (((14), (15)), // MEDKIT_SMALL
100 ((28), (19)), // MEDKIT_LARGE
101 ((28), (19)), // MEDKIT_BLACK
102 ((31), (16)), // ARMOR_GREEN
103 ((31), (16)), // ARMOR_BLUE
104 ((25), (25)), // SPHERE_BLUE
105 ((25), (25)), // SPHERE_WHITE
106 ((24), (47)), // SUIT
107 ((14), (27)), // OXYGEN
108 ((25), (25)), // INVUL
109 ((62), (24)), // WEAPON_SAW
110 ((63), (12)), // WEAPON_SHOTGUN1
111 ((54), (13)), // WEAPON_SHOTGUN2
112 ((54), (16)), // WEAPON_CHAINGUN
113 ((62), (16)), // WEAPON_ROCKETLAUNCHER
114 ((54), (16)), // WEAPON_PLASMA
115 ((61), (36)), // WEAPON_BFG
116 ((54), (16)), // WEAPON_SUPERPULEMET
117 (( 9), (11)), // AMMO_BULLETS
118 ((28), (16)), // AMMO_BULLETS_BOX
119 ((15), ( 7)), // AMMO_SHELLS
120 ((32), (12)), // AMMO_SHELLS_BOX
121 ((12), (27)), // AMMO_ROCKET
122 ((54), (21)), // AMMO_ROCKET_BOX
123 ((15), (12)), // AMMO_CELL
124 ((32), (21)), // AMMO_CELL_BIG
125 ((22), (29)), // AMMO_BACKPACK
126 ((16), (16)), // KEY_RED
127 ((16), (16)), // KEY_GREEN
128 ((16), (16)), // KEY_BLUE
129 (( 1), ( 1)), // WEAPON_KASTET
130 ((43), (16)), // WEAPON_PISTOL
131 ((14), (18)), // BOTTLE
132 ((16), (15)), // HELMET
133 ((32), (24)), // JETPACK
134 ((25), (25)), // INVIS
135 ((53), (20)), // WEAPON_FLAMETHROWER
136 ((13), (20))); // AMMO_FUELCAN
138 AreaSize: Array [AREA_PLAYERPOINT1..AREA_BLUETEAMPOINT] of TRectWH =
139 ((X:15; Y:12; Width:34; Height:52), // PLAYERPOINT1
140 (X:15; Y:12; Width:34; Height:52), // PLAYERPOINT2
141 (X:15; Y:12; Width:34; Height:52), // DMPOINT
142 (X:15; Y:11; Width:34; Height:52), // REDFLAG
143 (X:15; Y:11; Width:34; Height:52), // BLUEFLAG
144 (X:15; Y:11; Width:34; Height:52), // DOMFLAG
145 (X:15; Y:12; Width:34; Height:52), // REDTEAMPOINT
146 (X:15; Y:12; Width:34; Height:52)); // BLUETEAMPOINT
148 MonsterSize: Array [MONSTER_DEMON..MONSTER_MAN] of TRectWH =
149 ((X: 7; Y: 8; Width: 50; Height: 52), // DEMON
150 (X: 15; Y: 10; Width: 34; Height: 50), // IMP
151 (X: 15; Y: 8; Width: 34; Height: 52), // ZOMBY
152 (X: 15; Y: 8; Width: 34; Height: 52), // SERG
153 (X: 24; Y: 9; Width: 80; Height: 110), // CYBER
154 (X: 15; Y: 4; Width: 34; Height: 56), // CGUN
155 (X: 39; Y: 32; Width: 50; Height: 64), // BARON
156 (X: 39; Y: 32; Width: 50; Height: 64), // KNIGHT
157 (X: 34; Y: 36; Width: 60; Height: 56), // CACO
158 (X: 16; Y: 14; Width: 32; Height: 36), // SOUL
159 (X: 34; Y: 36; Width: 60; Height: 56), // PAIN
160 (X: 23; Y: 14; Width: 210; Height: 100), // SPIDER
161 (X: 14; Y: 17; Width: 100; Height: 42), // BSP
162 (X: 28; Y: 34; Width: 72; Height: 60), // MANCUB
163 (X: 30; Y: 28; Width: 68; Height: 72), // SKEL
164 (X: 30; Y: 28; Width: 68; Height: 72), // VILE
165 (X: 6; Y: 11; Width: 20; Height: 10), // FISH
166 (X: 20; Y: 13; Width: 24; Height: 36), // BARREL
167 (X: 30; Y: 26; Width: 68; Height: 76), // ROBO
168 (X: 15; Y: 6; Width: 34; Height: 52)); // MAN
170 MonsterSizeDelta: Array [MONSTER_DEMON..MONSTER_MAN] of TMonsterSizeDelta =
171 ((X: 1; Y: 4; Width: 64), // DEMON
172 (X: 8; Y: -4; Width: 64), // IMP
173 (X: 1; Y: -4; Width: 64), // ZOMBY
174 (X: 0; Y: -4; Width: 64), // SERG
175 (X: 2; Y: -6; Width: 128), // CYBER
176 (X: -1; Y: -2; Width: 64), // CGUN
177 (X: 4; Y: 0; Width: 128), // BARON
178 (X: 4; Y: 0; Width: 128), // KNIGHT
179 (X: 0; Y: -4; Width: 128), // CACO
180 (X: 1; Y: -10; Width: 64), // SOUL
181 (X: -1; Y: -3; Width: 128), // PAIN
182 (X: -4; Y: -4; Width: 256), // SPIDER
183 (X: 0; Y: -1; Width: 128), // BSP
184 (X: -2; Y: -7; Width: 128), // MANCUB
185 (X: -1; Y: 4; Width: 128), // SKEL
186 (X: 5; Y: -21; Width: 128), // VILE
187 (X: -1; Y: 0; Width: 32), // FISH
188 (X: 0; Y: -15; Width: 64), // BARREL
189 (X: -2; Y: -26; Width: 128), // ROBO
190 (X: 0; Y: -6; Width: 64)); // MAN
193 gColorEdge: Integer;
194 gAlphaEdge: Byte;
195 gAlphaTriggerLine: Byte;
196 gAlphaTriggerArea: Byte;
197 gAlphaMonsterRect: Byte;
198 gAlphaAreaRect: Byte;
199 drEdge: Array[0..3] of Byte;
200 gPanels: Array of TPanel;
201 gItems: Array of TItem;
202 gAreas: Array of TArea;
203 gMonsters: Array of TMonster;
204 gTriggers: Array of TTrigger;
205 gMapInfo: TMapInfo;
206 MapOffset: TPoint = (X: 0; Y: 0);
207 SelectedObjects: Array of TMapObject = nil;
209 procedure LoadSky(Res: String);
211 function AddItem(Item: TItem): DWORD;
212 function AddPanel(Panel: TPanel): DWORD;
213 function AddArea(Area: TArea): DWORD;
214 function AddMonster(Monster: TMonster): DWORD;
215 function AddTrigger(Trigger: TTrigger): DWORD;
217 procedure RemoveObject(ID: DWORD; ObjectType: Byte);
218 function PanelInShownLayer(PanelType: Word): Boolean;
219 function ObjectInRect(fX, fY: Integer; fWidth, fHeight: Word; ObjectType: Byte; All: Boolean): DWArray;
220 function ObjectCollideLevel(fID: DWORD; ObjectType: Byte; dX, dY: Integer): Boolean;
221 function ObjectCollide(ObjectType: Byte; ID: DWORD; fX, fY: Integer; fWidth, fHeight: Word): Boolean;
222 function ObjectGetRect(ObjectType: Byte; ID: DWORD): TRectWH;
223 procedure MoveObject(ObjectType: Byte; ID: DWORD; dX, dY: Integer);
224 function ResizeObject(ObjectType: Byte; ID: DWORD; dWidth, dHeight: Integer; ResizeDir: Byte): Boolean;
225 function ObjectSelected(ObjectType: Byte; ID: DWORD): Boolean;
227 function GetPanelName(PanelType: Word): String;
228 function GetPanelType(PanelName: String): Word;
229 function GetTriggerName(TriggerType: Byte): String;
230 function GetTriggerType(TriggerName: String): Byte;
232 function IsSpecialTexture(TextureName: String): Boolean;
233 function SpecialTextureID(TextureName: String): DWORD;
235 procedure ClearMap();
236 function SaveMap(Res: String): Pointer;
237 function LoadMap(Res: String): Boolean;
238 function LoadMapOld(_FileName: String): Boolean;
239 procedure DrawMap();
240 procedure LoadData();
241 procedure FreeData();
243 procedure ShiftMapObjects(dx, dy: Integer);
245 implementation
247 uses
248 BinEditor, g_textures, Dialogs, SysUtils, CONFIG, f_main,
249 Forms, Math, f_addresource_texture, WADEDITOR, g_language, g_options;
251 const
252 OLD_ITEM_MEDKIT_SMALL = 1;
253 OLD_ITEM_MEDKIT_LARGE = 2;
254 OLD_ITEM_ARMOR_GREEN = 3;
255 OLD_ITEM_ARMOR_BLUE = 4;
256 OLD_ITEM_SPHERE_BLUE = 5;
257 OLD_ITEM_SPHERE_WHITE = 6;
258 OLD_ITEM_WEAPON_SAW = 7;
259 OLD_ITEM_WEAPON_SHOTGUN1 = 8;
260 OLD_ITEM_WEAPON_SHOTGUN2 = 9;
261 OLD_ITEM_WEAPON_CHAINGUN = 10;
262 OLD_ITEM_WEAPON_ROCKETLAUNCHER = 11;
263 OLD_ITEM_WEAPON_PLASMA = 12;
264 OLD_ITEM_WEAPON_BFG = 13;
265 OLD_ITEM_WEAPON_SUPERPULEMET = 14;
266 OLD_ITEM_AMMO_BULLETS = 15;
267 OLD_ITEM_AMMO_BULLETS_BOX = 16;
268 OLD_ITEM_AMMO_SHELLS = 17;
269 OLD_ITEM_AMMO_SHELLS_BOX = 18;
270 OLD_ITEM_AMMO_ROCKET = 19;
271 OLD_ITEM_AMMO_ROCKET_BOX = 20;
272 OLD_ITEM_AMMO_CELL = 21;
273 OLD_ITEM_AMMO_CELL_BIG = 22;
274 OLD_ITEM_AMMO_BACKPACK = 23;
275 OLD_ITEM_KEY_RED = 24;
276 OLD_ITEM_KEY_GREEN = 25;
277 OLD_ITEM_KEY_BLUE = 26;
278 OLD_ITEM_SUIT = 27;
279 OLD_ITEM_OXYGEN = 28;
280 OLD_ITEM_MEDKIT_BLACK = 29;
281 OLD_ITEM_INVUL = 30;
283 ITEMSCONVERT: Array [OLD_ITEM_MEDKIT_SMALL..OLD_ITEM_INVUL] of Integer =
284 ((ITEM_MEDKIT_SMALL),
285 (ITEM_MEDKIT_LARGE),
286 (ITEM_ARMOR_GREEN),
287 (ITEM_ARMOR_BLUE),
288 (ITEM_SPHERE_BLUE),
289 (ITEM_SPHERE_WHITE),
290 (ITEM_WEAPON_SAW),
291 (ITEM_WEAPON_SHOTGUN1),
292 (ITEM_WEAPON_SHOTGUN2),
293 (ITEM_WEAPON_CHAINGUN),
294 (ITEM_WEAPON_ROCKETLAUNCHER),
295 (ITEM_WEAPON_PLASMA),
296 (ITEM_WEAPON_BFG),
297 (ITEM_WEAPON_SUPERPULEMET),
298 (ITEM_AMMO_BULLETS),
299 (ITEM_AMMO_BULLETS_BOX),
300 (ITEM_AMMO_SHELLS),
301 (ITEM_AMMO_SHELLS_BOX),
302 (ITEM_AMMO_ROCKET),
303 (ITEM_AMMO_ROCKET_BOX),
304 (ITEM_AMMO_CELL),
305 (ITEM_AMMO_CELL_BIG),
306 (ITEM_AMMO_BACKPACK),
307 (ITEM_KEY_RED),
308 (ITEM_KEY_GREEN),
309 (ITEM_KEY_BLUE),
310 (ITEM_SUIT),
311 (ITEM_OXYGEN),
312 (ITEM_MEDKIT_BLACK),
313 (ITEM_INVUL));
315 OldItemSize: Array [ITEM_MEDKIT_SMALL..ITEM_KEY_BLUE] of Array [0..1] of Byte =
316 (((14), (15)), // MEDKIT_SMALL
317 ((28), (19)), // MEDKIT_LARGE
318 ((28), (19)), // MEDKIT_BLACK - not in map generator
319 ((30), (16)), // ARMOR_GREEN
320 ((30), (16)), // ARMOR_BLUE
321 ((24), (24)), // SPHERE_BLUE
322 ((24), (24)), // SPHERE_WHITE
323 ((24), (46)), // SUIT
324 ((14), (27)), // OXYGEN
325 ((25), (25)), // INVUL - not in map generator
326 ((61), (23)), // WEAPON_SAW
327 ((62), (10)), // WEAPON_SHOTGUN1
328 ((52), (12)), // WEAPON_SHOTGUN2
329 ((53), (15)), // WEAPON_CHAINGUN
330 ((61), (15)), // WEAPON_ROCKETLAUNCHER
331 ((53), (14)), // WEAPON_PLASMA
332 ((61), (34)), // WEAPON_BFG
333 ((53), (16)), // WEAPON_SUPERPULEMET
334 (( 9), (10)), // AMMO_BULLETS
335 ((28), (16)), // AMMO_BULLETS_BOX
336 ((15), ( 7)), // AMMO_SHELLS
337 ((32), (12)), // AMMO_SHELLS_BOX
338 ((12), (26)), // AMMO_ROCKET
339 ((54), (21)), // AMMO_ROCKET_BOX
340 ((15), (12)), // AMMO_CELL
341 ((32), (21)), // AMMO_CELL_BIG
342 ((22), (29)), // AMMO_BACKPACK
343 ((16), (16)), // KEY_RED
344 ((16), (16)), // KEY_GREEN
345 ((16), (16))); // KEY_BLUE
347 OldAreaSize: Array [0..1] of Byte = ((34), (56));
349 SKY_TEXTURE = 'SKY';
351 procedure LoadSky(Res: String);
353 fn: String;
355 begin
356 g_DeleteTexture(SKY_TEXTURE);
358 if Res = '' then
359 Exit;
361 g_ProcessResourceStr(Res, @fn, nil, nil);
363 if fn = '' then
364 begin
365 g_ProcessResourceStr(OpenedMap, @fn, nil, nil);
366 fn := fn + Res;
368 else
369 fn := WadsDir + DirectorySeparator + Res;
371 g_CreateTextureWAD(SKY_TEXTURE, fn);
372 end;
374 function AddItem(Item: TItem): DWORD;
376 a: Integer;
377 ok: Boolean;
379 begin
380 ok := False;
381 a := 0;
383 if gItems <> nil then
384 for a := 0 to High(gItems) do
385 if gItems[a].ItemType = ITEM_NONE then
386 begin
387 ok := True;
388 Break;
389 end;
391 if not ok then
392 begin
393 a := Length(gItems);
394 SetLength(gItems, a + 128);
395 end;
397 gItems[a] := Item;
399 Result := a;
400 end;
402 function AddPanel(Panel: TPanel): DWORD;
404 a, b: Integer;
405 ok: Boolean;
407 begin
408 ok := False;
409 a := 0;
410 b := -1;
412 if gPanels <> nil then
413 for a := High(gPanels) downto 0 do
414 if gPanels[a].PanelType = PANEL_NONE then
415 b := a
416 else
417 Break;
419 if b <> -1 then
420 begin
421 a := b;
422 ok := True;
423 end;
425 if not ok then
426 begin
427 a := Length(gPanels);
428 SetLength(gPanels, a + 512);
429 end;
431 gPanels[a] := Panel;
433 Result := a;
434 end;
436 function AddArea(Area: TArea): DWORD;
438 a: Integer;
439 ok: Boolean;
441 begin
442 ok := False;
443 a := 0;
445 if gAreas <> nil then
446 for a := 0 to High(gAreas) do
447 if gAreas[a].AreaType = AREA_NONE then
448 begin
449 ok := True;
450 Break;
451 end;
453 if not ok then
454 begin
455 a := Length(gAreas);
456 SetLength(gAreas, a + 64);
457 end;
459 gAreas[a] := Area;
461 Result := a;
462 end;
464 function AddMonster(Monster: TMonster): DWORD;
466 a: Integer;
467 ok: Boolean;
469 begin
470 ok := False;
471 a := 0;
473 if gMonsters <> nil then
474 for a := 0 to High(gMonsters) do
475 if gMonsters[a].MonsterType = MONSTER_NONE then
476 begin
477 ok := True;
478 Break;
479 end;
481 if not ok then
482 begin
483 a := Length(gMonsters);
484 SetLength(gMonsters, a + 128);
485 end;
487 gMonsters[a] := Monster;
489 Result := a;
490 end;
492 function AddTrigger(Trigger: TTrigger): DWORD;
494 a: Integer;
495 ok: Boolean;
497 begin
498 ok := False;
499 a := 0;
501 if gTriggers <> nil then
502 for a := 0 to High(gTriggers) do
503 if gTriggers[a].TriggerType = TRIGGER_NONE then
504 begin
505 ok := True;
506 Break;
507 end;
509 if not ok then
510 begin
511 a := Length(gTriggers);
512 SetLength(gTriggers, a + 64);
513 end;
515 gTriggers[a] := Trigger;
517 Result := a;
518 end;
520 procedure RemoveObject(ID: DWORD; ObjectType: Byte);
522 a: Integer;
524 begin
525 case ObjectType of
526 OBJECT_PANEL:
527 begin
528 // Убираем ссылки триггеров на эту панель:
529 if gTriggers <> nil then
530 for a := 0 to High(gTriggers) do
531 if gTriggers[a].TriggerType <> 0 then
532 begin
533 if gTriggers[a].TexturePanel = Integer(ID) then
534 gTriggers[a].TexturePanel := -1;
536 if gTriggers[a].TriggerType in [
537 TRIGGER_OPENDOOR, TRIGGER_CLOSEDOOR,
538 TRIGGER_DOOR, TRIGGER_DOOR5, TRIGGER_CLOSETRAP,
539 TRIGGER_TRAP, TRIGGER_LIFTUP, TRIGGER_LIFTDOWN,
540 TRIGGER_LIFT] then
541 if gTriggers[a].Data.PanelID = Integer(ID) then
542 gTriggers[a].Data.PanelID := -1;
544 if (gTriggers[a].TriggerType = TRIGGER_SHOT) and
545 (gTriggers[a].Data.ShotPanelID = Integer(ID)) then
546 gTriggers[a].Data.ShotPanelID := -1;
547 end;
549 gPanels[ID].PanelType := 0;
550 end;
552 OBJECT_ITEM:
553 gItems[ID].ItemType := 0;
555 OBJECT_MONSTER:
556 begin
557 // Убираем ссылки триггеров на этого монстра:
558 if gTriggers <> nil then
559 for a := 0 to High(gTriggers) do
560 if gTriggers[a].TriggerType <> 0 then
561 begin
562 if gTriggers[a].TriggerType in [TRIGGER_PRESS,
563 TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF] then
564 if (gTriggers[a].Data.MonsterID-1 = Integer(ID)) then
565 gTriggers[a].Data.MonsterID := 0;
566 end;
568 gMonsters[ID].MonsterType := 0;
569 end;
571 OBJECT_AREA:
572 gAreas[ID].AreaType := 0;
574 OBJECT_TRIGGER:
575 gTriggers[ID].TriggerType := 0;
576 end;
577 end;
579 function PanelInShownLayer(PanelType: Word): Boolean;
580 begin
581 case PanelType of
582 PANEL_WALL:
583 Result := LayerEnabled[LAYER_WALLS];
585 PANEL_BACK:
586 Result := LayerEnabled[LAYER_BACK];
588 PANEL_FORE:
589 Result := LayerEnabled[LAYER_FOREGROUND];
591 PANEL_STEP:
592 Result := LayerEnabled[LAYER_STEPS];
594 PANEL_WATER, PANEL_ACID1, PANEL_ACID2,
595 PANEL_LIFTUP, PANEL_LIFTDOWN, PANEL_LIFTLEFT, PANEL_LIFTRIGHT,
596 PANEL_OPENDOOR, PANEL_CLOSEDOOR,
597 PANEL_BLOCKMON:
598 Result := LayerEnabled[LAYER_WATER];
600 else
601 Result := False;
602 end;
603 end;
605 function ObjectInRect(fX, fY: Integer; fWidth, fHeight: Word; ObjectType: Byte; All: Boolean): DWArray;
607 a: Integer;
609 begin
610 Result := nil;
612 case ObjectType of
613 OBJECT_PANEL:
614 if gPanels <> nil then
615 for a := High(gPanels) downto 0 do
616 with gPanels[a] do
617 begin
618 if not PanelInShownLayer(gPanels[a].PanelType) then
619 Continue;
621 if g_Collide(X, Y, Width, Height,
622 fX, fY, fWidth, fHeight) then
623 begin
624 SetLength(Result, Length(Result)+1);
625 Result[High(Result)] := a;
627 if not All then
628 Break;
629 end;
630 end;
632 OBJECT_ITEM:
633 if LayerEnabled[LAYER_ITEMS] and (gItems <> nil) then
634 for a := High(gItems) downto 0 do
635 with gItems[a] do
636 if (ItemType <> ITEM_NONE) and
637 g_Collide(X, Y, ItemSize[ItemType][0], ItemSize[ItemType][1],
638 fX, fY, fWidth, fHeight) then
639 begin
640 SetLength(Result, Length(Result)+1);
641 Result[High(Result)] := a;
643 if not All then
644 Break;
645 end;
647 OBJECT_MONSTER:
648 if LayerEnabled[LAYER_MONSTERS] and (gMonsters <> nil) then
649 for a := High(gMonsters) downto 0 do
650 if gMonsters[a].MonsterType <> MONSTER_NONE then
651 with MonsterSize[gMonsters[a].MonsterType] do
652 if (gMonsters[a].MonsterType <> 0) and
653 g_Collide(gMonsters[a].X, gMonsters[a].Y, Width, Height,
654 fX, fY, fWidth, fHeight) then
655 begin
656 SetLength(Result, Length(Result)+1);
657 Result[High(Result)] := a;
659 if not All then
660 Break;
661 end;
663 OBJECT_AREA:
664 if LayerEnabled[LAYER_AREAS] and (gAreas <> nil) then
665 for a := High(gAreas) downto 0 do
666 if gAreas[a].AreaType <> AREA_NONE then
667 with AreaSize[gAreas[a].AreaType] do
668 if (gAreas[a].AreaType <> 0) and
669 g_Collide(gAreas[a].X, gAreas[a].Y, Width, Height,
670 fX, fY, fWidth, fHeight) then
671 begin
672 SetLength(Result, Length(Result)+1);
673 Result[High(Result)] := a;
675 if not All then
676 Break;
677 end;
679 OBJECT_TRIGGER:
680 if LayerEnabled[LAYER_TRIGGERS] and (gTriggers <> nil) then
681 for a := High(gTriggers) downto 0 do
682 if gTriggers[a].TriggerType <> TRIGGER_NONE then
683 with gTriggers[a] do
684 begin
685 if (TriggerType <> 0) and
686 g_Collide(X, Y, Width, Height,
687 fX, fY, fWidth, fHeight) then
688 begin
689 SetLength(Result, Length(Result)+1);
690 Result[High(Result)] := a;
692 if not All then
693 Break;
694 end;
695 end;
696 end;
697 end;
699 function ObjectCollideLevel(fID: DWORD; ObjectType: Byte; dX, dY: Integer): Boolean;
701 PanelID: DWORD;
703 begin
704 Result := False;
705 PanelID := DWORD(-1);
707 case ObjectType of
708 OBJECT_PANEL:
709 with gPanels[fID] do
710 Result := (PanelID <> fID) and
711 g_CollideLevel2(X+dX, Y+dY,
712 Width, Height,
713 fID, PanelID);
715 OBJECT_ITEM:
716 with gItems[fID] do
717 Result := g_CollideLevel(X+dX, Y+dY,
718 ItemSize[ItemType][0], ItemSize[ItemType][1]);
720 OBJECT_MONSTER:
721 with MonsterSize[gMonsters[fID].MonsterType] do
722 Result := g_CollideLevel(gMonsters[fID].X+dX, gMonsters[fID].Y+dY,
723 Width, Height);
725 OBJECT_AREA:
726 with AreaSize[gAreas[fID].AreaType] do
727 Result := g_CollideLevel(gAreas[fID].X+dX, gAreas[fID].Y+dY,
728 Width, Height);
730 OBJECT_TRIGGER:
731 with gTriggers[fID] do
732 Result := g_CollideLevel(X+dX, Y+dY,
733 Width, Height);
734 end;
735 end;
737 function ObjectCollide(ObjectType: Byte; ID: DWORD; fX, fY: Integer; fWidth, fHeight: Word): Boolean;
738 begin
739 Result := False;
741 case ObjectType of
742 OBJECT_PANEL:
743 with gPanels[ID] do
744 Result := g_Collide(X, Y, Width, Height,
745 fX, fY, fWidth, fHeight);
747 OBJECT_ITEM:
748 with gItems[ID] do
749 Result := g_Collide(X, Y, ItemSize[ItemType][0], ItemSize[ItemType][1],
750 fX, fY, fWidth, fHeight);
752 OBJECT_MONSTER:
753 with MonsterSize[gMonsters[ID].MonsterType] do
754 Result := g_Collide(gMonsters[ID].X, gMonsters[ID].Y, Width, Height,
755 fX, fY, fWidth, fHeight);
757 OBJECT_AREA:
758 with AreaSize[gAreas[ID].AreaType] do
759 Result := g_Collide(gAreas[ID].X, gAreas[ID].Y, Width, Height,
760 fX, fY, fWidth, fHeight);
762 OBJECT_TRIGGER:
763 with gTriggers[ID] do
764 Result := g_Collide(X, Y, Width, Height,
765 fX, fY, fWidth, fHeight);
766 end;
767 end;
769 function ObjectGetRect(ObjectType: Byte; ID: DWORD): TRectWH;
770 begin
771 case ObjectType of
772 OBJECT_PANEL:
773 with gPanels[ID] do
774 begin
775 Result.X := X;
776 Result.Y := Y;
777 Result.Width := Width;
778 Result.Height := Height;
779 end;
781 OBJECT_ITEM:
782 with gItems[ID] do
783 begin
784 Result.X := X;
785 Result.Y := Y;
786 Result.Width := ItemSize[ItemType][0];
787 Result.Height := ItemSize[ItemType][1];
788 end;
790 OBJECT_MONSTER:
791 with MonsterSize[gMonsters[ID].MonsterType] do
792 begin
793 Result.X := gMonsters[ID].X;
794 Result.Y := gMonsters[ID].Y;
795 Result.Width := Width;
796 Result.Height := Height;
797 end;
799 OBJECT_AREA:
800 with AreaSize[gAreas[ID].AreaType] do
801 begin
802 Result.X := gAreas[ID].X;
803 Result.Y := gAreas[ID].Y;
804 Result.Width := Width;
805 Result.Height := Height;
806 end;
808 OBJECT_TRIGGER:
809 with gTriggers[ID] do
810 begin
811 Result.X := X;
812 Result.Y := Y;
813 Result.Width := Width;
814 Result.Height := Height;
815 end;
817 else
818 begin
819 Result.X := 0;
820 Result.Y := 0;
821 Result.Width := 0;
822 Result.Height := 0;
823 end;
824 end;
825 end;
827 procedure MoveObject(ObjectType: Byte; ID: DWORD; dX, dY: Integer);
828 begin
829 case ObjectType of
830 OBJECT_PANEL:
831 with gPanels[ID] do
832 begin
833 X := X + dX;
834 Y := Y + dY;
835 end;
837 OBJECT_ITEM:
838 with gItems[ID] do
839 begin
840 X := X + dX;
841 Y := Y + dY;
842 end;
844 OBJECT_MONSTER:
845 with gMonsters[ID] do
846 begin
847 X := X + dX;
848 Y := Y + dY;
849 end;
851 OBJECT_AREA:
852 with gAreas[ID] do
853 begin
854 X := X + dX;
855 Y := Y + dY;
856 end;
858 OBJECT_TRIGGER:
859 with gTriggers[ID] do
860 begin
861 X := X + dX;
862 Y := Y + dY;
863 end;
864 end;
865 end;
867 function ResizeObject(ObjectType: Byte; ID: DWORD; dWidth, dHeight: Integer; ResizeDir: Byte): Boolean;
868 begin
869 Result := True;
870 case ObjectType of
871 OBJECT_PANEL:
872 with gPanels[ID] do
873 begin
874 if Width >= -dWidth then
875 Width := Width+dWidth
876 else
877 begin
878 Width := 0;
879 Result := False;
880 Exit;
881 end;
883 if Height >= -dHeight then
884 Height := Height+dHeight
885 else
886 begin
887 Height := 0;
888 Result := False;
889 Exit;
890 end;
892 case ResizeDir of
893 2: Y := Y - dHeight;
894 4: X := X - dWidth;
895 end;
896 end;
898 OBJECT_ITEM, OBJECT_MONSTER, OBJECT_AREA:
899 Exit;
901 OBJECT_TRIGGER:
902 with gTriggers[ID] do
903 begin
904 if Width >= -dWidth then
905 Width := Width+dWidth
906 else
907 begin
908 Width := 0;
909 Result := False;
910 Exit;
911 end;
913 if Height >= -dHeight then
914 Height := Height+dHeight
915 else
916 begin
917 Height := 0;
918 Result := False;
919 Exit;
920 end;
922 case ResizeDir of
923 2: Y := Y - dHeight;
924 4: X := X - dWidth;
925 end;
926 end;
927 end;
928 end;
930 function ObjectSelected(ObjectType: Byte; ID: DWORD): Boolean;
932 a: Integer;
934 begin
935 Result := False;
937 if SelectedObjects <> nil then
938 for a := 0 to High(SelectedObjects) do
939 if SelectedObjects[a].Live and
940 (SelectedObjects[a].ObjectType = ObjectType) and
941 (SelectedObjects[a].ID = ID) then
942 begin
943 Result := True;
944 Break;
945 end;
946 end;
948 function GetPanelName(PanelType: Word): String;
949 begin
950 Result := '';
952 case PanelType of
953 PANEL_WALL: Result := PANELNAMES[0];
954 PANEL_BACK: Result := PANELNAMES[1];
955 PANEL_FORE: Result := PANELNAMES[2];
956 PANEL_OPENDOOR: Result := PANELNAMES[3];
957 PANEL_CLOSEDOOR: Result := PANELNAMES[4];
958 PANEL_STEP: Result := PANELNAMES[5];
959 PANEL_WATER: Result := PANELNAMES[6];
960 PANEL_ACID1: Result := PANELNAMES[7];
961 PANEL_ACID2: Result := PANELNAMES[8];
962 PANEL_LIFTUP: Result := PANELNAMES[9];
963 PANEL_LIFTDOWN: Result := PANELNAMES[10];
964 PANEL_LIFTLEFT: Result := PANELNAMES[11];
965 PANEL_LIFTRIGHT: Result := PANELNAMES[12];
966 PANEL_BLOCKMON: Result := PANELNAMES[13];
967 else Assert(False);
968 end;
969 end;
971 function GetPanelType(PanelName: String): Word;
972 begin
973 Result := 0;
975 if PanelName = PANELNAMES[0] then
976 Result := PANEL_WALL
977 else if PanelName = PANELNAMES[1] then
978 Result := PANEL_BACK
979 else if PanelName = PANELNAMES[2] then
980 Result := PANEL_FORE
981 else if PanelName = PANELNAMES[3] then
982 Result := PANEL_OPENDOOR
983 else if PanelName = PANELNAMES[4] then
984 Result := PANEL_CLOSEDOOR
985 else if PanelName = PANELNAMES[5] then
986 Result := PANEL_STEP
987 else if PanelName = PANELNAMES[6] then
988 Result := PANEL_WATER
989 else if PanelName = PANELNAMES[7] then
990 Result := PANEL_ACID1
991 else if PanelName = PANELNAMES[8] then
992 Result := PANEL_ACID2
993 else if PanelName = PANELNAMES[9] then
994 Result := PANEL_LIFTUP
995 else if PanelName = PANELNAMES[10] then
996 Result := PANEL_LIFTDOWN
997 else if PanelName = PANELNAMES[11] then
998 Result := PANEL_LIFTLEFT
999 else if PanelName = PANELNAMES[12] then
1000 Result := PANEL_LIFTRIGHT
1001 else if PanelName = PANELNAMES[13] then
1002 Result := PANEL_BLOCKMON;
1004 Assert(Result <> 0);
1005 end;
1007 function GetTriggerName(TriggerType: Byte): String;
1008 begin
1009 if TriggerType in [TRIGGER_EXIT..TRIGGER_MAX] then
1010 Result := TriggerNames[TriggerType]
1011 else
1012 Assert(False);
1013 end;
1015 function GetTriggerType(TriggerName: String): Byte;
1017 i: Integer;
1019 begin
1020 Result := TRIGGER_NONE;
1021 for i := TRIGGER_EXIT to TRIGGER_MAX do
1022 if TriggerNames[i] = TriggerName then
1023 begin
1024 Result := i;
1025 Exit;
1026 end;
1028 Assert(False);
1029 end;
1031 function IsSpecialTexture(TextureName: string): Boolean;
1032 begin
1033 Result := (TextureName = TEXTURE_NAME_WATER) or
1034 (TextureName = TEXTURE_NAME_ACID1) or
1035 (TextureName = TEXTURE_NAME_ACID2);
1036 end;
1038 function SpecialTextureID(TextureName: string): DWORD;
1039 begin
1040 Assert(IsSpecialTexture(TextureName));
1042 Result := 0;
1044 if TextureName = TEXTURE_NAME_WATER then
1045 Result := TEXTURE_SPECIAL_WATER
1046 else
1047 if TextureName = TEXTURE_NAME_ACID1 then
1048 Result := TEXTURE_SPECIAL_ACID1
1049 else
1050 if TextureName = TEXTURE_NAME_ACID2 then
1051 Result := TEXTURE_SPECIAL_ACID2;
1052 end;
1054 function SaveMap(Res: String): Pointer;
1056 WAD: TWADEditor_1;
1057 MapWriter: TMapWriter_1;
1058 textures: TTexturesRec1Array;
1059 panels: TPanelsRec1Array;
1060 items: TItemsRec1Array;
1061 areas: TAreasRec1Array;
1062 monsters: TMonsterRec1Array;
1063 triggers: TTriggersRec1Array;
1064 header: TMapHeaderRec_1;
1065 a, b, c: Integer;
1066 s: String;
1067 PanelTable: Array of Array [0..1] of Word;
1068 MonsterTable: Array of Array [0..1] of Word;
1069 Data: Pointer;
1070 FileName, SectionName, ResName: String;
1071 Len: LongWord;
1073 begin
1074 WAD := nil;
1075 textures := nil;
1076 panels := nil;
1077 items := nil;
1078 areas := nil;
1079 monsters := nil;
1080 triggers := nil;
1081 PanelTable := nil;
1082 MonsterTable := nil;
1083 Data := nil;
1084 Len := 0;
1086 // Открываем WAD, если надо:
1087 if Res <> '' then
1088 begin
1089 WAD := TWADEditor_1.Create();
1090 g_ProcessResourceStr(Res, FileName, SectionName, ResName);
1091 if not WAD.ReadFile(FileName) then
1092 WAD.FreeWAD();
1094 WAD.CreateImage();
1095 end;
1097 MapWriter := TMapWriter_1.Create();
1099 // Сохраняем заголовок:
1100 with header do
1101 begin
1102 ZeroMemory(@header, SizeOf(TMapHeaderRec_1));
1104 s := utf2win(gMapInfo.Name);
1105 if s <> '' then
1106 CopyMemory(@MapName[0], @s[1], Min(32, Length(s)));
1108 s := utf2win(gMapInfo.Description);
1109 if s <> '' then
1110 CopyMemory(@MapDescription[0], @s[1], Min(256, Length(s)));
1112 s := utf2win(gMapInfo.Author);
1113 if s <> '' then
1114 CopyMemory(@MapAuthor[0], @s[1], Min(32, Length(s)));
1116 s := utf2win(gMapInfo.MusicName);
1117 if s <> '' then
1118 CopyMemory(@MusicName[0], @s[1], Min(64, Length(s)));
1120 s := utf2win(gMapInfo.SkyName);
1121 if s <> '' then
1122 CopyMemory(@SkyName[0], @s[1], Min(64, Length(s)));
1124 Width := gMapInfo.Width;
1125 Height := gMapInfo.Height;
1126 end;
1128 MapWriter.AddHeader(header);
1130 // Сохраняем названия текстур:
1131 if MainForm.lbTextureList.Items.Count > 0 then
1132 begin
1133 for a := 0 to MainForm.lbTextureList.Items.Count-1 do
1134 begin
1135 SetLength(textures, Length(textures)+1);
1136 s := utf2win(MainForm.lbTextureList.Items[a]);
1137 CopyMemory(@textures[High(textures)].Resource[0], @s[1], Min(64, Length(s)));
1138 if g_GetTextureFlagByName(MainForm.lbTextureList.Items[a]) = 1 then
1139 textures[High(textures)].Anim := 1
1140 else
1141 textures[High(textures)].Anim := 0;
1142 end;
1144 MapWriter.AddTextures(textures);
1145 end;
1147 // Сохраняем панели:
1148 if gPanels <> nil then
1149 begin
1150 c := 0;
1152 for a := 0 to High(gPanels) do
1153 if gPanels[a].PanelType <> 0 then
1154 begin
1155 SetLength(PanelTable, Length(PanelTable)+1);
1156 PanelTable[High(PanelTable)][0] := a;
1157 PanelTable[High(PanelTable)][1] := c;
1158 c := c + 1;
1160 SetLength(panels, Length(panels)+1);
1162 with panels[High(panels)] do
1163 begin
1164 X := gPanels[a].X;
1165 Y := gPanels[a].Y;
1166 Width := gPanels[a].Width;
1167 Height := gPanels[a].Height;
1168 PanelType := gPanels[a].PanelType;
1169 Alpha := gPanels[a].Alpha;
1171 TextureNum := 0;
1172 Flags := 0;
1174 if WordBool(gPanels[a].PanelType and
1175 (PANEL_WATER or PANEL_ACID1 or PANEL_ACID2)) then
1176 Flags := PANEL_FLAG_WATERTEXTURES;
1178 // Может быть текстура:
1179 if not WordBool(gPanels[a].PanelType and
1180 (PANEL_LIFTUP or PANEL_LIFTDOWN or PANEL_LIFTLEFT or PANEL_LIFTRIGHT or PANEL_BLOCKMON)) then
1181 begin
1182 if gPanels[a].Blending then
1183 Flags := Flags or PANEL_FLAG_BLENDING;
1184 if gPanels[a].TextureID = TEXTURE_SPECIAL_NONE then
1185 Flags := Flags or PANEL_FLAG_HIDE;
1187 // Номер текстуры в списке текстур:
1188 if gPanels[a].TextureID <> TEXTURE_SPECIAL_NONE then
1189 for b := 0 to High(textures) do
1190 if utf2win(gPanels[a].TextureName) = textures[b].Resource then
1191 begin
1192 TextureNum := b;
1193 Break;
1194 end;
1195 end;
1196 end;
1197 end;
1199 MapWriter.AddPanels(panels);
1200 end;
1202 // Сохраняем предметы:
1203 if gItems <> nil then
1204 begin
1205 for a := 0 to High(gItems) do
1206 if gItems[a].ItemType <> 0 then
1207 begin
1208 SetLength(items, Length(items)+1);
1210 with items[High(items)] do
1211 begin
1212 X := gItems[a].X;
1213 Y := gItems[a].Y;
1214 ItemType := gItems[a].ItemType;
1215 if gItems[a].OnlyDM then
1216 Options := Options or ITEM_OPTION_ONLYDM;
1217 if gItems[a].Fall then
1218 Options := Options or ITEM_OPTION_FALL;
1219 end;
1220 end;
1222 MapWriter.AddItems(items);
1223 end;
1225 // Сохраняем монстров:
1226 if gMonsters <> nil then
1227 begin
1228 c := 0;
1230 for a := 0 to High(gMonsters) do
1231 if gMonsters[a].MonsterType <> 0 then
1232 begin
1233 SetLength(MonsterTable, Length(MonsterTable)+1);
1234 MonsterTable[High(MonsterTable)][0] := a;
1235 MonsterTable[High(MonsterTable)][1] := c;
1236 c := c + 1;
1238 SetLength(monsters, Length(monsters)+1);
1240 with monsters[High(monsters)] do
1241 begin
1242 X := gMonsters[a].X;
1243 Y := gMonsters[a].Y;
1244 MonsterType := gMonsters[a].MonsterType;
1245 Direction := Ord(gMonsters[a].Direction);
1246 end;
1247 end;
1249 MapWriter.AddMonsters(monsters);
1250 end;
1252 // Сохраняем области:
1253 if gAreas <> nil then
1254 begin
1255 for a := 0 to High(gAreas) do
1256 if gAreas[a].AreaType <> 0 then
1257 begin
1258 SetLength(areas, Length(areas)+1);
1260 with areas[High(areas)] do
1261 begin
1262 X := gAreas[a].X;
1263 Y := gAreas[a].Y;
1264 AreaType := gAreas[a].AreaType;
1265 Direction := Ord(gAreas[a].Direction);
1266 end;
1267 end;
1269 MapWriter.AddAreas(areas);
1270 end;
1272 // Сохраняем триггеры:
1273 if gTriggers <> nil then
1274 begin
1275 for a := 0 to High(gTriggers) do
1276 if gTriggers[a].TriggerType <> 0 then
1277 begin
1278 SetLength(triggers, Length(triggers)+1);
1280 with triggers[High(triggers)] do
1281 begin
1282 X := gTriggers[a].X;
1283 Y := gTriggers[a].Y;
1284 Width := gTriggers[a].Width;
1285 Height := gTriggers[a].Height;
1286 Enabled := Byte(gTriggers[a].Enabled);
1287 TexturePanel := -1;
1288 TriggerType := gTriggers[a].TriggerType;
1289 ActivateType := gTriggers[a].ActivateType;
1290 Keys := gTriggers[a].Key;
1291 DATA := gTriggers[a].Data.Default;
1293 if PanelTable <> nil then
1294 begin
1295 // Ищем номер панели, которой этот триггер меняет текстуру:
1296 if gTriggers[a].TexturePanel <> -1 then
1297 begin
1298 for c := 0 to High(PanelTable) do
1299 if PanelTable[c][0] = gTriggers[a].TexturePanel then
1300 TexturePanel := PanelTable[c][1];
1301 end;
1303 // Ищем номер панели, которую меняет этот триггер:
1304 if gTriggers[a].TriggerType in [
1305 TRIGGER_OPENDOOR, TRIGGER_CLOSEDOOR, TRIGGER_DOOR,
1306 TRIGGER_DOOR5, TRIGGER_CLOSETRAP, TRIGGER_TRAP,
1307 TRIGGER_LIFTUP, TRIGGER_LIFTDOWN, TRIGGER_LIFT] then
1308 if TTriggerData(DATA).PanelID <> -1 then
1309 for c := 0 to High(PanelTable) do
1310 if PanelTable[c][0] = TTriggerData(DATA).PanelID then
1311 begin
1312 TTriggerData(DATA).PanelID := PanelTable[c][1];
1313 Break;
1314 end;
1316 // Ищем номер панели индикации, которой этот триггер меняет текстуру:
1317 if (gTriggers[a].TriggerType = TRIGGER_SHOT) and
1318 (TTriggerData(DATA).ShotPanelID <> -1) then
1319 begin
1320 for c := 0 to High(PanelTable) do
1321 if PanelTable[c][0] = TTriggerData(DATA).ShotPanelID then
1322 TTriggerData(DATA).ShotPanelID := PanelTable[c][1];
1323 end;
1324 end;
1326 if MonsterTable <> nil then
1327 begin
1328 // Ищем номер монстра - условие активации триггера:
1329 if gTriggers[a].TriggerType in [
1330 TRIGGER_PRESS, TRIGGER_ON,
1331 TRIGGER_OFF, TRIGGER_ONOFF] then
1332 if TTriggerData(DATA).MonsterID <> 0 then
1333 for c := 0 to High(MonsterTable) do
1334 if MonsterTable[c][0] = TTriggerData(DATA).MonsterID-1 then
1335 begin
1336 TTriggerData(DATA).MonsterID := MonsterTable[c][1]+1;
1337 Break;
1338 end;
1339 end;
1340 end;
1341 end;
1343 MapWriter.AddTriggers(triggers);
1344 end;
1346 // Сохраняем карту в память:
1347 Len := MapWriter.SaveMap(Data);
1349 MapWriter.Free();
1351 // Записываем в WAD, если надо:
1352 if Res <> '' then
1353 begin
1354 s := utf2win(ResName);
1355 WAD.RemoveResource('', s);
1356 WAD.AddResource(Data, Len, s, '');
1357 WAD.SaveTo(FileName);
1359 FreeMem(Data);
1360 WAD.Free();
1362 Result := nil;
1364 else
1365 Result := Data;
1366 end;
1368 procedure AddTexture(res: String; Error: Boolean);
1370 a: Integer;
1371 begin
1372 with MainForm.lbTextureList do
1373 begin
1374 for a := 0 to Count-1 do
1375 if Items[a] = res then
1376 Exit;
1378 if Error and (slInvalidTextures.IndexOf(res) = -1) then
1379 slInvalidTextures.Add(res);
1380 Items.Add(res);
1381 end;
1382 end;
1384 function LoadMap(Res: String): Boolean;
1386 WAD: TWADEditor_1;
1387 MapReader: TMapReader_1;
1388 Header: TMapHeaderRec_1;
1389 textures: TTexturesRec1Array;
1390 panels: TPanelsRec1Array;
1391 items: TItemsRec1Array;
1392 monsters: TMonsterRec1Array;
1393 areas: TAreasRec1Array;
1394 triggers: TTriggersRec1Array;
1395 panel: TPanel;
1396 item: TItem;
1397 monster: TMonster;
1398 area: TArea;
1399 trigger: TTrigger;
1400 a: Integer;
1401 Data: Pointer;
1402 Width, Height, m: Word;
1403 FileName, SectionName, ResName, _fn: String;
1404 TextureRes, ustr: String;
1405 pData: Pointer;
1406 Len, FrameLen: Integer;
1407 Error: Boolean;
1408 NoTextureID: DWORD;
1409 NW, NH: Word;
1410 begin
1411 Result := False;
1412 pData := nil;
1413 Len := 0;
1414 Data := nil;
1415 FrameLen := 0;
1416 Width := 0;
1417 Height := 0;
1418 NoTextureID := 0;
1419 NW := 0;
1420 NH := 0;
1422 MainForm.pbLoad.Position := 0;
1423 MainForm.lLoad.Caption := MsgLoadWad;
1424 Application.ProcessMessages();
1426 // Открываем WAD:
1427 WAD := TWADEditor_1.Create();
1428 g_ProcessResourceStr(Res, FileName, SectionName, ResName);
1430 if not WAD.ReadFile(FileName) then
1431 begin
1432 WAD.Free();
1433 Exit;
1434 end;
1436 // Читаем ресурс карты:
1437 if not WAD.GetResource('', utf2win(ResName), pData, Len) then
1438 begin
1439 WAD.Free();
1440 Exit;
1441 end;
1443 WAD.Free();
1445 MapReader := TMapReader_1.Create();
1447 MainForm.lLoad.Caption := MsgLoadMap;
1448 Application.ProcessMessages();
1450 MapReader.LoadMap(pData);
1452 // Загружаем текстуры:
1453 textures := MapReader.GetTextures();
1455 if textures <> nil then
1456 begin
1457 MainForm.pbLoad.Position := 0;
1458 MainForm.pbLoad.Max := Length(textures);
1459 MainForm.lLoad.Caption := MsgLoadTextures;
1461 for a := 0 to High(textures) do
1462 begin
1463 MainForm.pbLoad.StepIt();
1464 Application.ProcessMessages();
1465 ustr := win2utf(textures[a].Resource);
1467 if IsSpecialTexture(ustr) then
1468 begin
1469 AddTexture(ustr, False);
1470 Continue;
1471 end;
1473 g_ProcessResourceStr(ustr, @_fn, nil, nil);
1475 if _fn = '' then
1476 TextureRes := FileName + ustr
1477 else
1478 TextureRes := WadsDir + DirectorySeparator + ustr;
1480 Error := False;
1482 if not ByteBool(textures[a].Anim) then
1483 begin // Обычная текстура
1484 if not g_CreateTextureWAD(ustr, TextureRes) then
1485 begin
1486 e_WriteLog(Format('g_CreateTextureWAD() error, res=%s',
1487 [ustr]), MSG_WARNING);
1488 Error := True;
1489 end;
1491 AddTexture(ustr, Error);
1493 else // Anim
1494 begin // Анимированная текстура
1495 if not GetFrame(TextureRes, Data, FrameLen, Width, Height) then
1496 begin // Кадры
1497 e_WriteLog(Format('GetFrame() error, res=%s',
1498 [ustr]), MSG_WARNING);
1499 Error := True;
1500 end;
1502 if not g_CreateTextureMemorySize(Data, FrameLen, ustr, 0, 0, Width, Height, 1) then
1503 begin // Сама текстура
1504 e_WriteLog(Format('g_CreateTextureMemorySize() error, res=%s',
1505 [ustr]), MSG_WARNING);
1506 Error := True;
1507 end;
1509 AddTexture(ustr, Error);
1510 end;
1511 end;
1512 end;
1514 // Загружаем панели:
1515 panels := MapReader.GetPanels();
1517 if panels <> nil then
1518 begin
1519 MainForm.pbLoad.Position := 0;
1520 MainForm.pbLoad.Max := Length(panels);
1521 MainForm.lLoad.Caption := MsgLoadPanels;
1523 for a := 0 to High(panels) do
1524 begin
1525 MainForm.pbLoad.StepIt();
1526 Application.ProcessMessages();
1528 panel.X := panels[a].X;
1529 panel.Y := panels[a].Y;
1530 panel.Height := panels[a].Height;
1531 panel.Width := panels[a].Width;
1532 panel.PanelType := panels[a].PanelType;
1533 panel.Alpha := panels[a].Alpha;
1535 panel.Blending := ByteBool(panels[a].Flags and PANEL_FLAG_BLENDING);
1537 panel.TextureWidth := 0;
1538 panel.TextureHeight := 0;
1539 panel.TextureName := '';
1540 panel.TextureID := TEXTURE_SPECIAL_NONE;
1542 m := PANEL_WALL or PANEL_BACK or PANEL_FORE or PANEL_STEP or
1543 PANEL_OPENDOOR or PANEL_CLOSEDOOR;
1545 if ByteBool(panels[a].Flags and PANEL_FLAG_WATERTEXTURES) then
1546 m := m or PANEL_WATER or PANEL_ACID1 or PANEL_ACID2;
1548 // Если панель видима:
1549 if WordBool(panel.PanelType and m) and
1550 (not (ByteBool(panels[a].Flags and PANEL_FLAG_HIDE))) then
1551 begin
1552 ustr := win2utf(textures[panels[a].TextureNum].Resource);
1553 if not IsSpecialTexture(ustr) then
1554 begin // Текстура
1555 if g_GetTexture(ustr, panel.TextureID) then
1556 g_GetTextureSizeByID(panel.TextureID, panel.TextureWidth, panel.TextureHeight)
1557 else begin
1558 panel.TextureWidth := 1;
1559 panel.TextureHeight := 1;
1560 if g_GetTexture('NOTEXTURE', NoTextureID) then
1561 begin
1562 panel.TextureID := TEXTURE_SPECIAL_NOTEXTURE;
1563 g_GetTextureSizeByID(NoTextureID, NW, NH);
1564 panel.TextureWidth := NW;
1565 panel.TextureHeight := NH;
1566 end;
1567 end;
1569 else // Спец. текстура
1570 panel.TextureID := SpecialTextureID(ustr);
1572 panel.TextureName := ustr;
1573 end;
1575 // Жидкость без текстуры:
1576 if WordBool(panel.PanelType and (PANEL_WATER or PANEL_ACID1 or PANEL_ACID2)) and
1577 (not ByteBool(panels[a].Flags and PANEL_FLAG_WATERTEXTURES)) then
1578 begin
1579 case panel.PanelType of
1580 PANEL_WATER: panel.TextureName := TEXTURE_NAME_WATER;
1581 PANEL_ACID1: panel.TextureName := TEXTURE_NAME_ACID1;
1582 PANEL_ACID2: panel.TextureName := TEXTURE_NAME_ACID2;
1583 end;
1585 panel.TextureID := SpecialTextureID(panel.TextureName);
1586 AddTexture(panel.TextureName, False);
1587 end;
1589 AddPanel(panel);
1590 end;
1591 end;
1593 // Загружаем предметы:
1594 items := MapReader.GetItems();
1596 if items <> nil then
1597 begin
1598 MainForm.pbLoad.Position := 0;
1599 MainForm.pbLoad.Max := Length(items);
1600 MainForm.lLoad.Caption := MsgLoadItems;
1602 for a := 0 to High(items) do
1603 begin
1604 MainForm.pbLoad.StepIt();
1605 Application.ProcessMessages();
1607 item.X := items[a].X;
1608 item.Y := items[a].Y;
1609 item.ItemType := items[a].ItemType;
1610 item.OnlyDM := ByteBool(items[a].Options and ITEM_OPTION_ONLYDM);
1611 item.Fall := ByteBool(items[a].Options and ITEM_OPTION_FALL);
1613 AddItem(item);
1614 end;
1615 end;
1617 // Загружаем монстров:
1618 monsters := MapReader.GetMonsters();
1620 if monsters <> nil then
1621 begin
1622 MainForm.pbLoad.Position := 0;
1623 MainForm.pbLoad.Max := Length(monsters);
1624 MainForm.lLoad.Caption := MsgLoadMonsters;
1626 for a := 0 to High(monsters) do
1627 begin
1628 MainForm.pbLoad.StepIt();
1629 Application.ProcessMessages();
1631 monster.X := monsters[a].X;
1632 monster.Y := monsters[a].Y;
1633 monster.MonsterType := monsters[a].MonsterType;
1634 monster.Direction := TDirection(monsters[a].Direction);
1636 AddMonster(monster);
1637 end;
1638 end;
1640 // Загружаем области:
1641 areas := MapReader.GetAreas();
1643 if areas <> nil then
1644 begin
1645 MainForm.pbLoad.Position := 0;
1646 MainForm.pbLoad.Max := Length(areas);
1647 MainForm.lLoad.Caption := MsgLoadAreas;
1649 for a := 0 to High(areas) do
1650 begin
1651 MainForm.pbLoad.StepIt();
1652 Application.ProcessMessages();
1654 area.X := areas[a].X;
1655 area.Y := areas[a].Y;
1656 area.AreaType := areas[a].AreaType;
1657 area.Direction := TDirection(areas[a].Direction);
1659 AddArea(area);
1660 end;
1661 end;
1663 // Загружаем триггеры:
1664 triggers := MapReader.GetTriggers();
1666 if triggers <> nil then
1667 begin
1668 MainForm.pbLoad.Position := 0;
1669 MainForm.pbLoad.Max := Length(triggers);
1670 MainForm.lLoad.Caption := MsgLoadTriggers;
1672 for a := 0 to High(triggers) do
1673 begin
1674 MainForm.pbLoad.StepIt();
1675 Application.ProcessMessages();
1677 trigger.X := triggers[a].X;
1678 trigger.Y := triggers[a].Y;
1679 trigger.Width := triggers[a].Width;
1680 trigger.Height := triggers[a].Height;
1682 trigger.Enabled := ByteBool(triggers[a].Enabled);
1683 trigger.TexturePanel := triggers[a].TexturePanel;
1684 trigger.TriggerType := triggers[a].TriggerType;
1685 trigger.ActivateType := triggers[a].ActivateType;
1686 trigger.Key := triggers[a].Keys;
1687 trigger.Data.Default := triggers[a].DATA;
1689 AddTrigger(trigger);
1690 end;
1691 end;
1693 // Загружаем заголовок карты:
1694 Header := MapReader.GetMapHeader();
1696 gMapInfo.FileName := FileName;
1698 with gMapInfo do
1699 begin
1700 MapName := ResName;
1701 Name := win2utf(Header.MapName);
1702 Description := win2utf(Header.MapDescription);
1703 Author := win2utf(Header.MapAuthor);
1704 MusicName := win2utf(Header.MusicName);
1705 SkyName := win2utf(Header.SkyName);
1706 Height := Header.Height;
1707 Width := Header.Width;
1708 end;
1710 LoadSky(gMapInfo.SkyName);
1712 textures := nil;
1713 panels := nil;
1714 items := nil;
1715 areas := nil;
1716 triggers := nil;
1718 MapReader.Free();
1719 FreeMem(pData);
1721 Result := True;
1722 end;
1724 function LoadMapOld(_FileName: String): Boolean;
1725 const
1726 TexturePrefix = 'standart.wad:STDTEXTURES\';
1727 DefaultMusRes = 'standart.wad:STDMUS\MUS1';
1728 DefaultSkyRes = 'standart.wad:STDSKY\SKY0';
1731 map: TConfig;
1732 i, a: Integer;
1733 s, section: String;
1734 panel: TPanel;
1735 item: TItem;
1736 area: TArea;
1738 begin
1739 Result := False;
1741 if not FileExists(_FileName) then
1742 Exit;
1744 // Открытие карты:
1745 MainForm.pbLoad.Position := 0;
1746 MainForm.lLoad.Caption := MsgLoadMap;;
1747 Application.ProcessMessages();
1749 map := TConfig.CreateFile(_FileName);
1751 // Чтение текстур:
1752 i := map.ReadInt('MapOptions', 'TextureCount', 0);
1754 MainForm.pbLoad.Max := i;
1755 MainForm.pbLoad.Position := 0;
1756 MainForm.lLoad.Caption := MsgLoadTextures;
1758 for a := 1 to i do
1759 begin
1760 MainForm.pbLoad.StepIt();
1761 Application.ProcessMessages();
1763 s := TexturePrefix + UpperCase(win2utf(map.ReadStr('Textures', 'TextureName'+IntToStr(a), '')));
1764 if s = TexturePrefix then
1765 Continue;
1767 // Нет такой текстуры - ищем в WAD карты:
1768 if not g_CreateTextureWAD(s, WadsDir + DirectorySeparator + s) then
1769 begin
1770 s := ExtractFileName(_FileName);
1771 Delete(s, Length(s)-3, 4);
1772 s := UpperCase(s) + '.WAD:TEXTURES\'+ UpperCase(win2utf(map.ReadStr('Textures', 'TextureName'+IntToStr(a), '')));
1774 if not g_CreateTextureWAD(s, WadsDir + DirectorySeparator + s) then
1775 Continue;
1776 end;
1778 MainForm.lbTextureList.Items.Add(s);
1779 end;
1781 // Чтение панелей:
1782 i := map.ReadInt('MapOptions', 'PanelCount', 0);
1784 MainForm.pbLoad.Max := i;
1785 MainForm.pbLoad.Position := 0;
1786 MainForm.lLoad.Caption := MsgLoadPanels;
1788 for a := 1 to i do
1789 begin
1790 MainForm.pbLoad.StepIt();
1791 Application.ProcessMessages();
1793 section := 'Panel' + IntToStr(a);
1794 if not map.SectionExists(section) then
1795 Continue;
1797 panel := Default(TPanel);
1798 panel.X := map.ReadInt(section, 'X1', 0);
1799 panel.Y := map.ReadInt(section, 'Y1', 0);
1800 panel.Height := map.ReadInt(section, 'Height', 16);
1801 panel.Width := map.ReadInt(section, 'Width', 16);
1803 case map.ReadInt(section, 'PanelType', 0) of
1804 0: panel.PanelType := PANEL_WALL;
1805 1: panel.PanelType := PANEL_BACK;
1806 2: panel.PanelType := PANEL_FORE;
1807 3: panel.PanelType := PANEL_STEP;
1808 4: panel.PanelType := PANEL_WATER;
1809 5: panel.PanelType := PANEL_ACID1;
1810 6: panel.PanelType := PANEL_ACID2;
1811 end;
1813 panel.Alpha := map.ReadInt(section, 'Alpha', 0);
1814 panel.Blending := false;
1816 // Текстура панели:
1817 if panel.PanelType in [PANEL_WALL, PANEL_BACK, PANEL_FORE, PANEL_STEP] then
1818 begin
1819 s := TexturePrefix + UpperCase(win2utf(map.ReadStr(section, 'TextureName', '')));
1821 if g_GetTexture(s, panel.TextureID) then
1822 begin
1823 g_GetTextureSizeByID(panel.TextureID, panel.TextureWidth, panel.TextureHeight);
1824 panel.TextureName := s;
1826 else // Нет такой текстуры - ищем в WAD карты:
1827 begin
1828 s := ExtractFileName(_FileName);
1829 Delete(s, Length(s)-3, 4);
1830 s := UpperCase(s) + '.WAD:TEXTURES\' + UpperCase(win2utf(map.ReadStr(section, 'TextureName', '')));
1832 if g_GetTexture(s, panel.TextureID) then
1833 begin
1834 g_GetTextureSizeByID(panel.TextureID, panel.TextureWidth, panel.TextureHeight);
1835 panel.TextureName := s;
1837 else
1838 Continue;
1839 end;
1841 else if panel.PanelType in [PANEL_WATER, PANEL_ACID1, PANEL_ACID2] then
1842 begin
1843 case panel.PanelType of
1844 PANEL_WATER:
1845 begin
1846 s := TEXTURE_NAME_WATER;
1847 panel.TextureID := TEXTURE_SPECIAL_WATER;
1848 end;
1849 PANEL_ACID1:
1850 begin
1851 s := TEXTURE_NAME_ACID2;
1852 panel.TextureID := TEXTURE_SPECIAL_ACID2;
1853 end;
1854 PANEL_ACID2:
1855 begin
1856 s := TEXTURE_NAME_ACID1;
1857 panel.TextureID := TEXTURE_SPECIAL_ACID1;
1858 end;
1859 end;
1861 with MainForm.lbTextureList.Items do
1862 if IndexOf(s) = -1 then
1863 Add(s);
1864 panel.TextureName := s;
1865 panel.TextureWidth := 1;
1866 panel.TextureHeight := 1;
1867 end;
1869 AddPanel(panel);
1870 end;
1872 // Чтение предметов:
1873 i := map.ReadInt('MapOptions', 'ItemCount', 0);
1875 MainForm.pbLoad.Max := i;
1876 MainForm.pbLoad.Position := 0;
1877 MainForm.lLoad.Caption := MsgLoadItems;
1879 for a := 1 to i do
1880 begin
1881 MainForm.pbLoad.StepIt();
1882 Application.ProcessMessages();
1884 section := 'Item' + IntToStr(a);
1885 if not map.SectionExists(section) then
1886 Continue;
1888 item := Default(TItem);
1889 item.X := map.ReadInt(section, 'X', 0);
1890 item.Y := map.ReadInt(section, 'Y', 0);
1891 item.ItemType := ITEMSCONVERT[map.ReadInt(section, 'Type', 0)];
1892 item.OnlyDM := False;
1893 item.Fall := item.ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE];
1895 // Размер предметов теперь другой:
1896 item.X := item.X + OldItemSize[item.ItemType][0] - ItemSize[item.ItemType][0];
1897 item.Y := item.Y + OldItemSize[item.ItemType][1] - ItemSize[item.ItemType][1];
1899 AddItem(item);
1900 end;
1902 // Чтение областей:
1903 i := map.ReadInt('MapOptions', 'AreaCount', 0);
1905 MainForm.pbLoad.Max := i;
1906 MainForm.pbLoad.Position := 0;
1907 MainForm.lLoad.Caption := MsgLoadAreas;
1909 for a := 1 to i do
1910 begin
1911 MainForm.pbLoad.StepIt();
1912 Application.ProcessMessages();
1914 section := 'Area' + IntToStr(a);
1915 if not map.SectionExists(section) then
1916 Continue;
1918 area := Default(TArea);
1919 area.X := map.ReadInt(section, 'X', 0);
1920 area.Y := map.ReadInt(section, 'Y', 0);
1921 area.AreaType := map.ReadInt(section, 'Type', 0);
1922 area.Direction := D_RIGHT;
1924 // Размер областей теперь другой:
1925 area.X := area.X + OldAreaSize[0] - AreaSize[area.AreaType].Width;
1926 area.Y := area.Y + OldAreaSize[1] - AreaSize[area.AreaType].Height;
1928 AddArea(area);
1929 end;
1931 // Чтение параметров карты:
1932 gMapInfo := Default(TMapInfo);
1933 with gMapInfo do
1934 begin
1935 Name := win2utf(map.ReadStr('MapOptions', 'MapName', ''));
1936 Description := win2utf(map.ReadStr('MapOptions', 'MapDescription', ''));
1937 Author := '';
1938 MusicName := DefaultMusRes;
1939 SkyName := DefaultSkyRes;
1940 FileName := _FileName;
1941 Height := map.ReadInt('MapOptions', 'Height', 1600);
1942 Width := map.ReadInt('MapOptions', 'Width', 1600);
1944 if Length(Name) > 32 then
1945 SetLength(Name, 32);
1946 if Length(Description) > 256 then
1947 SetLength(Description, 256);
1948 end;
1950 LoadSky(gMapInfo.SkyName);
1952 map.Free();
1954 Result := True;
1955 end;
1957 procedure ClearMap();
1959 a: Integer;
1961 begin
1962 if gPanels <> nil then
1963 for a := 0 to High(gPanels) do
1964 if gPanels[a].TextureName <> '' then
1965 g_DeleteTexture(gPanels[a].TextureName);
1967 SetLength(gPanels, 0);
1968 gPanels := nil;
1969 SetLength(gItems, 0);
1970 gItems := nil;
1971 SetLength(gAreas, 0);
1972 gAreas := nil;
1973 SetLength(gMonsters, 0);
1974 gMonsters := nil;
1975 SetLength(gTriggers, 0);
1976 gTriggers := nil;
1978 gMapInfo := Default(TMapInfo);
1979 gMapInfo.Width := 1600;
1980 gMapInfo.Height := 1600;
1982 with MainForm.lbTextureList do
1983 begin
1984 if Items.Count > 0 then
1985 for a := Items.Count-1 downto 0 do
1986 if not IsSpecialTexture(Items[a]) then
1987 g_DeleteTexture(Items[a]);
1989 Clear();
1990 end;
1992 MapOffset.X := 0;
1993 MapOffset.Y := 0;
1994 end;
1996 procedure DrawPanels(fPanelType: Word);
1998 procedure DrawTexture(a: Integer);
2000 NoTextureID: DWORD;
2001 NW, NH: Word;
2002 begin
2003 NoTextureID := 0;
2004 NW := 0;
2005 NH := 0;
2006 with gPanels[a] do
2007 begin
2008 case TextureID of
2009 TEXTURE_SPECIAL_NONE:
2010 if PreviewMode = 0 then
2011 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2012 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2013 64, 64, 64, 127);
2015 TEXTURE_SPECIAL_NOTEXTURE:
2016 if g_GetTexture('NOTEXTURE', NoTextureID) then
2017 begin
2018 g_GetTextureSizeByID(NoTextureID, NW, NH);
2019 e_DrawFill(NoTextureID, X+MapOffset.X, Y+MapOffset.Y,
2020 Width div NW, Height div NH, 0, False, False);
2021 end;
2023 TEXTURE_SPECIAL_WATER:
2024 if PreviewMode > 0 then
2025 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2026 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2027 0, 0, 255, 0, B_FILTER)
2028 else
2029 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2030 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2031 0, 0, 255, 127);
2033 TEXTURE_SPECIAL_ACID1:
2034 if PreviewMode > 0 then
2035 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2036 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2037 0, 127, 0, 0, B_FILTER)
2038 else
2039 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2040 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2041 0, 255, 0, 127);
2043 TEXTURE_SPECIAL_ACID2:
2044 if PreviewMode > 0 then
2045 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2046 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2047 127, 0, 0, 0, B_FILTER)
2048 else
2049 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2050 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2051 255, 0, 0, 127);
2053 else
2054 e_DrawFill(TextureID, X+MapOffset.X, Y+MapOffset.Y,
2055 Width div TextureWidth, Height div TextureHeight,
2056 Alpha, True, Blending);
2057 end;
2058 end;
2059 end;
2062 a: Integer;
2063 begin
2064 if gPanels <> nil then
2065 for a := 0 to High(gPanels) do
2066 if (gPanels[a].PanelType <> 0) and
2067 WordBool(gPanels[a].PanelType and fPanelType) then
2068 with gPanels[a] do
2069 begin
2070 if (TextureID < TEXTURE_SPECIAL_NOTEXTURE) and (TextureWidth = 0) and (TextureWidth = 0) then
2071 TextureID := TEXTURE_SPECIAL_NOTEXTURE;
2072 case PanelType of
2073 PANEL_WALL, PANEL_BACK, PANEL_FORE,
2074 PANEL_STEP, PANEL_OPENDOOR, PANEL_CLOSEDOOR,
2075 PANEL_WATER, PANEL_ACID1, PANEL_ACID2:
2076 DrawTexture(a);
2078 PANEL_LIFTUP:
2079 if PreviewMode = 0 then
2080 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2081 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2082 128, 64, 0, 0);
2083 PANEL_LIFTDOWN:
2084 if PreviewMode = 0 then
2085 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2086 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2087 90, 154, 138, 0);
2088 PANEL_LIFTLEFT:
2089 if PreviewMode = 0 then
2090 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2091 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2092 200, 80, 4, 0);
2093 PANEL_LIFTRIGHT:
2094 if PreviewMode = 0 then
2095 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2096 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2097 252, 140, 56, 0);
2098 PANEL_BLOCKMON:
2099 if PreviewMode = 0 then
2100 e_DrawFillQuad(X+MapOffset.X, Y+MapOffset.Y,
2101 X+MapOffset.X+Width-1, Y+MapOffset.Y+Height-1,
2102 192, 0, 192, 0);
2103 end;
2104 end;
2105 end;
2107 procedure DrawContours (fPanelType: Word);
2108 var i, xx, yy, ww, hh: Integer;
2109 begin
2110 if gPanels <> nil then
2111 for i := 0 to High(gPanels) do
2112 if (gPanels[i].PanelType <> 0) and WordBool(gPanels[i].PanelType and fPanelType) then
2113 begin
2114 xx := gPanels[i].X + MapOffset.X;
2115 yy := gPanels[i].Y + MapOffset.Y;
2116 ww := gPanels[i].X + MapOffset.X + gPanels[i].Width - 1;
2117 hh := gPanels[i].Y + MapOffset.Y + gPanels[i].Height - 1;
2118 case gPanels[i].PanelType of
2119 PANEL_NONE: ;
2120 PANEL_WALL: e_DrawQuad(xx, yy, ww, hh, 208, 208, 208, 0);
2121 PANEL_BACK: e_DrawQuad(xx, yy, ww, hh, 64, 64, 64, 0);
2122 PANEL_FORE: e_DrawQuad(xx, yy, ww, hh, 128, 128, 128, 0);
2123 PANEL_WATER: e_DrawQuad(xx, yy, ww, hh, 0, 0, 192, 0);
2124 PANEL_ACID1: e_DrawQuad(xx, yy, ww, hh, 0, 176, 0, 0);
2125 PANEL_ACID2: e_DrawQuad(xx, yy, ww, hh, 176, 0, 0, 0);
2126 PANEL_STEP: e_DrawQuad(xx, yy, ww, hh, 128, 128, 128, 0);
2127 PANEL_LIFTUP: e_DrawQuad(xx, yy, ww, hh, 116, 72, 36, 0);
2128 PANEL_LIFTDOWN: e_DrawQuad(xx, yy, ww, hh, 116, 124, 96, 0);
2129 PANEL_OPENDOOR: e_DrawQuad(xx, yy, ww, hh, 100, 220, 92, 0);
2130 PANEL_CLOSEDOOR: e_DrawQuad(xx, yy, ww, hh, 212, 184, 64, 0);
2131 PANEL_BLOCKMON: e_DrawQuad(xx, yy, ww, hh, 192, 0, 192, 0);
2132 PANEL_LIFTLEFT: e_DrawQuad(xx, yy, ww, hh, 200, 80, 4, 0);
2133 PANEL_LIFTRIGHT: e_DrawQuad(xx, yy, ww, hh, 252, 140, 56, 0);
2134 else
2135 assert(false)
2136 end;
2137 end;
2138 end;
2140 procedure DrawMap();
2142 a, w, h: Integer;
2143 ID: DWORD;
2144 xx, yy, dx, dy: Integer;
2145 ww, hh: Word;
2146 sel: Boolean;
2147 r: TRectWH;
2148 mask: Word;
2149 begin
2150 ID := 0;
2151 // В режиме Превью рисуем небо:
2152 if PreviewMode > 0 then
2153 begin
2154 w := Max(MainForm.RenderPanel.Width, MainForm.RenderPanel.Height);
2155 if MainForm.RenderPanel.Height > MainForm.RenderPanel.Width*3/4 then
2156 w := Round(w*4/3);
2157 h := Round(w*3/4);
2159 if g_GetTexture(SKY_TEXTURE, ID) then
2160 e_DrawSize(ID, 0, 0, 0, False, False, w, h)
2161 else
2162 e_DrawFillQuad(0, 0, w-1, h-1, 0, 0, 0, 0, B_NONE);
2163 end;
2165 // Рисуем панели (если Превью или если включен слой):
2166 if LayerEnabled[LAYER_BACK] or (PreviewMode = 1) then
2167 DrawPanels(PANEL_BACK);
2168 if PreviewMode > 0 then
2169 DrawPanels(PANEL_LIFTUP or PANEL_LIFTDOWN or PANEL_LIFTLEFT or PANEL_LIFTRIGHT)
2170 else
2171 if LayerEnabled[LAYER_WATER] then
2172 DrawPanels(PANEL_LIFTUP or PANEL_LIFTDOWN or PANEL_LIFTLEFT or PANEL_LIFTRIGHT or
2173 PANEL_OPENDOOR or PANEL_CLOSEDOOR or PANEL_BLOCKMON);
2174 if LayerEnabled[LAYER_WALLS] or (PreviewMode = 1) then
2175 DrawPanels(PANEL_WALL);
2176 if LayerEnabled[LAYER_STEPS] or (PreviewMode = 1) then
2177 DrawPanels(PANEL_STEP);
2179 // Рисуем предметы:
2180 if (LayerEnabled[LAYER_ITEMS] or (PreviewMode = 1)) and
2181 (gItems <> nil) then
2182 for a := 0 to High(gItems) do
2183 if gItems[a].ItemType <> ITEM_NONE then
2184 with gItems[a] do
2185 begin
2186 ID := DWORD(-1);
2188 case ItemType of
2189 0: Continue;
2190 ITEM_MEDKIT_SMALL: g_GetTexture('ITEM_MEDKIT_SMALL', ID);
2191 ITEM_MEDKIT_LARGE: g_GetTexture('ITEM_MEDKIT_LARGE', ID);
2192 ITEM_MEDKIT_BLACK: g_GetTexture('ITEM_MEDKIT_BLACK', ID);
2193 ITEM_ARMOR_GREEN: g_GetTexture('ITEM_ARMORGREEN', ID);
2194 ITEM_ARMOR_BLUE: g_GetTexture('ITEM_ARMORBLUE', ID);
2195 ITEM_SPHERE_BLUE: g_GetTexture('ITEM_BLUESPHERE', ID);
2196 ITEM_SPHERE_WHITE: g_GetTexture('ITEM_WHITESPHERE', ID);
2197 ITEM_SUIT: g_GetTexture('ITEM_SUIT', ID);
2198 ITEM_OXYGEN: g_GetTexture('ITEM_OXYGEN', ID);
2199 ITEM_INVUL: g_GetTexture('ITEM_INVUL', ID);
2200 ITEM_WEAPON_SAW: g_GetTexture('ITEM_WEAPON_SAW', ID);
2201 ITEM_WEAPON_SHOTGUN1: g_GetTexture('ITEM_WEAPON_SHOTGUN1', ID);
2202 ITEM_WEAPON_SHOTGUN2: g_GetTexture('ITEM_WEAPON_SHOTGUN2', ID);
2203 ITEM_WEAPON_CHAINGUN: g_GetTexture('ITEM_WEAPON_CHAINGUN', ID);
2204 ITEM_WEAPON_ROCKETLAUNCHER: g_GetTexture('ITEM_WEAPON_ROCKETLAUNCHER', ID);
2205 ITEM_WEAPON_PLASMA: g_GetTexture('ITEM_WEAPON_PLASMA', ID);
2206 ITEM_WEAPON_BFG: g_GetTexture('ITEM_WEAPON_BFG', ID);
2207 ITEM_WEAPON_SUPERPULEMET: g_GetTexture('ITEM_WEAPON_SUPERPULEMET', ID);
2208 ITEM_AMMO_BULLETS: g_GetTexture('ITEM_AMMO_BULLETS', ID);
2209 ITEM_AMMO_BULLETS_BOX: g_GetTexture('ITEM_AMMO_BULLETS_BOX', ID);
2210 ITEM_AMMO_SHELLS: g_GetTexture('ITEM_AMMO_SHELLS', ID);
2211 ITEM_AMMO_SHELLS_BOX: g_GetTexture('ITEM_AMMO_SHELLS_BOX', ID);
2212 ITEM_AMMO_ROCKET: g_GetTexture('ITEM_AMMO_ROCKET', ID);
2213 ITEM_AMMO_ROCKET_BOX: g_GetTexture('ITEM_AMMO_ROCKET_BOX', ID);
2214 ITEM_AMMO_CELL: g_GetTexture('ITEM_AMMO_CELL', ID);
2215 ITEM_AMMO_CELL_BIG: g_GetTexture('ITEM_AMMO_CELL_BIG', ID);
2216 ITEM_AMMO_BACKPACK: g_GetTexture('ITEM_AMMO_BACKPACK', ID);
2217 ITEM_KEY_RED: g_GetTexture('ITEM_KEY_RED', ID);
2218 ITEM_KEY_GREEN: g_GetTexture('ITEM_KEY_GREEN', ID);
2219 ITEM_KEY_BLUE: g_GetTexture('ITEM_KEY_BLUE', ID);
2220 ITEM_BOTTLE: g_GetTexture('ITEM_BOTTLE', ID);
2221 ITEM_HELMET: g_GetTexture('ITEM_HELMET', ID);
2222 ITEM_JETPACK: g_GetTexture('ITEM_JETPACK', ID);
2223 ITEM_INVIS: g_GetTexture('ITEM_INVIS', ID);
2224 ITEM_WEAPON_FLAMETHROWER: g_GetTexture('ITEM_WEAPON_FLAMETHROWER', ID);
2225 ITEM_AMMO_FUELCAN: g_GetTexture('ITEM_AMMO_FUELCAN', ID);
2226 end;
2228 if ID <> DWORD(-1) then
2229 e_Draw(ID, MapOffset.X+X, MapOffset.Y+Y, 0, True, False);
2230 end;
2232 // Рисуем монстров:
2233 if (LayerEnabled[LAYER_MONSTERS] or (PreviewMode = 1)) and
2234 (gMonsters <> nil) then
2235 for a := 0 to High(gMonsters) do
2236 if gMonsters[a].MonsterType <> MONSTER_NONE then
2237 with MonsterSize[gMonsters[a].MonsterType] do
2238 begin
2239 ID := DWORD(-1);
2240 sel := ObjectSelected(OBJECT_MONSTER, a);
2242 case gMonsters[a].MonsterType of
2243 0: Continue;
2244 MONSTER_DEMON: g_GetTexture('MONSTER_DEMON', ID);
2245 MONSTER_IMP: g_GetTexture('MONSTER_IMP', ID);
2246 MONSTER_ZOMBY: g_GetTexture('MONSTER_ZOMBY', ID);
2247 MONSTER_SERG: g_GetTexture('MONSTER_SERG', ID);
2248 MONSTER_CYBER: g_GetTexture('MONSTER_CYBER', ID);
2249 MONSTER_CGUN: g_GetTexture('MONSTER_CGUN', ID);
2250 MONSTER_BARON: g_GetTexture('MONSTER_BARON', ID);
2251 MONSTER_KNIGHT: g_GetTexture('MONSTER_KNIGHT', ID);
2252 MONSTER_CACO: g_GetTexture('MONSTER_CACO', ID);
2253 MONSTER_SOUL: g_GetTexture('MONSTER_SOUL', ID);
2254 MONSTER_PAIN: g_GetTexture('MONSTER_PAIN', ID);
2255 MONSTER_SPIDER: g_GetTexture('MONSTER_SPIDER', ID);
2256 MONSTER_BSP: g_GetTexture('MONSTER_BSP', ID);
2257 MONSTER_MANCUB: g_GetTexture('MONSTER_MANCUB', ID);
2258 MONSTER_SKEL: g_GetTexture('MONSTER_SKEL', ID);
2259 MONSTER_VILE: g_GetTexture('MONSTER_VILE', ID);
2260 MONSTER_FISH: g_GetTexture('MONSTER_FISH', ID);
2261 MONSTER_BARREL: g_GetTexture('MONSTER_BARREL', ID);
2262 MONSTER_ROBO: g_GetTexture('MONSTER_ROBO', ID);
2263 MONSTER_MAN: g_GetTexture('MONSTER_MAN', ID);
2264 end;
2266 if ID <> DWORD(-1) then
2267 if gMonsters[a].Direction = D_LEFT then
2268 begin
2269 // Расстояние от края текстуры до края визуального положения объекта на текстуре:
2270 xx := (X - MonsterSizeDelta[gMonsters[a].MonsterType].X) + Width;
2271 // Расстояние от края хит бокса до края визуального положения объекта на текстуре:
2272 xx := MonsterSizeDelta[gMonsters[a].MonsterType].Width - xx - X;
2273 // Т.к. двигать текстуру нужно будет в противоположном направлении:
2274 xx := (gMonsters[a].X - X) - xx;
2276 yy := (gMonsters[a].Y - Y) +
2277 MonsterSizeDelta[gMonsters[a].MonsterType].Y;
2279 e_Draw(ID, MapOffset.X + xx, MapOffset.Y + yy,
2280 0, True, False, M_HORIZONTAL);
2282 else
2283 begin
2284 // Левый верхний угол текстуры + смещение анимации:
2285 xx := (gMonsters[a].X - X) +
2286 MonsterSizeDelta[gMonsters[a].MonsterType].X;
2287 yy := (gMonsters[a].Y - Y) +
2288 MonsterSizeDelta[gMonsters[a].MonsterType].Y;
2290 e_Draw(ID, MapOffset.X + xx, MapOffset.Y + yy,
2291 0, True, False);
2292 end;
2294 // Рамка:
2295 if PreviewMode = 0 then
2296 begin
2297 e_DrawQuad(MapOffset.X+gMonsters[a].X, MapOffset.Y+gMonsters[a].Y,
2298 MapOffset.X+gMonsters[a].X+Width-1, MapOffset.Y+gMonsters[a].Y+Height-1,
2299 255, 255, 255, IfThen(sel, 0, gAlphaMonsterRect));
2300 end;
2301 end;
2303 // Рисуем закрытые двери после монстров:
2304 if ((PreviewMode = 2) and LayerEnabled[LAYER_WATER])
2305 or (PreviewMode = 1) then
2306 DrawPanels(PANEL_CLOSEDOOR);
2308 // Рисуем области:
2309 if (LayerEnabled[LAYER_AREAS] or (PreviewMode = 1)) and
2310 (gAreas <> nil) then
2311 for a := 0 to High(gAreas) do
2312 if gAreas[a].AreaType <> AREA_NONE then
2313 with AreaSize[gAreas[a].AreaType] do
2314 begin
2315 ID := DWORD(-1);
2316 sel := ObjectSelected(OBJECT_AREA, a);
2318 case gAreas[a].AreaType of
2319 AREA_PLAYERPOINT1: g_GetTexture('AREA_PLAYERPOINT1', ID);
2320 AREA_PLAYERPOINT2: g_GetTexture('AREA_PLAYERPOINT2', ID);
2321 AREA_DMPOINT: g_GetTexture('AREA_DMPOINT', ID);
2322 AREA_REDFLAG: g_GetTexture('AREA_REDFLAG', ID);
2323 AREA_BLUEFLAG: g_GetTexture('AREA_BLUEFLAG', ID);
2324 AREA_DOMFLAG: g_GetTexture('AREA_DOMFLAG', ID);
2325 AREA_REDTEAMPOINT: g_GetTexture('AREA_REDPOINT', ID);
2326 AREA_BLUETEAMPOINT: g_GetTexture('AREA_BLUEPOINT', ID);
2327 end;
2329 if (PreviewMode = 0) or
2330 (gAreas[a].AreaType = AREA_REDFLAG) or
2331 (gAreas[a].AreaType = AREA_BLUEFLAG) or
2332 (gAreas[a].AreaType = AREA_DOMFLAG) then
2333 if ID <> DWORD(-1) then
2334 if gAreas[a].Direction = D_LEFT then
2335 e_Draw(ID, MapOffset.X+gAreas[a].X-X, MapOffset.Y+gAreas[a].Y-Y,
2336 0, True, False, M_HORIZONTAL)
2337 else
2338 e_Draw(ID, MapOffset.X+gAreas[a].X-X, MapOffset.Y+gAreas[a].Y-Y,
2339 0, True, False);
2341 // Рамка:
2342 if PreviewMode = 0 then
2343 begin
2344 e_DrawQuad(MapOffset.X+gAreas[a].X, MapOffset.Y+gAreas[a].Y,
2345 MapOffset.X+gAreas[a].X+Width-1, MapOffset.Y+gAreas[a].Y+Height-1,
2346 255, 255, 255, IfThen(sel, 0, gAlphaAreaRect));
2348 e_DrawPoint(2, MapOffset.X+gAreas[a].X, MapOffset.Y+gAreas[a].Y, 255, 0, 0);
2349 end;
2350 end;
2352 // Рисуем жидкости и передний план после областей:
2353 if LayerEnabled[LAYER_WATER] or (PreviewMode = 1) then
2354 DrawPanels(PANEL_WATER or PANEL_ACID1 or PANEL_ACID2);
2355 if LayerEnabled[LAYER_FOREGROUND] or (PreviewMode = 1) then
2356 DrawPanels(PANEL_FORE);
2358 // Рисуем триггеры:
2359 if LayerEnabled[LAYER_TRIGGERS] and
2360 (PreviewMode = 0) and (gTriggers <> nil) then
2361 for a := 0 to High(gTriggers) do
2362 with gTriggers[a] do
2363 if TriggerType <> TRIGGER_NONE then
2364 begin
2365 // Если выбран - рисуем красным, иначе - белым:
2366 sel := ObjectSelected(OBJECT_TRIGGER, a);
2368 e_DrawFillQuad(MapOffset.X+X, MapOffset.Y+Y,
2369 MapOffset.X+X+Width-1, MapOffset.Y+Y+Height-1,
2370 0, 0, 0, 150);
2372 if TexturePanel <> -1 then
2373 begin
2374 with gPanels[TexturePanel] do
2375 begin
2376 xx := X;
2377 yy := Y;
2378 ww := Width;
2379 hh := Height;
2380 end;
2382 e_DrawQuad(MapOffset.X+xx, MapOffset.Y+yy,
2383 MapOffset.X+xx+ww-1, MapOffset.Y+yy+hh-1,
2384 255, 255, 255, IfThen(sel, 0, gAlphaTriggerArea));
2385 e_DrawLine(1, MapOffset.X+X+(Width div 2), MapOffset.Y+Y+(Height div 2),
2386 MapOffset.X+xx, MapOffset.Y+yy,
2387 0, 255, 0, IfThen(sel, 0, gAlphaTriggerArea));
2388 end;
2390 case TriggerType of
2391 TRIGGER_EXIT: ;
2393 TRIGGER_TELEPORT:
2394 begin
2395 // Точка назначения Телепорта:
2396 if Data.d2d_teleport then
2397 e_DrawLine(2, MapOffset.X+Data.TargetPoint.X-16,
2398 MapOffset.Y+Data.TargetPoint.Y-1,
2399 MapOffset.X+Data.TargetPoint.X+16, MapOffset.Y+Data.TargetPoint.Y-1,
2400 0, 0, 255, IfThen(sel, 0, gAlphaTriggerArea))
2401 else
2402 e_DrawQuad(MapOffset.X+Data.TargetPoint.X,
2403 MapOffset.Y+Data.TargetPoint.Y,
2404 MapOffset.X+Data.TargetPoint.X+AreaSize[AREA_DMPOINT].Width-1,
2405 MapOffset.Y+Data.TargetPoint.Y+AreaSize[AREA_DMPOINT].Height-1,
2406 255, 255, 255, IfThen(sel, 0, gAlphaTriggerArea));
2407 e_DrawPoint(2, MapOffset.X+Data.TargetPoint.X,
2408 MapOffset.Y+Data.TargetPoint.Y,
2409 255, 0, 0);
2410 // Линия к точке назначения Телепорта:
2411 e_DrawLine(1, MapOffset.X+X+(Width div 2),
2412 MapOffset.Y+Y+(Height div 2),
2413 MapOffset.X+Data.TargetPoint.X,
2414 MapOffset.Y+Data.TargetPoint.Y,
2415 255, 255, 255, IfThen(sel, 0, gAlphaTriggerLine));
2416 end;
2418 TRIGGER_OPENDOOR, TRIGGER_CLOSEDOOR,
2419 TRIGGER_DOOR, TRIGGER_DOOR5, TRIGGER_CLOSETRAP,
2420 TRIGGER_TRAP, TRIGGER_LIFTUP, TRIGGER_LIFTDOWN,
2421 TRIGGER_LIFT:
2422 if Data.PanelID <> -1 then
2423 begin
2424 // Дверь/Ловушка/Лифт:
2425 e_DrawQuad(MapOffset.X+gPanels[Data.PanelID].X,
2426 MapOffset.Y+gPanels[Data.PanelID].Y,
2427 MapOffset.X+gPanels[Data.PanelID].X+gPanels[Data.PanelID].Width-1,
2428 MapOffset.Y+gPanels[Data.PanelID].Y+gPanels[Data.PanelID].Height-1,
2429 255, 255, 255, IfThen(sel, 0, gAlphaTriggerArea));
2430 e_DrawPoint(2, MapOffset.X+gPanels[Data.PanelID].X,
2431 MapOffset.Y+gPanels[Data.PanelID].Y,
2432 255, 0, 0);
2433 // Линия к Двери/Ловушке/Лифту:
2434 e_DrawLine(1, MapOffset.X+X+(Width div 2),
2435 MapOffset.Y+Y+(Height div 2),
2436 MapOffset.X+gPanels[Data.PanelID].X,
2437 MapOffset.Y+gPanels[Data.PanelID].Y,
2438 255, 255, 255, IfThen(sel, 0, gAlphaTriggerLine));
2439 end;
2441 TRIGGER_PRESS, TRIGGER_ON,
2442 TRIGGER_OFF, TRIGGER_ONOFF:
2443 begin
2444 if (Data.tWidth > 0) and
2445 (Data.tHeight > 0) then
2446 begin
2447 // Область Расширителя:
2448 e_DrawQuad(MapOffset.X+Data.tX,
2449 MapOffset.Y+Data.tY,
2450 MapOffset.X+Data.tX+Data.tWidth-1,
2451 MapOffset.Y+Data.tY+Data.tHeight-1,
2452 255, 255, 255, IfThen(sel, 0, gAlphaTriggerArea));
2453 e_DrawPoint(2, MapOffset.X+Data.tX,
2454 MapOffset.Y+Data.tY,
2455 255, 0, 0);
2456 // Линия к области Расширителя:
2457 e_DrawLine(1, MapOffset.X+X+(Width div 2),
2458 MapOffset.Y+Y+(Height div 2),
2459 MapOffset.X+Data.tX,
2460 MapOffset.Y+Data.tY,
2461 255, 255, 255, IfThen(sel, 0, gAlphaTriggerLine));
2462 end;
2464 if Data.MonsterID <> 0 then
2465 if (gMonsters <> nil) and
2466 (gMonsters[Data.MonsterID-1].MonsterType <> MONSTER_NONE) then
2467 begin
2468 // Рамка вокруг Монстра - условия активации:
2469 r := ObjectGetRect(OBJECT_MONSTER, Data.MonsterID-1);
2470 e_DrawQuad(MapOffset.X+r.X,
2471 MapOffset.Y+r.Y,
2472 MapOffset.X+r.X+r.Width-1,
2473 MapOffset.Y+r.Y+r.Height-1,
2474 0, 255, 0, IfThen(sel, 0, gAlphaTriggerArea));
2475 // Линия к Монстру - условию активации:
2476 e_DrawLine(1, MapOffset.X+X+(Width div 2),
2477 MapOffset.Y+Y+(Height div 2),
2478 MapOffset.X+r.X,
2479 MapOffset.Y+r.Y,
2480 0, 255, 0, IfThen(sel, 0, gAlphaTriggerArea));
2482 end;
2483 end;
2485 TRIGGER_SECRET: ;
2487 TRIGGER_SPAWNMONSTER, TRIGGER_SPAWNITEM:
2488 begin
2489 if TriggerType = TRIGGER_SPAWNMONSTER then
2490 begin
2491 xx := Data.MonPos.X;
2492 yy := Data.MonPos.Y;
2494 else
2495 begin
2496 xx := Data.ItemPos.X;
2497 yy := Data.ItemPos.Y;
2498 end;
2499 // Точка появления Монстра/Предмета:
2500 e_DrawLine(2, MapOffset.X+xx-16,
2501 MapOffset.Y+yy-1,
2502 MapOffset.X+xx+16,
2503 MapOffset.Y+yy-1,
2504 0, 0, 255, IfThen(sel, 0, gAlphaTriggerArea));
2505 e_DrawPoint(2, MapOffset.X+xx,
2506 MapOffset.Y+yy,
2507 255, 0, 0);
2508 // Линия к точке появления Монстра/Предмета:
2509 e_DrawLine(1, MapOffset.X+X+(Width div 2),
2510 MapOffset.Y+Y+(Height div 2),
2511 MapOffset.X+xx,
2512 MapOffset.Y+yy,
2513 255, 255, 255, IfThen(sel, 0, gAlphaTriggerLine));
2514 // Предпросмотр создаваемого объекта:
2515 if sel then
2516 begin
2517 // Монстр:
2518 if TriggerType = TRIGGER_SPAWNMONSTER then
2519 begin
2520 if Data.MonType <> MONSTER_NONE then
2521 with MonsterSize[Data.MonType] do
2522 begin
2523 ID := DWORD(-1);
2524 case Data.MonType of
2525 MONSTER_DEMON: g_GetTexture('MONSTER_DEMON', ID);
2526 MONSTER_IMP: g_GetTexture('MONSTER_IMP', ID);
2527 MONSTER_ZOMBY: g_GetTexture('MONSTER_ZOMBY', ID);
2528 MONSTER_SERG: g_GetTexture('MONSTER_SERG', ID);
2529 MONSTER_CYBER: g_GetTexture('MONSTER_CYBER', ID);
2530 MONSTER_CGUN: g_GetTexture('MONSTER_CGUN', ID);
2531 MONSTER_BARON: g_GetTexture('MONSTER_BARON', ID);
2532 MONSTER_KNIGHT: g_GetTexture('MONSTER_KNIGHT', ID);
2533 MONSTER_CACO: g_GetTexture('MONSTER_CACO', ID);
2534 MONSTER_SOUL: g_GetTexture('MONSTER_SOUL', ID);
2535 MONSTER_PAIN: g_GetTexture('MONSTER_PAIN', ID);
2536 MONSTER_SPIDER: g_GetTexture('MONSTER_SPIDER', ID);
2537 MONSTER_BSP: g_GetTexture('MONSTER_BSP', ID);
2538 MONSTER_MANCUB: g_GetTexture('MONSTER_MANCUB', ID);
2539 MONSTER_SKEL: g_GetTexture('MONSTER_SKEL', ID);
2540 MONSTER_VILE: g_GetTexture('MONSTER_VILE', ID);
2541 MONSTER_FISH: g_GetTexture('MONSTER_FISH', ID);
2542 MONSTER_BARREL: g_GetTexture('MONSTER_BARREL', ID);
2543 MONSTER_ROBO: g_GetTexture('MONSTER_ROBO', ID);
2544 MONSTER_MAN: g_GetTexture('MONSTER_MAN', ID);
2545 end;
2546 if ID <> DWORD(-1) then
2547 begin
2548 if Data.MonDir = Byte(D_LEFT) then
2549 begin
2550 xx := X - MonsterSizeDelta[Data.MonType].X + Width;
2551 xx := MonsterSizeDelta[Data.MonType].Width - xx - X;
2552 xx := Data.TargetPoint.X - X - xx - (Width div 2);
2554 yy := Data.TargetPoint.Y - Y +
2555 MonsterSizeDelta[Data.MonType].Y-Height;
2557 e_Draw(ID, MapOffset.X + xx, MapOffset.Y + yy,
2558 128, True, False, M_HORIZONTAL);
2560 else
2561 begin
2562 xx := Data.TargetPoint.X - X +
2563 MonsterSizeDelta[Data.MonType].X-(Width div 2);
2564 yy := Data.TargetPoint.Y - Y +
2565 MonsterSizeDelta[Data.MonType].Y-Height;
2567 e_Draw(ID, MapOffset.X + xx, MapOffset.Y + yy,
2568 128, True, False);
2569 end;
2570 // Рамка:
2571 e_DrawQuad(MapOffset.X+Data.TargetPoint.X-(Width div 2), MapOffset.Y+Data.TargetPoint.Y-Height,
2572 MapOffset.X+Data.TargetPoint.X+(Width div 2)-1, MapOffset.Y+Data.TargetPoint.Y-1,
2573 255, 255, 0, 128);
2574 end;
2575 end;
2577 else
2578 // Предмет:
2579 begin
2580 if Data.ItemType <> ITEM_NONE then
2581 begin
2582 ID := DWORD(-1);
2583 case Data.ItemType of
2584 ITEM_MEDKIT_SMALL: g_GetTexture('ITEM_MEDKIT_SMALL', ID);
2585 ITEM_MEDKIT_LARGE: g_GetTexture('ITEM_MEDKIT_LARGE', ID);
2586 ITEM_MEDKIT_BLACK: g_GetTexture('ITEM_MEDKIT_BLACK', ID);
2587 ITEM_ARMOR_GREEN: g_GetTexture('ITEM_ARMORGREEN', ID);
2588 ITEM_ARMOR_BLUE: g_GetTexture('ITEM_ARMORBLUE', ID);
2589 ITEM_SPHERE_BLUE: g_GetTexture('ITEM_BLUESPHERE', ID);
2590 ITEM_SPHERE_WHITE: g_GetTexture('ITEM_WHITESPHERE', ID);
2591 ITEM_SUIT: g_GetTexture('ITEM_SUIT', ID);
2592 ITEM_OXYGEN: g_GetTexture('ITEM_OXYGEN', ID);
2593 ITEM_INVUL: g_GetTexture('ITEM_INVUL', ID);
2594 ITEM_WEAPON_SAW: g_GetTexture('ITEM_WEAPON_SAW', ID);
2595 ITEM_WEAPON_SHOTGUN1: g_GetTexture('ITEM_WEAPON_SHOTGUN1', ID);
2596 ITEM_WEAPON_SHOTGUN2: g_GetTexture('ITEM_WEAPON_SHOTGUN2', ID);
2597 ITEM_WEAPON_CHAINGUN: g_GetTexture('ITEM_WEAPON_CHAINGUN', ID);
2598 ITEM_WEAPON_ROCKETLAUNCHER: g_GetTexture('ITEM_WEAPON_ROCKETLAUNCHER', ID);
2599 ITEM_WEAPON_PLASMA: g_GetTexture('ITEM_WEAPON_PLASMA', ID);
2600 ITEM_WEAPON_BFG: g_GetTexture('ITEM_WEAPON_BFG', ID);
2601 ITEM_WEAPON_SUPERPULEMET: g_GetTexture('ITEM_WEAPON_SUPERPULEMET', ID);
2602 ITEM_AMMO_BULLETS: g_GetTexture('ITEM_AMMO_BULLETS', ID);
2603 ITEM_AMMO_BULLETS_BOX: g_GetTexture('ITEM_AMMO_BULLETS_BOX', ID);
2604 ITEM_AMMO_SHELLS: g_GetTexture('ITEM_AMMO_SHELLS', ID);
2605 ITEM_AMMO_SHELLS_BOX: g_GetTexture('ITEM_AMMO_SHELLS_BOX', ID);
2606 ITEM_AMMO_ROCKET: g_GetTexture('ITEM_AMMO_ROCKET', ID);
2607 ITEM_AMMO_ROCKET_BOX: g_GetTexture('ITEM_AMMO_ROCKET_BOX', ID);
2608 ITEM_AMMO_CELL: g_GetTexture('ITEM_AMMO_CELL', ID);
2609 ITEM_AMMO_CELL_BIG: g_GetTexture('ITEM_AMMO_CELL_BIG', ID);
2610 ITEM_AMMO_BACKPACK: g_GetTexture('ITEM_AMMO_BACKPACK', ID);
2611 ITEM_KEY_RED: g_GetTexture('ITEM_KEY_RED', ID);
2612 ITEM_KEY_GREEN: g_GetTexture('ITEM_KEY_GREEN', ID);
2613 ITEM_KEY_BLUE: g_GetTexture('ITEM_KEY_BLUE', ID);
2614 ITEM_BOTTLE: g_GetTexture('ITEM_BOTTLE', ID);
2615 ITEM_HELMET: g_GetTexture('ITEM_HELMET', ID);
2616 ITEM_JETPACK: g_GetTexture('ITEM_JETPACK', ID);
2617 ITEM_INVIS: g_GetTexture('ITEM_INVIS', ID);
2618 ITEM_WEAPON_FLAMETHROWER: g_GetTexture('ITEM_WEAPON_FLAMETHROWER', ID);
2619 ITEM_AMMO_FUELCAN: g_GetTexture('ITEM_AMMO_FUELCAN', ID);
2620 end;
2621 if ID <> DWORD(-1) then
2622 e_Draw(ID, MapOffset.X+Data.ItemPos.X-(ItemSize[Data.ItemType][0] div 2),
2623 MapOffset.Y+Data.ItemPos.Y-ItemSize[Data.ItemType][1],
2624 128, True, False);
2625 // Рамка:
2626 e_DrawQuad(MapOffset.X+Data.ItemPos.X-(ItemSize[Data.ItemType][0] div 2), MapOffset.Y+Data.ItemPos.Y-ItemSize[Data.ItemType][1],
2627 MapOffset.X+Data.ItemPos.X+(ItemSize[Data.ItemType][0] div 2)-1, MapOffset.Y+Data.ItemPos.Y-1,
2628 255, 255, 0, 128);
2629 end;
2630 end;
2631 end;
2632 end;
2634 TRIGGER_PUSH:
2635 begin
2636 // Линия направления и силы ускорения:
2637 xx := Round(Cos(-DegToRad(Data.PushAngle)) * Data.PushForce) + X+(Width div 2);
2638 yy := Round(Sin(-DegToRad(Data.PushAngle)) * Data.PushForce) + Y+(Height div 2);
2639 e_DrawLine(1, MapOffset.X+X+(Width div 2),
2640 MapOffset.Y+Y+(Height div 2),
2641 MapOffset.X+xx,
2642 MapOffset.Y+yy,
2643 255, 255, 255, IfThen(sel, 0, gAlphaTriggerLine));
2644 end;
2646 TRIGGER_SHOT:
2647 begin;
2648 xx := Data.ShotPos.X;
2649 yy := Data.ShotPos.Y;
2650 // Точка появления снаряда:
2651 e_DrawPoint(2, MapOffset.X+xx,
2652 MapOffset.Y+yy,
2653 255, 0, 0);
2654 // Линия к точке появления снаряда:
2655 e_DrawLine(1, MapOffset.X+X+(Width div 2),
2656 MapOffset.Y+Y+(Height div 2),
2657 MapOffset.X+xx,
2658 MapOffset.Y+yy,
2659 255, 255, 255, IfThen(sel, 0, gAlphaTriggerLine));
2660 // Линия направления выстрела:
2661 dx := Round(Cos(-DegToRad(Data.ShotAngle)) * 24);
2662 dy := Round(Sin(-DegToRad(Data.ShotAngle)) * 24);
2663 e_DrawLine(1, MapOffset.X+xx,
2664 MapOffset.Y+yy,
2665 MapOffset.X+xx+dx,
2666 MapOffset.Y+yy+dy,
2667 255, 255, 255, IfThen(sel, 0, gAlphaTriggerLine));
2669 if (Data.ShotPanelID <> -1) and
2670 (Data.ShotPanelID <= High(gPanels)) then
2671 begin
2672 // Линия к панели индикации выстрела
2673 with gPanels[Data.ShotPanelID] do
2674 begin
2675 xx := X;
2676 yy := Y;
2677 ww := Width;
2678 hh := Height;
2679 end;
2681 e_DrawQuad(MapOffset.X+xx, MapOffset.Y+yy,
2682 MapOffset.X+xx+ww-1, MapOffset.Y+yy+hh-1,
2683 255, 255, 255, IfThen(sel, 0, gAlphaTriggerArea));
2684 e_DrawLine(1, MapOffset.X+X+(Width div 2), MapOffset.Y+Y+(Height div 2),
2685 MapOffset.X+xx, MapOffset.Y+yy,
2686 255, 255, 0, IfThen(sel, 0, gAlphaTriggerArea));
2687 end;
2688 end;
2689 end;
2690 end;
2692 // Draw panel contours
2693 mask := 0;
2694 if ContourEnabled[LAYER_BACK] then
2695 mask := mask or PANEL_BACK;
2696 if ContourEnabled[LAYER_WALLS] then
2697 mask := mask or PANEL_WALL;
2698 if ContourEnabled[LAYER_FOREGROUND] then
2699 mask := mask or PANEL_FORE;
2700 if ContourEnabled[LAYER_STEPS] then
2701 mask := mask or PANEL_STEP;
2702 if ContourEnabled[LAYER_WATER] then
2703 mask := mask or PANEL_WATER or PANEL_ACID1 or PANEL_ACID2
2704 or PANEL_OPENDOOR or PANEL_CLOSEDOOR or PANEL_BLOCKMON
2705 or PANEL_LIFTUP or PANEL_LIFTDOWN or PANEL_LIFTLEFT or PANEL_LIFTRIGHT;
2706 if mask <> 0 then
2707 DrawContours(mask);
2708 if ContourEnabled[LAYER_ITEMS] and (gItems <> nil) then
2709 for a := 0 to High(gItems) do
2710 if gItems[a].ItemType <> ITEM_NONE then
2711 e_DrawQuad(
2712 MapOffset.X + gItems[a].X,
2713 MapOffset.Y + gItems[a].Y,
2714 MapOffset.X + gItems[a].X + ItemSize[gItems[a].ItemType, 0] - 1,
2715 MapOffset.Y + gItems[a].Y + ItemSize[gItems[a].ItemType, 1] - 1,
2716 0, 255, 255
2718 if ContourEnabled[LAYER_MONSTERS] and (gMonsters <> nil) then
2719 for a := 0 to High(gMonsters) do
2720 if gMonsters[a].MonsterType <> MONSTER_NONE then
2721 e_DrawQuad(
2722 MapOffset.X + gMonsters[a].X,
2723 MapOffset.Y + gMonsters[a].Y,
2724 MapOffset.X + gMonsters[a].X + MonsterSize[gMonsters[a].MonsterType].Width - 1,
2725 MapOffset.Y + gMonsters[a].Y + MonsterSize[gMonsters[a].MonsterType].Height - 1,
2726 200, 0, 0
2728 if ContourEnabled[LAYER_AREAS] and (gAreas <> nil) then
2729 for a := 0 to High(gAreas) do
2730 if gAreas[a].AreaType <> AREA_NONE then
2731 e_DrawQuad(
2732 MapOffset.X + gAreas[a].X,
2733 MapOffset.Y + gAreas[a].Y,
2734 MapOffset.X + gAreas[a].X + AreaSize[gAreas[a].AreaType].Width - 1,
2735 MapOffset.Y + gAreas[a].Y + AreaSize[gAreas[a].AreaType].Height - 1,
2736 0, 255, 255
2738 if ContourEnabled[LAYER_TRIGGERS] and (gTriggers <> nil) then
2739 for a := 0 to High(gTriggers) do
2740 if gTriggers[a].TriggerType <> TRIGGER_NONE then
2741 e_DrawQuad(
2742 MapOffset.X + gTriggers[a].X,
2743 MapOffset.Y + gTriggers[a].Y,
2744 MapOffset.X + gTriggers[a].X + gTriggers[a].Width - 1,
2745 MapOffset.Y + gTriggers[a].Y + gTriggers[a].Height - 1,
2746 255, 255, 0
2749 // Границы карты:
2750 if PreviewMode = 0 then
2751 begin
2752 e_DrawFillQuad(0,
2754 MainForm.RenderPanel.Width,
2755 -1 + MapOffset.Y,
2756 drEdge[0], drEdge[1], drEdge[2], drEdge[3], B_NONE); // Top
2757 e_DrawFillQuad(0,
2758 gMapInfo.Height + MapOffset.Y,
2759 MainForm.RenderPanel.Width,
2760 MainForm.RenderPanel.Height,
2761 drEdge[0], drEdge[1], drEdge[2], drEdge[3], B_NONE); // Bottom
2762 e_DrawFillQuad(0,
2763 MapOffset.Y,
2764 -1 + MapOffset.X,
2765 gMapInfo.Height + MapOffset.Y - 1,
2766 drEdge[0], drEdge[1], drEdge[2], drEdge[3], B_NONE); // Left
2767 e_DrawFillQuad(gMapInfo.Width + MapOffset.X,
2768 MapOffset.Y,
2769 MainForm.RenderPanel.Width,
2770 gMapInfo.Height + MapOffset.Y - 1,
2771 drEdge[0], drEdge[1], drEdge[2], drEdge[3], B_NONE); // Right
2772 end;
2773 end;
2775 procedure ShiftMapObjects(dx, dy: Integer);
2777 i: Integer;
2778 begin
2779 if gPanels <> nil then
2780 for i := 0 to High(gPanels) do
2781 if gPanels[i].PanelType <> 0 then
2782 begin
2783 Inc(gPanels[i].X, dx);
2784 Inc(gPanels[i].Y, dy);
2785 end;
2787 if gItems <> nil then
2788 for i := 0 to High(gItems) do
2789 if gItems[i].ItemType <> 0 then
2790 begin
2791 Inc(gItems[i].X, dx);
2792 Inc(gItems[i].Y, dy);
2793 end;
2795 if gAreas <> nil then
2796 for i := 0 to High(gAreas) do
2797 if gAreas[i].AreaType <> 0 then
2798 begin
2799 Inc(gAreas[i].X, dx);
2800 Inc(gAreas[i].Y, dy);
2801 end;
2803 if gMonsters <> nil then
2804 for i := 0 to High(gMonsters) do
2805 if gMonsters[i].MonsterType <> 0 then
2806 begin
2807 Inc(gMonsters[i].X, dx);
2808 Inc(gMonsters[i].Y, dy);
2809 end;
2811 if gTriggers <> nil then
2812 for i := 0 to High(gTriggers) do
2813 if gTriggers[i].TriggerType <> 0 then
2814 begin
2815 Inc(gTriggers[i].X, dx);
2816 Inc(gTriggers[i].Y, dy);
2818 case gTriggers[i].TriggerType of
2819 TRIGGER_TELEPORT:
2820 begin
2821 Inc(gTriggers[i].Data.TargetPoint.X, dx);
2822 Inc(gTriggers[i].Data.TargetPoint.Y, dy);
2823 end;
2825 TRIGGER_PRESS, TRIGGER_ON,
2826 TRIGGER_OFF, TRIGGER_ONOFF:
2827 begin
2828 Inc(gTriggers[i].Data.tX, dx);
2829 Inc(gTriggers[i].Data.tY, dy);
2830 end;
2832 TRIGGER_SPAWNMONSTER:
2833 begin
2834 Inc(gTriggers[i].Data.MonPos.X, dx);
2835 Inc(gTriggers[i].Data.MonPos.Y, dy);
2836 end;
2838 TRIGGER_SPAWNITEM:
2839 begin
2840 Inc(gTriggers[i].Data.ItemPos.X, dx);
2841 Inc(gTriggers[i].Data.ItemPos.Y, dy);
2842 end;
2844 TRIGGER_SHOT:
2845 begin
2846 Inc(gTriggers[i].Data.ShotPos.X, dx);
2847 Inc(gTriggers[i].Data.ShotPos.Y, dy);
2848 end;
2849 end;
2850 end;
2851 end;
2853 procedure LoadData();
2854 begin
2855 g_CreateTextureWAD('PREVIEW', EditorWad + ':TEXTURES\CHECKERS');
2856 g_CreateTextureWAD('NOTEXTURE', GameWad + ':TEXTURES\NOTEXTURE');
2858 g_CreateTextureWADSize('AREA_REDFLAG', GameWad + ':TEXTURES\FLAGRED', 0, 0, 64, 64);
2859 g_CreateTextureWADSize('AREA_BLUEFLAG', GameWad + ':TEXTURES\FLAGBLUE', 0, 0, 64, 64);
2860 g_CreateTextureWADSize('AREA_DOMFLAG', GameWad + ':TEXTURES\FLAGDOM', 0, 0, 64, 64);
2862 g_CreateTextureWADSize('MONSTER_DEMON', GameWad + ':MTEXTURES\DEMON_SLEEP', 0, 0, 64, 64);
2863 g_CreateTextureWADSize('MONSTER_IMP', GameWad + ':MTEXTURES\IMP_SLEEP', 0, 0, 64, 64);
2864 g_CreateTextureWADSize('MONSTER_ZOMBY', GameWad + ':MTEXTURES\ZOMBY_SLEEP', 0, 0, 64, 64);
2865 g_CreateTextureWADSize('MONSTER_SERG', GameWad + ':MTEXTURES\SERG_SLEEP', 0, 0, 64, 64);
2866 g_CreateTextureWADSize('MONSTER_CYBER', GameWad + ':MTEXTURES\CYBER_SLEEP', 0, 0, 128, 128);
2867 g_CreateTextureWADSize('MONSTER_CGUN', GameWad + ':MTEXTURES\CGUN_SLEEP', 0, 0, 64, 64);
2868 g_CreateTextureWADSize('MONSTER_BARON', GameWad + ':MTEXTURES\BARON_SLEEP', 0, 0, 128, 128);
2869 g_CreateTextureWADSize('MONSTER_KNIGHT', GameWad + ':MTEXTURES\KNIGHT_SLEEP', 0, 0, 128, 128);
2870 g_CreateTextureWADSize('MONSTER_CACO', GameWad + ':MTEXTURES\CACO_SLEEP', 0, 0, 128, 128);
2871 g_CreateTextureWADSize('MONSTER_SOUL', GameWad + ':MTEXTURES\SOUL_SLEEP', 0, 0, 64, 64);
2872 g_CreateTextureWADSize('MONSTER_PAIN', GameWad + ':MTEXTURES\PAIN_SLEEP', 0, 0, 128, 128);
2873 g_CreateTextureWADSize('MONSTER_SPIDER', GameWad + ':MTEXTURES\SPIDER_SLEEP', 0, 0, 256, 128);
2874 g_CreateTextureWADSize('MONSTER_BSP', GameWad + ':MTEXTURES\BSP_SLEEP', 0, 0, 128, 64);
2875 g_CreateTextureWADSize('MONSTER_MANCUB', GameWad + ':MTEXTURES\MANCUB_SLEEP', 0, 0, 128, 128);
2876 g_CreateTextureWADSize('MONSTER_SKEL', GameWad + ':MTEXTURES\SKEL_SLEEP', 0, 0, 128, 128);
2877 g_CreateTextureWADSize('MONSTER_VILE', GameWad + ':MTEXTURES\VILE_SLEEP', 0, 0, 128, 128);
2878 g_CreateTextureWADSize('MONSTER_FISH', GameWad + ':MTEXTURES\FISH_SLEEP', 0, 0, 32, 32);
2879 g_CreateTextureWADSize('MONSTER_BARREL', GameWad + ':MTEXTURES\BARREL_SLEEP', 0, 0, 64, 64);
2880 g_CreateTextureWADSize('MONSTER_ROBO', GameWad + ':MTEXTURES\ROBO_SLEEP', 0, 0, 128, 128);
2881 g_CreateTextureWADSize('MONSTER_MAN', GameWad + ':MTEXTURES\MAN_SLEEP', 0, 0, 64, 64);
2883 g_CreateTextureWADSize('ITEM_BLUESPHERE', GameWad + ':TEXTURES\SBLUE', 0, 0, 32, 32);
2884 g_CreateTextureWADSize('ITEM_WHITESPHERE', GameWad + ':TEXTURES\SWHITE', 0, 0, 32, 32);
2885 g_CreateTextureWADSize('ITEM_ARMORGREEN', GameWad + ':TEXTURES\ARMORGREEN', 0, 0, 32, 16);
2886 g_CreateTextureWADSize('ITEM_ARMORBLUE', GameWad + ':TEXTURES\ARMORBLUE', 0, 0, 32, 16);
2887 g_CreateTextureWADSize('ITEM_INVUL', GameWad + ':TEXTURES\INVUL', 0, 0, 32, 32);
2888 g_CreateTextureWADSize('ITEM_BOTTLE', GameWad + ':TEXTURES\BOTTLE', 0, 0, 16, 32);
2889 g_CreateTextureWADSize('ITEM_HELMET', GameWad + ':TEXTURES\HELMET', 0, 0, 16, 16);
2890 g_CreateTextureWADSize('ITEM_JETPACK', GameWad + ':TEXTURES\JETPACK', 0, 0, 32, 32);
2891 g_CreateTextureWADSize('ITEM_INVIS', GameWad + ':TEXTURES\INVIS', 0, 0, 32, 32);
2892 g_CreateTextureWADSize('ITEM_WEAPON_FLAMETHROWER', GameWad + ':TEXTURES\FLAMETHROWER', 0, 0, 64, 32);
2893 g_CreateTextureWADSize('ITEM_AMMO_FUELCAN', GameWad + ':TEXTURES\FUELCAN', 0, 0, 16, 32);
2895 g_CreateTextureWAD('ITEM_MEDKIT_SMALL', GameWad + ':TEXTURES\MED1');
2896 g_CreateTextureWAD('ITEM_MEDKIT_LARGE', GameWad + ':TEXTURES\MED2');
2897 g_CreateTextureWAD('ITEM_WEAPON_SAW', GameWad + ':TEXTURES\SAW');
2898 g_CreateTextureWAD('ITEM_WEAPON_PISTOL', GameWad + ':TEXTURES\PISTOL');
2899 g_CreateTextureWAD('ITEM_WEAPON_KASTET', GameWad + ':TEXTURES\KASTET');
2900 g_CreateTextureWAD('ITEM_WEAPON_SHOTGUN1', GameWad + ':TEXTURES\SHOTGUN1');
2901 g_CreateTextureWAD('ITEM_WEAPON_SHOTGUN2', GameWad + ':TEXTURES\SHOTGUN2');
2902 g_CreateTextureWAD('ITEM_WEAPON_CHAINGUN', GameWad + ':TEXTURES\MGUN');
2903 g_CreateTextureWAD('ITEM_WEAPON_ROCKETLAUNCHER', GameWad + ':TEXTURES\RLAUNCHER');
2904 g_CreateTextureWAD('ITEM_WEAPON_PLASMA', GameWad + ':TEXTURES\PGUN');
2905 g_CreateTextureWAD('ITEM_WEAPON_BFG', GameWad + ':TEXTURES\BFG');
2906 g_CreateTextureWAD('ITEM_WEAPON_SUPERPULEMET', GameWad + ':TEXTURES\SPULEMET');
2907 g_CreateTextureWAD('ITEM_AMMO_BULLETS', GameWad + ':TEXTURES\CLIP');
2908 g_CreateTextureWAD('ITEM_AMMO_BULLETS_BOX', GameWad + ':TEXTURES\AMMO');
2909 g_CreateTextureWAD('ITEM_AMMO_SHELLS', GameWad + ':TEXTURES\SHELL1');
2910 g_CreateTextureWAD('ITEM_AMMO_SHELLS_BOX', GameWad + ':TEXTURES\SHELL2');
2911 g_CreateTextureWAD('ITEM_AMMO_ROCKET', GameWad + ':TEXTURES\ROCKET');
2912 g_CreateTextureWAD('ITEM_AMMO_ROCKET_BOX', GameWad + ':TEXTURES\ROCKETS');
2913 g_CreateTextureWAD('ITEM_AMMO_CELL', GameWad + ':TEXTURES\CELL');
2914 g_CreateTextureWAD('ITEM_AMMO_CELL_BIG', GameWad + ':TEXTURES\CELL2');
2915 g_CreateTextureWAD('ITEM_AMMO_BACKPACK', GameWad + ':TEXTURES\BPACK');
2916 g_CreateTextureWAD('ITEM_KEY_RED', GameWad + ':TEXTURES\KEYR');
2917 g_CreateTextureWAD('ITEM_KEY_GREEN', GameWad + ':TEXTURES\KEYG');
2918 g_CreateTextureWAD('ITEM_KEY_BLUE', GameWad + ':TEXTURES\KEYB');
2919 g_CreateTextureWAD('ITEM_OXYGEN', GameWad + ':TEXTURES\OXYGEN');
2920 g_CreateTextureWAD('ITEM_SUIT', GameWad + ':TEXTURES\SUIT');
2921 g_CreateTextureWAD('ITEM_MEDKIT_BLACK', GameWad + ':TEXTURES\BMED');
2923 g_CreateTextureWAD('AREA_PLAYERPOINT1', EditorWad + ':TEXTURES\P1POINT');
2924 g_CreateTextureWAD('AREA_PLAYERPOINT2', EditorWad + ':TEXTURES\P2POINT');
2925 g_CreateTextureWAD('AREA_DMPOINT', EditorWad + ':TEXTURES\DMPOINT');
2926 g_CreateTextureWAD('AREA_REDPOINT', EditorWad + ':TEXTURES\REDPOINT');
2927 g_CreateTextureWAD('AREA_BLUEPOINT', EditorWad + ':TEXTURES\BLUEPOINT');
2928 end;
2930 procedure FreeData();
2931 begin
2932 g_DeleteTexture('NOTEXTURE');
2934 g_DeleteTexture('ITEM_BLUESPHERE');
2935 g_DeleteTexture('ITEM_WHITESPHERE');
2936 g_DeleteTexture('ITEM_ARMORGREEN');
2937 g_DeleteTexture('ITEM_ARMORBLUE');
2938 g_DeleteTexture('ITEM_INVUL');
2939 g_DeleteTexture('ITEM_BOTTLE');
2940 g_DeleteTexture('ITEM_HELMET');
2941 g_DeleteTexture('AREA_REDFLAG');
2942 g_DeleteTexture('AREA_BLUEFLAG');
2943 g_DeleteTexture('AREA_DOMFLAG');
2945 g_DeleteTexture('MONSTER_DEMON');
2946 g_DeleteTexture('MONSTER_IMP');
2947 g_DeleteTexture('MONSTER_ZOMBY');
2948 g_DeleteTexture('MONSTER_SERG');
2949 g_DeleteTexture('MONSTER_CGUN');
2950 g_DeleteTexture('MONSTER_BARREL');
2951 g_DeleteTexture('MONSTER_MAN');
2953 g_DeleteTexture('MONSTER_DEMON');
2954 g_DeleteTexture('MONSTER_IMP');
2955 g_DeleteTexture('MONSTER_ZOMBY');
2956 g_DeleteTexture('MONSTER_SERG');
2957 g_DeleteTexture('MONSTER_CYBER');
2958 g_DeleteTexture('MONSTER_CGUN');
2959 g_DeleteTexture('MONSTER_BARON');
2960 g_DeleteTexture('MONSTER_KNIGHT');
2961 g_DeleteTexture('MONSTER_CACO');
2962 g_DeleteTexture('MONSTER_SOUL');
2963 g_DeleteTexture('MONSTER_PAIN');
2964 g_DeleteTexture('MONSTER_SPIDER');
2965 g_DeleteTexture('MONSTER_BSP');
2966 g_DeleteTexture('MONSTER_MANCUB');
2967 g_DeleteTexture('MONSTER_SKEL');
2968 g_DeleteTexture('MONSTER_VILE');
2969 g_DeleteTexture('MONSTER_FISH');
2970 g_DeleteTexture('MONSTER_BARREL');
2971 g_DeleteTexture('MONSTER_ROBO');
2972 g_DeleteTexture('MONSTER_MAN');
2974 g_DeleteTexture('ITEM_MEDKIT_SMALL');
2975 g_DeleteTexture('ITEM_MEDKIT_LARGE');
2976 g_DeleteTexture('ITEM_WEAPON_SAW');
2977 g_DeleteTexture('ITEM_WEAPON_PISTOL');
2978 g_DeleteTexture('ITEM_WEAPON_KASTET');
2979 g_DeleteTexture('ITEM_WEAPON_SHOTGUN1');
2980 g_DeleteTexture('ITEM_WEAPON_SHOTGUN2');
2981 g_DeleteTexture('ITEM_WEAPON_CHAINGUN');
2982 g_DeleteTexture('ITEM_WEAPON_ROCKETLAUNCHER');
2983 g_DeleteTexture('ITEM_WEAPON_PLASMA');
2984 g_DeleteTexture('ITEM_WEAPON_BFG');
2985 g_DeleteTexture('ITEM_WEAPON_SUPERPULEMET');
2986 g_DeleteTexture('ITEM_AMMO_BULLETS');
2987 g_DeleteTexture('ITEM_AMMO_BULLETS_BOX');
2988 g_DeleteTexture('ITEM_AMMO_SHELLS');
2989 g_DeleteTexture('ITEM_AMMO_SHELLS_BOX');
2990 g_DeleteTexture('ITEM_AMMO_ROCKET');
2991 g_DeleteTexture('ITEM_AMMO_ROCKET_BOX');
2992 g_DeleteTexture('ITEM_AMMO_CELL');
2993 g_DeleteTexture('ITEM_AMMO_CELL_BIG');
2994 g_DeleteTexture('ITEM_AMMO_BACKPACK');
2995 g_DeleteTexture('ITEM_KEY_RED');
2996 g_DeleteTexture('ITEM_KEY_GREEN');
2997 g_DeleteTexture('ITEM_KEY_BLUE');
2998 g_DeleteTexture('ITEM_OXYGEN');
2999 g_DeleteTexture('ITEM_SUIT');
3000 g_DeleteTexture('ITEM_MEDKIT_BLACK');
3001 g_DeleteTexture('ITEM_JETPACK');
3002 g_DeleteTexture('ITEM_INVIS');
3003 g_DeleteTexture('ITEM_WEAPON_FLAMETHROWER');
3004 g_DeleteTexture('ITEM_AMMO_FUELCAN');
3006 g_DeleteTexture('AREA_PLAYERPOINT1');
3007 g_DeleteTexture('AREA_PLAYERPOINT2');
3008 g_DeleteTexture('AREA_DMPOINT');
3009 g_DeleteTexture('AREA_REDPOINT');
3010 g_DeleteTexture('AREA_BLUEPOINT');
3011 end;
3013 end.