Subversion Repositories spacemission

Rev

Rev 16 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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