From 45c3f90da059700f45a7f3e97572d2ec41a5517b Mon Sep 17 00:00:00 2001 From: Timerix Date: Fri, 27 Sep 2024 02:12:07 +0500 Subject: [PATCH] =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Млаумчерб.Клиент/LauncherLogger.cs | 13 ---- Млаумчерб.Клиент/Главне.cs | 6 +- Млаумчерб.Клиент/Игра.cs | 14 ++-- Млаумчерб.Клиент/Логи.cs | 79 ++++++++++++++++++++ Млаумчерб.Клиент/Млаумчерб.Клиент.csproj | 5 +- Млаумчерб.Клиент/Настройки.cs | 10 +-- Млаумчерб.Клиент/Ошибки.cs | 2 +- Млаумчерб.Клиент/Сеть.cs | 16 ++-- Млаумчерб.Клиент/видимое/Окне.axaml | 54 +++++++------ Млаумчерб.Клиент/видимое/Окне.axaml.cs | 69 ++++++++++------- Млаумчерб.Клиент/видимое/Приложение.axaml | 23 +++++- Млаумчерб.Клиент/видимое/Приложение.axaml.cs | 6 +- Млаумчерб.Клиент/классы/GameVersionProps.cs | 4 +- Млаумчерб.Клиент/классы/Пролетариат.cs | 25 +------ Млаумчерб.Клиент/классы/Пути.cs | 27 +++++++ 15 files changed, 238 insertions(+), 115 deletions(-) delete mode 100644 Млаумчерб.Клиент/LauncherLogger.cs create mode 100644 Млаумчерб.Клиент/Логи.cs create mode 100644 Млаумчерб.Клиент/классы/Пути.cs diff --git a/Млаумчерб.Клиент/LauncherLogger.cs b/Млаумчерб.Клиент/LauncherLogger.cs deleted file mode 100644 index bb91442..0000000 --- a/Млаумчерб.Клиент/LauncherLogger.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Млаумчерб.Клиент; - -public class LauncherLogger : FileLogger -{ - public static readonly IOPath LogsDirectory = "launcher_logs"; - - public LauncherLogger() : base(LogsDirectory, "млаумчерб") - { -#if DEBUG - DebugLogEnabled = true; -#endif - } -} \ No newline at end of file diff --git a/Млаумчерб.Клиент/Главне.cs b/Млаумчерб.Клиент/Главне.cs index f5fa8f4..e055cec 100644 --- a/Млаумчерб.Клиент/Главне.cs +++ b/Млаумчерб.Клиент/Главне.cs @@ -19,10 +19,6 @@ namespace Млаумчерб.Клиент; public class Главне { - public static readonly LauncherLogger Логгер = new(); - - public static Настройки Настройки = new(); - [STAThread] public static void Main(string[] args) { @@ -34,7 +30,7 @@ public class Главне } catch (Exception ex) { - Логгер.LogError(nameof(Главне), ex); + Приложение.Логгер.LogError(nameof(Главне), ex); } } diff --git a/Млаумчерб.Клиент/Игра.cs b/Млаумчерб.Клиент/Игра.cs index 0fa62a3..19b3c84 100644 --- a/Млаумчерб.Клиент/Игра.cs +++ b/Млаумчерб.Клиент/Игра.cs @@ -2,7 +2,7 @@ using DTLib.Extensions; using Млаумчерб.Клиент.видимое; using Млаумчерб.Клиент.классы; -using static Млаумчерб.Клиент.классы.Пролетариат; +using static Млаумчерб.Клиент.классы.Пути; namespace Млаумчерб.Клиент; @@ -49,13 +49,13 @@ public class GameVersionDescriptor private GameVersionDescriptor(GameVersionProps props) { _props = props; - WorkingDirectory = Path.Concat(Главне.Настройки.путь_к_кубачу, Name); + WorkingDirectory = Path.Concat(Приложение.Настройки.путь_к_кубачу, Name); string descriptorText = File.ReadAllText(props.LocalDescriptorPath); descriptor = JsonConvert.DeserializeObject(descriptorText) ?? throw new Exception($"can't parse descriptor file '{props.LocalDescriptorPath}'"); javaArgs = new JavaArguments(descriptor); gameArgs = new GameArguments(descriptor); - JavaExecutableFilePath = Path.Concat(Главне.Настройки.путь_к_жабе, "bin", + JavaExecutableFilePath = Path.Concat(Приложение.Настройки.путь_к_жабе, "bin", OperatingSystem.IsWindows() ? "javaw.exe" : "javaw"); } @@ -64,8 +64,8 @@ public class GameVersionDescriptor try { downloadCts = new CancellationTokenSource(); - if(Главне.Настройки.скачать_жабу) - await Сеть.DownloadJava(descriptor.javaVersion, Главне.Настройки.путь_к_жабе, force); + if(Приложение.Настройки.скачать_жабу) + await Сеть.DownloadJava(descriptor.javaVersion, Приложение.Настройки.путь_к_жабе, force); await Сеть.DownloadAssets(descriptor.assetIndex, downloadCts.Token, force); await Сеть.DownloadVersionFile(descriptor.downloads.client.url, GetVersionJarFilePath(Name), force); await Сеть.DownloadLibraries(descriptor.libraries, GetLibrariesDir(), force); @@ -91,7 +91,7 @@ public class GameVersionDescriptor .WithWorkingDirectory(WorkingDirectory.ToString()) .WithArguments(javaArgsList) .WithArguments(gameArgsList); - Главне.Логгер.LogInfo(nameof(GameVersionDescriptor), + Приложение.Логгер.LogInfo(nameof(GameVersionDescriptor), $"launching the game" + "\njava: " + command.TargetFilePath + "\nworking_dir: " + command.WorkingDirPath + @@ -100,7 +100,7 @@ public class GameVersionDescriptor gameCts = new(); commandTask = command.ExecuteAsync(gameCts.Token); var result = await commandTask; - Главне.Логгер.LogInfo(nameof(GameVersionDescriptor), $"game exited with code {result.ExitCode}"); + Приложение.Логгер.LogInfo(nameof(GameVersionDescriptor), $"game exited with code {result.ExitCode}"); } public void Close() diff --git a/Млаумчерб.Клиент/Логи.cs b/Млаумчерб.Клиент/Логи.cs new file mode 100644 index 0000000..ed58b09 --- /dev/null +++ b/Млаумчерб.Клиент/Логи.cs @@ -0,0 +1,79 @@ +namespace Млаумчерб.Клиент; + +public class LauncherLogger : ILogger +{ + private CompositeLogger _compositeLogger; + private FileLogger _fileLogger; + public static readonly IOPath LogsDirectory = "launcher_logs"; + public IOPath LogfileName => _fileLogger.LogfileName; + + public LauncherLogger() + { + _fileLogger = new FileLogger(LogsDirectory, "млаумчерб"); + ILogger[] loggers = + [ + _fileLogger, +#if DEBUG + new ConsoleLogger(), +#endif + ]; + _compositeLogger = new CompositeLogger(loggers); + +#if DEBUG + DebugLogEnabled = true; +#endif + } + + public delegate void LogHandler(string context, LogSeverity severity, object message, ILogFormat format); + public event LogHandler? OnLogMessage; + + public void Log(string context, LogSeverity severity, object message, ILogFormat format) + { + _compositeLogger.Log(context, severity, message, format); + bool isEnabled = severity switch + { + LogSeverity.Debug => DebugLogEnabled, + LogSeverity.Info => InfoLogEnabled, + LogSeverity.Warn => WarnLogEnabled, + LogSeverity.Error => ErrorLogEnabled, + _ => throw new ArgumentOutOfRangeException(nameof(severity), severity, null) + }; + if(isEnabled) + OnLogMessage?.Invoke(context, severity, message, format); + } + + public void Dispose() + { + _compositeLogger.Dispose(); + } + + public ILogFormat Format + { + get => _compositeLogger.Format; + set => _compositeLogger.Format = value; + } + + public bool DebugLogEnabled + { + get => _compositeLogger.DebugLogEnabled; + set => _compositeLogger.DebugLogEnabled = value; + } + + public bool InfoLogEnabled + { + get => _compositeLogger.InfoLogEnabled; + set => _compositeLogger.InfoLogEnabled = value; + } + + public bool WarnLogEnabled + { + get => _compositeLogger.WarnLogEnabled; + set => _compositeLogger.WarnLogEnabled = value; + } + + public bool ErrorLogEnabled + { + get => _compositeLogger.ErrorLogEnabled; + set => _compositeLogger.ErrorLogEnabled = value; + } +} \ No newline at end of file diff --git a/Млаумчерб.Клиент/Млаумчерб.Клиент.csproj b/Млаумчерб.Клиент/Млаумчерб.Клиент.csproj index 7d66827..9fe7199 100644 --- a/Млаумчерб.Клиент/Млаумчерб.Клиент.csproj +++ b/Млаумчерб.Клиент/Млаумчерб.Клиент.csproj @@ -1,6 +1,7 @@  - WinExe + Exe + WinExe net8.0 latest enable @@ -21,7 +22,7 @@ - + diff --git a/Млаумчерб.Клиент/Настройки.cs b/Млаумчерб.Клиент/Настройки.cs index 68ee790..3c6097d 100644 --- a/Млаумчерб.Клиент/Настройки.cs +++ b/Млаумчерб.Клиент/Настройки.cs @@ -14,10 +14,10 @@ public record Настройки public static Настройки ЗагрузитьИзФайла(string имя_файла = "млаумчерб.настройки") { - Главне.Логгер.LogInfo(nameof(Настройки), $"попытка загрузить настройки из файла '{имя_файла}'"); + Приложение.Логгер.LogInfo(nameof(Настройки), $"попытка загрузить настройки из файла '{имя_файла}'"); if(!File.Exists(имя_файла)) { - Главне.Логгер.LogInfo(nameof(Настройки), "файл не существует"); + Приложение.Логгер.LogInfo(nameof(Настройки), "файл не существует"); return new Настройки(); } @@ -33,15 +33,15 @@ public record Настройки $"Создан новый файл '{имя_файла}'."); } - Главне.Логгер.LogInfo(nameof(Настройки), $"настройки загружены: {н}"); + Приложение.Логгер.LogInfo(nameof(Настройки), $"настройки загружены: {н}"); return н; } public void СохранитьВФайл(string имя_файла = "млаумчерб.настройки") { - Главне.Логгер.LogInfo(nameof(Настройки), $"попытка сохранить настройки в файл '{имя_файла}'"); + Приложение.Логгер.LogInfo(nameof(Настройки), $"попытка сохранить настройки в файл '{имя_файла}'"); var текст = JsonConvert.SerializeObject(this, Formatting.Indented); File.WriteAllText(имя_файла, текст); - Главне.Логгер.LogInfo(nameof(Настройки), $"настройки сохранены: {текст}"); + Приложение.Логгер.LogInfo(nameof(Настройки), $"настройки сохранены: {текст}"); } } \ No newline at end of file diff --git a/Млаумчерб.Клиент/Ошибки.cs b/Млаумчерб.Клиент/Ошибки.cs index 2933861..3bf5e4a 100644 --- a/Млаумчерб.Клиент/Ошибки.cs +++ b/Млаумчерб.Клиент/Ошибки.cs @@ -15,7 +15,7 @@ public static class Ошибки internal static async void ПоказатьСообщение(string context, string err) { - Главне.Логгер.LogError(nameof(Ошибки), err); + Приложение.Логгер.LogError(nameof(Ошибки), err); var box = MessageBoxManager.GetMessageBoxCustom(new MessageBoxCustomParams { ButtonDefinitions = new List { new() { Name = "пон" } }, diff --git a/Млаумчерб.Клиент/Сеть.cs b/Млаумчерб.Клиент/Сеть.cs index ee1f2c3..e102068 100644 --- a/Млаумчерб.Клиент/Сеть.cs +++ b/Млаумчерб.Клиент/Сеть.cs @@ -55,7 +55,7 @@ public static class Сеть public static async Task DownloadAssets(AssetIndexProperties assetIndexProperties, CancellationToken ct, bool force) { - IOPath indexFilePath = Пролетариат.GetAssetIndexFilePath(assetIndexProperties.id); + IOPath indexFilePath = Пути.GetAssetIndexFilePath(assetIndexProperties.id); if (File.Exists(indexFilePath) && !force) return; @@ -64,9 +64,9 @@ public static class Сеть File.Delete(indexFilePathTmp); // TODO: add something to Downloads ScrollList - Главне.Логгер.LogInfo(nameof(DownloadAssets), $"started downloading asset index to '{indexFilePathTmp}'"); + Приложение.Логгер.LogInfo(nameof(DownloadAssets), $"started downloading asset index to '{indexFilePathTmp}'"); await DownloadFileHTTP(assetIndexProperties.url, indexFilePathTmp, null, ct); - Главне.Логгер.LogInfo(nameof(DownloadAssets), "finished downloading asset index"); + Приложение.Логгер.LogInfo(nameof(DownloadAssets), "finished downloading asset index"); string indexFileText = File.ReadAllText(indexFilePathTmp); AssetIndex assetIndex = JsonConvert.DeserializeObject(indexFileText) @@ -102,13 +102,13 @@ public static class Сеть long bytesPerSec = (currentSize - prevSize) / (timerDelay / 1000); float KbytesPerSec = bytesPerSec / 1024f; prevSize = currentSize; - Главне.Логгер.LogDebug(nameof(DownloadAssets), + Приложение.Логгер.LogDebug(nameof(DownloadAssets), $"download progress {currentSizeM}Mb/{totalSizeM}Mb ({KbytesPerSec}Kb/s)"); } using Timer timer = new Timer(true, timerDelay, ReportProgress); timer.Start(); - Главне.Логгер.LogInfo(nameof(DownloadAssets), "started downloading assets"); + Приложение.Логгер.LogInfo(nameof(DownloadAssets), "started downloading assets"); int parallelDownloads = 32; var tasks = new Task[parallelDownloads]; var currentlyDownloadingFileHashes = new string[parallelDownloads]; @@ -119,7 +119,7 @@ public static class Сеть string hashStart = hash.Substring(0, 2); var assetUrl = $"{ASSET_SERVER_URL}/{hashStart}/{hash}"; IOPath assetFilePath = Path.Concat("assets", "objects", hashStart, hash); - Главне.Логгер.LogDebug(nameof(DownloadAssets), $"downloading asset '{a.Key}' {hash}"); + Приложение.Логгер.LogDebug(nameof(DownloadAssets), $"downloading asset '{a.Key}' {hash}"); tasks[i] = DownloadFileHTTP(assetUrl, assetFilePath, AddBytesCountAtomic, ct); currentlyDownloadingFileHashes[i] = hash; if (++i == parallelDownloads) @@ -133,7 +133,7 @@ public static class Сеть timer.Stop(); timer.InvokeAction(); File.Move(indexFilePathTmp, indexFilePath, true); - Главне.Логгер.LogInfo(nameof(DownloadAssets), "finished downloading assets"); + Приложение.Логгер.LogInfo(nameof(DownloadAssets), "finished downloading assets"); } private static async Task> GetRemoteVersionDescriptorsAsync() @@ -150,7 +150,7 @@ public static class Сеть } catch (Exception ex) { - Главне.Логгер.LogWarn(nameof(Сеть), ex); + Приложение.Логгер.LogWarn(nameof(Сеть), ex); } } return descriptors; diff --git a/Млаумчерб.Клиент/видимое/Окне.axaml b/Млаумчерб.Клиент/видимое/Окне.axaml index 5ba4cd3..c9e5c73 100644 --- a/Млаумчерб.Клиент/видимое/Окне.axaml +++ b/Млаумчерб.Клиент/видимое/Окне.axaml @@ -6,7 +6,7 @@ Name="window" Title="млаумчерб" Icon="avares://млаумчерб/капитал/кубе.ico" - FontFamily="{StaticResource PlexMono}" FontSize="18" + FontFamily="{StaticResource MonospaceFont}" FontSize="18" MinWidth="800" MinHeight="500" Width="800" Height="500" WindowStartupLocation="CenterScreen"> @@ -25,9 +25,18 @@ - News + Лог + + + * 60 - Version: - - - + Версия: + - Username: - + Ник: + - Memory limit: + Выделенная память: - Mb + Мб - Fullscreen + Запустить полноэкранное - - Force update game files + + Проверить файлы игры @@ -81,21 +89,25 @@ - Downloads + Загрузки + - - - + + + - + diff --git a/Млаумчерб.Клиент/видимое/Окне.axaml.cs b/Млаумчерб.Клиент/видимое/Окне.axaml.cs index fa8df61..9921217 100644 --- a/Млаумчерб.Клиент/видимое/Окне.axaml.cs +++ b/Млаумчерб.Клиент/видимое/Окне.axaml.cs @@ -1,9 +1,11 @@ using Avalonia; using Avalonia.Controls; +using Avalonia.Controls.Presenters; using Avalonia.Data; using Avalonia.Interactivity; using Avalonia.Platform.Storage; using Avalonia.Threading; +using Avalonia.VisualTree; using Млаумчерб.Клиент.классы; namespace Млаумчерб.Клиент.видимое; @@ -37,13 +39,13 @@ public partial class Окне : Window set => SetValue(FullscreenProperty, value); } - public static readonly StyledProperty ForceUpdateGameFilesProperty = - AvaloniaProperty.Register<Окне, bool>(nameof(ForceUpdateGameFiles), + public static readonly StyledProperty CheckGameFilesProperty = + AvaloniaProperty.Register<Окне, bool>(nameof(CheckGameFiles), defaultBindingMode: BindingMode.TwoWay, defaultValue: false); - public bool ForceUpdateGameFiles + public bool CheckGameFiles { - get => GetValue(ForceUpdateGameFilesProperty); - set => SetValue(ForceUpdateGameFilesProperty, value); + get => GetValue(CheckGameFilesProperty); + set => SetValue(CheckGameFilesProperty, value); } public Окне() @@ -55,12 +57,28 @@ public partial class Окне : Window { try { - Главне.Настройки = Настройки.ЗагрузитьИзФайла(); - Username = Главне.Настройки.имя_пользователя; - MemoryLimit = Главне.Настройки.выделенная_память_мб; - Fullscreen = Главне.Настройки.открывать_на_весь_экран; + Приложение.Логгер.OnLogMessage += (context, severity, message, format) => + { + StringBuilder b = new(); + b.Append(DateTime.Now.ToString("[HH:mm:ss][")); + b.Append(severity); + b.Append("]: "); + b.Append(message); + b.Append('\n'); + double offsetFromBottom = LogScrollViewer.Extent.Height + - LogScrollViewer.Offset.Y + - LogScrollViewer.Viewport.Height; + bool is_scrolled_to_end = offsetFromBottom < 20.0; // scrolled less then one line up + LogTextBox.Text += b.ToString(); + if(is_scrolled_to_end) + LogScrollViewer.ScrollToEnd(); + }; - Directory.Create(Пролетариат.GetVersionDescriptorDir()); + Username = Приложение.Настройки.имя_пользователя; + MemoryLimit = Приложение.Настройки.выделенная_память_мб; + Fullscreen = Приложение.Настройки.открывать_на_весь_экран; + + Directory.Create(Пути.GetVersionDescriptorDir()); VersionComboBox.SelectedIndex = 0; VersionComboBox.IsEnabled = false; var versions = await GameVersionDescriptor.GetAllVersionsAsync(); @@ -69,8 +87,8 @@ public partial class Окне : Window foreach (var p in versions) { VersionComboBox.Items.Add(new VersionItemView(p)); - if (Главне.Настройки.последняя_запущенная_версия != null && - p.Name == Главне.Настройки.последняя_запущенная_версия) + if (Приложение.Настройки.последняя_запущенная_версия != null && + p.Name == Приложение.Настройки.последняя_запущенная_версия) VersionComboBox.SelectedIndex = VersionComboBox.Items.Count - 1; } VersionComboBox.IsEnabled = true; @@ -82,24 +100,23 @@ public partial class Окне : Window } } - private async void LaunchButtonHandler(object? sender, RoutedEventArgs e) + private async void Запуск(object? sender, RoutedEventArgs e) { try { - var selectedVersionView = (VersionItemView?)VersionComboBox.SelectedItem; var selectedVersion = selectedVersionView?.Props; - Главне.Настройки.последняя_запущенная_версия = selectedVersion?.Name; - Главне.Настройки.имя_пользователя = Username; - Главне.Настройки.выделенная_память_мб = MemoryLimit; - Главне.Настройки.открывать_на_весь_экран = Fullscreen; - Главне.Настройки.СохранитьВФайл(); + Приложение.Настройки.последняя_запущенная_версия = selectedVersion?.Name; + Приложение.Настройки.имя_пользователя = Username; + Приложение.Настройки.выделенная_память_мб = MemoryLimit; + Приложение.Настройки.открывать_на_весь_экран = Fullscreen; + Приложение.Настройки.СохранитьВФайл(); if (selectedVersion == null) return; var v = await GameVersionDescriptor.CreateFromPropsAsync(selectedVersion); - v.BeginUpdate(ForceUpdateGameFiles); - Dispatcher.UIThread.Invoke(() => ForceUpdateGameFiles = false); + v.BeginUpdate(CheckGameFiles); + Dispatcher.UIThread.Invoke(() => CheckGameFiles = false); } catch (Exception ex) { @@ -107,11 +124,11 @@ public partial class Окне : Window } } - private void OpenLogsDirectory(object? s, RoutedEventArgs e) + private void ОткрытьПапкуЛаунчера(object? s, RoutedEventArgs e) { try { - Launcher.LaunchDirectoryInfoAsync(new DirectoryInfo(LauncherLogger.LogsDirectory.ToString())) + Launcher.LaunchDirectoryInfoAsync(new DirectoryInfo(Directory.GetCurrent().ToString())) .ConfigureAwait(false); } catch (Exception ex) @@ -120,11 +137,11 @@ public partial class Окне : Window } } - private void OpenLogFile(object? sender, RoutedEventArgs e) + private void ОткрытьФайлЛогов(object? sender, RoutedEventArgs e) { try { - Launcher.LaunchFileInfoAsync(new FileInfo(Главне.Логгер.LogfileName.ToString())) + Launcher.LaunchFileInfoAsync(new FileInfo(Приложение.Логгер.LogfileName.ToString())) .ConfigureAwait(false); } catch (Exception ex) @@ -133,7 +150,7 @@ public partial class Окне : Window } } - private void OpenSourceRepository(object? sender, RoutedEventArgs e) + private void ОткрытьРепозиторий(object? sender, RoutedEventArgs e) { try { diff --git a/Млаумчерб.Клиент/видимое/Приложение.axaml b/Млаумчерб.Клиент/видимое/Приложение.axaml index dea9033..9c71f16 100644 --- a/Млаумчерб.Клиент/видимое/Приложение.axaml +++ b/Млаумчерб.Клиент/видимое/Приложение.axaml @@ -30,9 +30,30 @@ + + + + + + - avares://млаумчерб/капитал/IBMPlexMono-Regular.ttf + avares://млаумчерб/капитал/IBMPlexMono-Regular.ttf \ No newline at end of file diff --git a/Млаумчерб.Клиент/видимое/Приложение.axaml.cs b/Млаумчерб.Клиент/видимое/Приложение.axaml.cs index 5c52462..744411e 100644 --- a/Млаумчерб.Клиент/видимое/Приложение.axaml.cs +++ b/Млаумчерб.Клиент/видимое/Приложение.axaml.cs @@ -6,9 +6,13 @@ namespace Млаумчерб.Клиент.видимое; public class Приложение : Application { + public static LauncherLogger Логгер = new(); + public static Настройки Настройки = new(); + public override void Initialize() { - Главне.Логгер.LogInfo(nameof(Приложение), "приложение запущено"); + Логгер.LogInfo(nameof(Приложение), "приложение запущено"); + Настройки = Настройки.ЗагрузитьИзФайла(); AvaloniaXamlLoader.Load(this); } diff --git a/Млаумчерб.Клиент/классы/GameVersionProps.cs b/Млаумчерб.Клиент/классы/GameVersionProps.cs index 97f3794..6c57495 100644 --- a/Млаумчерб.Клиент/классы/GameVersionProps.cs +++ b/Млаумчерб.Клиент/классы/GameVersionProps.cs @@ -22,11 +22,11 @@ public class GameVersionProps Name = name; LocalDescriptorPath = descriptorPath; RemoteDescriptorUrl = url; - IsDownloaded = File.Exists(Пролетариат.GetVersionJarFilePath(name)); + IsDownloaded = File.Exists(Пути.GetVersionJarFilePath(name)); } public GameVersionProps(string name, string? url) : - this(name, url, Пролетариат.GetVersionDescriptorPath(name)) { } + this(name, url, Пути.GetVersionDescriptorPath(name)) { } public override string ToString() => Name; } diff --git a/Млаумчерб.Клиент/классы/Пролетариат.cs b/Млаумчерб.Клиент/классы/Пролетариат.cs index c8e2fc6..399532e 100644 --- a/Млаумчерб.Клиент/классы/Пролетариат.cs +++ b/Млаумчерб.Клиент/классы/Пролетариат.cs @@ -1,27 +1,6 @@ -using Млаумчерб.Клиент.видимое; - -namespace Млаумчерб.Клиент.классы; +namespace Млаумчерб.Клиент.классы; public static class Пролетариат { - public static IOPath GetAssetIndexFilePath(string id) => - Path.Concat(Главне.Настройки.путь_к_кубачу, $"assets/indexes/{id}.json"); - public static IOPath GetVersionDescriptorDir() => - Path.Concat(Главне.Настройки.путь_к_кубачу, "version_descriptors"); - - public static string GetVersionDescriptorName(IOPath path) => - path.LastName().RemoveExtension().ToString(); - - public static IOPath GetVersionDescriptorPath(string name) => - Path.Concat(GetVersionDescriptorDir(), Path.ReplaceRestrictedChars(name) + ".json"); - - public static IOPath GetVersionDir() => - Path.Concat(Главне.Настройки.путь_к_кубачу, "versions"); - - public static IOPath GetVersionJarFilePath(string name) => - Path.Concat(GetVersionDir(), name + ".jar"); - - public static IOPath GetLibrariesDir() => - Path.Concat(Главне.Настройки.путь_к_кубачу, "libraries"); -} +} \ No newline at end of file diff --git a/Млаумчерб.Клиент/классы/Пути.cs b/Млаумчерб.Клиент/классы/Пути.cs new file mode 100644 index 0000000..7315924 --- /dev/null +++ b/Млаумчерб.Клиент/классы/Пути.cs @@ -0,0 +1,27 @@ +using Млаумчерб.Клиент.видимое; + +namespace Млаумчерб.Клиент.классы; + +public static class Пути +{ + public static IOPath GetAssetIndexFilePath(string id) => + Path.Concat(Приложение.Настройки.путь_к_кубачу, $"assets/indexes/{id}.json"); + + public static IOPath GetVersionDescriptorDir() => + Path.Concat(Приложение.Настройки.путь_к_кубачу, "version_descriptors"); + + public static string GetVersionDescriptorName(IOPath path) => + path.LastName().RemoveExtension().ToString(); + + public static IOPath GetVersionDescriptorPath(string name) => + Path.Concat(GetVersionDescriptorDir(), Path.ReplaceRestrictedChars(name) + ".json"); + + public static IOPath GetVersionDir() => + Path.Concat(Приложение.Настройки.путь_к_кубачу, "versions"); + + public static IOPath GetVersionJarFilePath(string name) => + Path.Concat(GetVersionDir(), name + ".jar"); + + public static IOPath GetLibrariesDir() => + Path.Concat(Приложение.Настройки.путь_к_кубачу, "libraries"); +}