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
;
1830 MainForm
.miUndo
.Enabled
:= UndoBuffer
<> nil;
1833 procedure FullClear();
1835 RemoveSelectFromObjects();
1837 LoadSky(gMapInfo
.SkyName
);
1839 slInvalidTextures
.Clear();
1840 MapCheckForm
.lbErrorList
.Clear();
1841 MapCheckForm
.mErrorDescription
.Clear();
1843 MainForm
.miUndo
.Enabled
:= False;
1844 MainForm
.sbHorizontal
.Position
:= 0;
1845 MainForm
.sbVertical
.Position
:= 0;
1846 MainForm
.FormResize(nil);
1847 MainForm
.Caption
:= FormCaption
;
1852 procedure ErrorMessageBox(str
: String);
1854 Application
.MessageBox(PChar(str
), PChar(MsgMsgError
),
1855 MB_ICONINFORMATION
or MB_OK
or MB_DEFBUTTON1
);
1858 function CheckProperty(): Boolean;
1864 _id
:= GetFirstSelected();
1866 if SelectedObjects
[_id
].ObjectType
= OBJECT_PANEL
then
1867 with gPanels
[SelectedObjects
[_id
].ID
] do
1869 if TextureWidth
<> 0 then
1870 if StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropWidth
], 1) mod TextureWidth
<> 0 then
1872 ErrorMessageBox(Format(MsgMsgWrongTexwidth
,
1877 if TextureHeight
<> 0 then
1878 if StrToIntDef(Trim(MainForm
.vleObjectProperty
.Values
[MsgPropHeight
]), 1) mod TextureHeight
<> 0 then
1880 ErrorMessageBox(Format(MsgMsgWrongTexheight
,
1885 if IsTexturedPanel(PanelType
) and (TextureName
<> '') then
1886 if not (StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropPanelAlpha
], -1) in [0..255]) then
1888 ErrorMessageBox(MsgMsgWrongAlpha
);
1893 if SelectedObjects
[_id
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
] then
1894 if (StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropWidth
], 0) <= 0) or
1895 (StrToIntDef(MainForm
.vleObjectProperty
.Values
[MsgPropHeight
], 0) <= 0) then
1897 ErrorMessageBox(MsgMsgWrongSize
);
1901 if (Trim(MainForm
.vleObjectProperty
.Values
[MsgPropX
]) = '') or
1902 (Trim(MainForm
.vleObjectProperty
.Values
[MsgPropY
]) = '') then
1904 ErrorMessageBox(MsgMsgWrongXy
);
1911 procedure SelectTexture(ID
: Integer);
1913 MainForm
.lbTextureList
.ItemIndex
:= ID
;
1914 MainForm
.lbTextureListClick(nil);
1917 function AddTexture(aWAD
, aSection
, aTex
: String; silent
: Boolean): Boolean;
1919 a
, FrameLen
: Integer;
1922 ResourceName
: String;
1923 FullResourceName
: String;
1924 SectionName
: String;
1926 Width
, Height
: Word;
1934 if aSection
= '..' then
1937 SectionName
:= aSection
;
1940 aWAD
:= MsgWadSpecialMap
;
1942 if aWAD
= MsgWadSpecialMap
then
1944 g_ProcessResourceStr(OpenedMap
, @fn
, nil, nil);
1946 ResourceName
:= ':'+SectionName
+'\'+aTex
;
1949 if aWAD
= MsgWadSpecialTexs
then
1950 begin // Спец. текстуры
1952 ResourceName
:= aTex
;
1955 begin // Внешний WAD
1956 FileName
:= WadsDir
+ DirectorySeparator
+ aWAD
;
1957 ResourceName
:= aWAD
+':'+SectionName
+'\'+aTex
;
1962 // Есть ли уже такая текстура:
1963 for a
:= 0 to MainForm
.lbTextureList
.Items
.Count
-1 do
1964 if ResourceName
= MainForm
.lbTextureList
.Items
[a
] then
1967 ErrorMessageBox(Format(MsgMsgTextureAlready
,
1972 // Название ресурса <= 64 символов:
1973 if Length(ResourceName
) > 64 then
1976 ErrorMessageBox(Format(MsgMsgResName64
,
1984 if aWAD
= MsgWadSpecialTexs
then
1986 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
1993 FullResourceName
:= FileName
+':'+SectionName
+'\'+aTex
;
1995 if IsAnim(FullResourceName
) then
1996 begin // Аним. текстура
1997 GetFrame(FullResourceName
, Data
, FrameLen
, Width
, Height
);
1999 if not g_CreateTextureMemorySize(Data
, FrameLen
, ResourceName
, 0, 0, Width
, Height
, 1) then
2001 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
2003 else // Обычная текстура
2005 if not g_CreateTextureWAD(ResourceName
, FullResourceName
) then
2007 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
2009 if (not ok
) and (slInvalidTextures
.IndexOf(ResourceName
) = -1) then
2011 slInvalidTextures
.Add(ResourceName
);
2014 if (a
> -1) and (not silent
) then
2021 procedure UpdateCaption(sMap
, sFile
, sRes
: String);
2024 if (sFile
= '') and (sRes
= '') and (sMap
= '') then
2025 Caption
:= FormCaption
2028 Caption
:= Format('%s - %s:%s', [FormCaption
, sFile
, sRes
])
2030 if (sFile
<> '') and (sRes
<> '') then
2031 Caption
:= Format('%s - %s (%s:%s)', [FormCaption
, sMap
, sFile
, sRes
])
2033 Caption
:= Format('%s - %s', [FormCaption
, sMap
]);
2036 procedure OpenMap(FileName
: String; mapN
: String);
2041 SelectMapForm
.Caption
:= MsgCapOpen
;
2042 SelectMapForm
.GetMaps(FileName
);
2044 if (FileName
= OpenedWAD
) and
2045 (OpenedMap
<> '') then
2047 MapName
:= OpenedMap
;
2048 while (Pos(':\', MapName
) > 0) do
2049 Delete(MapName
, 1, Pos(':\', MapName
) + 1);
2051 idx
:= SelectMapForm
.lbMapList
.Items
.IndexOf(MapName
);
2052 SelectMapForm
.lbMapList
.ItemIndex
:= idx
;
2055 if SelectMapForm
.lbMapList
.Count
> 0 then
2056 SelectMapForm
.lbMapList
.ItemIndex
:= 0
2058 SelectMapForm
.lbMapList
.ItemIndex
:= -1;
2063 idx
:= SelectMapForm
.lbMapList
.Items
.IndexOf(mapN
);
2067 if (SelectMapForm
.ShowModal() = mrOK
) and
2068 (SelectMapForm
.lbMapList
.ItemIndex
<> -1) then
2069 idx
:= SelectMapForm
.lbMapList
.ItemIndex
2074 MapName
:= SelectMapForm
.lbMapList
.Items
[idx
];
2080 pLoadProgress
.Left
:= (RenderPanel
.Width
div 2)-(pLoadProgress
.Width
div 2);
2081 pLoadProgress
.Top
:= (RenderPanel
.Height
div 2)-(pLoadProgress
.Height
div 2);
2082 pLoadProgress
.Show();
2084 OpenedMap
:= FileName
+':\'+MapName
;
2085 OpenedWAD
:= FileName
;
2087 idx
:= RecentFiles
.IndexOf(OpenedMap
);
2088 // Такая карта уже недавно открывалась:
2090 RecentFiles
.Delete(idx
);
2091 RecentFiles
.Insert(0, OpenedMap
);
2092 RefreshRecentMenu();
2096 pLoadProgress
.Hide();
2099 lbTextureList
.Sorted
:= True;
2100 lbTextureList
.Sorted
:= False;
2102 UpdateCaption(gMapInfo
.Name
, ExtractFileName(FileName
), MapName
);
2106 procedure MoveSelectedObjects(Wall
, alt
: Boolean; dx
, dy
: Integer);
2111 if SelectedObjects
= nil then
2118 for a
:= 0 to High(SelectedObjects
) do
2119 if SelectedObjects
[a
].Live
then
2121 if ObjectCollideLevel(SelectedObjects
[a
].ID
, SelectedObjects
[a
].ObjectType
, dx
, 0) then
2124 if ObjectCollideLevel(SelectedObjects
[a
].ID
, SelectedObjects
[a
].ObjectType
, 0, dy
) then
2127 if (not okX
) or (not okY
) then
2133 for a
:= 0 to High(SelectedObjects
) do
2134 if SelectedObjects
[a
].Live
then
2137 MoveObject(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
, dx
, 0);
2140 MoveObject(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
, 0, dy
);
2142 if alt
and (SelectedObjects
[a
].ObjectType
= OBJECT_TRIGGER
) then
2144 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_PRESS
,
2145 TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
] then
2146 begin // Двигаем зону Расширителя
2148 gTriggers
[SelectedObjects
[a
].ID
].Data
.tX
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.tX
+dx
;
2150 gTriggers
[SelectedObjects
[a
].ID
].Data
.tY
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.tY
+dy
;
2153 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_TELEPORT
] then
2154 begin // Двигаем точку назначения Телепорта
2156 gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.X
+dx
;
2158 gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.Y
+dy
;
2161 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SPAWNMONSTER
] then
2162 begin // Двигаем точку создания монстра
2164 gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.X
+dx
;
2166 gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.Y
+dy
;
2169 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SPAWNITEM
] then
2170 begin // Двигаем точку создания предмета
2172 gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.X
+dx
;
2174 gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.Y
+dy
;
2177 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SHOT
] then
2178 begin // Двигаем точку создания выстрела
2180 gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.X
+dx
;
2182 gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.Y
+dy
;
2187 LastMovePoint
:= MousePos
;
2191 procedure ShowLayer(Layer
: Byte; show
: Boolean);
2193 LayerEnabled
[Layer
] := show
;
2198 MainForm
.miLayer1
.Checked
:= show
;
2199 MainForm
.miLayerP1
.Checked
:= show
;
2203 MainForm
.miLayer2
.Checked
:= show
;
2204 MainForm
.miLayerP2
.Checked
:= show
;
2208 MainForm
.miLayer3
.Checked
:= show
;
2209 MainForm
.miLayerP3
.Checked
:= show
;
2213 MainForm
.miLayer4
.Checked
:= show
;
2214 MainForm
.miLayerP4
.Checked
:= show
;
2218 MainForm
.miLayer5
.Checked
:= show
;
2219 MainForm
.miLayerP5
.Checked
:= show
;
2223 MainForm
.miLayer6
.Checked
:= show
;
2224 MainForm
.miLayerP6
.Checked
:= show
;
2228 MainForm
.miLayer7
.Checked
:= show
;
2229 MainForm
.miLayerP7
.Checked
:= show
;
2233 MainForm
.miLayer8
.Checked
:= show
;
2234 MainForm
.miLayerP8
.Checked
:= show
;
2238 MainForm
.miLayer9
.Checked
:= show
;
2239 MainForm
.miLayerP9
.Checked
:= show
;
2243 RemoveSelectFromObjects();
2246 procedure SwitchLayer(Layer
: Byte);
2248 ShowLayer(Layer
, not LayerEnabled
[Layer
]);
2251 procedure SwitchMap();
2253 ShowMap
:= not ShowMap
;
2254 MainForm
.tbShowMap
.Down
:= ShowMap
;
2255 MainForm
.miMiniMap
.Checked
:= ShowMap
;
2258 procedure ShowEdges();
2260 if drEdge
[3] < 255 then
2263 drEdge
[3] := gAlphaEdge
;
2264 MainForm
.miShowEdges
.Checked
:= drEdge
[3] <> 255;
2267 function SelectedTexture(): String;
2269 if MainForm
.lbTextureList
.ItemIndex
<> -1 then
2270 Result
:= MainForm
.lbTextureList
.Items
[MainForm
.lbTextureList
.ItemIndex
]
2275 function IsSpecialTextureSel(): Boolean;
2277 Result
:= (MainForm
.lbTextureList
.ItemIndex
<> -1) and
2278 IsSpecialTexture(MainForm
.lbTextureList
.Items
[MainForm
.lbTextureList
.ItemIndex
]);
2281 function CopyBufferToString(var CopyBuf
: TCopyRecArray
): String;
2286 procedure AddInt(x
: Integer);
2288 Res
:= Res
+ IntToStr(x
) + ' ';
2294 if Length(CopyBuf
) = 0 then
2297 Res
:= CLIPBOARD_SIG
+ ' ';
2299 for i
:= 0 to High(CopyBuf
) do
2301 if (CopyBuf
[i
].ObjectType
= OBJECT_PANEL
) and
2302 (CopyBuf
[i
].Panel
= nil) then
2306 AddInt(CopyBuf
[i
].ObjectType
);
2309 // Свойства объекта:
2310 case CopyBuf
[i
].ObjectType
of
2312 with CopyBuf
[i
].Panel
^ do
2319 Res
:= Res
+ '"' + TextureName
+ '" ';
2321 AddInt(IfThen(Blending
, 1, 0));
2325 with CopyBuf
[i
].Item
do
2330 AddInt(IfThen(OnlyDM
, 1, 0));
2331 AddInt(IfThen(Fall
, 1, 0));
2335 with CopyBuf
[i
].Monster
do
2337 AddInt(MonsterType
);
2340 AddInt(IfThen(Direction
= D_LEFT
, 1, 0));
2344 with CopyBuf
[i
].Area
do
2349 AddInt(IfThen(Direction
= D_LEFT
, 1, 0));
2353 with CopyBuf
[i
].Trigger
do
2355 AddInt(TriggerType
);
2360 AddInt(ActivateType
);
2362 AddInt(IfThen(Enabled
, 1, 0));
2363 AddInt(TexturePanel
);
2365 for j
:= 0 to 127 do
2366 AddInt(Data
.Default
[j
]);
2374 procedure StringToCopyBuffer(Str
: String; var CopyBuf
: TCopyRecArray
; var pmin
: TPoint
);
2377 minArea
, newArea
, newX
, newY
: LongInt;
2379 function GetNext(): String;
2384 if Str
[1] = '"' then
2396 Result
:= Copy(Str
, 1, p
-1);
2412 Result
:= Copy(Str
, 1, p
-1);
2420 minArea
:= High(minArea
);
2423 if GetNext() <> CLIPBOARD_SIG
then
2429 t
:= StrToIntDef(GetNext(), 0);
2431 if (t
< OBJECT_PANEL
) or (t
> OBJECT_TRIGGER
) or (GetNext() <> ';') then
2432 begin // Что-то не то => пропускаем:
2440 i
:= Length(CopyBuf
);
2441 SetLength(CopyBuf
, i
+ 1);
2443 CopyBuf
[i
].ObjectType
:= t
;
2444 CopyBuf
[i
].Panel
:= nil;
2446 // Свойства объекта:
2450 New(CopyBuf
[i
].Panel
);
2452 with CopyBuf
[i
].Panel
^ do
2454 PanelType
:= StrToIntDef(GetNext(), PANEL_WALL
);
2455 X
:= StrToIntDef(GetNext(), 0);
2456 Y
:= StrToIntDef(GetNext(), 0);
2457 Width
:= StrToIntDef(GetNext(), 16);
2458 Height
:= StrToIntDef(GetNext(), 16);
2459 TextureName
:= GetNext();
2460 Alpha
:= StrToIntDef(GetNext(), 0);
2461 Blending
:= (GetNext() = '1');
2462 newArea
:= X
* Y
- Width
* Height
;
2469 with CopyBuf
[i
].Item
do
2471 ItemType
:= StrToIntDef(GetNext(), ITEM_MEDKIT_SMALL
);
2472 X
:= StrToIntDef(GetNext(), 0);
2473 Y
:= StrToIntDef(GetNext(), 0);
2474 OnlyDM
:= (GetNext() = '1');
2475 Fall
:= (GetNext() = '1');
2482 with CopyBuf
[i
].Monster
do
2484 MonsterType
:= StrToIntDef(GetNext(), MONSTER_DEMON
);
2485 X
:= StrToIntDef(GetNext(), 0);
2486 Y
:= StrToIntDef(GetNext(), 0);
2488 then Direction
:= D_LEFT
2489 else Direction
:= D_RIGHT
;
2496 with CopyBuf
[i
].Area
do
2498 AreaType
:= StrToIntDef(GetNext(), AREA_PLAYERPOINT1
);
2499 X
:= StrToIntDef(GetNext(), 0);
2500 Y
:= StrToIntDef(GetNext(), 0);
2502 then Direction
:= D_LEFT
2503 else Direction
:= D_RIGHT
;
2510 with CopyBuf
[i
].Trigger
do
2512 TriggerType
:= StrToIntDef(GetNext(), TRIGGER_EXIT
);
2513 X
:= StrToIntDef(GetNext(), 0);
2514 Y
:= StrToIntDef(GetNext(), 0);
2515 Width
:= StrToIntDef(GetNext(), 16);
2516 Height
:= StrToIntDef(GetNext(), 16);
2517 ActivateType
:= StrToIntDef(GetNext(), 0);
2518 Key
:= StrToIntDef(GetNext(), 0);
2519 Enabled
:= (GetNext() = '1');
2520 TexturePanel
:= StrToIntDef(GetNext(), 0);
2522 do Data
.Default
[j
] := StrToIntDef(GetNext(), 0);
2523 newArea
:= X
* Y
- Width
* Height
;
2529 if newArea
< minArea
then
2538 //----------------------------------------
2539 //Закончились вспомогательные процедуры
2540 //----------------------------------------
2542 procedure TMainForm
.miRecentFileExecute (Sender
: TObject
);
2546 s
:= RecentFiles
[(Sender
as TMenuItem
).Tag
];
2547 fn
:= g_ExtractWadName(s
);
2548 if FileExists(fn
) then
2549 OpenMap(fn
, g_ExtractFilePathName(s
))
2551 Application
.MessageBox('File not available anymore', '', MB_OK
);
2552 // if Application.MessageBox(PChar(MsgMsgDelRecentPrompt), PChar(MsgMsgDelRecent), MB_ICONQUESTION or MB_YESNO) = idYes then
2554 // RecentFiles.Delete(n);
2555 // RefreshRecentMenu();
2559 procedure TMainForm
.RefillRecentMenu (menu
: TMenuItem
; start
: Integer; fmt
: AnsiString);
2560 var i
: Integer; MI
: TMenuItem
; s
: AnsiString;
2562 Assert(menu
<> nil);
2564 Assert(start
<= menu
.Count
);
2566 // clear all the recent entries from menu
2568 while i
< menu
.Count
do
2570 MI
:= menu
.Items
[i
];
2571 if @MI
.OnClick
<> @TMainForm
.miRecentFileExecute
then
2580 // fill with a new ones
2581 for i
:= 0 to RecentFiles
.Count
-1 do
2583 MI
:= TMenuItem
.Create(menu
);
2584 s
:= RecentFiles
[i
];
2585 MI
.Caption
:= Format(fmt
, [i
+1, g_ExtractWadNameNoPath(s
), g_ExtractFilePathName(s
)]);
2586 MI
.OnClick
:= miRecentFileExecute
;
2588 menu
.Insert(start
+ i
, MI
); // transfers ownership
2592 procedure TMainForm
.RefreshRecentMenu();
2595 while RecentFiles
.Count
> RecentCount
do
2596 RecentFiles
.Delete(RecentFiles
.Count
- 1);
2598 if miMacRecentSubMenu
.Visible
then
2600 // Reconstruct OSX-like recent list
2601 RefillRecentMenu(miMacRecentSubMenu
, 0, '%1:s - %2:s');
2602 miMacRecentEnd
.Enabled
:= RecentFiles
.Count
<> 0;
2603 miMacRecentEnd
.Visible
:= RecentFiles
.Count
<> 0;
2606 if miWinRecentStart
.Visible
then
2608 // Reconstruct Windows-like recent list
2609 start
:= miMenuFile
.IndexOf(miWinRecent
);
2610 if start
< 0 then start
:= miMenuFile
.Count
else start
+= 1;
2611 RefillRecentMenu(miMenuFile
, start
, '%0:d %1:s:%2:s');
2612 miWinRecent
.Enabled
:= False;
2613 miWinRecent
.Visible
:= RecentFiles
.Count
= 0;
2617 procedure TMainForm
.miMacRecentClearClick(Sender
: TObject
);
2619 RecentFiles
.Clear();
2620 RefreshRecentMenu();
2623 procedure TMainForm
.aEditorOptionsExecute(Sender
: TObject
);
2625 OptionsForm
.ShowModal();
2628 procedure LoadStdFont(cfgres
, texture
: string; var FontID
: DWORD
);
2642 wad
:= TWADEditor_1
.Create
;
2643 if wad
.ReadFile(GameWad
) then
2644 wad
.GetResource('FONTS', cfgres
, cfgdata
, cfglen
);
2649 if not g_CreateTextureWAD('FONT_STD', GameWad
+ ':FONTS\' + texture
) then
2650 e_WriteLog('ERROR ERROR ERROR', MSG_WARNING
);
2652 config
:= TConfig
.CreateMem(cfgdata
, cfglen
);
2653 cwdt
:= Min(Max(config
.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
2654 chgt
:= Min(Max(config
.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
2655 spc
:= Min(Max(config
.ReadInt('FontMap', 'Kerning', 0), -128), 127);
2657 if g_GetTexture('FONT_STD', ID
) then
2658 e_TextureFontBuild(ID
, FontID
, cwdt
, chgt
, spc
-2);
2663 e_WriteLog('Could not load FONT_STD', MSG_WARNING
);
2665 if cfglen
<> 0 then FreeMem(cfgdata
);
2668 procedure TMainForm
.FormCreate(Sender
: TObject
);
2678 miApple
.Enabled
:= True;
2679 miApple
.Visible
:= True;
2680 miMacRecentSubMenu
.Enabled
:= True;
2681 miMacRecentSubMenu
.Visible
:= True;
2682 miWinRecentStart
.Enabled
:= False;
2683 miWinRecentStart
.Visible
:= False;
2684 miWinRecent
.Enabled
:= False;
2685 miWinRecent
.Visible
:= False;
2686 miLine2
.Enabled
:= False;
2687 miLine2
.Visible
:= False;
2688 miExit
.Enabled
:= False;
2689 miExit
.Visible
:= False;
2690 miOptions
.Enabled
:= False;
2691 miOptions
.Visible
:= False;
2692 miMenuWindow
.Enabled
:= True;
2693 miMenuWindow
.Visible
:= True;
2694 miAbout
.Enabled
:= False;
2695 miAbout
.Visible
:= False;
2697 miApple
.Enabled
:= False;
2698 miApple
.Visible
:= False;
2699 miMacRecentSubMenu
.Enabled
:= False;
2700 miMacRecentSubMenu
.Visible
:= False;
2701 miWinRecentStart
.Enabled
:= True;
2702 miWinRecentStart
.Visible
:= True;
2703 miWinRecent
.Enabled
:= True;
2704 miWinRecent
.Visible
:= True;
2705 miLine2
.Enabled
:= True;
2706 miLine2
.Visible
:= True;
2707 miExit
.Enabled
:= True;
2708 miExit
.Visible
:= True;
2709 miOptions
.Enabled
:= True;
2710 miOptions
.Visible
:= True;
2711 miMenuWindow
.Enabled
:= False;
2712 miMenuWindow
.Visible
:= False;
2713 miAbout
.Enabled
:= True;
2714 miAbout
.Visible
:= True;
2717 miNewMap
.ShortCut
:= ShortCut(VK_N
, [ssModifier
]);
2718 miOpenMap
.ShortCut
:= ShortCut(VK_O
, [ssModifier
]);
2719 miSaveMap
.ShortCut
:= ShortCut(VK_S
, [ssModifier
]);
2721 miSaveMapAs
.ShortCut
:= ShortCut(VK_S
, [ssModifier
, ssShift
]);
2722 miReopenMap
.ShortCut
:= ShortCut(VK_F5
, [ssModifier
]);
2724 miUndo
.ShortCut
:= ShortCut(VK_Z
, [ssModifier
]);
2725 miCopy
.ShortCut
:= ShortCut(VK_C
, [ssModifier
]);
2726 miCut
.ShortCut
:= ShortCut(VK_X
, [ssModifier
]);
2727 miPaste
.ShortCut
:= ShortCut(VK_V
, [ssModifier
]);
2728 miSelectAll
.ShortCut
:= ShortCut(VK_A
, [ssModifier
]);
2729 miToFore
.ShortCut
:= ShortCut(VK_LCL_CLOSE_BRACKET
, [ssModifier
]);
2730 miToBack
.ShortCut
:= ShortCut(VK_LCL_OPEN_BRACKET
, [ssModifier
]);
2732 miMapOptions
.Shortcut
:= ShortCut(VK_P
, [ssModifier
, ssAlt
]);
2733 selectall1
.Shortcut
:= ShortCut(VK_A
, [ssModifier
, ssAlt
]);
2736 e_WriteLog('Doom 2D: Forever Editor version ' + EDITOR_VERSION
, MSG_NOTIFY
);
2737 e_WriteLog('Build date: ' + EDITOR_BUILDDATE
+ ' ' + EDITOR_BUILDTIME
, MSG_NOTIFY
);
2738 e_WriteLog('Build hash: ' + g_GetBuildHash(), MSG_NOTIFY
);
2739 e_WriteLog('Build by: ' + g_GetBuilderName(), MSG_NOTIFY
);
2741 slInvalidTextures
:= TStringList
.Create
;
2743 ShowLayer(LAYER_BACK
, True);
2744 ShowLayer(LAYER_WALLS
, True);
2745 ShowLayer(LAYER_FOREGROUND
, True);
2746 ShowLayer(LAYER_STEPS
, True);
2747 ShowLayer(LAYER_WATER
, True);
2748 ShowLayer(LAYER_ITEMS
, True);
2749 ShowLayer(LAYER_MONSTERS
, True);
2750 ShowLayer(LAYER_AREAS
, True);
2751 ShowLayer(LAYER_TRIGGERS
, True);
2755 FormCaption
:= MainForm
.Caption
;
2759 config
:= TConfig
.CreateFile(CfgFileName
);
2761 gWADEditorLogLevel
:= config
.ReadInt('WADEditor', 'LogLevel', DFWAD_LOG_DEFAULT
);
2763 if config
.ReadInt('Editor', 'XPos', -1) = -1 then
2764 Position
:= poDesktopCenter
2766 Left
:= config
.ReadInt('Editor', 'XPos', Left
);
2767 Top
:= config
.ReadInt('Editor', 'YPos', Top
);
2768 Width
:= config
.ReadInt('Editor', 'Width', Width
);
2769 Height
:= config
.ReadInt('Editor', 'Height', Height
);
2771 if config
.ReadBool('Editor', 'Maximize', False) then
2772 WindowState
:= wsMaximized
;
2773 ShowMap
:= config
.ReadBool('Editor', 'Minimap', False);
2774 PanelProps
.Width
:= config
.ReadInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
2775 Splitter1
.Left
:= PanelProps
.Left
;
2776 PanelObjs
.Height
:= config
.ReadInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
2777 Splitter2
.Top
:= PanelObjs
.Top
;
2778 StatusBar
.Top
:= PanelObjs
.BoundsRect
.Bottom
;
2779 DotEnable
:= config
.ReadBool('Editor', 'DotEnable', True);
2780 DotColor
:= config
.ReadInt('Editor', 'DotColor', $FFFFFF);
2781 DotStepOne
:= config
.ReadInt('Editor', 'DotStepOne', 16);
2782 DotStepTwo
:= config
.ReadInt('Editor', 'DotStepTwo', 8);
2783 DotStep
:= config
.ReadInt('Editor', 'DotStep', DotStepOne
);
2784 DrawTexturePanel
:= config
.ReadBool('Editor', 'DrawTexturePanel', True);
2785 DrawPanelSize
:= config
.ReadBool('Editor', 'DrawPanelSize', True);
2786 BackColor
:= config
.ReadInt('Editor', 'BackColor', $7F6040);
2787 PreviewColor
:= config
.ReadInt('Editor', 'PreviewColor', $00FF00);
2788 UseCheckerboard
:= config
.ReadBool('Editor', 'UseCheckerboard', True);
2789 gColorEdge
:= config
.ReadInt('Editor', 'EdgeColor', COLOR_EDGE
);
2790 gAlphaEdge
:= config
.ReadInt('Editor', 'EdgeAlpha', ALPHA_EDGE
);
2791 if gAlphaEdge
= 255 then
2792 gAlphaEdge
:= ALPHA_EDGE
;
2793 drEdge
[0] := GetRValue(gColorEdge
);
2794 drEdge
[1] := GetGValue(gColorEdge
);
2795 drEdge
[2] := GetBValue(gColorEdge
);
2796 if not config
.ReadBool('Editor', 'EdgeShow', True) then
2799 drEdge
[3] := gAlphaEdge
;
2800 gAlphaTriggerLine
:= config
.ReadInt('Editor', 'LineAlpha', ALPHA_LINE
);
2801 if gAlphaTriggerLine
= 255 then
2802 gAlphaTriggerLine
:= ALPHA_LINE
;
2803 gAlphaTriggerArea
:= config
.ReadInt('Editor', 'TriggerAlpha', ALPHA_AREA
);
2804 if gAlphaTriggerArea
= 255 then
2805 gAlphaTriggerArea
:= ALPHA_AREA
;
2806 gAlphaMonsterRect
:= config
.ReadInt('Editor', 'MonsterRectAlpha', 0);
2807 gAlphaAreaRect
:= config
.ReadInt('Editor', 'AreaRectAlpha', 0);
2808 Scale
:= Max(config
.ReadInt('Editor', 'Scale', 1), 1);
2809 DotSize
:= Max(config
.ReadInt('Editor', 'DotSize', 1), 1);
2810 OpenDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastOpenDir', MapsDir
);
2811 SaveDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastSaveDir', MapsDir
);
2813 s
:= config
.ReadStr('Editor', 'Language', '');
2816 TestGameMode
:= config
.ReadStr('TestRun', 'GameMode', 'DM');
2817 TestLimTime
:= config
.ReadStr('TestRun', 'LimTime', '0');
2818 TestLimScore
:= config
.ReadStr('TestRun', 'LimScore', '0');
2819 TestOptionsTwoPlayers
:= config
.ReadBool('TestRun', 'TwoPlayers', False);
2820 TestOptionsTeamDamage
:= config
.ReadBool('TestRun', 'TeamDamage', False);
2821 TestOptionsAllowExit
:= config
.ReadBool('TestRun', 'AllowExit', True);
2822 TestOptionsWeaponStay
:= config
.ReadBool('TestRun', 'WeaponStay', False);
2823 TestOptionsMonstersDM
:= config
.ReadBool('TestRun', 'MonstersDM', False);
2824 TestMapOnce
:= config
.ReadBool('TestRun', 'MapOnce', False);
2825 {$IF DEFINED(DARWIN)}
2826 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeDrawin', GameExeFile
);
2827 {$ELSEIF DEFINED(WINDOWS)}
2828 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeWindows', GameExeFile
);
2830 TestD2dExe
:= config
.ReadStr('TestRun', 'ExeUnix', GameExeFile
);
2832 TestD2DArgs
:= config
.ReadStr('TestRun', 'Args', '');
2834 RecentCount
:= config
.ReadInt('Editor', 'RecentCount', 5);
2835 if RecentCount
> 10 then
2837 if RecentCount
< 2 then
2840 RecentFiles
:= TStringList
.Create();
2841 for i
:= 0 to RecentCount
-1 do
2844 s
:= config
.ReadStr('RecentFilesWin', IntToStr(i
), '');
2846 s
:= config
.ReadStr('RecentFilesUnix', IntToStr(i
), '');
2851 RefreshRecentMenu();
2855 tbShowMap
.Down
:= ShowMap
;
2856 tbGridOn
.Down
:= DotEnable
;
2857 pcObjects
.ActivePageIndex
:= 0;
2858 Application
.Title
:= MsgEditorTitle
;
2860 Application
.OnIdle
:= OnIdle
;
2863 procedure PrintBlack(X
, Y
: Integer; Text: string; FontID
: DWORD
);
2865 // NOTE: all the font printing routines assume CP1251
2866 e_TextureFontPrintEx(X
, Y
, Text, FontID
, 0, 0, 0, 1.0);
2869 procedure InitGraphics
;
2871 // FIXME: this is a shitty hack
2872 if not gDataLoaded
then
2874 e_WriteLog('Init OpenGL', MSG_NOTIFY
);
2876 e_WriteLog('Loading data', MSG_NOTIFY
);
2877 LoadStdFont('STDTXT', 'STDFONT', gEditorFont
);
2878 e_WriteLog('Loading more data', MSG_NOTIFY
);
2880 e_WriteLog('Loading even more data', MSG_NOTIFY
);
2881 gDataLoaded
:= True;
2882 MainForm
.FormResize(nil);
2886 procedure TMainForm
.Draw();
2891 Width
, Height
: Word;
2894 aX
, aY
, aX2
, aY2
, XX
, ScaleSz
: Integer;
2896 LastDrawTime
:= GetTickCount64();
2906 e_Clear(GL_COLOR_BUFFER_BIT
,
2907 GetRValue(BackColor
)/255,
2908 GetGValue(BackColor
)/255,
2909 GetBValue(BackColor
)/255);
2913 ObjCount
:= SelectedObjectCount();
2915 // Обводим выделенные объекты красной рамкой:
2916 if ObjCount
> 0 then
2918 for a
:= 0 to High(SelectedObjects
) do
2919 if SelectedObjects
[a
].Live
then
2921 Rect
:= ObjectGetRect(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
);
2925 e_DrawQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2926 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2929 // Рисуем точки изменения размеров:
2930 if (ObjCount
= 1) and
2931 (SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) then
2933 e_DrawPoint(5, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2934 e_DrawPoint(5, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2935 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 255, 255);
2936 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 255, 255);
2938 e_DrawPoint(3, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2939 e_DrawPoint(3, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2940 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 0, 0);
2941 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 0, 0);
2948 if DotEnable
and (PreviewMode
= 0) then
2955 glDisable(GL_TEXTURE_2D
);
2956 glColor3ub(GetRValue(DotColor
), GetGValue(DotColor
), GetBValue(DotColor
));
2957 glPointSize(DotSize
);
2959 x
:= MapOffset
.X
mod DotStep
;
2960 while x
< RenderPanel
.Width
do
2962 y
:= MapOffset
.Y
mod DotStep
;
2963 while y
< RenderPanel
.Height
do
2965 glVertex2i(x
+ a
, y
+ a
);
2971 glColor4ub(e_Colors
.R
, e_Colors
.G
, e_Colors
.B
, 255);
2975 if (lbTextureList
.ItemIndex
<> -1) and (cbPreview
.Checked
) and
2976 (not IsSpecialTextureSel()) and (PreviewMode
= 0) then
2978 if not g_GetTexture(SelectedTexture(), ID
) then
2979 g_GetTexture('NOTEXTURE', ID
);
2980 g_GetTextureSizeByID(ID
, Width
, Height
);
2981 if UseCheckerboard
then
2983 if g_GetTexture('PREVIEW', PID
) then
2984 e_DrawFill(PID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, Width
div 16 + 1, Height
div 16 + 1, 0, True, False);
2986 e_DrawFillQuad(RenderPanel
.Width
-Width
-2, RenderPanel
.Height
-Height
-2,
2987 RenderPanel
.Width
-1, RenderPanel
.Height
-1,
2988 GetRValue(PreviewColor
), GetGValue(PreviewColor
), GetBValue(PreviewColor
), 0);
2989 e_Draw(ID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, 0, True, False);
2992 // Подсказка при выборе точки Телепорта:
2993 if SelectFlag
= SELECTFLAG_TELEPORT
then
2995 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
2996 if Data
.d2d_teleport
then
2997 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
2998 MousePos
.X
+16, MousePos
.Y
-1,
3001 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+AreaSize
[AREA_DMPOINT
].Width
-1,
3002 MousePos
.Y
+AreaSize
[AREA_DMPOINT
].Height
-1, 255, 255, 255);
3004 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3005 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3006 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintTeleport
), gEditorFont
);
3009 // Подсказка при выборе точки появления:
3010 if SelectFlag
= SELECTFLAG_SPAWNPOINT
then
3012 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
3013 MousePos
.X
+16, MousePos
.Y
-1,
3015 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3016 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3017 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintSpawn
), gEditorFont
);
3020 // Подсказка при выборе панели двери:
3021 if SelectFlag
= SELECTFLAG_DOOR
then
3023 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3024 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3025 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelDoor
), gEditorFont
);
3028 // Подсказка при выборе панели с текстурой:
3029 if SelectFlag
= SELECTFLAG_TEXTURE
then
3031 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 192, 192, 192, 127);
3032 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 255, 255, 255);
3033 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelTexture
), gEditorFont
);
3036 // Подсказка при выборе панели индикации выстрела:
3037 if SelectFlag
= SELECTFLAG_SHOTPANEL
then
3039 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 192, 192, 192, 127);
3040 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 255, 255, 255);
3041 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelShot
), gEditorFont
);
3044 // Подсказка при выборе панели лифта:
3045 if SelectFlag
= SELECTFLAG_LIFT
then
3047 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
3048 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
3049 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintPanelLift
), gEditorFont
);
3052 // Подсказка при выборе монстра:
3053 if SelectFlag
= SELECTFLAG_MONSTER
then
3055 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 192, 192, 192, 127);
3056 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 255, 255, 255);
3057 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintMonster
), gEditorFont
);
3060 // Подсказка при выборе области воздействия:
3061 if DrawPressRect
then
3063 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 192, 192, 192, 127);
3064 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 255, 255, 255);
3065 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, utf8to1251(MsgHintExtArea
), gEditorFont
);
3068 // Рисуем текстуры, если чертим панель:
3069 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and (DrawTexturePanel
) and
3070 (lbTextureList
.ItemIndex
<> -1) and (DrawRect
<> nil) and
3071 (lbPanelType
.ItemIndex
in [0..8]) and not IsSpecialTextureSel() then
3073 if not g_GetTexture(SelectedTexture(), ID
) then
3074 g_GetTexture('NOTEXTURE', ID
);
3075 g_GetTextureSizeByID(ID
, Width
, Height
);
3077 if (Abs(Right
-Left
) >= Width
) and (Abs(Bottom
-Top
) >= Height
) then
3078 e_DrawFill(ID
, Min(Left
, Right
), Min(Top
, Bottom
), Abs(Right
-Left
) div Width
,
3079 Abs(Bottom
-Top
) div Height
, 64, True, False);
3082 // Прямоугольник выделения:
3083 if DrawRect
<> nil then
3085 e_DrawQuad(Left
, Top
, Right
-1, Bottom
-1, 255, 255, 255);
3087 // Чертим мышью панель/триггер или меняем мышью их размер:
3088 if (((MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
]) and
3089 not(ssCtrl
in GetKeyShiftState())) or (MouseAction
= MOUSEACTION_RESIZE
)) and
3090 (DrawPanelSize
) then
3092 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 192, 192, 192, 127);
3093 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 255, 255, 255);
3095 if MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
] then
3096 begin // Чертим новый
3097 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(utf8to1251(MsgHintWidth
),
3098 [Abs(MousePos
.X
-MouseLDownPos
.X
)]), gEditorFont
);
3099 PrintBlack(MousePos
.X
+2, MousePos
.Y
+16, Format(utf8to1251(MsgHintHeight
),
3100 [Abs(MousePos
.Y
-MouseLDownPos
.Y
)]), gEditorFont
);
3102 else // Растягиваем существующий
3103 if SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
] then
3105 if SelectedObjects
[GetFirstSelected
].ObjectType
= OBJECT_PANEL
then
3107 Width
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
3108 Height
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
3112 Width
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
3113 Height
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
3116 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(utf8to1251(MsgHintWidth
), [Width
]),
3118 PrintBlack(MousePos
.X
+2, MousePos
.Y
+16, Format(utf8to1251(MsgHintHeight
), [Height
]),
3123 // Ближайшая к курсору мыши точка на сетке:
3124 e_DrawPoint(3, MousePos
.X
, MousePos
.Y
, 0, 0, 255);
3129 // Сколько пикселов карты в 1 пикселе мини-карты:
3130 ScaleSz
:= 16 div Scale
;
3131 // Размеры мини-карты:
3132 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
3133 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
3134 // X-координата на RenderPanel нулевой x-координаты карты:
3135 XX
:= RenderPanel
.Width
- aX
- 1;
3137 e_DrawFillQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 0, 0, 0, 0);
3138 e_DrawQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 197, 197, 197);
3140 if gPanels
<> nil then
3143 for a
:= 0 to High(gPanels
) do
3145 if PanelType
<> 0 then
3147 // Левый верхний угол:
3148 aX
:= XX
+ (X
div ScaleSz
);
3149 aY
:= 1 + (Y
div ScaleSz
);
3151 aX2
:= max(Width
div ScaleSz
, 1);
3152 aY2
:= max(Height
div ScaleSz
, 1);
3153 // Правый нижний угол:
3154 aX2
:= aX
+ aX2
- 1;
3155 aY2
:= aY
+ aY2
- 1;
3158 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
3159 PANEL_WATER
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
3160 PANEL_ACID1
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
3161 PANEL_ACID2
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
3162 PANEL_STEP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
3163 PANEL_LIFTUP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
3164 PANEL_LIFTDOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
3165 PANEL_LIFTLEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
3166 PANEL_LIFTRIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
3167 PANEL_OPENDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 100, 220, 92, 0);
3168 PANEL_CLOSEDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 212, 184, 64, 0);
3169 PANEL_BLOCKMON
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 192, 0, 192, 0);
3173 // Рисуем красным выделенные панели:
3174 if SelectedObjects
<> nil then
3175 for b
:= 0 to High(SelectedObjects
) do
3176 with SelectedObjects
[b
] do
3177 if Live
and (ObjectType
= OBJECT_PANEL
) then
3178 with gPanels
[SelectedObjects
[b
].ID
] do
3179 if PanelType
and not(PANEL_BACK
or PANEL_FORE
) <> 0 then
3181 // Левый верхний угол:
3182 aX
:= XX
+ (X
div ScaleSz
);
3183 aY
:= 1 + (Y
div ScaleSz
);
3185 aX2
:= max(Width
div ScaleSz
, 1);
3186 aY2
:= max(Height
div ScaleSz
, 1);
3187 // Правый нижний угол:
3188 aX2
:= aX
+ aX2
- 1;
3189 aY2
:= aY
+ aY2
- 1;
3191 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0)
3195 if (gMapInfo
.Width
> RenderPanel
.Width
) or
3196 (gMapInfo
.Height
> RenderPanel
.Height
) then
3198 // Окно, показывающее текущее положение экрана на карте:
3200 x
:= max(min(RenderPanel
.Width
, gMapInfo
.Width
) div ScaleSz
, 1);
3201 y
:= max(min(RenderPanel
.Height
, gMapInfo
.Height
) div ScaleSz
, 1);
3202 // Левый верхний угол:
3203 aX
:= XX
+ ((-MapOffset
.X
) div ScaleSz
);
3204 aY
:= 1 + ((-MapOffset
.Y
) div ScaleSz
);
3205 // Правый нижний угол:
3209 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 127, 192, 127, 127, B_BLEND
);
3210 e_DrawQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0);
3215 RenderPanel
.SwapBuffers();
3218 procedure TMainForm
.FormResize(Sender
: TObject
);
3220 e_SetViewPort(0, 0, RenderPanel
.Width
, RenderPanel
.Height
);
3222 sbHorizontal
.Min
:= Min(gMapInfo
.Width
- RenderPanel
.Width
, -RenderPanel
.Width
div 2);
3223 sbHorizontal
.Max
:= Max(0, gMapInfo
.Width
- RenderPanel
.Width
div 2);
3224 sbVertical
.Min
:= Min(gMapInfo
.Height
- RenderPanel
.Height
, -RenderPanel
.Height
div 2);
3225 sbVertical
.Max
:= Max(0, gMapInfo
.Height
- RenderPanel
.Height
div 2);
3227 MapOffset
.X
:= -sbHorizontal
.Position
;
3228 MapOffset
.Y
:= -sbVertical
.Position
;
3231 procedure TMainForm
.FormWindowStateChange(Sender
: TObject
);
3237 // deactivate all menus when main window minimized
3238 e
:= self
.WindowState
<> wsMinimized
;
3239 miMenuFile
.Enabled
:= e
;
3240 miMenuEdit
.Enabled
:= e
;
3241 miMenuView
.Enabled
:= e
;
3242 miMenuService
.Enabled
:= e
;
3243 miMenuWindow
.Enabled
:= e
;
3244 miMenuHelp
.Enabled
:= e
;
3245 miMenuHidden
.Enabled
:= e
;
3249 procedure SelectNextObject(X
, Y
: Integer; ObjectType
: Byte; ID
: DWORD
);
3254 j_max
:= 0; // shut up compiler
3258 res
:= (gPanels
<> nil) and
3259 PanelInShownLayer(gPanels
[ID
].PanelType
) and
3260 g_CollidePoint(X
, Y
, gPanels
[ID
].X
, gPanels
[ID
].Y
,
3262 gPanels
[ID
].Height
);
3263 j_max
:= Length(gPanels
) - 1;
3268 res
:= (gItems
<> nil) and
3269 LayerEnabled
[LAYER_ITEMS
] and
3270 g_CollidePoint(X
, Y
, gItems
[ID
].X
, gItems
[ID
].Y
,
3271 ItemSize
[gItems
[ID
].ItemType
][0],
3272 ItemSize
[gItems
[ID
].ItemType
][1]);
3273 j_max
:= Length(gItems
) - 1;
3278 res
:= (gMonsters
<> nil) and
3279 LayerEnabled
[LAYER_MONSTERS
] and
3280 g_CollidePoint(X
, Y
, gMonsters
[ID
].X
, gMonsters
[ID
].Y
,
3281 MonsterSize
[gMonsters
[ID
].MonsterType
].Width
,
3282 MonsterSize
[gMonsters
[ID
].MonsterType
].Height
);
3283 j_max
:= Length(gMonsters
) - 1;
3288 res
:= (gAreas
<> nil) and
3289 LayerEnabled
[LAYER_AREAS
] and
3290 g_CollidePoint(X
, Y
, gAreas
[ID
].X
, gAreas
[ID
].Y
,
3291 AreaSize
[gAreas
[ID
].AreaType
].Width
,
3292 AreaSize
[gAreas
[ID
].AreaType
].Height
);
3293 j_max
:= Length(gAreas
) - 1;
3298 res
:= (gTriggers
<> nil) and
3299 LayerEnabled
[LAYER_TRIGGERS
] and
3300 g_CollidePoint(X
, Y
, gTriggers
[ID
].X
, gTriggers
[ID
].Y
,
3301 gTriggers
[ID
].Width
,
3302 gTriggers
[ID
].Height
);
3303 j_max
:= Length(gTriggers
) - 1;
3313 // Перебор ID: от ID-1 до 0; потом от High до ID+1:
3322 if j
= Integer(ID
) then
3327 res
:= PanelInShownLayer(gPanels
[j
].PanelType
) and
3328 g_CollidePoint(X
, Y
, gPanels
[j
].X
, gPanels
[j
].Y
,
3332 res
:= (gItems
[j
].ItemType
<> ITEM_NONE
) and
3333 g_CollidePoint(X
, Y
, gItems
[j
].X
, gItems
[j
].Y
,
3334 ItemSize
[gItems
[j
].ItemType
][0],
3335 ItemSize
[gItems
[j
].ItemType
][1]);
3337 res
:= (gMonsters
[j
].MonsterType
<> MONSTER_NONE
) and
3338 g_CollidePoint(X
, Y
, gMonsters
[j
].X
, gMonsters
[j
].Y
,
3339 MonsterSize
[gMonsters
[j
].MonsterType
].Width
,
3340 MonsterSize
[gMonsters
[j
].MonsterType
].Height
);
3342 res
:= (gAreas
[j
].AreaType
<> AREA_NONE
) and
3343 g_CollidePoint(X
, Y
, gAreas
[j
].X
, gAreas
[j
].Y
,
3344 AreaSize
[gAreas
[j
].AreaType
].Width
,
3345 AreaSize
[gAreas
[j
].AreaType
].Height
);
3347 res
:= (gTriggers
[j
].TriggerType
<> TRIGGER_NONE
) and
3348 g_CollidePoint(X
, Y
, gTriggers
[j
].X
, gTriggers
[j
].Y
,
3350 gTriggers
[j
].Height
);
3357 SetLength(SelectedObjects
, 1);
3359 SelectedObjects
[0].ObjectType
:= ObjectType
;
3360 SelectedObjects
[0].ID
:= j
;
3361 SelectedObjects
[0].Live
:= True;
3369 procedure TMainForm
.RenderPanelMouseDown(Sender
: TObject
;
3370 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3374 c1
, c2
, c3
, c4
: Boolean;
3380 MainForm
.ActiveControl
:= RenderPanel
;
3381 RenderPanel
.SetFocus();
3383 RenderPanelMouseMove(RenderPanel
, Shift
, X
, Y
);
3385 if Button
= mbLeft
then // Left Mouse Button
3387 // Двигаем карту с помощью мыши и мини-карты:
3389 g_CollidePoint(X
, Y
,
3390 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3392 max(gMapInfo
.Width
div (16 div Scale
), 1),
3393 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3396 MouseAction
:= MOUSEACTION_MOVEMAP
;
3398 else // Ставим предмет/монстра/область:
3399 if (pcObjects
.ActivePageIndex
in [1, 2, 3]) and
3400 (not (ssShift
in Shift
)) then
3402 case pcObjects
.ActivePageIndex
of
3404 if lbItemList
.ItemIndex
= -1 then
3405 ErrorMessageBox(MsgMsgChooseItem
)
3408 item
.ItemType
:= lbItemList
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
3409 if item
.ItemType
>= ITEM_WEAPON_KASTET
then
3410 item
.ItemType
:= item
.ItemType
+ 2;
3411 item
.X
:= MousePos
.X
-MapOffset
.X
;
3412 item
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3414 if not (ssCtrl
in Shift
) then
3416 item
.X
:= item
.X
- (ItemSize
[item
.ItemType
][0] div 2);
3417 item
.Y
:= item
.Y
- ItemSize
[item
.ItemType
][1];
3420 item
.OnlyDM
:= cbOnlyDM
.Checked
;
3421 item
.Fall
:= cbFall
.Checked
;
3422 Undo_Add(OBJECT_ITEM
, AddItem(item
));
3425 if lbMonsterList
.ItemIndex
= -1 then
3426 ErrorMessageBox(MsgMsgChooseMonster
)
3429 monster
.MonsterType
:= lbMonsterList
.ItemIndex
+ MONSTER_DEMON
;
3430 monster
.X
:= MousePos
.X
-MapOffset
.X
;
3431 monster
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3433 if not (ssCtrl
in Shift
) then
3435 monster
.X
:= monster
.X
- (MonsterSize
[monster
.MonsterType
].Width
div 2);
3436 monster
.Y
:= monster
.Y
- MonsterSize
[monster
.MonsterType
].Height
;
3439 if rbMonsterLeft
.Checked
then
3440 monster
.Direction
:= D_LEFT
3442 monster
.Direction
:= D_RIGHT
;
3443 Undo_Add(OBJECT_MONSTER
, AddMonster(monster
));
3446 if lbAreasList
.ItemIndex
= -1 then
3447 ErrorMessageBox(MsgMsgChooseArea
)
3449 if (lbAreasList
.ItemIndex
+ 1) <> AREA_DOMFLAG
then
3451 area
.AreaType
:= lbAreasList
.ItemIndex
+ AREA_PLAYERPOINT1
;
3452 area
.X
:= MousePos
.X
-MapOffset
.X
;
3453 area
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3455 if not (ssCtrl
in Shift
) then
3457 area
.X
:= area
.X
- (AreaSize
[area
.AreaType
].Width
div 2);
3458 area
.Y
:= area
.Y
- AreaSize
[area
.AreaType
].Height
;
3461 if rbAreaLeft
.Checked
then
3462 area
.Direction
:= D_LEFT
3464 area
.Direction
:= D_RIGHT
;
3465 Undo_Add(OBJECT_AREA
, AddArea(area
));
3471 i
:= GetFirstSelected();
3473 // Выбираем объект под текущим:
3474 if (SelectedObjects
<> nil) and
3475 (ssShift
in Shift
) and (i
>= 0) and
3476 (SelectedObjects
[i
].Live
) then
3478 if SelectedObjectCount() = 1 then
3479 SelectNextObject(X
-MapOffset
.X
, Y
-MapOffset
.Y
,
3480 SelectedObjects
[i
].ObjectType
,
3481 SelectedObjects
[i
].ID
);
3485 // Рисуем область триггера "Расширитель":
3486 if DrawPressRect
and (i
>= 0) and
3487 (SelectedObjects
[i
].ObjectType
= OBJECT_TRIGGER
) and
3488 (gTriggers
[SelectedObjects
[i
].ID
].TriggerType
in
3489 [TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
]) then
3490 MouseAction
:= MOUSEACTION_DRAWPRESS
3491 else // Рисуем панель:
3492 if pcObjects
.ActivePageIndex
= 0 then
3494 if (lbPanelType
.ItemIndex
>= 0) then
3495 MouseAction
:= MOUSEACTION_DRAWPANEL
3497 else // Рисуем триггер:
3498 if (lbTriggersList
.ItemIndex
>= 0) then
3500 MouseAction
:= MOUSEACTION_DRAWTRIGGER
;
3504 end; // if Button = mbLeft
3506 if Button
= mbRight
then // Right Mouse Button
3508 // Клик по мини-карте:
3510 g_CollidePoint(X
, Y
,
3511 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3513 max(gMapInfo
.Width
div (16 div Scale
), 1),
3514 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3516 MouseAction
:= MOUSEACTION_NOACTION
;
3518 else // Нужно что-то выбрать мышью:
3519 if SelectFlag
<> SELECTFLAG_NONE
then
3522 SELECTFLAG_TELEPORT
:
3523 // Точку назначения телепортации:
3524 with gTriggers
[SelectedObjects
[
3525 GetFirstSelected() ].ID
].Data
.TargetPoint
do
3527 X
:= MousePos
.X
-MapOffset
.X
;
3528 Y
:= MousePos
.Y
-MapOffset
.Y
;
3531 SELECTFLAG_SPAWNPOINT
:
3532 // Точку создания монстра:
3533 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
3534 if TriggerType
= TRIGGER_SPAWNMONSTER
then
3536 Data
.MonPos
.X
:= MousePos
.X
-MapOffset
.X
;
3537 Data
.MonPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3539 else if TriggerType
= TRIGGER_SPAWNITEM
then
3540 begin // Точка создания предмета:
3541 Data
.ItemPos
.X
:= MousePos
.X
-MapOffset
.X
;
3542 Data
.ItemPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3544 else if TriggerType
= TRIGGER_SHOT
then
3545 begin // Точка создания выстрела:
3546 Data
.ShotPos
.X
:= MousePos
.X
-MapOffset
.X
;
3547 Data
.ShotPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3553 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3555 2, 2, OBJECT_PANEL
, True);
3556 if IDArray
<> nil then
3558 for i
:= 0 to High(IDArray
) do
3559 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3560 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
) then
3562 gTriggers
[SelectedObjects
[
3563 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3568 gTriggers
[SelectedObjects
[
3569 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3573 // Панель с текстурой:
3575 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3577 2, 2, OBJECT_PANEL
, True);
3578 if IDArray
<> nil then
3580 for i
:= 0 to High(IDArray
) do
3581 if ((gPanels
[IDArray
[i
]].PanelType
in
3582 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3583 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3585 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3586 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3587 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3589 gTriggers
[SelectedObjects
[
3590 GetFirstSelected() ].ID
].TexturePanel
:= IDArray
[i
];
3595 gTriggers
[SelectedObjects
[
3596 GetFirstSelected() ].ID
].TexturePanel
:= -1;
3602 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3604 2, 2, OBJECT_PANEL
, True);
3605 if IDArray
<> nil then
3607 for i
:= 0 to High(IDArray
) do
3608 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTUP
) or
3609 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTDOWN
) or
3610 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTLEFT
) or
3611 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTRIGHT
) then
3613 gTriggers
[SelectedObjects
[
3614 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3619 gTriggers
[SelectedObjects
[
3620 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3626 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3628 2, 2, OBJECT_MONSTER
, False);
3629 if IDArray
<> nil then
3630 gTriggers
[SelectedObjects
[
3631 GetFirstSelected() ].ID
].Data
.MonsterID
:= IDArray
[0]+1
3633 gTriggers
[SelectedObjects
[
3634 GetFirstSelected() ].ID
].Data
.MonsterID
:= 0;
3637 SELECTFLAG_SHOTPANEL
:
3638 // Панель индикации выстрела:
3640 if gTriggers
[SelectedObjects
[
3641 GetFirstSelected() ].ID
].TriggerType
= TRIGGER_SHOT
then
3643 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3645 2, 2, OBJECT_PANEL
, True);
3646 if IDArray
<> nil then
3648 for i
:= 0 to High(IDArray
) do
3649 if ((gPanels
[IDArray
[i
]].PanelType
in
3650 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3651 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3653 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3654 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3655 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3657 gTriggers
[SelectedObjects
[
3658 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= IDArray
[i
];
3663 gTriggers
[SelectedObjects
[
3664 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= -1;
3669 SelectFlag
:= SELECTFLAG_SELECTED
;
3671 else // if SelectFlag <> SELECTFLAG_NONE...
3673 // Что уже выбрано и не нажат Ctrl:
3674 if (SelectedObjects
<> nil) and
3675 (not (ssCtrl
in Shift
)) then
3676 for i
:= 0 to High(SelectedObjects
) do
3677 with SelectedObjects
[i
] do
3680 if (ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) and
3681 (SelectedObjectCount() = 1) then
3683 Rect
:= ObjectGetRect(ObjectType
, ID
);
3685 c1
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3686 Rect
.X
-2, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3687 c2
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3688 Rect
.X
+Rect
.Width
-3, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3689 c3
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3690 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
-2, 4, 4);
3691 c4
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3692 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
+Rect
.Height
-3, 4, 4);
3694 // Меняем размер панели или триггера:
3695 if c1
or c2
or c3
or c4
then
3697 MouseAction
:= MOUSEACTION_RESIZE
;
3698 LastMovePoint
:= MousePos
;
3702 ResizeType
:= RESIZETYPE_HORIZONTAL
;
3704 ResizeDirection
:= RESIZEDIR_LEFT
3706 ResizeDirection
:= RESIZEDIR_RIGHT
;
3707 RenderPanel
.Cursor
:= crSizeWE
;
3711 ResizeType
:= RESIZETYPE_VERTICAL
;
3713 ResizeDirection
:= RESIZEDIR_UP
3715 ResizeDirection
:= RESIZEDIR_DOWN
;
3716 RenderPanel
.Cursor
:= crSizeNS
;
3723 // Перемещаем панель или триггер:
3724 if ObjectCollide(ObjectType
, ID
,
3726 Y
-MapOffset
.Y
-1, 2, 2) then
3728 MouseAction
:= MOUSEACTION_MOVEOBJ
;
3729 LastMovePoint
:= MousePos
;
3735 end; // if Button = mbRight
3737 if Button
= mbMiddle
then // Middle Mouse Button
3739 SetCapture(RenderPanel
.Handle
);
3740 RenderPanel
.Cursor
:= crSize
;
3743 MouseMDown
:= Button
= mbMiddle
;
3745 MouseMDownPos
:= Mouse
.CursorPos
;
3747 MouseRDown
:= Button
= mbRight
;
3749 MouseRDownPos
:= MousePos
;
3751 MouseLDown
:= Button
= mbLeft
;
3753 MouseLDownPos
:= MousePos
;
3756 procedure TMainForm
.RenderPanelMouseUp(Sender
: TObject
;
3757 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3762 rSelectRect
: Boolean;
3763 wWidth
, wHeight
: Word;
3766 procedure SelectObjects(ObjectType
: Byte);
3771 IDArray
:= ObjectInRect(rRect
.X
, rRect
.Y
,
3772 rRect
.Width
, rRect
.Height
,
3773 ObjectType
, rSelectRect
);
3775 if IDArray
<> nil then
3776 for i
:= 0 to High(IDArray
) do
3777 SelectObject(ObjectType
, IDArray
[i
], (ssCtrl
in Shift
) or rSelectRect
);
3780 if Button
= mbLeft
then
3781 MouseLDown
:= False;
3782 if Button
= mbRight
then
3783 MouseRDown
:= False;
3784 if Button
= mbMiddle
then
3785 MouseMDown
:= False;
3787 if DrawRect
<> nil then
3793 ResizeType
:= RESIZETYPE_NONE
;
3796 if Button
= mbLeft
then // Left Mouse Button
3798 if MouseAction
<> MOUSEACTION_NONE
then
3799 begin // Было действие мышью
3800 // Мышь сдвинулась во время удержания клавиши,
3801 // либо активирован режим быстрого рисования:
3802 if ((MousePos
.X
<> MouseLDownPos
.X
) and
3803 (MousePos
.Y
<> MouseLDownPos
.Y
)) or
3804 ((MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
]) and
3805 (ssCtrl
in Shift
)) then
3808 MOUSEACTION_DRAWPANEL
:
3810 // Фон или передний план без текстуры - ошибка:
3811 if (lbPanelType
.ItemIndex
in [1, 2]) and
3812 (lbTextureList
.ItemIndex
= -1) then
3813 ErrorMessageBox(MsgMsgChooseTexture
)
3814 else // Назначаем параметры панели:
3816 case lbPanelType
.ItemIndex
of
3817 0: Panel
.PanelType
:= PANEL_WALL
;
3818 1: Panel
.PanelType
:= PANEL_BACK
;
3819 2: Panel
.PanelType
:= PANEL_FORE
;
3820 3: Panel
.PanelType
:= PANEL_OPENDOOR
;
3821 4: Panel
.PanelType
:= PANEL_CLOSEDOOR
;
3822 5: Panel
.PanelType
:= PANEL_STEP
;
3823 6: Panel
.PanelType
:= PANEL_WATER
;
3824 7: Panel
.PanelType
:= PANEL_ACID1
;
3825 8: Panel
.PanelType
:= PANEL_ACID2
;
3826 9: Panel
.PanelType
:= PANEL_LIFTUP
;
3827 10: Panel
.PanelType
:= PANEL_LIFTDOWN
;
3828 11: Panel
.PanelType
:= PANEL_LIFTLEFT
;
3829 12: Panel
.PanelType
:= PANEL_LIFTRIGHT
;
3830 13: Panel
.PanelType
:= PANEL_BLOCKMON
;
3833 Panel
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3834 Panel
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3835 if ssCtrl
in Shift
then
3839 if (lbTextureList
.ItemIndex
<> -1) and
3840 (not IsSpecialTextureSel()) then
3842 if not g_GetTexture(SelectedTexture(), TextureID
) then
3843 g_GetTexture('NOTEXTURE', TextureID
);
3844 g_GetTextureSizeByID(TextureID
, wWidth
, wHeight
);
3846 Panel
.Width
:= wWidth
;
3847 Panel
.Height
:= wHeight
;
3851 Panel
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3852 Panel
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3855 // Лифты, блокМон или отсутствие текстуры - пустая текстура:
3856 if (lbPanelType
.ItemIndex
in [9, 10, 11, 12, 13]) or
3857 (lbTextureList
.ItemIndex
= -1) then
3859 Panel
.TextureHeight
:= 1;
3860 Panel
.TextureWidth
:= 1;
3861 Panel
.TextureName
:= '';
3862 Panel
.TextureID
:= TEXTURE_SPECIAL_NONE
;
3864 else // Есть текстура:
3866 Panel
.TextureName
:= SelectedTexture();
3868 // Обычная текстура:
3869 if not IsSpecialTextureSel() then
3871 g_GetTextureSizeByName(Panel
.TextureName
,
3872 Panel
.TextureWidth
, Panel
.TextureHeight
);
3873 g_GetTexture(Panel
.TextureName
, Panel
.TextureID
);
3875 else // Спец.текстура:
3877 Panel
.TextureHeight
:= 1;
3878 Panel
.TextureWidth
:= 1;
3879 Panel
.TextureID
:= SpecialTextureID(SelectedTexture());
3884 Panel
.Blending
:= False;
3886 Undo_Add(OBJECT_PANEL
, AddPanel(Panel
));
3890 // Рисовали триггер:
3891 MOUSEACTION_DRAWTRIGGER
:
3893 trigger
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3894 trigger
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3895 if ssCtrl
in Shift
then
3899 trigger
.Width
:= wWidth
;
3900 trigger
.Height
:= wHeight
;
3904 trigger
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3905 trigger
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3908 trigger
.Enabled
:= True;
3909 trigger
.TriggerType
:= lbTriggersList
.ItemIndex
+1;
3910 trigger
.TexturePanel
:= -1;
3913 trigger
.ActivateType
:= 0;
3915 if clbActivationType
.Checked
[0] then
3916 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERCOLLIDE
;
3917 if clbActivationType
.Checked
[1] then
3918 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERCOLLIDE
;
3919 if clbActivationType
.Checked
[2] then
3920 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERPRESS
;
3921 if clbActivationType
.Checked
[3] then
3922 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERPRESS
;
3923 if clbActivationType
.Checked
[4] then
3924 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_SHOT
;
3925 if clbActivationType
.Checked
[5] then
3926 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_NOMONSTER
;
3928 // Необходимые для активации ключи:
3931 if clbKeys
.Checked
[0] then
3932 trigger
.Key
:= Trigger
.Key
or KEY_RED
;
3933 if clbKeys
.Checked
[1] then
3934 trigger
.Key
:= Trigger
.Key
or KEY_GREEN
;
3935 if clbKeys
.Checked
[2] then
3936 trigger
.Key
:= Trigger
.Key
or KEY_BLUE
;
3937 if clbKeys
.Checked
[3] then
3938 trigger
.Key
:= Trigger
.Key
or KEY_REDTEAM
;
3939 if clbKeys
.Checked
[4] then
3940 trigger
.Key
:= Trigger
.Key
or KEY_BLUETEAM
;
3942 // Параметры триггера:
3943 FillByte(trigger
.Data
.Default
[0], 128, 0);
3945 case trigger
.TriggerType
of
3946 // Переключаемая панель:
3947 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
3948 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
3949 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
3951 Trigger
.Data
.PanelID
:= -1;
3957 trigger
.Data
.TargetPoint
.X
:= trigger
.X
-64;
3958 trigger
.Data
.TargetPoint
.Y
:= trigger
.Y
-64;
3959 trigger
.Data
.d2d_teleport
:= True;
3960 trigger
.Data
.TlpDir
:= 0;
3963 // Изменение других триггеров:
3964 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
3967 trigger
.Data
.Count
:= 1;
3973 trigger
.Data
.Volume
:= 255;
3974 trigger
.Data
.Pan
:= 127;
3975 trigger
.Data
.PlayCount
:= 1;
3976 trigger
.Data
.Local
:= True;
3977 trigger
.Data
.SoundSwitch
:= False;
3983 trigger
.Data
.MusicAction
:= 1;
3986 // Создание монстра:
3987 TRIGGER_SPAWNMONSTER
:
3989 trigger
.Data
.MonType
:= MONSTER_ZOMBY
;
3990 trigger
.Data
.MonPos
.X
:= trigger
.X
-64;
3991 trigger
.Data
.MonPos
.Y
:= trigger
.Y
-64;
3992 trigger
.Data
.MonHealth
:= 0;
3993 trigger
.Data
.MonActive
:= False;
3994 trigger
.Data
.MonCount
:= 1;
3997 // Создание предмета:
4000 trigger
.Data
.ItemType
:= ITEM_AMMO_BULLETS
;
4001 trigger
.Data
.ItemPos
.X
:= trigger
.X
-64;
4002 trigger
.Data
.ItemPos
.Y
:= trigger
.Y
-64;
4003 trigger
.Data
.ItemOnlyDM
:= False;
4004 trigger
.Data
.ItemFalls
:= False;
4005 trigger
.Data
.ItemCount
:= 1;
4006 trigger
.Data
.ItemMax
:= 0;
4007 trigger
.Data
.ItemDelay
:= 0;
4013 trigger
.Data
.PushAngle
:= 90;
4014 trigger
.Data
.PushForce
:= 10;
4015 trigger
.Data
.ResetVel
:= True;
4020 trigger
.Data
.ScoreCount
:= 1;
4021 trigger
.Data
.ScoreCon
:= True;
4022 trigger
.Data
.ScoreMsg
:= True;
4027 trigger
.Data
.MessageKind
:= 0;
4028 trigger
.Data
.MessageSendTo
:= 0;
4029 trigger
.Data
.MessageText
:= '';
4030 trigger
.Data
.MessageTime
:= 144;
4035 trigger
.Data
.DamageValue
:= 5;
4036 trigger
.Data
.DamageInterval
:= 12;
4041 trigger
.Data
.HealValue
:= 5;
4042 trigger
.Data
.HealInterval
:= 36;
4047 trigger
.Data
.ShotType
:= TRIGGER_SHOT_BULLET
;
4048 trigger
.Data
.ShotSound
:= True;
4049 trigger
.Data
.ShotPanelID
:= -1;
4050 trigger
.Data
.ShotTarget
:= 0;
4051 trigger
.Data
.ShotIntSight
:= 0;
4052 trigger
.Data
.ShotAim
:= TRIGGER_SHOT_AIM_DEFAULT
;
4053 trigger
.Data
.ShotPos
.X
:= trigger
.X
-64;
4054 trigger
.Data
.ShotPos
.Y
:= trigger
.Y
-64;
4055 trigger
.Data
.ShotAngle
:= 0;
4056 trigger
.Data
.ShotWait
:= 18;
4057 trigger
.Data
.ShotAccuracy
:= 0;
4058 trigger
.Data
.ShotAmmo
:= 0;
4059 trigger
.Data
.ShotIntReload
:= 0;
4064 trigger
.Data
.FXCount
:= 1;
4065 trigger
.Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
4066 trigger
.Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
4067 trigger
.Data
.FXColorR
:= 0;
4068 trigger
.Data
.FXColorG
:= 0;
4069 trigger
.Data
.FXColorB
:= 255;
4070 trigger
.Data
.FXPos
:= TRIGGER_EFFECT_POS_CENTER
;
4071 trigger
.Data
.FXWait
:= 1;
4072 trigger
.Data
.FXVelX
:= 0;
4073 trigger
.Data
.FXVelY
:= -20;
4074 trigger
.Data
.FXSpreadL
:= 5;
4075 trigger
.Data
.FXSpreadR
:= 5;
4076 trigger
.Data
.FXSpreadU
:= 4;
4077 trigger
.Data
.FXSpreadD
:= 0;
4081 Undo_Add(OBJECT_TRIGGER
, AddTrigger(trigger
));
4084 // Рисовали область триггера "Расширитель":
4085 MOUSEACTION_DRAWPRESS
:
4086 with gTriggers
[SelectedObjects
[GetFirstSelected
].ID
] do
4088 Data
.tX
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
4089 Data
.tY
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
4090 Data
.tWidth
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
4091 Data
.tHeight
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
4093 DrawPressRect
:= False;
4097 MouseAction
:= MOUSEACTION_NONE
;
4099 end // if Button = mbLeft...
4100 else if Button
= mbRight
then // Right Mouse Button:
4102 if MouseAction
= MOUSEACTION_NOACTION
then
4104 MouseAction
:= MOUSEACTION_NONE
;
4108 // Объект передвинут или изменен в размере:
4109 if MouseAction
in [MOUSEACTION_MOVEOBJ
, MOUSEACTION_RESIZE
] then
4111 RenderPanel
.Cursor
:= crDefault
;
4112 MouseAction
:= MOUSEACTION_NONE
;
4117 // Еще не все выбрали:
4118 if SelectFlag
<> SELECTFLAG_NONE
then
4120 if SelectFlag
= SELECTFLAG_SELECTED
then
4121 SelectFlag
:= SELECTFLAG_NONE
;
4126 // Мышь сдвинулась во время удержания клавиши:
4127 if (MousePos
.X
<> MouseRDownPos
.X
) and
4128 (MousePos
.Y
<> MouseRDownPos
.Y
) then
4130 rSelectRect
:= True;
4132 rRect
.X
:= Min(MousePos
.X
, MouseRDownPos
.X
)-MapOffset
.X
;
4133 rRect
.Y
:= Min(MousePos
.Y
, MouseRDownPos
.Y
)-MapOffset
.Y
;
4134 rRect
.Width
:= Abs(MousePos
.X
-MouseRDownPos
.X
);
4135 rRect
.Height
:= Abs(MousePos
.Y
-MouseRDownPos
.Y
);
4137 else // Мышь не сдвинулась - нет прямоугольника:
4139 rSelectRect
:= False;
4141 rRect
.X
:= X
-MapOffset
.X
-1;
4142 rRect
.Y
:= Y
-MapOffset
.Y
-1;
4147 // Если зажат Ctrl - выделять еще, иначе только один выделенный объект:
4148 if not (ssCtrl
in Shift
) then
4149 RemoveSelectFromObjects();
4151 // Выделяем всё в выбранном прямоугольнике:
4152 if (ssCtrl
in Shift
) and (ssAlt
in Shift
) then
4154 SelectObjects(OBJECT_PANEL
);
4155 SelectObjects(OBJECT_ITEM
);
4156 SelectObjects(OBJECT_MONSTER
);
4157 SelectObjects(OBJECT_AREA
);
4158 SelectObjects(OBJECT_TRIGGER
);
4161 SelectObjects(pcObjects
.ActivePageIndex
+1);
4166 else // Middle Mouse Button
4168 RenderPanel
.Cursor
:= crDefault
;
4173 procedure TMainForm
.RenderPanelPaint(Sender
: TObject
);
4178 function TMainForm
.RenderMousePos(): Types
.TPoint
;
4180 Result
:= RenderPanel
.ScreenToClient(Mouse
.CursorPos
);
4183 procedure TMainForm
.RecountSelectedObjects();
4185 if SelectedObjectCount() = 0 then
4186 StatusBar
.Panels
[0].Text := ''
4188 StatusBar
.Panels
[0].Text := Format(MsgCapStatSelected
, [SelectedObjectCount()]);
4191 procedure TMainForm
.RenderPanelMouseMove(Sender
: TObject
;
4192 Shift
: TShiftState
; X
, Y
: Integer);
4195 dWidth
, dHeight
: Integer;
4198 wWidth
, wHeight
: Word;
4200 _id
:= GetFirstSelected();
4203 // Рисуем панель с текстурой, сетка - размеры текстуры:
4204 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and
4205 (lbPanelType
.ItemIndex
in [0..8]) and
4206 (lbTextureList
.ItemIndex
<> -1) and
4207 (not IsSpecialTextureSel()) then
4209 sX
:= StrToIntDef(lTextureWidth
.Caption
, DotStep
);
4210 sY
:= StrToIntDef(lTextureHeight
.Caption
, DotStep
);
4213 // Меняем размер панели с текстурой, сетка - размеры текстуры:
4214 if (MouseAction
= MOUSEACTION_RESIZE
) and
4215 ( (SelectedObjects
[_id
].ObjectType
= OBJECT_PANEL
) and
4216 IsTexturedPanel(gPanels
[SelectedObjects
[_id
].ID
].PanelType
) and
4217 (gPanels
[SelectedObjects
[_id
].ID
].TextureName
<> '') and
4218 (not IsSpecialTexture(gPanels
[SelectedObjects
[_id
].ID
].TextureName
)) ) then
4220 sX
:= gPanels
[SelectedObjects
[_id
].ID
].TextureWidth
;
4221 sY
:= gPanels
[SelectedObjects
[_id
].ID
].TextureHeight
;
4224 // Выравнивание по сетке:
4230 else // Нет выравнивания по сетке:
4236 // Новая позиция мыши:
4238 begin // Зажата левая кнопка мыши
4239 MousePos
.X
:= (Round((X
-MouseLDownPos
.X
)/sX
)*sX
)+MouseLDownPos
.X
;
4240 MousePos
.Y
:= (Round((Y
-MouseLDownPos
.Y
)/sY
)*sY
)+MouseLDownPos
.Y
;
4244 begin // Зажата правая кнопка мыши
4245 MousePos
.X
:= (Round((X
-MouseRDownPos
.X
)/sX
)*sX
)+MouseRDownPos
.X
;
4246 MousePos
.Y
:= (Round((Y
-MouseRDownPos
.Y
)/sY
)*sY
)+MouseRDownPos
.Y
;
4249 begin // Кнопки мыши не зажаты
4250 MousePos
.X
:= Round((-MapOffset
.X
+ X
) / sX
) * sX
+ MapOffset
.X
;
4251 MousePos
.Y
:= Round((-MapOffset
.Y
+ Y
) / sY
) * sY
+ MapOffset
.Y
;
4254 // Зажата только правая кнопка мыши:
4255 if (not MouseLDown
) and (MouseRDown
) and (not MouseMDown
) then
4257 // Рисуем прямоугольник выделения:
4258 if MouseAction
= MOUSEACTION_NONE
then
4260 if DrawRect
= nil then
4262 DrawRect
.Top
:= MouseRDownPos
.y
;
4263 DrawRect
.Left
:= MouseRDownPos
.x
;
4264 DrawRect
.Bottom
:= MousePos
.y
;
4265 DrawRect
.Right
:= MousePos
.x
;
4268 // Двигаем выделенные объекты:
4269 if MouseAction
= MOUSEACTION_MOVEOBJ
then
4271 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
,
4272 MousePos
.X
-LastMovePoint
.X
,
4273 MousePos
.Y
-LastMovePoint
.Y
);
4276 // Меняем размер выделенного объекта:
4277 if MouseAction
= MOUSEACTION_RESIZE
then
4279 if (SelectedObjectCount
= 1) and
4280 (SelectedObjects
[GetFirstSelected
].Live
) then
4282 dWidth
:= MousePos
.X
-LastMovePoint
.X
;
4283 dHeight
:= MousePos
.Y
-LastMovePoint
.Y
;
4286 RESIZETYPE_VERTICAL
: dWidth
:= 0;
4287 RESIZETYPE_HORIZONTAL
: dHeight
:= 0;
4290 case ResizeDirection
of
4291 RESIZEDIR_UP
: dHeight
:= -dHeight
;
4292 RESIZEDIR_LEFT
: dWidth
:= -dWidth
;
4295 if ResizeObject(SelectedObjects
[GetFirstSelected
].ObjectType
,
4296 SelectedObjects
[GetFirstSelected
].ID
,
4297 dWidth
, dHeight
, ResizeDirection
) then
4298 LastMovePoint
:= MousePos
;
4303 // Зажата только левая кнопка мыши:
4304 if (not MouseRDown
) and (MouseLDown
) and (not MouseMDown
) then
4306 // Рисуем прямоугольник планирования панели:
4307 if MouseAction
in [MOUSEACTION_DRAWPANEL
,
4308 MOUSEACTION_DRAWTRIGGER
,
4309 MOUSEACTION_DRAWPRESS
] then
4311 if DrawRect
= nil then
4313 if ssCtrl
in Shift
then
4317 if (lbTextureList
.ItemIndex
<> -1) and (not IsSpecialTextureSel()) and
4318 (MouseAction
= MOUSEACTION_DRAWPANEL
) then
4320 if not g_GetTexture(SelectedTexture(), TextureID
) then
4321 g_GetTexture('NOTEXTURE', TextureID
);
4322 g_GetTextureSizeByID(TextureID
, wWidth
, wHeight
);
4324 DrawRect
.Top
:= MouseLDownPos
.y
;
4325 DrawRect
.Left
:= MouseLDownPos
.x
;
4326 DrawRect
.Bottom
:= DrawRect
.Top
+ wHeight
;
4327 DrawRect
.Right
:= DrawRect
.Left
+ wWidth
;
4331 DrawRect
.Top
:= MouseLDownPos
.y
;
4332 DrawRect
.Left
:= MouseLDownPos
.x
;
4333 DrawRect
.Bottom
:= MousePos
.y
;
4334 DrawRect
.Right
:= MousePos
.x
;
4337 else // Двигаем карту:
4338 if MouseAction
= MOUSEACTION_MOVEMAP
then
4344 // Only Middle Mouse Button is pressed
4345 if (not MouseLDown
) and (not MouseRDown
) and (MouseMDown
) then
4347 MapOffset
.X
:= -EnsureRange(-MapOffset
.X
+ MouseMDownPos
.X
- Mouse
.CursorPos
.X
,
4348 sbHorizontal
.Min
, sbHorizontal
.Max
);
4349 sbHorizontal
.Position
:= -MapOffset
.X
;
4350 MapOffset
.Y
:= -EnsureRange(-MapOffset
.Y
+ MouseMDownPos
.Y
- Mouse
.CursorPos
.Y
,
4351 sbVertical
.Min
, sbVertical
.Max
);
4352 sbVertical
.Position
:= -MapOffset
.Y
;
4353 MouseMDownPos
:= Mouse
.CursorPos
;
4356 // Клавиши мыши не зажаты:
4357 if (not MouseRDown
) and (not MouseLDown
) and (DrawRect
<> nil) then
4363 // Строка состояния - координаты мыши:
4364 StatusBar
.Panels
[1].Text := Format('(%d:%d)',
4365 [MousePos
.X
-MapOffset
.X
, MousePos
.Y
-MapOffset
.Y
]);
4367 RenderPanel
.Invalidate
;
4370 procedure TMainForm
.FormCloseQuery(Sender
: TObject
; var CanClose
: Boolean);
4372 CanClose
:= Application
.MessageBox(PChar(MsgMsgExitPrompt
),
4374 MB_ICONQUESTION
or MB_YESNO
or
4375 MB_DEFBUTTON1
) = idYes
;
4378 procedure TMainForm
.aExitExecute(Sender
: TObject
);
4383 procedure TMainForm
.FormDestroy(Sender
: TObject
);
4389 config
:= TConfig
.CreateFile(CfgFileName
);
4391 config
.WriteInt('WADEditor', 'LogLevel', gWADEditorLogLevel
);
4393 if WindowState
<> wsMaximized
then
4395 config
.WriteInt('Editor', 'XPos', Left
);
4396 config
.WriteInt('Editor', 'YPos', Top
);
4397 config
.WriteInt('Editor', 'Width', Width
);
4398 config
.WriteInt('Editor', 'Height', Height
);
4402 config
.WriteInt('Editor', 'XPos', RestoredLeft
);
4403 config
.WriteInt('Editor', 'YPos', RestoredTop
);
4404 config
.WriteInt('Editor', 'Width', RestoredWidth
);
4405 config
.WriteInt('Editor', 'Height', RestoredHeight
);
4407 config
.WriteBool('Editor', 'Maximize', WindowState
= wsMaximized
);
4408 config
.WriteBool('Editor', 'Minimap', ShowMap
);
4409 config
.WriteInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
4410 config
.WriteInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
4411 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
4412 config
.WriteInt('Editor', 'DotStep', DotStep
);
4413 config
.WriteStr('Editor', 'LastOpenDir', OpenDialog
.InitialDir
);
4414 config
.WriteStr('Editor', 'LastSaveDir', SaveDialog
.InitialDir
);
4415 config
.WriteStr('Editor', 'Language', gLanguage
);
4416 config
.WriteBool('Editor', 'EdgeShow', drEdge
[3] < 255);
4417 config
.WriteInt('Editor', 'EdgeColor', gColorEdge
);
4418 config
.WriteInt('Editor', 'EdgeAlpha', gAlphaEdge
);
4419 config
.WriteInt('Editor', 'LineAlpha', gAlphaTriggerLine
);
4420 config
.WriteInt('Editor', 'TriggerAlpha', gAlphaTriggerArea
);
4421 config
.WriteInt('Editor', 'MonsterRectAlpha', gAlphaMonsterRect
);
4422 config
.WriteInt('Editor', 'AreaRectAlpha', gAlphaAreaRect
);
4424 for i
:= 0 to RecentCount
- 1 do
4426 if i
< RecentFiles
.Count
then s
:= RecentFiles
[i
] else s
:= '';
4428 config
.WriteStr('RecentFilesWin', IntToStr(i
), s
);
4430 config
.WriteStr('RecentFilesUnix', IntToStr(i
), s
);
4435 config
.SaveFile(CfgFileName
);
4438 slInvalidTextures
.Free
;
4441 procedure TMainForm
.FormDropFiles(Sender
: TObject
;
4442 const FileNames
: array of String);
4444 if Length(FileNames
) <> 1 then
4447 OpenMapFile(FileNames
[0]);
4450 procedure TMainForm
.RenderPanelResize(Sender
: TObject
);
4452 if MainForm
.Visible
then
4456 procedure TMainForm
.Splitter1Moved(Sender
: TObject
);
4461 procedure TMainForm
.MapTestCheck(Sender
: TObject
);
4463 if MapTestProcess
<> nil then
4465 if MapTestProcess
.Running
= false then
4467 if MapTestProcess
.ExitCode
<> 0 then
4468 Application
.MessageBox(PChar(MsgMsgExecError
), 'FIXME', MB_OK
or MB_ICONERROR
);
4469 SysUtils
.DeleteFile(MapTestFile
);
4471 FreeAndNil(MapTestProcess
);
4472 tbTestMap
.Enabled
:= True;
4477 procedure TMainForm
.aMapOptionsExecute(Sender
: TObject
);
4481 MapOptionsForm
.ShowModal();
4483 ResName
:= OpenedMap
;
4484 while (Pos(':\', ResName
) > 0) do
4485 Delete(ResName
, 1, Pos(':\', ResName
) + 1);
4487 UpdateCaption(gMapInfo
.Name
, ExtractFileName(OpenedWAD
), ResName
);
4490 procedure TMainForm
.aAboutExecute(Sender
: TObject
);
4492 AboutForm
.ShowModal();
4495 procedure TMainForm
.FormKeyDown(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
4501 if (not EditingProperties
) then
4503 if ssCtrl
in Shift
then
4506 '1': ContourEnabled
[LAYER_BACK
] := not ContourEnabled
[LAYER_BACK
];
4507 '2': ContourEnabled
[LAYER_WALLS
] := not ContourEnabled
[LAYER_WALLS
];
4508 '3': ContourEnabled
[LAYER_FOREGROUND
] := not ContourEnabled
[LAYER_FOREGROUND
];
4509 '4': ContourEnabled
[LAYER_STEPS
] := not ContourEnabled
[LAYER_STEPS
];
4510 '5': ContourEnabled
[LAYER_WATER
] := not ContourEnabled
[LAYER_WATER
];
4511 '6': ContourEnabled
[LAYER_ITEMS
] := not ContourEnabled
[LAYER_ITEMS
];
4512 '7': ContourEnabled
[LAYER_MONSTERS
] := not ContourEnabled
[LAYER_MONSTERS
];
4513 '8': ContourEnabled
[LAYER_AREAS
] := not ContourEnabled
[LAYER_AREAS
];
4514 '9': ContourEnabled
[LAYER_TRIGGERS
] := not ContourEnabled
[LAYER_TRIGGERS
];
4518 for i
:= Low(ContourEnabled
) to High(ContourEnabled
) do
4519 if ContourEnabled
[i
] then
4521 for i
:= Low(ContourEnabled
) to High(ContourEnabled
) do
4522 ContourEnabled
[i
] := not ok
4529 '1': SwitchLayer(LAYER_BACK
);
4530 '2': SwitchLayer(LAYER_WALLS
);
4531 '3': SwitchLayer(LAYER_FOREGROUND
);
4532 '4': SwitchLayer(LAYER_STEPS
);
4533 '5': SwitchLayer(LAYER_WATER
);
4534 '6': SwitchLayer(LAYER_ITEMS
);
4535 '7': SwitchLayer(LAYER_MONSTERS
);
4536 '8': SwitchLayer(LAYER_AREAS
);
4537 '9': SwitchLayer(LAYER_TRIGGERS
);
4538 '0': tbShowClick(tbShow
);
4542 if Key
= Ord('I') then
4543 begin // Поворот монстров и областей:
4544 if (SelectedObjects
<> nil) then
4546 for i
:= 0 to High(SelectedObjects
) do
4547 if (SelectedObjects
[i
].Live
) then
4549 if (SelectedObjects
[i
].ObjectType
= OBJECT_MONSTER
) then
4551 g_ChangeDir(gMonsters
[SelectedObjects
[i
].ID
].Direction
);
4554 if (SelectedObjects
[i
].ObjectType
= OBJECT_AREA
) then
4556 g_ChangeDir(gAreas
[SelectedObjects
[i
].ID
].Direction
);
4562 if pcObjects
.ActivePage
= tsMonsters
then
4564 if rbMonsterLeft
.Checked
then
4565 rbMonsterRight
.Checked
:= True
4567 rbMonsterLeft
.Checked
:= True;
4569 if pcObjects
.ActivePage
= tsAreas
then
4571 if rbAreaLeft
.Checked
then
4572 rbAreaRight
.Checked
:= True
4574 rbAreaLeft
.Checked
:= True;
4579 if not (ssCtrl
in Shift
) then
4581 // Быстрое превью карты:
4582 if Key
= Ord('E') then
4584 if PreviewMode
= 0 then
4588 // Вертикальный скролл карты:
4591 if Key
= Ord('W') then
4594 if ssShift
in Shift
then Position
:= EnsureRange(Position
- DotStep
* 4, Min
, Max
)
4595 else Position
:= EnsureRange(Position
- DotStep
, Min
, Max
);
4596 MapOffset
.Y
:= -Position
;
4599 if (MouseLDown
or MouseRDown
) then
4601 if DrawRect
<> nil then
4603 Inc(MouseLDownPos
.y
, dy
);
4604 Inc(MouseRDownPos
.y
, dy
);
4606 Inc(LastMovePoint
.Y
, dy
);
4607 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4611 if Key
= Ord('S') then
4614 if ssShift
in Shift
then Position
:= EnsureRange(Position
+ DotStep
* 4, Min
, Max
)
4615 else Position
:= EnsureRange(Position
+ DotStep
, Min
, Max
);
4616 MapOffset
.Y
:= -Position
;
4619 if (MouseLDown
or MouseRDown
) then
4621 if DrawRect
<> nil then
4623 Inc(MouseLDownPos
.y
, dy
);
4624 Inc(MouseRDownPos
.y
, dy
);
4626 Inc(LastMovePoint
.Y
, dy
);
4627 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4632 // Горизонтальный скролл карты:
4633 with sbHorizontal
do
4635 if Key
= Ord('A') then
4638 if ssShift
in Shift
then Position
:= EnsureRange(Position
- DotStep
* 4, Min
, Max
)
4639 else Position
:= EnsureRange(Position
- DotStep
, Min
, Max
);
4640 MapOffset
.X
:= -Position
;
4643 if (MouseLDown
or MouseRDown
) then
4645 if DrawRect
<> nil then
4647 Inc(MouseLDownPos
.x
, dx
);
4648 Inc(MouseRDownPos
.x
, dx
);
4650 Inc(LastMovePoint
.X
, dx
);
4651 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4655 if Key
= Ord('D') then
4658 if ssShift
in Shift
then Position
:= EnsureRange(Position
+ DotStep
* 4, Min
, Max
)
4659 else Position
:= EnsureRange(Position
+ DotStep
, Min
, Max
);
4660 MapOffset
.X
:= -Position
;
4663 if (MouseLDown
or MouseRDown
) then
4665 if DrawRect
<> nil then
4667 Inc(MouseLDownPos
.x
, dx
);
4668 Inc(MouseRDownPos
.x
, dx
);
4670 Inc(LastMovePoint
.X
, dx
);
4671 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4676 else // ssCtrl in Shift
4678 if ssShift
in Shift
then
4680 // Вставка по абсолютному смещению:
4681 if Key
= Ord('V') then
4682 aPasteObjectExecute(Sender
);
4684 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);
4688 // Удалить выделенные объекты:
4689 if (Key
= VK_DELETE
) and (SelectedObjects
<> nil) and
4690 RenderPanel
.Focused() then
4691 DeleteSelectedObjects();
4694 if (Key
= VK_ESCAPE
) and (SelectedObjects
<> nil) then
4695 RemoveSelectFromObjects();
4697 // Передвинуть объекты:
4698 if MainForm
.ActiveControl
= RenderPanel
then
4703 if Key
= VK_NUMPAD4
then
4704 dx
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4705 if Key
= VK_NUMPAD6
then
4706 dx
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4707 if Key
= VK_NUMPAD8
then
4708 dy
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4709 if Key
= VK_NUMPAD5
then
4710 dy
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4712 if (dx
<> 0) or (dy
<> 0) then
4714 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
, dx
, dy
);
4719 if ssCtrl
in Shift
then
4721 // Выбор панели с текстурой для триггера
4722 if Key
= Ord('T') then
4724 DrawPressRect
:= False;
4725 if SelectFlag
= SELECTFLAG_TEXTURE
then
4727 SelectFlag
:= SELECTFLAG_NONE
;
4730 vleObjectProperty
.FindRow(MsgPropTrTexturePanel
, i
);
4732 SelectFlag
:= SELECTFLAG_TEXTURE
;
4735 if Key
= Ord('D') then
4737 SelectFlag
:= SELECTFLAG_NONE
;
4738 if DrawPressRect
then
4740 DrawPressRect
:= False;
4745 // Выбор области воздействия, в зависимости от типа триггера
4746 vleObjectProperty
.FindRow(MsgPropTrExArea
, i
);
4749 DrawPressRect
:= True;
4752 vleObjectProperty
.FindRow(MsgPropTrDoorPanel
, i
);
4754 vleObjectProperty
.FindRow(MsgPropTrTrapPanel
, i
);
4757 SelectFlag
:= SELECTFLAG_DOOR
;
4760 vleObjectProperty
.FindRow(MsgPropTrLiftPanel
, i
);
4763 SelectFlag
:= SELECTFLAG_LIFT
;
4766 vleObjectProperty
.FindRow(MsgPropTrTeleportTo
, i
);
4769 SelectFlag
:= SELECTFLAG_TELEPORT
;
4772 vleObjectProperty
.FindRow(MsgPropTrSpawnTo
, i
);
4775 SelectFlag
:= SELECTFLAG_SPAWNPOINT
;
4779 // Выбор основного параметра, в зависимости от типа триггера
4780 vleObjectProperty
.FindRow(MsgPropTrNextMap
, i
);
4783 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
4784 SelectMapForm
.Caption
:= MsgCapSelect
;
4785 SelectMapForm
.GetMaps(FileName
);
4787 if SelectMapForm
.ShowModal() = mrOK
then
4789 vleObjectProperty
.Cells
[1, i
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
4790 bApplyProperty
.Click();
4794 vleObjectProperty
.FindRow(MsgPropTrSoundName
, i
);
4796 vleObjectProperty
.FindRow(MsgPropTrMusicName
, i
);
4799 AddSoundForm
.OKFunction
:= nil;
4800 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
4801 AddSoundForm
.SetResource
:= vleObjectProperty
.Cells
[1, i
];
4803 if (AddSoundForm
.ShowModal() = mrOk
) then
4805 vleObjectProperty
.Cells
[1, i
] := AddSoundForm
.ResourceName
;
4806 bApplyProperty
.Click();
4810 vleObjectProperty
.FindRow(MsgPropTrPushAngle
, i
);
4812 vleObjectProperty
.FindRow(MsgPropTrMessageText
, i
);
4815 vleObjectProperty
.Row
:= i
;
4816 vleObjectProperty
.SetFocus();
4823 procedure TMainForm
.aOptimizeExecute(Sender
: TObject
);
4825 RemoveSelectFromObjects();
4826 MapOptimizationForm
.ShowModal();
4829 procedure TMainForm
.aCheckMapExecute(Sender
: TObject
);
4831 MapCheckForm
.ShowModal();
4834 procedure TMainForm
.bbAddTextureClick(Sender
: TObject
);
4836 AddTextureForm
.lbResourcesList
.MultiSelect
:= True;
4837 AddTextureForm
.ShowModal();
4840 procedure TMainForm
.lbTextureListClick(Sender
: TObject
);
4843 TextureWidth
, TextureHeight
: Word;
4848 if (lbTextureList
.ItemIndex
<> -1) and
4849 (not IsSpecialTextureSel()) then
4851 if g_GetTexture(SelectedTexture(), TextureID
) then
4853 g_GetTextureSizeByID(TextureID
, TextureWidth
, TextureHeight
);
4855 lTextureWidth
.Caption
:= IntToStr(TextureWidth
);
4856 lTextureHeight
.Caption
:= IntToStr(TextureHeight
);
4859 lTextureWidth
.Caption
:= MsgNotAccessible
;
4860 lTextureHeight
.Caption
:= MsgNotAccessible
;
4865 lTextureWidth
.Caption
:= '';
4866 lTextureHeight
.Caption
:= '';
4870 procedure TMainForm
.lbTextureListDrawItem(Control
: TWinControl
; Index
: Integer;
4871 ARect
: TRect
; State
: TOwnerDrawState
);
4873 with Control
as TListBox
do
4875 if LCLType
.odSelected
in State
then
4877 Canvas
.Brush
.Color
:= clHighlight
;
4878 Canvas
.Font
.Color
:= clHighlightText
;
4880 if (Items
<> nil) and (Index
>= 0) then
4881 if slInvalidTextures
.IndexOf(Items
[Index
]) > -1 then
4883 Canvas
.Brush
.Color
:= clRed
;
4884 Canvas
.Font
.Color
:= clWhite
;
4886 Canvas
.FillRect(ARect
);
4887 Canvas
.TextRect(ARect
, ARect
.Left
, ARect
.Top
, Items
[Index
]);
4891 procedure TMainForm
.miMacMinimizeClick(Sender
: TObject
);
4893 self
.WindowState
:= wsMinimized
;
4894 self
.FormWindowStateChange(Sender
);
4897 procedure TMainForm
.miMacZoomClick(Sender
: TObject
);
4899 if self
.WindowState
= wsMaximized
then
4900 self
.WindowState
:= wsNormal
4902 self
.WindowState
:= wsMaximized
;
4903 self
.FormWindowStateChange(Sender
);
4906 procedure TMainForm
.miReopenMapClick(Sender
: TObject
);
4908 FileName
, Resource
: String;
4910 if OpenedMap
= '' then
4913 if Application
.MessageBox(PChar(MsgMsgReopenMapPrompt
),
4914 PChar(MsgMenuFileReopen
), MB_ICONQUESTION
or MB_YESNO
) <> idYes
then
4917 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, @Resource
);
4918 OpenMap(FileName
, Resource
);
4921 procedure TMainForm
.vleObjectPropertyGetPickList(Sender
: TObject
;
4922 const KeyName
: String; Values
: TStrings
);
4924 if vleObjectProperty
.ItemProps
[KeyName
].EditStyle
= esPickList
then
4926 if KeyName
= MsgPropDirection
then
4928 Values
.Add(DirNames
[D_LEFT
]);
4929 Values
.Add(DirNames
[D_RIGHT
]);
4931 else if KeyName
= MsgPropTrTeleportDir
then
4933 Values
.Add(DirNamesAdv
[0]);
4934 Values
.Add(DirNamesAdv
[1]);
4935 Values
.Add(DirNamesAdv
[2]);
4936 Values
.Add(DirNamesAdv
[3]);
4938 else if KeyName
= MsgPropTrMusicAct
then
4940 Values
.Add(MsgPropTrMusicOn
);
4941 Values
.Add(MsgPropTrMusicOff
);
4943 else if KeyName
= MsgPropTrMonsterBehaviour
then
4945 Values
.Add(MsgPropTrMonsterBehaviour0
);
4946 Values
.Add(MsgPropTrMonsterBehaviour1
);
4947 Values
.Add(MsgPropTrMonsterBehaviour2
);
4948 Values
.Add(MsgPropTrMonsterBehaviour3
);
4949 Values
.Add(MsgPropTrMonsterBehaviour4
);
4950 Values
.Add(MsgPropTrMonsterBehaviour5
);
4952 else if KeyName
= MsgPropTrScoreAct
then
4954 Values
.Add(MsgPropTrScoreAct0
);
4955 Values
.Add(MsgPropTrScoreAct1
);
4956 Values
.Add(MsgPropTrScoreAct2
);
4957 Values
.Add(MsgPropTrScoreAct3
);
4959 else if KeyName
= MsgPropTrScoreTeam
then
4961 Values
.Add(MsgPropTrScoreTeam0
);
4962 Values
.Add(MsgPropTrScoreTeam1
);
4963 Values
.Add(MsgPropTrScoreTeam2
);
4964 Values
.Add(MsgPropTrScoreTeam3
);
4966 else if KeyName
= MsgPropTrMessageKind
then
4968 Values
.Add(MsgPropTrMessageKind0
);
4969 Values
.Add(MsgPropTrMessageKind1
);
4971 else if KeyName
= MsgPropTrMessageTo
then
4973 Values
.Add(MsgPropTrMessageTo0
);
4974 Values
.Add(MsgPropTrMessageTo1
);
4975 Values
.Add(MsgPropTrMessageTo2
);
4976 Values
.Add(MsgPropTrMessageTo3
);
4977 Values
.Add(MsgPropTrMessageTo4
);
4978 Values
.Add(MsgPropTrMessageTo5
);
4980 else if KeyName
= MsgPropTrShotTo
then
4982 Values
.Add(MsgPropTrShotTo0
);
4983 Values
.Add(MsgPropTrShotTo1
);
4984 Values
.Add(MsgPropTrShotTo2
);
4985 Values
.Add(MsgPropTrShotTo3
);
4986 Values
.Add(MsgPropTrShotTo4
);
4987 Values
.Add(MsgPropTrShotTo5
);
4988 Values
.Add(MsgPropTrShotTo6
);
4990 else if KeyName
= MsgPropTrShotAim
then
4992 Values
.Add(MsgPropTrShotAim0
);
4993 Values
.Add(MsgPropTrShotAim1
);
4994 Values
.Add(MsgPropTrShotAim2
);
4995 Values
.Add(MsgPropTrShotAim3
);
4997 else if KeyName
= MsgPropTrDamageKind
then
4999 Values
.Add(MsgPropTrDamageKind0
);
5000 Values
.Add(MsgPropTrDamageKind3
);
5001 Values
.Add(MsgPropTrDamageKind4
);
5002 Values
.Add(MsgPropTrDamageKind5
);
5003 Values
.Add(MsgPropTrDamageKind6
);
5004 Values
.Add(MsgPropTrDamageKind7
);
5005 Values
.Add(MsgPropTrDamageKind8
);
5007 else if (KeyName
= MsgPropPanelBlend
) or
5008 (KeyName
= MsgPropDmOnly
) or
5009 (KeyName
= MsgPropItemFalls
) or
5010 (KeyName
= MsgPropTrEnabled
) or
5011 (KeyName
= MsgPropTrD2d
) or
5012 (KeyName
= MsgPropTrSilent
) or
5013 (KeyName
= MsgPropTrTeleportSilent
) or
5014 (KeyName
= MsgPropTrExRandom
) or
5015 (KeyName
= MsgPropTrTextureOnce
) or
5016 (KeyName
= MsgPropTrTextureAnimOnce
) or
5017 (KeyName
= MsgPropTrSoundLocal
) or
5018 (KeyName
= MsgPropTrSoundSwitch
) or
5019 (KeyName
= MsgPropTrMonsterActive
) or
5020 (KeyName
= MsgPropTrPushReset
) or
5021 (KeyName
= MsgPropTrScoreCon
) or
5022 (KeyName
= MsgPropTrScoreMsg
) or
5023 (KeyName
= MsgPropTrHealthMax
) or
5024 (KeyName
= MsgPropTrShotSound
) or
5025 (KeyName
= MsgPropTrEffectCenter
) then
5027 Values
.Add(BoolNames
[True]);
5028 Values
.Add(BoolNames
[False]);
5033 procedure TMainForm
.bApplyPropertyClick(Sender
: TObject
);
5035 _id
, a
, r
, c
: Integer;
5045 if SelectedObjectCount() <> 1 then
5047 if not SelectedObjects
[GetFirstSelected()].Live
then
5051 if not CheckProperty() then
5057 _id
:= GetFirstSelected();
5059 r
:= vleObjectProperty
.Row
;
5060 c
:= vleObjectProperty
.Col
;
5062 case SelectedObjects
[_id
].ObjectType
of
5065 with gPanels
[SelectedObjects
[_id
].ID
] do
5067 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5068 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5069 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropWidth
]));
5070 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropHeight
]));
5072 PanelType
:= GetPanelType(vleObjectProperty
.Values
[MsgPropPanelType
]);
5074 // Сброс ссылки на триггеры смены текстуры:
5075 if not WordBool(PanelType
and (PANEL_WALL
or PANEL_FORE
or PANEL_BACK
)) then
5076 if gTriggers
<> nil then
5077 for a
:= 0 to High(gTriggers
) do
5079 if (gTriggers
[a
].TriggerType
<> 0) and
5080 (gTriggers
[a
].TexturePanel
= Integer(SelectedObjects
[_id
].ID
)) then
5081 gTriggers
[a
].TexturePanel
:= -1;
5082 if (gTriggers
[a
].TriggerType
= TRIGGER_SHOT
) and
5083 (gTriggers
[a
].Data
.ShotPanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5084 gTriggers
[a
].Data
.ShotPanelID
:= -1;
5087 // Сброс ссылки на триггеры лифта:
5088 if not WordBool(PanelType
and (PANEL_LIFTUP
or PANEL_LIFTDOWN
or PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
)) then
5089 if gTriggers
<> nil then
5090 for a
:= 0 to High(gTriggers
) do
5091 if (gTriggers
[a
].TriggerType
in [TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
]) and
5092 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5093 gTriggers
[a
].Data
.PanelID
:= -1;
5095 // Сброс ссылки на триггеры двери:
5096 if not WordBool(PanelType
and (PANEL_OPENDOOR
or PANEL_CLOSEDOOR
)) then
5097 if gTriggers
<> nil then
5098 for a
:= 0 to High(gTriggers
) do
5099 if (gTriggers
[a
].TriggerType
in [TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5100 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
]) and
5101 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
5102 gTriggers
[a
].Data
.PanelID
:= -1;
5104 if IsTexturedPanel(PanelType
) then
5105 begin // Может быть текстура
5106 if TextureName
<> '' then
5107 begin // Была текстура
5108 Alpha
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropPanelAlpha
]));
5109 Blending
:= NameToBool(vleObjectProperty
.Values
[MsgPropPanelBlend
]);
5118 TextureName
:= vleObjectProperty
.Values
[MsgPropPanelTex
];
5120 if TextureName
<> '' then
5121 begin // Есть текстура
5122 // Обычная текстура:
5123 if not IsSpecialTexture(TextureName
) then
5125 g_GetTextureSizeByName(TextureName
,
5126 TextureWidth
, TextureHeight
);
5128 // Проверка кратности размеров панели:
5130 if TextureWidth
<> 0 then
5131 if gPanels
[SelectedObjects
[_id
].ID
].Width
mod TextureWidth
<> 0 then
5133 ErrorMessageBox(Format(MsgMsgWrongTexwidth
,
5137 if Res
and (TextureHeight
<> 0) then
5138 if gPanels
[SelectedObjects
[_id
].ID
].Height
mod TextureHeight
<> 0 then
5140 ErrorMessageBox(Format(MsgMsgWrongTexheight
,
5147 if not g_GetTexture(TextureName
, TextureID
) then
5148 // Не удалось загрузить текстуру, рисуем NOTEXTURE
5149 if g_GetTexture('NOTEXTURE', NoTextureID
) then
5151 TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
5152 g_GetTextureSizeByID(NoTextureID
, NW
, NH
);
5154 TextureHeight
:= NH
;
5157 TextureID
:= TEXTURE_SPECIAL_NONE
;
5167 TextureID
:= TEXTURE_SPECIAL_NONE
;
5170 else // Спец.текстура
5174 TextureID
:= SpecialTextureID(TextureName
);
5177 else // Нет текстуры
5181 TextureID
:= TEXTURE_SPECIAL_NONE
;
5184 else // Не может быть текстуры
5191 TextureID
:= TEXTURE_SPECIAL_NONE
;
5198 with gItems
[SelectedObjects
[_id
].ID
] do
5200 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5201 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5202 OnlyDM
:= NameToBool(vleObjectProperty
.Values
[MsgPropDmOnly
]);
5203 Fall
:= NameToBool(vleObjectProperty
.Values
[MsgPropItemFalls
]);
5209 with gMonsters
[SelectedObjects
[_id
].ID
] do
5211 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5212 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5213 Direction
:= NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]);
5219 with gAreas
[SelectedObjects
[_id
].ID
] do
5221 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5222 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5223 Direction
:= NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]);
5229 with gTriggers
[SelectedObjects
[_id
].ID
] do
5231 X
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropX
]));
5232 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropY
]));
5233 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropWidth
]));
5234 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[MsgPropHeight
]));
5235 Enabled
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrEnabled
]);
5236 ActivateType
:= StrToActivate(vleObjectProperty
.Values
[MsgPropTrActivation
]);
5237 Key
:= StrToKey(vleObjectProperty
.Values
[MsgPropTrKeys
]);
5242 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrNextMap
]);
5243 FillByte(Data
.MapName
[0], 16, 0);
5245 Move(s
[1], Data
.MapName
[0], Min(Length(s
), 16));
5250 Data
.ActivateOnce
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTextureOnce
]);
5251 Data
.AnimOnce
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTextureAnimOnce
]);
5254 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
5256 Data
.Wait
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 65535);
5257 Data
.Count
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExCount
], 0), 65535);
5258 if Data
.Count
< 1 then
5260 if TriggerType
= TRIGGER_PRESS
then
5261 Data
.ExtRandom
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrExRandom
]);
5264 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
, TRIGGER_DOOR5
,
5265 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
, TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
,
5268 Data
.NoSound
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSilent
]);
5269 Data
.d2d_doors
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrD2d
]);
5274 Data
.d2d_teleport
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrD2d
]);
5275 Data
.silent_teleport
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrTeleportSilent
]);
5276 Data
.TlpDir
:= NameToDirAdv(vleObjectProperty
.Values
[MsgPropTrTeleportDir
]);
5281 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrSoundName
]);
5282 FillByte(Data
.SoundName
[0], 64, 0);
5284 Move(s
[1], Data
.SoundName
[0], Min(Length(s
), 64));
5286 Data
.Volume
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundVolume
], 0), 255);
5287 Data
.Pan
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundPan
], 0), 255);
5288 Data
.PlayCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSoundCount
], 0), 255);
5289 Data
.Local
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSoundLocal
]);
5290 Data
.SoundSwitch
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSoundSwitch
]);
5293 TRIGGER_SPAWNMONSTER
:
5295 Data
.MonType
:= StrToMonster(vleObjectProperty
.Values
[MsgPropTrMonsterType
]);
5296 Data
.MonDir
:= Byte(NameToDir(vleObjectProperty
.Values
[MsgPropDirection
]));
5297 Data
.MonHealth
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrHealth
], 0), 1000000);
5298 if Data
.MonHealth
< 0 then
5299 Data
.MonHealth
:= 0;
5300 Data
.MonActive
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrMonsterActive
]);
5301 Data
.MonCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 64);
5302 if Data
.MonCount
< 1 then
5304 Data
.MonEffect
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrFxType
]);
5305 Data
.MonMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnMax
], 0), 65535);
5306 Data
.MonDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnDelay
], 0), 65535);
5308 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour1
then
5310 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour2
then
5312 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour3
then
5314 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour4
then
5316 if vleObjectProperty
.Values
[MsgPropTrMonsterBehaviour
] = MsgPropTrMonsterBehaviour5
then
5322 Data
.ItemType
:= StrToItem(vleObjectProperty
.Values
[MsgPropTrItemType
]);
5323 Data
.ItemOnlyDM
:= NameToBool(vleObjectProperty
.Values
[MsgPropDmOnly
]);
5324 Data
.ItemFalls
:= NameToBool(vleObjectProperty
.Values
[MsgPropItemFalls
]);
5325 Data
.ItemCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 64);
5326 if Data
.ItemCount
< 1 then
5327 Data
.ItemCount
:= 1;
5328 Data
.ItemEffect
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrFxType
]);
5329 Data
.ItemMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnMax
], 0), 65535);
5330 Data
.ItemDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[MsgPropTrSpawnDelay
], 0), 65535);
5335 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrMusicName
]);
5336 FillByte(Data
.MusicName
[0], 64, 0);
5338 Move(s
[1], Data
.MusicName
[0], Min(Length(s
), 64));
5340 if vleObjectProperty
.Values
[MsgPropTrMusicAct
] = MsgPropTrMusicOn
then
5341 Data
.MusicAction
:= 1
5343 Data
.MusicAction
:= 0;
5348 Data
.PushAngle
:= Min(
5349 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrPushAngle
], 0), 360);
5350 Data
.PushForce
:= Min(
5351 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrPushForce
], 0), 255);
5352 Data
.ResetVel
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrPushReset
]);
5357 Data
.ScoreAction
:= 0;
5358 if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct1
then
5359 Data
.ScoreAction
:= 1
5360 else if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct2
then
5361 Data
.ScoreAction
:= 2
5362 else if vleObjectProperty
.Values
[MsgPropTrScoreAct
] = MsgPropTrScoreAct3
then
5363 Data
.ScoreAction
:= 3;
5364 Data
.ScoreCount
:= Min(Max(
5365 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 0), 255);
5366 Data
.ScoreTeam
:= 0;
5367 if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam1
then
5369 else if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam2
then
5371 else if vleObjectProperty
.Values
[MsgPropTrScoreTeam
] = MsgPropTrScoreTeam3
then
5372 Data
.ScoreTeam
:= 3;
5373 Data
.ScoreCon
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrScoreCon
]);
5374 Data
.ScoreMsg
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrScoreMsg
]);
5379 Data
.MessageKind
:= 0;
5380 if vleObjectProperty
.Values
[MsgPropTrMessageKind
] = MsgPropTrMessageKind1
then
5381 Data
.MessageKind
:= 1;
5383 Data
.MessageSendTo
:= 0;
5384 if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo1
then
5385 Data
.MessageSendTo
:= 1
5386 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo2
then
5387 Data
.MessageSendTo
:= 2
5388 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo3
then
5389 Data
.MessageSendTo
:= 3
5390 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo4
then
5391 Data
.MessageSendTo
:= 4
5392 else if vleObjectProperty
.Values
[MsgPropTrMessageTo
] = MsgPropTrMessageTo5
then
5393 Data
.MessageSendTo
:= 5;
5395 s
:= utf2win(vleObjectProperty
.Values
[MsgPropTrMessageText
]);
5396 FillByte(Data
.MessageText
[0], 100, 0);
5398 Move(s
[1], Data
.MessageText
[0], Min(Length(s
), 100));
5400 Data
.MessageTime
:= Min(Max(
5401 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrMessageTime
], 0), 0), 65535);
5406 Data
.DamageValue
:= Min(Max(
5407 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrDamageValue
], 0), 0), 65535);
5408 Data
.DamageInterval
:= Min(Max(
5409 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrInterval
], 0), 0), 65535);
5410 s
:= vleObjectProperty
.Values
[MsgPropTrDamageKind
];
5411 if s
= MsgPropTrDamageKind3
then
5412 Data
.DamageKind
:= 3
5413 else if s
= MsgPropTrDamageKind4
then
5414 Data
.DamageKind
:= 4
5415 else if s
= MsgPropTrDamageKind5
then
5416 Data
.DamageKind
:= 5
5417 else if s
= MsgPropTrDamageKind6
then
5418 Data
.DamageKind
:= 6
5419 else if s
= MsgPropTrDamageKind7
then
5420 Data
.DamageKind
:= 7
5421 else if s
= MsgPropTrDamageKind8
then
5422 Data
.DamageKind
:= 8
5424 Data
.DamageKind
:= 0;
5429 Data
.HealValue
:= Min(Max(
5430 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrHealth
], 0), 0), 65535);
5431 Data
.HealInterval
:= Min(Max(
5432 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrInterval
], 0), 0), 65535);
5433 Data
.HealMax
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrHealthMax
]);
5434 Data
.HealSilent
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrSilent
]);
5439 Data
.ShotType
:= StrToShot(vleObjectProperty
.Values
[MsgPropTrShotType
]);
5440 Data
.ShotSound
:= NameToBool(vleObjectProperty
.Values
[MsgPropTrShotSound
]);
5441 Data
.ShotTarget
:= 0;
5442 if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo1
then
5443 Data
.ShotTarget
:= 1
5444 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo2
then
5445 Data
.ShotTarget
:= 2
5446 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo3
then
5447 Data
.ShotTarget
:= 3
5448 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo4
then
5449 Data
.ShotTarget
:= 4
5450 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo5
then
5451 Data
.ShotTarget
:= 5
5452 else if vleObjectProperty
.Values
[MsgPropTrShotTo
] = MsgPropTrShotTo6
then
5453 Data
.ShotTarget
:= 6;
5454 Data
.ShotIntSight
:= Min(Max(
5455 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotSight
], 0), 0), 65535);
5457 if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim1
then
5459 else if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim2
then
5461 else if vleObjectProperty
.Values
[MsgPropTrShotAim
] = MsgPropTrShotAim3
then
5463 Data
.ShotAngle
:= Min(
5464 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAngle
], 0), 360);
5465 Data
.ShotWait
:= Min(Max(
5466 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 0), 65535);
5467 Data
.ShotAccuracy
:= Min(Max(
5468 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAcc
], 0), 0), 65535);
5469 Data
.ShotAmmo
:= Min(Max(
5470 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotAmmo
], 0), 0), 65535);
5471 Data
.ShotIntReload
:= Min(Max(
5472 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrShotReload
], 0), 0), 65535);
5477 Data
.FXCount
:= Min(Max(
5478 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrCount
], 0), 0), 255);
5479 if vleObjectProperty
.Values
[MsgPropTrEffectType
] = MsgPropTrEffectParticle
then
5481 Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
5482 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
5483 if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectSliquid
then
5484 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
5485 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectLliquid
then
5486 Data
.FXSubType
:= TRIGGER_EFFECT_LLIQUID
5487 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectDliquid
then
5488 Data
.FXSubType
:= TRIGGER_EFFECT_DLIQUID
5489 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectBlood
then
5490 Data
.FXSubType
:= TRIGGER_EFFECT_BLOOD
5491 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectSpark
then
5492 Data
.FXSubType
:= TRIGGER_EFFECT_SPARK
5493 else if vleObjectProperty
.Values
[MsgPropTrEffectSubtype
] = MsgPropTrEffectBubble
then
5494 Data
.FXSubType
:= TRIGGER_EFFECT_BUBBLE
;
5497 Data
.FXType
:= TRIGGER_EFFECT_ANIMATION
;
5498 Data
.FXSubType
:= StrToEffect(vleObjectProperty
.Values
[MsgPropTrEffectSubtype
]);
5501 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectColor
], 0), 0), $FFFFFF);
5502 Data
.FXColorR
:= a
and $FF;
5503 Data
.FXColorG
:= (a
shr 8) and $FF;
5504 Data
.FXColorB
:= (a
shr 16) and $FF;
5505 if NameToBool(vleObjectProperty
.Values
[MsgPropTrEffectCenter
]) then
5509 Data
.FXWait
:= Min(Max(
5510 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrExDelay
], 0), 0), 65535);
5511 Data
.FXVelX
:= Min(Max(
5512 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectVelx
], 0), -128), 127);
5513 Data
.FXVelY
:= Min(Max(
5514 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectVely
], 0), -128), 127);
5515 Data
.FXSpreadL
:= Min(Max(
5516 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpl
], 0), 0), 255);
5517 Data
.FXSpreadR
:= Min(Max(
5518 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpr
], 0), 0), 255);
5519 Data
.FXSpreadU
:= Min(Max(
5520 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpu
], 0), 0), 255);
5521 Data
.FXSpreadD
:= Min(Max(
5522 StrToIntDef(vleObjectProperty
.Values
[MsgPropTrEffectSpd
], 0), 0), 255);
5531 vleObjectProperty
.Row
:= r
;
5532 vleObjectProperty
.Col
:= c
;
5535 procedure TMainForm
.bbRemoveTextureClick(Sender
: TObject
);
5539 i
:= lbTextureList
.ItemIndex
;
5543 if Application
.MessageBox(PChar(Format(MsgMsgDelTexturePrompt
,
5544 [SelectedTexture()])),
5545 PChar(MsgMsgDelTexture
),
5546 MB_ICONQUESTION
or MB_YESNO
or
5547 MB_DEFBUTTON1
) <> idYes
then
5550 if gPanels
<> nil then
5551 for a
:= 0 to High(gPanels
) do
5552 if (gPanels
[a
].PanelType
<> 0) and
5553 (gPanels
[a
].TextureName
= SelectedTexture()) then
5555 ErrorMessageBox(MsgMsgDelTextureCant
);
5559 g_DeleteTexture(SelectedTexture());
5560 i
:= slInvalidTextures
.IndexOf(lbTextureList
.Items
[i
]);
5562 slInvalidTextures
.Delete(i
);
5563 if lbTextureList
.ItemIndex
> -1 then
5564 lbTextureList
.Items
.Delete(lbTextureList
.ItemIndex
)
5567 procedure TMainForm
.aNewMapExecute(Sender
: TObject
);
5569 if Application
.MessageBox(PChar(MsgMsgClearMapPrompt
), PChar(MsgMsgClearMap
), MB_ICONQUESTION
or MB_YESNO
or MB_DEFBUTTON1
) = mrYes
then
5573 procedure TMainForm
.aUndoExecute(Sender
: TObject
);
5577 if UndoBuffer
= nil then
5579 if UndoBuffer
[High(UndoBuffer
)] = nil then
5582 for a
:= 0 to High(UndoBuffer
[High(UndoBuffer
)]) do
5583 with UndoBuffer
[High(UndoBuffer
)][a
] do
5591 UNDO_DELETE_ITEM
: AddItem(Item
);
5592 UNDO_DELETE_AREA
: AddArea(Area
);
5593 UNDO_DELETE_MONSTER
: AddMonster(Monster
);
5594 UNDO_DELETE_TRIGGER
: AddTrigger(Trigger
);
5595 UNDO_ADD_PANEL
: RemoveObject(AddID
, OBJECT_PANEL
);
5596 UNDO_ADD_ITEM
: RemoveObject(AddID
, OBJECT_ITEM
);
5597 UNDO_ADD_AREA
: RemoveObject(AddID
, OBJECT_AREA
);
5598 UNDO_ADD_MONSTER
: RemoveObject(AddID
, OBJECT_MONSTER
);
5599 UNDO_ADD_TRIGGER
: RemoveObject(AddID
, OBJECT_TRIGGER
);
5603 SetLength(UndoBuffer
, Length(UndoBuffer
)-1);
5605 RemoveSelectFromObjects();
5607 miUndo
.Enabled
:= UndoBuffer
<> nil;
5611 procedure TMainForm
.aCopyObjectExecute(Sender
: TObject
);
5614 CopyBuffer
: TCopyRecArray
;
5618 function CB_Compare(I1
, I2
: TCopyRec
): Integer;
5620 Result
:= Integer(I1
.ObjectType
) - Integer(I2
.ObjectType
);
5622 if Result
= 0 then // Одного типа
5623 Result
:= Integer(I1
.ID
) - Integer(I2
.ID
);
5626 procedure QuickSortCopyBuffer(L
, R
: Integer);
5634 P
:= CopyBuffer
[(L
+ R
) shr 1];
5637 while CB_Compare(CopyBuffer
[I
], P
) < 0 do
5639 while CB_Compare(CopyBuffer
[J
], P
) > 0 do
5645 CopyBuffer
[I
] := CopyBuffer
[J
];
5653 QuickSortCopyBuffer(L
, J
);
5660 if SelectedObjects
= nil then
5666 // Копируем объекты:
5667 for a
:= 0 to High(SelectedObjects
) do
5668 if SelectedObjects
[a
].Live
then
5669 with SelectedObjects
[a
] do
5671 SetLength(CopyBuffer
, Length(CopyBuffer
)+1);
5672 b
:= High(CopyBuffer
);
5673 CopyBuffer
[b
].ID
:= ID
;
5674 CopyBuffer
[b
].Panel
:= nil;
5679 CopyBuffer
[b
].ObjectType
:= OBJECT_PANEL
;
5680 New(CopyBuffer
[b
].Panel
);
5681 CopyBuffer
[b
].Panel
^ := gPanels
[ID
];
5686 CopyBuffer
[b
].ObjectType
:= OBJECT_ITEM
;
5687 CopyBuffer
[b
].Item
:= gItems
[ID
];
5692 CopyBuffer
[b
].ObjectType
:= OBJECT_MONSTER
;
5693 CopyBuffer
[b
].Monster
:= gMonsters
[ID
];
5698 CopyBuffer
[b
].ObjectType
:= OBJECT_AREA
;
5699 CopyBuffer
[b
].Area
:= gAreas
[ID
];
5704 CopyBuffer
[b
].ObjectType
:= OBJECT_TRIGGER
;
5705 CopyBuffer
[b
].Trigger
:= gTriggers
[ID
];
5710 // Сортировка по ID:
5711 if CopyBuffer
<> nil then
5713 QuickSortCopyBuffer(0, b
);
5716 // Постановка ссылок триггеров:
5717 for a
:= 0 to Length(CopyBuffer
)-1 do
5718 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
5720 case CopyBuffer
[a
].Trigger
.TriggerType
of
5721 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5722 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5723 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5724 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
5728 for b
:= 0 to Length(CopyBuffer
)-1 do
5729 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5730 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.PanelID
) then
5732 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= b
;
5737 // Этих панелей нет среди копируемых:
5739 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= -1;
5742 TRIGGER_PRESS
, TRIGGER_ON
,
5743 TRIGGER_OFF
, TRIGGER_ONOFF
:
5744 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
5748 for b
:= 0 to Length(CopyBuffer
)-1 do
5749 if (CopyBuffer
[b
].ObjectType
= OBJECT_MONSTER
) and
5750 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1) then
5752 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= b
+1;
5757 // Этих монстров нет среди копируемых:
5759 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= 0;
5763 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
5767 for b
:= 0 to Length(CopyBuffer
)-1 do
5768 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5769 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
) then
5771 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= b
;
5776 // Этих панелей нет среди копируемых:
5778 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= -1;
5782 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
5786 for b
:= 0 to Length(CopyBuffer
)-1 do
5787 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5788 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.TexturePanel
) then
5790 CopyBuffer
[a
].Trigger
.TexturePanel
:= b
;
5795 // Этих панелей нет среди копируемых:
5797 CopyBuffer
[a
].Trigger
.TexturePanel
:= -1;
5802 str
:= CopyBufferToString(CopyBuffer
);
5803 ClipBoard
.AsText
:= str
;
5805 for a
:= 0 to Length(CopyBuffer
)-1 do
5806 if (CopyBuffer
[a
].ObjectType
= OBJECT_PANEL
) and
5807 (CopyBuffer
[a
].Panel
<> nil) then
5808 Dispose(CopyBuffer
[a
].Panel
);
5813 procedure TMainForm
.aPasteObjectExecute(Sender
: TObject
);
5816 CopyBuffer
: TCopyRecArray
;
5818 swad
, ssec
, sres
: String;
5821 xadj
, yadj
: LongInt;
5826 pmin
.X
:= High(pmin
.X
);
5827 pmin
.Y
:= High(pmin
.Y
);
5829 StringToCopyBuffer(ClipBoard
.AsText
, CopyBuffer
, pmin
);
5830 if CopyBuffer
= nil then
5833 rel
:= not(ssShift
in GetKeyShiftState());
5834 h
:= High(CopyBuffer
);
5835 RemoveSelectFromObjects();
5838 pmin
.X
, pmin
.Y
, -MapOffset
.X
-32, -MapOffset
.Y
-32, RenderPanel
.Width
, RenderPanel
.Height
) then
5845 xadj
:= Floor((-pmin
.X
- MapOffset
.X
+ 32) / DotStep
) * DotStep
;
5846 yadj
:= Floor((-pmin
.Y
- MapOffset
.Y
+ 32) / DotStep
) * DotStep
;
5850 with CopyBuffer
[a
] do
5854 if Panel
<> nil then
5862 Panel
^.TextureID
:= TEXTURE_SPECIAL_NONE
;
5863 Panel
^.TextureWidth
:= 1;
5864 Panel
^.TextureHeight
:= 1;
5866 if (Panel
^.PanelType
= PANEL_LIFTUP
) or
5867 (Panel
^.PanelType
= PANEL_LIFTDOWN
) or
5868 (Panel
^.PanelType
= PANEL_LIFTLEFT
) or
5869 (Panel
^.PanelType
= PANEL_LIFTRIGHT
) or
5870 (Panel
^.PanelType
= PANEL_BLOCKMON
) or
5871 (Panel
^.TextureName
= '') then
5872 begin // Нет или не может быть текстуры:
5874 else // Есть текстура:
5876 // Обычная текстура:
5877 if not IsSpecialTexture(Panel
^.TextureName
) then
5879 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5883 g_ProcessResourceStr(Panel
^.TextureName
, swad
, ssec
, sres
);
5884 AddTexture(swad
, ssec
, sres
, True);
5885 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5889 g_GetTextureSizeByName(Panel
^.TextureName
,
5890 Panel
^.TextureWidth
, Panel
^.TextureHeight
)
5892 if g_GetTexture('NOTEXTURE', NoTextureID
) then
5894 Panel
^.TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
5895 g_GetTextureSizeByID(NoTextureID
, Panel
^.TextureWidth
, Panel
^.TextureHeight
);
5898 else // Спец.текстура:
5900 Panel
^.TextureID
:= SpecialTextureID(Panel
^.TextureName
);
5901 with MainForm
.lbTextureList
.Items
do
5902 if IndexOf(Panel
^.TextureName
) = -1 then
5903 Add(Panel
^.TextureName
);
5907 ID
:= AddPanel(Panel
^);
5909 Undo_Add(OBJECT_PANEL
, ID
, a
> 0);
5910 SelectObject(OBJECT_PANEL
, ID
, True);
5921 ID
:= AddItem(Item
);
5922 Undo_Add(OBJECT_ITEM
, ID
, a
> 0);
5923 SelectObject(OBJECT_ITEM
, ID
, True);
5934 ID
:= AddMonster(Monster
);
5935 Undo_Add(OBJECT_MONSTER
, ID
, a
> 0);
5936 SelectObject(OBJECT_MONSTER
, ID
, True);
5947 ID
:= AddArea(Area
);
5948 Undo_Add(OBJECT_AREA
, ID
, a
> 0);
5949 SelectObject(OBJECT_AREA
, ID
, True);
5963 Data
.TargetPoint
.X
+= xadj
;
5964 Data
.TargetPoint
.Y
+= yadj
;
5966 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
5971 TRIGGER_SPAWNMONSTER
:
5973 Data
.MonPos
.X
+= xadj
;
5974 Data
.MonPos
.Y
+= yadj
;
5978 Data
.ItemPos
.X
+= xadj
;
5979 Data
.ItemPos
.Y
+= yadj
;
5983 Data
.ShotPos
.X
+= xadj
;
5984 Data
.ShotPos
.Y
+= yadj
;
5989 ID
:= AddTrigger(Trigger
);
5990 Undo_Add(OBJECT_TRIGGER
, ID
, a
> 0);
5991 SelectObject(OBJECT_TRIGGER
, ID
, True);
5996 // Переставляем ссылки триггеров:
5997 for a
:= 0 to High(CopyBuffer
) do
5998 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
6000 case CopyBuffer
[a
].Trigger
.TriggerType
of
6001 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
6002 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6003 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6004 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
6005 gTriggers
[CopyBuffer
[a
].ID
].Data
.PanelID
:=
6006 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.PanelID
].ID
;
6008 TRIGGER_PRESS
, TRIGGER_ON
,
6009 TRIGGER_OFF
, TRIGGER_ONOFF
:
6010 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
6011 gTriggers
[CopyBuffer
[a
].ID
].Data
.MonsterID
:=
6012 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1].ID
+1;
6015 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
6016 gTriggers
[CopyBuffer
[a
].ID
].Data
.ShotPanelID
:=
6017 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
].ID
;
6020 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
6021 gTriggers
[CopyBuffer
[a
].ID
].TexturePanel
:=
6022 CopyBuffer
[CopyBuffer
[a
].Trigger
.TexturePanel
].ID
;
6031 procedure TMainForm
.aCutObjectExecute(Sender
: TObject
);
6034 DeleteSelectedObjects();
6037 procedure TMainForm
.vleObjectPropertyEditButtonClick(Sender
: TObject
);
6039 Key
, FileName
: String;
6042 Key
:= vleObjectProperty
.Keys
[vleObjectProperty
.Row
];
6044 if Key
= MsgPropPanelType
then
6046 with ChooseTypeForm
, vleObjectProperty
do
6047 begin // Выбор типа панели:
6048 Caption
:= MsgPropPanelType
;
6049 lbTypeSelect
.Items
.Clear();
6051 for b
:= 0 to High(PANELNAMES
) do
6053 lbTypeSelect
.Items
.Add(PANELNAMES
[b
]);
6054 if Values
[Key
] = PANELNAMES
[b
] then
6055 lbTypeSelect
.ItemIndex
:= b
;
6058 if ShowModal() = mrOK
then
6060 b
:= lbTypeSelect
.ItemIndex
;
6061 Values
[Key
] := PANELNAMES
[b
];
6062 vleObjectPropertyApply(Sender
);
6066 else if Key
= MsgPropTrTeleportTo
then
6067 SelectFlag
:= SELECTFLAG_TELEPORT
6068 else if Key
= MsgPropTrSpawnTo
then
6069 SelectFlag
:= SELECTFLAG_SPAWNPOINT
6070 else if (Key
= MsgPropTrDoorPanel
) or
6071 (Key
= MsgPropTrTrapPanel
) then
6072 SelectFlag
:= SELECTFLAG_DOOR
6073 else if Key
= MsgPropTrTexturePanel
then
6075 DrawPressRect
:= False;
6076 SelectFlag
:= SELECTFLAG_TEXTURE
;
6078 else if Key
= MsgPropTrShotPanel
then
6079 SelectFlag
:= SELECTFLAG_SHOTPANEL
6080 else if Key
= MsgPropTrLiftPanel
then
6081 SelectFlag
:= SELECTFLAG_LIFT
6082 else if key
= MsgPropTrExMonster
then
6083 SelectFlag
:= SELECTFLAG_MONSTER
6084 else if Key
= MsgPropTrExArea
then
6086 SelectFlag
:= SELECTFLAG_NONE
;
6087 DrawPressRect
:= True;
6089 else if Key
= MsgPropTrNextMap
then
6090 begin // Выбор следующей карты:
6091 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
6092 SelectMapForm
.Caption
:= MsgCapSelect
;
6093 SelectMapForm
.GetMaps(FileName
);
6095 if SelectMapForm
.ShowModal() = mrOK
then
6097 vleObjectProperty
.Values
[Key
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
6098 vleObjectPropertyApply(Sender
);
6101 else if (Key
= MsgPropTrSoundName
) or
6102 (Key
= MsgPropTrMusicName
) then
6103 begin // Выбор файла звука/музыки:
6104 AddSoundForm
.OKFunction
:= nil;
6105 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
6106 AddSoundForm
.SetResource
:= vleObjectProperty
.Values
[Key
];
6108 if (AddSoundForm
.ShowModal() = mrOk
) then
6110 vleObjectProperty
.Values
[Key
] := AddSoundForm
.ResourceName
;
6111 vleObjectPropertyApply(Sender
);
6114 else if Key
= MsgPropTrActivation
then
6115 with ActivationTypeForm
, vleObjectProperty
do
6116 begin // Выбор типов активации:
6117 cbPlayerCollide
.Checked
:= Pos('PC', Values
[Key
]) > 0;
6118 cbMonsterCollide
.Checked
:= Pos('MC', Values
[Key
]) > 0;
6119 cbPlayerPress
.Checked
:= Pos('PP', Values
[Key
]) > 0;
6120 cbMonsterPress
.Checked
:= Pos('MP', Values
[Key
]) > 0;
6121 cbShot
.Checked
:= Pos('SH', Values
[Key
]) > 0;
6122 cbNoMonster
.Checked
:= Pos('NM', Values
[Key
]) > 0;
6124 if ShowModal() = mrOK
then
6127 if cbPlayerCollide
.Checked
then
6128 b
:= ACTIVATE_PLAYERCOLLIDE
;
6129 if cbMonsterCollide
.Checked
then
6130 b
:= b
or ACTIVATE_MONSTERCOLLIDE
;
6131 if cbPlayerPress
.Checked
then
6132 b
:= b
or ACTIVATE_PLAYERPRESS
;
6133 if cbMonsterPress
.Checked
then
6134 b
:= b
or ACTIVATE_MONSTERPRESS
;
6135 if cbShot
.Checked
then
6136 b
:= b
or ACTIVATE_SHOT
;
6137 if cbNoMonster
.Checked
then
6138 b
:= b
or ACTIVATE_NOMONSTER
;
6140 Values
[Key
] := ActivateToStr(b
);
6141 vleObjectPropertyApply(Sender
);
6144 else if Key
= MsgPropTrKeys
then
6145 with KeysForm
, vleObjectProperty
do
6146 begin // Выбор необходимых ключей:
6147 cbRedKey
.Checked
:= Pos('RK', Values
[Key
]) > 0;
6148 cbGreenKey
.Checked
:= Pos('GK', Values
[Key
]) > 0;
6149 cbBlueKey
.Checked
:= Pos('BK', Values
[Key
]) > 0;
6150 cbRedTeam
.Checked
:= Pos('RT', Values
[Key
]) > 0;
6151 cbBlueTeam
.Checked
:= Pos('BT', Values
[Key
]) > 0;
6153 if ShowModal() = mrOK
then
6156 if cbRedKey
.Checked
then
6158 if cbGreenKey
.Checked
then
6159 b
:= b
or KEY_GREEN
;
6160 if cbBlueKey
.Checked
then
6162 if cbRedTeam
.Checked
then
6163 b
:= b
or KEY_REDTEAM
;
6164 if cbBlueTeam
.Checked
then
6165 b
:= b
or KEY_BLUETEAM
;
6167 Values
[Key
] := KeyToStr(b
);
6168 vleObjectPropertyApply(Sender
);
6171 else if Key
= MsgPropTrFxType
then
6172 with ChooseTypeForm
, vleObjectProperty
do
6173 begin // Выбор типа эффекта:
6174 Caption
:= MsgCapFxType
;
6175 lbTypeSelect
.Items
.Clear();
6177 for b
:= EFFECT_NONE
to EFFECT_FIRE
do
6178 lbTypeSelect
.Items
.Add(EffectToStr(b
));
6180 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]);
6182 if ShowModal() = mrOK
then
6184 b
:= lbTypeSelect
.ItemIndex
;
6185 Values
[Key
] := EffectToStr(b
);
6186 vleObjectPropertyApply(Sender
);
6189 else if Key
= MsgPropTrMonsterType
then
6190 with ChooseTypeForm
, vleObjectProperty
do
6191 begin // Выбор типа монстра:
6192 Caption
:= MsgCapMonsterType
;
6193 lbTypeSelect
.Items
.Clear();
6195 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
6196 lbTypeSelect
.Items
.Add(MonsterToStr(b
));
6198 lbTypeSelect
.ItemIndex
:= StrToMonster(Values
[Key
]) - MONSTER_DEMON
;
6200 if ShowModal() = mrOK
then
6202 b
:= lbTypeSelect
.ItemIndex
+ MONSTER_DEMON
;
6203 Values
[Key
] := MonsterToStr(b
);
6204 vleObjectPropertyApply(Sender
);
6207 else if Key
= MsgPropTrItemType
then
6208 with ChooseTypeForm
, vleObjectProperty
do
6209 begin // Выбор типа предмета:
6210 Caption
:= MsgCapItemType
;
6211 lbTypeSelect
.Items
.Clear();
6213 for b
:= ITEM_MEDKIT_SMALL
to ITEM_KEY_BLUE
do
6214 lbTypeSelect
.Items
.Add(ItemToStr(b
));
6215 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_BOTTLE
));
6216 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_HELMET
));
6217 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_JETPACK
));
6218 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_INVIS
));
6219 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_WEAPON_FLAMETHROWER
));
6220 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_AMMO_FUELCAN
));
6222 b
:= StrToItem(Values
[Key
]);
6223 if b
>= ITEM_BOTTLE
then
6225 lbTypeSelect
.ItemIndex
:= b
- ITEM_MEDKIT_SMALL
;
6227 if ShowModal() = mrOK
then
6229 b
:= lbTypeSelect
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
6230 if b
>= ITEM_WEAPON_KASTET
then
6232 Values
[Key
] := ItemToStr(b
);
6233 vleObjectPropertyApply(Sender
);
6236 else if Key
= MsgPropTrShotType
then
6237 with ChooseTypeForm
, vleObjectProperty
do
6238 begin // Выбор типа предмета:
6239 Caption
:= MsgPropTrShotType
;
6240 lbTypeSelect
.Items
.Clear();
6242 for b
:= TRIGGER_SHOT_PISTOL
to TRIGGER_SHOT_MAX
do
6243 lbTypeSelect
.Items
.Add(ShotToStr(b
));
6245 lbTypeSelect
.ItemIndex
:= StrToShot(Values
[Key
]);
6247 if ShowModal() = mrOK
then
6249 b
:= lbTypeSelect
.ItemIndex
;
6250 Values
[Key
] := ShotToStr(b
);
6251 vleObjectPropertyApply(Sender
);
6254 else if Key
= MsgPropTrEffectType
then
6255 with ChooseTypeForm
, vleObjectProperty
do
6256 begin // Выбор типа эффекта:
6257 Caption
:= MsgCapFxType
;
6258 lbTypeSelect
.Items
.Clear();
6260 lbTypeSelect
.Items
.Add(MsgPropTrEffectParticle
);
6261 lbTypeSelect
.Items
.Add(MsgPropTrEffectAnimation
);
6262 if Values
[Key
] = MsgPropTrEffectAnimation
then
6263 lbTypeSelect
.ItemIndex
:= 1
6265 lbTypeSelect
.ItemIndex
:= 0;
6267 if ShowModal() = mrOK
then
6269 b
:= lbTypeSelect
.ItemIndex
;
6271 Values
[Key
] := MsgPropTrEffectParticle
6273 Values
[Key
] := MsgPropTrEffectAnimation
;
6274 vleObjectPropertyApply(Sender
);
6277 else if Key
= MsgPropTrEffectSubtype
then
6278 with ChooseTypeForm
, vleObjectProperty
do
6279 begin // Выбор подтипа эффекта:
6280 Caption
:= MsgCapFxType
;
6281 lbTypeSelect
.Items
.Clear();
6283 if Values
[MsgPropTrEffectType
] = MsgPropTrEffectAnimation
then
6285 for b
:= EFFECT_TELEPORT
to EFFECT_FIRE
do
6286 lbTypeSelect
.Items
.Add(EffectToStr(b
));
6288 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]) - 1;
6291 lbTypeSelect
.Items
.Add(MsgPropTrEffectSliquid
);
6292 lbTypeSelect
.Items
.Add(MsgPropTrEffectLliquid
);
6293 lbTypeSelect
.Items
.Add(MsgPropTrEffectDliquid
);
6294 lbTypeSelect
.Items
.Add(MsgPropTrEffectBlood
);
6295 lbTypeSelect
.Items
.Add(MsgPropTrEffectSpark
);
6296 lbTypeSelect
.Items
.Add(MsgPropTrEffectBubble
);
6297 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SLIQUID
;
6298 if Values
[Key
] = MsgPropTrEffectLliquid
then
6299 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_LLIQUID
;
6300 if Values
[Key
] = MsgPropTrEffectDliquid
then
6301 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_DLIQUID
;
6302 if Values
[Key
] = MsgPropTrEffectBlood
then
6303 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BLOOD
;
6304 if Values
[Key
] = MsgPropTrEffectSpark
then
6305 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SPARK
;
6306 if Values
[Key
] = MsgPropTrEffectBubble
then
6307 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BUBBLE
;
6310 if ShowModal() = mrOK
then
6312 b
:= lbTypeSelect
.ItemIndex
;
6314 if Values
[MsgPropTrEffectType
] = MsgPropTrEffectAnimation
then
6315 Values
[Key
] := EffectToStr(b
+ 1)
6317 Values
[Key
] := MsgPropTrEffectSliquid
;
6318 if b
= TRIGGER_EFFECT_LLIQUID
then
6319 Values
[Key
] := MsgPropTrEffectLliquid
;
6320 if b
= TRIGGER_EFFECT_DLIQUID
then
6321 Values
[Key
] := MsgPropTrEffectDliquid
;
6322 if b
= TRIGGER_EFFECT_BLOOD
then
6323 Values
[Key
] := MsgPropTrEffectBlood
;
6324 if b
= TRIGGER_EFFECT_SPARK
then
6325 Values
[Key
] := MsgPropTrEffectSpark
;
6326 if b
= TRIGGER_EFFECT_BUBBLE
then
6327 Values
[Key
] := MsgPropTrEffectBubble
;
6330 vleObjectPropertyApply(Sender
);
6333 else if Key
= MsgPropTrEffectColor
then
6334 with vleObjectProperty
do
6335 begin // Выбор цвета эффекта:
6336 ColorDialog
.Color
:= StrToIntDef(Values
[Key
], 0);
6337 if ColorDialog
.Execute
then
6339 Values
[Key
] := IntToStr(ColorDialog
.Color
);
6340 vleObjectPropertyApply(Sender
);
6343 else if Key
= MsgPropPanelTex
then
6344 begin // Смена текстуры:
6345 vleObjectProperty
.Values
[Key
] := SelectedTexture();
6346 vleObjectPropertyApply(Sender
);
6350 procedure TMainForm
.vleObjectPropertyApply(Sender
: TObject
);
6352 // hack to prevent empty ID in list
6353 RenderPanel
.SetFocus();
6354 bApplyProperty
.Click();
6355 vleObjectProperty
.SetFocus();
6358 procedure TMainForm
.aSaveMapExecute(Sender
: TObject
);
6360 FileName
, Section
, Res
: String;
6362 if OpenedMap
= '' then
6364 aSaveMapAsExecute(nil);
6368 g_ProcessResourceStr(OpenedMap
, FileName
, Section
, Res
);
6370 SaveMap(FileName
+':\'+Res
, '');
6373 procedure TMainForm
.aOpenMapExecute(Sender
: TObject
);
6375 OpenDialog
.Filter
:= MsgFileFilterAll
;
6377 if OpenDialog
.Execute() then
6379 OpenMapFile(OpenDialog
.FileName
);
6380 OpenDialog
.InitialDir
:= ExtractFileDir(OpenDialog
.FileName
);
6384 procedure TMainForm
.OpenMapFile(FileName
: String);
6386 if (Pos('.ini', LowerCase(ExtractFileName(FileName
))) > 0) then
6390 pLoadProgress
.Left
:= (RenderPanel
.Width
div 2)-(pLoadProgress
.Width
div 2);
6391 pLoadProgress
.Top
:= (RenderPanel
.Height
div 2)-(pLoadProgress
.Height
div 2);
6392 pLoadProgress
.Show();
6397 LoadMapOld(FileName
);
6399 MainForm
.Caption
:= Format('%s - %s', [FormCaption
, ExtractFileName(FileName
)]);
6401 pLoadProgress
.Hide();
6402 MainForm
.FormResize(Self
);
6404 else // Карты из WAD:
6406 OpenMap(FileName
, '');
6410 procedure TMainForm
.FormActivate(Sender
: TObject
);
6412 MainForm
.ActiveControl
:= RenderPanel
;
6415 procedure TMainForm
.aDeleteMap(Sender
: TObject
);
6423 OpenDialog
.Filter
:= MsgFileFilterWad
;
6425 if not OpenDialog
.Execute() then
6428 WAD
:= TWADEditor_1
.Create();
6430 if not WAD
.ReadFile(OpenDialog
.FileName
) then
6438 MapList
:= WAD
.GetResourcesList('');
6440 SelectMapForm
.Caption
:= MsgCapRemove
;
6441 SelectMapForm
.lbMapList
.Items
.Clear();
6443 if MapList
<> nil then
6444 for a
:= 0 to High(MapList
) do
6445 SelectMapForm
.lbMapList
.Items
.Add(win2utf(MapList
[a
]));
6447 if (SelectMapForm
.ShowModal() = mrOK
) then
6449 str
:= SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
6451 Move(str
[1], MapName
[0], Min(16, Length(str
)));
6453 if Application
.MessageBox(PChar(Format(MsgMsgDeleteMapPrompt
, [MapName
, OpenDialog
.FileName
])), PChar(MsgMsgDeleteMap
), MB_ICONQUESTION
or MB_YESNO
or MB_DEFBUTTON2
) <> mrYes
then
6456 WAD
.RemoveResource('', utf2win(MapName
));
6458 Application
.MessageBox(
6459 PChar(Format(MsgMsgMapDeletedPrompt
, [MapName
])),
6460 PChar(MsgMsgMapDeleted
),
6461 MB_ICONINFORMATION
or MB_OK
or MB_DEFBUTTON1
6464 WAD
.SaveTo(OpenDialog
.FileName
);
6466 // Удалили текущую карту - сохранять по старому ее нельзя:
6467 if OpenedMap
= (OpenDialog
.FileName
+':\'+MapName
) then
6471 MainForm
.Caption
:= FormCaption
;
6478 procedure TMainForm
.vleObjectPropertyKeyDown(Sender
: TObject
;
6479 var Key
: Word; Shift
: TShiftState
);
6481 if Key
= VK_RETURN
then
6482 vleObjectPropertyApply(Sender
);
6485 procedure MovePanel(var ID
: DWORD
; MoveType
: Byte);
6490 if (ID
= 0) and (MoveType
= 0) then
6492 if (ID
= DWORD(High(gPanels
))) and (MoveType
<> 0) then
6494 if (ID
> DWORD(High(gPanels
))) then
6499 if MoveType
= 0 then // to Back
6501 if gTriggers
<> nil then
6502 for a
:= 0 to High(gTriggers
) do
6503 with gTriggers
[a
] do
6505 if TriggerType
= TRIGGER_NONE
then
6508 if TexturePanel
= _id
then
6511 if (TexturePanel
>= 0) and (TexturePanel
< _id
) then
6515 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
6516 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6517 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6518 if Data
.PanelID
= _id
then
6521 if (Data
.PanelID
>= 0) and (Data
.PanelID
< _id
) then
6525 if Data
.ShotPanelID
= _id
then
6526 Data
.ShotPanelID
:= 0
6528 if (Data
.ShotPanelID
>= 0) and (Data
.ShotPanelID
< _id
) then
6529 Inc(Data
.ShotPanelID
);
6533 tmp
:= gPanels
[_id
];
6535 for a
:= _id
downto 1 do
6536 gPanels
[a
] := gPanels
[a
-1];
6544 if gTriggers
<> nil then
6545 for a
:= 0 to High(gTriggers
) do
6546 with gTriggers
[a
] do
6548 if TriggerType
= TRIGGER_NONE
then
6551 if TexturePanel
= _id
then
6552 TexturePanel
:= High(gPanels
)
6554 if TexturePanel
> _id
then
6558 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
6559 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6560 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6561 if Data
.PanelID
= _id
then
6562 Data
.PanelID
:= High(gPanels
)
6564 if Data
.PanelID
> _id
then
6568 if Data
.ShotPanelID
= _id
then
6569 Data
.ShotPanelID
:= High(gPanels
)
6571 if Data
.ShotPanelID
> _id
then
6572 Dec(Data
.ShotPanelID
);
6576 tmp
:= gPanels
[_id
];
6578 for a
:= _id
to High(gPanels
)-1 do
6579 gPanels
[a
] := gPanels
[a
+1];
6581 gPanels
[High(gPanels
)] := tmp
;
6583 ID
:= High(gPanels
);
6587 procedure TMainForm
.aMoveToBack(Sender
: TObject
);
6591 if SelectedObjects
= nil then
6594 for a
:= 0 to High(SelectedObjects
) do
6595 with SelectedObjects
[a
] do
6596 if Live
and (ObjectType
= OBJECT_PANEL
) then
6598 SelectedObjects
[0] := SelectedObjects
[a
];
6599 SetLength(SelectedObjects
, 1);
6606 procedure TMainForm
.aMoveToFore(Sender
: TObject
);
6610 if SelectedObjects
= nil then
6613 for a
:= 0 to High(SelectedObjects
) do
6614 with SelectedObjects
[a
] do
6615 if Live
and (ObjectType
= OBJECT_PANEL
) then
6617 SelectedObjects
[0] := SelectedObjects
[a
];
6618 SetLength(SelectedObjects
, 1);
6625 procedure TMainForm
.aSaveMapAsExecute(Sender
: TObject
);
6626 var i
, idx
: Integer; list
: TStringList
; fmt
: String;
6628 list
:= TStringList
.Create();
6630 // TODO: get loclized strings automatically from language files
6631 SaveDialog
.DefaultExt
:= '.dfz';
6632 SaveDialog
.FilterIndex
:= 1;
6633 SaveDialog
.Filter
:= '';
6634 gWADEditorFactory
.GetRegistredEditors(list
);
6635 for i
:= 0 to list
.Count
- 1 do
6637 if list
[i
] = 'DFZIP' then
6638 SaveDialog
.FilterIndex
:= i
+ 1;
6641 SaveDialog
.Filter
:= SaveDialog
.Filter
+ '|';
6643 if list
[i
] = 'DFWAD' then
6644 SaveDialog
.Filter
:= SaveDialog
.Filter
+ MsgFileFilterSaveDFWAD
6645 else if list
[i
] = 'DFZIP' then
6646 SaveDialog
.Filter
:= SaveDialog
.Filter
+ MsgFileFilterSaveDFZIP
6648 SaveDialog
.Filter
:= SaveDialog
.Filter
+ list
[i
] + '|*.*';
6651 if SaveDialog
.Execute() then
6653 i
:= SaveDialog
.FilterIndex
- 1;
6654 if (i
>= 0) and (i
< list
.Count
) then fmt
:= list
[i
] else fmt
:= '';
6656 SaveMapForm
.GetMaps(SaveDialog
.FileName
, True, fmt
);
6657 if SaveMapForm
.ShowModal() = mrOK
then
6659 SaveDialog
.InitialDir
:= ExtractFileDir(SaveDialog
.FileName
);
6660 OpenedMap
:= SaveDialog
.FileName
+':\'+SaveMapForm
.eMapName
.Text;
6661 OpenedWAD
:= SaveDialog
.FileName
;
6663 idx
:= RecentFiles
.IndexOf(OpenedMap
);
6664 // Такая карта уже недавно открывалась:
6666 RecentFiles
.Delete(idx
);
6667 RecentFiles
.Insert(0, OpenedMap
);
6670 SaveMap(OpenedMap
, fmt
);
6672 gMapInfo
.FileName
:= SaveDialog
.FileName
;
6673 gMapInfo
.MapName
:= SaveMapForm
.eMapName
.Text;
6674 UpdateCaption(gMapInfo
.Name
, ExtractFileName(gMapInfo
.FileName
), gMapInfo
.MapName
);
6681 procedure TMainForm
.aSelectAllExecute(Sender
: TObject
);
6685 RemoveSelectFromObjects();
6687 case pcObjects
.ActivePageIndex
+1 of
6689 if gPanels
<> nil then
6690 for a
:= 0 to High(gPanels
) do
6691 if gPanels
[a
].PanelType
<> PANEL_NONE
then
6692 SelectObject(OBJECT_PANEL
, a
, True);
6694 if gItems
<> nil then
6695 for a
:= 0 to High(gItems
) do
6696 if gItems
[a
].ItemType
<> ITEM_NONE
then
6697 SelectObject(OBJECT_ITEM
, a
, True);
6699 if gMonsters
<> nil then
6700 for a
:= 0 to High(gMonsters
) do
6701 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
6702 SelectObject(OBJECT_MONSTER
, a
, True);
6704 if gAreas
<> nil then
6705 for a
:= 0 to High(gAreas
) do
6706 if gAreas
[a
].AreaType
<> AREA_NONE
then
6707 SelectObject(OBJECT_AREA
, a
, True);
6709 if gTriggers
<> nil then
6710 for a
:= 0 to High(gTriggers
) do
6711 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
6712 SelectObject(OBJECT_TRIGGER
, a
, True);
6715 RecountSelectedObjects();
6718 procedure TMainForm
.tbGridOnClick(Sender
: TObject
);
6720 DotEnable
:= not DotEnable
;
6721 (Sender
as TToolButton
).Down
:= DotEnable
;
6724 procedure TMainForm
.OnIdle(Sender
: TObject
; var Done
: Boolean);
6728 // TODO: move refresh to user actions (ask to repaint only when something changed)
6729 if GetTickCount64() - LastDrawTime
>= 1000 div MaxFPS
then
6734 if StartMap
<> '' then
6742 procedure TMainForm
.miMapPreviewClick(Sender
: TObject
);
6744 if PreviewMode
= 2 then
6747 if PreviewMode
= 0 then
6749 Splitter2
.Visible
:= False;
6750 Splitter1
.Visible
:= False;
6751 StatusBar
.Visible
:= False;
6752 PanelObjs
.Visible
:= False;
6753 PanelProps
.Visible
:= False;
6754 MainToolBar
.Visible
:= False;
6755 sbHorizontal
.Visible
:= False;
6756 sbVertical
.Visible
:= False;
6760 StatusBar
.Visible
:= True;
6761 PanelObjs
.Visible
:= True;
6762 PanelProps
.Visible
:= True;
6763 Splitter2
.Visible
:= True;
6764 Splitter1
.Visible
:= True;
6765 MainToolBar
.Visible
:= True;
6766 sbHorizontal
.Visible
:= True;
6767 sbVertical
.Visible
:= True;
6770 PreviewMode
:= PreviewMode
xor 1;
6771 (Sender
as TMenuItem
).Checked
:= PreviewMode
> 0;
6776 procedure TMainForm
.miLayer1Click(Sender
: TObject
);
6778 SwitchLayer(LAYER_BACK
);
6781 procedure TMainForm
.miLayer2Click(Sender
: TObject
);
6783 SwitchLayer(LAYER_WALLS
);
6786 procedure TMainForm
.miLayer3Click(Sender
: TObject
);
6788 SwitchLayer(LAYER_FOREGROUND
);
6791 procedure TMainForm
.miLayer4Click(Sender
: TObject
);
6793 SwitchLayer(LAYER_STEPS
);
6796 procedure TMainForm
.miLayer5Click(Sender
: TObject
);
6798 SwitchLayer(LAYER_WATER
);
6801 procedure TMainForm
.miLayer6Click(Sender
: TObject
);
6803 SwitchLayer(LAYER_ITEMS
);
6806 procedure TMainForm
.miLayer7Click(Sender
: TObject
);
6808 SwitchLayer(LAYER_MONSTERS
);
6811 procedure TMainForm
.miLayer8Click(Sender
: TObject
);
6813 SwitchLayer(LAYER_AREAS
);
6816 procedure TMainForm
.miLayer9Click(Sender
: TObject
);
6818 SwitchLayer(LAYER_TRIGGERS
);
6821 procedure TMainForm
.tbShowClick(Sender
: TObject
);
6827 for a
:= 0 to High(LayerEnabled
) do
6828 b
:= b
and LayerEnabled
[a
];
6832 ShowLayer(LAYER_BACK
, b
);
6833 ShowLayer(LAYER_WALLS
, b
);
6834 ShowLayer(LAYER_FOREGROUND
, b
);
6835 ShowLayer(LAYER_STEPS
, b
);
6836 ShowLayer(LAYER_WATER
, b
);
6837 ShowLayer(LAYER_ITEMS
, b
);
6838 ShowLayer(LAYER_MONSTERS
, b
);
6839 ShowLayer(LAYER_AREAS
, b
);
6840 ShowLayer(LAYER_TRIGGERS
, b
);
6843 procedure TMainForm
.miMiniMapClick(Sender
: TObject
);
6848 procedure TMainForm
.miSwitchGridClick(Sender
: TObject
);
6850 if DotStep
= DotStepOne
then
6851 DotStep
:= DotStepTwo
6853 DotStep
:= DotStepOne
;
6855 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6856 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6859 procedure TMainForm
.miShowEdgesClick(Sender
: TObject
);
6864 procedure TMainForm
.miSnapToGridClick(Sender
: TObject
);
6866 SnapToGrid
:= not SnapToGrid
;
6868 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6869 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6871 miSnapToGrid
.Checked
:= SnapToGrid
;
6874 procedure TMainForm
.minexttabClick(Sender
: TObject
);
6876 if pcObjects
.ActivePageIndex
< pcObjects
.PageCount
-1 then
6877 pcObjects
.ActivePageIndex
:= pcObjects
.ActivePageIndex
+1
6879 pcObjects
.ActivePageIndex
:= 0;
6882 procedure TMainForm
.miSaveMiniMapClick(Sender
: TObject
);
6884 SaveMiniMapForm
.ShowModal();
6887 procedure TMainForm
.bClearTextureClick(Sender
: TObject
);
6889 lbTextureList
.ItemIndex
:= -1;
6890 lTextureWidth
.Caption
:= '';
6891 lTextureHeight
.Caption
:= '';
6894 procedure TMainForm
.miPackMapClick(Sender
: TObject
);
6896 PackMapForm
.ShowModal();
6899 type SSArray
= array of String;
6901 function ParseString (Str
: AnsiString): SSArray
;
6902 function GetStr (var Str
: AnsiString): AnsiString;
6906 if Str
[1] = '"' then
6907 for b
:= 1 to Length(Str
) do
6908 if (b
= Length(Str
)) or (Str
[b
+ 1] = '"') then
6910 Result
:= Copy(Str
, 2, b
- 1);
6911 Delete(Str
, 1, b
+ 1);
6915 for a
:= 1 to Length(Str
) do
6916 if (a
= Length(Str
)) or (Str
[a
+ 1] = ' ') then
6918 Result
:= Copy(Str
, 1, a
);
6919 Delete(Str
, 1, a
+ 1);
6929 SetLength(Result
, Length(Result
)+1);
6930 Result
[High(Result
)] := GetStr(Str
);
6934 procedure TMainForm
.miTestMapClick(Sender
: TObject
);
6936 newWAD
, oldWAD
, tempMap
, ext
: String;
6943 // Ignore while map testing in progress
6944 if MapTestProcess
<> nil then
6947 // Сохраняем временную карту:
6950 newWAD
:= Format('%s/temp%.4d', [MapsDir
, time
]);
6952 until not FileExists(newWAD
);
6953 if OpenedMap
<> '' then
6955 oldWad
:= g_ExtractWadName(OpenedMap
);
6956 newWad
:= newWad
+ ExtractFileExt(oldWad
);
6957 if CopyFile(oldWad
, newWad
) = false then
6958 e_WriteLog('MapTest: unable to copy [' + oldWad
+ '] to [' + newWad
+ ']', MSG_WARNING
)
6962 newWad
:= newWad
+ '.wad'
6964 tempMap
:= newWAD
+ ':\' + TEST_MAP_NAME
;
6965 SaveMap(tempMap
, '');
6969 if TestOptionsTwoPlayers
then
6971 if TestOptionsTeamDamage
then
6973 if TestOptionsAllowExit
then
6975 if TestOptionsWeaponStay
then
6977 if TestOptionsMonstersDM
then
6981 proc
:= TProcessUTF8
.Create(nil);
6982 proc
.Executable
:= TestD2dExe
;
6984 // TODO: get real executable name from Info.plist
6985 if LowerCase(ExtractFileExt(TestD2dExe
)) = '.app' then
6986 proc
.Executable
:= TestD2dExe
+ DirectorySeparator
+ 'Contents' + DirectorySeparator
+ 'MacOS' + DirectorySeparator
+ 'Doom2DF';
6988 proc
.Parameters
.Add('-map');
6989 proc
.Parameters
.Add(tempMap
);
6990 proc
.Parameters
.Add('-gm');
6991 proc
.Parameters
.Add(TestGameMode
);
6992 proc
.Parameters
.Add('-limt');
6993 proc
.Parameters
.Add(TestLimTime
);
6994 proc
.Parameters
.Add('-lims');
6995 proc
.Parameters
.Add(TestLimScore
);
6996 proc
.Parameters
.Add('-opt');
6997 proc
.Parameters
.Add(IntToStr(opt
));
6998 proc
.Parameters
.Add('--debug');
7000 proc
.Parameters
.Add('--close');
7002 args
:= ParseString(TestD2DArgs
);
7003 for i
:= 0 to High(args
) do
7004 proc
.Parameters
.Add(args
[i
]);
7014 tbTestMap
.Enabled
:= False;
7015 MapTestFile
:= newWAD
;
7016 MapTestProcess
:= proc
;
7020 Application
.MessageBox(PChar(MsgMsgExecError
), 'FIXME', MB_OK
or MB_ICONERROR
);
7021 SysUtils
.DeleteFile(newWAD
);
7026 procedure TMainForm
.sbVerticalScroll(Sender
: TObject
;
7027 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
7029 MapOffset
.Y
:= -sbVertical
.Position
;
7030 RenderPanel
.Invalidate
;
7033 procedure TMainForm
.sbHorizontalScroll(Sender
: TObject
;
7034 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
7036 MapOffset
.X
:= -sbHorizontal
.Position
;
7037 RenderPanel
.Invalidate
;
7040 procedure TMainForm
.miOpenWadMapClick(Sender
: TObject
);
7042 if OpenedWAD
<> '' then
7044 OpenMap(OpenedWAD
, '');
7048 procedure TMainForm
.selectall1Click(Sender
: TObject
);
7052 RemoveSelectFromObjects();
7054 if gPanels
<> nil then
7055 for a
:= 0 to High(gPanels
) do
7056 if gPanels
[a
].PanelType
<> PANEL_NONE
then
7057 SelectObject(OBJECT_PANEL
, a
, True);
7059 if gItems
<> nil then
7060 for a
:= 0 to High(gItems
) do
7061 if gItems
[a
].ItemType
<> ITEM_NONE
then
7062 SelectObject(OBJECT_ITEM
, a
, True);
7064 if gMonsters
<> nil then
7065 for a
:= 0 to High(gMonsters
) do
7066 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
7067 SelectObject(OBJECT_MONSTER
, a
, True);
7069 if gAreas
<> nil then
7070 for a
:= 0 to High(gAreas
) do
7071 if gAreas
[a
].AreaType
<> AREA_NONE
then
7072 SelectObject(OBJECT_AREA
, a
, True);
7074 if gTriggers
<> nil then
7075 for a
:= 0 to High(gTriggers
) do
7076 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
7077 SelectObject(OBJECT_TRIGGER
, a
, True);
7079 RecountSelectedObjects();
7082 procedure TMainForm
.Splitter1CanResize(Sender
: TObject
;
7083 var NewSize
: Integer; var Accept
: Boolean);
7085 Accept
:= (NewSize
> 140);
7088 procedure TMainForm
.Splitter2CanResize(Sender
: TObject
;
7089 var NewSize
: Integer; var Accept
: Boolean);
7091 Accept
:= (NewSize
> 110);
7094 procedure TMainForm
.vleObjectPropertyEnter(Sender
: TObject
);
7096 EditingProperties
:= True;
7099 procedure TMainForm
.vleObjectPropertyExit(Sender
: TObject
);
7101 EditingProperties
:= False;
7104 procedure TMainForm
.FormKeyUp(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
7106 // Объекты передвигались:
7107 if MainForm
.ActiveControl
= RenderPanel
then
7109 if (Key
= VK_NUMPAD4
) or
7110 (Key
= VK_NUMPAD6
) or
7111 (Key
= VK_NUMPAD8
) or
7112 (Key
= VK_NUMPAD5
) or
7113 (Key
= Ord('V')) then
7116 // Быстрое превью карты:
7117 if Key
= Ord('E') then
7119 if PreviewMode
= 2 then
7122 RenderPanelMouseMove(Sender
, Shift
, RenderMousePos().X
, RenderMousePos().Y
);