3 {$INCLUDE ../shared/a_modes.inc}
8 LCLIntf
, LCLType
, SysUtils
, Variants
, Classes
, Graphics
,
9 Controls
, Forms
, Dialogs
, StdCtrls
, Buttons
,
10 ComCtrls
, ValEdit
, Types
, Menus
, ExtCtrls
,
11 CheckLst
, Grids
, OpenGLContext
, Utils
, UTF8Process
;
17 TMainForm
= class(TForm
)
21 StatusBar
: TStatusBar
;
22 OpenDialog
: TOpenDialog
;
23 SaveDialog
: TSaveDialog
;
24 ColorDialog
: TColorDialog
;
28 ImageList
: TImageList
;
31 miAppleAbout
: TMenuItem
;
32 miAppleLine0
: TMenuItem
;
33 miApplePref
: TMenuItem
;
34 miAppleLine1
: TMenuItem
;
36 miMenuFile
: TMenuItem
;
39 miMacRecentSubMenu
: TMenuItem
;
40 miMacRecentEnd
: TMenuItem
;
41 miMacRecentClear
: TMenuItem
;
42 Separator1
: TMenuItem
;
44 miSaveMapAs
: TMenuItem
;
45 miOpenWadMap
: TMenuItem
;
47 miReopenMap
: TMenuItem
;
48 miSaveMiniMap
: TMenuItem
;
49 miDeleteMap
: TMenuItem
;
51 miWinRecentStart
: TMenuItem
;
52 miWinRecent
: TMenuItem
;
56 miMenuEdit
: TMenuItem
;
63 miSelectAll
: TMenuItem
;
65 miSnapToGrid
: TMenuItem
;
66 miSwitchGrid
: TMenuItem
;
67 Separator2
: TMenuItem
;
71 miMapOptions
: TMenuItem
;
74 miMenuView
: TMenuItem
;
85 miViewLine1
: TMenuItem
;
87 miShowEdges
: TMenuItem
;
88 miViewLine2
: TMenuItem
;
89 miMapPreview
: TMenuItem
;
91 miMenuService
: TMenuItem
;
92 miCheckMap
: TMenuItem
;
93 miOptimmization
: TMenuItem
;
96 miMenuWindow
: TMenuItem
;
97 miMacMinimize
: TMenuItem
;
100 miMenuHelp
: TMenuItem
;
103 miMenuHidden
: TMenuItem
;
104 minexttab
: TMenuItem
;
105 selectall1
: TMenuItem
;
108 ilToolbar
: TImageList
;
109 MainToolBar
: TToolBar
;
110 tbNewMap
: TToolButton
;
111 tbOpenMap
: TToolButton
;
112 tbSaveMap
: TToolButton
;
113 tbOpenWadMap
: TToolButton
;
114 tbLine1
: TToolButton
;
115 tbShowMap
: TToolButton
;
116 tbLine2
: TToolButton
;
119 miLayerP1
: TMenuItem
;
120 miLayerP2
: TMenuItem
;
121 miLayerP3
: TMenuItem
;
122 miLayerP4
: TMenuItem
;
123 miLayerP5
: TMenuItem
;
124 miLayerP6
: TMenuItem
;
125 miLayerP7
: TMenuItem
;
126 miLayerP8
: TMenuItem
;
127 miLayerP9
: TMenuItem
;
128 tbLine3
: TToolButton
;
129 tbGridOn
: TToolButton
;
131 tbLine4
: TToolButton
;
132 tbTestMap
: TToolButton
;
135 pLoadProgress
: TPanel
;
137 pbLoad
: TProgressBar
;
141 RenderPanel
: TOpenGLControl
;
142 sbHorizontal
: TScrollBar
;
143 sbVertical
: TScrollBar
;
145 // Object propertiy editor:
147 PanelPropApply
: TPanel
;
148 bApplyProperty
: TButton
;
149 vleObjectProperty
: TValueListEditor
;
153 pcObjects
: TPageControl
;
156 PanelPanelType
: TPanel
;
157 lbPanelType
: TListBox
;
158 lbTextureList
: TListBox
;
159 PanelTextures
: TPanel
;
161 lTextureWidth
: TLabel
;
163 lTextureHeight
: TLabel
;
164 cbPreview
: TCheckBox
;
165 bbAddTexture
: TBitBtn
;
166 bbRemoveTexture
: TBitBtn
;
167 bClearTexture
: TButton
;
170 lbItemList
: TListBox
;
174 tsMonsters
: TTabSheet
;
175 lbMonsterList
: TListBox
;
176 rbMonsterLeft
: TRadioButton
;
177 rbMonsterRight
: TRadioButton
;
180 lbAreasList
: TListBox
;
181 rbAreaLeft
: TRadioButton
;
182 rbAreaRight
: TRadioButton
;
184 tsTriggers
: TTabSheet
;
185 lbTriggersList
: TListBox
;
186 clbActivationType
: TCheckListBox
;
187 clbKeys
: TCheckListBox
;
189 procedure aAboutExecute(Sender
: TObject
);
190 procedure aCheckMapExecute(Sender
: TObject
);
191 procedure aMoveToFore(Sender
: TObject
);
192 procedure aMoveToBack(Sender
: TObject
);
193 procedure aCopyObjectExecute(Sender
: TObject
);
194 procedure aCutObjectExecute(Sender
: TObject
);
195 procedure aEditorOptionsExecute(Sender
: TObject
);
196 procedure aExitExecute(Sender
: TObject
);
197 procedure aMapOptionsExecute(Sender
: TObject
);
198 procedure aNewMapExecute(Sender
: TObject
);
199 procedure aOpenMapExecute(Sender
: TObject
);
200 procedure aOptimizeExecute(Sender
: TObject
);
201 procedure aPasteObjectExecute(Sender
: TObject
);
202 procedure aSelectAllExecute(Sender
: TObject
);
203 procedure aSaveMapExecute(Sender
: TObject
);
204 procedure aSaveMapAsExecute(Sender
: TObject
);
205 procedure aUndoExecute(Sender
: TObject
);
206 procedure aDeleteMap(Sender
: TObject
);
207 procedure bApplyPropertyClick(Sender
: TObject
);
208 procedure bbAddTextureClick(Sender
: TObject
);
209 procedure bbRemoveTextureClick(Sender
: TObject
);
210 procedure FormActivate(Sender
: TObject
);
211 procedure FormCloseQuery(Sender
: TObject
; var CanClose
: Boolean);
212 procedure FormCreate(Sender
: TObject
);
213 procedure FormDestroy(Sender
: TObject
);
214 procedure FormDropFiles(Sender
: TObject
; const FileNames
: array of String);
215 procedure FormKeyDown(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
216 procedure FormResize(Sender
: TObject
);
217 procedure FormWindowStateChange(Sender
: TObject
);
218 procedure miRecentFileExecute(Sender
: TObject
);
219 procedure miMacRecentClearClick(Sender
: TObject
);
220 procedure miMacZoomClick(Sender
: TObject
);
221 procedure lbTextureListClick(Sender
: TObject
);
222 procedure lbTextureListDrawItem(Control
: TWinControl
; Index
: Integer;
223 ARect
: TRect
; State
: TOwnerDrawState
);
224 procedure miMacMinimizeClick(Sender
: TObject
);
225 procedure miReopenMapClick(Sender
: TObject
);
226 procedure RenderPanelMouseDown(Sender
: TObject
; Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
227 procedure RenderPanelMouseMove(Sender
: TObject
; Shift
: TShiftState
; X
, Y
: Integer);
228 procedure RenderPanelMouseUp(Sender
: TObject
; Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
229 procedure RenderPanelPaint(Sender
: TObject
);
230 procedure RenderPanelResize(Sender
: TObject
);
231 procedure Splitter1Moved(Sender
: TObject
);
232 procedure MapTestCheck(Sender
: TObject
);
233 procedure vleObjectPropertyEditButtonClick(Sender
: TObject
);
234 procedure vleObjectPropertyApply(Sender
: TObject
);
235 procedure vleObjectPropertyGetPickList(Sender
: TObject
; const KeyName
: String; Values
: TStrings
);
236 procedure vleObjectPropertyKeyDown(Sender
: TObject
; var Key
: Word;
238 procedure tbGridOnClick(Sender
: TObject
);
239 procedure miMapPreviewClick(Sender
: TObject
);
240 procedure miLayer1Click(Sender
: TObject
);
241 procedure miLayer2Click(Sender
: TObject
);
242 procedure miLayer3Click(Sender
: TObject
);
243 procedure miLayer4Click(Sender
: TObject
);
244 procedure miLayer5Click(Sender
: TObject
);
245 procedure miLayer6Click(Sender
: TObject
);
246 procedure miLayer7Click(Sender
: TObject
);
247 procedure miLayer8Click(Sender
: TObject
);
248 procedure miLayer9Click(Sender
: TObject
);
249 procedure tbShowClick(Sender
: TObject
);
250 procedure miSnapToGridClick(Sender
: TObject
);
251 procedure miMiniMapClick(Sender
: TObject
);
252 procedure miSwitchGridClick(Sender
: TObject
);
253 procedure miShowEdgesClick(Sender
: TObject
);
254 procedure minexttabClick(Sender
: TObject
);
255 procedure miSaveMiniMapClick(Sender
: TObject
);
256 procedure bClearTextureClick(Sender
: TObject
);
257 procedure miPackMapClick(Sender
: TObject
);
258 procedure miTestMapClick(Sender
: TObject
);
259 procedure sbVerticalScroll(Sender
: TObject
; ScrollCode
: TScrollCode
;
260 var ScrollPos
: Integer);
261 procedure sbHorizontalScroll(Sender
: TObject
; ScrollCode
: TScrollCode
;
262 var ScrollPos
: Integer);
263 procedure miOpenWadMapClick(Sender
: TObject
);
264 procedure selectall1Click(Sender
: TObject
);
265 procedure Splitter1CanResize(Sender
: TObject
; var NewSize
: Integer;
266 var Accept
: Boolean);
267 procedure Splitter2CanResize(Sender
: TObject
; var NewSize
: Integer;
268 var Accept
: Boolean);
269 procedure vleObjectPropertyEnter(Sender
: TObject
);
270 procedure vleObjectPropertyExit(Sender
: TObject
);
271 procedure FormKeyUp(Sender
: TObject
; var Key
: Word;
275 procedure OnIdle(Sender
: TObject
; var Done
: Boolean);
276 procedure RefillRecentMenu (menu
: TMenuItem
; start
: Integer; fmt
: AnsiString);
278 procedure RefreshRecentMenu();
279 procedure OpenMapFile(FileName
: String);
280 function RenderMousePos(): TPoint
;
281 procedure RecountSelectedObjects();
287 LAYER_FOREGROUND
= 2;
295 TEST_MAP_NAME
= '$$$_TEST_$$$';
296 LANGUAGE_FILE_NAME
= '_Editor.txt';
307 DotStepOne
, DotStepTwo
: Word;
309 DrawTexturePanel
: Boolean;
310 DrawPanelSize
: Boolean;
312 PreviewColor
: TColor
;
313 UseCheckerboard
: Boolean;
315 RecentCount
: Integer;
316 RecentFiles
: TStringList
;
317 slInvalidTextures
: TStringList
;
319 TestGameMode
: String;
321 TestLimScore
: String;
322 TestOptionsTwoPlayers
: Boolean;
323 TestOptionsTeamDamage
: Boolean;
324 TestOptionsAllowExit
: Boolean;
325 TestOptionsWeaponStay
: Boolean;
326 TestOptionsMonstersDM
: Boolean;
327 TestD2dExe
, TestD2DArgs
: String;
328 TestMapOnce
: Boolean;
330 LayerEnabled
: Array [LAYER_BACK
..LAYER_TRIGGERS
] of Boolean =
331 (True, True, True, True, True, True, True, True, True);
332 ContourEnabled
: Array [LAYER_BACK
..LAYER_TRIGGERS
] of Boolean =
333 (False, False, False, False, False, False, False, False, False);
334 PreviewMode
: Byte = 0;
340 procedure OpenMap(FileName
: String; mapN
: String);
341 function AddTexture(aWAD
, aSection
, aTex
: String; silent
: Boolean): Boolean;
342 procedure RemoveSelectFromObjects();
343 procedure ChangeShownProperty(Name
: String; NewValue
: String);
348 f_options
, e_graphics
, e_log
, GL
, Math
,
349 f_mapoptions
, g_basic
, f_about
, f_mapoptimization
,
350 f_mapcheck
, f_addresource_texture
, g_textures
,
351 f_activationtype
, f_keys
, wadreader
, fileutil
,
352 MAPREADER
, f_selectmap
, f_savemap
, WADEDITOR
, WADSTRUCT
, MAPDEF
,
353 g_map
, f_saveminimap
, f_addresource
, CONFIG
, f_packmap
,
354 f_addresource_sound
, f_choosetype
,
355 g_language
, ClipBrd
, g_options
;
358 UNDO_DELETE_PANEL
= 1;
359 UNDO_DELETE_ITEM
= 2;
360 UNDO_DELETE_AREA
= 3;
361 UNDO_DELETE_MONSTER
= 4;
362 UNDO_DELETE_TRIGGER
= 5;
366 UNDO_ADD_MONSTER
= 9;
367 UNDO_ADD_TRIGGER
= 10;
368 UNDO_MOVE_PANEL
= 11;
371 UNDO_MOVE_MONSTER
= 14;
372 UNDO_MOVE_TRIGGER
= 15;
373 UNDO_RESIZE_PANEL
= 16;
374 UNDO_RESIZE_TRIGGER
= 17;
376 MOUSEACTION_NONE
= 0;
377 MOUSEACTION_DRAWPANEL
= 1;
378 MOUSEACTION_DRAWTRIGGER
= 2;
379 MOUSEACTION_MOVEOBJ
= 3;
380 MOUSEACTION_RESIZE
= 4;
381 MOUSEACTION_MOVEMAP
= 5;
382 MOUSEACTION_DRAWPRESS
= 6;
383 MOUSEACTION_NOACTION
= 7;
386 RESIZETYPE_VERTICAL
= 1;
387 RESIZETYPE_HORIZONTAL
= 2;
396 SELECTFLAG_TELEPORT
= 1;
398 SELECTFLAG_TEXTURE
= 3;
400 SELECTFLAG_MONSTER
= 5;
401 SELECTFLAG_SPAWNPOINT
= 6;
402 SELECTFLAG_SHOTPANEL
= 7;
403 SELECTFLAG_SELECTED
= 8;
405 RECENT_FILES_MENU_START
= 12;
407 CLIPBOARD_SIG
= 'DF:ED';
411 case UndoType
: Byte of
412 UNDO_DELETE_PANEL
: (Panel
: ^TPanel
);
413 UNDO_DELETE_ITEM
: (Item
: TItem
);
414 UNDO_DELETE_AREA
: (Area
: TArea
);
415 UNDO_DELETE_MONSTER
: (Monster
: TMonster
);
416 UNDO_DELETE_TRIGGER
: (Trigger
: TTrigger
);
421 UNDO_ADD_TRIGGER
: (AddID
: DWORD
);
426 UNDO_MOVE_TRIGGER
: (MoveID
: DWORD
; dX
, dY
: Integer);
428 UNDO_RESIZE_TRIGGER
: (ResizeID
: DWORD
; dW
, dH
: Integer);
433 case ObjectType
: Byte of
434 OBJECT_PANEL
: (Panel
: ^TPanel
);
435 OBJECT_ITEM
: (Item
: TItem
);
436 OBJECT_AREA
: (Area
: TArea
);
437 OBJECT_MONSTER
: (Monster
: TMonster
);
438 OBJECT_TRIGGER
: (Trigger
: TTrigger
);
441 TCopyRecArray
= Array of TCopyRec
;
445 gDataLoaded
: Boolean = False;
446 ShowMap
: Boolean = False;
447 DrawRect
: PRect
= nil;
448 SnapToGrid
: Boolean = True;
450 MousePos
: Types
.TPoint
;
451 LastMovePoint
: Types
.TPoint
;
455 MouseLDownPos
: Types
.TPoint
;
456 MouseRDownPos
: Types
.TPoint
;
457 MouseMDownPos
: Types
.TPoint
;
459 SelectFlag
: Byte = SELECTFLAG_NONE
;
460 MouseAction
: Byte = MOUSEACTION_NONE
;
461 ResizeType
: Byte = RESIZETYPE_NONE
;
462 ResizeDirection
: Byte = RESIZEDIR_NONE
;
464 DrawPressRect
: Boolean = False;
465 EditingProperties
: Boolean = False;
467 UndoBuffer
: Array of Array of TUndoRec
= nil;
469 MapTestProcess
: TProcessUTF8
;
474 //----------------------------------------
475 //Далее идут вспомогательные процедуры
476 //----------------------------------------
478 function NameToBool(Name
: String): Boolean;
480 if Name
= BoolNames
[True] then
486 function NameToDir(Name
: String): TDirection
;
488 if Name
= DirNames
[D_LEFT
] then
494 function NameToDirAdv(Name
: String): Byte;
496 if Name
= DirNamesAdv
[1] then
499 if Name
= DirNamesAdv
[2] then
502 if Name
= DirNamesAdv
[3] then
508 function ActivateToStr(ActivateType
: Byte): String;
512 if ByteBool(ACTIVATE_PLAYERCOLLIDE
and ActivateType
) then
513 Result
:= Result
+ '+PC';
514 if ByteBool(ACTIVATE_MONSTERCOLLIDE
and ActivateType
) then
515 Result
:= Result
+ '+MC';
516 if ByteBool(ACTIVATE_PLAYERPRESS
and ActivateType
) then
517 Result
:= Result
+ '+PP';
518 if ByteBool(ACTIVATE_MONSTERPRESS
and ActivateType
) then
519 Result
:= Result
+ '+MP';
520 if ByteBool(ACTIVATE_SHOT
and ActivateType
) then
521 Result
:= Result
+ '+SH';
522 if ByteBool(ACTIVATE_NOMONSTER
and ActivateType
) then
523 Result
:= Result
+ '+NM';
525 if (Result
<> '') and (Result
[1] = '+') then
526 Delete(Result
, 1, 1);
529 function StrToActivate(Str
: String): Byte;
533 if Pos('PC', Str
) > 0 then
534 Result
:= ACTIVATE_PLAYERCOLLIDE
;
535 if Pos('MC', Str
) > 0 then
536 Result
:= Result
or ACTIVATE_MONSTERCOLLIDE
;
537 if Pos('PP', Str
) > 0 then
538 Result
:= Result
or ACTIVATE_PLAYERPRESS
;
539 if Pos('MP', Str
) > 0 then
540 Result
:= Result
or ACTIVATE_MONSTERPRESS
;
541 if Pos('SH', Str
) > 0 then
542 Result
:= Result
or ACTIVATE_SHOT
;
543 if Pos('NM', Str
) > 0 then
544 Result
:= Result
or ACTIVATE_NOMONSTER
;
547 function KeyToStr(Key
: Byte): String;
551 if ByteBool(KEY_RED
and Key
) then
552 Result
:= Result
+ '+RK';
553 if ByteBool(KEY_GREEN
and Key
) then
554 Result
:= Result
+ '+GK';
555 if ByteBool(KEY_BLUE
and Key
) then
556 Result
:= Result
+ '+BK';
557 if ByteBool(KEY_REDTEAM
and Key
) then
558 Result
:= Result
+ '+RT';
559 if ByteBool(KEY_BLUETEAM
and Key
) then
560 Result
:= Result
+ '+BT';
562 if (Result
<> '') and (Result
[1] = '+') then
563 Delete(Result
, 1, 1);
566 function StrToKey(Str
: String): Byte;
570 if Pos('RK', Str
) > 0 then
572 if Pos('GK', Str
) > 0 then
573 Result
:= Result
or KEY_GREEN
;
574 if Pos('BK', Str
) > 0 then
575 Result
:= Result
or KEY_BLUE
;
576 if Pos('RT', Str
) > 0 then
577 Result
:= Result
or KEY_REDTEAM
;
578 if Pos('BT', Str
) > 0 then
579 Result
:= Result
or KEY_BLUETEAM
;
582 function EffectToStr(Effect
: Byte): String;
584 if Effect
in [EFFECT_TELEPORT
..EFFECT_FIRE
] then
585 Result
:= EffectNames
[Effect
]
587 Result
:= EffectNames
[EFFECT_NONE
];
590 function StrToEffect(Str
: String): Byte;
594 Result
:= EFFECT_NONE
;
595 for i
:= EFFECT_TELEPORT
to EFFECT_FIRE
do
596 if EffectNames
[i
] = Str
then
603 function MonsterToStr(MonType
: Byte): String;
605 if MonType
in [MONSTER_DEMON
..MONSTER_MAN
] then
606 Result
:= MonsterNames
[MonType
]
608 Result
:= MonsterNames
[MONSTER_ZOMBY
];
611 function StrToMonster(Str
: String): Byte;
615 Result
:= MONSTER_ZOMBY
;
616 for i
:= MONSTER_DEMON
to MONSTER_MAN
do
617 if MonsterNames
[i
] = Str
then
624 function ItemToStr(ItemType
: Byte): String;
626 if ItemType
in [ITEM_MEDKIT_SMALL
..ITEM_MAX
] then
627 Result
:= ItemNames
[ItemType
]
629 Result
:= ItemNames
[ITEM_AMMO_BULLETS
];
632 function StrToItem(Str
: String): Byte;
636 Result
:= ITEM_AMMO_BULLETS
;
637 for i
:= ITEM_MEDKIT_SMALL
to ITEM_MAX
do
638 if ItemNames
[i
] = Str
then
645 function ShotToStr(ShotType
: Byte): String;
647 if ShotType
in [TRIGGER_SHOT_PISTOL
..TRIGGER_SHOT_MAX
] then
648 Result
:= ShotNames
[ShotType
]
650 Result
:= ShotNames
[TRIGGER_SHOT_PISTOL
];
653 function StrToShot(Str
: String): Byte;
657 Result
:= TRIGGER_SHOT_PISTOL
;
658 for i
:= TRIGGER_SHOT_PISTOL
to TRIGGER_SHOT_MAX
do
659 if ShotNames
[i
] = Str
then
666 function SelectedObjectCount(): Word;
672 if SelectedObjects
= nil then
675 for a
:= 0 to High(SelectedObjects
) do
676 if SelectedObjects
[a
].Live
then
677 Result
:= Result
+ 1;
680 function GetFirstSelected(): Integer;
686 if SelectedObjects
= nil then
689 for a
:= 0 to High(SelectedObjects
) do
690 if SelectedObjects
[a
].Live
then
697 function Normalize16(x
: Integer): Integer;
699 Result
:= (x
div 16) * 16;
702 procedure MoveMap(X
, Y
: Integer);
704 rx
, ry
, ScaleSz
: Integer;
706 with MainForm
.RenderPanel
do
708 ScaleSz
:= 16 div Scale
;
709 // Размер видимой части карты:
710 rx
:= Min(Normalize16(Width
), Normalize16(gMapInfo
.Width
)) div 2;
711 ry
:= Min(Normalize16(Height
), Normalize16(gMapInfo
.Height
)) div 2;
712 // Место клика на мини-карте:
713 MapOffset
.X
:= X
- (Width
- Max(gMapInfo
.Width
div ScaleSz
, 1) - 1);
714 MapOffset
.Y
:= Y
- 1;
715 // Это же место на "большой" карте:
716 MapOffset
.X
:= MapOffset
.X
* ScaleSz
;
717 MapOffset
.Y
:= MapOffset
.Y
* ScaleSz
;
718 // Левый верхний угол новой видимой части карты:
719 MapOffset
.X
:= MapOffset
.X
- rx
;
720 MapOffset
.Y
:= MapOffset
.Y
- ry
;
722 MapOffset
.X
:= EnsureRange(MapOffset
.X
, MainForm
.sbHorizontal
.Min
, MainForm
.sbHorizontal
.Max
);
723 MapOffset
.Y
:= EnsureRange(MapOffset
.Y
, MainForm
.sbVertical
.Min
, MainForm
.sbVertical
.Max
);
725 // MapOffset.X := Normalize16(MapOffset.X);
726 // MapOffset.Y := Normalize16(MapOffset.Y);
729 MainForm
.sbHorizontal
.Position
:= MapOffset
.X
;
730 MainForm
.sbVertical
.Position
:= MapOffset
.Y
;
732 MapOffset
.X
:= -MapOffset
.X
;
733 MapOffset
.Y
:= -MapOffset
.Y
;
738 function IsTexturedPanel(PanelType
: Word): Boolean;
740 Result
:= WordBool(PanelType
and (PANEL_WALL
or PANEL_BACK
or PANEL_FORE
or
741 PANEL_STEP
or PANEL_OPENDOOR
or PANEL_CLOSEDOOR
or
742 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
));
745 procedure FillProperty();
750 MainForm
.vleObjectProperty
.Strings
.Clear();
751 MainForm
.RecountSelectedObjects();
753 // Отображаем свойства если выделен только один объект:
754 if SelectedObjectCount() <> 1 then
757 _id
:= GetFirstSelected();
758 if not SelectedObjects
[_id
].Live
then
761 with MainForm
.vleObjectProperty
do
762 with ItemProps
[InsertRow(MsgPropId
, IntToStr(SelectedObjects
[_id
].ID
), True)] do
764 EditStyle
:= esSimple
;
768 case SelectedObjects
[0].ObjectType
of
771 with MainForm
.vleObjectProperty
,
772 gPanels
[SelectedObjects
[_id
].ID
] do
774 with ItemProps
[InsertRow(MsgPropX
, IntToStr(X
), True)] do
776 EditStyle
:= esSimple
;
780 with ItemProps
[InsertRow(MsgPropY
, IntToStr(Y
), True)] do
782 EditStyle
:= esSimple
;
786 with ItemProps
[InsertRow(MsgPropWidth
, IntToStr(Width
), True)] do
788 EditStyle
:= esSimple
;
792 with ItemProps
[InsertRow(MsgPropHeight
, IntToStr(Height
), True)] do
794 EditStyle
:= esSimple
;
798 with ItemProps
[InsertRow(MsgPropPanelType
, GetPanelName(PanelType
), True)] do
800 EditStyle
:= esEllipsis
;
804 if IsTexturedPanel(PanelType
) then
805 begin // Может быть текстура
806 with ItemProps
[InsertRow(MsgPropPanelTex
, TextureName
, True)] do
808 EditStyle
:= esEllipsis
;
812 if TextureName
<> '' then
813 begin // Есть текстура
814 with ItemProps
[InsertRow(MsgPropPanelAlpha
, IntToStr(Alpha
), True)] do
816 EditStyle
:= esSimple
;
820 with ItemProps
[InsertRow(MsgPropPanelBlend
, BoolNames
[Blending
], True)] do
822 EditStyle
:= esPickList
;
832 with MainForm
.vleObjectProperty
,
833 gItems
[SelectedObjects
[_id
].ID
] do
835 with ItemProps
[InsertRow(MsgPropX
, IntToStr(X
), True)] do
837 EditStyle
:= esSimple
;
841 with ItemProps
[InsertRow(MsgPropY
, IntToStr(Y
), True)] do
843 EditStyle
:= esSimple
;
847 with ItemProps
[InsertRow(MsgPropDmOnly
, BoolNames
[OnlyDM
], True)] do
849 EditStyle
:= esPickList
;
853 with ItemProps
[InsertRow(MsgPropItemFalls
, BoolNames
[Fall
], True)] do
855 EditStyle
:= esPickList
;
863 with MainForm
.vleObjectProperty
,
864 gMonsters
[SelectedObjects
[_id
].ID
] do
866 with ItemProps
[InsertRow(MsgPropX
, IntToStr(X
), True)] do
868 EditStyle
:= esSimple
;
872 with ItemProps
[InsertRow(MsgPropY
, IntToStr(Y
), True)] do
874 EditStyle
:= esSimple
;
878 with ItemProps
[InsertRow(MsgPropDirection
, DirNames
[Direction
], True)] do
880 EditStyle
:= esPickList
;
888 with MainForm
.vleObjectProperty
,
889 gAreas
[SelectedObjects
[_id
].ID
] do
891 with ItemProps
[InsertRow(MsgPropX
, IntToStr(X
), True)] do
893 EditStyle
:= esSimple
;
897 with ItemProps
[InsertRow(MsgPropY
, IntToStr(Y
), True)] do
899 EditStyle
:= esSimple
;
903 with ItemProps
[InsertRow(MsgPropDirection
, DirNames
[Direction
], True)] do
905 EditStyle
:= esPickList
;
913 with MainForm
.vleObjectProperty
,
914 gTriggers
[SelectedObjects
[_id
].ID
] do
916 with ItemProps
[InsertRow(MsgPropTrType
, GetTriggerName(TriggerType
), True)] do
918 EditStyle
:= esSimple
;
922 with ItemProps
[InsertRow(MsgPropX
, IntToStr(X
), True)] do
924 EditStyle
:= esSimple
;
928 with ItemProps
[InsertRow(MsgPropY
, IntToStr(Y
), True)] do
930 EditStyle
:= esSimple
;
934 with ItemProps
[InsertRow(MsgPropWidth
, IntToStr(Width
), True)] do
936 EditStyle
:= esSimple
;
940 with ItemProps
[InsertRow(MsgPropHeight
, IntToStr(Height
), True)] do
942 EditStyle
:= esSimple
;
946 with ItemProps
[InsertRow(MsgPropTrEnabled
, BoolNames
[Enabled
], True)] do
948 EditStyle
:= esPickList
;
952 with ItemProps
[InsertRow(MsgPropTrTexturePanel
, IntToStr(TexturePanel
), True)] do
954 EditStyle
:= esEllipsis
;
958 with ItemProps
[InsertRow(MsgPropTrActivation
, ActivateToStr(ActivateType
), True)] do
960 EditStyle
:= esEllipsis
;
964 with ItemProps
[InsertRow(MsgPropTrKeys
, KeyToStr(Key
), True)] do
966 EditStyle
:= esEllipsis
;
973 str
:= win2utf(Data
.MapName
);
974 with ItemProps
[InsertRow(MsgPropTrNextMap
, str
, True)] do
976 EditStyle
:= esEllipsis
;
983 with ItemProps
[InsertRow(MsgPropTrTeleportTo
, Format('(%d:%d)', [Data
.TargetPoint
.X
, Data
.TargetPoint
.Y
]), True)] do
985 EditStyle
:= esEllipsis
;
989 with ItemProps
[InsertRow(MsgPropTrD2d
, BoolNames
[Data
.d2d_teleport
], True)] do
991 EditStyle
:= esPickList
;
995 with ItemProps
[InsertRow(MsgPropTrTeleportSilent
, BoolNames
[Data
.silent_teleport
], True)] do
997 EditStyle
:= esPickList
;
1001 with ItemProps
[InsertRow(MsgPropTrTeleportDir
, DirNamesAdv
[Data
.TlpDir
], True)] do
1003 EditStyle
:= esPickList
;
1008 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
,
1009 TRIGGER_DOOR
, TRIGGER_DOOR5
:
1011 with ItemProps
[InsertRow(MsgPropTrDoorPanel
, IntToStr(Data
.PanelID
), True)] do
1013 EditStyle
:= esEllipsis
;
1017 with ItemProps
[InsertRow(MsgPropTrSilent
, BoolNames
[Data
.NoSound
], True)] do
1019 EditStyle
:= esPickList
;
1023 with ItemProps
[InsertRow(MsgPropTrD2d
, BoolNames
[Data
.d2d_doors
], True)] do
1025 EditStyle
:= esPickList
;
1030 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
:
1032 with ItemProps
[InsertRow(MsgPropTrTrapPanel
, IntToStr(Data
.PanelID
), True)] do
1034 EditStyle
:= esEllipsis
;
1038 with ItemProps
[InsertRow(MsgPropTrSilent
, BoolNames
[Data
.NoSound
], True)] do
1040 EditStyle
:= esPickList
;
1044 with ItemProps
[InsertRow(MsgPropTrD2d
, BoolNames
[Data
.d2d_doors
], True)] do
1046 EditStyle
:= esPickList
;
1051 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
1054 with ItemProps
[InsertRow(MsgPropTrExArea
,
1055 Format('(%d:%d %d:%d)', [Data
.tX
, Data
.tY
, Data
.tWidth
, Data
.tHeight
]), True)] do
1057 EditStyle
:= esEllipsis
;
1061 with ItemProps
[InsertRow(MsgPropTrExDelay
, IntToStr(Data
.Wait
), True)] do
1063 EditStyle
:= esSimple
;
1067 with ItemProps
[InsertRow(MsgPropTrExCount
, IntToStr(Data
.Count
), True)] do
1069 EditStyle
:= esSimple
;
1073 with ItemProps
[InsertRow(MsgPropTrExMonster
, IntToStr(Data
.MonsterID
-1), True)] do
1075 EditStyle
:= esEllipsis
;
1079 if TriggerType
= TRIGGER_PRESS
then
1080 with ItemProps
[InsertRow(MsgPropTrExRandom
, BoolNames
[Data
.ExtRandom
], True)] do
1082 EditStyle
:= esPickList
;
1090 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
1092 with ItemProps
[InsertRow(MsgPropTrLiftPanel
, IntToStr(Data
.PanelID
), True)] do
1094 EditStyle
:= esEllipsis
;
1098 with ItemProps
[InsertRow(MsgPropTrSilent
, BoolNames
[Data
.NoSound
], True)] do
1100 EditStyle
:= esPickList
;
1104 with ItemProps
[InsertRow(MsgPropTrD2d
, BoolNames
[Data
.d2d_doors
], True)] do
1106 EditStyle
:= esPickList
;
1113 with ItemProps
[InsertRow(MsgPropTrTextureOnce
, BoolNames
[Data
.ActivateOnce
], True)] do
1115 EditStyle
:= esPickList
;
1119 with ItemProps
[InsertRow(MsgPropTrTextureAnimOnce
, BoolNames
[Data
.AnimOnce
], True)] do
1121 EditStyle
:= esPickList
;
1128 str
:= win2utf(Data
.SoundName
);
1129 with ItemProps
[InsertRow(MsgPropTrSoundName
, str
, True)] do
1131 EditStyle
:= esEllipsis
;
1135 with ItemProps
[InsertRow(MsgPropTrSoundVolume
, IntToStr(Data
.Volume
), True)] do
1137 EditStyle
:= esSimple
;
1141 with ItemProps
[InsertRow(MsgPropTrSoundPan
, IntToStr(Data
.Pan
), True)] do
1143 EditStyle
:= esSimple
;
1147 with ItemProps
[InsertRow(MsgPropTrSoundCount
, IntToStr(Data
.PlayCount
), True)] do
1149 EditStyle
:= esSimple
;
1153 with ItemProps
[InsertRow(MsgPropTrSoundLocal
, BoolNames
[Data
.Local
], True)] do
1155 EditStyle
:= esPickList
;
1159 with ItemProps
[InsertRow(MsgPropTrSoundSwitch
, BoolNames
[Data
.SoundSwitch
], True)] do
1161 EditStyle
:= esPickList
;
1166 TRIGGER_SPAWNMONSTER
:
1168 with ItemProps
[InsertRow(MsgPropTrMonsterType
, MonsterToStr(Data
.MonType
), True)] do
1170 EditStyle
:= esEllipsis
;
1174 with ItemProps
[InsertRow(MsgPropTrSpawnTo
,
1175 Format('(%d:%d)', [Data
.MonPos
.X
, Data
.MonPos
.Y
]), True)] do
1177 EditStyle
:= esEllipsis
;
1181 with ItemProps
[InsertRow(MsgPropDirection
, DirNames
[TDirection(Data
.MonDir
)], True)] do
1183 EditStyle
:= esPickList
;
1187 with ItemProps
[InsertRow(MsgPropTrHealth
, IntToStr(Data
.MonHealth
), True)] do
1189 EditStyle
:= esSimple
;
1193 with ItemProps
[InsertRow(MsgPropTrMonsterActive
, BoolNames
[Data
.MonActive
], True)] do
1195 EditStyle
:= esPickList
;
1199 with ItemProps
[InsertRow(MsgPropTrCount
, IntToStr(Data
.MonCount
), True)] do
1201 EditStyle
:= esSimple
;
1205 with ItemProps
[InsertRow(MsgPropTrFxType
, EffectToStr(Data
.MonEffect
), True)] do
1207 EditStyle
:= esEllipsis
;
1211 with ItemProps
[InsertRow(MsgPropTrSpawnMax
, IntToStr(Data
.MonMax
), True)] do
1213 EditStyle
:= esSimple
;
1217 with ItemProps
[InsertRow(MsgPropTrSpawnDelay
, IntToStr(Data
.MonDelay
), True)] do
1219 EditStyle
:= esSimple
;
1223 case Data
.MonBehav
of
1224 1: str
:= MsgPropTrMonsterBehaviour1
;
1225 2: str
:= MsgPropTrMonsterBehaviour2
;
1226 3: str
:= MsgPropTrMonsterBehaviour3
;
1227 4: str
:= MsgPropTrMonsterBehaviour4
;
1228 5: str
:= MsgPropTrMonsterBehaviour5
;
1229 else str
:= MsgPropTrMonsterBehaviour0
;
1231 with ItemProps
[InsertRow(MsgPropTrMonsterBehaviour
, str
, True)] do
1233 EditStyle
:= esPickList
;
1240 with ItemProps
[InsertRow(MsgPropTrItemType
, ItemToStr(Data
.ItemType
), True)] do
1242 EditStyle
:= esEllipsis
;
1246 with ItemProps
[InsertRow(MsgPropTrSpawnTo
,
1247 Format('(%d:%d)', [Data
.ItemPos
.X
, Data
.ItemPos
.Y
]), True)] do
1249 EditStyle
:= esEllipsis
;
1253 with ItemProps
[InsertRow(MsgPropDmOnly
, BoolNames
[Data
.ItemOnlyDM
], True)] do
1255 EditStyle
:= esPickList
;
1259 with ItemProps
[InsertRow(MsgPropItemFalls
, BoolNames
[Data
.ItemFalls
], True)] do
1261 EditStyle
:= esPickList
;
1265 with ItemProps
[InsertRow(MsgPropTrCount
, IntToStr(Data
.ItemCount
), True)] do
1267 EditStyle
:= esSimple
;
1271 with ItemProps
[InsertRow(MsgPropTrFxType
, EffectToStr(Data
.ItemEffect
), True)] do
1273 EditStyle
:= esEllipsis
;
1277 with ItemProps
[InsertRow(MsgPropTrSpawnMax
, IntToStr(Data
.ItemMax
), True)] do
1279 EditStyle
:= esSimple
;
1283 with ItemProps
[InsertRow(MsgPropTrSpawnDelay
, IntToStr(Data
.ItemDelay
), True)] do
1285 EditStyle
:= esSimple
;
1292 str
:= win2utf(Data
.MusicName
);
1293 with ItemProps
[InsertRow(MsgPropTrMusicName
, str
, True)] do
1295 EditStyle
:= esEllipsis
;
1299 if Data
.MusicAction
= 1 then
1300 str
:= MsgPropTrMusicOn
1302 str
:= MsgPropTrMusicOff
;
1304 with ItemProps
[InsertRow(MsgPropTrMusicAct
, str
, True)] do
1306 EditStyle
:= esPickList
;
1313 with ItemProps
[InsertRow(MsgPropTrPushAngle
, IntToStr(Data
.PushAngle
), True)] do
1315 EditStyle
:= esSimple
;
1318 with ItemProps
[InsertRow(MsgPropTrPushForce
, IntToStr(Data
.PushForce
), True)] do
1320 EditStyle
:= esSimple
;
1323 with ItemProps
[InsertRow(MsgPropTrPushReset
, BoolNames
[Data
.ResetVel
], True)] do
1325 EditStyle
:= esPickList
;
1332 case Data
.ScoreAction
of
1333 1: str
:= MsgPropTrScoreAct1
;
1334 2: str
:= MsgPropTrScoreAct2
;
1335 3: str
:= MsgPropTrScoreAct3
;
1336 else str
:= MsgPropTrScoreAct0
;
1338 with ItemProps
[InsertRow(MsgPropTrScoreAct
, str
, True)] do
1340 EditStyle
:= esPickList
;
1343 with ItemProps
[InsertRow(MsgPropTrCount
, IntToStr(Data
.ScoreCount
), True)] do
1345 EditStyle
:= esSimple
;
1348 case Data
.ScoreTeam
of
1349 1: str
:= MsgPropTrScoreTeam1
;
1350 2: str
:= MsgPropTrScoreTeam2
;
1351 3: str
:= MsgPropTrScoreTeam3
;
1352 else str
:= MsgPropTrScoreTeam0
;
1354 with ItemProps
[InsertRow(MsgPropTrScoreTeam
, str
, True)] do
1356 EditStyle
:= esPickList
;
1359 with ItemProps
[InsertRow(MsgPropTrScoreCon
, BoolNames
[Data
.ScoreCon
], True)] do
1361 EditStyle
:= esPickList
;
1364 with ItemProps
[InsertRow(MsgPropTrScoreMsg
, BoolNames
[Data
.ScoreMsg
], True)] do
1366 EditStyle
:= esPickList
;
1373 case Data
.MessageKind
of
1374 1: str
:= MsgPropTrMessageKind1
;
1375 else str
:= MsgPropTrMessageKind0
;
1377 with ItemProps
[InsertRow(MsgPropTrMessageKind
, str
, True)] do
1379 EditStyle
:= esPickList
;
1382 case Data
.MessageSendTo
of
1383 1: str
:= MsgPropTrMessageTo1
;
1384 2: str
:= MsgPropTrMessageTo2
;
1385 3: str
:= MsgPropTrMessageTo3
;
1386 4: str
:= MsgPropTrMessageTo4
;
1387 5: str
:= MsgPropTrMessageTo5
;
1388 else str
:= MsgPropTrMessageTo0
;
1390 with ItemProps
[InsertRow(MsgPropTrMessageTo
, str
, True)] do
1392 EditStyle
:= esPickList
;
1395 str
:= win2utf(Data
.MessageText
);
1396 with ItemProps
[InsertRow(MsgPropTrMessageText
, str
, True)] do
1398 EditStyle
:= esSimple
;
1401 with ItemProps
[InsertRow(MsgPropTrMessageTime
, IntToStr(Data
.MessageTime
), True)] do
1403 EditStyle
:= esSimple
;
1410 with ItemProps
[InsertRow(MsgPropTrDamageValue
, IntToStr(Data
.DamageValue
), True)] do
1412 EditStyle
:= esSimple
;
1415 with ItemProps
[InsertRow(MsgPropTrInterval
, IntToStr(Data
.DamageInterval
), True)] do
1417 EditStyle
:= esSimple
;
1420 case Data
.DamageKind
of
1421 3: str
:= MsgPropTrDamageKind3
;
1422 4: str
:= MsgPropTrDamageKind4
;
1423 5: str
:= MsgPropTrDamageKind5
;
1424 6: str
:= MsgPropTrDamageKind6
;
1425 7: str
:= MsgPropTrDamageKind7
;
1426 8: str
:= MsgPropTrDamageKind8
;
1427 else str
:= MsgPropTrDamageKind0
;
1429 with ItemProps
[InsertRow(MsgPropTrDamageKind
, str
, True)] do
1431 EditStyle
:= esPickList
;
1438 with ItemProps
[InsertRow(MsgPropTrHealth
, IntToStr(Data
.HealValue
), True)] do
1440 EditStyle
:= esSimple
;
1443 with ItemProps
[InsertRow(MsgPropTrInterval
, IntToStr(Data
.HealInterval
), True)] do
1445 EditStyle
:= esSimple
;
1448 with ItemProps
[InsertRow(MsgPropTrHealthMax
, BoolNames
[Data
.HealMax
], True)] do
1450 EditStyle
:= esPickList
;
1453 with ItemProps
[InsertRow(MsgPropTrSilent
, BoolNames
[Data
.HealSilent
], True)] do
1455 EditStyle
:= esPickList
;
1462 with ItemProps
[InsertRow(MsgPropTrShotType
, ShotToStr(Data
.ShotType
), True)] do
1464 EditStyle
:= esEllipsis
;
1468 with ItemProps
[InsertRow(MsgPropTrShotSound
, BoolNames
[Data
.ShotSound
], True)] do
1470 EditStyle
:= esPickList
;
1474 with ItemProps
[InsertRow(MsgPropTrShotPanel
, IntToStr(Data
.ShotPanelID
), True)] do
1476 EditStyle
:= esEllipsis
;
1480 case Data
.ShotTarget
of
1481 1: str
:= MsgPropTrShotTo1
;
1482 2: str
:= MsgPropTrShotTo2
;
1483 3: str
:= MsgPropTrShotTo3
;
1484 4: str
:= MsgPropTrShotTo4
;
1485 5: str
:= MsgPropTrShotTo5
;
1486 6: str
:= MsgPropTrShotTo6
;
1487 else str
:= MsgPropTrShotTo0
;
1489 with ItemProps
[InsertRow(MsgPropTrShotTo
, str
, True)] do
1491 EditStyle
:= esPickList
;
1495 with ItemProps
[InsertRow(MsgPropTrShotSight
, IntToStr(Data
.ShotIntSight
), True)] do
1497 EditStyle
:= esSimple
;
1501 case Data
.ShotAim
of
1502 1: str
:= MsgPropTrShotAim1
;
1503 2: str
:= MsgPropTrShotAim2
;
1504 3: str
:= MsgPropTrShotAim3
;
1505 else str
:= MsgPropTrShotAim0
;
1507 with ItemProps
[InsertRow(MsgPropTrShotAim
, str
, True)] do
1509 EditStyle
:= esPickList
;
1513 with ItemProps
[InsertRow(MsgPropTrSpawnTo
,
1514 Format('(%d:%d)', [Data
.ShotPos
.X
, Data
.ShotPos
.Y
]), True)] do
1516 EditStyle
:= esEllipsis
;
1520 with ItemProps
[InsertRow(MsgPropTrShotAngle
, IntToStr(Data
.ShotAngle
), True)] do
1522 EditStyle
:= esSimple
;
1526 with ItemProps
[InsertRow(MsgPropTrExDelay
, IntToStr(Data
.ShotWait
), True)] do
1528 EditStyle
:= esSimple
;
1532 with ItemProps
[InsertRow(MsgPropTrShotAcc
, IntToStr(Data
.ShotAccuracy
), True)] do
1534 EditStyle
:= esSimple
;
1538 with ItemProps
[InsertRow(MsgPropTrShotAmmo
, IntToStr(Data
.ShotAmmo
), True)] do
1540 EditStyle
:= esSimple
;
1544 with ItemProps
[InsertRow(MsgPropTrShotReload
, IntToStr(Data
.ShotIntReload
), True)] do
1546 EditStyle
:= esSimple
;
1553 with ItemProps
[InsertRow(MsgPropTrCount
, IntToStr(Data
.FXCount
), True)] do
1555 EditStyle
:= esSimple
;
1559 if Data
.FXType
= 0 then
1560 str
:= MsgPropTrEffectParticle
1562 str
:= MsgPropTrEffectAnimation
;
1563 with ItemProps
[InsertRow(MsgPropTrEffectType
, str
, True)] do
1565 EditStyle
:= esEllipsis
;
1570 if Data
.FXType
= 0 then
1571 case Data
.FXSubType
of
1572 TRIGGER_EFFECT_SLIQUID
:
1573 str
:= MsgPropTrEffectSliquid
;
1574 TRIGGER_EFFECT_LLIQUID
:
1575 str
:= MsgPropTrEffectLliquid
;
1576 TRIGGER_EFFECT_DLIQUID
:
1577 str
:= MsgPropTrEffectDliquid
;
1578 TRIGGER_EFFECT_BLOOD
:
1579 str
:= MsgPropTrEffectBlood
;
1580 TRIGGER_EFFECT_SPARK
:
1581 str
:= MsgPropTrEffectSpark
;
1582 TRIGGER_EFFECT_BUBBLE
:
1583 str
:= MsgPropTrEffectBubble
;
1585 if Data
.FXType
= 1 then
1587 if (Data
.FXSubType
= 0) or (Data
.FXSubType
> EFFECT_FIRE
) then
1588 Data
.FXSubType
:= EFFECT_TELEPORT
;
1589 str
:= EffectToStr(Data
.FXSubType
);
1591 with ItemProps
[InsertRow(MsgPropTrEffectSubtype
, str
, True)] do
1593 EditStyle
:= esEllipsis
;
1597 with ItemProps
[InsertRow(MsgPropTrEffectColor
, IntToStr(Data
.FXColorR
or (Data
.FXColorG
shl 8) or (Data
.FXColorB
shl 16)), True)] do
1599 EditStyle
:= esEllipsis
;
1603 with ItemProps
[InsertRow(MsgPropTrEffectCenter
, BoolNames
[Data
.FXPos
= 0], True)] do
1605 EditStyle
:= esPickList
;
1609 with ItemProps
[InsertRow(MsgPropTrExDelay
, IntToStr(Data
.FXWait
), True)] do
1611 EditStyle
:= esSimple
;
1615 with ItemProps
[InsertRow(MsgPropTrEffectVelx
, IntToStr(Data
.FXVelX
), True)] do
1617 EditStyle
:= esSimple
;
1621 with ItemProps
[InsertRow(MsgPropTrEffectVely
, IntToStr(Data
.FXVelY
), True)] do
1623 EditStyle
:= esSimple
;
1627 with ItemProps
[InsertRow(MsgPropTrEffectSpl
, IntToStr(Data
.FXSpreadL
), True)] do
1629 EditStyle
:= esSimple
;
1633 with ItemProps
[InsertRow(MsgPropTrEffectSpr
, IntToStr(Data
.FXSpreadR
), True)] do
1635 EditStyle
:= esSimple
;
1639 with ItemProps
[InsertRow(MsgPropTrEffectSpu
, IntToStr(Data
.FXSpreadU
), True)] do
1641 EditStyle
:= esSimple
;
1645 with ItemProps
[InsertRow(MsgPropTrEffectSpd
, IntToStr(Data
.FXSpreadD
), True)] do
1647 EditStyle
:= esSimple
;
1651 end; //case TriggerType
1653 end; // OBJECT_TRIGGER:
1657 procedure ChangeShownProperty(Name
: String; NewValue
: String);
1661 if SelectedObjectCount() <> 1 then
1663 if not SelectedObjects
[GetFirstSelected()].Live
then
1666 // Есть ли такой ключ:
1667 if MainForm
.vleObjectProperty
.FindRow(Name
, row
) then
1669 MainForm
.vleObjectProperty
.Values
[Name
] := NewValue
;
1673 procedure SelectObject(fObjectType
: Byte; fID
: DWORD
; Multi
: Boolean);
1682 // Уже выделен - убираем:
1683 if SelectedObjects
<> nil then
1684 for a
:= 0 to High(SelectedObjects
) do
1685 with SelectedObjects
[a
] do
1686 if Live
and (ID
= fID
) and
1687 (ObjectType
= fObjectType
) then
1696 SetLength(SelectedObjects
, Length(SelectedObjects
)+1);
1698 with SelectedObjects
[High(SelectedObjects
)] do
1700 ObjectType
:= fObjectType
;
1707 SetLength(SelectedObjects
, 1);
1709 with SelectedObjects
[0] do
1711 ObjectType
:= fObjectType
;
1717 MainForm
.miCopy
.Enabled
:= True;
1718 MainForm
.miCut
.Enabled
:= True;
1720 if fObjectType
= OBJECT_PANEL
then
1722 MainForm
.miToFore
.Enabled
:= True;
1723 MainForm
.miToBack
.Enabled
:= True;
1727 procedure RemoveSelectFromObjects();
1729 SelectedObjects
:= nil;
1730 DrawPressRect
:= False;
1731 MouseLDown
:= False;
1732 MouseRDown
:= False;
1733 MouseAction
:= MOUSEACTION_NONE
;
1734 SelectFlag
:= SELECTFLAG_NONE
;
1735 ResizeType
:= RESIZETYPE_NONE
;
1736 ResizeDirection
:= RESIZEDIR_NONE
;
1738 MainForm
.vleObjectProperty
.Strings
.Clear();
1740 MainForm
.miCopy
.Enabled
:= False;
1741 MainForm
.miCut
.Enabled
:= False;
1742 MainForm
.miToFore
.Enabled
:= False;
1743 MainForm
.miToBack
.Enabled
:= False;
1746 procedure DeleteSelectedObjects();
1751 if SelectedObjects
= nil then
1757 for a
:= 0 to High(SelectedObjects
) do
1758 with SelectedObjects
[a
] do
1763 SetLength(UndoBuffer
, Length(UndoBuffer
)+1);
1764 i
:= High(UndoBuffer
);
1768 SetLength(UndoBuffer
[i
], Length(UndoBuffer
[i
])+1);
1769 ii
:= High(UndoBuffer
[i
]);
1774 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_PANEL
;
1775 New(UndoBuffer
[i
, ii
].Panel
);
1776 UndoBuffer
[i
, ii
].Panel
^ := gPanels
[ID
];
1780 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_ITEM
;
1781 UndoBuffer
[i
, ii
].Item
:= gItems
[ID
];
1785 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_AREA
;
1786 UndoBuffer
[i
, ii
].Area
:= gAreas
[ID
];
1790 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_TRIGGER
;
1791 UndoBuffer
[i
, ii
].Trigger
:= gTriggers
[ID
];
1795 RemoveObject(ID
, ObjectType
);
1798 RemoveSelectFromObjects();
1800 MainForm
.miUndo
.Enabled
:= UndoBuffer
<> nil;
1801 MainForm
.RecountSelectedObjects();
1804 procedure Undo_Add(ObjectType
: Byte; ID
: DWORD
; Group
: Boolean = False);
1808 if (not Group
) or (Length(UndoBuffer
) = 0) then
1809 SetLength(UndoBuffer
, Length(UndoBuffer
)+1);
1810 SetLength(UndoBuffer
[High(UndoBuffer
)], Length(UndoBuffer
[High(UndoBuffer
)])+1);
1811 i
:= High(UndoBuffer
);
1812 ii
:= High(UndoBuffer
[i
]);
1816 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_PANEL
;
1818 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_ITEM
;
1820 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_MONSTER
;
1822 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_AREA
;
1824 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_TRIGGER
;
1827 UndoBuffer
[i
, ii
].AddID
:= ID
;
1829 MainForm
.miUndo
.Enabled
:= UndoBuffer
<> nil;
1832 procedure FullClear();
1834 RemoveSelectFromObjects();
1836 LoadSky(gMapInfo
.SkyName
);
1838 slInvalidTextures
.Clear();
1839 MapCheckForm
.lbErrorList
.Clear();
1840 MapCheckForm
.mErrorDescription
.Clear();
1842 MainForm
.miUndo
.Enabled
:= False;
1843 MainForm
.sbHorizontal
.Position
:= 0;
1844 MainForm
.sbVertical
.Position
:= 0;
1845 MainForm
.FormResize(nil);
1846 MainForm
.Caption
:= FormCaption
;
1851 procedure ErrorMessageBox(str
: String);
1853 Application
.MessageBox(PChar(str
), PChar(MsgMsgError
),
1854 MB_ICONINFORMATION
or MB_OK
or MB_DEFBUTTON1
);
1857 function CheckProperty(): Boolean;
1863 _id
:= GetFirstSelected();
1865 if SelectedObjects
[_id
].ObjectType
= OBJECT_PANEL
then
1866 with gPanels
[SelectedObjects
[_id
].ID
] do
1868 if TextureWidth
<> 0 then
1869 if StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropWidth
], 1) mod TextureWidth
<> 0 then
1871 ErrorMessageBox(Format(MsgMsgWrongTexwidth
,
1876 if TextureHeight
<> 0 then
1877 if StrToIntDef(Trim(MainForm
.vleObjectProperty
.Values
[MsgPropHeight
]), 1) mod TextureHeight
<> 0 then
1879 ErrorMessageBox(Format(MsgMsgWrongTexheight
,
1884 if IsTexturedPanel(PanelType
) and (TextureName
<> '') then
1885 if not (StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropPanelAlpha
], -1) in [0..255]) then
1887 ErrorMessageBox(MsgMsgWrongAlpha
);
1892 if SelectedObjects
[_id
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
] then
1893 if (StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropWidth
], 0) <= 0) or
1894 (StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropHeight
], 0) <= 0) then
1896 ErrorMessageBox(MsgMsgWrongSize
);
1900 if (Trim(MainForm
.vleObjectProperty
.Values
[MsgPropX
]) = '') or
1901 (Trim(MainForm
.vleObjectProperty
.Values
[MsgPropY
]) = '') then
1903 ErrorMessageBox(MsgMsgWrongXy
);
1910 procedure SelectTexture(ID
: Integer);
1912 MainForm
.lbTextureList
.ItemIndex
:= ID
;
1913 MainForm
.lbTextureListClick(nil);
1916 function AddTexture(aWAD
, aSection
, aTex
: String; silent
: Boolean): Boolean;
1918 a
, FrameLen
: Integer;
1921 ResourceName
: String;
1922 FullResourceName
: String;
1923 SectionName
: String;
1925 Width
, Height
: Word;
1933 if aSection
= '..' then
1936 SectionName
:= aSection
;
1939 aWAD
:= MsgWadSpecialMap
;
1941 if aWAD
= MsgWadSpecialMap
then
1943 g_ProcessResourceStr(OpenedMap
, @fn
, nil, nil);
1945 ResourceName
:= ':'+SectionName
+'\'+aTex
;
1948 if aWAD
= MsgWadSpecialTexs
then
1949 begin // Спец. текстуры
1951 ResourceName
:= aTex
;
1954 begin // Внешний WAD
1955 FileName
:= WadsDir
+ DirectorySeparator
+ aWAD
;
1956 ResourceName
:= aWAD
+':'+SectionName
+'\'+aTex
;
1961 // Есть ли уже такая текстура:
1962 for a
:= 0 to MainForm
.lbTextureList
.Items
.Count
-1 do
1963 if ResourceName
= MainForm
.lbTextureList
.Items
[a
] then
1966 ErrorMessageBox(Format(MsgMsgTextureAlready
,
1971 // Название ресурса <= 64 символов:
1972 if Length(ResourceName
) > 64 then
1975 ErrorMessageBox(Format(MsgMsgResName64
,
1983 if aWAD
= MsgWadSpecialTexs
then
1985 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
1992 FullResourceName
:= FileName
+':'+SectionName
+'\'+aTex
;
1994 if IsAnim(FullResourceName
) then
1995 begin // Аним. текстура
1996 GetFrame(FullResourceName
, Data
, FrameLen
, Width
, Height
);
1998 if not g_CreateTextureMemorySize(Data
, FrameLen
, ResourceName
, 0, 0, Width
, Height
, 1) then
2000 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
2002 else // Обычная текстура
2004 if not g_CreateTextureWAD(ResourceName
, FullResourceName
) then
2006 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
2008 if (not ok
) and (slInvalidTextures
.IndexOf(ResourceName
) = -1) then
2010 slInvalidTextures
.Add(ResourceName
);
2013 if (a
> -1) and (not silent
) then
2020 procedure UpdateCaption(sMap
, sFile
, sRes
: String);
2023 if (sFile
= '') and (sRes
= '') and (sMap
= '') then
2024 Caption
:= FormCaption
2027 Caption
:= Format('%s - %s:%s', [FormCaption
, sFile
, sRes
])
2029 if (sFile
<> '') and (sRes
<> '') then
2030 Caption
:= Format('%s - %s (%s:%s)', [FormCaption
, sMap
, sFile
, sRes
])
2032 Caption
:= Format('%s - %s', [FormCaption
, sMap
]);
2035 procedure OpenMap(FileName
: String; mapN
: String);
2040 SelectMapForm
.Caption
:= MsgCapOpen
;
2041 SelectMapForm
.GetMaps(FileName
);
2043 if (FileName
= OpenedWAD
) and
2044 (OpenedMap
<> '') then
2046 MapName
:= OpenedMap
;
2047 while (Pos(':\', MapName
) > 0) do
2048 Delete(MapName
, 1, Pos(':\', MapName
) + 1);
2050 idx
:= SelectMapForm
.lbMapList
.Items
.IndexOf(MapName
);
2051 SelectMapForm
.lbMapList
.ItemIndex
:= idx
;
2054 if SelectMapForm
.lbMapList
.Count
> 0 then
2055 SelectMapForm
.lbMapList
.ItemIndex
:= 0
2057 SelectMapForm
.lbMapList
.ItemIndex
:= -1;
2062 idx
:= SelectMapForm
.lbMapList
.Items
.IndexOf(mapN
);
2066 if (SelectMapForm
.ShowModal() = mrOK
) and
2067 (SelectMapForm
.lbMapList
.ItemIndex
<> -1) then
2068 idx
:= SelectMapForm
.lbMapList
.ItemIndex
2073 MapName
:= SelectMapForm
.lbMapList
.Items
[idx
];
2079 pLoadProgress
.Left
:= (RenderPanel
.Width
div 2)-(pLoadProgress
.Width
div 2);
2080 pLoadProgress
.Top
:= (RenderPanel
.Height
div 2)-(pLoadProgress
.Height
div 2);
2081 pLoadProgress
.Show();
2083 OpenedMap
:= FileName
+':\'+MapName
;
2084 OpenedWAD
:= FileName
;
2086 idx
:= RecentFiles
.IndexOf(OpenedMap
);
2087 // Такая карта уже недавно открывалась:
2089 RecentFiles
.Delete(idx
);
2090 RecentFiles
.Insert(0, OpenedMap
);
2091 RefreshRecentMenu();
2095 pLoadProgress
.Hide();
2098 lbTextureList
.Sorted
:= True;
2099 lbTextureList
.Sorted
:= False;
2101 UpdateCaption(gMapInfo
.Name
, ExtractFileName(FileName
), MapName
);
2105 procedure MoveSelectedObjects(Wall
, alt
: Boolean; dx
, dy
: Integer);
2110 if SelectedObjects
= nil then
2117 for a
:= 0 to High(SelectedObjects
) do
2118 if SelectedObjects
[a
].Live
then
2120 if ObjectCollideLevel(SelectedObjects
[a
].ID
, SelectedObjects
[a
].ObjectType
, dx
, 0) then
2123 if ObjectCollideLevel(SelectedObjects
[a
].ID
, SelectedObjects
[a
].ObjectType
, 0, dy
) then
2126 if (not okX
) or (not okY
) then
2132 for a
:= 0 to High(SelectedObjects
) do
2133 if SelectedObjects
[a
].Live
then
2136 MoveObject(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
, dx
, 0);
2139 MoveObject(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
, 0, dy
);
2141 if alt
and (SelectedObjects
[a
].ObjectType
= OBJECT_TRIGGER
) then
2143 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_PRESS
,
2144 TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
] then
2145 begin // Двигаем зону Расширителя
2147 gTriggers
[SelectedObjects
[a
].ID
].Data
.tX
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.tX
+dx
;
2149 gTriggers
[SelectedObjects
[a
].ID
].Data
.tY
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.tY
+dy
;
2152 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_TELEPORT
] then
2153 begin // Двигаем точку назначения Телепорта
2155 gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.X
+dx
;
2157 gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.Y
+dy
;
2160 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SPAWNMONSTER
] then
2161 begin // Двигаем точку создания монстра
2163 gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.X
+dx
;
2165 gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.Y
+dy
;
2168 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SPAWNITEM
] then
2169 begin // Двигаем точку создания предмета
2171 gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.X
+dx
;
2173 gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.Y
+dy
;
2176 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SHOT
] then
2177 begin // Двигаем точку создания выстрела
2179 gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.X
+dx
;
2181 gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.Y
+dy
;
2186 LastMovePoint
:= MousePos
;
2190 procedure ShowLayer(Layer
: Byte; show
: Boolean);
2192 LayerEnabled
[Layer
] := show
;
2197 MainForm
.miLayer1
.Checked
:= show
;
2198 MainForm
.miLayerP1
.Checked
:= show
;
2202 MainForm
.miLayer2
.Checked
:= show
;
2203 MainForm
.miLayerP2
.Checked
:= show
;
2207 MainForm
.miLayer3
.Checked
:= show
;
2208 MainForm
.miLayerP3
.Checked
:= show
;
2212 MainForm
.miLayer4
.Checked
:= show
;
2213 MainForm
.miLayerP4
.Checked
:= show
;
2217 MainForm
.miLayer5
.Checked
:= show
;
2218 MainForm
.miLayerP5
.Checked
:= show
;
2222 MainForm
.miLayer6
.Checked
:= show
;
2223 MainForm
.miLayerP6
.Checked
:= show
;
2227 MainForm
.miLayer7
.Checked
:= show
;
2228 MainForm
.miLayerP7
.Checked
:= show
;
2232 MainForm
.miLayer8
.Checked
:= show
;
2233 MainForm
.miLayerP8
.Checked
:= show
;
2237 MainForm
.miLayer9
.Checked
:= show
;
2238 MainForm
.miLayerP9
.Checked
:= show
;
2242 RemoveSelectFromObjects();
2245 procedure SwitchLayer(Layer
: Byte);
2247 ShowLayer(Layer
, not LayerEnabled
[Layer
]);
2250 procedure SwitchMap();
2252 ShowMap
:= not ShowMap
;
2253 MainForm
.tbShowMap
.Down
:= ShowMap
;
2254 MainForm
.miMiniMap
.Checked
:= ShowMap
;
2257 procedure ShowEdges();
2259 if drEdge
[3] < 255 then
2262 drEdge
[3] := gAlphaEdge
;
2263 MainForm
.miShowEdges
.Checked
:= drEdge
[3] <> 255;
2266 function SelectedTexture(): String;
2268 if MainForm
.lbTextureList
.ItemIndex
<> -1 then
2269 Result
:= MainForm
.lbTextureList
.Items
[MainForm
.lbTextureList
.ItemIndex
]
2274 function IsSpecialTextureSel(): Boolean;
2276 Result
:= (MainForm
.lbTextureList
.ItemIndex
<> -1) and
2277 IsSpecialTexture(MainForm
.lbTextureList
.Items
[MainForm
.lbTextureList
.ItemIndex
]);
2280 function CopyBufferToString(var CopyBuf
: TCopyRecArray
): String;
2285 procedure AddInt(x
: Integer);
2287 Res
:= Res
+ IntToStr(x
) + ' ';
2293 if Length(CopyBuf
) = 0 then
2296 Res
:= CLIPBOARD_SIG
+ ' ';
2298 for i
:= 0 to High(CopyBuf
) do
2300 if (CopyBuf
[i
].ObjectType
= OBJECT_PANEL
) and
2301 (CopyBuf
[i
].Panel
= nil) then
2305 AddInt(CopyBuf
[i
].ObjectType
);
2308 // Свойства объекта:
2309 case CopyBuf
[i
].ObjectType
of
2311 with CopyBuf
[i
].Panel
^ do
2318 Res
:= Res
+ '"' + TextureName
+ '" ';
2320 AddInt(IfThen(Blending
, 1, 0));
2324 with CopyBuf
[i
].Item
do
2329 AddInt(IfThen(OnlyDM
, 1, 0));
2330 AddInt(IfThen(Fall
, 1, 0));
2334 with CopyBuf
[i
].Monster
do
2336 AddInt(MonsterType
);
2339 AddInt(IfThen(Direction
= D_LEFT
, 1, 0));
2343 with CopyBuf
[i
].Area
do
2348 AddInt(IfThen(Direction
= D_LEFT
, 1, 0));
2352 with CopyBuf
[i
].Trigger
do
2354 AddInt(TriggerType
);
2359 AddInt(ActivateType
);
2361 AddInt(IfThen(Enabled
, 1, 0));
2362 AddInt(TexturePanel
);
2364 for j
:= 0 to 127 do
2365 AddInt(Data
.Default
[j
]);
2373 procedure StringToCopyBuffer(Str
: String; var CopyBuf
: TCopyRecArray
; var pmin
: TPoint
);
2376 minArea
, newArea
, newX
, newY
: LongInt;
2378 function GetNext(): String;
2383 if Str
[1] = '"' then
2395 Result
:= Copy(Str
, 1, p
-1);
2411 Result
:= Copy(Str
, 1, p
-1);
2419 minArea
:= High(minArea
);
2422 if GetNext() <> CLIPBOARD_SIG
then
2428 t
:= StrToIntDef(GetNext(), 0);
2430 if (t
< OBJECT_PANEL
) or (t
> OBJECT_TRIGGER
) or (GetNext() <> ';') then
2431 begin // Что-то не то => пропускаем:
2439 i
:= Length(CopyBuf
);
2440 SetLength(CopyBuf
, i
+ 1);
2442 CopyBuf
[i
].ObjectType
:= t
;
2443 CopyBuf
[i
].Panel
:= nil;
2445 // Свойства объекта:
2449 New(CopyBuf
[i
].Panel
);
2451 with CopyBuf
[i
].Panel
^ do
2453 PanelType
:= StrToIntDef(GetNext(), PANEL_WALL
);
2454 X
:= StrToIntDef(GetNext(), 0);
2455 Y
:= StrToIntDef(GetNext(), 0);
2456 Width
:= StrToIntDef(GetNext(), 16);
2457 Height
:= StrToIntDef(GetNext(), 16);
2458 TextureName
:= GetNext();
2459 Alpha
:= StrToIntDef(GetNext(), 0);
2460 Blending
:= (GetNext() = '1');
2461 newArea
:= X
* Y
- Width
* Height
;
2468 with CopyBuf
[i
].Item
do
2470 ItemType
:= StrToIntDef(GetNext(), ITEM_MEDKIT_SMALL
);
2471 X
:= StrToIntDef(GetNext(), 0);
2472 Y
:= StrToIntDef(GetNext(), 0);
2473 OnlyDM
:= (GetNext() = '1');
2474 Fall
:= (GetNext() = '1');
2481 with CopyBuf
[i
].Monster
do
2483 MonsterType
:= StrToIntDef(GetNext(), MONSTER_DEMON
);
2484 X
:= StrToIntDef(GetNext(), 0);
2485 Y
:= StrToIntDef(GetNext(), 0);
2487 then Direction
:= D_LEFT
2488 else Direction
:= D_RIGHT
;
2495 with CopyBuf
[i
].Area
do
2497 AreaType
:= StrToIntDef(GetNext(), AREA_PLAYERPOINT1
);
2498 X
:= StrToIntDef(GetNext(), 0);
2499 Y
:= StrToIntDef(GetNext(), 0);
2501 then Direction
:= D_LEFT
2502 else Direction
:= D_RIGHT
;
2509 with CopyBuf
[i
].Trigger
do
2511 TriggerType
:= StrToIntDef(GetNext(), TRIGGER_EXIT
);
2512 X
:= StrToIntDef(GetNext(), 0);
2513 Y
:= StrToIntDef(GetNext(), 0);
2514 Width
:= StrToIntDef(GetNext(), 16);
2515 Height
:= StrToIntDef(GetNext(), 16);
2516 ActivateType
:= StrToIntDef(GetNext(), 0);
2517 Key
:= StrToIntDef(GetNext(), 0);
2518 Enabled
:= (GetNext() = '1');
2519 TexturePanel
:= StrToIntDef(GetNext(), 0);
2521 do Data
.Default
[j
] := StrToIntDef(GetNext(), 0);
2522 newArea
:= X
* Y
- Width
* Height
;
2528 if newArea
< minArea
then
2537 //----------------------------------------
2538 //Закончились вспомогательные процедуры
2539 //----------------------------------------
2541 procedure TMainForm
.miRecentFileExecute (Sender
: TObject
);
2545 s
:= RecentFiles
[(Sender
as TMenuItem
).Tag
];
2546 fn
:= g_ExtractWadName(s
);
2547 if FileExists(fn
) then
2548 OpenMap(fn
, g_ExtractFilePathName(s
))
2550 Application
.MessageBox('', 'File not available anymore', MB_OK
);
2551 // if Application.MessageBox(PChar(MsgMsgDelRecentPrompt), PChar(MsgMsgDelRecent), MB_ICONQUESTION or MB_YESNO) = idYes then
2553 // RecentFiles.Delete(n);
2554 // RefreshRecentMenu();
2558 procedure TMainForm
.RefillRecentMenu (menu
: TMenuItem
; start
: Integer; fmt
: AnsiString);
2559 var i
: Integer; MI
: TMenuItem
; s
: AnsiString;
2561 Assert(menu
<> nil);
2563 Assert(start
<= menu
.Count
);
2565 // clear all the recent entries from menu
2567 while i
< menu
.Count
do
2569 MI
:= menu
.Items
[i
];
2570 if @MI
.OnClick
<> @TMainForm
.miRecentFileExecute
then
2579 // fill with a new ones
2580 for i
:= 0 to RecentFiles
.Count
-1 do
2582 MI
:= TMenuItem
.Create(menu
);
2583 s
:= RecentFiles
[i
];
2584 MI
.Caption
:= Format(fmt
, [i
+1, g_ExtractWadNameNoPath(s
), g_ExtractFilePathName(s
)]);
2585 MI
.OnClick
:= miRecentFileExecute
;
2587 menu
.Insert(start
+ i
, MI
); // transfers ownership
2591 procedure TMainForm
.RefreshRecentMenu();
2594 while RecentFiles
.Count
> RecentCount
do
2595 RecentFiles
.Delete(RecentFiles
.Count
- 1);
2597 if miMacRecentSubMenu
.Visible
then
2599 // Reconstruct OSX-like recent list
2600 RefillRecentMenu(miMacRecentSubMenu
, 0, '%1:s - %2:s');
2601 miMacRecentEnd
.Enabled
:= RecentFiles
.Count
<> 0;
2602 miMacRecentEnd
.Visible
:= RecentFiles
.Count
<> 0;
2605 if miWinRecentStart
.Visible
then
2607 // Reconstruct Windows-like recent list
2608 start
:= miMenuFile
.IndexOf(miWinRecent
);
2609 if start
< 0 then start
:= miMenuFile
.Count
else start
+= 1;
2610 RefillRecentMenu(miMenuFile
, start
, '%0:d %1:s:%2:s');
2611 miWinRecent
.Enabled
:= False;
2612 miWinRecent
.Visible
:= RecentFiles
.Count
= 0;
2616 procedure TMainForm
.miMacRecentClearClick(Sender
: TObject
);
2618 RecentFiles
.Clear();
2619 RefreshRecentMenu();
2622 procedure TMainForm
.aEditorOptionsExecute(Sender
: TObject
);
2624 OptionsForm
.ShowModal();
2627 procedure LoadStdFont(cfgres
, texture
: string; var FontID
: DWORD
);
2641 wad
:= TWADEditor_1
.Create
;
2642 if wad
.ReadFile(GameWad
) then
2643 wad
.GetResource('FONTS', cfgres
, cfgdata
, cfglen
);
2648 if not g_CreateTextureWAD('FONT_STD', GameWad
+ ':FONTS\' + texture
) then
2649 e_WriteLog('ERROR ERROR ERROR', MSG_WARNING
);
2651 config
:= TConfig
.CreateMem(cfgdata
, cfglen
);
2652 cwdt
:= Min(Max(config
.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
2653 chgt
:= Min(Max(config
.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
2654 spc
:= Min(Max(config
.ReadInt('FontMap', 'Kerning', 0), -128), 127);
2656 if g_GetTexture('FONT_STD', ID
) then
2657 e_TextureFontBuild(ID
, FontID
, cwdt
, chgt
, spc
-2);
2662 e_WriteLog('Could not load FONT_STD', MSG_WARNING
);
2664 if cfglen
<> 0 then FreeMem(cfgdata
);
2667 procedure TMainForm
.FormCreate(Sender
: TObject
);
2676 miApple
.Enabled
:= True;
2677 miApple
.Visible
:= True;
2678 miMacRecentSubMenu
.Enabled
:= True;
2679 miMacRecentSubMenu
.Visible
:= True;
2680 miWinRecentStart
.Enabled
:= False;
2681 miWinRecentStart
.Visible
:= False;
2682 miWinRecent
.Enabled
:= False;
2683 miWinRecent
.Visible
:= False;
2684 miLine2
.Enabled
:= False;
2685 miLine2
.Visible
:= False;
2686 miExit
.Enabled
:= False;
2687 miExit
.Visible
:= False;
2688 miOptions
.Enabled
:= False;
2689 miOptions
.Visible
:= False;
2690 miMenuWindow
.Enabled
:= True;
2691 miMenuWindow
.Visible
:= True;
2692 miAbout
.Enabled
:= False;
2693 miAbout
.Visible
:= False;
2695 miApple
.Enabled
:= False;
2696 miApple
.Visible
:= False;
2697 miMacRecentSubMenu
.Enabled
:= False;
2698 miMacRecentSubMenu
.Visible
:= False;
2699 miWinRecentStart
.Enabled
:= True;
2700 miWinRecentStart
.Visible
:= True;
2701 miWinRecent
.Enabled
:= True;
2702 miWinRecent
.Visible
:= True;
2703 miLine2
.Enabled
:= True;
2704 miLine2
.Visible
:= True;
2705 miExit
.Enabled
:= True;
2706 miExit
.Visible
:= True;
2707 miOptions
.Enabled
:= True;
2708 miOptions
.Visible
:= True;
2709 miMenuWindow
.Enabled
:= False;
2710 miMenuWindow
.Visible
:= False;
2711 miAbout
.Enabled
:= True;
2712 miAbout
.Visible
:= True;
2715 miNewMap
.ShortCut
:= ShortCut(VK_N
, [ssModifier
]);
2716 miOpenMap
.ShortCut
:= ShortCut(VK_O
, [ssModifier
]);
2717 miSaveMap
.ShortCut
:= ShortCut(VK_S
, [ssModifier
]);
2719 miSaveMapAs
.ShortCut
:= ShortCut(VK_S
, [ssModifier
, ssShift
]);
2720 miReopenMap
.ShortCut
:= ShortCut(VK_F5
, [ssModifier
]);
2722 miUndo
.ShortCut
:= ShortCut(VK_Z
, [ssModifier
]);
2723 miCopy
.ShortCut
:= ShortCut(VK_C
, [ssModifier
]);
2724 miCut
.ShortCut
:= ShortCut(VK_X
, [ssModifier
]);
2725 miPaste
.ShortCut
:= ShortCut(VK_V
, [ssModifier
]);
2726 miSelectAll
.ShortCut
:= ShortCut(VK_A
, [ssModifier
]);
2727 miToFore
.ShortCut
:= ShortCut(VK_LCL_CLOSE_BRACKET
, [ssModifier
]);
2728 miToBack
.ShortCut
:= ShortCut(VK_LCL_OPEN_BRACKET
, [ssModifier
]);
2730 miMapOptions
.Shortcut
:= ShortCut(VK_P
, [ssModifier
, ssAlt
]);
2731 selectall1
.Shortcut
:= ShortCut(VK_A
, [ssModifier
, ssAlt
]);
2734 e_WriteLog('Doom 2D: Forever Editor version ' + EDITOR_VERSION
, MSG_NOTIFY
);
2735 e_WriteLog('Build date: ' + EDITOR_BUILDDATE
+ ' ' + EDITOR_BUILDTIME
, MSG_NOTIFY
);
2736 e_WriteLog('Build hash: ' + g_GetBuildHash(), MSG_NOTIFY
);
2737 e_WriteLog('Build by: ' + g_GetBuilderName(), MSG_NOTIFY
);
2739 slInvalidTextures
:= TStringList
.Create
;
2741 ShowLayer(LAYER_BACK
, True);
2742 ShowLayer(LAYER_WALLS
, True);
2743 ShowLayer(LAYER_FOREGROUND
, True);
2744 ShowLayer(LAYER_STEPS
, True);
2745 ShowLayer(LAYER_WATER
, True);
2746 ShowLayer(LAYER_ITEMS
, True);
2747 ShowLayer(LAYER_MONSTERS
, True);
2748 ShowLayer(LAYER_AREAS
, True);
2749 ShowLayer(LAYER_TRIGGERS
, True);
2753 FormCaption
:= MainForm
.Caption
;
2757 config
:= TConfig
.CreateFile(CfgFileName
);
2759 if config
.ReadInt('Editor', 'XPos', -1) = -1 then
2760 Position
:= poDesktopCenter
2762 Left
:= config
.ReadInt('Editor', 'XPos', Left
);
2763 Top
:= config
.ReadInt('Editor', 'YPos', Top
);
2764 Width
:= config
.ReadInt('Editor', 'Width', Width
);
2765 Height
:= config
.ReadInt('Editor', 'Height', Height
);
2767 if config
.ReadBool('Editor', 'Maximize', False) then
2768 WindowState
:= wsMaximized
;
2769 ShowMap
:= config
.ReadBool('Editor', 'Minimap', False);
2770 PanelProps
.Width
:= config
.ReadInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
2771 Splitter1
.Left
:= PanelProps
.Left
;
2772 PanelObjs
.Height
:= config
.ReadInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
2773 Splitter2
.Top
:= PanelObjs
.Top
;
2774 StatusBar
.Top
:= PanelObjs
.BoundsRect
.Bottom
;
2775 DotEnable
:= config
.ReadBool('Editor', 'DotEnable', True);
2776 DotColor
:= config
.ReadInt('Editor', 'DotColor', $FFFFFF);
2777 DotStepOne
:= config
.ReadInt('Editor', 'DotStepOne', 16);
2778 DotStepTwo
:= config
.ReadInt('Editor', 'DotStepTwo', 8);
2779 DotStep
:= config
.ReadInt('Editor', 'DotStep', DotStepOne
);
2780 DrawTexturePanel
:= config
.ReadBool('Editor', 'DrawTexturePanel', True);
2781 DrawPanelSize
:= config
.ReadBool('Editor', 'DrawPanelSize', True);
2782 BackColor
:= config
.ReadInt('Editor', 'BackColor', $7F6040);
2783 PreviewColor
:= config
.ReadInt('Editor', 'PreviewColor', $00FF00);
2784 UseCheckerboard
:= config
.ReadBool('Editor', 'UseCheckerboard', True);
2785 gColorEdge
:= config
.ReadInt('Editor', 'EdgeColor', COLOR_EDGE
);
2786 gAlphaEdge
:= config
.ReadInt('Editor', 'EdgeAlpha', ALPHA_EDGE
);
2787 if gAlphaEdge
= 255 then
2788 gAlphaEdge
:= ALPHA_EDGE
;
2789 drEdge
[0] := GetRValue(gColorEdge
);
2790 drEdge
[1] := GetGValue(gColorEdge
);
2791 drEdge
[2] := GetBValue(gColorEdge
);
2792 if not config
.ReadBool('Editor', 'EdgeShow', True) then
2795 drEdge
[3] := gAlphaEdge
;
2796 gAlphaTriggerLine
:= config
.ReadInt('Editor', 'LineAlpha', ALPHA_LINE
);
2797 if gAlphaTriggerLine
= 255 then
2798 gAlphaTriggerLine
:= ALPHA_LINE
;
2799 gAlphaTriggerArea
:= config
.ReadInt('Editor', 'TriggerAlpha', ALPHA_AREA
);
2800 if gAlphaTriggerArea
= 255 then
2801 gAlphaTriggerArea
:= ALPHA_AREA
;
2802 gAlphaMonsterRect
:= config
.ReadInt('Editor', 'MonsterRectAlpha', 0);
2803 gAlphaAreaRect
:= config
.ReadInt('Editor', 'AreaRectAlpha', 0);
2804 Scale
:= Max(config
.ReadInt('Editor', 'Scale', 1), 1);
2805 DotSize
:= Max(config
.ReadInt('Editor', 'DotSize', 1), 1);
2806 OpenDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastOpenDir', MapsDir
);
2807 SaveDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastSaveDir', MapsDir
);
2809 s
:= config
.ReadStr('Editor', 'Language', '');
2812 TestGameMode
:= config
.ReadStr('TestRun', 'GameMode', 'DM');
2813 TestLimTime
:= config
.ReadStr('TestRun', 'LimTime', '0');
2814 TestLimScore
:= config
.ReadStr('TestRun', 'LimScore', '0');
2815 TestOptionsTwoPlayers
:= config
.ReadBool('TestRun', 'TwoPlayers', False);
2816 TestOptionsTeamDamage
:= config
.ReadBool('TestRun', 'TeamDamage', False);
2817 TestOptionsAllowExit
:= config
.ReadBool('TestRun', 'AllowExit', True);
2818 TestOptionsWeaponStay
:= config
.ReadBool('TestRun', 'WeaponStay', False);
2819 TestOptionsMonstersDM
:= config
.ReadBool('TestRun', 'MonstersDM', False);
2820 TestMapOnce
:= config
.ReadBool('TestRun', 'MapOnce', False);
2821 {$IF DEFINED(DARWIN)}
2822 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeDrawin', GameExeFile
);
2823 {$ELSEIF DEFINED(WINDOWS)}
2824 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeWindows', GameExeFile
);
2826 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeUnix', GameExeFile
);
2828 TestD2DArgs
:= config
.ReadStr('TestRun', 'Args', '');
2830 RecentCount
:= config
.ReadInt('Editor', 'RecentCount', 5);
2831 if RecentCount
> 10 then
2833 if RecentCount
< 2 then
2836 RecentFiles
:= TStringList
.Create();
2837 for i
:= 0 to RecentCount
-1 do
2840 s
:= config
.ReadStr('RecentFilesWin', IntToStr(i
), '');
2842 s
:= config
.ReadStr('RecentFilesUnix', IntToStr(i
), '');
2847 RefreshRecentMenu();
2851 tbShowMap
.Down
:= ShowMap
;
2852 tbGridOn
.Down
:= DotEnable
;
2853 pcObjects
.ActivePageIndex
:= 0;
2854 Application
.Title
:= MsgEditorTitle
;
2856 Application
.OnIdle
:= OnIdle
;
2859 procedure PrintBlack(X
, Y
: Integer; Text: string; FontID
: DWORD
);
2861 // NOTE: all the font printing routines assume CP1251
2862 e_TextureFontPrintEx(X
, Y
, Text, FontID
, 0, 0, 0, 1.0);
2865 procedure InitGraphics
;
2867 // FIXME: this is a shitty hack
2868 if not gDataLoaded
then
2870 e_WriteLog('Init OpenGL', MSG_NOTIFY
);
2872 e_WriteLog('Loading data', MSG_NOTIFY
);
2873 LoadStdFont('STDTXT', 'STDFONT', gEditorFont
);
2874 e_WriteLog('Loading more data', MSG_NOTIFY
);
2876 e_WriteLog('Loading even more data', MSG_NOTIFY
);
2877 gDataLoaded
:= True;
2878 MainForm
.FormResize(nil);
2882 procedure TMainForm
.Draw();
2887 Width
, Height
: Word;
2890 aX
, aY
, aX2
, aY2
, XX
, ScaleSz
: Integer;
2901 e_Clear(GL_COLOR_BUFFER_BIT
,
2902 GetRValue(BackColor
)/255,
2903 GetGValue(BackColor
)/255,
2904 GetBValue(BackColor
)/255);
2908 ObjCount
:= SelectedObjectCount();
2910 // Обводим выделенные объекты красной рамкой:
2911 if ObjCount
> 0 then
2913 for a
:= 0 to High(SelectedObjects
) do
2914 if SelectedObjects
[a
].Live
then
2916 Rect
:= ObjectGetRect(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
);
2920 e_DrawQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2921 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2924 // Рисуем точки изменения размеров:
2925 if (ObjCount
= 1) and
2926 (SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) then
2928 e_DrawPoint(5, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2929 e_DrawPoint(5, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2930 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 255, 255);
2931 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 255, 255);
2933 e_DrawPoint(3, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2934 e_DrawPoint(3, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2935 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 0, 0);
2936 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 0, 0);
2943 if DotEnable
and (PreviewMode
= 0) then
2950 x
:= MapOffset
.X
mod DotStep
;
2951 y
:= MapOffset
.Y
mod DotStep
;
2953 while x
< RenderPanel
.Width
do
2955 while y
< RenderPanel
.Height
do
2957 e_DrawPoint(DotSize
, x
+ a
, y
+ a
,
2958 GetRValue(DotColor
),
2959 GetGValue(DotColor
),
2960 GetBValue(DotColor
));
2964 y
:= MapOffset
.Y
mod DotStep
;
2969 if (lbTextureList
.ItemIndex
<> -1) and (cbPreview
.Checked
) and
2970 (not IsSpecialTextureSel()) and (PreviewMode
= 0) then
2972 if not g_GetTexture(SelectedTexture(), ID
) then
2973 g_GetTexture('NOTEXTURE', ID
);
2974 g_GetTextureSizeByID(ID
, Width
, Height
);
2975 if UseCheckerboard
then
2977 if g_GetTexture('PREVIEW', PID
) then
2978 e_DrawFill(PID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, Width
div 16 + 1, Height
div 16 + 1, 0, True, False);
2980 e_DrawFillQuad(RenderPanel
.Width
-Width
-2, RenderPanel
.Height
-Height
-2,
2981 RenderPanel
.Width
-1, RenderPanel
.Height
-1,
2982 GetRValue(PreviewColor
), GetGValue(PreviewColor
), GetBValue(PreviewColor
), 0);
2983 e_Draw(ID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, 0, True, False);
2986 // Подсказка при выборе точки Телепорта:
2987 if SelectFlag
= SELECTFLAG_TELEPORT
then
2989 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
2990 if Data
.d2d_teleport
then
2991 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
2992 MousePos
.X
+16, MousePos
.Y
-1,
2995 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+AreaSize
[AREA_DMPOINT
].Width
-1,
2996 MousePos
.Y
+AreaSize
[AREA_DMPOINT
].Height
-1, 255, 255, 255);
2998 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
2999 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3000 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintTeleport
), gEditorFont
);
3003 // Подсказка при выборе точки появления:
3004 if SelectFlag
= SELECTFLAG_SPAWNPOINT
then
3006 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
3007 MousePos
.X
+16, MousePos
.Y
-1,
3009 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3010 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3011 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintSpawn
), gEditorFont
);
3014 // Подсказка при выборе панели двери:
3015 if SelectFlag
= SELECTFLAG_DOOR
then
3017 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3018 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3019 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelDoor
), gEditorFont
);
3022 // Подсказка при выборе панели с текстурой:
3023 if SelectFlag
= SELECTFLAG_TEXTURE
then
3025 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 192, 192, 192, 127);
3026 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 255, 255, 255);
3027 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelTexture
), gEditorFont
);
3030 // Подсказка при выборе панели индикации выстрела:
3031 if SelectFlag
= SELECTFLAG_SHOTPANEL
then
3033 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 192, 192, 192, 127);
3034 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 255, 255, 255);
3035 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelShot
), gEditorFont
);
3038 // Подсказка при выборе панели лифта:
3039 if SelectFlag
= SELECTFLAG_LIFT
then
3041 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3042 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3043 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelLift
), gEditorFont
);
3046 // Подсказка при выборе монстра:
3047 if SelectFlag
= SELECTFLAG_MONSTER
then
3049 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 192, 192, 192, 127);
3050 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 255, 255, 255);
3051 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintMonster
), gEditorFont
);
3054 // Подсказка при выборе области воздействия:
3055 if DrawPressRect
then
3057 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 192, 192, 192, 127);
3058 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 255, 255, 255);
3059 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintExtArea
), gEditorFont
);
3062 // Рисуем текстуры, если чертим панель:
3063 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and (DrawTexturePanel
) and
3064 (lbTextureList
.ItemIndex
<> -1) and (DrawRect
<> nil) and
3065 (lbPanelType
.ItemIndex
in [0..8]) and not IsSpecialTextureSel() then
3067 if not g_GetTexture(SelectedTexture(), ID
) then
3068 g_GetTexture('NOTEXTURE', ID
);
3069 g_GetTextureSizeByID(ID
, Width
, Height
);
3071 if (Abs(Right
-Left
) >= Width
) and (Abs(Bottom
-Top
) >= Height
) then
3072 e_DrawFill(ID
, Min(Left
, Right
), Min(Top
, Bottom
), Abs(Right
-Left
) div Width
,
3073 Abs(Bottom
-Top
) div Height
, 64, True, False);
3076 // Прямоугольник выделения:
3077 if DrawRect
<> nil then
3079 e_DrawQuad(Left
, Top
, Right
-1, Bottom
-1, 255, 255, 255);
3081 // Чертим мышью панель/триггер или меняем мышью их размер:
3082 if (((MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
]) and
3083 not(ssCtrl
in GetKeyShiftState())) or (MouseAction
= MOUSEACTION_RESIZE
)) and
3084 (DrawPanelSize
) then
3086 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 192, 192, 192, 127);
3087 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 255, 255, 255);
3089 if MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
] then
3090 begin // Чертим новый
3091 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(utf8to1251(MsgHintWidth
),
3092 [Abs(MousePos
.X
-MouseLDownPos
.X
)]), gEditorFont
);
3093 PrintBlack(MousePos
.X
+2, MousePos
.Y
+16, Format(utf8to1251(MsgHintHeight
),
3094 [Abs(MousePos
.Y
-MouseLDownPos
.Y
)]), gEditorFont
);
3096 else // Растягиваем существующий
3097 if SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
] then
3099 if SelectedObjects
[GetFirstSelected
].ObjectType
= OBJECT_PANEL
then
3101 Width
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
3102 Height
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
3106 Width
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
3107 Height
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
3110 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(utf8to1251(MsgHintWidth
), [Width
]),
3112 PrintBlack(MousePos
.X
+2, MousePos
.Y
+16, Format(utf8to1251(MsgHintHeight
), [Height
]),
3117 // Ближайшая к курсору мыши точка на сетке:
3118 e_DrawPoint(3, MousePos
.X
, MousePos
.Y
, 0, 0, 255);
3123 // Сколько пикселов карты в 1 пикселе мини-карты:
3124 ScaleSz
:= 16 div Scale
;
3125 // Размеры мини-карты:
3126 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3127 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3128 // X-координата на RenderPanel нулевой x-координаты карты:
3129 XX
:= RenderPanel
.Width
- aX
- 1;
3131 e_DrawFillQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 0, 0, 0, 0);
3132 e_DrawQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 197, 197, 197);
3134 if gPanels
<> nil then
3137 for a
:= 0 to High(gPanels
) do
3139 if PanelType
<> 0 then
3141 // Левый верхний угол:
3142 aX
:= XX
+ (X
div ScaleSz
);
3143 aY
:= 1 + (Y
div ScaleSz
);
3145 aX2
:= max(Width
div ScaleSz
, 1);
3146 aY2
:= max(Height
div ScaleSz
, 1);
3147 // Правый нижний угол:
3148 aX2
:= aX
+ aX2
- 1;
3149 aY2
:= aY
+ aY2
- 1;
3152 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3153 PANEL_WATER
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3154 PANEL_ACID1
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3155 PANEL_ACID2
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3156 PANEL_STEP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3157 PANEL_LIFTUP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3158 PANEL_LIFTDOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3159 PANEL_LIFTLEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3160 PANEL_LIFTRIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3161 PANEL_OPENDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 100, 220, 92, 0);
3162 PANEL_CLOSEDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 212, 184, 64, 0);
3163 PANEL_BLOCKMON
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 192, 0, 192, 0);
3167 // Рисуем красным выделенные панели:
3168 if SelectedObjects
<> nil then
3169 for b
:= 0 to High(SelectedObjects
) do
3170 with SelectedObjects
[b
] do
3171 if Live
and (ObjectType
= OBJECT_PANEL
) then
3172 with gPanels
[SelectedObjects
[b
].ID
] do
3173 if PanelType
and not(PANEL_BACK
or PANEL_FORE
) <> 0 then
3175 // Левый верхний угол:
3176 aX
:= XX
+ (X
div ScaleSz
);
3177 aY
:= 1 + (Y
div ScaleSz
);
3179 aX2
:= max(Width
div ScaleSz
, 1);
3180 aY2
:= max(Height
div ScaleSz
, 1);
3181 // Правый нижний угол:
3182 aX2
:= aX
+ aX2
- 1;
3183 aY2
:= aY
+ aY2
- 1;
3185 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0)
3189 if (gMapInfo
.Width
> RenderPanel
.Width
) or
3190 (gMapInfo
.Height
> RenderPanel
.Height
) then
3192 // Окно, показывающее текущее положение экрана на карте:
3194 x
:= max(min(RenderPanel
.Width
, gMapInfo
.Width
) div ScaleSz
, 1);
3195 y
:= max(min(RenderPanel
.Height
, gMapInfo
.Height
) div ScaleSz
, 1);
3196 // Левый верхний угол:
3197 aX
:= XX
+ ((-MapOffset
.X
) div ScaleSz
);
3198 aY
:= 1 + ((-MapOffset
.Y
) div ScaleSz
);
3199 // Правый нижний угол:
3203 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 127, 192, 127, 127, B_BLEND
);
3204 e_DrawQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0);
3209 RenderPanel
.SwapBuffers();
3212 procedure TMainForm
.FormResize(Sender
: TObject
);
3214 e_SetViewPort(0, 0, RenderPanel
.Width
, RenderPanel
.Height
);
3216 sbHorizontal
.Min
:= Min(gMapInfo
.Width
- RenderPanel
.Width
, -RenderPanel
.Width
div 2);
3217 sbHorizontal
.Max
:= Max(0, gMapInfo
.Width
- RenderPanel
.Width
div 2);
3218 sbVertical
.Min
:= Min(gMapInfo
.Height
- RenderPanel
.Height
, -RenderPanel
.Height
div 2);
3219 sbVertical
.Max
:= Max(0, gMapInfo
.Height
- RenderPanel
.Height
div 2);
3221 MapOffset
.X
:= -sbHorizontal
.Position
;
3222 MapOffset
.Y
:= -sbVertical
.Position
;
3225 procedure TMainForm
.FormWindowStateChange(Sender
: TObject
);
3231 // deactivate all menus when main window minimized
3232 e
:= self
.WindowState
<> wsMinimized
;
3233 miMenuFile
.Enabled
:= e
;
3234 miMenuEdit
.Enabled
:= e
;
3235 miMenuView
.Enabled
:= e
;
3236 miMenuService
.Enabled
:= e
;
3237 miMenuWindow
.Enabled
:= e
;
3238 miMenuHelp
.Enabled
:= e
;
3239 miMenuHidden
.Enabled
:= e
;
3243 procedure SelectNextObject(X
, Y
: Integer; ObjectType
: Byte; ID
: DWORD
);
3248 j_max
:= 0; // shut up compiler
3252 res
:= (gPanels
<> nil) and
3253 PanelInShownLayer(gPanels
[ID
].PanelType
) and
3254 g_CollidePoint(X
, Y
, gPanels
[ID
].X
, gPanels
[ID
].Y
,
3256 gPanels
[ID
].Height
);
3257 j_max
:= Length(gPanels
) - 1;
3262 res
:= (gItems
<> nil) and
3263 LayerEnabled
[LAYER_ITEMS
] and
3264 g_CollidePoint(X
, Y
, gItems
[ID
].X
, gItems
[ID
].Y
,
3265 ItemSize
[gItems
[ID
].ItemType
][0],
3266 ItemSize
[gItems
[ID
].ItemType
][1]);
3267 j_max
:= Length(gItems
) - 1;
3272 res
:= (gMonsters
<> nil) and
3273 LayerEnabled
[LAYER_MONSTERS
] and
3274 g_CollidePoint(X
, Y
, gMonsters
[ID
].X
, gMonsters
[ID
].Y
,
3275 MonsterSize
[gMonsters
[ID
].MonsterType
].Width
,
3276 MonsterSize
[gMonsters
[ID
].MonsterType
].Height
);
3277 j_max
:= Length(gMonsters
) - 1;
3282 res
:= (gAreas
<> nil) and
3283 LayerEnabled
[LAYER_AREAS
] and
3284 g_CollidePoint(X
, Y
, gAreas
[ID
].X
, gAreas
[ID
].Y
,
3285 AreaSize
[gAreas
[ID
].AreaType
].Width
,
3286 AreaSize
[gAreas
[ID
].AreaType
].Height
);
3287 j_max
:= Length(gAreas
) - 1;
3292 res
:= (gTriggers
<> nil) and
3293 LayerEnabled
[LAYER_TRIGGERS
] and
3294 g_CollidePoint(X
, Y
, gTriggers
[ID
].X
, gTriggers
[ID
].Y
,
3295 gTriggers
[ID
].Width
,
3296 gTriggers
[ID
].Height
);
3297 j_max
:= Length(gTriggers
) - 1;
3307 // Перебор ID: от ID-1 до 0; потом от High до ID+1:
3316 if j
= Integer(ID
) then
3321 res
:= PanelInShownLayer(gPanels
[j
].PanelType
) and
3322 g_CollidePoint(X
, Y
, gPanels
[j
].X
, gPanels
[j
].Y
,
3326 res
:= (gItems
[j
].ItemType
<> ITEM_NONE
) and
3327 g_CollidePoint(X
, Y
, gItems
[j
].X
, gItems
[j
].Y
,
3328 ItemSize
[gItems
[j
].ItemType
][0],
3329 ItemSize
[gItems
[j
].ItemType
][1]);
3331 res
:= (gMonsters
[j
].MonsterType
<> MONSTER_NONE
) and
3332 g_CollidePoint(X
, Y
, gMonsters
[j
].X
, gMonsters
[j
].Y
,
3333 MonsterSize
[gMonsters
[j
].MonsterType
].Width
,
3334 MonsterSize
[gMonsters
[j
].MonsterType
].Height
);
3336 res
:= (gAreas
[j
].AreaType
<> AREA_NONE
) and
3337 g_CollidePoint(X
, Y
, gAreas
[j
].X
, gAreas
[j
].Y
,
3338 AreaSize
[gAreas
[j
].AreaType
].Width
,
3339 AreaSize
[gAreas
[j
].AreaType
].Height
);
3341 res
:= (gTriggers
[j
].TriggerType
<> TRIGGER_NONE
) and
3342 g_CollidePoint(X
, Y
, gTriggers
[j
].X
, gTriggers
[j
].Y
,
3344 gTriggers
[j
].Height
);
3351 SetLength(SelectedObjects
, 1);
3353 SelectedObjects
[0].ObjectType
:= ObjectType
;
3354 SelectedObjects
[0].ID
:= j
;
3355 SelectedObjects
[0].Live
:= True;
3363 procedure TMainForm
.RenderPanelMouseDown(Sender
: TObject
;
3364 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3368 c1
, c2
, c3
, c4
: Boolean;
3374 MainForm
.ActiveControl
:= RenderPanel
;
3375 RenderPanel
.SetFocus();
3377 RenderPanelMouseMove(RenderPanel
, Shift
, X
, Y
);
3379 if Button
= mbLeft
then // Left Mouse Button
3381 // Двигаем карту с помощью мыши и мини-карты:
3383 g_CollidePoint(X
, Y
,
3384 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3386 max(gMapInfo
.Width
div (16 div Scale
), 1),
3387 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3390 MouseAction
:= MOUSEACTION_MOVEMAP
;
3392 else // Ставим предмет/монстра/область:
3393 if (pcObjects
.ActivePageIndex
in [1, 2, 3]) and
3394 (not (ssShift
in Shift
)) then
3396 case pcObjects
.ActivePageIndex
of
3398 if lbItemList
.ItemIndex
= -1 then
3399 ErrorMessageBox(MsgMsgChooseItem
)
3402 item
.ItemType
:= lbItemList
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
3403 if item
.ItemType
>= ITEM_WEAPON_KASTET
then
3404 item
.ItemType
:= item
.ItemType
+ 2;
3405 item
.X
:= MousePos
.X
-MapOffset
.X
;
3406 item
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3408 if not (ssCtrl
in Shift
) then
3410 item
.X
:= item
.X
- (ItemSize
[item
.ItemType
][0] div 2);
3411 item
.Y
:= item
.Y
- ItemSize
[item
.ItemType
][1];
3414 item
.OnlyDM
:= cbOnlyDM
.Checked
;
3415 item
.Fall
:= cbFall
.Checked
;
3416 Undo_Add(OBJECT_ITEM
, AddItem(item
));
3419 if lbMonsterList
.ItemIndex
= -1 then
3420 ErrorMessageBox(MsgMsgChooseMonster
)
3423 monster
.MonsterType
:= lbMonsterList
.ItemIndex
+ MONSTER_DEMON
;
3424 monster
.X
:= MousePos
.X
-MapOffset
.X
;
3425 monster
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3427 if not (ssCtrl
in Shift
) then
3429 monster
.X
:= monster
.X
- (MonsterSize
[monster
.MonsterType
].Width
div 2);
3430 monster
.Y
:= monster
.Y
- MonsterSize
[monster
.MonsterType
].Height
;
3433 if rbMonsterLeft
.Checked
then
3434 monster
.Direction
:= D_LEFT
3436 monster
.Direction
:= D_RIGHT
;
3437 Undo_Add(OBJECT_MONSTER
, AddMonster(monster
));
3440 if lbAreasList
.ItemIndex
= -1 then
3441 ErrorMessageBox(MsgMsgChooseArea
)
3443 if (lbAreasList
.ItemIndex
+ 1) <> AREA_DOMFLAG
then
3445 area
.AreaType
:= lbAreasList
.ItemIndex
+ AREA_PLAYERPOINT1
;
3446 area
.X
:= MousePos
.X
-MapOffset
.X
;
3447 area
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3449 if not (ssCtrl
in Shift
) then
3451 area
.X
:= area
.X
- (AreaSize
[area
.AreaType
].Width
div 2);
3452 area
.Y
:= area
.Y
- AreaSize
[area
.AreaType
].Height
;
3455 if rbAreaLeft
.Checked
then
3456 area
.Direction
:= D_LEFT
3458 area
.Direction
:= D_RIGHT
;
3459 Undo_Add(OBJECT_AREA
, AddArea(area
));
3465 i
:= GetFirstSelected();
3467 // Выбираем объект под текущим:
3468 if (SelectedObjects
<> nil) and
3469 (ssShift
in Shift
) and (i
>= 0) and
3470 (SelectedObjects
[i
].Live
) then
3472 if SelectedObjectCount() = 1 then
3473 SelectNextObject(X
-MapOffset
.X
, Y
-MapOffset
.Y
,
3474 SelectedObjects
[i
].ObjectType
,
3475 SelectedObjects
[i
].ID
);
3479 // Рисуем область триггера "Расширитель":
3480 if DrawPressRect
and (i
>= 0) and
3481 (SelectedObjects
[i
].ObjectType
= OBJECT_TRIGGER
) and
3482 (gTriggers
[SelectedObjects
[i
].ID
].TriggerType
in
3483 [TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
]) then
3484 MouseAction
:= MOUSEACTION_DRAWPRESS
3485 else // Рисуем панель:
3486 if pcObjects
.ActivePageIndex
= 0 then
3488 if (lbPanelType
.ItemIndex
>= 0) then
3489 MouseAction
:= MOUSEACTION_DRAWPANEL
3491 else // Рисуем триггер:
3492 if (lbTriggersList
.ItemIndex
>= 0) then
3494 MouseAction
:= MOUSEACTION_DRAWTRIGGER
;
3498 end; // if Button = mbLeft
3500 if Button
= mbRight
then // Right Mouse Button
3502 // Клик по мини-карте:
3504 g_CollidePoint(X
, Y
,
3505 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3507 max(gMapInfo
.Width
div (16 div Scale
), 1),
3508 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3510 MouseAction
:= MOUSEACTION_NOACTION
;
3512 else // Нужно что-то выбрать мышью:
3513 if SelectFlag
<> SELECTFLAG_NONE
then
3516 SELECTFLAG_TELEPORT
:
3517 // Точку назначения телепортации:
3518 with gTriggers
[SelectedObjects
[
3519 GetFirstSelected() ].ID
].Data
.TargetPoint
do
3521 X
:= MousePos
.X
-MapOffset
.X
;
3522 Y
:= MousePos
.Y
-MapOffset
.Y
;
3525 SELECTFLAG_SPAWNPOINT
:
3526 // Точку создания монстра:
3527 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
3528 if TriggerType
= TRIGGER_SPAWNMONSTER
then
3530 Data
.MonPos
.X
:= MousePos
.X
-MapOffset
.X
;
3531 Data
.MonPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3533 else if TriggerType
= TRIGGER_SPAWNITEM
then
3534 begin // Точка создания предмета:
3535 Data
.ItemPos
.X
:= MousePos
.X
-MapOffset
.X
;
3536 Data
.ItemPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3538 else if TriggerType
= TRIGGER_SHOT
then
3539 begin // Точка создания выстрела:
3540 Data
.ShotPos
.X
:= MousePos
.X
-MapOffset
.X
;
3541 Data
.ShotPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3547 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3549 2, 2, OBJECT_PANEL
, True);
3550 if IDArray
<> nil then
3552 for i
:= 0 to High(IDArray
) do
3553 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3554 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
) then
3556 gTriggers
[SelectedObjects
[
3557 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3562 gTriggers
[SelectedObjects
[
3563 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3567 // Панель с текстурой:
3569 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3571 2, 2, OBJECT_PANEL
, True);
3572 if IDArray
<> nil then
3574 for i
:= 0 to High(IDArray
) do
3575 if ((gPanels
[IDArray
[i
]].PanelType
in
3576 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3577 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3579 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3580 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3581 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3583 gTriggers
[SelectedObjects
[
3584 GetFirstSelected() ].ID
].TexturePanel
:= IDArray
[i
];
3589 gTriggers
[SelectedObjects
[
3590 GetFirstSelected() ].ID
].TexturePanel
:= -1;
3596 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3598 2, 2, OBJECT_PANEL
, True);
3599 if IDArray
<> nil then
3601 for i
:= 0 to High(IDArray
) do
3602 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTUP
) or
3603 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTDOWN
) or
3604 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTLEFT
) or
3605 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTRIGHT
) then
3607 gTriggers
[SelectedObjects
[
3608 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3613 gTriggers
[SelectedObjects
[
3614 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3620 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3622 2, 2, OBJECT_MONSTER
, False);
3623 if IDArray
<> nil then
3624 gTriggers
[SelectedObjects
[
3625 GetFirstSelected() ].ID
].Data
.MonsterID
:= IDArray
[0]+1
3627 gTriggers
[SelectedObjects
[
3628 GetFirstSelected() ].ID
].Data
.MonsterID
:= 0;
3631 SELECTFLAG_SHOTPANEL
:
3632 // Панель индикации выстрела:
3634 if gTriggers
[SelectedObjects
[
3635 GetFirstSelected() ].ID
].TriggerType
= TRIGGER_SHOT
then
3637 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3639 2, 2, OBJECT_PANEL
, True);
3640 if IDArray
<> nil then
3642 for i
:= 0 to High(IDArray
) do
3643 if ((gPanels
[IDArray
[i
]].PanelType
in
3644 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3645 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3647 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3648 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3649 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3651 gTriggers
[SelectedObjects
[
3652 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= IDArray
[i
];
3657 gTriggers
[SelectedObjects
[
3658 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= -1;
3663 SelectFlag
:= SELECTFLAG_SELECTED
;
3665 else // if SelectFlag <> SELECTFLAG_NONE...
3667 // Что уже выбрано и не нажат Ctrl:
3668 if (SelectedObjects
<> nil) and
3669 (not (ssCtrl
in Shift
)) then
3670 for i
:= 0 to High(SelectedObjects
) do
3671 with SelectedObjects
[i
] do
3674 if (ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) and
3675 (SelectedObjectCount() = 1) then
3677 Rect
:= ObjectGetRect(ObjectType
, ID
);
3679 c1
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3680 Rect
.X
-2, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3681 c2
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3682 Rect
.X
+Rect
.Width
-3, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3683 c3
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3684 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
-2, 4, 4);
3685 c4
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3686 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
+Rect
.Height
-3, 4, 4);
3688 // Меняем размер панели или триггера:
3689 if c1
or c2
or c3
or c4
then
3691 MouseAction
:= MOUSEACTION_RESIZE
;
3692 LastMovePoint
:= MousePos
;
3696 ResizeType
:= RESIZETYPE_HORIZONTAL
;
3698 ResizeDirection
:= RESIZEDIR_LEFT
3700 ResizeDirection
:= RESIZEDIR_RIGHT
;
3701 RenderPanel
.Cursor
:= crSizeWE
;
3705 ResizeType
:= RESIZETYPE_VERTICAL
;
3707 ResizeDirection
:= RESIZEDIR_UP
3709 ResizeDirection
:= RESIZEDIR_DOWN
;
3710 RenderPanel
.Cursor
:= crSizeNS
;
3717 // Перемещаем панель или триггер:
3718 if ObjectCollide(ObjectType
, ID
,
3720 Y
-MapOffset
.Y
-1, 2, 2) then
3722 MouseAction
:= MOUSEACTION_MOVEOBJ
;
3723 LastMovePoint
:= MousePos
;
3729 end; // if Button = mbRight
3731 if Button
= mbMiddle
then // Middle Mouse Button
3733 SetCapture(RenderPanel
.Handle
);
3734 RenderPanel
.Cursor
:= crSize
;
3737 MouseMDown
:= Button
= mbMiddle
;
3739 MouseMDownPos
:= Mouse
.CursorPos
;
3741 MouseRDown
:= Button
= mbRight
;
3743 MouseRDownPos
:= MousePos
;
3745 MouseLDown
:= Button
= mbLeft
;
3747 MouseLDownPos
:= MousePos
;
3750 procedure TMainForm
.RenderPanelMouseUp(Sender
: TObject
;
3751 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3756 rSelectRect
: Boolean;
3757 wWidth
, wHeight
: Word;
3760 procedure SelectObjects(ObjectType
: Byte);
3765 IDArray
:= ObjectInRect(rRect
.X
, rRect
.Y
,
3766 rRect
.Width
, rRect
.Height
,
3767 ObjectType
, rSelectRect
);
3769 if IDArray
<> nil then
3770 for i
:= 0 to High(IDArray
) do
3771 SelectObject(ObjectType
, IDArray
[i
], (ssCtrl
in Shift
) or rSelectRect
);
3774 if Button
= mbLeft
then
3775 MouseLDown
:= False;
3776 if Button
= mbRight
then
3777 MouseRDown
:= False;
3778 if Button
= mbMiddle
then
3779 MouseMDown
:= False;
3781 if DrawRect
<> nil then
3787 ResizeType
:= RESIZETYPE_NONE
;
3790 if Button
= mbLeft
then // Left Mouse Button
3792 if MouseAction
<> MOUSEACTION_NONE
then
3793 begin // Было действие мышью
3794 // Мышь сдвинулась во время удержания клавиши,
3795 // либо активирован режим быстрого рисования:
3796 if ((MousePos
.X
<> MouseLDownPos
.X
) and
3797 (MousePos
.Y
<> MouseLDownPos
.Y
)) or
3798 ((MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
]) and
3799 (ssCtrl
in Shift
)) then
3802 MOUSEACTION_DRAWPANEL
:
3804 // Фон или передний план без текстуры - ошибка:
3805 if (lbPanelType
.ItemIndex
in [1, 2]) and
3806 (lbTextureList
.ItemIndex
= -1) then
3807 ErrorMessageBox(MsgMsgChooseTexture
)
3808 else // Назначаем параметры панели:
3810 case lbPanelType
.ItemIndex
of
3811 0: Panel
.PanelType
:= PANEL_WALL
;
3812 1: Panel
.PanelType
:= PANEL_BACK
;
3813 2: Panel
.PanelType
:= PANEL_FORE
;
3814 3: Panel
.PanelType
:= PANEL_OPENDOOR
;
3815 4: Panel
.PanelType
:= PANEL_CLOSEDOOR
;
3816 5: Panel
.PanelType
:= PANEL_STEP
;
3817 6: Panel
.PanelType
:= PANEL_WATER
;
3818 7: Panel
.PanelType
:= PANEL_ACID1
;
3819 8: Panel
.PanelType
:= PANEL_ACID2
;
3820 9: Panel
.PanelType
:= PANEL_LIFTUP
;
3821 10: Panel
.PanelType
:= PANEL_LIFTDOWN
;
3822 11: Panel
.PanelType
:= PANEL_LIFTLEFT
;
3823 12: Panel
.PanelType
:= PANEL_LIFTRIGHT
;
3824 13: Panel
.PanelType
:= PANEL_BLOCKMON
;
3827 Panel
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3828 Panel
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3829 if ssCtrl
in Shift
then
3833 if (lbTextureList
.ItemIndex
<> -1) and
3834 (not IsSpecialTextureSel()) then
3836 if not g_GetTexture(SelectedTexture(), TextureID
) then
3837 g_GetTexture('NOTEXTURE', TextureID
);
3838 g_GetTextureSizeByID(TextureID
, wWidth
, wHeight
);
3840 Panel
.Width
:= wWidth
;
3841 Panel
.Height
:= wHeight
;
3845 Panel
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3846 Panel
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3849 // Лифты, блокМон или отсутствие текстуры - пустая текстура:
3850 if (lbPanelType
.ItemIndex
in [9, 10, 11, 12, 13]) or
3851 (lbTextureList
.ItemIndex
= -1) then
3853 Panel
.TextureHeight
:= 1;
3854 Panel
.TextureWidth
:= 1;
3855 Panel
.TextureName
:= '';
3856 Panel
.TextureID
:= TEXTURE_SPECIAL_NONE
;
3858 else // Есть текстура:
3860 Panel
.TextureName
:= SelectedTexture();
3862 // Обычная текстура:
3863 if not IsSpecialTextureSel() then
3865 g_GetTextureSizeByName(Panel
.TextureName
,
3866 Panel
.TextureWidth
, Panel
.TextureHeight
);
3867 g_GetTexture(Panel
.TextureName
, Panel
.TextureID
);
3869 else // Спец.текстура:
3871 Panel
.TextureHeight
:= 1;
3872 Panel
.TextureWidth
:= 1;
3873 Panel
.TextureID
:= SpecialTextureID(SelectedTexture());
3878 Panel
.Blending
:= False;
3880 Undo_Add(OBJECT_PANEL
, AddPanel(Panel
));
3884 // Рисовали триггер:
3885 MOUSEACTION_DRAWTRIGGER
:
3887 trigger
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3888 trigger
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3889 if ssCtrl
in Shift
then
3893 trigger
.Width
:= wWidth
;
3894 trigger
.Height
:= wHeight
;
3898 trigger
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3899 trigger
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3902 trigger
.Enabled
:= True;
3903 trigger
.TriggerType
:= lbTriggersList
.ItemIndex
+1;
3904 trigger
.TexturePanel
:= -1;
3907 trigger
.ActivateType
:= 0;
3909 if clbActivationType
.Checked
[0] then
3910 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERCOLLIDE
;
3911 if clbActivationType
.Checked
[1] then
3912 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERCOLLIDE
;
3913 if clbActivationType
.Checked
[2] then
3914 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERPRESS
;
3915 if clbActivationType
.Checked
[3] then
3916 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERPRESS
;
3917 if clbActivationType
.Checked
[4] then
3918 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_SHOT
;
3919 if clbActivationType
.Checked
[5] then
3920 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_NOMONSTER
;
3922 // Необходимые для активации ключи:
3925 if clbKeys
.Checked
[0] then
3926 trigger
.Key
:= Trigger
.Key
or KEY_RED
;
3927 if clbKeys
.Checked
[1] then
3928 trigger
.Key
:= Trigger
.Key
or KEY_GREEN
;
3929 if clbKeys
.Checked
[2] then
3930 trigger
.Key
:= Trigger
.Key
or KEY_BLUE
;
3931 if clbKeys
.Checked
[3] then
3932 trigger
.Key
:= Trigger
.Key
or KEY_REDTEAM
;
3933 if clbKeys
.Checked
[4] then
3934 trigger
.Key
:= Trigger
.Key
or KEY_BLUETEAM
;
3936 // Параметры триггера:
3937 FillByte(trigger
.Data
.Default
[0], 128, 0);
3939 case trigger
.TriggerType
of
3940 // Переключаемая панель:
3941 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
3942 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
3943 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
3945 Trigger
.Data
.PanelID
:= -1;
3951 trigger
.Data
.TargetPoint
.X
:= trigger
.X
-64;
3952 trigger
.Data
.TargetPoint
.Y
:= trigger
.Y
-64;
3953 trigger
.Data
.d2d_teleport
:= True;
3954 trigger
.Data
.TlpDir
:= 0;
3957 // Изменение других триггеров:
3958 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
3961 trigger
.Data
.Count
:= 1;
3967 trigger
.Data
.Volume
:= 255;
3968 trigger
.Data
.Pan
:= 127;
3969 trigger
.Data
.PlayCount
:= 1;
3970 trigger
.Data
.Local
:= True;
3971 trigger
.Data
.SoundSwitch
:= False;
3977 trigger
.Data
.MusicAction
:= 1;
3980 // Создание монстра:
3981 TRIGGER_SPAWNMONSTER
:
3983 trigger
.Data
.MonType
:= MONSTER_ZOMBY
;
3984 trigger
.Data
.MonPos
.X
:= trigger
.X
-64;
3985 trigger
.Data
.MonPos
.Y
:= trigger
.Y
-64;
3986 trigger
.Data
.MonHealth
:= 0;
3987 trigger
.Data
.MonActive
:= False;
3988 trigger
.Data
.MonCount
:= 1;
3991 // Создание предмета:
3994 trigger
.Data
.ItemType
:= ITEM_AMMO_BULLETS
;
3995 trigger
.Data
.ItemPos
.X
:= trigger
.X
-64;
3996 trigger
.Data
.ItemPos
.Y
:= trigger
.Y
-64;
3997 trigger
.Data
.ItemOnlyDM
:= False;
3998 trigger
.Data
.ItemFalls
:= False;
3999 trigger
.Data
.ItemCount
:= 1;
4000 trigger
.Data
.ItemMax
:= 0;
4001 trigger
.Data
.ItemDelay
:= 0;
4007 trigger
.Data
.PushAngle
:= 90;
4008 trigger
.Data
.PushForce
:= 10;
4009 trigger
.Data
.ResetVel
:= True;
4014 trigger
.Data
.ScoreCount
:= 1;
4015 trigger
.Data
.ScoreCon
:= True;
4016 trigger
.Data
.ScoreMsg
:= True;
4021 trigger
.Data
.MessageKind
:= 0;
4022 trigger
.Data
.MessageSendTo
:= 0;
4023 trigger
.Data
.MessageText
:= '';
4024 trigger
.Data
.MessageTime
:= 144;
4029 trigger
.Data
.DamageValue
:= 5;
4030 trigger
.Data
.DamageInterval
:= 12;
4035 trigger
.Data
.HealValue
:= 5;
4036 trigger
.Data
.HealInterval
:= 36;
4041 trigger
.Data
.ShotType
:= TRIGGER_SHOT_BULLET
;
4042 trigger
.Data
.ShotSound
:= True;
4043 trigger
.Data
.ShotPanelID
:= -1;
4044 trigger
.Data
.ShotTarget
:= 0;
4045 trigger
.Data
.ShotIntSight
:= 0;
4046 trigger
.Data
.ShotAim
:= TRIGGER_SHOT_AIM_DEFAULT
;
4047 trigger
.Data
.ShotPos
.X
:= trigger
.X
-64;
4048 trigger
.Data
.ShotPos
.Y
:= trigger
.Y
-64;
4049 trigger
.Data
.ShotAngle
:= 0;
4050 trigger
.Data
.ShotWait
:= 18;
4051 trigger
.Data
.ShotAccuracy
:= 0;
4052 trigger
.Data
.ShotAmmo
:= 0;
4053 trigger
.Data
.ShotIntReload
:= 0;
4058 trigger
.Data
.FXCount
:= 1;
4059 trigger
.Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
4060 trigger
.Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
4061 trigger
.Data
.FXColorR
:= 0;
4062 trigger
.Data
.FXColorG
:= 0;
4063 trigger
.Data
.FXColorB
:= 255;
4064 trigger
.Data
.FXPos
:= TRIGGER_EFFECT_POS_CENTER
;
4065 trigger
.Data
.FXWait
:= 1;
4066 trigger
.Data
.FXVelX
:= 0;
4067 trigger
.Data
.FXVelY
:= -20;
4068 trigger
.Data
.FXSpreadL
:= 5;
4069 trigger
.Data
.FXSpreadR
:= 5;
4070 trigger
.Data
.FXSpreadU
:= 4;
4071 trigger
.Data
.FXSpreadD
:= 0;
4075 Undo_Add(OBJECT_TRIGGER
, AddTrigger(trigger
));
4078 // Рисовали область триггера "Расширитель":
4079 MOUSEACTION_DRAWPRESS
:
4080 with gTriggers
[SelectedObjects
[GetFirstSelected
].ID
] do
4082 Data
.tX
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
4083 Data
.tY
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
4084 Data
.tWidth
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
4085 Data
.tHeight
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
4087 DrawPressRect
:= False;
4091 MouseAction
:= MOUSEACTION_NONE
;
4093 end // if Button = mbLeft...
4094 else if Button
= mbRight
then // Right Mouse Button:
4096 if MouseAction
= MOUSEACTION_NOACTION
then
4098 MouseAction
:= MOUSEACTION_NONE
;
4102 // Объект передвинут или изменен в размере:
4103 if MouseAction
in [MOUSEACTION_MOVEOBJ
, MOUSEACTION_RESIZE
] then
4105 RenderPanel
.Cursor
:= crDefault
;
4106 MouseAction
:= MOUSEACTION_NONE
;
4111 // Еще не все выбрали:
4112 if SelectFlag
<> SELECTFLAG_NONE
then
4114 if SelectFlag
= SELECTFLAG_SELECTED
then
4115 SelectFlag
:= SELECTFLAG_NONE
;
4120 // Мышь сдвинулась во время удержания клавиши:
4121 if (MousePos
.X
<> MouseRDownPos
.X
) and
4122 (MousePos
.Y
<> MouseRDownPos
.Y
) then
4124 rSelectRect
:= True;
4126 rRect
.X
:= Min(MousePos
.X
, MouseRDownPos
.X
)-MapOffset
.X
;
4127 rRect
.Y
:= Min(MousePos
.Y
, MouseRDownPos
.Y
)-MapOffset
.Y
;
4128 rRect
.Width
:= Abs(MousePos
.X
-MouseRDownPos
.X
);
4129 rRect
.Height
:= Abs(MousePos
.Y
-MouseRDownPos
.Y
);
4131 else // Мышь не сдвинулась - нет прямоугольника:
4133 rSelectRect
:= False;
4135 rRect
.X
:= X
-MapOffset
.X
-1;
4136 rRect
.Y
:= Y
-MapOffset
.Y
-1;
4141 // Если зажат Ctrl - выделять еще, иначе только один выделенный объект:
4142 if not (ssCtrl
in Shift
) then
4143 RemoveSelectFromObjects();
4145 // Выделяем всё в выбранном прямоугольнике:
4146 if (ssCtrl
in Shift
) and (ssAlt
in Shift
) then
4148 SelectObjects(OBJECT_PANEL
);
4149 SelectObjects(OBJECT_ITEM
);
4150 SelectObjects(OBJECT_MONSTER
);
4151 SelectObjects(OBJECT_AREA
);
4152 SelectObjects(OBJECT_TRIGGER
);
4155 SelectObjects(pcObjects
.ActivePageIndex
+1);
4160 else // Middle Mouse Button
4162 RenderPanel
.Cursor
:= crDefault
;
4167 procedure TMainForm
.RenderPanelPaint(Sender
: TObject
);
4172 function TMainForm
.RenderMousePos(): Types
.TPoint
;
4174 Result
:= RenderPanel
.ScreenToClient(Mouse
.CursorPos
);
4177 procedure TMainForm
.RecountSelectedObjects();
4179 if SelectedObjectCount() = 0 then
4180 StatusBar
.Panels
[0].Text := ''
4182 StatusBar
.Panels
[0].Text := Format(MsgCapStatSelected
, [SelectedObjectCount()]);
4185 procedure TMainForm
.RenderPanelMouseMove(Sender
: TObject
;
4186 Shift
: TShiftState
; X
, Y
: Integer);
4189 dWidth
, dHeight
: Integer;
4192 wWidth
, wHeight
: Word;
4194 _id
:= GetFirstSelected();
4197 // Рисуем панель с текстурой, сетка - размеры текстуры:
4198 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and
4199 (lbPanelType
.ItemIndex
in [0..8]) and
4200 (lbTextureList
.ItemIndex
<> -1) and
4201 (not IsSpecialTextureSel()) then
4203 sX
:= StrToIntDef(lTextureWidth
.Caption
, DotStep
);
4204 sY
:= StrToIntDef(lTextureHeight
.Caption
, DotStep
);
4207 // Меняем размер панели с текстурой, сетка - размеры текстуры:
4208 if (MouseAction
= MOUSEACTION_RESIZE
) and
4209 ( (SelectedObjects
[_id
].ObjectType
= OBJECT_PANEL
) and
4210 IsTexturedPanel(gPanels
[SelectedObjects
[_id
].ID
].PanelType
) and
4211 (gPanels
[SelectedObjects
[_id
].ID
].TextureName
<> '') and
4212 (not IsSpecialTexture(gPanels
[SelectedObjects
[_id
].ID
].TextureName
)) ) then
4214 sX
:= gPanels
[SelectedObjects
[_id
].ID
].TextureWidth
;
4215 sY
:= gPanels
[SelectedObjects
[_id
].ID
].TextureHeight
;
4218 // Выравнивание по сетке:
4224 else // Нет выравнивания по сетке:
4230 // Новая позиция мыши:
4232 begin // Зажата левая кнопка мыши
4233 MousePos
.X
:= (Round((X
-MouseLDownPos
.X
)/sX
)*sX
)+MouseLDownPos
.X
;
4234 MousePos
.Y
:= (Round((Y
-MouseLDownPos
.Y
)/sY
)*sY
)+MouseLDownPos
.Y
;
4238 begin // Зажата правая кнопка мыши
4239 MousePos
.X
:= (Round((X
-MouseRDownPos
.X
)/sX
)*sX
)+MouseRDownPos
.X
;
4240 MousePos
.Y
:= (Round((Y
-MouseRDownPos
.Y
)/sY
)*sY
)+MouseRDownPos
.Y
;
4243 begin // Кнопки мыши не зажаты
4244 MousePos
.X
:= Round((-MapOffset
.X
+ X
) / sX
) * sX
+ MapOffset
.X
;
4245 MousePos
.Y
:= Round((-MapOffset
.Y
+ Y
) / sY
) * sY
+ MapOffset
.Y
;
4248 // Зажата только правая кнопка мыши:
4249 if (not MouseLDown
) and (MouseRDown
) and (not MouseMDown
) then
4251 // Рисуем прямоугольник выделения:
4252 if MouseAction
= MOUSEACTION_NONE
then
4254 if DrawRect
= nil then
4256 DrawRect
.Top
:= MouseRDownPos
.y
;
4257 DrawRect
.Left
:= MouseRDownPos
.x
;
4258 DrawRect
.Bottom
:= MousePos
.y
;
4259 DrawRect
.Right
:= MousePos
.x
;
4262 // Двигаем выделенные объекты:
4263 if MouseAction
= MOUSEACTION_MOVEOBJ
then
4265 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
,
4266 MousePos
.X
-LastMovePoint
.X
,
4267 MousePos
.Y
-LastMovePoint
.Y
);
4270 // Меняем размер выделенного объекта:
4271 if MouseAction
= MOUSEACTION_RESIZE
then
4273 if (SelectedObjectCount
= 1) and
4274 (SelectedObjects
[GetFirstSelected
].Live
) then
4276 dWidth
:= MousePos
.X
-LastMovePoint
.X
;
4277 dHeight
:= MousePos
.Y
-LastMovePoint
.Y
;
4280 RESIZETYPE_VERTICAL
: dWidth
:= 0;
4281 RESIZETYPE_HORIZONTAL
: dHeight
:= 0;
4284 case ResizeDirection
of
4285 RESIZEDIR_UP
: dHeight
:= -dHeight
;
4286 RESIZEDIR_LEFT
: dWidth
:= -dWidth
;
4289 if ResizeObject(SelectedObjects
[GetFirstSelected
].ObjectType
,
4290 SelectedObjects
[GetFirstSelected
].ID
,
4291 dWidth
, dHeight
, ResizeDirection
) then
4292 LastMovePoint
:= MousePos
;
4297 // Зажата только левая кнопка мыши:
4298 if (not MouseRDown
) and (MouseLDown
) and (not MouseMDown
) then
4300 // Рисуем прямоугольник планирования панели:
4301 if MouseAction
in [MOUSEACTION_DRAWPANEL
,
4302 MOUSEACTION_DRAWTRIGGER
,
4303 MOUSEACTION_DRAWPRESS
] then
4305 if DrawRect
= nil then
4307 if ssCtrl
in Shift
then
4311 if (lbTextureList
.ItemIndex
<> -1) and (not IsSpecialTextureSel()) and
4312 (MouseAction
= MOUSEACTION_DRAWPANEL
) then
4314 if not g_GetTexture(SelectedTexture(), TextureID
) then
4315 g_GetTexture('NOTEXTURE', TextureID
);
4316 g_GetTextureSizeByID(TextureID
, wWidth
, wHeight
);
4318 DrawRect
.Top
:= MouseLDownPos
.y
;
4319 DrawRect
.Left
:= MouseLDownPos
.x
;
4320 DrawRect
.Bottom
:= DrawRect
.Top
+ wHeight
;
4321 DrawRect
.Right
:= DrawRect
.Left
+ wWidth
;
4325 DrawRect
.Top
:= MouseLDownPos
.y
;
4326 DrawRect
.Left
:= MouseLDownPos
.x
;
4327 DrawRect
.Bottom
:= MousePos
.y
;
4328 DrawRect
.Right
:= MousePos
.x
;
4331 else // Двигаем карту:
4332 if MouseAction
= MOUSEACTION_MOVEMAP
then
4338 // Only Middle Mouse Button is pressed
4339 if (not MouseLDown
) and (not MouseRDown
) and (MouseMDown
) then
4341 MapOffset
.X
:= -EnsureRange(-MapOffset
.X
+ MouseMDownPos
.X
- Mouse
.CursorPos
.X
,
4342 sbHorizontal
.Min
, sbHorizontal
.Max
);
4343 sbHorizontal
.Position
:= -MapOffset
.X
;
4344 MapOffset
.Y
:= -EnsureRange(-MapOffset
.Y
+ MouseMDownPos
.Y
- Mouse
.CursorPos
.Y
,
4345 sbVertical
.Min
, sbVertical
.Max
);
4346 sbVertical
.Position
:= -MapOffset
.Y
;
4347 MouseMDownPos
:= Mouse
.CursorPos
;
4350 // Клавиши мыши не зажаты:
4351 if (not MouseRDown
) and (not MouseLDown
) and (DrawRect
<> nil) then
4357 // Строка состояния - координаты мыши:
4358 StatusBar
.Panels
[1].Text := Format('(%d:%d)',
4359 [MousePos
.X
-MapOffset
.X
, MousePos
.Y
-MapOffset
.Y
]);
4361 RenderPanel
.Invalidate
;
4364 procedure TMainForm
.FormCloseQuery(Sender
: TObject
; var CanClose
: Boolean);
4366 CanClose
:= Application
.MessageBox(PChar(MsgMsgExitPrompt
),
4368 MB_ICONQUESTION
or MB_YESNO
or
4369 MB_DEFBUTTON1
) = idYes
;
4372 procedure TMainForm
.aExitExecute(Sender
: TObject
);
4377 procedure TMainForm
.FormDestroy(Sender
: TObject
);
4383 config
:= TConfig
.CreateFile(CfgFileName
);
4385 if WindowState
<> wsMaximized
then
4387 config
.WriteInt('Editor', 'XPos', Left
);
4388 config
.WriteInt('Editor', 'YPos', Top
);
4389 config
.WriteInt('Editor', 'Width', Width
);
4390 config
.WriteInt('Editor', 'Height', Height
);
4394 config
.WriteInt('Editor', 'XPos', RestoredLeft
);
4395 config
.WriteInt('Editor', 'YPos', RestoredTop
);
4396 config
.WriteInt('Editor', 'Width', RestoredWidth
);
4397 config
.WriteInt('Editor', 'Height', RestoredHeight
);
4399 config
.WriteBool('Editor', 'Maximize', WindowState
= wsMaximized
);
4400 config
.WriteBool('Editor', 'Minimap', ShowMap
);
4401 config
.WriteInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
4402 config
.WriteInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
4403 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
4404 config
.WriteInt('Editor', 'DotStep', DotStep
);
4405 config
.WriteStr('Editor', 'LastOpenDir', OpenDialog
.InitialDir
);
4406 config
.WriteStr('Editor', 'LastSaveDir', SaveDialog
.InitialDir
);
4407 config
.WriteStr('Editor', 'Language', gLanguage
);
4408 config
.WriteBool('Editor', 'EdgeShow', drEdge
[3] < 255);
4409 config
.WriteInt('Editor', 'EdgeColor', gColorEdge
);
4410 config
.WriteInt('Editor', 'EdgeAlpha', gAlphaEdge
);
4411 config
.WriteInt('Editor', 'LineAlpha', gAlphaTriggerLine
);
4412 config
.WriteInt('Editor', 'TriggerAlpha', gAlphaTriggerArea
);
4413 config
.WriteInt('Editor', 'MonsterRectAlpha', gAlphaMonsterRect
);
4414 config
.WriteInt('Editor', 'AreaRectAlpha', gAlphaAreaRect
);
4416 for i
:= 0 to RecentCount
- 1 do
4418 if i
< RecentFiles
.Count
then s
:= RecentFiles
[i
] else s
:= '';
4420 config
.WriteStr('RecentFilesWin', IntToStr(i
), s
);
4422 config
.WriteStr('RecentFilesUnix', IntToStr(i
), s
);
4427 config
.SaveFile(CfgFileName
);
4430 slInvalidTextures
.Free
;
4433 procedure TMainForm
.FormDropFiles(Sender
: TObject
;
4434 const FileNames
: array of String);
4436 if Length(FileNames
) <> 1 then
4439 OpenMapFile(FileNames
[0]);
4442 procedure TMainForm
.RenderPanelResize(Sender
: TObject
);
4444 if MainForm
.Visible
then
4448 procedure TMainForm
.Splitter1Moved(Sender
: TObject
);
4453 procedure TMainForm
.MapTestCheck(Sender
: TObject
);
4455 if MapTestProcess
<> nil then
4457 if MapTestProcess
.Running
= false then
4459 if MapTestProcess
.ExitCode
<> 0 then
4460 Application
.MessageBox(PChar(MsgMsgExecError
), 'FIXME', MB_OK
or MB_ICONERROR
);
4461 SysUtils
.DeleteFile(MapTestFile
);
4463 FreeAndNil(MapTestProcess
);
4464 tbTestMap
.Enabled
:= True;
4469 procedure TMainForm
.aMapOptionsExecute(Sender
: TObject
);
4473 MapOptionsForm
.ShowModal();
4475 ResName
:= OpenedMap
;
4476 while (Pos(':\', ResName
) > 0) do
4477 Delete(ResName
, 1, Pos(':\', ResName
) + 1);
4479 UpdateCaption(gMapInfo
.Name
, ExtractFileName(OpenedWAD
), ResName
);
4482 procedure TMainForm
.aAboutExecute(Sender
: TObject
);
4484 AboutForm
.ShowModal();
4487 procedure TMainForm
.FormKeyDown(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
4493 if (not EditingProperties
) then
4495 if ssCtrl
in Shift
then
4498 '1': ContourEnabled
[LAYER_BACK
] := not ContourEnabled
[LAYER_BACK
];
4499 '2': ContourEnabled
[LAYER_WALLS
] := not ContourEnabled
[LAYER_WALLS
];
4500 '3': ContourEnabled
[LAYER_FOREGROUND
] := not ContourEnabled
[LAYER_FOREGROUND
];
4501 '4': ContourEnabled
[LAYER_STEPS
] := not ContourEnabled
[LAYER_STEPS
];
4502 '5': ContourEnabled
[LAYER_WATER
] := not ContourEnabled
[LAYER_WATER
];
4503 '6': ContourEnabled
[LAYER_ITEMS
] := not ContourEnabled
[LAYER_ITEMS
];
4504 '7': ContourEnabled
[LAYER_MONSTERS
] := not ContourEnabled
[LAYER_MONSTERS
];
4505 '8': ContourEnabled
[LAYER_AREAS
] := not ContourEnabled
[LAYER_AREAS
];
4506 '9': ContourEnabled
[LAYER_TRIGGERS
] := not ContourEnabled
[LAYER_TRIGGERS
];
4510 for i
:= Low(ContourEnabled
) to High(ContourEnabled
) do
4511 if ContourEnabled
[i
] then
4513 for i
:= Low(ContourEnabled
) to High(ContourEnabled
) do
4514 ContourEnabled
[i
] := not ok
4521 '1': SwitchLayer(LAYER_BACK
);
4522 '2': SwitchLayer(LAYER_WALLS
);
4523 '3': SwitchLayer(LAYER_FOREGROUND
);
4524 '4': SwitchLayer(LAYER_STEPS
);
4525 '5': SwitchLayer(LAYER_WATER
);
4526 '6': SwitchLayer(LAYER_ITEMS
);
4527 '7': SwitchLayer(LAYER_MONSTERS
);
4528 '8': SwitchLayer(LAYER_AREAS
);
4529 '9': SwitchLayer(LAYER_TRIGGERS
);
4530 '0': tbShowClick(tbShow
);
4534 if Key
= Ord('I') then
4535 begin // Поворот монстров и областей:
4536 if (SelectedObjects
<> nil) then
4538 for i
:= 0 to High(SelectedObjects
) do
4539 if (SelectedObjects
[i
].Live
) then
4541 if (SelectedObjects
[i
].ObjectType
= OBJECT_MONSTER
) then
4543 g_ChangeDir(gMonsters
[SelectedObjects
[i
].ID
].Direction
);
4546 if (SelectedObjects
[i
].ObjectType
= OBJECT_AREA
) then
4548 g_ChangeDir(gAreas
[SelectedObjects
[i
].ID
].Direction
);
4554 if pcObjects
.ActivePage
= tsMonsters
then
4556 if rbMonsterLeft
.Checked
then
4557 rbMonsterRight
.Checked
:= True
4559 rbMonsterLeft
.Checked
:= True;
4561 if pcObjects
.ActivePage
= tsAreas
then
4563 if rbAreaLeft
.Checked
then
4564 rbAreaRight
.Checked
:= True
4566 rbAreaLeft
.Checked
:= True;
4571 if not (ssCtrl
in Shift
) then
4573 // Быстрое превью карты:
4574 if Key
= Ord('E') then
4576 if PreviewMode
= 0 then
4580 // Вертикальный скролл карты:
4583 if Key
= Ord('W') then
4586 if ssShift
in Shift
then Position
:= EnsureRange(Position
- DotStep
* 4, Min
, Max
)
4587 else Position
:= EnsureRange(Position
- DotStep
, Min
, Max
);
4588 MapOffset
.Y
:= -Position
;
4591 if (MouseLDown
or MouseRDown
) then
4593 if DrawRect
<> nil then
4595 Inc(MouseLDownPos
.y
, dy
);
4596 Inc(MouseRDownPos
.y
, dy
);
4598 Inc(LastMovePoint
.Y
, dy
);
4599 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4603 if Key
= Ord('S') then
4606 if ssShift
in Shift
then Position
:= EnsureRange(Position
+ DotStep
* 4, Min
, Max
)
4607 else Position
:= EnsureRange(Position
+ DotStep
, Min
, Max
);
4608 MapOffset
.Y
:= -Position
;
4611 if (MouseLDown
or MouseRDown
) then
4613 if DrawRect
<> nil then
4615 Inc(MouseLDownPos
.y
, dy
);
4616 Inc(MouseRDownPos
.y
, dy
);
4618 Inc(LastMovePoint
.Y
, dy
);
4619 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4624 // Горизонтальный скролл карты:
4625 with sbHorizontal
do
4627 if Key
= Ord('A') then
4630 if ssShift
in Shift
then Position
:= EnsureRange(Position
- DotStep
* 4, Min
, Max
)
4631 else Position
:= EnsureRange(Position
- DotStep
, Min
, Max
);
4632 MapOffset
.X
:= -Position
;
4635 if (MouseLDown
or MouseRDown
) then
4637 if DrawRect
<> nil then
4639 Inc(MouseLDownPos
.x
, dx
);
4640 Inc(MouseRDownPos
.x
, dx
);
4642 Inc(LastMovePoint
.X
, dx
);
4643 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4647 if Key
= Ord('D') then
4650 if ssShift
in Shift
then Position
:= EnsureRange(Position
+ DotStep
* 4, Min
, Max
)
4651 else Position
:= EnsureRange(Position
+ DotStep
, Min
, Max
);
4652 MapOffset
.X
:= -Position
;
4655 if (MouseLDown
or MouseRDown
) then
4657 if DrawRect
<> nil then
4659 Inc(MouseLDownPos
.x
, dx
);
4660 Inc(MouseRDownPos
.x
, dx
);
4662 Inc(LastMovePoint
.X
, dx
);
4663 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4668 else // ssCtrl in Shift
4670 if ssShift
in Shift
then
4672 // Вставка по абсолютному смещению:
4673 if Key
= Ord('V') then
4674 aPasteObjectExecute(Sender
);
4676 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4680 // Удалить выделенные объекты:
4681 if (Key
= VK_DELETE
) and (SelectedObjects
<> nil) and
4682 RenderPanel
.Focused() then
4683 DeleteSelectedObjects();
4686 if (Key
= VK_ESCAPE
) and (SelectedObjects
<> nil) then
4687 RemoveSelectFromObjects();
4689 // Передвинуть объекты:
4690 if MainForm
.ActiveControl
= RenderPanel
then
4695 if Key
= VK_NUMPAD4
then
4696 dx
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4697 if Key
= VK_NUMPAD6
then
4698 dx
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4699 if Key
= VK_NUMPAD8
then
4700 dy
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4701 if Key
= VK_NUMPAD5
then
4702 dy
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4704 if (dx
<> 0) or (dy
<> 0) then
4706 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
, dx
, dy
);
4711 if ssCtrl
in Shift
then
4713 // Выбор панели с текстурой для триггера
4714 if Key
= Ord('T') then
4716 DrawPressRect
:= False;
4717 if SelectFlag
= SELECTFLAG_TEXTURE
then
4719 SelectFlag
:= SELECTFLAG_NONE
;
4722 vleObjectProperty
.FindRow(MsgPropTrTexturePanel
, i
);
4724 SelectFlag
:= SELECTFLAG_TEXTURE
;
4727 if Key
= Ord('D') then
4729 SelectFlag
:= SELECTFLAG_NONE
;
4730 if DrawPressRect
then
4732 DrawPressRect
:= False;
4737 // Выбор области воздействия, в зависимости от типа триггера
4738 vleObjectProperty
.FindRow(MsgPropTrExArea
, i
);
4741 DrawPressRect
:= True;
4744 vleObjectProperty
.FindRow(MsgPropTrDoorPanel
, i
);
4746 vleObjectProperty
.FindRow(MsgPropTrTrapPanel
, i
);
4749 SelectFlag
:= SELECTFLAG_DOOR
;
4752 vleObjectProperty
.FindRow(MsgPropTrLiftPanel
, i
);
4755 SelectFlag
:= SELECTFLAG_LIFT
;
4758 vleObjectProperty
.FindRow(MsgPropTrTeleportTo
, i
);
4761 SelectFlag
:= SELECTFLAG_TELEPORT
;
4764 vleObjectProperty
.FindRow(MsgPropTrSpawnTo
, i
);
4767 SelectFlag
:= SELECTFLAG_SPAWNPOINT
;
4771 // Выбор основного параметра, в зависимости от типа триггера
4772 vleObjectProperty
.FindRow(MsgPropTrNextMap
, i
);
4775 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
4776 SelectMapForm
.Caption
:= MsgCapSelect
;
4777 SelectMapForm
.GetMaps(FileName
);
4779 if SelectMapForm
.ShowModal() = mrOK
then
4781 vleObjectProperty
.Cells
[1, i
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
4782 bApplyProperty
.Click();
4786 vleObjectProperty
.FindRow(MsgPropTrSoundName
, i
);
4788 vleObjectProperty
.FindRow(MsgPropTrMusicName
, i
);
4791 AddSoundForm
.OKFunction
:= nil;
4792 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
4793 AddSoundForm
.SetResource
:= vleObjectProperty
.Cells
[1, i
];
4795 if (AddSoundForm
.ShowModal() = mrOk
) then
4797 vleObjectProperty
.Cells
[1, i
] := AddSoundForm
.ResourceName
;
4798 bApplyProperty
.Click();
4802 vleObjectProperty
.FindRow(MsgPropTrPushAngle
, i
);
4804 vleObjectProperty
.FindRow(MsgPropTrMessageText
, i
);
4807 vleObjectProperty
.Row
:= i
;
4808 vleObjectProperty
.SetFocus();
4815 procedure TMainForm
.aOptimizeExecute(Sender
: TObject
);
4817 RemoveSelectFromObjects();
4818 MapOptimizationForm
.ShowModal();
4821 procedure TMainForm
.aCheckMapExecute(Sender
: TObject
);
4823 MapCheckForm
.ShowModal();
4826 procedure TMainForm
.bbAddTextureClick(Sender
: TObject
);
4828 AddTextureForm
.lbResourcesList
.MultiSelect
:= True;
4829 AddTextureForm
.ShowModal();
4832 procedure TMainForm
.lbTextureListClick(Sender
: TObject
);
4835 TextureWidth
, TextureHeight
: Word;
4840 if (lbTextureList
.ItemIndex
<> -1) and
4841 (not IsSpecialTextureSel()) then
4843 if g_GetTexture(SelectedTexture(), TextureID
) then
4845 g_GetTextureSizeByID(TextureID
, TextureWidth
, TextureHeight
);
4847 lTextureWidth
.Caption
:= IntToStr(TextureWidth
);
4848 lTextureHeight
.Caption
:= IntToStr(TextureHeight
);
4851 lTextureWidth
.Caption
:= MsgNotAccessible
;
4852 lTextureHeight
.Caption
:= MsgNotAccessible
;
4857 lTextureWidth
.Caption
:= '';
4858 lTextureHeight
.Caption
:= '';
4862 procedure TMainForm
.lbTextureListDrawItem(Control
: TWinControl
; Index
: Integer;
4863 ARect
: TRect
; State
: TOwnerDrawState
);
4865 with Control
as TListBox
do
4867 if LCLType
.odSelected
in State
then
4869 Canvas
.Brush
.Color
:= clHighlight
;
4870 Canvas
.Font
.Color
:= clHighlightText
;
4872 if (Items
<> nil) and (Index
>= 0) then
4873 if slInvalidTextures
.IndexOf(Items
[Index
]) > -1 then
4875 Canvas
.Brush
.Color
:= clRed
;
4876 Canvas
.Font
.Color
:= clWhite
;
4878 Canvas
.FillRect(ARect
);
4879 Canvas
.TextRect(ARect
, ARect
.Left
, ARect
.Top
, Items
[Index
]);
4883 procedure TMainForm
.miMacMinimizeClick(Sender
: TObject
);
4885 self
.WindowState
:= wsMinimized
;
4886 self
.FormWindowStateChange(Sender
);
4889 procedure TMainForm
.miMacZoomClick(Sender
: TObject
);
4891 if self
.WindowState
= wsMaximized
then
4892 self
.WindowState
:= wsNormal
4894 self
.WindowState
:= wsMaximized
;
4895 self
.FormWindowStateChange(Sender
);
4898 procedure TMainForm
.miReopenMapClick(Sender
: TObject
);
4900 FileName
, Resource
: String;
4902 if OpenedMap
= '' then
4905 if Application
.MessageBox(PChar(MsgMsgReopenMapPrompt
),
4906 PChar(MsgMenuFileReopen
), MB_ICONQUESTION
or MB_YESNO
) <> idYes
then
4909 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, @Resource
);
4910 OpenMap(FileName
, Resource
);
4913 procedure TMainForm
.vleObjectPropertyGetPickList(Sender
: TObject
;
4914 const KeyName
: String; Values
: TStrings
);
4916 if vleObjectProperty
.ItemProps
[KeyName
].EditStyle
= esPickList
then
4918 if KeyName
= MsgPropDirection
then
4920 Values
.Add(DirNames
[D_LEFT
]);
4921 Values
.Add(DirNames
[D_RIGHT
]);
4923 else if KeyName
= MsgPropTrTeleportDir
then
4925 Values
.Add(DirNamesAdv
[0]);
4926 Values
.Add(DirNamesAdv
[1]);
4927 Values
.Add(DirNamesAdv
[2]);
4928 Values
.Add(DirNamesAdv
[3]);
4930 else if KeyName
= MsgPropTrMusicAct
then
4932 Values
.Add(MsgPropTrMusicOn
);
4933 Values
.Add(MsgPropTrMusicOff
);
4935 else if KeyName
= MsgPropTrMonsterBehaviour
then
4937 Values
.Add(MsgPropTrMonsterBehaviour0
);
4938 Values
.Add(MsgPropTrMonsterBehaviour1
);
4939 Values
.Add(MsgPropTrMonsterBehaviour2
);
4940 Values
.Add(MsgPropTrMonsterBehaviour3
);
4941 Values
.Add(MsgPropTrMonsterBehaviour4
);
4942 Values
.Add(MsgPropTrMonsterBehaviour5
);
4944 else if KeyName
= MsgPropTrScoreAct
then
4946 Values
.Add(MsgPropTrScoreAct0
);
4947 Values
.Add(MsgPropTrScoreAct1
);
4948 Values
.Add(MsgPropTrScoreAct2
);
4949 Values
.Add(MsgPropTrScoreAct3
);
4951 else if KeyName
= MsgPropTrScoreTeam
then
4953 Values
.Add(MsgPropTrScoreTeam0
);
4954 Values
.Add(MsgPropTrScoreTeam1
);
4955 Values
.Add(MsgPropTrScoreTeam2
);
4956 Values
.Add(MsgPropTrScoreTeam3
);
4958 else if KeyName
= MsgPropTrMessageKind
then
4960 Values
.Add(MsgPropTrMessageKind0
);
4961 Values
.Add(MsgPropTrMessageKind1
);
4963 else if KeyName
= MsgPropTrMessageTo
then
4965 Values
.Add(MsgPropTrMessageTo0
);
4966 Values
.Add(MsgPropTrMessageTo1
);
4967 Values
.Add(MsgPropTrMessageTo2
);
4968 Values
.Add(MsgPropTrMessageTo3
);
4969 Values
.Add(MsgPropTrMessageTo4
);
4970 Values
.Add(MsgPropTrMessageTo5
);
4972 else if KeyName
= MsgPropTrShotTo
then
4974 Values
.Add(MsgPropTrShotTo0
);
4975 Values
.Add(MsgPropTrShotTo1
);
4976 Values
.Add(MsgPropTrShotTo2
);
4977 Values
.Add(MsgPropTrShotTo3
);
4978 Values
.Add(MsgPropTrShotTo4
);
4979 Values
.Add(MsgPropTrShotTo5
);
4980 Values
.Add(MsgPropTrShotTo6
);
4982 else if KeyName
= MsgPropTrShotAim
then
4984 Values
.Add(MsgPropTrShotAim0
);
4985 Values
.Add(MsgPropTrShotAim1
);
4986 Values
.Add(MsgPropTrShotAim2
);
4987 Values
.Add(MsgPropTrShotAim3
);
4989 else if KeyName
= MsgPropTrDamageKind
then
4991 Values
.Add(MsgPropTrDamageKind0
);
4992 Values
.Add(MsgPropTrDamageKind3
);
4993 Values
.Add(MsgPropTrDamageKind4
);
4994 Values
.Add(MsgPropTrDamageKind5
);
4995 Values
.Add(MsgPropTrDamageKind6
);
4996 Values
.Add(MsgPropTrDamageKind7
);
4997 Values
.Add(MsgPropTrDamageKind8
);
4999 else if (KeyName
= MsgPropPanelBlend
) or
5000 (KeyName
= MsgPropDmOnly
) or
5001 (KeyName
= MsgPropItemFalls
) or
5002 (KeyName
= MsgPropTrEnabled
) or
5003 (KeyName
= MsgPropTrD2d
) or
5004 (KeyName
= MsgPropTrSilent
) or
5005 (KeyName
= MsgPropTrTeleportSilent
) or
5006 (KeyName
= MsgPropTrExRandom
) or
5007 (KeyName
= MsgPropTrTextureOnce
) or
5008 (KeyName
= MsgPropTrTextureAnimOnce
) or
5009 (KeyName
= MsgPropTrSoundLocal
) or
5010 (KeyName
= MsgPropTrSoundSwitch
) or
5011 (KeyName
= MsgPropTrMonsterActive
) or
5012 (KeyName
= MsgPropTrPushReset
) or
5013 (KeyName
= MsgPropTrScoreCon
) or
5014 (KeyName
= MsgPropTrScoreMsg
) or
5015 (KeyName
= MsgPropTrHealthMax
) or
5016 (KeyName
= MsgPropTrShotSound
) or
5017 (KeyName
= MsgPropTrEffectCenter
) then
5019 Values
.Add(BoolNames
[True]);
5020 Values
.Add(BoolNames
[False]);
5025 procedure TMainForm
.bApplyPropertyClick(Sender
: TObject
);
5027 _id
, a
, r
, c
: Integer;
5037 if SelectedObjectCount() <> 1 then
5039 if not SelectedObjects
[GetFirstSelected()].Live
then
5043 if not CheckProperty() then
5049 _id
:= GetFirstSelected();
5051 r
:= vleObjectProperty
.Row
;
5052 c
:= vleObjectProperty
.Col
;
5054 case SelectedObjects
[_id
].ObjectType
of
5057 with gPanels
[SelectedObjects
[_id
].ID
] do
5059 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5060 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5061 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropWidth
]));
5062 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropHeight
]));
5064 PanelType
:= GetPanelType(vleObjectProperty
.Values
[MsgPropPanelType
]);
5066 // Сброс ссылки на триггеры смены текстуры:
5067 if not WordBool(PanelType
and (PANEL_WALL
or PANEL_FORE
or PANEL_BACK
)) then
5068 if gTriggers
<> nil then
5069 for a
:= 0 to High(gTriggers
) do
5071 if (gTriggers
[a
].TriggerType
<> 0) and
5072 (gTriggers
[a
].TexturePanel
= Integer(SelectedObjects
[_id
].ID
)) then
5073 gTriggers
[a
].TexturePanel
:= -1;
5074 if (gTriggers
[a
].TriggerType
= TRIGGER_SHOT
) and
5075 (gTriggers
[a
].Data
.ShotPanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5076 gTriggers
[a
].Data
.ShotPanelID
:= -1;
5079 // Сброс ссылки на триггеры лифта:
5080 if not WordBool(PanelType
and (PANEL_LIFTUP
or PANEL_LIFTDOWN
or PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
)) then
5081 if gTriggers
<> nil then
5082 for a
:= 0 to High(gTriggers
) do
5083 if (gTriggers
[a
].TriggerType
in [TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
]) and
5084 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5085 gTriggers
[a
].Data
.PanelID
:= -1;
5087 // Сброс ссылки на триггеры двери:
5088 if not WordBool(PanelType
and (PANEL_OPENDOOR
or PANEL_CLOSEDOOR
)) then
5089 if gTriggers
<> nil then
5090 for a
:= 0 to High(gTriggers
) do
5091 if (gTriggers
[a
].TriggerType
in [TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5092 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
]) and
5093 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5094 gTriggers
[a
].Data
.PanelID
:= -1;
5096 if IsTexturedPanel(PanelType
) then
5097 begin // Может быть текстура
5098 if TextureName
<> '' then
5099 begin // Была текстура
5100 Alpha
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropPanelAlpha
]));
5101 Blending
:= NameToBool(vleObjectProperty
.Values
[MsgPropPanelBlend
]);
5110 TextureName
:= vleObjectProperty
.Values
[MsgPropPanelTex
];
5112 if TextureName
<> '' then
5113 begin // Есть текстура
5114 // Обычная текстура:
5115 if not IsSpecialTexture(TextureName
) then
5117 g_GetTextureSizeByName(TextureName
,
5118 TextureWidth
, TextureHeight
);
5120 // Проверка кратности размеров панели:
5122 if TextureWidth
<> 0 then
5123 if gPanels
[SelectedObjects
[_id
].ID
].Width
mod TextureWidth
<> 0 then
5125 ErrorMessageBox(Format(MsgMsgWrongTexwidth
,
5129 if Res
and (TextureHeight
<> 0) then
5130 if gPanels
[SelectedObjects
[_id
].ID
].Height
mod TextureHeight
<> 0 then
5132 ErrorMessageBox(Format(MsgMsgWrongTexheight
,
5139 if not g_GetTexture(TextureName
, TextureID
) then
5140 // Не удалось загрузить текстуру, рисуем NOTEXTURE
5141 if g_GetTexture('NOTEXTURE', NoTextureID
) then
5143 TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
5144 g_GetTextureSizeByID(NoTextureID
, NW
, NH
);
5146 TextureHeight
:= NH
;
5149 TextureID
:= TEXTURE_SPECIAL_NONE
;
5159 TextureID
:= TEXTURE_SPECIAL_NONE
;
5162 else // Спец.текстура
5166 TextureID
:= SpecialTextureID(TextureName
);
5169 else // Нет текстуры
5173 TextureID
:= TEXTURE_SPECIAL_NONE
;
5176 else // Не может быть текстуры
5183 TextureID
:= TEXTURE_SPECIAL_NONE
;
5190 with gItems
[SelectedObjects
[_id
].ID
] do
5192 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5193 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5194 OnlyDM
:= NameToBool(vleObjectProperty
.Values
[MsgPropDmOnly
]);
5195 Fall
:= NameToBool(vleObjectProperty
.Values
[MsgPropItemFalls
]);
5201 with gMonsters
[SelectedObjects
[_id
].ID
] do
5203 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5204 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5205 Direction
:= NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]);
5211 with gAreas
[SelectedObjects
[_id
].ID
] do
5213 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5214 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5215 Direction
:= NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]);
5221 with gTriggers
[SelectedObjects
[_id
].ID
] do
5223 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5224 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5225 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropWidth
]));
5226 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropHeight
]));
5227 Enabled
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrEnabled
]);
5228 ActivateType
:= StrToActivate(vleObjectProperty
.Values
[MsgPropTrActivation
]);
5229 Key
:= StrToKey(vleObjectProperty
.Values
[MsgPropTrKeys
]);
5234 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrNextMap
]);
5235 FillByte(Data
.MapName
[0], 16, 0);
5237 Move(s
[1], Data
.MapName
[0], Min(Length(s
), 16));
5242 Data
.ActivateOnce
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTextureOnce
]);
5243 Data
.AnimOnce
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTextureAnimOnce
]);
5246 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
5248 Data
.Wait
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 65535);
5249 Data
.Count
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExCount
], 0), 65535);
5250 if Data
.Count
< 1 then
5252 if TriggerType
= TRIGGER_PRESS
then
5253 Data
.ExtRandom
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrExRandom
]);
5256 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
, TRIGGER_DOOR5
,
5257 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
, TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
,
5260 Data
.NoSound
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSilent
]);
5261 Data
.d2d_doors
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrD2d
]);
5266 Data
.d2d_teleport
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrD2d
]);
5267 Data
.silent_teleport
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTeleportSilent
]);
5268 Data
.TlpDir
:= NameToDirAdv(vleObjectProperty
.Values
[MsgPropTrTeleportDir
]);
5273 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrSoundName
]);
5274 FillByte(Data
.SoundName
[0], 64, 0);
5276 Move(s
[1], Data
.SoundName
[0], Min(Length(s
), 64));
5278 Data
.Volume
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundVolume
], 0), 255);
5279 Data
.Pan
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundPan
], 0), 255);
5280 Data
.PlayCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundCount
], 0), 255);
5281 Data
.Local
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSoundLocal
]);
5282 Data
.SoundSwitch
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSoundSwitch
]);
5285 TRIGGER_SPAWNMONSTER
:
5287 Data
.MonType
:= StrToMonster(vleObjectProperty
.Values
[MsgPropTrMonsterType
]);
5288 Data
.MonDir
:= Byte(NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]));
5289 Data
.MonHealth
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrHealth
], 0), 1000000);
5290 if Data
.MonHealth
< 0 then
5291 Data
.MonHealth
:= 0;
5292 Data
.MonActive
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrMonsterActive
]);
5293 Data
.MonCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 64);
5294 if Data
.MonCount
< 1 then
5296 Data
.MonEffect
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrFxType
]);
5297 Data
.MonMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnMax
], 0), 65535);
5298 Data
.MonDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnDelay
], 0), 65535);
5300 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour1
then
5302 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour2
then
5304 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour3
then
5306 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour4
then
5308 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour5
then
5314 Data
.ItemType
:= StrToItem(vleObjectProperty
.Values
[MsgPropTrItemType
]);
5315 Data
.ItemOnlyDM
:= NameToBool(vleObjectProperty
.Values
[MsgPropDmOnly
]);
5316 Data
.ItemFalls
:= NameToBool(vleObjectProperty
.Values
[MsgPropItemFalls
]);
5317 Data
.ItemCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 64);
5318 if Data
.ItemCount
< 1 then
5319 Data
.ItemCount
:= 1;
5320 Data
.ItemEffect
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrFxType
]);
5321 Data
.ItemMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnMax
], 0), 65535);
5322 Data
.ItemDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnDelay
], 0), 65535);
5327 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrMusicName
]);
5328 FillByte(Data
.MusicName
[0], 64, 0);
5330 Move(s
[1], Data
.MusicName
[0], Min(Length(s
), 64));
5332 if vleObjectProperty
.Values
[MsgPropTrMusicAct
] = MsgPropTrMusicOn
then
5333 Data
.MusicAction
:= 1
5335 Data
.MusicAction
:= 0;
5340 Data
.PushAngle
:= Min(
5341 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrPushAngle
], 0), 360);
5342 Data
.PushForce
:= Min(
5343 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrPushForce
], 0), 255);
5344 Data
.ResetVel
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrPushReset
]);
5349 Data
.ScoreAction
:= 0;
5350 if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct1
then
5351 Data
.ScoreAction
:= 1
5352 else if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct2
then
5353 Data
.ScoreAction
:= 2
5354 else if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct3
then
5355 Data
.ScoreAction
:= 3;
5356 Data
.ScoreCount
:= Min(Max(
5357 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 0), 255);
5358 Data
.ScoreTeam
:= 0;
5359 if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam1
then
5361 else if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam2
then
5363 else if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam3
then
5364 Data
.ScoreTeam
:= 3;
5365 Data
.ScoreCon
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrScoreCon
]);
5366 Data
.ScoreMsg
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrScoreMsg
]);
5371 Data
.MessageKind
:= 0;
5372 if vleObjectProperty
.Values
[MsgPropTrMessageKind
] = MsgPropTrMessageKind1
then
5373 Data
.MessageKind
:= 1;
5375 Data
.MessageSendTo
:= 0;
5376 if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo1
then
5377 Data
.MessageSendTo
:= 1
5378 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo2
then
5379 Data
.MessageSendTo
:= 2
5380 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo3
then
5381 Data
.MessageSendTo
:= 3
5382 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo4
then
5383 Data
.MessageSendTo
:= 4
5384 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo5
then
5385 Data
.MessageSendTo
:= 5;
5387 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrMessageText
]);
5388 FillByte(Data
.MessageText
[0], 100, 0);
5390 Move(s
[1], Data
.MessageText
[0], Min(Length(s
), 100));
5392 Data
.MessageTime
:= Min(Max(
5393 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrMessageTime
], 0), 0), 65535);
5398 Data
.DamageValue
:= Min(Max(
5399 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrDamageValue
], 0), 0), 65535);
5400 Data
.DamageInterval
:= Min(Max(
5401 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrInterval
], 0), 0), 65535);
5402 s
:= vleObjectProperty
.Values
[MsgPropTrDamageKind
];
5403 if s
= MsgPropTrDamageKind3
then
5404 Data
.DamageKind
:= 3
5405 else if s
= MsgPropTrDamageKind4
then
5406 Data
.DamageKind
:= 4
5407 else if s
= MsgPropTrDamageKind5
then
5408 Data
.DamageKind
:= 5
5409 else if s
= MsgPropTrDamageKind6
then
5410 Data
.DamageKind
:= 6
5411 else if s
= MsgPropTrDamageKind7
then
5412 Data
.DamageKind
:= 7
5413 else if s
= MsgPropTrDamageKind8
then
5414 Data
.DamageKind
:= 8
5416 Data
.DamageKind
:= 0;
5421 Data
.HealValue
:= Min(Max(
5422 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrHealth
], 0), 0), 65535);
5423 Data
.HealInterval
:= Min(Max(
5424 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrInterval
], 0), 0), 65535);
5425 Data
.HealMax
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrHealthMax
]);
5426 Data
.HealSilent
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSilent
]);
5431 Data
.ShotType
:= StrToShot(vleObjectProperty
.Values
[MsgPropTrShotType
]);
5432 Data
.ShotSound
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrShotSound
]);
5433 Data
.ShotTarget
:= 0;
5434 if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo1
then
5435 Data
.ShotTarget
:= 1
5436 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo2
then
5437 Data
.ShotTarget
:= 2
5438 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo3
then
5439 Data
.ShotTarget
:= 3
5440 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo4
then
5441 Data
.ShotTarget
:= 4
5442 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo5
then
5443 Data
.ShotTarget
:= 5
5444 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo6
then
5445 Data
.ShotTarget
:= 6;
5446 Data
.ShotIntSight
:= Min(Max(
5447 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotSight
], 0), 0), 65535);
5449 if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim1
then
5451 else if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim2
then
5453 else if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim3
then
5455 Data
.ShotAngle
:= Min(
5456 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAngle
], 0), 360);
5457 Data
.ShotWait
:= Min(Max(
5458 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 0), 65535);
5459 Data
.ShotAccuracy
:= Min(Max(
5460 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAcc
], 0), 0), 65535);
5461 Data
.ShotAmmo
:= Min(Max(
5462 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAmmo
], 0), 0), 65535);
5463 Data
.ShotIntReload
:= Min(Max(
5464 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotReload
], 0), 0), 65535);
5469 Data
.FXCount
:= Min(Max(
5470 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 0), 255);
5471 if vleObjectProperty
.Values
[MsgPropTrEffectType
] = MsgPropTrEffectParticle
then
5473 Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
5474 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
5475 if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectSliquid
then
5476 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
5477 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectLliquid
then
5478 Data
.FXSubType
:= TRIGGER_EFFECT_LLIQUID
5479 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectDliquid
then
5480 Data
.FXSubType
:= TRIGGER_EFFECT_DLIQUID
5481 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectBlood
then
5482 Data
.FXSubType
:= TRIGGER_EFFECT_BLOOD
5483 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectSpark
then
5484 Data
.FXSubType
:= TRIGGER_EFFECT_SPARK
5485 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectBubble
then
5486 Data
.FXSubType
:= TRIGGER_EFFECT_BUBBLE
;
5489 Data
.FXType
:= TRIGGER_EFFECT_ANIMATION
;
5490 Data
.FXSubType
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrEffectSubtype
]);
5493 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectColor
], 0), 0), $FFFFFF);
5494 Data
.FXColorR
:= a
and $FF;
5495 Data
.FXColorG
:= (a
shr 8) and $FF;
5496 Data
.FXColorB
:= (a
shr 16) and $FF;
5497 if NameToBool(vleObjectProperty
.Values
[MsgPropTrEffectCenter
]) then
5501 Data
.FXWait
:= Min(Max(
5502 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 0), 65535);
5503 Data
.FXVelX
:= Min(Max(
5504 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectVelx
], 0), -128), 127);
5505 Data
.FXVelY
:= Min(Max(
5506 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectVely
], 0), -128), 127);
5507 Data
.FXSpreadL
:= Min(Max(
5508 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpl
], 0), 0), 255);
5509 Data
.FXSpreadR
:= Min(Max(
5510 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpr
], 0), 0), 255);
5511 Data
.FXSpreadU
:= Min(Max(
5512 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpu
], 0), 0), 255);
5513 Data
.FXSpreadD
:= Min(Max(
5514 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpd
], 0), 0), 255);
5523 vleObjectProperty
.Row
:= r
;
5524 vleObjectProperty
.Col
:= c
;
5527 procedure TMainForm
.bbRemoveTextureClick(Sender
: TObject
);
5531 i
:= lbTextureList
.ItemIndex
;
5535 if Application
.MessageBox(PChar(Format(MsgMsgDelTexturePrompt
,
5536 [SelectedTexture()])),
5537 PChar(MsgMsgDelTexture
),
5538 MB_ICONQUESTION
or MB_YESNO
or
5539 MB_DEFBUTTON1
) <> idYes
then
5542 if gPanels
<> nil then
5543 for a
:= 0 to High(gPanels
) do
5544 if (gPanels
[a
].PanelType
<> 0) and
5545 (gPanels
[a
].TextureName
= SelectedTexture()) then
5547 ErrorMessageBox(MsgMsgDelTextureCant
);
5551 g_DeleteTexture(SelectedTexture());
5552 i
:= slInvalidTextures
.IndexOf(lbTextureList
.Items
[i
]);
5554 slInvalidTextures
.Delete(i
);
5555 if lbTextureList
.ItemIndex
> -1 then
5556 lbTextureList
.Items
.Delete(lbTextureList
.ItemIndex
)
5559 procedure TMainForm
.aNewMapExecute(Sender
: TObject
);
5561 if Application
.MessageBox(PChar(MsgMsgClearMapPrompt
), PChar(MsgMsgClearMap
), MB_ICONQUESTION
or MB_YESNO
or MB_DEFBUTTON1
) = mrYes
then
5565 procedure TMainForm
.aUndoExecute(Sender
: TObject
);
5569 if UndoBuffer
= nil then
5571 if UndoBuffer
[High(UndoBuffer
)] = nil then
5574 for a
:= 0 to High(UndoBuffer
[High(UndoBuffer
)]) do
5575 with UndoBuffer
[High(UndoBuffer
)][a
] do
5583 UNDO_DELETE_ITEM
: AddItem(Item
);
5584 UNDO_DELETE_AREA
: AddArea(Area
);
5585 UNDO_DELETE_MONSTER
: AddMonster(Monster
);
5586 UNDO_DELETE_TRIGGER
: AddTrigger(Trigger
);
5587 UNDO_ADD_PANEL
: RemoveObject(AddID
, OBJECT_PANEL
);
5588 UNDO_ADD_ITEM
: RemoveObject(AddID
, OBJECT_ITEM
);
5589 UNDO_ADD_AREA
: RemoveObject(AddID
, OBJECT_AREA
);
5590 UNDO_ADD_MONSTER
: RemoveObject(AddID
, OBJECT_MONSTER
);
5591 UNDO_ADD_TRIGGER
: RemoveObject(AddID
, OBJECT_TRIGGER
);
5595 SetLength(UndoBuffer
, Length(UndoBuffer
)-1);
5597 RemoveSelectFromObjects();
5599 miUndo
.Enabled
:= UndoBuffer
<> nil;
5603 procedure TMainForm
.aCopyObjectExecute(Sender
: TObject
);
5606 CopyBuffer
: TCopyRecArray
;
5610 function CB_Compare(I1
, I2
: TCopyRec
): Integer;
5612 Result
:= Integer(I1
.ObjectType
) - Integer(I2
.ObjectType
);
5614 if Result
= 0 then // Одного типа
5615 Result
:= Integer(I1
.ID
) - Integer(I2
.ID
);
5618 procedure QuickSortCopyBuffer(L
, R
: Integer);
5626 P
:= CopyBuffer
[(L
+ R
) shr 1];
5629 while CB_Compare(CopyBuffer
[I
], P
) < 0 do
5631 while CB_Compare(CopyBuffer
[J
], P
) > 0 do
5637 CopyBuffer
[I
] := CopyBuffer
[J
];
5645 QuickSortCopyBuffer(L
, J
);
5652 if SelectedObjects
= nil then
5658 // Копируем объекты:
5659 for a
:= 0 to High(SelectedObjects
) do
5660 if SelectedObjects
[a
].Live
then
5661 with SelectedObjects
[a
] do
5663 SetLength(CopyBuffer
, Length(CopyBuffer
)+1);
5664 b
:= High(CopyBuffer
);
5665 CopyBuffer
[b
].ID
:= ID
;
5666 CopyBuffer
[b
].Panel
:= nil;
5671 CopyBuffer
[b
].ObjectType
:= OBJECT_PANEL
;
5672 New(CopyBuffer
[b
].Panel
);
5673 CopyBuffer
[b
].Panel
^ := gPanels
[ID
];
5678 CopyBuffer
[b
].ObjectType
:= OBJECT_ITEM
;
5679 CopyBuffer
[b
].Item
:= gItems
[ID
];
5684 CopyBuffer
[b
].ObjectType
:= OBJECT_MONSTER
;
5685 CopyBuffer
[b
].Monster
:= gMonsters
[ID
];
5690 CopyBuffer
[b
].ObjectType
:= OBJECT_AREA
;
5691 CopyBuffer
[b
].Area
:= gAreas
[ID
];
5696 CopyBuffer
[b
].ObjectType
:= OBJECT_TRIGGER
;
5697 CopyBuffer
[b
].Trigger
:= gTriggers
[ID
];
5702 // Сортировка по ID:
5703 if CopyBuffer
<> nil then
5705 QuickSortCopyBuffer(0, b
);
5708 // Постановка ссылок триггеров:
5709 for a
:= 0 to Length(CopyBuffer
)-1 do
5710 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
5712 case CopyBuffer
[a
].Trigger
.TriggerType
of
5713 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5714 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5715 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5716 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
5720 for b
:= 0 to Length(CopyBuffer
)-1 do
5721 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5722 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.PanelID
) then
5724 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= b
;
5729 // Этих панелей нет среди копируемых:
5731 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= -1;
5734 TRIGGER_PRESS
, TRIGGER_ON
,
5735 TRIGGER_OFF
, TRIGGER_ONOFF
:
5736 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
5740 for b
:= 0 to Length(CopyBuffer
)-1 do
5741 if (CopyBuffer
[b
].ObjectType
= OBJECT_MONSTER
) and
5742 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1) then
5744 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= b
+1;
5749 // Этих монстров нет среди копируемых:
5751 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= 0;
5755 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
5759 for b
:= 0 to Length(CopyBuffer
)-1 do
5760 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5761 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
) then
5763 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= b
;
5768 // Этих панелей нет среди копируемых:
5770 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= -1;
5774 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
5778 for b
:= 0 to Length(CopyBuffer
)-1 do
5779 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5780 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.TexturePanel
) then
5782 CopyBuffer
[a
].Trigger
.TexturePanel
:= b
;
5787 // Этих панелей нет среди копируемых:
5789 CopyBuffer
[a
].Trigger
.TexturePanel
:= -1;
5794 str
:= CopyBufferToString(CopyBuffer
);
5795 ClipBoard
.AsText
:= str
;
5797 for a
:= 0 to Length(CopyBuffer
)-1 do
5798 if (CopyBuffer
[a
].ObjectType
= OBJECT_PANEL
) and
5799 (CopyBuffer
[a
].Panel
<> nil) then
5800 Dispose(CopyBuffer
[a
].Panel
);
5805 procedure TMainForm
.aPasteObjectExecute(Sender
: TObject
);
5808 CopyBuffer
: TCopyRecArray
;
5810 swad
, ssec
, sres
: String;
5813 xadj
, yadj
: LongInt;
5818 pmin
.X
:= High(pmin
.X
);
5819 pmin
.Y
:= High(pmin
.Y
);
5821 StringToCopyBuffer(ClipBoard
.AsText
, CopyBuffer
, pmin
);
5822 if CopyBuffer
= nil then
5825 rel
:= not(ssShift
in GetKeyShiftState());
5826 h
:= High(CopyBuffer
);
5827 RemoveSelectFromObjects();
5830 pmin
.X
, pmin
.Y
, -MapOffset
.X
-32, -MapOffset
.Y
-32, RenderPanel
.Width
, RenderPanel
.Height
) then
5837 xadj
:= Floor((-pmin
.X
- MapOffset
.X
+ 32) / DotStep
) * DotStep
;
5838 yadj
:= Floor((-pmin
.Y
- MapOffset
.Y
+ 32) / DotStep
) * DotStep
;
5842 with CopyBuffer
[a
] do
5846 if Panel
<> nil then
5854 Panel
^.TextureID
:= TEXTURE_SPECIAL_NONE
;
5855 Panel
^.TextureWidth
:= 1;
5856 Panel
^.TextureHeight
:= 1;
5858 if (Panel
^.PanelType
= PANEL_LIFTUP
) or
5859 (Panel
^.PanelType
= PANEL_LIFTDOWN
) or
5860 (Panel
^.PanelType
= PANEL_LIFTLEFT
) or
5861 (Panel
^.PanelType
= PANEL_LIFTRIGHT
) or
5862 (Panel
^.PanelType
= PANEL_BLOCKMON
) or
5863 (Panel
^.TextureName
= '') then
5864 begin // Нет или не может быть текстуры:
5866 else // Есть текстура:
5868 // Обычная текстура:
5869 if not IsSpecialTexture(Panel
^.TextureName
) then
5871 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5875 g_ProcessResourceStr(Panel
^.TextureName
, swad
, ssec
, sres
);
5876 AddTexture(swad
, ssec
, sres
, True);
5877 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5881 g_GetTextureSizeByName(Panel
^.TextureName
,
5882 Panel
^.TextureWidth
, Panel
^.TextureHeight
)
5884 if g_GetTexture('NOTEXTURE', NoTextureID
) then
5886 Panel
^.TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
5887 g_GetTextureSizeByID(NoTextureID
, Panel
^.TextureWidth
, Panel
^.TextureHeight
);
5890 else // Спец.текстура:
5892 Panel
^.TextureID
:= SpecialTextureID(Panel
^.TextureName
);
5893 with MainForm
.lbTextureList
.Items
do
5894 if IndexOf(Panel
^.TextureName
) = -1 then
5895 Add(Panel
^.TextureName
);
5899 ID
:= AddPanel(Panel
^);
5901 Undo_Add(OBJECT_PANEL
, ID
, a
> 0);
5902 SelectObject(OBJECT_PANEL
, ID
, True);
5913 ID
:= AddItem(Item
);
5914 Undo_Add(OBJECT_ITEM
, ID
, a
> 0);
5915 SelectObject(OBJECT_ITEM
, ID
, True);
5926 ID
:= AddMonster(Monster
);
5927 Undo_Add(OBJECT_MONSTER
, ID
, a
> 0);
5928 SelectObject(OBJECT_MONSTER
, ID
, True);
5939 ID
:= AddArea(Area
);
5940 Undo_Add(OBJECT_AREA
, ID
, a
> 0);
5941 SelectObject(OBJECT_AREA
, ID
, True);
5955 Data
.TargetPoint
.X
+= xadj
;
5956 Data
.TargetPoint
.Y
+= yadj
;
5958 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
5963 TRIGGER_SPAWNMONSTER
:
5965 Data
.MonPos
.X
+= xadj
;
5966 Data
.MonPos
.Y
+= yadj
;
5970 Data
.ItemPos
.X
+= xadj
;
5971 Data
.ItemPos
.Y
+= yadj
;
5975 Data
.ShotPos
.X
+= xadj
;
5976 Data
.ShotPos
.Y
+= yadj
;
5981 ID
:= AddTrigger(Trigger
);
5982 Undo_Add(OBJECT_TRIGGER
, ID
, a
> 0);
5983 SelectObject(OBJECT_TRIGGER
, ID
, True);
5988 // Переставляем ссылки триггеров:
5989 for a
:= 0 to High(CopyBuffer
) do
5990 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
5992 case CopyBuffer
[a
].Trigger
.TriggerType
of
5993 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5994 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5995 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5996 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
5997 gTriggers
[CopyBuffer
[a
].ID
].Data
.PanelID
:=
5998 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.PanelID
].ID
;
6000 TRIGGER_PRESS
, TRIGGER_ON
,
6001 TRIGGER_OFF
, TRIGGER_ONOFF
:
6002 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
6003 gTriggers
[CopyBuffer
[a
].ID
].Data
.MonsterID
:=
6004 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1].ID
+1;
6007 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
6008 gTriggers
[CopyBuffer
[a
].ID
].Data
.ShotPanelID
:=
6009 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
].ID
;
6012 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
6013 gTriggers
[CopyBuffer
[a
].ID
].TexturePanel
:=
6014 CopyBuffer
[CopyBuffer
[a
].Trigger
.TexturePanel
].ID
;
6023 procedure TMainForm
.aCutObjectExecute(Sender
: TObject
);
6026 DeleteSelectedObjects();
6029 procedure TMainForm
.vleObjectPropertyEditButtonClick(Sender
: TObject
);
6031 Key
, FileName
: String;
6034 Key
:= vleObjectProperty
.Keys
[vleObjectProperty
.Row
];
6036 if Key
= MsgPropPanelType
then
6038 with ChooseTypeForm
, vleObjectProperty
do
6039 begin // Выбор типа панели:
6040 Caption
:= MsgPropPanelType
;
6041 lbTypeSelect
.Items
.Clear();
6043 for b
:= 0 to High(PANELNAMES
) do
6045 lbTypeSelect
.Items
.Add(PANELNAMES
[b
]);
6046 if Values
[Key
] = PANELNAMES
[b
] then
6047 lbTypeSelect
.ItemIndex
:= b
;
6050 if ShowModal() = mrOK
then
6052 b
:= lbTypeSelect
.ItemIndex
;
6053 Values
[Key
] := PANELNAMES
[b
];
6054 vleObjectPropertyApply(Sender
);
6058 else if Key
= MsgPropTrTeleportTo
then
6059 SelectFlag
:= SELECTFLAG_TELEPORT
6060 else if Key
= MsgPropTrSpawnTo
then
6061 SelectFlag
:= SELECTFLAG_SPAWNPOINT
6062 else if (Key
= MsgPropTrDoorPanel
) or
6063 (Key
= MsgPropTrTrapPanel
) then
6064 SelectFlag
:= SELECTFLAG_DOOR
6065 else if Key
= MsgPropTrTexturePanel
then
6067 DrawPressRect
:= False;
6068 SelectFlag
:= SELECTFLAG_TEXTURE
;
6070 else if Key
= MsgPropTrShotPanel
then
6071 SelectFlag
:= SELECTFLAG_SHOTPANEL
6072 else if Key
= MsgPropTrLiftPanel
then
6073 SelectFlag
:= SELECTFLAG_LIFT
6074 else if key
= MsgPropTrExMonster
then
6075 SelectFlag
:= SELECTFLAG_MONSTER
6076 else if Key
= MsgPropTrExArea
then
6078 SelectFlag
:= SELECTFLAG_NONE
;
6079 DrawPressRect
:= True;
6081 else if Key
= MsgPropTrNextMap
then
6082 begin // Выбор следующей карты:
6083 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
6084 SelectMapForm
.Caption
:= MsgCapSelect
;
6085 SelectMapForm
.GetMaps(FileName
);
6087 if SelectMapForm
.ShowModal() = mrOK
then
6089 vleObjectProperty
.Values
[Key
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
6090 vleObjectPropertyApply(Sender
);
6093 else if (Key
= MsgPropTrSoundName
) or
6094 (Key
= MsgPropTrMusicName
) then
6095 begin // Выбор файла звука/музыки:
6096 AddSoundForm
.OKFunction
:= nil;
6097 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
6098 AddSoundForm
.SetResource
:= vleObjectProperty
.Values
[Key
];
6100 if (AddSoundForm
.ShowModal() = mrOk
) then
6102 vleObjectProperty
.Values
[Key
] := AddSoundForm
.ResourceName
;
6103 vleObjectPropertyApply(Sender
);
6106 else if Key
= MsgPropTrActivation
then
6107 with ActivationTypeForm
, vleObjectProperty
do
6108 begin // Выбор типов активации:
6109 cbPlayerCollide
.Checked
:= Pos('PC', Values
[Key
]) > 0;
6110 cbMonsterCollide
.Checked
:= Pos('MC', Values
[Key
]) > 0;
6111 cbPlayerPress
.Checked
:= Pos('PP', Values
[Key
]) > 0;
6112 cbMonsterPress
.Checked
:= Pos('MP', Values
[Key
]) > 0;
6113 cbShot
.Checked
:= Pos('SH', Values
[Key
]) > 0;
6114 cbNoMonster
.Checked
:= Pos('NM', Values
[Key
]) > 0;
6116 if ShowModal() = mrOK
then
6119 if cbPlayerCollide
.Checked
then
6120 b
:= ACTIVATE_PLAYERCOLLIDE
;
6121 if cbMonsterCollide
.Checked
then
6122 b
:= b
or ACTIVATE_MONSTERCOLLIDE
;
6123 if cbPlayerPress
.Checked
then
6124 b
:= b
or ACTIVATE_PLAYERPRESS
;
6125 if cbMonsterPress
.Checked
then
6126 b
:= b
or ACTIVATE_MONSTERPRESS
;
6127 if cbShot
.Checked
then
6128 b
:= b
or ACTIVATE_SHOT
;
6129 if cbNoMonster
.Checked
then
6130 b
:= b
or ACTIVATE_NOMONSTER
;
6132 Values
[Key
] := ActivateToStr(b
);
6133 vleObjectPropertyApply(Sender
);
6136 else if Key
= MsgPropTrKeys
then
6137 with KeysForm
, vleObjectProperty
do
6138 begin // Выбор необходимых ключей:
6139 cbRedKey
.Checked
:= Pos('RK', Values
[Key
]) > 0;
6140 cbGreenKey
.Checked
:= Pos('GK', Values
[Key
]) > 0;
6141 cbBlueKey
.Checked
:= Pos('BK', Values
[Key
]) > 0;
6142 cbRedTeam
.Checked
:= Pos('RT', Values
[Key
]) > 0;
6143 cbBlueTeam
.Checked
:= Pos('BT', Values
[Key
]) > 0;
6145 if ShowModal() = mrOK
then
6148 if cbRedKey
.Checked
then
6150 if cbGreenKey
.Checked
then
6151 b
:= b
or KEY_GREEN
;
6152 if cbBlueKey
.Checked
then
6154 if cbRedTeam
.Checked
then
6155 b
:= b
or KEY_REDTEAM
;
6156 if cbBlueTeam
.Checked
then
6157 b
:= b
or KEY_BLUETEAM
;
6159 Values
[Key
] := KeyToStr(b
);
6160 vleObjectPropertyApply(Sender
);
6163 else if Key
= MsgPropTrFxType
then
6164 with ChooseTypeForm
, vleObjectProperty
do
6165 begin // Выбор типа эффекта:
6166 Caption
:= MsgCapFxType
;
6167 lbTypeSelect
.Items
.Clear();
6169 for b
:= EFFECT_NONE
to EFFECT_FIRE
do
6170 lbTypeSelect
.Items
.Add(EffectToStr(b
));
6172 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]);
6174 if ShowModal() = mrOK
then
6176 b
:= lbTypeSelect
.ItemIndex
;
6177 Values
[Key
] := EffectToStr(b
);
6178 vleObjectPropertyApply(Sender
);
6181 else if Key
= MsgPropTrMonsterType
then
6182 with ChooseTypeForm
, vleObjectProperty
do
6183 begin // Выбор типа монстра:
6184 Caption
:= MsgCapMonsterType
;
6185 lbTypeSelect
.Items
.Clear();
6187 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
6188 lbTypeSelect
.Items
.Add(MonsterToStr(b
));
6190 lbTypeSelect
.ItemIndex
:= StrToMonster(Values
[Key
]) - MONSTER_DEMON
;
6192 if ShowModal() = mrOK
then
6194 b
:= lbTypeSelect
.ItemIndex
+ MONSTER_DEMON
;
6195 Values
[Key
] := MonsterToStr(b
);
6196 vleObjectPropertyApply(Sender
);
6199 else if Key
= MsgPropTrItemType
then
6200 with ChooseTypeForm
, vleObjectProperty
do
6201 begin // Выбор типа предмета:
6202 Caption
:= MsgCapItemType
;
6203 lbTypeSelect
.Items
.Clear();
6205 for b
:= ITEM_MEDKIT_SMALL
to ITEM_KEY_BLUE
do
6206 lbTypeSelect
.Items
.Add(ItemToStr(b
));
6207 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_BOTTLE
));
6208 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_HELMET
));
6209 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_JETPACK
));
6210 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_INVIS
));
6211 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_WEAPON_FLAMETHROWER
));
6212 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_AMMO_FUELCAN
));
6214 b
:= StrToItem(Values
[Key
]);
6215 if b
>= ITEM_BOTTLE
then
6217 lbTypeSelect
.ItemIndex
:= b
- ITEM_MEDKIT_SMALL
;
6219 if ShowModal() = mrOK
then
6221 b
:= lbTypeSelect
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
6222 if b
>= ITEM_WEAPON_KASTET
then
6224 Values
[Key
] := ItemToStr(b
);
6225 vleObjectPropertyApply(Sender
);
6228 else if Key
= MsgPropTrShotType
then
6229 with ChooseTypeForm
, vleObjectProperty
do
6230 begin // Выбор типа предмета:
6231 Caption
:= MsgPropTrShotType
;
6232 lbTypeSelect
.Items
.Clear();
6234 for b
:= TRIGGER_SHOT_PISTOL
to TRIGGER_SHOT_MAX
do
6235 lbTypeSelect
.Items
.Add(ShotToStr(b
));
6237 lbTypeSelect
.ItemIndex
:= StrToShot(Values
[Key
]);
6239 if ShowModal() = mrOK
then
6241 b
:= lbTypeSelect
.ItemIndex
;
6242 Values
[Key
] := ShotToStr(b
);
6243 vleObjectPropertyApply(Sender
);
6246 else if Key
= MsgPropTrEffectType
then
6247 with ChooseTypeForm
, vleObjectProperty
do
6248 begin // Выбор типа эффекта:
6249 Caption
:= MsgCapFxType
;
6250 lbTypeSelect
.Items
.Clear();
6252 lbTypeSelect
.Items
.Add(MsgPropTrEffectParticle
);
6253 lbTypeSelect
.Items
.Add(MsgPropTrEffectAnimation
);
6254 if Values
[Key
] = MsgPropTrEffectAnimation
then
6255 lbTypeSelect
.ItemIndex
:= 1
6257 lbTypeSelect
.ItemIndex
:= 0;
6259 if ShowModal() = mrOK
then
6261 b
:= lbTypeSelect
.ItemIndex
;
6263 Values
[Key
] := MsgPropTrEffectParticle
6265 Values
[Key
] := MsgPropTrEffectAnimation
;
6266 vleObjectPropertyApply(Sender
);
6269 else if Key
= MsgPropTrEffectSubtype
then
6270 with ChooseTypeForm
, vleObjectProperty
do
6271 begin // Выбор подтипа эффекта:
6272 Caption
:= MsgCapFxType
;
6273 lbTypeSelect
.Items
.Clear();
6275 if Values
[MsgPropTrEffectType
] = MsgPropTrEffectAnimation
then
6277 for b
:= EFFECT_TELEPORT
to EFFECT_FIRE
do
6278 lbTypeSelect
.Items
.Add(EffectToStr(b
));
6280 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]) - 1;
6283 lbTypeSelect
.Items
.Add(MsgPropTrEffectSliquid
);
6284 lbTypeSelect
.Items
.Add(MsgPropTrEffectLliquid
);
6285 lbTypeSelect
.Items
.Add(MsgPropTrEffectDliquid
);
6286 lbTypeSelect
.Items
.Add(MsgPropTrEffectBlood
);
6287 lbTypeSelect
.Items
.Add(MsgPropTrEffectSpark
);
6288 lbTypeSelect
.Items
.Add(MsgPropTrEffectBubble
);
6289 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SLIQUID
;
6290 if Values
[Key
] = MsgPropTrEffectLliquid
then
6291 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_LLIQUID
;
6292 if Values
[Key
] = MsgPropTrEffectDliquid
then
6293 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_DLIQUID
;
6294 if Values
[Key
] = MsgPropTrEffectBlood
then
6295 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BLOOD
;
6296 if Values
[Key
] = MsgPropTrEffectSpark
then
6297 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SPARK
;
6298 if Values
[Key
] = MsgPropTrEffectBubble
then
6299 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BUBBLE
;
6302 if ShowModal() = mrOK
then
6304 b
:= lbTypeSelect
.ItemIndex
;
6306 if Values
[MsgPropTrEffectType
] = MsgPropTrEffectAnimation
then
6307 Values
[Key
] := EffectToStr(b
+ 1)
6309 Values
[Key
] := MsgPropTrEffectSliquid
;
6310 if b
= TRIGGER_EFFECT_LLIQUID
then
6311 Values
[Key
] := MsgPropTrEffectLliquid
;
6312 if b
= TRIGGER_EFFECT_DLIQUID
then
6313 Values
[Key
] := MsgPropTrEffectDliquid
;
6314 if b
= TRIGGER_EFFECT_BLOOD
then
6315 Values
[Key
] := MsgPropTrEffectBlood
;
6316 if b
= TRIGGER_EFFECT_SPARK
then
6317 Values
[Key
] := MsgPropTrEffectSpark
;
6318 if b
= TRIGGER_EFFECT_BUBBLE
then
6319 Values
[Key
] := MsgPropTrEffectBubble
;
6322 vleObjectPropertyApply(Sender
);
6325 else if Key
= MsgPropTrEffectColor
then
6326 with vleObjectProperty
do
6327 begin // Выбор цвета эффекта:
6328 ColorDialog
.Color
:= StrToIntDef(Values
[Key
], 0);
6329 if ColorDialog
.Execute
then
6331 Values
[Key
] := IntToStr(ColorDialog
.Color
);
6332 vleObjectPropertyApply(Sender
);
6335 else if Key
= MsgPropPanelTex
then
6336 begin // Смена текстуры:
6337 vleObjectProperty
.Values
[Key
] := SelectedTexture();
6338 vleObjectPropertyApply(Sender
);
6342 procedure TMainForm
.vleObjectPropertyApply(Sender
: TObject
);
6344 // hack to prevent empty ID in list
6345 RenderPanel
.SetFocus();
6346 bApplyProperty
.Click();
6347 vleObjectProperty
.SetFocus();
6350 procedure TMainForm
.aSaveMapExecute(Sender
: TObject
);
6352 FileName
, Section
, Res
: String;
6354 if OpenedMap
= '' then
6356 aSaveMapAsExecute(nil);
6360 g_ProcessResourceStr(OpenedMap
, FileName
, Section
, Res
);
6362 SaveMap(FileName
+':\'+Res
, '');
6365 procedure TMainForm
.aOpenMapExecute(Sender
: TObject
);
6367 OpenDialog
.Filter
:= MsgFileFilterAll
;
6369 if OpenDialog
.Execute() then
6371 OpenMapFile(OpenDialog
.FileName
);
6372 OpenDialog
.InitialDir
:= ExtractFileDir(OpenDialog
.FileName
);
6376 procedure TMainForm
.OpenMapFile(FileName
: String);
6378 if (Pos('.ini', LowerCase(ExtractFileName(FileName
))) > 0) then
6382 pLoadProgress
.Left
:= (RenderPanel
.Width
div 2)-(pLoadProgress
.Width
div 2);
6383 pLoadProgress
.Top
:= (RenderPanel
.Height
div 2)-(pLoadProgress
.Height
div 2);
6384 pLoadProgress
.Show();
6389 LoadMapOld(FileName
);
6391 MainForm
.Caption
:= Format('%s - %s', [FormCaption
, ExtractFileName(FileName
)]);
6393 pLoadProgress
.Hide();
6394 MainForm
.FormResize(Self
);
6396 else // Карты из WAD:
6398 OpenMap(FileName
, '');
6402 procedure TMainForm
.FormActivate(Sender
: TObject
);
6404 MainForm
.ActiveControl
:= RenderPanel
;
6407 procedure TMainForm
.aDeleteMap(Sender
: TObject
);
6415 OpenDialog
.Filter
:= MsgFileFilterWad
;
6417 if not OpenDialog
.Execute() then
6420 WAD
:= TWADEditor_1
.Create();
6422 if not WAD
.ReadFile(OpenDialog
.FileName
) then
6430 MapList
:= WAD
.GetResourcesList('');
6432 SelectMapForm
.Caption
:= MsgCapRemove
;
6433 SelectMapForm
.lbMapList
.Items
.Clear();
6435 if MapList
<> nil then
6436 for a
:= 0 to High(MapList
) do
6437 SelectMapForm
.lbMapList
.Items
.Add(win2utf(MapList
[a
]));
6439 if (SelectMapForm
.ShowModal() = mrOK
) then
6441 str
:= SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
6443 Move(str
[1], MapName
[0], Min(16, Length(str
)));
6445 if Application
.MessageBox(PChar(Format(MsgMsgDeleteMapPrompt
, [MapName
, OpenDialog
.FileName
])), PChar(MsgMsgDeleteMap
), MB_ICONQUESTION
or MB_YESNO
or MB_DEFBUTTON2
) <> mrYes
then
6448 WAD
.RemoveResource('', utf2win(MapName
));
6450 Application
.MessageBox(
6451 PChar(Format(MsgMsgMapDeletedPrompt
, [MapName
])),
6452 PChar(MsgMsgMapDeleted
),
6453 MB_ICONINFORMATION
or MB_OK
or MB_DEFBUTTON1
6456 WAD
.SaveTo(OpenDialog
.FileName
);
6458 // Удалили текущую карту - сохранять по старому ее нельзя:
6459 if OpenedMap
= (OpenDialog
.FileName
+':\'+MapName
) then
6463 MainForm
.Caption
:= FormCaption
;
6470 procedure TMainForm
.vleObjectPropertyKeyDown(Sender
: TObject
;
6471 var Key
: Word; Shift
: TShiftState
);
6473 if Key
= VK_RETURN
then
6474 vleObjectPropertyApply(Sender
);
6477 procedure MovePanel(var ID
: DWORD
; MoveType
: Byte);
6482 if (ID
= 0) and (MoveType
= 0) then
6484 if (ID
= DWORD(High(gPanels
))) and (MoveType
<> 0) then
6486 if (ID
> DWORD(High(gPanels
))) then
6491 if MoveType
= 0 then // to Back
6493 if gTriggers
<> nil then
6494 for a
:= 0 to High(gTriggers
) do
6495 with gTriggers
[a
] do
6497 if TriggerType
= TRIGGER_NONE
then
6500 if TexturePanel
= _id
then
6503 if (TexturePanel
>= 0) and (TexturePanel
< _id
) then
6507 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
6508 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6509 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6510 if Data
.PanelID
= _id
then
6513 if (Data
.PanelID
>= 0) and (Data
.PanelID
< _id
) then
6517 if Data
.ShotPanelID
= _id
then
6518 Data
.ShotPanelID
:= 0
6520 if (Data
.ShotPanelID
>= 0) and (Data
.ShotPanelID
< _id
) then
6521 Inc(Data
.ShotPanelID
);
6525 tmp
:= gPanels
[_id
];
6527 for a
:= _id
downto 1 do
6528 gPanels
[a
] := gPanels
[a
-1];
6536 if gTriggers
<> nil then
6537 for a
:= 0 to High(gTriggers
) do
6538 with gTriggers
[a
] do
6540 if TriggerType
= TRIGGER_NONE
then
6543 if TexturePanel
= _id
then
6544 TexturePanel
:= High(gPanels
)
6546 if TexturePanel
> _id
then
6550 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
6551 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6552 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6553 if Data
.PanelID
= _id
then
6554 Data
.PanelID
:= High(gPanels
)
6556 if Data
.PanelID
> _id
then
6560 if Data
.ShotPanelID
= _id
then
6561 Data
.ShotPanelID
:= High(gPanels
)
6563 if Data
.ShotPanelID
> _id
then
6564 Dec(Data
.ShotPanelID
);
6568 tmp
:= gPanels
[_id
];
6570 for a
:= _id
to High(gPanels
)-1 do
6571 gPanels
[a
] := gPanels
[a
+1];
6573 gPanels
[High(gPanels
)] := tmp
;
6575 ID
:= High(gPanels
);
6579 procedure TMainForm
.aMoveToBack(Sender
: TObject
);
6583 if SelectedObjects
= nil then
6586 for a
:= 0 to High(SelectedObjects
) do
6587 with SelectedObjects
[a
] do
6588 if Live
and (ObjectType
= OBJECT_PANEL
) then
6590 SelectedObjects
[0] := SelectedObjects
[a
];
6591 SetLength(SelectedObjects
, 1);
6598 procedure TMainForm
.aMoveToFore(Sender
: TObject
);
6602 if SelectedObjects
= nil then
6605 for a
:= 0 to High(SelectedObjects
) do
6606 with SelectedObjects
[a
] do
6607 if Live
and (ObjectType
= OBJECT_PANEL
) then
6609 SelectedObjects
[0] := SelectedObjects
[a
];
6610 SetLength(SelectedObjects
, 1);
6617 procedure TMainForm
.aSaveMapAsExecute(Sender
: TObject
);
6618 var i
, idx
: Integer; list
: TStringList
; fmt
: String;
6620 list
:= TStringList
.Create();
6622 // TODO: get loclized strings automatically from language files
6623 SaveDialog
.DefaultExt
:= '.dfz';
6624 SaveDialog
.FilterIndex
:= 1;
6625 SaveDialog
.Filter
:= '';
6626 gWADEditorFactory
.GetRegistredEditors(list
);
6627 for i
:= 0 to list
.Count
- 1 do
6629 if list
[i
] = 'DFZIP' then
6630 SaveDialog
.FilterIndex
:= i
+ 1;
6633 SaveDialog
.Filter
:= SaveDialog
.Filter
+ '|';
6635 if list
[i
] = 'DFWAD' then
6636 SaveDialog
.Filter
:= SaveDialog
.Filter
+ MsgFileFilterSaveDFWAD
6637 else if list
[i
] = 'DFZIP' then
6638 SaveDialog
.Filter
:= SaveDialog
.Filter
+ MsgFileFilterSaveDFZIP
6640 SaveDialog
.Filter
:= SaveDialog
.Filter
+ list
[i
] + '|*.*';
6643 if SaveDialog
.Execute() then
6645 i
:= SaveDialog
.FilterIndex
- 1;
6646 if (i
>= 0) and (i
< list
.Count
) then fmt
:= list
[i
] else fmt
:= '';
6648 SaveMapForm
.GetMaps(SaveDialog
.FileName
, True, fmt
);
6649 if SaveMapForm
.ShowModal() = mrOK
then
6651 SaveDialog
.InitialDir
:= ExtractFileDir(SaveDialog
.FileName
);
6652 OpenedMap
:= SaveDialog
.FileName
+':\'+SaveMapForm
.eMapName
.Text;
6653 OpenedWAD
:= SaveDialog
.FileName
;
6655 idx
:= RecentFiles
.IndexOf(OpenedMap
);
6656 // Такая карта уже недавно открывалась:
6658 RecentFiles
.Delete(idx
);
6659 RecentFiles
.Insert(0, OpenedMap
);
6662 SaveMap(OpenedMap
, fmt
);
6664 gMapInfo
.FileName
:= SaveDialog
.FileName
;
6665 gMapInfo
.MapName
:= SaveMapForm
.eMapName
.Text;
6666 UpdateCaption(gMapInfo
.Name
, ExtractFileName(gMapInfo
.FileName
), gMapInfo
.MapName
);
6673 procedure TMainForm
.aSelectAllExecute(Sender
: TObject
);
6677 RemoveSelectFromObjects();
6679 case pcObjects
.ActivePageIndex
+1 of
6681 if gPanels
<> nil then
6682 for a
:= 0 to High(gPanels
) do
6683 if gPanels
[a
].PanelType
<> PANEL_NONE
then
6684 SelectObject(OBJECT_PANEL
, a
, True);
6686 if gItems
<> nil then
6687 for a
:= 0 to High(gItems
) do
6688 if gItems
[a
].ItemType
<> ITEM_NONE
then
6689 SelectObject(OBJECT_ITEM
, a
, True);
6691 if gMonsters
<> nil then
6692 for a
:= 0 to High(gMonsters
) do
6693 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
6694 SelectObject(OBJECT_MONSTER
, a
, True);
6696 if gAreas
<> nil then
6697 for a
:= 0 to High(gAreas
) do
6698 if gAreas
[a
].AreaType
<> AREA_NONE
then
6699 SelectObject(OBJECT_AREA
, a
, True);
6701 if gTriggers
<> nil then
6702 for a
:= 0 to High(gTriggers
) do
6703 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
6704 SelectObject(OBJECT_TRIGGER
, a
, True);
6707 RecountSelectedObjects();
6710 procedure TMainForm
.tbGridOnClick(Sender
: TObject
);
6712 DotEnable
:= not DotEnable
;
6713 (Sender
as TToolButton
).Down
:= DotEnable
;
6716 procedure TMainForm
.OnIdle(Sender
: TObject
; var Done
: Boolean);
6719 if StartMap
<> '' then
6727 procedure TMainForm
.miMapPreviewClick(Sender
: TObject
);
6729 if PreviewMode
= 2 then
6732 if PreviewMode
= 0 then
6734 Splitter2
.Visible
:= False;
6735 Splitter1
.Visible
:= False;
6736 StatusBar
.Visible
:= False;
6737 PanelObjs
.Visible
:= False;
6738 PanelProps
.Visible
:= False;
6739 MainToolBar
.Visible
:= False;
6740 sbHorizontal
.Visible
:= False;
6741 sbVertical
.Visible
:= False;
6745 StatusBar
.Visible
:= True;
6746 PanelObjs
.Visible
:= True;
6747 PanelProps
.Visible
:= True;
6748 Splitter2
.Visible
:= True;
6749 Splitter1
.Visible
:= True;
6750 MainToolBar
.Visible
:= True;
6751 sbHorizontal
.Visible
:= True;
6752 sbVertical
.Visible
:= True;
6755 PreviewMode
:= PreviewMode
xor 1;
6756 (Sender
as TMenuItem
).Checked
:= PreviewMode
> 0;
6761 procedure TMainForm
.miLayer1Click(Sender
: TObject
);
6763 SwitchLayer(LAYER_BACK
);
6766 procedure TMainForm
.miLayer2Click(Sender
: TObject
);
6768 SwitchLayer(LAYER_WALLS
);
6771 procedure TMainForm
.miLayer3Click(Sender
: TObject
);
6773 SwitchLayer(LAYER_FOREGROUND
);
6776 procedure TMainForm
.miLayer4Click(Sender
: TObject
);
6778 SwitchLayer(LAYER_STEPS
);
6781 procedure TMainForm
.miLayer5Click(Sender
: TObject
);
6783 SwitchLayer(LAYER_WATER
);
6786 procedure TMainForm
.miLayer6Click(Sender
: TObject
);
6788 SwitchLayer(LAYER_ITEMS
);
6791 procedure TMainForm
.miLayer7Click(Sender
: TObject
);
6793 SwitchLayer(LAYER_MONSTERS
);
6796 procedure TMainForm
.miLayer8Click(Sender
: TObject
);
6798 SwitchLayer(LAYER_AREAS
);
6801 procedure TMainForm
.miLayer9Click(Sender
: TObject
);
6803 SwitchLayer(LAYER_TRIGGERS
);
6806 procedure TMainForm
.tbShowClick(Sender
: TObject
);
6812 for a
:= 0 to High(LayerEnabled
) do
6813 b
:= b
and LayerEnabled
[a
];
6817 ShowLayer(LAYER_BACK
, b
);
6818 ShowLayer(LAYER_WALLS
, b
);
6819 ShowLayer(LAYER_FOREGROUND
, b
);
6820 ShowLayer(LAYER_STEPS
, b
);
6821 ShowLayer(LAYER_WATER
, b
);
6822 ShowLayer(LAYER_ITEMS
, b
);
6823 ShowLayer(LAYER_MONSTERS
, b
);
6824 ShowLayer(LAYER_AREAS
, b
);
6825 ShowLayer(LAYER_TRIGGERS
, b
);
6828 procedure TMainForm
.miMiniMapClick(Sender
: TObject
);
6833 procedure TMainForm
.miSwitchGridClick(Sender
: TObject
);
6835 if DotStep
= DotStepOne
then
6836 DotStep
:= DotStepTwo
6838 DotStep
:= DotStepOne
;
6840 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6841 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6844 procedure TMainForm
.miShowEdgesClick(Sender
: TObject
);
6849 procedure TMainForm
.miSnapToGridClick(Sender
: TObject
);
6851 SnapToGrid
:= not SnapToGrid
;
6853 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6854 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6856 miSnapToGrid
.Checked
:= SnapToGrid
;
6859 procedure TMainForm
.minexttabClick(Sender
: TObject
);
6861 if pcObjects
.ActivePageIndex
< pcObjects
.PageCount
-1 then
6862 pcObjects
.ActivePageIndex
:= pcObjects
.ActivePageIndex
+1
6864 pcObjects
.ActivePageIndex
:= 0;
6867 procedure TMainForm
.miSaveMiniMapClick(Sender
: TObject
);
6869 SaveMiniMapForm
.ShowModal();
6872 procedure TMainForm
.bClearTextureClick(Sender
: TObject
);
6874 lbTextureList
.ItemIndex
:= -1;
6875 lTextureWidth
.Caption
:= '';
6876 lTextureHeight
.Caption
:= '';
6879 procedure TMainForm
.miPackMapClick(Sender
: TObject
);
6881 PackMapForm
.ShowModal();
6884 type SSArray
= array of String;
6886 function ParseString (Str
: AnsiString): SSArray
;
6887 function GetStr (var Str
: AnsiString): AnsiString;
6891 if Str
[1] = '"' then
6892 for b
:= 1 to Length(Str
) do
6893 if (b
= Length(Str
)) or (Str
[b
+ 1] = '"') then
6895 Result
:= Copy(Str
, 2, b
- 1);
6896 Delete(Str
, 1, b
+ 1);
6900 for a
:= 1 to Length(Str
) do
6901 if (a
= Length(Str
)) or (Str
[a
+ 1] = ' ') then
6903 Result
:= Copy(Str
, 1, a
);
6904 Delete(Str
, 1, a
+ 1);
6914 SetLength(Result
, Length(Result
)+1);
6915 Result
[High(Result
)] := GetStr(Str
);
6919 procedure TMainForm
.miTestMapClick(Sender
: TObject
);
6921 newWAD
, oldWAD
, tempMap
, ext
: String;
6928 // Ignore while map testing in progress
6929 if MapTestProcess
<> nil then
6932 // Сохраняем временную карту:
6935 newWAD
:= Format('%s/temp%.4d', [MapsDir
, time
]);
6937 until not FileExists(newWAD
);
6938 if OpenedMap
<> '' then
6940 oldWad
:= g_ExtractWadName(OpenedMap
);
6941 newWad
:= newWad
+ ExtractFileExt(oldWad
);
6942 if CopyFile(oldWad
, newWad
) = false then
6943 e_WriteLog('MapTest: unable to copy [' + oldWad
+ '] to [' + newWad
+ ']', MSG_WARNING
)
6947 newWad
:= newWad
+ '.wad'
6949 tempMap
:= newWAD
+ ':\' + TEST_MAP_NAME
;
6950 SaveMap(tempMap
, '');
6954 if TestOptionsTwoPlayers
then
6956 if TestOptionsTeamDamage
then
6958 if TestOptionsAllowExit
then
6960 if TestOptionsWeaponStay
then
6962 if TestOptionsMonstersDM
then
6966 proc
:= TProcessUTF8
.Create(nil);
6967 proc
.Executable
:= TestD2dExe
;
6969 // TODO: get real executable name from Info.plist
6970 if LowerCase(ExtractFileExt(TestD2dExe
)) = '.app' then
6971 proc
.Executable
:= TestD2dExe
+ DirectorySeparator
+ 'Contents' + DirectorySeparator
+ 'MacOS' + DirectorySeparator
+ 'Doom2DF';
6973 proc
.Parameters
.Add('-map');
6974 proc
.Parameters
.Add(tempMap
);
6975 proc
.Parameters
.Add('-gm');
6976 proc
.Parameters
.Add(TestGameMode
);
6977 proc
.Parameters
.Add('-limt');
6978 proc
.Parameters
.Add(TestLimTime
);
6979 proc
.Parameters
.Add('-lims');
6980 proc
.Parameters
.Add(TestLimScore
);
6981 proc
.Parameters
.Add('-opt');
6982 proc
.Parameters
.Add(IntToStr(opt
));
6983 proc
.Parameters
.Add('--debug');
6985 proc
.Parameters
.Add('--close');
6987 args
:= ParseString(TestD2DArgs
);
6988 for i
:= 0 to High(args
) do
6989 proc
.Parameters
.Add(args
[i
]);
6999 tbTestMap
.Enabled
:= False;
7000 MapTestFile
:= newWAD
;
7001 MapTestProcess
:= proc
;
7005 Application
.MessageBox(PChar(MsgMsgExecError
), 'FIXME', MB_OK
or MB_ICONERROR
);
7006 SysUtils
.DeleteFile(newWAD
);
7011 procedure TMainForm
.sbVerticalScroll(Sender
: TObject
;
7012 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
7014 MapOffset
.Y
:= -sbVertical
.Position
;
7015 RenderPanel
.Invalidate
;
7018 procedure TMainForm
.sbHorizontalScroll(Sender
: TObject
;
7019 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
7021 MapOffset
.X
:= -sbHorizontal
.Position
;
7022 RenderPanel
.Invalidate
;
7025 procedure TMainForm
.miOpenWadMapClick(Sender
: TObject
);
7027 if OpenedWAD
<> '' then
7029 OpenMap(OpenedWAD
, '');
7033 procedure TMainForm
.selectall1Click(Sender
: TObject
);
7037 RemoveSelectFromObjects();
7039 if gPanels
<> nil then
7040 for a
:= 0 to High(gPanels
) do
7041 if gPanels
[a
].PanelType
<> PANEL_NONE
then
7042 SelectObject(OBJECT_PANEL
, a
, True);
7044 if gItems
<> nil then
7045 for a
:= 0 to High(gItems
) do
7046 if gItems
[a
].ItemType
<> ITEM_NONE
then
7047 SelectObject(OBJECT_ITEM
, a
, True);
7049 if gMonsters
<> nil then
7050 for a
:= 0 to High(gMonsters
) do
7051 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
7052 SelectObject(OBJECT_MONSTER
, a
, True);
7054 if gAreas
<> nil then
7055 for a
:= 0 to High(gAreas
) do
7056 if gAreas
[a
].AreaType
<> AREA_NONE
then
7057 SelectObject(OBJECT_AREA
, a
, True);
7059 if gTriggers
<> nil then
7060 for a
:= 0 to High(gTriggers
) do
7061 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
7062 SelectObject(OBJECT_TRIGGER
, a
, True);
7064 RecountSelectedObjects();
7067 procedure TMainForm
.Splitter1CanResize(Sender
: TObject
;
7068 var NewSize
: Integer; var Accept
: Boolean);
7070 Accept
:= (NewSize
> 140);
7073 procedure TMainForm
.Splitter2CanResize(Sender
: TObject
;
7074 var NewSize
: Integer; var Accept
: Boolean);
7076 Accept
:= (NewSize
> 110);
7079 procedure TMainForm
.vleObjectPropertyEnter(Sender
: TObject
);
7081 EditingProperties
:= True;
7084 procedure TMainForm
.vleObjectPropertyExit(Sender
: TObject
);
7086 EditingProperties
:= False;
7089 procedure TMainForm
.FormKeyUp(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
7091 // Объекты передвигались:
7092 if MainForm
.ActiveControl
= RenderPanel
then
7094 if (Key
= VK_NUMPAD4
) or
7095 (Key
= VK_NUMPAD6
) or
7096 (Key
= VK_NUMPAD8
) or
7097 (Key
= VK_NUMPAD5
) or
7098 (Key
= Ord('V')) then
7101 // Быстрое превью карты:
7102 if Key
= Ord('E') then
7104 if PreviewMode
= 2 then
7107 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);