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 gWADEditorLogLevel
:= config
.ReadInt('WADEditor', 'LogLevel', DFWAD_LOG_DEFAULT
);
2761 if config
.ReadInt('Editor', 'XPos', -1) = -1 then
2762 Position
:= poDesktopCenter
2764 Left
:= config
.ReadInt('Editor', 'XPos', Left
);
2765 Top
:= config
.ReadInt('Editor', 'YPos', Top
);
2766 Width
:= config
.ReadInt('Editor', 'Width', Width
);
2767 Height
:= config
.ReadInt('Editor', 'Height', Height
);
2769 if config
.ReadBool('Editor', 'Maximize', False) then
2770 WindowState
:= wsMaximized
;
2771 ShowMap
:= config
.ReadBool('Editor', 'Minimap', False);
2772 PanelProps
.Width
:= config
.ReadInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
2773 Splitter1
.Left
:= PanelProps
.Left
;
2774 PanelObjs
.Height
:= config
.ReadInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
2775 Splitter2
.Top
:= PanelObjs
.Top
;
2776 StatusBar
.Top
:= PanelObjs
.BoundsRect
.Bottom
;
2777 DotEnable
:= config
.ReadBool('Editor', 'DotEnable', True);
2778 DotColor
:= config
.ReadInt('Editor', 'DotColor', $FFFFFF);
2779 DotStepOne
:= config
.ReadInt('Editor', 'DotStepOne', 16);
2780 DotStepTwo
:= config
.ReadInt('Editor', 'DotStepTwo', 8);
2781 DotStep
:= config
.ReadInt('Editor', 'DotStep', DotStepOne
);
2782 DrawTexturePanel
:= config
.ReadBool('Editor', 'DrawTexturePanel', True);
2783 DrawPanelSize
:= config
.ReadBool('Editor', 'DrawPanelSize', True);
2784 BackColor
:= config
.ReadInt('Editor', 'BackColor', $7F6040);
2785 PreviewColor
:= config
.ReadInt('Editor', 'PreviewColor', $00FF00);
2786 UseCheckerboard
:= config
.ReadBool('Editor', 'UseCheckerboard', True);
2787 gColorEdge
:= config
.ReadInt('Editor', 'EdgeColor', COLOR_EDGE
);
2788 gAlphaEdge
:= config
.ReadInt('Editor', 'EdgeAlpha', ALPHA_EDGE
);
2789 if gAlphaEdge
= 255 then
2790 gAlphaEdge
:= ALPHA_EDGE
;
2791 drEdge
[0] := GetRValue(gColorEdge
);
2792 drEdge
[1] := GetGValue(gColorEdge
);
2793 drEdge
[2] := GetBValue(gColorEdge
);
2794 if not config
.ReadBool('Editor', 'EdgeShow', True) then
2797 drEdge
[3] := gAlphaEdge
;
2798 gAlphaTriggerLine
:= config
.ReadInt('Editor', 'LineAlpha', ALPHA_LINE
);
2799 if gAlphaTriggerLine
= 255 then
2800 gAlphaTriggerLine
:= ALPHA_LINE
;
2801 gAlphaTriggerArea
:= config
.ReadInt('Editor', 'TriggerAlpha', ALPHA_AREA
);
2802 if gAlphaTriggerArea
= 255 then
2803 gAlphaTriggerArea
:= ALPHA_AREA
;
2804 gAlphaMonsterRect
:= config
.ReadInt('Editor', 'MonsterRectAlpha', 0);
2805 gAlphaAreaRect
:= config
.ReadInt('Editor', 'AreaRectAlpha', 0);
2806 Scale
:= Max(config
.ReadInt('Editor', 'Scale', 1), 1);
2807 DotSize
:= Max(config
.ReadInt('Editor', 'DotSize', 1), 1);
2808 OpenDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastOpenDir', MapsDir
);
2809 SaveDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastSaveDir', MapsDir
);
2811 s
:= config
.ReadStr('Editor', 'Language', '');
2814 TestGameMode
:= config
.ReadStr('TestRun', 'GameMode', 'DM');
2815 TestLimTime
:= config
.ReadStr('TestRun', 'LimTime', '0');
2816 TestLimScore
:= config
.ReadStr('TestRun', 'LimScore', '0');
2817 TestOptionsTwoPlayers
:= config
.ReadBool('TestRun', 'TwoPlayers', False);
2818 TestOptionsTeamDamage
:= config
.ReadBool('TestRun', 'TeamDamage', False);
2819 TestOptionsAllowExit
:= config
.ReadBool('TestRun', 'AllowExit', True);
2820 TestOptionsWeaponStay
:= config
.ReadBool('TestRun', 'WeaponStay', False);
2821 TestOptionsMonstersDM
:= config
.ReadBool('TestRun', 'MonstersDM', False);
2822 TestMapOnce
:= config
.ReadBool('TestRun', 'MapOnce', False);
2823 {$IF DEFINED(DARWIN)}
2824 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeDrawin', GameExeFile
);
2825 {$ELSEIF DEFINED(WINDOWS)}
2826 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeWindows', GameExeFile
);
2828 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeUnix', GameExeFile
);
2830 TestD2DArgs
:= config
.ReadStr('TestRun', 'Args', '');
2832 RecentCount
:= config
.ReadInt('Editor', 'RecentCount', 5);
2833 if RecentCount
> 10 then
2835 if RecentCount
< 2 then
2838 RecentFiles
:= TStringList
.Create();
2839 for i
:= 0 to RecentCount
-1 do
2842 s
:= config
.ReadStr('RecentFilesWin', IntToStr(i
), '');
2844 s
:= config
.ReadStr('RecentFilesUnix', IntToStr(i
), '');
2849 RefreshRecentMenu();
2853 tbShowMap
.Down
:= ShowMap
;
2854 tbGridOn
.Down
:= DotEnable
;
2855 pcObjects
.ActivePageIndex
:= 0;
2856 Application
.Title
:= MsgEditorTitle
;
2858 Application
.OnIdle
:= OnIdle
;
2861 procedure PrintBlack(X
, Y
: Integer; Text: string; FontID
: DWORD
);
2863 // NOTE: all the font printing routines assume CP1251
2864 e_TextureFontPrintEx(X
, Y
, Text, FontID
, 0, 0, 0, 1.0);
2867 procedure InitGraphics
;
2869 // FIXME: this is a shitty hack
2870 if not gDataLoaded
then
2872 e_WriteLog('Init OpenGL', MSG_NOTIFY
);
2874 e_WriteLog('Loading data', MSG_NOTIFY
);
2875 LoadStdFont('STDTXT', 'STDFONT', gEditorFont
);
2876 e_WriteLog('Loading more data', MSG_NOTIFY
);
2878 e_WriteLog('Loading even more data', MSG_NOTIFY
);
2879 gDataLoaded
:= True;
2880 MainForm
.FormResize(nil);
2884 procedure TMainForm
.Draw();
2889 Width
, Height
: Word;
2892 aX
, aY
, aX2
, aY2
, XX
, ScaleSz
: Integer;
2903 e_Clear(GL_COLOR_BUFFER_BIT
,
2904 GetRValue(BackColor
)/255,
2905 GetGValue(BackColor
)/255,
2906 GetBValue(BackColor
)/255);
2910 ObjCount
:= SelectedObjectCount();
2912 // Обводим выделенные объекты красной рамкой:
2913 if ObjCount
> 0 then
2915 for a
:= 0 to High(SelectedObjects
) do
2916 if SelectedObjects
[a
].Live
then
2918 Rect
:= ObjectGetRect(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
);
2922 e_DrawQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2923 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2926 // Рисуем точки изменения размеров:
2927 if (ObjCount
= 1) and
2928 (SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) then
2930 e_DrawPoint(5, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2931 e_DrawPoint(5, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2932 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 255, 255);
2933 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 255, 255);
2935 e_DrawPoint(3, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2936 e_DrawPoint(3, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2937 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 0, 0);
2938 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 0, 0);
2945 if DotEnable
and (PreviewMode
= 0) then
2952 x
:= MapOffset
.X
mod DotStep
;
2953 y
:= MapOffset
.Y
mod DotStep
;
2955 while x
< RenderPanel
.Width
do
2957 while y
< RenderPanel
.Height
do
2959 e_DrawPoint(DotSize
, x
+ a
, y
+ a
,
2960 GetRValue(DotColor
),
2961 GetGValue(DotColor
),
2962 GetBValue(DotColor
));
2966 y
:= MapOffset
.Y
mod DotStep
;
2971 if (lbTextureList
.ItemIndex
<> -1) and (cbPreview
.Checked
) and
2972 (not IsSpecialTextureSel()) and (PreviewMode
= 0) then
2974 if not g_GetTexture(SelectedTexture(), ID
) then
2975 g_GetTexture('NOTEXTURE', ID
);
2976 g_GetTextureSizeByID(ID
, Width
, Height
);
2977 if UseCheckerboard
then
2979 if g_GetTexture('PREVIEW', PID
) then
2980 e_DrawFill(PID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, Width
div 16 + 1, Height
div 16 + 1, 0, True, False);
2982 e_DrawFillQuad(RenderPanel
.Width
-Width
-2, RenderPanel
.Height
-Height
-2,
2983 RenderPanel
.Width
-1, RenderPanel
.Height
-1,
2984 GetRValue(PreviewColor
), GetGValue(PreviewColor
), GetBValue(PreviewColor
), 0);
2985 e_Draw(ID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, 0, True, False);
2988 // Подсказка при выборе точки Телепорта:
2989 if SelectFlag
= SELECTFLAG_TELEPORT
then
2991 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
2992 if Data
.d2d_teleport
then
2993 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
2994 MousePos
.X
+16, MousePos
.Y
-1,
2997 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+AreaSize
[AREA_DMPOINT
].Width
-1,
2998 MousePos
.Y
+AreaSize
[AREA_DMPOINT
].Height
-1, 255, 255, 255);
3000 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3001 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3002 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintTeleport
), gEditorFont
);
3005 // Подсказка при выборе точки появления:
3006 if SelectFlag
= SELECTFLAG_SPAWNPOINT
then
3008 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
3009 MousePos
.X
+16, MousePos
.Y
-1,
3011 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3012 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3013 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintSpawn
), gEditorFont
);
3016 // Подсказка при выборе панели двери:
3017 if SelectFlag
= SELECTFLAG_DOOR
then
3019 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3020 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3021 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelDoor
), gEditorFont
);
3024 // Подсказка при выборе панели с текстурой:
3025 if SelectFlag
= SELECTFLAG_TEXTURE
then
3027 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 192, 192, 192, 127);
3028 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 255, 255, 255);
3029 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelTexture
), gEditorFont
);
3032 // Подсказка при выборе панели индикации выстрела:
3033 if SelectFlag
= SELECTFLAG_SHOTPANEL
then
3035 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 192, 192, 192, 127);
3036 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 255, 255, 255);
3037 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelShot
), gEditorFont
);
3040 // Подсказка при выборе панели лифта:
3041 if SelectFlag
= SELECTFLAG_LIFT
then
3043 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3044 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3045 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelLift
), gEditorFont
);
3048 // Подсказка при выборе монстра:
3049 if SelectFlag
= SELECTFLAG_MONSTER
then
3051 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 192, 192, 192, 127);
3052 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 255, 255, 255);
3053 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintMonster
), gEditorFont
);
3056 // Подсказка при выборе области воздействия:
3057 if DrawPressRect
then
3059 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 192, 192, 192, 127);
3060 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 255, 255, 255);
3061 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintExtArea
), gEditorFont
);
3064 // Рисуем текстуры, если чертим панель:
3065 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and (DrawTexturePanel
) and
3066 (lbTextureList
.ItemIndex
<> -1) and (DrawRect
<> nil) and
3067 (lbPanelType
.ItemIndex
in [0..8]) and not IsSpecialTextureSel() then
3069 if not g_GetTexture(SelectedTexture(), ID
) then
3070 g_GetTexture('NOTEXTURE', ID
);
3071 g_GetTextureSizeByID(ID
, Width
, Height
);
3073 if (Abs(Right
-Left
) >= Width
) and (Abs(Bottom
-Top
) >= Height
) then
3074 e_DrawFill(ID
, Min(Left
, Right
), Min(Top
, Bottom
), Abs(Right
-Left
) div Width
,
3075 Abs(Bottom
-Top
) div Height
, 64, True, False);
3078 // Прямоугольник выделения:
3079 if DrawRect
<> nil then
3081 e_DrawQuad(Left
, Top
, Right
-1, Bottom
-1, 255, 255, 255);
3083 // Чертим мышью панель/триггер или меняем мышью их размер:
3084 if (((MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
]) and
3085 not(ssCtrl
in GetKeyShiftState())) or (MouseAction
= MOUSEACTION_RESIZE
)) and
3086 (DrawPanelSize
) then
3088 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 192, 192, 192, 127);
3089 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 255, 255, 255);
3091 if MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
] then
3092 begin // Чертим новый
3093 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(utf8to1251(MsgHintWidth
),
3094 [Abs(MousePos
.X
-MouseLDownPos
.X
)]), gEditorFont
);
3095 PrintBlack(MousePos
.X
+2, MousePos
.Y
+16, Format(utf8to1251(MsgHintHeight
),
3096 [Abs(MousePos
.Y
-MouseLDownPos
.Y
)]), gEditorFont
);
3098 else // Растягиваем существующий
3099 if SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
] then
3101 if SelectedObjects
[GetFirstSelected
].ObjectType
= OBJECT_PANEL
then
3103 Width
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
3104 Height
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
3108 Width
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
3109 Height
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
3112 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(utf8to1251(MsgHintWidth
), [Width
]),
3114 PrintBlack(MousePos
.X
+2, MousePos
.Y
+16, Format(utf8to1251(MsgHintHeight
), [Height
]),
3119 // Ближайшая к курсору мыши точка на сетке:
3120 e_DrawPoint(3, MousePos
.X
, MousePos
.Y
, 0, 0, 255);
3125 // Сколько пикселов карты в 1 пикселе мини-карты:
3126 ScaleSz
:= 16 div Scale
;
3127 // Размеры мини-карты:
3128 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3129 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3130 // X-координата на RenderPanel нулевой x-координаты карты:
3131 XX
:= RenderPanel
.Width
- aX
- 1;
3133 e_DrawFillQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 0, 0, 0, 0);
3134 e_DrawQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 197, 197, 197);
3136 if gPanels
<> nil then
3139 for a
:= 0 to High(gPanels
) do
3141 if PanelType
<> 0 then
3143 // Левый верхний угол:
3144 aX
:= XX
+ (X
div ScaleSz
);
3145 aY
:= 1 + (Y
div ScaleSz
);
3147 aX2
:= max(Width
div ScaleSz
, 1);
3148 aY2
:= max(Height
div ScaleSz
, 1);
3149 // Правый нижний угол:
3150 aX2
:= aX
+ aX2
- 1;
3151 aY2
:= aY
+ aY2
- 1;
3154 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3155 PANEL_WATER
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3156 PANEL_ACID1
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3157 PANEL_ACID2
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3158 PANEL_STEP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3159 PANEL_LIFTUP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3160 PANEL_LIFTDOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3161 PANEL_LIFTLEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3162 PANEL_LIFTRIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3163 PANEL_OPENDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 100, 220, 92, 0);
3164 PANEL_CLOSEDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 212, 184, 64, 0);
3165 PANEL_BLOCKMON
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 192, 0, 192, 0);
3169 // Рисуем красным выделенные панели:
3170 if SelectedObjects
<> nil then
3171 for b
:= 0 to High(SelectedObjects
) do
3172 with SelectedObjects
[b
] do
3173 if Live
and (ObjectType
= OBJECT_PANEL
) then
3174 with gPanels
[SelectedObjects
[b
].ID
] do
3175 if PanelType
and not(PANEL_BACK
or PANEL_FORE
) <> 0 then
3177 // Левый верхний угол:
3178 aX
:= XX
+ (X
div ScaleSz
);
3179 aY
:= 1 + (Y
div ScaleSz
);
3181 aX2
:= max(Width
div ScaleSz
, 1);
3182 aY2
:= max(Height
div ScaleSz
, 1);
3183 // Правый нижний угол:
3184 aX2
:= aX
+ aX2
- 1;
3185 aY2
:= aY
+ aY2
- 1;
3187 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0)
3191 if (gMapInfo
.Width
> RenderPanel
.Width
) or
3192 (gMapInfo
.Height
> RenderPanel
.Height
) then
3194 // Окно, показывающее текущее положение экрана на карте:
3196 x
:= max(min(RenderPanel
.Width
, gMapInfo
.Width
) div ScaleSz
, 1);
3197 y
:= max(min(RenderPanel
.Height
, gMapInfo
.Height
) div ScaleSz
, 1);
3198 // Левый верхний угол:
3199 aX
:= XX
+ ((-MapOffset
.X
) div ScaleSz
);
3200 aY
:= 1 + ((-MapOffset
.Y
) div ScaleSz
);
3201 // Правый нижний угол:
3205 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 127, 192, 127, 127, B_BLEND
);
3206 e_DrawQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0);
3211 RenderPanel
.SwapBuffers();
3214 procedure TMainForm
.FormResize(Sender
: TObject
);
3216 e_SetViewPort(0, 0, RenderPanel
.Width
, RenderPanel
.Height
);
3218 sbHorizontal
.Min
:= Min(gMapInfo
.Width
- RenderPanel
.Width
, -RenderPanel
.Width
div 2);
3219 sbHorizontal
.Max
:= Max(0, gMapInfo
.Width
- RenderPanel
.Width
div 2);
3220 sbVertical
.Min
:= Min(gMapInfo
.Height
- RenderPanel
.Height
, -RenderPanel
.Height
div 2);
3221 sbVertical
.Max
:= Max(0, gMapInfo
.Height
- RenderPanel
.Height
div 2);
3223 MapOffset
.X
:= -sbHorizontal
.Position
;
3224 MapOffset
.Y
:= -sbVertical
.Position
;
3227 procedure TMainForm
.FormWindowStateChange(Sender
: TObject
);
3233 // deactivate all menus when main window minimized
3234 e
:= self
.WindowState
<> wsMinimized
;
3235 miMenuFile
.Enabled
:= e
;
3236 miMenuEdit
.Enabled
:= e
;
3237 miMenuView
.Enabled
:= e
;
3238 miMenuService
.Enabled
:= e
;
3239 miMenuWindow
.Enabled
:= e
;
3240 miMenuHelp
.Enabled
:= e
;
3241 miMenuHidden
.Enabled
:= e
;
3245 procedure SelectNextObject(X
, Y
: Integer; ObjectType
: Byte; ID
: DWORD
);
3250 j_max
:= 0; // shut up compiler
3254 res
:= (gPanels
<> nil) and
3255 PanelInShownLayer(gPanels
[ID
].PanelType
) and
3256 g_CollidePoint(X
, Y
, gPanels
[ID
].X
, gPanels
[ID
].Y
,
3258 gPanels
[ID
].Height
);
3259 j_max
:= Length(gPanels
) - 1;
3264 res
:= (gItems
<> nil) and
3265 LayerEnabled
[LAYER_ITEMS
] and
3266 g_CollidePoint(X
, Y
, gItems
[ID
].X
, gItems
[ID
].Y
,
3267 ItemSize
[gItems
[ID
].ItemType
][0],
3268 ItemSize
[gItems
[ID
].ItemType
][1]);
3269 j_max
:= Length(gItems
) - 1;
3274 res
:= (gMonsters
<> nil) and
3275 LayerEnabled
[LAYER_MONSTERS
] and
3276 g_CollidePoint(X
, Y
, gMonsters
[ID
].X
, gMonsters
[ID
].Y
,
3277 MonsterSize
[gMonsters
[ID
].MonsterType
].Width
,
3278 MonsterSize
[gMonsters
[ID
].MonsterType
].Height
);
3279 j_max
:= Length(gMonsters
) - 1;
3284 res
:= (gAreas
<> nil) and
3285 LayerEnabled
[LAYER_AREAS
] and
3286 g_CollidePoint(X
, Y
, gAreas
[ID
].X
, gAreas
[ID
].Y
,
3287 AreaSize
[gAreas
[ID
].AreaType
].Width
,
3288 AreaSize
[gAreas
[ID
].AreaType
].Height
);
3289 j_max
:= Length(gAreas
) - 1;
3294 res
:= (gTriggers
<> nil) and
3295 LayerEnabled
[LAYER_TRIGGERS
] and
3296 g_CollidePoint(X
, Y
, gTriggers
[ID
].X
, gTriggers
[ID
].Y
,
3297 gTriggers
[ID
].Width
,
3298 gTriggers
[ID
].Height
);
3299 j_max
:= Length(gTriggers
) - 1;
3309 // Перебор ID: от ID-1 до 0; потом от High до ID+1:
3318 if j
= Integer(ID
) then
3323 res
:= PanelInShownLayer(gPanels
[j
].PanelType
) and
3324 g_CollidePoint(X
, Y
, gPanels
[j
].X
, gPanels
[j
].Y
,
3328 res
:= (gItems
[j
].ItemType
<> ITEM_NONE
) and
3329 g_CollidePoint(X
, Y
, gItems
[j
].X
, gItems
[j
].Y
,
3330 ItemSize
[gItems
[j
].ItemType
][0],
3331 ItemSize
[gItems
[j
].ItemType
][1]);
3333 res
:= (gMonsters
[j
].MonsterType
<> MONSTER_NONE
) and
3334 g_CollidePoint(X
, Y
, gMonsters
[j
].X
, gMonsters
[j
].Y
,
3335 MonsterSize
[gMonsters
[j
].MonsterType
].Width
,
3336 MonsterSize
[gMonsters
[j
].MonsterType
].Height
);
3338 res
:= (gAreas
[j
].AreaType
<> AREA_NONE
) and
3339 g_CollidePoint(X
, Y
, gAreas
[j
].X
, gAreas
[j
].Y
,
3340 AreaSize
[gAreas
[j
].AreaType
].Width
,
3341 AreaSize
[gAreas
[j
].AreaType
].Height
);
3343 res
:= (gTriggers
[j
].TriggerType
<> TRIGGER_NONE
) and
3344 g_CollidePoint(X
, Y
, gTriggers
[j
].X
, gTriggers
[j
].Y
,
3346 gTriggers
[j
].Height
);
3353 SetLength(SelectedObjects
, 1);
3355 SelectedObjects
[0].ObjectType
:= ObjectType
;
3356 SelectedObjects
[0].ID
:= j
;
3357 SelectedObjects
[0].Live
:= True;
3365 procedure TMainForm
.RenderPanelMouseDown(Sender
: TObject
;
3366 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3370 c1
, c2
, c3
, c4
: Boolean;
3376 MainForm
.ActiveControl
:= RenderPanel
;
3377 RenderPanel
.SetFocus();
3379 RenderPanelMouseMove(RenderPanel
, Shift
, X
, Y
);
3381 if Button
= mbLeft
then // Left Mouse Button
3383 // Двигаем карту с помощью мыши и мини-карты:
3385 g_CollidePoint(X
, Y
,
3386 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3388 max(gMapInfo
.Width
div (16 div Scale
), 1),
3389 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3392 MouseAction
:= MOUSEACTION_MOVEMAP
;
3394 else // Ставим предмет/монстра/область:
3395 if (pcObjects
.ActivePageIndex
in [1, 2, 3]) and
3396 (not (ssShift
in Shift
)) then
3398 case pcObjects
.ActivePageIndex
of
3400 if lbItemList
.ItemIndex
= -1 then
3401 ErrorMessageBox(MsgMsgChooseItem
)
3404 item
.ItemType
:= lbItemList
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
3405 if item
.ItemType
>= ITEM_WEAPON_KASTET
then
3406 item
.ItemType
:= item
.ItemType
+ 2;
3407 item
.X
:= MousePos
.X
-MapOffset
.X
;
3408 item
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3410 if not (ssCtrl
in Shift
) then
3412 item
.X
:= item
.X
- (ItemSize
[item
.ItemType
][0] div 2);
3413 item
.Y
:= item
.Y
- ItemSize
[item
.ItemType
][1];
3416 item
.OnlyDM
:= cbOnlyDM
.Checked
;
3417 item
.Fall
:= cbFall
.Checked
;
3418 Undo_Add(OBJECT_ITEM
, AddItem(item
));
3421 if lbMonsterList
.ItemIndex
= -1 then
3422 ErrorMessageBox(MsgMsgChooseMonster
)
3425 monster
.MonsterType
:= lbMonsterList
.ItemIndex
+ MONSTER_DEMON
;
3426 monster
.X
:= MousePos
.X
-MapOffset
.X
;
3427 monster
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3429 if not (ssCtrl
in Shift
) then
3431 monster
.X
:= monster
.X
- (MonsterSize
[monster
.MonsterType
].Width
div 2);
3432 monster
.Y
:= monster
.Y
- MonsterSize
[monster
.MonsterType
].Height
;
3435 if rbMonsterLeft
.Checked
then
3436 monster
.Direction
:= D_LEFT
3438 monster
.Direction
:= D_RIGHT
;
3439 Undo_Add(OBJECT_MONSTER
, AddMonster(monster
));
3442 if lbAreasList
.ItemIndex
= -1 then
3443 ErrorMessageBox(MsgMsgChooseArea
)
3445 if (lbAreasList
.ItemIndex
+ 1) <> AREA_DOMFLAG
then
3447 area
.AreaType
:= lbAreasList
.ItemIndex
+ AREA_PLAYERPOINT1
;
3448 area
.X
:= MousePos
.X
-MapOffset
.X
;
3449 area
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3451 if not (ssCtrl
in Shift
) then
3453 area
.X
:= area
.X
- (AreaSize
[area
.AreaType
].Width
div 2);
3454 area
.Y
:= area
.Y
- AreaSize
[area
.AreaType
].Height
;
3457 if rbAreaLeft
.Checked
then
3458 area
.Direction
:= D_LEFT
3460 area
.Direction
:= D_RIGHT
;
3461 Undo_Add(OBJECT_AREA
, AddArea(area
));
3467 i
:= GetFirstSelected();
3469 // Выбираем объект под текущим:
3470 if (SelectedObjects
<> nil) and
3471 (ssShift
in Shift
) and (i
>= 0) and
3472 (SelectedObjects
[i
].Live
) then
3474 if SelectedObjectCount() = 1 then
3475 SelectNextObject(X
-MapOffset
.X
, Y
-MapOffset
.Y
,
3476 SelectedObjects
[i
].ObjectType
,
3477 SelectedObjects
[i
].ID
);
3481 // Рисуем область триггера "Расширитель":
3482 if DrawPressRect
and (i
>= 0) and
3483 (SelectedObjects
[i
].ObjectType
= OBJECT_TRIGGER
) and
3484 (gTriggers
[SelectedObjects
[i
].ID
].TriggerType
in
3485 [TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
]) then
3486 MouseAction
:= MOUSEACTION_DRAWPRESS
3487 else // Рисуем панель:
3488 if pcObjects
.ActivePageIndex
= 0 then
3490 if (lbPanelType
.ItemIndex
>= 0) then
3491 MouseAction
:= MOUSEACTION_DRAWPANEL
3493 else // Рисуем триггер:
3494 if (lbTriggersList
.ItemIndex
>= 0) then
3496 MouseAction
:= MOUSEACTION_DRAWTRIGGER
;
3500 end; // if Button = mbLeft
3502 if Button
= mbRight
then // Right Mouse Button
3504 // Клик по мини-карте:
3506 g_CollidePoint(X
, Y
,
3507 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3509 max(gMapInfo
.Width
div (16 div Scale
), 1),
3510 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3512 MouseAction
:= MOUSEACTION_NOACTION
;
3514 else // Нужно что-то выбрать мышью:
3515 if SelectFlag
<> SELECTFLAG_NONE
then
3518 SELECTFLAG_TELEPORT
:
3519 // Точку назначения телепортации:
3520 with gTriggers
[SelectedObjects
[
3521 GetFirstSelected() ].ID
].Data
.TargetPoint
do
3523 X
:= MousePos
.X
-MapOffset
.X
;
3524 Y
:= MousePos
.Y
-MapOffset
.Y
;
3527 SELECTFLAG_SPAWNPOINT
:
3528 // Точку создания монстра:
3529 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
3530 if TriggerType
= TRIGGER_SPAWNMONSTER
then
3532 Data
.MonPos
.X
:= MousePos
.X
-MapOffset
.X
;
3533 Data
.MonPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3535 else if TriggerType
= TRIGGER_SPAWNITEM
then
3536 begin // Точка создания предмета:
3537 Data
.ItemPos
.X
:= MousePos
.X
-MapOffset
.X
;
3538 Data
.ItemPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3540 else if TriggerType
= TRIGGER_SHOT
then
3541 begin // Точка создания выстрела:
3542 Data
.ShotPos
.X
:= MousePos
.X
-MapOffset
.X
;
3543 Data
.ShotPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3549 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3551 2, 2, OBJECT_PANEL
, True);
3552 if IDArray
<> nil then
3554 for i
:= 0 to High(IDArray
) do
3555 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3556 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
) then
3558 gTriggers
[SelectedObjects
[
3559 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3564 gTriggers
[SelectedObjects
[
3565 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3569 // Панель с текстурой:
3571 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3573 2, 2, OBJECT_PANEL
, True);
3574 if IDArray
<> nil then
3576 for i
:= 0 to High(IDArray
) do
3577 if ((gPanels
[IDArray
[i
]].PanelType
in
3578 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3579 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3581 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3582 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3583 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3585 gTriggers
[SelectedObjects
[
3586 GetFirstSelected() ].ID
].TexturePanel
:= IDArray
[i
];
3591 gTriggers
[SelectedObjects
[
3592 GetFirstSelected() ].ID
].TexturePanel
:= -1;
3598 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3600 2, 2, OBJECT_PANEL
, True);
3601 if IDArray
<> nil then
3603 for i
:= 0 to High(IDArray
) do
3604 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTUP
) or
3605 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTDOWN
) or
3606 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTLEFT
) or
3607 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTRIGHT
) then
3609 gTriggers
[SelectedObjects
[
3610 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3615 gTriggers
[SelectedObjects
[
3616 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3622 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3624 2, 2, OBJECT_MONSTER
, False);
3625 if IDArray
<> nil then
3626 gTriggers
[SelectedObjects
[
3627 GetFirstSelected() ].ID
].Data
.MonsterID
:= IDArray
[0]+1
3629 gTriggers
[SelectedObjects
[
3630 GetFirstSelected() ].ID
].Data
.MonsterID
:= 0;
3633 SELECTFLAG_SHOTPANEL
:
3634 // Панель индикации выстрела:
3636 if gTriggers
[SelectedObjects
[
3637 GetFirstSelected() ].ID
].TriggerType
= TRIGGER_SHOT
then
3639 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3641 2, 2, OBJECT_PANEL
, True);
3642 if IDArray
<> nil then
3644 for i
:= 0 to High(IDArray
) do
3645 if ((gPanels
[IDArray
[i
]].PanelType
in
3646 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3647 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3649 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3650 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3651 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3653 gTriggers
[SelectedObjects
[
3654 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= IDArray
[i
];
3659 gTriggers
[SelectedObjects
[
3660 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= -1;
3665 SelectFlag
:= SELECTFLAG_SELECTED
;
3667 else // if SelectFlag <> SELECTFLAG_NONE...
3669 // Что уже выбрано и не нажат Ctrl:
3670 if (SelectedObjects
<> nil) and
3671 (not (ssCtrl
in Shift
)) then
3672 for i
:= 0 to High(SelectedObjects
) do
3673 with SelectedObjects
[i
] do
3676 if (ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) and
3677 (SelectedObjectCount() = 1) then
3679 Rect
:= ObjectGetRect(ObjectType
, ID
);
3681 c1
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3682 Rect
.X
-2, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3683 c2
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3684 Rect
.X
+Rect
.Width
-3, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3685 c3
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3686 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
-2, 4, 4);
3687 c4
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3688 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
+Rect
.Height
-3, 4, 4);
3690 // Меняем размер панели или триггера:
3691 if c1
or c2
or c3
or c4
then
3693 MouseAction
:= MOUSEACTION_RESIZE
;
3694 LastMovePoint
:= MousePos
;
3698 ResizeType
:= RESIZETYPE_HORIZONTAL
;
3700 ResizeDirection
:= RESIZEDIR_LEFT
3702 ResizeDirection
:= RESIZEDIR_RIGHT
;
3703 RenderPanel
.Cursor
:= crSizeWE
;
3707 ResizeType
:= RESIZETYPE_VERTICAL
;
3709 ResizeDirection
:= RESIZEDIR_UP
3711 ResizeDirection
:= RESIZEDIR_DOWN
;
3712 RenderPanel
.Cursor
:= crSizeNS
;
3719 // Перемещаем панель или триггер:
3720 if ObjectCollide(ObjectType
, ID
,
3722 Y
-MapOffset
.Y
-1, 2, 2) then
3724 MouseAction
:= MOUSEACTION_MOVEOBJ
;
3725 LastMovePoint
:= MousePos
;
3731 end; // if Button = mbRight
3733 if Button
= mbMiddle
then // Middle Mouse Button
3735 SetCapture(RenderPanel
.Handle
);
3736 RenderPanel
.Cursor
:= crSize
;
3739 MouseMDown
:= Button
= mbMiddle
;
3741 MouseMDownPos
:= Mouse
.CursorPos
;
3743 MouseRDown
:= Button
= mbRight
;
3745 MouseRDownPos
:= MousePos
;
3747 MouseLDown
:= Button
= mbLeft
;
3749 MouseLDownPos
:= MousePos
;
3752 procedure TMainForm
.RenderPanelMouseUp(Sender
: TObject
;
3753 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3758 rSelectRect
: Boolean;
3759 wWidth
, wHeight
: Word;
3762 procedure SelectObjects(ObjectType
: Byte);
3767 IDArray
:= ObjectInRect(rRect
.X
, rRect
.Y
,
3768 rRect
.Width
, rRect
.Height
,
3769 ObjectType
, rSelectRect
);
3771 if IDArray
<> nil then
3772 for i
:= 0 to High(IDArray
) do
3773 SelectObject(ObjectType
, IDArray
[i
], (ssCtrl
in Shift
) or rSelectRect
);
3776 if Button
= mbLeft
then
3777 MouseLDown
:= False;
3778 if Button
= mbRight
then
3779 MouseRDown
:= False;
3780 if Button
= mbMiddle
then
3781 MouseMDown
:= False;
3783 if DrawRect
<> nil then
3789 ResizeType
:= RESIZETYPE_NONE
;
3792 if Button
= mbLeft
then // Left Mouse Button
3794 if MouseAction
<> MOUSEACTION_NONE
then
3795 begin // Было действие мышью
3796 // Мышь сдвинулась во время удержания клавиши,
3797 // либо активирован режим быстрого рисования:
3798 if ((MousePos
.X
<> MouseLDownPos
.X
) and
3799 (MousePos
.Y
<> MouseLDownPos
.Y
)) or
3800 ((MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
]) and
3801 (ssCtrl
in Shift
)) then
3804 MOUSEACTION_DRAWPANEL
:
3806 // Фон или передний план без текстуры - ошибка:
3807 if (lbPanelType
.ItemIndex
in [1, 2]) and
3808 (lbTextureList
.ItemIndex
= -1) then
3809 ErrorMessageBox(MsgMsgChooseTexture
)
3810 else // Назначаем параметры панели:
3812 case lbPanelType
.ItemIndex
of
3813 0: Panel
.PanelType
:= PANEL_WALL
;
3814 1: Panel
.PanelType
:= PANEL_BACK
;
3815 2: Panel
.PanelType
:= PANEL_FORE
;
3816 3: Panel
.PanelType
:= PANEL_OPENDOOR
;
3817 4: Panel
.PanelType
:= PANEL_CLOSEDOOR
;
3818 5: Panel
.PanelType
:= PANEL_STEP
;
3819 6: Panel
.PanelType
:= PANEL_WATER
;
3820 7: Panel
.PanelType
:= PANEL_ACID1
;
3821 8: Panel
.PanelType
:= PANEL_ACID2
;
3822 9: Panel
.PanelType
:= PANEL_LIFTUP
;
3823 10: Panel
.PanelType
:= PANEL_LIFTDOWN
;
3824 11: Panel
.PanelType
:= PANEL_LIFTLEFT
;
3825 12: Panel
.PanelType
:= PANEL_LIFTRIGHT
;
3826 13: Panel
.PanelType
:= PANEL_BLOCKMON
;
3829 Panel
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3830 Panel
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3831 if ssCtrl
in Shift
then
3835 if (lbTextureList
.ItemIndex
<> -1) and
3836 (not IsSpecialTextureSel()) then
3838 if not g_GetTexture(SelectedTexture(), TextureID
) then
3839 g_GetTexture('NOTEXTURE', TextureID
);
3840 g_GetTextureSizeByID(TextureID
, wWidth
, wHeight
);
3842 Panel
.Width
:= wWidth
;
3843 Panel
.Height
:= wHeight
;
3847 Panel
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3848 Panel
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3851 // Лифты, блокМон или отсутствие текстуры - пустая текстура:
3852 if (lbPanelType
.ItemIndex
in [9, 10, 11, 12, 13]) or
3853 (lbTextureList
.ItemIndex
= -1) then
3855 Panel
.TextureHeight
:= 1;
3856 Panel
.TextureWidth
:= 1;
3857 Panel
.TextureName
:= '';
3858 Panel
.TextureID
:= TEXTURE_SPECIAL_NONE
;
3860 else // Есть текстура:
3862 Panel
.TextureName
:= SelectedTexture();
3864 // Обычная текстура:
3865 if not IsSpecialTextureSel() then
3867 g_GetTextureSizeByName(Panel
.TextureName
,
3868 Panel
.TextureWidth
, Panel
.TextureHeight
);
3869 g_GetTexture(Panel
.TextureName
, Panel
.TextureID
);
3871 else // Спец.текстура:
3873 Panel
.TextureHeight
:= 1;
3874 Panel
.TextureWidth
:= 1;
3875 Panel
.TextureID
:= SpecialTextureID(SelectedTexture());
3880 Panel
.Blending
:= False;
3882 Undo_Add(OBJECT_PANEL
, AddPanel(Panel
));
3886 // Рисовали триггер:
3887 MOUSEACTION_DRAWTRIGGER
:
3889 trigger
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3890 trigger
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3891 if ssCtrl
in Shift
then
3895 trigger
.Width
:= wWidth
;
3896 trigger
.Height
:= wHeight
;
3900 trigger
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3901 trigger
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3904 trigger
.Enabled
:= True;
3905 trigger
.TriggerType
:= lbTriggersList
.ItemIndex
+1;
3906 trigger
.TexturePanel
:= -1;
3909 trigger
.ActivateType
:= 0;
3911 if clbActivationType
.Checked
[0] then
3912 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERCOLLIDE
;
3913 if clbActivationType
.Checked
[1] then
3914 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERCOLLIDE
;
3915 if clbActivationType
.Checked
[2] then
3916 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERPRESS
;
3917 if clbActivationType
.Checked
[3] then
3918 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERPRESS
;
3919 if clbActivationType
.Checked
[4] then
3920 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_SHOT
;
3921 if clbActivationType
.Checked
[5] then
3922 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_NOMONSTER
;
3924 // Необходимые для активации ключи:
3927 if clbKeys
.Checked
[0] then
3928 trigger
.Key
:= Trigger
.Key
or KEY_RED
;
3929 if clbKeys
.Checked
[1] then
3930 trigger
.Key
:= Trigger
.Key
or KEY_GREEN
;
3931 if clbKeys
.Checked
[2] then
3932 trigger
.Key
:= Trigger
.Key
or KEY_BLUE
;
3933 if clbKeys
.Checked
[3] then
3934 trigger
.Key
:= Trigger
.Key
or KEY_REDTEAM
;
3935 if clbKeys
.Checked
[4] then
3936 trigger
.Key
:= Trigger
.Key
or KEY_BLUETEAM
;
3938 // Параметры триггера:
3939 FillByte(trigger
.Data
.Default
[0], 128, 0);
3941 case trigger
.TriggerType
of
3942 // Переключаемая панель:
3943 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
3944 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
3945 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
3947 Trigger
.Data
.PanelID
:= -1;
3953 trigger
.Data
.TargetPoint
.X
:= trigger
.X
-64;
3954 trigger
.Data
.TargetPoint
.Y
:= trigger
.Y
-64;
3955 trigger
.Data
.d2d_teleport
:= True;
3956 trigger
.Data
.TlpDir
:= 0;
3959 // Изменение других триггеров:
3960 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
3963 trigger
.Data
.Count
:= 1;
3969 trigger
.Data
.Volume
:= 255;
3970 trigger
.Data
.Pan
:= 127;
3971 trigger
.Data
.PlayCount
:= 1;
3972 trigger
.Data
.Local
:= True;
3973 trigger
.Data
.SoundSwitch
:= False;
3979 trigger
.Data
.MusicAction
:= 1;
3982 // Создание монстра:
3983 TRIGGER_SPAWNMONSTER
:
3985 trigger
.Data
.MonType
:= MONSTER_ZOMBY
;
3986 trigger
.Data
.MonPos
.X
:= trigger
.X
-64;
3987 trigger
.Data
.MonPos
.Y
:= trigger
.Y
-64;
3988 trigger
.Data
.MonHealth
:= 0;
3989 trigger
.Data
.MonActive
:= False;
3990 trigger
.Data
.MonCount
:= 1;
3993 // Создание предмета:
3996 trigger
.Data
.ItemType
:= ITEM_AMMO_BULLETS
;
3997 trigger
.Data
.ItemPos
.X
:= trigger
.X
-64;
3998 trigger
.Data
.ItemPos
.Y
:= trigger
.Y
-64;
3999 trigger
.Data
.ItemOnlyDM
:= False;
4000 trigger
.Data
.ItemFalls
:= False;
4001 trigger
.Data
.ItemCount
:= 1;
4002 trigger
.Data
.ItemMax
:= 0;
4003 trigger
.Data
.ItemDelay
:= 0;
4009 trigger
.Data
.PushAngle
:= 90;
4010 trigger
.Data
.PushForce
:= 10;
4011 trigger
.Data
.ResetVel
:= True;
4016 trigger
.Data
.ScoreCount
:= 1;
4017 trigger
.Data
.ScoreCon
:= True;
4018 trigger
.Data
.ScoreMsg
:= True;
4023 trigger
.Data
.MessageKind
:= 0;
4024 trigger
.Data
.MessageSendTo
:= 0;
4025 trigger
.Data
.MessageText
:= '';
4026 trigger
.Data
.MessageTime
:= 144;
4031 trigger
.Data
.DamageValue
:= 5;
4032 trigger
.Data
.DamageInterval
:= 12;
4037 trigger
.Data
.HealValue
:= 5;
4038 trigger
.Data
.HealInterval
:= 36;
4043 trigger
.Data
.ShotType
:= TRIGGER_SHOT_BULLET
;
4044 trigger
.Data
.ShotSound
:= True;
4045 trigger
.Data
.ShotPanelID
:= -1;
4046 trigger
.Data
.ShotTarget
:= 0;
4047 trigger
.Data
.ShotIntSight
:= 0;
4048 trigger
.Data
.ShotAim
:= TRIGGER_SHOT_AIM_DEFAULT
;
4049 trigger
.Data
.ShotPos
.X
:= trigger
.X
-64;
4050 trigger
.Data
.ShotPos
.Y
:= trigger
.Y
-64;
4051 trigger
.Data
.ShotAngle
:= 0;
4052 trigger
.Data
.ShotWait
:= 18;
4053 trigger
.Data
.ShotAccuracy
:= 0;
4054 trigger
.Data
.ShotAmmo
:= 0;
4055 trigger
.Data
.ShotIntReload
:= 0;
4060 trigger
.Data
.FXCount
:= 1;
4061 trigger
.Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
4062 trigger
.Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
4063 trigger
.Data
.FXColorR
:= 0;
4064 trigger
.Data
.FXColorG
:= 0;
4065 trigger
.Data
.FXColorB
:= 255;
4066 trigger
.Data
.FXPos
:= TRIGGER_EFFECT_POS_CENTER
;
4067 trigger
.Data
.FXWait
:= 1;
4068 trigger
.Data
.FXVelX
:= 0;
4069 trigger
.Data
.FXVelY
:= -20;
4070 trigger
.Data
.FXSpreadL
:= 5;
4071 trigger
.Data
.FXSpreadR
:= 5;
4072 trigger
.Data
.FXSpreadU
:= 4;
4073 trigger
.Data
.FXSpreadD
:= 0;
4077 Undo_Add(OBJECT_TRIGGER
, AddTrigger(trigger
));
4080 // Рисовали область триггера "Расширитель":
4081 MOUSEACTION_DRAWPRESS
:
4082 with gTriggers
[SelectedObjects
[GetFirstSelected
].ID
] do
4084 Data
.tX
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
4085 Data
.tY
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
4086 Data
.tWidth
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
4087 Data
.tHeight
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
4089 DrawPressRect
:= False;
4093 MouseAction
:= MOUSEACTION_NONE
;
4095 end // if Button = mbLeft...
4096 else if Button
= mbRight
then // Right Mouse Button:
4098 if MouseAction
= MOUSEACTION_NOACTION
then
4100 MouseAction
:= MOUSEACTION_NONE
;
4104 // Объект передвинут или изменен в размере:
4105 if MouseAction
in [MOUSEACTION_MOVEOBJ
, MOUSEACTION_RESIZE
] then
4107 RenderPanel
.Cursor
:= crDefault
;
4108 MouseAction
:= MOUSEACTION_NONE
;
4113 // Еще не все выбрали:
4114 if SelectFlag
<> SELECTFLAG_NONE
then
4116 if SelectFlag
= SELECTFLAG_SELECTED
then
4117 SelectFlag
:= SELECTFLAG_NONE
;
4122 // Мышь сдвинулась во время удержания клавиши:
4123 if (MousePos
.X
<> MouseRDownPos
.X
) and
4124 (MousePos
.Y
<> MouseRDownPos
.Y
) then
4126 rSelectRect
:= True;
4128 rRect
.X
:= Min(MousePos
.X
, MouseRDownPos
.X
)-MapOffset
.X
;
4129 rRect
.Y
:= Min(MousePos
.Y
, MouseRDownPos
.Y
)-MapOffset
.Y
;
4130 rRect
.Width
:= Abs(MousePos
.X
-MouseRDownPos
.X
);
4131 rRect
.Height
:= Abs(MousePos
.Y
-MouseRDownPos
.Y
);
4133 else // Мышь не сдвинулась - нет прямоугольника:
4135 rSelectRect
:= False;
4137 rRect
.X
:= X
-MapOffset
.X
-1;
4138 rRect
.Y
:= Y
-MapOffset
.Y
-1;
4143 // Если зажат Ctrl - выделять еще, иначе только один выделенный объект:
4144 if not (ssCtrl
in Shift
) then
4145 RemoveSelectFromObjects();
4147 // Выделяем всё в выбранном прямоугольнике:
4148 if (ssCtrl
in Shift
) and (ssAlt
in Shift
) then
4150 SelectObjects(OBJECT_PANEL
);
4151 SelectObjects(OBJECT_ITEM
);
4152 SelectObjects(OBJECT_MONSTER
);
4153 SelectObjects(OBJECT_AREA
);
4154 SelectObjects(OBJECT_TRIGGER
);
4157 SelectObjects(pcObjects
.ActivePageIndex
+1);
4162 else // Middle Mouse Button
4164 RenderPanel
.Cursor
:= crDefault
;
4169 procedure TMainForm
.RenderPanelPaint(Sender
: TObject
);
4174 function TMainForm
.RenderMousePos(): Types
.TPoint
;
4176 Result
:= RenderPanel
.ScreenToClient(Mouse
.CursorPos
);
4179 procedure TMainForm
.RecountSelectedObjects();
4181 if SelectedObjectCount() = 0 then
4182 StatusBar
.Panels
[0].Text := ''
4184 StatusBar
.Panels
[0].Text := Format(MsgCapStatSelected
, [SelectedObjectCount()]);
4187 procedure TMainForm
.RenderPanelMouseMove(Sender
: TObject
;
4188 Shift
: TShiftState
; X
, Y
: Integer);
4191 dWidth
, dHeight
: Integer;
4194 wWidth
, wHeight
: Word;
4196 _id
:= GetFirstSelected();
4199 // Рисуем панель с текстурой, сетка - размеры текстуры:
4200 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and
4201 (lbPanelType
.ItemIndex
in [0..8]) and
4202 (lbTextureList
.ItemIndex
<> -1) and
4203 (not IsSpecialTextureSel()) then
4205 sX
:= StrToIntDef(lTextureWidth
.Caption
, DotStep
);
4206 sY
:= StrToIntDef(lTextureHeight
.Caption
, DotStep
);
4209 // Меняем размер панели с текстурой, сетка - размеры текстуры:
4210 if (MouseAction
= MOUSEACTION_RESIZE
) and
4211 ( (SelectedObjects
[_id
].ObjectType
= OBJECT_PANEL
) and
4212 IsTexturedPanel(gPanels
[SelectedObjects
[_id
].ID
].PanelType
) and
4213 (gPanels
[SelectedObjects
[_id
].ID
].TextureName
<> '') and
4214 (not IsSpecialTexture(gPanels
[SelectedObjects
[_id
].ID
].TextureName
)) ) then
4216 sX
:= gPanels
[SelectedObjects
[_id
].ID
].TextureWidth
;
4217 sY
:= gPanels
[SelectedObjects
[_id
].ID
].TextureHeight
;
4220 // Выравнивание по сетке:
4226 else // Нет выравнивания по сетке:
4232 // Новая позиция мыши:
4234 begin // Зажата левая кнопка мыши
4235 MousePos
.X
:= (Round((X
-MouseLDownPos
.X
)/sX
)*sX
)+MouseLDownPos
.X
;
4236 MousePos
.Y
:= (Round((Y
-MouseLDownPos
.Y
)/sY
)*sY
)+MouseLDownPos
.Y
;
4240 begin // Зажата правая кнопка мыши
4241 MousePos
.X
:= (Round((X
-MouseRDownPos
.X
)/sX
)*sX
)+MouseRDownPos
.X
;
4242 MousePos
.Y
:= (Round((Y
-MouseRDownPos
.Y
)/sY
)*sY
)+MouseRDownPos
.Y
;
4245 begin // Кнопки мыши не зажаты
4246 MousePos
.X
:= Round((-MapOffset
.X
+ X
) / sX
) * sX
+ MapOffset
.X
;
4247 MousePos
.Y
:= Round((-MapOffset
.Y
+ Y
) / sY
) * sY
+ MapOffset
.Y
;
4250 // Зажата только правая кнопка мыши:
4251 if (not MouseLDown
) and (MouseRDown
) and (not MouseMDown
) then
4253 // Рисуем прямоугольник выделения:
4254 if MouseAction
= MOUSEACTION_NONE
then
4256 if DrawRect
= nil then
4258 DrawRect
.Top
:= MouseRDownPos
.y
;
4259 DrawRect
.Left
:= MouseRDownPos
.x
;
4260 DrawRect
.Bottom
:= MousePos
.y
;
4261 DrawRect
.Right
:= MousePos
.x
;
4264 // Двигаем выделенные объекты:
4265 if MouseAction
= MOUSEACTION_MOVEOBJ
then
4267 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
,
4268 MousePos
.X
-LastMovePoint
.X
,
4269 MousePos
.Y
-LastMovePoint
.Y
);
4272 // Меняем размер выделенного объекта:
4273 if MouseAction
= MOUSEACTION_RESIZE
then
4275 if (SelectedObjectCount
= 1) and
4276 (SelectedObjects
[GetFirstSelected
].Live
) then
4278 dWidth
:= MousePos
.X
-LastMovePoint
.X
;
4279 dHeight
:= MousePos
.Y
-LastMovePoint
.Y
;
4282 RESIZETYPE_VERTICAL
: dWidth
:= 0;
4283 RESIZETYPE_HORIZONTAL
: dHeight
:= 0;
4286 case ResizeDirection
of
4287 RESIZEDIR_UP
: dHeight
:= -dHeight
;
4288 RESIZEDIR_LEFT
: dWidth
:= -dWidth
;
4291 if ResizeObject(SelectedObjects
[GetFirstSelected
].ObjectType
,
4292 SelectedObjects
[GetFirstSelected
].ID
,
4293 dWidth
, dHeight
, ResizeDirection
) then
4294 LastMovePoint
:= MousePos
;
4299 // Зажата только левая кнопка мыши:
4300 if (not MouseRDown
) and (MouseLDown
) and (not MouseMDown
) then
4302 // Рисуем прямоугольник планирования панели:
4303 if MouseAction
in [MOUSEACTION_DRAWPANEL
,
4304 MOUSEACTION_DRAWTRIGGER
,
4305 MOUSEACTION_DRAWPRESS
] then
4307 if DrawRect
= nil then
4309 if ssCtrl
in Shift
then
4313 if (lbTextureList
.ItemIndex
<> -1) and (not IsSpecialTextureSel()) and
4314 (MouseAction
= MOUSEACTION_DRAWPANEL
) then
4316 if not g_GetTexture(SelectedTexture(), TextureID
) then
4317 g_GetTexture('NOTEXTURE', TextureID
);
4318 g_GetTextureSizeByID(TextureID
, wWidth
, wHeight
);
4320 DrawRect
.Top
:= MouseLDownPos
.y
;
4321 DrawRect
.Left
:= MouseLDownPos
.x
;
4322 DrawRect
.Bottom
:= DrawRect
.Top
+ wHeight
;
4323 DrawRect
.Right
:= DrawRect
.Left
+ wWidth
;
4327 DrawRect
.Top
:= MouseLDownPos
.y
;
4328 DrawRect
.Left
:= MouseLDownPos
.x
;
4329 DrawRect
.Bottom
:= MousePos
.y
;
4330 DrawRect
.Right
:= MousePos
.x
;
4333 else // Двигаем карту:
4334 if MouseAction
= MOUSEACTION_MOVEMAP
then
4340 // Only Middle Mouse Button is pressed
4341 if (not MouseLDown
) and (not MouseRDown
) and (MouseMDown
) then
4343 MapOffset
.X
:= -EnsureRange(-MapOffset
.X
+ MouseMDownPos
.X
- Mouse
.CursorPos
.X
,
4344 sbHorizontal
.Min
, sbHorizontal
.Max
);
4345 sbHorizontal
.Position
:= -MapOffset
.X
;
4346 MapOffset
.Y
:= -EnsureRange(-MapOffset
.Y
+ MouseMDownPos
.Y
- Mouse
.CursorPos
.Y
,
4347 sbVertical
.Min
, sbVertical
.Max
);
4348 sbVertical
.Position
:= -MapOffset
.Y
;
4349 MouseMDownPos
:= Mouse
.CursorPos
;
4352 // Клавиши мыши не зажаты:
4353 if (not MouseRDown
) and (not MouseLDown
) and (DrawRect
<> nil) then
4359 // Строка состояния - координаты мыши:
4360 StatusBar
.Panels
[1].Text := Format('(%d:%d)',
4361 [MousePos
.X
-MapOffset
.X
, MousePos
.Y
-MapOffset
.Y
]);
4363 RenderPanel
.Invalidate
;
4366 procedure TMainForm
.FormCloseQuery(Sender
: TObject
; var CanClose
: Boolean);
4368 CanClose
:= Application
.MessageBox(PChar(MsgMsgExitPrompt
),
4370 MB_ICONQUESTION
or MB_YESNO
or
4371 MB_DEFBUTTON1
) = idYes
;
4374 procedure TMainForm
.aExitExecute(Sender
: TObject
);
4379 procedure TMainForm
.FormDestroy(Sender
: TObject
);
4385 config
:= TConfig
.CreateFile(CfgFileName
);
4387 config
.WriteInt('WADEditor', 'LogLevel', gWADEditorLogLevel
);
4389 if WindowState
<> wsMaximized
then
4391 config
.WriteInt('Editor', 'XPos', Left
);
4392 config
.WriteInt('Editor', 'YPos', Top
);
4393 config
.WriteInt('Editor', 'Width', Width
);
4394 config
.WriteInt('Editor', 'Height', Height
);
4398 config
.WriteInt('Editor', 'XPos', RestoredLeft
);
4399 config
.WriteInt('Editor', 'YPos', RestoredTop
);
4400 config
.WriteInt('Editor', 'Width', RestoredWidth
);
4401 config
.WriteInt('Editor', 'Height', RestoredHeight
);
4403 config
.WriteBool('Editor', 'Maximize', WindowState
= wsMaximized
);
4404 config
.WriteBool('Editor', 'Minimap', ShowMap
);
4405 config
.WriteInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
4406 config
.WriteInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
4407 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
4408 config
.WriteInt('Editor', 'DotStep', DotStep
);
4409 config
.WriteStr('Editor', 'LastOpenDir', OpenDialog
.InitialDir
);
4410 config
.WriteStr('Editor', 'LastSaveDir', SaveDialog
.InitialDir
);
4411 config
.WriteStr('Editor', 'Language', gLanguage
);
4412 config
.WriteBool('Editor', 'EdgeShow', drEdge
[3] < 255);
4413 config
.WriteInt('Editor', 'EdgeColor', gColorEdge
);
4414 config
.WriteInt('Editor', 'EdgeAlpha', gAlphaEdge
);
4415 config
.WriteInt('Editor', 'LineAlpha', gAlphaTriggerLine
);
4416 config
.WriteInt('Editor', 'TriggerAlpha', gAlphaTriggerArea
);
4417 config
.WriteInt('Editor', 'MonsterRectAlpha', gAlphaMonsterRect
);
4418 config
.WriteInt('Editor', 'AreaRectAlpha', gAlphaAreaRect
);
4420 for i
:= 0 to RecentCount
- 1 do
4422 if i
< RecentFiles
.Count
then s
:= RecentFiles
[i
] else s
:= '';
4424 config
.WriteStr('RecentFilesWin', IntToStr(i
), s
);
4426 config
.WriteStr('RecentFilesUnix', IntToStr(i
), s
);
4431 config
.SaveFile(CfgFileName
);
4434 slInvalidTextures
.Free
;
4437 procedure TMainForm
.FormDropFiles(Sender
: TObject
;
4438 const FileNames
: array of String);
4440 if Length(FileNames
) <> 1 then
4443 OpenMapFile(FileNames
[0]);
4446 procedure TMainForm
.RenderPanelResize(Sender
: TObject
);
4448 if MainForm
.Visible
then
4452 procedure TMainForm
.Splitter1Moved(Sender
: TObject
);
4457 procedure TMainForm
.MapTestCheck(Sender
: TObject
);
4459 if MapTestProcess
<> nil then
4461 if MapTestProcess
.Running
= false then
4463 if MapTestProcess
.ExitCode
<> 0 then
4464 Application
.MessageBox(PChar(MsgMsgExecError
), 'FIXME', MB_OK
or MB_ICONERROR
);
4465 SysUtils
.DeleteFile(MapTestFile
);
4467 FreeAndNil(MapTestProcess
);
4468 tbTestMap
.Enabled
:= True;
4473 procedure TMainForm
.aMapOptionsExecute(Sender
: TObject
);
4477 MapOptionsForm
.ShowModal();
4479 ResName
:= OpenedMap
;
4480 while (Pos(':\', ResName
) > 0) do
4481 Delete(ResName
, 1, Pos(':\', ResName
) + 1);
4483 UpdateCaption(gMapInfo
.Name
, ExtractFileName(OpenedWAD
), ResName
);
4486 procedure TMainForm
.aAboutExecute(Sender
: TObject
);
4488 AboutForm
.ShowModal();
4491 procedure TMainForm
.FormKeyDown(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
4497 if (not EditingProperties
) then
4499 if ssCtrl
in Shift
then
4502 '1': ContourEnabled
[LAYER_BACK
] := not ContourEnabled
[LAYER_BACK
];
4503 '2': ContourEnabled
[LAYER_WALLS
] := not ContourEnabled
[LAYER_WALLS
];
4504 '3': ContourEnabled
[LAYER_FOREGROUND
] := not ContourEnabled
[LAYER_FOREGROUND
];
4505 '4': ContourEnabled
[LAYER_STEPS
] := not ContourEnabled
[LAYER_STEPS
];
4506 '5': ContourEnabled
[LAYER_WATER
] := not ContourEnabled
[LAYER_WATER
];
4507 '6': ContourEnabled
[LAYER_ITEMS
] := not ContourEnabled
[LAYER_ITEMS
];
4508 '7': ContourEnabled
[LAYER_MONSTERS
] := not ContourEnabled
[LAYER_MONSTERS
];
4509 '8': ContourEnabled
[LAYER_AREAS
] := not ContourEnabled
[LAYER_AREAS
];
4510 '9': ContourEnabled
[LAYER_TRIGGERS
] := not ContourEnabled
[LAYER_TRIGGERS
];
4514 for i
:= Low(ContourEnabled
) to High(ContourEnabled
) do
4515 if ContourEnabled
[i
] then
4517 for i
:= Low(ContourEnabled
) to High(ContourEnabled
) do
4518 ContourEnabled
[i
] := not ok
4525 '1': SwitchLayer(LAYER_BACK
);
4526 '2': SwitchLayer(LAYER_WALLS
);
4527 '3': SwitchLayer(LAYER_FOREGROUND
);
4528 '4': SwitchLayer(LAYER_STEPS
);
4529 '5': SwitchLayer(LAYER_WATER
);
4530 '6': SwitchLayer(LAYER_ITEMS
);
4531 '7': SwitchLayer(LAYER_MONSTERS
);
4532 '8': SwitchLayer(LAYER_AREAS
);
4533 '9': SwitchLayer(LAYER_TRIGGERS
);
4534 '0': tbShowClick(tbShow
);
4538 if Key
= Ord('I') then
4539 begin // Поворот монстров и областей:
4540 if (SelectedObjects
<> nil) then
4542 for i
:= 0 to High(SelectedObjects
) do
4543 if (SelectedObjects
[i
].Live
) then
4545 if (SelectedObjects
[i
].ObjectType
= OBJECT_MONSTER
) then
4547 g_ChangeDir(gMonsters
[SelectedObjects
[i
].ID
].Direction
);
4550 if (SelectedObjects
[i
].ObjectType
= OBJECT_AREA
) then
4552 g_ChangeDir(gAreas
[SelectedObjects
[i
].ID
].Direction
);
4558 if pcObjects
.ActivePage
= tsMonsters
then
4560 if rbMonsterLeft
.Checked
then
4561 rbMonsterRight
.Checked
:= True
4563 rbMonsterLeft
.Checked
:= True;
4565 if pcObjects
.ActivePage
= tsAreas
then
4567 if rbAreaLeft
.Checked
then
4568 rbAreaRight
.Checked
:= True
4570 rbAreaLeft
.Checked
:= True;
4575 if not (ssCtrl
in Shift
) then
4577 // Быстрое превью карты:
4578 if Key
= Ord('E') then
4580 if PreviewMode
= 0 then
4584 // Вертикальный скролл карты:
4587 if Key
= Ord('W') then
4590 if ssShift
in Shift
then Position
:= EnsureRange(Position
- DotStep
* 4, Min
, Max
)
4591 else Position
:= EnsureRange(Position
- DotStep
, Min
, Max
);
4592 MapOffset
.Y
:= -Position
;
4595 if (MouseLDown
or MouseRDown
) then
4597 if DrawRect
<> nil then
4599 Inc(MouseLDownPos
.y
, dy
);
4600 Inc(MouseRDownPos
.y
, dy
);
4602 Inc(LastMovePoint
.Y
, dy
);
4603 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4607 if Key
= Ord('S') then
4610 if ssShift
in Shift
then Position
:= EnsureRange(Position
+ DotStep
* 4, Min
, Max
)
4611 else Position
:= EnsureRange(Position
+ DotStep
, Min
, Max
);
4612 MapOffset
.Y
:= -Position
;
4615 if (MouseLDown
or MouseRDown
) then
4617 if DrawRect
<> nil then
4619 Inc(MouseLDownPos
.y
, dy
);
4620 Inc(MouseRDownPos
.y
, dy
);
4622 Inc(LastMovePoint
.Y
, dy
);
4623 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4628 // Горизонтальный скролл карты:
4629 with sbHorizontal
do
4631 if Key
= Ord('A') then
4634 if ssShift
in Shift
then Position
:= EnsureRange(Position
- DotStep
* 4, Min
, Max
)
4635 else Position
:= EnsureRange(Position
- DotStep
, Min
, Max
);
4636 MapOffset
.X
:= -Position
;
4639 if (MouseLDown
or MouseRDown
) then
4641 if DrawRect
<> nil then
4643 Inc(MouseLDownPos
.x
, dx
);
4644 Inc(MouseRDownPos
.x
, dx
);
4646 Inc(LastMovePoint
.X
, dx
);
4647 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4651 if Key
= Ord('D') then
4654 if ssShift
in Shift
then Position
:= EnsureRange(Position
+ DotStep
* 4, Min
, Max
)
4655 else Position
:= EnsureRange(Position
+ DotStep
, Min
, Max
);
4656 MapOffset
.X
:= -Position
;
4659 if (MouseLDown
or MouseRDown
) then
4661 if DrawRect
<> nil then
4663 Inc(MouseLDownPos
.x
, dx
);
4664 Inc(MouseRDownPos
.x
, dx
);
4666 Inc(LastMovePoint
.X
, dx
);
4667 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4672 else // ssCtrl in Shift
4674 if ssShift
in Shift
then
4676 // Вставка по абсолютному смещению:
4677 if Key
= Ord('V') then
4678 aPasteObjectExecute(Sender
);
4680 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4684 // Удалить выделенные объекты:
4685 if (Key
= VK_DELETE
) and (SelectedObjects
<> nil) and
4686 RenderPanel
.Focused() then
4687 DeleteSelectedObjects();
4690 if (Key
= VK_ESCAPE
) and (SelectedObjects
<> nil) then
4691 RemoveSelectFromObjects();
4693 // Передвинуть объекты:
4694 if MainForm
.ActiveControl
= RenderPanel
then
4699 if Key
= VK_NUMPAD4
then
4700 dx
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4701 if Key
= VK_NUMPAD6
then
4702 dx
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4703 if Key
= VK_NUMPAD8
then
4704 dy
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4705 if Key
= VK_NUMPAD5
then
4706 dy
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4708 if (dx
<> 0) or (dy
<> 0) then
4710 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
, dx
, dy
);
4715 if ssCtrl
in Shift
then
4717 // Выбор панели с текстурой для триггера
4718 if Key
= Ord('T') then
4720 DrawPressRect
:= False;
4721 if SelectFlag
= SELECTFLAG_TEXTURE
then
4723 SelectFlag
:= SELECTFLAG_NONE
;
4726 vleObjectProperty
.FindRow(MsgPropTrTexturePanel
, i
);
4728 SelectFlag
:= SELECTFLAG_TEXTURE
;
4731 if Key
= Ord('D') then
4733 SelectFlag
:= SELECTFLAG_NONE
;
4734 if DrawPressRect
then
4736 DrawPressRect
:= False;
4741 // Выбор области воздействия, в зависимости от типа триггера
4742 vleObjectProperty
.FindRow(MsgPropTrExArea
, i
);
4745 DrawPressRect
:= True;
4748 vleObjectProperty
.FindRow(MsgPropTrDoorPanel
, i
);
4750 vleObjectProperty
.FindRow(MsgPropTrTrapPanel
, i
);
4753 SelectFlag
:= SELECTFLAG_DOOR
;
4756 vleObjectProperty
.FindRow(MsgPropTrLiftPanel
, i
);
4759 SelectFlag
:= SELECTFLAG_LIFT
;
4762 vleObjectProperty
.FindRow(MsgPropTrTeleportTo
, i
);
4765 SelectFlag
:= SELECTFLAG_TELEPORT
;
4768 vleObjectProperty
.FindRow(MsgPropTrSpawnTo
, i
);
4771 SelectFlag
:= SELECTFLAG_SPAWNPOINT
;
4775 // Выбор основного параметра, в зависимости от типа триггера
4776 vleObjectProperty
.FindRow(MsgPropTrNextMap
, i
);
4779 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
4780 SelectMapForm
.Caption
:= MsgCapSelect
;
4781 SelectMapForm
.GetMaps(FileName
);
4783 if SelectMapForm
.ShowModal() = mrOK
then
4785 vleObjectProperty
.Cells
[1, i
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
4786 bApplyProperty
.Click();
4790 vleObjectProperty
.FindRow(MsgPropTrSoundName
, i
);
4792 vleObjectProperty
.FindRow(MsgPropTrMusicName
, i
);
4795 AddSoundForm
.OKFunction
:= nil;
4796 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
4797 AddSoundForm
.SetResource
:= vleObjectProperty
.Cells
[1, i
];
4799 if (AddSoundForm
.ShowModal() = mrOk
) then
4801 vleObjectProperty
.Cells
[1, i
] := AddSoundForm
.ResourceName
;
4802 bApplyProperty
.Click();
4806 vleObjectProperty
.FindRow(MsgPropTrPushAngle
, i
);
4808 vleObjectProperty
.FindRow(MsgPropTrMessageText
, i
);
4811 vleObjectProperty
.Row
:= i
;
4812 vleObjectProperty
.SetFocus();
4819 procedure TMainForm
.aOptimizeExecute(Sender
: TObject
);
4821 RemoveSelectFromObjects();
4822 MapOptimizationForm
.ShowModal();
4825 procedure TMainForm
.aCheckMapExecute(Sender
: TObject
);
4827 MapCheckForm
.ShowModal();
4830 procedure TMainForm
.bbAddTextureClick(Sender
: TObject
);
4832 AddTextureForm
.lbResourcesList
.MultiSelect
:= True;
4833 AddTextureForm
.ShowModal();
4836 procedure TMainForm
.lbTextureListClick(Sender
: TObject
);
4839 TextureWidth
, TextureHeight
: Word;
4844 if (lbTextureList
.ItemIndex
<> -1) and
4845 (not IsSpecialTextureSel()) then
4847 if g_GetTexture(SelectedTexture(), TextureID
) then
4849 g_GetTextureSizeByID(TextureID
, TextureWidth
, TextureHeight
);
4851 lTextureWidth
.Caption
:= IntToStr(TextureWidth
);
4852 lTextureHeight
.Caption
:= IntToStr(TextureHeight
);
4855 lTextureWidth
.Caption
:= MsgNotAccessible
;
4856 lTextureHeight
.Caption
:= MsgNotAccessible
;
4861 lTextureWidth
.Caption
:= '';
4862 lTextureHeight
.Caption
:= '';
4866 procedure TMainForm
.lbTextureListDrawItem(Control
: TWinControl
; Index
: Integer;
4867 ARect
: TRect
; State
: TOwnerDrawState
);
4869 with Control
as TListBox
do
4871 if LCLType
.odSelected
in State
then
4873 Canvas
.Brush
.Color
:= clHighlight
;
4874 Canvas
.Font
.Color
:= clHighlightText
;
4876 if (Items
<> nil) and (Index
>= 0) then
4877 if slInvalidTextures
.IndexOf(Items
[Index
]) > -1 then
4879 Canvas
.Brush
.Color
:= clRed
;
4880 Canvas
.Font
.Color
:= clWhite
;
4882 Canvas
.FillRect(ARect
);
4883 Canvas
.TextRect(ARect
, ARect
.Left
, ARect
.Top
, Items
[Index
]);
4887 procedure TMainForm
.miMacMinimizeClick(Sender
: TObject
);
4889 self
.WindowState
:= wsMinimized
;
4890 self
.FormWindowStateChange(Sender
);
4893 procedure TMainForm
.miMacZoomClick(Sender
: TObject
);
4895 if self
.WindowState
= wsMaximized
then
4896 self
.WindowState
:= wsNormal
4898 self
.WindowState
:= wsMaximized
;
4899 self
.FormWindowStateChange(Sender
);
4902 procedure TMainForm
.miReopenMapClick(Sender
: TObject
);
4904 FileName
, Resource
: String;
4906 if OpenedMap
= '' then
4909 if Application
.MessageBox(PChar(MsgMsgReopenMapPrompt
),
4910 PChar(MsgMenuFileReopen
), MB_ICONQUESTION
or MB_YESNO
) <> idYes
then
4913 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, @Resource
);
4914 OpenMap(FileName
, Resource
);
4917 procedure TMainForm
.vleObjectPropertyGetPickList(Sender
: TObject
;
4918 const KeyName
: String; Values
: TStrings
);
4920 if vleObjectProperty
.ItemProps
[KeyName
].EditStyle
= esPickList
then
4922 if KeyName
= MsgPropDirection
then
4924 Values
.Add(DirNames
[D_LEFT
]);
4925 Values
.Add(DirNames
[D_RIGHT
]);
4927 else if KeyName
= MsgPropTrTeleportDir
then
4929 Values
.Add(DirNamesAdv
[0]);
4930 Values
.Add(DirNamesAdv
[1]);
4931 Values
.Add(DirNamesAdv
[2]);
4932 Values
.Add(DirNamesAdv
[3]);
4934 else if KeyName
= MsgPropTrMusicAct
then
4936 Values
.Add(MsgPropTrMusicOn
);
4937 Values
.Add(MsgPropTrMusicOff
);
4939 else if KeyName
= MsgPropTrMonsterBehaviour
then
4941 Values
.Add(MsgPropTrMonsterBehaviour0
);
4942 Values
.Add(MsgPropTrMonsterBehaviour1
);
4943 Values
.Add(MsgPropTrMonsterBehaviour2
);
4944 Values
.Add(MsgPropTrMonsterBehaviour3
);
4945 Values
.Add(MsgPropTrMonsterBehaviour4
);
4946 Values
.Add(MsgPropTrMonsterBehaviour5
);
4948 else if KeyName
= MsgPropTrScoreAct
then
4950 Values
.Add(MsgPropTrScoreAct0
);
4951 Values
.Add(MsgPropTrScoreAct1
);
4952 Values
.Add(MsgPropTrScoreAct2
);
4953 Values
.Add(MsgPropTrScoreAct3
);
4955 else if KeyName
= MsgPropTrScoreTeam
then
4957 Values
.Add(MsgPropTrScoreTeam0
);
4958 Values
.Add(MsgPropTrScoreTeam1
);
4959 Values
.Add(MsgPropTrScoreTeam2
);
4960 Values
.Add(MsgPropTrScoreTeam3
);
4962 else if KeyName
= MsgPropTrMessageKind
then
4964 Values
.Add(MsgPropTrMessageKind0
);
4965 Values
.Add(MsgPropTrMessageKind1
);
4967 else if KeyName
= MsgPropTrMessageTo
then
4969 Values
.Add(MsgPropTrMessageTo0
);
4970 Values
.Add(MsgPropTrMessageTo1
);
4971 Values
.Add(MsgPropTrMessageTo2
);
4972 Values
.Add(MsgPropTrMessageTo3
);
4973 Values
.Add(MsgPropTrMessageTo4
);
4974 Values
.Add(MsgPropTrMessageTo5
);
4976 else if KeyName
= MsgPropTrShotTo
then
4978 Values
.Add(MsgPropTrShotTo0
);
4979 Values
.Add(MsgPropTrShotTo1
);
4980 Values
.Add(MsgPropTrShotTo2
);
4981 Values
.Add(MsgPropTrShotTo3
);
4982 Values
.Add(MsgPropTrShotTo4
);
4983 Values
.Add(MsgPropTrShotTo5
);
4984 Values
.Add(MsgPropTrShotTo6
);
4986 else if KeyName
= MsgPropTrShotAim
then
4988 Values
.Add(MsgPropTrShotAim0
);
4989 Values
.Add(MsgPropTrShotAim1
);
4990 Values
.Add(MsgPropTrShotAim2
);
4991 Values
.Add(MsgPropTrShotAim3
);
4993 else if KeyName
= MsgPropTrDamageKind
then
4995 Values
.Add(MsgPropTrDamageKind0
);
4996 Values
.Add(MsgPropTrDamageKind3
);
4997 Values
.Add(MsgPropTrDamageKind4
);
4998 Values
.Add(MsgPropTrDamageKind5
);
4999 Values
.Add(MsgPropTrDamageKind6
);
5000 Values
.Add(MsgPropTrDamageKind7
);
5001 Values
.Add(MsgPropTrDamageKind8
);
5003 else if (KeyName
= MsgPropPanelBlend
) or
5004 (KeyName
= MsgPropDmOnly
) or
5005 (KeyName
= MsgPropItemFalls
) or
5006 (KeyName
= MsgPropTrEnabled
) or
5007 (KeyName
= MsgPropTrD2d
) or
5008 (KeyName
= MsgPropTrSilent
) or
5009 (KeyName
= MsgPropTrTeleportSilent
) or
5010 (KeyName
= MsgPropTrExRandom
) or
5011 (KeyName
= MsgPropTrTextureOnce
) or
5012 (KeyName
= MsgPropTrTextureAnimOnce
) or
5013 (KeyName
= MsgPropTrSoundLocal
) or
5014 (KeyName
= MsgPropTrSoundSwitch
) or
5015 (KeyName
= MsgPropTrMonsterActive
) or
5016 (KeyName
= MsgPropTrPushReset
) or
5017 (KeyName
= MsgPropTrScoreCon
) or
5018 (KeyName
= MsgPropTrScoreMsg
) or
5019 (KeyName
= MsgPropTrHealthMax
) or
5020 (KeyName
= MsgPropTrShotSound
) or
5021 (KeyName
= MsgPropTrEffectCenter
) then
5023 Values
.Add(BoolNames
[True]);
5024 Values
.Add(BoolNames
[False]);
5029 procedure TMainForm
.bApplyPropertyClick(Sender
: TObject
);
5031 _id
, a
, r
, c
: Integer;
5041 if SelectedObjectCount() <> 1 then
5043 if not SelectedObjects
[GetFirstSelected()].Live
then
5047 if not CheckProperty() then
5053 _id
:= GetFirstSelected();
5055 r
:= vleObjectProperty
.Row
;
5056 c
:= vleObjectProperty
.Col
;
5058 case SelectedObjects
[_id
].ObjectType
of
5061 with gPanels
[SelectedObjects
[_id
].ID
] do
5063 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5064 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5065 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropWidth
]));
5066 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropHeight
]));
5068 PanelType
:= GetPanelType(vleObjectProperty
.Values
[MsgPropPanelType
]);
5070 // Сброс ссылки на триггеры смены текстуры:
5071 if not WordBool(PanelType
and (PANEL_WALL
or PANEL_FORE
or PANEL_BACK
)) then
5072 if gTriggers
<> nil then
5073 for a
:= 0 to High(gTriggers
) do
5075 if (gTriggers
[a
].TriggerType
<> 0) and
5076 (gTriggers
[a
].TexturePanel
= Integer(SelectedObjects
[_id
].ID
)) then
5077 gTriggers
[a
].TexturePanel
:= -1;
5078 if (gTriggers
[a
].TriggerType
= TRIGGER_SHOT
) and
5079 (gTriggers
[a
].Data
.ShotPanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5080 gTriggers
[a
].Data
.ShotPanelID
:= -1;
5083 // Сброс ссылки на триггеры лифта:
5084 if not WordBool(PanelType
and (PANEL_LIFTUP
or PANEL_LIFTDOWN
or PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
)) then
5085 if gTriggers
<> nil then
5086 for a
:= 0 to High(gTriggers
) do
5087 if (gTriggers
[a
].TriggerType
in [TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
]) and
5088 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5089 gTriggers
[a
].Data
.PanelID
:= -1;
5091 // Сброс ссылки на триггеры двери:
5092 if not WordBool(PanelType
and (PANEL_OPENDOOR
or PANEL_CLOSEDOOR
)) then
5093 if gTriggers
<> nil then
5094 for a
:= 0 to High(gTriggers
) do
5095 if (gTriggers
[a
].TriggerType
in [TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5096 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
]) and
5097 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5098 gTriggers
[a
].Data
.PanelID
:= -1;
5100 if IsTexturedPanel(PanelType
) then
5101 begin // Может быть текстура
5102 if TextureName
<> '' then
5103 begin // Была текстура
5104 Alpha
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropPanelAlpha
]));
5105 Blending
:= NameToBool(vleObjectProperty
.Values
[MsgPropPanelBlend
]);
5114 TextureName
:= vleObjectProperty
.Values
[MsgPropPanelTex
];
5116 if TextureName
<> '' then
5117 begin // Есть текстура
5118 // Обычная текстура:
5119 if not IsSpecialTexture(TextureName
) then
5121 g_GetTextureSizeByName(TextureName
,
5122 TextureWidth
, TextureHeight
);
5124 // Проверка кратности размеров панели:
5126 if TextureWidth
<> 0 then
5127 if gPanels
[SelectedObjects
[_id
].ID
].Width
mod TextureWidth
<> 0 then
5129 ErrorMessageBox(Format(MsgMsgWrongTexwidth
,
5133 if Res
and (TextureHeight
<> 0) then
5134 if gPanels
[SelectedObjects
[_id
].ID
].Height
mod TextureHeight
<> 0 then
5136 ErrorMessageBox(Format(MsgMsgWrongTexheight
,
5143 if not g_GetTexture(TextureName
, TextureID
) then
5144 // Не удалось загрузить текстуру, рисуем NOTEXTURE
5145 if g_GetTexture('NOTEXTURE', NoTextureID
) then
5147 TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
5148 g_GetTextureSizeByID(NoTextureID
, NW
, NH
);
5150 TextureHeight
:= NH
;
5153 TextureID
:= TEXTURE_SPECIAL_NONE
;
5163 TextureID
:= TEXTURE_SPECIAL_NONE
;
5166 else // Спец.текстура
5170 TextureID
:= SpecialTextureID(TextureName
);
5173 else // Нет текстуры
5177 TextureID
:= TEXTURE_SPECIAL_NONE
;
5180 else // Не может быть текстуры
5187 TextureID
:= TEXTURE_SPECIAL_NONE
;
5194 with gItems
[SelectedObjects
[_id
].ID
] do
5196 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5197 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5198 OnlyDM
:= NameToBool(vleObjectProperty
.Values
[MsgPropDmOnly
]);
5199 Fall
:= NameToBool(vleObjectProperty
.Values
[MsgPropItemFalls
]);
5205 with gMonsters
[SelectedObjects
[_id
].ID
] do
5207 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5208 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5209 Direction
:= NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]);
5215 with gAreas
[SelectedObjects
[_id
].ID
] do
5217 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5218 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5219 Direction
:= NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]);
5225 with gTriggers
[SelectedObjects
[_id
].ID
] do
5227 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5228 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5229 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropWidth
]));
5230 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropHeight
]));
5231 Enabled
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrEnabled
]);
5232 ActivateType
:= StrToActivate(vleObjectProperty
.Values
[MsgPropTrActivation
]);
5233 Key
:= StrToKey(vleObjectProperty
.Values
[MsgPropTrKeys
]);
5238 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrNextMap
]);
5239 FillByte(Data
.MapName
[0], 16, 0);
5241 Move(s
[1], Data
.MapName
[0], Min(Length(s
), 16));
5246 Data
.ActivateOnce
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTextureOnce
]);
5247 Data
.AnimOnce
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTextureAnimOnce
]);
5250 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
5252 Data
.Wait
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 65535);
5253 Data
.Count
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExCount
], 0), 65535);
5254 if Data
.Count
< 1 then
5256 if TriggerType
= TRIGGER_PRESS
then
5257 Data
.ExtRandom
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrExRandom
]);
5260 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
, TRIGGER_DOOR5
,
5261 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
, TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
,
5264 Data
.NoSound
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSilent
]);
5265 Data
.d2d_doors
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrD2d
]);
5270 Data
.d2d_teleport
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrD2d
]);
5271 Data
.silent_teleport
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTeleportSilent
]);
5272 Data
.TlpDir
:= NameToDirAdv(vleObjectProperty
.Values
[MsgPropTrTeleportDir
]);
5277 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrSoundName
]);
5278 FillByte(Data
.SoundName
[0], 64, 0);
5280 Move(s
[1], Data
.SoundName
[0], Min(Length(s
), 64));
5282 Data
.Volume
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundVolume
], 0), 255);
5283 Data
.Pan
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundPan
], 0), 255);
5284 Data
.PlayCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundCount
], 0), 255);
5285 Data
.Local
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSoundLocal
]);
5286 Data
.SoundSwitch
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSoundSwitch
]);
5289 TRIGGER_SPAWNMONSTER
:
5291 Data
.MonType
:= StrToMonster(vleObjectProperty
.Values
[MsgPropTrMonsterType
]);
5292 Data
.MonDir
:= Byte(NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]));
5293 Data
.MonHealth
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrHealth
], 0), 1000000);
5294 if Data
.MonHealth
< 0 then
5295 Data
.MonHealth
:= 0;
5296 Data
.MonActive
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrMonsterActive
]);
5297 Data
.MonCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 64);
5298 if Data
.MonCount
< 1 then
5300 Data
.MonEffect
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrFxType
]);
5301 Data
.MonMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnMax
], 0), 65535);
5302 Data
.MonDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnDelay
], 0), 65535);
5304 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour1
then
5306 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour2
then
5308 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour3
then
5310 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour4
then
5312 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour5
then
5318 Data
.ItemType
:= StrToItem(vleObjectProperty
.Values
[MsgPropTrItemType
]);
5319 Data
.ItemOnlyDM
:= NameToBool(vleObjectProperty
.Values
[MsgPropDmOnly
]);
5320 Data
.ItemFalls
:= NameToBool(vleObjectProperty
.Values
[MsgPropItemFalls
]);
5321 Data
.ItemCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 64);
5322 if Data
.ItemCount
< 1 then
5323 Data
.ItemCount
:= 1;
5324 Data
.ItemEffect
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrFxType
]);
5325 Data
.ItemMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnMax
], 0), 65535);
5326 Data
.ItemDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnDelay
], 0), 65535);
5331 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrMusicName
]);
5332 FillByte(Data
.MusicName
[0], 64, 0);
5334 Move(s
[1], Data
.MusicName
[0], Min(Length(s
), 64));
5336 if vleObjectProperty
.Values
[MsgPropTrMusicAct
] = MsgPropTrMusicOn
then
5337 Data
.MusicAction
:= 1
5339 Data
.MusicAction
:= 0;
5344 Data
.PushAngle
:= Min(
5345 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrPushAngle
], 0), 360);
5346 Data
.PushForce
:= Min(
5347 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrPushForce
], 0), 255);
5348 Data
.ResetVel
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrPushReset
]);
5353 Data
.ScoreAction
:= 0;
5354 if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct1
then
5355 Data
.ScoreAction
:= 1
5356 else if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct2
then
5357 Data
.ScoreAction
:= 2
5358 else if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct3
then
5359 Data
.ScoreAction
:= 3;
5360 Data
.ScoreCount
:= Min(Max(
5361 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 0), 255);
5362 Data
.ScoreTeam
:= 0;
5363 if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam1
then
5365 else if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam2
then
5367 else if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam3
then
5368 Data
.ScoreTeam
:= 3;
5369 Data
.ScoreCon
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrScoreCon
]);
5370 Data
.ScoreMsg
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrScoreMsg
]);
5375 Data
.MessageKind
:= 0;
5376 if vleObjectProperty
.Values
[MsgPropTrMessageKind
] = MsgPropTrMessageKind1
then
5377 Data
.MessageKind
:= 1;
5379 Data
.MessageSendTo
:= 0;
5380 if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo1
then
5381 Data
.MessageSendTo
:= 1
5382 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo2
then
5383 Data
.MessageSendTo
:= 2
5384 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo3
then
5385 Data
.MessageSendTo
:= 3
5386 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo4
then
5387 Data
.MessageSendTo
:= 4
5388 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo5
then
5389 Data
.MessageSendTo
:= 5;
5391 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrMessageText
]);
5392 FillByte(Data
.MessageText
[0], 100, 0);
5394 Move(s
[1], Data
.MessageText
[0], Min(Length(s
), 100));
5396 Data
.MessageTime
:= Min(Max(
5397 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrMessageTime
], 0), 0), 65535);
5402 Data
.DamageValue
:= Min(Max(
5403 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrDamageValue
], 0), 0), 65535);
5404 Data
.DamageInterval
:= Min(Max(
5405 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrInterval
], 0), 0), 65535);
5406 s
:= vleObjectProperty
.Values
[MsgPropTrDamageKind
];
5407 if s
= MsgPropTrDamageKind3
then
5408 Data
.DamageKind
:= 3
5409 else if s
= MsgPropTrDamageKind4
then
5410 Data
.DamageKind
:= 4
5411 else if s
= MsgPropTrDamageKind5
then
5412 Data
.DamageKind
:= 5
5413 else if s
= MsgPropTrDamageKind6
then
5414 Data
.DamageKind
:= 6
5415 else if s
= MsgPropTrDamageKind7
then
5416 Data
.DamageKind
:= 7
5417 else if s
= MsgPropTrDamageKind8
then
5418 Data
.DamageKind
:= 8
5420 Data
.DamageKind
:= 0;
5425 Data
.HealValue
:= Min(Max(
5426 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrHealth
], 0), 0), 65535);
5427 Data
.HealInterval
:= Min(Max(
5428 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrInterval
], 0), 0), 65535);
5429 Data
.HealMax
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrHealthMax
]);
5430 Data
.HealSilent
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSilent
]);
5435 Data
.ShotType
:= StrToShot(vleObjectProperty
.Values
[MsgPropTrShotType
]);
5436 Data
.ShotSound
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrShotSound
]);
5437 Data
.ShotTarget
:= 0;
5438 if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo1
then
5439 Data
.ShotTarget
:= 1
5440 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo2
then
5441 Data
.ShotTarget
:= 2
5442 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo3
then
5443 Data
.ShotTarget
:= 3
5444 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo4
then
5445 Data
.ShotTarget
:= 4
5446 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo5
then
5447 Data
.ShotTarget
:= 5
5448 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo6
then
5449 Data
.ShotTarget
:= 6;
5450 Data
.ShotIntSight
:= Min(Max(
5451 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotSight
], 0), 0), 65535);
5453 if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim1
then
5455 else if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim2
then
5457 else if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim3
then
5459 Data
.ShotAngle
:= Min(
5460 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAngle
], 0), 360);
5461 Data
.ShotWait
:= Min(Max(
5462 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 0), 65535);
5463 Data
.ShotAccuracy
:= Min(Max(
5464 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAcc
], 0), 0), 65535);
5465 Data
.ShotAmmo
:= Min(Max(
5466 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAmmo
], 0), 0), 65535);
5467 Data
.ShotIntReload
:= Min(Max(
5468 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotReload
], 0), 0), 65535);
5473 Data
.FXCount
:= Min(Max(
5474 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 0), 255);
5475 if vleObjectProperty
.Values
[MsgPropTrEffectType
] = MsgPropTrEffectParticle
then
5477 Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
5478 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
5479 if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectSliquid
then
5480 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
5481 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectLliquid
then
5482 Data
.FXSubType
:= TRIGGER_EFFECT_LLIQUID
5483 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectDliquid
then
5484 Data
.FXSubType
:= TRIGGER_EFFECT_DLIQUID
5485 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectBlood
then
5486 Data
.FXSubType
:= TRIGGER_EFFECT_BLOOD
5487 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectSpark
then
5488 Data
.FXSubType
:= TRIGGER_EFFECT_SPARK
5489 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectBubble
then
5490 Data
.FXSubType
:= TRIGGER_EFFECT_BUBBLE
;
5493 Data
.FXType
:= TRIGGER_EFFECT_ANIMATION
;
5494 Data
.FXSubType
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrEffectSubtype
]);
5497 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectColor
], 0), 0), $FFFFFF);
5498 Data
.FXColorR
:= a
and $FF;
5499 Data
.FXColorG
:= (a
shr 8) and $FF;
5500 Data
.FXColorB
:= (a
shr 16) and $FF;
5501 if NameToBool(vleObjectProperty
.Values
[MsgPropTrEffectCenter
]) then
5505 Data
.FXWait
:= Min(Max(
5506 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 0), 65535);
5507 Data
.FXVelX
:= Min(Max(
5508 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectVelx
], 0), -128), 127);
5509 Data
.FXVelY
:= Min(Max(
5510 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectVely
], 0), -128), 127);
5511 Data
.FXSpreadL
:= Min(Max(
5512 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpl
], 0), 0), 255);
5513 Data
.FXSpreadR
:= Min(Max(
5514 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpr
], 0), 0), 255);
5515 Data
.FXSpreadU
:= Min(Max(
5516 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpu
], 0), 0), 255);
5517 Data
.FXSpreadD
:= Min(Max(
5518 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpd
], 0), 0), 255);
5527 vleObjectProperty
.Row
:= r
;
5528 vleObjectProperty
.Col
:= c
;
5531 procedure TMainForm
.bbRemoveTextureClick(Sender
: TObject
);
5535 i
:= lbTextureList
.ItemIndex
;
5539 if Application
.MessageBox(PChar(Format(MsgMsgDelTexturePrompt
,
5540 [SelectedTexture()])),
5541 PChar(MsgMsgDelTexture
),
5542 MB_ICONQUESTION
or MB_YESNO
or
5543 MB_DEFBUTTON1
) <> idYes
then
5546 if gPanels
<> nil then
5547 for a
:= 0 to High(gPanels
) do
5548 if (gPanels
[a
].PanelType
<> 0) and
5549 (gPanels
[a
].TextureName
= SelectedTexture()) then
5551 ErrorMessageBox(MsgMsgDelTextureCant
);
5555 g_DeleteTexture(SelectedTexture());
5556 i
:= slInvalidTextures
.IndexOf(lbTextureList
.Items
[i
]);
5558 slInvalidTextures
.Delete(i
);
5559 if lbTextureList
.ItemIndex
> -1 then
5560 lbTextureList
.Items
.Delete(lbTextureList
.ItemIndex
)
5563 procedure TMainForm
.aNewMapExecute(Sender
: TObject
);
5565 if Application
.MessageBox(PChar(MsgMsgClearMapPrompt
), PChar(MsgMsgClearMap
), MB_ICONQUESTION
or MB_YESNO
or MB_DEFBUTTON1
) = mrYes
then
5569 procedure TMainForm
.aUndoExecute(Sender
: TObject
);
5573 if UndoBuffer
= nil then
5575 if UndoBuffer
[High(UndoBuffer
)] = nil then
5578 for a
:= 0 to High(UndoBuffer
[High(UndoBuffer
)]) do
5579 with UndoBuffer
[High(UndoBuffer
)][a
] do
5587 UNDO_DELETE_ITEM
: AddItem(Item
);
5588 UNDO_DELETE_AREA
: AddArea(Area
);
5589 UNDO_DELETE_MONSTER
: AddMonster(Monster
);
5590 UNDO_DELETE_TRIGGER
: AddTrigger(Trigger
);
5591 UNDO_ADD_PANEL
: RemoveObject(AddID
, OBJECT_PANEL
);
5592 UNDO_ADD_ITEM
: RemoveObject(AddID
, OBJECT_ITEM
);
5593 UNDO_ADD_AREA
: RemoveObject(AddID
, OBJECT_AREA
);
5594 UNDO_ADD_MONSTER
: RemoveObject(AddID
, OBJECT_MONSTER
);
5595 UNDO_ADD_TRIGGER
: RemoveObject(AddID
, OBJECT_TRIGGER
);
5599 SetLength(UndoBuffer
, Length(UndoBuffer
)-1);
5601 RemoveSelectFromObjects();
5603 miUndo
.Enabled
:= UndoBuffer
<> nil;
5607 procedure TMainForm
.aCopyObjectExecute(Sender
: TObject
);
5610 CopyBuffer
: TCopyRecArray
;
5614 function CB_Compare(I1
, I2
: TCopyRec
): Integer;
5616 Result
:= Integer(I1
.ObjectType
) - Integer(I2
.ObjectType
);
5618 if Result
= 0 then // Одного типа
5619 Result
:= Integer(I1
.ID
) - Integer(I2
.ID
);
5622 procedure QuickSortCopyBuffer(L
, R
: Integer);
5630 P
:= CopyBuffer
[(L
+ R
) shr 1];
5633 while CB_Compare(CopyBuffer
[I
], P
) < 0 do
5635 while CB_Compare(CopyBuffer
[J
], P
) > 0 do
5641 CopyBuffer
[I
] := CopyBuffer
[J
];
5649 QuickSortCopyBuffer(L
, J
);
5656 if SelectedObjects
= nil then
5662 // Копируем объекты:
5663 for a
:= 0 to High(SelectedObjects
) do
5664 if SelectedObjects
[a
].Live
then
5665 with SelectedObjects
[a
] do
5667 SetLength(CopyBuffer
, Length(CopyBuffer
)+1);
5668 b
:= High(CopyBuffer
);
5669 CopyBuffer
[b
].ID
:= ID
;
5670 CopyBuffer
[b
].Panel
:= nil;
5675 CopyBuffer
[b
].ObjectType
:= OBJECT_PANEL
;
5676 New(CopyBuffer
[b
].Panel
);
5677 CopyBuffer
[b
].Panel
^ := gPanels
[ID
];
5682 CopyBuffer
[b
].ObjectType
:= OBJECT_ITEM
;
5683 CopyBuffer
[b
].Item
:= gItems
[ID
];
5688 CopyBuffer
[b
].ObjectType
:= OBJECT_MONSTER
;
5689 CopyBuffer
[b
].Monster
:= gMonsters
[ID
];
5694 CopyBuffer
[b
].ObjectType
:= OBJECT_AREA
;
5695 CopyBuffer
[b
].Area
:= gAreas
[ID
];
5700 CopyBuffer
[b
].ObjectType
:= OBJECT_TRIGGER
;
5701 CopyBuffer
[b
].Trigger
:= gTriggers
[ID
];
5706 // Сортировка по ID:
5707 if CopyBuffer
<> nil then
5709 QuickSortCopyBuffer(0, b
);
5712 // Постановка ссылок триггеров:
5713 for a
:= 0 to Length(CopyBuffer
)-1 do
5714 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
5716 case CopyBuffer
[a
].Trigger
.TriggerType
of
5717 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5718 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5719 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5720 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
5724 for b
:= 0 to Length(CopyBuffer
)-1 do
5725 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5726 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.PanelID
) then
5728 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= b
;
5733 // Этих панелей нет среди копируемых:
5735 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= -1;
5738 TRIGGER_PRESS
, TRIGGER_ON
,
5739 TRIGGER_OFF
, TRIGGER_ONOFF
:
5740 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
5744 for b
:= 0 to Length(CopyBuffer
)-1 do
5745 if (CopyBuffer
[b
].ObjectType
= OBJECT_MONSTER
) and
5746 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1) then
5748 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= b
+1;
5753 // Этих монстров нет среди копируемых:
5755 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= 0;
5759 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
5763 for b
:= 0 to Length(CopyBuffer
)-1 do
5764 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5765 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
) then
5767 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= b
;
5772 // Этих панелей нет среди копируемых:
5774 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= -1;
5778 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
5782 for b
:= 0 to Length(CopyBuffer
)-1 do
5783 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5784 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.TexturePanel
) then
5786 CopyBuffer
[a
].Trigger
.TexturePanel
:= b
;
5791 // Этих панелей нет среди копируемых:
5793 CopyBuffer
[a
].Trigger
.TexturePanel
:= -1;
5798 str
:= CopyBufferToString(CopyBuffer
);
5799 ClipBoard
.AsText
:= str
;
5801 for a
:= 0 to Length(CopyBuffer
)-1 do
5802 if (CopyBuffer
[a
].ObjectType
= OBJECT_PANEL
) and
5803 (CopyBuffer
[a
].Panel
<> nil) then
5804 Dispose(CopyBuffer
[a
].Panel
);
5809 procedure TMainForm
.aPasteObjectExecute(Sender
: TObject
);
5812 CopyBuffer
: TCopyRecArray
;
5814 swad
, ssec
, sres
: String;
5817 xadj
, yadj
: LongInt;
5822 pmin
.X
:= High(pmin
.X
);
5823 pmin
.Y
:= High(pmin
.Y
);
5825 StringToCopyBuffer(ClipBoard
.AsText
, CopyBuffer
, pmin
);
5826 if CopyBuffer
= nil then
5829 rel
:= not(ssShift
in GetKeyShiftState());
5830 h
:= High(CopyBuffer
);
5831 RemoveSelectFromObjects();
5834 pmin
.X
, pmin
.Y
, -MapOffset
.X
-32, -MapOffset
.Y
-32, RenderPanel
.Width
, RenderPanel
.Height
) then
5841 xadj
:= Floor((-pmin
.X
- MapOffset
.X
+ 32) / DotStep
) * DotStep
;
5842 yadj
:= Floor((-pmin
.Y
- MapOffset
.Y
+ 32) / DotStep
) * DotStep
;
5846 with CopyBuffer
[a
] do
5850 if Panel
<> nil then
5858 Panel
^.TextureID
:= TEXTURE_SPECIAL_NONE
;
5859 Panel
^.TextureWidth
:= 1;
5860 Panel
^.TextureHeight
:= 1;
5862 if (Panel
^.PanelType
= PANEL_LIFTUP
) or
5863 (Panel
^.PanelType
= PANEL_LIFTDOWN
) or
5864 (Panel
^.PanelType
= PANEL_LIFTLEFT
) or
5865 (Panel
^.PanelType
= PANEL_LIFTRIGHT
) or
5866 (Panel
^.PanelType
= PANEL_BLOCKMON
) or
5867 (Panel
^.TextureName
= '') then
5868 begin // Нет или не может быть текстуры:
5870 else // Есть текстура:
5872 // Обычная текстура:
5873 if not IsSpecialTexture(Panel
^.TextureName
) then
5875 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5879 g_ProcessResourceStr(Panel
^.TextureName
, swad
, ssec
, sres
);
5880 AddTexture(swad
, ssec
, sres
, True);
5881 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5885 g_GetTextureSizeByName(Panel
^.TextureName
,
5886 Panel
^.TextureWidth
, Panel
^.TextureHeight
)
5888 if g_GetTexture('NOTEXTURE', NoTextureID
) then
5890 Panel
^.TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
5891 g_GetTextureSizeByID(NoTextureID
, Panel
^.TextureWidth
, Panel
^.TextureHeight
);
5894 else // Спец.текстура:
5896 Panel
^.TextureID
:= SpecialTextureID(Panel
^.TextureName
);
5897 with MainForm
.lbTextureList
.Items
do
5898 if IndexOf(Panel
^.TextureName
) = -1 then
5899 Add(Panel
^.TextureName
);
5903 ID
:= AddPanel(Panel
^);
5905 Undo_Add(OBJECT_PANEL
, ID
, a
> 0);
5906 SelectObject(OBJECT_PANEL
, ID
, True);
5917 ID
:= AddItem(Item
);
5918 Undo_Add(OBJECT_ITEM
, ID
, a
> 0);
5919 SelectObject(OBJECT_ITEM
, ID
, True);
5930 ID
:= AddMonster(Monster
);
5931 Undo_Add(OBJECT_MONSTER
, ID
, a
> 0);
5932 SelectObject(OBJECT_MONSTER
, ID
, True);
5943 ID
:= AddArea(Area
);
5944 Undo_Add(OBJECT_AREA
, ID
, a
> 0);
5945 SelectObject(OBJECT_AREA
, ID
, True);
5959 Data
.TargetPoint
.X
+= xadj
;
5960 Data
.TargetPoint
.Y
+= yadj
;
5962 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
5967 TRIGGER_SPAWNMONSTER
:
5969 Data
.MonPos
.X
+= xadj
;
5970 Data
.MonPos
.Y
+= yadj
;
5974 Data
.ItemPos
.X
+= xadj
;
5975 Data
.ItemPos
.Y
+= yadj
;
5979 Data
.ShotPos
.X
+= xadj
;
5980 Data
.ShotPos
.Y
+= yadj
;
5985 ID
:= AddTrigger(Trigger
);
5986 Undo_Add(OBJECT_TRIGGER
, ID
, a
> 0);
5987 SelectObject(OBJECT_TRIGGER
, ID
, True);
5992 // Переставляем ссылки триггеров:
5993 for a
:= 0 to High(CopyBuffer
) do
5994 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
5996 case CopyBuffer
[a
].Trigger
.TriggerType
of
5997 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5998 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5999 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6000 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
6001 gTriggers
[CopyBuffer
[a
].ID
].Data
.PanelID
:=
6002 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.PanelID
].ID
;
6004 TRIGGER_PRESS
, TRIGGER_ON
,
6005 TRIGGER_OFF
, TRIGGER_ONOFF
:
6006 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
6007 gTriggers
[CopyBuffer
[a
].ID
].Data
.MonsterID
:=
6008 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1].ID
+1;
6011 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
6012 gTriggers
[CopyBuffer
[a
].ID
].Data
.ShotPanelID
:=
6013 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
].ID
;
6016 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
6017 gTriggers
[CopyBuffer
[a
].ID
].TexturePanel
:=
6018 CopyBuffer
[CopyBuffer
[a
].Trigger
.TexturePanel
].ID
;
6027 procedure TMainForm
.aCutObjectExecute(Sender
: TObject
);
6030 DeleteSelectedObjects();
6033 procedure TMainForm
.vleObjectPropertyEditButtonClick(Sender
: TObject
);
6035 Key
, FileName
: String;
6038 Key
:= vleObjectProperty
.Keys
[vleObjectProperty
.Row
];
6040 if Key
= MsgPropPanelType
then
6042 with ChooseTypeForm
, vleObjectProperty
do
6043 begin // Выбор типа панели:
6044 Caption
:= MsgPropPanelType
;
6045 lbTypeSelect
.Items
.Clear();
6047 for b
:= 0 to High(PANELNAMES
) do
6049 lbTypeSelect
.Items
.Add(PANELNAMES
[b
]);
6050 if Values
[Key
] = PANELNAMES
[b
] then
6051 lbTypeSelect
.ItemIndex
:= b
;
6054 if ShowModal() = mrOK
then
6056 b
:= lbTypeSelect
.ItemIndex
;
6057 Values
[Key
] := PANELNAMES
[b
];
6058 vleObjectPropertyApply(Sender
);
6062 else if Key
= MsgPropTrTeleportTo
then
6063 SelectFlag
:= SELECTFLAG_TELEPORT
6064 else if Key
= MsgPropTrSpawnTo
then
6065 SelectFlag
:= SELECTFLAG_SPAWNPOINT
6066 else if (Key
= MsgPropTrDoorPanel
) or
6067 (Key
= MsgPropTrTrapPanel
) then
6068 SelectFlag
:= SELECTFLAG_DOOR
6069 else if Key
= MsgPropTrTexturePanel
then
6071 DrawPressRect
:= False;
6072 SelectFlag
:= SELECTFLAG_TEXTURE
;
6074 else if Key
= MsgPropTrShotPanel
then
6075 SelectFlag
:= SELECTFLAG_SHOTPANEL
6076 else if Key
= MsgPropTrLiftPanel
then
6077 SelectFlag
:= SELECTFLAG_LIFT
6078 else if key
= MsgPropTrExMonster
then
6079 SelectFlag
:= SELECTFLAG_MONSTER
6080 else if Key
= MsgPropTrExArea
then
6082 SelectFlag
:= SELECTFLAG_NONE
;
6083 DrawPressRect
:= True;
6085 else if Key
= MsgPropTrNextMap
then
6086 begin // Выбор следующей карты:
6087 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
6088 SelectMapForm
.Caption
:= MsgCapSelect
;
6089 SelectMapForm
.GetMaps(FileName
);
6091 if SelectMapForm
.ShowModal() = mrOK
then
6093 vleObjectProperty
.Values
[Key
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
6094 vleObjectPropertyApply(Sender
);
6097 else if (Key
= MsgPropTrSoundName
) or
6098 (Key
= MsgPropTrMusicName
) then
6099 begin // Выбор файла звука/музыки:
6100 AddSoundForm
.OKFunction
:= nil;
6101 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
6102 AddSoundForm
.SetResource
:= vleObjectProperty
.Values
[Key
];
6104 if (AddSoundForm
.ShowModal() = mrOk
) then
6106 vleObjectProperty
.Values
[Key
] := AddSoundForm
.ResourceName
;
6107 vleObjectPropertyApply(Sender
);
6110 else if Key
= MsgPropTrActivation
then
6111 with ActivationTypeForm
, vleObjectProperty
do
6112 begin // Выбор типов активации:
6113 cbPlayerCollide
.Checked
:= Pos('PC', Values
[Key
]) > 0;
6114 cbMonsterCollide
.Checked
:= Pos('MC', Values
[Key
]) > 0;
6115 cbPlayerPress
.Checked
:= Pos('PP', Values
[Key
]) > 0;
6116 cbMonsterPress
.Checked
:= Pos('MP', Values
[Key
]) > 0;
6117 cbShot
.Checked
:= Pos('SH', Values
[Key
]) > 0;
6118 cbNoMonster
.Checked
:= Pos('NM', Values
[Key
]) > 0;
6120 if ShowModal() = mrOK
then
6123 if cbPlayerCollide
.Checked
then
6124 b
:= ACTIVATE_PLAYERCOLLIDE
;
6125 if cbMonsterCollide
.Checked
then
6126 b
:= b
or ACTIVATE_MONSTERCOLLIDE
;
6127 if cbPlayerPress
.Checked
then
6128 b
:= b
or ACTIVATE_PLAYERPRESS
;
6129 if cbMonsterPress
.Checked
then
6130 b
:= b
or ACTIVATE_MONSTERPRESS
;
6131 if cbShot
.Checked
then
6132 b
:= b
or ACTIVATE_SHOT
;
6133 if cbNoMonster
.Checked
then
6134 b
:= b
or ACTIVATE_NOMONSTER
;
6136 Values
[Key
] := ActivateToStr(b
);
6137 vleObjectPropertyApply(Sender
);
6140 else if Key
= MsgPropTrKeys
then
6141 with KeysForm
, vleObjectProperty
do
6142 begin // Выбор необходимых ключей:
6143 cbRedKey
.Checked
:= Pos('RK', Values
[Key
]) > 0;
6144 cbGreenKey
.Checked
:= Pos('GK', Values
[Key
]) > 0;
6145 cbBlueKey
.Checked
:= Pos('BK', Values
[Key
]) > 0;
6146 cbRedTeam
.Checked
:= Pos('RT', Values
[Key
]) > 0;
6147 cbBlueTeam
.Checked
:= Pos('BT', Values
[Key
]) > 0;
6149 if ShowModal() = mrOK
then
6152 if cbRedKey
.Checked
then
6154 if cbGreenKey
.Checked
then
6155 b
:= b
or KEY_GREEN
;
6156 if cbBlueKey
.Checked
then
6158 if cbRedTeam
.Checked
then
6159 b
:= b
or KEY_REDTEAM
;
6160 if cbBlueTeam
.Checked
then
6161 b
:= b
or KEY_BLUETEAM
;
6163 Values
[Key
] := KeyToStr(b
);
6164 vleObjectPropertyApply(Sender
);
6167 else if Key
= MsgPropTrFxType
then
6168 with ChooseTypeForm
, vleObjectProperty
do
6169 begin // Выбор типа эффекта:
6170 Caption
:= MsgCapFxType
;
6171 lbTypeSelect
.Items
.Clear();
6173 for b
:= EFFECT_NONE
to EFFECT_FIRE
do
6174 lbTypeSelect
.Items
.Add(EffectToStr(b
));
6176 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]);
6178 if ShowModal() = mrOK
then
6180 b
:= lbTypeSelect
.ItemIndex
;
6181 Values
[Key
] := EffectToStr(b
);
6182 vleObjectPropertyApply(Sender
);
6185 else if Key
= MsgPropTrMonsterType
then
6186 with ChooseTypeForm
, vleObjectProperty
do
6187 begin // Выбор типа монстра:
6188 Caption
:= MsgCapMonsterType
;
6189 lbTypeSelect
.Items
.Clear();
6191 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
6192 lbTypeSelect
.Items
.Add(MonsterToStr(b
));
6194 lbTypeSelect
.ItemIndex
:= StrToMonster(Values
[Key
]) - MONSTER_DEMON
;
6196 if ShowModal() = mrOK
then
6198 b
:= lbTypeSelect
.ItemIndex
+ MONSTER_DEMON
;
6199 Values
[Key
] := MonsterToStr(b
);
6200 vleObjectPropertyApply(Sender
);
6203 else if Key
= MsgPropTrItemType
then
6204 with ChooseTypeForm
, vleObjectProperty
do
6205 begin // Выбор типа предмета:
6206 Caption
:= MsgCapItemType
;
6207 lbTypeSelect
.Items
.Clear();
6209 for b
:= ITEM_MEDKIT_SMALL
to ITEM_KEY_BLUE
do
6210 lbTypeSelect
.Items
.Add(ItemToStr(b
));
6211 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_BOTTLE
));
6212 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_HELMET
));
6213 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_JETPACK
));
6214 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_INVIS
));
6215 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_WEAPON_FLAMETHROWER
));
6216 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_AMMO_FUELCAN
));
6218 b
:= StrToItem(Values
[Key
]);
6219 if b
>= ITEM_BOTTLE
then
6221 lbTypeSelect
.ItemIndex
:= b
- ITEM_MEDKIT_SMALL
;
6223 if ShowModal() = mrOK
then
6225 b
:= lbTypeSelect
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
6226 if b
>= ITEM_WEAPON_KASTET
then
6228 Values
[Key
] := ItemToStr(b
);
6229 vleObjectPropertyApply(Sender
);
6232 else if Key
= MsgPropTrShotType
then
6233 with ChooseTypeForm
, vleObjectProperty
do
6234 begin // Выбор типа предмета:
6235 Caption
:= MsgPropTrShotType
;
6236 lbTypeSelect
.Items
.Clear();
6238 for b
:= TRIGGER_SHOT_PISTOL
to TRIGGER_SHOT_MAX
do
6239 lbTypeSelect
.Items
.Add(ShotToStr(b
));
6241 lbTypeSelect
.ItemIndex
:= StrToShot(Values
[Key
]);
6243 if ShowModal() = mrOK
then
6245 b
:= lbTypeSelect
.ItemIndex
;
6246 Values
[Key
] := ShotToStr(b
);
6247 vleObjectPropertyApply(Sender
);
6250 else if Key
= MsgPropTrEffectType
then
6251 with ChooseTypeForm
, vleObjectProperty
do
6252 begin // Выбор типа эффекта:
6253 Caption
:= MsgCapFxType
;
6254 lbTypeSelect
.Items
.Clear();
6256 lbTypeSelect
.Items
.Add(MsgPropTrEffectParticle
);
6257 lbTypeSelect
.Items
.Add(MsgPropTrEffectAnimation
);
6258 if Values
[Key
] = MsgPropTrEffectAnimation
then
6259 lbTypeSelect
.ItemIndex
:= 1
6261 lbTypeSelect
.ItemIndex
:= 0;
6263 if ShowModal() = mrOK
then
6265 b
:= lbTypeSelect
.ItemIndex
;
6267 Values
[Key
] := MsgPropTrEffectParticle
6269 Values
[Key
] := MsgPropTrEffectAnimation
;
6270 vleObjectPropertyApply(Sender
);
6273 else if Key
= MsgPropTrEffectSubtype
then
6274 with ChooseTypeForm
, vleObjectProperty
do
6275 begin // Выбор подтипа эффекта:
6276 Caption
:= MsgCapFxType
;
6277 lbTypeSelect
.Items
.Clear();
6279 if Values
[MsgPropTrEffectType
] = MsgPropTrEffectAnimation
then
6281 for b
:= EFFECT_TELEPORT
to EFFECT_FIRE
do
6282 lbTypeSelect
.Items
.Add(EffectToStr(b
));
6284 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]) - 1;
6287 lbTypeSelect
.Items
.Add(MsgPropTrEffectSliquid
);
6288 lbTypeSelect
.Items
.Add(MsgPropTrEffectLliquid
);
6289 lbTypeSelect
.Items
.Add(MsgPropTrEffectDliquid
);
6290 lbTypeSelect
.Items
.Add(MsgPropTrEffectBlood
);
6291 lbTypeSelect
.Items
.Add(MsgPropTrEffectSpark
);
6292 lbTypeSelect
.Items
.Add(MsgPropTrEffectBubble
);
6293 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SLIQUID
;
6294 if Values
[Key
] = MsgPropTrEffectLliquid
then
6295 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_LLIQUID
;
6296 if Values
[Key
] = MsgPropTrEffectDliquid
then
6297 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_DLIQUID
;
6298 if Values
[Key
] = MsgPropTrEffectBlood
then
6299 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BLOOD
;
6300 if Values
[Key
] = MsgPropTrEffectSpark
then
6301 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SPARK
;
6302 if Values
[Key
] = MsgPropTrEffectBubble
then
6303 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BUBBLE
;
6306 if ShowModal() = mrOK
then
6308 b
:= lbTypeSelect
.ItemIndex
;
6310 if Values
[MsgPropTrEffectType
] = MsgPropTrEffectAnimation
then
6311 Values
[Key
] := EffectToStr(b
+ 1)
6313 Values
[Key
] := MsgPropTrEffectSliquid
;
6314 if b
= TRIGGER_EFFECT_LLIQUID
then
6315 Values
[Key
] := MsgPropTrEffectLliquid
;
6316 if b
= TRIGGER_EFFECT_DLIQUID
then
6317 Values
[Key
] := MsgPropTrEffectDliquid
;
6318 if b
= TRIGGER_EFFECT_BLOOD
then
6319 Values
[Key
] := MsgPropTrEffectBlood
;
6320 if b
= TRIGGER_EFFECT_SPARK
then
6321 Values
[Key
] := MsgPropTrEffectSpark
;
6322 if b
= TRIGGER_EFFECT_BUBBLE
then
6323 Values
[Key
] := MsgPropTrEffectBubble
;
6326 vleObjectPropertyApply(Sender
);
6329 else if Key
= MsgPropTrEffectColor
then
6330 with vleObjectProperty
do
6331 begin // Выбор цвета эффекта:
6332 ColorDialog
.Color
:= StrToIntDef(Values
[Key
], 0);
6333 if ColorDialog
.Execute
then
6335 Values
[Key
] := IntToStr(ColorDialog
.Color
);
6336 vleObjectPropertyApply(Sender
);
6339 else if Key
= MsgPropPanelTex
then
6340 begin // Смена текстуры:
6341 vleObjectProperty
.Values
[Key
] := SelectedTexture();
6342 vleObjectPropertyApply(Sender
);
6346 procedure TMainForm
.vleObjectPropertyApply(Sender
: TObject
);
6348 // hack to prevent empty ID in list
6349 RenderPanel
.SetFocus();
6350 bApplyProperty
.Click();
6351 vleObjectProperty
.SetFocus();
6354 procedure TMainForm
.aSaveMapExecute(Sender
: TObject
);
6356 FileName
, Section
, Res
: String;
6358 if OpenedMap
= '' then
6360 aSaveMapAsExecute(nil);
6364 g_ProcessResourceStr(OpenedMap
, FileName
, Section
, Res
);
6366 SaveMap(FileName
+':\'+Res
, '');
6369 procedure TMainForm
.aOpenMapExecute(Sender
: TObject
);
6371 OpenDialog
.Filter
:= MsgFileFilterAll
;
6373 if OpenDialog
.Execute() then
6375 OpenMapFile(OpenDialog
.FileName
);
6376 OpenDialog
.InitialDir
:= ExtractFileDir(OpenDialog
.FileName
);
6380 procedure TMainForm
.OpenMapFile(FileName
: String);
6382 if (Pos('.ini', LowerCase(ExtractFileName(FileName
))) > 0) then
6386 pLoadProgress
.Left
:= (RenderPanel
.Width
div 2)-(pLoadProgress
.Width
div 2);
6387 pLoadProgress
.Top
:= (RenderPanel
.Height
div 2)-(pLoadProgress
.Height
div 2);
6388 pLoadProgress
.Show();
6393 LoadMapOld(FileName
);
6395 MainForm
.Caption
:= Format('%s - %s', [FormCaption
, ExtractFileName(FileName
)]);
6397 pLoadProgress
.Hide();
6398 MainForm
.FormResize(Self
);
6400 else // Карты из WAD:
6402 OpenMap(FileName
, '');
6406 procedure TMainForm
.FormActivate(Sender
: TObject
);
6408 MainForm
.ActiveControl
:= RenderPanel
;
6411 procedure TMainForm
.aDeleteMap(Sender
: TObject
);
6419 OpenDialog
.Filter
:= MsgFileFilterWad
;
6421 if not OpenDialog
.Execute() then
6424 WAD
:= TWADEditor_1
.Create();
6426 if not WAD
.ReadFile(OpenDialog
.FileName
) then
6434 MapList
:= WAD
.GetResourcesList('');
6436 SelectMapForm
.Caption
:= MsgCapRemove
;
6437 SelectMapForm
.lbMapList
.Items
.Clear();
6439 if MapList
<> nil then
6440 for a
:= 0 to High(MapList
) do
6441 SelectMapForm
.lbMapList
.Items
.Add(win2utf(MapList
[a
]));
6443 if (SelectMapForm
.ShowModal() = mrOK
) then
6445 str
:= SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
6447 Move(str
[1], MapName
[0], Min(16, Length(str
)));
6449 if Application
.MessageBox(PChar(Format(MsgMsgDeleteMapPrompt
, [MapName
, OpenDialog
.FileName
])), PChar(MsgMsgDeleteMap
), MB_ICONQUESTION
or MB_YESNO
or MB_DEFBUTTON2
) <> mrYes
then
6452 WAD
.RemoveResource('', utf2win(MapName
));
6454 Application
.MessageBox(
6455 PChar(Format(MsgMsgMapDeletedPrompt
, [MapName
])),
6456 PChar(MsgMsgMapDeleted
),
6457 MB_ICONINFORMATION
or MB_OK
or MB_DEFBUTTON1
6460 WAD
.SaveTo(OpenDialog
.FileName
);
6462 // Удалили текущую карту - сохранять по старому ее нельзя:
6463 if OpenedMap
= (OpenDialog
.FileName
+':\'+MapName
) then
6467 MainForm
.Caption
:= FormCaption
;
6474 procedure TMainForm
.vleObjectPropertyKeyDown(Sender
: TObject
;
6475 var Key
: Word; Shift
: TShiftState
);
6477 if Key
= VK_RETURN
then
6478 vleObjectPropertyApply(Sender
);
6481 procedure MovePanel(var ID
: DWORD
; MoveType
: Byte);
6486 if (ID
= 0) and (MoveType
= 0) then
6488 if (ID
= DWORD(High(gPanels
))) and (MoveType
<> 0) then
6490 if (ID
> DWORD(High(gPanels
))) then
6495 if MoveType
= 0 then // to Back
6497 if gTriggers
<> nil then
6498 for a
:= 0 to High(gTriggers
) do
6499 with gTriggers
[a
] do
6501 if TriggerType
= TRIGGER_NONE
then
6504 if TexturePanel
= _id
then
6507 if (TexturePanel
>= 0) and (TexturePanel
< _id
) then
6511 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
6512 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6513 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6514 if Data
.PanelID
= _id
then
6517 if (Data
.PanelID
>= 0) and (Data
.PanelID
< _id
) then
6521 if Data
.ShotPanelID
= _id
then
6522 Data
.ShotPanelID
:= 0
6524 if (Data
.ShotPanelID
>= 0) and (Data
.ShotPanelID
< _id
) then
6525 Inc(Data
.ShotPanelID
);
6529 tmp
:= gPanels
[_id
];
6531 for a
:= _id
downto 1 do
6532 gPanels
[a
] := gPanels
[a
-1];
6540 if gTriggers
<> nil then
6541 for a
:= 0 to High(gTriggers
) do
6542 with gTriggers
[a
] do
6544 if TriggerType
= TRIGGER_NONE
then
6547 if TexturePanel
= _id
then
6548 TexturePanel
:= High(gPanels
)
6550 if TexturePanel
> _id
then
6554 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
6555 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6556 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6557 if Data
.PanelID
= _id
then
6558 Data
.PanelID
:= High(gPanels
)
6560 if Data
.PanelID
> _id
then
6564 if Data
.ShotPanelID
= _id
then
6565 Data
.ShotPanelID
:= High(gPanels
)
6567 if Data
.ShotPanelID
> _id
then
6568 Dec(Data
.ShotPanelID
);
6572 tmp
:= gPanels
[_id
];
6574 for a
:= _id
to High(gPanels
)-1 do
6575 gPanels
[a
] := gPanels
[a
+1];
6577 gPanels
[High(gPanels
)] := tmp
;
6579 ID
:= High(gPanels
);
6583 procedure TMainForm
.aMoveToBack(Sender
: TObject
);
6587 if SelectedObjects
= nil then
6590 for a
:= 0 to High(SelectedObjects
) do
6591 with SelectedObjects
[a
] do
6592 if Live
and (ObjectType
= OBJECT_PANEL
) then
6594 SelectedObjects
[0] := SelectedObjects
[a
];
6595 SetLength(SelectedObjects
, 1);
6602 procedure TMainForm
.aMoveToFore(Sender
: TObject
);
6606 if SelectedObjects
= nil then
6609 for a
:= 0 to High(SelectedObjects
) do
6610 with SelectedObjects
[a
] do
6611 if Live
and (ObjectType
= OBJECT_PANEL
) then
6613 SelectedObjects
[0] := SelectedObjects
[a
];
6614 SetLength(SelectedObjects
, 1);
6621 procedure TMainForm
.aSaveMapAsExecute(Sender
: TObject
);
6622 var i
, idx
: Integer; list
: TStringList
; fmt
: String;
6624 list
:= TStringList
.Create();
6626 // TODO: get loclized strings automatically from language files
6627 SaveDialog
.DefaultExt
:= '.dfz';
6628 SaveDialog
.FilterIndex
:= 1;
6629 SaveDialog
.Filter
:= '';
6630 gWADEditorFactory
.GetRegistredEditors(list
);
6631 for i
:= 0 to list
.Count
- 1 do
6633 if list
[i
] = 'DFZIP' then
6634 SaveDialog
.FilterIndex
:= i
+ 1;
6637 SaveDialog
.Filter
:= SaveDialog
.Filter
+ '|';
6639 if list
[i
] = 'DFWAD' then
6640 SaveDialog
.Filter
:= SaveDialog
.Filter
+ MsgFileFilterSaveDFWAD
6641 else if list
[i
] = 'DFZIP' then
6642 SaveDialog
.Filter
:= SaveDialog
.Filter
+ MsgFileFilterSaveDFZIP
6644 SaveDialog
.Filter
:= SaveDialog
.Filter
+ list
[i
] + '|*.*';
6647 if SaveDialog
.Execute() then
6649 i
:= SaveDialog
.FilterIndex
- 1;
6650 if (i
>= 0) and (i
< list
.Count
) then fmt
:= list
[i
] else fmt
:= '';
6652 SaveMapForm
.GetMaps(SaveDialog
.FileName
, True, fmt
);
6653 if SaveMapForm
.ShowModal() = mrOK
then
6655 SaveDialog
.InitialDir
:= ExtractFileDir(SaveDialog
.FileName
);
6656 OpenedMap
:= SaveDialog
.FileName
+':\'+SaveMapForm
.eMapName
.Text;
6657 OpenedWAD
:= SaveDialog
.FileName
;
6659 idx
:= RecentFiles
.IndexOf(OpenedMap
);
6660 // Такая карта уже недавно открывалась:
6662 RecentFiles
.Delete(idx
);
6663 RecentFiles
.Insert(0, OpenedMap
);
6666 SaveMap(OpenedMap
, fmt
);
6668 gMapInfo
.FileName
:= SaveDialog
.FileName
;
6669 gMapInfo
.MapName
:= SaveMapForm
.eMapName
.Text;
6670 UpdateCaption(gMapInfo
.Name
, ExtractFileName(gMapInfo
.FileName
), gMapInfo
.MapName
);
6677 procedure TMainForm
.aSelectAllExecute(Sender
: TObject
);
6681 RemoveSelectFromObjects();
6683 case pcObjects
.ActivePageIndex
+1 of
6685 if gPanels
<> nil then
6686 for a
:= 0 to High(gPanels
) do
6687 if gPanels
[a
].PanelType
<> PANEL_NONE
then
6688 SelectObject(OBJECT_PANEL
, a
, True);
6690 if gItems
<> nil then
6691 for a
:= 0 to High(gItems
) do
6692 if gItems
[a
].ItemType
<> ITEM_NONE
then
6693 SelectObject(OBJECT_ITEM
, a
, True);
6695 if gMonsters
<> nil then
6696 for a
:= 0 to High(gMonsters
) do
6697 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
6698 SelectObject(OBJECT_MONSTER
, a
, True);
6700 if gAreas
<> nil then
6701 for a
:= 0 to High(gAreas
) do
6702 if gAreas
[a
].AreaType
<> AREA_NONE
then
6703 SelectObject(OBJECT_AREA
, a
, True);
6705 if gTriggers
<> nil then
6706 for a
:= 0 to High(gTriggers
) do
6707 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
6708 SelectObject(OBJECT_TRIGGER
, a
, True);
6711 RecountSelectedObjects();
6714 procedure TMainForm
.tbGridOnClick(Sender
: TObject
);
6716 DotEnable
:= not DotEnable
;
6717 (Sender
as TToolButton
).Down
:= DotEnable
;
6720 procedure TMainForm
.OnIdle(Sender
: TObject
; var Done
: Boolean);
6723 if StartMap
<> '' then
6731 procedure TMainForm
.miMapPreviewClick(Sender
: TObject
);
6733 if PreviewMode
= 2 then
6736 if PreviewMode
= 0 then
6738 Splitter2
.Visible
:= False;
6739 Splitter1
.Visible
:= False;
6740 StatusBar
.Visible
:= False;
6741 PanelObjs
.Visible
:= False;
6742 PanelProps
.Visible
:= False;
6743 MainToolBar
.Visible
:= False;
6744 sbHorizontal
.Visible
:= False;
6745 sbVertical
.Visible
:= False;
6749 StatusBar
.Visible
:= True;
6750 PanelObjs
.Visible
:= True;
6751 PanelProps
.Visible
:= True;
6752 Splitter2
.Visible
:= True;
6753 Splitter1
.Visible
:= True;
6754 MainToolBar
.Visible
:= True;
6755 sbHorizontal
.Visible
:= True;
6756 sbVertical
.Visible
:= True;
6759 PreviewMode
:= PreviewMode
xor 1;
6760 (Sender
as TMenuItem
).Checked
:= PreviewMode
> 0;
6765 procedure TMainForm
.miLayer1Click(Sender
: TObject
);
6767 SwitchLayer(LAYER_BACK
);
6770 procedure TMainForm
.miLayer2Click(Sender
: TObject
);
6772 SwitchLayer(LAYER_WALLS
);
6775 procedure TMainForm
.miLayer3Click(Sender
: TObject
);
6777 SwitchLayer(LAYER_FOREGROUND
);
6780 procedure TMainForm
.miLayer4Click(Sender
: TObject
);
6782 SwitchLayer(LAYER_STEPS
);
6785 procedure TMainForm
.miLayer5Click(Sender
: TObject
);
6787 SwitchLayer(LAYER_WATER
);
6790 procedure TMainForm
.miLayer6Click(Sender
: TObject
);
6792 SwitchLayer(LAYER_ITEMS
);
6795 procedure TMainForm
.miLayer7Click(Sender
: TObject
);
6797 SwitchLayer(LAYER_MONSTERS
);
6800 procedure TMainForm
.miLayer8Click(Sender
: TObject
);
6802 SwitchLayer(LAYER_AREAS
);
6805 procedure TMainForm
.miLayer9Click(Sender
: TObject
);
6807 SwitchLayer(LAYER_TRIGGERS
);
6810 procedure TMainForm
.tbShowClick(Sender
: TObject
);
6816 for a
:= 0 to High(LayerEnabled
) do
6817 b
:= b
and LayerEnabled
[a
];
6821 ShowLayer(LAYER_BACK
, b
);
6822 ShowLayer(LAYER_WALLS
, b
);
6823 ShowLayer(LAYER_FOREGROUND
, b
);
6824 ShowLayer(LAYER_STEPS
, b
);
6825 ShowLayer(LAYER_WATER
, b
);
6826 ShowLayer(LAYER_ITEMS
, b
);
6827 ShowLayer(LAYER_MONSTERS
, b
);
6828 ShowLayer(LAYER_AREAS
, b
);
6829 ShowLayer(LAYER_TRIGGERS
, b
);
6832 procedure TMainForm
.miMiniMapClick(Sender
: TObject
);
6837 procedure TMainForm
.miSwitchGridClick(Sender
: TObject
);
6839 if DotStep
= DotStepOne
then
6840 DotStep
:= DotStepTwo
6842 DotStep
:= DotStepOne
;
6844 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6845 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6848 procedure TMainForm
.miShowEdgesClick(Sender
: TObject
);
6853 procedure TMainForm
.miSnapToGridClick(Sender
: TObject
);
6855 SnapToGrid
:= not SnapToGrid
;
6857 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6858 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6860 miSnapToGrid
.Checked
:= SnapToGrid
;
6863 procedure TMainForm
.minexttabClick(Sender
: TObject
);
6865 if pcObjects
.ActivePageIndex
< pcObjects
.PageCount
-1 then
6866 pcObjects
.ActivePageIndex
:= pcObjects
.ActivePageIndex
+1
6868 pcObjects
.ActivePageIndex
:= 0;
6871 procedure TMainForm
.miSaveMiniMapClick(Sender
: TObject
);
6873 SaveMiniMapForm
.ShowModal();
6876 procedure TMainForm
.bClearTextureClick(Sender
: TObject
);
6878 lbTextureList
.ItemIndex
:= -1;
6879 lTextureWidth
.Caption
:= '';
6880 lTextureHeight
.Caption
:= '';
6883 procedure TMainForm
.miPackMapClick(Sender
: TObject
);
6885 PackMapForm
.ShowModal();
6888 type SSArray
= array of String;
6890 function ParseString (Str
: AnsiString): SSArray
;
6891 function GetStr (var Str
: AnsiString): AnsiString;
6895 if Str
[1] = '"' then
6896 for b
:= 1 to Length(Str
) do
6897 if (b
= Length(Str
)) or (Str
[b
+ 1] = '"') then
6899 Result
:= Copy(Str
, 2, b
- 1);
6900 Delete(Str
, 1, b
+ 1);
6904 for a
:= 1 to Length(Str
) do
6905 if (a
= Length(Str
)) or (Str
[a
+ 1] = ' ') then
6907 Result
:= Copy(Str
, 1, a
);
6908 Delete(Str
, 1, a
+ 1);
6918 SetLength(Result
, Length(Result
)+1);
6919 Result
[High(Result
)] := GetStr(Str
);
6923 procedure TMainForm
.miTestMapClick(Sender
: TObject
);
6925 newWAD
, oldWAD
, tempMap
, ext
: String;
6932 // Ignore while map testing in progress
6933 if MapTestProcess
<> nil then
6936 // Сохраняем временную карту:
6939 newWAD
:= Format('%s/temp%.4d', [MapsDir
, time
]);
6941 until not FileExists(newWAD
);
6942 if OpenedMap
<> '' then
6944 oldWad
:= g_ExtractWadName(OpenedMap
);
6945 newWad
:= newWad
+ ExtractFileExt(oldWad
);
6946 if CopyFile(oldWad
, newWad
) = false then
6947 e_WriteLog('MapTest: unable to copy [' + oldWad
+ '] to [' + newWad
+ ']', MSG_WARNING
)
6951 newWad
:= newWad
+ '.wad'
6953 tempMap
:= newWAD
+ ':\' + TEST_MAP_NAME
;
6954 SaveMap(tempMap
, '');
6958 if TestOptionsTwoPlayers
then
6960 if TestOptionsTeamDamage
then
6962 if TestOptionsAllowExit
then
6964 if TestOptionsWeaponStay
then
6966 if TestOptionsMonstersDM
then
6970 proc
:= TProcessUTF8
.Create(nil);
6971 proc
.Executable
:= TestD2dExe
;
6973 // TODO: get real executable name from Info.plist
6974 if LowerCase(ExtractFileExt(TestD2dExe
)) = '.app' then
6975 proc
.Executable
:= TestD2dExe
+ DirectorySeparator
+ 'Contents' + DirectorySeparator
+ 'MacOS' + DirectorySeparator
+ 'Doom2DF';
6977 proc
.Parameters
.Add('-map');
6978 proc
.Parameters
.Add(tempMap
);
6979 proc
.Parameters
.Add('-gm');
6980 proc
.Parameters
.Add(TestGameMode
);
6981 proc
.Parameters
.Add('-limt');
6982 proc
.Parameters
.Add(TestLimTime
);
6983 proc
.Parameters
.Add('-lims');
6984 proc
.Parameters
.Add(TestLimScore
);
6985 proc
.Parameters
.Add('-opt');
6986 proc
.Parameters
.Add(IntToStr(opt
));
6987 proc
.Parameters
.Add('--debug');
6989 proc
.Parameters
.Add('--close');
6991 args
:= ParseString(TestD2DArgs
);
6992 for i
:= 0 to High(args
) do
6993 proc
.Parameters
.Add(args
[i
]);
7003 tbTestMap
.Enabled
:= False;
7004 MapTestFile
:= newWAD
;
7005 MapTestProcess
:= proc
;
7009 Application
.MessageBox(PChar(MsgMsgExecError
), 'FIXME', MB_OK
or MB_ICONERROR
);
7010 SysUtils
.DeleteFile(newWAD
);
7015 procedure TMainForm
.sbVerticalScroll(Sender
: TObject
;
7016 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
7018 MapOffset
.Y
:= -sbVertical
.Position
;
7019 RenderPanel
.Invalidate
;
7022 procedure TMainForm
.sbHorizontalScroll(Sender
: TObject
;
7023 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
7025 MapOffset
.X
:= -sbHorizontal
.Position
;
7026 RenderPanel
.Invalidate
;
7029 procedure TMainForm
.miOpenWadMapClick(Sender
: TObject
);
7031 if OpenedWAD
<> '' then
7033 OpenMap(OpenedWAD
, '');
7037 procedure TMainForm
.selectall1Click(Sender
: TObject
);
7041 RemoveSelectFromObjects();
7043 if gPanels
<> nil then
7044 for a
:= 0 to High(gPanels
) do
7045 if gPanels
[a
].PanelType
<> PANEL_NONE
then
7046 SelectObject(OBJECT_PANEL
, a
, True);
7048 if gItems
<> nil then
7049 for a
:= 0 to High(gItems
) do
7050 if gItems
[a
].ItemType
<> ITEM_NONE
then
7051 SelectObject(OBJECT_ITEM
, a
, True);
7053 if gMonsters
<> nil then
7054 for a
:= 0 to High(gMonsters
) do
7055 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
7056 SelectObject(OBJECT_MONSTER
, a
, True);
7058 if gAreas
<> nil then
7059 for a
:= 0 to High(gAreas
) do
7060 if gAreas
[a
].AreaType
<> AREA_NONE
then
7061 SelectObject(OBJECT_AREA
, a
, True);
7063 if gTriggers
<> nil then
7064 for a
:= 0 to High(gTriggers
) do
7065 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
7066 SelectObject(OBJECT_TRIGGER
, a
, True);
7068 RecountSelectedObjects();
7071 procedure TMainForm
.Splitter1CanResize(Sender
: TObject
;
7072 var NewSize
: Integer; var Accept
: Boolean);
7074 Accept
:= (NewSize
> 140);
7077 procedure TMainForm
.Splitter2CanResize(Sender
: TObject
;
7078 var NewSize
: Integer; var Accept
: Boolean);
7080 Accept
:= (NewSize
> 110);
7083 procedure TMainForm
.vleObjectPropertyEnter(Sender
: TObject
);
7085 EditingProperties
:= True;
7088 procedure TMainForm
.vleObjectPropertyExit(Sender
: TObject
);
7090 EditingProperties
:= False;
7093 procedure TMainForm
.FormKeyUp(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
7095 // Объекты передвигались:
7096 if MainForm
.ActiveControl
= RenderPanel
then
7098 if (Key
= VK_NUMPAD4
) or
7099 (Key
= VK_NUMPAD6
) or
7100 (Key
= VK_NUMPAD8
) or
7101 (Key
= VK_NUMPAD5
) or
7102 (Key
= Ord('V')) then
7105 // Быстрое превью карты:
7106 if Key
= Ord('E') then
7108 if PreviewMode
= 2 then
7111 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);