From e0e6797622e978a4cffa4a86138daef20dcbdf41 Mon Sep 17 00:00:00 2001 From: Taicanium Date: Wed, 17 Apr 2024 10:09:22 -0500 Subject: [PATCH] 1.1.3.13 Changes --- .gitignore | 1 + CHANGELOG.md | 4 ++++ Common.cs | 9 +++++---- KNOWN.md | 6 +++++- MainWindow.xaml.cs | 18 +++++++++++------- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 426d76d..8d289e2 100644 --- a/.gitignore +++ b/.gitignore @@ -396,3 +396,4 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml +*.sln diff --git a/CHANGELOG.md b/CHANGELOG.md index 461fad2..f091916 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 1.1.3.13 - 17/04/2024 +- File and folder selection dialogs now open by default to the standard F-Chat 3.0 log location (%appdata%/fchat/data) when selecting source logs, and to the user's desktop when selecting a destination. +- Minor fix: HTML output files containing a second, empty HTML body. + # 1.1.3.12 - 27/03/2024 - Hotfix: Recurrence of the previous headerless HTML issue. - HTML messages containing multiple lines of subtext are no longer cut off by line height restrictions. diff --git a/Common.cs b/Common.cs index 68c53d6..9730602 100644 --- a/Common.cs +++ b/Common.cs @@ -11,10 +11,11 @@ namespace FLogS static class Common { public readonly static string dateFormat = "yyyy-MM-dd HH:mm:ss"; // ISO 8601. + public readonly static string defaultLogDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "fchat", "data"); private readonly static DateTime epoch = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); public readonly static string errorFile = "FLogS_ERROR.txt"; public static Dictionary? fileListing; - public static readonly Dictionary htmlEntities = new() + public readonly static Dictionary htmlEntities = new() { { "&", "&" }, { "\"", """ }, @@ -29,8 +30,8 @@ static class Common { "®", "®" }, { "\n", "
" }, }; - public static readonly string htmlFooter = "\n"; - public static readonly string htmlHeader = @" + public readonly static string htmlFooter = "\n"; + public readonly static string htmlHeader = @" @@ -65,7 +66,7 @@ static class Common public static bool plaintext = true; public static string lastException = string.Empty; public static uint lastTimestamp; - public static readonly Dictionary tagClosings = new() + public readonly static Dictionary tagClosings = new() { { "b", "" }, { "i", "" }, diff --git a/KNOWN.md b/KNOWN.md index 2ff1ab5..256759b 100644 --- a/KNOWN.md +++ b/KNOWN.md @@ -1,2 +1,6 @@ # Known Issues -- Ads are read correctly as they are in later versions, but much older clients didn't record ads as uniquely ID'd messages - they appear to have just been plaintext, with no delimiter. Reading them causes patches of garbage. \ No newline at end of file +- Ads are read correctly as they are in later versions, but much older clients didn't record ads as uniquely ID'd messages - they appear to have just been plaintext, with no delimiter. Reading them causes patches of garbage. + +# Todo +- Preliminary scan of selected destination files, if they exist. If they appear at a glance to be un-translated user logs, refuse to overwrite them. (i.e. if it appears the user accidentally used a source log as the destination) +- Android version for mobile users of F-Chat. \ No newline at end of file diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index b11821e..7062edb 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -51,6 +51,7 @@ private enum FLogS_ERROR DEST_NOT_DIRECTORY, DEST_NOT_FILE, DEST_NOT_FOUND, + DEST_SENSITIVE, // Todo. NO_DEST, NO_DEST_DIR, NO_REGEX, @@ -142,12 +143,13 @@ private void DatePicker_Update(object? sender, RoutedEventArgs e) return; } - private static string DialogFileSelect(bool checkExists = false, bool multi = true) + private static string DialogFileSelect(bool outputSelect = false, bool checkExists = false, bool multi = true) { OpenFileDialog openFileDialog = new() { CheckFileExists = checkExists, Multiselect = multi, + InitialDirectory = outputSelect ? Environment.GetFolderPath(Environment.SpecialFolder.Desktop) : Path.Exists(Common.defaultLogDir) ? Common.defaultLogDir : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), }; if (openFileDialog.ShowDialog() == true) return string.Join(";", openFileDialog.FileNames.Where(file => !file.Contains(".idx"))); // IDX files contain metadata relating to the corresponding (usually extension-less) log files. @@ -155,11 +157,12 @@ private static string DialogFileSelect(bool checkExists = false, bool multi = tr return string.Empty; } - private static string DialogFolderSelect() + private static string DialogFolderSelect(bool outputSelect = false) { System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new() { - ShowNewFolderButton = true + ShowNewFolderButton = true, + InitialDirectory = outputSelect ? Environment.GetFolderPath(Environment.SpecialFolder.Desktop) : Path.Exists(Common.defaultLogDir) ? Common.defaultLogDir : Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), }; if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) return folderBrowserDialog.SelectedPath; @@ -207,17 +210,17 @@ private void DirectoryRunButton_Click(object? sender, RoutedEventArgs e) private void DstDirectoryButton_Click(object? sender, RoutedEventArgs e) { - DirectoryOutput.Text = DialogFolderSelect(); + DirectoryOutput.Text = DialogFolderSelect(true); } private void DstFileButton_Click(object? sender, RoutedEventArgs e) { - FileOutput.Text = DialogFileSelect(multi: false); + FileOutput.Text = DialogFileSelect(outputSelect: true, multi: false); } private void DstPhraseButton_Click(object? sender, RoutedEventArgs e) { - PhraseOutput.Text = DialogFolderSelect(); + PhraseOutput.Text = DialogFolderSelect(true); } private void FormatOverride(object? sender, RoutedEventArgs e) @@ -250,6 +253,7 @@ private void FormatOverride(object? sender, RoutedEventArgs e) (FLogS_ERROR.DEST_NOT_DIRECTORY, _) => "Destination is not a directory.", (FLogS_ERROR.DEST_NOT_FILE, _) => "Destination is not a file.", (FLogS_ERROR.DEST_NOT_FOUND, _) => "Destination directory does not exist.", + (FLogS_ERROR.DEST_SENSITIVE, _) => "Destination appears to contain source log data.", // Todo. (FLogS_ERROR.NO_DEST, _) => "No destination file selected.", (FLogS_ERROR.NO_DEST_DIR, _) => "No destination directory selected.", (FLogS_ERROR.NO_REGEX, _) => "No search text entered.", @@ -424,7 +428,7 @@ private void SrcDirectoryButton_Click(object? sender, RoutedEventArgs e) private void SrcFileButton_Click(object? sender, RoutedEventArgs e) { - FileSource.Text = DialogFileSelect(true, false); + FileSource.Text = DialogFileSelect(false, true, false); } private void SrcPhraseButton_Click(object? sender, RoutedEventArgs e)