Compare commits

..

No commits in common. "45c3f90da059700f45a7f3e97572d2ec41a5517b" and "c2e2785a32b6b952b6b47908f1f91044202e0eef" have entirely different histories.

17 changed files with 94 additions and 240 deletions

View File

@ -0,0 +1,13 @@
namespace Млаумчерб.Клиент;
public class LauncherLogger : FileLogger
{
public static readonly IOPath LogsDirectory = "launcher_logs";
public LauncherLogger() : base(LogsDirectory, "млаумчерб")
{
#if DEBUG
DebugLogEnabled = true;
#endif
}
}

View File

@ -1,12 +1,11 @@
using System.Buffers; using System.Buffers;
using System.Net.Http; using System.Net.Http;
using Млаумчерб.Клиент.видимое;
using Млаумчерб.Клиент.классы; using Млаумчерб.Клиент.классы;
using Timer = DTLib.Timer; using Timer = DTLib.Timer;
namespace Млаумчерб.Клиент; namespace Млаумчерб.Клиент;
public static class Сеть public static class Network
{ {
private static HttpClient http = new(); private static HttpClient http = new();
private const string ASSET_SERVER_URL = "https://resources.download.minecraft.net/"; private const string ASSET_SERVER_URL = "https://resources.download.minecraft.net/";
@ -55,7 +54,7 @@ public static class Сеть
public static async Task DownloadAssets(AssetIndexProperties assetIndexProperties, CancellationToken ct, bool force) 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) if (File.Exists(indexFilePath) && !force)
return; return;
@ -150,7 +149,7 @@ public static class Сеть
} }
catch (Exception ex) catch (Exception ex)
{ {
Приложение.Логгер.LogWarn(nameof(Сеть), ex); Приложение.Логгер.LogWarn(nameof(Network), ex);
} }
} }
return descriptors; return descriptors;

View File

@ -4,6 +4,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Млаумчерб.Клиент" xmlns:local="clr-namespace:Млаумчерб.Клиент"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Млаумчерб.Клиент.видимое.VersionItemView"> x:Class="Млаумчерб.Клиент.VersionItemView">
<TextBlock Name="text" Background="Transparent"/> <TextBlock Name="text" Background="Transparent"/>
</UserControl> </UserControl>

View File

@ -2,7 +2,7 @@
using Avalonia.Media; using Avalonia.Media;
using Млаумчерб.Клиент.классы; using Млаумчерб.Клиент.классы;
namespace Млаумчерб.Клиент.видимое; namespace Млаумчерб.Клиент;
public partial class VersionItemView : ListBoxItem public partial class VersionItemView : ListBoxItem
{ {

View File

@ -13,7 +13,6 @@ global using Directory = DTLib.Filesystem.Directory;
global using Path = DTLib.Filesystem.Path; global using Path = DTLib.Filesystem.Path;
using System.Globalization; using System.Globalization;
using Avalonia; using Avalonia;
using Млаумчерб.Клиент.видимое;
namespace Млаумчерб.Клиент; namespace Млаумчерб.Клиент;

View File

@ -1,8 +1,7 @@
using CliWrap; using CliWrap;
using DTLib.Extensions; using DTLib.Extensions;
using Млаумчерб.Клиент.видимое;
using Млаумчерб.Клиент.классы; using Млаумчерб.Клиент.классы;
using static Млаумчерб.Клиент.классы.Пути; using static Млаумчерб.Клиент.классы.Пролетариат;
namespace Млаумчерб.Клиент; namespace Млаумчерб.Клиент;
@ -29,7 +28,7 @@ public class GameVersionDescriptor
string name = GetVersionDescriptorName(f); string name = GetVersionDescriptorName(f);
propsList.Add(new GameVersionProps(name, null, f)); propsList.Add(new GameVersionProps(name, null, f));
} }
var remoteVersions = await Сеть.GetDownloadableVersions(); var remoteVersions = await Network.GetDownloadableVersions();
propsList.AddRange(remoteVersions); propsList.AddRange(remoteVersions);
return propsList; return propsList;
} }
@ -41,7 +40,7 @@ public class GameVersionDescriptor
if (props.RemoteDescriptorUrl is null) if (props.RemoteDescriptorUrl is null)
throw new NullReferenceException("can't download game version descriptor '" throw new NullReferenceException("can't download game version descriptor '"
+ props.Name + "', because RemoteDescriptorUrl is null"); + props.Name + "', because RemoteDescriptorUrl is null");
await Сеть.DownloadFileHTTP(props.RemoteDescriptorUrl, props.LocalDescriptorPath); await Network.DownloadFileHTTP(props.RemoteDescriptorUrl, props.LocalDescriptorPath);
} }
return new GameVersionDescriptor(props); return new GameVersionDescriptor(props);
} }
@ -65,10 +64,10 @@ public class GameVersionDescriptor
{ {
downloadCts = new CancellationTokenSource(); downloadCts = new CancellationTokenSource();
if(Приложение.Настройки.скачатьабу) if(Приложение.Настройки.скачатьабу)
await Сеть.DownloadJava(descriptor.javaVersion, Приложение.Настройки.путь_к_жабе, force); await Network.DownloadJava(descriptor.javaVersion, Приложение.Настройки.путь_к_жабе, force);
await Сеть.DownloadAssets(descriptor.assetIndex, downloadCts.Token, force); await Network.DownloadAssets(descriptor.assetIndex, downloadCts.Token, force);
await Сеть.DownloadVersionFile(descriptor.downloads.client.url, GetVersionJarFilePath(Name), force); await Network.DownloadVersionFile(descriptor.downloads.client.url, GetVersionJarFilePath(Name), force);
await Сеть.DownloadLibraries(descriptor.libraries, GetLibrariesDir(), force); await Network.DownloadLibraries(descriptor.libraries, GetLibrariesDir(), force);
// await Network.DownloadModpack(modpack, WorkingDirectory, force); // await Network.DownloadModpack(modpack, WorkingDirectory, force);
_props.IsDownloaded = true; _props.IsDownloaded = true;
} }

View File

@ -1,79 +0,0 @@
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;
}
}

View File

@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType Condition="'$(Configuration)' == 'Debug'">Exe</OutputType> <OutputType>WinExe</OutputType>
<OutputType Condition="'$(Configuration)' != 'Debug'">WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -22,7 +21,7 @@
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.*" /> <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.*" />
<PackageReference Include="Avalonia.Labs.Gif" Version="11.2.999-cibuild-00051673"/> <PackageReference Include="Avalonia.Labs.Gif" Version="11.2.999-cibuild-00051673"/>
<PackageReference Include="CliWrap" Version="3.6.*" /> <PackageReference Include="CliWrap" Version="3.6.*" />
<PackageReference Include="DTLib" Version="1.4.2" /> <PackageReference Include="DTLib" Version="1.4.1" />
<PackageReference Include="MessageBox.Avalonia" Version="3.1.*" /> <PackageReference Include="MessageBox.Avalonia" Version="3.1.*" />
<PackageReference Include="Newtonsoft.Json" Version="13.*" /> <PackageReference Include="Newtonsoft.Json" Version="13.*" />
</ItemGroup> </ItemGroup>
@ -31,19 +30,4 @@
<AvaloniaResource Include="капитал\**"/> <AvaloniaResource Include="капитал\**"/>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Update="видимое\VersionItemView.axaml.cs">
<DependentUpon>VersionItemView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="видимое\Окне.axaml.cs">
<DependentUpon>Окне.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="видимое\Приложение.axaml.cs">
<DependentUpon>Приложение.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
</Project> </Project>

View File

@ -1,6 +1,4 @@
using Млаумчерб.Клиент.видимое; namespace Млаумчерб.Клиент;
namespace Млаумчерб.Клиент;
public record Настройки public record Настройки
{ {

View File

@ -2,11 +2,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gif="clr-namespace:Avalonia.Labs.Gif;assembly=Avalonia.Labs.Gif" xmlns:gif="clr-namespace:Avalonia.Labs.Gif;assembly=Avalonia.Labs.Gif"
xmlns:local="clr-namespace:Млаумчерб" xmlns:local="clr-namespace:Млаумчерб"
x:Class="Млаумчерб.Клиент.видимое.Окне" x:Class="Млаумчерб.Клиент.Окне"
Name="window" Name="window"
Title="млаумчерб" Title="млаумчерб"
Icon="avares://млаумчерб/капитал/кубе.ico" Icon="avares://млаумчерб/капитал/кубе.ico"
FontFamily="{StaticResource MonospaceFont}" FontSize="18" FontFamily="{StaticResource PlexMono}" FontSize="18"
MinWidth="800" MinHeight="500" MinWidth="800" MinHeight="500"
Width="800" Height="500" Width="800" Height="500"
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">
@ -25,18 +25,9 @@
<TextBlock FontWeight="Bold" <TextBlock FontWeight="Bold"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"> VerticalAlignment="Center">
Лог News
</TextBlock> </TextBlock>
</Border> </Border>
<ScrollViewer Name="LogScrollViewer" Grid.Row="1"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Visible"
Background="Transparent">
<TextBox Name="LogTextBox"
FontSize="12"
IsReadOnly="True" TextWrapping="Wrap"
Background="Transparent" BorderThickness="0"/>
</ScrollViewer>
</Grid> </Grid>
</Border> </Border>
<Border Grid.Column="1" <Border Grid.Column="1"
@ -45,39 +36,40 @@
<Grid> <Grid>
<Grid.RowDefinitions>* 60</Grid.RowDefinitions> <Grid.RowDefinitions>* 60</Grid.RowDefinitions>
<StackPanel Orientation="Vertical" Margin="10" Spacing="10"> <StackPanel Orientation="Vertical" Margin="10" Spacing="10">
<TextBlock>Версия:</TextBlock> <TextBlock>Version:</TextBlock>
<ComboBox Name="VersionComboBox"/> <ComboBox Name="VersionComboBox">
<TextBlock>Ник:</TextBlock> </ComboBox>
<TextBox Background="Transparent"
Text="{Binding #window.Username}"/> <TextBlock>Username:</TextBlock>
<TextBox Text="{Binding #window.Username}"></TextBox>
<TextBlock> <TextBlock>
<Run>Выделенная память:</Run> <Run>Memory limit:</Run>
<TextBox Background="Transparent" Padding="0" <TextBox Background="Transparent" Padding="0"
BorderThickness="1" BorderThickness="1"
BorderBrush="#777777" BorderBrush="#777777"
Text="{Binding #window.MemoryLimit}"> Text="{Binding #window.MemoryLimit}">
</TextBox> </TextBox>
<Run>Мб</Run> <Run>Mb</Run>
</TextBlock> </TextBlock>
<Slider Minimum="2048" Maximum="8192" <Slider Minimum="2048" Maximum="8192"
Value="{Binding #window.MemoryLimit}"> Value="{Binding #window.MemoryLimit}">
</Slider> </Slider>
<CheckBox IsChecked="{Binding #window.Fullscreen}"> <CheckBox IsChecked="{Binding #window.Fullscreen}">
Запустить полноэкранное Fullscreen
</CheckBox> </CheckBox>
<CheckBox IsChecked="{Binding #window.CheckGameFiles}"> <CheckBox IsChecked="{Binding #window.ForceUpdateGameFiles}">
Проверить файлы игры Force update game files
</CheckBox> </CheckBox>
</StackPanel> </StackPanel>
<Button Grid.Row="1" Margin="10" Padding="0 0 0 4" <Button Grid.Row="1" Margin="10" Padding="0 0 0 4"
Classes="button_no_border" Classes="button_no_border"
Background="#BBfd7300" Background="#BBFF5900"
Click="Запуск"> Click="LaunchButtonHandler">
Запуск Launch
</Button> </Button>
</Grid> </Grid>
</Border> </Border>
@ -89,25 +81,21 @@
<TextBlock FontWeight="Bold" <TextBlock FontWeight="Bold"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"> VerticalAlignment="Center">
Загрузки Downloads
</TextBlock> </TextBlock>
</Border> </Border>
<ScrollViewer Name="DownloadsScrollViewer" Grid.Row="1"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Visible"
Background="Transparent"/>
</Grid> </Grid>
</Border> </Border>
</Grid> </Grid>
<Border Grid.Row="1" Background="#954808B0"> <Border Grid.Row="1" Background="#954808B0">
<Grid> <Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Button Classes="menu_button button_no_border" Click="ОткрытьПапкуЛаунчера">директория лаунчера</Button> <Button Classes="menu_button button_no_border" Click="OpenLogsDirectory">logs directory</Button>
<Border Classes="menu_separator"/> <Border Classes="menu_separator"></Border>
<Button Classes="menu_button button_no_border" Click="ОткрытьФайлЛогов">лог-файл</Button> <Button Classes="menu_button button_no_border" Click="OpenLogFile">log file</Button>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Classes="menu_button button_no_border" Click="ОткрытьРепозиторий">исходный код</Button> <Button Classes="menu_button button_no_border" Click="OpenSourceRepository">source code</Button>
<gif:GifImage <gif:GifImage
Width="30" Height="30" Stretch="Uniform" Width="30" Height="30" Stretch="Uniform"
Source="avares://млаумчерб/капитал/лисик.gif"/> Source="avares://млаумчерб/капитал/лисик.gif"/>

View File

@ -1,14 +1,12 @@
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Presenters;
using Avalonia.Data; using Avalonia.Data;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
using Avalonia.Threading; using Avalonia.Threading;
using Avalonia.VisualTree;
using Млаумчерб.Клиент.классы; using Млаумчерб.Клиент.классы;
namespace Млаумчерб.Клиент.видимое; namespace Млаумчерб.Клиент;
public partial class Окне : Window public partial class Окне : Window
{ {
@ -39,13 +37,13 @@ public partial class Окне : Window
set => SetValue(FullscreenProperty, value); set => SetValue(FullscreenProperty, value);
} }
public static readonly StyledProperty<bool> CheckGameFilesProperty = public static readonly StyledProperty<bool> ForceUpdateGameFilesProperty =
AvaloniaProperty.Register<Окне, bool>(nameof(CheckGameFiles), AvaloniaProperty.Register<Окне, bool>(nameof(ForceUpdateGameFiles),
defaultBindingMode: BindingMode.TwoWay, defaultValue: false); defaultBindingMode: BindingMode.TwoWay, defaultValue: false);
public bool CheckGameFiles public bool ForceUpdateGameFiles
{ {
get => GetValue(CheckGameFilesProperty); get => GetValue(ForceUpdateGameFilesProperty);
set => SetValue(CheckGameFilesProperty, value); set => SetValue(ForceUpdateGameFilesProperty, value);
} }
public Окне() public Окне()
@ -57,28 +55,12 @@ public partial class Окне : Window
{ {
try try
{ {
Приложение.Логгер.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();
};
Username = Приложение.Настройки.имя_пользователя; Username = Приложение.Настройки.имя_пользователя;
MemoryLimit = Приложение.Настройки.выделенная_память_мб; MemoryLimit = Приложение.Настройки.выделенная_память_мб;
Fullscreen = Приложение.Настройки.открыватьаесь_экран; Fullscreen = Приложение.Настройки.открыватьаесь_экран;
Directory.Create(Пути.GetVersionDescriptorDir()); Directory.Create(Пролетариат.GetVersionDescriptorDir());
VersionComboBox.SelectedIndex = 0; VersionComboBox.SelectedIndex = 0;
VersionComboBox.IsEnabled = false; VersionComboBox.IsEnabled = false;
var versions = await GameVersionDescriptor.GetAllVersionsAsync(); var versions = await GameVersionDescriptor.GetAllVersionsAsync();
@ -100,10 +82,11 @@ public partial class Окне : Window
} }
} }
private async void Запуск(object? sender, RoutedEventArgs e) private async void LaunchButtonHandler(object? sender, RoutedEventArgs e)
{ {
try try
{ {
var selectedVersionView = (VersionItemView?)VersionComboBox.SelectedItem; var selectedVersionView = (VersionItemView?)VersionComboBox.SelectedItem;
var selectedVersion = selectedVersionView?.Props; var selectedVersion = selectedVersionView?.Props;
Приложение.Настройки.последняяапущенная_версия = selectedVersion?.Name; Приложение.Настройки.последняяапущенная_версия = selectedVersion?.Name;
@ -115,8 +98,8 @@ public partial class Окне : Window
return; return;
var v = await GameVersionDescriptor.CreateFromPropsAsync(selectedVersion); var v = await GameVersionDescriptor.CreateFromPropsAsync(selectedVersion);
v.BeginUpdate(CheckGameFiles); v.BeginUpdate(ForceUpdateGameFiles);
Dispatcher.UIThread.Invoke(() => CheckGameFiles = false); Dispatcher.UIThread.Invoke(() => ForceUpdateGameFiles = false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -124,11 +107,11 @@ public partial class Окне : Window
} }
} }
private void ОткрытьПапкуЛаунчера(object? s, RoutedEventArgs e) private void OpenLogsDirectory(object? s, RoutedEventArgs e)
{ {
try try
{ {
Launcher.LaunchDirectoryInfoAsync(new DirectoryInfo(Directory.GetCurrent().ToString())) Launcher.LaunchDirectoryInfoAsync(new DirectoryInfo(LauncherLogger.LogsDirectory.ToString()))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
@ -137,7 +120,7 @@ public partial class Окне : Window
} }
} }
private void ОткрытьФайлЛогов(object? sender, RoutedEventArgs e) private void OpenLogFile(object? sender, RoutedEventArgs e)
{ {
try try
{ {
@ -150,7 +133,7 @@ public partial class Окне : Window
} }
} }
private void ОткрытьРепозиторий(object? sender, RoutedEventArgs e) private void OpenSourceRepository(object? sender, RoutedEventArgs e)
{ {
try try
{ {

View File

@ -4,7 +4,6 @@ using MsBox.Avalonia;
using MsBox.Avalonia.Dto; using MsBox.Avalonia.Dto;
using MsBox.Avalonia.Enums; using MsBox.Avalonia.Enums;
using MsBox.Avalonia.Models; using MsBox.Avalonia.Models;
using Млаумчерб.Клиент.видимое;
namespace Млаумчерб.Клиент; namespace Млаумчерб.Клиент;

View File

@ -1,6 +1,6 @@
<Application xmlns="https://github.com/avaloniaui" <Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Млаумчерб.Клиент.видимое.Приложение" x:Class="Млаумчерб.Клиент.Приложение"
RequestedThemeVariant="Dark"> RequestedThemeVariant="Dark">
<Application.Styles> <Application.Styles>
<SimpleTheme /> <SimpleTheme />
@ -30,30 +30,9 @@
<Setter Property="Width" Value="1"/> <Setter Property="Width" Value="1"/>
<Setter Property="Margin" Value="4"/> <Setter Property="Margin" Value="4"/>
</Style> </Style>
<Style Selector="ScrollBar /template/ Border">
<Setter Property="Width" Value="5"/>
<Setter Property="Margin" Value="4"/>
<Setter Property="ClipToBounds" Value="True"/>
<Setter Property="CornerRadius" Value="0"/>
</Style>
<Style Selector="ScrollBar /template/ Rectangle">
<Setter Property="Fill" Value="#d8ceb9"/>
</Style>
<Style Selector="ScrollBar /template/ Thumb">
<Setter Property="Background" Value="#fd7300"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="CornerRadius" Value="0"/>
</Style>
<Style Selector="ScrollBar /template/ Thumb /template/ Border">
<Setter Property="ClipToBounds" Value="True"/>
<Setter Property="CornerRadius" Value="0"/>
<Setter Property="Width" Value="5"/>
</Style>
</Application.Styles> </Application.Styles>
<Application.Resources> <Application.Resources>
<FontFamily x:Key="MonospaceFont">avares://млаумчерб/капитал/IBMPlexMono-Regular.ttf</FontFamily> <FontFamily x:Key="PlexMono">avares://млаумчерб/капитал/IBMPlexMono-Regular.ttf</FontFamily>
</Application.Resources> </Application.Resources>
</Application> </Application>

View File

@ -2,17 +2,15 @@ using Avalonia;
using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
namespace Млаумчерб.Клиент.видимое; namespace Млаумчерб.Клиент;
public class Приложение : Application public class Приложение : Application
{ {
public static LauncherLogger Логгер = new(); public static readonly LauncherLogger Логгер = new();
public static Настройки Настройки = new();
public override void Initialize() public override void Initialize()
{ {
Логгер.LogInfo(nameof(Приложение), "приложение запущено"); Логгер.LogInfo(nameof(Приложение), "приложение запущено");
Настройки = Настройки.ЗагрузитьИзФайла();
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
} }
@ -25,4 +23,6 @@ public class Приложение : Application
base.OnFrameworkInitializationCompleted(); base.OnFrameworkInitializationCompleted();
} }
public static Настройки Настройки = new();
} }

View File

@ -22,11 +22,11 @@ public class GameVersionProps
Name = name; Name = name;
LocalDescriptorPath = descriptorPath; LocalDescriptorPath = descriptorPath;
RemoteDescriptorUrl = url; RemoteDescriptorUrl = url;
IsDownloaded = File.Exists(Пути.GetVersionJarFilePath(name)); IsDownloaded = File.Exists(Пролетариат.GetVersionJarFilePath(name));
} }
public GameVersionProps(string name, string? url) : public GameVersionProps(string name, string? url) :
this(name, url, Пути.GetVersionDescriptorPath(name)) { } this(name, url, Пролетариат.GetVersionDescriptorPath(name)) { }
public override string ToString() => Name; public override string ToString() => Name;
} }

View File

@ -2,5 +2,24 @@
public static class Пролетариат 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");
} }

View File

@ -1,27 +0,0 @@
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");
}