логи
This commit is contained in:
@@ -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 @@
|
||||
<TextBlock FontWeight="Bold"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
News
|
||||
Лог
|
||||
</TextBlock>
|
||||
</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>
|
||||
</Border>
|
||||
<Border Grid.Column="1"
|
||||
@@ -36,40 +45,39 @@
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>* 60</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Vertical" Margin="10" Spacing="10">
|
||||
<TextBlock>Version:</TextBlock>
|
||||
<ComboBox Name="VersionComboBox">
|
||||
|
||||
</ComboBox>
|
||||
<TextBlock>Версия:</TextBlock>
|
||||
<ComboBox Name="VersionComboBox"/>
|
||||
|
||||
<TextBlock>Username:</TextBlock>
|
||||
<TextBox Text="{Binding #window.Username}"></TextBox>
|
||||
<TextBlock>Ник:</TextBlock>
|
||||
<TextBox Background="Transparent"
|
||||
Text="{Binding #window.Username}"/>
|
||||
|
||||
<TextBlock>
|
||||
<Run>Memory limit:</Run>
|
||||
<Run>Выделенная память:</Run>
|
||||
<TextBox Background="Transparent" Padding="0"
|
||||
BorderThickness="1"
|
||||
BorderBrush="#777777"
|
||||
Text="{Binding #window.MemoryLimit}">
|
||||
</TextBox>
|
||||
<Run>Mb</Run>
|
||||
<Run>Мб</Run>
|
||||
</TextBlock>
|
||||
<Slider Minimum="2048" Maximum="8192"
|
||||
Value="{Binding #window.MemoryLimit}">
|
||||
</Slider>
|
||||
|
||||
<CheckBox IsChecked="{Binding #window.Fullscreen}">
|
||||
Fullscreen
|
||||
Запустить полноэкранное
|
||||
</CheckBox>
|
||||
|
||||
<CheckBox IsChecked="{Binding #window.ForceUpdateGameFiles}">
|
||||
Force update game files
|
||||
<CheckBox IsChecked="{Binding #window.CheckGameFiles}">
|
||||
Проверить файлы игры
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
<Button Grid.Row="1" Margin="10" Padding="0 0 0 4"
|
||||
Classes="button_no_border"
|
||||
Background="#BBFF5900"
|
||||
Click="LaunchButtonHandler">
|
||||
Launch
|
||||
Background="#BBfd7300"
|
||||
Click="Запуск">
|
||||
Запуск
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
@@ -81,21 +89,25 @@
|
||||
<TextBlock FontWeight="Bold"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
Downloads
|
||||
Загрузки
|
||||
</TextBlock>
|
||||
</Border>
|
||||
<ScrollViewer Name="DownloadsScrollViewer" Grid.Row="1"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Visible"
|
||||
Background="Transparent"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
<Border Grid.Row="1" Background="#954808B0">
|
||||
<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>
|
||||
<Button Classes="menu_button button_no_border" Click="ОткрытьПапкуЛаунчера">директория лаунчера</Button>
|
||||
<Border Classes="menu_separator"/>
|
||||
<Button Classes="menu_button button_no_border" Click="ОткрытьФайлЛогов">лог-файл</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Classes="menu_button button_no_border" Click="OpenSourceRepository">source code</Button>
|
||||
<Button Classes="menu_button button_no_border" Click="ОткрытьРепозиторий">исходный код</Button>
|
||||
<gif:GifImage
|
||||
Width="30" Height="30" Stretch="Uniform"
|
||||
Source="avares://млаумчерб/капитал/лисик.gif"/>
|
||||
|
||||
@@ -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<bool> ForceUpdateGameFilesProperty =
|
||||
AvaloniaProperty.Register<Окне, bool>(nameof(ForceUpdateGameFiles),
|
||||
public static readonly StyledProperty<bool> 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
|
||||
{
|
||||
|
||||
@@ -30,9 +30,30 @@
|
||||
<Setter Property="Width" Value="1"/>
|
||||
<Setter Property="Margin" Value="4"/>
|
||||
</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.Resources>
|
||||
<FontFamily x:Key="PlexMono">avares://млаумчерб/капитал/IBMPlexMono-Regular.ttf</FontFamily>
|
||||
<FontFamily x:Key="MonospaceFont">avares://млаумчерб/капитал/IBMPlexMono-Regular.ttf</FontFamily>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user