Rev 16 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | daniel-mar | 1 | unit DXReg; |
2 | |||
3 | interface |
||
4 | |||
4 | daniel-mar | 5 | {$I DelphiXcfg.inc} |
16 | daniel-mar | 6 | {$WARNINGS OFF} |
1 | daniel-mar | 7 | uses |
8 | Windows, SysUtils, Classes, Forms, Dialogs, Graphics, TypInfo, |
||
4 | daniel-mar | 9 | Controls, StdCtrls, ExtCtrls, Buttons, |
10 | {$IFDEF D3DRM}Colli3DX, {$ENDIF} |
||
11 | {$IFNDEF VER6UP}DsgnIntf, |
||
12 | {$ELSE}Designintf, DesignEditors, VCLEditors, PropertyCategories, |
||
13 | {$ENDIF} |
||
14 | DXDraws, DXSounds, DIB, DXWave, DXInput, DXPlay, DXSprite, DXClass; |
||
1 | daniel-mar | 15 | |
4 | daniel-mar | 16 | type |
1 | daniel-mar | 17 | |
4 | daniel-mar | 18 | { TDXDrawDisplayProperty } |
19 | |||
20 | TDXDrawDisplayProperty = class(TClassProperty) |
||
21 | public |
||
22 | function GetAttributes: TPropertyAttributes; override; |
||
23 | function GetValue: string; override; |
||
24 | procedure GetValues(Proc: TGetStrProc); override; |
||
25 | procedure SetValue(const Value: string); override; |
||
26 | end; |
||
27 | |||
28 | { TDIBProperty } |
||
29 | |||
30 | TDIBProperty = class(TPropertyEditor) |
||
31 | public |
||
32 | procedure Edit; override; |
||
33 | function GetValue: string; override; |
||
34 | function GetAttributes: TPropertyAttributes; override; |
||
35 | end; |
||
36 | |||
37 | { TDXDIBEditor } |
||
38 | |||
39 | TDXDIBEditor = class(TComponentEditor) |
||
40 | public |
||
41 | procedure Edit; override; |
||
42 | procedure ExecuteVerb(Index: Integer); override; |
||
43 | function GetVerb(Index: Integer): string; override; |
||
44 | function GetVerbCount: Integer; override; |
||
45 | end; |
||
46 | |||
47 | { TPictureCollectionItem_PictureProperty } |
||
48 | |||
49 | TPictureCollectionItem_PictureProperty = class(TPropertyEditor) |
||
50 | public |
||
51 | procedure Edit; override; |
||
52 | function GetValue: string; override; |
||
53 | function GetAttributes: TPropertyAttributes; override; |
||
54 | end; |
||
55 | |||
56 | { TDXImageListEditor } |
||
57 | |||
58 | TDXImageListEditor = class(TComponentEditor) |
||
59 | private |
||
60 | procedure ListBox1DblClick(Sender: TObject); |
||
61 | public |
||
62 | procedure ExecuteVerb(Index: Integer); override; |
||
63 | function GetVerb(Index: Integer): string; override; |
||
64 | function GetVerbCount: Integer; override; |
||
65 | end; |
||
66 | |||
67 | { TDXSpriteEngineEditor} |
||
68 | |||
69 | TDXSpriteEngineEditor = class(TComponentEditor) |
||
70 | private |
||
71 | procedure ListBox1DblClick(Sender: TObject); |
||
72 | public |
||
73 | procedure ExecuteVerb(Index: Integer); override; |
||
74 | function GetVerb(Index: Integer): string; override; |
||
75 | function GetVerbCount: Integer; override; |
||
76 | end; |
||
77 | |||
78 | { TWaveProperty } |
||
79 | |||
80 | TWaveProperty = class(TPropertyEditor) |
||
81 | public |
||
82 | procedure Edit; override; |
||
83 | function GetValue: string; override; |
||
84 | function GetAttributes: TPropertyAttributes; override; |
||
85 | end; |
||
86 | |||
87 | { TDXWaveEditor } |
||
88 | |||
89 | TDXWaveEditor = class(TComponentEditor) |
||
90 | public |
||
91 | procedure Edit; override; |
||
92 | procedure ExecuteVerb(Index: Integer); override; |
||
93 | function GetVerb(Index: Integer): string; override; |
||
94 | function GetVerbCount: Integer; override; |
||
95 | end; |
||
96 | |||
97 | { TDXWaveListEditor } |
||
98 | |||
99 | TDXWaveListEditor = class(TComponentEditor) |
||
100 | public |
||
101 | procedure ExecuteVerb(Index: Integer); override; |
||
102 | function GetVerb(Index: Integer): string; override; |
||
103 | function GetVerbCount: Integer; override; |
||
104 | end; |
||
105 | |||
106 | { TForceFeedbackEffectsProperty } |
||
107 | |||
108 | TForceFeedbackEffectsProperty = class(TClassProperty) |
||
109 | public |
||
110 | procedure Edit; override; |
||
111 | function GetValue: string; override; |
||
112 | function GetAttributes: TPropertyAttributes; override; |
||
113 | end; |
||
114 | |||
115 | { TDXInputEditor } |
||
116 | |||
117 | TDXInputEditor = class(TComponentEditor) |
||
118 | public |
||
119 | procedure Edit; override; |
||
120 | procedure ExecuteVerb(Index: Integer); override; |
||
121 | function GetVerb(Index: Integer): string; override; |
||
122 | function GetVerbCount: Integer; override; |
||
123 | end; |
||
124 | |||
125 | { TGUIDProperty } |
||
126 | |||
127 | TGUIDProperty = class(TStringProperty) |
||
128 | public |
||
129 | procedure Edit; override; |
||
130 | function GetAttributes: TPropertyAttributes; override; |
||
131 | end; |
||
132 | |||
133 | { TSpriteProperty } |
||
134 | |||
135 | TSpriteProperty = class(TClassProperty) |
||
136 | public |
||
137 | procedure Edit; override; |
||
138 | function GetValue: string; override; |
||
139 | function GetAttributes: TPropertyAttributes; override; |
||
140 | end; |
||
141 | |||
142 | { TMidiProperty } |
||
143 | |||
144 | TMidiProperty = class(TClassProperty) |
||
145 | public |
||
146 | procedure Edit; override; |
||
147 | function GetValue: string; override; |
||
148 | function GetAttributes: TPropertyAttributes; override; |
||
149 | end; |
||
150 | |||
151 | TMidiEditor = class(TDefaultEditor) |
||
152 | public |
||
153 | {$IFDEF VER6UP} |
||
154 | procedure EditProperty(const Prop: IProperty; var Continue: Boolean); override; |
||
155 | {$ELSE} |
||
156 | procedure EditProperty(PropertyEditor: TPropertyEditor; |
||
157 | var continue, FreeEditor: Boolean); override; |
||
158 | {$ENDIF} |
||
159 | end; |
||
160 | |||
161 | { TDXMidiListEditor } |
||
162 | |||
163 | TDXMidiListEditor = class(TComponentEditor) |
||
164 | public |
||
165 | procedure ExecuteVerb(Index: Integer); override; |
||
166 | function GetVerb(Index: Integer): string; override; |
||
167 | function GetVerbCount: Integer; override; |
||
168 | end; |
||
169 | |||
170 | { Trace editor} |
||
171 | |||
172 | TDXDrawEditor = class(TComponentEditor) |
||
173 | public |
||
174 | procedure ExecuteVerb(Index: Integer); override; |
||
175 | function GetVerb(Index: Integer): string; override; |
||
176 | function GetVerbCount: Integer; override; |
||
177 | end; |
||
178 | |||
1 | daniel-mar | 179 | procedure Register; |
180 | |||
181 | implementation |
||
182 | |||
4 | daniel-mar | 183 | uses DXPictEdit, DXWaveEdit, DXFFBEdit, DXInptEdit, DXGUIDEdit, DXSpriteEdit, |
184 | DXMidiEdit, DXDIBEffectEdit, {$IFDEF VER4UP}DXGlueItEdit,{$ENDIF} DXPathEdit; |
||
1 | daniel-mar | 185 | |
186 | const |
||
187 | SNone = '(None)'; |
||
4 | daniel-mar | 188 | |
1 | daniel-mar | 189 | SSettingImage = '&Image...'; |
190 | SSettingWave = '&Wave...'; |
||
191 | SDXGFileFilter = 'DXG file(*.dxg)|*.dxg|All files(*.*)|*.*'; |
||
192 | SDXGOpenFileFilter = 'DXG file(*.dxg)|*.dxg|Bitmap file(*.bmp)|*.bmp|All files(*.*)|*.*'; |
||
4 | daniel-mar | 193 | SDXWFileFilter = 'DXW file(*.dxw)|*.dxg|All files(*.*)|*.*'; |
1 | daniel-mar | 194 | SDXWOpenFileFilter = 'DXW file(*.dxw)|*.dxw|Wave file(*.wav)|*.wav|All files(*.*)|*.*'; |
4 | daniel-mar | 195 | SDXMFileFilter = 'DXM file(*.dxm)|*.dxm|All files(*.*)|*.*'; |
196 | SDXMOpenFileFilter = 'DXM file(*.dxm)|*.dxm|Midi file(*.mid)|*.mid|All files(*.*)|*.*'; |
||
197 | |||
1 | daniel-mar | 198 | SSinglePlayer = '&Single player'; |
199 | SMultiPlayer1 = 'Multi player &1'; |
||
200 | SMultiPlayer2 = 'Multi player &2'; |
||
201 | |||
202 | SOpen = '&Open...'; |
||
4 | daniel-mar | 203 | SSave = '&Save...'; |
1 | daniel-mar | 204 | |
205 | procedure Register; |
||
206 | begin |
||
4 | daniel-mar | 207 | RegisterPropertyEditor(TypeInfo(TDXDrawDisplay), nil, '', |
208 | TDXDrawDisplayProperty); |
||
209 | |||
210 | RegisterPropertyEditor(TypeInfo(TDIB), nil, '', TDIBProperty); |
||
211 | RegisterComponentEditor(TCustomDXDIB, TDXDIBEditor); |
||
212 | |||
213 | RegisterPropertyEditor(TypeInfo(TPicture), TPictureCollectionItem, 'Picture', TPictureCollectionItem_PictureProperty); |
||
214 | RegisterComponentEditor(TCustomDXImageList, TDXImageListEditor); |
||
215 | |||
216 | RegisterPropertyEditor(TypeInfo(TWave), nil, '', TWaveProperty); |
||
217 | RegisterComponentEditor(TCustomDXWave, TDXWaveEditor); |
||
218 | |||
219 | RegisterComponentEditor(TCustomDXWaveList, TDXWaveListEditor); |
||
220 | |||
221 | RegisterPropertyEditor(TypeInfo(TForceFeedbackEffects), nil, '', TForceFeedbackEffectsProperty); |
||
222 | |||
223 | RegisterComponentEditor(TCustomDXInput, TDXInputEditor); |
||
224 | |||
57 | daniel-mar | 225 | {$IFDEF UseDirectPlay} |
4 | daniel-mar | 226 | RegisterPropertyEditor(TypeInfo(string), TCustomDXPlay, 'GUID', TGUIDProperty); |
57 | daniel-mar | 227 | {$ENDIF} // UseDirectPlay |
4 | daniel-mar | 228 | |
229 | RegisterPropertyEditor(TypeInfo(TImageSprite), NIL, '', TSpriteProperty); |
||
230 | RegisterPropertyEditor(TypeInfo(TImageSpriteEx), NIL, '', TSpriteProperty); |
||
231 | RegisterPropertyEditor(TypeInfo(TSprite), NIL, '', TSpriteProperty); |
||
232 | RegisterPropertyEditor(TypeInfo(TBackgroundSprite), NIL, '', TSpriteProperty); |
||
233 | |||
234 | RegisterPropertyEditor(TypeInfo(TMusicDataProp), nil, 'MIDI', TMidiProperty); |
||
235 | RegisterComponentEditor(TDXMusic, TDXMidiListEditor); |
||
236 | RegisterComponentEditor(TDXSpriteEngine, TDXSpriteEngineEditor); |
||
237 | |||
1 | daniel-mar | 238 | RegisterComponents('DelphiX', |
239 | [TDXDraw, |
||
4 | daniel-mar | 240 | TDXDIB, |
241 | TDXImageList, |
||
242 | {$IFDEF DX3D_deprecated} |
||
243 | TDX3D, |
||
244 | {$ENDIF} |
||
245 | TDXSound, |
||
246 | TDXWave, |
||
247 | TDXWaveList, |
||
248 | TDXInput, |
||
57 | daniel-mar | 249 | {$IFDEF UseDirectPlay} |
4 | daniel-mar | 250 | TDXPlay, |
57 | daniel-mar | 251 | {$ENDIF} // UseDirectPlay |
4 | daniel-mar | 252 | TDXSpriteEngine, |
253 | TDXTimer, |
||
254 | TDXPaintBox, |
||
255 | TDXFont, |
||
256 | TDXPowerFont, |
||
257 | TDXMusic |
||
258 | ]); |
||
259 | RegisterComponentEditor(TCustomDXDraw, TDXDrawEditor); |
||
1 | daniel-mar | 260 | end; |
261 | |||
4 | daniel-mar | 262 | { TDXDrawDisplayProperty } |
1 | daniel-mar | 263 | |
4 | daniel-mar | 264 | function TDXDrawDisplayProperty.GetAttributes: TPropertyAttributes; |
265 | begin |
||
266 | Result := inherited GetAttributes + [paValueList] - [paReadOnly]; |
||
267 | end; |
||
1 | daniel-mar | 268 | |
4 | daniel-mar | 269 | const |
270 | SDisplayMode = '%dx%dx%d'; |
||
271 | |||
272 | function TDXDrawDisplayProperty.GetValue: string; |
||
273 | begin |
||
274 | with TDXDrawDisplay(GetOrdValue) do |
||
275 | Result := Format(SDisplayMode, [Width, Height, BitCount]); |
||
276 | end; |
||
277 | |||
278 | procedure TDXDrawDisplayProperty.GetValues(Proc: TGetStrProc); |
||
279 | const |
||
280 | List: array[0..2] of TPoint = ( |
||
281 | (X: 640; Y: 480), |
||
282 | (X: 800; Y: 600), |
||
283 | (X: 1024; Y: 768)); |
||
284 | var |
||
285 | BitCount, i: Integer; |
||
286 | begin |
||
287 | for i := Low(List) to High(List) do |
||
288 | for BitCount := 1 to 3 do |
||
289 | Proc(Format(SDisplayMode, [List[i].x, List[i].y, BitCount * 8])); |
||
290 | end; |
||
291 | |||
292 | procedure TDXDrawDisplayProperty.SetValue(const Value: string); |
||
293 | var |
||
294 | s: string; |
||
295 | i, AWidth, AHeight, ABitCount: Integer; |
||
296 | begin |
||
297 | s := Value; |
||
298 | |||
299 | i := Pos('x', s); |
||
300 | AWidth := StrToInt(Copy(s, 1, i - 1)); |
||
301 | s := Copy(s, i + 1, Length(s)); |
||
302 | |||
303 | i := Pos('x', s); |
||
304 | AHeight := StrToInt(Copy(s, 1, i - 1)); |
||
305 | s := Copy(s, i + 1, Length(s)); |
||
306 | |||
307 | ABitCount := StrToInt(s); |
||
308 | |||
309 | with TDXDrawDisplay(GetOrdValue) do |
||
310 | begin |
||
311 | Width := AWidth; |
||
312 | Height := AHeight; |
||
313 | BitCount := ABitCount; |
||
314 | end; |
||
315 | |||
316 | SetOrdValue(GetOrdValue); |
||
317 | end; |
||
318 | |||
319 | { TDIBProperty } |
||
320 | |||
321 | procedure TDIBProperty.Edit; |
||
322 | var |
||
323 | Form: TDelphiXPictureEditForm; |
||
324 | begin |
||
325 | Form := TDelphiXPictureEditForm.Create(nil); |
||
326 | try |
||
327 | Form.ViewBox.Picture.Assign(TDIB(GetOrdValue)); |
||
328 | Form.DIBClassOnly := True; |
||
329 | Form.ShowModal; |
||
330 | if Form.Tag <> 0 then |
||
331 | begin |
||
332 | SetOrdValue(Integer(Form.ViewBox.Picture.Graphic)); |
||
333 | Designer.Modified; |
||
334 | end; |
||
335 | finally |
||
336 | Form.Free; |
||
337 | end; |
||
338 | end; |
||
339 | |||
340 | function TDIBProperty.GetAttributes: TPropertyAttributes; |
||
341 | begin |
||
342 | Result := [paDialog, paReadOnly]; |
||
343 | end; |
||
344 | |||
345 | function TDIBProperty.GetValue: string; |
||
346 | begin |
||
347 | if TDIB(GetOrdValue).Size = 0 then |
||
348 | Result := SNone |
||
349 | else |
||
350 | Result := Format('(%s)', [TObject(GetOrdValue).ClassName]); |
||
351 | end; |
||
352 | |||
353 | { TDXDIBEditor } |
||
354 | |||
355 | procedure TDXDIBEditor.Edit; |
||
356 | var |
||
357 | Form: TDelphiXPictureEditForm; |
||
358 | begin |
||
359 | Form := TDelphiXPictureEditForm.Create(nil); |
||
360 | try |
||
361 | Form.ViewBox.Picture.Assign(TCustomDXDIB(Component).DIB); |
||
362 | Form.DIBClassOnly := True; |
||
363 | Form.ShowModal; |
||
364 | if Form.Tag <> 0 then |
||
365 | begin |
||
366 | TCustomDXDIB(Component).DIB.Assign(TGraphic(Form.ViewBox.Picture.Graphic)); |
||
367 | Designer.Modified; |
||
368 | end; |
||
369 | finally |
||
370 | Form.Free; |
||
371 | end; |
||
372 | end; |
||
373 | |||
374 | procedure TDXDIBEditor.ExecuteVerb(Index: Integer); |
||
375 | begin |
||
376 | case Index of |
||
377 | 0: Edit; |
||
378 | end; |
||
379 | end; |
||
380 | |||
381 | function TDXDIBEditor.GetVerb(Index: Integer): string; |
||
382 | begin |
||
383 | case Index of |
||
384 | 0: Result := SSettingImage; |
||
385 | end; |
||
386 | end; |
||
387 | |||
388 | function TDXDIBEditor.GetVerbCount: Integer; |
||
389 | begin |
||
390 | Result := 1; |
||
391 | end; |
||
392 | |||
393 | { TPictureCollectionItem_PictureProperty } |
||
394 | |||
395 | procedure TPictureCollectionItem_PictureProperty.Edit; |
||
396 | var |
||
397 | Form: TDelphiXPictureEditForm; |
||
398 | Item: TPictureCollectionItem; |
||
399 | TempDIB: TDIB; |
||
400 | begin |
||
401 | Form := TDelphiXPictureEditForm.Create(nil); |
||
402 | try |
||
403 | Form.ViewBox.Picture := TPicture(GetOrdValue); |
||
404 | Form.ShowModal; |
||
405 | if Form.Tag <> 0 then |
||
406 | begin |
||
407 | SetOrdValue(Integer(Form.ViewBox.Picture)); |
||
408 | |||
409 | Item := GetComponent(0) as TPictureCollectionItem; |
||
410 | if Item.Picture.Graphic <> nil then |
||
411 | begin |
||
412 | TempDIB := TDIB.Create; |
||
413 | try |
||
414 | TempDIB.SetSize(1, 1, 24); |
||
415 | TempDIB.Canvas.Draw(0, 0, Item.Picture.Graphic); |
||
416 | Item.TransparentColor := TempDIB.Pixels[0, 0]; |
||
417 | finally |
||
418 | TempDIB.Free; |
||
419 | end; |
||
420 | end; |
||
421 | Designer.Modified; |
||
422 | end; |
||
423 | finally |
||
424 | Form.Free; |
||
425 | end; |
||
426 | end; |
||
427 | |||
428 | function TPictureCollectionItem_PictureProperty.GetAttributes: TPropertyAttributes; |
||
429 | begin |
||
430 | Result := [paDialog, paReadOnly]; |
||
431 | end; |
||
432 | |||
433 | function TPictureCollectionItem_PictureProperty.GetValue: string; |
||
434 | begin |
||
435 | if (TPicture(GetOrdValue).Graphic = nil) or (TPicture(GetOrdValue).Graphic.Empty) then |
||
436 | Result := SNone |
||
437 | else |
||
438 | Result := Format('(%s)', [TPicture(GetOrdValue).Graphic.ClassName]); |
||
439 | end; |
||
440 | |||
441 | { dialog } |
||
442 | function CreateListBox(DblClck: TNotifyEvent; out lstbx: TListBox): TForm; |
||
443 | var |
||
444 | Panel1: TPanel; |
||
445 | Panel2: TPanel; |
||
446 | BitBtn1: TBitBtn; |
||
447 | BitBtn2: TBitBtn; |
||
448 | begin |
||
449 | Result := TForm.Create(nil); |
||
450 | Panel1 := TPanel.Create(Result); |
||
451 | lstbx := TListBox.Create(Result); |
||
452 | Panel2 := TPanel.Create(Result); |
||
453 | BitBtn1 := TBitBtn.Create(Result); |
||
454 | BitBtn2 := TBitBtn.Create(Result); |
||
455 | with Result do |
||
456 | begin |
||
457 | Name := 'Form12'; |
||
458 | Left := 0; |
||
459 | Top := 0; |
||
460 | BorderStyle := bsDialog; |
||
461 | Caption := 'Select Item'; |
||
462 | ClientHeight := 206; |
||
463 | ClientWidth := 228; |
||
464 | Color := clBtnFace; |
||
465 | Font.Charset := DEFAULT_CHARSET; |
||
466 | Font.Color := clWindowText; |
||
467 | Font.Height := -11; |
||
468 | Font.Name := 'Tahoma'; |
||
469 | Font.Style := []; |
||
470 | Position := poScreenCenter; |
||
471 | PixelsPerInch := 96; |
||
472 | end; |
||
473 | with Panel1 do |
||
474 | begin |
||
475 | Name := 'Panel1'; |
||
476 | Parent := Result; |
||
477 | Left := 0; |
||
478 | Top := 0; |
||
479 | Width := 228; |
||
480 | Height := 165; |
||
481 | Align := alClient; |
||
482 | BevelOuter := bvNone; |
||
483 | BorderWidth := 4; |
||
484 | Caption := ''; |
||
485 | TabOrder := 0; |
||
486 | end; |
||
487 | with lstbx do |
||
488 | begin |
||
489 | Name := 'ListBox1'; |
||
490 | Parent := Panel1; |
||
491 | Left := 4; |
||
492 | Top := 4; |
||
493 | Width := 220; |
||
494 | Height := 157; |
||
495 | Align := alClient; |
||
496 | ItemHeight := 13; |
||
497 | TabOrder := 0; |
||
498 | OnDblClick := DblClck; |
||
499 | end; |
||
500 | with Panel2 do |
||
501 | begin |
||
502 | Name := 'Panel2'; |
||
503 | Parent := Result; |
||
504 | Left := 0; |
||
505 | Top := 165; |
||
506 | Width := 228; |
||
507 | Height := 41; |
||
508 | Align := alBottom; |
||
509 | BevelOuter := bvNone; |
||
510 | Caption := ''; |
||
511 | TabOrder := 1; |
||
512 | end; |
||
513 | with BitBtn1 do |
||
514 | begin |
||
515 | Name := 'BitBtn1'; |
||
516 | Parent := Panel2; |
||
517 | Left := 24; |
||
518 | Top := 8; |
||
519 | Width := 75; |
||
520 | Height := 25; |
||
521 | TabOrder := 0; |
||
522 | Kind := bkOK; |
||
523 | end; |
||
524 | with BitBtn2 do |
||
525 | begin |
||
526 | Name := 'BitBtn2'; |
||
527 | Parent := Panel2; |
||
528 | Left := 128; |
||
529 | Top := 8; |
||
530 | Width := 75; |
||
531 | Height := 25; |
||
532 | TabOrder := 1; |
||
533 | Kind := bkCancel; |
||
534 | end; |
||
535 | end; |
||
536 | function Alter(const str, altstr: string): string; |
||
537 | begin |
||
538 | if str = '' then Result := altstr |
||
539 | else Result := str; |
||
540 | end; |
||
541 | |||
542 | { TDXImageListEditor } |
||
543 | |||
544 | procedure TDXImageListEditor.ExecuteVerb(Index: Integer); |
||
545 | var |
||
546 | OpenDialog: TOpenDialog; |
||
547 | SaveDialog: TSaveDialog; |
||
548 | DelphiXDIBEffectEditForm: TTDelphiXDIBEffectEditForm; |
||
549 | {$IFDEF VER4UP} |
||
550 | DXGlueItEditForm: TDXGlueItEditor; |
||
551 | {$ENDIF} |
||
552 | Q: TPictureCollectionItem; |
||
553 | I, N: Integer; |
||
554 | S, Z: string; |
||
555 | {$IFDEF VER4UP} |
||
556 | QQ: TCustomDXImageList; |
||
557 | FrmListBox: TForm; |
||
558 | ListBox1: TListBox; |
||
559 | {$ENDIF} |
||
560 | begin |
||
561 | case Index of |
||
562 | 0: begin |
||
563 | OpenDialog := TOpenDialog.Create(nil); |
||
564 | try |
||
565 | OpenDialog.DefaultExt := 'dxg'; |
||
566 | OpenDialog.Filter := SDXGOpenFileFilter; |
||
567 | OpenDialog.Options := [ofPathMustExist, ofFileMustExist, ofAllowMultiSelect]; |
||
568 | if OpenDialog.Execute then |
||
569 | begin |
||
570 | if OpenDialog.FilterIndex = 2 then |
||
571 | begin |
||
572 | for i := 0 to OpenDialog.Files.Count - 1 do |
||
573 | with TPictureCollectionItem.Create(TCustomDXImageList(Component).Items) do |
||
574 | begin |
||
575 | try |
||
576 | Picture.LoadFromFile(OpenDialog.Files[i]); |
||
577 | Name := ExtractFileName(OpenDialog.Files[i]); |
||
578 | except |
||
579 | Free; |
||
580 | raise; |
||
581 | end; |
||
582 | end; |
||
583 | end else |
||
584 | TCustomDXImageList(Component).Items.LoadFromFile(OpenDialog.FileName); |
||
585 | Designer.Modified; |
||
586 | end; |
||
587 | finally |
||
588 | OpenDialog.Free; |
||
589 | end; |
||
590 | end; |
||
591 | 1: begin |
||
592 | SaveDialog := TSaveDialog.Create(nil); |
||
593 | try |
||
594 | SaveDialog.DefaultExt := 'dxg'; |
||
595 | SaveDialog.Filter := SDXGFileFilter; |
||
596 | SaveDialog.Options := [ofOverwritePrompt, ofPathMustExist]; |
||
597 | if SaveDialog.Execute then |
||
598 | TCustomDXImageList(Component).Items.SaveToFile(SaveDialog.FileName); |
||
599 | finally |
||
600 | SaveDialog.Free; |
||
601 | end; |
||
602 | end; |
||
603 | 2: |
||
604 | begin {Create shine effect...} |
||
605 | {special effect} |
||
606 | DelphiXDIBEffectEditForm := TTDelphiXDIBEffectEditForm.Create(nil); |
||
607 | try |
||
608 | DelphiXDIBEffectEditForm.ShowModal; |
||
609 | if DelphiXDIBEffectEditForm.Tag = 1 then begin |
||
610 | {check all names in list of images} |
||
611 | N := 0; |
||
612 | Z := DelphiXDIBEffectEditForm.eName.Text; S := Z; |
||
613 | I := TCustomDXImageList(Component).Items.IndexOf(Z); |
||
614 | {hleda jmeno} |
||
615 | while I <> -1 do begin |
||
616 | S := Format('%s_%d', [Z, N]); {new name} |
||
617 | I := TCustomDXImageList(Component).Items.IndexOf(S); |
||
618 | Inc(N); |
||
619 | end; |
||
620 | {add item} |
||
621 | Q := TPictureCollectionItem(TCustomDXImageList(Component).Items.Add); |
||
622 | Q.Picture.Assign(DelphiXDIBEffectEditForm.ResultDIB); |
||
623 | Q.Name := S; {it has to name!} |
||
624 | Q.Transparent := False; {transparend will be set in future} |
||
625 | Designer.Modified; |
||
626 | end; |
||
627 | finally |
||
628 | DelphiXDIBEffectEditForm.Free; |
||
629 | end; |
||
630 | end; |
||
631 | {$IFDEF VER4UP} |
||
632 | 3: {Glue-it editor} |
||
633 | begin |
||
634 | DXGlueItEditForm := TDXGlueItEditor.Create(nil); |
||
635 | try |
||
636 | QQ := TCustomDXImageList(Component); Q := nil; |
||
637 | |||
638 | if QQ.Items.Count > 0 then begin |
||
639 | FrmListBox := CreateListBox(ListBox1DblClick, ListBox1); |
||
640 | try |
||
641 | for I := 0 to QQ.Items.Count - 1 do begin |
||
642 | S := QQ.Items[I].Name; |
||
643 | ListBox1.Items.Add(Alter(S, '(unnamed).' + IntToStr(I))); |
||
644 | end; |
||
645 | |||
646 | case FrmListBox.ShowModal of |
||
647 | mrOk: //when select one |
||
648 | begin |
||
649 | //when image selected |
||
650 | if ListBox1.ItemIndex <> -1 then begin |
||
651 | Q := QQ.Items[ListBox1.ItemIndex]; |
||
652 | //load one image into editor |
||
653 | DXGlueItEditForm.LoadImageFromList(Q.Name, Q.Picture, Q.Width, |
||
654 | Q.Height, Q.Transparent, Q.TransparentColor); |
||
655 | //image loadet, noe se up edit mode |
||
656 | DXGlueItEditForm.Operation := ogiEdit; |
||
657 | end; |
||
658 | end; |
||
659 | mrCancel: DXGlueItEditForm.Operation := ogiNew; |
||
660 | else |
||
661 | Exit |
||
662 | end {case}; |
||
663 | finally |
||
664 | FrmListBox.Free; |
||
665 | end; |
||
666 | end |
||
667 | else |
||
668 | DXGlueItEditForm.Operation := ogiNew; |
||
669 | DXGlueItEditForm.ShowModal; |
||
670 | if DXGlueItEditForm.Tag = 1 then begin |
||
671 | //when image as new. it has to create new item |
||
672 | if DXGlueItEditForm.Operation = ogiNew then |
||
673 | Q := TPictureCollectionItem(TCustomDXImageList(Component).Items.Add); |
||
674 | //and store edited image into |
||
675 | if Assigned(Q) then |
||
676 | DXGlueItEditForm.SaveImageIntoList(Q); |
||
677 | //signal to designer that anything was changed; |
||
678 | Designer.Modified; |
||
679 | end; |
||
680 | finally |
||
681 | DXGlueItEditForm.Free; |
||
682 | end; |
||
683 | end; |
||
684 | {$ENDIF} |
||
685 | end; |
||
686 | end; |
||
687 | |||
688 | function TDXImageListEditor.GetVerb(Index: Integer): string; |
||
689 | begin |
||
690 | case Index of |
||
691 | 0: Result := SOpen; |
||
692 | 1: Result := SSave; |
||
693 | 2: Result := 'Shine effect...'; |
||
694 | {$IFDEF VER4UP} |
||
695 | //fix bug by Pásztor Károly [fenistil@hu.hu] |
||
696 | 3: Result := 'Glue it...'; |
||
697 | {$ENDIF} |
||
698 | end; |
||
699 | end; |
||
700 | |||
701 | function TDXImageListEditor.GetVerbCount: Integer; |
||
702 | begin |
||
703 | Result := {$IFDEF VER4UP}4{$ELSE}3{$ENDIF}; |
||
704 | end; |
||
705 | |||
706 | procedure TDXImageListEditor.ListBox1DblClick(Sender: TObject); |
||
707 | begin |
||
708 | if Sender is TListBox then with (Sender as TListBox) do |
||
709 | if ItemIndex <> -1 then |
||
710 | (Owner as TForm).ModalResult := mrOk; |
||
711 | end; |
||
712 | |||
713 | { TWaveProperty } |
||
714 | |||
715 | procedure TWaveProperty.Edit; |
||
716 | var |
||
717 | Form: TDelphiXWaveEditForm; |
||
718 | begin |
||
719 | Form := TDelphiXWaveEditForm.Create(nil); |
||
720 | try |
||
721 | Form.Wave := TWave(GetOrdValue); |
||
722 | Form.ShowModal; |
||
723 | if Form.Tag <> 0 then |
||
724 | begin |
||
725 | SetOrdValue(Integer(Form.Wave)); |
||
726 | Designer.Modified; |
||
727 | end; |
||
728 | finally |
||
729 | Form.Free; |
||
730 | end; |
||
731 | end; |
||
732 | |||
733 | function TWaveProperty.GetAttributes: TPropertyAttributes; |
||
734 | begin |
||
735 | Result := [paDialog, paReadOnly]; |
||
736 | end; |
||
737 | |||
738 | function TWaveProperty.GetValue: string; |
||
739 | begin |
||
740 | if TWave(GetOrdValue).Size = 0 then |
||
741 | Result := SNone |
||
742 | else |
||
743 | Result := Format('(%s)', [TObject(GetOrdValue).ClassName]); |
||
744 | end; |
||
745 | |||
746 | { TDXWaveEditor } |
||
747 | |||
748 | procedure TDXWaveEditor.Edit; |
||
749 | var |
||
750 | Form: TDelphiXWaveEditForm; |
||
751 | begin |
||
752 | Form := TDelphiXWaveEditForm.Create(nil); |
||
753 | try |
||
754 | Form.Wave := TCustomDXWave(Component).Wave; |
||
755 | Form.ShowModal; |
||
756 | if Form.Tag <> 0 then |
||
757 | begin |
||
758 | TCustomDXWave(Component).Wave := Form.Wave; |
||
759 | Designer.Modified; |
||
760 | end; |
||
761 | finally |
||
762 | Form.Free; |
||
763 | end; |
||
764 | end; |
||
765 | |||
766 | procedure TDXWaveEditor.ExecuteVerb(Index: Integer); |
||
767 | begin |
||
768 | case Index of |
||
769 | 0: Edit; |
||
770 | end; |
||
771 | end; |
||
772 | |||
773 | function TDXWaveEditor.GetVerb(Index: Integer): string; |
||
774 | begin |
||
775 | case Index of |
||
776 | 0: Result := SSettingWave; |
||
777 | end; |
||
778 | end; |
||
779 | |||
780 | function TDXWaveEditor.GetVerbCount: Integer; |
||
781 | begin |
||
782 | Result := 1; |
||
783 | end; |
||
784 | |||
785 | { TDXWaveListEditor } |
||
786 | |||
787 | procedure TDXWaveListEditor.ExecuteVerb(Index: Integer); |
||
788 | var |
||
789 | OpenDialog: TOpenDialog; |
||
790 | SaveDialog: TSaveDialog; |
||
791 | i: Integer; |
||
792 | begin |
||
793 | case Index of |
||
794 | 0: begin |
||
795 | OpenDialog := TOpenDialog.Create(nil); |
||
796 | try |
||
797 | OpenDialog.DefaultExt := 'dxw'; |
||
798 | OpenDialog.Filter := SDXWOpenFileFilter; |
||
799 | OpenDialog.Options := [ofPathMustExist, ofFileMustExist, ofAllowMultiSelect]; |
||
800 | if OpenDialog.Execute then |
||
801 | begin |
||
802 | if OpenDialog.FilterIndex = 2 then |
||
803 | begin |
||
804 | for i := 0 to OpenDialog.Files.Count - 1 do |
||
805 | with TWaveCollectionItem.Create(TCustomDXWaveList(Component).Items) do |
||
806 | begin |
||
807 | try |
||
808 | Wave.LoadFromFile(OpenDialog.Files[i]); |
||
809 | Name := ExtractFileName(OpenDialog.Files[i]); |
||
810 | except |
||
811 | Free; |
||
812 | raise; |
||
813 | end; |
||
814 | end; |
||
815 | end else |
||
816 | TCustomDXWaveList(Component).Items.LoadFromFile(OpenDialog.FileName); |
||
817 | Designer.Modified; |
||
818 | end; |
||
819 | finally |
||
820 | OpenDialog.Free; |
||
821 | end; |
||
822 | end; |
||
823 | 1: begin |
||
824 | SaveDialog := TSaveDialog.Create(nil); |
||
825 | try |
||
826 | SaveDialog.DefaultExt := 'dxw'; |
||
827 | SaveDialog.Filter := SDXWFileFilter; |
||
828 | SaveDialog.Options := [ofOverwritePrompt, ofPathMustExist]; |
||
829 | if SaveDialog.Execute then |
||
830 | TCustomDXWaveList(Component).Items.SaveToFile(SaveDialog.FileName); |
||
831 | finally |
||
832 | SaveDialog.Free; |
||
833 | end; |
||
834 | end; |
||
835 | end; |
||
836 | end; |
||
837 | |||
838 | function TDXWaveListEditor.GetVerb(Index: Integer): string; |
||
839 | begin |
||
840 | case Index of |
||
841 | 0: Result := SOpen; |
||
842 | 1: Result := SSave; |
||
843 | end; |
||
844 | end; |
||
845 | |||
846 | function TDXWaveListEditor.GetVerbCount: Integer; |
||
847 | begin |
||
848 | Result := 2; |
||
849 | end; |
||
850 | |||
851 | { TForceFeedbackEffectsProperty } |
||
852 | |||
853 | procedure TForceFeedbackEffectsProperty.Edit; |
||
854 | var |
||
855 | Form: TDelphiXFFEditForm; |
||
856 | Effects: TForceFeedbackEffects; |
||
857 | begin |
||
858 | Effects := TForceFeedbackEffects(GetOrdValue); |
||
859 | |||
860 | Form := TDelphiXFFEditForm.Create(nil); |
||
861 | try |
||
862 | if Effects.Input is TJoystick then |
||
863 | Form.Effects := Form.DXInput.Joystick.Effects |
||
864 | else if Effects.Input is TKeyboard then |
||
865 | Form.Effects := Form.DXInput.Keyboard.Effects |
||
866 | else if Effects.Input is TMouse then |
||
867 | Form.Effects := Form.DXInput.Mouse.Effects |
||
868 | else Exit; |
||
869 | |||
870 | Form.Effects.Assign(TForceFeedbackEffects(GetOrdValue)); |
||
871 | Form.ShowModal; |
||
872 | if Form.Tag <> 0 then |
||
873 | begin |
||
874 | SetOrdValue(Integer(Form.Effects)); |
||
875 | Designer.Modified; |
||
876 | end; |
||
877 | finally |
||
878 | Form.Free; |
||
879 | end; |
||
880 | end; |
||
881 | |||
882 | function TForceFeedbackEffectsProperty.GetAttributes: TPropertyAttributes; |
||
883 | begin |
||
884 | Result := [paDialog, paReadOnly]; |
||
885 | end; |
||
886 | |||
887 | function TForceFeedbackEffectsProperty.GetValue: string; |
||
888 | begin |
||
889 | if TForceFeedbackEffects(GetOrdValue).Count = 0 then |
||
890 | Result := SNone |
||
891 | else |
||
892 | Result := Format('(%s)', [TObject(GetOrdValue).ClassName]); |
||
893 | end; |
||
894 | |||
895 | { TDXInputEditor } |
||
896 | |||
897 | procedure TDXInputEditor.Edit; |
||
898 | var |
||
899 | Form: TDelphiXInputEditForm; |
||
900 | begin |
||
901 | Form := TDelphiXInputEditForm.Create(nil); |
||
902 | try |
||
903 | Form.DXInput := TCustomDXInput(Component); |
||
904 | Form.ShowModal; |
||
905 | if Form.Tag <> 0 then |
||
906 | Designer.Modified; |
||
907 | finally |
||
908 | Form.Free; |
||
909 | end; |
||
910 | end; |
||
911 | |||
912 | procedure TDXInputEditor.ExecuteVerb(Index: Integer); |
||
913 | begin |
||
914 | case Index of |
||
915 | 0: begin |
||
916 | with TCustomDXInput(Component) do |
||
917 | begin |
||
918 | Joystick.ID := 0; |
||
919 | Keyboard.KeyAssigns := DefKeyAssign; |
||
920 | end; |
||
921 | Designer.Modified; |
||
922 | end; |
||
923 | 1: begin |
||
924 | with TCustomDXInput(Component) do |
||
925 | begin |
||
926 | Joystick.ID := 0; |
||
927 | Keyboard.KeyAssigns := DefKeyAssign2_1; |
||
928 | end; |
||
929 | Designer.Modified; |
||
930 | end; |
||
931 | 2: begin |
||
932 | with TCustomDXInput(Component) do |
||
933 | begin |
||
934 | Joystick.ID := 1; |
||
935 | Keyboard.KeyAssigns := DefKeyAssign2_2; |
||
936 | end; |
||
937 | Designer.Modified; |
||
938 | end; |
||
939 | end; |
||
940 | end; |
||
941 | |||
942 | function TDXInputEditor.GetVerb(Index: Integer): string; |
||
943 | begin |
||
944 | case Index of |
||
945 | 0: Result := SSinglePlayer; |
||
946 | 1: Result := SMultiPlayer1; |
||
947 | 2: Result := SMultiPlayer2; |
||
948 | end; |
||
949 | end; |
||
950 | |||
951 | function TDXInputEditor.GetVerbCount: Integer; |
||
952 | begin |
||
953 | Result := 3; |
||
954 | end; |
||
955 | |||
956 | { TGUIDProperty } |
||
957 | |||
958 | procedure TGUIDProperty.Edit; |
||
959 | var |
||
960 | Form: TDelphiXGUIDEditForm; |
||
961 | begin |
||
962 | Form := TDelphiXGUIDEditForm.Create(nil); |
||
963 | try |
||
964 | Form.GUID := GetStrValue; |
||
965 | Form.ShowModal; |
||
966 | if Form.Tag <> 0 then |
||
967 | begin |
||
968 | SetStrValue(Form.GUID); |
||
969 | Designer.Modified; |
||
970 | end; |
||
971 | finally |
||
972 | Form.Free; |
||
973 | end; |
||
974 | end; |
||
975 | |||
976 | function TGUIDProperty.GetAttributes: TPropertyAttributes; |
||
977 | begin |
||
978 | Result := inherited GetAttributes + [paDialog]; |
||
979 | end; |
||
980 | |||
981 | { TSpriteProperty } |
||
982 | |||
983 | procedure TSpriteProperty.Edit; |
||
984 | var |
||
985 | DirectAccessToSprite: TSprite; |
||
986 | Form: TDelphiXSpriteEditForm; |
||
987 | //FormDesigner: IDesigner; |
||
988 | begin |
||
989 | DirectAccessToSprite := TSprite(GetOrdValue); |
||
990 | //FormDesigner := Designer; |
||
991 | Form := TDelphiXSpriteEditForm.Create(nil); |
||
992 | {FormDesigner.GetComponentNames(GetTypeData(GetPropType), Proc);} |
||
993 | try |
||
994 | Form.LoadDataToForm(DirectAccessToSprite); |
||
995 | //Form.Sprite.AsSign(TPersistent(GetOrdValue)); |
||
996 | Form.ShowModal; |
||
997 | if Form.Tag <> 0 then |
||
998 | begin |
||
999 | DirectAccessToSprite := TSprite(Form.SaveDataFromForm); |
||
1000 | SetOrdValue(Integer(DirectAccessToSprite)); |
||
1001 | Designer.Modified; |
||
1002 | end; |
||
1003 | finally |
||
1004 | Form.Free; |
||
1005 | end; |
||
1006 | end; |
||
1007 | |||
1008 | function TSpriteProperty.GetAttributes: TPropertyAttributes; |
||
1009 | begin |
||
1010 | Result := [paDialog]; |
||
1011 | end; |
||
1012 | |||
1013 | function TSpriteProperty.GetValue: string; |
||
1014 | begin |
||
1015 | Result := Format('(%s)', [TObject(GetOrdValue).ClassName]); |
||
1016 | end; |
||
1017 | |||
1018 | { TMidiProperty } |
||
1019 | |||
1020 | procedure TMidiProperty.Edit; |
||
1021 | var |
||
1022 | DelphiXMidiEditForm: TDelphiXMidiEditForm; |
||
1023 | DirectAccessToMidiData: TMusicDataProp; |
||
1024 | S: string; I: Integer; |
||
1025 | begin |
||
1026 | DirectAccessToMidiData := TMusicDataProp(GetOrdValue); |
||
1027 | DelphiXMidiEditForm := TDelphiXMidiEditForm.Create(nil); |
||
1028 | try |
||
1029 | DelphiXMidiEditForm.MidiData := DirectAccessToMidiData.MusicData; |
||
1030 | DelphiXMidiEditForm.MidiFileName := DirectAccessToMidiData.MidiName; |
||
1031 | DelphiXMidiEditForm.Showmodal; |
||
1032 | if DelphiXMidiEditForm.Tag = 1 then begin |
||
1033 | DirectAccessToMidiData.MusicData := DelphiXMidiEditForm.MidiData; |
||
1034 | S := ''; |
||
1035 | if DelphiXMidiEditForm.MidiFileName <> '' then begin |
||
1036 | S := ExtractFileName(DelphiXMidiEditForm.MidiFileName); |
||
1037 | I := Pos(ExtractFileExt(S), S); |
||
1038 | if I > 0 then S := Copy(S, 1, I - 1); |
||
1039 | end; |
||
1040 | DirectAccessToMidiData.MidiName := S; |
||
1041 | Designer.Modified; |
||
1042 | end; |
||
1043 | finally |
||
1044 | DelphiXMidiEditForm.Free; |
||
1045 | end; |
||
1046 | end; |
||
1047 | |||
1048 | function TMidiProperty.GetAttributes: TPropertyAttributes; |
||
1049 | begin |
||
1050 | Result := [paDialog]; |
||
1051 | end; |
||
1052 | |||
1053 | function TMidiProperty.GetValue: string; |
||
1054 | var |
||
1055 | S: string; |
||
1056 | begin |
||
1057 | S := TMusicDataProp(GetOrdValue).MusicData; |
||
1058 | if Length(S) = 0 then |
||
1059 | Result := SNone |
||
1060 | else |
||
1061 | Result := '(Midi)'; |
||
1062 | end; |
||
1063 | |||
1064 | {$IFDEF VER6UP} |
||
1065 | procedure TMidiEditor.EditProperty(const Prop: IProperty; var Continue: Boolean); |
||
1066 | {$ELSE} |
||
1067 | procedure TMidiEditor.EditProperty(PropertyEditor: TPropertyEditor; |
||
1068 | var continue, FreeEditor: Boolean); |
||
1069 | {$ENDIF} |
||
1070 | var |
||
1071 | PropName: string; |
||
1072 | begin |
||
1073 | PropName := {$IFDEF VER6UP}Prop{$ELSE}PropertyEditor{$ENDIF}.GetName; |
||
1074 | if (CompareText(PropName, 'Midi') = 0) then |
||
1075 | begin |
||
1076 | {$IFDEF VER6UP}Prop{$ELSE}PropertyEditor{$ENDIF}.edit; |
||
1077 | continue := false; |
||
1078 | end; |
||
1079 | end; |
||
1080 | |||
1081 | { TDXMidiListEditor } |
||
1082 | |||
1083 | procedure TDXMidiListEditor.ExecuteVerb(Index: Integer); |
||
1084 | var |
||
1085 | OpenDialog: TOpenDialog; |
||
1086 | SaveDialog: TSaveDialog; |
||
1087 | i: Integer; |
||
1088 | begin |
||
1089 | case Index of |
||
1090 | 0: begin |
||
1091 | OpenDialog := TOpenDialog.Create(nil); |
||
1092 | try |
||
1093 | OpenDialog.DefaultExt := 'dxm'; |
||
1094 | OpenDialog.Filter := SDXMOpenFileFilter; |
||
1095 | OpenDialog.Options := [ofPathMustExist, ofFileMustExist, ofAllowMultiSelect]; |
||
1096 | if OpenDialog.Execute then |
||
1097 | begin |
||
1098 | if OpenDialog.FilterIndex = 2 then |
||
1099 | begin |
||
1100 | for i := 0 to OpenDialog.Files.Count - 1 do |
||
1101 | with TMusicListCollectionItem.Create(TDXMusic(Component).Midis) do |
||
1102 | begin |
||
1103 | try |
||
1104 | LoadFromFile(OpenDialog.Files[i]); |
||
1105 | Name := ExtractFileName(OpenDialog.Files[i]); |
||
1106 | except |
||
1107 | Free; |
||
1108 | raise; |
||
1109 | end; |
||
1110 | end; |
||
1111 | end |
||
1112 | else |
||
1113 | TDXMusic(Component).Midis.LoadFromFile(OpenDialog.FileName); |
||
1114 | Designer.Modified; |
||
1115 | end; |
||
1116 | finally |
||
1117 | OpenDialog.Free; |
||
1118 | end; |
||
1119 | end; |
||
1120 | 1: begin |
||
1121 | SaveDialog := TSaveDialog.Create(nil); |
||
1122 | try |
||
1123 | SaveDialog.DefaultExt := 'dxm'; |
||
1124 | SaveDialog.Filter := SDXMFileFilter; |
||
1125 | SaveDialog.Options := [ofOverwritePrompt, ofPathMustExist]; |
||
1126 | if SaveDialog.Execute then |
||
1127 | TCustomDXWaveList(Component).Items.SaveToFile(SaveDialog.FileName); |
||
1128 | finally |
||
1129 | SaveDialog.Free; |
||
1130 | end; |
||
1131 | end; |
||
1132 | end; |
||
1133 | end; |
||
1134 | |||
1135 | function TDXMidiListEditor.GetVerbCount: Integer; |
||
1136 | begin |
||
1137 | Result := 2; |
||
1138 | end; |
||
1139 | |||
1140 | function TDXMidiListEditor.GetVerb(Index: Integer): string; |
||
1141 | begin |
||
1142 | case Index of |
||
1143 | 0: Result := SOpen; |
||
1144 | 1: Result := SSave; |
||
1145 | end; |
||
1146 | end; |
||
1147 | |||
1148 | { TDXSpriteEngineEditor } |
||
1149 | |||
1150 | procedure TDXSpriteEngineEditor.ListBox1DblClick(Sender: TObject); |
||
1151 | begin |
||
1152 | if Sender is TListBox then with (Sender as TListBox) do |
||
1153 | if ItemIndex <> -1 then |
||
1154 | (Owner as TForm).ModalResult := mrOk; |
||
1155 | end; |
||
1156 | |||
1157 | procedure TDXSpriteEngineEditor.ExecuteVerb(Index: Integer); |
||
1158 | var |
||
1159 | FrmListBox: TForm; |
||
1160 | ListBox1: TListBox; |
||
1161 | DelphiXSpriteEditForm: TDelphiXSpriteEditForm; |
||
1162 | ASprite: TSprite; |
||
1163 | I, Z: Integer; |
||
1164 | S: string; |
||
1165 | Q: TCustomDXSpriteEngine; |
||
1166 | begin |
||
1167 | case Index of |
||
1168 | 0: begin |
||
1169 | FrmListBox := nil; |
||
1170 | Z := 0; //default value |
||
1171 | DelphiXSpriteEditForm := TDelphiXSpriteEditForm.Create(nil); |
||
1172 | try |
||
1173 | Q := TCustomDXSpriteEngine(Component); |
||
1174 | case Q.Items.Count of |
||
1175 | 0: begin |
||
1176 | ShowMessage('You must create any item of sprite first!'); |
||
1177 | Exit; |
||
1178 | end; |
||
1179 | 1: ASprite := Q.Items[Z].Sprite; |
||
1180 | else |
||
1181 | FrmListBox := CreateListBox(ListBox1DblClick, ListBox1); |
||
1182 | for I := 0 to Q.Items.Count - 1 do begin |
||
1183 | S := Q.Items[I].Name; |
||
1184 | ListBox1.Items.Add(Alter(S, '(unnamed).' + IntToStr(I))); |
||
1185 | end; |
||
1186 | if FrmListBox.ShowModal <> mrOk then Exit; |
||
1187 | Z := ListBox1.ItemIndex; |
||
1188 | if Z = -1 then Exit; |
||
1189 | ASprite := Q.Items[Z].Sprite; |
||
1190 | {synchronize of names} |
||
1191 | if ASprite.Caption = '' then |
||
1192 | if Q.Items[ListBox1.ItemIndex].Name <> '' then |
||
1193 | ASprite.Caption := Q.Items[Z].Name; |
||
1194 | end {case}; |
||
1195 | DelphiXSpriteEditForm.LoadDataToForm(ASprite); |
||
1196 | DelphiXSpriteEditForm.ShowModal; |
||
1197 | if DelphiXSpriteEditForm.Tag <> 0 then begin |
||
1198 | ASprite := TSprite(DelphiXSpriteEditForm.SaveDataFromForm); |
||
1199 | if Q.Items[Z].Name = '' then |
||
1200 | if ASprite.Caption <> '' then |
||
1201 | Q.Items[Z].Name := ASprite.Caption; |
||
1202 | Designer.Modified; |
||
1203 | end; |
||
1204 | finally |
||
1205 | if Assigned(FrmListBox) then FrmListBox.Free; |
||
1206 | DelphiXSpriteEditForm.Free; |
||
1207 | end; |
||
1208 | end; |
||
1209 | end; |
||
1210 | end; |
||
1211 | |||
1212 | function TDXSpriteEngineEditor.GetVerbCount: Integer; |
||
1213 | begin |
||
1214 | Result := 1; |
||
1215 | end; |
||
1216 | |||
1217 | function TDXSpriteEngineEditor.GetVerb(Index: Integer): string; |
||
1218 | begin |
||
1219 | case Index of |
||
1220 | 0: Result := 'Sprite Editor'; |
||
1221 | end; |
||
1222 | end; |
||
1223 | |||
1224 | { TDXDrawEditor } |
||
1225 | |||
1226 | procedure TDXDrawEditor.ExecuteVerb(Index: Integer); |
||
1227 | var |
||
1228 | ediform: TDelphiXPathsEditForm; |
||
1229 | Q: TCustomDXDraw; |
||
1230 | I: Integer; |
||
1231 | S: string; |
||
1232 | T: TTrace; |
||
1233 | {$IFNDEF VER4UP} |
||
1234 | H: TTrace; |
||
1235 | J: Integer; |
||
1236 | {$ENDIF} |
||
1237 | begin |
||
1238 | case Index of |
||
1239 | 0: begin |
||
1240 | Q := TCustomDXDraw(Component); |
||
1241 | {paths editor} |
||
1242 | ediform := TDelphiXPathsEditForm.Create(nil); |
||
1243 | try |
||
1244 | ediform.Pane.Width := Q.Display.Width; |
||
1245 | ediform.Pane.Height := Q.Display.Width; |
||
1246 | for I := 0 to Q.Traces.Count - 1 do begin |
||
1247 | S := Q.Traces.Items[I].Name; |
||
1248 | T := ediform.PrivateTraces.Add; |
||
1249 | T.Name := S; |
||
1250 | {$IFDEF VER4UP} |
||
1251 | T.Assign(Q.Traces.Items[I]); |
||
1252 | {$ELSE} |
||
1253 | T.Blit := Q.Traces.Items[I].Blit; |
||
1254 | {$ENDIF} |
||
1255 | if Trim(S) = '' then S := Format('(unnamed[%d])', [I]); |
||
1256 | ediform.cbListOfTraces.Items.Add(S); |
||
1257 | end; |
||
1258 | ediform.ShowTracesOnPane; |
||
1259 | |||
1260 | ediform.ShowModal; |
||
1261 | |||
1262 | if ediform.Tag = 1 then begin |
||
1263 | {clear traces} |
||
1264 | Q.Traces.Clear; |
||
1265 | {rewrite backward} |
||
1266 | for i := 0 to ediform.PrivateTraces.Count -1 do begin |
||
1267 | T := Q.Traces.Add; |
||
1268 | T.Name := ediform.PrivateTraces.Items[I].Name; |
||
1269 | {$IFDEF VER4UP} |
||
1270 | T.Assign(ediform.PrivateTraces.Items[i]); |
||
1271 | {$ELSE} |
||
1272 | H := ediform.PrivateTraces.Items[i]; |
||
1273 | T.Blit := H.Blit; |
||
1274 | T.Blit.SetPathLen(H.Blit.GetPathCount); |
||
1275 | for J := 0 to H.Blit.GetPathCount - 1 do begin |
||
1276 | T.Blit.Path[J] := H.Blit.Path[J] |
||
1277 | end |
||
1278 | {$ENDIF} |
||
1279 | end; |
||
1280 | {prepis zmeny} |
||
1281 | Designer.Modified; |
||
1282 | end; |
||
1283 | finally |
||
1284 | ediform.Free; |
||
1285 | end; |
||
1286 | end; |
||
1287 | end; |
||
1288 | end; |
||
1289 | |||
1290 | function TDXDrawEditor.GetVerbCount: Integer; |
||
1291 | begin |
||
1292 | Result := 1; |
||
1293 | end; |
||
1294 | |||
1295 | function TDXDrawEditor.GetVerb(Index: Integer): string; |
||
1296 | begin |
||
1297 | case Index of |
||
1298 | 0: Result := 'Traces Editor'; |
||
1299 | end; |
||
1300 | end; |
||
1301 | |||
1302 | end. |