📄 dxreg.pas
字号:
with TPictureCollectionItem.Create(TCustomDXImageList(Component).Items) do
begin
try
Picture.LoadFromFile(OpenDialog.Files[i]);
Name := ExtractFileName(OpenDialog.Files[i]);
except
Free;
raise;
end;
end;
end else
TCustomDXImageList(Component).Items.LoadFromFile(OpenDialog.FileName);
Designer.Modified;
end;
finally
OpenDialog.Free;
end;
end;
1: begin
SaveDialog := TSaveDialog.Create(nil);
try
SaveDialog.DefaultExt := 'dxg';
SaveDialog.Filter := SDXGFileFilter;
SaveDialog.Options := [ofOverwritePrompt, ofPathMustExist];
if SaveDialog.Execute then
TCustomDXImageList(Component).Items.SaveToFile(SaveDialog.FileName);
finally
SaveDialog.Free;
end;
end;
end;
end;
function TDXImageListEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SOpen;
1: Result := SSave;
end;
end;
function TDXImageListEditor.GetVerbCount: Integer;
begin
Result := 2;
end;
{ TWaveProperty }
procedure TWaveProperty.Edit;
var
Form: TDelphiXWaveEditForm;
begin
Form := TDelphiXWaveEditForm.Create(nil);
try
Form.Wave := TWave(GetOrdValue);
Form.ShowModal;
if Form.Tag<>0 then
begin
SetOrdValue(Integer(Form.Wave));
Designer.Modified;
end;
finally
Form.Free;
end;
end;
function TWaveProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
function TWaveProperty.GetValue: string;
begin
if TWave(GetOrdValue).Size=0 then
Result := SNone
else
Result := Format('(%s)', [TObject(GetOrdValue).ClassName]);
end;
{ TDXWaveEditor }
procedure TDXWaveEditor.Edit;
var
Form: TDelphiXWaveEditForm;
begin
Form := TDelphiXWaveEditForm.Create(nil);
try
Form.Wave := TCustomDXWave(Component).Wave;
Form.ShowModal;
if Form.Tag<>0 then
begin
TCustomDXWave(Component).Wave := Form.Wave;
Designer.Modified;
end;
finally
Form.Free;
end;
end;
procedure TDXWaveEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0: Edit;
end;
end;
function TDXWaveEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SSettingWave;
end;
end;
function TDXWaveEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
{ TDXWaveListEditor }
procedure TDXWaveListEditor.ExecuteVerb(Index: Integer);
var
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
i: Integer;
begin
case Index of
0: begin
OpenDialog := TOpenDialog.Create(nil);
try
OpenDialog.DefaultExt := 'dxw';
OpenDialog.Filter := SDXWOpenFileFilter;
OpenDialog.Options := [ofPathMustExist, ofFileMustExist, ofAllowMultiSelect];
if OpenDialog.Execute then
begin
if OpenDialog.FilterIndex=2 then
begin
for i:=0 to OpenDialog.Files.Count-1 do
with TWaveCollectionItem.Create(TCustomDXWaveList(Component).Items) do
begin
try
Wave.LoadFromFile(OpenDialog.Files[i]);
Name := ExtractFileName(OpenDialog.Files[i]);
except
Free;
raise;
end;
end;
end else
TCustomDXWaveList(Component).Items.LoadFromFile(OpenDialog.FileName);
Designer.Modified;
end;
finally
OpenDialog.Free;
end;
end;
1: begin
SaveDialog := TSaveDialog.Create(nil);
try
SaveDialog.DefaultExt := 'dxw';
SaveDialog.Filter := SDXWFileFilter;
SaveDialog.Options := [ofOverwritePrompt, ofPathMustExist];
if SaveDialog.Execute then
TCustomDXWaveList(Component).Items.SaveToFile(SaveDialog.FileName);
finally
SaveDialog.Free;
end;
end;
end;
end;
function TDXWaveListEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SOpen;
1: Result := SSave;
end;
end;
function TDXWaveListEditor.GetVerbCount: Integer;
begin
Result := 2;
end;
{ TForceFeedbackEffectsProperty }
procedure TForceFeedbackEffectsProperty.Edit;
var
Form: TDelphiXFFEditForm;
Effects: TForceFeedbackEffects;
begin
Effects := TForceFeedbackEffects(GetOrdValue);
Form := TDelphiXFFEditForm.Create(nil);
try
if Effects.Input is TJoystick then
Form.Effects := Form.DXInput.Joystick.Effects
else if Effects.Input is TKeyboard then
Form.Effects := Form.DXInput.Keyboard.Effects
else if Effects.Input is TMouse then
Form.Effects := Form.DXInput.Mouse.Effects
else Exit;
Form.Effects.Assign(TForceFeedbackEffects(GetOrdValue));
Form.ShowModal;
if Form.Tag<>0 then
begin
SetOrdValue(Integer(Form.Effects));
Designer.Modified;
end;
finally
Form.Free;
end;
end;
function TForceFeedbackEffectsProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
function TForceFeedbackEffectsProperty.GetValue: string;
begin
if TForceFeedbackEffects(GetOrdValue).Count=0 then
Result := SNone
else
Result := Format('(%s)', [TObject(GetOrdValue).ClassName]);
end;
{ TDXInputEditor }
procedure TDXInputEditor.Edit;
var
Form: TDelphiXInputEditForm;
begin
Form := TDelphiXInputEditForm.Create(nil);
try
Form.DXInput := TCustomDXInput(Component);
Form.ShowModal;
if Form.Tag<>0 then
Designer.Modified;
finally
Form.Free;
end;
end;
procedure TDXInputEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0: begin
with TCustomDXInput(Component) do
begin
Joystick.ID := 0;
Keyboard.KeyAssigns := DefKeyAssign;
end;
Designer.Modified;
end;
1: begin
with TCustomDXInput(Component) do
begin
Joystick.ID := 0;
Keyboard.KeyAssigns := DefKeyAssign2_1;
end;
Designer.Modified;
end;
2: begin
with TCustomDXInput(Component) do
begin
Joystick.ID := 1;
Keyboard.KeyAssigns := DefKeyAssign2_2;
end;
Designer.Modified;
end;
end;
end;
function TDXInputEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := SSinglePlayer;
1: Result := SMultiPlayer1;
2: Result := SMultiPlayer2;
end;
end;
function TDXInputEditor.GetVerbCount: Integer;
begin
Result := 3;
end;
{ TGUIDProperty }
procedure TGUIDProperty.Edit;
var
Form: TDelphiXGUIDEditForm;
begin
Form := TDelphiXGUIDEditForm.Create(nil);
try
Form.GUID := GetStrValue;
Form.ShowModal;
if Form.Tag<>0 then
begin
SetStrValue(Form.GUID);
Designer.Modified;
end;
finally
Form.Free;
end;
end;
function TGUIDProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog];
end;
{ TSpriteProperty }
procedure TSpriteProperty.Edit;
var
DirectAccessToSprite: TPersistent;
Form: TDelphiXSpriteEditForm;
begin
DirectAccessToSprite := TPersistent(GetOrdValue);
Form := TDelphiXSpriteEditForm.Create(nil);
try
Form.LoadDataToForm(DirectAccessToSprite);
//Form.Sprite.AsSign(TPersistent(GetOrdValue));
Form.ShowModal;
if Form.Tag<>0 then
begin
Form.SaveDataFromForm(DirectAccessToSprite);
Designer.Modified;
end;
finally
Form.Free;
end;
end;
function TSpriteProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
{$IfDef DelphiX_Delphi6}
procedure TSpriteEditor.EditProperty(const Prop: IProperty; var Continue: Boolean);
{$Else}
procedure TSpriteEditor.EditProperty(PropertyEditor : TPropertyEditor;
var continue, FreeEditor : boolean);
{$EndIf}
var
PropName : string;
begin
PropName:={$IfDef DelphiX_Delphi6}Prop{$Else}PropertyEditor{$EndIf}.GetName;
if (CompareText(PropName, 'Sprite')=0) Or (CompareText(PropName, 'ISprite')=0)
Or (CompareText(PropName, 'ISpriteEx')=0) Or (CompareText(PropName, 'BckSprite')=0) then
begin
{$IfDef DelphiX_Delphi6}Prop{$Else}PropertyEditor{$EndIf}.edit;
continue:=false;
end;
end;
{ TMidiProperty }
procedure TMidiProperty.Edit;
var
DelphiXMidiEditForm: TDelphiXMidiEditForm;
DirectAccessToMidiData: TMusicDataProp;
S: string; I: Integer;
begin
DirectAccessToMidiData := TMusicDataProp(GetOrdValue);
DelphiXMidiEditForm := TDelphiXMidiEditForm.Create(nil);
try
DelphiXMidiEditForm.MidiData := DirectAccessToMidiData.MusicData;
DelphiXMidiEditForm.MidiFileName := DirectAccessToMidiData.MidiName;
DelphiXMidiEditForm.Showmodal;
if DelphiXMidiEditForm.Tag = 1 then begin
DirectAccessToMidiData.MusicData := DelphiXMidiEditForm.MidiData;
S := '';
if DelphiXMidiEditForm.MidiFileName <> '' then begin
S := ExtractFileName(DelphiXMidiEditForm.MidiFileName);
I := Pos(ExtractFileExt(S),S);
if I > 0 then S := Copy(S, 1, I-1);
end;
DirectAccessToMidiData.MidiName := S;
Designer.Modified;
end;
finally
DelphiXMidiEditForm.Free;
end;
end;
function TMidiProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TMidiProperty.GetValue: string;
var
S: string;
begin
S := TMusicDataProp(GetOrdValue).MusicData;
if Length(S) = 0 then
Result := SNone
else
Result := '(Midi)';
end;
{$IfDef DelphiX_Delphi6}
procedure TMidiEditor.EditProperty(const Prop: IProperty; var Continue: Boolean);
{$Else}
procedure TMidiEditor.EditProperty(PropertyEditor : TPropertyEditor;
var continue, FreeEditor : boolean);
{$EndIf}
var
PropName : string;
begin
PropName:={$IfDef DelphiX_Delphi6}Prop{$Else}PropertyEditor{$EndIf}.GetName;
if (CompareText(PropName, 'Midi')=0) then
begin
{$IfDef DelphiX_Delphi6}Prop{$Else}PropertyEditor{$EndIf}.edit;
continue:=false;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -