diff --git a/Млаумчерб.Клиент/LauncherLogger.cs b/Млаумчерб.Клиент/LauncherLogger.cs new file mode 100644 index 0000000..cd7d219 --- /dev/null +++ b/Млаумчерб.Клиент/LauncherLogger.cs @@ -0,0 +1,13 @@ +using DTLib.Filesystem; +using DTLib.Logging; + +namespace Млаумчерб.Клиент; + +public class LauncherLogger : FileLogger +{ + public static readonly IOPath LogsDirectory = "launcher-logs"; + + public LauncherLogger() : base(LogsDirectory, "млаумчерб") + { + } +} \ No newline at end of file diff --git a/Млаумчерб.Клиент/Network.cs b/Млаумчерб.Клиент/Network.cs new file mode 100644 index 0000000..15f9f0d --- /dev/null +++ b/Млаумчерб.Клиент/Network.cs @@ -0,0 +1,13 @@ +namespace Млаумчерб.Клиент; + +public record struct NetworkTransferResult +{ + public long BytesTotal; + public long BytesTransferred; + public long BytesPerSecond; +} + +public class NetworkHelper +{ + +} \ No newline at end of file diff --git a/Млаумчерб.Клиент/Главне.cs b/Млаумчерб.Клиент/Главне.cs index 9ad4dc6..26adaf6 100644 --- a/Млаумчерб.Клиент/Главне.cs +++ b/Млаумчерб.Клиент/Главне.cs @@ -2,6 +2,10 @@ global using System.Collections.Generic; global using System.IO; global using System.Text; +global using DTLib.Logging; +global using DTLib.Filesystem; +global using File = DTLib.Filesystem.File; +global using Directory = DTLib.Filesystem.Directory; using System.Globalization; using Avalonia; diff --git a/Млаумчерб.Клиент/Игра.cs b/Млаумчерб.Клиент/Игра.cs new file mode 100644 index 0000000..31c2145 --- /dev/null +++ b/Млаумчерб.Клиент/Игра.cs @@ -0,0 +1,41 @@ +using System.Threading.Tasks; +using DTLib.Filesystem; +using Path = DTLib.Filesystem.Path; + +namespace Млаумчерб.Клиент; + +public interface IGame +{ + string Name { get; } + IOPath InstallationDirectory { get; } + Progress BeginUpdate(); + void EndUpdate(); + Task Launch(); +} + +public class MinecraftVersion : IGame +{ + public string Name { get; } + public IOPath InstallationDirectory { get; } + + public MinecraftVersion(string name) + { + Name = name; + InstallationDirectory = Path.Concat("minecraft", Path.ReplaceRestrictedChars(name)); + } + + public Progress BeginUpdate() + { + throw new NotImplementedException(); + } + + public void EndUpdate() + { + throw new NotImplementedException(); + } + + public Task Launch() + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Млаумчерб.Клиент/Млаумчерб.Клиент.csproj b/Млаумчерб.Клиент/Млаумчерб.Клиент.csproj index 1c11a44..6f12b6f 100644 --- a/Млаумчерб.Клиент/Млаумчерб.Клиент.csproj +++ b/Млаумчерб.Клиент/Млаумчерб.Клиент.csproj @@ -13,15 +13,17 @@ - - - - - - - - - + + + + + + + + + + + diff --git a/Млаумчерб.Клиент/Настройки.cs b/Млаумчерб.Клиент/Настройки.cs index 28ba930..fccfe8b 100644 --- a/Млаумчерб.Клиент/Настройки.cs +++ b/Млаумчерб.Клиент/Настройки.cs @@ -1,20 +1,20 @@ -using Newtonsoft.Json; +using DTLib.Logging; +using Newtonsoft.Json; namespace Млаумчерб.Клиент; -public class Настройки +public record Настройки { public string имя_пользователя { get; set; } = ""; public int выделенная_память_мб { get; set; } = 4096; public bool открывать_на_весь_экран { get; set; } - - public static readonly Encoding UTF8WithoutBom = new UTF8Encoding(false); public static Настройки ЗагрузитьИзФайла(string имя_файла = "млаумчерб.настройки") { - //TODO: лог + Приложение.Логгер.LogInfo(nameof(Настройки), $"попытка загрузить настройки из файла '{имя_файла}'"); if(!File.Exists(имя_файла)) { + Приложение.Логгер.LogInfo(nameof(Настройки), "файл не существует"); return new Настройки(); } @@ -30,13 +30,15 @@ public class Настройки $"Создан новый файл '{имя_файла}'."); } + Приложение.Логгер.LogInfo(nameof(Настройки), $"настройки загружены: {н}"); return н; } public void СохранитьВФайл(string имя_файла = "млаумчерб.настройки") { - //TODO: log + Приложение.Логгер.LogInfo(nameof(Настройки), $"попытка сохранить настройки в файл '{имя_файла}'"); var текст = JsonConvert.SerializeObject(this, Formatting.Indented); - File.WriteAllText(имя_файла, текст, UTF8WithoutBom); + File.WriteAllText(имя_файла, текст); + Приложение.Логгер.LogInfo(nameof(Настройки), $"настройки сохранены: {текст}"); } } \ No newline at end of file diff --git a/Млаумчерб.Клиент/Окне.axaml b/Млаумчерб.Клиент/Окне.axaml index f4d22e4..59855e2 100644 --- a/Млаумчерб.Клиент/Окне.axaml +++ b/Млаумчерб.Клиент/Окне.axaml @@ -1,5 +1,7 @@ - 30 * 30 - - - + * 30 + + + * 300 * + Classes="dark_tr_bg white_border"> 30 * - 30 - + + + News + + + Classes="dark_tr_bg white_border" + Margin="10 0"> * 60 + Version: + + + + Username: + Memory limit: Mb + Fullscreen + Update game files - + + + + + + + + + diff --git a/Млаумчерб.Клиент/Окне.axaml.cs b/Млаумчерб.Клиент/Окне.axaml.cs index 0675045..3511493 100644 --- a/Млаумчерб.Клиент/Окне.axaml.cs +++ b/Млаумчерб.Клиент/Окне.axaml.cs @@ -1,8 +1,8 @@ -using System.ComponentModel.DataAnnotations; using Avalonia; using Avalonia.Controls; using Avalonia.Data; using Avalonia.Interactivity; +using Avalonia.Platform.Storage; namespace Млаумчерб.Клиент; @@ -79,4 +79,19 @@ public partial class Окне : Window Ошибки.ПоказатьСообщение(ex); } } + + private void OpenLogsDirectory(object? s, RoutedEventArgs e) + { + Launcher.LaunchDirectoryInfoAsync(new DirectoryInfo(LauncherLogger.LogsDirectory.ToString())); + } + + private void OpenLogFile(object? sender, RoutedEventArgs e) + { + Launcher.LaunchFileInfoAsync(new FileInfo(Приложение.Логгер.LogfileName.ToString())); + } + + private void OpenSourceRepository(object? sender, RoutedEventArgs e) + { + Launcher.LaunchUriAsync(new Uri("https://timerix.ddns.net:3322/Timerix/mlaumcherb")); + } } \ No newline at end of file diff --git a/Млаумчерб.Клиент/Ошибки.cs b/Млаумчерб.Клиент/Ошибки.cs index 263cfc0..b55b0eb 100644 --- a/Млаумчерб.Клиент/Ошибки.cs +++ b/Млаумчерб.Клиент/Ошибки.cs @@ -1,7 +1,9 @@ using Avalonia.Controls; using DTLib.Ben.Demystifier; +using DTLib.Logging; using MsBox.Avalonia; using MsBox.Avalonia.Dto; +using MsBox.Avalonia.Enums; using MsBox.Avalonia.Models; namespace Млаумчерб.Клиент; @@ -13,12 +15,13 @@ public static class Ошибки internal static async void ПоказатьСообщение(string err) { + Приложение.Логгер.LogError(nameof(Ошибки), err); var box = MessageBoxManager.GetMessageBoxCustom(new MessageBoxCustomParams { ButtonDefinitions = new List { new() { Name = "пон" } }, ContentTitle = "ОШИБКА", ContentMessage = err, - Icon = MsBox.Avalonia.Enums.Icon.Error, + Icon = Icon.Error, WindowStartupLocation = WindowStartupLocation.CenterOwner, CanResize = true, MaxWidth = 1000, @@ -28,7 +31,6 @@ public static class Ошибки Topmost = true } ); - //TODO: write to log await box.ShowAsync().ConfigureAwait(false); } } \ No newline at end of file diff --git a/Млаумчерб.Клиент/Приложение.axaml b/Млаумчерб.Клиент/Приложение.axaml index 56a234e..77afed0 100644 --- a/Млаумчерб.Клиент/Приложение.axaml +++ b/Млаумчерб.Клиент/Приложение.axaml @@ -5,18 +5,31 @@ - - - - + + + + + + diff --git a/Млаумчерб.Клиент/Приложение.axaml.cs b/Млаумчерб.Клиент/Приложение.axaml.cs index 5ca0861..7486df9 100644 --- a/Млаумчерб.Клиент/Приложение.axaml.cs +++ b/Млаумчерб.Клиент/Приложение.axaml.cs @@ -4,10 +4,13 @@ using Avalonia.Markup.Xaml; namespace Млаумчерб.Клиент; -public partial class Приложение : Application +public class Приложение : Application { + public static readonly LauncherLogger Логгер = new(); + public override void Initialize() { + Логгер.LogInfo(nameof(Приложение), "приложение запущено"); AvaloniaXamlLoader.Load(this); } diff --git a/Млаумчерб.Клиент/капитал/лисик.gif b/Млаумчерб.Клиент/капитал/лисик.gif new file mode 100644 index 0000000..54405b4 Binary files /dev/null and b/Млаумчерб.Клиент/капитал/лисик.gif differ diff --git a/Млаумчерб.Клиент/классы/Буржуазия.cs b/Млаумчерб.Клиент/классы/Буржуазия.cs new file mode 100644 index 0000000..b6e4022 --- /dev/null +++ b/Млаумчерб.Клиент/классы/Буржуазия.cs @@ -0,0 +1,98 @@ +using Newtonsoft.Json; + +namespace Млаумчерб.Клиент.классы; + +public class Artifact +{ + [JsonRequired] public string url { get; set; } = ""; + [JsonRequired] public string sha1 { get; set; } = ""; + [JsonRequired] public int size { get; set; } +} + +public class Os +{ + [JsonRequired] public string name { get; set; } = ""; +} + +public class Rule +{ + [JsonRequired] public string action { get; set; } = ""; + [JsonRequired] public Os os { get; set; } = null!; +} + +public class Classifiers +{ + [JsonProperty("natives-linux")] + public Artifact? nativeslinux { get; set; } + + [JsonProperty("natives-osx")] + public Artifact? nativesosx { get; set; } + + [JsonProperty("natives-windows")] + public Artifact? nativeswindows { get; set; } +} + +public class LibraryDownloads +{ + public Artifact? artifact { get; set; } + public Classifiers? classifiers { get; set; } +} + +public class Extract +{ + public List? exclude { get; set; } +} + +public class Natives +{ + public string? linux { get; set; } + public string? osx { get; set; } + public string? windows { get; set; } +} + +public class Library +{ + [JsonRequired] public string name { get; set; } = ""; + public List? rules { get; set; } + public Natives? natives { get; set; } + public Extract? extract { get; set; } + [JsonRequired] public LibraryDownloads downloads { get; set; } = null!; +} + +public class AssetIndex +{ + [JsonRequired] public string id { get; set; } = ""; + [JsonRequired] public int totalSize { get; set; } + [JsonRequired] public bool known { get; set; } + [JsonRequired] public string url { get; set; } = ""; + [JsonRequired] public string sha1 { get; set; } = ""; + [JsonRequired] public int size { get; set; } +} + +public class Downloads +{ + [JsonRequired] public Artifact client { get; set; } = null!; +} + +public class JavaVersion +{ + [JsonRequired] public string component { get; set; } = ""; + [JsonRequired] public int majorVersion { get; set; } +} + +public class MinecraftVersionDescriptor +{ + [JsonRequired] public string id { get; set; } = ""; + [JsonRequired] public string jar { get; set; } = ""; + [JsonRequired] public string family { get; set; } = ""; + [JsonRequired] public DateTime time { get; set; } + [JsonRequired] public DateTime releaseTime { get; set; } + [JsonRequired] public string type { get; set; } = ""; + [JsonRequired] public string mainClass { get; set; } = ""; + [JsonRequired] public Downloads downloads { get; set; } = null!; + [JsonRequired] public JavaVersion javaVersion { get; set; } = null!; + [JsonRequired] public List libraries { get; set; } = null!; + [JsonRequired] public AssetIndex assetIndex { get; set; } = null!; + [JsonRequired] public string assets { get; set; } = ""; + // public string minecraftArguments { get; set; } +} \ No newline at end of file diff --git a/Млаумчерб.Клиент/классы/Пролетариат.cs b/Млаумчерб.Клиент/классы/Пролетариат.cs new file mode 100644 index 0000000..efa37f2 --- /dev/null +++ b/Млаумчерб.Клиент/классы/Пролетариат.cs @@ -0,0 +1,6 @@ +namespace Млаумчерб.Клиент.классы; + +public class Пролетариат +{ + +} \ No newline at end of file