|
@@ -1438,9 +1438,13 @@ function TFMain.ScriptFileSaveAs(AVars: TVariableSet): TScriptResult;
|
|
if Config.DefaultRememberStartupTargetDirectory then
|
|
if Config.DefaultRememberStartupTargetDirectory then
|
|
Config.SetStartupTargetDirectory(FSaveInitialDir);
|
|
Config.SetStartupTargetDirectory(FSaveInitialDir);
|
|
Image.CurrentFilenameUTF8 := filename;
|
|
Image.CurrentFilenameUTF8 := filename;
|
|
|
|
+ AVars.Strings['Result'] := filename;
|
|
result := srOk;
|
|
result := srOk;
|
|
if Assigned(Scripting.RecordingFunctionParameters) then
|
|
if Assigned(Scripting.RecordingFunctionParameters) then
|
|
- Scripting.RecordingFunctionParameters.AddString('FileName',filename);
|
|
|
|
|
|
+ begin
|
|
|
|
+ Scripting.RecordingFunctionParameters.AddString('FileName',filename);
|
|
|
|
+ Scripting.RecordingFunctionParameters.AddBoolean('Validate',True);
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
except
|
|
except
|
|
on ex: Exception do
|
|
on ex: Exception do
|
|
@@ -1494,7 +1498,7 @@ begin
|
|
|
|
|
|
if AVars.Booleans['Validate'] and (initialDir <> '') then
|
|
if AVars.Booleans['Validate'] and (initialDir <> '') then
|
|
begin
|
|
begin
|
|
- if FileManager.FileExists(initialDir+filename) then
|
|
|
|
|
|
+ if not AVars.Booleans['Overwrite'] and (FileManager.FileExists(initialDir+filename)) then
|
|
begin
|
|
begin
|
|
if QuestionDlg(rsSave, rsOverwriteFile, mtConfirmation,
|
|
if QuestionDlg(rsSave, rsOverwriteFile, mtConfirmation,
|
|
[mrOk, rsOkay, mrCancel, rsCancel],0) <> mrOk then
|
|
[mrOk, rsOkay, mrCancel, rsCancel],0) <> mrOk then
|
|
@@ -1547,12 +1551,16 @@ begin
|
|
if SuggestImageFormat(Image.currentFilenameUTF8) in [ifIco,ifCur,ifTiff,ifGif] then
|
|
if SuggestImageFormat(Image.currentFilenameUTF8) in [ifIco,ifCur,ifTiff,ifGif] then
|
|
begin
|
|
begin
|
|
Image.UpdateMultiImage;
|
|
Image.UpdateMultiImage;
|
|
|
|
+ AVars.Strings['Result'] := Image.currentFilenameUTF8;
|
|
result := srOk;
|
|
result := srOk;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
if LazPaintInstance.ShowSaveOptionDlg(nil,Image.currentFilenameUTF8,AVars.Booleans['SkipOptions']) then
|
|
if LazPaintInstance.ShowSaveOptionDlg(nil,Image.currentFilenameUTF8,AVars.Booleans['SkipOptions']) then
|
|
- result := srOk
|
|
|
|
|
|
+ begin
|
|
|
|
+ AVars.Strings['Result'] := Image.currentFilenameUTF8;
|
|
|
|
+ result := srOk;
|
|
|
|
+ end
|
|
else
|
|
else
|
|
result := srCancelledByUser;
|
|
result := srCancelledByUser;
|
|
end;
|
|
end;
|
|
@@ -1863,19 +1871,31 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function TFMain.ScriptFileSaveSelectionAs(AVars: TVariableSet): TScriptResult;
|
|
function TFMain.ScriptFileSaveSelectionAs(AVars: TVariableSet): TScriptResult;
|
|
-var filename: string;
|
|
|
|
|
|
+var filename, initialDir: string;
|
|
vFileName: TScriptVariableReference;
|
|
vFileName: TScriptVariableReference;
|
|
begin
|
|
begin
|
|
if Image.SelectionMaskEmpty then
|
|
if Image.SelectionMaskEmpty then
|
|
begin
|
|
begin
|
|
- result := srOk;
|
|
|
|
|
|
+ result := srException;
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
filename := '';
|
|
filename := '';
|
|
vFileName := AVars.GetVariable('FileName');
|
|
vFileName := AVars.GetVariable('FileName');
|
|
if AVars.IsReferenceDefined(vFileName) then
|
|
if AVars.IsReferenceDefined(vFileName) then
|
|
|
|
+ begin
|
|
filename:= AVars.GetString(vFileName);
|
|
filename:= AVars.GetString(vFileName);
|
|
|
|
+ {$WARNINGS OFF}
|
|
|
|
+ if PathDelim <> '\' then filename := StringReplace(filename, '\', PathDelim, [rfReplaceAll]);
|
|
|
|
+ if PathDelim <> '/' then filename := StringReplace(filename, '/', PathDelim, [rfReplaceAll]);
|
|
|
|
+ {$WARNINGS ON}
|
|
|
|
+ if ExtractFilePath(filename)<>'' then fileName := ExpandFileName(filename);
|
|
|
|
+ end;
|
|
if filename = '' then filename := FSaveSelectionInitialFilename;
|
|
if filename = '' then filename := FSaveSelectionInitialFilename;
|
|
|
|
+ initialDir := ExtractFilePath(filename);
|
|
|
|
+ if AVars.Booleans['Validate'] and (filename <> '') and (initialDir <> '') then
|
|
|
|
+ begin
|
|
|
|
+ //skip
|
|
|
|
+ end else
|
|
if UseImageBrowser then
|
|
if UseImageBrowser then
|
|
begin
|
|
begin
|
|
if not assigned(FSaveSelection) then
|
|
if not assigned(FSaveSelection) then
|
|
@@ -1886,7 +1906,7 @@ begin
|
|
FSaveSelection.Caption := SaveSelectionDialog.Title;
|
|
FSaveSelection.Caption := SaveSelectionDialog.Title;
|
|
FSaveSelection.DefaultExtension := SaveSelectionDialog.DefaultExt;
|
|
FSaveSelection.DefaultExtension := SaveSelectionDialog.DefaultExt;
|
|
end;
|
|
end;
|
|
- if pos(PathDelim,filename)<>0 then FSaveSelection.InitialDirectory := ExtractFilePath(filename);
|
|
|
|
|
|
+ if initialDir<>'' then FSaveSelection.InitialDirectory := initialDir;
|
|
FSaveSelection.InitialFilename := ExtractFileName(filename);
|
|
FSaveSelection.InitialFilename := ExtractFileName(filename);
|
|
if (FSaveSelection.ShowModal = mrOk) and (FSaveSelection.Filename <> '') then
|
|
if (FSaveSelection.ShowModal = mrOk) and (FSaveSelection.Filename <> '') then
|
|
filename := FSaveSelection.Filename
|
|
filename := FSaveSelection.Filename
|
|
@@ -1899,7 +1919,7 @@ begin
|
|
begin
|
|
begin
|
|
filename := SaveSelectionDialog.FileName;
|
|
filename := SaveSelectionDialog.FileName;
|
|
SaveSelectionDialog.FileName := ExtractFileName(filename);
|
|
SaveSelectionDialog.FileName := ExtractFileName(filename);
|
|
- SaveSelectionDialog.InitialDir := ExtractFilePath(filename);
|
|
|
|
|
|
+ if initialDir<>'' then SaveSelectionDialog.InitialDir := initialDir;
|
|
end;
|
|
end;
|
|
if SaveSelectionDialog.Execute then
|
|
if SaveSelectionDialog.Execute then
|
|
filename := SaveSelectionDialog.FileName
|
|
filename := SaveSelectionDialog.FileName
|
|
@@ -1916,9 +1936,14 @@ begin
|
|
begin
|
|
begin
|
|
try
|
|
try
|
|
Image.SaveSelectionMaskToFileUTF8(filename);
|
|
Image.SaveSelectionMaskToFileUTF8(filename);
|
|
|
|
+ FSaveSelectionInitialFilename := filename;
|
|
result := srOk;
|
|
result := srOk;
|
|
if Assigned(Scripting.RecordingFunctionParameters) then
|
|
if Assigned(Scripting.RecordingFunctionParameters) then
|
|
- Scripting.RecordingFunctionParameters.AddString('FileName',filename);
|
|
|
|
|
|
+ begin
|
|
|
|
+ Scripting.RecordingFunctionParameters.AddString('FileName',filename);
|
|
|
|
+ Scripting.RecordingFunctionParameters.AddBoolean('Validate',True);
|
|
|
|
+ end;
|
|
|
|
+ AVars.Strings['Result'] := filename;
|
|
except
|
|
except
|
|
on ex: Exception do
|
|
on ex: Exception do
|
|
begin
|
|
begin
|