diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f99a72f..2ebc5ec 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -22,7 +22,7 @@ jobs: runtime: win-x64 env: - proj: "Totk.ZStdTool" + proj: "TotkZstdTool" steps: - uses: actions/checkout@master @@ -30,7 +30,7 @@ jobs: - name: Install DotNET uses: actions/setup-dotnet@v3 with: - dotnet-version: "7.0.x" + dotnet-version: "8.0.x" - name: Publish Totk ZStd Tool shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 09fcae0..64251be 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: runtime: win-x64 env: - proj: "Totk.ZStdTool" + proj: "TotkZstdTool" steps: - uses: actions/checkout@master @@ -31,7 +31,7 @@ jobs: - name: Install DotNET uses: actions/setup-dotnet@v3 with: - dotnet-version: "7.0.x" + dotnet-version: "8.0.x" - name: Publish Totk ZStd Tool shell: bash diff --git a/ReadMe.md b/ReadMe.md index 2431140..e3bad0c 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,7 +1,7 @@ # Totk Decompression/Compression Tool [![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) -[![Downloads](https://img.shields.io/github/downloads/TotkMods/Totk.ZStdTool/total)](https://github.com/TotkMods/Totk.ZStdTool/releases) +[![Downloads](https://img.shields.io/github/downloads/TotkMods/TotkZstdTool/total)](https://github.com/TotkMods/TotkZstdTool/releases) A simple tool for decompressing and compressing `.zs` files in Totk. @@ -18,7 +18,7 @@ A simple tool for decompressing and compressing `.zs` files in Totk. ## Setup 1. Download and install the .NET 7 Runtime. -2. Download the latest release of [Totk zStd Tool](https://github.com/TotkMods/Totk.ZStdTool/releases/latest). +2. Download the latest release of [Totk zStd Tool](https://github.com/TotkMods/TotkZstdTool/releases/latest). 3. Open the application and configure your settings: - **Game Path**: Specify the path to your Totk game dump (RomFS - not an XCI or NSP file). This field is required. diff --git a/Totk.ZStdTool.sln b/TotkZstdTool.sln similarity index 87% rename from Totk.ZStdTool.sln rename to TotkZstdTool.sln index dfb993a..ba0e2c8 100644 --- a/Totk.ZStdTool.sln +++ b/TotkZstdTool.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.5.33530.505 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Totk.ZStdTool", "src\Totk.ZStdTool.csproj", "{82E909E6-EDF7-4C14-9F71-4CB1C95467D2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TotkZstdTool", "src\TotkZstdTool.csproj", "{82E909E6-EDF7-4C14-9F71-4CB1C95467D2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/App.axaml b/src/App.axaml index c213987..895648f 100644 --- a/src/App.axaml +++ b/src/App.axaml @@ -1,7 +1,7 @@ - diff --git a/src/App.axaml.cs b/src/App.axaml.cs index 2240751..abf5fb5 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -3,10 +3,10 @@ using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; using Avalonia.VisualTree; -using Totk.ZStdTool.ViewModels; -using Totk.ZStdTool.Views; +using TotkZstdTool.ViewModels; +using TotkZstdTool.Views; -namespace Totk.ZStdTool; +namespace TotkZstdTool; public partial class App : Application { @@ -19,8 +19,10 @@ public override void Initialize() public override void OnFrameworkInitializationCompleted() { - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - desktop.MainWindow = new ShellView { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new ShellView + { DataContext = ShellViewModel.Shared, }; diff --git a/src/CommandProcessor.cs b/src/CommandProcessor.cs index 9e8e082..52e2bc3 100644 --- a/src/CommandProcessor.cs +++ b/src/CommandProcessor.cs @@ -1,6 +1,6 @@ -using Totk.ZStdTool.Helpers; +using TotkZstdTool.Helpers; -namespace Totk.ZStdTool; +namespace TotkZstdTool; public static class CommandProcessor { @@ -10,15 +10,18 @@ public static class CommandProcessor public static void Process(List args) { string[] files = args.Where(File.Exists).ToArray(); - if (files.Length == args.Count) { - foreach (string file in files) { + if (files.Length == args.Count) + { + foreach (string file in files) + { ProcessShellInput(file); } return; } - - if (args[0].AsFlag() == 'h') { + + if (args[0].AsFlag() == 'h') + { Console.WriteLine(""" Compress a file: c, compress [-o|--output] [-d|--dictionaries] [-h|--help] @@ -38,7 +41,8 @@ public static void Process(List args) .Select((x, i) => (key: x.AsFlag(), value: args[args.IndexOf(x) + 1])) .ToDictionary(x => x.key, x => x.value); - Action> command = args[0][0] switch { + Action> command = args[0][0] switch + { 'c' => Compress, 'd' => Decompress, _ => throw new NotImplementedException( @@ -55,10 +59,12 @@ public static char AsFlag(this string input) public static void ProcessShellInput(string input) { - if (input.EndsWith(".zs")) { + if (input.EndsWith(".zs")) + { Decompress(input, new()); } - else { + else + { Compress(input, new()); } } @@ -69,11 +75,13 @@ public static void Compress(string input, Dictionary flags) output ??= input + ".zs"; bool useDictionaries = true; - if (flags.TryGetValue('d', out string? useDictionariesArg)) { + if (flags.TryGetValue('d', out string? useDictionariesArg)) + { useDictionaries = useDictionariesArg.ToLower() is not "f" or "false" or "n" or "no"; } - if (Path.GetDirectoryName(output) is string directory && !string.IsNullOrEmpty(directory)) { + if (Path.GetDirectoryName(output) is string directory && !string.IsNullOrEmpty(directory)) + { Directory.CreateDirectory(directory); } @@ -85,7 +93,8 @@ public static void Decompress(string input, Dictionary flags) flags.TryGetValue('o', out string? output); output ??= Path.ChangeExtension(input, string.Empty); - if (Path.GetDirectoryName(output) is string directory && !string.IsNullOrEmpty(directory)) { + if (Path.GetDirectoryName(output) is string directory && !string.IsNullOrEmpty(directory)) + { Directory.CreateDirectory(directory); } diff --git a/src/Helpers/BrowserDialog.cs b/src/Helpers/BrowserDialog.cs index dfc7ba7..69abc92 100644 --- a/src/Helpers/BrowserDialog.cs +++ b/src/Helpers/BrowserDialog.cs @@ -1,6 +1,6 @@ using Avalonia.Platform.Storage; -namespace Totk.ZStdTool.Helpers; +namespace TotkZstdTool.Helpers; public enum BrowserMode { OpenFile, OpenFolder, SaveFile } @@ -37,8 +37,10 @@ public BrowserDialog(BrowserMode mode, string? title = null, string? filter = nu _suggestedFileName = suggestedFileName; _instanceBrowserKey = instanceBrowserKey; - if (instanceBrowserKey != null) { - if (!Stashed.ContainsKey(instanceBrowserKey)) { + if (instanceBrowserKey != null) + { + if (!Stashed.ContainsKey(instanceBrowserKey)) + { Stashed.Add(instanceBrowserKey, new()); } } @@ -61,19 +63,23 @@ public BrowserDialog(BrowserMode mode, string? title = null, string? filter = nu IStorageProvider StorageProvider = App.VisualRoot!.StorageProvider; - object? result = _mode switch { - BrowserMode.OpenFolder => await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions() { + object? result = _mode switch + { + BrowserMode.OpenFolder => await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions() + { Title = _title, SuggestedStartLocation = GetLastDirectory(), AllowMultiple = allowMultiple }), - BrowserMode.OpenFile => await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions() { + BrowserMode.OpenFile => await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions() + { Title = _title, SuggestedStartLocation = GetLastDirectory(), AllowMultiple = allowMultiple, FileTypeFilter = LoadFileBrowserFilter(_filter) }), - BrowserMode.SaveFile => await StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions() { + BrowserMode.SaveFile => await StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions() + { Title = _title, SuggestedStartLocation = GetLastDirectory(), FileTypeChoices = LoadFileBrowserFilter(_filter), @@ -82,36 +88,44 @@ public BrowserDialog(BrowserMode mode, string? title = null, string? filter = nu _ => throw new NotImplementedException() }; - if (result is IReadOnlyList folders && folders.Count > 0) { + if (result is IReadOnlyList folders && folders.Count > 0) + { SetLastDirectory(folders[folders.Count - 1]); return folders.Select(folder => folder.Path.LocalPath); } - else if (result is IReadOnlyList files && files.Count > 0) { + else if (result is IReadOnlyList files && files.Count > 0) + { SetLastDirectory(await files[files.Count - 1].GetParentAsync()); return files.Select(file => file.Path.LocalPath); } - else if (result is IStorageFile file) { + else if (result is IStorageFile file) + { SetLastDirectory(await file.GetParentAsync()); return new string[1] { file.Path.LocalPath }; } - else { + else + { return null; } } internal void SetLastDirectory(IStorageFolder? folder) { - if (_mode == BrowserMode.SaveFile) { + if (_mode == BrowserMode.SaveFile) + { LastSaveDirectory = folder; - if (_instanceBrowserKey != null) { + if (_instanceBrowserKey != null) + { Stashed[_instanceBrowserKey].SaveDirectory = folder; } } - else { + else + { LastOpenDirectory = folder; - if (_instanceBrowserKey != null) { + if (_instanceBrowserKey != null) + { Stashed[_instanceBrowserKey].OpenDirectory = folder; } } @@ -119,19 +133,25 @@ internal void SetLastDirectory(IStorageFolder? folder) internal IStorageFolder? GetLastDirectory() { - if (_mode == BrowserMode.SaveFile) { - if (_instanceBrowserKey != null) { + if (_mode == BrowserMode.SaveFile) + { + if (_instanceBrowserKey != null) + { return Stashed[_instanceBrowserKey].SaveDirectory; } - else { + else + { return LastSaveDirectory; } } - else { - if (_instanceBrowserKey != null) { + else + { + if (_instanceBrowserKey != null) + { return Stashed[_instanceBrowserKey].OpenDirectory; } - else { + else + { return LastOpenDirectory; } } @@ -139,21 +159,26 @@ internal void SetLastDirectory(IStorageFolder? folder) internal static FilePickerFileType[] LoadFileBrowserFilter(string? filter = null) { - if (filter != null) { - try { + if (filter != null) + { + try + { string[] groups = filter.Split('|'); FilePickerFileType[] types = new FilePickerFileType[groups.Length]; - for (int i = 0; i < groups.Length; i++) { + for (int i = 0; i < groups.Length; i++) + { string[] pair = groups[i].Split(':'); - types[i] = new(pair[0]) { + types[i] = new(pair[0]) + { Patterns = pair[1].Split(';') }; } return types; } - catch { + catch + { throw new FormatException( $"Could not parse filter arguments '{filter}'.\n" + $"Example: \"Yaml Files:*.yml;*.yaml|All Files:*.*\"." diff --git a/src/Helpers/ZStdHelper.cs b/src/Helpers/ZStdHelper.cs index 3ed1467..336fef1 100644 --- a/src/Helpers/ZStdHelper.cs +++ b/src/Helpers/ZStdHelper.cs @@ -1,13 +1,14 @@ using CommunityToolkit.HighPerformance.Buffers; using TotkCommon; -namespace Totk.ZStdTool.Helpers; +namespace TotkZstdTool.Helpers; public static class ZstdHelper { public static int GetDictioanryId(this string path, bool useDictionaries) { - return useDictionaries switch { + return useDictionaries switch + { false => -1, true => path.EndsWith(".rsizetable") || path.EndsWith("ZsDic.pack") ? -1 : path.EndsWith(".bcett.byml") ? 3 : @@ -31,7 +32,7 @@ public static SpanOwner Decompress(string file) size = Zstd.GetDecompressedSize(buffer.Span); SpanOwner decompressed = SpanOwner.Allocate(size); - TotkCommon.Totk.Zstd.Decompress(buffer.Span, decompressed.Span); + Totk.Zstd.Decompress(buffer.Span, decompressed.Span); return decompressed; } @@ -51,7 +52,7 @@ public static SpanOwner Compress(string file, bool useDictionaries) size = Zstd.GetDecompressedSize(buffer.Span); SpanOwner decompressed = SpanOwner.Allocate(size); - TotkCommon.Totk.Zstd.Decompress(buffer.Span, decompressed.Span); + Totk.Zstd.Decompress(buffer.Span, decompressed.Span); return decompressed; } @@ -60,7 +61,8 @@ public static void DecompressFolder(string path, string output, bool recursive, string[] files = Directory.GetFiles(path, "*.zs", recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); setCount?.Invoke(files.Length); - for (int i = 0; i < files.Length; i++) { + for (int i = 0; i < files.Length; i++) + { string file = files[i]; using SpanOwner data = Decompress(file); @@ -78,7 +80,8 @@ public static void CompressFolder(string path, string output, bool recursive, Ac string[] files = Directory.GetFiles(path, "*.*", recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); setCount?.Invoke(files.Length); - for (int i = 0; i < files.Length; i++) { + for (int i = 0; i < files.Length; i++) + { string file = files[i]; using SpanOwner data = Compress(file, useDictionaries); diff --git a/src/Program.cs b/src/Program.cs index 9b06550..062abfd 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -1,7 +1,7 @@ using Avalonia; using Avalonia.ReactiveUI; -namespace Totk.ZStdTool; +namespace TotkZstdTool; internal class Program { @@ -11,13 +11,17 @@ internal class Program [STAThread] public static void Main(string[] args) { - if (args.Length > 0) { + if (args.Length > 0) + { CommandProcessor.Process(args.ToList()); } - else { -#if WIN_X64 - WindowHelper.SetWindowMode(WindowMode.Hidden); -#endif + else + { + if (OperatingSystem.IsWindows()) + { + WindowHelper.SetWindowMode(WindowMode.Hidden); + } + BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); } } diff --git a/src/Totk.ZStdTool.csproj b/src/TotkZstdTool.csproj similarity index 95% rename from src/Totk.ZStdTool.csproj rename to src/TotkZstdTool.csproj index febe717..d8d9557 100644 --- a/src/Totk.ZStdTool.csproj +++ b/src/TotkZstdTool.csproj @@ -10,7 +10,6 @@ embedded Assets\icon.ico true - WIN_X64 diff --git a/src/ViewModels/ShellViewModel.cs b/src/ViewModels/ShellViewModel.cs index 910e8e7..8d103c4 100644 --- a/src/ViewModels/ShellViewModel.cs +++ b/src/ViewModels/ShellViewModel.cs @@ -1,18 +1,20 @@ using Avalonia.Controls; using Avalonia.Threading; using FluentAvalonia.UI.Controls; -using Totk.ZStdTool.Helpers; +using TotkZstdTool.Helpers; -namespace Totk.ZStdTool.ViewModels; +namespace TotkZstdTool.ViewModels; public class ShellViewModel : ReactiveObject { public static ShellViewModel Shared { get; } = new(); private string _filePath = string.Empty; - public string FilePath { + public string FilePath + { get => _filePath; - set { + set + { this.RaiseAndSetIfChanged(ref _filePath, value); this.RaiseAndSetIfChanged(ref _canDecompress, File.Exists(value) && Path.GetExtension(value) == ".zs", nameof(CanDecompress)); this.RaiseAndSetIfChanged(ref _canCompress, File.Exists(value) && Path.GetExtension(value) != ".zs", nameof(CanCompress)); @@ -26,15 +28,18 @@ public string FilePath { public bool CanCompress => _canCompress; private bool _decompressRecursive = true; - public bool DecompressRecursive { + public bool DecompressRecursive + { get => _decompressRecursive; set => this.RaiseAndSetIfChanged(ref _decompressRecursive, value); } private string _folderPath = string.Empty; - public string FolderPath { + public string FolderPath + { get => _folderPath; - set { + set + { this.RaiseAndSetIfChanged(ref _folderPath, value); this.RaiseAndSetIfChanged(ref _canDecompressFolder, Directory.Exists(value), nameof(CanDecompressFolder)); this.RaiseAndSetIfChanged(ref _canCompressFolder, Directory.Exists(value), nameof(CanCompressFolder)); @@ -48,9 +53,11 @@ public string FolderPath { public bool CanCompressFolder => _canCompressFolder; private bool _useDictionaries = true; - public bool UseDictionaries { + public bool UseDictionaries + { get => _useDictionaries; - set { + set + { this.RaiseAndSetIfChanged(ref _useDictionaries, value); } } @@ -58,15 +65,19 @@ public bool UseDictionaries { public async Task Browse(object param) { var mode = param as string; - if (mode == "File") { + if (mode == "File") + { BrowserDialog dialog = new(BrowserMode.OpenFile, "Open zStd File", "zStd Files:*.zs|Any File:*.*", instanceBrowserKey: "load"); - if (await dialog.ShowDialog() is string path) { + if (await dialog.ShowDialog() is string path) + { FilePath = path; } } - else if (mode == "Folder") { + else if (mode == "Folder") + { BrowserDialog dialog = new(BrowserMode.OpenFolder, "Open Folder", instanceBrowserKey: "load-fld"); - if (await dialog.ShowDialog() is string path) { + if (await dialog.ShowDialog() is string path) + { FolderPath = path; } } @@ -76,21 +87,25 @@ public async Task Browse(object param) public async Task Decompress() { - if (!await CheckConfig()) { + if (!await CheckConfig()) + { return; } - try { + try + { string outputFile = Path.GetFileNameWithoutExtension(FilePath); BrowserDialog dialog = new(BrowserMode.SaveFile, "Save Decompressed File", $"Raw File:*{Path.GetExtension(outputFile)}|Any File:*.*", outputFile, "save"); - if (await dialog.ShowDialog() is string path) { + if (await dialog.ShowDialog() is string path) + { StartLoading(1); ZstdHelper.Decompress(FilePath, path); UpdateCount(1); - ContentDialog dlg = new() { + ContentDialog dlg = new() + { Content = $"File Decompressed to '{path}'", DefaultButton = ContentDialogButton.Primary, PrimaryButtonText = "Close", @@ -101,9 +116,12 @@ public async Task Decompress() StopLoading(); } } - catch (Exception ex) { - ContentDialog dlg = new() { - Content = new TextBox { + catch (Exception ex) + { + ContentDialog dlg = new() + { + Content = new TextBox + { MaxHeight = 250, Text = ex.ToString(), IsReadOnly = true, @@ -114,24 +132,29 @@ public async Task Decompress() await dlg.ShowAsync(); } - finally { + finally + { StopLoading(); } } public async Task Compress() { - if (!await CheckConfig()) { + if (!await CheckConfig()) + { return; } - try { + try + { string outputFile = $"{Path.GetFileName(FilePath)}.zs"; BrowserDialog dialog = new(BrowserMode.SaveFile, "Save Compressed File", $"Zstd Compressed File:*.zs|Any File:*.*", outputFile, "save"); - if (await dialog.ShowDialog() is string path) { + if (await dialog.ShowDialog() is string path) + { ZstdHelper.Compress(FilePath, path, UseDictionaries); - ContentDialog dlg = new() { + ContentDialog dlg = new() + { Content = $"File compressed to '{path}'", DefaultButton = ContentDialogButton.Primary, PrimaryButtonText = "Close", @@ -141,9 +164,12 @@ public async Task Compress() await dlg.ShowAsync(); } } - catch (Exception ex) { - ContentDialog dlg = new() { - Content = new TextBox { + catch (Exception ex) + { + ContentDialog dlg = new() + { + Content = new TextBox + { MaxHeight = 250, Text = ex.ToString(), IsReadOnly = true, @@ -154,25 +180,30 @@ public async Task Compress() await dlg.ShowAsync(); } - finally { + finally + { StopLoading(); } } public async Task DecompressFolder() { - if (!await CheckConfig()) { + if (!await CheckConfig()) + { return; } - try { + try + { string outputFile = Path.GetFileNameWithoutExtension(FilePath); BrowserDialog dialog = new(BrowserMode.OpenFolder, "Output Folder", "save-fld"); - if (await dialog.ShowDialog() is string path && Directory.Exists(path)) { + if (await dialog.ShowDialog() is string path && Directory.Exists(path)) + { StartLoading(); await Task.Run(() => ZstdHelper.DecompressFolder(FolderPath, path, DecompressRecursive, SetCount, UpdateCount)); - ContentDialog dlg = new() { + ContentDialog dlg = new() + { Content = $"Folder Decompressed to '{path}'", DefaultButton = ContentDialogButton.Primary, PrimaryButtonText = "Close", @@ -183,9 +214,12 @@ public async Task DecompressFolder() StopLoading(); } } - catch (Exception ex) { - ContentDialog dlg = new() { - Content = new TextBox { + catch (Exception ex) + { + ContentDialog dlg = new() + { + Content = new TextBox + { MaxHeight = 250, Text = ex.ToString(), IsReadOnly = true, @@ -200,18 +234,22 @@ public async Task DecompressFolder() public async Task CompressFolder() { - if (!await CheckConfig()) { + if (!await CheckConfig()) + { return; } - try { + try + { string outputFile = Path.GetFileNameWithoutExtension(FilePath); BrowserDialog dialog = new(BrowserMode.OpenFolder, "Output Folder", "save-fld"); - if (await dialog.ShowDialog() is string path && Directory.Exists(path)) { + if (await dialog.ShowDialog() is string path && Directory.Exists(path)) + { StartLoading(); await Task.Run(() => ZstdHelper.CompressFolder(FolderPath, path, DecompressRecursive, SetCount, UpdateCount, UseDictionaries)); - ContentDialog dlg = new() { + ContentDialog dlg = new() + { Content = $"Folder compressed to '{path}'", DefaultButton = ContentDialogButton.Primary, PrimaryButtonText = "Close", @@ -222,9 +260,12 @@ public async Task CompressFolder() StopLoading(); } } - catch (Exception ex) { - ContentDialog dlg = new() { - Content = new TextBox { + catch (Exception ex) + { + ContentDialog dlg = new() + { + Content = new TextBox + { MaxHeight = 250, Text = ex.ToString(), IsReadOnly = true, @@ -239,10 +280,13 @@ public async Task CompressFolder() public static async Task ShowSettings() { - ContentDialog dlg = new() { - Content = new ScrollViewer { + ContentDialog dlg = new() + { + Content = new ScrollViewer + { MaxHeight = 250, - Content = new StackPanel { + Content = new StackPanel + { Margin = new(0, 0, 15, 0), Spacing = 10, Children = { @@ -260,7 +304,8 @@ public static async Task ShowSettings() Title = "Settings" }; - if (await dlg.ShowAsync() == ContentDialogResult.Primary) { + if (await dlg.ShowAsync() == ContentDialogResult.Primary) + { var stack = (dlg.Content as ScrollViewer)!.Content as StackPanel; TotkCommon.Totk.Config.GamePath = (stack!.Children[0] as TextBox)!.Text!; TotkCommon.Totk.Config.Save(); @@ -269,15 +314,18 @@ public static async Task ShowSettings() public static async Task CheckConfig() { - if (File.Exists(TotkCommon.Totk.Config.ZsDicPath)) { + if (File.Exists(TotkCommon.Totk.Config.ZsDicPath)) + { return true; } - ContentDialog dialog = new() { - Content = new HyperlinkButton { + ContentDialog dialog = new() + { + Content = new HyperlinkButton + { MaxHeight = 250, Content = "Please read the documentation for help", - NavigateUri = new Uri("https://github.com/TotkMods/Totk.ZStdTool#setup") + NavigateUri = new Uri("https://github.com/TotkMods/TotkZstdTool#setup") }, PrimaryButtonText = "OK", Title = "Invalid Game Path" @@ -290,32 +338,37 @@ public static async Task CheckConfig() // // Loading stuff - private readonly DispatcherTimer _timer = new() { + private readonly DispatcherTimer _timer = new() + { Interval = new(0, 0, 0, 0, 500), }; public ShellViewModel() { - _timer.Tick += (s, e) => { + _timer.Tick += (s, e) => + { LoadingDots += " ."; LoadingDots = LoadingDots.Replace(" . . . . .", " ."); }; } private bool _isLoading = false; - public bool IsLoading { + public bool IsLoading + { get => _isLoading; set => this.RaiseAndSetIfChanged(ref _isLoading, value); } private string _loadingDots = " . . . ."; - public string LoadingDots { + public string LoadingDots + { get => _loadingDots; set => this.RaiseAndSetIfChanged(ref _loadingDots, value); } private string _processCount = "-/-"; - public string ProcessCount { + public string ProcessCount + { get => _processCount; set => this.RaiseAndSetIfChanged(ref _processCount, value); } @@ -325,7 +378,8 @@ public void StartLoading(int? initCount = null) _timer.Start(); IsLoading = true; - if (initCount is int num) { + if (initCount is int num) + { SetCount(num); } } diff --git a/src/Views/ShellView.axaml b/src/Views/ShellView.axaml index c196f47..5ef0e3f 100644 --- a/src/Views/ShellView.axaml +++ b/src/Views/ShellView.axaml @@ -1,4 +1,4 @@ -