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;
274 LastDrawTime
: UInt64;
276 procedure OnIdle(Sender
: TObject
; var Done
: Boolean);
277 procedure RefillRecentMenu (menu
: TMenuItem
; start
: Integer; fmt
: AnsiString);
279 procedure RefreshRecentMenu();
280 procedure OpenMapFile(FileName
: String);
281 function RenderMousePos(): TPoint
;
282 procedure RecountSelectedObjects();
288 LAYER_FOREGROUND
= 2;
296 TEST_MAP_NAME
= '$$$_TEST_$$$';
297 LANGUAGE_FILE_NAME
= '_Editor.txt';
308 DotStepOne
, DotStepTwo
: Word;
310 DrawTexturePanel
: Boolean;
311 DrawPanelSize
: Boolean;
313 PreviewColor
: TColor
;
314 UseCheckerboard
: Boolean;
316 RecentCount
: Integer;
317 RecentFiles
: TStringList
;
318 slInvalidTextures
: TStringList
;
320 TestGameMode
: String;
322 TestLimScore
: String;
323 TestOptionsTwoPlayers
: Boolean;
324 TestOptionsTeamDamage
: Boolean;
325 TestOptionsAllowExit
: Boolean;
326 TestOptionsWeaponStay
: Boolean;
327 TestOptionsMonstersDM
: Boolean;
328 TestD2dExe
, TestD2DArgs
: String;
329 TestMapOnce
: Boolean;
331 LayerEnabled
: Array [LAYER_BACK
..LAYER_TRIGGERS
] of Boolean =
332 (True, True, True, True, True, True, True, True, True);
333 ContourEnabled
: Array [LAYER_BACK
..LAYER_TRIGGERS
] of Boolean =
334 (False, False, False, False, False, False, False, False, False);
335 PreviewMode
: Byte = 0;
341 procedure OpenMap(FileName
: String; mapN
: String);
342 function AddTexture(aWAD
, aSection
, aTex
: String; silent
: Boolean): Boolean;
343 procedure RemoveSelectFromObjects();
344 procedure ChangeShownProperty(Name
: String; NewValue
: String);
349 f_options
, e_graphics
, e_log
, GL
, Math
,
350 f_mapoptions
, g_basic
, f_about
, f_mapoptimization
,
351 f_mapcheck
, f_addresource_texture
, g_textures
,
352 f_activationtype
, f_keys
, wadreader
, fileutil
,
353 MAPREADER
, f_selectmap
, f_savemap
, WADEDITOR
, WADSTRUCT
, MAPDEF
,
354 g_map
, f_saveminimap
, f_addresource
, CONFIG
, f_packmap
,
355 f_addresource_sound
, f_choosetype
,
356 g_language
, ClipBrd
, g_options
;
359 UNDO_DELETE_PANEL
= 1;
360 UNDO_DELETE_ITEM
= 2;
361 UNDO_DELETE_AREA
= 3;
362 UNDO_DELETE_MONSTER
= 4;
363 UNDO_DELETE_TRIGGER
= 5;
367 UNDO_ADD_MONSTER
= 9;
368 UNDO_ADD_TRIGGER
= 10;
369 UNDO_MOVE_PANEL
= 11;
372 UNDO_MOVE_MONSTER
= 14;
373 UNDO_MOVE_TRIGGER
= 15;
374 UNDO_RESIZE_PANEL
= 16;
375 UNDO_RESIZE_TRIGGER
= 17;
377 MOUSEACTION_NONE
= 0;
378 MOUSEACTION_DRAWPANEL
= 1;
379 MOUSEACTION_DRAWTRIGGER
= 2;
380 MOUSEACTION_MOVEOBJ
= 3;
381 MOUSEACTION_RESIZE
= 4;
382 MOUSEACTION_MOVEMAP
= 5;
383 MOUSEACTION_DRAWPRESS
= 6;
384 MOUSEACTION_NOACTION
= 7;
387 RESIZETYPE_VERTICAL
= 1;
388 RESIZETYPE_HORIZONTAL
= 2;
397 SELECTFLAG_TELEPORT
= 1;
399 SELECTFLAG_TEXTURE
= 3;
401 SELECTFLAG_MONSTER
= 5;
402 SELECTFLAG_SPAWNPOINT
= 6;
403 SELECTFLAG_SHOTPANEL
= 7;
404 SELECTFLAG_SELECTED
= 8;
406 RECENT_FILES_MENU_START
= 12;
408 CLIPBOARD_SIG
= 'DF:ED';
412 case UndoType
: Byte of
413 UNDO_DELETE_PANEL
: (Panel
: ^TPanel
);
414 UNDO_DELETE_ITEM
: (Item
: TItem
);
415 UNDO_DELETE_AREA
: (Area
: TArea
);
416 UNDO_DELETE_MONSTER
: (Monster
: TMonster
);
417 UNDO_DELETE_TRIGGER
: (Trigger
: TTrigger
);
422 UNDO_ADD_TRIGGER
: (AddID
: DWORD
);
427 UNDO_MOVE_TRIGGER
: (MoveID
: DWORD
; dX
, dY
: Integer);
429 UNDO_RESIZE_TRIGGER
: (ResizeID
: DWORD
; dW
, dH
: Integer);
434 case ObjectType
: Byte of
435 OBJECT_PANEL
: (Panel
: ^TPanel
);
436 OBJECT_ITEM
: (Item
: TItem
);
437 OBJECT_AREA
: (Area
: TArea
);
438 OBJECT_MONSTER
: (Monster
: TMonster
);
439 OBJECT_TRIGGER
: (Trigger
: TTrigger
);
442 TCopyRecArray
= Array of TCopyRec
;
446 gDataLoaded
: Boolean = False;
447 ShowMap
: Boolean = False;
448 DrawRect
: PRect
= nil;
449 SnapToGrid
: Boolean = True;
451 MousePos
: Types
.TPoint
;
452 LastMovePoint
: Types
.TPoint
;
456 MouseLDownPos
: Types
.TPoint
;
457 MouseRDownPos
: Types
.TPoint
;
458 MouseMDownPos
: Types
.TPoint
;
460 SelectFlag
: Byte = SELECTFLAG_NONE
;
461 MouseAction
: Byte = MOUSEACTION_NONE
;
462 ResizeType
: Byte = RESIZETYPE_NONE
;
463 ResizeDirection
: Byte = RESIZEDIR_NONE
;
465 DrawPressRect
: Boolean = False;
466 EditingProperties
: Boolean = False;
468 UndoBuffer
: Array of Array of TUndoRec
= nil;
470 MapTestProcess
: TProcessUTF8
;
475 //----------------------------------------
476 //Далее идут вспомогательные процедуры
477 //----------------------------------------
479 function NameToBool(Name
: String): Boolean;
481 if Name
= BoolNames
[True] then
487 function NameToDir(Name
: String): TDirection
;
489 if Name
= DirNames
[D_LEFT
] then
495 function NameToDirAdv(Name
: String): Byte;
497 if Name
= DirNamesAdv
[1] then
500 if Name
= DirNamesAdv
[2] then
503 if Name
= DirNamesAdv
[3] then
509 function ActivateToStr(ActivateType
: Byte): String;
513 if ByteBool(ACTIVATE_PLAYERCOLLIDE
and ActivateType
) then
514 Result
:= Result
+ '+PC';
515 if ByteBool(ACTIVATE_MONSTERCOLLIDE
and ActivateType
) then
516 Result
:= Result
+ '+MC';
517 if ByteBool(ACTIVATE_PLAYERPRESS
and ActivateType
) then
518 Result
:= Result
+ '+PP';
519 if ByteBool(ACTIVATE_MONSTERPRESS
and ActivateType
) then
520 Result
:= Result
+ '+MP';
521 if ByteBool(ACTIVATE_SHOT
and ActivateType
) then
522 Result
:= Result
+ '+SH';
523 if ByteBool(ACTIVATE_NOMONSTER
and ActivateType
) then
524 Result
:= Result
+ '+NM';
526 if (Result
<> '') and (Result
[1] = '+') then
527 Delete(Result
, 1, 1);
530 function StrToActivate(Str
: String): Byte;
534 if Pos('PC', Str
) > 0 then
535 Result
:= ACTIVATE_PLAYERCOLLIDE
;
536 if Pos('MC', Str
) > 0 then
537 Result
:= Result
or ACTIVATE_MONSTERCOLLIDE
;
538 if Pos('PP', Str
) > 0 then
539 Result
:= Result
or ACTIVATE_PLAYERPRESS
;
540 if Pos('MP', Str
) > 0 then
541 Result
:= Result
or ACTIVATE_MONSTERPRESS
;
542 if Pos('SH', Str
) > 0 then
543 Result
:= Result
or ACTIVATE_SHOT
;
544 if Pos('NM', Str
) > 0 then
545 Result
:= Result
or ACTIVATE_NOMONSTER
;
548 function KeyToStr(Key
: Byte): String;
552 if ByteBool(KEY_RED
and Key
) then
553 Result
:= Result
+ '+RK';
554 if ByteBool(KEY_GREEN
and Key
) then
555 Result
:= Result
+ '+GK';
556 if ByteBool(KEY_BLUE
and Key
) then
557 Result
:= Result
+ '+BK';
558 if ByteBool(KEY_REDTEAM
and Key
) then
559 Result
:= Result
+ '+RT';
560 if ByteBool(KEY_BLUETEAM
and Key
) then
561 Result
:= Result
+ '+BT';
563 if (Result
<> '') and (Result
[1] = '+') then
564 Delete(Result
, 1, 1);
567 function StrToKey(Str
: String): Byte;
571 if Pos('RK', Str
) > 0 then
573 if Pos('GK', Str
) > 0 then
574 Result
:= Result
or KEY_GREEN
;
575 if Pos('BK', Str
) > 0 then
576 Result
:= Result
or KEY_BLUE
;
577 if Pos('RT', Str
) > 0 then
578 Result
:= Result
or KEY_REDTEAM
;
579 if Pos('BT', Str
) > 0 then
580 Result
:= Result
or KEY_BLUETEAM
;
583 function EffectToStr(Effect
: Byte): String;
585 if Effect
in [EFFECT_TELEPORT
..EFFECT_FIRE
] then
586 Result
:= EffectNames
[Effect
]
588 Result
:= EffectNames
[EFFECT_NONE
];
591 function StrToEffect(Str
: String): Byte;
595 Result
:= EFFECT_NONE
;
596 for i
:= EFFECT_TELEPORT
to EFFECT_FIRE
do
597 if EffectNames
[i
] = Str
then
604 function MonsterToStr(MonType
: Byte): String;
606 if MonType
in [MONSTER_DEMON
..MONSTER_MAN
] then
607 Result
:= MonsterNames
[MonType
]
609 Result
:= MonsterNames
[MONSTER_ZOMBY
];
612 function StrToMonster(Str
: String): Byte;
616 Result
:= MONSTER_ZOMBY
;
617 for i
:= MONSTER_DEMON
to MONSTER_MAN
do
618 if MonsterNames
[i
] = Str
then
625 function ItemToStr(ItemType
: Byte): String;
627 if ItemType
in [ITEM_MEDKIT_SMALL
..ITEM_MAX
] then
628 Result
:= ItemNames
[ItemType
]
630 Result
:= ItemNames
[ITEM_AMMO_BULLETS
];
633 function StrToItem(Str
: String): Byte;
637 Result
:= ITEM_AMMO_BULLETS
;
638 for i
:= ITEM_MEDKIT_SMALL
to ITEM_MAX
do
639 if ItemNames
[i
] = Str
then
646 function ShotToStr(ShotType
: Byte): String;
648 if ShotType
in [TRIGGER_SHOT_PISTOL
..TRIGGER_SHOT_MAX
] then
649 Result
:= ShotNames
[ShotType
]
651 Result
:= ShotNames
[TRIGGER_SHOT_PISTOL
];
654 function StrToShot(Str
: String): Byte;
658 Result
:= TRIGGER_SHOT_PISTOL
;
659 for i
:= TRIGGER_SHOT_PISTOL
to TRIGGER_SHOT_MAX
do
660 if ShotNames
[i
] = Str
then
667 function SelectedObjectCount(): Word;
673 if SelectedObjects
= nil then
676 for a
:= 0 to High(SelectedObjects
) do
677 if SelectedObjects
[a
].Live
then
678 Result
:= Result
+ 1;
681 function GetFirstSelected(): Integer;
687 if SelectedObjects
= nil then
690 for a
:= 0 to High(SelectedObjects
) do
691 if SelectedObjects
[a
].Live
then
698 function Normalize16(x
: Integer): Integer;
700 Result
:= (x
div 16) * 16;
703 procedure MoveMap(X
, Y
: Integer);
705 rx
, ry
, ScaleSz
: Integer;
707 with MainForm
.RenderPanel
do
709 ScaleSz
:= 16 div Scale
;
710 // Размер видимой части карты:
711 rx
:= Min(Normalize16(Width
), Normalize16(gMapInfo
.Width
)) div 2;
712 ry
:= Min(Normalize16(Height
), Normalize16(gMapInfo
.Height
)) div 2;
713 // Место клика на мини-карте:
714 MapOffset
.X
:= X
- (Width
- Max(gMapInfo
.Width
div ScaleSz
, 1) - 1);
715 MapOffset
.Y
:= Y
- 1;
716 // Это же место на "большой" карте:
717 MapOffset
.X
:= MapOffset
.X
* ScaleSz
;
718 MapOffset
.Y
:= MapOffset
.Y
* ScaleSz
;
719 // Левый верхний угол новой видимой части карты:
720 MapOffset
.X
:= MapOffset
.X
- rx
;
721 MapOffset
.Y
:= MapOffset
.Y
- ry
;
723 MapOffset
.X
:= EnsureRange(MapOffset
.X
, MainForm
.sbHorizontal
.Min
, MainForm
.sbHorizontal
.Max
);
724 MapOffset
.Y
:= EnsureRange(MapOffset
.Y
, MainForm
.sbVertical
.Min
, MainForm
.sbVertical
.Max
);
726 // MapOffset.X := Normalize16(MapOffset.X);
727 // MapOffset.Y := Normalize16(MapOffset.Y);
730 MainForm
.sbHorizontal
.Position
:= MapOffset
.X
;
731 MainForm
.sbVertical
.Position
:= MapOffset
.Y
;
733 MapOffset
.X
:= -MapOffset
.X
;
734 MapOffset
.Y
:= -MapOffset
.Y
;
739 function IsTexturedPanel(PanelType
: Word): Boolean;
741 Result
:= WordBool(PanelType
and (PANEL_WALL
or PANEL_BACK
or PANEL_FORE
or
742 PANEL_STEP
or PANEL_OPENDOOR
or PANEL_CLOSEDOOR
or
743 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
));
746 procedure FillProperty();
751 MainForm
.vleObjectProperty
.Strings
.Clear();
752 MainForm
.RecountSelectedObjects();
754 // Отображаем свойства если выделен только один объект:
755 if SelectedObjectCount() <> 1 then
758 _id
:= GetFirstSelected();
759 if not SelectedObjects
[_id
].Live
then
762 with MainForm
.vleObjectProperty
do
763 with ItemProps
[InsertRow(MsgPropId
, IntToStr(SelectedObjects
[_id
].ID
), True)] do
765 EditStyle
:= esSimple
;
769 case SelectedObjects
[0].ObjectType
of
772 with MainForm
.vleObjectProperty
,
773 gPanels
[SelectedObjects
[_id
].ID
] do
775 with ItemProps
[InsertRow(MsgPropX
, IntToStr(X
), True)] do
777 EditStyle
:= esSimple
;
781 with ItemProps
[InsertRow(MsgPropY
, IntToStr(Y
), True)] do
783 EditStyle
:= esSimple
;
787 with ItemProps
[InsertRow(MsgPropWidth
, IntToStr(Width
), True)] do
789 EditStyle
:= esSimple
;
793 with ItemProps
[InsertRow(MsgPropHeight
, IntToStr(Height
), True)] do
795 EditStyle
:= esSimple
;
799 with ItemProps
[InsertRow(MsgPropPanelType
, GetPanelName(PanelType
), True)] do
801 EditStyle
:= esEllipsis
;
805 if IsTexturedPanel(PanelType
) then
806 begin // Может быть текстура
807 with ItemProps
[InsertRow(MsgPropPanelTex
, TextureName
, True)] do
809 EditStyle
:= esEllipsis
;
813 if TextureName
<> '' then
814 begin // Есть текстура
815 with ItemProps
[InsertRow(MsgPropPanelAlpha
, IntToStr(Alpha
), True)] do
817 EditStyle
:= esSimple
;
821 with ItemProps
[InsertRow(MsgPropPanelBlend
, BoolNames
[Blending
], True)] do
823 EditStyle
:= esPickList
;
833 with MainForm
.vleObjectProperty
,
834 gItems
[SelectedObjects
[_id
].ID
] do
836 with ItemProps
[InsertRow(MsgPropX
, IntToStr(X
), True)] do
838 EditStyle
:= esSimple
;
842 with ItemProps
[InsertRow(MsgPropY
, IntToStr(Y
), True)] do
844 EditStyle
:= esSimple
;
848 with ItemProps
[InsertRow(MsgPropDmOnly
, BoolNames
[OnlyDM
], True)] do
850 EditStyle
:= esPickList
;
854 with ItemProps
[InsertRow(MsgPropItemFalls
, BoolNames
[Fall
], True)] do
856 EditStyle
:= esPickList
;
864 with MainForm
.vleObjectProperty
,
865 gMonsters
[SelectedObjects
[_id
].ID
] do
867 with ItemProps
[InsertRow(MsgPropX
, IntToStr(X
), True)] do
869 EditStyle
:= esSimple
;
873 with ItemProps
[InsertRow(MsgPropY
, IntToStr(Y
), True)] do
875 EditStyle
:= esSimple
;
879 with ItemProps
[InsertRow(MsgPropDirection
, DirNames
[Direction
], True)] do
881 EditStyle
:= esPickList
;
889 with MainForm
.vleObjectProperty
,
890 gAreas
[SelectedObjects
[_id
].ID
] do
892 with ItemProps
[InsertRow(MsgPropX
, IntToStr(X
), True)] do
894 EditStyle
:= esSimple
;
898 with ItemProps
[InsertRow(MsgPropY
, IntToStr(Y
), True)] do
900 EditStyle
:= esSimple
;
904 with ItemProps
[InsertRow(MsgPropDirection
, DirNames
[Direction
], True)] do
906 EditStyle
:= esPickList
;
914 with MainForm
.vleObjectProperty
,
915 gTriggers
[SelectedObjects
[_id
].ID
] do
917 with ItemProps
[InsertRow(MsgPropTrType
, GetTriggerName(TriggerType
), True)] do
919 EditStyle
:= esSimple
;
923 with ItemProps
[InsertRow(MsgPropX
, IntToStr(X
), True)] do
925 EditStyle
:= esSimple
;
929 with ItemProps
[InsertRow(MsgPropY
, IntToStr(Y
), True)] do
931 EditStyle
:= esSimple
;
935 with ItemProps
[InsertRow(MsgPropWidth
, IntToStr(Width
), True)] do
937 EditStyle
:= esSimple
;
941 with ItemProps
[InsertRow(MsgPropHeight
, IntToStr(Height
), True)] do
943 EditStyle
:= esSimple
;
947 with ItemProps
[InsertRow(MsgPropTrEnabled
, BoolNames
[Enabled
], True)] do
949 EditStyle
:= esPickList
;
953 with ItemProps
[InsertRow(MsgPropTrTexturePanel
, IntToStr(TexturePanel
), True)] do
955 EditStyle
:= esEllipsis
;
959 with ItemProps
[InsertRow(MsgPropTrActivation
, ActivateToStr(ActivateType
), True)] do
961 EditStyle
:= esEllipsis
;
965 with ItemProps
[InsertRow(MsgPropTrKeys
, KeyToStr(Key
), True)] do
967 EditStyle
:= esEllipsis
;
974 str
:= win2utf(Data
.MapName
);
975 with ItemProps
[InsertRow(MsgPropTrNextMap
, str
, True)] do
977 EditStyle
:= esEllipsis
;
984 with ItemProps
[InsertRow(MsgPropTrTeleportTo
, Format('(%d:%d)', [Data
.TargetPoint
.X
, Data
.TargetPoint
.Y
]), True)] do
986 EditStyle
:= esEllipsis
;
990 with ItemProps
[InsertRow(MsgPropTrD2d
, BoolNames
[Data
.d2d_teleport
], True)] do
992 EditStyle
:= esPickList
;
996 with ItemProps
[InsertRow(MsgPropTrTeleportSilent
, BoolNames
[Data
.silent_teleport
], True)] do
998 EditStyle
:= esPickList
;
1002 with ItemProps
[InsertRow(MsgPropTrTeleportDir
, DirNamesAdv
[Data
.TlpDir
], True)] do
1004 EditStyle
:= esPickList
;
1009 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
,
1010 TRIGGER_DOOR
, TRIGGER_DOOR5
:
1012 with ItemProps
[InsertRow(MsgPropTrDoorPanel
, IntToStr(Data
.PanelID
), True)] do
1014 EditStyle
:= esEllipsis
;
1018 with ItemProps
[InsertRow(MsgPropTrSilent
, BoolNames
[Data
.NoSound
], True)] do
1020 EditStyle
:= esPickList
;
1024 with ItemProps
[InsertRow(MsgPropTrD2d
, BoolNames
[Data
.d2d_doors
], True)] do
1026 EditStyle
:= esPickList
;
1031 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
:
1033 with ItemProps
[InsertRow(MsgPropTrTrapPanel
, IntToStr(Data
.PanelID
), True)] do
1035 EditStyle
:= esEllipsis
;
1039 with ItemProps
[InsertRow(MsgPropTrSilent
, BoolNames
[Data
.NoSound
], True)] do
1041 EditStyle
:= esPickList
;
1045 with ItemProps
[InsertRow(MsgPropTrD2d
, BoolNames
[Data
.d2d_doors
], True)] do
1047 EditStyle
:= esPickList
;
1052 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
1055 with ItemProps
[InsertRow(MsgPropTrExArea
,
1056 Format('(%d:%d %d:%d)', [Data
.tX
, Data
.tY
, Data
.tWidth
, Data
.tHeight
]), True)] do
1058 EditStyle
:= esEllipsis
;
1062 with ItemProps
[InsertRow(MsgPropTrExDelay
, IntToStr(Data
.Wait
), True)] do
1064 EditStyle
:= esSimple
;
1068 with ItemProps
[InsertRow(MsgPropTrExCount
, IntToStr(Data
.Count
), True)] do
1070 EditStyle
:= esSimple
;
1074 with ItemProps
[InsertRow(MsgPropTrExMonster
, IntToStr(Data
.MonsterID
-1), True)] do
1076 EditStyle
:= esEllipsis
;
1080 if TriggerType
= TRIGGER_PRESS
then
1081 with ItemProps
[InsertRow(MsgPropTrExRandom
, BoolNames
[Data
.ExtRandom
], True)] do
1083 EditStyle
:= esPickList
;
1091 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
1093 with ItemProps
[InsertRow(MsgPropTrLiftPanel
, IntToStr(Data
.PanelID
), True)] do
1095 EditStyle
:= esEllipsis
;
1099 with ItemProps
[InsertRow(MsgPropTrSilent
, BoolNames
[Data
.NoSound
], True)] do
1101 EditStyle
:= esPickList
;
1105 with ItemProps
[InsertRow(MsgPropTrD2d
, BoolNames
[Data
.d2d_doors
], True)] do
1107 EditStyle
:= esPickList
;
1114 with ItemProps
[InsertRow(MsgPropTrTextureOnce
, BoolNames
[Data
.ActivateOnce
], True)] do
1116 EditStyle
:= esPickList
;
1120 with ItemProps
[InsertRow(MsgPropTrTextureAnimOnce
, BoolNames
[Data
.AnimOnce
], True)] do
1122 EditStyle
:= esPickList
;
1129 str
:= win2utf(Data
.SoundName
);
1130 with ItemProps
[InsertRow(MsgPropTrSoundName
, str
, True)] do
1132 EditStyle
:= esEllipsis
;
1136 with ItemProps
[InsertRow(MsgPropTrSoundVolume
, IntToStr(Data
.Volume
), True)] do
1138 EditStyle
:= esSimple
;
1142 with ItemProps
[InsertRow(MsgPropTrSoundPan
, IntToStr(Data
.Pan
), True)] do
1144 EditStyle
:= esSimple
;
1148 with ItemProps
[InsertRow(MsgPropTrSoundCount
, IntToStr(Data
.PlayCount
), True)] do
1150 EditStyle
:= esSimple
;
1154 with ItemProps
[InsertRow(MsgPropTrSoundLocal
, BoolNames
[Data
.Local
], True)] do
1156 EditStyle
:= esPickList
;
1160 with ItemProps
[InsertRow(MsgPropTrSoundSwitch
, BoolNames
[Data
.SoundSwitch
], True)] do
1162 EditStyle
:= esPickList
;
1167 TRIGGER_SPAWNMONSTER
:
1169 with ItemProps
[InsertRow(MsgPropTrMonsterType
, MonsterToStr(Data
.MonType
), True)] do
1171 EditStyle
:= esEllipsis
;
1175 with ItemProps
[InsertRow(MsgPropTrSpawnTo
,
1176 Format('(%d:%d)', [Data
.MonPos
.X
, Data
.MonPos
.Y
]), True)] do
1178 EditStyle
:= esEllipsis
;
1182 with ItemProps
[InsertRow(MsgPropDirection
, DirNames
[TDirection(Data
.MonDir
)], True)] do
1184 EditStyle
:= esPickList
;
1188 with ItemProps
[InsertRow(MsgPropTrHealth
, IntToStr(Data
.MonHealth
), True)] do
1190 EditStyle
:= esSimple
;
1194 with ItemProps
[InsertRow(MsgPropTrMonsterActive
, BoolNames
[Data
.MonActive
], True)] do
1196 EditStyle
:= esPickList
;
1200 with ItemProps
[InsertRow(MsgPropTrCount
, IntToStr(Data
.MonCount
), True)] do
1202 EditStyle
:= esSimple
;
1206 with ItemProps
[InsertRow(MsgPropTrFxType
, EffectToStr(Data
.MonEffect
), True)] do
1208 EditStyle
:= esEllipsis
;
1212 with ItemProps
[InsertRow(MsgPropTrSpawnMax
, IntToStr(Data
.MonMax
), True)] do
1214 EditStyle
:= esSimple
;
1218 with ItemProps
[InsertRow(MsgPropTrSpawnDelay
, IntToStr(Data
.MonDelay
), True)] do
1220 EditStyle
:= esSimple
;
1224 case Data
.MonBehav
of
1225 1: str
:= MsgPropTrMonsterBehaviour1
;
1226 2: str
:= MsgPropTrMonsterBehaviour2
;
1227 3: str
:= MsgPropTrMonsterBehaviour3
;
1228 4: str
:= MsgPropTrMonsterBehaviour4
;
1229 5: str
:= MsgPropTrMonsterBehaviour5
;
1230 else str
:= MsgPropTrMonsterBehaviour0
;
1232 with ItemProps
[InsertRow(MsgPropTrMonsterBehaviour
, str
, True)] do
1234 EditStyle
:= esPickList
;
1241 with ItemProps
[InsertRow(MsgPropTrItemType
, ItemToStr(Data
.ItemType
), True)] do
1243 EditStyle
:= esEllipsis
;
1247 with ItemProps
[InsertRow(MsgPropTrSpawnTo
,
1248 Format('(%d:%d)', [Data
.ItemPos
.X
, Data
.ItemPos
.Y
]), True)] do
1250 EditStyle
:= esEllipsis
;
1254 with ItemProps
[InsertRow(MsgPropDmOnly
, BoolNames
[Data
.ItemOnlyDM
], True)] do
1256 EditStyle
:= esPickList
;
1260 with ItemProps
[InsertRow(MsgPropItemFalls
, BoolNames
[Data
.ItemFalls
], True)] do
1262 EditStyle
:= esPickList
;
1266 with ItemProps
[InsertRow(MsgPropTrCount
, IntToStr(Data
.ItemCount
), True)] do
1268 EditStyle
:= esSimple
;
1272 with ItemProps
[InsertRow(MsgPropTrFxType
, EffectToStr(Data
.ItemEffect
), True)] do
1274 EditStyle
:= esEllipsis
;
1278 with ItemProps
[InsertRow(MsgPropTrSpawnMax
, IntToStr(Data
.ItemMax
), True)] do
1280 EditStyle
:= esSimple
;
1284 with ItemProps
[InsertRow(MsgPropTrSpawnDelay
, IntToStr(Data
.ItemDelay
), True)] do
1286 EditStyle
:= esSimple
;
1293 str
:= win2utf(Data
.MusicName
);
1294 with ItemProps
[InsertRow(MsgPropTrMusicName
, str
, True)] do
1296 EditStyle
:= esEllipsis
;
1300 if Data
.MusicAction
= 1 then
1301 str
:= MsgPropTrMusicOn
1303 str
:= MsgPropTrMusicOff
;
1305 with ItemProps
[InsertRow(MsgPropTrMusicAct
, str
, True)] do
1307 EditStyle
:= esPickList
;
1314 with ItemProps
[InsertRow(MsgPropTrPushAngle
, IntToStr(Data
.PushAngle
), True)] do
1316 EditStyle
:= esSimple
;
1319 with ItemProps
[InsertRow(MsgPropTrPushForce
, IntToStr(Data
.PushForce
), True)] do
1321 EditStyle
:= esSimple
;
1324 with ItemProps
[InsertRow(MsgPropTrPushReset
, BoolNames
[Data
.ResetVel
], True)] do
1326 EditStyle
:= esPickList
;
1333 case Data
.ScoreAction
of
1334 1: str
:= MsgPropTrScoreAct1
;
1335 2: str
:= MsgPropTrScoreAct2
;
1336 3: str
:= MsgPropTrScoreAct3
;
1337 else str
:= MsgPropTrScoreAct0
;
1339 with ItemProps
[InsertRow(MsgPropTrScoreAct
, str
, True)] do
1341 EditStyle
:= esPickList
;
1344 with ItemProps
[InsertRow(MsgPropTrCount
, IntToStr(Data
.ScoreCount
), True)] do
1346 EditStyle
:= esSimple
;
1349 case Data
.ScoreTeam
of
1350 1: str
:= MsgPropTrScoreTeam1
;
1351 2: str
:= MsgPropTrScoreTeam2
;
1352 3: str
:= MsgPropTrScoreTeam3
;
1353 else str
:= MsgPropTrScoreTeam0
;
1355 with ItemProps
[InsertRow(MsgPropTrScoreTeam
, str
, True)] do
1357 EditStyle
:= esPickList
;
1360 with ItemProps
[InsertRow(MsgPropTrScoreCon
, BoolNames
[Data
.ScoreCon
], True)] do
1362 EditStyle
:= esPickList
;
1365 with ItemProps
[InsertRow(MsgPropTrScoreMsg
, BoolNames
[Data
.ScoreMsg
], True)] do
1367 EditStyle
:= esPickList
;
1374 case Data
.MessageKind
of
1375 1: str
:= MsgPropTrMessageKind1
;
1376 else str
:= MsgPropTrMessageKind0
;
1378 with ItemProps
[InsertRow(MsgPropTrMessageKind
, str
, True)] do
1380 EditStyle
:= esPickList
;
1383 case Data
.MessageSendTo
of
1384 1: str
:= MsgPropTrMessageTo1
;
1385 2: str
:= MsgPropTrMessageTo2
;
1386 3: str
:= MsgPropTrMessageTo3
;
1387 4: str
:= MsgPropTrMessageTo4
;
1388 5: str
:= MsgPropTrMessageTo5
;
1389 else str
:= MsgPropTrMessageTo0
;
1391 with ItemProps
[InsertRow(MsgPropTrMessageTo
, str
, True)] do
1393 EditStyle
:= esPickList
;
1396 str
:= win2utf(Data
.MessageText
);
1397 with ItemProps
[InsertRow(MsgPropTrMessageText
, str
, True)] do
1399 EditStyle
:= esSimple
;
1402 with ItemProps
[InsertRow(MsgPropTrMessageTime
, IntToStr(Data
.MessageTime
), True)] do
1404 EditStyle
:= esSimple
;
1411 with ItemProps
[InsertRow(MsgPropTrDamageValue
, IntToStr(Data
.DamageValue
), True)] do
1413 EditStyle
:= esSimple
;
1416 with ItemProps
[InsertRow(MsgPropTrInterval
, IntToStr(Data
.DamageInterval
), True)] do
1418 EditStyle
:= esSimple
;
1421 case Data
.DamageKind
of
1422 3: str
:= MsgPropTrDamageKind3
;
1423 4: str
:= MsgPropTrDamageKind4
;
1424 5: str
:= MsgPropTrDamageKind5
;
1425 6: str
:= MsgPropTrDamageKind6
;
1426 7: str
:= MsgPropTrDamageKind7
;
1427 8: str
:= MsgPropTrDamageKind8
;
1428 else str
:= MsgPropTrDamageKind0
;
1430 with ItemProps
[InsertRow(MsgPropTrDamageKind
, str
, True)] do
1432 EditStyle
:= esPickList
;
1439 with ItemProps
[InsertRow(MsgPropTrHealth
, IntToStr(Data
.HealValue
), True)] do
1441 EditStyle
:= esSimple
;
1444 with ItemProps
[InsertRow(MsgPropTrInterval
, IntToStr(Data
.HealInterval
), True)] do
1446 EditStyle
:= esSimple
;
1449 with ItemProps
[InsertRow(MsgPropTrHealthMax
, BoolNames
[Data
.HealMax
], True)] do
1451 EditStyle
:= esPickList
;
1454 with ItemProps
[InsertRow(MsgPropTrSilent
, BoolNames
[Data
.HealSilent
], True)] do
1456 EditStyle
:= esPickList
;
1463 with ItemProps
[InsertRow(MsgPropTrShotType
, ShotToStr(Data
.ShotType
), True)] do
1465 EditStyle
:= esEllipsis
;
1469 with ItemProps
[InsertRow(MsgPropTrShotSound
, BoolNames
[Data
.ShotSound
], True)] do
1471 EditStyle
:= esPickList
;
1475 with ItemProps
[InsertRow(MsgPropTrShotPanel
, IntToStr(Data
.ShotPanelID
), True)] do
1477 EditStyle
:= esEllipsis
;
1481 case Data
.ShotTarget
of
1482 1: str
:= MsgPropTrShotTo1
;
1483 2: str
:= MsgPropTrShotTo2
;
1484 3: str
:= MsgPropTrShotTo3
;
1485 4: str
:= MsgPropTrShotTo4
;
1486 5: str
:= MsgPropTrShotTo5
;
1487 6: str
:= MsgPropTrShotTo6
;
1488 else str
:= MsgPropTrShotTo0
;
1490 with ItemProps
[InsertRow(MsgPropTrShotTo
, str
, True)] do
1492 EditStyle
:= esPickList
;
1496 with ItemProps
[InsertRow(MsgPropTrShotSight
, IntToStr(Data
.ShotIntSight
), True)] do
1498 EditStyle
:= esSimple
;
1502 case Data
.ShotAim
of
1503 1: str
:= MsgPropTrShotAim1
;
1504 2: str
:= MsgPropTrShotAim2
;
1505 3: str
:= MsgPropTrShotAim3
;
1506 else str
:= MsgPropTrShotAim0
;
1508 with ItemProps
[InsertRow(MsgPropTrShotAim
, str
, True)] do
1510 EditStyle
:= esPickList
;
1514 with ItemProps
[InsertRow(MsgPropTrSpawnTo
,
1515 Format('(%d:%d)', [Data
.ShotPos
.X
, Data
.ShotPos
.Y
]), True)] do
1517 EditStyle
:= esEllipsis
;
1521 with ItemProps
[InsertRow(MsgPropTrShotAngle
, IntToStr(Data
.ShotAngle
), True)] do
1523 EditStyle
:= esSimple
;
1527 with ItemProps
[InsertRow(MsgPropTrExDelay
, IntToStr(Data
.ShotWait
), True)] do
1529 EditStyle
:= esSimple
;
1533 with ItemProps
[InsertRow(MsgPropTrShotAcc
, IntToStr(Data
.ShotAccuracy
), True)] do
1535 EditStyle
:= esSimple
;
1539 with ItemProps
[InsertRow(MsgPropTrShotAmmo
, IntToStr(Data
.ShotAmmo
), True)] do
1541 EditStyle
:= esSimple
;
1545 with ItemProps
[InsertRow(MsgPropTrShotReload
, IntToStr(Data
.ShotIntReload
), True)] do
1547 EditStyle
:= esSimple
;
1554 with ItemProps
[InsertRow(MsgPropTrCount
, IntToStr(Data
.FXCount
), True)] do
1556 EditStyle
:= esSimple
;
1560 if Data
.FXType
= 0 then
1561 str
:= MsgPropTrEffectParticle
1563 str
:= MsgPropTrEffectAnimation
;
1564 with ItemProps
[InsertRow(MsgPropTrEffectType
, str
, True)] do
1566 EditStyle
:= esEllipsis
;
1571 if Data
.FXType
= 0 then
1572 case Data
.FXSubType
of
1573 TRIGGER_EFFECT_SLIQUID
:
1574 str
:= MsgPropTrEffectSliquid
;
1575 TRIGGER_EFFECT_LLIQUID
:
1576 str
:= MsgPropTrEffectLliquid
;
1577 TRIGGER_EFFECT_DLIQUID
:
1578 str
:= MsgPropTrEffectDliquid
;
1579 TRIGGER_EFFECT_BLOOD
:
1580 str
:= MsgPropTrEffectBlood
;
1581 TRIGGER_EFFECT_SPARK
:
1582 str
:= MsgPropTrEffectSpark
;
1583 TRIGGER_EFFECT_BUBBLE
:
1584 str
:= MsgPropTrEffectBubble
;
1586 if Data
.FXType
= 1 then
1588 if (Data
.FXSubType
= 0) or (Data
.FXSubType
> EFFECT_FIRE
) then
1589 Data
.FXSubType
:= EFFECT_TELEPORT
;
1590 str
:= EffectToStr(Data
.FXSubType
);
1592 with ItemProps
[InsertRow(MsgPropTrEffectSubtype
, str
, True)] do
1594 EditStyle
:= esEllipsis
;
1598 with ItemProps
[InsertRow(MsgPropTrEffectColor
, IntToStr(Data
.FXColorR
or (Data
.FXColorG
shl 8) or (Data
.FXColorB
shl 16)), True)] do
1600 EditStyle
:= esEllipsis
;
1604 with ItemProps
[InsertRow(MsgPropTrEffectCenter
, BoolNames
[Data
.FXPos
= 0], True)] do
1606 EditStyle
:= esPickList
;
1610 with ItemProps
[InsertRow(MsgPropTrExDelay
, IntToStr(Data
.FXWait
), True)] do
1612 EditStyle
:= esSimple
;
1616 with ItemProps
[InsertRow(MsgPropTrEffectVelx
, IntToStr(Data
.FXVelX
), True)] do
1618 EditStyle
:= esSimple
;
1622 with ItemProps
[InsertRow(MsgPropTrEffectVely
, IntToStr(Data
.FXVelY
), True)] do
1624 EditStyle
:= esSimple
;
1628 with ItemProps
[InsertRow(MsgPropTrEffectSpl
, IntToStr(Data
.FXSpreadL
), True)] do
1630 EditStyle
:= esSimple
;
1634 with ItemProps
[InsertRow(MsgPropTrEffectSpr
, IntToStr(Data
.FXSpreadR
), True)] do
1636 EditStyle
:= esSimple
;
1640 with ItemProps
[InsertRow(MsgPropTrEffectSpu
, IntToStr(Data
.FXSpreadU
), True)] do
1642 EditStyle
:= esSimple
;
1646 with ItemProps
[InsertRow(MsgPropTrEffectSpd
, IntToStr(Data
.FXSpreadD
), True)] do
1648 EditStyle
:= esSimple
;
1652 end; //case TriggerType
1654 end; // OBJECT_TRIGGER:
1658 procedure ChangeShownProperty(Name
: String; NewValue
: String);
1662 if SelectedObjectCount() <> 1 then
1664 if not SelectedObjects
[GetFirstSelected()].Live
then
1667 // Есть ли такой ключ:
1668 if MainForm
.vleObjectProperty
.FindRow(Name
, row
) then
1670 MainForm
.vleObjectProperty
.Values
[Name
] := NewValue
;
1674 procedure SelectObject(fObjectType
: Byte; fID
: DWORD
; Multi
: Boolean);
1683 // Уже выделен - убираем:
1684 if SelectedObjects
<> nil then
1685 for a
:= 0 to High(SelectedObjects
) do
1686 with SelectedObjects
[a
] do
1687 if Live
and (ID
= fID
) and
1688 (ObjectType
= fObjectType
) then
1697 SetLength(SelectedObjects
, Length(SelectedObjects
)+1);
1699 with SelectedObjects
[High(SelectedObjects
)] do
1701 ObjectType
:= fObjectType
;
1708 SetLength(SelectedObjects
, 1);
1710 with SelectedObjects
[0] do
1712 ObjectType
:= fObjectType
;
1718 MainForm
.miCopy
.Enabled
:= True;
1719 MainForm
.miCut
.Enabled
:= True;
1721 if fObjectType
= OBJECT_PANEL
then
1723 MainForm
.miToFore
.Enabled
:= True;
1724 MainForm
.miToBack
.Enabled
:= True;
1728 procedure RemoveSelectFromObjects();
1730 SelectedObjects
:= nil;
1731 DrawPressRect
:= False;
1732 MouseLDown
:= False;
1733 MouseRDown
:= False;
1734 MouseAction
:= MOUSEACTION_NONE
;
1735 SelectFlag
:= SELECTFLAG_NONE
;
1736 ResizeType
:= RESIZETYPE_NONE
;
1737 ResizeDirection
:= RESIZEDIR_NONE
;
1739 MainForm
.vleObjectProperty
.Strings
.Clear();
1741 MainForm
.miCopy
.Enabled
:= False;
1742 MainForm
.miCut
.Enabled
:= False;
1743 MainForm
.miToFore
.Enabled
:= False;
1744 MainForm
.miToBack
.Enabled
:= False;
1747 procedure DeleteSelectedObjects();
1752 if SelectedObjects
= nil then
1758 for a
:= 0 to High(SelectedObjects
) do
1759 with SelectedObjects
[a
] do
1764 SetLength(UndoBuffer
, Length(UndoBuffer
)+1);
1765 i
:= High(UndoBuffer
);
1769 SetLength(UndoBuffer
[i
], Length(UndoBuffer
[i
])+1);
1770 ii
:= High(UndoBuffer
[i
]);
1775 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_PANEL
;
1776 New(UndoBuffer
[i
, ii
].Panel
);
1777 UndoBuffer
[i
, ii
].Panel
^ := gPanels
[ID
];
1781 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_ITEM
;
1782 UndoBuffer
[i
, ii
].Item
:= gItems
[ID
];
1786 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_AREA
;
1787 UndoBuffer
[i
, ii
].Area
:= gAreas
[ID
];
1791 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_TRIGGER
;
1792 UndoBuffer
[i
, ii
].Trigger
:= gTriggers
[ID
];
1796 RemoveObject(ID
, ObjectType
);
1799 RemoveSelectFromObjects();
1801 MainForm
.miUndo
.Enabled
:= UndoBuffer
<> nil;
1802 MainForm
.RecountSelectedObjects();
1805 procedure Undo_Add(ObjectType
: Byte; ID
: DWORD
; Group
: Boolean = False);
1809 if (not Group
) or (Length(UndoBuffer
) = 0) then
1810 SetLength(UndoBuffer
, Length(UndoBuffer
)+1);
1811 SetLength(UndoBuffer
[High(UndoBuffer
)], Length(UndoBuffer
[High(UndoBuffer
)])+1);
1812 i
:= High(UndoBuffer
);
1813 ii
:= High(UndoBuffer
[i
]);
1817 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_PANEL
;
1819 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_ITEM
;
1821 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_MONSTER
;
1823 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_AREA
;
1825 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_TRIGGER
;
1828 UndoBuffer
[i
, ii
].AddID
:= ID
;
1829 MainForm
.miUndo
.Enabled
:= UndoBuffer
<> nil;
1832 procedure DiscardUndoBuffer();
1836 for i
:= 0 to High(UndoBuffer
) do
1837 for k
:= 0 to High(UndoBuffer
[i
]) do
1838 with UndoBuffer
[i
][k
] do
1839 if UndoType
= UNDO_DELETE_PANEL
then
1845 procedure FullClear();
1847 RemoveSelectFromObjects();
1849 LoadSky(gMapInfo
.SkyName
);
1850 DiscardUndoBuffer();
1851 slInvalidTextures
.Clear();
1852 MapCheckForm
.lbErrorList
.Clear();
1853 MapCheckForm
.mErrorDescription
.Clear();
1855 MainForm
.miUndo
.Enabled
:= False;
1856 MainForm
.sbHorizontal
.Position
:= 0;
1857 MainForm
.sbVertical
.Position
:= 0;
1858 MainForm
.FormResize(nil);
1859 MainForm
.Caption
:= FormCaption
;
1864 procedure ErrorMessageBox(str
: String);
1866 Application
.MessageBox(PChar(str
), PChar(MsgMsgError
),
1867 MB_ICONINFORMATION
or MB_OK
or MB_DEFBUTTON1
);
1870 function CheckProperty(): Boolean;
1876 _id
:= GetFirstSelected();
1878 if SelectedObjects
[_id
].ObjectType
= OBJECT_PANEL
then
1879 with gPanels
[SelectedObjects
[_id
].ID
] do
1881 if TextureWidth
<> 0 then
1882 if StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropWidth
], 1) mod TextureWidth
<> 0 then
1884 ErrorMessageBox(Format(MsgMsgWrongTexwidth
,
1889 if TextureHeight
<> 0 then
1890 if StrToIntDef(Trim(MainForm
.vleObjectProperty
.Values
[MsgPropHeight
]), 1) mod TextureHeight
<> 0 then
1892 ErrorMessageBox(Format(MsgMsgWrongTexheight
,
1897 if IsTexturedPanel(PanelType
) and (TextureName
<> '') then
1898 if not (StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropPanelAlpha
], -1) in [0..255]) then
1900 ErrorMessageBox(MsgMsgWrongAlpha
);
1905 if SelectedObjects
[_id
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
] then
1906 if (StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropWidth
], 0) <= 0) or
1907 (StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropHeight
], 0) <= 0) then
1909 ErrorMessageBox(MsgMsgWrongSize
);
1913 if (Trim(MainForm
.vleObjectProperty
.Values
[MsgPropX
]) = '') or
1914 (Trim(MainForm
.vleObjectProperty
.Values
[MsgPropY
]) = '') then
1916 ErrorMessageBox(MsgMsgWrongXy
);
1923 procedure SelectTexture(ID
: Integer);
1925 MainForm
.lbTextureList
.ItemIndex
:= ID
;
1926 MainForm
.lbTextureListClick(nil);
1929 function AddTexture(aWAD
, aSection
, aTex
: String; silent
: Boolean): Boolean;
1931 a
, FrameLen
: Integer;
1934 ResourceName
: String;
1935 FullResourceName
: String;
1936 SectionName
: String;
1938 Width
, Height
: Word;
1946 if aSection
= '..' then
1949 SectionName
:= aSection
;
1952 aWAD
:= MsgWadSpecialMap
;
1954 if aWAD
= MsgWadSpecialMap
then
1956 g_ProcessResourceStr(OpenedMap
, @fn
, nil, nil);
1958 ResourceName
:= ':'+SectionName
+'\'+aTex
;
1961 if aWAD
= MsgWadSpecialTexs
then
1962 begin // Спец. текстуры
1964 ResourceName
:= aTex
;
1967 begin // Внешний WAD
1968 FileName
:= WadsDir
+ DirectorySeparator
+ aWAD
;
1969 ResourceName
:= aWAD
+':'+SectionName
+'\'+aTex
;
1974 // Есть ли уже такая текстура:
1975 for a
:= 0 to MainForm
.lbTextureList
.Items
.Count
-1 do
1976 if ResourceName
= MainForm
.lbTextureList
.Items
[a
] then
1979 ErrorMessageBox(Format(MsgMsgTextureAlready
,
1984 // Название ресурса <= 64 символов:
1985 if Length(ResourceName
) > 64 then
1988 ErrorMessageBox(Format(MsgMsgResName64
,
1996 if aWAD
= MsgWadSpecialTexs
then
1998 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
2005 FullResourceName
:= FileName
+':'+SectionName
+'\'+aTex
;
2007 if IsAnim(FullResourceName
) then
2008 begin // Аним. текстура
2009 GetFrame(FullResourceName
, Data
, FrameLen
, Width
, Height
);
2011 if not g_CreateTextureMemorySize(Data
, FrameLen
, ResourceName
, 0, 0, Width
, Height
, 1) then
2013 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
2015 else // Обычная текстура
2017 if not g_CreateTextureWAD(ResourceName
, FullResourceName
) then
2019 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
2021 if (not ok
) and (slInvalidTextures
.IndexOf(ResourceName
) = -1) then
2023 slInvalidTextures
.Add(ResourceName
);
2026 if (a
> -1) and (not silent
) then
2033 procedure UpdateCaption(sMap
, sFile
, sRes
: String);
2036 if (sFile
= '') and (sRes
= '') and (sMap
= '') then
2037 Caption
:= FormCaption
2040 Caption
:= Format('%s - %s:%s', [FormCaption
, sFile
, sRes
])
2042 if (sFile
<> '') and (sRes
<> '') then
2043 Caption
:= Format('%s - %s (%s:%s)', [FormCaption
, sMap
, sFile
, sRes
])
2045 Caption
:= Format('%s - %s', [FormCaption
, sMap
]);
2048 procedure OpenMap(FileName
: String; mapN
: String);
2053 SelectMapForm
.Caption
:= MsgCapOpen
;
2054 SelectMapForm
.GetMaps(FileName
);
2056 if (FileName
= OpenedWAD
) and
2057 (OpenedMap
<> '') then
2059 MapName
:= OpenedMap
;
2060 while (Pos(':\', MapName
) > 0) do
2061 Delete(MapName
, 1, Pos(':\', MapName
) + 1);
2063 idx
:= SelectMapForm
.lbMapList
.Items
.IndexOf(MapName
);
2064 SelectMapForm
.lbMapList
.ItemIndex
:= idx
;
2067 if SelectMapForm
.lbMapList
.Count
> 0 then
2068 SelectMapForm
.lbMapList
.ItemIndex
:= 0
2070 SelectMapForm
.lbMapList
.ItemIndex
:= -1;
2075 idx
:= SelectMapForm
.lbMapList
.Items
.IndexOf(mapN
);
2079 if (SelectMapForm
.ShowModal() = mrOK
) and
2080 (SelectMapForm
.lbMapList
.ItemIndex
<> -1) then
2081 idx
:= SelectMapForm
.lbMapList
.ItemIndex
2086 MapName
:= SelectMapForm
.lbMapList
.Items
[idx
];
2092 pLoadProgress
.Left
:= (RenderPanel
.Width
div 2)-(pLoadProgress
.Width
div 2);
2093 pLoadProgress
.Top
:= (RenderPanel
.Height
div 2)-(pLoadProgress
.Height
div 2);
2094 pLoadProgress
.Show();
2096 OpenedMap
:= FileName
+':\'+MapName
;
2097 OpenedWAD
:= FileName
;
2099 idx
:= RecentFiles
.IndexOf(OpenedMap
);
2100 // Такая карта уже недавно открывалась:
2102 RecentFiles
.Delete(idx
);
2103 RecentFiles
.Insert(0, OpenedMap
);
2104 RefreshRecentMenu();
2108 pLoadProgress
.Hide();
2111 lbTextureList
.Sorted
:= True;
2112 lbTextureList
.Sorted
:= False;
2114 UpdateCaption(gMapInfo
.Name
, ExtractFileName(FileName
), MapName
);
2118 procedure MoveSelectedObjects(Wall
, alt
: Boolean; dx
, dy
: Integer);
2123 if SelectedObjects
= nil then
2130 for a
:= 0 to High(SelectedObjects
) do
2131 if SelectedObjects
[a
].Live
then
2133 if ObjectCollideLevel(SelectedObjects
[a
].ID
, SelectedObjects
[a
].ObjectType
, dx
, 0) then
2136 if ObjectCollideLevel(SelectedObjects
[a
].ID
, SelectedObjects
[a
].ObjectType
, 0, dy
) then
2139 if (not okX
) or (not okY
) then
2145 for a
:= 0 to High(SelectedObjects
) do
2146 if SelectedObjects
[a
].Live
then
2149 MoveObject(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
, dx
, 0);
2152 MoveObject(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
, 0, dy
);
2154 if alt
and (SelectedObjects
[a
].ObjectType
= OBJECT_TRIGGER
) then
2156 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_PRESS
,
2157 TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
] then
2158 begin // Двигаем зону Расширителя
2160 gTriggers
[SelectedObjects
[a
].ID
].Data
.tX
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.tX
+dx
;
2162 gTriggers
[SelectedObjects
[a
].ID
].Data
.tY
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.tY
+dy
;
2165 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_TELEPORT
] then
2166 begin // Двигаем точку назначения Телепорта
2168 gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.X
+dx
;
2170 gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.Y
+dy
;
2173 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SPAWNMONSTER
] then
2174 begin // Двигаем точку создания монстра
2176 gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.X
+dx
;
2178 gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.Y
+dy
;
2181 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SPAWNITEM
] then
2182 begin // Двигаем точку создания предмета
2184 gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.X
+dx
;
2186 gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.Y
+dy
;
2189 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SHOT
] then
2190 begin // Двигаем точку создания выстрела
2192 gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.X
+dx
;
2194 gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.Y
+dy
;
2199 LastMovePoint
:= MousePos
;
2203 procedure ShowLayer(Layer
: Byte; show
: Boolean);
2205 LayerEnabled
[Layer
] := show
;
2210 MainForm
.miLayer1
.Checked
:= show
;
2211 MainForm
.miLayerP1
.Checked
:= show
;
2215 MainForm
.miLayer2
.Checked
:= show
;
2216 MainForm
.miLayerP2
.Checked
:= show
;
2220 MainForm
.miLayer3
.Checked
:= show
;
2221 MainForm
.miLayerP3
.Checked
:= show
;
2225 MainForm
.miLayer4
.Checked
:= show
;
2226 MainForm
.miLayerP4
.Checked
:= show
;
2230 MainForm
.miLayer5
.Checked
:= show
;
2231 MainForm
.miLayerP5
.Checked
:= show
;
2235 MainForm
.miLayer6
.Checked
:= show
;
2236 MainForm
.miLayerP6
.Checked
:= show
;
2240 MainForm
.miLayer7
.Checked
:= show
;
2241 MainForm
.miLayerP7
.Checked
:= show
;
2245 MainForm
.miLayer8
.Checked
:= show
;
2246 MainForm
.miLayerP8
.Checked
:= show
;
2250 MainForm
.miLayer9
.Checked
:= show
;
2251 MainForm
.miLayerP9
.Checked
:= show
;
2255 RemoveSelectFromObjects();
2258 procedure SwitchLayer(Layer
: Byte);
2260 ShowLayer(Layer
, not LayerEnabled
[Layer
]);
2263 procedure SwitchMap();
2265 ShowMap
:= not ShowMap
;
2266 MainForm
.tbShowMap
.Down
:= ShowMap
;
2267 MainForm
.miMiniMap
.Checked
:= ShowMap
;
2270 procedure ShowEdges();
2272 if drEdge
[3] < 255 then
2275 drEdge
[3] := gAlphaEdge
;
2276 MainForm
.miShowEdges
.Checked
:= drEdge
[3] <> 255;
2279 function SelectedTexture(): String;
2281 if MainForm
.lbTextureList
.ItemIndex
<> -1 then
2282 Result
:= MainForm
.lbTextureList
.Items
[MainForm
.lbTextureList
.ItemIndex
]
2287 function IsSpecialTextureSel(): Boolean;
2289 Result
:= (MainForm
.lbTextureList
.ItemIndex
<> -1) and
2290 IsSpecialTexture(MainForm
.lbTextureList
.Items
[MainForm
.lbTextureList
.ItemIndex
]);
2293 function CopyBufferToString(var CopyBuf
: TCopyRecArray
): String;
2298 procedure AddInt(x
: Integer);
2300 Res
:= Res
+ IntToStr(x
) + ' ';
2306 if Length(CopyBuf
) = 0 then
2309 Res
:= CLIPBOARD_SIG
+ ' ';
2311 for i
:= 0 to High(CopyBuf
) do
2313 if (CopyBuf
[i
].ObjectType
= OBJECT_PANEL
) and
2314 (CopyBuf
[i
].Panel
= nil) then
2318 AddInt(CopyBuf
[i
].ObjectType
);
2321 // Свойства объекта:
2322 case CopyBuf
[i
].ObjectType
of
2324 with CopyBuf
[i
].Panel
^ do
2331 Res
:= Res
+ '"' + TextureName
+ '" ';
2333 AddInt(IfThen(Blending
, 1, 0));
2337 with CopyBuf
[i
].Item
do
2342 AddInt(IfThen(OnlyDM
, 1, 0));
2343 AddInt(IfThen(Fall
, 1, 0));
2347 with CopyBuf
[i
].Monster
do
2349 AddInt(MonsterType
);
2352 AddInt(IfThen(Direction
= D_LEFT
, 1, 0));
2356 with CopyBuf
[i
].Area
do
2361 AddInt(IfThen(Direction
= D_LEFT
, 1, 0));
2365 with CopyBuf
[i
].Trigger
do
2367 AddInt(TriggerType
);
2372 AddInt(ActivateType
);
2374 AddInt(IfThen(Enabled
, 1, 0));
2375 AddInt(TexturePanel
);
2377 for j
:= 0 to 127 do
2378 AddInt(Data
.Default
[j
]);
2386 procedure StringToCopyBuffer(Str
: String; var CopyBuf
: TCopyRecArray
; var pmin
: TPoint
);
2389 minArea
, newArea
, newX
, newY
: LongInt;
2391 function GetNext(): String;
2396 if Str
[1] = '"' then
2408 Result
:= Copy(Str
, 1, p
-1);
2424 Result
:= Copy(Str
, 1, p
-1);
2432 minArea
:= High(minArea
);
2435 if GetNext() <> CLIPBOARD_SIG
then
2441 t
:= StrToIntDef(GetNext(), 0);
2443 if (t
< OBJECT_PANEL
) or (t
> OBJECT_TRIGGER
) or (GetNext() <> ';') then
2444 begin // Что-то не то => пропускаем:
2452 i
:= Length(CopyBuf
);
2453 SetLength(CopyBuf
, i
+ 1);
2455 CopyBuf
[i
].ObjectType
:= t
;
2456 CopyBuf
[i
].Panel
:= nil;
2458 // Свойства объекта:
2462 New(CopyBuf
[i
].Panel
);
2464 with CopyBuf
[i
].Panel
^ do
2466 PanelType
:= StrToIntDef(GetNext(), PANEL_WALL
);
2467 X
:= StrToIntDef(GetNext(), 0);
2468 Y
:= StrToIntDef(GetNext(), 0);
2469 Width
:= StrToIntDef(GetNext(), 16);
2470 Height
:= StrToIntDef(GetNext(), 16);
2471 TextureName
:= GetNext();
2472 Alpha
:= StrToIntDef(GetNext(), 0);
2473 Blending
:= (GetNext() = '1');
2474 newArea
:= X
* Y
- Width
* Height
;
2481 with CopyBuf
[i
].Item
do
2483 ItemType
:= StrToIntDef(GetNext(), ITEM_MEDKIT_SMALL
);
2484 X
:= StrToIntDef(GetNext(), 0);
2485 Y
:= StrToIntDef(GetNext(), 0);
2486 OnlyDM
:= (GetNext() = '1');
2487 Fall
:= (GetNext() = '1');
2494 with CopyBuf
[i
].Monster
do
2496 MonsterType
:= StrToIntDef(GetNext(), MONSTER_DEMON
);
2497 X
:= StrToIntDef(GetNext(), 0);
2498 Y
:= StrToIntDef(GetNext(), 0);
2500 then Direction
:= D_LEFT
2501 else Direction
:= D_RIGHT
;
2508 with CopyBuf
[i
].Area
do
2510 AreaType
:= StrToIntDef(GetNext(), AREA_PLAYERPOINT1
);
2511 X
:= StrToIntDef(GetNext(), 0);
2512 Y
:= StrToIntDef(GetNext(), 0);
2514 then Direction
:= D_LEFT
2515 else Direction
:= D_RIGHT
;
2522 with CopyBuf
[i
].Trigger
do
2524 TriggerType
:= StrToIntDef(GetNext(), TRIGGER_EXIT
);
2525 X
:= StrToIntDef(GetNext(), 0);
2526 Y
:= StrToIntDef(GetNext(), 0);
2527 Width
:= StrToIntDef(GetNext(), 16);
2528 Height
:= StrToIntDef(GetNext(), 16);
2529 ActivateType
:= StrToIntDef(GetNext(), 0);
2530 Key
:= StrToIntDef(GetNext(), 0);
2531 Enabled
:= (GetNext() = '1');
2532 TexturePanel
:= StrToIntDef(GetNext(), 0);
2534 do Data
.Default
[j
] := StrToIntDef(GetNext(), 0);
2535 newArea
:= X
* Y
- Width
* Height
;
2541 if newArea
< minArea
then
2550 //----------------------------------------
2551 //Закончились вспомогательные процедуры
2552 //----------------------------------------
2554 procedure TMainForm
.miRecentFileExecute (Sender
: TObject
);
2558 s
:= RecentFiles
[(Sender
as TMenuItem
).Tag
];
2559 fn
:= g_ExtractWadName(s
);
2560 if FileExists(fn
) then
2561 OpenMap(fn
, g_ExtractFilePathName(s
))
2563 Application
.MessageBox('File not available anymore', '', MB_OK
);
2564 // if Application.MessageBox(PChar(MsgMsgDelRecentPrompt), PChar(MsgMsgDelRecent), MB_ICONQUESTION or MB_YESNO) = idYes then
2566 // RecentFiles.Delete(n);
2567 // RefreshRecentMenu();
2571 procedure TMainForm
.RefillRecentMenu (menu
: TMenuItem
; start
: Integer; fmt
: AnsiString);
2572 var i
: Integer; MI
: TMenuItem
; s
: AnsiString;
2574 Assert(menu
<> nil);
2576 Assert(start
<= menu
.Count
);
2578 // clear all the recent entries from menu
2580 while i
< menu
.Count
do
2582 MI
:= menu
.Items
[i
];
2583 if @MI
.OnClick
<> @TMainForm
.miRecentFileExecute
then
2592 // fill with a new ones
2593 for i
:= 0 to RecentFiles
.Count
-1 do
2595 MI
:= TMenuItem
.Create(menu
);
2596 s
:= RecentFiles
[i
];
2597 MI
.Caption
:= Format(fmt
, [i
+1, g_ExtractWadNameNoPath(s
), g_ExtractFilePathName(s
)]);
2598 MI
.OnClick
:= miRecentFileExecute
;
2600 menu
.Insert(start
+ i
, MI
); // transfers ownership
2604 procedure TMainForm
.RefreshRecentMenu();
2607 while RecentFiles
.Count
> RecentCount
do
2608 RecentFiles
.Delete(RecentFiles
.Count
- 1);
2610 if miMacRecentSubMenu
.Visible
then
2612 // Reconstruct OSX-like recent list
2613 RefillRecentMenu(miMacRecentSubMenu
, 0, '%1:s - %2:s');
2614 miMacRecentEnd
.Enabled
:= RecentFiles
.Count
<> 0;
2615 miMacRecentEnd
.Visible
:= RecentFiles
.Count
<> 0;
2618 if miWinRecentStart
.Visible
then
2620 // Reconstruct Windows-like recent list
2621 start
:= miMenuFile
.IndexOf(miWinRecent
);
2622 if start
< 0 then start
:= miMenuFile
.Count
else start
+= 1;
2623 RefillRecentMenu(miMenuFile
, start
, '%0:d %1:s:%2:s');
2624 miWinRecent
.Enabled
:= False;
2625 miWinRecent
.Visible
:= RecentFiles
.Count
= 0;
2629 procedure TMainForm
.miMacRecentClearClick(Sender
: TObject
);
2631 RecentFiles
.Clear();
2632 RefreshRecentMenu();
2635 procedure TMainForm
.aEditorOptionsExecute(Sender
: TObject
);
2637 OptionsForm
.ShowModal();
2640 procedure LoadStdFont(cfgres
, texture
: string; var FontID
: DWORD
);
2654 wad
:= TWADEditor_1
.Create
;
2655 if wad
.ReadFile(GameWad
) then
2656 wad
.GetResource('FONTS', cfgres
, cfgdata
, cfglen
);
2661 if not g_CreateTextureWAD('FONT_STD', GameWad
+ ':FONTS\' + texture
) then
2662 e_WriteLog('ERROR ERROR ERROR', MSG_WARNING
);
2664 config
:= TConfig
.CreateMem(cfgdata
, cfglen
);
2665 cwdt
:= Min(Max(config
.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
2666 chgt
:= Min(Max(config
.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
2667 spc
:= Min(Max(config
.ReadInt('FontMap', 'Kerning', 0), -128), 127);
2669 if g_GetTexture('FONT_STD', ID
) then
2670 e_TextureFontBuild(ID
, FontID
, cwdt
, chgt
, spc
-2);
2675 e_WriteLog('Could not load FONT_STD', MSG_WARNING
);
2677 if cfglen
<> 0 then FreeMem(cfgdata
);
2680 procedure TMainForm
.FormCreate(Sender
: TObject
);
2690 miApple
.Enabled
:= True;
2691 miApple
.Visible
:= True;
2692 miMacRecentSubMenu
.Enabled
:= True;
2693 miMacRecentSubMenu
.Visible
:= True;
2694 miWinRecentStart
.Enabled
:= False;
2695 miWinRecentStart
.Visible
:= False;
2696 miWinRecent
.Enabled
:= False;
2697 miWinRecent
.Visible
:= False;
2698 miLine2
.Enabled
:= False;
2699 miLine2
.Visible
:= False;
2700 miExit
.Enabled
:= False;
2701 miExit
.Visible
:= False;
2702 miOptions
.Enabled
:= False;
2703 miOptions
.Visible
:= False;
2704 miMenuWindow
.Enabled
:= True;
2705 miMenuWindow
.Visible
:= True;
2706 miAbout
.Enabled
:= False;
2707 miAbout
.Visible
:= False;
2709 miApple
.Enabled
:= False;
2710 miApple
.Visible
:= False;
2711 miMacRecentSubMenu
.Enabled
:= False;
2712 miMacRecentSubMenu
.Visible
:= False;
2713 miWinRecentStart
.Enabled
:= True;
2714 miWinRecentStart
.Visible
:= True;
2715 miWinRecent
.Enabled
:= True;
2716 miWinRecent
.Visible
:= True;
2717 miLine2
.Enabled
:= True;
2718 miLine2
.Visible
:= True;
2719 miExit
.Enabled
:= True;
2720 miExit
.Visible
:= True;
2721 miOptions
.Enabled
:= True;
2722 miOptions
.Visible
:= True;
2723 miMenuWindow
.Enabled
:= False;
2724 miMenuWindow
.Visible
:= False;
2725 miAbout
.Enabled
:= True;
2726 miAbout
.Visible
:= True;
2729 miNewMap
.ShortCut
:= ShortCut(VK_N
, [ssModifier
]);
2730 miOpenMap
.ShortCut
:= ShortCut(VK_O
, [ssModifier
]);
2731 miSaveMap
.ShortCut
:= ShortCut(VK_S
, [ssModifier
]);
2733 miSaveMapAs
.ShortCut
:= ShortCut(VK_S
, [ssModifier
, ssShift
]);
2734 miReopenMap
.ShortCut
:= ShortCut(VK_F5
, [ssModifier
]);
2736 miUndo
.ShortCut
:= ShortCut(VK_Z
, [ssModifier
]);
2737 miCopy
.ShortCut
:= ShortCut(VK_C
, [ssModifier
]);
2738 miCut
.ShortCut
:= ShortCut(VK_X
, [ssModifier
]);
2739 miPaste
.ShortCut
:= ShortCut(VK_V
, [ssModifier
]);
2740 miSelectAll
.ShortCut
:= ShortCut(VK_A
, [ssModifier
]);
2741 miToFore
.ShortCut
:= ShortCut(VK_LCL_CLOSE_BRACKET
, [ssModifier
]);
2742 miToBack
.ShortCut
:= ShortCut(VK_LCL_OPEN_BRACKET
, [ssModifier
]);
2744 miMapOptions
.Shortcut
:= ShortCut(VK_P
, [ssModifier
, ssAlt
]);
2745 selectall1
.Shortcut
:= ShortCut(VK_A
, [ssModifier
, ssAlt
]);
2748 e_WriteLog('Doom 2D: Forever Editor version ' + EDITOR_VERSION
, MSG_NOTIFY
);
2749 e_WriteLog('Build date: ' + EDITOR_BUILDDATE
+ ' ' + EDITOR_BUILDTIME
, MSG_NOTIFY
);
2750 e_WriteLog('Build hash: ' + g_GetBuildHash(), MSG_NOTIFY
);
2751 e_WriteLog('Build by: ' + g_GetBuilderName(), MSG_NOTIFY
);
2753 slInvalidTextures
:= TStringList
.Create
;
2755 ShowLayer(LAYER_BACK
, True);
2756 ShowLayer(LAYER_WALLS
, True);
2757 ShowLayer(LAYER_FOREGROUND
, True);
2758 ShowLayer(LAYER_STEPS
, True);
2759 ShowLayer(LAYER_WATER
, True);
2760 ShowLayer(LAYER_ITEMS
, True);
2761 ShowLayer(LAYER_MONSTERS
, True);
2762 ShowLayer(LAYER_AREAS
, True);
2763 ShowLayer(LAYER_TRIGGERS
, True);
2767 FormCaption
:= MainForm
.Caption
;
2771 config
:= TConfig
.CreateFile(CfgFileName
);
2773 gWADEditorLogLevel
:= config
.ReadInt('WADEditor', 'LogLevel', DFWAD_LOG_DEFAULT
);
2775 if config
.ReadInt('Editor', 'XPos', -1) = -1 then
2776 Position
:= poDesktopCenter
2778 Left
:= config
.ReadInt('Editor', 'XPos', Left
);
2779 Top
:= config
.ReadInt('Editor', 'YPos', Top
);
2780 Width
:= config
.ReadInt('Editor', 'Width', Width
);
2781 Height
:= config
.ReadInt('Editor', 'Height', Height
);
2783 if config
.ReadBool('Editor', 'Maximize', False) then
2784 WindowState
:= wsMaximized
;
2785 ShowMap
:= config
.ReadBool('Editor', 'Minimap', False);
2786 PanelProps
.Width
:= config
.ReadInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
2787 Splitter1
.Left
:= PanelProps
.Left
;
2788 PanelObjs
.Height
:= config
.ReadInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
2789 Splitter2
.Top
:= PanelObjs
.Top
;
2790 StatusBar
.Top
:= PanelObjs
.BoundsRect
.Bottom
;
2791 DotEnable
:= config
.ReadBool('Editor', 'DotEnable', True);
2792 DotColor
:= config
.ReadInt('Editor', 'DotColor', $FFFFFF);
2793 DotStepOne
:= config
.ReadInt('Editor', 'DotStepOne', 16);
2794 DotStepTwo
:= config
.ReadInt('Editor', 'DotStepTwo', 8);
2795 DotStep
:= config
.ReadInt('Editor', 'DotStep', DotStepOne
);
2796 DrawTexturePanel
:= config
.ReadBool('Editor', 'DrawTexturePanel', True);
2797 DrawPanelSize
:= config
.ReadBool('Editor', 'DrawPanelSize', True);
2798 BackColor
:= config
.ReadInt('Editor', 'BackColor', $7F6040);
2799 PreviewColor
:= config
.ReadInt('Editor', 'PreviewColor', $00FF00);
2800 UseCheckerboard
:= config
.ReadBool('Editor', 'UseCheckerboard', True);
2801 gColorEdge
:= config
.ReadInt('Editor', 'EdgeColor', COLOR_EDGE
);
2802 gAlphaEdge
:= config
.ReadInt('Editor', 'EdgeAlpha', ALPHA_EDGE
);
2803 if gAlphaEdge
= 255 then
2804 gAlphaEdge
:= ALPHA_EDGE
;
2805 drEdge
[0] := GetRValue(gColorEdge
);
2806 drEdge
[1] := GetGValue(gColorEdge
);
2807 drEdge
[2] := GetBValue(gColorEdge
);
2808 if not config
.ReadBool('Editor', 'EdgeShow', True) then
2811 drEdge
[3] := gAlphaEdge
;
2812 gAlphaTriggerLine
:= config
.ReadInt('Editor', 'LineAlpha', ALPHA_LINE
);
2813 if gAlphaTriggerLine
= 255 then
2814 gAlphaTriggerLine
:= ALPHA_LINE
;
2815 gAlphaTriggerArea
:= config
.ReadInt('Editor', 'TriggerAlpha', ALPHA_AREA
);
2816 if gAlphaTriggerArea
= 255 then
2817 gAlphaTriggerArea
:= ALPHA_AREA
;
2818 gAlphaMonsterRect
:= config
.ReadInt('Editor', 'MonsterRectAlpha', 0);
2819 gAlphaAreaRect
:= config
.ReadInt('Editor', 'AreaRectAlpha', 0);
2820 Scale
:= Max(config
.ReadInt('Editor', 'Scale', 1), 1);
2821 DotSize
:= Max(config
.ReadInt('Editor', 'DotSize', 1), 1);
2822 OpenDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastOpenDir', MapsDir
);
2823 SaveDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastSaveDir', MapsDir
);
2825 s
:= config
.ReadStr('Editor', 'Language', '');
2828 TestGameMode
:= config
.ReadStr('TestRun', 'GameMode', 'DM');
2829 TestLimTime
:= config
.ReadStr('TestRun', 'LimTime', '0');
2830 TestLimScore
:= config
.ReadStr('TestRun', 'LimScore', '0');
2831 TestOptionsTwoPlayers
:= config
.ReadBool('TestRun', 'TwoPlayers', False);
2832 TestOptionsTeamDamage
:= config
.ReadBool('TestRun', 'TeamDamage', False);
2833 TestOptionsAllowExit
:= config
.ReadBool('TestRun', 'AllowExit', True);
2834 TestOptionsWeaponStay
:= config
.ReadBool('TestRun', 'WeaponStay', False);
2835 TestOptionsMonstersDM
:= config
.ReadBool('TestRun', 'MonstersDM', False);
2836 TestMapOnce
:= config
.ReadBool('TestRun', 'MapOnce', False);
2837 {$IF DEFINED(DARWIN)}
2838 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeDrawin', GameExeFile
);
2839 {$ELSEIF DEFINED(WINDOWS)}
2840 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeWindows', GameExeFile
);
2842 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeUnix', GameExeFile
);
2844 TestD2DArgs
:= config
.ReadStr('TestRun', 'Args', '');
2846 RecentCount
:= config
.ReadInt('Editor', 'RecentCount', 5);
2847 if RecentCount
> 10 then
2849 if RecentCount
< 2 then
2852 RecentFiles
:= TStringList
.Create();
2853 for i
:= 0 to RecentCount
-1 do
2856 s
:= config
.ReadStr('RecentFilesWin', IntToStr(i
), '');
2858 s
:= config
.ReadStr('RecentFilesUnix', IntToStr(i
), '');
2863 RefreshRecentMenu();
2867 tbShowMap
.Down
:= ShowMap
;
2868 tbGridOn
.Down
:= DotEnable
;
2869 pcObjects
.ActivePageIndex
:= 0;
2870 Application
.Title
:= MsgEditorTitle
;
2872 Application
.OnIdle
:= OnIdle
;
2875 procedure PrintBlack(X
, Y
: Integer; Text: string; FontID
: DWORD
);
2877 // NOTE: all the font printing routines assume CP1251
2878 e_TextureFontPrintEx(X
, Y
, Text, FontID
, 0, 0, 0, 1.0);
2881 procedure InitGraphics
;
2883 // FIXME: this is a shitty hack
2884 if not gDataLoaded
then
2886 e_WriteLog('Init OpenGL', MSG_NOTIFY
);
2888 e_WriteLog('Loading data', MSG_NOTIFY
);
2889 LoadStdFont('STDTXT', 'STDFONT', gEditorFont
);
2890 e_WriteLog('Loading more data', MSG_NOTIFY
);
2892 e_WriteLog('Loading even more data', MSG_NOTIFY
);
2893 gDataLoaded
:= True;
2894 MainForm
.FormResize(nil);
2898 procedure TMainForm
.Draw();
2903 Width
, Height
: Word;
2906 aX
, aY
, aX2
, aY2
, XX
, ScaleSz
: Integer;
2908 LastDrawTime
:= GetTickCount64();
2918 e_Clear(GL_COLOR_BUFFER_BIT
,
2919 GetRValue(BackColor
)/255,
2920 GetGValue(BackColor
)/255,
2921 GetBValue(BackColor
)/255);
2925 ObjCount
:= SelectedObjectCount();
2927 // Обводим выделенные объекты красной рамкой:
2928 if ObjCount
> 0 then
2930 for a
:= 0 to High(SelectedObjects
) do
2931 if SelectedObjects
[a
].Live
then
2933 Rect
:= ObjectGetRect(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
);
2937 e_DrawQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2938 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2941 // Рисуем точки изменения размеров:
2942 if (ObjCount
= 1) and
2943 (SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) then
2945 e_DrawPoint(5, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2946 e_DrawPoint(5, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2947 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 255, 255);
2948 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 255, 255);
2950 e_DrawPoint(3, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2951 e_DrawPoint(3, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2952 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 0, 0);
2953 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 0, 0);
2960 if DotEnable
and (PreviewMode
= 0) then
2967 glDisable(GL_TEXTURE_2D
);
2968 glColor3ub(GetRValue(DotColor
), GetGValue(DotColor
), GetBValue(DotColor
));
2969 glPointSize(DotSize
);
2971 x
:= MapOffset
.X
mod DotStep
;
2972 while x
< RenderPanel
.Width
do
2974 y
:= MapOffset
.Y
mod DotStep
;
2975 while y
< RenderPanel
.Height
do
2977 glVertex2i(x
+ a
, y
+ a
);
2983 glColor4ub(e_Colors
.R
, e_Colors
.G
, e_Colors
.B
, 255);
2987 if (lbTextureList
.ItemIndex
<> -1) and (cbPreview
.Checked
) and
2988 (not IsSpecialTextureSel()) and (PreviewMode
= 0) then
2990 if not g_GetTexture(SelectedTexture(), ID
) then
2991 g_GetTexture('NOTEXTURE', ID
);
2992 g_GetTextureSizeByID(ID
, Width
, Height
);
2993 if UseCheckerboard
then
2995 if g_GetTexture('PREVIEW', PID
) then
2996 e_DrawFill(PID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, Width
div 16 + 1, Height
div 16 + 1, 0, True, False);
2998 e_DrawFillQuad(RenderPanel
.Width
-Width
-2, RenderPanel
.Height
-Height
-2,
2999 RenderPanel
.Width
-1, RenderPanel
.Height
-1,
3000 GetRValue(PreviewColor
), GetGValue(PreviewColor
), GetBValue(PreviewColor
), 0);
3001 e_Draw(ID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, 0, True, False);
3004 // Подсказка при выборе точки Телепорта:
3005 if SelectFlag
= SELECTFLAG_TELEPORT
then
3007 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
3008 if Data
.d2d_teleport
then
3009 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
3010 MousePos
.X
+16, MousePos
.Y
-1,
3013 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+AreaSize
[AREA_DMPOINT
].Width
-1,
3014 MousePos
.Y
+AreaSize
[AREA_DMPOINT
].Height
-1, 255, 255, 255);
3016 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3017 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3018 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintTeleport
), gEditorFont
);
3021 // Подсказка при выборе точки появления:
3022 if SelectFlag
= SELECTFLAG_SPAWNPOINT
then
3024 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
3025 MousePos
.X
+16, MousePos
.Y
-1,
3027 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3028 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3029 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintSpawn
), gEditorFont
);
3032 // Подсказка при выборе панели двери:
3033 if SelectFlag
= SELECTFLAG_DOOR
then
3035 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3036 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3037 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelDoor
), gEditorFont
);
3040 // Подсказка при выборе панели с текстурой:
3041 if SelectFlag
= SELECTFLAG_TEXTURE
then
3043 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 192, 192, 192, 127);
3044 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 255, 255, 255);
3045 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelTexture
), gEditorFont
);
3048 // Подсказка при выборе панели индикации выстрела:
3049 if SelectFlag
= SELECTFLAG_SHOTPANEL
then
3051 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 192, 192, 192, 127);
3052 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 255, 255, 255);
3053 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelShot
), gEditorFont
);
3056 // Подсказка при выборе панели лифта:
3057 if SelectFlag
= SELECTFLAG_LIFT
then
3059 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3060 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3061 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelLift
), gEditorFont
);
3064 // Подсказка при выборе монстра:
3065 if SelectFlag
= SELECTFLAG_MONSTER
then
3067 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 192, 192, 192, 127);
3068 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 255, 255, 255);
3069 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintMonster
), gEditorFont
);
3072 // Подсказка при выборе области воздействия:
3073 if DrawPressRect
then
3075 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 192, 192, 192, 127);
3076 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 255, 255, 255);
3077 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintExtArea
), gEditorFont
);
3080 // Рисуем текстуры, если чертим панель:
3081 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and (DrawTexturePanel
) and
3082 (lbTextureList
.ItemIndex
<> -1) and (DrawRect
<> nil) and
3083 (lbPanelType
.ItemIndex
in [0..8]) and not IsSpecialTextureSel() then
3085 if not g_GetTexture(SelectedTexture(), ID
) then
3086 g_GetTexture('NOTEXTURE', ID
);
3087 g_GetTextureSizeByID(ID
, Width
, Height
);
3089 if (Abs(Right
-Left
) >= Width
) and (Abs(Bottom
-Top
) >= Height
) then
3090 e_DrawFill(ID
, Min(Left
, Right
), Min(Top
, Bottom
), Abs(Right
-Left
) div Width
,
3091 Abs(Bottom
-Top
) div Height
, 64, True, False);
3094 // Прямоугольник выделения:
3095 if DrawRect
<> nil then
3097 e_DrawQuad(Left
, Top
, Right
-1, Bottom
-1, 255, 255, 255);
3099 // Чертим мышью панель/триггер или меняем мышью их размер:
3100 if (((MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
]) and
3101 not(ssCtrl
in GetKeyShiftState())) or (MouseAction
= MOUSEACTION_RESIZE
)) and
3102 (DrawPanelSize
) then
3104 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 192, 192, 192, 127);
3105 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 255, 255, 255);
3107 if MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
] then
3108 begin // Чертим новый
3109 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(utf8to1251(MsgHintWidth
),
3110 [Abs(MousePos
.X
-MouseLDownPos
.X
)]), gEditorFont
);
3111 PrintBlack(MousePos
.X
+2, MousePos
.Y
+16, Format(utf8to1251(MsgHintHeight
),
3112 [Abs(MousePos
.Y
-MouseLDownPos
.Y
)]), gEditorFont
);
3114 else // Растягиваем существующий
3115 if SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
] then
3117 if SelectedObjects
[GetFirstSelected
].ObjectType
= OBJECT_PANEL
then
3119 Width
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
3120 Height
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
3124 Width
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
3125 Height
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
3128 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(utf8to1251(MsgHintWidth
), [Width
]),
3130 PrintBlack(MousePos
.X
+2, MousePos
.Y
+16, Format(utf8to1251(MsgHintHeight
), [Height
]),
3135 // Ближайшая к курсору мыши точка на сетке:
3136 e_DrawPoint(3, MousePos
.X
, MousePos
.Y
, 0, 0, 255);
3141 // Сколько пикселов карты в 1 пикселе мини-карты:
3142 ScaleSz
:= 16 div Scale
;
3143 // Размеры мини-карты:
3144 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3145 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3146 // X-координата на RenderPanel нулевой x-координаты карты:
3147 XX
:= RenderPanel
.Width
- aX
- 1;
3149 e_DrawFillQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 0, 0, 0, 0);
3150 e_DrawQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 197, 197, 197);
3152 if gPanels
<> nil then
3155 for a
:= 0 to High(gPanels
) do
3157 if PanelType
<> 0 then
3159 // Левый верхний угол:
3160 aX
:= XX
+ (X
div ScaleSz
);
3161 aY
:= 1 + (Y
div ScaleSz
);
3163 aX2
:= max(Width
div ScaleSz
, 1);
3164 aY2
:= max(Height
div ScaleSz
, 1);
3165 // Правый нижний угол:
3166 aX2
:= aX
+ aX2
- 1;
3167 aY2
:= aY
+ aY2
- 1;
3170 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3171 PANEL_WATER
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3172 PANEL_ACID1
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3173 PANEL_ACID2
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3174 PANEL_STEP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3175 PANEL_LIFTUP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3176 PANEL_LIFTDOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3177 PANEL_LIFTLEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3178 PANEL_LIFTRIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3179 PANEL_OPENDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 100, 220, 92, 0);
3180 PANEL_CLOSEDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 212, 184, 64, 0);
3181 PANEL_BLOCKMON
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 192, 0, 192, 0);
3185 // Рисуем красным выделенные панели:
3186 if SelectedObjects
<> nil then
3187 for b
:= 0 to High(SelectedObjects
) do
3188 with SelectedObjects
[b
] do
3189 if Live
and (ObjectType
= OBJECT_PANEL
) then
3190 with gPanels
[SelectedObjects
[b
].ID
] do
3191 if PanelType
and not(PANEL_BACK
or PANEL_FORE
) <> 0 then
3193 // Левый верхний угол:
3194 aX
:= XX
+ (X
div ScaleSz
);
3195 aY
:= 1 + (Y
div ScaleSz
);
3197 aX2
:= max(Width
div ScaleSz
, 1);
3198 aY2
:= max(Height
div ScaleSz
, 1);
3199 // Правый нижний угол:
3200 aX2
:= aX
+ aX2
- 1;
3201 aY2
:= aY
+ aY2
- 1;
3203 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0)
3207 if (gMapInfo
.Width
> RenderPanel
.Width
) or
3208 (gMapInfo
.Height
> RenderPanel
.Height
) then
3210 // Окно, показывающее текущее положение экрана на карте:
3212 x
:= max(min(RenderPanel
.Width
, gMapInfo
.Width
) div ScaleSz
, 1);
3213 y
:= max(min(RenderPanel
.Height
, gMapInfo
.Height
) div ScaleSz
, 1);
3214 // Левый верхний угол:
3215 aX
:= XX
+ ((-MapOffset
.X
) div ScaleSz
);
3216 aY
:= 1 + ((-MapOffset
.Y
) div ScaleSz
);
3217 // Правый нижний угол:
3221 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 127, 192, 127, 127, B_BLEND
);
3222 e_DrawQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0);
3227 RenderPanel
.SwapBuffers();
3230 procedure TMainForm
.FormResize(Sender
: TObject
);
3232 e_SetViewPort(0, 0, RenderPanel
.Width
, RenderPanel
.Height
);
3234 sbHorizontal
.Min
:= Min(gMapInfo
.Width
- RenderPanel
.Width
, -RenderPanel
.Width
div 2);
3235 sbHorizontal
.Max
:= Max(0, gMapInfo
.Width
- RenderPanel
.Width
div 2);
3236 sbVertical
.Min
:= Min(gMapInfo
.Height
- RenderPanel
.Height
, -RenderPanel
.Height
div 2);
3237 sbVertical
.Max
:= Max(0, gMapInfo
.Height
- RenderPanel
.Height
div 2);
3239 MapOffset
.X
:= -sbHorizontal
.Position
;
3240 MapOffset
.Y
:= -sbVertical
.Position
;
3243 procedure TMainForm
.FormWindowStateChange(Sender
: TObject
);
3249 // deactivate all menus when main window minimized
3250 e
:= self
.WindowState
<> wsMinimized
;
3251 miMenuFile
.Enabled
:= e
;
3252 miMenuEdit
.Enabled
:= e
;
3253 miMenuView
.Enabled
:= e
;
3254 miMenuService
.Enabled
:= e
;
3255 miMenuWindow
.Enabled
:= e
;
3256 miMenuHelp
.Enabled
:= e
;
3257 miMenuHidden
.Enabled
:= e
;
3261 procedure SelectNextObject(X
, Y
: Integer; ObjectType
: Byte; ID
: DWORD
);
3266 j_max
:= 0; // shut up compiler
3270 res
:= (gPanels
<> nil) and
3271 PanelInShownLayer(gPanels
[ID
].PanelType
) and
3272 g_CollidePoint(X
, Y
, gPanels
[ID
].X
, gPanels
[ID
].Y
,
3274 gPanels
[ID
].Height
);
3275 j_max
:= Length(gPanels
) - 1;
3280 res
:= (gItems
<> nil) and
3281 LayerEnabled
[LAYER_ITEMS
] and
3282 g_CollidePoint(X
, Y
, gItems
[ID
].X
, gItems
[ID
].Y
,
3283 ItemSize
[gItems
[ID
].ItemType
][0],
3284 ItemSize
[gItems
[ID
].ItemType
][1]);
3285 j_max
:= Length(gItems
) - 1;
3290 res
:= (gMonsters
<> nil) and
3291 LayerEnabled
[LAYER_MONSTERS
] and
3292 g_CollidePoint(X
, Y
, gMonsters
[ID
].X
, gMonsters
[ID
].Y
,
3293 MonsterSize
[gMonsters
[ID
].MonsterType
].Width
,
3294 MonsterSize
[gMonsters
[ID
].MonsterType
].Height
);
3295 j_max
:= Length(gMonsters
) - 1;
3300 res
:= (gAreas
<> nil) and
3301 LayerEnabled
[LAYER_AREAS
] and
3302 g_CollidePoint(X
, Y
, gAreas
[ID
].X
, gAreas
[ID
].Y
,
3303 AreaSize
[gAreas
[ID
].AreaType
].Width
,
3304 AreaSize
[gAreas
[ID
].AreaType
].Height
);
3305 j_max
:= Length(gAreas
) - 1;
3310 res
:= (gTriggers
<> nil) and
3311 LayerEnabled
[LAYER_TRIGGERS
] and
3312 g_CollidePoint(X
, Y
, gTriggers
[ID
].X
, gTriggers
[ID
].Y
,
3313 gTriggers
[ID
].Width
,
3314 gTriggers
[ID
].Height
);
3315 j_max
:= Length(gTriggers
) - 1;
3325 // Перебор ID: от ID-1 до 0; потом от High до ID+1:
3334 if j
= Integer(ID
) then
3339 res
:= PanelInShownLayer(gPanels
[j
].PanelType
) and
3340 g_CollidePoint(X
, Y
, gPanels
[j
].X
, gPanels
[j
].Y
,
3344 res
:= (gItems
[j
].ItemType
<> ITEM_NONE
) and
3345 g_CollidePoint(X
, Y
, gItems
[j
].X
, gItems
[j
].Y
,
3346 ItemSize
[gItems
[j
].ItemType
][0],
3347 ItemSize
[gItems
[j
].ItemType
][1]);
3349 res
:= (gMonsters
[j
].MonsterType
<> MONSTER_NONE
) and
3350 g_CollidePoint(X
, Y
, gMonsters
[j
].X
, gMonsters
[j
].Y
,
3351 MonsterSize
[gMonsters
[j
].MonsterType
].Width
,
3352 MonsterSize
[gMonsters
[j
].MonsterType
].Height
);
3354 res
:= (gAreas
[j
].AreaType
<> AREA_NONE
) and
3355 g_CollidePoint(X
, Y
, gAreas
[j
].X
, gAreas
[j
].Y
,
3356 AreaSize
[gAreas
[j
].AreaType
].Width
,
3357 AreaSize
[gAreas
[j
].AreaType
].Height
);
3359 res
:= (gTriggers
[j
].TriggerType
<> TRIGGER_NONE
) and
3360 g_CollidePoint(X
, Y
, gTriggers
[j
].X
, gTriggers
[j
].Y
,
3362 gTriggers
[j
].Height
);
3369 SetLength(SelectedObjects
, 1);
3371 SelectedObjects
[0].ObjectType
:= ObjectType
;
3372 SelectedObjects
[0].ID
:= j
;
3373 SelectedObjects
[0].Live
:= True;
3381 procedure TMainForm
.RenderPanelMouseDown(Sender
: TObject
;
3382 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3386 c1
, c2
, c3
, c4
: Boolean;
3392 MainForm
.ActiveControl
:= RenderPanel
;
3393 RenderPanel
.SetFocus();
3395 RenderPanelMouseMove(RenderPanel
, Shift
, X
, Y
);
3397 if Button
= mbLeft
then // Left Mouse Button
3399 // Двигаем карту с помощью мыши и мини-карты:
3401 g_CollidePoint(X
, Y
,
3402 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3404 max(gMapInfo
.Width
div (16 div Scale
), 1),
3405 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3408 MouseAction
:= MOUSEACTION_MOVEMAP
;
3410 else // Ставим предмет/монстра/область:
3411 if (pcObjects
.ActivePageIndex
in [1, 2, 3]) and
3412 (not (ssShift
in Shift
)) then
3414 case pcObjects
.ActivePageIndex
of
3416 if lbItemList
.ItemIndex
= -1 then
3417 ErrorMessageBox(MsgMsgChooseItem
)
3420 item
.ItemType
:= lbItemList
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
3421 if item
.ItemType
>= ITEM_WEAPON_KASTET
then
3422 item
.ItemType
:= item
.ItemType
+ 2;
3423 item
.X
:= MousePos
.X
-MapOffset
.X
;
3424 item
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3426 if not (ssCtrl
in Shift
) then
3428 item
.X
:= item
.X
- (ItemSize
[item
.ItemType
][0] div 2);
3429 item
.Y
:= item
.Y
- ItemSize
[item
.ItemType
][1];
3432 item
.OnlyDM
:= cbOnlyDM
.Checked
;
3433 item
.Fall
:= cbFall
.Checked
;
3434 Undo_Add(OBJECT_ITEM
, AddItem(item
));
3437 if lbMonsterList
.ItemIndex
= -1 then
3438 ErrorMessageBox(MsgMsgChooseMonster
)
3441 monster
.MonsterType
:= lbMonsterList
.ItemIndex
+ MONSTER_DEMON
;
3442 monster
.X
:= MousePos
.X
-MapOffset
.X
;
3443 monster
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3445 if not (ssCtrl
in Shift
) then
3447 monster
.X
:= monster
.X
- (MonsterSize
[monster
.MonsterType
].Width
div 2);
3448 monster
.Y
:= monster
.Y
- MonsterSize
[monster
.MonsterType
].Height
;
3451 if rbMonsterLeft
.Checked
then
3452 monster
.Direction
:= D_LEFT
3454 monster
.Direction
:= D_RIGHT
;
3455 Undo_Add(OBJECT_MONSTER
, AddMonster(monster
));
3458 if lbAreasList
.ItemIndex
= -1 then
3459 ErrorMessageBox(MsgMsgChooseArea
)
3461 if (lbAreasList
.ItemIndex
+ 1) <> AREA_DOMFLAG
then
3463 area
.AreaType
:= lbAreasList
.ItemIndex
+ AREA_PLAYERPOINT1
;
3464 area
.X
:= MousePos
.X
-MapOffset
.X
;
3465 area
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3467 if not (ssCtrl
in Shift
) then
3469 area
.X
:= area
.X
- (AreaSize
[area
.AreaType
].Width
div 2);
3470 area
.Y
:= area
.Y
- AreaSize
[area
.AreaType
].Height
;
3473 if rbAreaLeft
.Checked
then
3474 area
.Direction
:= D_LEFT
3476 area
.Direction
:= D_RIGHT
;
3477 Undo_Add(OBJECT_AREA
, AddArea(area
));
3483 i
:= GetFirstSelected();
3485 // Выбираем объект под текущим:
3486 if (SelectedObjects
<> nil) and
3487 (ssShift
in Shift
) and (i
>= 0) and
3488 (SelectedObjects
[i
].Live
) then
3490 if SelectedObjectCount() = 1 then
3491 SelectNextObject(X
-MapOffset
.X
, Y
-MapOffset
.Y
,
3492 SelectedObjects
[i
].ObjectType
,
3493 SelectedObjects
[i
].ID
);
3497 // Рисуем область триггера "Расширитель":
3498 if DrawPressRect
and (i
>= 0) and
3499 (SelectedObjects
[i
].ObjectType
= OBJECT_TRIGGER
) and
3500 (gTriggers
[SelectedObjects
[i
].ID
].TriggerType
in
3501 [TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
]) then
3502 MouseAction
:= MOUSEACTION_DRAWPRESS
3503 else // Рисуем панель:
3504 if pcObjects
.ActivePageIndex
= 0 then
3506 if (lbPanelType
.ItemIndex
>= 0) then
3507 MouseAction
:= MOUSEACTION_DRAWPANEL
3509 else // Рисуем триггер:
3510 if (lbTriggersList
.ItemIndex
>= 0) then
3512 MouseAction
:= MOUSEACTION_DRAWTRIGGER
;
3516 end; // if Button = mbLeft
3518 if Button
= mbRight
then // Right Mouse Button
3520 // Клик по мини-карте:
3522 g_CollidePoint(X
, Y
,
3523 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3525 max(gMapInfo
.Width
div (16 div Scale
), 1),
3526 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3528 MouseAction
:= MOUSEACTION_NOACTION
;
3530 else // Нужно что-то выбрать мышью:
3531 if SelectFlag
<> SELECTFLAG_NONE
then
3534 SELECTFLAG_TELEPORT
:
3535 // Точку назначения телепортации:
3536 with gTriggers
[SelectedObjects
[
3537 GetFirstSelected() ].ID
].Data
.TargetPoint
do
3539 X
:= MousePos
.X
-MapOffset
.X
;
3540 Y
:= MousePos
.Y
-MapOffset
.Y
;
3543 SELECTFLAG_SPAWNPOINT
:
3544 // Точку создания монстра:
3545 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
3546 if TriggerType
= TRIGGER_SPAWNMONSTER
then
3548 Data
.MonPos
.X
:= MousePos
.X
-MapOffset
.X
;
3549 Data
.MonPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3551 else if TriggerType
= TRIGGER_SPAWNITEM
then
3552 begin // Точка создания предмета:
3553 Data
.ItemPos
.X
:= MousePos
.X
-MapOffset
.X
;
3554 Data
.ItemPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3556 else if TriggerType
= TRIGGER_SHOT
then
3557 begin // Точка создания выстрела:
3558 Data
.ShotPos
.X
:= MousePos
.X
-MapOffset
.X
;
3559 Data
.ShotPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3565 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3567 2, 2, OBJECT_PANEL
, True);
3568 if IDArray
<> nil then
3570 for i
:= 0 to High(IDArray
) do
3571 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3572 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
) then
3574 gTriggers
[SelectedObjects
[
3575 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3580 gTriggers
[SelectedObjects
[
3581 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3585 // Панель с текстурой:
3587 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3589 2, 2, OBJECT_PANEL
, True);
3590 if IDArray
<> nil then
3592 for i
:= 0 to High(IDArray
) do
3593 if ((gPanels
[IDArray
[i
]].PanelType
in
3594 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3595 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3597 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3598 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3599 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3601 gTriggers
[SelectedObjects
[
3602 GetFirstSelected() ].ID
].TexturePanel
:= IDArray
[i
];
3607 gTriggers
[SelectedObjects
[
3608 GetFirstSelected() ].ID
].TexturePanel
:= -1;
3614 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3616 2, 2, OBJECT_PANEL
, True);
3617 if IDArray
<> nil then
3619 for i
:= 0 to High(IDArray
) do
3620 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTUP
) or
3621 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTDOWN
) or
3622 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTLEFT
) or
3623 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTRIGHT
) then
3625 gTriggers
[SelectedObjects
[
3626 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3631 gTriggers
[SelectedObjects
[
3632 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3638 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3640 2, 2, OBJECT_MONSTER
, False);
3641 if IDArray
<> nil then
3642 gTriggers
[SelectedObjects
[
3643 GetFirstSelected() ].ID
].Data
.MonsterID
:= IDArray
[0]+1
3645 gTriggers
[SelectedObjects
[
3646 GetFirstSelected() ].ID
].Data
.MonsterID
:= 0;
3649 SELECTFLAG_SHOTPANEL
:
3650 // Панель индикации выстрела:
3652 if gTriggers
[SelectedObjects
[
3653 GetFirstSelected() ].ID
].TriggerType
= TRIGGER_SHOT
then
3655 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3657 2, 2, OBJECT_PANEL
, True);
3658 if IDArray
<> nil then
3660 for i
:= 0 to High(IDArray
) do
3661 if ((gPanels
[IDArray
[i
]].PanelType
in
3662 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3663 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3665 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3666 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3667 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3669 gTriggers
[SelectedObjects
[
3670 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= IDArray
[i
];
3675 gTriggers
[SelectedObjects
[
3676 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= -1;
3681 SelectFlag
:= SELECTFLAG_SELECTED
;
3683 else // if SelectFlag <> SELECTFLAG_NONE...
3685 // Что уже выбрано и не нажат Ctrl:
3686 if (SelectedObjects
<> nil) and
3687 (not (ssCtrl
in Shift
)) then
3688 for i
:= 0 to High(SelectedObjects
) do
3689 with SelectedObjects
[i
] do
3692 if (ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) and
3693 (SelectedObjectCount() = 1) then
3695 Rect
:= ObjectGetRect(ObjectType
, ID
);
3697 c1
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3698 Rect
.X
-2, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3699 c2
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3700 Rect
.X
+Rect
.Width
-3, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3701 c3
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3702 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
-2, 4, 4);
3703 c4
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3704 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
+Rect
.Height
-3, 4, 4);
3706 // Меняем размер панели или триггера:
3707 if c1
or c2
or c3
or c4
then
3709 MouseAction
:= MOUSEACTION_RESIZE
;
3710 LastMovePoint
:= MousePos
;
3714 ResizeType
:= RESIZETYPE_HORIZONTAL
;
3716 ResizeDirection
:= RESIZEDIR_LEFT
3718 ResizeDirection
:= RESIZEDIR_RIGHT
;
3719 RenderPanel
.Cursor
:= crSizeWE
;
3723 ResizeType
:= RESIZETYPE_VERTICAL
;
3725 ResizeDirection
:= RESIZEDIR_UP
3727 ResizeDirection
:= RESIZEDIR_DOWN
;
3728 RenderPanel
.Cursor
:= crSizeNS
;
3735 // Перемещаем панель или триггер:
3736 if ObjectCollide(ObjectType
, ID
,
3738 Y
-MapOffset
.Y
-1, 2, 2) then
3740 MouseAction
:= MOUSEACTION_MOVEOBJ
;
3741 LastMovePoint
:= MousePos
;
3747 end; // if Button = mbRight
3749 if Button
= mbMiddle
then // Middle Mouse Button
3751 SetCapture(RenderPanel
.Handle
);
3752 RenderPanel
.Cursor
:= crSize
;
3755 MouseMDown
:= Button
= mbMiddle
;
3757 MouseMDownPos
:= Mouse
.CursorPos
;
3759 MouseRDown
:= Button
= mbRight
;
3761 MouseRDownPos
:= MousePos
;
3763 MouseLDown
:= Button
= mbLeft
;
3765 MouseLDownPos
:= MousePos
;
3768 procedure TMainForm
.RenderPanelMouseUp(Sender
: TObject
;
3769 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3774 rSelectRect
: Boolean;
3775 wWidth
, wHeight
: Word;
3778 procedure SelectObjects(ObjectType
: Byte);
3783 IDArray
:= ObjectInRect(rRect
.X
, rRect
.Y
,
3784 rRect
.Width
, rRect
.Height
,
3785 ObjectType
, rSelectRect
);
3787 if IDArray
<> nil then
3788 for i
:= 0 to High(IDArray
) do
3789 SelectObject(ObjectType
, IDArray
[i
], (ssCtrl
in Shift
) or rSelectRect
);
3792 if Button
= mbLeft
then
3793 MouseLDown
:= False;
3794 if Button
= mbRight
then
3795 MouseRDown
:= False;
3796 if Button
= mbMiddle
then
3797 MouseMDown
:= False;
3799 if DrawRect
<> nil then
3805 ResizeType
:= RESIZETYPE_NONE
;
3808 if Button
= mbLeft
then // Left Mouse Button
3810 if MouseAction
<> MOUSEACTION_NONE
then
3811 begin // Было действие мышью
3812 // Мышь сдвинулась во время удержания клавиши,
3813 // либо активирован режим быстрого рисования:
3814 if ((MousePos
.X
<> MouseLDownPos
.X
) and
3815 (MousePos
.Y
<> MouseLDownPos
.Y
)) or
3816 ((MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
]) and
3817 (ssCtrl
in Shift
)) then
3820 MOUSEACTION_DRAWPANEL
:
3822 // Фон или передний план без текстуры - ошибка:
3823 if (lbPanelType
.ItemIndex
in [1, 2]) and
3824 (lbTextureList
.ItemIndex
= -1) then
3825 ErrorMessageBox(MsgMsgChooseTexture
)
3826 else // Назначаем параметры панели:
3828 case lbPanelType
.ItemIndex
of
3829 0: Panel
.PanelType
:= PANEL_WALL
;
3830 1: Panel
.PanelType
:= PANEL_BACK
;
3831 2: Panel
.PanelType
:= PANEL_FORE
;
3832 3: Panel
.PanelType
:= PANEL_OPENDOOR
;
3833 4: Panel
.PanelType
:= PANEL_CLOSEDOOR
;
3834 5: Panel
.PanelType
:= PANEL_STEP
;
3835 6: Panel
.PanelType
:= PANEL_WATER
;
3836 7: Panel
.PanelType
:= PANEL_ACID1
;
3837 8: Panel
.PanelType
:= PANEL_ACID2
;
3838 9: Panel
.PanelType
:= PANEL_LIFTUP
;
3839 10: Panel
.PanelType
:= PANEL_LIFTDOWN
;
3840 11: Panel
.PanelType
:= PANEL_LIFTLEFT
;
3841 12: Panel
.PanelType
:= PANEL_LIFTRIGHT
;
3842 13: Panel
.PanelType
:= PANEL_BLOCKMON
;
3845 Panel
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3846 Panel
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3847 if ssCtrl
in Shift
then
3851 if (lbTextureList
.ItemIndex
<> -1) and
3852 (not IsSpecialTextureSel()) then
3854 if not g_GetTexture(SelectedTexture(), TextureID
) then
3855 g_GetTexture('NOTEXTURE', TextureID
);
3856 g_GetTextureSizeByID(TextureID
, wWidth
, wHeight
);
3858 Panel
.Width
:= wWidth
;
3859 Panel
.Height
:= wHeight
;
3863 Panel
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3864 Panel
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3867 // Лифты, блокМон или отсутствие текстуры - пустая текстура:
3868 if (lbPanelType
.ItemIndex
in [9, 10, 11, 12, 13]) or
3869 (lbTextureList
.ItemIndex
= -1) then
3871 Panel
.TextureHeight
:= 1;
3872 Panel
.TextureWidth
:= 1;
3873 Panel
.TextureName
:= '';
3874 Panel
.TextureID
:= TEXTURE_SPECIAL_NONE
;
3876 else // Есть текстура:
3878 Panel
.TextureName
:= SelectedTexture();
3880 // Обычная текстура:
3881 if not IsSpecialTextureSel() then
3883 g_GetTextureSizeByName(Panel
.TextureName
,
3884 Panel
.TextureWidth
, Panel
.TextureHeight
);
3885 g_GetTexture(Panel
.TextureName
, Panel
.TextureID
);
3887 else // Спец.текстура:
3889 Panel
.TextureHeight
:= 1;
3890 Panel
.TextureWidth
:= 1;
3891 Panel
.TextureID
:= SpecialTextureID(SelectedTexture());
3896 Panel
.Blending
:= False;
3898 Undo_Add(OBJECT_PANEL
, AddPanel(Panel
));
3902 // Рисовали триггер:
3903 MOUSEACTION_DRAWTRIGGER
:
3905 trigger
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3906 trigger
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3907 if ssCtrl
in Shift
then
3911 trigger
.Width
:= wWidth
;
3912 trigger
.Height
:= wHeight
;
3916 trigger
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3917 trigger
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3920 trigger
.Enabled
:= True;
3921 trigger
.TriggerType
:= lbTriggersList
.ItemIndex
+1;
3922 trigger
.TexturePanel
:= -1;
3925 trigger
.ActivateType
:= 0;
3927 if clbActivationType
.Checked
[0] then
3928 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERCOLLIDE
;
3929 if clbActivationType
.Checked
[1] then
3930 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERCOLLIDE
;
3931 if clbActivationType
.Checked
[2] then
3932 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERPRESS
;
3933 if clbActivationType
.Checked
[3] then
3934 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERPRESS
;
3935 if clbActivationType
.Checked
[4] then
3936 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_SHOT
;
3937 if clbActivationType
.Checked
[5] then
3938 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_NOMONSTER
;
3940 // Необходимые для активации ключи:
3943 if clbKeys
.Checked
[0] then
3944 trigger
.Key
:= Trigger
.Key
or KEY_RED
;
3945 if clbKeys
.Checked
[1] then
3946 trigger
.Key
:= Trigger
.Key
or KEY_GREEN
;
3947 if clbKeys
.Checked
[2] then
3948 trigger
.Key
:= Trigger
.Key
or KEY_BLUE
;
3949 if clbKeys
.Checked
[3] then
3950 trigger
.Key
:= Trigger
.Key
or KEY_REDTEAM
;
3951 if clbKeys
.Checked
[4] then
3952 trigger
.Key
:= Trigger
.Key
or KEY_BLUETEAM
;
3954 // Параметры триггера:
3955 FillByte(trigger
.Data
.Default
[0], 128, 0);
3957 case trigger
.TriggerType
of
3958 // Переключаемая панель:
3959 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
3960 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
3961 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
3963 Trigger
.Data
.PanelID
:= -1;
3969 trigger
.Data
.TargetPoint
.X
:= trigger
.X
-64;
3970 trigger
.Data
.TargetPoint
.Y
:= trigger
.Y
-64;
3971 trigger
.Data
.d2d_teleport
:= True;
3972 trigger
.Data
.TlpDir
:= 0;
3975 // Изменение других триггеров:
3976 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
3979 trigger
.Data
.Count
:= 1;
3985 trigger
.Data
.Volume
:= 255;
3986 trigger
.Data
.Pan
:= 127;
3987 trigger
.Data
.PlayCount
:= 1;
3988 trigger
.Data
.Local
:= True;
3989 trigger
.Data
.SoundSwitch
:= False;
3995 trigger
.Data
.MusicAction
:= 1;
3998 // Создание монстра:
3999 TRIGGER_SPAWNMONSTER
:
4001 trigger
.Data
.MonType
:= MONSTER_ZOMBY
;
4002 trigger
.Data
.MonPos
.X
:= trigger
.X
-64;
4003 trigger
.Data
.MonPos
.Y
:= trigger
.Y
-64;
4004 trigger
.Data
.MonHealth
:= 0;
4005 trigger
.Data
.MonActive
:= False;
4006 trigger
.Data
.MonCount
:= 1;
4009 // Создание предмета:
4012 trigger
.Data
.ItemType
:= ITEM_AMMO_BULLETS
;
4013 trigger
.Data
.ItemPos
.X
:= trigger
.X
-64;
4014 trigger
.Data
.ItemPos
.Y
:= trigger
.Y
-64;
4015 trigger
.Data
.ItemOnlyDM
:= False;
4016 trigger
.Data
.ItemFalls
:= False;
4017 trigger
.Data
.ItemCount
:= 1;
4018 trigger
.Data
.ItemMax
:= 0;
4019 trigger
.Data
.ItemDelay
:= 0;
4025 trigger
.Data
.PushAngle
:= 90;
4026 trigger
.Data
.PushForce
:= 10;
4027 trigger
.Data
.ResetVel
:= True;
4032 trigger
.Data
.ScoreCount
:= 1;
4033 trigger
.Data
.ScoreCon
:= True;
4034 trigger
.Data
.ScoreMsg
:= True;
4039 trigger
.Data
.MessageKind
:= 0;
4040 trigger
.Data
.MessageSendTo
:= 0;
4041 trigger
.Data
.MessageText
:= '';
4042 trigger
.Data
.MessageTime
:= 144;
4047 trigger
.Data
.DamageValue
:= 5;
4048 trigger
.Data
.DamageInterval
:= 12;
4053 trigger
.Data
.HealValue
:= 5;
4054 trigger
.Data
.HealInterval
:= 36;
4059 trigger
.Data
.ShotType
:= TRIGGER_SHOT_BULLET
;
4060 trigger
.Data
.ShotSound
:= True;
4061 trigger
.Data
.ShotPanelID
:= -1;
4062 trigger
.Data
.ShotTarget
:= 0;
4063 trigger
.Data
.ShotIntSight
:= 0;
4064 trigger
.Data
.ShotAim
:= TRIGGER_SHOT_AIM_DEFAULT
;
4065 trigger
.Data
.ShotPos
.X
:= trigger
.X
-64;
4066 trigger
.Data
.ShotPos
.Y
:= trigger
.Y
-64;
4067 trigger
.Data
.ShotAngle
:= 0;
4068 trigger
.Data
.ShotWait
:= 18;
4069 trigger
.Data
.ShotAccuracy
:= 0;
4070 trigger
.Data
.ShotAmmo
:= 0;
4071 trigger
.Data
.ShotIntReload
:= 0;
4076 trigger
.Data
.FXCount
:= 1;
4077 trigger
.Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
4078 trigger
.Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
4079 trigger
.Data
.FXColorR
:= 0;
4080 trigger
.Data
.FXColorG
:= 0;
4081 trigger
.Data
.FXColorB
:= 255;
4082 trigger
.Data
.FXPos
:= TRIGGER_EFFECT_POS_CENTER
;
4083 trigger
.Data
.FXWait
:= 1;
4084 trigger
.Data
.FXVelX
:= 0;
4085 trigger
.Data
.FXVelY
:= -20;
4086 trigger
.Data
.FXSpreadL
:= 5;
4087 trigger
.Data
.FXSpreadR
:= 5;
4088 trigger
.Data
.FXSpreadU
:= 4;
4089 trigger
.Data
.FXSpreadD
:= 0;
4093 Undo_Add(OBJECT_TRIGGER
, AddTrigger(trigger
));
4096 // Рисовали область триггера "Расширитель":
4097 MOUSEACTION_DRAWPRESS
:
4098 with gTriggers
[SelectedObjects
[GetFirstSelected
].ID
] do
4100 Data
.tX
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
4101 Data
.tY
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
4102 Data
.tWidth
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
4103 Data
.tHeight
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
4105 DrawPressRect
:= False;
4109 MouseAction
:= MOUSEACTION_NONE
;
4111 end // if Button = mbLeft...
4112 else if Button
= mbRight
then // Right Mouse Button:
4114 if MouseAction
= MOUSEACTION_NOACTION
then
4116 MouseAction
:= MOUSEACTION_NONE
;
4120 // Объект передвинут или изменен в размере:
4121 if MouseAction
in [MOUSEACTION_MOVEOBJ
, MOUSEACTION_RESIZE
] then
4123 RenderPanel
.Cursor
:= crDefault
;
4124 MouseAction
:= MOUSEACTION_NONE
;
4129 // Еще не все выбрали:
4130 if SelectFlag
<> SELECTFLAG_NONE
then
4132 if SelectFlag
= SELECTFLAG_SELECTED
then
4133 SelectFlag
:= SELECTFLAG_NONE
;
4138 // Мышь сдвинулась во время удержания клавиши:
4139 if (MousePos
.X
<> MouseRDownPos
.X
) and
4140 (MousePos
.Y
<> MouseRDownPos
.Y
) then
4142 rSelectRect
:= True;
4144 rRect
.X
:= Min(MousePos
.X
, MouseRDownPos
.X
)-MapOffset
.X
;
4145 rRect
.Y
:= Min(MousePos
.Y
, MouseRDownPos
.Y
)-MapOffset
.Y
;
4146 rRect
.Width
:= Abs(MousePos
.X
-MouseRDownPos
.X
);
4147 rRect
.Height
:= Abs(MousePos
.Y
-MouseRDownPos
.Y
);
4149 else // Мышь не сдвинулась - нет прямоугольника:
4151 rSelectRect
:= False;
4153 rRect
.X
:= X
-MapOffset
.X
-1;
4154 rRect
.Y
:= Y
-MapOffset
.Y
-1;
4159 // Если зажат Ctrl - выделять еще, иначе только один выделенный объект:
4160 if not (ssCtrl
in Shift
) then
4161 RemoveSelectFromObjects();
4163 // Выделяем всё в выбранном прямоугольнике:
4164 if (ssCtrl
in Shift
) and (ssAlt
in Shift
) then
4166 SelectObjects(OBJECT_PANEL
);
4167 SelectObjects(OBJECT_ITEM
);
4168 SelectObjects(OBJECT_MONSTER
);
4169 SelectObjects(OBJECT_AREA
);
4170 SelectObjects(OBJECT_TRIGGER
);
4173 SelectObjects(pcObjects
.ActivePageIndex
+1);
4178 else // Middle Mouse Button
4180 RenderPanel
.Cursor
:= crDefault
;
4185 procedure TMainForm
.RenderPanelPaint(Sender
: TObject
);
4190 function TMainForm
.RenderMousePos(): Types
.TPoint
;
4192 Result
:= RenderPanel
.ScreenToClient(Mouse
.CursorPos
);
4195 procedure TMainForm
.RecountSelectedObjects();
4197 if SelectedObjectCount() = 0 then
4198 StatusBar
.Panels
[0].Text := ''
4200 StatusBar
.Panels
[0].Text := Format(MsgCapStatSelected
, [SelectedObjectCount()]);
4203 procedure TMainForm
.RenderPanelMouseMove(Sender
: TObject
;
4204 Shift
: TShiftState
; X
, Y
: Integer);
4207 dWidth
, dHeight
: Integer;
4210 wWidth
, wHeight
: Word;
4212 _id
:= GetFirstSelected();
4215 // Рисуем панель с текстурой, сетка - размеры текстуры:
4216 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and
4217 (lbPanelType
.ItemIndex
in [0..8]) and
4218 (lbTextureList
.ItemIndex
<> -1) and
4219 (not IsSpecialTextureSel()) then
4221 sX
:= StrToIntDef(lTextureWidth
.Caption
, DotStep
);
4222 sY
:= StrToIntDef(lTextureHeight
.Caption
, DotStep
);
4225 // Меняем размер панели с текстурой, сетка - размеры текстуры:
4226 if (MouseAction
= MOUSEACTION_RESIZE
) and
4227 ( (SelectedObjects
[_id
].ObjectType
= OBJECT_PANEL
) and
4228 IsTexturedPanel(gPanels
[SelectedObjects
[_id
].ID
].PanelType
) and
4229 (gPanels
[SelectedObjects
[_id
].ID
].TextureName
<> '') and
4230 (not IsSpecialTexture(gPanels
[SelectedObjects
[_id
].ID
].TextureName
)) ) then
4232 sX
:= gPanels
[SelectedObjects
[_id
].ID
].TextureWidth
;
4233 sY
:= gPanels
[SelectedObjects
[_id
].ID
].TextureHeight
;
4236 // Выравнивание по сетке:
4242 else // Нет выравнивания по сетке:
4248 // Новая позиция мыши:
4250 begin // Зажата левая кнопка мыши
4251 MousePos
.X
:= (Round((X
-MouseLDownPos
.X
)/sX
)*sX
)+MouseLDownPos
.X
;
4252 MousePos
.Y
:= (Round((Y
-MouseLDownPos
.Y
)/sY
)*sY
)+MouseLDownPos
.Y
;
4256 begin // Зажата правая кнопка мыши
4257 MousePos
.X
:= (Round((X
-MouseRDownPos
.X
)/sX
)*sX
)+MouseRDownPos
.X
;
4258 MousePos
.Y
:= (Round((Y
-MouseRDownPos
.Y
)/sY
)*sY
)+MouseRDownPos
.Y
;
4261 begin // Кнопки мыши не зажаты
4262 MousePos
.X
:= Round((-MapOffset
.X
+ X
) / sX
) * sX
+ MapOffset
.X
;
4263 MousePos
.Y
:= Round((-MapOffset
.Y
+ Y
) / sY
) * sY
+ MapOffset
.Y
;
4266 // Зажата только правая кнопка мыши:
4267 if (not MouseLDown
) and (MouseRDown
) and (not MouseMDown
) then
4269 // Рисуем прямоугольник выделения:
4270 if MouseAction
= MOUSEACTION_NONE
then
4272 if DrawRect
= nil then
4274 DrawRect
.Top
:= MouseRDownPos
.y
;
4275 DrawRect
.Left
:= MouseRDownPos
.x
;
4276 DrawRect
.Bottom
:= MousePos
.y
;
4277 DrawRect
.Right
:= MousePos
.x
;
4280 // Двигаем выделенные объекты:
4281 if MouseAction
= MOUSEACTION_MOVEOBJ
then
4283 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
,
4284 MousePos
.X
-LastMovePoint
.X
,
4285 MousePos
.Y
-LastMovePoint
.Y
);
4288 // Меняем размер выделенного объекта:
4289 if MouseAction
= MOUSEACTION_RESIZE
then
4291 if (SelectedObjectCount
= 1) and
4292 (SelectedObjects
[GetFirstSelected
].Live
) then
4294 dWidth
:= MousePos
.X
-LastMovePoint
.X
;
4295 dHeight
:= MousePos
.Y
-LastMovePoint
.Y
;
4298 RESIZETYPE_VERTICAL
: dWidth
:= 0;
4299 RESIZETYPE_HORIZONTAL
: dHeight
:= 0;
4302 case ResizeDirection
of
4303 RESIZEDIR_UP
: dHeight
:= -dHeight
;
4304 RESIZEDIR_LEFT
: dWidth
:= -dWidth
;
4307 if ResizeObject(SelectedObjects
[GetFirstSelected
].ObjectType
,
4308 SelectedObjects
[GetFirstSelected
].ID
,
4309 dWidth
, dHeight
, ResizeDirection
) then
4310 LastMovePoint
:= MousePos
;
4315 // Зажата только левая кнопка мыши:
4316 if (not MouseRDown
) and (MouseLDown
) and (not MouseMDown
) then
4318 // Рисуем прямоугольник планирования панели:
4319 if MouseAction
in [MOUSEACTION_DRAWPANEL
,
4320 MOUSEACTION_DRAWTRIGGER
,
4321 MOUSEACTION_DRAWPRESS
] then
4323 if DrawRect
= nil then
4325 if ssCtrl
in Shift
then
4329 if (lbTextureList
.ItemIndex
<> -1) and (not IsSpecialTextureSel()) and
4330 (MouseAction
= MOUSEACTION_DRAWPANEL
) then
4332 if not g_GetTexture(SelectedTexture(), TextureID
) then
4333 g_GetTexture('NOTEXTURE', TextureID
);
4334 g_GetTextureSizeByID(TextureID
, wWidth
, wHeight
);
4336 DrawRect
.Top
:= MouseLDownPos
.y
;
4337 DrawRect
.Left
:= MouseLDownPos
.x
;
4338 DrawRect
.Bottom
:= DrawRect
.Top
+ wHeight
;
4339 DrawRect
.Right
:= DrawRect
.Left
+ wWidth
;
4343 DrawRect
.Top
:= MouseLDownPos
.y
;
4344 DrawRect
.Left
:= MouseLDownPos
.x
;
4345 DrawRect
.Bottom
:= MousePos
.y
;
4346 DrawRect
.Right
:= MousePos
.x
;
4349 else // Двигаем карту:
4350 if MouseAction
= MOUSEACTION_MOVEMAP
then
4356 // Only Middle Mouse Button is pressed
4357 if (not MouseLDown
) and (not MouseRDown
) and (MouseMDown
) then
4359 MapOffset
.X
:= -EnsureRange(-MapOffset
.X
+ MouseMDownPos
.X
- Mouse
.CursorPos
.X
,
4360 sbHorizontal
.Min
, sbHorizontal
.Max
);
4361 sbHorizontal
.Position
:= -MapOffset
.X
;
4362 MapOffset
.Y
:= -EnsureRange(-MapOffset
.Y
+ MouseMDownPos
.Y
- Mouse
.CursorPos
.Y
,
4363 sbVertical
.Min
, sbVertical
.Max
);
4364 sbVertical
.Position
:= -MapOffset
.Y
;
4365 MouseMDownPos
:= Mouse
.CursorPos
;
4368 // Клавиши мыши не зажаты:
4369 if (not MouseRDown
) and (not MouseLDown
) and (DrawRect
<> nil) then
4375 // Строка состояния - координаты мыши:
4376 StatusBar
.Panels
[1].Text := Format('(%d:%d)',
4377 [MousePos
.X
-MapOffset
.X
, MousePos
.Y
-MapOffset
.Y
]);
4379 RenderPanel
.Invalidate
;
4382 procedure TMainForm
.FormCloseQuery(Sender
: TObject
; var CanClose
: Boolean);
4384 CanClose
:= Application
.MessageBox(PChar(MsgMsgExitPrompt
),
4386 MB_ICONQUESTION
or MB_YESNO
or
4387 MB_DEFBUTTON1
) = idYes
;
4390 procedure TMainForm
.aExitExecute(Sender
: TObject
);
4395 procedure TMainForm
.FormDestroy(Sender
: TObject
);
4401 config
:= TConfig
.CreateFile(CfgFileName
);
4403 config
.WriteInt('WADEditor', 'LogLevel', gWADEditorLogLevel
);
4405 if WindowState
<> wsMaximized
then
4407 config
.WriteInt('Editor', 'XPos', Left
);
4408 config
.WriteInt('Editor', 'YPos', Top
);
4409 config
.WriteInt('Editor', 'Width', Width
);
4410 config
.WriteInt('Editor', 'Height', Height
);
4414 config
.WriteInt('Editor', 'XPos', RestoredLeft
);
4415 config
.WriteInt('Editor', 'YPos', RestoredTop
);
4416 config
.WriteInt('Editor', 'Width', RestoredWidth
);
4417 config
.WriteInt('Editor', 'Height', RestoredHeight
);
4419 config
.WriteBool('Editor', 'Maximize', WindowState
= wsMaximized
);
4420 config
.WriteBool('Editor', 'Minimap', ShowMap
);
4421 config
.WriteInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
4422 config
.WriteInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
4423 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
4424 config
.WriteInt('Editor', 'DotStep', DotStep
);
4425 config
.WriteStr('Editor', 'LastOpenDir', OpenDialog
.InitialDir
);
4426 config
.WriteStr('Editor', 'LastSaveDir', SaveDialog
.InitialDir
);
4427 config
.WriteStr('Editor', 'Language', gLanguage
);
4428 config
.WriteBool('Editor', 'EdgeShow', drEdge
[3] < 255);
4429 config
.WriteInt('Editor', 'EdgeColor', gColorEdge
);
4430 config
.WriteInt('Editor', 'EdgeAlpha', gAlphaEdge
);
4431 config
.WriteInt('Editor', 'LineAlpha', gAlphaTriggerLine
);
4432 config
.WriteInt('Editor', 'TriggerAlpha', gAlphaTriggerArea
);
4433 config
.WriteInt('Editor', 'MonsterRectAlpha', gAlphaMonsterRect
);
4434 config
.WriteInt('Editor', 'AreaRectAlpha', gAlphaAreaRect
);
4436 for i
:= 0 to RecentCount
- 1 do
4438 if i
< RecentFiles
.Count
then s
:= RecentFiles
[i
] else s
:= '';
4440 config
.WriteStr('RecentFilesWin', IntToStr(i
), s
);
4442 config
.WriteStr('RecentFilesUnix', IntToStr(i
), s
);
4447 config
.SaveFile(CfgFileName
);
4450 slInvalidTextures
.Free();
4451 DiscardUndoBuffer();
4454 procedure TMainForm
.FormDropFiles(Sender
: TObject
;
4455 const FileNames
: array of String);
4457 if Length(FileNames
) <> 1 then
4460 OpenMapFile(FileNames
[0]);
4463 procedure TMainForm
.RenderPanelResize(Sender
: TObject
);
4465 if MainForm
.Visible
then
4469 procedure TMainForm
.Splitter1Moved(Sender
: TObject
);
4474 procedure TMainForm
.MapTestCheck(Sender
: TObject
);
4476 if MapTestProcess
<> nil then
4478 if MapTestProcess
.Running
= false then
4480 if MapTestProcess
.ExitCode
<> 0 then
4481 Application
.MessageBox(PChar(MsgMsgExecError
), 'FIXME', MB_OK
or MB_ICONERROR
);
4482 SysUtils
.DeleteFile(MapTestFile
);
4484 FreeAndNil(MapTestProcess
);
4485 tbTestMap
.Enabled
:= True;
4490 procedure TMainForm
.aMapOptionsExecute(Sender
: TObject
);
4494 MapOptionsForm
.ShowModal();
4496 ResName
:= OpenedMap
;
4497 while (Pos(':\', ResName
) > 0) do
4498 Delete(ResName
, 1, Pos(':\', ResName
) + 1);
4500 UpdateCaption(gMapInfo
.Name
, ExtractFileName(OpenedWAD
), ResName
);
4503 procedure TMainForm
.aAboutExecute(Sender
: TObject
);
4505 AboutForm
.ShowModal();
4508 procedure TMainForm
.FormKeyDown(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
4514 if (not EditingProperties
) then
4516 if ssCtrl
in Shift
then
4519 '1': ContourEnabled
[LAYER_BACK
] := not ContourEnabled
[LAYER_BACK
];
4520 '2': ContourEnabled
[LAYER_WALLS
] := not ContourEnabled
[LAYER_WALLS
];
4521 '3': ContourEnabled
[LAYER_FOREGROUND
] := not ContourEnabled
[LAYER_FOREGROUND
];
4522 '4': ContourEnabled
[LAYER_STEPS
] := not ContourEnabled
[LAYER_STEPS
];
4523 '5': ContourEnabled
[LAYER_WATER
] := not ContourEnabled
[LAYER_WATER
];
4524 '6': ContourEnabled
[LAYER_ITEMS
] := not ContourEnabled
[LAYER_ITEMS
];
4525 '7': ContourEnabled
[LAYER_MONSTERS
] := not ContourEnabled
[LAYER_MONSTERS
];
4526 '8': ContourEnabled
[LAYER_AREAS
] := not ContourEnabled
[LAYER_AREAS
];
4527 '9': ContourEnabled
[LAYER_TRIGGERS
] := not ContourEnabled
[LAYER_TRIGGERS
];
4531 for i
:= Low(ContourEnabled
) to High(ContourEnabled
) do
4532 if ContourEnabled
[i
] then
4534 for i
:= Low(ContourEnabled
) to High(ContourEnabled
) do
4535 ContourEnabled
[i
] := not ok
4542 '1': SwitchLayer(LAYER_BACK
);
4543 '2': SwitchLayer(LAYER_WALLS
);
4544 '3': SwitchLayer(LAYER_FOREGROUND
);
4545 '4': SwitchLayer(LAYER_STEPS
);
4546 '5': SwitchLayer(LAYER_WATER
);
4547 '6': SwitchLayer(LAYER_ITEMS
);
4548 '7': SwitchLayer(LAYER_MONSTERS
);
4549 '8': SwitchLayer(LAYER_AREAS
);
4550 '9': SwitchLayer(LAYER_TRIGGERS
);
4551 '0': tbShowClick(tbShow
);
4555 if Key
= Ord('I') then
4556 begin // Поворот монстров и областей:
4557 if (SelectedObjects
<> nil) then
4559 for i
:= 0 to High(SelectedObjects
) do
4560 if (SelectedObjects
[i
].Live
) then
4562 if (SelectedObjects
[i
].ObjectType
= OBJECT_MONSTER
) then
4564 g_ChangeDir(gMonsters
[SelectedObjects
[i
].ID
].Direction
);
4567 if (SelectedObjects
[i
].ObjectType
= OBJECT_AREA
) then
4569 g_ChangeDir(gAreas
[SelectedObjects
[i
].ID
].Direction
);
4575 if pcObjects
.ActivePage
= tsMonsters
then
4577 if rbMonsterLeft
.Checked
then
4578 rbMonsterRight
.Checked
:= True
4580 rbMonsterLeft
.Checked
:= True;
4582 if pcObjects
.ActivePage
= tsAreas
then
4584 if rbAreaLeft
.Checked
then
4585 rbAreaRight
.Checked
:= True
4587 rbAreaLeft
.Checked
:= True;
4592 if not (ssCtrl
in Shift
) then
4594 // Быстрое превью карты:
4595 if Key
= Ord('E') then
4597 if PreviewMode
= 0 then
4601 // Вертикальный скролл карты:
4604 if Key
= Ord('W') then
4607 if ssShift
in Shift
then Position
:= EnsureRange(Position
- DotStep
* 4, Min
, Max
)
4608 else Position
:= EnsureRange(Position
- DotStep
, Min
, Max
);
4609 MapOffset
.Y
:= -Position
;
4612 if (MouseLDown
or MouseRDown
) then
4614 if DrawRect
<> nil then
4616 Inc(MouseLDownPos
.y
, dy
);
4617 Inc(MouseRDownPos
.y
, dy
);
4619 Inc(LastMovePoint
.Y
, dy
);
4620 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4624 if Key
= Ord('S') then
4627 if ssShift
in Shift
then Position
:= EnsureRange(Position
+ DotStep
* 4, Min
, Max
)
4628 else Position
:= EnsureRange(Position
+ DotStep
, Min
, Max
);
4629 MapOffset
.Y
:= -Position
;
4632 if (MouseLDown
or MouseRDown
) then
4634 if DrawRect
<> nil then
4636 Inc(MouseLDownPos
.y
, dy
);
4637 Inc(MouseRDownPos
.y
, dy
);
4639 Inc(LastMovePoint
.Y
, dy
);
4640 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4645 // Горизонтальный скролл карты:
4646 with sbHorizontal
do
4648 if Key
= Ord('A') then
4651 if ssShift
in Shift
then Position
:= EnsureRange(Position
- DotStep
* 4, Min
, Max
)
4652 else Position
:= EnsureRange(Position
- DotStep
, Min
, Max
);
4653 MapOffset
.X
:= -Position
;
4656 if (MouseLDown
or MouseRDown
) then
4658 if DrawRect
<> nil then
4660 Inc(MouseLDownPos
.x
, dx
);
4661 Inc(MouseRDownPos
.x
, dx
);
4663 Inc(LastMovePoint
.X
, dx
);
4664 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4668 if Key
= Ord('D') then
4671 if ssShift
in Shift
then Position
:= EnsureRange(Position
+ DotStep
* 4, Min
, Max
)
4672 else Position
:= EnsureRange(Position
+ DotStep
, Min
, Max
);
4673 MapOffset
.X
:= -Position
;
4676 if (MouseLDown
or MouseRDown
) then
4678 if DrawRect
<> nil then
4680 Inc(MouseLDownPos
.x
, dx
);
4681 Inc(MouseRDownPos
.x
, dx
);
4683 Inc(LastMovePoint
.X
, dx
);
4684 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4689 else // ssCtrl in Shift
4691 if ssShift
in Shift
then
4693 // Вставка по абсолютному смещению:
4694 if Key
= Ord('V') then
4695 aPasteObjectExecute(Sender
);
4697 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4701 // Удалить выделенные объекты:
4702 if (Key
= VK_DELETE
) and (SelectedObjects
<> nil) and RenderPanel
.Focused() then
4703 DeleteSelectedObjects();
4706 if (Key
= VK_ESCAPE
) and (SelectedObjects
<> nil) then
4707 RemoveSelectFromObjects();
4709 // Передвинуть объекты:
4710 if MainForm
.ActiveControl
= RenderPanel
then
4715 if Key
= VK_NUMPAD4
then
4716 dx
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4717 if Key
= VK_NUMPAD6
then
4718 dx
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4719 if Key
= VK_NUMPAD8
then
4720 dy
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4721 if Key
= VK_NUMPAD5
then
4722 dy
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4724 if (dx
<> 0) or (dy
<> 0) then
4726 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
, dx
, dy
);
4731 if ssCtrl
in Shift
then
4733 // Выбор панели с текстурой для триггера
4734 if Key
= Ord('T') then
4736 DrawPressRect
:= False;
4737 if SelectFlag
= SELECTFLAG_TEXTURE
then
4739 SelectFlag
:= SELECTFLAG_NONE
;
4742 vleObjectProperty
.FindRow(MsgPropTrTexturePanel
, i
);
4744 SelectFlag
:= SELECTFLAG_TEXTURE
;
4747 if Key
= Ord('D') then
4749 SelectFlag
:= SELECTFLAG_NONE
;
4750 if DrawPressRect
then
4752 DrawPressRect
:= False;
4757 // Выбор области воздействия, в зависимости от типа триггера
4758 vleObjectProperty
.FindRow(MsgPropTrExArea
, i
);
4761 DrawPressRect
:= True;
4764 vleObjectProperty
.FindRow(MsgPropTrDoorPanel
, i
);
4766 vleObjectProperty
.FindRow(MsgPropTrTrapPanel
, i
);
4769 SelectFlag
:= SELECTFLAG_DOOR
;
4772 vleObjectProperty
.FindRow(MsgPropTrLiftPanel
, i
);
4775 SelectFlag
:= SELECTFLAG_LIFT
;
4778 vleObjectProperty
.FindRow(MsgPropTrTeleportTo
, i
);
4781 SelectFlag
:= SELECTFLAG_TELEPORT
;
4784 vleObjectProperty
.FindRow(MsgPropTrSpawnTo
, i
);
4787 SelectFlag
:= SELECTFLAG_SPAWNPOINT
;
4791 // Выбор основного параметра, в зависимости от типа триггера
4792 vleObjectProperty
.FindRow(MsgPropTrNextMap
, i
);
4795 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
4796 SelectMapForm
.Caption
:= MsgCapSelect
;
4797 SelectMapForm
.GetMaps(FileName
);
4799 if SelectMapForm
.ShowModal() = mrOK
then
4801 vleObjectProperty
.Cells
[1, i
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
4802 bApplyProperty
.Click();
4806 vleObjectProperty
.FindRow(MsgPropTrSoundName
, i
);
4808 vleObjectProperty
.FindRow(MsgPropTrMusicName
, i
);
4811 AddSoundForm
.OKFunction
:= nil;
4812 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
4813 AddSoundForm
.SetResource
:= vleObjectProperty
.Cells
[1, i
];
4815 if (AddSoundForm
.ShowModal() = mrOk
) then
4817 vleObjectProperty
.Cells
[1, i
] := AddSoundForm
.ResourceName
;
4818 bApplyProperty
.Click();
4822 vleObjectProperty
.FindRow(MsgPropTrPushAngle
, i
);
4824 vleObjectProperty
.FindRow(MsgPropTrMessageText
, i
);
4827 vleObjectProperty
.Row
:= i
;
4828 vleObjectProperty
.SetFocus();
4835 procedure TMainForm
.aOptimizeExecute(Sender
: TObject
);
4837 RemoveSelectFromObjects();
4838 MapOptimizationForm
.ShowModal();
4841 procedure TMainForm
.aCheckMapExecute(Sender
: TObject
);
4843 MapCheckForm
.ShowModal();
4846 procedure TMainForm
.bbAddTextureClick(Sender
: TObject
);
4848 AddTextureForm
.lbResourcesList
.MultiSelect
:= True;
4849 AddTextureForm
.ShowModal();
4852 procedure TMainForm
.lbTextureListClick(Sender
: TObject
);
4855 TextureWidth
, TextureHeight
: Word;
4860 if (lbTextureList
.ItemIndex
<> -1) and
4861 (not IsSpecialTextureSel()) then
4863 if g_GetTexture(SelectedTexture(), TextureID
) then
4865 g_GetTextureSizeByID(TextureID
, TextureWidth
, TextureHeight
);
4867 lTextureWidth
.Caption
:= IntToStr(TextureWidth
);
4868 lTextureHeight
.Caption
:= IntToStr(TextureHeight
);
4871 lTextureWidth
.Caption
:= MsgNotAccessible
;
4872 lTextureHeight
.Caption
:= MsgNotAccessible
;
4877 lTextureWidth
.Caption
:= '';
4878 lTextureHeight
.Caption
:= '';
4882 procedure TMainForm
.lbTextureListDrawItem(Control
: TWinControl
; Index
: Integer;
4883 ARect
: TRect
; State
: TOwnerDrawState
);
4885 with Control
as TListBox
do
4887 if LCLType
.odSelected
in State
then
4889 Canvas
.Brush
.Color
:= clHighlight
;
4890 Canvas
.Font
.Color
:= clHighlightText
;
4892 if (Items
<> nil) and (Index
>= 0) then
4893 if slInvalidTextures
.IndexOf(Items
[Index
]) > -1 then
4895 Canvas
.Brush
.Color
:= clRed
;
4896 Canvas
.Font
.Color
:= clWhite
;
4898 Canvas
.FillRect(ARect
);
4899 Canvas
.TextRect(ARect
, ARect
.Left
, ARect
.Top
, Items
[Index
]);
4903 procedure TMainForm
.miMacMinimizeClick(Sender
: TObject
);
4905 self
.WindowState
:= wsMinimized
;
4906 self
.FormWindowStateChange(Sender
);
4909 procedure TMainForm
.miMacZoomClick(Sender
: TObject
);
4911 if self
.WindowState
= wsMaximized
then
4912 self
.WindowState
:= wsNormal
4914 self
.WindowState
:= wsMaximized
;
4915 self
.FormWindowStateChange(Sender
);
4918 procedure TMainForm
.miReopenMapClick(Sender
: TObject
);
4920 FileName
, Resource
: String;
4922 if OpenedMap
= '' then
4925 if Application
.MessageBox(PChar(MsgMsgReopenMapPrompt
),
4926 PChar(MsgMenuFileReopen
), MB_ICONQUESTION
or MB_YESNO
) <> idYes
then
4929 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, @Resource
);
4930 OpenMap(FileName
, Resource
);
4933 procedure TMainForm
.vleObjectPropertyGetPickList(Sender
: TObject
;
4934 const KeyName
: String; Values
: TStrings
);
4936 if vleObjectProperty
.ItemProps
[KeyName
].EditStyle
= esPickList
then
4938 if KeyName
= MsgPropDirection
then
4940 Values
.Add(DirNames
[D_LEFT
]);
4941 Values
.Add(DirNames
[D_RIGHT
]);
4943 else if KeyName
= MsgPropTrTeleportDir
then
4945 Values
.Add(DirNamesAdv
[0]);
4946 Values
.Add(DirNamesAdv
[1]);
4947 Values
.Add(DirNamesAdv
[2]);
4948 Values
.Add(DirNamesAdv
[3]);
4950 else if KeyName
= MsgPropTrMusicAct
then
4952 Values
.Add(MsgPropTrMusicOn
);
4953 Values
.Add(MsgPropTrMusicOff
);
4955 else if KeyName
= MsgPropTrMonsterBehaviour
then
4957 Values
.Add(MsgPropTrMonsterBehaviour0
);
4958 Values
.Add(MsgPropTrMonsterBehaviour1
);
4959 Values
.Add(MsgPropTrMonsterBehaviour2
);
4960 Values
.Add(MsgPropTrMonsterBehaviour3
);
4961 Values
.Add(MsgPropTrMonsterBehaviour4
);
4962 Values
.Add(MsgPropTrMonsterBehaviour5
);
4964 else if KeyName
= MsgPropTrScoreAct
then
4966 Values
.Add(MsgPropTrScoreAct0
);
4967 Values
.Add(MsgPropTrScoreAct1
);
4968 Values
.Add(MsgPropTrScoreAct2
);
4969 Values
.Add(MsgPropTrScoreAct3
);
4971 else if KeyName
= MsgPropTrScoreTeam
then
4973 Values
.Add(MsgPropTrScoreTeam0
);
4974 Values
.Add(MsgPropTrScoreTeam1
);
4975 Values
.Add(MsgPropTrScoreTeam2
);
4976 Values
.Add(MsgPropTrScoreTeam3
);
4978 else if KeyName
= MsgPropTrMessageKind
then
4980 Values
.Add(MsgPropTrMessageKind0
);
4981 Values
.Add(MsgPropTrMessageKind1
);
4983 else if KeyName
= MsgPropTrMessageTo
then
4985 Values
.Add(MsgPropTrMessageTo0
);
4986 Values
.Add(MsgPropTrMessageTo1
);
4987 Values
.Add(MsgPropTrMessageTo2
);
4988 Values
.Add(MsgPropTrMessageTo3
);
4989 Values
.Add(MsgPropTrMessageTo4
);
4990 Values
.Add(MsgPropTrMessageTo5
);
4992 else if KeyName
= MsgPropTrShotTo
then
4994 Values
.Add(MsgPropTrShotTo0
);
4995 Values
.Add(MsgPropTrShotTo1
);
4996 Values
.Add(MsgPropTrShotTo2
);
4997 Values
.Add(MsgPropTrShotTo3
);
4998 Values
.Add(MsgPropTrShotTo4
);
4999 Values
.Add(MsgPropTrShotTo5
);
5000 Values
.Add(MsgPropTrShotTo6
);
5002 else if KeyName
= MsgPropTrShotAim
then
5004 Values
.Add(MsgPropTrShotAim0
);
5005 Values
.Add(MsgPropTrShotAim1
);
5006 Values
.Add(MsgPropTrShotAim2
);
5007 Values
.Add(MsgPropTrShotAim3
);
5009 else if KeyName
= MsgPropTrDamageKind
then
5011 Values
.Add(MsgPropTrDamageKind0
);
5012 Values
.Add(MsgPropTrDamageKind3
);
5013 Values
.Add(MsgPropTrDamageKind4
);
5014 Values
.Add(MsgPropTrDamageKind5
);
5015 Values
.Add(MsgPropTrDamageKind6
);
5016 Values
.Add(MsgPropTrDamageKind7
);
5017 Values
.Add(MsgPropTrDamageKind8
);
5019 else if (KeyName
= MsgPropPanelBlend
) or
5020 (KeyName
= MsgPropDmOnly
) or
5021 (KeyName
= MsgPropItemFalls
) or
5022 (KeyName
= MsgPropTrEnabled
) or
5023 (KeyName
= MsgPropTrD2d
) or
5024 (KeyName
= MsgPropTrSilent
) or
5025 (KeyName
= MsgPropTrTeleportSilent
) or
5026 (KeyName
= MsgPropTrExRandom
) or
5027 (KeyName
= MsgPropTrTextureOnce
) or
5028 (KeyName
= MsgPropTrTextureAnimOnce
) or
5029 (KeyName
= MsgPropTrSoundLocal
) or
5030 (KeyName
= MsgPropTrSoundSwitch
) or
5031 (KeyName
= MsgPropTrMonsterActive
) or
5032 (KeyName
= MsgPropTrPushReset
) or
5033 (KeyName
= MsgPropTrScoreCon
) or
5034 (KeyName
= MsgPropTrScoreMsg
) or
5035 (KeyName
= MsgPropTrHealthMax
) or
5036 (KeyName
= MsgPropTrShotSound
) or
5037 (KeyName
= MsgPropTrEffectCenter
) then
5039 Values
.Add(BoolNames
[True]);
5040 Values
.Add(BoolNames
[False]);
5045 procedure TMainForm
.bApplyPropertyClick(Sender
: TObject
);
5047 _id
, a
, r
, c
: Integer;
5057 if SelectedObjectCount() <> 1 then
5059 if not SelectedObjects
[GetFirstSelected()].Live
then
5063 if not CheckProperty() then
5069 _id
:= GetFirstSelected();
5071 r
:= vleObjectProperty
.Row
;
5072 c
:= vleObjectProperty
.Col
;
5074 case SelectedObjects
[_id
].ObjectType
of
5077 with gPanels
[SelectedObjects
[_id
].ID
] do
5079 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5080 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5081 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropWidth
]));
5082 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropHeight
]));
5084 PanelType
:= GetPanelType(vleObjectProperty
.Values
[MsgPropPanelType
]);
5086 // Сброс ссылки на триггеры смены текстуры:
5087 if not WordBool(PanelType
and (PANEL_WALL
or PANEL_FORE
or PANEL_BACK
)) then
5088 if gTriggers
<> nil then
5089 for a
:= 0 to High(gTriggers
) do
5091 if (gTriggers
[a
].TriggerType
<> 0) and
5092 (gTriggers
[a
].TexturePanel
= Integer(SelectedObjects
[_id
].ID
)) then
5093 gTriggers
[a
].TexturePanel
:= -1;
5094 if (gTriggers
[a
].TriggerType
= TRIGGER_SHOT
) and
5095 (gTriggers
[a
].Data
.ShotPanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5096 gTriggers
[a
].Data
.ShotPanelID
:= -1;
5099 // Сброс ссылки на триггеры лифта:
5100 if not WordBool(PanelType
and (PANEL_LIFTUP
or PANEL_LIFTDOWN
or PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
)) then
5101 if gTriggers
<> nil then
5102 for a
:= 0 to High(gTriggers
) do
5103 if (gTriggers
[a
].TriggerType
in [TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
]) and
5104 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5105 gTriggers
[a
].Data
.PanelID
:= -1;
5107 // Сброс ссылки на триггеры двери:
5108 if not WordBool(PanelType
and (PANEL_OPENDOOR
or PANEL_CLOSEDOOR
)) then
5109 if gTriggers
<> nil then
5110 for a
:= 0 to High(gTriggers
) do
5111 if (gTriggers
[a
].TriggerType
in [TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5112 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
]) and
5113 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5114 gTriggers
[a
].Data
.PanelID
:= -1;
5116 if IsTexturedPanel(PanelType
) then
5117 begin // Может быть текстура
5118 if TextureName
<> '' then
5119 begin // Была текстура
5120 Alpha
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropPanelAlpha
]));
5121 Blending
:= NameToBool(vleObjectProperty
.Values
[MsgPropPanelBlend
]);
5130 TextureName
:= vleObjectProperty
.Values
[MsgPropPanelTex
];
5132 if TextureName
<> '' then
5133 begin // Есть текстура
5134 // Обычная текстура:
5135 if not IsSpecialTexture(TextureName
) then
5137 g_GetTextureSizeByName(TextureName
,
5138 TextureWidth
, TextureHeight
);
5140 // Проверка кратности размеров панели:
5142 if TextureWidth
<> 0 then
5143 if gPanels
[SelectedObjects
[_id
].ID
].Width
mod TextureWidth
<> 0 then
5145 ErrorMessageBox(Format(MsgMsgWrongTexwidth
,
5149 if Res
and (TextureHeight
<> 0) then
5150 if gPanels
[SelectedObjects
[_id
].ID
].Height
mod TextureHeight
<> 0 then
5152 ErrorMessageBox(Format(MsgMsgWrongTexheight
,
5159 if not g_GetTexture(TextureName
, TextureID
) then
5160 // Не удалось загрузить текстуру, рисуем NOTEXTURE
5161 if g_GetTexture('NOTEXTURE', NoTextureID
) then
5163 TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
5164 g_GetTextureSizeByID(NoTextureID
, NW
, NH
);
5166 TextureHeight
:= NH
;
5169 TextureID
:= TEXTURE_SPECIAL_NONE
;
5179 TextureID
:= TEXTURE_SPECIAL_NONE
;
5182 else // Спец.текстура
5186 TextureID
:= SpecialTextureID(TextureName
);
5189 else // Нет текстуры
5193 TextureID
:= TEXTURE_SPECIAL_NONE
;
5196 else // Не может быть текстуры
5203 TextureID
:= TEXTURE_SPECIAL_NONE
;
5210 with gItems
[SelectedObjects
[_id
].ID
] do
5212 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5213 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5214 OnlyDM
:= NameToBool(vleObjectProperty
.Values
[MsgPropDmOnly
]);
5215 Fall
:= NameToBool(vleObjectProperty
.Values
[MsgPropItemFalls
]);
5221 with gMonsters
[SelectedObjects
[_id
].ID
] do
5223 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5224 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5225 Direction
:= NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]);
5231 with gAreas
[SelectedObjects
[_id
].ID
] do
5233 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5234 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5235 Direction
:= NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]);
5241 with gTriggers
[SelectedObjects
[_id
].ID
] do
5243 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5244 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5245 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropWidth
]));
5246 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropHeight
]));
5247 Enabled
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrEnabled
]);
5248 ActivateType
:= StrToActivate(vleObjectProperty
.Values
[MsgPropTrActivation
]);
5249 Key
:= StrToKey(vleObjectProperty
.Values
[MsgPropTrKeys
]);
5254 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrNextMap
]);
5255 FillByte(Data
.MapName
[0], 16, 0);
5257 Move(s
[1], Data
.MapName
[0], Min(Length(s
), 16));
5262 Data
.ActivateOnce
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTextureOnce
]);
5263 Data
.AnimOnce
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTextureAnimOnce
]);
5266 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
5268 Data
.Wait
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 65535);
5269 Data
.Count
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExCount
], 0), 65535);
5270 if Data
.Count
< 1 then
5272 if TriggerType
= TRIGGER_PRESS
then
5273 Data
.ExtRandom
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrExRandom
]);
5276 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
, TRIGGER_DOOR5
,
5277 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
, TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
,
5280 Data
.NoSound
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSilent
]);
5281 Data
.d2d_doors
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrD2d
]);
5286 Data
.d2d_teleport
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrD2d
]);
5287 Data
.silent_teleport
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTeleportSilent
]);
5288 Data
.TlpDir
:= NameToDirAdv(vleObjectProperty
.Values
[MsgPropTrTeleportDir
]);
5293 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrSoundName
]);
5294 FillByte(Data
.SoundName
[0], 64, 0);
5296 Move(s
[1], Data
.SoundName
[0], Min(Length(s
), 64));
5298 Data
.Volume
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundVolume
], 0), 255);
5299 Data
.Pan
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundPan
], 0), 255);
5300 Data
.PlayCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundCount
], 0), 255);
5301 Data
.Local
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSoundLocal
]);
5302 Data
.SoundSwitch
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSoundSwitch
]);
5305 TRIGGER_SPAWNMONSTER
:
5307 Data
.MonType
:= StrToMonster(vleObjectProperty
.Values
[MsgPropTrMonsterType
]);
5308 Data
.MonDir
:= Byte(NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]));
5309 Data
.MonHealth
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrHealth
], 0), 1000000);
5310 if Data
.MonHealth
< 0 then
5311 Data
.MonHealth
:= 0;
5312 Data
.MonActive
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrMonsterActive
]);
5313 Data
.MonCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 64);
5314 if Data
.MonCount
< 1 then
5316 Data
.MonEffect
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrFxType
]);
5317 Data
.MonMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnMax
], 0), 65535);
5318 Data
.MonDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnDelay
], 0), 65535);
5320 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour1
then
5322 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour2
then
5324 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour3
then
5326 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour4
then
5328 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour5
then
5334 Data
.ItemType
:= StrToItem(vleObjectProperty
.Values
[MsgPropTrItemType
]);
5335 Data
.ItemOnlyDM
:= NameToBool(vleObjectProperty
.Values
[MsgPropDmOnly
]);
5336 Data
.ItemFalls
:= NameToBool(vleObjectProperty
.Values
[MsgPropItemFalls
]);
5337 Data
.ItemCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 64);
5338 if Data
.ItemCount
< 1 then
5339 Data
.ItemCount
:= 1;
5340 Data
.ItemEffect
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrFxType
]);
5341 Data
.ItemMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnMax
], 0), 65535);
5342 Data
.ItemDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnDelay
], 0), 65535);
5347 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrMusicName
]);
5348 FillByte(Data
.MusicName
[0], 64, 0);
5350 Move(s
[1], Data
.MusicName
[0], Min(Length(s
), 64));
5352 if vleObjectProperty
.Values
[MsgPropTrMusicAct
] = MsgPropTrMusicOn
then
5353 Data
.MusicAction
:= 1
5355 Data
.MusicAction
:= 0;
5360 Data
.PushAngle
:= Min(
5361 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrPushAngle
], 0), 360);
5362 Data
.PushForce
:= Min(
5363 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrPushForce
], 0), 255);
5364 Data
.ResetVel
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrPushReset
]);
5369 Data
.ScoreAction
:= 0;
5370 if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct1
then
5371 Data
.ScoreAction
:= 1
5372 else if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct2
then
5373 Data
.ScoreAction
:= 2
5374 else if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct3
then
5375 Data
.ScoreAction
:= 3;
5376 Data
.ScoreCount
:= Min(Max(
5377 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 0), 255);
5378 Data
.ScoreTeam
:= 0;
5379 if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam1
then
5381 else if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam2
then
5383 else if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam3
then
5384 Data
.ScoreTeam
:= 3;
5385 Data
.ScoreCon
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrScoreCon
]);
5386 Data
.ScoreMsg
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrScoreMsg
]);
5391 Data
.MessageKind
:= 0;
5392 if vleObjectProperty
.Values
[MsgPropTrMessageKind
] = MsgPropTrMessageKind1
then
5393 Data
.MessageKind
:= 1;
5395 Data
.MessageSendTo
:= 0;
5396 if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo1
then
5397 Data
.MessageSendTo
:= 1
5398 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo2
then
5399 Data
.MessageSendTo
:= 2
5400 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo3
then
5401 Data
.MessageSendTo
:= 3
5402 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo4
then
5403 Data
.MessageSendTo
:= 4
5404 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo5
then
5405 Data
.MessageSendTo
:= 5;
5407 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrMessageText
]);
5408 FillByte(Data
.MessageText
[0], 100, 0);
5410 Move(s
[1], Data
.MessageText
[0], Min(Length(s
), 100));
5412 Data
.MessageTime
:= Min(Max(
5413 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrMessageTime
], 0), 0), 65535);
5418 Data
.DamageValue
:= Min(Max(
5419 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrDamageValue
], 0), 0), 65535);
5420 Data
.DamageInterval
:= Min(Max(
5421 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrInterval
], 0), 0), 65535);
5422 s
:= vleObjectProperty
.Values
[MsgPropTrDamageKind
];
5423 if s
= MsgPropTrDamageKind3
then
5424 Data
.DamageKind
:= 3
5425 else if s
= MsgPropTrDamageKind4
then
5426 Data
.DamageKind
:= 4
5427 else if s
= MsgPropTrDamageKind5
then
5428 Data
.DamageKind
:= 5
5429 else if s
= MsgPropTrDamageKind6
then
5430 Data
.DamageKind
:= 6
5431 else if s
= MsgPropTrDamageKind7
then
5432 Data
.DamageKind
:= 7
5433 else if s
= MsgPropTrDamageKind8
then
5434 Data
.DamageKind
:= 8
5436 Data
.DamageKind
:= 0;
5441 Data
.HealValue
:= Min(Max(
5442 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrHealth
], 0), 0), 65535);
5443 Data
.HealInterval
:= Min(Max(
5444 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrInterval
], 0), 0), 65535);
5445 Data
.HealMax
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrHealthMax
]);
5446 Data
.HealSilent
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSilent
]);
5451 Data
.ShotType
:= StrToShot(vleObjectProperty
.Values
[MsgPropTrShotType
]);
5452 Data
.ShotSound
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrShotSound
]);
5453 Data
.ShotTarget
:= 0;
5454 if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo1
then
5455 Data
.ShotTarget
:= 1
5456 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo2
then
5457 Data
.ShotTarget
:= 2
5458 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo3
then
5459 Data
.ShotTarget
:= 3
5460 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo4
then
5461 Data
.ShotTarget
:= 4
5462 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo5
then
5463 Data
.ShotTarget
:= 5
5464 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo6
then
5465 Data
.ShotTarget
:= 6;
5466 Data
.ShotIntSight
:= Min(Max(
5467 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotSight
], 0), 0), 65535);
5469 if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim1
then
5471 else if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim2
then
5473 else if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim3
then
5475 Data
.ShotAngle
:= Min(
5476 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAngle
], 0), 360);
5477 Data
.ShotWait
:= Min(Max(
5478 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 0), 65535);
5479 Data
.ShotAccuracy
:= Min(Max(
5480 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAcc
], 0), 0), 65535);
5481 Data
.ShotAmmo
:= Min(Max(
5482 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAmmo
], 0), 0), 65535);
5483 Data
.ShotIntReload
:= Min(Max(
5484 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotReload
], 0), 0), 65535);
5489 Data
.FXCount
:= Min(Max(
5490 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 0), 255);
5491 if vleObjectProperty
.Values
[MsgPropTrEffectType
] = MsgPropTrEffectParticle
then
5493 Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
5494 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
5495 if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectSliquid
then
5496 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
5497 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectLliquid
then
5498 Data
.FXSubType
:= TRIGGER_EFFECT_LLIQUID
5499 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectDliquid
then
5500 Data
.FXSubType
:= TRIGGER_EFFECT_DLIQUID
5501 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectBlood
then
5502 Data
.FXSubType
:= TRIGGER_EFFECT_BLOOD
5503 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectSpark
then
5504 Data
.FXSubType
:= TRIGGER_EFFECT_SPARK
5505 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectBubble
then
5506 Data
.FXSubType
:= TRIGGER_EFFECT_BUBBLE
;
5509 Data
.FXType
:= TRIGGER_EFFECT_ANIMATION
;
5510 Data
.FXSubType
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrEffectSubtype
]);
5513 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectColor
], 0), 0), $FFFFFF);
5514 Data
.FXColorR
:= a
and $FF;
5515 Data
.FXColorG
:= (a
shr 8) and $FF;
5516 Data
.FXColorB
:= (a
shr 16) and $FF;
5517 if NameToBool(vleObjectProperty
.Values
[MsgPropTrEffectCenter
]) then
5521 Data
.FXWait
:= Min(Max(
5522 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 0), 65535);
5523 Data
.FXVelX
:= Min(Max(
5524 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectVelx
], 0), -128), 127);
5525 Data
.FXVelY
:= Min(Max(
5526 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectVely
], 0), -128), 127);
5527 Data
.FXSpreadL
:= Min(Max(
5528 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpl
], 0), 0), 255);
5529 Data
.FXSpreadR
:= Min(Max(
5530 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpr
], 0), 0), 255);
5531 Data
.FXSpreadU
:= Min(Max(
5532 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpu
], 0), 0), 255);
5533 Data
.FXSpreadD
:= Min(Max(
5534 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpd
], 0), 0), 255);
5543 vleObjectProperty
.Row
:= r
;
5544 vleObjectProperty
.Col
:= c
;
5547 procedure TMainForm
.bbRemoveTextureClick(Sender
: TObject
);
5551 i
:= lbTextureList
.ItemIndex
;
5555 if Application
.MessageBox(PChar(Format(MsgMsgDelTexturePrompt
,
5556 [SelectedTexture()])),
5557 PChar(MsgMsgDelTexture
),
5558 MB_ICONQUESTION
or MB_YESNO
or
5559 MB_DEFBUTTON1
) <> idYes
then
5562 if gPanels
<> nil then
5563 for a
:= 0 to High(gPanels
) do
5564 if (gPanels
[a
].PanelType
<> 0) and
5565 (gPanels
[a
].TextureName
= SelectedTexture()) then
5567 ErrorMessageBox(MsgMsgDelTextureCant
);
5571 g_DeleteTexture(SelectedTexture());
5572 i
:= slInvalidTextures
.IndexOf(lbTextureList
.Items
[i
]);
5574 slInvalidTextures
.Delete(i
);
5575 if lbTextureList
.ItemIndex
> -1 then
5576 lbTextureList
.Items
.Delete(lbTextureList
.ItemIndex
)
5579 procedure TMainForm
.aNewMapExecute(Sender
: TObject
);
5581 if Application
.MessageBox(PChar(MsgMsgClearMapPrompt
), PChar(MsgMsgClearMap
), MB_ICONQUESTION
or MB_YESNO
or MB_DEFBUTTON1
) = mrYes
then
5585 procedure TMainForm
.aUndoExecute(Sender
: TObject
);
5589 if UndoBuffer
= nil then
5591 if UndoBuffer
[High(UndoBuffer
)] = nil then
5594 for a
:= 0 to High(UndoBuffer
[High(UndoBuffer
)]) do
5595 with UndoBuffer
[High(UndoBuffer
)][a
] do
5603 UNDO_DELETE_ITEM
: AddItem(Item
);
5604 UNDO_DELETE_AREA
: AddArea(Area
);
5605 UNDO_DELETE_MONSTER
: AddMonster(Monster
);
5606 UNDO_DELETE_TRIGGER
: AddTrigger(Trigger
);
5607 UNDO_ADD_PANEL
: RemoveObject(AddID
, OBJECT_PANEL
);
5608 UNDO_ADD_ITEM
: RemoveObject(AddID
, OBJECT_ITEM
);
5609 UNDO_ADD_AREA
: RemoveObject(AddID
, OBJECT_AREA
);
5610 UNDO_ADD_MONSTER
: RemoveObject(AddID
, OBJECT_MONSTER
);
5611 UNDO_ADD_TRIGGER
: RemoveObject(AddID
, OBJECT_TRIGGER
);
5615 SetLength(UndoBuffer
, Length(UndoBuffer
)-1);
5616 RemoveSelectFromObjects();
5617 miUndo
.Enabled
:= UndoBuffer
<> nil;
5621 procedure TMainForm
.aCopyObjectExecute(Sender
: TObject
);
5624 CopyBuffer
: TCopyRecArray
;
5628 function CB_Compare(I1
, I2
: TCopyRec
): Integer;
5630 Result
:= Integer(I1
.ObjectType
) - Integer(I2
.ObjectType
);
5632 if Result
= 0 then // Одного типа
5633 Result
:= Integer(I1
.ID
) - Integer(I2
.ID
);
5636 procedure QuickSortCopyBuffer(L
, R
: Integer);
5644 P
:= CopyBuffer
[(L
+ R
) shr 1];
5647 while CB_Compare(CopyBuffer
[I
], P
) < 0 do
5649 while CB_Compare(CopyBuffer
[J
], P
) > 0 do
5655 CopyBuffer
[I
] := CopyBuffer
[J
];
5663 QuickSortCopyBuffer(L
, J
);
5670 if SelectedObjects
= nil then
5676 // Копируем объекты:
5677 for a
:= 0 to High(SelectedObjects
) do
5678 if SelectedObjects
[a
].Live
then
5679 with SelectedObjects
[a
] do
5681 SetLength(CopyBuffer
, Length(CopyBuffer
)+1);
5682 b
:= High(CopyBuffer
);
5683 CopyBuffer
[b
].ID
:= ID
;
5684 CopyBuffer
[b
].Panel
:= nil;
5689 CopyBuffer
[b
].ObjectType
:= OBJECT_PANEL
;
5690 New(CopyBuffer
[b
].Panel
);
5691 CopyBuffer
[b
].Panel
^ := gPanels
[ID
];
5696 CopyBuffer
[b
].ObjectType
:= OBJECT_ITEM
;
5697 CopyBuffer
[b
].Item
:= gItems
[ID
];
5702 CopyBuffer
[b
].ObjectType
:= OBJECT_MONSTER
;
5703 CopyBuffer
[b
].Monster
:= gMonsters
[ID
];
5708 CopyBuffer
[b
].ObjectType
:= OBJECT_AREA
;
5709 CopyBuffer
[b
].Area
:= gAreas
[ID
];
5714 CopyBuffer
[b
].ObjectType
:= OBJECT_TRIGGER
;
5715 CopyBuffer
[b
].Trigger
:= gTriggers
[ID
];
5720 // Сортировка по ID:
5721 if CopyBuffer
<> nil then
5723 QuickSortCopyBuffer(0, b
);
5726 // Постановка ссылок триггеров:
5727 for a
:= 0 to Length(CopyBuffer
)-1 do
5728 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
5730 case CopyBuffer
[a
].Trigger
.TriggerType
of
5731 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5732 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5733 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5734 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
5738 for b
:= 0 to Length(CopyBuffer
)-1 do
5739 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5740 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.PanelID
) then
5742 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= b
;
5747 // Этих панелей нет среди копируемых:
5749 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= -1;
5752 TRIGGER_PRESS
, TRIGGER_ON
,
5753 TRIGGER_OFF
, TRIGGER_ONOFF
:
5754 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
5758 for b
:= 0 to Length(CopyBuffer
)-1 do
5759 if (CopyBuffer
[b
].ObjectType
= OBJECT_MONSTER
) and
5760 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1) then
5762 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= b
+1;
5767 // Этих монстров нет среди копируемых:
5769 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= 0;
5773 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
5777 for b
:= 0 to Length(CopyBuffer
)-1 do
5778 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5779 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
) then
5781 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= b
;
5786 // Этих панелей нет среди копируемых:
5788 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= -1;
5792 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
5796 for b
:= 0 to Length(CopyBuffer
)-1 do
5797 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5798 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.TexturePanel
) then
5800 CopyBuffer
[a
].Trigger
.TexturePanel
:= b
;
5805 // Этих панелей нет среди копируемых:
5807 CopyBuffer
[a
].Trigger
.TexturePanel
:= -1;
5812 str
:= CopyBufferToString(CopyBuffer
);
5813 ClipBoard
.AsText
:= str
;
5815 for a
:= 0 to Length(CopyBuffer
)-1 do
5816 if (CopyBuffer
[a
].ObjectType
= OBJECT_PANEL
) and
5817 (CopyBuffer
[a
].Panel
<> nil) then
5818 Dispose(CopyBuffer
[a
].Panel
);
5823 procedure TMainForm
.aPasteObjectExecute(Sender
: TObject
);
5826 CopyBuffer
: TCopyRecArray
;
5828 swad
, ssec
, sres
: String;
5831 xadj
, yadj
: LongInt;
5836 pmin
.X
:= High(pmin
.X
);
5837 pmin
.Y
:= High(pmin
.Y
);
5839 StringToCopyBuffer(ClipBoard
.AsText
, CopyBuffer
, pmin
);
5840 if CopyBuffer
= nil then
5843 rel
:= not(ssShift
in GetKeyShiftState());
5844 h
:= High(CopyBuffer
);
5845 RemoveSelectFromObjects();
5848 pmin
.X
, pmin
.Y
, -MapOffset
.X
-32, -MapOffset
.Y
-32, RenderPanel
.Width
, RenderPanel
.Height
) then
5855 xadj
:= Floor((-pmin
.X
- MapOffset
.X
+ 32) / DotStep
) * DotStep
;
5856 yadj
:= Floor((-pmin
.Y
- MapOffset
.Y
+ 32) / DotStep
) * DotStep
;
5860 with CopyBuffer
[a
] do
5864 if Panel
<> nil then
5872 Panel
^.TextureID
:= TEXTURE_SPECIAL_NONE
;
5873 Panel
^.TextureWidth
:= 1;
5874 Panel
^.TextureHeight
:= 1;
5876 if (Panel
^.PanelType
= PANEL_LIFTUP
) or
5877 (Panel
^.PanelType
= PANEL_LIFTDOWN
) or
5878 (Panel
^.PanelType
= PANEL_LIFTLEFT
) or
5879 (Panel
^.PanelType
= PANEL_LIFTRIGHT
) or
5880 (Panel
^.PanelType
= PANEL_BLOCKMON
) or
5881 (Panel
^.TextureName
= '') then
5882 begin // Нет или не может быть текстуры:
5884 else // Есть текстура:
5886 // Обычная текстура:
5887 if not IsSpecialTexture(Panel
^.TextureName
) then
5889 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5893 g_ProcessResourceStr(Panel
^.TextureName
, swad
, ssec
, sres
);
5894 AddTexture(swad
, ssec
, sres
, True);
5895 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5899 g_GetTextureSizeByName(Panel
^.TextureName
,
5900 Panel
^.TextureWidth
, Panel
^.TextureHeight
)
5902 if g_GetTexture('NOTEXTURE', NoTextureID
) then
5904 Panel
^.TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
5905 g_GetTextureSizeByID(NoTextureID
, Panel
^.TextureWidth
, Panel
^.TextureHeight
);
5908 else // Спец.текстура:
5910 Panel
^.TextureID
:= SpecialTextureID(Panel
^.TextureName
);
5911 with MainForm
.lbTextureList
.Items
do
5912 if IndexOf(Panel
^.TextureName
) = -1 then
5913 Add(Panel
^.TextureName
);
5917 ID
:= AddPanel(Panel
^);
5919 Undo_Add(OBJECT_PANEL
, ID
, a
> 0);
5920 SelectObject(OBJECT_PANEL
, ID
, True);
5931 ID
:= AddItem(Item
);
5932 Undo_Add(OBJECT_ITEM
, ID
, a
> 0);
5933 SelectObject(OBJECT_ITEM
, ID
, True);
5944 ID
:= AddMonster(Monster
);
5945 Undo_Add(OBJECT_MONSTER
, ID
, a
> 0);
5946 SelectObject(OBJECT_MONSTER
, ID
, True);
5957 ID
:= AddArea(Area
);
5958 Undo_Add(OBJECT_AREA
, ID
, a
> 0);
5959 SelectObject(OBJECT_AREA
, ID
, True);
5973 Data
.TargetPoint
.X
+= xadj
;
5974 Data
.TargetPoint
.Y
+= yadj
;
5976 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
5981 TRIGGER_SPAWNMONSTER
:
5983 Data
.MonPos
.X
+= xadj
;
5984 Data
.MonPos
.Y
+= yadj
;
5988 Data
.ItemPos
.X
+= xadj
;
5989 Data
.ItemPos
.Y
+= yadj
;
5993 Data
.ShotPos
.X
+= xadj
;
5994 Data
.ShotPos
.Y
+= yadj
;
5999 ID
:= AddTrigger(Trigger
);
6000 Undo_Add(OBJECT_TRIGGER
, ID
, a
> 0);
6001 SelectObject(OBJECT_TRIGGER
, ID
, True);
6006 // Переставляем ссылки триггеров:
6007 for a
:= 0 to High(CopyBuffer
) do
6008 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
6010 case CopyBuffer
[a
].Trigger
.TriggerType
of
6011 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
6012 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6013 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6014 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
6015 gTriggers
[CopyBuffer
[a
].ID
].Data
.PanelID
:=
6016 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.PanelID
].ID
;
6018 TRIGGER_PRESS
, TRIGGER_ON
,
6019 TRIGGER_OFF
, TRIGGER_ONOFF
:
6020 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
6021 gTriggers
[CopyBuffer
[a
].ID
].Data
.MonsterID
:=
6022 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1].ID
+1;
6025 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
6026 gTriggers
[CopyBuffer
[a
].ID
].Data
.ShotPanelID
:=
6027 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
].ID
;
6030 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
6031 gTriggers
[CopyBuffer
[a
].ID
].TexturePanel
:=
6032 CopyBuffer
[CopyBuffer
[a
].Trigger
.TexturePanel
].ID
;
6041 procedure TMainForm
.aCutObjectExecute(Sender
: TObject
);
6044 DeleteSelectedObjects();
6047 procedure TMainForm
.vleObjectPropertyEditButtonClick(Sender
: TObject
);
6049 Key
, FileName
: String;
6052 Key
:= vleObjectProperty
.Keys
[vleObjectProperty
.Row
];
6054 if Key
= MsgPropPanelType
then
6056 with ChooseTypeForm
, vleObjectProperty
do
6057 begin // Выбор типа панели:
6058 Caption
:= MsgPropPanelType
;
6059 lbTypeSelect
.Items
.Clear();
6061 for b
:= 0 to High(PANELNAMES
) do
6063 lbTypeSelect
.Items
.Add(PANELNAMES
[b
]);
6064 if Values
[Key
] = PANELNAMES
[b
] then
6065 lbTypeSelect
.ItemIndex
:= b
;
6068 if ShowModal() = mrOK
then
6070 b
:= lbTypeSelect
.ItemIndex
;
6071 Values
[Key
] := PANELNAMES
[b
];
6072 vleObjectPropertyApply(Sender
);
6076 else if Key
= MsgPropTrTeleportTo
then
6077 SelectFlag
:= SELECTFLAG_TELEPORT
6078 else if Key
= MsgPropTrSpawnTo
then
6079 SelectFlag
:= SELECTFLAG_SPAWNPOINT
6080 else if (Key
= MsgPropTrDoorPanel
) or
6081 (Key
= MsgPropTrTrapPanel
) then
6082 SelectFlag
:= SELECTFLAG_DOOR
6083 else if Key
= MsgPropTrTexturePanel
then
6085 DrawPressRect
:= False;
6086 SelectFlag
:= SELECTFLAG_TEXTURE
;
6088 else if Key
= MsgPropTrShotPanel
then
6089 SelectFlag
:= SELECTFLAG_SHOTPANEL
6090 else if Key
= MsgPropTrLiftPanel
then
6091 SelectFlag
:= SELECTFLAG_LIFT
6092 else if key
= MsgPropTrExMonster
then
6093 SelectFlag
:= SELECTFLAG_MONSTER
6094 else if Key
= MsgPropTrExArea
then
6096 SelectFlag
:= SELECTFLAG_NONE
;
6097 DrawPressRect
:= True;
6099 else if Key
= MsgPropTrNextMap
then
6100 begin // Выбор следующей карты:
6101 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
6102 SelectMapForm
.Caption
:= MsgCapSelect
;
6103 SelectMapForm
.GetMaps(FileName
);
6105 if SelectMapForm
.ShowModal() = mrOK
then
6107 vleObjectProperty
.Values
[Key
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
6108 vleObjectPropertyApply(Sender
);
6111 else if (Key
= MsgPropTrSoundName
) or
6112 (Key
= MsgPropTrMusicName
) then
6113 begin // Выбор файла звука/музыки:
6114 AddSoundForm
.OKFunction
:= nil;
6115 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
6116 AddSoundForm
.SetResource
:= vleObjectProperty
.Values
[Key
];
6118 if (AddSoundForm
.ShowModal() = mrOk
) then
6120 vleObjectProperty
.Values
[Key
] := AddSoundForm
.ResourceName
;
6121 vleObjectPropertyApply(Sender
);
6124 else if Key
= MsgPropTrActivation
then
6125 with ActivationTypeForm
, vleObjectProperty
do
6126 begin // Выбор типов активации:
6127 cbPlayerCollide
.Checked
:= Pos('PC', Values
[Key
]) > 0;
6128 cbMonsterCollide
.Checked
:= Pos('MC', Values
[Key
]) > 0;
6129 cbPlayerPress
.Checked
:= Pos('PP', Values
[Key
]) > 0;
6130 cbMonsterPress
.Checked
:= Pos('MP', Values
[Key
]) > 0;
6131 cbShot
.Checked
:= Pos('SH', Values
[Key
]) > 0;
6132 cbNoMonster
.Checked
:= Pos('NM', Values
[Key
]) > 0;
6134 if ShowModal() = mrOK
then
6137 if cbPlayerCollide
.Checked
then
6138 b
:= ACTIVATE_PLAYERCOLLIDE
;
6139 if cbMonsterCollide
.Checked
then
6140 b
:= b
or ACTIVATE_MONSTERCOLLIDE
;
6141 if cbPlayerPress
.Checked
then
6142 b
:= b
or ACTIVATE_PLAYERPRESS
;
6143 if cbMonsterPress
.Checked
then
6144 b
:= b
or ACTIVATE_MONSTERPRESS
;
6145 if cbShot
.Checked
then
6146 b
:= b
or ACTIVATE_SHOT
;
6147 if cbNoMonster
.Checked
then
6148 b
:= b
or ACTIVATE_NOMONSTER
;
6150 Values
[Key
] := ActivateToStr(b
);
6151 vleObjectPropertyApply(Sender
);
6154 else if Key
= MsgPropTrKeys
then
6155 with KeysForm
, vleObjectProperty
do
6156 begin // Выбор необходимых ключей:
6157 cbRedKey
.Checked
:= Pos('RK', Values
[Key
]) > 0;
6158 cbGreenKey
.Checked
:= Pos('GK', Values
[Key
]) > 0;
6159 cbBlueKey
.Checked
:= Pos('BK', Values
[Key
]) > 0;
6160 cbRedTeam
.Checked
:= Pos('RT', Values
[Key
]) > 0;
6161 cbBlueTeam
.Checked
:= Pos('BT', Values
[Key
]) > 0;
6163 if ShowModal() = mrOK
then
6166 if cbRedKey
.Checked
then
6168 if cbGreenKey
.Checked
then
6169 b
:= b
or KEY_GREEN
;
6170 if cbBlueKey
.Checked
then
6172 if cbRedTeam
.Checked
then
6173 b
:= b
or KEY_REDTEAM
;
6174 if cbBlueTeam
.Checked
then
6175 b
:= b
or KEY_BLUETEAM
;
6177 Values
[Key
] := KeyToStr(b
);
6178 vleObjectPropertyApply(Sender
);
6181 else if Key
= MsgPropTrFxType
then
6182 with ChooseTypeForm
, vleObjectProperty
do
6183 begin // Выбор типа эффекта:
6184 Caption
:= MsgCapFxType
;
6185 lbTypeSelect
.Items
.Clear();
6187 for b
:= EFFECT_NONE
to EFFECT_FIRE
do
6188 lbTypeSelect
.Items
.Add(EffectToStr(b
));
6190 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]);
6192 if ShowModal() = mrOK
then
6194 b
:= lbTypeSelect
.ItemIndex
;
6195 Values
[Key
] := EffectToStr(b
);
6196 vleObjectPropertyApply(Sender
);
6199 else if Key
= MsgPropTrMonsterType
then
6200 with ChooseTypeForm
, vleObjectProperty
do
6201 begin // Выбор типа монстра:
6202 Caption
:= MsgCapMonsterType
;
6203 lbTypeSelect
.Items
.Clear();
6205 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
6206 lbTypeSelect
.Items
.Add(MonsterToStr(b
));
6208 lbTypeSelect
.ItemIndex
:= StrToMonster(Values
[Key
]) - MONSTER_DEMON
;
6210 if ShowModal() = mrOK
then
6212 b
:= lbTypeSelect
.ItemIndex
+ MONSTER_DEMON
;
6213 Values
[Key
] := MonsterToStr(b
);
6214 vleObjectPropertyApply(Sender
);
6217 else if Key
= MsgPropTrItemType
then
6218 with ChooseTypeForm
, vleObjectProperty
do
6219 begin // Выбор типа предмета:
6220 Caption
:= MsgCapItemType
;
6221 lbTypeSelect
.Items
.Clear();
6223 for b
:= ITEM_MEDKIT_SMALL
to ITEM_KEY_BLUE
do
6224 lbTypeSelect
.Items
.Add(ItemToStr(b
));
6225 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_BOTTLE
));
6226 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_HELMET
));
6227 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_JETPACK
));
6228 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_INVIS
));
6229 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_WEAPON_FLAMETHROWER
));
6230 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_AMMO_FUELCAN
));
6232 b
:= StrToItem(Values
[Key
]);
6233 if b
>= ITEM_BOTTLE
then
6235 lbTypeSelect
.ItemIndex
:= b
- ITEM_MEDKIT_SMALL
;
6237 if ShowModal() = mrOK
then
6239 b
:= lbTypeSelect
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
6240 if b
>= ITEM_WEAPON_KASTET
then
6242 Values
[Key
] := ItemToStr(b
);
6243 vleObjectPropertyApply(Sender
);
6246 else if Key
= MsgPropTrShotType
then
6247 with ChooseTypeForm
, vleObjectProperty
do
6248 begin // Выбор типа предмета:
6249 Caption
:= MsgPropTrShotType
;
6250 lbTypeSelect
.Items
.Clear();
6252 for b
:= TRIGGER_SHOT_PISTOL
to TRIGGER_SHOT_MAX
do
6253 lbTypeSelect
.Items
.Add(ShotToStr(b
));
6255 lbTypeSelect
.ItemIndex
:= StrToShot(Values
[Key
]);
6257 if ShowModal() = mrOK
then
6259 b
:= lbTypeSelect
.ItemIndex
;
6260 Values
[Key
] := ShotToStr(b
);
6261 vleObjectPropertyApply(Sender
);
6264 else if Key
= MsgPropTrEffectType
then
6265 with ChooseTypeForm
, vleObjectProperty
do
6266 begin // Выбор типа эффекта:
6267 Caption
:= MsgCapFxType
;
6268 lbTypeSelect
.Items
.Clear();
6270 lbTypeSelect
.Items
.Add(MsgPropTrEffectParticle
);
6271 lbTypeSelect
.Items
.Add(MsgPropTrEffectAnimation
);
6272 if Values
[Key
] = MsgPropTrEffectAnimation
then
6273 lbTypeSelect
.ItemIndex
:= 1
6275 lbTypeSelect
.ItemIndex
:= 0;
6277 if ShowModal() = mrOK
then
6279 b
:= lbTypeSelect
.ItemIndex
;
6281 Values
[Key
] := MsgPropTrEffectParticle
6283 Values
[Key
] := MsgPropTrEffectAnimation
;
6284 vleObjectPropertyApply(Sender
);
6287 else if Key
= MsgPropTrEffectSubtype
then
6288 with ChooseTypeForm
, vleObjectProperty
do
6289 begin // Выбор подтипа эффекта:
6290 Caption
:= MsgCapFxType
;
6291 lbTypeSelect
.Items
.Clear();
6293 if Values
[MsgPropTrEffectType
] = MsgPropTrEffectAnimation
then
6295 for b
:= EFFECT_TELEPORT
to EFFECT_FIRE
do
6296 lbTypeSelect
.Items
.Add(EffectToStr(b
));
6298 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]) - 1;
6301 lbTypeSelect
.Items
.Add(MsgPropTrEffectSliquid
);
6302 lbTypeSelect
.Items
.Add(MsgPropTrEffectLliquid
);
6303 lbTypeSelect
.Items
.Add(MsgPropTrEffectDliquid
);
6304 lbTypeSelect
.Items
.Add(MsgPropTrEffectBlood
);
6305 lbTypeSelect
.Items
.Add(MsgPropTrEffectSpark
);
6306 lbTypeSelect
.Items
.Add(MsgPropTrEffectBubble
);
6307 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SLIQUID
;
6308 if Values
[Key
] = MsgPropTrEffectLliquid
then
6309 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_LLIQUID
;
6310 if Values
[Key
] = MsgPropTrEffectDliquid
then
6311 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_DLIQUID
;
6312 if Values
[Key
] = MsgPropTrEffectBlood
then
6313 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BLOOD
;
6314 if Values
[Key
] = MsgPropTrEffectSpark
then
6315 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SPARK
;
6316 if Values
[Key
] = MsgPropTrEffectBubble
then
6317 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BUBBLE
;
6320 if ShowModal() = mrOK
then
6322 b
:= lbTypeSelect
.ItemIndex
;
6324 if Values
[MsgPropTrEffectType
] = MsgPropTrEffectAnimation
then
6325 Values
[Key
] := EffectToStr(b
+ 1)
6327 Values
[Key
] := MsgPropTrEffectSliquid
;
6328 if b
= TRIGGER_EFFECT_LLIQUID
then
6329 Values
[Key
] := MsgPropTrEffectLliquid
;
6330 if b
= TRIGGER_EFFECT_DLIQUID
then
6331 Values
[Key
] := MsgPropTrEffectDliquid
;
6332 if b
= TRIGGER_EFFECT_BLOOD
then
6333 Values
[Key
] := MsgPropTrEffectBlood
;
6334 if b
= TRIGGER_EFFECT_SPARK
then
6335 Values
[Key
] := MsgPropTrEffectSpark
;
6336 if b
= TRIGGER_EFFECT_BUBBLE
then
6337 Values
[Key
] := MsgPropTrEffectBubble
;
6340 vleObjectPropertyApply(Sender
);
6343 else if Key
= MsgPropTrEffectColor
then
6344 with vleObjectProperty
do
6345 begin // Выбор цвета эффекта:
6346 ColorDialog
.Color
:= StrToIntDef(Values
[Key
], 0);
6347 if ColorDialog
.Execute
then
6349 Values
[Key
] := IntToStr(ColorDialog
.Color
);
6350 vleObjectPropertyApply(Sender
);
6353 else if Key
= MsgPropPanelTex
then
6354 begin // Смена текстуры:
6355 vleObjectProperty
.Values
[Key
] := SelectedTexture();
6356 vleObjectPropertyApply(Sender
);
6360 procedure TMainForm
.vleObjectPropertyApply(Sender
: TObject
);
6362 // hack to prevent empty ID in list
6363 RenderPanel
.SetFocus();
6364 bApplyProperty
.Click();
6365 vleObjectProperty
.SetFocus();
6368 procedure TMainForm
.aSaveMapExecute(Sender
: TObject
);
6370 FileName
, Section
, Res
: String;
6372 if OpenedMap
= '' then
6374 aSaveMapAsExecute(nil);
6378 g_ProcessResourceStr(OpenedMap
, FileName
, Section
, Res
);
6380 SaveMap(FileName
+':\'+Res
, '');
6383 procedure TMainForm
.aOpenMapExecute(Sender
: TObject
);
6385 OpenDialog
.Filter
:= MsgFileFilterAll
;
6387 if OpenDialog
.Execute() then
6389 OpenMapFile(OpenDialog
.FileName
);
6390 OpenDialog
.InitialDir
:= ExtractFileDir(OpenDialog
.FileName
);
6394 procedure TMainForm
.OpenMapFile(FileName
: String);
6396 if (Pos('.ini', LowerCase(ExtractFileName(FileName
))) > 0) then
6400 pLoadProgress
.Left
:= (RenderPanel
.Width
div 2)-(pLoadProgress
.Width
div 2);
6401 pLoadProgress
.Top
:= (RenderPanel
.Height
div 2)-(pLoadProgress
.Height
div 2);
6402 pLoadProgress
.Show();
6407 LoadMapOld(FileName
);
6409 MainForm
.Caption
:= Format('%s - %s', [FormCaption
, ExtractFileName(FileName
)]);
6411 pLoadProgress
.Hide();
6412 MainForm
.FormResize(Self
);
6414 else // Карты из WAD:
6416 OpenMap(FileName
, '');
6420 procedure TMainForm
.FormActivate(Sender
: TObject
);
6422 MainForm
.ActiveControl
:= RenderPanel
;
6425 procedure TMainForm
.aDeleteMap(Sender
: TObject
);
6433 OpenDialog
.Filter
:= MsgFileFilterWad
;
6435 if not OpenDialog
.Execute() then
6438 WAD
:= TWADEditor_1
.Create();
6440 if not WAD
.ReadFile(OpenDialog
.FileName
) then
6448 MapList
:= WAD
.GetResourcesList('');
6450 SelectMapForm
.Caption
:= MsgCapRemove
;
6451 SelectMapForm
.lbMapList
.Items
.Clear();
6453 if MapList
<> nil then
6454 for a
:= 0 to High(MapList
) do
6455 SelectMapForm
.lbMapList
.Items
.Add(win2utf(MapList
[a
]));
6457 if (SelectMapForm
.ShowModal() = mrOK
) then
6459 str
:= SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
6461 Move(str
[1], MapName
[0], Min(16, Length(str
)));
6463 if Application
.MessageBox(PChar(Format(MsgMsgDeleteMapPrompt
, [MapName
, OpenDialog
.FileName
])), PChar(MsgMsgDeleteMap
), MB_ICONQUESTION
or MB_YESNO
or MB_DEFBUTTON2
) <> mrYes
then
6466 WAD
.RemoveResource('', utf2win(MapName
));
6468 Application
.MessageBox(
6469 PChar(Format(MsgMsgMapDeletedPrompt
, [MapName
])),
6470 PChar(MsgMsgMapDeleted
),
6471 MB_ICONINFORMATION
or MB_OK
or MB_DEFBUTTON1
6474 WAD
.SaveTo(OpenDialog
.FileName
);
6476 // Удалили текущую карту - сохранять по старому ее нельзя:
6477 if OpenedMap
= (OpenDialog
.FileName
+':\'+MapName
) then
6481 MainForm
.Caption
:= FormCaption
;
6488 procedure TMainForm
.vleObjectPropertyKeyDown(Sender
: TObject
;
6489 var Key
: Word; Shift
: TShiftState
);
6491 if Key
= VK_RETURN
then
6492 vleObjectPropertyApply(Sender
);
6495 procedure MovePanel(var ID
: DWORD
; MoveType
: Byte);
6500 if (ID
= 0) and (MoveType
= 0) then
6502 if (ID
= DWORD(High(gPanels
))) and (MoveType
<> 0) then
6504 if (ID
> DWORD(High(gPanels
))) then
6509 if MoveType
= 0 then // to Back
6511 if gTriggers
<> nil then
6512 for a
:= 0 to High(gTriggers
) do
6513 with gTriggers
[a
] do
6515 if TriggerType
= TRIGGER_NONE
then
6518 if TexturePanel
= _id
then
6521 if (TexturePanel
>= 0) and (TexturePanel
< _id
) then
6525 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
6526 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6527 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6528 if Data
.PanelID
= _id
then
6531 if (Data
.PanelID
>= 0) and (Data
.PanelID
< _id
) then
6535 if Data
.ShotPanelID
= _id
then
6536 Data
.ShotPanelID
:= 0
6538 if (Data
.ShotPanelID
>= 0) and (Data
.ShotPanelID
< _id
) then
6539 Inc(Data
.ShotPanelID
);
6543 tmp
:= gPanels
[_id
];
6545 for a
:= _id
downto 1 do
6546 gPanels
[a
] := gPanels
[a
-1];
6554 if gTriggers
<> nil then
6555 for a
:= 0 to High(gTriggers
) do
6556 with gTriggers
[a
] do
6558 if TriggerType
= TRIGGER_NONE
then
6561 if TexturePanel
= _id
then
6562 TexturePanel
:= High(gPanels
)
6564 if TexturePanel
> _id
then
6568 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
6569 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6570 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6571 if Data
.PanelID
= _id
then
6572 Data
.PanelID
:= High(gPanels
)
6574 if Data
.PanelID
> _id
then
6578 if Data
.ShotPanelID
= _id
then
6579 Data
.ShotPanelID
:= High(gPanels
)
6581 if Data
.ShotPanelID
> _id
then
6582 Dec(Data
.ShotPanelID
);
6586 tmp
:= gPanels
[_id
];
6588 for a
:= _id
to High(gPanels
)-1 do
6589 gPanels
[a
] := gPanels
[a
+1];
6591 gPanels
[High(gPanels
)] := tmp
;
6593 ID
:= High(gPanels
);
6597 procedure TMainForm
.aMoveToBack(Sender
: TObject
);
6601 if SelectedObjects
= nil then
6604 for a
:= 0 to High(SelectedObjects
) do
6605 with SelectedObjects
[a
] do
6606 if Live
and (ObjectType
= OBJECT_PANEL
) then
6608 SelectedObjects
[0] := SelectedObjects
[a
];
6609 SetLength(SelectedObjects
, 1);
6616 procedure TMainForm
.aMoveToFore(Sender
: TObject
);
6620 if SelectedObjects
= nil then
6623 for a
:= 0 to High(SelectedObjects
) do
6624 with SelectedObjects
[a
] do
6625 if Live
and (ObjectType
= OBJECT_PANEL
) then
6627 SelectedObjects
[0] := SelectedObjects
[a
];
6628 SetLength(SelectedObjects
, 1);
6635 procedure TMainForm
.aSaveMapAsExecute(Sender
: TObject
);
6636 var i
, idx
: Integer; list
: TStringList
; fmt
: String;
6638 list
:= TStringList
.Create();
6640 // TODO: get loclized strings automatically from language files
6641 SaveDialog
.DefaultExt
:= '.dfz';
6642 SaveDialog
.FilterIndex
:= 1;
6643 SaveDialog
.Filter
:= '';
6644 gWADEditorFactory
.GetRegistredEditors(list
);
6645 for i
:= 0 to list
.Count
- 1 do
6647 if list
[i
] = 'DFZIP' then
6648 SaveDialog
.FilterIndex
:= i
+ 1;
6651 SaveDialog
.Filter
:= SaveDialog
.Filter
+ '|';
6653 if list
[i
] = 'DFWAD' then
6654 SaveDialog
.Filter
:= SaveDialog
.Filter
+ MsgFileFilterSaveDFWAD
6655 else if list
[i
] = 'DFZIP' then
6656 SaveDialog
.Filter
:= SaveDialog
.Filter
+ MsgFileFilterSaveDFZIP
6658 SaveDialog
.Filter
:= SaveDialog
.Filter
+ list
[i
] + '|*.*';
6661 if SaveDialog
.Execute() then
6663 i
:= SaveDialog
.FilterIndex
- 1;
6664 if (i
>= 0) and (i
< list
.Count
) then fmt
:= list
[i
] else fmt
:= '';
6666 SaveMapForm
.GetMaps(SaveDialog
.FileName
, True, fmt
);
6667 if SaveMapForm
.ShowModal() = mrOK
then
6669 SaveDialog
.InitialDir
:= ExtractFileDir(SaveDialog
.FileName
);
6670 OpenedMap
:= SaveDialog
.FileName
+':\'+SaveMapForm
.eMapName
.Text;
6671 OpenedWAD
:= SaveDialog
.FileName
;
6673 idx
:= RecentFiles
.IndexOf(OpenedMap
);
6674 // Такая карта уже недавно открывалась:
6676 RecentFiles
.Delete(idx
);
6677 RecentFiles
.Insert(0, OpenedMap
);
6680 SaveMap(OpenedMap
, fmt
);
6682 gMapInfo
.FileName
:= SaveDialog
.FileName
;
6683 gMapInfo
.MapName
:= SaveMapForm
.eMapName
.Text;
6684 UpdateCaption(gMapInfo
.Name
, ExtractFileName(gMapInfo
.FileName
), gMapInfo
.MapName
);
6691 procedure TMainForm
.aSelectAllExecute(Sender
: TObject
);
6695 RemoveSelectFromObjects();
6697 case pcObjects
.ActivePageIndex
+1 of
6699 if gPanels
<> nil then
6700 for a
:= 0 to High(gPanels
) do
6701 if gPanels
[a
].PanelType
<> PANEL_NONE
then
6702 SelectObject(OBJECT_PANEL
, a
, True);
6704 if gItems
<> nil then
6705 for a
:= 0 to High(gItems
) do
6706 if gItems
[a
].ItemType
<> ITEM_NONE
then
6707 SelectObject(OBJECT_ITEM
, a
, True);
6709 if gMonsters
<> nil then
6710 for a
:= 0 to High(gMonsters
) do
6711 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
6712 SelectObject(OBJECT_MONSTER
, a
, True);
6714 if gAreas
<> nil then
6715 for a
:= 0 to High(gAreas
) do
6716 if gAreas
[a
].AreaType
<> AREA_NONE
then
6717 SelectObject(OBJECT_AREA
, a
, True);
6719 if gTriggers
<> nil then
6720 for a
:= 0 to High(gTriggers
) do
6721 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
6722 SelectObject(OBJECT_TRIGGER
, a
, True);
6725 RecountSelectedObjects();
6728 procedure TMainForm
.tbGridOnClick(Sender
: TObject
);
6730 DotEnable
:= not DotEnable
;
6731 (Sender
as TToolButton
).Down
:= DotEnable
;
6734 procedure TMainForm
.OnIdle(Sender
: TObject
; var Done
: Boolean);
6738 // TODO: move refresh to user actions (ask to repaint only when something changed)
6739 if GetTickCount64() - LastDrawTime
>= 1000 div MaxFPS
then
6744 if StartMap
<> '' then
6752 procedure TMainForm
.miMapPreviewClick(Sender
: TObject
);
6754 if PreviewMode
= 2 then
6757 if PreviewMode
= 0 then
6759 Splitter2
.Visible
:= False;
6760 Splitter1
.Visible
:= False;
6761 StatusBar
.Visible
:= False;
6762 PanelObjs
.Visible
:= False;
6763 PanelProps
.Visible
:= False;
6764 MainToolBar
.Visible
:= False;
6765 sbHorizontal
.Visible
:= False;
6766 sbVertical
.Visible
:= False;
6770 StatusBar
.Visible
:= True;
6771 PanelObjs
.Visible
:= True;
6772 PanelProps
.Visible
:= True;
6773 Splitter2
.Visible
:= True;
6774 Splitter1
.Visible
:= True;
6775 MainToolBar
.Visible
:= True;
6776 sbHorizontal
.Visible
:= True;
6777 sbVertical
.Visible
:= True;
6780 PreviewMode
:= PreviewMode
xor 1;
6781 (Sender
as TMenuItem
).Checked
:= PreviewMode
> 0;
6786 procedure TMainForm
.miLayer1Click(Sender
: TObject
);
6788 SwitchLayer(LAYER_BACK
);
6791 procedure TMainForm
.miLayer2Click(Sender
: TObject
);
6793 SwitchLayer(LAYER_WALLS
);
6796 procedure TMainForm
.miLayer3Click(Sender
: TObject
);
6798 SwitchLayer(LAYER_FOREGROUND
);
6801 procedure TMainForm
.miLayer4Click(Sender
: TObject
);
6803 SwitchLayer(LAYER_STEPS
);
6806 procedure TMainForm
.miLayer5Click(Sender
: TObject
);
6808 SwitchLayer(LAYER_WATER
);
6811 procedure TMainForm
.miLayer6Click(Sender
: TObject
);
6813 SwitchLayer(LAYER_ITEMS
);
6816 procedure TMainForm
.miLayer7Click(Sender
: TObject
);
6818 SwitchLayer(LAYER_MONSTERS
);
6821 procedure TMainForm
.miLayer8Click(Sender
: TObject
);
6823 SwitchLayer(LAYER_AREAS
);
6826 procedure TMainForm
.miLayer9Click(Sender
: TObject
);
6828 SwitchLayer(LAYER_TRIGGERS
);
6831 procedure TMainForm
.tbShowClick(Sender
: TObject
);
6837 for a
:= 0 to High(LayerEnabled
) do
6838 b
:= b
and LayerEnabled
[a
];
6842 ShowLayer(LAYER_BACK
, b
);
6843 ShowLayer(LAYER_WALLS
, b
);
6844 ShowLayer(LAYER_FOREGROUND
, b
);
6845 ShowLayer(LAYER_STEPS
, b
);
6846 ShowLayer(LAYER_WATER
, b
);
6847 ShowLayer(LAYER_ITEMS
, b
);
6848 ShowLayer(LAYER_MONSTERS
, b
);
6849 ShowLayer(LAYER_AREAS
, b
);
6850 ShowLayer(LAYER_TRIGGERS
, b
);
6853 procedure TMainForm
.miMiniMapClick(Sender
: TObject
);
6858 procedure TMainForm
.miSwitchGridClick(Sender
: TObject
);
6860 if DotStep
= DotStepOne
then
6861 DotStep
:= DotStepTwo
6863 DotStep
:= DotStepOne
;
6865 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6866 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6869 procedure TMainForm
.miShowEdgesClick(Sender
: TObject
);
6874 procedure TMainForm
.miSnapToGridClick(Sender
: TObject
);
6876 SnapToGrid
:= not SnapToGrid
;
6878 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6879 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6881 miSnapToGrid
.Checked
:= SnapToGrid
;
6884 procedure TMainForm
.minexttabClick(Sender
: TObject
);
6886 if pcObjects
.ActivePageIndex
< pcObjects
.PageCount
-1 then
6887 pcObjects
.ActivePageIndex
:= pcObjects
.ActivePageIndex
+1
6889 pcObjects
.ActivePageIndex
:= 0;
6892 procedure TMainForm
.miSaveMiniMapClick(Sender
: TObject
);
6894 SaveMiniMapForm
.ShowModal();
6897 procedure TMainForm
.bClearTextureClick(Sender
: TObject
);
6899 lbTextureList
.ItemIndex
:= -1;
6900 lTextureWidth
.Caption
:= '';
6901 lTextureHeight
.Caption
:= '';
6904 procedure TMainForm
.miPackMapClick(Sender
: TObject
);
6906 PackMapForm
.ShowModal();
6909 type SSArray
= array of String;
6911 function ParseString (Str
: AnsiString): SSArray
;
6912 function GetStr (var Str
: AnsiString): AnsiString;
6916 if Str
[1] = '"' then
6917 for b
:= 1 to Length(Str
) do
6918 if (b
= Length(Str
)) or (Str
[b
+ 1] = '"') then
6920 Result
:= Copy(Str
, 2, b
- 1);
6921 Delete(Str
, 1, b
+ 1);
6925 for a
:= 1 to Length(Str
) do
6926 if (a
= Length(Str
)) or (Str
[a
+ 1] = ' ') then
6928 Result
:= Copy(Str
, 1, a
);
6929 Delete(Str
, 1, a
+ 1);
6939 SetLength(Result
, Length(Result
)+1);
6940 Result
[High(Result
)] := GetStr(Str
);
6944 procedure TMainForm
.miTestMapClick(Sender
: TObject
);
6946 newWAD
, oldWAD
, tempMap
, ext
: String;
6953 // Ignore while map testing in progress
6954 if MapTestProcess
<> nil then
6957 // Сохраняем временную карту:
6960 newWAD
:= Format('%s/temp%.4d', [MapsDir
, time
]);
6962 until not FileExists(newWAD
);
6963 if OpenedMap
<> '' then
6965 oldWad
:= g_ExtractWadName(OpenedMap
);
6966 newWad
:= newWad
+ ExtractFileExt(oldWad
);
6967 if CopyFile(oldWad
, newWad
) = false then
6968 e_WriteLog('MapTest: unable to copy [' + oldWad
+ '] to [' + newWad
+ ']', MSG_WARNING
)
6972 newWad
:= newWad
+ '.wad'
6974 tempMap
:= newWAD
+ ':\' + TEST_MAP_NAME
;
6975 SaveMap(tempMap
, '');
6979 if TestOptionsTwoPlayers
then
6981 if TestOptionsTeamDamage
then
6983 if TestOptionsAllowExit
then
6985 if TestOptionsWeaponStay
then
6987 if TestOptionsMonstersDM
then
6991 proc
:= TProcessUTF8
.Create(nil);
6992 proc
.Executable
:= TestD2dExe
;
6994 // TODO: get real executable name from Info.plist
6995 if LowerCase(ExtractFileExt(TestD2dExe
)) = '.app' then
6996 proc
.Executable
:= TestD2dExe
+ DirectorySeparator
+ 'Contents' + DirectorySeparator
+ 'MacOS' + DirectorySeparator
+ 'Doom2DF';
6998 proc
.Parameters
.Add('-map');
6999 proc
.Parameters
.Add(tempMap
);
7000 proc
.Parameters
.Add('-gm');
7001 proc
.Parameters
.Add(TestGameMode
);
7002 proc
.Parameters
.Add('-limt');
7003 proc
.Parameters
.Add(TestLimTime
);
7004 proc
.Parameters
.Add('-lims');
7005 proc
.Parameters
.Add(TestLimScore
);
7006 proc
.Parameters
.Add('-opt');
7007 proc
.Parameters
.Add(IntToStr(opt
));
7008 proc
.Parameters
.Add('--debug');
7010 proc
.Parameters
.Add('--close');
7012 args
:= ParseString(TestD2DArgs
);
7013 for i
:= 0 to High(args
) do
7014 proc
.Parameters
.Add(args
[i
]);
7024 tbTestMap
.Enabled
:= False;
7025 MapTestFile
:= newWAD
;
7026 MapTestProcess
:= proc
;
7030 Application
.MessageBox(PChar(MsgMsgExecError
), 'FIXME', MB_OK
or MB_ICONERROR
);
7031 SysUtils
.DeleteFile(newWAD
);
7036 procedure TMainForm
.sbVerticalScroll(Sender
: TObject
;
7037 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
7039 MapOffset
.Y
:= -sbVertical
.Position
;
7040 RenderPanel
.Invalidate
;
7043 procedure TMainForm
.sbHorizontalScroll(Sender
: TObject
;
7044 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
7046 MapOffset
.X
:= -sbHorizontal
.Position
;
7047 RenderPanel
.Invalidate
;
7050 procedure TMainForm
.miOpenWadMapClick(Sender
: TObject
);
7052 if OpenedWAD
<> '' then
7054 OpenMap(OpenedWAD
, '');
7058 procedure TMainForm
.selectall1Click(Sender
: TObject
);
7062 RemoveSelectFromObjects();
7064 if gPanels
<> nil then
7065 for a
:= 0 to High(gPanels
) do
7066 if gPanels
[a
].PanelType
<> PANEL_NONE
then
7067 SelectObject(OBJECT_PANEL
, a
, True);
7069 if gItems
<> nil then
7070 for a
:= 0 to High(gItems
) do
7071 if gItems
[a
].ItemType
<> ITEM_NONE
then
7072 SelectObject(OBJECT_ITEM
, a
, True);
7074 if gMonsters
<> nil then
7075 for a
:= 0 to High(gMonsters
) do
7076 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
7077 SelectObject(OBJECT_MONSTER
, a
, True);
7079 if gAreas
<> nil then
7080 for a
:= 0 to High(gAreas
) do
7081 if gAreas
[a
].AreaType
<> AREA_NONE
then
7082 SelectObject(OBJECT_AREA
, a
, True);
7084 if gTriggers
<> nil then
7085 for a
:= 0 to High(gTriggers
) do
7086 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
7087 SelectObject(OBJECT_TRIGGER
, a
, True);
7089 RecountSelectedObjects();
7092 procedure TMainForm
.Splitter1CanResize(Sender
: TObject
;
7093 var NewSize
: Integer; var Accept
: Boolean);
7095 Accept
:= (NewSize
> 140);
7098 procedure TMainForm
.Splitter2CanResize(Sender
: TObject
;
7099 var NewSize
: Integer; var Accept
: Boolean);
7101 Accept
:= (NewSize
> 110);
7104 procedure TMainForm
.vleObjectPropertyEnter(Sender
: TObject
);
7106 EditingProperties
:= True;
7109 procedure TMainForm
.vleObjectPropertyExit(Sender
: TObject
);
7111 EditingProperties
:= False;
7114 procedure TMainForm
.FormKeyUp(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
7116 // Объекты передвигались:
7117 if MainForm
.ActiveControl
= RenderPanel
then
7119 if (Key
= VK_NUMPAD4
) or
7120 (Key
= VK_NUMPAD6
) or
7121 (Key
= VK_NUMPAD8
) or
7122 (Key
= VK_NUMPAD5
) or
7123 (Key
= Ord('V')) then
7126 // Быстрое превью карты:
7127 if Key
= Ord('E') then
7129 if PreviewMode
= 2 then
7132 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);