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