aboutsummaryrefslogtreecommitdiffstats
path: root/unicode/src
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-23 20:35:13 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-23 20:35:13 +0000
commit483260f11f03502b20d470c416366844f1199927 (patch)
tree2ac5495fadd735a37d922d8192a9909a1652a131 /unicode/src
parent0c5d191e7c511440cd0010cb3fcee43432e3e143 (diff)
downloadusdx-483260f11f03502b20d470c416366844f1199927.tar.gz
usdx-483260f11f03502b20d470c416366844f1199927.tar.xz
usdx-483260f11f03502b20d470c416366844f1199927.zip
Editor:
- if encoding must be changed to UTF-8 create a backup copy of the old file - show error/info dialog if file saving failed/succeeded git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1911 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'unicode/src')
-rw-r--r--unicode/src/screens/UScreenEditSub.pas25
1 files changed, 23 insertions, 2 deletions
diff --git a/unicode/src/screens/UScreenEditSub.pas b/unicode/src/screens/UScreenEditSub.pas
index 56d11124..00e62c16 100644
--- a/unicode/src/screens/UScreenEditSub.pas
+++ b/unicode/src/screens/UScreenEditSub.pas
@@ -139,13 +139,26 @@ uses
procedure OnSaveEncodingError(Value: boolean; Data: Pointer);
var
SResult: TSaveSongResult;
+ FilePath: IPath;
+ Success: boolean;
begin
+ Success := false;
if (Value) then
begin
CurrentSong.Encoding := encUTF8;
- SResult := SaveSong(CurrentSong, Lines[0], CurrentSong.Path.Append(CurrentSong.FileName),
+ FilePath := CurrentSong.Path.Append(CurrentSong.FileName);
+ // create backup file
+ FilePath.CopyFile(Path(FilePath.ToUTF8 + '.ansi.bak'), false);
+ // store in UTF-8 encoding
+ SResult := SaveSong(CurrentSong, Lines[0], FilePath,
boolean(Data));
+ Success := (SResult = ssrOK);
end;
+
+ if (Success) then
+ ScreenPopupInfo.ShowPopup(Language.Translate('INFO_FILE_SAVED'))
+ else
+ ScreenPopupError.ShowPopup(Language.Translate('ERROR_SAVE_FILE_FAILED'));
end;
// Method for input parsing. If false is returned, GetNextWindow
@@ -182,10 +195,18 @@ begin
// Save Song
SResult := SaveSong(CurrentSong, Lines[0], CurrentSong.Path.Append(CurrentSong.FileName),
(SDL_ModState = KMOD_LSHIFT));
- if (SResult = ssrEncodingError) then
+ if (SResult = ssrOK) then
+ begin
+ ScreenPopupInfo.ShowPopup(Language.Translate('INFO_FILE_SAVED'));
+ end
+ else if (SResult = ssrEncodingError) then
begin
ScreenPopupCheck.ShowPopup(Language.Translate('ENCODING_ERROR_ASK_FOR_UTF8'), OnSaveEncodingError,
Pointer(SDL_ModState = KMOD_LSHIFT), true);
+ end
+ else
+ begin
+ ScreenPopupError.ShowPopup(Language.Translate('ERROR_SAVE_FILE_FAILED'));
end;
Exit;
end;