3 {$INCLUDE ../shared/a_modes.inc}
8 LCLIntf
, LCLType
, SysUtils
, Variants
, Classes
, Graphics
,
9 Controls
, Forms
, Dialogs
, StdCtrls
, Buttons
,
10 ComCtrls
, ValEdit
, Types
, Menus
, ExtCtrls
,
11 CheckLst
, Grids
, OpenGLContext
, utils
, UTF8Process
;
17 TMainForm
= class(TForm
)
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 lbTextureListDrawItem(Control
: TWinControl
; Index
: Integer;
211 ARect
: TRect
; State
: TOwnerDrawState
);
212 procedure RenderPanelMouseDown(Sender
: TObject
; Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
213 procedure RenderPanelMouseMove(Sender
: TObject
; Shift
: TShiftState
; X
, Y
: Integer);
214 procedure RenderPanelMouseUp(Sender
: TObject
; Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
215 procedure RenderPanelPaint(Sender
: TObject
);
216 procedure RenderPanelResize(Sender
: TObject
);
217 procedure Splitter1Moved(Sender
: TObject
);
218 procedure vleObjectPropertyEditButtonClick(Sender
: TObject
);
219 procedure vleObjectPropertyApply(Sender
: TObject
);
220 procedure vleObjectPropertyGetPickList(Sender
: TObject
; const KeyName
: String; Values
: TStrings
);
221 procedure vleObjectPropertyKeyDown(Sender
: TObject
; var Key
: Word;
223 procedure tbGridOnClick(Sender
: TObject
);
224 procedure miMapPreviewClick(Sender
: TObject
);
225 procedure miLayer1Click(Sender
: TObject
);
226 procedure miLayer2Click(Sender
: TObject
);
227 procedure miLayer3Click(Sender
: TObject
);
228 procedure miLayer4Click(Sender
: TObject
);
229 procedure miLayer5Click(Sender
: TObject
);
230 procedure miLayer6Click(Sender
: TObject
);
231 procedure miLayer7Click(Sender
: TObject
);
232 procedure miLayer8Click(Sender
: TObject
);
233 procedure miLayer9Click(Sender
: TObject
);
234 procedure tbShowClick(Sender
: TObject
);
235 procedure miSnapToGridClick(Sender
: TObject
);
236 procedure miMiniMapClick(Sender
: TObject
);
237 procedure miSwitchGridClick(Sender
: TObject
);
238 procedure miShowEdgesClick(Sender
: TObject
);
239 procedure minexttabClick(Sender
: TObject
);
240 procedure miSaveMiniMapClick(Sender
: TObject
);
241 procedure bClearTextureClick(Sender
: TObject
);
242 procedure miPackMapClick(Sender
: TObject
);
243 procedure aRecentFileExecute(Sender
: TObject
);
244 procedure miMapTestSettingsClick(Sender
: TObject
);
245 procedure miTestMapClick(Sender
: TObject
);
246 procedure sbVerticalScroll(Sender
: TObject
; ScrollCode
: TScrollCode
;
247 var ScrollPos
: Integer);
248 procedure sbHorizontalScroll(Sender
: TObject
; ScrollCode
: TScrollCode
;
249 var ScrollPos
: Integer);
250 procedure miOpenWadMapClick(Sender
: TObject
);
251 procedure selectall1Click(Sender
: TObject
);
252 procedure Splitter1CanResize(Sender
: TObject
; var NewSize
: Integer;
253 var Accept
: Boolean);
254 procedure Splitter2CanResize(Sender
: TObject
; var NewSize
: Integer;
255 var Accept
: Boolean);
256 procedure vleObjectPropertyEnter(Sender
: TObject
);
257 procedure vleObjectPropertyExit(Sender
: TObject
);
258 procedure FormKeyUp(Sender
: TObject
; var Key
: Word;
262 procedure OnIdle(Sender
: TObject
; var Done
: Boolean);
264 procedure RefreshRecentMenu();
270 LAYER_FOREGROUND
= 2;
278 TEST_MAP_NAME
= '$$$_TEST_$$$';
279 LANGUAGE_FILE_NAME
= '_Editor.txt';
290 DotStepOne
, DotStepTwo
: Byte;
292 DrawTexturePanel
: Boolean;
293 DrawPanelSize
: Boolean;
295 PreviewColor
: TColor
;
297 RecentCount
: Integer;
298 RecentFiles
: TStringList
;
299 slInvalidTextures
: TStringList
;
301 TestGameMode
: String;
303 TestLimScore
: String;
304 TestOptionsTwoPlayers
: Boolean;
305 TestOptionsTeamDamage
: Boolean;
306 TestOptionsAllowExit
: Boolean;
307 TestOptionsWeaponStay
: Boolean;
308 TestOptionsMonstersDM
: Boolean;
310 TestMapOnce
: Boolean;
312 LayerEnabled
: Array [LAYER_BACK
..LAYER_TRIGGERS
] of Boolean =
313 (True, True, True, True, True, True, True, True, True);
314 PreviewMode
: Byte = 0;
320 procedure OpenMap(FileName
: String; mapN
: String);
321 function AddTexture(aWAD
, aSection
, aTex
: String; silent
: Boolean): Boolean;
322 procedure RemoveSelectFromObjects();
323 procedure ChangeShownProperty(Name
: String; NewValue
: String);
328 f_options
, e_graphics
, e_log
, GL
, Math
,
329 f_mapoptions
, g_basic
, f_about
, f_mapoptimization
,
330 f_mapcheck
, f_addresource_texture
, g_textures
,
331 f_activationtype
, f_keys
,
332 MAPREADER
, f_selectmap
, f_savemap
, WADEDITOR
, WADSTRUCT
, MAPDEF
,
333 g_map
, f_saveminimap
, f_addresource
, CONFIG
, f_packmap
,
334 f_addresource_sound
, f_maptest
, f_choosetype
,
335 g_language
, f_selectlang
, ClipBrd
;
338 UNDO_DELETE_PANEL
= 1;
339 UNDO_DELETE_ITEM
= 2;
340 UNDO_DELETE_AREA
= 3;
341 UNDO_DELETE_MONSTER
= 4;
342 UNDO_DELETE_TRIGGER
= 5;
346 UNDO_ADD_MONSTER
= 9;
347 UNDO_ADD_TRIGGER
= 10;
348 UNDO_MOVE_PANEL
= 11;
351 UNDO_MOVE_MONSTER
= 14;
352 UNDO_MOVE_TRIGGER
= 15;
353 UNDO_RESIZE_PANEL
= 16;
354 UNDO_RESIZE_TRIGGER
= 17;
356 MOUSEACTION_NONE
= 0;
357 MOUSEACTION_DRAWPANEL
= 1;
358 MOUSEACTION_DRAWTRIGGER
= 2;
359 MOUSEACTION_MOVEOBJ
= 3;
360 MOUSEACTION_RESIZE
= 4;
361 MOUSEACTION_MOVEMAP
= 5;
362 MOUSEACTION_DRAWPRESS
= 6;
363 MOUSEACTION_NOACTION
= 7;
366 RESIZETYPE_VERTICAL
= 1;
367 RESIZETYPE_HORIZONTAL
= 2;
376 SELECTFLAG_TELEPORT
= 1;
378 SELECTFLAG_TEXTURE
= 3;
380 SELECTFLAG_MONSTER
= 5;
381 SELECTFLAG_SPAWNPOINT
= 6;
382 SELECTFLAG_SHOTPANEL
= 7;
383 SELECTFLAG_SELECTED
= 8;
385 RECENT_FILES_MENU_START
= 11;
387 CLIPBOARD_SIG
= 'DF:ED';
393 UNDO_DELETE_PANEL
: (Panel
: ^TPanel
);
394 UNDO_DELETE_ITEM
: (Item
: TItem
);
395 UNDO_DELETE_AREA
: (Area
: TArea
);
396 UNDO_DELETE_MONSTER
: (Monster
: TMonster
);
397 UNDO_DELETE_TRIGGER
: (Trigger
: TTrigger
);
402 UNDO_ADD_TRIGGER
: (AddID
: DWORD
);
407 UNDO_MOVE_TRIGGER
: (MoveID
: DWORD
; dX
, dY
: Integer);
409 UNDO_RESIZE_TRIGGER
: (ResizeID
: DWORD
; dW
, dH
: Integer);
416 OBJECT_PANEL
: (Panel
: ^TPanel
);
417 OBJECT_ITEM
: (Item
: TItem
);
418 OBJECT_AREA
: (Area
: TArea
);
419 OBJECT_MONSTER
: (Monster
: TMonster
);
420 OBJECT_TRIGGER
: (Trigger
: TTrigger
);
423 TCopyRecArray
= Array of TCopyRec
;
427 gDataLoaded
: Boolean = False;
428 ShowMap
: Boolean = False;
429 DrawRect
: PRect
= nil;
430 SnapToGrid
: Boolean = True;
432 MousePos
: Types
.TPoint
;
433 LastMovePoint
: Types
.TPoint
;
436 MouseLDownPos
: Types
.TPoint
;
437 MouseRDownPos
: Types
.TPoint
;
439 SelectFlag
: Byte = SELECTFLAG_NONE
;
440 MouseAction
: Byte = MOUSEACTION_NONE
;
441 ResizeType
: Byte = RESIZETYPE_NONE
;
442 ResizeDirection
: Byte = RESIZEDIR_NONE
;
444 DrawPressRect
: Boolean = False;
445 EditingProperties
: Boolean = False;
447 UndoBuffer
: Array of Array of TUndoRec
= nil;
452 //----------------------------------------
453 //Далее идут вспомогательные процедуры
454 //----------------------------------------
456 function NameToBool(Name
: String): Boolean;
458 if Name
= BoolNames
[True] then
464 function NameToDir(Name
: String): TDirection
;
466 if Name
= DirNames
[D_LEFT
] then
472 function NameToDirAdv(Name
: String): Byte;
474 if Name
= DirNamesAdv
[1] then
477 if Name
= DirNamesAdv
[2] then
480 if Name
= DirNamesAdv
[3] then
486 function ActivateToStr(ActivateType
: Byte): String;
490 if ByteBool(ACTIVATE_PLAYERCOLLIDE
and ActivateType
) then
491 Result
:= Result
+ '+PC';
492 if ByteBool(ACTIVATE_MONSTERCOLLIDE
and ActivateType
) then
493 Result
:= Result
+ '+MC';
494 if ByteBool(ACTIVATE_PLAYERPRESS
and ActivateType
) then
495 Result
:= Result
+ '+PP';
496 if ByteBool(ACTIVATE_MONSTERPRESS
and ActivateType
) then
497 Result
:= Result
+ '+MP';
498 if ByteBool(ACTIVATE_SHOT
and ActivateType
) then
499 Result
:= Result
+ '+SH';
500 if ByteBool(ACTIVATE_NOMONSTER
and ActivateType
) then
501 Result
:= Result
+ '+NM';
503 if (Result
<> '') and (Result
[1] = '+') then
504 Delete(Result
, 1, 1);
507 function StrToActivate(Str
: String): Byte;
511 if Pos('PC', Str
) > 0 then
512 Result
:= ACTIVATE_PLAYERCOLLIDE
;
513 if Pos('MC', Str
) > 0 then
514 Result
:= Result
or ACTIVATE_MONSTERCOLLIDE
;
515 if Pos('PP', Str
) > 0 then
516 Result
:= Result
or ACTIVATE_PLAYERPRESS
;
517 if Pos('MP', Str
) > 0 then
518 Result
:= Result
or ACTIVATE_MONSTERPRESS
;
519 if Pos('SH', Str
) > 0 then
520 Result
:= Result
or ACTIVATE_SHOT
;
521 if Pos('NM', Str
) > 0 then
522 Result
:= Result
or ACTIVATE_NOMONSTER
;
525 function KeyToStr(Key
: Byte): String;
529 if ByteBool(KEY_RED
and Key
) then
530 Result
:= Result
+ '+RK';
531 if ByteBool(KEY_GREEN
and Key
) then
532 Result
:= Result
+ '+GK';
533 if ByteBool(KEY_BLUE
and Key
) then
534 Result
:= Result
+ '+BK';
535 if ByteBool(KEY_REDTEAM
and Key
) then
536 Result
:= Result
+ '+RT';
537 if ByteBool(KEY_BLUETEAM
and Key
) then
538 Result
:= Result
+ '+BT';
540 if (Result
<> '') and (Result
[1] = '+') then
541 Delete(Result
, 1, 1);
544 function StrToKey(Str
: String): Byte;
548 if Pos('RK', Str
) > 0 then
550 if Pos('GK', Str
) > 0 then
551 Result
:= Result
or KEY_GREEN
;
552 if Pos('BK', Str
) > 0 then
553 Result
:= Result
or KEY_BLUE
;
554 if Pos('RT', Str
) > 0 then
555 Result
:= Result
or KEY_REDTEAM
;
556 if Pos('BT', Str
) > 0 then
557 Result
:= Result
or KEY_BLUETEAM
;
560 function EffectToStr(Effect
: Byte): String;
562 if Effect
in [EFFECT_TELEPORT
..EFFECT_FIRE
] then
563 Result
:= EffectNames
[Effect
]
565 Result
:= EffectNames
[EFFECT_NONE
];
568 function StrToEffect(Str
: String): Byte;
572 Result
:= EFFECT_NONE
;
573 for i
:= EFFECT_TELEPORT
to EFFECT_FIRE
do
574 if EffectNames
[i
] = Str
then
581 function MonsterToStr(MonType
: Byte): String;
583 if MonType
in [MONSTER_DEMON
..MONSTER_MAN
] then
584 Result
:= MonsterNames
[MonType
]
586 Result
:= MonsterNames
[MONSTER_ZOMBY
];
589 function StrToMonster(Str
: String): Byte;
593 Result
:= MONSTER_ZOMBY
;
594 for i
:= MONSTER_DEMON
to MONSTER_MAN
do
595 if MonsterNames
[i
] = Str
then
602 function ItemToStr(ItemType
: Byte): String;
604 if ItemType
in [ITEM_MEDKIT_SMALL
..ITEM_MAX
] then
605 Result
:= ItemNames
[ItemType
]
607 Result
:= ItemNames
[ITEM_AMMO_BULLETS
];
610 function StrToItem(Str
: String): Byte;
614 Result
:= ITEM_AMMO_BULLETS
;
615 for i
:= ITEM_MEDKIT_SMALL
to ITEM_MAX
do
616 if ItemNames
[i
] = Str
then
623 function ShotToStr(ShotType
: Byte): String;
625 if ShotType
in [TRIGGER_SHOT_PISTOL
..TRIGGER_SHOT_MAX
] then
626 Result
:= ShotNames
[ShotType
]
628 Result
:= ShotNames
[TRIGGER_SHOT_PISTOL
];
631 function StrToShot(Str
: String): Byte;
635 Result
:= TRIGGER_SHOT_PISTOL
;
636 for i
:= TRIGGER_SHOT_PISTOL
to TRIGGER_SHOT_MAX
do
637 if ShotNames
[i
] = Str
then
644 function SelectedObjectCount(): Word;
650 if SelectedObjects
= nil then
653 for a
:= 0 to High(SelectedObjects
) do
654 if SelectedObjects
[a
].Live
then
655 Result
:= Result
+ 1;
658 function GetFirstSelected(): Integer;
664 if SelectedObjects
= nil then
667 for a
:= 0 to High(SelectedObjects
) do
668 if SelectedObjects
[a
].Live
then
675 function Normalize16(x
: Integer): Integer;
677 Result
:= (x
div 16) * 16;
680 procedure MoveMap(X
, Y
: Integer);
682 rx
, ry
, ScaleSz
: Integer;
684 with MainForm
.RenderPanel
do
686 ScaleSz
:= 16 div Scale
;
687 // Размер видимой части карты:
688 rx
:= min(Normalize16(Width
), Normalize16(gMapInfo
.Width
)) div 2;
689 ry
:= min(Normalize16(Height
), Normalize16(gMapInfo
.Height
)) div 2;
690 // Место клика на мини-карте:
691 MapOffset
.X
:= X
- (Width
-max(gMapInfo
.Width
div ScaleSz
, 1)-1);
692 MapOffset
.Y
:= Y
- 1;
693 // Это же место на "большой" карте:
694 MapOffset
.X
:= MapOffset
.X
* ScaleSz
;
695 MapOffset
.Y
:= MapOffset
.Y
* ScaleSz
;
696 // Левый верхний угол новой видимой части карты:
697 MapOffset
.X
:= MapOffset
.X
- rx
;
698 MapOffset
.Y
:= MapOffset
.Y
- ry
;
700 if MapOffset
.X
< 0 then
702 if MapOffset
.Y
< 0 then
704 if MapOffset
.X
> MainForm
.sbHorizontal
.Max
then
705 MapOffset
.X
:= MainForm
.sbHorizontal
.Max
;
706 if MapOffset
.Y
> MainForm
.sbVertical
.Max
then
707 MapOffset
.Y
:= MainForm
.sbVertical
.Max
;
709 MapOffset
.X
:= Normalize16(MapOffset
.X
);
710 MapOffset
.Y
:= Normalize16(MapOffset
.Y
);
713 MainForm
.sbHorizontal
.Position
:= MapOffset
.X
;
714 MainForm
.sbVertical
.Position
:= MapOffset
.Y
;
716 MapOffset
.X
:= -MapOffset
.X
;
717 MapOffset
.Y
:= -MapOffset
.Y
;
722 function IsTexturedPanel(PanelType
: Word): Boolean;
724 Result
:= WordBool(PanelType
and (PANEL_WALL
or PANEL_BACK
or PANEL_FORE
or
725 PANEL_STEP
or PANEL_OPENDOOR
or PANEL_CLOSEDOOR
or
726 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
));
729 procedure FillProperty();
734 MainForm
.vleObjectProperty
.Strings
.Clear();
736 // Отображаем свойства если выделен только один объект:
737 if SelectedObjectCount() <> 1 then
740 _id
:= GetFirstSelected();
741 if not SelectedObjects
[_id
].Live
then
744 with MainForm
.vleObjectProperty
do
745 with ItemProps
[InsertRow(_lc
[I_PROP_ID
], IntToStr(SelectedObjects
[_id
].ID
), True)] do
747 EditStyle
:= esSimple
;
751 case SelectedObjects
[0].ObjectType
of
754 with MainForm
.vleObjectProperty
,
755 gPanels
[SelectedObjects
[_id
].ID
] do
757 with ItemProps
[InsertRow(_lc
[I_PROP_X
], IntToStr(X
), True)] do
759 EditStyle
:= esSimple
;
763 with ItemProps
[InsertRow(_lc
[I_PROP_Y
], IntToStr(Y
), True)] do
765 EditStyle
:= esSimple
;
769 with ItemProps
[InsertRow(_lc
[I_PROP_WIDTH
], IntToStr(Width
), True)] do
771 EditStyle
:= esSimple
;
775 with ItemProps
[InsertRow(_lc
[I_PROP_HEIGHT
], IntToStr(Height
), True)] do
777 EditStyle
:= esSimple
;
781 with ItemProps
[InsertRow(_lc
[I_PROP_PANEL_TYPE
], GetPanelName(PanelType
), True)] do
783 EditStyle
:= esEllipsis
;
787 if IsTexturedPanel(PanelType
) then
788 begin // Может быть текстура
789 with ItemProps
[InsertRow(_lc
[I_PROP_PANEL_TEX
], TextureName
, True)] do
791 EditStyle
:= esEllipsis
;
795 if TextureName
<> '' then
796 begin // Есть текстура
797 with ItemProps
[InsertRow(_lc
[I_PROP_PANEL_ALPHA
], IntToStr(Alpha
), True)] do
799 EditStyle
:= esSimple
;
803 with ItemProps
[InsertRow(_lc
[I_PROP_PANEL_BLEND
], BoolNames
[Blending
], True)] do
805 EditStyle
:= esPickList
;
815 with MainForm
.vleObjectProperty
,
816 gItems
[SelectedObjects
[_id
].ID
] do
818 with ItemProps
[InsertRow(_lc
[I_PROP_X
], IntToStr(X
), True)] do
820 EditStyle
:= esSimple
;
824 with ItemProps
[InsertRow(_lc
[I_PROP_Y
], IntToStr(Y
), True)] do
826 EditStyle
:= esSimple
;
830 with ItemProps
[InsertRow(_lc
[I_PROP_DM_ONLY
], BoolNames
[OnlyDM
], True)] do
832 EditStyle
:= esPickList
;
836 with ItemProps
[InsertRow(_lc
[I_PROP_ITEM_FALLS
], BoolNames
[Fall
], True)] do
838 EditStyle
:= esPickList
;
846 with MainForm
.vleObjectProperty
,
847 gMonsters
[SelectedObjects
[_id
].ID
] do
849 with ItemProps
[InsertRow(_lc
[I_PROP_X
], IntToStr(X
), True)] do
851 EditStyle
:= esSimple
;
855 with ItemProps
[InsertRow(_lc
[I_PROP_Y
], IntToStr(Y
), True)] do
857 EditStyle
:= esSimple
;
861 with ItemProps
[InsertRow(_lc
[I_PROP_DIRECTION
], DirNames
[Direction
], True)] do
863 EditStyle
:= esPickList
;
871 with MainForm
.vleObjectProperty
,
872 gAreas
[SelectedObjects
[_id
].ID
] do
874 with ItemProps
[InsertRow(_lc
[I_PROP_X
], IntToStr(X
), True)] do
876 EditStyle
:= esSimple
;
880 with ItemProps
[InsertRow(_lc
[I_PROP_Y
], IntToStr(Y
), True)] do
882 EditStyle
:= esSimple
;
886 with ItemProps
[InsertRow(_lc
[I_PROP_DIRECTION
], DirNames
[Direction
], True)] do
888 EditStyle
:= esPickList
;
896 with MainForm
.vleObjectProperty
,
897 gTriggers
[SelectedObjects
[_id
].ID
] do
899 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TYPE
], GetTriggerName(TriggerType
), True)] do
901 EditStyle
:= esSimple
;
905 with ItemProps
[InsertRow(_lc
[I_PROP_X
], IntToStr(X
), True)] do
907 EditStyle
:= esSimple
;
911 with ItemProps
[InsertRow(_lc
[I_PROP_Y
], IntToStr(Y
), True)] do
913 EditStyle
:= esSimple
;
917 with ItemProps
[InsertRow(_lc
[I_PROP_WIDTH
], IntToStr(Width
), True)] do
919 EditStyle
:= esSimple
;
923 with ItemProps
[InsertRow(_lc
[I_PROP_HEIGHT
], IntToStr(Height
), True)] do
925 EditStyle
:= esSimple
;
929 with ItemProps
[InsertRow(_lc
[I_PROP_TR_ENABLED
], BoolNames
[Enabled
], True)] do
931 EditStyle
:= esPickList
;
935 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TEXTURE_PANEL
], IntToStr(TexturePanel
), True)] do
937 EditStyle
:= esEllipsis
;
941 with ItemProps
[InsertRow(_lc
[I_PROP_TR_ACTIVATION
], ActivateToStr(ActivateType
), True)] do
943 EditStyle
:= esEllipsis
;
947 with ItemProps
[InsertRow(_lc
[I_PROP_TR_KEYS
], KeyToStr(Key
), True)] do
949 EditStyle
:= esEllipsis
;
956 str
:= win2utf(Data
.MapName
);
957 with ItemProps
[InsertRow(_lc
[I_PROP_TR_NEXT_MAP
], str
, True)] do
959 EditStyle
:= esEllipsis
;
966 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TELEPORT_TO
], Format('(%d:%d)', [Data
.TargetPoint
.X
, Data
.TargetPoint
.Y
]), True)] do
968 EditStyle
:= esEllipsis
;
972 with ItemProps
[InsertRow(_lc
[I_PROP_TR_D2D
], BoolNames
[Data
.d2d_teleport
], True)] do
974 EditStyle
:= esPickList
;
978 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TELEPORT_SILENT
], BoolNames
[Data
.silent_teleport
], True)] do
980 EditStyle
:= esPickList
;
984 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TELEPORT_DIR
], DirNamesAdv
[Data
.TlpDir
], True)] do
986 EditStyle
:= esPickList
;
991 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
,
992 TRIGGER_DOOR
, TRIGGER_DOOR5
:
994 with ItemProps
[InsertRow(_lc
[I_PROP_TR_DOOR_PANEL
], IntToStr(Data
.PanelID
), True)] do
996 EditStyle
:= esEllipsis
;
1000 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SILENT
], BoolNames
[Data
.NoSound
], True)] do
1002 EditStyle
:= esPickList
;
1006 with ItemProps
[InsertRow(_lc
[I_PROP_TR_D2D
], BoolNames
[Data
.d2d_doors
], True)] do
1008 EditStyle
:= esPickList
;
1013 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
:
1015 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TRAP_PANEL
], IntToStr(Data
.PanelID
), True)] do
1017 EditStyle
:= esEllipsis
;
1021 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SILENT
], BoolNames
[Data
.NoSound
], True)] do
1023 EditStyle
:= esPickList
;
1027 with ItemProps
[InsertRow(_lc
[I_PROP_TR_D2D
], BoolNames
[Data
.d2d_doors
], True)] do
1029 EditStyle
:= esPickList
;
1034 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
1037 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_AREA
],
1038 Format('(%d:%d %d:%d)', [Data
.tX
, Data
.tY
, Data
.tWidth
, Data
.tHeight
]), True)] do
1040 EditStyle
:= esEllipsis
;
1044 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_DELAY
], IntToStr(Data
.Wait
), True)] do
1046 EditStyle
:= esSimple
;
1050 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_COUNT
], IntToStr(Data
.Count
), True)] do
1052 EditStyle
:= esSimple
;
1056 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_MONSTER
], IntToStr(Data
.MonsterID
-1), True)] do
1058 EditStyle
:= esEllipsis
;
1062 if TriggerType
= TRIGGER_PRESS
then
1063 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_RANDOM
], BoolNames
[Data
.ExtRandom
], True)] do
1065 EditStyle
:= esPickList
;
1073 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
1075 with ItemProps
[InsertRow(_lc
[I_PROP_TR_LIFT_PANEL
], IntToStr(Data
.PanelID
), True)] do
1077 EditStyle
:= esEllipsis
;
1081 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SILENT
], BoolNames
[Data
.NoSound
], True)] do
1083 EditStyle
:= esPickList
;
1087 with ItemProps
[InsertRow(_lc
[I_PROP_TR_D2D
], BoolNames
[Data
.d2d_doors
], True)] do
1089 EditStyle
:= esPickList
;
1096 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TEXTURE_ONCE
], BoolNames
[Data
.ActivateOnce
], True)] do
1098 EditStyle
:= esPickList
;
1102 with ItemProps
[InsertRow(_lc
[I_PROP_TR_TEXTURE_ANIM_ONCE
], BoolNames
[Data
.AnimOnce
], True)] do
1104 EditStyle
:= esPickList
;
1111 str
:= win2utf(Data
.SoundName
);
1112 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_NAME
], str
, True)] do
1114 EditStyle
:= esEllipsis
;
1118 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_VOLUME
], IntToStr(Data
.Volume
), True)] do
1120 EditStyle
:= esSimple
;
1124 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_PAN
], IntToStr(Data
.Pan
), True)] do
1126 EditStyle
:= esSimple
;
1130 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_COUNT
], IntToStr(Data
.PlayCount
), True)] do
1132 EditStyle
:= esSimple
;
1136 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_LOCAL
], BoolNames
[Data
.Local
], True)] do
1138 EditStyle
:= esPickList
;
1142 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SOUND_SWITCH
], BoolNames
[Data
.SoundSwitch
], True)] do
1144 EditStyle
:= esPickList
;
1149 TRIGGER_SPAWNMONSTER
:
1151 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MONSTER_TYPE
], MonsterToStr(Data
.MonType
), True)] do
1153 EditStyle
:= esEllipsis
;
1157 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_TO
],
1158 Format('(%d:%d)', [Data
.MonPos
.X
, Data
.MonPos
.Y
]), True)] do
1160 EditStyle
:= esEllipsis
;
1164 with ItemProps
[InsertRow(_lc
[I_PROP_DIRECTION
], DirNames
[TDirection(Data
.MonDir
)], True)] do
1166 EditStyle
:= esPickList
;
1170 with ItemProps
[InsertRow(_lc
[I_PROP_TR_HEALTH
], IntToStr(Data
.MonHealth
), True)] do
1172 EditStyle
:= esSimple
;
1176 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MONSTER_ACTIVE
], BoolNames
[Data
.MonActive
], True)] do
1178 EditStyle
:= esPickList
;
1182 with ItemProps
[InsertRow(_lc
[I_PROP_TR_COUNT
], IntToStr(Data
.MonCount
), True)] do
1184 EditStyle
:= esSimple
;
1188 with ItemProps
[InsertRow(_lc
[I_PROP_TR_FX_TYPE
], EffectToStr(Data
.MonEffect
), True)] do
1190 EditStyle
:= esEllipsis
;
1194 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_MAX
], IntToStr(Data
.MonMax
), True)] do
1196 EditStyle
:= esSimple
;
1200 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_DELAY
], IntToStr(Data
.MonDelay
), True)] do
1202 EditStyle
:= esSimple
;
1206 case Data
.MonBehav
of
1207 1: str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_1
];
1208 2: str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_2
];
1209 3: str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_3
];
1210 4: str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_4
];
1211 5: str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_5
];
1212 else str
:= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_0
];
1214 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
], str
, True)] do
1216 EditStyle
:= esPickList
;
1223 with ItemProps
[InsertRow(_lc
[I_PROP_TR_ITEM_TYPE
], ItemToStr(Data
.ItemType
), True)] do
1225 EditStyle
:= esEllipsis
;
1229 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_TO
],
1230 Format('(%d:%d)', [Data
.ItemPos
.X
, Data
.ItemPos
.Y
]), True)] do
1232 EditStyle
:= esEllipsis
;
1236 with ItemProps
[InsertRow(_lc
[I_PROP_DM_ONLY
], BoolNames
[Data
.ItemOnlyDM
], True)] do
1238 EditStyle
:= esPickList
;
1242 with ItemProps
[InsertRow(_lc
[I_PROP_ITEM_FALLS
], BoolNames
[Data
.ItemFalls
], True)] do
1244 EditStyle
:= esPickList
;
1248 with ItemProps
[InsertRow(_lc
[I_PROP_TR_COUNT
], IntToStr(Data
.ItemCount
), True)] do
1250 EditStyle
:= esSimple
;
1254 with ItemProps
[InsertRow(_lc
[I_PROP_TR_FX_TYPE
], EffectToStr(Data
.ItemEffect
), True)] do
1256 EditStyle
:= esEllipsis
;
1260 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_MAX
], IntToStr(Data
.ItemMax
), True)] do
1262 EditStyle
:= esSimple
;
1266 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_DELAY
], IntToStr(Data
.ItemDelay
), True)] do
1268 EditStyle
:= esSimple
;
1275 str
:= win2utf(Data
.MusicName
);
1276 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MUSIC_NAME
], str
, True)] do
1278 EditStyle
:= esEllipsis
;
1282 if Data
.MusicAction
= 1 then
1283 str
:= _lc
[I_PROP_TR_MUSIC_ON
]
1285 str
:= _lc
[I_PROP_TR_MUSIC_OFF
];
1287 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MUSIC_ACT
], str
, True)] do
1289 EditStyle
:= esPickList
;
1296 with ItemProps
[InsertRow(_lc
[I_PROP_TR_PUSH_ANGLE
], IntToStr(Data
.PushAngle
), True)] do
1298 EditStyle
:= esSimple
;
1301 with ItemProps
[InsertRow(_lc
[I_PROP_TR_PUSH_FORCE
], IntToStr(Data
.PushForce
), True)] do
1303 EditStyle
:= esSimple
;
1306 with ItemProps
[InsertRow(_lc
[I_PROP_TR_PUSH_RESET
], BoolNames
[Data
.ResetVel
], True)] do
1308 EditStyle
:= esPickList
;
1315 case Data
.ScoreAction
of
1316 1: str
:= _lc
[I_PROP_TR_SCORE_ACT_1
];
1317 2: str
:= _lc
[I_PROP_TR_SCORE_ACT_2
];
1318 3: str
:= _lc
[I_PROP_TR_SCORE_ACT_3
];
1319 else str
:= _lc
[I_PROP_TR_SCORE_ACT_0
];
1321 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SCORE_ACT
], str
, True)] do
1323 EditStyle
:= esPickList
;
1326 with ItemProps
[InsertRow(_lc
[I_PROP_TR_COUNT
], IntToStr(Data
.ScoreCount
), True)] do
1328 EditStyle
:= esSimple
;
1331 case Data
.ScoreTeam
of
1332 1: str
:= _lc
[I_PROP_TR_SCORE_TEAM_1
];
1333 2: str
:= _lc
[I_PROP_TR_SCORE_TEAM_2
];
1334 3: str
:= _lc
[I_PROP_TR_SCORE_TEAM_3
];
1335 else str
:= _lc
[I_PROP_TR_SCORE_TEAM_0
];
1337 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SCORE_TEAM
], str
, True)] do
1339 EditStyle
:= esPickList
;
1342 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SCORE_CON
], BoolNames
[Data
.ScoreCon
], True)] do
1344 EditStyle
:= esPickList
;
1347 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SCORE_MSG
], BoolNames
[Data
.ScoreMsg
], True)] do
1349 EditStyle
:= esPickList
;
1356 case Data
.MessageKind
of
1357 1: str
:= _lc
[I_PROP_TR_MESSAGE_KIND_1
];
1358 else str
:= _lc
[I_PROP_TR_MESSAGE_KIND_0
];
1360 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MESSAGE_KIND
], str
, True)] do
1362 EditStyle
:= esPickList
;
1365 case Data
.MessageSendTo
of
1366 1: str
:= _lc
[I_PROP_TR_MESSAGE_TO_1
];
1367 2: str
:= _lc
[I_PROP_TR_MESSAGE_TO_2
];
1368 3: str
:= _lc
[I_PROP_TR_MESSAGE_TO_3
];
1369 4: str
:= _lc
[I_PROP_TR_MESSAGE_TO_4
];
1370 5: str
:= _lc
[I_PROP_TR_MESSAGE_TO_5
];
1371 else str
:= _lc
[I_PROP_TR_MESSAGE_TO_0
];
1373 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MESSAGE_TO
], str
, True)] do
1375 EditStyle
:= esPickList
;
1378 str
:= win2utf(Data
.MessageText
);
1379 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MESSAGE_TEXT
], str
, True)] do
1381 EditStyle
:= esSimple
;
1384 with ItemProps
[InsertRow(_lc
[I_PROP_TR_MESSAGE_TIME
], IntToStr(Data
.MessageTime
), True)] do
1386 EditStyle
:= esSimple
;
1393 with ItemProps
[InsertRow(_lc
[I_PROP_TR_DAMAGE_VALUE
], IntToStr(Data
.DamageValue
), True)] do
1395 EditStyle
:= esSimple
;
1398 with ItemProps
[InsertRow(_lc
[I_PROP_TR_INTERVAL
], IntToStr(Data
.DamageInterval
), True)] do
1400 EditStyle
:= esSimple
;
1407 with ItemProps
[InsertRow(_lc
[I_PROP_TR_HEALTH
], IntToStr(Data
.HealValue
), True)] do
1409 EditStyle
:= esSimple
;
1412 with ItemProps
[InsertRow(_lc
[I_PROP_TR_INTERVAL
], IntToStr(Data
.HealInterval
), True)] do
1414 EditStyle
:= esSimple
;
1417 with ItemProps
[InsertRow(_lc
[I_PROP_TR_HEALTH_MAX
], BoolNames
[Data
.HealMax
], True)] do
1419 EditStyle
:= esPickList
;
1422 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SILENT
], BoolNames
[Data
.HealSilent
], True)] do
1424 EditStyle
:= esPickList
;
1431 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_TYPE
], ShotToStr(Data
.ShotType
), True)] do
1433 EditStyle
:= esEllipsis
;
1437 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_SOUND
], BoolNames
[Data
.ShotSound
], True)] do
1439 EditStyle
:= esPickList
;
1443 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_PANEL
], IntToStr(Data
.ShotPanelID
), True)] do
1445 EditStyle
:= esEllipsis
;
1449 case Data
.ShotTarget
of
1450 1: str
:= _lc
[I_PROP_TR_SHOT_TO_1
];
1451 2: str
:= _lc
[I_PROP_TR_SHOT_TO_2
];
1452 3: str
:= _lc
[I_PROP_TR_SHOT_TO_3
];
1453 4: str
:= _lc
[I_PROP_TR_SHOT_TO_4
];
1454 5: str
:= _lc
[I_PROP_TR_SHOT_TO_5
];
1455 6: str
:= _lc
[I_PROP_TR_SHOT_TO_6
];
1456 else str
:= _lc
[I_PROP_TR_SHOT_TO_0
];
1458 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_TO
], str
, True)] do
1460 EditStyle
:= esPickList
;
1464 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_SIGHT
], IntToStr(Data
.ShotIntSight
), True)] do
1466 EditStyle
:= esSimple
;
1470 case Data
.ShotAim
of
1471 1: str
:= _lc
[I_PROP_TR_SHOT_AIM_1
];
1472 2: str
:= _lc
[I_PROP_TR_SHOT_AIM_2
];
1473 3: str
:= _lc
[I_PROP_TR_SHOT_AIM_3
];
1474 else str
:= _lc
[I_PROP_TR_SHOT_AIM_0
];
1476 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_AIM
], str
, True)-1] do
1478 EditStyle
:= esPickList
;
1482 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SPAWN_TO
],
1483 Format('(%d:%d)', [Data
.ShotPos
.X
, Data
.ShotPos
.Y
]), True)] do
1485 EditStyle
:= esEllipsis
;
1489 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_ANGLE
], IntToStr(Data
.ShotAngle
), True)] do
1491 EditStyle
:= esSimple
;
1495 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_DELAY
], IntToStr(Data
.ShotWait
), True)] do
1497 EditStyle
:= esSimple
;
1501 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_ACC
], IntToStr(Data
.ShotAccuracy
), True)] do
1503 EditStyle
:= esSimple
;
1507 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_AMMO
], IntToStr(Data
.ShotAmmo
), True)] do
1509 EditStyle
:= esSimple
;
1513 with ItemProps
[InsertRow(_lc
[I_PROP_TR_SHOT_RELOAD
], IntToStr(Data
.ShotIntReload
), True)] do
1515 EditStyle
:= esSimple
;
1522 with ItemProps
[InsertRow(_lc
[I_PROP_TR_COUNT
], IntToStr(Data
.FXCount
), True)] do
1524 EditStyle
:= esSimple
;
1528 if Data
.FXType
= 0 then
1529 str
:= _lc
[I_PROP_TR_EFFECT_PARTICLE
]
1531 str
:= _lc
[I_PROP_TR_EFFECT_ANIMATION
];
1532 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_TYPE
], str
, True)] do
1534 EditStyle
:= esEllipsis
;
1539 if Data
.FXType
= 0 then
1540 case Data
.FXSubType
of
1541 TRIGGER_EFFECT_SLIQUID
:
1542 str
:= _lc
[I_PROP_TR_EFFECT_SLIQUID
];
1543 TRIGGER_EFFECT_LLIQUID
:
1544 str
:= _lc
[I_PROP_TR_EFFECT_LLIQUID
];
1545 TRIGGER_EFFECT_DLIQUID
:
1546 str
:= _lc
[I_PROP_TR_EFFECT_DLIQUID
];
1547 TRIGGER_EFFECT_BLOOD
:
1548 str
:= _lc
[I_PROP_TR_EFFECT_BLOOD
];
1549 TRIGGER_EFFECT_SPARK
:
1550 str
:= _lc
[I_PROP_TR_EFFECT_SPARK
];
1551 TRIGGER_EFFECT_BUBBLE
:
1552 str
:= _lc
[I_PROP_TR_EFFECT_BUBBLE
];
1554 if Data
.FXType
= 1 then
1556 if (Data
.FXSubType
= 0) or (Data
.FXSubType
> EFFECT_FIRE
) then
1557 Data
.FXSubType
:= EFFECT_TELEPORT
;
1558 str
:= EffectToStr(Data
.FXSubType
);
1560 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_SUBTYPE
], str
, True)] do
1562 EditStyle
:= esEllipsis
;
1566 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_COLOR
], IntToStr(Data
.FXColorR
or (Data
.FXColorG
shl 8) or (Data
.FXColorB
shl 16)), True)] do
1568 EditStyle
:= esEllipsis
;
1572 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_CENTER
], BoolNames
[Data
.FXPos
= 0], True)] do
1574 EditStyle
:= esPickList
;
1578 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EX_DELAY
], IntToStr(Data
.FXWait
), True)] do
1580 EditStyle
:= esSimple
;
1584 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_VELX
], IntToStr(Data
.FXVelX
), True)] do
1586 EditStyle
:= esSimple
;
1590 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_VELY
], IntToStr(Data
.FXVelY
), True)] do
1592 EditStyle
:= esSimple
;
1596 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_SPL
], IntToStr(Data
.FXSpreadL
), True)] do
1598 EditStyle
:= esSimple
;
1602 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_SPR
], IntToStr(Data
.FXSpreadR
), True)] do
1604 EditStyle
:= esSimple
;
1608 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_SPU
], IntToStr(Data
.FXSpreadU
), True)] do
1610 EditStyle
:= esSimple
;
1614 with ItemProps
[InsertRow(_lc
[I_PROP_TR_EFFECT_SPD
], IntToStr(Data
.FXSpreadD
), True)] do
1616 EditStyle
:= esSimple
;
1620 end; //case TriggerType
1622 end; // OBJECT_TRIGGER:
1626 procedure ChangeShownProperty(Name
: String; NewValue
: String);
1630 if SelectedObjectCount() <> 1 then
1632 if not SelectedObjects
[GetFirstSelected()].Live
then
1635 // Есть ли такой ключ:
1636 if MainForm
.vleObjectProperty
.FindRow(Name
, row
) then
1638 MainForm
.vleObjectProperty
.Values
[Name
] := NewValue
;
1642 procedure SelectObject(fObjectType
: Byte; fID
: DWORD
; Multi
: Boolean);
1651 // Уже выделен - убираем:
1652 if SelectedObjects
<> nil then
1653 for a
:= 0 to High(SelectedObjects
) do
1654 with SelectedObjects
[a
] do
1655 if Live
and (ID
= fID
) and
1656 (ObjectType
= fObjectType
) then
1665 SetLength(SelectedObjects
, Length(SelectedObjects
)+1);
1667 with SelectedObjects
[High(SelectedObjects
)] do
1669 ObjectType
:= fObjectType
;
1676 SetLength(SelectedObjects
, 1);
1678 with SelectedObjects
[0] do
1680 ObjectType
:= fObjectType
;
1686 MainForm
.miCopy
.Enabled
:= True;
1687 MainForm
.miCut
.Enabled
:= True;
1689 if fObjectType
= OBJECT_PANEL
then
1691 MainForm
.miToFore
.Enabled
:= True;
1692 MainForm
.miToBack
.Enabled
:= True;
1696 procedure RemoveSelectFromObjects();
1698 SelectedObjects
:= nil;
1699 DrawPressRect
:= False;
1700 MouseLDown
:= False;
1701 MouseRDown
:= False;
1702 MouseAction
:= MOUSEACTION_NONE
;
1703 SelectFlag
:= SELECTFLAG_NONE
;
1704 ResizeType
:= RESIZETYPE_NONE
;
1705 ResizeDirection
:= RESIZEDIR_NONE
;
1707 MainForm
.vleObjectProperty
.Strings
.Clear();
1709 MainForm
.miCopy
.Enabled
:= False;
1710 MainForm
.miCut
.Enabled
:= False;
1711 MainForm
.miToFore
.Enabled
:= False;
1712 MainForm
.miToBack
.Enabled
:= False;
1715 procedure DeleteSelectedObjects();
1720 if SelectedObjects
= nil then
1726 for a
:= 0 to High(SelectedObjects
) do
1727 with SelectedObjects
[a
] do
1732 SetLength(UndoBuffer
, Length(UndoBuffer
)+1);
1733 i
:= High(UndoBuffer
);
1737 SetLength(UndoBuffer
[i
], Length(UndoBuffer
[i
])+1);
1738 ii
:= High(UndoBuffer
[i
]);
1743 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_PANEL
;
1744 New(UndoBuffer
[i
, ii
].Panel
);
1745 UndoBuffer
[i
, ii
].Panel
^ := gPanels
[ID
];
1749 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_ITEM
;
1750 UndoBuffer
[i
, ii
].Item
:= gItems
[ID
];
1754 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_AREA
;
1755 UndoBuffer
[i
, ii
].Area
:= gAreas
[ID
];
1759 UndoBuffer
[i
, ii
].UndoType
:= UNDO_DELETE_TRIGGER
;
1760 UndoBuffer
[i
, ii
].Trigger
:= gTriggers
[ID
];
1764 RemoveObject(ID
, ObjectType
);
1767 RemoveSelectFromObjects();
1769 MainForm
.miUndo
.Enabled
:= UndoBuffer
<> nil;
1772 procedure Undo_Add(ObjectType
: Byte; ID
: DWORD
; Group
: Boolean = False);
1776 if (not Group
) or (Length(UndoBuffer
) = 0) then
1777 SetLength(UndoBuffer
, Length(UndoBuffer
)+1);
1778 SetLength(UndoBuffer
[High(UndoBuffer
)], Length(UndoBuffer
[High(UndoBuffer
)])+1);
1779 i
:= High(UndoBuffer
);
1780 ii
:= High(UndoBuffer
[i
]);
1784 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_PANEL
;
1786 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_ITEM
;
1788 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_MONSTER
;
1790 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_AREA
;
1792 UndoBuffer
[i
, ii
].UndoType
:= UNDO_ADD_TRIGGER
;
1795 UndoBuffer
[i
, ii
].AddID
:= ID
;
1797 MainForm
.miUndo
.Enabled
:= UndoBuffer
<> nil;
1800 procedure FullClear();
1802 RemoveSelectFromObjects();
1804 LoadSky(gMapInfo
.SkyName
);
1806 slInvalidTextures
.Clear();
1807 MapCheckForm
.lbErrorList
.Clear();
1808 MapCheckForm
.mErrorDescription
.Clear();
1810 MainForm
.miUndo
.Enabled
:= False;
1811 MainForm
.sbHorizontal
.Position
:= 0;
1812 MainForm
.sbVertical
.Position
:= 0;
1813 MainForm
.FormResize(nil);
1814 MainForm
.Caption
:= FormCaption
;
1819 procedure ErrorMessageBox(str
: String);
1821 MessageBox(0, PChar(str
), PChar(_lc
[I_MSG_ERROR
]),
1822 MB_ICONINFORMATION
or MB_OK
or MB_DEFBUTTON1
);
1825 function CheckProperty(): Boolean;
1831 _id
:= GetFirstSelected();
1833 if SelectedObjects
[_id
].ObjectType
= OBJECT_PANEL
then
1834 with gPanels
[SelectedObjects
[_id
].ID
] do
1836 if TextureWidth
<> 0 then
1837 if StrToIntDef(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_WIDTH
]], 1) mod TextureWidth
<> 0 then
1839 ErrorMessageBox(Format(_lc
[I_MSG_WRONG_TEXWIDTH
],
1844 if TextureHeight
<> 0 then
1845 if StrToIntDef(Trim(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_HEIGHT
]]), 1) mod TextureHeight
<> 0 then
1847 ErrorMessageBox(Format(_lc
[I_MSG_WRONG_TEXHEIGHT
],
1852 if IsTexturedPanel(PanelType
) and (TextureName
<> '') then
1853 if not (StrToIntDef(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_PANEL_ALPHA
]], -1) in [0..255]) then
1855 ErrorMessageBox(_lc
[I_MSG_WRONG_ALPHA
]);
1860 if SelectedObjects
[_id
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
] then
1861 if (StrToIntDef(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_WIDTH
]], 0) <= 0) or
1862 (StrToIntDef(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_HEIGHT
]], 0) <= 0) then
1864 ErrorMessageBox(_lc
[I_MSG_WRONG_SIZE
]);
1868 if (Trim(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_X
]]) = '') or
1869 (Trim(MainForm
.vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]) = '') then
1871 ErrorMessageBox(_lc
[I_MSG_WRONG_XY
]);
1878 procedure SelectTexture(ID
: Integer);
1880 MainForm
.lbTextureList
.ItemIndex
:= ID
;
1881 MainForm
.lbTextureListClick(nil);
1884 function AddTexture(aWAD
, aSection
, aTex
: String; silent
: Boolean): Boolean;
1886 a
, FrameLen
: Integer;
1889 ResourceName
: String;
1890 FullResourceName
: String;
1891 SectionName
: String;
1893 Width
, Height
: Word;
1901 if aSection
= '..' then
1904 SectionName
:= aSection
;
1906 if aWAD
= _lc
[I_WAD_SPECIAL_MAP
] then
1908 g_ProcessResourceStr(OpenedMap
, @fn
, nil, nil);
1909 //FileName := EditorDir+'maps\'+ExtractFileName(fn);
1911 ResourceName
:= ':'+SectionName
+'\'+aTex
;
1914 if aWAD
= _lc
[I_WAD_SPECIAL_TEXS
] then
1915 begin // Спец. текстуры
1917 ResourceName
:= aTex
;
1920 begin // Внешний WAD
1921 FileName
:= EditorDir
+'wads/'+aWAD
;
1922 ResourceName
:= aWAD
+':'+SectionName
+'\'+aTex
;
1927 // Есть ли уже такая текстура:
1928 for a
:= 0 to MainForm
.lbTextureList
.Items
.Count
-1 do
1929 if ResourceName
= MainForm
.lbTextureList
.Items
[a
] then
1932 ErrorMessageBox(Format(_lc
[I_MSG_TEXTURE_ALREADY
],
1937 // Название ресурса <= 64 символов:
1938 if Length(ResourceName
) > 64 then
1941 ErrorMessageBox(Format(_lc
[I_MSG_RES_NAME_64
],
1949 if aWAD
= _lc
[I_WAD_SPECIAL_TEXS
] then
1951 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
1958 FullResourceName
:= FileName
+':'+SectionName
+'\'+aTex
;
1960 if IsAnim(FullResourceName
) then
1961 begin // Аним. текстура
1962 GetFrame(FullResourceName
, Data
, FrameLen
, Width
, Height
);
1964 if g_CreateTextureMemorySize(Data
, FrameLen
, ResourceName
, 0, 0, Width
, Height
, 1) then
1965 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
1967 else // Обычная текстура
1969 if g_CreateTextureWAD(ResourceName
, FullResourceName
) then
1970 a
:= MainForm
.lbTextureList
.Items
.Add(ResourceName
);
1972 if (a
> -1) and (not silent
) then
1979 procedure UpdateCaption(sMap
, sFile
, sRes
: String);
1982 if (sFile
= '') and (sRes
= '') and (sMap
= '') then
1983 Caption
:= FormCaption
1986 Caption
:= Format('%s - %s:%s', [FormCaption
, sFile
, sRes
])
1988 if (sFile
<> '') and (sRes
<> '') then
1989 Caption
:= Format('%s - %s (%s:%s)', [FormCaption
, sMap
, sFile
, sRes
])
1991 Caption
:= Format('%s - %s', [FormCaption
, sMap
]);
1994 procedure OpenMap(FileName
: String; mapN
: String);
1999 SelectMapForm
.Caption
:= _lc
[I_CAP_OPEN
];
2000 SelectMapForm
.GetMaps(FileName
);
2002 if (FileName
= OpenedWAD
) and
2003 (OpenedMap
<> '') then
2005 MapName
:= OpenedMap
;
2006 while (Pos(':\', MapName
) > 0) do
2007 Delete(MapName
, 1, Pos(':\', MapName
) + 1);
2009 idx
:= SelectMapForm
.lbMapList
.Items
.IndexOf(MapName
);
2010 SelectMapForm
.lbMapList
.ItemIndex
:= idx
;
2013 if SelectMapForm
.lbMapList
.Count
> 0 then
2014 SelectMapForm
.lbMapList
.ItemIndex
:= 0
2016 SelectMapForm
.lbMapList
.ItemIndex
:= -1;
2021 idx
:= SelectMapForm
.lbMapList
.Items
.IndexOf(mapN
);
2025 if (SelectMapForm
.ShowModal() = mrOK
) and
2026 (SelectMapForm
.lbMapList
.ItemIndex
<> -1) then
2027 idx
:= SelectMapForm
.lbMapList
.ItemIndex
2032 MapName
:= SelectMapForm
.lbMapList
.Items
[idx
];
2038 pLoadProgress
.Left
:= (RenderPanel
.Width
div 2)-(pLoadProgress
.Width
div 2);
2039 pLoadProgress
.Top
:= (RenderPanel
.Height
div 2)-(pLoadProgress
.Height
div 2);
2040 pLoadProgress
.Show();
2042 OpenedMap
:= FileName
+':\'+MapName
;
2043 OpenedWAD
:= FileName
;
2045 idx
:= RecentFiles
.IndexOf(OpenedMap
);
2046 // Такая карта уже недавно открывалась:
2048 RecentFiles
.Delete(idx
);
2049 RecentFiles
.Insert(0, OpenedMap
);
2050 RefreshRecentMenu();
2054 pLoadProgress
.Hide();
2057 lbTextureList
.Sorted
:= True;
2058 lbTextureList
.Sorted
:= False;
2060 UpdateCaption(gMapInfo
.Name
, ExtractFileName(FileName
), MapName
);
2064 procedure MoveSelectedObjects(Wall
, alt
: Boolean; dx
, dy
: Integer);
2069 if SelectedObjects
= nil then
2076 for a
:= 0 to High(SelectedObjects
) do
2077 if SelectedObjects
[a
].Live
then
2079 if ObjectCollideLevel(SelectedObjects
[a
].ID
, SelectedObjects
[a
].ObjectType
, dx
, 0) then
2082 if ObjectCollideLevel(SelectedObjects
[a
].ID
, SelectedObjects
[a
].ObjectType
, 0, dy
) then
2085 if (not okX
) or (not okY
) then
2091 for a
:= 0 to High(SelectedObjects
) do
2092 if SelectedObjects
[a
].Live
then
2095 MoveObject(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
, dx
, 0);
2098 MoveObject(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
, 0, dy
);
2100 if alt
and (SelectedObjects
[a
].ObjectType
= OBJECT_TRIGGER
) then
2102 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_PRESS
,
2103 TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
] then
2104 begin // Двигаем зону Расширителя
2106 gTriggers
[SelectedObjects
[a
].ID
].Data
.tX
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.tX
+dx
;
2108 gTriggers
[SelectedObjects
[a
].ID
].Data
.tY
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.tY
+dy
;
2111 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_TELEPORT
] then
2112 begin // Двигаем точку назначения Телепорта
2114 gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.X
+dx
;
2116 gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.TargetPoint
.Y
+dy
;
2119 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SPAWNMONSTER
] then
2120 begin // Двигаем точку создания монстра
2122 gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.X
+dx
;
2124 gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.MonPos
.Y
+dy
;
2127 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SPAWNITEM
] then
2128 begin // Двигаем точку создания предмета
2130 gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.X
+dx
;
2132 gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ItemPos
.Y
+dy
;
2135 if gTriggers
[SelectedObjects
[a
].ID
].TriggerType
in [TRIGGER_SHOT
] then
2136 begin // Двигаем точку создания выстрела
2138 gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.X
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.X
+dx
;
2140 gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.Y
:= gTriggers
[SelectedObjects
[a
].ID
].Data
.ShotPos
.Y
+dy
;
2145 LastMovePoint
:= MousePos
;
2149 procedure ShowLayer(Layer
: Byte; show
: Boolean);
2151 LayerEnabled
[Layer
] := show
;
2156 MainForm
.miLayer1
.Checked
:= show
;
2157 MainForm
.miLayerP1
.Checked
:= show
;
2161 MainForm
.miLayer2
.Checked
:= show
;
2162 MainForm
.miLayerP2
.Checked
:= show
;
2166 MainForm
.miLayer3
.Checked
:= show
;
2167 MainForm
.miLayerP3
.Checked
:= show
;
2171 MainForm
.miLayer4
.Checked
:= show
;
2172 MainForm
.miLayerP4
.Checked
:= show
;
2176 MainForm
.miLayer5
.Checked
:= show
;
2177 MainForm
.miLayerP5
.Checked
:= show
;
2181 MainForm
.miLayer6
.Checked
:= show
;
2182 MainForm
.miLayerP6
.Checked
:= show
;
2186 MainForm
.miLayer7
.Checked
:= show
;
2187 MainForm
.miLayerP7
.Checked
:= show
;
2191 MainForm
.miLayer8
.Checked
:= show
;
2192 MainForm
.miLayerP8
.Checked
:= show
;
2196 MainForm
.miLayer9
.Checked
:= show
;
2197 MainForm
.miLayerP9
.Checked
:= show
;
2201 RemoveSelectFromObjects();
2204 procedure SwitchLayer(Layer
: Byte);
2206 ShowLayer(Layer
, not LayerEnabled
[Layer
]);
2209 procedure SwitchMap();
2211 ShowMap
:= not ShowMap
;
2212 MainForm
.tbShowMap
.Down
:= ShowMap
;
2215 procedure ShowEdges();
2217 if drEdge
[3] < 255 then
2220 drEdge
[3] := gAlphaEdge
;
2223 function SelectedTexture(): String;
2225 if MainForm
.lbTextureList
.ItemIndex
<> -1 then
2226 Result
:= MainForm
.lbTextureList
.Items
[MainForm
.lbTextureList
.ItemIndex
]
2231 function IsSpecialTextureSel(): Boolean;
2233 Result
:= (MainForm
.lbTextureList
.ItemIndex
<> -1) and
2234 IsSpecialTexture(MainForm
.lbTextureList
.Items
[MainForm
.lbTextureList
.ItemIndex
]);
2237 function CopyBufferToString(var CopyBuf
: TCopyRecArray
): String;
2242 procedure AddInt(x
: Integer);
2244 Res
:= Res
+ IntToStr(x
) + ' ';
2250 if Length(CopyBuf
) = 0 then
2253 Res
:= CLIPBOARD_SIG
+ ' ';
2255 for i
:= 0 to High(CopyBuf
) do
2257 if (CopyBuf
[i
].ObjectType
= OBJECT_PANEL
) and
2258 (CopyBuf
[i
].Panel
= nil) then
2262 AddInt(CopyBuf
[i
].ObjectType
);
2265 // Свойства объекта:
2266 case CopyBuf
[i
].ObjectType
of
2268 with CopyBuf
[i
].Panel
^ do
2275 Res
:= Res
+ '"' + TextureName
+ '" ';
2277 AddInt(IfThen(Blending
, 1, 0));
2281 with CopyBuf
[i
].Item
do
2286 AddInt(IfThen(OnlyDM
, 1, 0));
2287 AddInt(IfThen(Fall
, 1, 0));
2291 with CopyBuf
[i
].Monster
do
2293 AddInt(MonsterType
);
2296 AddInt(IfThen(Direction
= D_LEFT
, 1, 0));
2300 with CopyBuf
[i
].Area
do
2305 AddInt(IfThen(Direction
= D_LEFT
, 1, 0));
2309 with CopyBuf
[i
].Trigger
do
2311 AddInt(TriggerType
);
2316 AddInt(ActivateType
);
2318 AddInt(IfThen(Enabled
, 1, 0));
2319 AddInt(TexturePanel
);
2321 for j
:= 0 to 127 do
2322 AddInt(Data
.Default
[j
]);
2330 procedure StringToCopyBuffer(Str
: String; var CopyBuf
: TCopyRecArray
);
2334 function GetNext(): String;
2339 if Str
[1] = '"' then
2351 Result
:= Copy(Str
, 1, p
-1);
2367 Result
:= Copy(Str
, 1, p
-1);
2377 if GetNext() <> CLIPBOARD_SIG
then
2383 t
:= StrToIntDef(GetNext(), 0);
2385 if (t
< OBJECT_PANEL
) or (t
> OBJECT_TRIGGER
) or
2386 (GetNext() <> ';') then
2387 begin // Что-то не то => пропускаем:
2395 i
:= Length(CopyBuf
);
2396 SetLength(CopyBuf
, i
+ 1);
2398 CopyBuf
[i
].ObjectType
:= t
;
2399 CopyBuf
[i
].Panel
:= nil;
2401 // Свойства объекта:
2405 New(CopyBuf
[i
].Panel
);
2407 with CopyBuf
[i
].Panel
^ do
2409 PanelType
:= StrToIntDef(GetNext(), PANEL_WALL
);
2410 X
:= StrToIntDef(GetNext(), 0);
2411 Y
:= StrToIntDef(GetNext(), 0);
2412 Width
:= StrToIntDef(GetNext(), 16);
2413 Height
:= StrToIntDef(GetNext(), 16);
2414 TextureName
:= GetNext();
2415 Alpha
:= StrToIntDef(GetNext(), 0);
2416 Blending
:= (GetNext() = '1');
2421 with CopyBuf
[i
].Item
do
2423 ItemType
:= StrToIntDef(GetNext(), ITEM_MEDKIT_SMALL
);
2424 X
:= StrToIntDef(GetNext(), 0);
2425 Y
:= StrToIntDef(GetNext(), 0);
2426 OnlyDM
:= (GetNext() = '1');
2427 Fall
:= (GetNext() = '1');
2431 with CopyBuf
[i
].Monster
do
2433 MonsterType
:= StrToIntDef(GetNext(), MONSTER_DEMON
);
2434 X
:= StrToIntDef(GetNext(), 0);
2435 Y
:= StrToIntDef(GetNext(), 0);
2437 if GetNext() = '1' then
2440 Direction
:= D_RIGHT
;
2444 with CopyBuf
[i
].Area
do
2446 AreaType
:= StrToIntDef(GetNext(), AREA_PLAYERPOINT1
);
2447 X
:= StrToIntDef(GetNext(), 0);
2448 Y
:= StrToIntDef(GetNext(), 0);
2449 if GetNext() = '1' then
2452 Direction
:= D_RIGHT
;
2456 with CopyBuf
[i
].Trigger
do
2458 TriggerType
:= StrToIntDef(GetNext(), TRIGGER_EXIT
);
2459 X
:= StrToIntDef(GetNext(), 0);
2460 Y
:= StrToIntDef(GetNext(), 0);
2461 Width
:= StrToIntDef(GetNext(), 16);
2462 Height
:= StrToIntDef(GetNext(), 16);
2463 ActivateType
:= StrToIntDef(GetNext(), 0);
2464 Key
:= StrToIntDef(GetNext(), 0);
2465 Enabled
:= (GetNext() = '1');
2466 TexturePanel
:= StrToIntDef(GetNext(), 0);
2468 for j
:= 0 to 127 do
2469 Data
.Default
[j
] := StrToIntDef(GetNext(), 0);
2475 //----------------------------------------
2476 //Закончились вспомогательные процедуры
2477 //----------------------------------------
2479 procedure TMainForm
.RefreshRecentMenu();
2484 // Лишние запомненные карты:
2485 while RecentFiles
.Count
> RecentCount
do
2486 RecentFiles
.Delete(RecentFiles
.Count
-1);
2488 // Лишние строки меню:
2489 while MainMenu
.Items
[0].Count
> RECENT_FILES_MENU_START
do
2490 MainMenu
.Items
[0].Delete(MainMenu
.Items
[0].Count
-1);
2492 // Отделение списка карт от строки "Выход":
2493 if RecentFiles
.Count
> 0 then
2495 MI
:= TMenuItem
.Create(MainMenu
.Items
[0]);
2497 MainMenu
.Items
[0].Add(MI
);
2500 // Добавление в меню списка запомненных карт:
2501 for i
:= 0 to RecentFiles
.Count
-1 do
2503 MI
:= TMenuItem
.Create(MainMenu
.Items
[0]);
2504 MI
.Caption
:= IntToStr(i
+1) + ' ' + RecentFiles
[i
];
2505 MI
.OnClick
:= aRecentFileExecute
;
2506 MainMenu
.Items
[0].Add(MI
);
2510 procedure TMainForm
.aRecentFileExecute(Sender
: TObject
);
2516 s
:= LowerCase((Sender
as TMenuItem
).Caption
);
2517 Delete(s
, Pos('&', s
), 1);
2518 s
:= Trim(Copy(s
, 1, 2));
2519 n
:= StrToIntDef(s
, 0) - 1;
2521 if (n
< 0) or (n
>= RecentFiles
.Count
) then
2524 s
:= RecentFiles
[n
];
2525 pw
:= Pos('.wad:\', LowerCase(s
));
2529 begin // Map name included
2530 fn
:= Copy(s
, 1, pw
+ 3);
2531 Delete(s
, 1, pw
+ 5);
2532 if (FileExists(fn
)) then
2538 else // Only wad name
2539 if (FileExists(s
)) then
2545 if (not b
) and (MessageBox(0, PChar(_lc
[I_MSG_DEL_RECENT_PROMT
]),
2546 PChar(_lc
[I_MSG_DEL_RECENT
]), MB_ICONQUESTION
or MB_YESNO
) = idYes
) then
2548 RecentFiles
.Delete(n
);
2549 RefreshRecentMenu();
2553 procedure TMainForm
.aEditorOptionsExecute(Sender
: TObject
);
2555 OptionsForm
.ShowModal();
2558 procedure LoadStdFont(cfgres
, texture
: string; var FontID
: DWORD
);
2572 wad
:= TWADEditor_1
.Create
;
2573 if wad
.ReadFile(EditorDir
+'data/Game.wad') then
2574 wad
.GetResource('FONTS', cfgres
, cfgdata
, cfglen
);
2579 if not g_CreateTextureWAD('FONT_STD', EditorDir
+'data/Game.wad:FONTS\'+texture
) then
2580 e_WriteLog('ERROR ERROR ERROR', MSG_WARNING
);
2582 config
:= TConfig
.CreateMem(cfgdata
, cfglen
);
2583 cwdt
:= Min(Max(config
.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
2584 chgt
:= Min(Max(config
.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
2585 spc
:= Min(Max(config
.ReadInt('FontMap', 'Kerning', 0), -128), 127);
2587 if g_GetTexture('FONT_STD', ID
) then
2588 e_TextureFontBuild(ID
, FontID
, cwdt
, chgt
, spc
-2);
2593 e_WriteLog('Could not load FONT_STD', MSG_WARNING
);
2595 if cfglen
<> 0 then FreeMem(cfgdata
);
2598 procedure TMainForm
.FormCreate(Sender
: TObject
);
2606 EditorDir
:= ExtractFilePath(Application
.ExeName
);
2608 e_InitLog(EditorDir
+'Editor.log', WM_NEWFILE
);
2610 slInvalidTextures
:= TStringList
.Create
;
2612 ShowLayer(LAYER_BACK
, True);
2613 ShowLayer(LAYER_WALLS
, True);
2614 ShowLayer(LAYER_FOREGROUND
, True);
2615 ShowLayer(LAYER_STEPS
, True);
2616 ShowLayer(LAYER_WATER
, True);
2617 ShowLayer(LAYER_ITEMS
, True);
2618 ShowLayer(LAYER_MONSTERS
, True);
2619 ShowLayer(LAYER_AREAS
, True);
2620 ShowLayer(LAYER_TRIGGERS
, True);
2624 FormCaption
:= MainForm
.Caption
;
2628 config
:= TConfig
.CreateFile(EditorDir
+'Editor.cfg');
2630 if config
.ReadInt('Editor', 'XPos', -1) = -1 then
2631 Position
:= poDesktopCenter
2633 Left
:= config
.ReadInt('Editor', 'XPos', Left
);
2634 Top
:= config
.ReadInt('Editor', 'YPos', Top
);
2635 Width
:= config
.ReadInt('Editor', 'Width', Width
);
2636 Height
:= config
.ReadInt('Editor', 'Height', Height
);
2638 if config
.ReadBool('Editor', 'Maximize', False) then
2639 WindowState
:= wsMaximized
;
2640 ShowMap
:= config
.ReadBool('Editor', 'Minimap', False);
2641 PanelProps
.Width
:= config
.ReadInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
2642 Splitter1
.Left
:= PanelProps
.Left
;
2643 PanelObjs
.Height
:= config
.ReadInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
2644 Splitter2
.Top
:= PanelObjs
.Top
;
2645 StatusBar
.Top
:= PanelObjs
.BoundsRect
.Bottom
;
2646 DotEnable
:= config
.ReadBool('Editor', 'DotEnable', True);
2647 DotColor
:= config
.ReadInt('Editor', 'DotColor', $FFFFFF);
2648 DotStepOne
:= config
.ReadInt('Editor', 'DotStepOne', 16);
2649 DotStepTwo
:= config
.ReadInt('Editor', 'DotStepTwo', 8);
2650 DotStep
:= config
.ReadInt('Editor', 'DotStep', DotStepOne
);
2651 DrawTexturePanel
:= config
.ReadBool('Editor', 'DrawTexturePanel', True);
2652 DrawPanelSize
:= config
.ReadBool('Editor', 'DrawPanelSize', True);
2653 BackColor
:= config
.ReadInt('Editor', 'BackColor', $7F6040);
2654 PreviewColor
:= config
.ReadInt('Editor', 'PreviewColor', $00FF00);
2655 gColorEdge
:= config
.ReadInt('Editor', 'EdgeColor', COLOR_EDGE
);
2656 gAlphaEdge
:= config
.ReadInt('Editor', 'EdgeAlpha', ALPHA_EDGE
);
2657 if gAlphaEdge
= 255 then
2658 gAlphaEdge
:= ALPHA_EDGE
;
2659 drEdge
[0] := GetRValue(gColorEdge
);
2660 drEdge
[1] := GetGValue(gColorEdge
);
2661 drEdge
[2] := GetBValue(gColorEdge
);
2662 if not config
.ReadBool('Editor', 'EdgeShow', True) then
2665 drEdge
[3] := gAlphaEdge
;
2666 gAlphaTriggerLine
:= config
.ReadInt('Editor', 'LineAlpha', ALPHA_LINE
);
2667 if gAlphaTriggerLine
= 255 then
2668 gAlphaTriggerLine
:= ALPHA_LINE
;
2669 gAlphaTriggerArea
:= config
.ReadInt('Editor', 'TriggerAlpha', ALPHA_AREA
);
2670 if gAlphaTriggerArea
= 255 then
2671 gAlphaTriggerArea
:= ALPHA_AREA
;
2672 if config
.ReadInt('Editor', 'Scale', 0) = 1 then
2676 if config
.ReadInt('Editor', 'DotSize', 0) = 1 then
2680 OpenDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastOpenDir', EditorDir
);
2681 SaveDialog
.InitialDir
:= config
.ReadStr('Editor', 'LastSaveDir', EditorDir
);
2683 s
:= config
.ReadStr('Editor', 'Language', '');
2686 RecentCount
:= config
.ReadInt('Editor', 'RecentCount', 5);
2687 if RecentCount
> 10 then
2689 if RecentCount
< 2 then
2692 RecentFiles
:= TStringList
.Create();
2693 for i
:= 0 to RecentCount
-1 do
2695 s
:= config
.ReadStr('RecentFiles', IntToStr(i
+1), '');
2699 RefreshRecentMenu();
2703 tbShowMap
.Down
:= ShowMap
;
2704 tbGridOn
.Down
:= DotEnable
;
2705 pcObjects
.ActivePageIndex
:= 0;
2706 Application
.Title
:= _lc
[I_EDITOR_TITLE
];
2708 Application
.OnIdle
:= OnIdle
;
2711 procedure PrintBlack(X
, Y
: Integer; Text: string; FontID
: DWORD
);
2713 // NOTE: all the font printing routines assume CP1251
2714 e_TextureFontPrintEx(X
, Y
, Text, FontID
, 0, 0, 0, 1.0);
2717 procedure TMainForm
.Draw();
2722 Width
, Height
: Word;
2725 aX
, aY
, aX2
, aY2
, XX
, ScaleSz
: Integer;
2734 e_Clear(GL_COLOR_BUFFER_BIT
,
2735 GetRValue(BackColor
)/255,
2736 GetGValue(BackColor
)/255,
2737 GetBValue(BackColor
)/255);
2741 ObjCount
:= SelectedObjectCount();
2743 // Обводим выделенные объекты красной рамкой:
2744 if ObjCount
> 0 then
2746 for a
:= 0 to High(SelectedObjects
) do
2747 if SelectedObjects
[a
].Live
then
2749 Rect
:= ObjectGetRect(SelectedObjects
[a
].ObjectType
, SelectedObjects
[a
].ID
);
2753 e_DrawQuad(X
+MapOffset
.X
, Y
+MapOffset
.Y
,
2754 X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+Height
-1,
2757 // Рисуем точки изменения размеров:
2758 if (ObjCount
= 1) and
2759 (SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) then
2761 e_DrawPoint(5, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2762 e_DrawPoint(5, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 255, 255);
2763 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 255, 255);
2764 e_DrawPoint(5, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 255, 255);
2766 e_DrawPoint(3, X
+MapOffset
.X
, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2767 e_DrawPoint(3, X
+MapOffset
.X
+Width
-1, Y
+MapOffset
.Y
+(Height
div 2), 255, 0, 0);
2768 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
, 255, 0, 0);
2769 e_DrawPoint(3, X
+MapOffset
.X
+(Width
div 2), Y
+MapOffset
.Y
+Height
-1, 255, 0, 0);
2776 if DotEnable
and (PreviewMode
= 0) then
2783 for x
:= 0 to (RenderPanel
.Width
div DotStep
) do
2784 for y
:= 0 to (RenderPanel
.Height
div DotStep
) do
2785 e_DrawPoint(DotSize
, x
*DotStep
+ a
, y
*DotStep
+ a
,
2786 GetRValue(DotColor
),
2787 GetGValue(DotColor
),
2788 GetBValue(DotColor
));
2792 if (lbTextureList
.ItemIndex
<> -1) and (cbPreview
.Checked
) and
2793 (not IsSpecialTextureSel()) and (PreviewMode
= 0) then
2795 if not g_GetTexture(SelectedTexture(), ID
) then
2796 g_GetTexture('NOTEXTURE', ID
);
2797 g_GetTextureSizeByID(ID
, Width
, Height
);
2798 if g_GetTexture('PREVIEW', PID
) then
2799 e_DrawFill(PID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, Width
div 16 + 1, Height
div 16 + 1, 0, True, False);
2800 e_Draw(ID
, RenderPanel
.Width
-Width
, RenderPanel
.Height
-Height
, 0, True, False);
2803 // Подсказка при выборе точки Телепорта:
2804 if SelectFlag
= SELECTFLAG_TELEPORT
then
2806 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
2807 if Data
.d2d_teleport
then
2808 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
2809 MousePos
.X
+16, MousePos
.Y
-1,
2812 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+AreaSize
[AREA_DMPOINT
].Width
-1,
2813 MousePos
.Y
+AreaSize
[AREA_DMPOINT
].Height
-1, 255, 255, 255);
2815 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
2816 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
2817 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_TELEPORT
], gEditorFont
);
2820 // Подсказка при выборе точки появления:
2821 if SelectFlag
= SELECTFLAG_SPAWNPOINT
then
2823 e_DrawLine(2, MousePos
.X
-16, MousePos
.Y
-1,
2824 MousePos
.X
+16, MousePos
.Y
-1,
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_SPAWN
], gEditorFont
);
2831 // Подсказка при выборе панели двери:
2832 if SelectFlag
= SELECTFLAG_DOOR
then
2834 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
2835 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
2836 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_PANEL_DOOR
], gEditorFont
);
2839 // Подсказка при выборе панели с текстурой:
2840 if SelectFlag
= SELECTFLAG_TEXTURE
then
2842 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 192, 192, 192, 127);
2843 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+196, MousePos
.Y
+18, 255, 255, 255);
2844 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_PANEL_TEXTURE
], gEditorFont
);
2847 // Подсказка при выборе панели индикации выстрела:
2848 if SelectFlag
= SELECTFLAG_SHOTPANEL
then
2850 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 192, 192, 192, 127);
2851 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+316, MousePos
.Y
+18, 255, 255, 255);
2852 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_PANEL_SHOT
], gEditorFont
);
2855 // Подсказка при выборе панели лифта:
2856 if SelectFlag
= SELECTFLAG_LIFT
then
2858 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 192, 192, 192, 127);
2859 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+180, MousePos
.Y
+18, 255, 255, 255);
2860 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_PANEL_LIFT
], gEditorFont
);
2863 // Подсказка при выборе монстра:
2864 if SelectFlag
= SELECTFLAG_MONSTER
then
2866 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 192, 192, 192, 127);
2867 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+120, MousePos
.Y
+18, 255, 255, 255);
2868 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_MONSTER
], gEditorFont
);
2871 // Подсказка при выборе области воздействия:
2872 if DrawPressRect
then
2874 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 192, 192, 192, 127);
2875 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+204, MousePos
.Y
+18, 255, 255, 255);
2876 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, _glc
[I_HINT_EXT_AREA
], gEditorFont
);
2879 // Рисуем текстуры, если чертим панель:
2880 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and (DrawTexturePanel
) and
2881 (lbTextureList
.ItemIndex
<> -1) and (DrawRect
<> nil) and
2882 (lbPanelType
.ItemIndex
in [0..8]) and not IsSpecialTextureSel() then
2884 if not g_GetTexture(SelectedTexture(), ID
) then
2885 g_GetTexture('NOTEXTURE', ID
);
2886 g_GetTextureSizeByID(ID
, Width
, Height
);
2888 e_DrawFill(ID
, Min(Left
, Right
), Min(Top
, Bottom
), Abs(Right
-Left
) div Width
,
2889 Abs(Bottom
-Top
) div Height
, 0, True, False);
2892 // Прямоугольник выделения:
2893 if DrawRect
<> nil then
2895 e_DrawQuad(Left
, Top
, Right
-1, Bottom
-1, 255, 255, 255);
2897 // Чертим мышью панель/триггер или меняем мышью их размер:
2898 if (MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
, MOUSEACTION_RESIZE
]) and
2899 (DrawPanelSize
) then
2901 e_DrawFillQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 192, 192, 192, 127);
2902 e_DrawQuad(MousePos
.X
, MousePos
.Y
, MousePos
.X
+88, MousePos
.Y
+33, 255, 255, 255);
2904 if MouseAction
in [MOUSEACTION_DRAWPANEL
, MOUSEACTION_DRAWTRIGGER
] then
2905 begin // Чертим новый
2906 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(_glc
[I_HINT_WIDTH
],
2907 [Abs(MousePos
.X
-MouseLDownPos
.X
)]), gEditorFont
);
2908 PrintBlack(MousePos
.X
+2, MousePos
.Y
+14, Format(_glc
[I_HINT_HEIGHT
],
2909 [Abs(MousePos
.Y
-MouseLDownPos
.Y
)]), gEditorFont
);
2911 else // Растягиваем существующий
2912 if SelectedObjects
[GetFirstSelected
].ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
] then
2914 if SelectedObjects
[GetFirstSelected
].ObjectType
= OBJECT_PANEL
then
2916 Width
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
2917 Height
:= gPanels
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
2921 Width
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Width
;
2922 Height
:= gTriggers
[SelectedObjects
[GetFirstSelected
].ID
].Height
;
2925 PrintBlack(MousePos
.X
+2, MousePos
.Y
+2, Format(_glc
[I_HINT_WIDTH
], [Width
]),
2927 PrintBlack(MousePos
.X
+2, MousePos
.Y
+14, Format(_glc
[I_HINT_HEIGHT
], [Height
]),
2932 // Ближайшая к курсору мыши точка на сетке:
2933 e_DrawPoint(3, MousePos
.X
, MousePos
.Y
, 0, 0, 255);
2938 // Сколько пикселов карты в 1 пикселе мини-карты:
2939 ScaleSz
:= 16 div Scale
;
2940 // Размеры мини-карты:
2941 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
2942 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
2943 // X-координата на RenderPanel нулевой x-координаты карты:
2944 XX
:= RenderPanel
.Width
- aX
- 1;
2946 e_DrawFillQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 0, 0, 0, 0);
2947 e_DrawQuad(XX
-1, 0, RenderPanel
.Width
-1, aY
+1, 197, 197, 197);
2949 if gPanels
<> nil then
2952 for a
:= 0 to High(gPanels
) do
2954 if PanelType
<> 0 then
2956 // Левый верхний угол:
2957 aX
:= XX
+ (X
div ScaleSz
);
2958 aY
:= 1 + (Y
div ScaleSz
);
2960 aX2
:= max(Width
div ScaleSz
, 1);
2961 aY2
:= max(Height
div ScaleSz
, 1);
2962 // Правый нижний угол:
2963 aX2
:= aX
+ aX2
- 1;
2964 aY2
:= aY
+ aY2
- 1;
2967 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
2968 PANEL_WATER
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
2969 PANEL_ACID1
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
2970 PANEL_ACID2
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
2971 PANEL_STEP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
2972 PANEL_LIFTUP
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
2973 PANEL_LIFTDOWN
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
2974 PANEL_LIFTLEFT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
2975 PANEL_LIFTRIGHT
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
2976 PANEL_OPENDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 100, 220, 92, 0);
2977 PANEL_CLOSEDOOR
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 212, 184, 64, 0);
2978 PANEL_BLOCKMON
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 192, 0, 192, 0);
2982 // Рисуем красным выделенные панели:
2983 if SelectedObjects
<> nil then
2984 for b
:= 0 to High(SelectedObjects
) do
2985 with SelectedObjects
[b
] do
2986 if Live
and (ObjectType
= OBJECT_PANEL
) then
2987 with gPanels
[SelectedObjects
[b
].ID
] do
2988 if PanelType
and not(PANEL_BACK
or PANEL_FORE
) <> 0 then
2990 // Левый верхний угол:
2991 aX
:= XX
+ (X
div ScaleSz
);
2992 aY
:= 1 + (Y
div ScaleSz
);
2994 aX2
:= max(Width
div ScaleSz
, 1);
2995 aY2
:= max(Height
div ScaleSz
, 1);
2996 // Правый нижний угол:
2997 aX2
:= aX
+ aX2
- 1;
2998 aY2
:= aY
+ aY2
- 1;
3000 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0)
3004 if (gMapInfo
.Width
> RenderPanel
.Width
) or
3005 (gMapInfo
.Height
> RenderPanel
.Height
) then
3007 // Окно, показывающее текущее положение экрана на карте:
3009 x
:= max(min(RenderPanel
.Width
, gMapInfo
.Width
) div ScaleSz
, 1);
3010 y
:= max(min(RenderPanel
.Height
, gMapInfo
.Height
) div ScaleSz
, 1);
3011 // Левый верхний угол:
3012 aX
:= XX
+ ((-MapOffset
.X
) div ScaleSz
);
3013 aY
:= 1 + ((-MapOffset
.Y
) div ScaleSz
);
3014 // Правый нижний угол:
3018 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 127, 192, 127, 127, B_BLEND
);
3019 e_DrawQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0);
3024 RenderPanel
.SwapBuffers();
3027 procedure TMainForm
.FormResize(Sender
: TObject
);
3029 e_SetViewPort(0, 0, RenderPanel
.Width
, RenderPanel
.Height
);
3031 if gMapInfo
.Width
>= RenderPanel
.Width
then
3032 sbHorizontal
.Max
:= Normalize16(gMapInfo
.Width
-RenderPanel
.Width
+16)
3034 sbHorizontal
.Max
:= 0;
3036 if gMapInfo
.Height
>= RenderPanel
.Height
then
3037 sbVertical
.Max
:= Normalize16(gMapInfo
.Height
-RenderPanel
.Height
+16)
3039 sbVertical
.Max
:= 0;
3041 MapOffset
.X
:= -Normalize16(sbHorizontal
.Position
);
3042 MapOffset
.Y
:= -Normalize16(sbVertical
.Position
);
3045 procedure SelectNextObject(X
, Y
: Integer; ObjectType
: Byte; ID
: DWORD
);
3050 j_max
:= 0; // shut up compiler
3054 res
:= (gPanels
<> nil) and
3055 PanelInShownLayer(gPanels
[ID
].PanelType
) and
3056 g_CollidePoint(X
, Y
, gPanels
[ID
].X
, gPanels
[ID
].Y
,
3058 gPanels
[ID
].Height
);
3059 j_max
:= Length(gPanels
) - 1;
3064 res
:= (gItems
<> nil) and
3065 LayerEnabled
[LAYER_ITEMS
] and
3066 g_CollidePoint(X
, Y
, gItems
[ID
].X
, gItems
[ID
].Y
,
3067 ItemSize
[gItems
[ID
].ItemType
][0],
3068 ItemSize
[gItems
[ID
].ItemType
][1]);
3069 j_max
:= Length(gItems
) - 1;
3074 res
:= (gMonsters
<> nil) and
3075 LayerEnabled
[LAYER_MONSTERS
] and
3076 g_CollidePoint(X
, Y
, gMonsters
[ID
].X
, gMonsters
[ID
].Y
,
3077 MonsterSize
[gMonsters
[ID
].MonsterType
].Width
,
3078 MonsterSize
[gMonsters
[ID
].MonsterType
].Height
);
3079 j_max
:= Length(gMonsters
) - 1;
3084 res
:= (gAreas
<> nil) and
3085 LayerEnabled
[LAYER_AREAS
] and
3086 g_CollidePoint(X
, Y
, gAreas
[ID
].X
, gAreas
[ID
].Y
,
3087 AreaSize
[gAreas
[ID
].AreaType
].Width
,
3088 AreaSize
[gAreas
[ID
].AreaType
].Height
);
3089 j_max
:= Length(gAreas
) - 1;
3094 res
:= (gTriggers
<> nil) and
3095 LayerEnabled
[LAYER_TRIGGERS
] and
3096 g_CollidePoint(X
, Y
, gTriggers
[ID
].X
, gTriggers
[ID
].Y
,
3097 gTriggers
[ID
].Width
,
3098 gTriggers
[ID
].Height
);
3099 j_max
:= Length(gTriggers
) - 1;
3109 // Перебор ID: от ID-1 до 0; потом от High до ID+1:
3118 if j
= Integer(ID
) then
3123 res
:= PanelInShownLayer(gPanels
[j
].PanelType
) and
3124 g_CollidePoint(X
, Y
, gPanels
[j
].X
, gPanels
[j
].Y
,
3128 res
:= (gItems
[j
].ItemType
<> ITEM_NONE
) and
3129 g_CollidePoint(X
, Y
, gItems
[j
].X
, gItems
[j
].Y
,
3130 ItemSize
[gItems
[j
].ItemType
][0],
3131 ItemSize
[gItems
[j
].ItemType
][1]);
3133 res
:= (gMonsters
[j
].MonsterType
<> MONSTER_NONE
) and
3134 g_CollidePoint(X
, Y
, gMonsters
[j
].X
, gMonsters
[j
].Y
,
3135 MonsterSize
[gMonsters
[j
].MonsterType
].Width
,
3136 MonsterSize
[gMonsters
[j
].MonsterType
].Height
);
3138 res
:= (gAreas
[j
].AreaType
<> AREA_NONE
) and
3139 g_CollidePoint(X
, Y
, gAreas
[j
].X
, gAreas
[j
].Y
,
3140 AreaSize
[gAreas
[j
].AreaType
].Width
,
3141 AreaSize
[gAreas
[j
].AreaType
].Height
);
3143 res
:= (gTriggers
[j
].TriggerType
<> TRIGGER_NONE
) and
3144 g_CollidePoint(X
, Y
, gTriggers
[j
].X
, gTriggers
[j
].Y
,
3146 gTriggers
[j
].Height
);
3153 SetLength(SelectedObjects
, 1);
3155 SelectedObjects
[0].ObjectType
:= ObjectType
;
3156 SelectedObjects
[0].ID
:= j
;
3157 SelectedObjects
[0].Live
:= True;
3165 procedure TMainForm
.RenderPanelMouseDown(Sender
: TObject
;
3166 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3170 c1
, c2
, c3
, c4
: Boolean;
3176 MainForm
.ActiveControl
:= RenderPanel
;
3177 RenderPanel
.SetFocus();
3179 RenderPanelMouseMove(RenderPanel
, Shift
, X
, Y
);
3181 if Button
= mbLeft
then // Left Mouse Button
3183 // Двигаем карту с помощью мыши и мини-карты:
3185 g_CollidePoint(X
, Y
,
3186 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3188 max(gMapInfo
.Width
div (16 div Scale
), 1),
3189 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3192 MouseAction
:= MOUSEACTION_MOVEMAP
;
3194 else // Ставим предмет/монстра/область:
3195 if (pcObjects
.ActivePageIndex
in [1, 2, 3]) and
3196 (not (ssShift
in Shift
)) then
3198 case pcObjects
.ActivePageIndex
of
3200 if lbItemList
.ItemIndex
= -1 then
3201 ErrorMessageBox(_lc
[I_MSG_CHOOSE_ITEM
])
3204 item
.ItemType
:= lbItemList
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
3205 if item
.ItemType
>= ITEM_WEAPON_KASTET
then
3206 item
.ItemType
:= item
.ItemType
+ 2;
3207 item
.X
:= MousePos
.X
-MapOffset
.X
;
3208 item
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3210 if not (ssCtrl
in Shift
) then
3212 item
.X
:= item
.X
- (ItemSize
[item
.ItemType
][0] div 2);
3213 item
.Y
:= item
.Y
- ItemSize
[item
.ItemType
][1];
3216 item
.OnlyDM
:= cbOnlyDM
.Checked
;
3217 item
.Fall
:= cbFall
.Checked
;
3218 Undo_Add(OBJECT_ITEM
, AddItem(item
));
3221 if lbMonsterList
.ItemIndex
= -1 then
3222 ErrorMessageBox(_lc
[I_MSG_CHOOSE_MONSTER
])
3225 monster
.MonsterType
:= lbMonsterList
.ItemIndex
+ MONSTER_DEMON
;
3226 monster
.X
:= MousePos
.X
-MapOffset
.X
;
3227 monster
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3229 if not (ssCtrl
in Shift
) then
3231 monster
.X
:= monster
.X
- (MonsterSize
[monster
.MonsterType
].Width
div 2);
3232 monster
.Y
:= monster
.Y
- MonsterSize
[monster
.MonsterType
].Height
;
3235 if rbMonsterLeft
.Checked
then
3236 monster
.Direction
:= D_LEFT
3238 monster
.Direction
:= D_RIGHT
;
3239 Undo_Add(OBJECT_MONSTER
, AddMonster(monster
));
3242 if lbAreasList
.ItemIndex
= -1 then
3243 ErrorMessageBox(_lc
[I_MSG_CHOOSE_AREA
])
3245 if (lbAreasList
.ItemIndex
+ 1) <> AREA_DOMFLAG
then
3247 area
.AreaType
:= lbAreasList
.ItemIndex
+ AREA_PLAYERPOINT1
;
3248 area
.X
:= MousePos
.X
-MapOffset
.X
;
3249 area
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3251 if not (ssCtrl
in Shift
) then
3253 area
.X
:= area
.X
- (AreaSize
[area
.AreaType
].Width
div 2);
3254 area
.Y
:= area
.Y
- AreaSize
[area
.AreaType
].Height
;
3257 if rbAreaLeft
.Checked
then
3258 area
.Direction
:= D_LEFT
3260 area
.Direction
:= D_RIGHT
;
3261 Undo_Add(OBJECT_AREA
, AddArea(area
));
3267 i
:= GetFirstSelected();
3269 // Выбираем объект под текущим:
3270 if (SelectedObjects
<> nil) and
3271 (ssShift
in Shift
) and (i
>= 0) and
3272 (SelectedObjects
[i
].Live
) then
3274 if SelectedObjectCount() = 1 then
3275 SelectNextObject(X
-MapOffset
.X
, Y
-MapOffset
.Y
,
3276 SelectedObjects
[i
].ObjectType
,
3277 SelectedObjects
[i
].ID
);
3281 // Рисуем область триггера "Расширитель":
3282 if DrawPressRect
and (i
>= 0) and
3283 (SelectedObjects
[i
].ObjectType
= OBJECT_TRIGGER
) and
3284 (gTriggers
[SelectedObjects
[i
].ID
].TriggerType
in
3285 [TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
]) then
3286 MouseAction
:= MOUSEACTION_DRAWPRESS
3287 else // Рисуем панель:
3288 if pcObjects
.ActivePageIndex
= 0 then
3290 if (lbPanelType
.ItemIndex
>= 0) then
3291 MouseAction
:= MOUSEACTION_DRAWPANEL
3293 else // Рисуем триггер:
3294 if (lbTriggersList
.ItemIndex
>= 0) then
3296 MouseAction
:= MOUSEACTION_DRAWTRIGGER
;
3300 end; // if Button = mbLeft
3302 if Button
= mbRight
then // Right Mouse Button
3304 // Клик по мини-карте:
3306 g_CollidePoint(X
, Y
,
3307 RenderPanel
.Width
-max(gMapInfo
.Width
div (16 div Scale
), 1)-1,
3309 max(gMapInfo
.Width
div (16 div Scale
), 1),
3310 max(gMapInfo
.Height
div (16 div Scale
), 1) ) then
3312 MouseAction
:= MOUSEACTION_NOACTION
;
3314 else // Нужно что-то выбрать мышью:
3315 if SelectFlag
<> SELECTFLAG_NONE
then
3318 SELECTFLAG_TELEPORT
:
3319 // Точку назначения телепортации:
3320 with gTriggers
[SelectedObjects
[
3321 GetFirstSelected() ].ID
].Data
.TargetPoint
do
3323 X
:= MousePos
.X
-MapOffset
.X
;
3324 Y
:= MousePos
.Y
-MapOffset
.Y
;
3327 SELECTFLAG_SPAWNPOINT
:
3328 // Точку создания монстра:
3329 with gTriggers
[SelectedObjects
[GetFirstSelected()].ID
] do
3330 if TriggerType
= TRIGGER_SPAWNMONSTER
then
3332 Data
.MonPos
.X
:= MousePos
.X
-MapOffset
.X
;
3333 Data
.MonPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3335 else if TriggerType
= TRIGGER_SPAWNITEM
then
3336 begin // Точка создания предмета:
3337 Data
.ItemPos
.X
:= MousePos
.X
-MapOffset
.X
;
3338 Data
.ItemPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3340 else if TriggerType
= TRIGGER_SHOT
then
3341 begin // Точка создания выстрела:
3342 Data
.ShotPos
.X
:= MousePos
.X
-MapOffset
.X
;
3343 Data
.ShotPos
.Y
:= MousePos
.Y
-MapOffset
.Y
;
3349 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3351 2, 2, OBJECT_PANEL
, True);
3352 if IDArray
<> nil then
3354 for i
:= 0 to High(IDArray
) do
3355 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3356 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
) then
3358 gTriggers
[SelectedObjects
[
3359 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3364 gTriggers
[SelectedObjects
[
3365 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3369 // Панель с текстурой:
3371 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3373 2, 2, OBJECT_PANEL
, True);
3374 if IDArray
<> nil then
3376 for i
:= 0 to High(IDArray
) do
3377 if ((gPanels
[IDArray
[i
]].PanelType
in
3378 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3379 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3381 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3382 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3383 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3385 gTriggers
[SelectedObjects
[
3386 GetFirstSelected() ].ID
].TexturePanel
:= IDArray
[i
];
3391 gTriggers
[SelectedObjects
[
3392 GetFirstSelected() ].ID
].TexturePanel
:= -1;
3398 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3400 2, 2, OBJECT_PANEL
, True);
3401 if IDArray
<> nil then
3403 for i
:= 0 to High(IDArray
) do
3404 if (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTUP
) or
3405 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTDOWN
) or
3406 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTLEFT
) or
3407 (gPanels
[IDArray
[i
]].PanelType
= PANEL_LIFTRIGHT
) then
3409 gTriggers
[SelectedObjects
[
3410 GetFirstSelected() ].ID
].Data
.PanelID
:= IDArray
[i
];
3415 gTriggers
[SelectedObjects
[
3416 GetFirstSelected() ].ID
].Data
.PanelID
:= -1;
3422 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3424 2, 2, OBJECT_MONSTER
, False);
3425 if IDArray
<> nil then
3426 gTriggers
[SelectedObjects
[
3427 GetFirstSelected() ].ID
].Data
.MonsterID
:= IDArray
[0]+1
3429 gTriggers
[SelectedObjects
[
3430 GetFirstSelected() ].ID
].Data
.MonsterID
:= 0;
3433 SELECTFLAG_SHOTPANEL
:
3434 // Панель индикации выстрела:
3436 if gTriggers
[SelectedObjects
[
3437 GetFirstSelected() ].ID
].TriggerType
= TRIGGER_SHOT
then
3439 IDArray
:= ObjectInRect(X
-MapOffset
.X
,
3441 2, 2, OBJECT_PANEL
, True);
3442 if IDArray
<> nil then
3444 for i
:= 0 to High(IDArray
) do
3445 if ((gPanels
[IDArray
[i
]].PanelType
in
3446 [PANEL_WALL
, PANEL_BACK
, PANEL_FORE
,
3447 PANEL_WATER
, PANEL_ACID1
, PANEL_ACID2
,
3449 (gPanels
[IDArray
[i
]].PanelType
= PANEL_OPENDOOR
) or
3450 (gPanels
[IDArray
[i
]].PanelType
= PANEL_CLOSEDOOR
)) and
3451 (gPanels
[IDArray
[i
]].TextureName
<> '') then
3453 gTriggers
[SelectedObjects
[
3454 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= IDArray
[i
];
3459 gTriggers
[SelectedObjects
[
3460 GetFirstSelected() ].ID
].Data
.ShotPanelID
:= -1;
3465 SelectFlag
:= SELECTFLAG_SELECTED
;
3467 else // if SelectFlag <> SELECTFLAG_NONE...
3469 // Что уже выбрано и не нажат Ctrl:
3470 if (SelectedObjects
<> nil) and
3471 (not (ssCtrl
in Shift
)) then
3472 for i
:= 0 to High(SelectedObjects
) do
3473 with SelectedObjects
[i
] do
3476 if (ObjectType
in [OBJECT_PANEL
, OBJECT_TRIGGER
]) and
3477 (SelectedObjectCount() = 1) then
3479 Rect
:= ObjectGetRect(ObjectType
, ID
);
3481 c1
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3482 Rect
.X
-2, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3483 c2
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3484 Rect
.X
+Rect
.Width
-3, Rect
.Y
+(Rect
.Height
div 2)-2, 4, 4);
3485 c3
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3486 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
-2, 4, 4);
3487 c4
:= g_Collide(X
-MapOffset
.X
-1, Y
-MapOffset
.Y
-1, 2, 2,
3488 Rect
.X
+(Rect
.Width
div 2)-2, Rect
.Y
+Rect
.Height
-3, 4, 4);
3490 // Меняем размер панели или триггера:
3491 if c1
or c2
or c3
or c4
then
3493 MouseAction
:= MOUSEACTION_RESIZE
;
3494 LastMovePoint
:= MousePos
;
3498 ResizeType
:= RESIZETYPE_HORIZONTAL
;
3500 ResizeDirection
:= RESIZEDIR_LEFT
3502 ResizeDirection
:= RESIZEDIR_RIGHT
;
3503 RenderPanel
.Cursor
:= crSizeWE
;
3507 ResizeType
:= RESIZETYPE_VERTICAL
;
3509 ResizeDirection
:= RESIZEDIR_UP
3511 ResizeDirection
:= RESIZEDIR_DOWN
;
3512 RenderPanel
.Cursor
:= crSizeNS
;
3519 // Перемещаем панель или триггер:
3520 if ObjectCollide(ObjectType
, ID
,
3522 Y
-MapOffset
.Y
-1, 2, 2) then
3524 MouseAction
:= MOUSEACTION_MOVEOBJ
;
3525 LastMovePoint
:= MousePos
;
3531 end; // if Button = mbRight
3533 MouseRDown
:= Button
= mbRight
;
3535 MouseRDownPos
:= MousePos
;
3537 MouseLDown
:= Button
= mbLeft
;
3539 MouseLDownPos
:= MousePos
;
3542 procedure TMainForm
.RenderPanelMouseUp(Sender
: TObject
;
3543 Button
: TMouseButton
; Shift
: TShiftState
; X
, Y
: Integer);
3550 rSelectRect
: Boolean;
3552 if Button
= mbLeft
then
3553 MouseLDown
:= False;
3554 if Button
= mbRight
then
3555 MouseRDown
:= False;
3558 ResizeType
:= RESIZETYPE_NONE
;
3560 if Button
= mbLeft
then // Left Mouse Button
3562 if MouseAction
<> MOUSEACTION_NONE
then
3563 begin // Было действие мышью
3564 // Мышь сдвинулась во время удержания клавиши:
3565 if (MousePos
.X
<> MouseLDownPos
.X
) and
3566 (MousePos
.Y
<> MouseLDownPos
.Y
) then
3569 MOUSEACTION_DRAWPANEL
:
3571 // Фон или передний план без текстуры - ошибка:
3572 if (lbPanelType
.ItemIndex
in [1, 2]) and
3573 (lbTextureList
.ItemIndex
= -1) then
3574 ErrorMessageBox(_lc
[I_MSG_CHOOSE_TEXTURE
])
3575 else // Назначаем параметры панели:
3577 case lbPanelType
.ItemIndex
of
3578 0: Panel
.PanelType
:= PANEL_WALL
;
3579 1: Panel
.PanelType
:= PANEL_BACK
;
3580 2: Panel
.PanelType
:= PANEL_FORE
;
3581 3: Panel
.PanelType
:= PANEL_OPENDOOR
;
3582 4: Panel
.PanelType
:= PANEL_CLOSEDOOR
;
3583 5: Panel
.PanelType
:= PANEL_STEP
;
3584 6: Panel
.PanelType
:= PANEL_WATER
;
3585 7: Panel
.PanelType
:= PANEL_ACID1
;
3586 8: Panel
.PanelType
:= PANEL_ACID2
;
3587 9: Panel
.PanelType
:= PANEL_LIFTUP
;
3588 10: Panel
.PanelType
:= PANEL_LIFTDOWN
;
3589 11: Panel
.PanelType
:= PANEL_LIFTLEFT
;
3590 12: Panel
.PanelType
:= PANEL_LIFTRIGHT
;
3591 13: Panel
.PanelType
:= PANEL_BLOCKMON
;
3594 Panel
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3595 Panel
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3596 Panel
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3597 Panel
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3599 // Лифты, блокМон или отсутствие текстуры - пустая текстура:
3600 if (lbPanelType
.ItemIndex
in [9, 10, 11, 12, 13]) or
3601 (lbTextureList
.ItemIndex
= -1) then
3603 Panel
.TextureHeight
:= 1;
3604 Panel
.TextureWidth
:= 1;
3605 Panel
.TextureName
:= '';
3606 Panel
.TextureID
:= TEXTURE_SPECIAL_NONE
;
3608 else // Есть текстура:
3610 Panel
.TextureName
:= SelectedTexture();
3612 // Обычная текстура:
3613 if not IsSpecialTextureSel() then
3615 g_GetTextureSizeByName(Panel
.TextureName
,
3616 Panel
.TextureWidth
, Panel
.TextureHeight
);
3617 g_GetTexture(Panel
.TextureName
, Panel
.TextureID
);
3619 else // Спец.текстура:
3621 Panel
.TextureHeight
:= 1;
3622 Panel
.TextureWidth
:= 1;
3623 Panel
.TextureID
:= SpecialTextureID(SelectedTexture());
3628 Panel
.Blending
:= False;
3630 Undo_Add(OBJECT_PANEL
, AddPanel(Panel
));
3634 // Рисовали триггер:
3635 MOUSEACTION_DRAWTRIGGER
:
3637 trigger
.X
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3638 trigger
.Y
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3639 trigger
.Width
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3640 trigger
.Height
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3642 trigger
.Enabled
:= True;
3643 trigger
.TriggerType
:= lbTriggersList
.ItemIndex
+1;
3644 trigger
.TexturePanel
:= -1;
3647 trigger
.ActivateType
:= 0;
3649 if clbActivationType
.Checked
[0] then
3650 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERCOLLIDE
;
3651 if clbActivationType
.Checked
[1] then
3652 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERCOLLIDE
;
3653 if clbActivationType
.Checked
[2] then
3654 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_PLAYERPRESS
;
3655 if clbActivationType
.Checked
[3] then
3656 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_MONSTERPRESS
;
3657 if clbActivationType
.Checked
[4] then
3658 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_SHOT
;
3659 if clbActivationType
.Checked
[5] then
3660 trigger
.ActivateType
:= Trigger
.ActivateType
or ACTIVATE_NOMONSTER
;
3662 // Необходимые для активации ключи:
3665 if clbKeys
.Checked
[0] then
3666 trigger
.Key
:= Trigger
.Key
or KEY_RED
;
3667 if clbKeys
.Checked
[1] then
3668 trigger
.Key
:= Trigger
.Key
or KEY_GREEN
;
3669 if clbKeys
.Checked
[2] then
3670 trigger
.Key
:= Trigger
.Key
or KEY_BLUE
;
3671 if clbKeys
.Checked
[3] then
3672 trigger
.Key
:= Trigger
.Key
or KEY_REDTEAM
;
3673 if clbKeys
.Checked
[4] then
3674 trigger
.Key
:= Trigger
.Key
or KEY_BLUETEAM
;
3676 // Параметры триггера:
3677 FillByte(trigger
.Data
.Default
[0], 128, 0);
3679 case trigger
.TriggerType
of
3680 // Переключаемая панель:
3681 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
3682 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
3683 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
3685 Trigger
.Data
.PanelID
:= -1;
3691 trigger
.Data
.TargetPoint
.X
:= trigger
.X
-64;
3692 trigger
.Data
.TargetPoint
.Y
:= trigger
.Y
-64;
3693 trigger
.Data
.d2d_teleport
:= True;
3694 trigger
.Data
.TlpDir
:= 0;
3697 // Изменение других триггеров:
3698 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
3701 trigger
.Data
.Count
:= 1;
3707 trigger
.Data
.Volume
:= 255;
3708 trigger
.Data
.Pan
:= 127;
3709 trigger
.Data
.PlayCount
:= 1;
3710 trigger
.Data
.Local
:= True;
3711 trigger
.Data
.SoundSwitch
:= False;
3717 trigger
.Data
.MusicAction
:= 1;
3720 // Создание монстра:
3721 TRIGGER_SPAWNMONSTER
:
3723 trigger
.Data
.MonType
:= MONSTER_ZOMBY
;
3724 trigger
.Data
.MonPos
.X
:= trigger
.X
-64;
3725 trigger
.Data
.MonPos
.Y
:= trigger
.Y
-64;
3726 trigger
.Data
.MonHealth
:= 0;
3727 trigger
.Data
.MonActive
:= False;
3728 trigger
.Data
.MonCount
:= 1;
3731 // Создание предмета:
3734 trigger
.Data
.ItemType
:= ITEM_AMMO_BULLETS
;
3735 trigger
.Data
.ItemPos
.X
:= trigger
.X
-64;
3736 trigger
.Data
.ItemPos
.Y
:= trigger
.Y
-64;
3737 trigger
.Data
.ItemOnlyDM
:= False;
3738 trigger
.Data
.ItemFalls
:= False;
3739 trigger
.Data
.ItemCount
:= 1;
3740 trigger
.Data
.ItemMax
:= 0;
3741 trigger
.Data
.ItemDelay
:= 0;
3747 trigger
.Data
.PushAngle
:= 90;
3748 trigger
.Data
.PushForce
:= 10;
3749 trigger
.Data
.ResetVel
:= True;
3754 trigger
.Data
.ScoreCount
:= 1;
3755 trigger
.Data
.ScoreCon
:= True;
3756 trigger
.Data
.ScoreMsg
:= True;
3761 trigger
.Data
.MessageKind
:= 0;
3762 trigger
.Data
.MessageSendTo
:= 0;
3763 trigger
.Data
.MessageText
:= '';
3764 trigger
.Data
.MessageTime
:= 144;
3769 trigger
.Data
.DamageValue
:= 5;
3770 trigger
.Data
.DamageInterval
:= 12;
3775 trigger
.Data
.HealValue
:= 5;
3776 trigger
.Data
.HealInterval
:= 36;
3781 trigger
.Data
.ShotType
:= TRIGGER_SHOT_BULLET
;
3782 trigger
.Data
.ShotSound
:= True;
3783 trigger
.Data
.ShotPanelID
:= -1;
3784 trigger
.Data
.ShotTarget
:= 0;
3785 trigger
.Data
.ShotIntSight
:= 0;
3786 trigger
.Data
.ShotAim
:= TRIGGER_SHOT_AIM_DEFAULT
;
3787 trigger
.Data
.ShotPos
.X
:= trigger
.X
-64;
3788 trigger
.Data
.ShotPos
.Y
:= trigger
.Y
-64;
3789 trigger
.Data
.ShotAngle
:= 0;
3790 trigger
.Data
.ShotWait
:= 18;
3791 trigger
.Data
.ShotAccuracy
:= 0;
3792 trigger
.Data
.ShotAmmo
:= 0;
3793 trigger
.Data
.ShotIntReload
:= 0;
3798 trigger
.Data
.FXCount
:= 1;
3799 trigger
.Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
3800 trigger
.Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
3801 trigger
.Data
.FXColorR
:= 0;
3802 trigger
.Data
.FXColorG
:= 0;
3803 trigger
.Data
.FXColorB
:= 255;
3804 trigger
.Data
.FXPos
:= TRIGGER_EFFECT_POS_CENTER
;
3805 trigger
.Data
.FXWait
:= 1;
3806 trigger
.Data
.FXVelX
:= 0;
3807 trigger
.Data
.FXVelY
:= -20;
3808 trigger
.Data
.FXSpreadL
:= 5;
3809 trigger
.Data
.FXSpreadR
:= 5;
3810 trigger
.Data
.FXSpreadU
:= 4;
3811 trigger
.Data
.FXSpreadD
:= 0;
3815 Undo_Add(OBJECT_TRIGGER
, AddTrigger(trigger
));
3818 // Рисовали область триггера "Расширитель":
3819 MOUSEACTION_DRAWPRESS
:
3820 with gTriggers
[SelectedObjects
[GetFirstSelected
].ID
] do
3822 Data
.tX
:= Min(MousePos
.X
-MapOffset
.X
, MouseLDownPos
.X
-MapOffset
.X
);
3823 Data
.tY
:= Min(MousePos
.Y
-MapOffset
.Y
, MouseLDownPos
.Y
-MapOffset
.Y
);
3824 Data
.tWidth
:= Abs(MousePos
.X
-MouseLDownPos
.X
);
3825 Data
.tHeight
:= Abs(MousePos
.Y
-MouseLDownPos
.Y
);
3827 DrawPressRect
:= False;
3831 MouseAction
:= MOUSEACTION_NONE
;
3833 end // if Button = mbLeft...
3834 else // Right Mouse Button:
3836 if MouseAction
= MOUSEACTION_NOACTION
then
3838 MouseAction
:= MOUSEACTION_NONE
;
3842 // Объект передвинут или изменен в размере:
3843 if MouseAction
in [MOUSEACTION_MOVEOBJ
, MOUSEACTION_RESIZE
] then
3845 MouseAction
:= MOUSEACTION_NONE
;
3850 // Еще не все выбрали:
3851 if SelectFlag
<> SELECTFLAG_NONE
then
3853 if SelectFlag
= SELECTFLAG_SELECTED
then
3854 SelectFlag
:= SELECTFLAG_NONE
;
3859 // Мышь сдвинулась во время удержания клавиши:
3860 if (MousePos
.X
<> MouseRDownPos
.X
) and
3861 (MousePos
.Y
<> MouseRDownPos
.Y
) then
3863 rSelectRect
:= True;
3865 rRect
.X
:= Min(MousePos
.X
, MouseRDownPos
.X
)-MapOffset
.X
;
3866 rRect
.Y
:= Min(MousePos
.Y
, MouseRDownPos
.Y
)-MapOffset
.Y
;
3867 rRect
.Width
:= Abs(MousePos
.X
-MouseRDownPos
.X
);
3868 rRect
.Height
:= Abs(MousePos
.Y
-MouseRDownPos
.Y
);
3870 else // Мышь не сдвинулась - нет прямоугольника:
3872 rSelectRect
:= False;
3874 rRect
.X
:= X
-MapOffset
.X
-1;
3875 rRect
.Y
:= Y
-MapOffset
.Y
-1;
3880 // Если зажат Ctrl - выделять еще, иначе только один выделенный объект:
3881 if not (ssCtrl
in Shift
) then
3882 RemoveSelectFromObjects();
3884 // Выделяем всё в выбранном прямоугольнике:
3885 IDArray
:= ObjectInRect(rRect
.X
, rRect
.Y
,
3886 rRect
.Width
, rRect
.Height
,
3887 pcObjects
.ActivePageIndex
+1, rSelectRect
);
3889 if IDArray
<> nil then
3890 for i
:= 0 to High(IDArray
) do
3891 SelectObject(pcObjects
.ActivePageIndex
+1, IDArray
[i
],
3892 (ssCtrl
in Shift
) or rSelectRect
);
3898 procedure TMainForm
.RenderPanelPaint(Sender
: TObject
);
3903 procedure TMainForm
.RenderPanelMouseMove(Sender
: TObject
;
3904 Shift
: TShiftState
; X
, Y
: Integer);
3907 dWidth
, dHeight
: Integer;
3910 _id
:= GetFirstSelected();
3912 // Рисуем панель с текстурой, сетка - размеры текстуры:
3913 if (MouseAction
= MOUSEACTION_DRAWPANEL
) and
3914 (lbPanelType
.ItemIndex
in [0..8]) and
3915 (lbTextureList
.ItemIndex
<> -1) and
3916 (not IsSpecialTextureSel()) then
3918 sX
:= StrToIntDef(lTextureWidth
.Caption
, DotStep
);
3919 sY
:= StrToIntDef(lTextureHeight
.Caption
, DotStep
);
3922 // Меняем размер панели с текстурой, сетка - размеры текстуры:
3923 if (MouseAction
= MOUSEACTION_RESIZE
) and
3924 ( (SelectedObjects
[_id
].ObjectType
= OBJECT_PANEL
) and
3925 IsTexturedPanel(gPanels
[SelectedObjects
[_id
].ID
].PanelType
) and
3926 (gPanels
[SelectedObjects
[_id
].ID
].TextureName
<> '') and
3927 (not IsSpecialTexture(gPanels
[SelectedObjects
[_id
].ID
].TextureName
)) ) then
3929 sX
:= gPanels
[SelectedObjects
[_id
].ID
].TextureWidth
;
3930 sY
:= gPanels
[SelectedObjects
[_id
].ID
].TextureHeight
;
3933 // Выравнивание по сетке:
3939 else // Нет выравнивания по сетке:
3945 // Новая позиция мыши:
3947 begin // Зажата левая кнопка мыши
3948 MousePos
.X
:= (Round((X
-MouseLDownPos
.X
)/sX
)*sX
)+MouseLDownPos
.X
;
3949 MousePos
.Y
:= (Round((Y
-MouseLDownPos
.Y
)/sY
)*sY
)+MouseLDownPos
.Y
;
3953 begin // Зажата правая кнопка мыши
3954 MousePos
.X
:= (Round((X
-MouseRDownPos
.X
)/sX
)*sX
)+MouseRDownPos
.X
;
3955 MousePos
.Y
:= (Round((Y
-MouseRDownPos
.Y
)/sY
)*sY
)+MouseRDownPos
.Y
;
3958 begin // Кнопки мыши не зажаты
3959 MousePos
.X
:= (Round(X
/sX
)*sX
);
3960 MousePos
.Y
:= (Round(Y
/sY
)*sY
);
3963 // Изменение размера закончилось - ставим обычный курсор:
3964 if ResizeType
= RESIZETYPE_NONE
then
3965 RenderPanel
.Cursor
:= crDefault
;
3967 // Зажата только правая кнопка мыши:
3968 if (not MouseLDown
) and (MouseRDown
) then
3970 // Рисуем прямоугольник выделения:
3971 if MouseAction
= MOUSEACTION_NONE
then
3973 if DrawRect
= nil then
3975 DrawRect
.Top
:= MouseRDownPos
.y
;
3976 DrawRect
.Left
:= MouseRDownPos
.x
;
3977 DrawRect
.Bottom
:= MousePos
.y
;
3978 DrawRect
.Right
:= MousePos
.x
;
3981 // Двигаем выделенные объекты:
3982 if MouseAction
= MOUSEACTION_MOVEOBJ
then
3984 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
,
3985 MousePos
.X
-LastMovePoint
.X
,
3986 MousePos
.Y
-LastMovePoint
.Y
);
3989 // Меняем размер выделенного объекта:
3990 if MouseAction
= MOUSEACTION_RESIZE
then
3992 if (SelectedObjectCount
= 1) and
3993 (SelectedObjects
[GetFirstSelected
].Live
) then
3995 dWidth
:= MousePos
.X
-LastMovePoint
.X
;
3996 dHeight
:= MousePos
.Y
-LastMovePoint
.Y
;
3999 RESIZETYPE_VERTICAL
: dWidth
:= 0;
4000 RESIZETYPE_HORIZONTAL
: dHeight
:= 0;
4003 case ResizeDirection
of
4004 RESIZEDIR_UP
: dHeight
:= -dHeight
;
4005 RESIZEDIR_LEFT
: dWidth
:= -dWidth
;
4008 ResizeObject(SelectedObjects
[GetFirstSelected
].ObjectType
,
4009 SelectedObjects
[GetFirstSelected
].ID
,
4010 dWidth
, dHeight
, ResizeDirection
);
4012 LastMovePoint
:= MousePos
;
4017 // Зажата только левая кнопка мыши:
4018 if (not MouseRDown
) and (MouseLDown
) then
4020 // Рисуем прямоугольник планирования панели:
4021 if MouseAction
in [MOUSEACTION_DRAWPANEL
,
4022 MOUSEACTION_DRAWTRIGGER
,
4023 MOUSEACTION_DRAWPRESS
] then
4025 if DrawRect
= nil then
4027 DrawRect
.Top
:= MouseLDownPos
.y
;
4028 DrawRect
.Left
:= MouseLDownPos
.x
;
4029 DrawRect
.Bottom
:= MousePos
.y
;
4030 DrawRect
.Right
:= MousePos
.x
;
4032 else // Двигаем карту:
4033 if MouseAction
= MOUSEACTION_MOVEMAP
then
4039 // Клавиши мыши не зажаты:
4040 if (not MouseRDown
) and (not MouseLDown
) then
4043 // Строка состояния - координаты мыши:
4044 StatusBar
.Panels
[1].Text := Format('(%d:%d)',
4045 [MousePos
.X
-MapOffset
.X
, MousePos
.Y
-MapOffset
.Y
]);
4048 procedure TMainForm
.FormCloseQuery(Sender
: TObject
; var CanClose
: Boolean);
4050 CanClose
:= MessageBox(0, PChar(_lc
[I_MSG_EXIT_PROMT
]),
4051 PChar(_lc
[I_MSG_EXIT
]),
4052 MB_ICONQUESTION
or MB_YESNO
or
4053 MB_DEFBUTTON1
) = idYes
;
4056 procedure TMainForm
.aExitExecute(Sender
: TObject
);
4061 procedure TMainForm
.FormDestroy(Sender
: TObject
);
4066 config
:= TConfig
.CreateFile(EditorDir
+'Editor.cfg');
4068 if WindowState
<> wsMaximized
then
4070 config
.WriteInt('Editor', 'XPos', Left
);
4071 config
.WriteInt('Editor', 'YPos', Top
);
4072 config
.WriteInt('Editor', 'Width', Width
);
4073 config
.WriteInt('Editor', 'Height', Height
);
4077 config
.WriteInt('Editor', 'XPos', RestoredLeft
);
4078 config
.WriteInt('Editor', 'YPos', RestoredTop
);
4079 config
.WriteInt('Editor', 'Width', RestoredWidth
);
4080 config
.WriteInt('Editor', 'Height', RestoredHeight
);
4082 config
.WriteBool('Editor', 'Maximize', WindowState
= wsMaximized
);
4083 config
.WriteBool('Editor', 'Minimap', ShowMap
);
4084 config
.WriteInt('Editor', 'PanelProps', PanelProps
.ClientWidth
);
4085 config
.WriteInt('Editor', 'PanelObjs', PanelObjs
.ClientHeight
);
4086 config
.WriteBool('Editor', 'DotEnable', DotEnable
);
4087 config
.WriteInt('Editor', 'DotStep', DotStep
);
4088 config
.WriteStr('Editor', 'LastOpenDir', OpenDialog
.InitialDir
);
4089 config
.WriteStr('Editor', 'LastSaveDir', SaveDialog
.InitialDir
);
4090 config
.WriteBool('Editor', 'EdgeShow', drEdge
[3] < 255);
4091 config
.WriteInt('Editor', 'EdgeColor', gColorEdge
);
4092 config
.WriteInt('Editor', 'EdgeAlpha', gAlphaEdge
);
4093 config
.WriteInt('Editor', 'LineAlpha', gAlphaTriggerLine
);
4094 config
.WriteInt('Editor', 'TriggerAlpha', gAlphaTriggerArea
);
4096 for i
:= 0 to RecentCount
-1 do
4097 if i
< RecentFiles
.Count
then
4098 config
.WriteStr('RecentFiles', IntToStr(i
+1), RecentFiles
[i
])
4100 config
.WriteStr('RecentFiles', IntToStr(i
+1), '');
4103 config
.SaveFile(EditorDir
+'Editor.cfg');
4106 slInvalidTextures
.Free
;
4109 procedure TMainForm
.RenderPanelResize(Sender
: TObject
);
4111 if MainForm
.Visible
then
4115 procedure TMainForm
.Splitter1Moved(Sender
: TObject
);
4120 procedure TMainForm
.aMapOptionsExecute(Sender
: TObject
);
4124 MapOptionsForm
.ShowModal();
4126 ResName
:= OpenedMap
;
4127 while (Pos(':\', ResName
) > 0) do
4128 Delete(ResName
, 1, Pos(':\', ResName
) + 1);
4130 UpdateCaption(gMapInfo
.Name
, ExtractFileName(OpenedWAD
), ResName
);
4133 procedure TMainForm
.aAboutExecute(Sender
: TObject
);
4135 AboutForm
.ShowModal();
4138 procedure TMainForm
.FormKeyDown(Sender
: TObject
; var Key
: Word;
4139 Shift
: TShiftState
);
4144 if (not EditingProperties
) then
4146 if Key
= Ord('1') then
4147 SwitchLayer(LAYER_BACK
);
4148 if Key
= Ord('2') then
4149 SwitchLayer(LAYER_WALLS
);
4150 if Key
= Ord('3') then
4151 SwitchLayer(LAYER_FOREGROUND
);
4152 if Key
= Ord('4') then
4153 SwitchLayer(LAYER_STEPS
);
4154 if Key
= Ord('5') then
4155 SwitchLayer(LAYER_WATER
);
4156 if Key
= Ord('6') then
4157 SwitchLayer(LAYER_ITEMS
);
4158 if Key
= Ord('7') then
4159 SwitchLayer(LAYER_MONSTERS
);
4160 if Key
= Ord('8') then
4161 SwitchLayer(LAYER_AREAS
);
4162 if Key
= Ord('9') then
4163 SwitchLayer(LAYER_TRIGGERS
);
4164 if Key
= Ord('0') then
4165 tbShowClick(tbShow
);
4167 if Key
= Ord('V') then
4168 begin // Поворот монстров и областей:
4169 if (SelectedObjects
<> nil) then
4171 for i
:= 0 to High(SelectedObjects
) do
4172 if (SelectedObjects
[i
].Live
) then
4174 if (SelectedObjects
[i
].ObjectType
= OBJECT_MONSTER
) then
4176 g_ChangeDir(gMonsters
[SelectedObjects
[i
].ID
].Direction
);
4179 if (SelectedObjects
[i
].ObjectType
= OBJECT_AREA
) then
4181 g_ChangeDir(gAreas
[SelectedObjects
[i
].ID
].Direction
);
4187 if pcObjects
.ActivePage
= tsMonsters
then
4189 if rbMonsterLeft
.Checked
then
4190 rbMonsterRight
.Checked
:= True
4192 rbMonsterLeft
.Checked
:= True;
4194 if pcObjects
.ActivePage
= tsAreas
then
4196 if rbAreaLeft
.Checked
then
4197 rbAreaRight
.Checked
:= True
4199 rbAreaLeft
.Checked
:= True;
4204 if not (ssCtrl
in Shift
) then
4206 // Быстрое превью карты:
4207 if Key
= Ord('E') then
4209 if PreviewMode
= 0 then
4213 // Вертикальный скролл карты:
4216 if Key
= Ord('W') then
4218 Position
:= IfThen(Position
> DotStep
, Position
-DotStep
, 0);
4219 MapOffset
.Y
:= -Round(Position
/16) * 16;
4222 if Key
= Ord('S') then
4224 Position
:= IfThen(Position
+DotStep
< Max
, Position
+DotStep
, Max
);
4225 MapOffset
.Y
:= -Round(Position
/16) * 16;
4229 // Горизонтальный скролл карты:
4230 with sbHorizontal
do
4232 if Key
= Ord('A') then
4234 Position
:= IfThen(Position
> DotStep
, Position
-DotStep
, 0);
4235 MapOffset
.X
:= -Round(Position
/16) * 16;
4238 if Key
= Ord('D') then
4240 Position
:= IfThen(Position
+DotStep
< Max
, Position
+DotStep
, Max
);
4241 MapOffset
.X
:= -Round(Position
/16) * 16;
4247 // Удалить выделенные объекты:
4248 if (Key
= VK_DELETE
) and (SelectedObjects
<> nil) and
4249 RenderPanel
.Focused() then
4250 DeleteSelectedObjects();
4253 if (Key
= VK_ESCAPE
) and (SelectedObjects
<> nil) then
4254 RemoveSelectFromObjects();
4256 // Передвинуть объекты:
4257 if MainForm
.ActiveControl
= RenderPanel
then
4262 if Key
= VK_NUMPAD4
then
4263 dx
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4264 if Key
= VK_NUMPAD6
then
4265 dx
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4266 if Key
= VK_NUMPAD8
then
4267 dy
:= IfThen(ssAlt
in Shift
, -1, -DotStep
);
4268 if Key
= VK_NUMPAD5
then
4269 dy
:= IfThen(ssAlt
in Shift
, 1, DotStep
);
4271 if (dx
<> 0) or (dy
<> 0) then
4273 MoveSelectedObjects(ssShift
in Shift
, ssCtrl
in Shift
, dx
, dy
);
4278 if ssCtrl
in Shift
then
4280 // Выбор панели с текстурой для триггера
4281 if Key
= Ord('T') then
4283 DrawPressRect
:= False;
4284 if SelectFlag
= SELECTFLAG_TEXTURE
then
4286 SelectFlag
:= SELECTFLAG_NONE
;
4289 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_TEXTURE_PANEL
], i
);
4291 SelectFlag
:= SELECTFLAG_TEXTURE
;
4294 if Key
= Ord('D') then
4296 SelectFlag
:= SELECTFLAG_NONE
;
4297 if DrawPressRect
then
4299 DrawPressRect
:= False;
4304 // Выбор области воздействия, в зависимости от типа триггера
4305 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_EX_AREA
], i
);
4308 DrawPressRect
:= True;
4311 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_DOOR_PANEL
], i
);
4313 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_TRAP_PANEL
], i
);
4316 SelectFlag
:= SELECTFLAG_DOOR
;
4319 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_LIFT_PANEL
], i
);
4322 SelectFlag
:= SELECTFLAG_LIFT
;
4325 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_TELEPORT_TO
], i
);
4328 SelectFlag
:= SELECTFLAG_TELEPORT
;
4331 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_SPAWN_TO
], i
);
4334 SelectFlag
:= SELECTFLAG_SPAWNPOINT
;
4338 // Выбор основного параметра, в зависимости от типа триггера
4339 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_NEXT_MAP
], i
);
4342 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
4343 SelectMapForm
.Caption
:= _lc
[I_CAP_SELECT
];
4344 SelectMapForm
.GetMaps(FileName
);
4346 if SelectMapForm
.ShowModal() = mrOK
then
4348 vleObjectProperty
.Cells
[1, i
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
4349 bApplyProperty
.Click();
4353 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_SOUND_NAME
], i
);
4355 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_MUSIC_NAME
], i
);
4358 AddSoundForm
.OKFunction
:= nil;
4359 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
4360 AddSoundForm
.SetResource
:= vleObjectProperty
.Cells
[1, i
];
4362 if (AddSoundForm
.ShowModal() = mrOk
) then
4364 vleObjectProperty
.Cells
[1, i
] := AddSoundForm
.ResourceName
;
4365 bApplyProperty
.Click();
4369 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_PUSH_ANGLE
], i
);
4371 vleObjectProperty
.FindRow(_lc
[I_PROP_TR_MESSAGE_TEXT
], i
);
4374 vleObjectProperty
.Row
:= i
;
4375 vleObjectProperty
.SetFocus();
4382 procedure TMainForm
.aOptimizeExecute(Sender
: TObject
);
4384 RemoveSelectFromObjects();
4385 MapOptimizationForm
.ShowModal();
4388 procedure TMainForm
.aCheckMapExecute(Sender
: TObject
);
4390 MapCheckForm
.ShowModal();
4393 procedure TMainForm
.bbAddTextureClick(Sender
: TObject
);
4395 AddTextureForm
.lbResourcesList
.MultiSelect
:= True;
4396 AddTextureForm
.ShowModal();
4399 procedure TMainForm
.lbTextureListClick(Sender
: TObject
);
4402 TextureWidth
, TextureHeight
: Word;
4407 if (lbTextureList
.ItemIndex
<> -1) and
4408 (not IsSpecialTextureSel()) then
4410 if g_GetTexture(SelectedTexture(), TextureID
) then
4412 g_GetTextureSizeByID(TextureID
, TextureWidth
, TextureHeight
);
4414 lTextureWidth
.Caption
:= IntToStr(TextureWidth
);
4415 lTextureHeight
.Caption
:= IntToStr(TextureHeight
);
4418 lTextureWidth
.Caption
:= _lc
[I_NOT_ACCESSIBLE
];
4419 lTextureHeight
.Caption
:= _lc
[I_NOT_ACCESSIBLE
];
4424 lTextureWidth
.Caption
:= '';
4425 lTextureHeight
.Caption
:= '';
4429 procedure TMainForm
.lbTextureListDrawItem(Control
: TWinControl
; Index
: Integer;
4430 ARect
: TRect
; State
: TOwnerDrawState
);
4432 with Control
as TListBox
do
4434 if LCLType
.odSelected
in State
then
4436 Canvas
.Brush
.Color
:= clHighlight
;
4437 Canvas
.Font
.Color
:= clHighlightText
;
4439 if (Items
<> nil) and (Index
>= 0) then
4440 if slInvalidTextures
.IndexOf(Items
[Index
]) > -1 then
4442 Canvas
.Brush
.Color
:= clRed
;
4443 Canvas
.Font
.Color
:= clWhite
;
4445 Canvas
.FillRect(ARect
);
4446 Canvas
.TextRect(ARect
, ARect
.Left
, ARect
.Top
, Items
[Index
]);
4450 procedure TMainForm
.vleObjectPropertyGetPickList(Sender
: TObject
;
4451 const KeyName
: String; Values
: TStrings
);
4453 if vleObjectProperty
.ItemProps
[KeyName
].EditStyle
= esPickList
then
4455 if KeyName
= _lc
[I_PROP_DIRECTION
] then
4457 Values
.Add(DirNames
[D_LEFT
]);
4458 Values
.Add(DirNames
[D_RIGHT
]);
4460 else if KeyName
= _lc
[I_PROP_TR_TELEPORT_DIR
] then
4462 Values
.Add(DirNamesAdv
[0]);
4463 Values
.Add(DirNamesAdv
[1]);
4464 Values
.Add(DirNamesAdv
[2]);
4465 Values
.Add(DirNamesAdv
[3]);
4467 else if KeyName
= _lc
[I_PROP_TR_MUSIC_ACT
] then
4469 Values
.Add(_lc
[I_PROP_TR_MUSIC_ON
]);
4470 Values
.Add(_lc
[I_PROP_TR_MUSIC_OFF
]);
4472 else if KeyName
= _lc
[I_PROP_TR_MONSTER_BEHAVIOUR
] then
4474 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_0
]);
4475 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_1
]);
4476 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_2
]);
4477 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_3
]);
4478 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_4
]);
4479 Values
.Add(_lc
[I_PROP_TR_MONSTER_BEHAVIOUR_5
]);
4481 else if KeyName
= _lc
[I_PROP_TR_SCORE_ACT
] then
4483 Values
.Add(_lc
[I_PROP_TR_SCORE_ACT_0
]);
4484 Values
.Add(_lc
[I_PROP_TR_SCORE_ACT_1
]);
4485 Values
.Add(_lc
[I_PROP_TR_SCORE_ACT_2
]);
4486 Values
.Add(_lc
[I_PROP_TR_SCORE_ACT_3
]);
4488 else if KeyName
= _lc
[I_PROP_TR_SCORE_TEAM
] then
4490 Values
.Add(_lc
[I_PROP_TR_SCORE_TEAM_0
]);
4491 Values
.Add(_lc
[I_PROP_TR_SCORE_TEAM_1
]);
4492 Values
.Add(_lc
[I_PROP_TR_SCORE_TEAM_2
]);
4493 Values
.Add(_lc
[I_PROP_TR_SCORE_TEAM_3
]);
4495 else if KeyName
= _lc
[I_PROP_TR_MESSAGE_KIND
] then
4497 Values
.Add(_lc
[I_PROP_TR_MESSAGE_KIND_0
]);
4498 Values
.Add(_lc
[I_PROP_TR_MESSAGE_KIND_1
]);
4500 else if KeyName
= _lc
[I_PROP_TR_MESSAGE_TO
] then
4502 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_0
]);
4503 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_1
]);
4504 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_2
]);
4505 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_3
]);
4506 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_4
]);
4507 Values
.Add(_lc
[I_PROP_TR_MESSAGE_TO_5
]);
4509 else if KeyName
= _lc
[I_PROP_TR_SHOT_TO
] then
4511 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_0
]);
4512 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_1
]);
4513 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_2
]);
4514 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_3
]);
4515 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_4
]);
4516 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_5
]);
4517 Values
.Add(_lc
[I_PROP_TR_SHOT_TO_6
]);
4519 else if KeyName
= _lc
[I_PROP_TR_SHOT_AIM
] then
4521 Values
.Add(_lc
[I_PROP_TR_SHOT_AIM_0
]);
4522 Values
.Add(_lc
[I_PROP_TR_SHOT_AIM_1
]);
4523 Values
.Add(_lc
[I_PROP_TR_SHOT_AIM_2
]);
4524 Values
.Add(_lc
[I_PROP_TR_SHOT_AIM_3
]);
4526 else if (KeyName
= _lc
[I_PROP_PANEL_BLEND
]) or
4527 (KeyName
= _lc
[I_PROP_DM_ONLY
]) or
4528 (KeyName
= _lc
[I_PROP_ITEM_FALLS
]) or
4529 (KeyName
= _lc
[I_PROP_TR_ENABLED
]) or
4530 (KeyName
= _lc
[I_PROP_TR_D2D
]) or
4531 (KeyName
= _lc
[I_PROP_TR_SILENT
]) or
4532 (KeyName
= _lc
[I_PROP_TR_TELEPORT_SILENT
]) or
4533 (KeyName
= _lc
[I_PROP_TR_EX_RANDOM
]) or
4534 (KeyName
= _lc
[I_PROP_TR_TEXTURE_ONCE
]) or
4535 (KeyName
= _lc
[I_PROP_TR_TEXTURE_ANIM_ONCE
]) or
4536 (KeyName
= _lc
[I_PROP_TR_SOUND_LOCAL
]) or
4537 (KeyName
= _lc
[I_PROP_TR_SOUND_SWITCH
]) or
4538 (KeyName
= _lc
[I_PROP_TR_MONSTER_ACTIVE
]) or
4539 (KeyName
= _lc
[I_PROP_TR_PUSH_RESET
]) or
4540 (KeyName
= _lc
[I_PROP_TR_SCORE_CON
]) or
4541 (KeyName
= _lc
[I_PROP_TR_SCORE_MSG
]) or
4542 (KeyName
= _lc
[I_PROP_TR_HEALTH_MAX
]) or
4543 (KeyName
= _lc
[I_PROP_TR_SHOT_SOUND
]) or
4544 (KeyName
= _lc
[I_PROP_TR_EFFECT_CENTER
]) then
4546 Values
.Add(BoolNames
[True]);
4547 Values
.Add(BoolNames
[False]);
4552 procedure TMainForm
.bApplyPropertyClick(Sender
: TObject
);
4554 _id
, a
, r
, c
: Integer;
4564 if SelectedObjectCount() <> 1 then
4566 if not SelectedObjects
[GetFirstSelected()].Live
then
4570 if not CheckProperty() then
4576 _id
:= GetFirstSelected();
4578 r
:= vleObjectProperty
.Row
;
4579 c
:= vleObjectProperty
.Col
;
4581 case SelectedObjects
[_id
].ObjectType
of
4584 with gPanels
[SelectedObjects
[_id
].ID
] do
4586 X
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_X
]]));
4587 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]));
4588 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_WIDTH
]]));
4589 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_HEIGHT
]]));
4591 PanelType
:= GetPanelType(vleObjectProperty
.Values
[_lc
[I_PROP_PANEL_TYPE
]]);
4593 // Сброс ссылки на триггеры смены текстуры:
4594 if not WordBool(PanelType
and (PANEL_WALL
or PANEL_FORE
or PANEL_BACK
)) then
4595 if gTriggers
<> nil then
4596 for a
:= 0 to High(gTriggers
) do
4598 if (gTriggers
[a
].TriggerType
<> 0) and
4599 (gTriggers
[a
].TexturePanel
= Integer(SelectedObjects
[_id
].ID
)) then
4600 gTriggers
[a
].TexturePanel
:= -1;
4601 if (gTriggers
[a
].TriggerType
= TRIGGER_SHOT
) and
4602 (gTriggers
[a
].Data
.ShotPanelID
= Integer(SelectedObjects
[_id
].ID
)) then
4603 gTriggers
[a
].Data
.ShotPanelID
:= -1;
4606 // Сброс ссылки на триггеры лифта:
4607 if not WordBool(PanelType
and (PANEL_LIFTUP
or PANEL_LIFTDOWN
or PANEL_LIFTLEFT
or PANEL_LIFTRIGHT
)) then
4608 if gTriggers
<> nil then
4609 for a
:= 0 to High(gTriggers
) do
4610 if (gTriggers
[a
].TriggerType
in [TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
]) and
4611 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
4612 gTriggers
[a
].Data
.PanelID
:= -1;
4614 // Сброс ссылки на триггеры двери:
4615 if not WordBool(PanelType
and (PANEL_OPENDOOR
or PANEL_CLOSEDOOR
)) then
4616 if gTriggers
<> nil then
4617 for a
:= 0 to High(gTriggers
) do
4618 if (gTriggers
[a
].TriggerType
in [TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
4619 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
]) and
4620 (gTriggers
[a
].Data
.PanelID
= Integer(SelectedObjects
[_id
].ID
)) then
4621 gTriggers
[a
].Data
.PanelID
:= -1;
4623 if IsTexturedPanel(PanelType
) then
4624 begin // Может быть текстура
4625 if TextureName
<> '' then
4626 begin // Была текстура
4627 Alpha
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_PANEL_ALPHA
]]));
4628 Blending
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_PANEL_BLEND
]]);
4637 TextureName
:= vleObjectProperty
.Values
[_lc
[I_PROP_PANEL_TEX
]];
4639 if TextureName
<> '' then
4640 begin // Есть текстура
4641 // Обычная текстура:
4642 if not IsSpecialTexture(TextureName
) then
4644 g_GetTextureSizeByName(TextureName
,
4645 TextureWidth
, TextureHeight
);
4647 // Проверка кратности размеров панели:
4649 if TextureWidth
<> 0 then
4650 if gPanels
[SelectedObjects
[_id
].ID
].Width
mod TextureWidth
<> 0 then
4652 ErrorMessageBox(Format(_lc
[I_MSG_WRONG_TEXWIDTH
],
4656 if Res
and (TextureHeight
<> 0) then
4657 if gPanels
[SelectedObjects
[_id
].ID
].Height
mod TextureHeight
<> 0 then
4659 ErrorMessageBox(Format(_lc
[I_MSG_WRONG_TEXHEIGHT
],
4666 if not g_GetTexture(TextureName
, TextureID
) then
4667 // Не удалось загрузить текстуру, рисуем NOTEXTURE
4668 if g_GetTexture('NOTEXTURE', NoTextureID
) then
4670 TextureID
:= TEXTURE_SPECIAL_NOTEXTURE
;
4671 g_GetTextureSizeByID(NoTextureID
, NW
, NH
);
4673 TextureHeight
:= NH
;
4676 TextureID
:= TEXTURE_SPECIAL_NONE
;
4686 TextureID
:= TEXTURE_SPECIAL_NONE
;
4689 else // Спец.текстура
4693 TextureID
:= SpecialTextureID(TextureName
);
4696 else // Нет текстуры
4700 TextureID
:= TEXTURE_SPECIAL_NONE
;
4703 else // Не может быть текстуры
4710 TextureID
:= TEXTURE_SPECIAL_NONE
;
4717 with gItems
[SelectedObjects
[_id
].ID
] do
4719 X
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_X
]]));
4720 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]));
4721 OnlyDM
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_DM_ONLY
]]);
4722 Fall
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_ITEM_FALLS
]]);
4728 with gMonsters
[SelectedObjects
[_id
].ID
] do
4730 X
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_X
]]));
4731 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]));
4732 Direction
:= NameToDir(vleObjectProperty
.Values
[_lc
[I_PROP_DIRECTION
]]);
4738 with gAreas
[SelectedObjects
[_id
].ID
] do
4740 X
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_X
]]));
4741 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]));
4742 Direction
:= NameToDir(vleObjectProperty
.Values
[_lc
[I_PROP_DIRECTION
]]);
4748 with gTriggers
[SelectedObjects
[_id
].ID
] do
4750 X
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_X
]]));
4751 Y
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_Y
]]));
4752 Width
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_WIDTH
]]));
4753 Height
:= StrToInt(Trim(vleObjectProperty
.Values
[_lc
[I_PROP_HEIGHT
]]));
4754 Enabled
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_ENABLED
]]);
4755 ActivateType
:= StrToActivate(vleObjectProperty
.Values
[_lc
[I_PROP_TR_ACTIVATION
]]);
4756 Key
:= StrToKey(vleObjectProperty
.Values
[_lc
[I_PROP_TR_KEYS
]]);
4761 s
:= utf2win(vleObjectProperty
.Values
[_lc
[I_PROP_TR_NEXT_MAP
]]);
4762 FillByte(Data
.MapName
[0], 16, 0);
4764 Move(s
[1], Data
.MapName
[0], Min(Length(s
), 16));
4769 Data
.ActivateOnce
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_TEXTURE_ONCE
]]);
4770 Data
.AnimOnce
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_TEXTURE_ANIM_ONCE
]]);
4773 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
, TRIGGER_ONOFF
:
4775 Data
.Wait
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EX_DELAY
]], 0), 65535);
4776 Data
.Count
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EX_COUNT
]], 0), 65535);
4777 if Data
.Count
< 1 then
4779 if TriggerType
= TRIGGER_PRESS
then
4780 Data
.ExtRandom
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EX_RANDOM
]]);
4783 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
, TRIGGER_DOOR5
,
4784 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
, TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
,
4787 Data
.NoSound
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SILENT
]]);
4788 Data
.d2d_doors
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_D2D
]]);
4793 Data
.d2d_teleport
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_D2D
]]);
4794 Data
.silent_teleport
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_TELEPORT_SILENT
]]);
4795 Data
.TlpDir
:= NameToDirAdv(vleObjectProperty
.Values
[_lc
[I_PROP_TR_TELEPORT_DIR
]]);
4800 s
:= utf2win(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_NAME
]]);
4801 FillByte(Data
.SoundName
[0], 64, 0);
4803 Move(s
[1], Data
.SoundName
[0], Min(Length(s
), 64));
4805 Data
.Volume
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_VOLUME
]], 0), 255);
4806 Data
.Pan
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_PAN
]], 0), 255);
4807 Data
.PlayCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_COUNT
]], 0), 255);
4808 Data
.Local
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_LOCAL
]]);
4809 Data
.SoundSwitch
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SOUND_SWITCH
]]);
4812 TRIGGER_SPAWNMONSTER
:
4814 Data
.MonType
:= StrToMonster(vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_TYPE
]]);
4815 Data
.MonDir
:= Byte(NameToDir(vleObjectProperty
.Values
[_lc
[I_PROP_DIRECTION
]]));
4816 Data
.MonHealth
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_HEALTH
]], 0), 1000000);
4817 if Data
.MonHealth
< 0 then
4818 Data
.MonHealth
:= 0;
4819 Data
.MonActive
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_ACTIVE
]]);
4820 Data
.MonCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_COUNT
]], 0), 64);
4821 if Data
.MonCount
< 1 then
4823 Data
.MonEffect
:= StrToEffect(vleObjectProperty
.Values
[_lc
[I_PROP_TR_FX_TYPE
]]);
4824 Data
.MonMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SPAWN_MAX
]], 0), 65535);
4825 Data
.MonDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SPAWN_DELAY
]], 0), 65535);
4827 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
]] = _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_1
] then
4829 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
]] = _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_2
] then
4831 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
]] = _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_3
] then
4833 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
]] = _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_4
] then
4835 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MONSTER_BEHAVIOUR
]] = _lc
[I_PROP_TR_MONSTER_BEHAVIOUR_5
] then
4841 Data
.ItemType
:= StrToItem(vleObjectProperty
.Values
[_lc
[I_PROP_TR_ITEM_TYPE
]]);
4842 Data
.ItemOnlyDM
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_DM_ONLY
]]);
4843 Data
.ItemFalls
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_ITEM_FALLS
]]);
4844 Data
.ItemCount
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_COUNT
]], 0), 64);
4845 if Data
.ItemCount
< 1 then
4846 Data
.ItemCount
:= 1;
4847 Data
.ItemEffect
:= StrToEffect(vleObjectProperty
.Values
[_lc
[I_PROP_TR_FX_TYPE
]]);
4848 Data
.ItemMax
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SPAWN_MAX
]], 0), 65535);
4849 Data
.ItemDelay
:= Min(StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SPAWN_DELAY
]], 0), 65535);
4854 s
:= utf2win(vleObjectProperty
.Values
[_lc
[I_PROP_TR_MUSIC_NAME
]]);
4855 FillByte(Data
.MusicName
[0], 64, 0);
4857 Move(s
[1], Data
.MusicName
[0], Min(Length(s
), 64));
4859 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MUSIC_ACT
]] = _lc
[I_PROP_TR_MUSIC_ON
] then
4860 Data
.MusicAction
:= 1
4862 Data
.MusicAction
:= 2;
4867 Data
.PushAngle
:= Min(
4868 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_PUSH_ANGLE
]], 0), 360);
4869 Data
.PushForce
:= Min(
4870 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_PUSH_FORCE
]], 0), 255);
4871 Data
.ResetVel
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_PUSH_RESET
]]);
4876 Data
.ScoreAction
:= 0;
4877 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_ACT
]] = _lc
[I_PROP_TR_SCORE_ACT_1
] then
4878 Data
.ScoreAction
:= 1
4879 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_ACT
]] = _lc
[I_PROP_TR_SCORE_ACT_2
] then
4880 Data
.ScoreAction
:= 2
4881 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_ACT
]] = _lc
[I_PROP_TR_SCORE_ACT_3
] then
4882 Data
.ScoreAction
:= 3;
4883 Data
.ScoreCount
:= Min(Max(
4884 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_COUNT
]], 0), 0), 255);
4885 Data
.ScoreTeam
:= 0;
4886 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_TEAM
]] = _lc
[I_PROP_TR_SCORE_TEAM_1
] then
4888 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_TEAM
]] = _lc
[I_PROP_TR_SCORE_TEAM_2
] then
4890 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_TEAM
]] = _lc
[I_PROP_TR_SCORE_TEAM_3
] then
4891 Data
.ScoreTeam
:= 3;
4892 Data
.ScoreCon
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_CON
]]);
4893 Data
.ScoreMsg
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SCORE_MSG
]]);
4898 Data
.MessageKind
:= 0;
4899 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_KIND
]] = _lc
[I_PROP_TR_MESSAGE_KIND_1
] then
4900 Data
.MessageKind
:= 1;
4902 Data
.MessageSendTo
:= 0;
4903 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TO
]] = _lc
[I_PROP_TR_MESSAGE_TO_1
] then
4904 Data
.MessageSendTo
:= 1
4905 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TO
]] = _lc
[I_PROP_TR_MESSAGE_TO_2
] then
4906 Data
.MessageSendTo
:= 2
4907 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TO
]] = _lc
[I_PROP_TR_MESSAGE_TO_3
] then
4908 Data
.MessageSendTo
:= 3
4909 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TO
]] = _lc
[I_PROP_TR_MESSAGE_TO_4
] then
4910 Data
.MessageSendTo
:= 4
4911 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TO
]] = _lc
[I_PROP_TR_MESSAGE_TO_5
] then
4912 Data
.MessageSendTo
:= 5;
4914 s
:= utf2win(vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TEXT
]]);
4915 FillByte(Data
.MessageText
[0], 100, 0);
4917 Move(s
[1], Data
.MessageText
[0], Min(Length(s
), 100));
4919 Data
.MessageTime
:= Min(Max(
4920 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_MESSAGE_TIME
]], 0), 0), 65535);
4925 Data
.DamageValue
:= Min(Max(
4926 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_DAMAGE_VALUE
]], 0), 0), 65535);
4927 Data
.DamageInterval
:= Min(Max(
4928 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_INTERVAL
]], 0), 0), 65535);
4933 Data
.HealValue
:= Min(Max(
4934 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_HEALTH
]], 0), 0), 65535);
4935 Data
.HealInterval
:= Min(Max(
4936 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_INTERVAL
]], 0), 0), 65535);
4937 Data
.HealMax
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_HEALTH_MAX
]]);
4938 Data
.HealSilent
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SILENT
]]);
4943 Data
.ShotType
:= StrToShot(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TYPE
]]);
4944 Data
.ShotSound
:= NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_SOUND
]]);
4945 Data
.ShotTarget
:= 0;
4946 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_1
] then
4947 Data
.ShotTarget
:= 1
4948 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_2
] then
4949 Data
.ShotTarget
:= 2
4950 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_3
] then
4951 Data
.ShotTarget
:= 3
4952 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_4
] then
4953 Data
.ShotTarget
:= 4
4954 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_5
] then
4955 Data
.ShotTarget
:= 5
4956 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_TO
]] = _lc
[I_PROP_TR_SHOT_TO_6
] then
4957 Data
.ShotTarget
:= 6;
4958 Data
.ShotIntSight
:= Min(Max(
4959 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_SIGHT
]], 0), 0), 65535);
4961 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_AIM
]] = _lc
[I_PROP_TR_SHOT_AIM_1
] then
4963 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_AIM
]] = _lc
[I_PROP_TR_SHOT_AIM_2
] then
4965 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_AIM
]] = _lc
[I_PROP_TR_SHOT_AIM_3
] then
4967 Data
.ShotAngle
:= Min(
4968 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_ANGLE
]], 0), 360);
4969 Data
.ShotWait
:= Min(Max(
4970 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EX_DELAY
]], 0), 0), 65535);
4971 Data
.ShotAccuracy
:= Min(Max(
4972 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_ACC
]], 0), 0), 65535);
4973 Data
.ShotAmmo
:= Min(Max(
4974 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_AMMO
]], 0), 0), 65535);
4975 Data
.ShotIntReload
:= Min(Max(
4976 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_SHOT_RELOAD
]], 0), 0), 65535);
4981 Data
.FXCount
:= Min(Max(
4982 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_COUNT
]], 0), 0), 255);
4983 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_TYPE
]] = _lc
[I_PROP_TR_EFFECT_PARTICLE
] then
4985 Data
.FXType
:= TRIGGER_EFFECT_PARTICLE
;
4986 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
;
4987 if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_SLIQUID
] then
4988 Data
.FXSubType
:= TRIGGER_EFFECT_SLIQUID
4989 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_LLIQUID
] then
4990 Data
.FXSubType
:= TRIGGER_EFFECT_LLIQUID
4991 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_DLIQUID
] then
4992 Data
.FXSubType
:= TRIGGER_EFFECT_DLIQUID
4993 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_BLOOD
] then
4994 Data
.FXSubType
:= TRIGGER_EFFECT_BLOOD
4995 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_SPARK
] then
4996 Data
.FXSubType
:= TRIGGER_EFFECT_SPARK
4997 else if vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]] = _lc
[I_PROP_TR_EFFECT_BUBBLE
] then
4998 Data
.FXSubType
:= TRIGGER_EFFECT_BUBBLE
;
5001 Data
.FXType
:= TRIGGER_EFFECT_ANIMATION
;
5002 Data
.FXSubType
:= StrToEffect(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SUBTYPE
]]);
5005 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_COLOR
]], 0), 0), $FFFFFF);
5006 Data
.FXColorR
:= a
and $FF;
5007 Data
.FXColorG
:= (a
shr 8) and $FF;
5008 Data
.FXColorB
:= (a
shr 16) and $FF;
5009 if NameToBool(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_CENTER
]]) then
5013 Data
.FXWait
:= Min(Max(
5014 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EX_DELAY
]], 0), 0), 65535);
5015 Data
.FXVelX
:= Min(Max(
5016 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_VELX
]], 0), -128), 127);
5017 Data
.FXVelY
:= Min(Max(
5018 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_VELY
]], 0), -128), 127);
5019 Data
.FXSpreadL
:= Min(Max(
5020 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SPL
]], 0), 0), 255);
5021 Data
.FXSpreadR
:= Min(Max(
5022 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SPR
]], 0), 0), 255);
5023 Data
.FXSpreadU
:= Min(Max(
5024 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SPU
]], 0), 0), 255);
5025 Data
.FXSpreadD
:= Min(Max(
5026 StrToIntDef(vleObjectProperty
.Values
[_lc
[I_PROP_TR_EFFECT_SPD
]], 0), 0), 255);
5035 vleObjectProperty
.Row
:= r
;
5036 vleObjectProperty
.Col
:= c
;
5039 procedure TMainForm
.bbRemoveTextureClick(Sender
: TObject
);
5043 i
:= lbTextureList
.ItemIndex
;
5047 if MessageBox(0, PChar(Format(_lc
[I_MSG_DEL_TEXTURE_PROMT
],
5048 [SelectedTexture()])),
5049 PChar(_lc
[I_MSG_DEL_TEXTURE
]),
5050 MB_ICONQUESTION
or MB_YESNO
or
5051 MB_DEFBUTTON1
) <> idYes
then
5054 if gPanels
<> nil then
5055 for a
:= 0 to High(gPanels
) do
5056 if (gPanels
[a
].PanelType
<> 0) and
5057 (gPanels
[a
].TextureName
= SelectedTexture()) then
5059 ErrorMessageBox(_lc
[I_MSG_DEL_TEXTURE_CANT
]);
5063 g_DeleteTexture(SelectedTexture());
5064 i
:= slInvalidTextures
.IndexOf(lbTextureList
.Items
[i
]);
5066 slInvalidTextures
.Delete(i
);
5067 if lbTextureList
.ItemIndex
> -1 then
5068 lbTextureList
.Items
.Delete(lbTextureList
.ItemIndex
)
5071 procedure TMainForm
.aNewMapExecute(Sender
: TObject
);
5073 if (MessageBox(0, PChar(_lc
[I_MSG_CLEAR_MAP_PROMT
]),
5074 PChar(_lc
[I_MSG_CLEAR_MAP
]),
5075 MB_ICONQUESTION
or MB_YESNO
or
5076 MB_DEFBUTTON1
) = mrYes
) then
5080 procedure TMainForm
.aUndoExecute(Sender
: TObject
);
5084 if UndoBuffer
= nil then
5086 if UndoBuffer
[High(UndoBuffer
)] = nil then
5089 for a
:= 0 to High(UndoBuffer
[High(UndoBuffer
)]) do
5090 with UndoBuffer
[High(UndoBuffer
)][a
] do
5098 UNDO_DELETE_ITEM
: AddItem(Item
);
5099 UNDO_DELETE_AREA
: AddArea(Area
);
5100 UNDO_DELETE_MONSTER
: AddMonster(Monster
);
5101 UNDO_DELETE_TRIGGER
: AddTrigger(Trigger
);
5102 UNDO_ADD_PANEL
: RemoveObject(AddID
, OBJECT_PANEL
);
5103 UNDO_ADD_ITEM
: RemoveObject(AddID
, OBJECT_ITEM
);
5104 UNDO_ADD_AREA
: RemoveObject(AddID
, OBJECT_AREA
);
5105 UNDO_ADD_MONSTER
: RemoveObject(AddID
, OBJECT_MONSTER
);
5106 UNDO_ADD_TRIGGER
: RemoveObject(AddID
, OBJECT_TRIGGER
);
5110 SetLength(UndoBuffer
, Length(UndoBuffer
)-1);
5112 RemoveSelectFromObjects();
5114 miUndo
.Enabled
:= UndoBuffer
<> nil;
5118 procedure TMainForm
.aCopyObjectExecute(Sender
: TObject
);
5121 CopyBuffer
: TCopyRecArray
;
5125 function CB_Compare(I1
, I2
: TCopyRec
): Integer;
5127 Result
:= Integer(I1
.ObjectType
) - Integer(I2
.ObjectType
);
5129 if Result
= 0 then // Одного типа
5130 Result
:= Integer(I1
.ID
) - Integer(I2
.ID
);
5133 procedure QuickSortCopyBuffer(L
, R
: Integer);
5141 P
:= CopyBuffer
[(L
+ R
) shr 1];
5144 while CB_Compare(CopyBuffer
[I
], P
) < 0 do
5146 while CB_Compare(CopyBuffer
[J
], P
) > 0 do
5152 CopyBuffer
[I
] := CopyBuffer
[J
];
5160 QuickSortCopyBuffer(L
, J
);
5167 if SelectedObjects
= nil then
5173 // Копируем объекты:
5174 for a
:= 0 to High(SelectedObjects
) do
5175 if SelectedObjects
[a
].Live
then
5176 with SelectedObjects
[a
] do
5178 SetLength(CopyBuffer
, Length(CopyBuffer
)+1);
5179 b
:= High(CopyBuffer
);
5180 CopyBuffer
[b
].ID
:= ID
;
5181 CopyBuffer
[b
].Panel
:= nil;
5186 CopyBuffer
[b
].ObjectType
:= OBJECT_PANEL
;
5187 New(CopyBuffer
[b
].Panel
);
5188 CopyBuffer
[b
].Panel
^ := gPanels
[ID
];
5193 CopyBuffer
[b
].ObjectType
:= OBJECT_ITEM
;
5194 CopyBuffer
[b
].Item
:= gItems
[ID
];
5199 CopyBuffer
[b
].ObjectType
:= OBJECT_MONSTER
;
5200 CopyBuffer
[b
].Monster
:= gMonsters
[ID
];
5205 CopyBuffer
[b
].ObjectType
:= OBJECT_AREA
;
5206 CopyBuffer
[b
].Area
:= gAreas
[ID
];
5211 CopyBuffer
[b
].ObjectType
:= OBJECT_TRIGGER
;
5212 CopyBuffer
[b
].Trigger
:= gTriggers
[ID
];
5217 // Сортировка по ID:
5218 if CopyBuffer
<> nil then
5220 QuickSortCopyBuffer(0, b
);
5223 // Пестановка ссылок триггеров:
5224 for a
:= 0 to Length(CopyBuffer
)-1 do
5225 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
5227 case CopyBuffer
[a
].Trigger
.TriggerType
of
5228 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5229 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5230 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5231 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
5235 for b
:= 0 to Length(CopyBuffer
)-1 do
5236 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5237 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.PanelID
) then
5239 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= b
;
5244 // Этих панелей нет среди копируемых:
5246 CopyBuffer
[a
].Trigger
.Data
.PanelID
:= -1;
5249 TRIGGER_PRESS
, TRIGGER_ON
,
5250 TRIGGER_OFF
, TRIGGER_ONOFF
:
5251 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
5255 for b
:= 0 to Length(CopyBuffer
)-1 do
5256 if (CopyBuffer
[b
].ObjectType
= OBJECT_MONSTER
) and
5257 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1) then
5259 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= b
+1;
5264 // Этих монстров нет среди копируемых:
5266 CopyBuffer
[a
].Trigger
.Data
.MonsterID
:= 0;
5270 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
5274 for b
:= 0 to Length(CopyBuffer
)-1 do
5275 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5276 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
) then
5278 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= b
;
5283 // Этих панелей нет среди копируемых:
5285 CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
:= -1;
5289 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
5293 for b
:= 0 to Length(CopyBuffer
)-1 do
5294 if (CopyBuffer
[b
].ObjectType
= OBJECT_PANEL
) and
5295 (Integer(CopyBuffer
[b
].ID
) = CopyBuffer
[a
].Trigger
.TexturePanel
) then
5297 CopyBuffer
[a
].Trigger
.TexturePanel
:= b
;
5302 // Этих панелей нет среди копируемых:
5304 CopyBuffer
[a
].Trigger
.TexturePanel
:= -1;
5309 str
:= CopyBufferToString(CopyBuffer
);
5310 ClipBoard
.AsText
:= str
;
5312 for a
:= 0 to Length(CopyBuffer
)-1 do
5313 if (CopyBuffer
[a
].ObjectType
= OBJECT_PANEL
) and
5314 (CopyBuffer
[a
].Panel
<> nil) then
5315 Dispose(CopyBuffer
[a
].Panel
);
5320 procedure TMainForm
.aPasteObjectExecute(Sender
: TObject
);
5323 CopyBuffer
: TCopyRecArray
;
5325 swad
, ssec
, sres
: String;
5329 StringToCopyBuffer(ClipBoard
.AsText
, CopyBuffer
);
5331 if CopyBuffer
= nil then
5334 RemoveSelectFromObjects();
5336 h
:= High(CopyBuffer
);
5338 with CopyBuffer
[a
] do
5342 if Panel
<> nil then
5344 Panel
^.X
:= Panel
^.X
+ 16;
5345 Panel
^.Y
:= Panel
^.Y
+ 16;
5347 Panel
^.TextureID
:= TEXTURE_SPECIAL_NONE
;
5348 Panel
^.TextureWidth
:= 1;
5349 Panel
^.TextureHeight
:= 1;
5351 if (Panel
^.PanelType
= PANEL_LIFTUP
) or
5352 (Panel
^.PanelType
= PANEL_LIFTDOWN
) or
5353 (Panel
^.PanelType
= PANEL_LIFTLEFT
) or
5354 (Panel
^.PanelType
= PANEL_LIFTRIGHT
) or
5355 (Panel
^.PanelType
= PANEL_BLOCKMON
) or
5356 (Panel
^.TextureName
= '') then
5357 begin // Нет или не может быть текстуры:
5359 else // Есть текстура:
5361 // Обычная текстура:
5362 if not IsSpecialTexture(Panel
^.TextureName
) then
5364 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5368 g_ProcessResourceStr(Panel
^.TextureName
, swad
, ssec
, sres
);
5369 AddTexture(swad
, ssec
, sres
, True);
5370 res
:= g_GetTexture(Panel
^.TextureName
, Panel
^.TextureID
);
5374 g_GetTextureSizeByName(Panel
^.TextureName
,
5375 Panel
^.TextureWidth
, Panel
^.TextureHeight
)
5377 Panel
^.TextureName
:= '';
5379 else // Спец.текстура:
5381 Panel
^.TextureID
:= SpecialTextureID(Panel
^.TextureName
);
5382 with MainForm
.lbTextureList
.Items
do
5383 if IndexOf(Panel
^.TextureName
) = -1 then
5384 Add(Panel
^.TextureName
);
5388 ID
:= AddPanel(Panel
^);
5390 Undo_Add(OBJECT_PANEL
, ID
, a
> 0);
5391 SelectObject(OBJECT_PANEL
, ID
, True);
5396 Item
.X
:= Item
.X
+ 16;
5397 Item
.Y
:= Item
.Y
+ 16;
5399 ID
:= AddItem(Item
);
5400 Undo_Add(OBJECT_ITEM
, ID
, a
> 0);
5401 SelectObject(OBJECT_ITEM
, ID
, True);
5406 Monster
.X
:= Monster
.X
+ 16;
5407 Monster
.Y
:= Monster
.Y
+ 16;
5409 ID
:= AddMonster(Monster
);
5410 Undo_Add(OBJECT_MONSTER
, ID
, a
> 0);
5411 SelectObject(OBJECT_MONSTER
, ID
, True);
5416 Area
.X
:= Area
.X
+ 16;
5417 Area
.Y
:= Area
.Y
+ 16;
5419 ID
:= AddArea(Area
);
5420 Undo_Add(OBJECT_AREA
, ID
, a
> 0);
5421 SelectObject(OBJECT_AREA
, ID
, True);
5426 Trigger
.X
:= Trigger
.X
+ 16;
5427 Trigger
.Y
:= Trigger
.Y
+ 16;
5429 ID
:= AddTrigger(Trigger
);
5430 Undo_Add(OBJECT_TRIGGER
, ID
, a
> 0);
5431 SelectObject(OBJECT_TRIGGER
, ID
, True);
5436 // Переставляем ссылки триггеров:
5437 for a
:= 0 to High(CopyBuffer
) do
5438 if CopyBuffer
[a
].ObjectType
= OBJECT_TRIGGER
then
5440 case CopyBuffer
[a
].Trigger
.TriggerType
of
5441 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5442 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5443 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5444 if CopyBuffer
[a
].Trigger
.Data
.PanelID
<> -1 then
5445 gTriggers
[CopyBuffer
[a
].ID
].Data
.PanelID
:=
5446 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.PanelID
].ID
;
5448 TRIGGER_PRESS
, TRIGGER_ON
,
5449 TRIGGER_OFF
, TRIGGER_ONOFF
:
5450 if CopyBuffer
[a
].Trigger
.Data
.MonsterID
<> 0 then
5451 gTriggers
[CopyBuffer
[a
].ID
].Data
.MonsterID
:=
5452 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.MonsterID
-1].ID
+1;
5455 if CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
<> -1 then
5456 gTriggers
[CopyBuffer
[a
].ID
].Data
.ShotPanelID
:=
5457 CopyBuffer
[CopyBuffer
[a
].Trigger
.Data
.ShotPanelID
].ID
;
5460 if CopyBuffer
[a
].Trigger
.TexturePanel
<> -1 then
5461 gTriggers
[CopyBuffer
[a
].ID
].TexturePanel
:=
5462 CopyBuffer
[CopyBuffer
[a
].Trigger
.TexturePanel
].ID
;
5471 procedure TMainForm
.aCutObjectExecute(Sender
: TObject
);
5474 DeleteSelectedObjects();
5477 procedure TMainForm
.vleObjectPropertyEditButtonClick(Sender
: TObject
);
5479 Key
, FileName
: String;
5482 Key
:= vleObjectProperty
.Keys
[vleObjectProperty
.Row
];
5484 if Key
= _lc
[I_PROP_PANEL_TYPE
] then
5486 with ChooseTypeForm
, vleObjectProperty
do
5487 begin // Выбор типа панели:
5488 Caption
:= _lc
[I_PROP_PANEL_TYPE
];
5489 lbTypeSelect
.Items
.Clear();
5491 for b
:= 0 to High(PANELNAMES
) do
5493 lbTypeSelect
.Items
.Add(PANELNAMES
[b
]);
5494 if Values
[Key
] = PANELNAMES
[b
] then
5495 lbTypeSelect
.ItemIndex
:= b
;
5498 if ShowModal() = mrOK
then
5500 b
:= lbTypeSelect
.ItemIndex
;
5501 Values
[Key
] := PANELNAMES
[b
];
5502 vleObjectPropertyApply(Sender
);
5506 else if Key
= _lc
[I_PROP_TR_TELEPORT_TO
] then
5507 SelectFlag
:= SELECTFLAG_TELEPORT
5508 else if Key
= _lc
[I_PROP_TR_SPAWN_TO
] then
5509 SelectFlag
:= SELECTFLAG_SPAWNPOINT
5510 else if (Key
= _lc
[I_PROP_TR_DOOR_PANEL
]) or
5511 (Key
= _lc
[I_PROP_TR_TRAP_PANEL
]) then
5512 SelectFlag
:= SELECTFLAG_DOOR
5513 else if Key
= _lc
[I_PROP_TR_TEXTURE_PANEL
] then
5515 DrawPressRect
:= False;
5516 SelectFlag
:= SELECTFLAG_TEXTURE
;
5518 else if Key
= _lc
[I_PROP_TR_SHOT_PANEL
] then
5519 SelectFlag
:= SELECTFLAG_SHOTPANEL
5520 else if Key
= _lc
[I_PROP_TR_LIFT_PANEL
] then
5521 SelectFlag
:= SELECTFLAG_LIFT
5522 else if key
= _lc
[I_PROP_TR_EX_MONSTER
] then
5523 SelectFlag
:= SELECTFLAG_MONSTER
5524 else if Key
= _lc
[I_PROP_TR_EX_AREA
] then
5526 SelectFlag
:= SELECTFLAG_NONE
;
5527 DrawPressRect
:= True;
5529 else if Key
= _lc
[I_PROP_TR_NEXT_MAP
] then
5530 begin // Выбор следующей карты:
5531 g_ProcessResourceStr(OpenedMap
, @FileName
, nil, nil);
5532 SelectMapForm
.Caption
:= _lc
[I_CAP_SELECT
];
5533 SelectMapForm
.GetMaps(FileName
);
5535 if SelectMapForm
.ShowModal() = mrOK
then
5537 vleObjectProperty
.Values
[Key
] := SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
5538 vleObjectPropertyApply(Sender
);
5541 else if (Key
= _lc
[I_PROP_TR_SOUND_NAME
]) or
5542 (Key
= _lc
[I_PROP_TR_MUSIC_NAME
]) then
5543 begin // Выбор файла звука/музыки:
5544 AddSoundForm
.OKFunction
:= nil;
5545 AddSoundForm
.lbResourcesList
.MultiSelect
:= False;
5546 AddSoundForm
.SetResource
:= vleObjectProperty
.Values
[Key
];
5548 if (AddSoundForm
.ShowModal() = mrOk
) then
5550 vleObjectProperty
.Values
[Key
] := AddSoundForm
.ResourceName
;
5551 vleObjectPropertyApply(Sender
);
5554 else if Key
= _lc
[I_PROP_TR_ACTIVATION
] then
5555 with ActivationTypeForm
, vleObjectProperty
do
5556 begin // Выбор типов активации:
5557 cbPlayerCollide
.Checked
:= Pos('PC', Values
[Key
]) > 0;
5558 cbMonsterCollide
.Checked
:= Pos('MC', Values
[Key
]) > 0;
5559 cbPlayerPress
.Checked
:= Pos('PP', Values
[Key
]) > 0;
5560 cbMonsterPress
.Checked
:= Pos('MP', Values
[Key
]) > 0;
5561 cbShot
.Checked
:= Pos('SH', Values
[Key
]) > 0;
5562 cbNoMonster
.Checked
:= Pos('NM', Values
[Key
]) > 0;
5564 if ShowModal() = mrOK
then
5567 if cbPlayerCollide
.Checked
then
5568 b
:= ACTIVATE_PLAYERCOLLIDE
;
5569 if cbMonsterCollide
.Checked
then
5570 b
:= b
or ACTIVATE_MONSTERCOLLIDE
;
5571 if cbPlayerPress
.Checked
then
5572 b
:= b
or ACTIVATE_PLAYERPRESS
;
5573 if cbMonsterPress
.Checked
then
5574 b
:= b
or ACTIVATE_MONSTERPRESS
;
5575 if cbShot
.Checked
then
5576 b
:= b
or ACTIVATE_SHOT
;
5577 if cbNoMonster
.Checked
then
5578 b
:= b
or ACTIVATE_NOMONSTER
;
5580 Values
[Key
] := ActivateToStr(b
);
5581 vleObjectPropertyApply(Sender
);
5584 else if Key
= _lc
[I_PROP_TR_KEYS
] then
5585 with KeysForm
, vleObjectProperty
do
5586 begin // Выбор необходимых ключей:
5587 cbRedKey
.Checked
:= Pos('RK', Values
[Key
]) > 0;
5588 cbGreenKey
.Checked
:= Pos('GK', Values
[Key
]) > 0;
5589 cbBlueKey
.Checked
:= Pos('BK', Values
[Key
]) > 0;
5590 cbRedTeam
.Checked
:= Pos('RT', Values
[Key
]) > 0;
5591 cbBlueTeam
.Checked
:= Pos('BT', Values
[Key
]) > 0;
5593 if ShowModal() = mrOK
then
5596 if cbRedKey
.Checked
then
5598 if cbGreenKey
.Checked
then
5599 b
:= b
or KEY_GREEN
;
5600 if cbBlueKey
.Checked
then
5602 if cbRedTeam
.Checked
then
5603 b
:= b
or KEY_REDTEAM
;
5604 if cbBlueTeam
.Checked
then
5605 b
:= b
or KEY_BLUETEAM
;
5607 Values
[Key
] := KeyToStr(b
);
5608 vleObjectPropertyApply(Sender
);
5611 else if Key
= _lc
[I_PROP_TR_FX_TYPE
] then
5612 with ChooseTypeForm
, vleObjectProperty
do
5613 begin // Выбор типа эффекта:
5614 Caption
:= _lc
[I_CAP_FX_TYPE
];
5615 lbTypeSelect
.Items
.Clear();
5617 for b
:= EFFECT_NONE
to EFFECT_FIRE
do
5618 lbTypeSelect
.Items
.Add(EffectToStr(b
));
5620 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]);
5622 if ShowModal() = mrOK
then
5624 b
:= lbTypeSelect
.ItemIndex
;
5625 Values
[Key
] := EffectToStr(b
);
5626 vleObjectPropertyApply(Sender
);
5629 else if Key
= _lc
[I_PROP_TR_MONSTER_TYPE
] then
5630 with ChooseTypeForm
, vleObjectProperty
do
5631 begin // Выбор типа монстра:
5632 Caption
:= _lc
[I_CAP_MONSTER_TYPE
];
5633 lbTypeSelect
.Items
.Clear();
5635 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
5636 lbTypeSelect
.Items
.Add(MonsterToStr(b
));
5638 lbTypeSelect
.ItemIndex
:= StrToMonster(Values
[Key
]) - MONSTER_DEMON
;
5640 if ShowModal() = mrOK
then
5642 b
:= lbTypeSelect
.ItemIndex
+ MONSTER_DEMON
;
5643 Values
[Key
] := MonsterToStr(b
);
5644 vleObjectPropertyApply(Sender
);
5647 else if Key
= _lc
[I_PROP_TR_ITEM_TYPE
] then
5648 with ChooseTypeForm
, vleObjectProperty
do
5649 begin // Выбор типа предмета:
5650 Caption
:= _lc
[I_CAP_ITEM_TYPE
];
5651 lbTypeSelect
.Items
.Clear();
5653 for b
:= ITEM_MEDKIT_SMALL
to ITEM_KEY_BLUE
do
5654 lbTypeSelect
.Items
.Add(ItemToStr(b
));
5655 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_BOTTLE
));
5656 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_HELMET
));
5657 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_JETPACK
));
5658 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_INVIS
));
5659 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_WEAPON_FLAMETHROWER
));
5660 lbTypeSelect
.Items
.Add(ItemToStr(ITEM_AMMO_FUELCAN
));
5662 b
:= StrToItem(Values
[Key
]);
5663 if b
>= ITEM_BOTTLE
then
5665 lbTypeSelect
.ItemIndex
:= b
- ITEM_MEDKIT_SMALL
;
5667 if ShowModal() = mrOK
then
5669 b
:= lbTypeSelect
.ItemIndex
+ ITEM_MEDKIT_SMALL
;
5670 if b
>= ITEM_WEAPON_KASTET
then
5672 Values
[Key
] := ItemToStr(b
);
5673 vleObjectPropertyApply(Sender
);
5676 else if Key
= _lc
[I_PROP_TR_SHOT_TYPE
] then
5677 with ChooseTypeForm
, vleObjectProperty
do
5678 begin // Выбор типа предмета:
5679 Caption
:= _lc
[I_PROP_TR_SHOT_TYPE
];
5680 lbTypeSelect
.Items
.Clear();
5682 for b
:= TRIGGER_SHOT_PISTOL
to TRIGGER_SHOT_MAX
do
5683 lbTypeSelect
.Items
.Add(ShotToStr(b
));
5685 lbTypeSelect
.ItemIndex
:= StrToShot(Values
[Key
]);
5687 if ShowModal() = mrOK
then
5689 b
:= lbTypeSelect
.ItemIndex
;
5690 Values
[Key
] := ShotToStr(b
);
5691 vleObjectPropertyApply(Sender
);
5694 else if Key
= _lc
[I_PROP_TR_EFFECT_TYPE
] then
5695 with ChooseTypeForm
, vleObjectProperty
do
5696 begin // Выбор типа эффекта:
5697 Caption
:= _lc
[I_CAP_FX_TYPE
];
5698 lbTypeSelect
.Items
.Clear();
5700 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_PARTICLE
]);
5701 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_ANIMATION
]);
5702 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_ANIMATION
] then
5703 lbTypeSelect
.ItemIndex
:= 1
5705 lbTypeSelect
.ItemIndex
:= 0;
5707 if ShowModal() = mrOK
then
5709 b
:= lbTypeSelect
.ItemIndex
;
5711 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_PARTICLE
]
5713 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_ANIMATION
];
5714 vleObjectPropertyApply(Sender
);
5717 else if Key
= _lc
[I_PROP_TR_EFFECT_SUBTYPE
] then
5718 with ChooseTypeForm
, vleObjectProperty
do
5719 begin // Выбор подтипа эффекта:
5720 Caption
:= _lc
[I_CAP_FX_TYPE
];
5721 lbTypeSelect
.Items
.Clear();
5723 if Values
[_lc
[I_PROP_TR_EFFECT_TYPE
]] = _lc
[I_PROP_TR_EFFECT_ANIMATION
] then
5725 for b
:= EFFECT_TELEPORT
to EFFECT_FIRE
do
5726 lbTypeSelect
.Items
.Add(EffectToStr(b
));
5728 lbTypeSelect
.ItemIndex
:= StrToEffect(Values
[Key
]) - 1;
5731 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_SLIQUID
]);
5732 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_LLIQUID
]);
5733 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_DLIQUID
]);
5734 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_BLOOD
]);
5735 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_SPARK
]);
5736 lbTypeSelect
.Items
.Add(_lc
[I_PROP_TR_EFFECT_BUBBLE
]);
5737 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SLIQUID
;
5738 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_LLIQUID
] then
5739 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_LLIQUID
;
5740 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_DLIQUID
] then
5741 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_DLIQUID
;
5742 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_BLOOD
] then
5743 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BLOOD
;
5744 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_SPARK
] then
5745 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_SPARK
;
5746 if Values
[Key
] = _lc
[I_PROP_TR_EFFECT_BUBBLE
] then
5747 lbTypeSelect
.ItemIndex
:= TRIGGER_EFFECT_BUBBLE
;
5750 if ShowModal() = mrOK
then
5752 b
:= lbTypeSelect
.ItemIndex
;
5754 if Values
[_lc
[I_PROP_TR_EFFECT_TYPE
]] = _lc
[I_PROP_TR_EFFECT_ANIMATION
] then
5755 Values
[Key
] := EffectToStr(b
+ 1)
5757 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_SLIQUID
];
5758 if b
= TRIGGER_EFFECT_LLIQUID
then
5759 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_LLIQUID
];
5760 if b
= TRIGGER_EFFECT_DLIQUID
then
5761 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_DLIQUID
];
5762 if b
= TRIGGER_EFFECT_BLOOD
then
5763 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_BLOOD
];
5764 if b
= TRIGGER_EFFECT_SPARK
then
5765 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_SPARK
];
5766 if b
= TRIGGER_EFFECT_BUBBLE
then
5767 Values
[Key
] := _lc
[I_PROP_TR_EFFECT_BUBBLE
];
5770 vleObjectPropertyApply(Sender
);
5773 else if Key
= _lc
[I_PROP_TR_EFFECT_COLOR
] then
5774 with vleObjectProperty
do
5775 begin // Выбор цвета эффекта:
5776 ColorDialog
.Color
:= StrToIntDef(Values
[Key
], 0);
5777 if ColorDialog
.Execute
then
5779 Values
[Key
] := IntToStr(ColorDialog
.Color
);
5780 vleObjectPropertyApply(Sender
);
5783 else if Key
= _lc
[I_PROP_PANEL_TEX
] then
5784 begin // Смена текстуры:
5785 vleObjectProperty
.Values
[Key
] := SelectedTexture();
5786 vleObjectPropertyApply(Sender
);
5790 procedure TMainForm
.vleObjectPropertyApply(Sender
: TObject
);
5792 // hack to prevent empty ID in list
5793 RenderPanel
.SetFocus();
5794 bApplyProperty
.Click();
5795 vleObjectProperty
.SetFocus();
5798 procedure TMainForm
.aSaveMapExecute(Sender
: TObject
);
5800 FileName
, Section
, Res
: String;
5802 if OpenedMap
= '' then
5804 aSaveMapAsExecute(nil);
5808 g_ProcessResourceStr(OpenedMap
, FileName
, Section
, Res
);
5810 SaveMap(FileName
+':\'+Res
);
5813 procedure TMainForm
.aOpenMapExecute(Sender
: TObject
);
5815 OpenDialog
.Filter
:= _lc
[I_FILE_FILTER_ALL
];
5817 if OpenDialog
.Execute() then
5819 if (Pos('.ini', LowerCase(ExtractFileName(OpenDialog
.FileName
))) > 0) then
5823 pLoadProgress
.Left
:= (RenderPanel
.Width
div 2)-(pLoadProgress
.Width
div 2);
5824 pLoadProgress
.Top
:= (RenderPanel
.Height
div 2)-(pLoadProgress
.Height
div 2);
5825 pLoadProgress
.Show();
5830 LoadMapOld(OpenDialog
.FileName
);
5832 MainForm
.Caption
:= Format('%s - %s', [FormCaption
, ExtractFileName(OpenDialog
.FileName
)]);
5834 pLoadProgress
.Hide();
5835 MainForm
.FormResize(Self
);
5837 else // Карты из WAD:
5839 OpenMap(OpenDialog
.FileName
, '');
5842 OpenDialog
.InitialDir
:= ExtractFileDir(OpenDialog
.FileName
);
5846 procedure TMainForm
.FormActivate(Sender
: TObject
);
5851 MainForm
.ActiveControl
:= RenderPanel
;
5854 if gLanguage
= '' then
5856 lang
:= SelectLanguageForm
.ShowModal();
5858 1: gLanguage
:= LANGUAGE_ENGLISH
;
5859 else gLanguage
:= LANGUAGE_RUSSIAN
;
5862 config
:= TConfig
.CreateFile(EditorDir
+'Editor.cfg');
5863 config
.WriteStr('Editor', 'Language', gLanguage
);
5864 config
.SaveFile(EditorDir
+'Editor.cfg');
5868 //e_WriteLog('Read language file', MSG_NOTIFY);
5869 //g_Language_Load(EditorDir+'\data\'+gLanguage+LANGUAGE_FILE_NAME);
5870 g_Language_Set(gLanguage
);
5873 procedure TMainForm
.aDeleteMap(Sender
: TObject
);
5881 OpenDialog
.Filter
:= _lc
[I_FILE_FILTER_WAD
];
5883 if not OpenDialog
.Execute() then
5886 WAD
:= TWADEditor_1
.Create();
5888 if not WAD
.ReadFile(OpenDialog
.FileName
) then
5896 MapList
:= WAD
.GetResourcesList('');
5898 SelectMapForm
.Caption
:= _lc
[I_CAP_REMOVE
];
5899 SelectMapForm
.lbMapList
.Items
.Clear();
5901 if MapList
<> nil then
5902 for a
:= 0 to High(MapList
) do
5903 SelectMapForm
.lbMapList
.Items
.Add(win2utf(MapList
[a
]));
5905 if (SelectMapForm
.ShowModal() = mrOK
) then
5907 str
:= SelectMapForm
.lbMapList
.Items
[SelectMapForm
.lbMapList
.ItemIndex
];
5909 Move(str
[1], MapName
[0], Min(16, Length(str
)));
5911 if MessageBox(0, PChar(Format(_lc
[I_MSG_DELETE_MAP_PROMT
],
5912 [MapName
, OpenDialog
.FileName
])),
5913 PChar(_lc
[I_MSG_DELETE_MAP
]),
5914 MB_ICONQUESTION
or MB_YESNO
or
5915 MB_DEFBUTTON2
) <> mrYes
then
5918 WAD
.RemoveResource('', utf2win(MapName
));
5920 MessageBox(0, PChar(Format(_lc
[I_MSG_MAP_DELETED_PROMT
],
5922 PChar(_lc
[I_MSG_MAP_DELETED
]),
5923 MB_ICONINFORMATION
or MB_OK
or
5926 WAD
.SaveTo(OpenDialog
.FileName
);
5928 // Удалили текущую карту - сохранять по старому ее нельзя:
5929 if OpenedMap
= (OpenDialog
.FileName
+':\'+MapName
) then
5933 MainForm
.Caption
:= FormCaption
;
5940 procedure TMainForm
.vleObjectPropertyKeyDown(Sender
: TObject
;
5941 var Key
: Word; Shift
: TShiftState
);
5943 if Key
= VK_RETURN
then
5944 vleObjectPropertyApply(Sender
);
5947 procedure MovePanel(var ID
: DWORD
; MoveType
: Byte);
5952 if (ID
= 0) and (MoveType
= 0) then
5954 if (ID
= DWORD(High(gPanels
))) and (MoveType
<> 0) then
5956 if (ID
> DWORD(High(gPanels
))) then
5961 if MoveType
= 0 then // to Back
5963 if gTriggers
<> nil then
5964 for a
:= 0 to High(gTriggers
) do
5965 with gTriggers
[a
] do
5967 if TriggerType
= TRIGGER_NONE
then
5970 if TexturePanel
= _id
then
5973 if (TexturePanel
>= 0) and (TexturePanel
< _id
) then
5977 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
5978 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
5979 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
5980 if Data
.PanelID
= _id
then
5983 if (Data
.PanelID
>= 0) and (Data
.PanelID
< _id
) then
5987 if Data
.ShotPanelID
= _id
then
5988 Data
.ShotPanelID
:= 0
5990 if (Data
.ShotPanelID
>= 0) and (Data
.ShotPanelID
< _id
) then
5991 Inc(Data
.ShotPanelID
);
5995 tmp
:= gPanels
[_id
];
5997 for a
:= _id
downto 1 do
5998 gPanels
[a
] := gPanels
[a
-1];
6006 if gTriggers
<> nil then
6007 for a
:= 0 to High(gTriggers
) do
6008 with gTriggers
[a
] do
6010 if TriggerType
= TRIGGER_NONE
then
6013 if TexturePanel
= _id
then
6014 TexturePanel
:= High(gPanels
)
6016 if TexturePanel
> _id
then
6020 TRIGGER_OPENDOOR
, TRIGGER_CLOSEDOOR
, TRIGGER_DOOR
,
6021 TRIGGER_DOOR5
, TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6022 TRIGGER_LIFTUP
, TRIGGER_LIFTDOWN
, TRIGGER_LIFT
:
6023 if Data
.PanelID
= _id
then
6024 Data
.PanelID
:= High(gPanels
)
6026 if Data
.PanelID
> _id
then
6030 if Data
.ShotPanelID
= _id
then
6031 Data
.ShotPanelID
:= High(gPanels
)
6033 if Data
.ShotPanelID
> _id
then
6034 Dec(Data
.ShotPanelID
);
6038 tmp
:= gPanels
[_id
];
6040 for a
:= _id
to High(gPanels
)-1 do
6041 gPanels
[a
] := gPanels
[a
+1];
6043 gPanels
[High(gPanels
)] := tmp
;
6045 ID
:= High(gPanels
);
6049 procedure TMainForm
.aMoveToBack(Sender
: TObject
);
6053 if SelectedObjects
= nil then
6056 for a
:= 0 to High(SelectedObjects
) do
6057 with SelectedObjects
[a
] do
6058 if Live
and (ObjectType
= OBJECT_PANEL
) then
6060 SelectedObjects
[0] := SelectedObjects
[a
];
6061 SetLength(SelectedObjects
, 1);
6068 procedure TMainForm
.aMoveToFore(Sender
: TObject
);
6072 if SelectedObjects
= nil then
6075 for a
:= 0 to High(SelectedObjects
) do
6076 with SelectedObjects
[a
] do
6077 if Live
and (ObjectType
= OBJECT_PANEL
) then
6079 SelectedObjects
[0] := SelectedObjects
[a
];
6080 SetLength(SelectedObjects
, 1);
6087 procedure TMainForm
.aSaveMapAsExecute(Sender
: TObject
);
6091 SaveDialog
.Filter
:= _lc
[I_FILE_FILTER_WAD
];
6093 if not SaveDialog
.Execute() then
6096 SaveMapForm
.GetMaps(SaveDialog
.FileName
, True);
6098 if SaveMapForm
.ShowModal() <> mrOK
then
6101 SaveDialog
.InitialDir
:= ExtractFileDir(SaveDialog
.FileName
);
6102 OpenedMap
:= SaveDialog
.FileName
+':\'+SaveMapForm
.eMapName
.Text;
6103 OpenedWAD
:= SaveDialog
.FileName
;
6105 idx
:= RecentFiles
.IndexOf(OpenedMap
);
6106 // Такая карта уже недавно открывалась:
6108 RecentFiles
.Delete(idx
);
6109 RecentFiles
.Insert(0, OpenedMap
);
6114 gMapInfo
.FileName
:= SaveDialog
.FileName
;
6115 gMapInfo
.MapName
:= SaveMapForm
.eMapName
.Text;
6116 UpdateCaption(gMapInfo
.Name
, ExtractFileName(gMapInfo
.FileName
), gMapInfo
.MapName
);
6119 procedure TMainForm
.aSelectAllExecute(Sender
: TObject
);
6123 RemoveSelectFromObjects();
6125 case pcObjects
.ActivePageIndex
+1 of
6127 if gPanels
<> nil then
6128 for a
:= 0 to High(gPanels
) do
6129 if gPanels
[a
].PanelType
<> PANEL_NONE
then
6130 SelectObject(OBJECT_PANEL
, a
, True);
6132 if gItems
<> nil then
6133 for a
:= 0 to High(gItems
) do
6134 if gItems
[a
].ItemType
<> ITEM_NONE
then
6135 SelectObject(OBJECT_ITEM
, a
, True);
6137 if gMonsters
<> nil then
6138 for a
:= 0 to High(gMonsters
) do
6139 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
6140 SelectObject(OBJECT_MONSTER
, a
, True);
6142 if gAreas
<> nil then
6143 for a
:= 0 to High(gAreas
) do
6144 if gAreas
[a
].AreaType
<> AREA_NONE
then
6145 SelectObject(OBJECT_AREA
, a
, True);
6147 if gTriggers
<> nil then
6148 for a
:= 0 to High(gTriggers
) do
6149 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
6150 SelectObject(OBJECT_TRIGGER
, a
, True);
6154 procedure TMainForm
.tbGridOnClick(Sender
: TObject
);
6156 DotEnable
:= not DotEnable
;
6157 (Sender
as TToolButton
).Down
:= DotEnable
;
6160 procedure TMainForm
.OnIdle(Sender
: TObject
; var Done
: Boolean);
6162 // FIXME: this is a shitty hack
6163 if not gDataLoaded
then
6165 e_WriteLog('Init OpenGL', MSG_NOTIFY
);
6167 e_WriteLog('Loading data', MSG_NOTIFY
);
6168 LoadStdFont('STDTXT', 'STDFONT', gEditorFont
);
6169 e_WriteLog('Loading more data', MSG_NOTIFY
);
6171 e_WriteLog('Loading even more data', MSG_NOTIFY
);
6172 gDataLoaded
:= True;
6173 MainForm
.FormResize(nil);
6178 procedure TMainForm
.miMapPreviewClick(Sender
: TObject
);
6180 if PreviewMode
= 2 then
6183 if PreviewMode
= 0 then
6185 Splitter2
.Visible
:= False;
6186 Splitter1
.Visible
:= False;
6187 StatusBar
.Visible
:= False;
6188 PanelObjs
.Visible
:= False;
6189 PanelProps
.Visible
:= False;
6190 MainToolBar
.Visible
:= False;
6191 sbHorizontal
.Visible
:= False;
6192 sbVertical
.Visible
:= False;
6196 StatusBar
.Visible
:= True;
6197 PanelObjs
.Visible
:= True;
6198 PanelProps
.Visible
:= True;
6199 Splitter2
.Visible
:= True;
6200 Splitter1
.Visible
:= True;
6201 MainToolBar
.Visible
:= True;
6202 sbHorizontal
.Visible
:= True;
6203 sbVertical
.Visible
:= True;
6206 PreviewMode
:= PreviewMode
xor 1;
6207 (Sender
as TMenuItem
).Checked
:= PreviewMode
> 0;
6212 procedure TMainForm
.miLayer1Click(Sender
: TObject
);
6214 SwitchLayer(LAYER_BACK
);
6217 procedure TMainForm
.miLayer2Click(Sender
: TObject
);
6219 SwitchLayer(LAYER_WALLS
);
6222 procedure TMainForm
.miLayer3Click(Sender
: TObject
);
6224 SwitchLayer(LAYER_FOREGROUND
);
6227 procedure TMainForm
.miLayer4Click(Sender
: TObject
);
6229 SwitchLayer(LAYER_STEPS
);
6232 procedure TMainForm
.miLayer5Click(Sender
: TObject
);
6234 SwitchLayer(LAYER_WATER
);
6237 procedure TMainForm
.miLayer6Click(Sender
: TObject
);
6239 SwitchLayer(LAYER_ITEMS
);
6242 procedure TMainForm
.miLayer7Click(Sender
: TObject
);
6244 SwitchLayer(LAYER_MONSTERS
);
6247 procedure TMainForm
.miLayer8Click(Sender
: TObject
);
6249 SwitchLayer(LAYER_AREAS
);
6252 procedure TMainForm
.miLayer9Click(Sender
: TObject
);
6254 SwitchLayer(LAYER_TRIGGERS
);
6257 procedure TMainForm
.tbShowClick(Sender
: TObject
);
6263 for a
:= 0 to High(LayerEnabled
) do
6264 b
:= b
and LayerEnabled
[a
];
6268 ShowLayer(LAYER_BACK
, b
);
6269 ShowLayer(LAYER_WALLS
, b
);
6270 ShowLayer(LAYER_FOREGROUND
, b
);
6271 ShowLayer(LAYER_STEPS
, b
);
6272 ShowLayer(LAYER_WATER
, b
);
6273 ShowLayer(LAYER_ITEMS
, b
);
6274 ShowLayer(LAYER_MONSTERS
, b
);
6275 ShowLayer(LAYER_AREAS
, b
);
6276 ShowLayer(LAYER_TRIGGERS
, b
);
6279 procedure TMainForm
.miMiniMapClick(Sender
: TObject
);
6284 procedure TMainForm
.miSwitchGridClick(Sender
: TObject
);
6286 if DotStep
= DotStepOne
then
6287 DotStep
:= DotStepTwo
6289 DotStep
:= DotStepOne
;
6291 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6292 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6295 procedure TMainForm
.miShowEdgesClick(Sender
: TObject
);
6300 procedure TMainForm
.miSnapToGridClick(Sender
: TObject
);
6302 SnapToGrid
:= not SnapToGrid
;
6304 MousePos
.X
:= (MousePos
.X
div DotStep
) * DotStep
;
6305 MousePos
.Y
:= (MousePos
.Y
div DotStep
) * DotStep
;
6307 miSnapToGrid
.Checked
:= SnapToGrid
;
6310 procedure TMainForm
.minexttabClick(Sender
: TObject
);
6312 if pcObjects
.ActivePageIndex
< pcObjects
.PageCount
-1 then
6313 pcObjects
.ActivePageIndex
:= pcObjects
.ActivePageIndex
+1
6315 pcObjects
.ActivePageIndex
:= 0;
6318 procedure TMainForm
.miSaveMiniMapClick(Sender
: TObject
);
6320 SaveMiniMapForm
.ShowModal();
6323 procedure TMainForm
.bClearTextureClick(Sender
: TObject
);
6325 lbTextureList
.ItemIndex
:= -1;
6326 lTextureWidth
.Caption
:= '';
6327 lTextureHeight
.Caption
:= '';
6330 procedure TMainForm
.miPackMapClick(Sender
: TObject
);
6332 PackMapForm
.ShowModal();
6335 procedure TMainForm
.miMapTestSettingsClick(Sender
: TObject
);
6337 MapTestForm
.ShowModal();
6340 procedure TMainForm
.miTestMapClick(Sender
: TObject
);
6342 cmd
, mapWAD
, mapToRun
, tempWAD
: String;
6349 if OpenedMap
<> '' then
6351 // Указываем текущую карту для теста:
6352 g_ProcessResourceStr(OpenedMap
, @mapWAD
, nil, @mapToRun
);
6353 mapToRun
:= mapWAD
+ ':\' + mapToRun
;
6354 mapToRun
:= ExtractRelativePath(ExtractFilePath(TestD2dExe
) + 'maps/', mapToRun
);
6356 // Сохраняем временную карту:
6359 mapWAD
:= ExtractFilePath(TestD2dExe
) + Format('maps/temp%.4d.wad', [time
]);
6361 until not FileExists(mapWAD
);
6362 tempWAD
:= mapWAD
+ ':\' + TEST_MAP_NAME
;
6365 tempWAD
:= ExtractRelativePath(ExtractFilePath(TestD2dExe
) + 'maps/', tempWAD
);
6366 // Если карта не была открыта, указываем временную в качестве текущей:
6367 if mapToRun
= '' then
6368 mapToRun
:= tempWAD
;
6372 if TestOptionsTwoPlayers
then
6374 if TestOptionsTeamDamage
then
6376 if TestOptionsAllowExit
then
6378 if TestOptionsWeaponStay
then
6380 if TestOptionsMonstersDM
then
6383 // Составляем командную строку:
6384 cmd
:= '-map "' + mapToRun
+ '"';
6385 cmd
:= cmd
+ ' -testmap "' + tempWAD
+ '"';
6386 cmd
:= cmd
+ ' -gm ' + TestGameMode
;
6387 cmd
:= cmd
+ ' -limt ' + TestLimTime
;
6388 cmd
:= cmd
+ ' -lims ' + TestLimScore
;
6389 cmd
:= cmd
+ ' -opt ' + IntToStr(opt
);
6392 cmd
:= cmd
+ ' --close';
6394 cmd
:= cmd
+ ' --debug';
6397 proc
:= TProcessUTF8
.Create(nil);
6398 proc
.Executable
:= TestD2dExe
;
6399 proc
.Parameters
.Add(cmd
);
6408 Application
.Minimize();
6411 if (not res
) or (proc
.ExitCode
< 0) then
6413 MessageBox(0, 'FIXME',
6414 PChar(_lc
[I_MSG_EXEC_ERROR
]),
6415 MB_OK
or MB_ICONERROR
);
6419 SysUtils
.DeleteFile(mapWAD
);
6420 Application
.Restore();
6423 procedure TMainForm
.sbVerticalScroll(Sender
: TObject
;
6424 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
6426 MapOffset
.Y
:= -Normalize16(sbVertical
.Position
);
6429 procedure TMainForm
.sbHorizontalScroll(Sender
: TObject
;
6430 ScrollCode
: TScrollCode
; var ScrollPos
: Integer);
6432 MapOffset
.X
:= -Normalize16(sbHorizontal
.Position
);
6435 procedure TMainForm
.miOpenWadMapClick(Sender
: TObject
);
6437 if OpenedWAD
<> '' then
6439 OpenMap(OpenedWAD
, '');
6443 procedure TMainForm
.selectall1Click(Sender
: TObject
);
6447 RemoveSelectFromObjects();
6449 if gPanels
<> nil then
6450 for a
:= 0 to High(gPanels
) do
6451 if gPanels
[a
].PanelType
<> PANEL_NONE
then
6452 SelectObject(OBJECT_PANEL
, a
, True);
6454 if gItems
<> nil then
6455 for a
:= 0 to High(gItems
) do
6456 if gItems
[a
].ItemType
<> ITEM_NONE
then
6457 SelectObject(OBJECT_ITEM
, a
, True);
6459 if gMonsters
<> nil then
6460 for a
:= 0 to High(gMonsters
) do
6461 if gMonsters
[a
].MonsterType
<> MONSTER_NONE
then
6462 SelectObject(OBJECT_MONSTER
, a
, True);
6464 if gAreas
<> nil then
6465 for a
:= 0 to High(gAreas
) do
6466 if gAreas
[a
].AreaType
<> AREA_NONE
then
6467 SelectObject(OBJECT_AREA
, a
, True);
6469 if gTriggers
<> nil then
6470 for a
:= 0 to High(gTriggers
) do
6471 if gTriggers
[a
].TriggerType
<> TRIGGER_NONE
then
6472 SelectObject(OBJECT_TRIGGER
, a
, True);
6475 procedure TMainForm
.Splitter1CanResize(Sender
: TObject
;
6476 var NewSize
: Integer; var Accept
: Boolean);
6478 Accept
:= (NewSize
> 140);
6481 procedure TMainForm
.Splitter2CanResize(Sender
: TObject
;
6482 var NewSize
: Integer; var Accept
: Boolean);
6484 Accept
:= (NewSize
> 110);
6487 procedure TMainForm
.vleObjectPropertyEnter(Sender
: TObject
);
6489 EditingProperties
:= True;
6492 procedure TMainForm
.vleObjectPropertyExit(Sender
: TObject
);
6494 EditingProperties
:= False;
6497 procedure TMainForm
.FormKeyUp(Sender
: TObject
; var Key
: Word;
6498 Shift
: TShiftState
);
6500 // Объекты передвигались:
6501 if MainForm
.ActiveControl
= RenderPanel
then
6503 if (Key
= VK_NUMPAD4
) or
6504 (Key
= VK_NUMPAD6
) or
6505 (Key
= VK_NUMPAD8
) or
6506 (Key
= VK_NUMPAD5
) or
6507 (Key
= Ord('V')) then
6510 // Быстрое превью карты:
6511 if Key
= Ord('E') then
6513 if PreviewMode
= 2 then