логгирование и лисик.gif
This commit is contained in:
parent
6a087767a1
commit
1ecc8ccc18
13
Млаумчерб.Клиент/LauncherLogger.cs
Normal file
13
Млаумчерб.Клиент/LauncherLogger.cs
Normal file
@ -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, "млаумчерб")
|
||||
{
|
||||
}
|
||||
}
|
||||
13
Млаумчерб.Клиент/Network.cs
Normal file
13
Млаумчерб.Клиент/Network.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace Млаумчерб.Клиент;
|
||||
|
||||
public record struct NetworkTransferResult
|
||||
{
|
||||
public long BytesTotal;
|
||||
public long BytesTransferred;
|
||||
public long BytesPerSecond;
|
||||
}
|
||||
|
||||
public class NetworkHelper
|
||||
{
|
||||
|
||||
}
|
||||
@ -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;
|
||||
|
||||
|
||||
41
Млаумчерб.Клиент/Игра.cs
Normal file
41
Млаумчерб.Клиент/Игра.cs
Normal file
@ -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<NetworkTransferResult> 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<NetworkTransferResult> BeginUpdate()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void EndUpdate()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task Launch()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@ -13,15 +13,17 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.1.3" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.1.3" />
|
||||
<PackageReference Include="Avalonia.Themes.Simple" Version="11.1.3" />
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.3" />
|
||||
<PackageReference Include="DTLib" Version="1.3.4" />
|
||||
<PackageReference Include="DTLib.Ben.Demystifier" Version="1.0.6" />
|
||||
<PackageReference Include="DTLib.Logging" Version="1.3.5" />
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="3.1.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Avalonia" Version="11.*" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.*" />
|
||||
<PackageReference Include="Avalonia.Themes.Simple" Version="11.*" />
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.*" />
|
||||
<PackageReference Include="AvaloniaGif-Unofficial" Version="1.0.0" />
|
||||
<PackageReference Include="DTLib" Version="1.3.*" />
|
||||
<PackageReference Include="DTLib.Ben.Demystifier" Version="1.0.*" />
|
||||
<PackageReference Include="DTLib.Logging" Version="1.3.*" />
|
||||
<PackageReference Include="DTLib.Network" Version="1.4.*" />
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="3.1.*" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -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(Настройки), $"настройки сохранены: {текст}");
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:gif="clr-namespace:Avalonia.Gif;assembly=Avalonia.Gif"
|
||||
xmlns:local="clr-namespace:Млаумчерб"
|
||||
x:Class="Млаумчерб.Клиент.Окне"
|
||||
Name="window"
|
||||
Title="млаумчерб"
|
||||
@ -9,29 +11,39 @@
|
||||
Width="800" Height="500"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>30 * 30</Grid.RowDefinitions>
|
||||
<Image Grid.RowSpan="3" Stretch="UniformToFill"
|
||||
Source="avares://млаумчерб/капитал/фоне.png"></Image>
|
||||
<!-- <Border Grid.Row="0" Background="#7000b0"></Border> -->
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.RowDefinitions>* 30</Grid.RowDefinitions>
|
||||
<Image Grid.RowSpan="2" Stretch="UniformToFill"
|
||||
Source="avares://млаумчерб/капитал/фоне.png"/>
|
||||
|
||||
<Grid Grid.Row="0" Margin="10">
|
||||
<Grid.ColumnDefinitions>* 300 *</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0"
|
||||
Classes="dark_box white_border"
|
||||
Margin="10 5 ">
|
||||
Classes="dark_tr_bg white_border">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>30 *</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>30</Grid.ColumnDefinitions>
|
||||
<Button></Button>
|
||||
<Border Classes="white_border" Margin="-1" Padding="4">
|
||||
<TextBlock FontWeight="Bold"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
News
|
||||
</TextBlock>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border Grid.Column="1"
|
||||
Classes="dark_box white_border"
|
||||
Margin="5 5">
|
||||
Classes="dark_tr_bg white_border"
|
||||
Margin="10 0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>* 60</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Vertical" Margin="10" Spacing="10">
|
||||
<TextBlock>Version:</TextBlock>
|
||||
<ComboBox Name="VersionComboBox">
|
||||
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock>Username:</TextBlock>
|
||||
<TextBox Text="{Binding #window.Username}"></TextBox>
|
||||
|
||||
<TextBlock>
|
||||
<Run>Memory limit:</Run>
|
||||
<TextBox Background="Transparent" Padding="0"
|
||||
@ -42,18 +54,19 @@
|
||||
<Run>Mb</Run>
|
||||
</TextBlock>
|
||||
<Slider Minimum="2048" Maximum="8192"
|
||||
Foreground="Blue"
|
||||
Value="{Binding #window.MemoryLimit}">
|
||||
</Slider>
|
||||
|
||||
<CheckBox IsChecked="{Binding #window.Fullscreen}">
|
||||
Fullscreen
|
||||
</CheckBox>
|
||||
|
||||
<CheckBox IsChecked="{Binding #window.UpdateGameFiles}">
|
||||
Update game files
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
<Button Grid.Row="1" Margin="10" Padding="0 0 0 5"
|
||||
BorderThickness="2" BorderBrush="Transparent"
|
||||
<Button Grid.Row="1" Margin="10" Padding="0 0 0 4"
|
||||
Classes="button_no_border"
|
||||
Background="#BBFF5900"
|
||||
Click="LaunchButtonHandler">
|
||||
Launch
|
||||
@ -61,11 +74,33 @@
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="2"
|
||||
Classes="dark_box white_border"
|
||||
Margin="10 5">
|
||||
|
||||
<Border Grid.Column="2" Classes="dark_tr_bg white_border">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>30 *</Grid.RowDefinitions>
|
||||
<Border Classes="white_border" Margin="-1" Padding="4">
|
||||
<TextBlock FontWeight="Bold"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
Downloads
|
||||
</TextBlock>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
<Border Grid.Row="1" Background="#6f4808B0">
|
||||
<Grid>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<Button Classes="menu_button button_no_border" Click="OpenLogsDirectory">logs directory</Button>
|
||||
<Border Classes="menu_separator"></Border>
|
||||
<Button Classes="menu_button button_no_border" Click="OpenLogFile">log file</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Classes="menu_button button_no_border" Click="OpenSourceRepository">source code</Button>
|
||||
<gif:GifImage
|
||||
Width="30" Height="30" Stretch="Uniform"
|
||||
SourceUri="avares://млаумчерб/капитал/лисик.gif"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@ -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"));
|
||||
}
|
||||
}
|
||||
@ -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<ButtonDefinition> { 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);
|
||||
}
|
||||
}
|
||||
@ -5,18 +5,31 @@
|
||||
<Application.Styles>
|
||||
<SimpleTheme />
|
||||
|
||||
<Style Selector="Control.center">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="Border.dark_box">
|
||||
<Style Selector="Border.dark_tr_bg">
|
||||
<Setter Property="Background" Value="#b7303040"/>
|
||||
</Style>
|
||||
<Style Selector="Control.white_border">
|
||||
|
||||
<Style Selector="Border.white_border">
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="BorderBrush" Value="White"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="Button.button_no_border">
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="Button.menu_button">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Padding" Value="4 0"/>
|
||||
<Setter Property="MinWidth" Value="50"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="Border.menu_separator">
|
||||
<Setter Property="Background" Value="#ff505050"/>
|
||||
<Setter Property="Width" Value="1"/>
|
||||
<Setter Property="Margin" Value="4"/>
|
||||
</Style>
|
||||
</Application.Styles>
|
||||
|
||||
<Application.Resources>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
BIN
Млаумчерб.Клиент/капитал/лисик.gif
Normal file
BIN
Млаумчерб.Клиент/капитал/лисик.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
98
Млаумчерб.Клиент/классы/Буржуазия.cs
Normal file
98
Млаумчерб.Клиент/классы/Буржуазия.cs
Normal file
@ -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<string>? 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<Rule>? 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<Library> libraries { get; set; } = null!;
|
||||
[JsonRequired] public AssetIndex assetIndex { get; set; } = null!;
|
||||
[JsonRequired] public string assets { get; set; } = "";
|
||||
// public string minecraftArguments { get; set; }
|
||||
}
|
||||
6
Млаумчерб.Клиент/классы/Пролетариат.cs
Normal file
6
Млаумчерб.Клиент/классы/Пролетариат.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace Млаумчерб.Клиент.классы;
|
||||
|
||||
public class Пролетариат
|
||||
{
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user