Skip to content

Commit

Permalink
1.1.3.13 Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Taicanium committed Apr 17, 2024
1 parent f22175e commit e0e6797
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,4 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
*.sln
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
9 changes: 5 additions & 4 deletions Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, FileInfo>? fileListing;
public static readonly Dictionary<string, string> htmlEntities = new()
public readonly static Dictionary<string, string> htmlEntities = new()
{
{ "&", "&amp;" },
{ "\"", "&quot;" },
Expand All @@ -29,8 +30,8 @@ static class Common
{ "®", "&reg;" },
{ "\n", "<br />" },
};
public static readonly string htmlFooter = "</body>\n</html>";
public static readonly string htmlHeader = @"
public readonly static string htmlFooter = "</body>\n</html>";
public readonly static string htmlHeader = @"
<!DOCTYPE html>
<html>
<head>
Expand Down Expand Up @@ -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<string, string> tagClosings = new()
public readonly static Dictionary<string, string> tagClosings = new()
{
{ "b", "</b>" },
{ "i", "</i>" },
Expand Down
6 changes: 5 additions & 1 deletion KNOWN.md
Original file line number Diff line number Diff line change
@@ -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.
- 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.
18 changes: 11 additions & 7 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -142,24 +143,26 @@ 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.
// They will never contain actual messages, so we exclude them unconditionally.
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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e0e6797

Please sign in to comment.