3 {$INCLUDE ../shared/a_modes.inc}
8 LCLIntf
, LCLType
, LMessages
, SysUtils
, Variants
, Classes
, Graphics
,
9 Controls
, Forms
, Dialogs
, ImgList
, StdCtrls
, Buttons
,
10 ComCtrls
, ValEdit
, Types
, ToolWin
, Menus
, ExtCtrls
,
11 CheckLst
, Grids
, OpenGLContext
, utils
;
17 TMainForm
= class(TForm
)
22 miMenuFile
: TMenuItem
;
26 miSaveMapAs
: TMenuItem
;
27 miOpenWadMap
: TMenuItem
;
29 miSaveMiniMap
: TMenuItem
;
30 miDeleteMap
: TMenuItem
;
35 miMenuEdit
: TMenuItem
;
42 miSelectAll
: TMenuItem
;
47 miMenuTools
: TMenuItem
;
48 miSnapToGrid
: TMenuItem
;
50 miSwitchGrid
: TMenuItem
;
51 miShowEdges
: TMenuItem
;
63 miMenuService
: TMenuItem
;
64 miCheckMap
: TMenuItem
;
65 miOptimmization
: TMenuItem
;
66 miMapPreview
: TMenuItem
;
69 miMenuSettings
: TMenuItem
;
70 miMapOptions
: TMenuItem
;
74 miMapTestSettings
: TMenuItem
;
76 miMenuHelp
: TMenuItem
;
78 // Скрытый пункт меню для Ctrl+Tab:
82 // Панель инструментов:
83 MainToolBar
: TToolBar
;
85 pLoadProgress
: TPanel
;
86 RenderPanel
: TOpenGLControl
;
87 tbNewMap
: TToolButton
;
88 tbOpenMap
: TToolButton
;
89 tbSaveMap
: TToolButton
;
90 tbOpenWadMap
: TToolButton
;
92 tbShowMap
: TToolButton
;
96 tbGridOn
: TToolButton
;
99 tbTestMap
: TToolButton
;
100 // Всплывающее меню для кнопки слоев:
102 miLayerP1
: TMenuItem
;
103 miLayerP2
: TMenuItem
;
104 miLayerP3
: TMenuItem
;
105 miLayerP4
: TMenuItem
;
106 miLayerP5
: TMenuItem
;
107 miLayerP6
: TMenuItem
;
108 miLayerP7
: TMenuItem
;
109 miLayerP8
: TMenuItem
;
110 miLayerP9
: TMenuItem
;
111 // Всплывающее меню для кнопки теста карты:
112 pmMapTest
: TPopupMenu
;
113 miMapTestPMSet
: TMenuItem
;
118 sbHorizontal
: TScrollBar
;
119 sbVertical
: TScrollBar
;
123 // Панель применения свойств:
124 PanelPropApply
: TPanel
;
125 bApplyProperty
: TButton
;
126 // Редактор свойств объектов:
127 vleObjectProperty
: TValueListEditor
;
129 // Панель объектов - вкладки:
131 pcObjects
: TPageControl
;
134 lbTextureList
: TListBox
;
135 // Панель настройки текстур:
136 PanelTextures
: TPanel
;
138 lTextureWidth
: TLabel
;
140 lTextureHeight
: TLabel
;
141 cbPreview
: TCheckBox
;
142 bbAddTexture
: TBitBtn
;
143 bbRemoveTexture
: TBitBtn
;
144 bClearTexture
: TButton
;
145 // Панель типов панелей:
146 PanelPanelType
: TPanel
;
147 lbPanelType
: TListBox
;
148 // Вкладка "Предметы":
150 lbItemList
: TListBox
;
153 // Вкладка "Монстры":
154 tsMonsters
: TTabSheet
;
155 lbMonsterList
: TListBox
;
156 rbMonsterLeft
: TRadioButton
;
157 rbMonsterRight
: TRadioButton
;
158 // Вкладка "Области":
160 lbAreasList
: TListBox
;
161 rbAreaLeft
: TRadioButton
;
162 rbAreaRight
: TRadioButton
;
163 // Вкладка "Триггеры":
164 tsTriggers
: TTabSheet
;
165 lbTriggersList
: TListBox
;
166 clbActivationType
: TCheckListBox
;
167 clbKeys
: TCheckListBox
;
170 Splitter1
: TSplitter
;
171 Splitter2
: TSplitter
;
172 StatusBar
: TStatusBar
;
174 // Специальные объекты:
175 ImageList
: TImageList
;
176 ilToolbar
: TImageList
;
177 OpenDialog
: TOpenDialog
;
178 SaveDialog
: TSaveDialog
;
179 selectall1
: TMenuItem
;
180 ColorDialog
: TColorDialog
;
182 procedure aAboutExecute(Sender
: TObject
);
183 procedure aCheckMapExecute(Sender
: TObject
);
184 procedure aMoveToFore(Sender
: TObject
);
185 procedure aMoveToBack(Sender
: TObject
);
186 procedure aCopyObjectExecute(Sender
: TObject
);
187 procedure aCutObjectExecute(Sender
: TObject
);
188 procedure aEditorOptionsExecute(Sender
: TObject
);
189 procedure aExitExecute(Sender
: TObject
);
190 procedure aMapOptionsExecute(Sender
: TObject
);
191 procedure aNewMapExecute(Sender
: TObject
);
192 procedure aOpenMapExecute(Sender
: TObject
);
193 procedure aOptimizeExecute(Sender
: TObject
);
194 procedure aPasteObjectExecute(Sender
: TObject
);
195 procedure aSelectAllExecute(Sender
: TObject
);
196 procedure aSaveMapExecute(Sender
: TObject
);
197 procedure aSaveMapAsExecute(Sender
: TObject
);
198 procedure aUndoExecute(Sender
: TObject
);
199 procedure aDeleteMap(Sender
: TObject
);
200 procedure bApplyPropertyClick(Sender
: TObject
);
201 procedure bbAddTextureClick(Sender
: TObject
);
202 procedure bbRemoveTextureClick(Sender
: TObject
);
203 procedure FormActivate(Sender
: TObject
);
204 procedure FormCloseQuery(Sender
: TObject
; var CanClose
: Boolean);
205 procedure FormCreate(Sender
: TObject
);
206 procedure FormDestroy(Sender
: TObject
);
207 procedure FormKeyDown(Sender
: TObject
; var Key
: Word; Shift
: TShiftState
);
208 procedure FormResize(Sender
: TObject
);
209 procedure lbTextureListClick(Sender
: TObject
);
210 procedure RenderPanelMouseDown(Sender
: TObject
; Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
211 procedure RenderPanelMouseMove(Sender
: TObject
; Shift
: TShiftState
; X
, Y
: Integer);
212 procedure RenderPanelMouseUp(Sender
: TObject
; Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
213 procedure RenderPanelPaint(Sender
: TObject
);
214 procedure RenderPanelResize(Sender
: TObject
);
215 procedure vleObjectPropertyEditButtonClick(Sender
: TObject
);
216 procedure vleObjectPropertyGetPickList(Sender
: TObject
; const KeyName
: String; Values
: TStrings
);
217 procedure vleObjectPropertyKeyDown(Sender
: TObject
; var Key
: Word;
219 procedure tbGridOnClick(Sender
: TObject
);
220 procedure miMapPreviewClick(Sender
: TObject
);
221 procedure miLayer1Click(Sender
: TObject
);
222 procedure miLayer2Click(Sender
: TObject
);
223 procedure miLayer3Click(Sender
: TObject
);
224 procedure miLayer4Click(Sender
: TObject
);
225 procedure miLayer5Click(Sender
: TObject
);
226 procedure miLayer6Click(Sender
: TObject
);
227 procedure miLayer7Click(Sender
: TObject
);
228 procedure miLayer8Click(Sender
: TObject
);
229 procedure miLayer9Click(Sender
: TObject
);
230 procedure tbShowClick(Sender
: TObject
);
231 procedure miSnapToGridClick(Sender
: TObject
);
232 procedure miMiniMapClick(Sender
: TObject
);
233 procedure miSwitchGridClick(Sender
: TObject
);
234 procedure miShowEdgesClick(Sender
: TObject
);
235 procedure minexttabClick(Sender
: TObject
);
236 procedure miSaveMiniMapClick(Sender
: TObject
);
237 procedure bClearTextureClick(Sender
: TObject
);
238 procedure miPackMapClick(Sender
: TObject
);
239 procedure aRecentFileExecute(Sender
: TObject
);
240 procedure miMapTestSettingsClick(Sender
: TObject
);
241 procedure miTestMapClick(Sender
: TObject
);
242 procedure sbVerticalScroll(Sender
: TObject
; ScrollCode
: TScrollCode
;
243 var ScrollPos
: Integer);
244 procedure sbHorizontalScroll(Sender
: TObject
; ScrollCode
: TScrollCode
;
245 var ScrollPos
: Integer);
246 procedure miOpenWadMapClick(Sender
: TObject
);
247 procedure selectall1Click(Sender
: TObject
);
248 procedure Splitter1CanResize(Sender
: TObject
; var NewSize
: Integer;
249 var Accept
: Boolean);
250 procedure Splitter2CanResize(Sender
: TObject
; var NewSize
: Integer;
251 var Accept
: Boolean);
252 procedure vleObjectPropertyEnter(Sender
: TObject
);
253 procedure vleObjectPropertyExit(Sender
: TObject
);
254 procedure FormKeyUp(Sender
: TObject
; var Key
: Word;
258 procedure OnIdle(Sender
: TObject
; var Done
: Boolean);
260 procedure RefreshRecentMenu();
261 { procedure lbTextureListDrawItem(Control: TWinControl; Index: Integer;
262 Rect: TRect; State: TOwnerDrawState); }
268 LAYER_FOREGROUND
= 2;
276 TEST_MAP_NAME
= '$$$_TEST_$$$';
277 LANGUAGE_FILE_NAME
= '_Editor.txt';
288 DotStepOne
, DotStepTwo
: Byte;
290 DrawTexturePanel
: Boolean;
291 DrawPanelSize
: Boolean;
293 PreviewColor
: TColor
;
295 RecentCount
: Integer;
296 RecentFiles
: TStringList
;
297 slInvalidTextures
: TStringList
;
299 TestGameMode
: String;
301 TestLimScore
: String;
302 TestOptionsTwoPlayers
: Boolean;
303 TestOptionsTeamDamage
: Boolean;
304 TestOptionsAllowExit
: Boolean;
305 TestOptionsWeaponStay
: Boolean;
306 TestOptionsMonstersDM
: Boolean;
308 TestMapOnce
: Boolean;
310 LayerEnabled
: Array [LAYER_BACK
..LAYER_TRIGGERS
] of Boolean =
311 (True, True, True, True, True, True, True, True, True);
312 PreviewMode
: Boolean = False;
318 procedure OpenMap(FileName
: String; mapN
: String);
319 function AddTexture(aWAD
, aSection
, aTex
: String; silent
: Boolean): Boolean;
320 procedure RemoveSelectFromObjects();
321 procedure ChangeShownProperty(Name
: String; NewValue
: String);
326 f_options
, e_graphics
, e_log
, GL
, GLExt
, Math
,
327 f_mapoptions
, g_basic
, f_about
, f_mapoptimization
,
328 f_mapcheck
, f_addresource_texture
, g_textures
,
329 f_activationtype
, f_keys
, MAPWRITER
, MAPSTRUCT
,
330 MAPREADER
, f_selectmap
, f_savemap
, WADEDITOR
, WADSTRUCT
, MAPDEF
,
331 g_map
, f_saveminimap
, f_addresource
, CONFIG
, f_packmap
,
332 f_addresource_sound
, f_maptest
, f_choosetype
,
333 g_language
, f_selectlang
, ClipBrd
;
336 UNDO_DELETE_PANEL
= 1;
337 UNDO_DELETE_ITEM
= 2;
338 UNDO_DELETE_AREA
= 3;
339 UNDO_DELETE_MONSTER
= 4;
340 UNDO_DELETE_TRIGGER
= 5;
344 UNDO_ADD_MONSTER
= 9;
345 UNDO_ADD_TRIGGER
= 10;
346 UNDO_MOVE_PANEL
= 11;
349 UNDO_MOVE_MONSTER
= 14;
350 UNDO_MOVE_TRIGGER
= 15;
351 UNDO_RESIZE_PANEL
= 16;
352 UNDO_RESIZE_TRIGGER
= 17;
354 MOUSEACTION_NONE
= 0;
355 MOUSEACTION_DRAWPANEL
= 1;
356 MOUSEACTION_DRAWTRIGGER
= 2;
357 MOUSEACTION_MOVEOBJ
= 3;
358 MOUSEACTION_RESIZE
= 4;
359 MOUSEACTION_MOVEMAP
= 5;
360 MOUSEACTION_DRAWPRESS
= 6;
361 MOUSEACTION_NOACTION
= 7;
364 RESIZETYPE_VERTICAL
= 1;
365 RESIZETYPE_HORIZONTAL
= 2;
374 SELECTFLAG_TELEPORT
= 1;
376 SELECTFLAG_TEXTURE
= 3;
378 SELECTFLAG_MONSTER
= 5;
379 SELECTFLAG_SPAWNPOINT
= 6;
380 SELECTFLAG_SHOTPANEL
= 7;
381 SELECTFLAG_SELECTED
= 8;
383 RECENT_FILES_MENU_START
= 11;
385 CLIPBOARD_SIG
= 'DF:ED';
391 UNDO_DELETE_PANEL
: (Panel
: ^TPanel
);
392 UNDO_DELETE_ITEM
: (Item
: TItem
);
393 UNDO_DELETE_AREA
: (Area
: TArea
);
394 UNDO_DELETE_MONSTER
: (Monster
: TMonster
);
395 UNDO_DELETE_TRIGGER
: (Trigger
: TTrigger
);
400 UNDO_ADD_TRIGGER
: (AddID
: DWORD
);
405 UNDO_MOVE_TRIGGER
: (MoveID
: DWORD
; dX
, dY
: Integer);
407 UNDO_RESIZE_TRIGGER
: (ResizeID
: DWORD
; dW
, dH
: Integer);
414 OBJECT_PANEL
: (Panel
: ^TPanel
);
415 OBJECT_ITEM
: (Item
: TItem
);
416 OBJECT_AREA
: (Area
: TArea
);
417 OBJECT_MONSTER
: (Monster
: TMonster
);
418 OBJECT_TRIGGER
: (Trigger
: TTrigger
);
421 TCopyRecArray
= Array of TCopyRec
;
425 gDataLoaded
: Boolean = False;
426 ShowMap
: Boolean = False;
427 DrawRect
: PRect
= nil;
428 SnapToGrid
: Boolean = True;
430 MousePos
: Types
.TPoint
;
431 LastMovePoint
: Types
.TPoint
;
434 MouseLDownPos
: Types
.TPoint
;
435 MouseRDownPos
: Types
.TPoint
;
437 SelectFlag
: Byte = SELECTFLAG_NONE
;
438 MouseAction
: Byte = MOUSEACTION_NONE
;
439 ResizeType
: Byte = RESIZETYPE_NONE
;
440 ResizeDirection
: Byte = RESIZEDIR_NONE
;
442 DrawPressRect
: Boolean = False;
443 EditingProperties
: Boolean = False;
445 UndoBuffer
: Array of Array of TUndoRec
= nil;
450 //----------------------------------------
451 //Далее идут вспомогательные процедуры
452 //----------------------------------------
454 function NameToBool(Name
: String): Boolean;
456 if Name
= BoolNames
[True] then
462 function NameToDir(Name
: String): TDirection
;
464 if Name
= DirNames
[D_LEFT
] then
470 function NameToDirAdv(Name
: String): Byte;
472 if Name
= DirNamesAdv
[1] then
475 if Name
= DirNamesAdv
[2] then
478 if Name
= DirNamesAdv
[3] then
484 function ActivateToStr(ActivateType
: Byte): String;
488 if ByteBool(ACTIVATE_PLAYERCOLLIDE
and ActivateType
) then
489 Result
:= Result
+ '+PC';
490 if ByteBool(ACTIVATE_MONSTERCOLLIDE
and ActivateType
) then
491 Result
:= Result
+ '+MC';
492 if ByteBool(ACTIVATE_PLAYERPRESS
and ActivateType
) then
493 Result
:= Result
+ '+PP';
494 if ByteBool(ACTIVATE_MONSTERPRESS
and ActivateType
) then
495 Result
:= Result
+ '+MP';
496 if ByteBool(ACTIVATE_SHOT
and ActivateType
) then
497 Result
:= Result
+ '+SH';
498 if ByteBool(ACTIVATE_NOMONSTER
and ActivateType
) then
499 Result
:= Result
+ '+NM';
501 if (Result
<> '') and (Result
[1] = '+') then
502 Delete(Result
, 1, 1);
505 function StrToActivate(Str
: String): Byte;
509 if Pos('PC', Str
) > 0 then
510 Result
:= ACTIVATE_PLAYERCOLLIDE
;
511 if Pos('MC', Str
) > 0 then
512 Result
:= Result
or ACTIVATE_MONSTERCOLLIDE
;
513 if Pos('PP', Str
) > 0 then
514 Result
:= Result
or ACTIVATE_PLAYERPRESS
;
515 if Pos('MP', Str
) > 0 then
516 Result
:= Result
or ACTIVATE_MONSTERPRESS
;
517 if Pos('SH', Str
) > 0 then
518 Result
:= Result
or ACTIVATE_SHOT
;
519 if Pos('NM', Str
) > 0 then
520 Result
:= Result
or ACTIVATE_NOMONSTER
;
523 function KeyToStr(Key
: Byte): String;
527 if ByteBool(KEY_RED
and Key
) then
528 Result
:= Result
+ '+RK';
529 if ByteBool(KEY_GREEN
and Key
) then
530 Result
:= Result
+ '+GK';
531 if ByteBool(KEY_BLUE
and Key
) then
532 Result
:= Result
+ '+BK';
533 if ByteBool(KEY_REDTEAM
and Key
) then
534 Result
:= Result
+ '+RT';
535 if ByteBool(KEY_BLUETEAM
and Key
) then
536 Result
:= Result
+ '+BT';
538 if (Result
<> '') and (Result
[1] = '+') then
539 Delete(Result
, 1, 1);
542 function StrToKey(Str
: String): Byte;
546 if Pos('RK', Str
) > 0 then
548 if Pos('GK', Str
) > 0 then
549 Result
:= Result
or KEY_GREEN
;
550 if Pos('BK', Str
) > 0 then
551 Result
:= Result
or KEY_BLUE
;
552 if Pos('RT', Str
) > 0 then
553 Result
:= Result
or KEY_REDTEAM
;
554 if Pos('BT', Str
) > 0 then
555 Result
:= Result
or KEY_BLUETEAM
;
558 function EffectToStr(Effect
: Byte): String;
560 if Effect
in [EFFECT_TELEPORT
..EFFECT_FIRE
] then
561 Result
:= EffectNames
[Effect
]
563 Result
:= EffectNames
[EFFECT_NONE
];
566 function StrToEffect(Str
: String): Byte;
570 Result
:= EFFECT_NONE
;
571 for i
:= EFFECT_TELEPORT
to EFFECT_FIRE
do
572 if EffectNames
[i
] = Str
then
579 function MonsterToStr(MonType
: Byte): String;
581 if MonType
in [MONSTER_DEMON
..MONSTER_MAN
] then
582 Result
:= MonsterNames
[MonType
]
584 Result
:= MonsterNames
[MONSTER_ZOMBY
];
587 function StrToMonster(Str
: String): Byte;
591 Result
:= MONSTER_ZOMBY
;
592 for i
:= MONSTER_DEMON
to MONSTER_MAN
do
593 if MonsterNames
[i
] = Str
then
600 function ItemToStr(ItemType
: Byte): String;
602 if ItemType
in [ITEM_MEDKIT_SMALL
..ITEM_MAX
] then
603 Result
:= ItemNames
[ItemType
]
605 Result
:= ItemNames
[ITEM_AMMO_BULLETS
];
608 function StrToItem(Str
: String): Byte;
612 Result
:= ITEM_AMMO_BULLETS
;
613 for i
:= ITEM_MEDKIT_SMALL
to ITEM_MAX
do
614 if ItemNames
[i
] = Str
then
621 function ShotToStr(ShotType
: Byte): String;
623 if ShotType
in [TRIGGER_SHOT_PISTOL
..TRIGGER_SHOT_MAX
] then
624 Result
:= ShotNames
[ShotType
]
626 Result
:= ShotNames
[TRIGGER_SHOT_PISTOL
];
629 function StrToShot(Str
: String): Byte;
633 Result
:= TRIGGER_SHOT_PISTOL
;
634 for i
:= TRIGGER_SHOT_PISTOL
to TRIGGER_SHOT_MAX
do
635 if ShotNames
[i
] = Str
then
642 function SelectedObjectCount(): Word;
648 if SelectedObjects
= nil then
651 for a
:= 0 to High(SelectedObjects
) do
652 if SelectedObjects
[a
].Live
then
653 Result
:= Result
+ 1;
656 function GetFirstSelected(): Integer;
662 if SelectedObjects
= nil then
665 for a
:= 0 to High(SelectedObjects
) do
666 if SelectedObjects
[a
].Live
then
673 function Normalize16(x
: Integer): Integer;
675 Result
:= (x
div 16) * 16;
678 procedure MoveMap(X
, Y
: Integer);
680 rx
, ry
, ScaleSz
: Integer;
682 with MainForm
.RenderPanel
do
684 ScaleSz
:= 16 div Scale
;
685 // Размер видимой части карты:
686 rx
:= min(Normalize16(Width
), Normalize16(gMapInfo
.Width
)) div 2;
687 ry
:= min(Normalize16(Height
), Normalize16(gMapInfo
.Height
)) div 2;
688 // Место клика на мини-карте:
689 MapOffset
.X
:= X
- (Width
-max(gMapInfo
.Width
div ScaleSz
, 1)-1);
690 MapOffset
.Y
:= Y
- 1;
691 // Это же место на "большой" карте:
692 MapOffset
.X
:= MapOffset
.X
* ScaleSz
;
693 MapOffset
.Y
:= MapOffset
.Y
* ScaleSz
;
694 // Левый верхний угол новой видимой части карты:
695 MapOffset
.X
:= MapOffset
.X
- rx
;
696 MapOffset
.Y
:= MapOffset
.Y
- ry
;
698 if MapOffset
.X
< 0 then
700 if MapOffset
.Y
< 0 then
702 if MapOffset
.X
> MainForm
.sbHorizontal
.Max
then
703 MapOffset
.X
:= MainForm
.sbHorizontal
.Max
;
704 if MapOffset
.Y
> MainForm
.sbVertical
.Max
then
705 MapOffset
.Y
:= MainForm
.sbVertical
.Max
;
707 MapOffset
.X
:= Normalize16(MapOffset
.X
);
708 MapOffset
.Y
:= Normalize16(MapOffset
.Y
);
711 MainForm
.sbHorizontal
.Position
:= MapOffset
.X
;
712 MainForm
.sbVertical
.Position
:= MapOffset
.Y
;
714 MapOffset
.X
:= -MapOffset
.X
;
715 MapOffset
.Y
:= -MapOffset
.Y
;
720 function IsTexturedPanel(PanelType
: Word): Boolean;
722 Result
:= WordBool(PanelType
and (PANEL_WALL
or PANEL_BACK
or PANEL_FORE
or
723 PANEL_STEP
or PANEL_OPENDOOR
or PANEL_CLOSEDOOR
or
724 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
));
727 procedure FillProperty();
732 MainForm
.vleObjectProperty
.Strings
.Clear();
734 // Отображаем свойства если выделен только один объект:
735 if SelectedObjectCount() <> 1 then
738 _id
:= GetFirstSelected();
739 if not SelectedObjects
[_id
].Live
then
742 with MainForm
.vleObjectProperty
do
743 with ItemProps
[InsertRow(_lc
[I_PROP_ID
], IntToStr(SelectedObjects
[_id
].ID
), True)] do
745 EditStyle
:= esSimple
;
749 case SelectedObjects
[0].ObjectType
of
752 with MainForm
.vleObjectProperty
,
753 gPanels
[SelectedObjects
[_id
].ID
] do
755 with ItemProps
[InsertRow(_lc
[I_PROP_X
], IntToStr(X
), True)] do
757 EditStyle
:= esSimple
;
761 with ItemProps
[InsertRow(_lc
[I_PROP_Y
], IntToStr(Y
), True)] do
763 EditStyle
:= esSimple
;
767 with ItemProps
[InsertRow(_lc
[I_PROP_WIDTH
], IntToStr(Width
), True)] do
769 EditStyle
:= esSimple
;
773 with ItemProps
[InsertRow(_lc
[I_PROP_HEIGHT
], IntToStr(Height
), True)] do
775 EditStyle
:= esSimple
;
779 with ItemProps
[InsertRow(_lc
[I_PROP_PANEL_TYPE
], GetPanelName(PanelType
), True)] do
781 EditStyle
:= esEllipsis
;
785 if IsTexturedPanel(PanelType
) then
786 begin // Может быть текстура
787 with ItemProps
[InsertRow(_lc
[I_PROP_PANEL_TEX
], TextureName
, True)] do
789 EditStyle
:= esEllipsis
;
793 if TextureName
<> '' then
794 begin // Есть текстура
795 with ItemProps
[InsertRow(_lc
[I_PROP_PANEL_ALPHA
], IntToStr(Alpha
), True)] do
797 EditStyle
:= esSimple
;
801 with ItemProps
[InsertRow(_lc
[I_PROP_PANEL_BLEND
], BoolNames
[Blending
], True)] do
803 EditStyle
:= esPickList
;
813 with MainForm
.vleObjectProperty
,
814 gItems
[SelectedObjects
[_id
].ID
] do
816 with ItemProps
[InsertRow(_lc
[I_PROP_X
], IntToStr(X
), True)] do
818 EditStyle
:= esSimple
;
822 with ItemProps
[InsertRow(_lc
[I_PROP_Y
], IntToStr(Y
), True)] do
824 EditStyle
:= esSimple
;
828 with ItemProps
[InsertRow(_lc
[I_PROP_DM_ONLY
], BoolNames
[OnlyDM
], True)] do
830 EditStyle
:= esPickList
;
834 with ItemProps
[InsertRow(_lc
[I_PROP_ITEM_FALLS
], BoolNames
[Fall
], True)] do
836 EditStyle
:= esPickList
;
844 with MainForm
.vleObjectProperty
,
845 gMonsters
[SelectedObjects
[_id
].ID
] do
847 with ItemProps
[InsertRow(_lc
[I_PROP_X
], IntToStr(X
), True)] do
849 EditStyle
:= esSimple
;
853 with ItemProps
[InsertRow(_lc
[I_PROP_Y
], IntToStr(Y
), True)] do
855 EditStyle
:= esSimple
;
859 with ItemProps
[InsertRow(_lc
[I_PROP_DIRECTION
], DirNames
[Direction
], True)] do
861 EditStyle
:= esPickList
;
869 with MainForm
.vleObjectProperty
,
870 gAreas
[SelectedObjects
[_id
].ID
] do
872 with ItemProps
[InsertRow(_lc
[I_PROP_X
], IntToStr(X
), True)] do
874 EditStyle
:= esSimple
;
878 with ItemProps
[InsertRow(_lc
[I_PROP_Y
], IntToStr(Y
), True)] do
880 EditStyle
:= esSimple
;
884 with ItemProps
[InsertRow(_lc
[I_PROP_DIRECTION
], DirNames
[Direction
], True)] do
886 EditStyle
:= esPickList
;
894 with MainForm
.vleObjectProperty
,
895 gTriggers
[SelectedObjects
[_id
].ID
] do
897 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TYPE
], GetTriggerName(TriggerType
), True)] do
899 EditStyle
:= esSimple
;
903 with ItemProps
[InsertRow(_lc
[I_PROP_X
], IntToStr(X
), True)] do
905 EditStyle
:= esSimple
;
909 with ItemProps
[InsertRow(_lc
[I_PROP_Y
], IntToStr(Y
), True)] do
911 EditStyle
:= esSimple
;
915 with ItemProps
[InsertRow(_lc
[I_PROP_WIDTH
], IntToStr(Width
), True)] do
917 EditStyle
:= esSimple
;
921 with ItemProps
[InsertRow(_lc
[I_PROP_HEIGHT
], IntToStr(Height
), True)] do
923 EditStyle
:= esSimple
;
927 with ItemProps
[InsertRow(_lc
[I_PROP_TR_ENABLED
], BoolNames
[Enabled
], True)] do
929 EditStyle
:= esPickList
;
933 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TEXTURE_PANEL
], IntToStr(TexturePanel
), True)] do
935 EditStyle
:= esEllipsis
;
939 with ItemProps
[InsertRow(_lc
[I_PROP_TR_ACTIVATION
], ActivateToStr(ActivateType
), True)] do
941 EditStyle
:= esEllipsis
;
945 with ItemProps
[InsertRow(_lc
[I_PROP_TR_KEYS
], KeyToStr(Key
), True)] do
947 EditStyle
:= esEllipsis
;
954 with ItemProps
[InsertRow(_lc
[I_PROP_TR_NEXT_MAP
], Data
.MapName
, True)] do
956 EditStyle
:= esEllipsis
;
963 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TELEPORT_TO
], Format('(%d:%d)', [Data
.TargetPoint
.X
, Data
.TargetPoint
.Y
]), True)] do
965 EditStyle
:= esEllipsis
;
969 with ItemProps
[InsertRow(_lc
[I_PROP_TR_D2D
], BoolNames
[Data
.d2d_teleport
], True)] do
971 EditStyle
:= esPickList
;
975 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TELEPORT_SILENT
], BoolNames
[Data
.silent_teleport
], True)] do
977 EditStyle
:= esPickList
;
981 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TELEPORT_DIR
], DirNamesAdv
[Data
.TlpDir
], True)] do
983 EditStyle
:= esPickList
;
988 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
,
989 TRIGGER_DOOR
, TRIGGER_DOOR5
:
991 with ItemProps
[InsertRow(_lc
[I_PROP_TR_DOOR_PANEL
], IntToStr(Data
.PanelID
), True)] do
993 EditStyle
:= esEllipsis
;
997 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SILENT
], BoolNames
[Data
.NoSound
], True)] do
999 EditStyle
:= esPickList
;
1003 with ItemProps
[InsertRow(_lc
[I_PROP_TR_D2D
], BoolNames
[Data
.d2d_doors
], True)] do
1005 EditStyle
:= esPickList
;
1010 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
:
1012 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TRAP_PANEL
], IntToStr(Data
.PanelID
), True)] do
1014 EditStyle
:= esEllipsis
;
1018 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SILENT
], BoolNames
[Data
.NoSound
], True)] do
1020 EditStyle
:= esPickList
;
1024 with ItemProps
[InsertRow(_lc
[I_PROP_TR_D2D
], BoolNames
[Data
.d2d_doors
], True)] do
1026 EditStyle
:= esPickList
;
1031 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
1034 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_AREA
],
1035 Format('(%d:%d %d:%d)', [Data
.tX
, Data
.tY
, Data
.tWidth
, Data
.tHeight
]), True)] do
1037 EditStyle
:= esEllipsis
;
1041 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_DELAY
], IntToStr(Data
.Wait
), True)] do
1043 EditStyle
:= esSimple
;
1047 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_COUNT
], IntToStr(Data
.Count
), True)] do
1049 EditStyle
:= esSimple
;
1053 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_MONSTER
], IntToStr(Data
.MonsterID
-1), True)] do
1055 EditStyle
:= esEllipsis
;
1059 if TriggerType
= TRIGGER_PRESS
then
1060 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_RANDOM
], BoolNames
[Data
.ExtRandom
], True)] do
1062 EditStyle
:= esPickList
;
1070 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
1072 with ItemProps
[InsertRow(_lc
[I_PROP_TR_LIFT_PANEL
], IntToStr(Data
.PanelID
), True)] do
1074 EditStyle
:= esEllipsis
;
1078 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SILENT
], BoolNames
[Data
.NoSound
], True)] do
1080 EditStyle
:= esPickList
;
1084 with ItemProps
[InsertRow(_lc
[I_PROP_TR_D2D
], BoolNames
[Data
.d2d_doors
], True)] do
1086 EditStyle
:= esPickList
;
1093 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TEXTURE_ONCE
], BoolNames
[Data
.ActivateOnce
], True)] do
1095 EditStyle
:= esPickList
;
1099 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TEXTURE_ANIM_ONCE
], BoolNames
[Data
.AnimOnce
], True)] do
1101 EditStyle
:= esPickList
;
1108 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_NAME
], Data
.SoundName
, True)] do
1110 EditStyle
:= esEllipsis
;
1114 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_VOLUME
], IntToStr(Data
.Volume
), True)] do
1116 EditStyle
:= esSimple
;
1120 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_PAN
], IntToStr(Data
.Pan
), True)] do
1122 EditStyle
:= esSimple
;
1126 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_COUNT
], IntToStr(Data
.PlayCount
), True)] do
1128 EditStyle
:= esSimple
;
1132 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_LOCAL
], BoolNames
[Data
.Local
], True)] do
1134 EditStyle
:= esPickList
;
1138 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_SWITCH
], BoolNames
[Data
.SoundSwitch
], True)] do
1140 EditStyle
:= esPickList
;
1145 TRIGGER_SPAWNMONSTER
:
1147 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MONSTER_TYPE
], MonsterToStr(Data
.MonType
), True)] do
1149 EditStyle
:= esEllipsis
;
1153 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_TO
],
1154 Format('(%d:%d)', [Data
.MonPos
.X
, Data
.MonPos
.Y
]), True)] do
1156 EditStyle
:= esEllipsis
;
1160 with ItemProps
[InsertRow(_lc
[I_PROP_DIRECTION
], DirNames
[TDirection(Data
.MonDir
)], True)] do
1162 EditStyle
:= esPickList
;
1166 with ItemProps
[InsertRow(_lc
[I_PROP_TR_HEALTH
], IntToStr(Data
.MonHealth
), True)] do
1168 EditStyle
:= esSimple
;
1172 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MONSTER_ACTIVE
], BoolNames
[Data
.MonActive
], True)] do
1174 EditStyle
:= esPickList
;
1178 with ItemProps
[InsertRow(_lc
[I_PROP_TR_COUNT
], IntToStr(Data
.MonCount
), True)] do
1180 EditStyle
:= esSimple
;
1184 with ItemProps
[InsertRow(_lc
[I_PROP_TR_FX_TYPE
], EffectToStr(Data
.MonEffect
), True)] do
1186 EditStyle
:= esEllipsis
;
1190 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_MAX
], IntToStr(Data
.MonMax
), True)] do
1192 EditStyle
:= esSimple
;
1196 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_DELAY
], IntToStr(Data
.MonDelay
), True)] do
1198 EditStyle
:= esSimple
;
1202 case Data
.MonBehav
of
1203 1: str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_1
];
1204 2: str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_2
];
1205 3: str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_3
];
1206 4: str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_4
];
1207 5: str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_5
];
1208 else str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_0
];
1210 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
], str
, True)] do
1212 EditStyle
:= esPickList
;
1219 with ItemProps
[InsertRow(_lc
[I_PROP_TR_ITEM_TYPE
], ItemToStr(Data
.ItemType
), True)] do
1221 EditStyle
:= esEllipsis
;
1225 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_TO
],
1226 Format('(%d:%d)', [Data
.ItemPos
.X
, Data
.ItemPos
.Y
]), True)] do
1228 EditStyle
:= esEllipsis
;
1232 with ItemProps
[InsertRow(_lc
[I_PROP_DM_ONLY
], BoolNames
[Data
.ItemOnlyDM
], True)] do
1234 EditStyle
:= esPickList
;
1238 with ItemProps
[InsertRow(_lc
[I_PROP_ITEM_FALLS
], BoolNames
[Data
.ItemFalls
], True)] do
1240 EditStyle
:= esPickList
;
1244 with ItemProps
[InsertRow(_lc
[I_PROP_TR_COUNT
], IntToStr(Data
.ItemCount
), True)] do
1246 EditStyle
:= esSimple
;
1250 with ItemProps
[InsertRow(_lc
[I_PROP_TR_FX_TYPE
], EffectToStr(Data
.ItemEffect
), True)] do
1252 EditStyle
:= esEllipsis
;
1256 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_MAX
], IntToStr(Data
.ItemMax
), True)] do
1258 EditStyle
:= esSimple
;
1262 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_DELAY
], IntToStr(Data
.ItemDelay
), True)] do
1264 EditStyle
:= esSimple
;
1271 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MUSIC_NAME
], Data
.MusicName
, True)] do
1273 EditStyle
:= esEllipsis
;
1277 if Data
.MusicAction
= 1 then
1278 str
:= _lc
[I_PROP_TR_MUSIC_ON
]
1280 str
:= _lc
[I_PROP_TR_MUSIC_OFF
];
1282 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MUSIC_ACT
], str
, True)] do
1284 EditStyle
:= esPickList
;
1291 with ItemProps
[InsertRow(_lc
[I_PROP_TR_PUSH_ANGLE
], IntToStr(Data
.PushAngle
), True)] do
1293 EditStyle
:= esSimple
;
1296 with ItemProps
[InsertRow(_lc
[I_PROP_TR_PUSH_FORCE
], IntToStr(Data
.PushForce
), True)] do
1298 EditStyle
:= esSimple
;
1301 with ItemProps
[InsertRow(_lc
[I_PROP_TR_PUSH_RESET
], BoolNames
[Data
.ResetVel
], True)] do
1303 EditStyle
:= esPickList
;
1310 case Data
.ScoreAction
of
1311 1: str
:= _lc
[I_PROP_TR_SCORE_ACT_1
];
1312 2: str
:= _lc
[I_PROP_TR_SCORE_ACT_2
];
1313 3: str
:= _lc
[I_PROP_TR_SCORE_ACT_3
];
1314 else str
:= _lc
[I_PROP_TR_SCORE_ACT_0
];
1316 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SCORE_ACT
], str
, True)] do
1318 EditStyle
:= esPickList
;
1321 with ItemProps
[InsertRow(_lc
[I_PROP_TR_COUNT
], IntToStr(Data
.ScoreCount
), True)] do
1323 EditStyle
:= esSimple
;
1326 case Data
.ScoreTeam
of
1327 1: str
:= _lc
[I_PROP_TR_SCORE_TEAM_1
];
1328 2: str
:= _lc
[I_PROP_TR_SCORE_TEAM_2
];
1329 3: str
:= _lc
[I_PROP_TR_SCORE_TEAM_3
];
1330 else str
:= _lc
[I_PROP_TR_SCORE_TEAM_0
];
1332 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SCORE_TEAM
], str
, True)] do
1334 EditStyle
:= esPickList
;
1337 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SCORE_CON
], BoolNames
[Data
.ScoreCon
], True)] do
1339 EditStyle
:= esPickList
;
1342 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SCORE_MSG
], BoolNames
[Data
.ScoreMsg
], True)] do
1344 EditStyle
:= esPickList
;
1351 case Data
.MessageKind
of
1352 1: str
:= _lc
[I_PROP_TR_MESSAGE_KIND_1
];
1353 else str
:= _lc
[I_PROP_TR_MESSAGE_KIND_0
];
1355 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MESSAGE_KIND
], str
, True)] do
1357 EditStyle
:= esPickList
;
1360 case Data
.MessageSendTo
of
1361 1: str
:= _lc
[I_PROP_TR_MESSAGE_TO_1
];
1362 2: str
:= _lc
[I_PROP_TR_MESSAGE_TO_2
];
1363 3: str
:= _lc
[I_PROP_TR_MESSAGE_TO_3
];
1364 4: str
:= _lc
[I_PROP_TR_MESSAGE_TO_4
];
1365 5: str
:= _lc
[I_PROP_TR_MESSAGE_TO_5
];
1366 else str
:= _lc
[I_PROP_TR_MESSAGE_TO_0
];
1368 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MESSAGE_TO
], str
, True)] do
1370 EditStyle
:= esPickList
;
1373 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MESSAGE_TEXT
], Data
.MessageText
, True)] do
1375 EditStyle
:= esSimple
;
1378 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MESSAGE_TIME
], IntToStr(Data
.MessageTime
), True)] do
1380 EditStyle
:= esSimple
;
1387 with ItemProps
[InsertRow(_lc
[I_PROP_TR_DAMAGE_VALUE
], IntToStr(Data
.DamageValue
), True)] do
1389 EditStyle
:= esSimple
;
1392 with ItemProps
[InsertRow(_lc
[I_PROP_TR_INTERVAL
], IntToStr(Data
.DamageInterval
), True)] do
1394 EditStyle
:= esSimple
;
1401 with ItemProps
[InsertRow(_lc
[I_PROP_TR_HEALTH
], IntToStr(Data
.HealValue
), True)] do
1403 EditStyle
:= esSimple
;
1406 with ItemProps
[InsertRow(_lc
[I_PROP_TR_INTERVAL
], IntToStr(Data
.HealInterval
), True)] do
1408 EditStyle
:= esSimple
;
1411 with ItemProps
[InsertRow(_lc
[I_PROP_TR_HEALTH_MAX
], BoolNames
[Data
.HealMax
], True)] do
1413 EditStyle
:= esPickList
;
1416 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SILENT
], BoolNames
[Data
.HealSilent
], True)] do
1418 EditStyle
:= esPickList
;
1425 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_TYPE
], ShotToStr(Data
.ShotType
), True)] do
1427 EditStyle
:= esEllipsis
;
1431 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_SOUND
], BoolNames
[Data
.ShotSound
], True)] do
1433 EditStyle
:= esPickList
;
1437 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_PANEL
], IntToStr(Data
.ShotPanelID
), True)] do
1439 EditStyle
:= esEllipsis
;
1443 case Data
.ShotTarget
of
1444 1: str
:= _lc
[I_PROP_TR_SHOT_TO_1
];
1445 2: str
:= _lc
[I_PROP_TR_SHOT_TO_2
];
1446 3: str
:= _lc
[I_PROP_TR_SHOT_TO_3
];
1447 4: str
:= _lc
[I_PROP_TR_SHOT_TO_4
];
1448 5: str
:= _lc
[I_PROP_TR_SHOT_TO_5
];
1449 6: str
:= _lc
[I_PROP_TR_SHOT_TO_6
];
1450 else str
:= _lc
[I_PROP_TR_SHOT_TO_0
];
1452 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_TO
], str
, True)] do
1454 EditStyle
:= esPickList
;
1458 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_SIGHT
], IntToStr(Data
.ShotIntSight
), True)] do
1460 EditStyle
:= esSimple
;
1464 case Data
.ShotAim
of
1465 1: str
:= _lc
[I_PROP_TR_SHOT_AIM_1
];
1466 2: str
:= _lc
[I_PROP_TR_SHOT_AIM_2
];
1467 3: str
:= _lc
[I_PROP_TR_SHOT_AIM_3
];
1468 else str
:= _lc
[I_PROP_TR_SHOT_AIM_0
];
1470 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_AIM
], str
, True)-1] do
1472 EditStyle
:= esPickList
;
1476 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_TO
],
1477 Format('(%d:%d)', [Data
.ShotPos
.X
, Data
.ShotPos
.Y
]), True)] do
1479 EditStyle
:= esEllipsis
;
1483 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_ANGLE
], IntToStr(Data
.ShotAngle
), True)] do
1485 EditStyle
:= esSimple
;
1489 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_DELAY
], IntToStr(Data
.ShotWait
), True)] do
1491 EditStyle
:= esSimple
;
1495 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_ACC
], IntToStr(Data
.ShotAccuracy
), True)] do
1497 EditStyle
:= esSimple
;
1501 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_AMMO
], IntToStr(Data
.ShotAmmo
), True)] do
1503 EditStyle
:= esSimple
;
1507 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_RELOAD
], IntToStr(Data
.ShotIntReload
), True)] do
1509 EditStyle
:= esSimple
;
1516 with ItemProps
[InsertRow(_lc
[I_PROP_TR_COUNT
], IntToStr(Data
.FXCount
), True)] do
1518 EditStyle
:= esSimple
;
1522 if Data
.FXType
= 0 then
1523 str
:= _lc
[I_PROP_TR_EFFECT_PARTICLE
]
1525 str
:= _lc
[I_PROP_TR_EFFECT_ANIMATION
];
1526 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_TYPE
], str
, True)] do
1528 EditStyle
:= esEllipsis
;
1533 if Data
.FXType
= 0 then
1534 case Data
.FXSubType
of
1535 TRIGGER_EFFECT_SLIQUID
:
1536 str
:= _lc
[I_PROP_TR_EFFECT_SLIQUID
];
1537 TRIGGER_EFFECT_LLIQUID
:
1538 str
:= _lc
[I_PROP_TR_EFFECT_LLIQUID
];
1539 TRIGGER_EFFECT_DLIQUID
:
1540 str
:= _lc
[I_PROP_TR_EFFECT_DLIQUID
];
1541 TRIGGER_EFFECT_BLOOD
:
1542 str
:= _lc
[I_PROP_TR_EFFECT_BLOOD
];
1543 TRIGGER_EFFECT_SPARK
:
1544 str
:= _lc
[I_PROP_TR_EFFECT_SPARK
];
1545 TRIGGER_EFFECT_BUBBLE
:
1546 str
:= _lc
[I_PROP_TR_EFFECT_BUBBLE
];
1548 if Data
.FXType
= 1 then
1550 if (Data
.FXSubType
= 0) or (Data
.FXSubType
> EFFECT_FIRE
) then
1551 Data
.FXSubType
:= EFFECT_TELEPORT
;
1552 str
:= EffectToStr(Data
.FXSubType
);
1554 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_SUBTYPE
], str
, True)] do
1556 EditStyle
:= esEllipsis
;
1560 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_COLOR
], IntToStr(Data
.FXColorR
or (Data
.FXColorG
shl 8) or (Data
.FXColorB
shl 16)), True)] do
1562 EditStyle
:= esEllipsis
;
1566 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_CENTER
], BoolNames
[Data
.FXPos
= 0], True)] do
1568 EditStyle
:= esPickList
;
1572 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_DELAY
], IntToStr(Data
.FXWait
), True)] do
1574 EditStyle
:= esSimple
;
1578 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_VELX
], IntToStr(Data
.FXVelX
), True)] do
1580 EditStyle
:= esSimple
;
1584 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_VELY
], IntToStr(Data
.FXVelY
), True)] do
1586 EditStyle
:= esSimple
;
1590 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_SPL
], IntToStr(Data
.FXSpreadL
), True)] do
1592 EditStyle
:= esSimple
;
1596 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_SPR
], IntToStr(Data
.FXSpreadR
), True)] do
1598 EditStyle
:= esSimple
;
1602 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_SPU
], IntToStr(Data
.FXSpreadU
), True)] do
1604 EditStyle
:= esSimple
;
1608 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_SPD
], IntToStr(Data
.FXSpreadD
), True)] do
1610 EditStyle
:= esSimple
;
1614 end; //case TriggerType
1616 end; // OBJECT_TRIGGER:
1620 procedure ChangeShownProperty(Name
: String; NewValue
: String);
1624 if SelectedObjectCount() <> 1 then
1626 if not SelectedObjects
[GetFirstSelected()].Live
then
1629 // Есть ли такой ключ:
1630 if MainForm
.vleObjectProperty
.FindRow(Name
, row
) then
1632 MainForm
.vleObjectProperty
.Values
[Name
] := NewValue
;
1636 procedure SelectObject(fObjectType
: Byte; fID
: DWORD
; Multi
: Boolean);
1645 // Уже выделен - убираем:
1646 if SelectedObjects
<> nil then
1647 for a
:= 0 to High(SelectedObjects
) do
1648 with SelectedObjects
[a
] do
1649 if Live
and (ID
= fID
) and
1650 (ObjectType
= fObjectType
) then
1659 SetLength(SelectedObjects
, Length(SelectedObjects
)+1);
1661 with SelectedObjects
[High(SelectedObjects
)] do
1663 ObjectType
:= fObjectType
;
1670 SetLength(SelectedObjects
, 1);
1672 with SelectedObjects
[0] do
1674 ObjectType
:= fObjectType
;
1680 MainForm
.miCopy
.Enabled
:= True;
1681 MainForm
.miCut
.Enabled
:= True;
1683 if fObjectType
= OBJECT_PANEL
then
1685 MainForm
.miToFore
.Enabled
:= True;
1686 MainForm
.miToBack
.Enabled
:= True;
1690 procedure RemoveSelectFromObjects();
1692 SelectedObjects
:= nil;
1693 DrawPressRect
:= False;
1694 MouseLDown
:= False;
1695 MouseRDown
:= False;
1696 MouseAction
:= MOUSEACTION_NONE
;
1697 SelectFlag
:= SELECTFLAG_NONE
;
1698 ResizeType
:= RESIZETYPE_NONE
;
1699 ResizeDirection
:= RESIZEDIR_NONE
;
1701 MainForm
.vleObjectProperty
.Strings
.Clear();
1703 MainForm
.miCopy
.Enabled
:= False;
1704 MainForm
.miCut
.Enabled
:= False;
1705 MainForm
.miToFore
.Enabled
:= False;
1706 MainForm
.miToBack
.Enabled
:= False;
1709 procedure DeleteSelectedObjects();
1714 if SelectedObjects
= nil then
1720 for a
:= 0 to High(SelectedObjects
) do
1721 with SelectedObjects
[a
] do
1726 SetLength(UndoBuffer
, Length(UndoBuffer
)+1);
1727 i
:= High(UndoBuffer
);
1731 SetLength(UndoBuffer
[i
], Length(UndoBuffer
[i
])+1);
1732 ii
:= High(UndoBuffer
[i
]);
1737 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_PANEL
;
1738 New(UndoBuffer
[i
, ii
].Panel
);
1739 UndoBuffer
[i
, ii
].Panel
^ := gPanels
[ID
];
1743 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_ITEM
;
1744 UndoBuffer
[i
, ii
].Item
:= gItems
[ID
];
1748 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_AREA
;
1749 UndoBuffer
[i
, ii
].Area
:= gAreas
[ID
];
1753 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_TRIGGER
;
1754 UndoBuffer
[i
, ii
].Trigger
:= gTriggers
[ID
];
1758 RemoveObject(ID
, ObjectType
);
1761 RemoveSelectFromObjects();
1763 MainForm
.miUndo
.Enabled
:= UndoBuffer
<> nil;
1766 procedure Undo_Add(ObjectType
: Byte; ID
: DWORD
; Group
: Boolean = False);
1770 if (not Group
) or (Length(UndoBuffer
) = 0) then
1771 SetLength(UndoBuffer
, Length(UndoBuffer
)+1);
1772 SetLength(UndoBuffer
[High(UndoBuffer
)], Length(UndoBuffer
[High(UndoBuffer
)])+1);
1773 i
:= High(UndoBuffer
);
1774 ii
:= High(UndoBuffer
[i
]);
1778 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_PANEL
;
1780 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_ITEM
;
1782 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_MONSTER
;
1784 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_AREA
;
1786 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_TRIGGER
;
1789 UndoBuffer
[i
, ii
].AddID
:= ID
;
1791 MainForm
.miUndo
.Enabled
:= UndoBuffer
<> nil;
1794 procedure FullClear();
1796 RemoveSelectFromObjects();
1798 LoadSky(gMapInfo
.SkyName
);
1800 slInvalidTextures
.Clear();
1801 MapCheckForm
.lbErrorList
.Clear();
1802 MapCheckForm
.mErrorDescription
.Clear();
1804 MainForm
.miUndo
.Enabled
:= False;
1805 MainForm
.sbHorizontal
.Position
:= 0;
1806 MainForm
.sbVertical
.Position
:= 0;
1807 MainForm
.FormResize(nil);
1808 MainForm
.Caption
:= FormCaption
;
1813 procedure ErrorMessageBox(str
: String);
1815 MessageBox(0, PChar(str
), PChar(_lc
[I_MSG_ERROR
]),
1816 MB_ICONINFORMATION
or MB_OK
or MB_DEFBUTTON1
);
1819 function CheckProperty(): Boolean;
1825 _id
:= GetFirstSelected();
1827 if SelectedObjects
[_id
].ObjectType
= OBJECT_PANEL
then
1828 with gPanels
[SelectedObjects
[_id
].ID
] do
1830 if TextureWidth
<> 0 then
1831 if StrToIntDef(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_WIDTH
]], 1) mod TextureWidth
<> 0 then
1833 ErrorMessageBox(Format(_lc
[I_MSG_WRONG_TEXWIDTH
],
1838 if TextureHeight
<> 0 then
1839 if StrToIntDef(Trim(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_HEIGHT
]]), 1) mod TextureHeight
<> 0 then
1841 ErrorMessageBox(Format(_lc
[I_MSG_WRONG_TEXHEIGHT
],
1846 if IsTexturedPanel(PanelType
) and (TextureName
<> '') then
1847 if not (StrToIntDef(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_PANEL_ALPHA
]], -1) in [0..255]) then
1849 ErrorMessageBox(_lc
[I_MSG_WRONG_ALPHA
]);
1854 if SelectedObjects
[_id
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
] then
1855 if (StrToIntDef(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_WIDTH
]], 0) <= 0) or
1856 (StrToIntDef(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_HEIGHT
]], 0) <= 0) then
1858 ErrorMessageBox(_lc
[I_MSG_WRONG_SIZE
]);
1862 if (Trim(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_X
]]) = '') or
1863 (Trim(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]) = '') then
1865 ErrorMessageBox(_lc
[I_MSG_WRONG_XY
]);
1872 procedure SelectTexture(ID
: Integer);
1874 MainForm
.lbTextureList
.ItemIndex
:= ID
;
1875 MainForm
.lbTextureListClick(nil);
1878 function AddTexture(aWAD
, aSection
, aTex
: String; silent
: Boolean): Boolean;
1880 a
, FrameLen
: Integer;
1883 ResourceName
: String;
1884 UResourceName
: String;
1885 FullResourceName
: String;
1886 SectionName
: String;
1888 Width
, Height
: Word;
1891 if aSection
= '..' then
1894 SectionName
:= aSection
;
1896 if aWAD
= _lc
[I_WAD_SPECIAL_MAP
] then
1898 g_ProcessResourceStr(OpenedMap
, @fn
, nil, nil);
1899 //FileName := EditorDir+'maps\'+ExtractFileName(fn);
1901 ResourceName
:= ':'+SectionName
+'\'+aTex
;
1904 if aWAD
= _lc
[I_WAD_SPECIAL_TEXS
] then
1905 begin // Спец. текстуры
1907 ResourceName
:= aTex
;
1910 begin // Внешний WAD
1911 FileName
:= EditorDir
+'wads/'+aWAD
;
1912 ResourceName
:= aWAD
+':'+SectionName
+'\'+aTex
;
1916 UResourceName
:= win2utf(ResourceName
);
1918 // Есть ли уже такая текстура:
1919 for a
:= 0 to MainForm
.lbTextureList
.Items
.Count
-1 do
1920 if UResourceName
= MainForm
.lbTextureList
.Items
[a
] then
1923 ErrorMessageBox(Format(_lc
[I_MSG_TEXTURE_ALREADY
],
1928 // Название ресурса <= 64 символов:
1929 if Length(ResourceName
) > 64 then
1932 ErrorMessageBox(Format(_lc
[I_MSG_RES_NAME_64
],
1940 if aWAD
= _lc
[I_WAD_SPECIAL_TEXS
] then
1942 a
:= MainForm
.lbTextureList
.Items
.Add(UResourceName
);
1949 FullResourceName
:= FileName
+':'+SectionName
+'\'+aTex
;
1951 if IsAnim(FullResourceName
) then
1952 begin // Аним. текстура
1953 GetFrame(FullResourceName
, Data
, FrameLen
, Width
, Height
);
1955 if g_CreateTextureMemorySize(Data
, FrameLen
, ResourceName
, 0, 0, Width
, Height
, 1) then
1956 a
:= MainForm
.lbTextureList
.Items
.Add(UResourceName
);
1958 else // Обычная текстура
1960 if g_CreateTextureWAD(ResourceName
, FullResourceName
) then
1961 a
:= MainForm
.lbTextureList
.Items
.Add(UResourceName
);
1963 if (a
> -1) and (not silent
) then
1970 procedure UpdateCaption(sMap
, sFile
, sRes
: String);
1973 if (sFile
= '') and (sRes
= '') and (sMap
= '') then
1974 Caption
:= FormCaption
1977 Caption
:= Format('%s - %s:%s', [FormCaption
, sFile
, sRes
])
1979 if (sFile
<> '') and (sRes
<> '') then
1980 Caption
:= Format('%s - %s (%s:%s)', [FormCaption
, sMap
, sFile
, sRes
])
1982 Caption
:= Format('%s - %s', [FormCaption
, sMap
]);
1985 procedure OpenMap(FileName
: String; mapN
: String);
1990 SelectMapForm
.GetMaps(FileName
);
1992 if (FileName
= OpenedWAD
) and
1993 (OpenedMap
<> '') then
1995 MapName
:= OpenedMap
;
1996 while (Pos(':\', MapName
) > 0) do
1997 Delete(MapName
, 1, Pos(':\', MapName
) + 1);
1999 idx
:= SelectMapForm
.lbMapList
.Items
.IndexOf(MapName
);
2000 SelectMapForm
.lbMapList
.ItemIndex
:= idx
;
2003 if SelectMapForm
.lbMapList
.Count
> 0 then
2004 SelectMapForm
.lbMapList
.ItemIndex
:= 0
2006 SelectMapForm
.lbMapList
.ItemIndex
:= -1;
2011 idx
:= SelectMapForm
.lbMapList
.Items
.IndexOf(mapN
);
2015 if (SelectMapForm
.ShowModal() = mrOK
) and
2016 (SelectMapForm
.lbMapList
.ItemIndex
<> -1) then
2017 idx
:= SelectMapForm
.lbMapList
.ItemIndex
2022 MapName
:= SelectMapForm
.lbMapList
.Items
[idx
];
2028 pLoadProgress
.Left
:= (RenderPanel
.Width
div 2)-(pLoadProgress
.Width
div 2);
2029 pLoadProgress
.Top
:= (RenderPanel
.Height
div 2)-(pLoadProgress
.Height
div 2);
2030 pLoadProgress
.Show();
2032 OpenedMap
:= FileName
+':\'+MapName
;
2033 OpenedWAD
:= FileName
;
2035 idx
:= RecentFiles
.IndexOf(OpenedMap
);
2036 // Такая карта уже недавно открывалась:
2038 RecentFiles
.Delete(idx
);
2039 RecentFiles
.Insert(0, OpenedMap
);
2040 RefreshRecentMenu();
2044 pLoadProgress
.Hide();
2047 lbTextureList
.Sorted
:= True;
2048 lbTextureList
.Sorted
:= False;
2050 UpdateCaption(gMapInfo
.Name
, ExtractFileName(FileName
), MapName
);
2054 procedure MoveSelectedObjects(Wall
, alt
: Boolean; dx
, dy
: Integer);
2059 if SelectedObjects
= nil then
2066 for a
:= 0 to High(SelectedObjects
) do
2067 if SelectedObjects
[a
].Live
then
2069 if ObjectCollideLevel(SelectedObjects
[a
].ID
, SelectedObjects
[a
].ObjectType
, dx
, 0) then
2072 if ObjectCollideLevel(SelectedObjects
[a
].ID
, SelectedObjects
[a
].ObjectType
, 0, dy
) then
2075 if (not okX
) or (not okY
) then
2081 for a
:= 0 to High(SelectedObjects
) do
2082 if SelectedObjects
[a
].Live
then
2085 MoveObject(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
, dx
, 0);
2088 MoveObject(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
, 0, dy
);
2090 if alt
and (SelectedObjects
[a
].ObjectType
= OBJECT_TRIGGER
) then
2092 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_PRESS
,
2093 TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
] then
2094 begin // Двигаем зону Расширителя
2096 gTriggers
[SelectedObjects
[a
].ID
].Data
.tX
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.tX
+dx
;
2098 gTriggers
[SelectedObjects
[a
].ID
].Data
.tY
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.tY
+dy
;
2101 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_TELEPORT
] then
2102 begin // Двигаем точку назначения Телепорта
2104 gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.X
+dx
;
2106 gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.Y
+dy
;
2109 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SPAWNMONSTER
] then
2110 begin // Двигаем точку создания монстра
2112 gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.X
+dx
;
2114 gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.Y
+dy
;
2117 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SPAWNITEM
] then
2118 begin // Двигаем точку создания предмета
2120 gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.X
+dx
;
2122 gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.Y
+dy
;
2125 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SHOT
] then
2126 begin // Двигаем точку создания выстрела
2128 gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.X
+dx
;
2130 gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.Y
+dy
;
2135 LastMovePoint
:= MousePos
;
2139 procedure ShowLayer(Layer
: Byte; show
: Boolean);
2141 LayerEnabled
[Layer
] := show
;
2146 MainForm
.miLayer1
.Checked
:= show
;
2147 MainForm
.miLayerP1
.Checked
:= show
;
2151 MainForm
.miLayer2
.Checked
:= show
;
2152 MainForm
.miLayerP2
.Checked
:= show
;
2156 MainForm
.miLayer3
.Checked
:= show
;
2157 MainForm
.miLayerP3
.Checked
:= show
;
2161 MainForm
.miLayer4
.Checked
:= show
;
2162 MainForm
.miLayerP4
.Checked
:= show
;
2166 MainForm
.miLayer5
.Checked
:= show
;
2167 MainForm
.miLayerP5
.Checked
:= show
;
2171 MainForm
.miLayer6
.Checked
:= show
;
2172 MainForm
.miLayerP6
.Checked
:= show
;
2176 MainForm
.miLayer7
.Checked
:= show
;
2177 MainForm
.miLayerP7
.Checked
:= show
;
2181 MainForm
.miLayer8
.Checked
:= show
;
2182 MainForm
.miLayerP8
.Checked
:= show
;
2186 MainForm
.miLayer9
.Checked
:= show
;
2187 MainForm
.miLayerP9
.Checked
:= show
;
2191 RemoveSelectFromObjects();
2194 procedure SwitchLayer(Layer
: Byte);
2196 ShowLayer(Layer
, not LayerEnabled
[Layer
]);
2199 procedure SwitchMap();
2201 ShowMap
:= not ShowMap
;
2202 MainForm
.tbShowMap
.Down
:= ShowMap
;
2205 procedure ShowEdges();
2207 if drEdge
[3] < 255 then
2210 drEdge
[3] := gAlphaEdge
;
2213 function SelectedTexture(): String;
2215 if MainForm
.lbTextureList
.ItemIndex
<> -1 then
2216 Result
:= utf2win(MainForm
.lbTextureList
.Items
[MainForm
.lbTextureList
.ItemIndex
])
2221 function IsSpecialTextureSel(): Boolean;
2223 Result
:= (MainForm
.lbTextureList
.ItemIndex
<> -1) and
2224 IsSpecialTexture(utf2win(MainForm
.lbTextureList
.Items
[MainForm
.lbTextureList
.ItemIndex
]));
2227 function CopyBufferToString(var CopyBuf
: TCopyRecArray
): String;
2232 procedure AddInt(x
: Integer);
2234 Res
:= Res
+ IntToStr(x
) + ' ';
2240 if Length(CopyBuf
) = 0 then
2243 Res
:= CLIPBOARD_SIG
+ ' ';
2245 for i
:= 0 to High(CopyBuf
) do
2247 if (CopyBuf
[i
].ObjectType
= OBJECT_PANEL
) and
2248 (CopyBuf
[i
].Panel
= nil) then
2252 AddInt(CopyBuf
[i
].ObjectType
);
2255 // Свойства объекта:
2256 case CopyBuf
[i
].ObjectType
of
2258 with CopyBuf
[i
].Panel
^ do
2265 Res
:= Res
+ '"' + TextureName
+ '" ';
2267 AddInt(IfThen(Blending
, 1, 0));
2271 with CopyBuf
[i
].Item
do
2276 AddInt(IfThen(OnlyDM
, 1, 0));
2277 AddInt(IfThen(Fall
, 1, 0));
2281 with CopyBuf
[i
].Monster
do
2283 AddInt(MonsterType
);
2286 AddInt(IfThen(Direction
= D_LEFT
, 1, 0));
2290 with CopyBuf
[i
].Area
do
2295 AddInt(IfThen(Direction
= D_LEFT
, 1, 0));
2299 with CopyBuf
[i
].Trigger
do
2301 AddInt(TriggerType
);
2306 AddInt(ActivateType
);
2308 AddInt(IfThen(Enabled
, 1, 0));
2309 AddInt(TexturePanel
);
2311 for j
:= 0 to 127 do
2312 AddInt(Data
.Default
[j
]);
2320 procedure StringToCopyBuffer(Str
: String; var CopyBuf
: TCopyRecArray
);
2324 function GetNext(): String;
2329 if Str
[1] = '"' then
2341 Result
:= Copy(Str
, 1, p
-1);
2357 Result
:= Copy(Str
, 1, p
-1);
2367 if GetNext() <> CLIPBOARD_SIG
then
2373 t
:= StrToIntDef(GetNext(), 0);
2375 if (t
< OBJECT_PANEL
) or (t
> OBJECT_TRIGGER
) or
2376 (GetNext() <> ';') then
2377 begin // Что-то не то => пропускаем:
2385 i
:= Length(CopyBuf
);
2386 SetLength(CopyBuf
, i
+ 1);
2388 CopyBuf
[i
].ObjectType
:= t
;
2389 CopyBuf
[i
].Panel
:= nil;
2391 // Свойства объекта:
2395 New(CopyBuf
[i
].Panel
);
2397 with CopyBuf
[i
].Panel
^ do
2399 PanelType
:= StrToIntDef(GetNext(), PANEL_WALL
);
2400 X
:= StrToIntDef(GetNext(), 0);
2401 Y
:= StrToIntDef(GetNext(), 0);
2402 Width
:= StrToIntDef(GetNext(), 16);
2403 Height
:= StrToIntDef(GetNext(), 16);
2404 TextureName
:= GetNext();
2405 Alpha
:= StrToIntDef(GetNext(), 0);
2406 Blending
:= (GetNext() = '1');
2411 with CopyBuf
[i
].Item
do
2413 ItemType
:= StrToIntDef(GetNext(), ITEM_MEDKIT_SMALL
);
2414 X
:= StrToIntDef(GetNext(), 0);
2415 Y
:= StrToIntDef(GetNext(), 0);
2416 OnlyDM
:= (GetNext() = '1');
2417 Fall
:= (GetNext() = '1');
2421 with CopyBuf
[i
].Monster
do
2423 MonsterType
:= StrToIntDef(GetNext(), MONSTER_DEMON
);
2424 X
:= StrToIntDef(GetNext(), 0);
2425 Y
:= StrToIntDef(GetNext(), 0);
2427 if GetNext() = '1' then
2430 Direction
:= D_RIGHT
;
2434 with CopyBuf
[i
].Area
do
2436 AreaType
:= StrToIntDef(GetNext(), AREA_PLAYERPOINT1
);
2437 X
:= StrToIntDef(GetNext(), 0);
2438 Y
:= StrToIntDef(GetNext(), 0);
2439 if GetNext() = '1' then
2442 Direction
:= D_RIGHT
;
2446 with CopyBuf
[i
].Trigger
do
2448 TriggerType
:= StrToIntDef(GetNext(), TRIGGER_EXIT
);
2449 X
:= StrToIntDef(GetNext(), 0);
2450 Y
:= StrToIntDef(GetNext(), 0);
2451 Width
:= StrToIntDef(GetNext(), 16);
2452 Height
:= StrToIntDef(GetNext(), 16);
2453 ActivateType
:= StrToIntDef(GetNext(), 0);
2454 Key
:= StrToIntDef(GetNext(), 0);
2455 Enabled
:= (GetNext() = '1');
2456 TexturePanel
:= StrToIntDef(GetNext(), 0);
2458 for j
:= 0 to 127 do
2459 Data
.Default
[j
] := StrToIntDef(GetNext(), 0);
2465 //----------------------------------------
2466 //Закончились вспомогательные процедуры
2467 //----------------------------------------
2469 procedure TMainForm
.RefreshRecentMenu();
2474 // Лишние запомненные карты:
2475 while RecentFiles
.Count
> RecentCount
do
2476 RecentFiles
.Delete(RecentFiles
.Count
-1);
2478 // Лишние строки меню:
2479 while MainMenu
.Items
[0].Count
> RECENT_FILES_MENU_START
do
2480 MainMenu
.Items
[0].Delete(MainMenu
.Items
[0].Count
-1);
2482 // Отделение списка карт от строки "Выход":
2483 if RecentFiles
.Count
> 0 then
2485 MI
:= TMenuItem
.Create(MainMenu
.Items
[0]);
2487 MainMenu
.Items
[0].Add(MI
);
2490 // Добавление в меню списка запомненных карт:
2491 for i
:= 0 to RecentFiles
.Count
-1 do
2493 MI
:= TMenuItem
.Create(MainMenu
.Items
[0]);
2494 MI
.Caption
:= IntToStr(i
+1) + ' ' + RecentFiles
[i
];
2495 MI
.OnClick
:= aRecentFileExecute
;
2496 MainMenu
.Items
[0].Add(MI
);
2500 procedure TMainForm
.aRecentFileExecute(Sender
: TObject
);
2505 s
:= LowerCase((Sender
as TMenuItem
).Caption
);
2506 Delete(s
, Pos('&', s
), 1);
2507 s
:= Trim(Copy(s
, 1, 2));
2508 n
:= StrToIntDef(s
, 0) - 1;
2510 if (n
< 0) or (n
>= RecentFiles
.Count
) then
2513 s
:= RecentFiles
[n
];
2514 pw
:= Pos('.wad:\', LowerCase(s
));
2517 begin // Map name included
2518 fn
:= Copy(s
, 1, pw
+ 3);
2519 Delete(s
, 1, pw
+ 5);
2520 if (FileExists(fn
)) then
2523 else // Only wad name
2524 if (FileExists(s
)) then
2528 procedure TMainForm
.aEditorOptionsExecute(Sender
: TObject
);
2530 OptionsForm
.ShowModal();
2533 procedure LoadStdFont(cfgres
, texture
: string; var FontID
: DWORD
);
2545 wad
:= TWADEditor_1
.Create
;
2546 if wad
.ReadFile(EditorDir
+'data/Game.wad') then
2547 wad
.GetResource('FONTS', cfgres
, cfgdata
, cfglen
);
2552 if not g_CreateTextureWAD('FONT_STD', EditorDir
+'data/Game.wad:FONTS\'+texture
) then
2553 e_WriteLog('ERROR ERROR ERROR', MSG_WARNING
);
2555 config
:= TConfig
.CreateMem(cfgdata
, cfglen
);
2556 cwdt
:= Min(Max(config
.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
2557 chgt
:= Min(Max(config
.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
2558 spc
:= Min(Max(config
.ReadInt('FontMap', 'Kerning', 0), -128), 127);
2560 if g_GetTexture('FONT_STD', ID
) then
2561 e_TextureFontBuild(ID
, FontID
, cwdt
, chgt
, spc
-2);
2566 e_WriteLog('Could not load FONT_STD', MSG_WARNING
);
2568 if cfglen
<> 0 then FreeMem(cfgdata
);
2571 procedure TMainForm
.FormCreate(Sender
: TObject
);
2579 EditorDir
:= ExtractFilePath(Application
.ExeName
);
2581 e_InitLog(EditorDir
+'Editor.log', WM_NEWFILE
);
2583 slInvalidTextures
:= TStringList
.Create
;
2585 ShowLayer(LAYER_BACK
, True);
2586 ShowLayer(LAYER_WALLS
, True);
2587 ShowLayer(LAYER_FOREGROUND
, True);
2588 ShowLayer(LAYER_STEPS
, True);
2589 ShowLayer(LAYER_WATER
, True);
2590 ShowLayer(LAYER_ITEMS
, True);
2591 ShowLayer(LAYER_MONSTERS
, True);
2592 ShowLayer(LAYER_AREAS
, True);
2593 ShowLayer(LAYER_TRIGGERS
, True);
2597 FormCaption
:= MainForm
.Caption
;
2601 config
:= TConfig
.CreateFile(EditorDir
+'Editor.cfg');
2603 if config
.ReadInt('Editor', 'XPos', -1) = -1 then
2604 Position
:= poDesktopCenter
2606 Left
:= config
.ReadInt('Editor', 'XPos', Left
);
2607 Top
:= config
.ReadInt('Editor', 'YPos', Top
);
2608 Width
:= config
.ReadInt('Editor', 'Width', Width
);
2609 Height
:= config
.ReadInt('Editor', 'Height', Height
);
2611 if config
.ReadBool('Editor', 'Maximize', False) then
2612 WindowState
:= wsMaximized
;
2613 ShowMap
:= config
.ReadBool('Editor', 'Minimap', False);
2614 PanelProps
.Width
:= config
.ReadInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
2615 Splitter1
.Left
:= PanelProps
.Left
;
2616 PanelObjs
.Height
:= config
.ReadInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
2617 Splitter2
.Top
:= PanelObjs
.Top
;
2618 StatusBar
.Top
:= PanelObjs
.BoundsRect
.Bottom
;
2619 DotEnable
:= config
.ReadBool('Editor', 'DotEnable', True);
2620 DotColor
:= config
.ReadInt('Editor', 'DotColor', $FFFFFF);
2621 DotStepOne
:= config
.ReadInt('Editor', 'DotStepOne', 16);
2622 DotStepTwo
:= config
.ReadInt('Editor', 'DotStepTwo', 8);
2623 DotStep
:= config
.ReadInt('Editor', 'DotStep', DotStepOne
);
2624 DrawTexturePanel
:= config
.ReadBool('Editor', 'DrawTexturePanel', True);
2625 DrawPanelSize
:= config
.ReadBool('Editor', 'DrawPanelSize', True);
2626 BackColor
:= config
.ReadInt('Editor', 'BackColor', $7F6040);
2627 PreviewColor
:= config
.ReadInt('Editor', 'PreviewColor', $00FF00);
2628 gColorEdge
:= config
.ReadInt('Editor', 'EdgeColor', COLOR_EDGE
);
2629 gAlphaEdge
:= config
.ReadInt('Editor', 'EdgeAlpha', ALPHA_EDGE
);
2630 if gAlphaEdge
= 255 then
2631 gAlphaEdge
:= ALPHA_EDGE
;
2632 drEdge
[0] := GetRValue(gColorEdge
);
2633 drEdge
[1] := GetGValue(gColorEdge
);
2634 drEdge
[2] := GetBValue(gColorEdge
);
2635 if not config
.ReadBool('Editor', 'EdgeShow', True) then
2638 drEdge
[3] := gAlphaEdge
;
2639 gAlphaTriggerLine
:= config
.ReadInt('Editor', 'LineAlpha', ALPHA_LINE
);
2640 if gAlphaTriggerLine
= 255 then
2641 gAlphaTriggerLine
:= ALPHA_LINE
;
2642 gAlphaTriggerArea
:= config
.ReadInt('Editor', 'TriggerAlpha', ALPHA_AREA
);
2643 if gAlphaTriggerArea
= 255 then
2644 gAlphaTriggerArea
:= ALPHA_AREA
;
2645 if config
.ReadInt('Editor', 'Scale', 0) = 1 then
2649 if config
.ReadInt('Editor', 'DotSize', 0) = 1 then
2653 OpenDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastOpenDir', EditorDir
);
2654 SaveDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastSaveDir', EditorDir
);
2656 s
:= config
.ReadStr('Editor', 'Language', '');
2659 RecentCount
:= config
.ReadInt('Editor', 'RecentCount', 5);
2660 if RecentCount
> 10 then
2662 if RecentCount
< 2 then
2665 RecentFiles
:= TStringList
.Create();
2666 for i
:= 0 to RecentCount
-1 do
2668 s
:= config
.ReadStr('RecentFiles', IntToStr(i
+1), '');
2672 RefreshRecentMenu();
2676 tbShowMap
.Down
:= ShowMap
;
2677 tbGridOn
.Down
:= DotEnable
;
2678 pcObjects
.ActivePageIndex
:= 0;
2679 Application
.Title
:= _lc
[I_EDITOR_TITLE
];
2681 Application
.OnIdle
:= OnIdle
;
2684 procedure PrintBlack(X
, Y
: Integer; Text: string; FontID
: DWORD
);
2686 // NOTE: all the font printing routines assume CP1251
2687 e_TextureFontPrintEx(X
, Y
, Text, FontID
, 0, 0, 0, 1.0);
2690 procedure TMainForm
.Draw();
2695 Width
, Height
: Word;
2698 aX
, aY
, aX2
, aY2
, XX
, ScaleSz
: Integer;
2702 e_Clear(GL_COLOR_BUFFER_BIT
,
2703 GetRValue(BackColor
)/255,
2704 GetGValue(BackColor
)/255,
2705 GetBValue(BackColor
)/255);
2709 ObjCount
:= SelectedObjectCount();
2711 // Обводим выделенные объекты красной рамкой:
2712 if ObjCount
> 0 then
2714 for a
:= 0 to High(SelectedObjects
) do
2715 if SelectedObjects
[a
].Live
then
2717 Rect
:= ObjectGetRect(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
);
2721 e_DrawQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2722 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2725 // Рисуем точки изменения размеров:
2726 if (ObjCount
= 1) and
2727 (SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) then
2729 e_DrawPoint(5, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2730 e_DrawPoint(5, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2731 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 255, 255);
2732 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 255, 255);
2734 e_DrawPoint(3, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2735 e_DrawPoint(3, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2736 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 0, 0);
2737 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 0, 0);
2744 if DotEnable
and (not PreviewMode
) then
2751 for x
:= 0 to (RenderPanel
.Width
div DotStep
) do
2752 for y
:= 0 to (RenderPanel
.Height
div DotStep
) do
2753 e_DrawPoint(DotSize
, x
*DotStep
+ a
, y
*DotStep
+ a
,
2754 GetRValue(DotColor
),
2755 GetGValue(DotColor
),
2756 GetBValue(DotColor
));
2760 if (lbTextureList
.ItemIndex
<> -1) and (cbPreview
.Checked
) and
2761 (not IsSpecialTextureSel()) and (not PreviewMode
) then
2763 if not g_GetTexture(SelectedTexture(), ID
) then
2764 g_GetTexture('NOTEXTURE', ID
);
2765 g_GetTextureSizeByID(ID
, Width
, Height
);
2766 if g_GetTexture('PREVIEW', PID
) then
2767 e_DrawFill(PID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, Width
div 16 + 1, Height
div 16 + 1, 0, True, False);
2768 e_Draw(ID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, 0, True, False);
2771 // Подсказка при выборе точки Телепорта:
2772 if SelectFlag
= SELECTFLAG_TELEPORT
then
2774 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
2775 if Data
.d2d_teleport
then
2776 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
2777 MousePos
.X
+16, MousePos
.Y
-1,
2780 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+AreaSize
[AREA_DMPOINT
].Width
-1,
2781 MousePos
.Y
+AreaSize
[AREA_DMPOINT
].Height
-1, 255, 255, 255);
2783 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
2784 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
2785 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_TELEPORT
], gEditorFont
);
2788 // Подсказка при выборе точки появления:
2789 if SelectFlag
= SELECTFLAG_SPAWNPOINT
then
2791 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
2792 MousePos
.X
+16, MousePos
.Y
-1,
2794 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
2795 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
2796 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_SPAWN
], gEditorFont
);
2799 // Подсказка при выборе панели двери:
2800 if SelectFlag
= SELECTFLAG_DOOR
then
2802 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
2803 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
2804 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_PANEL_DOOR
], gEditorFont
);
2807 // Подсказка при выборе панели с текстурой:
2808 if SelectFlag
= SELECTFLAG_TEXTURE
then
2810 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 192, 192, 192, 127);
2811 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 255, 255, 255);
2812 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_PANEL_TEXTURE
], gEditorFont
);
2815 // Подсказка при выборе панели индикации выстрела:
2816 if SelectFlag
= SELECTFLAG_SHOTPANEL
then
2818 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 192, 192, 192, 127);
2819 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 255, 255, 255);
2820 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_PANEL_SHOT
], gEditorFont
);
2823 // Подсказка при выборе панели лифта:
2824 if SelectFlag
= SELECTFLAG_LIFT
then
2826 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
2827 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
2828 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_PANEL_LIFT
], gEditorFont
);
2831 // Подсказка при выборе монстра:
2832 if SelectFlag
= SELECTFLAG_MONSTER
then
2834 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 192, 192, 192, 127);
2835 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 255, 255, 255);
2836 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_MONSTER
], gEditorFont
);
2839 // Подсказка при выборе области воздействия:
2840 if DrawPressRect
then
2842 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 192, 192, 192, 127);
2843 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 255, 255, 255);
2844 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_EXT_AREA
], gEditorFont
);
2847 // Рисуем текстуры, если чертим панель:
2848 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and (DrawTexturePanel
) and
2849 (lbTextureList
.ItemIndex
<> -1) and (DrawRect
<> nil) and
2850 (lbPanelType
.ItemIndex
in [0..8]) and not IsSpecialTextureSel() then
2852 if not g_GetTexture(SelectedTexture(), ID
) then
2853 g_GetTexture('NOTEXTURE', ID
);
2854 g_GetTextureSizeByID(ID
, Width
, Height
);
2856 e_DrawFill(ID
, Min(Left
, Right
), Min(Top
, Bottom
), Abs(Right
-Left
) div Width
,
2857 Abs(Bottom
-Top
) div Height
, 0, True, False);
2860 // Прямоугольник выделения:
2861 if DrawRect
<> nil then
2863 e_DrawQuad(Left
, Top
, Right
-1, Bottom
-1, 255, 255, 255);
2865 // Чертим мышью панель/триггер или меняем мышью их размер:
2866 if (MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
, MOUSEACTION_RESIZE
]) and
2867 (DrawPanelSize
) then
2869 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 192, 192, 192, 127);
2870 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 255, 255, 255);
2872 if MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
] then
2873 begin // Чертим новый
2874 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(_glc
[I_HINT_WIDTH
],
2875 [Abs(MousePos
.X
-MouseLDownPos
.X
)]), gEditorFont
);
2876 PrintBlack(MousePos
.X
+2, MousePos
.Y
+14, Format(_glc
[I_HINT_HEIGHT
],
2877 [Abs(MousePos
.Y
-MouseLDownPos
.Y
)]), gEditorFont
);
2879 else // Растягиваем существующий
2880 if SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
] then
2882 if SelectedObjects
[GetFirstSelected
].ObjectType
= OBJECT_PANEL
then
2884 Width
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
2885 Height
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
2889 Width
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
2890 Height
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
2893 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(_glc
[I_HINT_WIDTH
], [Width
]),
2895 PrintBlack(MousePos
.X
+2, MousePos
.Y
+14, Format(_glc
[I_HINT_HEIGHT
], [Height
]),
2900 // Ближайшая к курсору мыши точка на сетке:
2901 e_DrawPoint(3, MousePos
.X
, MousePos
.Y
, 0, 0, 255);
2906 // Сколько пикселов карты в 1 пикселе мини-карты:
2907 ScaleSz
:= 16 div Scale
;
2908 // Размеры мини-карты:
2909 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
2910 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
2911 // X-координата на RenderPanel нулевой x-координаты карты:
2912 XX
:= RenderPanel
.Width
- aX
- 1;
2914 e_DrawFillQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 0, 0, 0, 0);
2915 e_DrawQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 197, 197, 197);
2917 if gPanels
<> nil then
2920 for a
:= 0 to High(gPanels
) do
2922 if PanelType
<> 0 then
2924 // Левый верхний угол:
2925 aX
:= XX
+ (X
div ScaleSz
);
2926 aY
:= 1 + (Y
div ScaleSz
);
2928 aX2
:= max(Width
div ScaleSz
, 1);
2929 aY2
:= max(Height
div ScaleSz
, 1);
2930 // Правый нижний угол:
2931 aX2
:= aX
+ aX2
- 1;
2932 aY2
:= aY
+ aY2
- 1;
2935 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
2936 PANEL_WATER
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
2937 PANEL_ACID1
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
2938 PANEL_ACID2
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
2939 PANEL_STEP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
2940 PANEL_LIFTUP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
2941 PANEL_LIFTDOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
2942 PANEL_LIFTLEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
2943 PANEL_LIFTRIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
2944 PANEL_OPENDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 100, 220, 92, 0);
2945 PANEL_CLOSEDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 212, 184, 64, 0);
2946 PANEL_BLOCKMON
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 192, 0, 192, 0);
2950 // Рисуем красным выделенные панели:
2951 if SelectedObjects
<> nil then
2952 for b
:= 0 to High(SelectedObjects
) do
2953 with SelectedObjects
[b
] do
2954 if Live
and (ObjectType
= OBJECT_PANEL
) then
2955 with gPanels
[SelectedObjects
[b
].ID
] do
2956 if PanelType
and not(PANEL_BACK
or PANEL_FORE
) <> 0 then
2958 // Левый верхний угол:
2959 aX
:= XX
+ (X
div ScaleSz
);
2960 aY
:= 1 + (Y
div ScaleSz
);
2962 aX2
:= max(Width
div ScaleSz
, 1);
2963 aY2
:= max(Height
div ScaleSz
, 1);
2964 // Правый нижний угол:
2965 aX2
:= aX
+ aX2
- 1;
2966 aY2
:= aY
+ aY2
- 1;
2968 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0)
2972 if (gMapInfo
.Width
> RenderPanel
.Width
) or
2973 (gMapInfo
.Height
> RenderPanel
.Height
) then
2975 // Окно, показывающее текущее положение экрана на карте:
2977 x
:= max(min(RenderPanel
.Width
, gMapInfo
.Width
) div ScaleSz
, 1);
2978 y
:= max(min(RenderPanel
.Height
, gMapInfo
.Height
) div ScaleSz
, 1);
2979 // Левый верхний угол:
2980 aX
:= XX
+ ((-MapOffset
.X
) div ScaleSz
);
2981 aY
:= 1 + ((-MapOffset
.Y
) div ScaleSz
);
2982 // Правый нижний угол:
2986 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 127, 192, 127, 127, B_BLEND
);
2987 e_DrawQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0);
2992 RenderPanel
.SwapBuffers();
2995 procedure TMainForm
.FormResize(Sender
: TObject
);
2997 e_SetViewPort(0, 0, RenderPanel
.Width
, RenderPanel
.Height
);
2999 if gMapInfo
.Width
>= RenderPanel
.Width
then
3000 sbHorizontal
.Max
:= Normalize16(gMapInfo
.Width
-RenderPanel
.Width
+16)
3002 sbHorizontal
.Max
:= 0;
3004 if gMapInfo
.Height
>= RenderPanel
.Height
then
3005 sbVertical
.Max
:= Normalize16(gMapInfo
.Height
-RenderPanel
.Height
+16)
3007 sbVertical
.Max
:= 0;
3009 MapOffset
.X
:= -Normalize16(sbHorizontal
.Position
);
3010 MapOffset
.Y
:= -Normalize16(sbVertical
.Position
);
3013 procedure SelectNextObject(X
, Y
: Integer; ObjectType
: Byte; ID
: DWORD
);
3018 j_max
:= 0; // shut up compiler
3022 res
:= (gPanels
<> nil) and
3023 PanelInShownLayer(gPanels
[ID
].PanelType
) and
3024 g_CollidePoint(X
, Y
, gPanels
[ID
].X
, gPanels
[ID
].Y
,
3026 gPanels
[ID
].Height
);
3027 j_max
:= Length(gPanels
) - 1;
3032 res
:= (gItems
<> nil) and
3033 LayerEnabled
[LAYER_ITEMS
] and
3034 g_CollidePoint(X
, Y
, gItems
[ID
].X
, gItems
[ID
].Y
,
3035 ItemSize
[gItems
[ID
].ItemType
][0],
3036 ItemSize
[gItems
[ID
].ItemType
][1]);
3037 j_max
:= Length(gItems
) - 1;
3042 res
:= (gMonsters
<> nil) and
3043 LayerEnabled
[LAYER_MONSTERS
] and
3044 g_CollidePoint(X
, Y
, gMonsters
[ID
].X
, gMonsters
[ID
].Y
,
3045 MonsterSize
[gMonsters
[ID
].MonsterType
].Width
,
3046 MonsterSize
[gMonsters
[ID
].MonsterType
].Height
);
3047 j_max
:= Length(gMonsters
) - 1;
3052 res
:= (gAreas
<> nil) and
3053 LayerEnabled
[LAYER_AREAS
] and
3054 g_CollidePoint(X
, Y
, gAreas
[ID
].X
, gAreas
[ID
].Y
,
3055 AreaSize
[gAreas
[ID
].AreaType
].Width
,
3056 AreaSize
[gAreas
[ID
].AreaType
].Height
);
3057 j_max
:= Length(gAreas
) - 1;
3062 res
:= (gTriggers
<> nil) and
3063 LayerEnabled
[LAYER_TRIGGERS
] and
3064 g_CollidePoint(X
, Y
, gTriggers
[ID
].X
, gTriggers
[ID
].Y
,
3065 gTriggers
[ID
].Width
,
3066 gTriggers
[ID
].Height
);
3067 j_max
:= Length(gTriggers
) - 1;
3077 // Перебор ID: от ID-1 до 0; потом от High до ID+1:
3086 if j
= Integer(ID
) then
3091 res
:= PanelInShownLayer(gPanels
[j
].PanelType
) and
3092 g_CollidePoint(X
, Y
, gPanels
[j
].X
, gPanels
[j
].Y
,
3096 res
:= (gItems
[j
].ItemType
<> ITEM_NONE
) and
3097 g_CollidePoint(X
, Y
, gItems
[j
].X
, gItems
[j
].Y
,
3098 ItemSize
[gItems
[j
].ItemType
][0],
3099 ItemSize
[gItems
[j
].ItemType
][1]);
3101 res
:= (gMonsters
[j
].MonsterType
<> MONSTER_NONE
) and
3102 g_CollidePoint(X
, Y
, gMonsters
[j
].X
, gMonsters
[j
].Y
,
3103 MonsterSize
[gMonsters
[j
].MonsterType
].Width
,
3104 MonsterSize
[gMonsters
[j
].MonsterType
].Height
);
3106 res
:= (gAreas
[j
].AreaType
<> AREA_NONE
) and
3107 g_CollidePoint(X
, Y
, gAreas
[j
].X
, gAreas
[j
].Y
,
3108 AreaSize
[gAreas
[j
].AreaType
].Width
,
3109 AreaSize
[gAreas
[j
].AreaType
].Height
);
3111 res
:= (gTriggers
[j
].TriggerType
<> TRIGGER_NONE
) and
3112 g_CollidePoint(X
, Y
, gTriggers
[j
].X
, gTriggers
[j
].Y
,
3114 gTriggers
[j
].Height
);
3121 SetLength(SelectedObjects
, 1);
3123 SelectedObjects
[0].ObjectType
:= ObjectType
;
3124 SelectedObjects
[0].ID
:= j
;
3125 SelectedObjects
[0].Live
:= True;
3133 procedure TMainForm
.RenderPanelMouseDown(Sender
: TObject
;
3134 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3138 c1
, c2
, c3
, c4
: Boolean;
3144 MainForm
.ActiveControl
:= RenderPanel
;
3145 RenderPanel
.SetFocus();
3147 RenderPanelMouseMove(RenderPanel
, Shift
, X
, Y
);
3149 if Button
= mbLeft
then // Left Mouse Button
3151 // Двигаем карту с помощью мыши и мини-карты:
3153 g_CollidePoint(X
, Y
,
3154 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3156 max(gMapInfo
.Width
div (16 div Scale
), 1),
3157 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3160 MouseAction
:= MOUSEACTION_MOVEMAP
;
3162 else // Ставим предмет/монстра/область:
3163 if (pcObjects
.ActivePageIndex
in [1, 2, 3]) and
3164 (not (ssShift
in Shift
)) then
3166 case pcObjects
.ActivePageIndex
of
3168 if lbItemList
.ItemIndex
= -1 then
3169 ErrorMessageBox(_lc
[I_MSG_CHOOSE_ITEM
])
3172 item
.ItemType
:= lbItemList
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
3173 if item
.ItemType
>= ITEM_WEAPON_KASTET
then
3174 item
.ItemType
:= item
.ItemType
+ 2;
3175 item
.X
:= MousePos
.X
-MapOffset
.X
;
3176 item
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3178 if not (ssCtrl
in Shift
) then
3180 item
.X
:= item
.X
- (ItemSize
[item
.ItemType
][0] div 2);
3181 item
.Y
:= item
.Y
- ItemSize
[item
.ItemType
][1];
3184 item
.OnlyDM
:= cbOnlyDM
.Checked
;
3185 item
.Fall
:= cbFall
.Checked
;
3186 Undo_Add(OBJECT_ITEM
, AddItem(item
));
3189 if lbMonsterList
.ItemIndex
= -1 then
3190 ErrorMessageBox(_lc
[I_MSG_CHOOSE_MONSTER
])
3193 monster
.MonsterType
:= lbMonsterList
.ItemIndex
+ MONSTER_DEMON
;
3194 monster
.X
:= MousePos
.X
-MapOffset
.X
;
3195 monster
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3197 if not (ssCtrl
in Shift
) then
3199 monster
.X
:= monster
.X
- (MonsterSize
[monster
.MonsterType
].Width
div 2);
3200 monster
.Y
:= monster
.Y
- MonsterSize
[monster
.MonsterType
].Height
;
3203 if rbMonsterLeft
.Checked
then
3204 monster
.Direction
:= D_LEFT
3206 monster
.Direction
:= D_RIGHT
;
3207 Undo_Add(OBJECT_MONSTER
, AddMonster(monster
));
3210 if lbAreasList
.ItemIndex
= -1 then
3211 ErrorMessageBox(_lc
[I_MSG_CHOOSE_AREA
])
3213 if (lbAreasList
.ItemIndex
+ 1) <> AREA_DOMFLAG
then
3215 area
.AreaType
:= lbAreasList
.ItemIndex
+ AREA_PLAYERPOINT1
;
3216 area
.X
:= MousePos
.X
-MapOffset
.X
;
3217 area
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3219 if not (ssCtrl
in Shift
) then
3221 area
.X
:= area
.X
- (AreaSize
[area
.AreaType
].Width
div 2);
3222 area
.Y
:= area
.Y
- AreaSize
[area
.AreaType
].Height
;
3225 if rbAreaLeft
.Checked
then
3226 area
.Direction
:= D_LEFT
3228 area
.Direction
:= D_RIGHT
;
3229 Undo_Add(OBJECT_AREA
, AddArea(area
));
3235 i
:= GetFirstSelected();
3237 // Выбираем объект под текущим:
3238 if (SelectedObjects
<> nil) and
3239 (ssShift
in Shift
) and (i
>= 0) and
3240 (SelectedObjects
[i
].Live
) then
3242 if SelectedObjectCount() = 1 then
3243 SelectNextObject(X
-MapOffset
.X
, Y
-MapOffset
.Y
,
3244 SelectedObjects
[i
].ObjectType
,
3245 SelectedObjects
[i
].ID
);
3249 // Рисуем область триггера "Расширитель":
3250 if DrawPressRect
and (i
>= 0) and
3251 (SelectedObjects
[i
].ObjectType
= OBJECT_TRIGGER
) and
3252 (gTriggers
[SelectedObjects
[i
].ID
].TriggerType
in
3253 [TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
]) then
3254 MouseAction
:= MOUSEACTION_DRAWPRESS
3255 else // Рисуем панель:
3256 if pcObjects
.ActivePageIndex
= 0 then
3258 if (lbPanelType
.ItemIndex
>= 0) then
3259 MouseAction
:= MOUSEACTION_DRAWPANEL
3261 else // Рисуем триггер:
3262 if (lbTriggersList
.ItemIndex
>= 0) then
3264 MouseAction
:= MOUSEACTION_DRAWTRIGGER
;
3268 end; // if Button = mbLeft
3270 if Button
= mbRight
then // Right Mouse Button
3272 // Клик по мини-карте:
3274 g_CollidePoint(X
, Y
,
3275 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3277 max(gMapInfo
.Width
div (16 div Scale
), 1),
3278 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3280 MouseAction
:= MOUSEACTION_NOACTION
;
3282 else // Нужно что-то выбрать мышью:
3283 if SelectFlag
<> SELECTFLAG_NONE
then
3286 SELECTFLAG_TELEPORT
:
3287 // Точку назначения телепортации:
3288 with gTriggers
[SelectedObjects
[
3289 GetFirstSelected() ].ID
].Data
.TargetPoint
do
3291 X
:= MousePos
.X
-MapOffset
.X
;
3292 Y
:= MousePos
.Y
-MapOffset
.Y
;
3295 SELECTFLAG_SPAWNPOINT
:
3296 // Точку создания монстра:
3297 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
3298 if TriggerType
= TRIGGER_SPAWNMONSTER
then
3300 Data
.MonPos
.X
:= MousePos
.X
-MapOffset
.X
;
3301 Data
.MonPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3303 else if TriggerType
= TRIGGER_SPAWNITEM
then
3304 begin // Точка создания предмета:
3305 Data
.ItemPos
.X
:= MousePos
.X
-MapOffset
.X
;
3306 Data
.ItemPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3308 else if TriggerType
= TRIGGER_SHOT
then
3309 begin // Точка создания выстрела:
3310 Data
.ShotPos
.X
:= MousePos
.X
-MapOffset
.X
;
3311 Data
.ShotPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3317 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3319 2, 2, OBJECT_PANEL
, True);
3320 if IDArray
<> nil then
3322 for i
:= 0 to High(IDArray
) do
3323 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3324 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
) then
3326 gTriggers
[SelectedObjects
[
3327 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3332 gTriggers
[SelectedObjects
[
3333 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3337 // Панель с текстурой:
3339 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3341 2, 2, OBJECT_PANEL
, True);
3342 if IDArray
<> nil then
3344 for i
:= 0 to High(IDArray
) do
3345 if ((gPanels
[IDArray
[i
]].PanelType
in
3346 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3347 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3349 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3350 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3351 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3353 gTriggers
[SelectedObjects
[
3354 GetFirstSelected() ].ID
].TexturePanel
:= IDArray
[i
];
3359 gTriggers
[SelectedObjects
[
3360 GetFirstSelected() ].ID
].TexturePanel
:= -1;
3366 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3368 2, 2, OBJECT_PANEL
, True);
3369 if IDArray
<> nil then
3371 for i
:= 0 to High(IDArray
) do
3372 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTUP
) or
3373 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTDOWN
) or
3374 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTLEFT
) or
3375 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTRIGHT
) then
3377 gTriggers
[SelectedObjects
[
3378 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3383 gTriggers
[SelectedObjects
[
3384 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3390 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3392 2, 2, OBJECT_MONSTER
, False);
3393 if IDArray
<> nil then
3394 gTriggers
[SelectedObjects
[
3395 GetFirstSelected() ].ID
].Data
.MonsterID
:= IDArray
[0]+1
3397 gTriggers
[SelectedObjects
[
3398 GetFirstSelected() ].ID
].Data
.MonsterID
:= 0;
3401 SELECTFLAG_SHOTPANEL
:
3402 // Панель индикации выстрела:
3404 if gTriggers
[SelectedObjects
[
3405 GetFirstSelected() ].ID
].TriggerType
= TRIGGER_SHOT
then
3407 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3409 2, 2, OBJECT_PANEL
, True);
3410 if IDArray
<> nil then
3412 for i
:= 0 to High(IDArray
) do
3413 if ((gPanels
[IDArray
[i
]].PanelType
in
3414 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3415 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3417 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3418 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3419 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3421 gTriggers
[SelectedObjects
[
3422 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= IDArray
[i
];
3427 gTriggers
[SelectedObjects
[
3428 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= -1;
3433 SelectFlag
:= SELECTFLAG_SELECTED
;
3435 else // if SelectFlag <> SELECTFLAG_NONE...
3437 // Что уже выбрано и не нажат Ctrl:
3438 if (SelectedObjects
<> nil) and
3439 (not (ssCtrl
in Shift
)) then
3440 for i
:= 0 to High(SelectedObjects
) do
3441 with SelectedObjects
[i
] do
3444 if (ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) and
3445 (SelectedObjectCount() = 1) then
3447 Rect
:= ObjectGetRect(ObjectType
, ID
);
3449 c1
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3450 Rect
.X
-2, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3451 c2
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3452 Rect
.X
+Rect
.Width
-3, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3453 c3
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3454 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
-2, 4, 4);
3455 c4
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3456 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
+Rect
.Height
-3, 4, 4);
3458 // Меняем размер панели или триггера:
3459 if c1
or c2
or c3
or c4
then
3461 MouseAction
:= MOUSEACTION_RESIZE
;
3462 LastMovePoint
:= MousePos
;
3466 ResizeType
:= RESIZETYPE_HORIZONTAL
;
3468 ResizeDirection
:= RESIZEDIR_LEFT
3470 ResizeDirection
:= RESIZEDIR_RIGHT
;
3471 RenderPanel
.Cursor
:= crSizeWE
;
3475 ResizeType
:= RESIZETYPE_VERTICAL
;
3477 ResizeDirection
:= RESIZEDIR_UP
3479 ResizeDirection
:= RESIZEDIR_DOWN
;
3480 RenderPanel
.Cursor
:= crSizeNS
;
3487 // Перемещаем панель или триггер:
3488 if ObjectCollide(ObjectType
, ID
,
3490 Y
-MapOffset
.Y
-1, 2, 2) then
3492 MouseAction
:= MOUSEACTION_MOVEOBJ
;
3493 LastMovePoint
:= MousePos
;
3499 end; // if Button = mbRight
3501 MouseRDown
:= Button
= mbRight
;
3503 MouseRDownPos
:= MousePos
;
3505 MouseLDown
:= Button
= mbLeft
;
3507 MouseLDownPos
:= MousePos
;
3510 procedure TMainForm
.RenderPanelMouseUp(Sender
: TObject
;
3511 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3518 rSelectRect
: Boolean;
3520 if Button
= mbLeft
then
3521 MouseLDown
:= False;
3522 if Button
= mbRight
then
3523 MouseRDown
:= False;
3526 ResizeType
:= RESIZETYPE_NONE
;
3528 if Button
= mbLeft
then // Left Mouse Button
3530 if MouseAction
<> MOUSEACTION_NONE
then
3531 begin // Было действие мышью
3532 // Мышь сдвинулась во время удержания клавиши:
3533 if (MousePos
.X
<> MouseLDownPos
.X
) and
3534 (MousePos
.Y
<> MouseLDownPos
.Y
) then
3537 MOUSEACTION_DRAWPANEL
:
3539 // Фон или передний план без текстуры - ошибка:
3540 if (lbPanelType
.ItemIndex
in [1, 2]) and
3541 (lbTextureList
.ItemIndex
= -1) then
3542 ErrorMessageBox(_lc
[I_MSG_CHOOSE_TEXTURE
])
3543 else // Назначаем параметры панели:
3545 case lbPanelType
.ItemIndex
of
3546 0: Panel
.PanelType
:= PANEL_WALL
;
3547 1: Panel
.PanelType
:= PANEL_BACK
;
3548 2: Panel
.PanelType
:= PANEL_FORE
;
3549 3: Panel
.PanelType
:= PANEL_OPENDOOR
;
3550 4: Panel
.PanelType
:= PANEL_CLOSEDOOR
;
3551 5: Panel
.PanelType
:= PANEL_STEP
;
3552 6: Panel
.PanelType
:= PANEL_WATER
;
3553 7: Panel
.PanelType
:= PANEL_ACID1
;
3554 8: Panel
.PanelType
:= PANEL_ACID2
;
3555 9: Panel
.PanelType
:= PANEL_LIFTUP
;
3556 10: Panel
.PanelType
:= PANEL_LIFTDOWN
;
3557 11: Panel
.PanelType
:= PANEL_LIFTLEFT
;
3558 12: Panel
.PanelType
:= PANEL_LIFTRIGHT
;
3559 13: Panel
.PanelType
:= PANEL_BLOCKMON
;
3562 Panel
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3563 Panel
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3564 Panel
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3565 Panel
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3567 // Лифты, блокМон или отсутствие текстуры - пустая текстура:
3568 if (lbPanelType
.ItemIndex
in [9, 10, 11, 12, 13]) or
3569 (lbTextureList
.ItemIndex
= -1) then
3571 Panel
.TextureHeight
:= 1;
3572 Panel
.TextureWidth
:= 1;
3573 Panel
.TextureName
:= '';
3574 Panel
.TextureID
:= TEXTURE_SPECIAL_NONE
;
3576 else // Есть текстура:
3578 Panel
.TextureName
:= SelectedTexture();
3580 // Обычная текстура:
3581 if not IsSpecialTextureSel() then
3583 g_GetTextureSizeByName(Panel
.TextureName
,
3584 Panel
.TextureWidth
, Panel
.TextureHeight
);
3585 g_GetTexture(Panel
.TextureName
, Panel
.TextureID
);
3587 else // Спец.текстура:
3589 Panel
.TextureHeight
:= 1;
3590 Panel
.TextureWidth
:= 1;
3591 Panel
.TextureID
:= SpecialTextureID(SelectedTexture());
3596 Panel
.Blending
:= False;
3598 Undo_Add(OBJECT_PANEL
, AddPanel(Panel
));
3602 // Рисовали триггер:
3603 MOUSEACTION_DRAWTRIGGER
:
3605 trigger
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3606 trigger
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3607 trigger
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3608 trigger
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3610 trigger
.Enabled
:= True;
3611 trigger
.TriggerType
:= lbTriggersList
.ItemIndex
+1;
3612 trigger
.TexturePanel
:= -1;
3615 trigger
.ActivateType
:= 0;
3617 if clbActivationType
.Checked
[0] then
3618 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERCOLLIDE
;
3619 if clbActivationType
.Checked
[1] then
3620 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERCOLLIDE
;
3621 if clbActivationType
.Checked
[2] then
3622 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERPRESS
;
3623 if clbActivationType
.Checked
[3] then
3624 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERPRESS
;
3625 if clbActivationType
.Checked
[4] then
3626 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_SHOT
;
3627 if clbActivationType
.Checked
[5] then
3628 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_NOMONSTER
;
3630 // Необходимые для активации ключи:
3633 if clbKeys
.Checked
[0] then
3634 trigger
.Key
:= Trigger
.Key
or KEY_RED
;
3635 if clbKeys
.Checked
[1] then
3636 trigger
.Key
:= Trigger
.Key
or KEY_GREEN
;
3637 if clbKeys
.Checked
[2] then
3638 trigger
.Key
:= Trigger
.Key
or KEY_BLUE
;
3639 if clbKeys
.Checked
[3] then
3640 trigger
.Key
:= Trigger
.Key
or KEY_REDTEAM
;
3641 if clbKeys
.Checked
[4] then
3642 trigger
.Key
:= Trigger
.Key
or KEY_BLUETEAM
;
3644 // Параметры триггера:
3645 FillByte(trigger
.Data
.Default
[0], 128, 0);
3647 case trigger
.TriggerType
of
3648 // Переключаемая панель:
3649 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
3650 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
3651 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
3653 Trigger
.Data
.PanelID
:= -1;
3659 trigger
.Data
.TargetPoint
.X
:= trigger
.X
-64;
3660 trigger
.Data
.TargetPoint
.Y
:= trigger
.Y
-64;
3661 trigger
.Data
.d2d_teleport
:= True;
3662 trigger
.Data
.TlpDir
:= 0;
3665 // Изменение других триггеров:
3666 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
3669 trigger
.Data
.Count
:= 1;
3675 trigger
.Data
.Volume
:= 255;
3676 trigger
.Data
.Pan
:= 127;
3677 trigger
.Data
.PlayCount
:= 1;
3678 trigger
.Data
.Local
:= True;
3679 trigger
.Data
.SoundSwitch
:= False;
3685 trigger
.Data
.MusicAction
:= 1;
3688 // Создание монстра:
3689 TRIGGER_SPAWNMONSTER
:
3691 trigger
.Data
.MonType
:= MONSTER_ZOMBY
;
3692 trigger
.Data
.MonPos
.X
:= trigger
.X
-64;
3693 trigger
.Data
.MonPos
.Y
:= trigger
.Y
-64;
3694 trigger
.Data
.MonHealth
:= 0;
3695 trigger
.Data
.MonActive
:= False;
3696 trigger
.Data
.MonCount
:= 1;
3699 // Создание предмета:
3702 trigger
.Data
.ItemType
:= ITEM_AMMO_BULLETS
;
3703 trigger
.Data
.ItemPos
.X
:= trigger
.X
-64;
3704 trigger
.Data
.ItemPos
.Y
:= trigger
.Y
-64;
3705 trigger
.Data
.ItemOnlyDM
:= False;
3706 trigger
.Data
.ItemFalls
:= False;
3707 trigger
.Data
.ItemCount
:= 1;
3708 trigger
.Data
.ItemMax
:= 0;
3709 trigger
.Data
.ItemDelay
:= 0;
3715 trigger
.Data
.PushAngle
:= 90;
3716 trigger
.Data
.PushForce
:= 10;
3717 trigger
.Data
.ResetVel
:= True;
3722 trigger
.Data
.ScoreCount
:= 1;
3723 trigger
.Data
.ScoreCon
:= True;
3724 trigger
.Data
.ScoreMsg
:= True;
3729 trigger
.Data
.MessageKind
:= 0;
3730 trigger
.Data
.MessageSendTo
:= 0;
3731 trigger
.Data
.MessageText
:= '';
3732 trigger
.Data
.MessageTime
:= 144;
3737 trigger
.Data
.DamageValue
:= 5;
3738 trigger
.Data
.DamageInterval
:= 12;
3743 trigger
.Data
.HealValue
:= 5;
3744 trigger
.Data
.HealInterval
:= 36;
3749 trigger
.Data
.ShotType
:= TRIGGER_SHOT_BULLET
;
3750 trigger
.Data
.ShotSound
:= True;
3751 trigger
.Data
.ShotPanelID
:= -1;
3752 trigger
.Data
.ShotTarget
:= 0;
3753 trigger
.Data
.ShotIntSight
:= 0;
3754 trigger
.Data
.ShotAim
:= TRIGGER_SHOT_AIM_DEFAULT
;
3755 trigger
.Data
.ShotPos
.X
:= trigger
.X
-64;
3756 trigger
.Data
.ShotPos
.Y
:= trigger
.Y
-64;
3757 trigger
.Data
.ShotAngle
:= 0;
3758 trigger
.Data
.ShotWait
:= 18;
3759 trigger
.Data
.ShotAccuracy
:= 0;
3760 trigger
.Data
.ShotAmmo
:= 0;
3761 trigger
.Data
.ShotIntReload
:= 0;
3766 trigger
.Data
.FXCount
:= 1;
3767 trigger
.Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
3768 trigger
.Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
3769 trigger
.Data
.FXColorR
:= 0;
3770 trigger
.Data
.FXColorG
:= 0;
3771 trigger
.Data
.FXColorB
:= 255;
3772 trigger
.Data
.FXPos
:= TRIGGER_EFFECT_POS_CENTER
;
3773 trigger
.Data
.FXWait
:= 1;
3774 trigger
.Data
.FXVelX
:= 0;
3775 trigger
.Data
.FXVelY
:= -20;
3776 trigger
.Data
.FXSpreadL
:= 5;
3777 trigger
.Data
.FXSpreadR
:= 5;
3778 trigger
.Data
.FXSpreadU
:= 4;
3779 trigger
.Data
.FXSpreadD
:= 0;
3783 Undo_Add(OBJECT_TRIGGER
, AddTrigger(trigger
));
3786 // Рисовали область триггера "Расширитель":
3787 MOUSEACTION_DRAWPRESS
:
3788 with gTriggers
[SelectedObjects
[GetFirstSelected
].ID
] do
3790 Data
.tX
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3791 Data
.tY
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3792 Data
.tWidth
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3793 Data
.tHeight
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3795 DrawPressRect
:= False;
3799 MouseAction
:= MOUSEACTION_NONE
;
3801 end // if Button = mbLeft...
3802 else // Right Mouse Button:
3804 if MouseAction
= MOUSEACTION_NOACTION
then
3806 MouseAction
:= MOUSEACTION_NONE
;
3810 // Объект передвинут или изменен в размере:
3811 if MouseAction
in [MOUSEACTION_MOVEOBJ
, MOUSEACTION_RESIZE
] then
3813 MouseAction
:= MOUSEACTION_NONE
;
3818 // Еще не все выбрали:
3819 if SelectFlag
<> SELECTFLAG_NONE
then
3821 if SelectFlag
= SELECTFLAG_SELECTED
then
3822 SelectFlag
:= SELECTFLAG_NONE
;
3827 // Мышь сдвинулась во время удержания клавиши:
3828 if (MousePos
.X
<> MouseRDownPos
.X
) and
3829 (MousePos
.Y
<> MouseRDownPos
.Y
) then
3831 rSelectRect
:= True;
3833 rRect
.X
:= Min(MousePos
.X
, MouseRDownPos
.X
)-MapOffset
.X
;
3834 rRect
.Y
:= Min(MousePos
.Y
, MouseRDownPos
.Y
)-MapOffset
.Y
;
3835 rRect
.Width
:= Abs(MousePos
.X
-MouseRDownPos
.X
);
3836 rRect
.Height
:= Abs(MousePos
.Y
-MouseRDownPos
.Y
);
3838 else // Мышь не сдвинулась - нет прямоугольника:
3840 rSelectRect
:= False;
3842 rRect
.X
:= X
-MapOffset
.X
-1;
3843 rRect
.Y
:= Y
-MapOffset
.Y
-1;
3848 // Если зажат Ctrl - выделять еще, иначе только один выделенный объект:
3849 if not (ssCtrl
in Shift
) then
3850 RemoveSelectFromObjects();
3852 // Выделяем всё в выбранном прямоугольнике:
3853 IDArray
:= ObjectInRect(rRect
.X
, rRect
.Y
,
3854 rRect
.Width
, rRect
.Height
,
3855 pcObjects
.ActivePageIndex
+1, rSelectRect
);
3857 if IDArray
<> nil then
3858 for i
:= 0 to High(IDArray
) do
3859 SelectObject(pcObjects
.ActivePageIndex
+1, IDArray
[i
],
3860 (ssCtrl
in Shift
) or rSelectRect
);
3866 procedure TMainForm
.RenderPanelPaint(Sender
: TObject
);
3871 procedure TMainForm
.RenderPanelMouseMove(Sender
: TObject
;
3872 Shift
: TShiftState
; X
, Y
: Integer);
3875 dWidth
, dHeight
: Integer;
3878 _id
:= GetFirstSelected();
3880 // Рисуем панель с текстурой, сетка - размеры текстуры:
3881 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and
3882 (lbPanelType
.ItemIndex
in [0..8]) and
3883 (lbTextureList
.ItemIndex
<> -1) and
3884 (not IsSpecialTextureSel()) then
3886 sX
:= StrToIntDef(lTextureWidth
.Caption
, DotStep
);
3887 sY
:= StrToIntDef(lTextureHeight
.Caption
, DotStep
);
3890 // Меняем размер панели с текстурой, сетка - размеры текстуры:
3891 if (MouseAction
= MOUSEACTION_RESIZE
) and
3892 ( (SelectedObjects
[_id
].ObjectType
= OBJECT_PANEL
) and
3893 IsTexturedPanel(gPanels
[SelectedObjects
[_id
].ID
].PanelType
) and
3894 (gPanels
[SelectedObjects
[_id
].ID
].TextureName
<> '') and
3895 (not IsSpecialTexture(gPanels
[SelectedObjects
[_id
].ID
].TextureName
)) ) then
3897 sX
:= gPanels
[SelectedObjects
[_id
].ID
].TextureWidth
;
3898 sY
:= gPanels
[SelectedObjects
[_id
].ID
].TextureHeight
;
3901 // Выравнивание по сетке:
3907 else // Нет выравнивания по сетке:
3913 // Новая позиция мыши:
3915 begin // Зажата левая кнопка мыши
3916 MousePos
.X
:= (Round((X
-MouseLDownPos
.X
)/sX
)*sX
)+MouseLDownPos
.X
;
3917 MousePos
.Y
:= (Round((Y
-MouseLDownPos
.Y
)/sY
)*sY
)+MouseLDownPos
.Y
;
3921 begin // Зажата правая кнопка мыши
3922 MousePos
.X
:= (Round((X
-MouseRDownPos
.X
)/sX
)*sX
)+MouseRDownPos
.X
;
3923 MousePos
.Y
:= (Round((Y
-MouseRDownPos
.Y
)/sY
)*sY
)+MouseRDownPos
.Y
;
3926 begin // Кнопки мыши не зажаты
3927 MousePos
.X
:= (Round(X
/sX
)*sX
);
3928 MousePos
.Y
:= (Round(Y
/sY
)*sY
);
3931 // Изменение размера закончилось - ставим обычный курсор:
3932 if ResizeType
= RESIZETYPE_NONE
then
3933 RenderPanel
.Cursor
:= crDefault
;
3935 // Зажата только правая кнопка мыши:
3936 if (not MouseLDown
) and (MouseRDown
) then
3938 // Рисуем прямоугольник выделения:
3939 if MouseAction
= MOUSEACTION_NONE
then
3941 if DrawRect
= nil then
3943 DrawRect
.Top
:= MouseRDownPos
.y
;
3944 DrawRect
.Left
:= MouseRDownPos
.x
;
3945 DrawRect
.Bottom
:= MousePos
.y
;
3946 DrawRect
.Right
:= MousePos
.x
;
3949 // Двигаем выделенные объекты:
3950 if MouseAction
= MOUSEACTION_MOVEOBJ
then
3952 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
,
3953 MousePos
.X
-LastMovePoint
.X
,
3954 MousePos
.Y
-LastMovePoint
.Y
);
3957 // Меняем размер выделенного объекта:
3958 if MouseAction
= MOUSEACTION_RESIZE
then
3960 if (SelectedObjectCount
= 1) and
3961 (SelectedObjects
[GetFirstSelected
].Live
) then
3963 dWidth
:= MousePos
.X
-LastMovePoint
.X
;
3964 dHeight
:= MousePos
.Y
-LastMovePoint
.Y
;
3967 RESIZETYPE_VERTICAL
: dWidth
:= 0;
3968 RESIZETYPE_HORIZONTAL
: dHeight
:= 0;
3971 case ResizeDirection
of
3972 RESIZEDIR_UP
: dHeight
:= -dHeight
;
3973 RESIZEDIR_LEFT
: dWidth
:= -dWidth
;
3976 ResizeObject(SelectedObjects
[GetFirstSelected
].ObjectType
,
3977 SelectedObjects
[GetFirstSelected
].ID
,
3978 dWidth
, dHeight
, ResizeDirection
);
3980 LastMovePoint
:= MousePos
;
3985 // Зажата только левая кнопка мыши:
3986 if (not MouseRDown
) and (MouseLDown
) then
3988 // Рисуем прямоугольник планирования панели:
3989 if MouseAction
in [MOUSEACTION_DRAWPANEL
,
3990 MOUSEACTION_DRAWTRIGGER
,
3991 MOUSEACTION_DRAWPRESS
] then
3993 if DrawRect
= nil then
3995 DrawRect
.Top
:= MouseLDownPos
.y
;
3996 DrawRect
.Left
:= MouseLDownPos
.x
;
3997 DrawRect
.Bottom
:= MousePos
.y
;
3998 DrawRect
.Right
:= MousePos
.x
;
4000 else // Двигаем карту:
4001 if MouseAction
= MOUSEACTION_MOVEMAP
then
4007 // Клавиши мыши не зажаты:
4008 if (not MouseRDown
) and (not MouseLDown
) then
4011 // Строка состояния - координаты мыши:
4012 StatusBar
.Panels
[1].Text := Format('(%d:%d)',
4013 [MousePos
.X
-MapOffset
.X
, MousePos
.Y
-MapOffset
.Y
]);
4016 procedure TMainForm
.FormCloseQuery(Sender
: TObject
; var CanClose
: Boolean);
4018 CanClose
:= MessageBox(0, PChar(_lc
[I_MSG_EXIT_PROMT
]),
4019 PChar(_lc
[I_MSG_EXIT
]),
4020 MB_ICONQUESTION
or MB_YESNO
or
4021 MB_DEFBUTTON1
) = idYes
;
4024 procedure TMainForm
.aExitExecute(Sender
: TObject
);
4029 procedure TMainForm
.FormDestroy(Sender
: TObject
);
4034 config
:= TConfig
.CreateFile(EditorDir
+'Editor.cfg');
4036 if WindowState
<> wsMaximized
then
4038 config
.WriteInt('Editor', 'XPos', Left
);
4039 config
.WriteInt('Editor', 'YPos', Top
);
4040 config
.WriteInt('Editor', 'Width', Width
);
4041 config
.WriteInt('Editor', 'Height', Height
);
4043 config
.WriteBool('Editor', 'Maximize', WindowState
= wsMaximized
);
4044 config
.WriteBool('Editor', 'Minimap', ShowMap
);
4045 config
.WriteInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
4046 config
.WriteInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
4047 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
4048 config
.WriteInt('Editor', 'DotStep', DotStep
);
4049 config
.WriteStr('Editor', 'LastOpenDir', OpenDialog
.InitialDir
);
4050 config
.WriteStr('Editor', 'LastSaveDir', SaveDialog
.InitialDir
);
4051 config
.WriteBool('Editor', 'EdgeShow', drEdge
[3] < 255);
4052 config
.WriteInt('Editor', 'EdgeColor', gColorEdge
);
4053 config
.WriteInt('Editor', 'EdgeAlpha', gAlphaEdge
);
4054 config
.WriteInt('Editor', 'LineAlpha', gAlphaTriggerLine
);
4055 config
.WriteInt('Editor', 'TriggerAlpha', gAlphaTriggerArea
);
4057 for i
:= 0 to RecentCount
-1 do
4058 if i
< RecentFiles
.Count
then
4059 config
.WriteStr('RecentFiles', IntToStr(i
+1), RecentFiles
[i
])
4061 config
.WriteStr('RecentFiles', IntToStr(i
+1), '');
4064 config
.SaveFile(EditorDir
+'Editor.cfg');
4067 slInvalidTextures
.Free
;
4070 procedure TMainForm
.RenderPanelResize(Sender
: TObject
);
4072 if MainForm
.Visible
then
4076 procedure TMainForm
.aMapOptionsExecute(Sender
: TObject
);
4080 MapOptionsForm
.ShowModal();
4082 ResName
:= OpenedMap
;
4083 while (Pos(':\', ResName
) > 0) do
4084 Delete(ResName
, 1, Pos(':\', ResName
) + 1);
4086 UpdateCaption(gMapInfo
.Name
, ExtractFileName(OpenedWAD
), ResName
);
4089 procedure TMainForm
.aAboutExecute(Sender
: TObject
);
4091 AboutForm
.ShowModal();
4094 procedure TMainForm
.FormKeyDown(Sender
: TObject
; var Key
: Word;
4095 Shift
: TShiftState
);
4100 if (not EditingProperties
) then
4102 if Key
= Ord('1') then
4103 SwitchLayer(LAYER_BACK
);
4104 if Key
= Ord('2') then
4105 SwitchLayer(LAYER_WALLS
);
4106 if Key
= Ord('3') then
4107 SwitchLayer(LAYER_FOREGROUND
);
4108 if Key
= Ord('4') then
4109 SwitchLayer(LAYER_STEPS
);
4110 if Key
= Ord('5') then
4111 SwitchLayer(LAYER_WATER
);
4112 if Key
= Ord('6') then
4113 SwitchLayer(LAYER_ITEMS
);
4114 if Key
= Ord('7') then
4115 SwitchLayer(LAYER_MONSTERS
);
4116 if Key
= Ord('8') then
4117 SwitchLayer(LAYER_AREAS
);
4118 if Key
= Ord('9') then
4119 SwitchLayer(LAYER_TRIGGERS
);
4120 if Key
= Ord('0') then
4121 tbShowClick(tbShow
);
4123 if Key
= Ord('V') then
4124 begin // Поворот монстров и областей:
4125 if (SelectedObjects
<> nil) then
4127 for i
:= 0 to High(SelectedObjects
) do
4128 if (SelectedObjects
[i
].Live
) then
4130 if (SelectedObjects
[i
].ObjectType
= OBJECT_MONSTER
) then
4132 g_ChangeDir(gMonsters
[SelectedObjects
[i
].ID
].Direction
);
4135 if (SelectedObjects
[i
].ObjectType
= OBJECT_AREA
) then
4137 g_ChangeDir(gAreas
[SelectedObjects
[i
].ID
].Direction
);
4143 if pcObjects
.ActivePage
= tsMonsters
then
4145 if rbMonsterLeft
.Checked
then
4146 rbMonsterRight
.Checked
:= True
4148 rbMonsterLeft
.Checked
:= True;
4150 if pcObjects
.ActivePage
= tsAreas
then
4152 if rbAreaLeft
.Checked
then
4153 rbAreaRight
.Checked
:= True
4155 rbAreaLeft
.Checked
:= True;
4160 if not (ssCtrl
in Shift
) then
4162 // Вертикальный скролл карты:
4165 if Key
= Ord('W') then
4167 Position
:= IfThen(Position
> DotStep
, Position
-DotStep
, 0);
4168 MapOffset
.Y
:= -Round(Position
/16) * 16;
4171 if Key
= Ord('S') then
4173 Position
:= IfThen(Position
+DotStep
< Max
, Position
+DotStep
, Max
);
4174 MapOffset
.Y
:= -Round(Position
/16) * 16;
4178 // Горизонтальный скролл карты:
4179 with sbHorizontal
do
4181 if Key
= Ord('A') then
4183 Position
:= IfThen(Position
> DotStep
, Position
-DotStep
, 0);
4184 MapOffset
.X
:= -Round(Position
/16) * 16;
4187 if Key
= Ord('D') then
4189 Position
:= IfThen(Position
+DotStep
< Max
, Position
+DotStep
, Max
);
4190 MapOffset
.X
:= -Round(Position
/16) * 16;
4196 // Удалить выделенные объекты:
4197 if (Key
= VK_DELETE
) and (SelectedObjects
<> nil) and
4198 RenderPanel
.Focused() then
4199 DeleteSelectedObjects();
4202 if (Key
= VK_ESCAPE
) and (SelectedObjects
<> nil) then
4203 RemoveSelectFromObjects();
4205 // Передвинуть объекты:
4206 if MainForm
.ActiveControl
= RenderPanel
then
4211 if Key
= VK_NUMPAD4
then
4212 dx
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4213 if Key
= VK_NUMPAD6
then
4214 dx
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4215 if Key
= VK_NUMPAD8
then
4216 dy
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4217 if Key
= VK_NUMPAD5
then
4218 dy
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4220 if (dx
<> 0) or (dy
<> 0) then
4222 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
, dx
, dy
);
4227 if ssCtrl
in Shift
then
4229 // Выбор панели с текстурой для триггера
4230 if Key
= Ord('T') then
4232 DrawPressRect
:= False;
4233 if SelectFlag
= SELECTFLAG_TEXTURE
then
4235 SelectFlag
:= SELECTFLAG_NONE
;
4238 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_TEXTURE_PANEL
], i
);
4240 SelectFlag
:= SELECTFLAG_TEXTURE
;
4243 if Key
= Ord('D') then
4245 SelectFlag
:= SELECTFLAG_NONE
;
4246 if DrawPressRect
then
4248 DrawPressRect
:= False;
4252 // Выбор области воздействия, в зависимости от типа триггера
4253 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_EX_AREA
], i
);
4256 DrawPressRect
:= True;
4259 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_DOOR_PANEL
], i
);
4261 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_TRAP_PANEL
], i
);
4264 SelectFlag
:= SELECTFLAG_DOOR
;
4267 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_LIFT_PANEL
], i
);
4270 SelectFlag
:= SELECTFLAG_LIFT
;
4273 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_TELEPORT_TO
], i
);
4276 SelectFlag
:= SELECTFLAG_TELEPORT
;
4279 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_SPAWN_TO
], i
);
4282 SelectFlag
:= SELECTFLAG_SPAWNPOINT
;
4286 // Выбор основного параметра, в зависимости от типа триггера
4287 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_NEXT_MAP
], i
);
4290 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
4291 SelectMapForm
.GetMaps(FileName
);
4293 if SelectMapForm
.ShowModal() = mrOK
then
4295 vleObjectProperty
.Cells
[1, i
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
4296 bApplyProperty
.Click();
4300 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_SOUND_NAME
], i
);
4302 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_MUSIC_NAME
], i
);
4305 AddSoundForm
.OKFunction
:= nil;
4306 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
4307 AddSoundForm
.SetResource
:= utf2win(vleObjectProperty
.Cells
[1, i
]);
4309 if (AddSoundForm
.ShowModal() = mrOk
) then
4311 vleObjectProperty
.Cells
[1, i
] := win2utf(AddSoundForm
.ResourceName
);
4312 bApplyProperty
.Click();
4316 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_PUSH_ANGLE
], i
);
4318 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_MESSAGE_TEXT
], i
);
4321 vleObjectProperty
.Row
:= i
;
4322 vleObjectProperty
.SetFocus();
4329 procedure TMainForm
.aOptimizeExecute(Sender
: TObject
);
4331 RemoveSelectFromObjects();
4332 MapOptimizationForm
.ShowModal();
4335 procedure TMainForm
.aCheckMapExecute(Sender
: TObject
);
4337 MapCheckForm
.ShowModal();
4340 procedure TMainForm
.bbAddTextureClick(Sender
: TObject
);
4342 AddTextureForm
.lbResourcesList
.MultiSelect
:= True;
4343 AddTextureForm
.ShowModal();
4346 procedure TMainForm
.lbTextureListClick(Sender
: TObject
);
4349 TextureWidth
, TextureHeight
: Word;
4351 if (lbTextureList
.ItemIndex
<> -1) and
4352 (not IsSpecialTextureSel()) then
4354 if g_GetTexture(SelectedTexture(), TextureID
) then
4356 g_GetTextureSizeByID(TextureID
, TextureWidth
, TextureHeight
);
4358 lTextureWidth
.Caption
:= IntToStr(TextureWidth
);
4359 lTextureHeight
.Caption
:= IntToStr(TextureHeight
);
4362 lTextureWidth
.Caption
:= _lc
[I_NOT_ACCESSIBLE
];
4363 lTextureHeight
.Caption
:= _lc
[I_NOT_ACCESSIBLE
];
4368 lTextureWidth
.Caption
:= '';
4369 lTextureHeight
.Caption
:= '';
4373 procedure TMainForm
.vleObjectPropertyGetPickList(Sender
: TObject
;
4374 const KeyName
: String; Values
: TStrings
);
4376 if vleObjectProperty
.ItemProps
[KeyName
].EditStyle
= esPickList
then
4378 if KeyName
= _lc
[I_PROP_DIRECTION
] then
4380 Values
.Add(DirNames
[D_LEFT
]);
4381 Values
.Add(DirNames
[D_RIGHT
]);
4383 else if KeyName
= _lc
[I_PROP_TR_TELEPORT_DIR
] then
4385 Values
.Add(DirNamesAdv
[0]);
4386 Values
.Add(DirNamesAdv
[1]);
4387 Values
.Add(DirNamesAdv
[2]);
4388 Values
.Add(DirNamesAdv
[3]);
4390 else if KeyName
= _lc
[I_PROP_TR_MUSIC_ACT
] then
4392 Values
.Add(_lc
[I_PROP_TR_MUSIC_ON
]);
4393 Values
.Add(_lc
[I_PROP_TR_MUSIC_OFF
]);
4395 else if KeyName
= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR
] then
4397 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_0
]);
4398 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_1
]);
4399 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_2
]);
4400 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_3
]);
4401 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_4
]);
4402 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_5
]);
4404 else if KeyName
= _lc
[I_PROP_TR_SCORE_ACT
] then
4406 Values
.Add(_lc
[I_PROP_TR_SCORE_ACT_0
]);
4407 Values
.Add(_lc
[I_PROP_TR_SCORE_ACT_1
]);
4408 Values
.Add(_lc
[I_PROP_TR_SCORE_ACT_2
]);
4409 Values
.Add(_lc
[I_PROP_TR_SCORE_ACT_3
]);
4411 else if KeyName
= _lc
[I_PROP_TR_SCORE_TEAM
] then
4413 Values
.Add(_lc
[I_PROP_TR_SCORE_TEAM_0
]);
4414 Values
.Add(_lc
[I_PROP_TR_SCORE_TEAM_1
]);
4415 Values
.Add(_lc
[I_PROP_TR_SCORE_TEAM_2
]);
4416 Values
.Add(_lc
[I_PROP_TR_SCORE_TEAM_3
]);
4418 else if KeyName
= _lc
[I_PROP_TR_MESSAGE_KIND
] then
4420 Values
.Add(_lc
[I_PROP_TR_MESSAGE_KIND_0
]);
4421 Values
.Add(_lc
[I_PROP_TR_MESSAGE_KIND_1
]);
4423 else if KeyName
= _lc
[I_PROP_TR_MESSAGE_TO
] then
4425 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_0
]);
4426 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_1
]);
4427 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_2
]);
4428 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_3
]);
4429 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_4
]);
4430 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_5
]);
4432 else if KeyName
= _lc
[I_PROP_TR_SHOT_TO
] then
4434 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_0
]);
4435 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_1
]);
4436 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_2
]);
4437 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_3
]);
4438 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_4
]);
4439 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_5
]);
4440 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_6
]);
4442 else if KeyName
= _lc
[I_PROP_TR_SHOT_AIM
] then
4444 Values
.Add(_lc
[I_PROP_TR_SHOT_AIM_0
]);
4445 Values
.Add(_lc
[I_PROP_TR_SHOT_AIM_1
]);
4446 Values
.Add(_lc
[I_PROP_TR_SHOT_AIM_2
]);
4447 Values
.Add(_lc
[I_PROP_TR_SHOT_AIM_3
]);
4449 else if (KeyName
= _lc
[I_PROP_PANEL_BLEND
]) or
4450 (KeyName
= _lc
[I_PROP_DM_ONLY
]) or
4451 (KeyName
= _lc
[I_PROP_ITEM_FALLS
]) or
4452 (KeyName
= _lc
[I_PROP_TR_ENABLED
]) or
4453 (KeyName
= _lc
[I_PROP_TR_D2D
]) or
4454 (KeyName
= _lc
[I_PROP_TR_SILENT
]) or
4455 (KeyName
= _lc
[I_PROP_TR_TELEPORT_SILENT
]) or
4456 (KeyName
= _lc
[I_PROP_TR_EX_RANDOM
]) or
4457 (KeyName
= _lc
[I_PROP_TR_TEXTURE_ONCE
]) or
4458 (KeyName
= _lc
[I_PROP_TR_TEXTURE_ANIM_ONCE
]) or
4459 (KeyName
= _lc
[I_PROP_TR_SOUND_LOCAL
]) or
4460 (KeyName
= _lc
[I_PROP_TR_SOUND_SWITCH
]) or
4461 (KeyName
= _lc
[I_PROP_TR_MONSTER_ACTIVE
]) or
4462 (KeyName
= _lc
[I_PROP_TR_PUSH_RESET
]) or
4463 (KeyName
= _lc
[I_PROP_TR_SCORE_CON
]) or
4464 (KeyName
= _lc
[I_PROP_TR_SCORE_MSG
]) or
4465 (KeyName
= _lc
[I_PROP_TR_HEALTH_MAX
]) or
4466 (KeyName
= _lc
[I_PROP_TR_SHOT_SOUND
]) or
4467 (KeyName
= _lc
[I_PROP_TR_EFFECT_CENTER
]) then
4469 Values
.Add(BoolNames
[True]);
4470 Values
.Add(BoolNames
[False]);
4475 procedure TMainForm
.bApplyPropertyClick(Sender
: TObject
);
4477 _id
, a
, r
, c
: Integer;
4483 if SelectedObjectCount() <> 1 then
4485 if not SelectedObjects
[GetFirstSelected()].Live
then
4489 if not CheckProperty() then
4495 _id
:= GetFirstSelected();
4497 r
:= vleObjectProperty
.Row
;
4498 c
:= vleObjectProperty
.Col
;
4500 case SelectedObjects
[_id
].ObjectType
of
4503 with gPanels
[SelectedObjects
[_id
].ID
] do
4505 X
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_X
]]));
4506 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]));
4507 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_WIDTH
]]));
4508 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_HEIGHT
]]));
4510 PanelType
:= GetPanelType(vleObjectProperty
.Values
[_lc
[I_PROP_PANEL_TYPE
]]);
4512 // Сброс ссылки на триггеры смены текстуры:
4513 if not WordBool(PanelType
and (PANEL_WALL
or PANEL_FORE
or PANEL_BACK
)) then
4514 if gTriggers
<> nil then
4515 for a
:= 0 to High(gTriggers
) do
4517 if (gTriggers
[a
].TriggerType
<> 0) and
4518 (gTriggers
[a
].TexturePanel
= Integer(SelectedObjects
[_id
].ID
)) then
4519 gTriggers
[a
].TexturePanel
:= -1;
4520 if (gTriggers
[a
].TriggerType
= TRIGGER_SHOT
) and
4521 (gTriggers
[a
].Data
.ShotPanelID
= Integer(SelectedObjects
[_id
].ID
)) then
4522 gTriggers
[a
].Data
.ShotPanelID
:= -1;
4525 // Сброс ссылки на триггеры лифта:
4526 if not WordBool(PanelType
and (PANEL_LIFTUP
or PANEL_LIFTDOWN
or PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
)) then
4527 if gTriggers
<> nil then
4528 for a
:= 0 to High(gTriggers
) do
4529 if (gTriggers
[a
].TriggerType
in [TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
]) and
4530 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
4531 gTriggers
[a
].Data
.PanelID
:= -1;
4533 // Сброс ссылки на триггеры двери:
4534 if not WordBool(PanelType
and (PANEL_OPENDOOR
or PANEL_CLOSEDOOR
)) then
4535 if gTriggers
<> nil then
4536 for a
:= 0 to High(gTriggers
) do
4537 if (gTriggers
[a
].TriggerType
in [TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
4538 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
]) and
4539 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
4540 gTriggers
[a
].Data
.PanelID
:= -1;
4542 if IsTexturedPanel(PanelType
) then
4543 begin // Может быть текстура
4544 if TextureName
<> '' then
4545 begin // Была текстура
4546 Alpha
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_PANEL_ALPHA
]]));
4547 Blending
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_PANEL_BLEND
]]);
4556 TextureName
:= vleObjectProperty
.Values
[_lc
[I_PROP_PANEL_TEX
]];
4558 if TextureName
<> '' then
4559 begin // Есть текстура
4560 // Обычная текстура:
4561 if not IsSpecialTexture(TextureName
) then
4563 g_GetTextureSizeByName(TextureName
,
4564 TextureWidth
, TextureHeight
);
4566 // Проверка кратности размеров панели:
4568 if TextureWidth
<> 0 then
4569 if gPanels
[SelectedObjects
[_id
].ID
].Width
mod TextureWidth
<> 0 then
4571 ErrorMessageBox(Format(_lc
[I_MSG_WRONG_TEXWIDTH
],
4575 if Res
and (TextureHeight
<> 0) then
4576 if gPanels
[SelectedObjects
[_id
].ID
].Height
mod TextureHeight
<> 0 then
4578 ErrorMessageBox(Format(_lc
[I_MSG_WRONG_TEXHEIGHT
],
4585 if not g_GetTexture(TextureName
, TextureID
) then
4586 // Не удалось загрузить текстуру, рисуем NOTEXTURE
4587 if g_GetTexture('NOTEXTURE', NoTextureID
) then
4589 TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
4590 g_GetTextureSizeByID(NoTextureID
, NW
, NH
);
4592 TextureHeight
:= NH
;
4595 TextureID
:= TEXTURE_SPECIAL_NONE
;
4605 TextureID
:= TEXTURE_SPECIAL_NONE
;
4608 else // Спец.текстура
4612 TextureID
:= SpecialTextureID(TextureName
);
4615 else // Нет текстуры
4619 TextureID
:= TEXTURE_SPECIAL_NONE
;
4622 else // Не может быть текстуры
4629 TextureID
:= TEXTURE_SPECIAL_NONE
;
4636 with gItems
[SelectedObjects
[_id
].ID
] do
4638 X
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_X
]]));
4639 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]));
4640 OnlyDM
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_DM_ONLY
]]);
4641 Fall
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_ITEM_FALLS
]]);
4647 with gMonsters
[SelectedObjects
[_id
].ID
] do
4649 X
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_X
]]));
4650 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]));
4651 Direction
:= NameToDir(vleObjectProperty
.Values
[_lc
[I_PROP_DIRECTION
]]);
4657 with gAreas
[SelectedObjects
[_id
].ID
] do
4659 X
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_X
]]));
4660 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]));
4661 Direction
:= NameToDir(vleObjectProperty
.Values
[_lc
[I_PROP_DIRECTION
]]);
4667 with gTriggers
[SelectedObjects
[_id
].ID
] do
4669 X
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_X
]]));
4670 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]));
4671 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_WIDTH
]]));
4672 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_HEIGHT
]]));
4673 Enabled
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_ENABLED
]]);
4674 ActivateType
:= StrToActivate(vleObjectProperty
.Values
[_lc
[I_PROP_TR_ACTIVATION
]]);
4675 Key
:= StrToKey(vleObjectProperty
.Values
[_lc
[I_PROP_TR_KEYS
]]);
4680 s
:= vleObjectProperty
.Values
[_lc
[I_PROP_TR_NEXT_MAP
]];
4681 FillByte(Data
.MapName
[0], 16, 0);
4683 Move(Data
.MapName
[0], s
[1], Min(Length(s
), 16));
4688 Data
.ActivateOnce
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_TEXTURE_ONCE
]]);
4689 Data
.AnimOnce
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_TEXTURE_ANIM_ONCE
]]);
4692 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
4694 Data
.Wait
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EX_DELAY
]], 0), 65535);
4695 Data
.Count
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EX_COUNT
]], 0), 65535);
4696 if Data
.Count
< 1 then
4698 if TriggerType
= TRIGGER_PRESS
then
4699 Data
.ExtRandom
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EX_RANDOM
]]);
4702 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
, TRIGGER_DOOR5
,
4703 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
, TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
,
4706 Data
.NoSound
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SILENT
]]);
4707 Data
.d2d_doors
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_D2D
]]);
4712 Data
.d2d_teleport
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_D2D
]]);
4713 Data
.silent_teleport
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_TELEPORT_SILENT
]]);
4714 Data
.TlpDir
:= NameToDirAdv(vleObjectProperty
.Values
[_lc
[I_PROP_TR_TELEPORT_DIR
]]);
4719 s
:= vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_NAME
]];
4720 FillByte(Data
.SoundName
[0], 64, 0);
4722 Move(Data
.SoundName
[0], s
[1], Min(Length(s
), 64));
4724 Data
.Volume
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_VOLUME
]], 0), 255);
4725 Data
.Pan
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_PAN
]], 0), 255);
4726 Data
.PlayCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_COUNT
]], 0), 255);
4727 Data
.Local
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_LOCAL
]]);
4728 Data
.SoundSwitch
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_SWITCH
]]);
4731 TRIGGER_SPAWNMONSTER
:
4733 Data
.MonType
:= StrToMonster(vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_TYPE
]]);
4734 Data
.MonDir
:= Byte(NameToDir(vleObjectProperty
.Values
[_lc
[I_PROP_DIRECTION
]]));
4735 Data
.MonHealth
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_HEALTH
]], 0), 1000000);
4736 if Data
.MonHealth
< 0 then
4737 Data
.MonHealth
:= 0;
4738 Data
.MonActive
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_ACTIVE
]]);
4739 Data
.MonCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_COUNT
]], 0), 64);
4740 if Data
.MonCount
< 1 then
4742 Data
.MonEffect
:= StrToEffect(vleObjectProperty
.Values
[_lc
[I_PROP_TR_FX_TYPE
]]);
4743 Data
.MonMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SPAWN_MAX
]], 0), 65535);
4744 Data
.MonDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SPAWN_DELAY
]], 0), 65535);
4746 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
]] = _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_1
] then
4748 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
]] = _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_2
] then
4750 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
]] = _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_3
] then
4752 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
]] = _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_4
] then
4754 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
]] = _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_5
] then
4760 Data
.ItemType
:= StrToItem(vleObjectProperty
.Values
[_lc
[I_PROP_TR_ITEM_TYPE
]]);
4761 Data
.ItemOnlyDM
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_DM_ONLY
]]);
4762 Data
.ItemFalls
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_ITEM_FALLS
]]);
4763 Data
.ItemCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_COUNT
]], 0), 64);
4764 if Data
.ItemCount
< 1 then
4765 Data
.ItemCount
:= 1;
4766 Data
.ItemEffect
:= StrToEffect(vleObjectProperty
.Values
[_lc
[I_PROP_TR_FX_TYPE
]]);
4767 Data
.ItemMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SPAWN_MAX
]], 0), 65535);
4768 Data
.ItemDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SPAWN_DELAY
]], 0), 65535);
4773 s
:= vleObjectProperty
.Values
[_lc
[I_PROP_TR_MUSIC_NAME
]];
4774 FillByte(Data
.MusicName
[0], 64, 0);
4776 Move(Data
.MusicName
[0], s
[1], Min(Length(s
), 64));
4778 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MUSIC_ACT
]] = _lc
[I_PROP_TR_MUSIC_ON
] then
4779 Data
.MusicAction
:= 1
4781 Data
.MusicAction
:= 2;
4786 Data
.PushAngle
:= Min(
4787 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_PUSH_ANGLE
]], 0), 360);
4788 Data
.PushForce
:= Min(
4789 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_PUSH_FORCE
]], 0), 255);
4790 Data
.ResetVel
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_PUSH_RESET
]]);
4795 Data
.ScoreAction
:= 0;
4796 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_ACT
]] = _lc
[I_PROP_TR_SCORE_ACT_1
] then
4797 Data
.ScoreAction
:= 1
4798 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_ACT
]] = _lc
[I_PROP_TR_SCORE_ACT_2
] then
4799 Data
.ScoreAction
:= 2
4800 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_ACT
]] = _lc
[I_PROP_TR_SCORE_ACT_3
] then
4801 Data
.ScoreAction
:= 3;
4802 Data
.ScoreCount
:= Min(Max(
4803 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_COUNT
]], 0), 0), 255);
4804 Data
.ScoreTeam
:= 0;
4805 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_TEAM
]] = _lc
[I_PROP_TR_SCORE_TEAM_1
] then
4807 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_TEAM
]] = _lc
[I_PROP_TR_SCORE_TEAM_2
] then
4809 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_TEAM
]] = _lc
[I_PROP_TR_SCORE_TEAM_3
] then
4810 Data
.ScoreTeam
:= 3;
4811 Data
.ScoreCon
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_CON
]]);
4812 Data
.ScoreMsg
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_MSG
]]);
4817 Data
.MessageKind
:= 0;
4818 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_KIND
]] = _lc
[I_PROP_TR_MESSAGE_KIND_1
] then
4819 Data
.MessageKind
:= 1;
4821 Data
.MessageSendTo
:= 0;
4822 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TO
]] = _lc
[I_PROP_TR_MESSAGE_TO_1
] then
4823 Data
.MessageSendTo
:= 1
4824 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TO
]] = _lc
[I_PROP_TR_MESSAGE_TO_2
] then
4825 Data
.MessageSendTo
:= 2
4826 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TO
]] = _lc
[I_PROP_TR_MESSAGE_TO_3
] then
4827 Data
.MessageSendTo
:= 3
4828 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TO
]] = _lc
[I_PROP_TR_MESSAGE_TO_4
] then
4829 Data
.MessageSendTo
:= 4
4830 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TO
]] = _lc
[I_PROP_TR_MESSAGE_TO_5
] then
4831 Data
.MessageSendTo
:= 5;
4833 s
:= vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TEXT
]];
4834 FillByte(Data
.MessageText
[0], 100, 0);
4836 Move(Data
.MessageText
[0], s
[1], Min(Length(s
), 100));
4838 Data
.MessageTime
:= Min(Max(
4839 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TIME
]], 0), 0), 65535);
4844 Data
.DamageValue
:= Min(Max(
4845 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_DAMAGE_VALUE
]], 0), 0), 65535);
4846 Data
.DamageInterval
:= Min(Max(
4847 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_INTERVAL
]], 0), 0), 65535);
4852 Data
.HealValue
:= Min(Max(
4853 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_HEALTH
]], 0), 0), 65535);
4854 Data
.HealInterval
:= Min(Max(
4855 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_INTERVAL
]], 0), 0), 65535);
4856 Data
.HealMax
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_HEALTH_MAX
]]);
4857 Data
.HealSilent
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SILENT
]]);
4862 Data
.ShotType
:= StrToShot(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TYPE
]]);
4863 Data
.ShotSound
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_SOUND
]]);
4864 Data
.ShotTarget
:= 0;
4865 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_1
] then
4866 Data
.ShotTarget
:= 1
4867 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_2
] then
4868 Data
.ShotTarget
:= 2
4869 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_3
] then
4870 Data
.ShotTarget
:= 3
4871 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_4
] then
4872 Data
.ShotTarget
:= 4
4873 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_5
] then
4874 Data
.ShotTarget
:= 5
4875 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_6
] then
4876 Data
.ShotTarget
:= 6;
4877 Data
.ShotIntSight
:= Min(Max(
4878 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_SIGHT
]], 0), 0), 65535);
4880 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_AIM
]] = _lc
[I_PROP_TR_SHOT_AIM_1
] then
4882 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_AIM
]] = _lc
[I_PROP_TR_SHOT_AIM_2
] then
4884 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_AIM
]] = _lc
[I_PROP_TR_SHOT_AIM_3
] then
4886 Data
.ShotAngle
:= Min(
4887 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_ANGLE
]], 0), 360);
4888 Data
.ShotWait
:= Min(Max(
4889 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EX_DELAY
]], 0), 0), 65535);
4890 Data
.ShotAccuracy
:= Min(Max(
4891 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_ACC
]], 0), 0), 65535);
4892 Data
.ShotAmmo
:= Min(Max(
4893 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_AMMO
]], 0), 0), 65535);
4894 Data
.ShotIntReload
:= Min(Max(
4895 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_RELOAD
]], 0), 0), 65535);
4900 Data
.FXCount
:= Min(Max(
4901 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_COUNT
]], 0), 0), 255);
4902 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_TYPE
]] = _lc
[I_PROP_TR_EFFECT_PARTICLE
] then
4904 Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
4905 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
4906 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_SLIQUID
] then
4907 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
4908 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_LLIQUID
] then
4909 Data
.FXSubType
:= TRIGGER_EFFECT_LLIQUID
4910 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_DLIQUID
] then
4911 Data
.FXSubType
:= TRIGGER_EFFECT_DLIQUID
4912 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_BLOOD
] then
4913 Data
.FXSubType
:= TRIGGER_EFFECT_BLOOD
4914 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_SPARK
] then
4915 Data
.FXSubType
:= TRIGGER_EFFECT_SPARK
4916 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_BUBBLE
] then
4917 Data
.FXSubType
:= TRIGGER_EFFECT_BUBBLE
;
4920 Data
.FXType
:= TRIGGER_EFFECT_ANIMATION
;
4921 Data
.FXSubType
:= StrToEffect(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]]);
4924 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_COLOR
]], 0), 0), $FFFFFF);
4925 Data
.FXColorR
:= a
and $FF;
4926 Data
.FXColorG
:= (a
shr 8) and $FF;
4927 Data
.FXColorB
:= (a
shr 16) and $FF;
4928 if NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_CENTER
]]) then
4932 Data
.FXWait
:= Min(Max(
4933 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EX_DELAY
]], 0), 0), 65535);
4934 Data
.FXVelX
:= Min(Max(
4935 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_VELX
]], 0), -128), 127);
4936 Data
.FXVelY
:= Min(Max(
4937 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_VELY
]], 0), -128), 127);
4938 Data
.FXSpreadL
:= Min(Max(
4939 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SPL
]], 0), 0), 255);
4940 Data
.FXSpreadR
:= Min(Max(
4941 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SPR
]], 0), 0), 255);
4942 Data
.FXSpreadU
:= Min(Max(
4943 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SPU
]], 0), 0), 255);
4944 Data
.FXSpreadD
:= Min(Max(
4945 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SPD
]], 0), 0), 255);
4954 vleObjectProperty
.Row
:= r
;
4955 vleObjectProperty
.Col
:= c
;
4958 procedure TMainForm
.bbRemoveTextureClick(Sender
: TObject
);
4962 i
:= lbTextureList
.ItemIndex
;
4966 if MessageBox(0, PChar(Format(_lc
[I_MSG_DEL_TEXTURE_PROMT
],
4967 [SelectedTexture()])),
4968 PChar(_lc
[I_MSG_DEL_TEXTURE
]),
4969 MB_ICONQUESTION
or MB_YESNO
or
4970 MB_DEFBUTTON1
) <> idYes
then
4973 if gPanels
<> nil then
4974 for a
:= 0 to High(gPanels
) do
4975 if (gPanels
[a
].PanelType
<> 0) and
4976 (gPanels
[a
].TextureName
= SelectedTexture()) then
4978 ErrorMessageBox(_lc
[I_MSG_DEL_TEXTURE_CANT
]);
4982 g_DeleteTexture(SelectedTexture());
4983 i
:= slInvalidTextures
.IndexOf(lbTextureList
.Items
[i
]);
4985 slInvalidTextures
.Delete(i
);
4986 if lbTextureList
.ItemIndex
> -1 then
4987 lbTextureList
.Items
.Delete(lbTextureList
.ItemIndex
)
4990 procedure TMainForm
.aNewMapExecute(Sender
: TObject
);
4992 if (MessageBox(0, PChar(_lc
[I_MSG_CLEAR_MAP_PROMT
]),
4993 PChar(_lc
[I_MSG_CLEAR_MAP
]),
4994 MB_ICONQUESTION
or MB_YESNO
or
4995 MB_DEFBUTTON1
) = mrYes
) then
4999 procedure TMainForm
.aUndoExecute(Sender
: TObject
);
5003 if UndoBuffer
= nil then
5005 if UndoBuffer
[High(UndoBuffer
)] = nil then
5008 for a
:= 0 to High(UndoBuffer
[High(UndoBuffer
)]) do
5009 with UndoBuffer
[High(UndoBuffer
)][a
] do
5017 UNDO_DELETE_ITEM
: AddItem(Item
);
5018 UNDO_DELETE_AREA
: AddArea(Area
);
5019 UNDO_DELETE_MONSTER
: AddMonster(Monster
);
5020 UNDO_DELETE_TRIGGER
: AddTrigger(Trigger
);
5021 UNDO_ADD_PANEL
: RemoveObject(AddID
, OBJECT_PANEL
);
5022 UNDO_ADD_ITEM
: RemoveObject(AddID
, OBJECT_ITEM
);
5023 UNDO_ADD_AREA
: RemoveObject(AddID
, OBJECT_AREA
);
5024 UNDO_ADD_MONSTER
: RemoveObject(AddID
, OBJECT_MONSTER
);
5025 UNDO_ADD_TRIGGER
: RemoveObject(AddID
, OBJECT_TRIGGER
);
5029 SetLength(UndoBuffer
, Length(UndoBuffer
)-1);
5031 RemoveSelectFromObjects();
5033 miUndo
.Enabled
:= UndoBuffer
<> nil;
5037 procedure TMainForm
.aCopyObjectExecute(Sender
: TObject
);
5040 CopyBuffer
: TCopyRecArray
;
5044 function CB_Compare(I1
, I2
: TCopyRec
): Integer;
5046 Result
:= Integer(I1
.ObjectType
) - Integer(I2
.ObjectType
);
5048 if Result
= 0 then // Одного типа
5049 Result
:= Integer(I1
.ID
) - Integer(I2
.ID
);
5052 procedure QuickSortCopyBuffer(L
, R
: Integer);
5060 P
:= CopyBuffer
[(L
+ R
) shr 1];
5063 while CB_Compare(CopyBuffer
[I
], P
) < 0 do
5065 while CB_Compare(CopyBuffer
[J
], P
) > 0 do
5071 CopyBuffer
[I
] := CopyBuffer
[J
];
5079 QuickSortCopyBuffer(L
, J
);
5086 if SelectedObjects
= nil then
5092 // Копируем объекты:
5093 for a
:= 0 to High(SelectedObjects
) do
5094 if SelectedObjects
[a
].Live
then
5095 with SelectedObjects
[a
] do
5097 SetLength(CopyBuffer
, Length(CopyBuffer
)+1);
5098 b
:= High(CopyBuffer
);
5099 CopyBuffer
[b
].ID
:= ID
;
5100 CopyBuffer
[b
].Panel
:= nil;
5105 CopyBuffer
[b
].ObjectType
:= OBJECT_PANEL
;
5106 New(CopyBuffer
[b
].Panel
);
5107 CopyBuffer
[b
].Panel
^ := gPanels
[ID
];
5112 CopyBuffer
[b
].ObjectType
:= OBJECT_ITEM
;
5113 CopyBuffer
[b
].Item
:= gItems
[ID
];
5118 CopyBuffer
[b
].ObjectType
:= OBJECT_MONSTER
;
5119 CopyBuffer
[b
].Monster
:= gMonsters
[ID
];
5124 CopyBuffer
[b
].ObjectType
:= OBJECT_AREA
;
5125 CopyBuffer
[b
].Area
:= gAreas
[ID
];
5130 CopyBuffer
[b
].ObjectType
:= OBJECT_TRIGGER
;
5131 CopyBuffer
[b
].Trigger
:= gTriggers
[ID
];
5136 // Сортировка по ID:
5137 if CopyBuffer
<> nil then
5139 QuickSortCopyBuffer(0, b
);
5142 // Пестановка ссылок триггеров:
5143 for a
:= 0 to Length(CopyBuffer
)-1 do
5144 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
5146 case CopyBuffer
[a
].Trigger
.TriggerType
of
5147 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5148 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5149 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5150 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
5154 for b
:= 0 to Length(CopyBuffer
)-1 do
5155 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5156 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.PanelID
) then
5158 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= b
;
5163 // Этих панелей нет среди копируемых:
5165 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= -1;
5168 TRIGGER_PRESS
, TRIGGER_ON
,
5169 TRIGGER_OFF
, TRIGGER_ONOFF
:
5170 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
5174 for b
:= 0 to Length(CopyBuffer
)-1 do
5175 if (CopyBuffer
[b
].ObjectType
= OBJECT_MONSTER
) and
5176 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1) then
5178 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= b
+1;
5183 // Этих монстров нет среди копируемых:
5185 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= 0;
5189 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
5193 for b
:= 0 to Length(CopyBuffer
)-1 do
5194 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5195 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
) then
5197 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= b
;
5202 // Этих панелей нет среди копируемых:
5204 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= -1;
5208 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
5212 for b
:= 0 to Length(CopyBuffer
)-1 do
5213 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5214 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.TexturePanel
) then
5216 CopyBuffer
[a
].Trigger
.TexturePanel
:= b
;
5221 // Этих панелей нет среди копируемых:
5223 CopyBuffer
[a
].Trigger
.TexturePanel
:= -1;
5228 str
:= CopyBufferToString(CopyBuffer
);
5229 ClipBoard
.AsText
:= str
;
5231 for a
:= 0 to Length(CopyBuffer
)-1 do
5232 if (CopyBuffer
[a
].ObjectType
= OBJECT_PANEL
) and
5233 (CopyBuffer
[a
].Panel
<> nil) then
5234 Dispose(CopyBuffer
[a
].Panel
);
5239 procedure TMainForm
.aPasteObjectExecute(Sender
: TObject
);
5242 CopyBuffer
: TCopyRecArray
;
5244 swad
, ssec
, sres
: String;
5248 StringToCopyBuffer(ClipBoard
.AsText
, CopyBuffer
);
5250 if CopyBuffer
= nil then
5253 RemoveSelectFromObjects();
5255 h
:= High(CopyBuffer
);
5257 with CopyBuffer
[a
] do
5261 if Panel
<> nil then
5263 Panel
^.X
:= Panel
^.X
+ 16;
5264 Panel
^.Y
:= Panel
^.Y
+ 16;
5266 Panel
^.TextureID
:= TEXTURE_SPECIAL_NONE
;
5267 Panel
^.TextureWidth
:= 1;
5268 Panel
^.TextureHeight
:= 1;
5270 if (Panel
^.PanelType
= PANEL_LIFTUP
) or
5271 (Panel
^.PanelType
= PANEL_LIFTDOWN
) or
5272 (Panel
^.PanelType
= PANEL_LIFTLEFT
) or
5273 (Panel
^.PanelType
= PANEL_LIFTRIGHT
) or
5274 (Panel
^.PanelType
= PANEL_BLOCKMON
) or
5275 (Panel
^.TextureName
= '') then
5276 begin // Нет или не может быть текстуры:
5278 else // Есть текстура:
5280 // Обычная текстура:
5281 if not IsSpecialTexture(Panel
^.TextureName
) then
5283 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5287 g_ProcessResourceStr(Panel
^.TextureName
, swad
, ssec
, sres
);
5288 AddTexture(swad
, ssec
, sres
, True);
5289 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5293 g_GetTextureSizeByName(Panel
^.TextureName
,
5294 Panel
^.TextureWidth
, Panel
^.TextureHeight
)
5296 Panel
^.TextureName
:= '';
5298 else // Спец.текстура:
5300 Panel
^.TextureID
:= SpecialTextureID(Panel
^.TextureName
);
5301 with MainForm
.lbTextureList
.Items
do
5302 if IndexOf(win2utf(Panel
^.TextureName
)) = -1 then
5303 Add(win2utf(Panel
^.TextureName
));
5307 ID
:= AddPanel(Panel
^);
5309 Undo_Add(OBJECT_PANEL
, ID
, a
> 0);
5310 SelectObject(OBJECT_PANEL
, ID
, True);
5315 Item
.X
:= Item
.X
+ 16;
5316 Item
.Y
:= Item
.Y
+ 16;
5318 ID
:= AddItem(Item
);
5319 Undo_Add(OBJECT_ITEM
, ID
, a
> 0);
5320 SelectObject(OBJECT_ITEM
, ID
, True);
5325 Monster
.X
:= Monster
.X
+ 16;
5326 Monster
.Y
:= Monster
.Y
+ 16;
5328 ID
:= AddMonster(Monster
);
5329 Undo_Add(OBJECT_MONSTER
, ID
, a
> 0);
5330 SelectObject(OBJECT_MONSTER
, ID
, True);
5335 Area
.X
:= Area
.X
+ 16;
5336 Area
.Y
:= Area
.Y
+ 16;
5338 ID
:= AddArea(Area
);
5339 Undo_Add(OBJECT_AREA
, ID
, a
> 0);
5340 SelectObject(OBJECT_AREA
, ID
, True);
5345 Trigger
.X
:= Trigger
.X
+ 16;
5346 Trigger
.Y
:= Trigger
.Y
+ 16;
5348 ID
:= AddTrigger(Trigger
);
5349 Undo_Add(OBJECT_TRIGGER
, ID
, a
> 0);
5350 SelectObject(OBJECT_TRIGGER
, ID
, True);
5355 // Переставляем ссылки триггеров:
5356 for a
:= 0 to High(CopyBuffer
) do
5357 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
5359 case CopyBuffer
[a
].Trigger
.TriggerType
of
5360 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5361 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5362 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5363 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
5364 gTriggers
[CopyBuffer
[a
].ID
].Data
.PanelID
:=
5365 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.PanelID
].ID
;
5367 TRIGGER_PRESS
, TRIGGER_ON
,
5368 TRIGGER_OFF
, TRIGGER_ONOFF
:
5369 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
5370 gTriggers
[CopyBuffer
[a
].ID
].Data
.MonsterID
:=
5371 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1].ID
+1;
5374 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
5375 gTriggers
[CopyBuffer
[a
].ID
].Data
.ShotPanelID
:=
5376 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
].ID
;
5379 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
5380 gTriggers
[CopyBuffer
[a
].ID
].TexturePanel
:=
5381 CopyBuffer
[CopyBuffer
[a
].Trigger
.TexturePanel
].ID
;
5390 procedure TMainForm
.aCutObjectExecute(Sender
: TObject
);
5393 DeleteSelectedObjects();
5396 procedure TMainForm
.vleObjectPropertyEditButtonClick(Sender
: TObject
);
5398 Key
, FileName
: String;
5401 Key
:= vleObjectProperty
.Keys
[vleObjectProperty
.Row
];
5403 if Key
= _lc
[I_PROP_PANEL_TYPE
] then
5405 with ChooseTypeForm
, vleObjectProperty
do
5406 begin // Выбор типа панели:
5407 Caption
:= _lc
[I_PROP_PANEL_TYPE
];
5408 lbTypeSelect
.Items
.Clear();
5410 for b
:= 0 to High(PANELNAMES
) do
5412 lbTypeSelect
.Items
.Add(PANELNAMES
[b
]);
5413 if Values
[Key
] = PANELNAMES
[b
] then
5414 lbTypeSelect
.ItemIndex
:= b
;
5417 if ShowModal() = mrOK
then
5419 b
:= lbTypeSelect
.ItemIndex
;
5420 Values
[Key
] := PANELNAMES
[b
];
5421 bApplyProperty
.Click();
5425 else if Key
= _lc
[I_PROP_TR_TELEPORT_TO
] then
5426 SelectFlag
:= SELECTFLAG_TELEPORT
5427 else if Key
= _lc
[I_PROP_TR_SPAWN_TO
] then
5428 SelectFlag
:= SELECTFLAG_SPAWNPOINT
5429 else if (Key
= _lc
[I_PROP_TR_DOOR_PANEL
]) or
5430 (Key
= _lc
[I_PROP_TR_TRAP_PANEL
]) then
5431 SelectFlag
:= SELECTFLAG_DOOR
5432 else if Key
= _lc
[I_PROP_TR_TEXTURE_PANEL
] then
5434 DrawPressRect
:= False;
5435 SelectFlag
:= SELECTFLAG_TEXTURE
;
5437 else if Key
= _lc
[I_PROP_TR_SHOT_PANEL
] then
5438 SelectFlag
:= SELECTFLAG_SHOTPANEL
5439 else if Key
= _lc
[I_PROP_TR_LIFT_PANEL
] then
5440 SelectFlag
:= SELECTFLAG_LIFT
5441 else if key
= _lc
[I_PROP_TR_EX_MONSTER
] then
5442 SelectFlag
:= SELECTFLAG_MONSTER
5443 else if Key
= _lc
[I_PROP_TR_EX_AREA
] then
5445 SelectFlag
:= SELECTFLAG_NONE
;
5446 DrawPressRect
:= True;
5448 else if Key
= _lc
[I_PROP_TR_NEXT_MAP
] then
5449 begin // Выбор следующей карты:
5450 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
5451 SelectMapForm
.GetMaps(FileName
);
5453 if SelectMapForm
.ShowModal() = mrOK
then
5455 vleObjectProperty
.Values
[Key
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
5456 bApplyProperty
.Click();
5459 else if (Key
= _lc
[I_PROP_TR_SOUND_NAME
]) or
5460 (Key
= _lc
[I_PROP_TR_MUSIC_NAME
]) then
5461 begin // Выбор файла звука/музыки:
5462 AddSoundForm
.OKFunction
:= nil;
5463 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
5464 AddSoundForm
.SetResource
:= utf2win(vleObjectProperty
.Values
[Key
]);
5466 if (AddSoundForm
.ShowModal() = mrOk
) then
5468 vleObjectProperty
.Values
[Key
] := utf2win(AddSoundForm
.ResourceName
);
5469 bApplyProperty
.Click();
5472 else if Key
= _lc
[I_PROP_TR_ACTIVATION
] then
5473 with ActivationTypeForm
, vleObjectProperty
do
5474 begin // Выбор типов активации:
5475 cbPlayerCollide
.Checked
:= Pos('PC', Values
[Key
]) > 0;
5476 cbMonsterCollide
.Checked
:= Pos('MC', Values
[Key
]) > 0;
5477 cbPlayerPress
.Checked
:= Pos('PP', Values
[Key
]) > 0;
5478 cbMonsterPress
.Checked
:= Pos('MP', Values
[Key
]) > 0;
5479 cbShot
.Checked
:= Pos('SH', Values
[Key
]) > 0;
5480 cbNoMonster
.Checked
:= Pos('NM', Values
[Key
]) > 0;
5482 if ShowModal() = mrOK
then
5485 if cbPlayerCollide
.Checked
then
5486 b
:= ACTIVATE_PLAYERCOLLIDE
;
5487 if cbMonsterCollide
.Checked
then
5488 b
:= b
or ACTIVATE_MONSTERCOLLIDE
;
5489 if cbPlayerPress
.Checked
then
5490 b
:= b
or ACTIVATE_PLAYERPRESS
;
5491 if cbMonsterPress
.Checked
then
5492 b
:= b
or ACTIVATE_MONSTERPRESS
;
5493 if cbShot
.Checked
then
5494 b
:= b
or ACTIVATE_SHOT
;
5495 if cbNoMonster
.Checked
then
5496 b
:= b
or ACTIVATE_NOMONSTER
;
5498 Values
[Key
] := ActivateToStr(b
);
5499 bApplyProperty
.Click();
5502 else if Key
= _lc
[I_PROP_TR_KEYS
] then
5503 with KeysForm
, vleObjectProperty
do
5504 begin // Выбор необходимых ключей:
5505 cbRedKey
.Checked
:= Pos('RK', Values
[Key
]) > 0;
5506 cbGreenKey
.Checked
:= Pos('GK', Values
[Key
]) > 0;
5507 cbBlueKey
.Checked
:= Pos('BK', Values
[Key
]) > 0;
5508 cbRedTeam
.Checked
:= Pos('RT', Values
[Key
]) > 0;
5509 cbBlueTeam
.Checked
:= Pos('BT', Values
[Key
]) > 0;
5511 if ShowModal() = mrOK
then
5514 if cbRedKey
.Checked
then
5516 if cbGreenKey
.Checked
then
5517 b
:= b
or KEY_GREEN
;
5518 if cbBlueKey
.Checked
then
5520 if cbRedTeam
.Checked
then
5521 b
:= b
or KEY_REDTEAM
;
5522 if cbBlueTeam
.Checked
then
5523 b
:= b
or KEY_BLUETEAM
;
5525 Values
[Key
] := KeyToStr(b
);
5526 bApplyProperty
.Click();
5529 else if Key
= _lc
[I_PROP_TR_FX_TYPE
] then
5530 with ChooseTypeForm
, vleObjectProperty
do
5531 begin // Выбор типа эффекта:
5532 Caption
:= _lc
[I_CAP_FX_TYPE
];
5533 lbTypeSelect
.Items
.Clear();
5535 for b
:= EFFECT_NONE
to EFFECT_FIRE
do
5536 lbTypeSelect
.Items
.Add(EffectToStr(b
));
5538 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]);
5540 if ShowModal() = mrOK
then
5542 b
:= lbTypeSelect
.ItemIndex
;
5543 Values
[Key
] := EffectToStr(b
);
5544 bApplyProperty
.Click();
5547 else if Key
= _lc
[I_PROP_TR_MONSTER_TYPE
] then
5548 with ChooseTypeForm
, vleObjectProperty
do
5549 begin // Выбор типа монстра:
5550 Caption
:= _lc
[I_CAP_MONSTER_TYPE
];
5551 lbTypeSelect
.Items
.Clear();
5553 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5554 lbTypeSelect
.Items
.Add(MonsterToStr(b
));
5556 lbTypeSelect
.ItemIndex
:= StrToMonster(Values
[Key
]) - MONSTER_DEMON
;
5558 if ShowModal() = mrOK
then
5560 b
:= lbTypeSelect
.ItemIndex
+ MONSTER_DEMON
;
5561 Values
[Key
] := MonsterToStr(b
);
5562 bApplyProperty
.Click();
5565 else if Key
= _lc
[I_PROP_TR_ITEM_TYPE
] then
5566 with ChooseTypeForm
, vleObjectProperty
do
5567 begin // Выбор типа предмета:
5568 Caption
:= _lc
[I_CAP_ITEM_TYPE
];
5569 lbTypeSelect
.Items
.Clear();
5571 for b
:= ITEM_MEDKIT_SMALL
to ITEM_KEY_BLUE
do
5572 lbTypeSelect
.Items
.Add(ItemToStr(b
));
5573 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_BOTTLE
));
5574 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_HELMET
));
5575 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_JETPACK
));
5576 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_INVIS
));
5577 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_WEAPON_FLAMETHROWER
));
5578 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_AMMO_FUELCAN
));
5580 b
:= StrToItem(Values
[Key
]);
5581 if b
>= ITEM_BOTTLE
then
5583 lbTypeSelect
.ItemIndex
:= b
- ITEM_MEDKIT_SMALL
;
5585 if ShowModal() = mrOK
then
5587 b
:= lbTypeSelect
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
5588 if b
>= ITEM_WEAPON_KASTET
then
5590 Values
[Key
] := ItemToStr(b
);
5591 bApplyProperty
.Click();
5594 else if Key
= _lc
[I_PROP_TR_SHOT_TYPE
] then
5595 with ChooseTypeForm
, vleObjectProperty
do
5596 begin // Выбор типа предмета:
5597 Caption
:= _lc
[I_PROP_TR_SHOT_TYPE
];
5598 lbTypeSelect
.Items
.Clear();
5600 for b
:= TRIGGER_SHOT_PISTOL
to TRIGGER_SHOT_MAX
do
5601 lbTypeSelect
.Items
.Add(ShotToStr(b
));
5603 lbTypeSelect
.ItemIndex
:= StrToShot(Values
[Key
]);
5605 if ShowModal() = mrOK
then
5607 b
:= lbTypeSelect
.ItemIndex
;
5608 Values
[Key
] := ShotToStr(b
);
5609 bApplyProperty
.Click();
5612 else if Key
= _lc
[I_PROP_TR_EFFECT_TYPE
] then
5613 with ChooseTypeForm
, vleObjectProperty
do
5614 begin // Выбор типа эффекта:
5615 Caption
:= _lc
[I_CAP_FX_TYPE
];
5616 lbTypeSelect
.Items
.Clear();
5618 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_PARTICLE
]);
5619 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_ANIMATION
]);
5620 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_ANIMATION
] then
5621 lbTypeSelect
.ItemIndex
:= 1
5623 lbTypeSelect
.ItemIndex
:= 0;
5625 if ShowModal() = mrOK
then
5627 b
:= lbTypeSelect
.ItemIndex
;
5629 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_PARTICLE
]
5631 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_ANIMATION
];
5632 bApplyProperty
.Click();
5635 else if Key
= _lc
[I_PROP_TR_EFFECT_SUBTYPE
] then
5636 with ChooseTypeForm
, vleObjectProperty
do
5637 begin // Выбор подтипа эффекта:
5638 Caption
:= _lc
[I_CAP_FX_TYPE
];
5639 lbTypeSelect
.Items
.Clear();
5641 if Values
[_lc
[I_PROP_TR_EFFECT_TYPE
]] = _lc
[I_PROP_TR_EFFECT_ANIMATION
] then
5643 for b
:= EFFECT_TELEPORT
to EFFECT_FIRE
do
5644 lbTypeSelect
.Items
.Add(EffectToStr(b
));
5646 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]) - 1;
5649 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_SLIQUID
]);
5650 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_LLIQUID
]);
5651 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_DLIQUID
]);
5652 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_BLOOD
]);
5653 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_SPARK
]);
5654 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_BUBBLE
]);
5655 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SLIQUID
;
5656 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_LLIQUID
] then
5657 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_LLIQUID
;
5658 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_DLIQUID
] then
5659 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_DLIQUID
;
5660 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_BLOOD
] then
5661 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BLOOD
;
5662 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_SPARK
] then
5663 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SPARK
;
5664 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_BUBBLE
] then
5665 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BUBBLE
;
5668 if ShowModal() = mrOK
then
5670 b
:= lbTypeSelect
.ItemIndex
;
5672 if Values
[_lc
[I_PROP_TR_EFFECT_TYPE
]] = _lc
[I_PROP_TR_EFFECT_ANIMATION
] then
5673 Values
[Key
] := EffectToStr(b
+ 1)
5675 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_SLIQUID
];
5676 if b
= TRIGGER_EFFECT_LLIQUID
then
5677 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_LLIQUID
];
5678 if b
= TRIGGER_EFFECT_DLIQUID
then
5679 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_DLIQUID
];
5680 if b
= TRIGGER_EFFECT_BLOOD
then
5681 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_BLOOD
];
5682 if b
= TRIGGER_EFFECT_SPARK
then
5683 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_SPARK
];
5684 if b
= TRIGGER_EFFECT_BUBBLE
then
5685 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_BUBBLE
];
5688 bApplyProperty
.Click();
5691 else if Key
= _lc
[I_PROP_TR_EFFECT_COLOR
] then
5692 with vleObjectProperty
do
5693 begin // Выбор цвета эффекта:
5694 ColorDialog
.Color
:= StrToIntDef(Values
[Key
], 0);
5695 if ColorDialog
.Execute
then
5697 Values
[Key
] := IntToStr(ColorDialog
.Color
);
5698 bApplyProperty
.Click();
5701 else if Key
= _lc
[I_PROP_PANEL_TEX
] then
5702 begin // Смена текстуры:
5703 vleObjectProperty
.Values
[Key
] := SelectedTexture();
5704 bApplyProperty
.Click();
5708 procedure TMainForm
.aSaveMapExecute(Sender
: TObject
);
5710 FileName
, Section
, Res
: String;
5712 if OpenedMap
= '' then
5714 aSaveMapAsExecute(nil);
5718 g_ProcessResourceStr(OpenedMap
, FileName
, Section
, Res
);
5720 SaveMap(FileName
+':\'+Res
);
5723 procedure TMainForm
.aOpenMapExecute(Sender
: TObject
);
5725 OpenDialog
.Filter
:= _lc
[I_FILE_FILTER_ALL
];
5727 if OpenDialog
.Execute() then
5729 if (Pos('.ini', LowerCase(ExtractFileName(OpenDialog
.FileName
))) > 0) then
5733 pLoadProgress
.Left
:= (RenderPanel
.Width
div 2)-(pLoadProgress
.Width
div 2);
5734 pLoadProgress
.Top
:= (RenderPanel
.Height
div 2)-(pLoadProgress
.Height
div 2);
5735 pLoadProgress
.Show();
5740 LoadMapOld(OpenDialog
.FileName
);
5742 MainForm
.Caption
:= Format('%s - %s', [FormCaption
, ExtractFileName(OpenDialog
.FileName
)]);
5744 pLoadProgress
.Hide();
5745 MainForm
.FormResize(Self
);
5747 else // Карты из WAD:
5749 OpenMap(OpenDialog
.FileName
, '');
5752 OpenDialog
.InitialDir
:= ExtractFileDir(OpenDialog
.FileName
);
5756 procedure TMainForm
.FormActivate(Sender
: TObject
);
5761 MainForm
.ActiveControl
:= RenderPanel
;
5764 if gLanguage
= '' then
5766 lang
:= SelectLanguageForm
.ShowModal();
5768 1: gLanguage
:= LANGUAGE_ENGLISH
;
5769 else gLanguage
:= LANGUAGE_RUSSIAN
;
5772 config
:= TConfig
.CreateFile(EditorDir
+'Editor.cfg');
5773 config
.WriteStr('Editor', 'Language', gLanguage
);
5774 config
.SaveFile(EditorDir
+'Editor.cfg');
5778 //e_WriteLog('Read language file', MSG_NOTIFY);
5779 //g_Language_Load(EditorDir+'\data\'+gLanguage+LANGUAGE_FILE_NAME);
5780 g_Language_Set(gLanguage
);
5783 procedure TMainForm
.aDeleteMap(Sender
: TObject
);
5791 OpenDialog
.Filter
:= _lc
[I_FILE_FILTER_WAD
];
5793 if not OpenDialog
.Execute() then
5796 WAD
:= TWADEditor_1
.Create();
5798 if not WAD
.ReadFile(OpenDialog
.FileName
) then
5806 MapList
:= WAD
.GetResourcesList('');
5808 SelectMapForm
.lbMapList
.Items
.Clear();
5810 if MapList
<> nil then
5811 for a
:= 0 to High(MapList
) do
5812 SelectMapForm
.lbMapList
.Items
.Add(MapList
[a
]);
5814 if (SelectMapForm
.ShowModal() = mrOK
) then
5816 str
:= SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
5818 Move(MapName
[0], str
[1], Min(16, Length(str
)));
5820 if MessageBox(0, PChar(Format(_lc
[I_MSG_DELETE_MAP_PROMT
],
5821 [MapName
, OpenDialog
.FileName
])),
5822 PChar(_lc
[I_MSG_DELETE_MAP
]),
5823 MB_ICONQUESTION
or MB_YESNO
or
5824 MB_DEFBUTTON2
) <> mrYes
then
5827 WAD
.RemoveResource('', MapName
);
5829 MessageBox(0, PChar(Format(_lc
[I_MSG_MAP_DELETED_PROMT
],
5831 PChar(_lc
[I_MSG_MAP_DELETED
]),
5832 MB_ICONINFORMATION
or MB_OK
or
5835 WAD
.SaveTo(OpenDialog
.FileName
);
5837 // Удалили текущую карту - сохранять по старому ее нельзя:
5838 if OpenedMap
= (OpenDialog
.FileName
+':\'+MapName
) then
5842 MainForm
.Caption
:= FormCaption
;
5849 procedure TMainForm
.vleObjectPropertyKeyDown(Sender
: TObject
;
5850 var Key
: Word; Shift
: TShiftState
);
5852 if Key
= VK_RETURN
then
5853 bApplyProperty
.Click();
5856 procedure MovePanel(var ID
: DWORD
; MoveType
: Byte);
5861 if (ID
= 0) and (MoveType
= 0) then
5863 if (ID
= DWORD(High(gPanels
))) and (MoveType
<> 0) then
5865 if (ID
> DWORD(High(gPanels
))) then
5870 if MoveType
= 0 then // to Back
5872 if gTriggers
<> nil then
5873 for a
:= 0 to High(gTriggers
) do
5874 with gTriggers
[a
] do
5876 if TriggerType
= TRIGGER_NONE
then
5879 if TexturePanel
= _id
then
5882 if (TexturePanel
>= 0) and (TexturePanel
< _id
) then
5886 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5887 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5888 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5889 if Data
.PanelID
= _id
then
5892 if (Data
.PanelID
>= 0) and (Data
.PanelID
< _id
) then
5896 if Data
.ShotPanelID
= _id
then
5897 Data
.ShotPanelID
:= 0
5899 if (Data
.ShotPanelID
>= 0) and (Data
.ShotPanelID
< _id
) then
5900 Inc(Data
.ShotPanelID
);
5904 tmp
:= gPanels
[_id
];
5906 for a
:= _id
downto 1 do
5907 gPanels
[a
] := gPanels
[a
-1];
5915 if gTriggers
<> nil then
5916 for a
:= 0 to High(gTriggers
) do
5917 with gTriggers
[a
] do
5919 if TriggerType
= TRIGGER_NONE
then
5922 if TexturePanel
= _id
then
5923 TexturePanel
:= High(gPanels
)
5925 if TexturePanel
> _id
then
5929 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5930 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5931 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5932 if Data
.PanelID
= _id
then
5933 Data
.PanelID
:= High(gPanels
)
5935 if Data
.PanelID
> _id
then
5939 if Data
.ShotPanelID
= _id
then
5940 Data
.ShotPanelID
:= High(gPanels
)
5942 if Data
.ShotPanelID
> _id
then
5943 Dec(Data
.ShotPanelID
);
5947 tmp
:= gPanels
[_id
];
5949 for a
:= _id
to High(gPanels
)-1 do
5950 gPanels
[a
] := gPanels
[a
+1];
5952 gPanels
[High(gPanels
)] := tmp
;
5954 ID
:= High(gPanels
);
5958 procedure TMainForm
.aMoveToBack(Sender
: TObject
);
5962 if SelectedObjects
= nil then
5965 for a
:= 0 to High(SelectedObjects
) do
5966 with SelectedObjects
[a
] do
5967 if Live
and (ObjectType
= OBJECT_PANEL
) then
5969 SelectedObjects
[0] := SelectedObjects
[a
];
5970 SetLength(SelectedObjects
, 1);
5977 procedure TMainForm
.aMoveToFore(Sender
: TObject
);
5981 if SelectedObjects
= nil then
5984 for a
:= 0 to High(SelectedObjects
) do
5985 with SelectedObjects
[a
] do
5986 if Live
and (ObjectType
= OBJECT_PANEL
) then
5988 SelectedObjects
[0] := SelectedObjects
[a
];
5989 SetLength(SelectedObjects
, 1);
5996 procedure TMainForm
.aSaveMapAsExecute(Sender
: TObject
);
6000 SaveDialog
.Filter
:= _lc
[I_FILE_FILTER_WAD
];
6002 if not SaveDialog
.Execute() then
6005 SaveMapForm
.GetMaps(SaveDialog
.FileName
, True);
6007 if SaveMapForm
.ShowModal() <> mrOK
then
6010 SaveDialog
.InitialDir
:= ExtractFileDir(SaveDialog
.FileName
);
6011 OpenedMap
:= SaveDialog
.FileName
+':\'+SaveMapForm
.eMapName
.Text;
6012 OpenedWAD
:= SaveDialog
.FileName
;
6014 idx
:= RecentFiles
.IndexOf(OpenedMap
);
6015 // Такая карта уже недавно открывалась:
6017 RecentFiles
.Delete(idx
);
6018 RecentFiles
.Insert(0, OpenedMap
);
6023 gMapInfo
.FileName
:= SaveDialog
.FileName
;
6024 gMapInfo
.MapName
:= SaveMapForm
.eMapName
.Text;
6025 UpdateCaption(gMapInfo
.Name
, ExtractFileName(gMapInfo
.FileName
), gMapInfo
.MapName
);
6028 procedure TMainForm
.aSelectAllExecute(Sender
: TObject
);
6032 RemoveSelectFromObjects();
6034 case pcObjects
.ActivePageIndex
+1 of
6036 if gPanels
<> nil then
6037 for a
:= 0 to High(gPanels
) do
6038 if gPanels
[a
].PanelType
<> PANEL_NONE
then
6039 SelectObject(OBJECT_PANEL
, a
, True);
6041 if gItems
<> nil then
6042 for a
:= 0 to High(gItems
) do
6043 if gItems
[a
].ItemType
<> ITEM_NONE
then
6044 SelectObject(OBJECT_ITEM
, a
, True);
6046 if gMonsters
<> nil then
6047 for a
:= 0 to High(gMonsters
) do
6048 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
6049 SelectObject(OBJECT_MONSTER
, a
, True);
6051 if gAreas
<> nil then
6052 for a
:= 0 to High(gAreas
) do
6053 if gAreas
[a
].AreaType
<> AREA_NONE
then
6054 SelectObject(OBJECT_AREA
, a
, True);
6056 if gTriggers
<> nil then
6057 for a
:= 0 to High(gTriggers
) do
6058 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
6059 SelectObject(OBJECT_TRIGGER
, a
, True);
6063 procedure TMainForm
.tbGridOnClick(Sender
: TObject
);
6065 DotEnable
:= not DotEnable
;
6066 (Sender
as TToolButton
).Down
:= DotEnable
;
6069 procedure TMainForm
.OnIdle(Sender
: TObject
; var Done
: Boolean);
6071 // FIXME: this is a shitty hack
6072 if not gDataLoaded
then
6074 e_WriteLog('Init OpenGL', MSG_NOTIFY
);
6076 e_WriteLog('Loading data', MSG_NOTIFY
);
6077 LoadStdFont('STDTXT', 'STDFONT', gEditorFont
);
6078 e_WriteLog('Loading more data', MSG_NOTIFY
);
6080 e_WriteLog('Loading even more data', MSG_NOTIFY
);
6081 gDataLoaded
:= True;
6082 MainForm
.FormResize(nil);
6087 procedure TMainForm
.miMapPreviewClick(Sender
: TObject
);
6089 if not PreviewMode
then
6091 Splitter2
.Visible
:= False;
6092 Splitter1
.Visible
:= False;
6093 StatusBar
.Visible
:= False;
6094 PanelObjs
.Visible
:= False;
6095 PanelProps
.Visible
:= False;
6096 MainToolBar
.Visible
:= False;
6097 sbHorizontal
.Visible
:= False;
6098 sbVertical
.Visible
:= False;
6102 StatusBar
.Visible
:= True;
6103 PanelObjs
.Visible
:= True;
6104 PanelProps
.Visible
:= True;
6105 Splitter2
.Visible
:= True;
6106 Splitter1
.Visible
:= True;
6107 MainToolBar
.Visible
:= True;
6108 sbHorizontal
.Visible
:= True;
6109 sbVertical
.Visible
:= True;
6112 PreviewMode
:= not PreviewMode
;
6113 (Sender
as TMenuItem
).Checked
:= PreviewMode
;
6118 procedure TMainForm
.miLayer1Click(Sender
: TObject
);
6120 SwitchLayer(LAYER_BACK
);
6123 procedure TMainForm
.miLayer2Click(Sender
: TObject
);
6125 SwitchLayer(LAYER_WALLS
);
6128 procedure TMainForm
.miLayer3Click(Sender
: TObject
);
6130 SwitchLayer(LAYER_FOREGROUND
);
6133 procedure TMainForm
.miLayer4Click(Sender
: TObject
);
6135 SwitchLayer(LAYER_STEPS
);
6138 procedure TMainForm
.miLayer5Click(Sender
: TObject
);
6140 SwitchLayer(LAYER_WATER
);
6143 procedure TMainForm
.miLayer6Click(Sender
: TObject
);
6145 SwitchLayer(LAYER_ITEMS
);
6148 procedure TMainForm
.miLayer7Click(Sender
: TObject
);
6150 SwitchLayer(LAYER_MONSTERS
);
6153 procedure TMainForm
.miLayer8Click(Sender
: TObject
);
6155 SwitchLayer(LAYER_AREAS
);
6158 procedure TMainForm
.miLayer9Click(Sender
: TObject
);
6160 SwitchLayer(LAYER_TRIGGERS
);
6163 procedure TMainForm
.tbShowClick(Sender
: TObject
);
6169 for a
:= 0 to High(LayerEnabled
) do
6170 b
:= b
and LayerEnabled
[a
];
6174 ShowLayer(LAYER_BACK
, b
);
6175 ShowLayer(LAYER_WALLS
, b
);
6176 ShowLayer(LAYER_FOREGROUND
, b
);
6177 ShowLayer(LAYER_STEPS
, b
);
6178 ShowLayer(LAYER_WATER
, b
);
6179 ShowLayer(LAYER_ITEMS
, b
);
6180 ShowLayer(LAYER_MONSTERS
, b
);
6181 ShowLayer(LAYER_AREAS
, b
);
6182 ShowLayer(LAYER_TRIGGERS
, b
);
6185 procedure TMainForm
.miMiniMapClick(Sender
: TObject
);
6190 procedure TMainForm
.miSwitchGridClick(Sender
: TObject
);
6192 if DotStep
= DotStepOne
then
6193 DotStep
:= DotStepTwo
6195 DotStep
:= DotStepOne
;
6197 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6198 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6201 procedure TMainForm
.miShowEdgesClick(Sender
: TObject
);
6206 procedure TMainForm
.miSnapToGridClick(Sender
: TObject
);
6208 SnapToGrid
:= not SnapToGrid
;
6210 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6211 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6213 miSnapToGrid
.Checked
:= SnapToGrid
;
6216 procedure TMainForm
.minexttabClick(Sender
: TObject
);
6218 if pcObjects
.ActivePageIndex
< pcObjects
.PageCount
-1 then
6219 pcObjects
.ActivePageIndex
:= pcObjects
.ActivePageIndex
+1
6221 pcObjects
.ActivePageIndex
:= 0;
6224 procedure TMainForm
.miSaveMiniMapClick(Sender
: TObject
);
6226 SaveMiniMapForm
.ShowModal();
6229 procedure TMainForm
.bClearTextureClick(Sender
: TObject
);
6231 lbTextureList
.ItemIndex
:= -1;
6232 lTextureWidth
.Caption
:= '';
6233 lTextureHeight
.Caption
:= '';
6236 procedure TMainForm
.miPackMapClick(Sender
: TObject
);
6238 PackMapForm
.ShowModal();
6241 procedure TMainForm
.miMapTestSettingsClick(Sender
: TObject
);
6243 MapTestForm
.ShowModal();
6246 procedure TMainForm
.miTestMapClick(Sender
: TObject
);
6248 cmd
, mapWAD
, mapToRun
: String;
6252 // Сохраняем временную карту:
6255 mapWAD
:= ExtractFilePath(TestD2dExe
) + Format('maps/temp%.4d.wad', [time
]);
6257 until not FileExists(mapWAD
);
6258 mapToRun
:= mapWAD
+ ':\' + TEST_MAP_NAME
;
6261 mapToRun
:= ExtractRelativePath(ExtractFilePath(TestD2dExe
) + 'maps/', mapToRun
);
6265 if TestOptionsTwoPlayers
then
6267 if TestOptionsTeamDamage
then
6269 if TestOptionsAllowExit
then
6271 if TestOptionsWeaponStay
then
6273 if TestOptionsMonstersDM
then
6276 // Составляем командную строку:
6277 cmd
:= ' -map "' + mapToRun
+ '"';
6278 cmd
:= cmd
+ ' -gm ' + TestGameMode
;
6279 cmd
:= cmd
+ ' -limt ' + TestLimTime
;
6280 cmd
:= cmd
+ ' -lims ' + TestLimScore
;
6281 cmd
:= cmd
+ ' -opt ' + IntToStr(opt
);
6284 cmd
:= cmd
+ ' --close';
6286 cmd
:= cmd
+ ' --debug';
6287 cmd
:= cmd
+ ' --tempdelete';
6290 Application
.Minimize();
6291 if ExecuteProcess(TestD2dExe
, cmd
) < 0 then
6293 MessageBox(0, 'FIXME',
6294 PChar(_lc
[I_MSG_EXEC_ERROR
]),
6295 MB_OK
or MB_ICONERROR
);
6298 SysUtils
.DeleteFile(mapWAD
);
6299 Application
.Restore();
6302 procedure TMainForm
.sbVerticalScroll(Sender
: TObject
;
6303 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
6305 MapOffset
.Y
:= -Normalize16(sbVertical
.Position
);
6308 procedure TMainForm
.sbHorizontalScroll(Sender
: TObject
;
6309 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
6311 MapOffset
.X
:= -Normalize16(sbHorizontal
.Position
);
6314 procedure TMainForm
.miOpenWadMapClick(Sender
: TObject
);
6316 if OpenedWAD
<> '' then
6318 OpenMap(OpenedWAD
, '');
6322 procedure TMainForm
.selectall1Click(Sender
: TObject
);
6326 RemoveSelectFromObjects();
6328 if gPanels
<> nil then
6329 for a
:= 0 to High(gPanels
) do
6330 if gPanels
[a
].PanelType
<> PANEL_NONE
then
6331 SelectObject(OBJECT_PANEL
, a
, True);
6333 if gItems
<> nil then
6334 for a
:= 0 to High(gItems
) do
6335 if gItems
[a
].ItemType
<> ITEM_NONE
then
6336 SelectObject(OBJECT_ITEM
, a
, True);
6338 if gMonsters
<> nil then
6339 for a
:= 0 to High(gMonsters
) do
6340 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
6341 SelectObject(OBJECT_MONSTER
, a
, True);
6343 if gAreas
<> nil then
6344 for a
:= 0 to High(gAreas
) do
6345 if gAreas
[a
].AreaType
<> AREA_NONE
then
6346 SelectObject(OBJECT_AREA
, a
, True);
6348 if gTriggers
<> nil then
6349 for a
:= 0 to High(gTriggers
) do
6350 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
6351 SelectObject(OBJECT_TRIGGER
, a
, True);
6354 procedure TMainForm
.Splitter1CanResize(Sender
: TObject
;
6355 var NewSize
: Integer; var Accept
: Boolean);
6357 Accept
:= (NewSize
> 140);
6360 procedure TMainForm
.Splitter2CanResize(Sender
: TObject
;
6361 var NewSize
: Integer; var Accept
: Boolean);
6363 Accept
:= (NewSize
> 110);
6366 procedure TMainForm
.vleObjectPropertyEnter(Sender
: TObject
);
6368 EditingProperties
:= True;
6371 procedure TMainForm
.vleObjectPropertyExit(Sender
: TObject
);
6373 EditingProperties
:= False;
6376 procedure TMainForm
.FormKeyUp(Sender
: TObject
; var Key
: Word;
6377 Shift
: TShiftState
);
6379 // Объекты передвигались:
6380 if MainForm
.ActiveControl
= RenderPanel
then
6382 if (Key
= VK_NUMPAD4
) or
6383 (Key
= VK_NUMPAD6
) or
6384 (Key
= VK_NUMPAD8
) or
6385 (Key
= VK_NUMPAD5
) or
6386 (Key
= Ord('V')) then
6392 procedure TMainForm.lbTextureListDrawItem(Control: TWinControl; Index: Integer;
6393 Rect: TRect; State: LCLType.TOwnerDrawState);
6395 with Control as TListBox do
6397 if LCLType.odSelected in State then
6399 Canvas.Brush.Color := clHighlight;
6400 Canvas.Font.Color := clHighlightText;
6402 if (Items <> nil) and (Index >= 0) then
6403 if slInvalidTextures.IndexOf(Items[Index]) > -1 then
6405 Canvas.Brush.Color := clRed;
6406 Canvas.Font.Color := clWhite;
6408 Canvas.FillRect(Rect);
6409 Canvas.TextRect(Rect, Rect.Left, Rect.Top, Items[Index]);