moved some files

This commit is contained in:
2024-09-26 01:10:11 +05:00
parent c2e2785a32
commit d24dbea501
13 changed files with 78 additions and 55 deletions

View File

@@ -0,0 +1,9 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Млаумчерб.Клиент"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Млаумчерб.Клиент.видимое.VersionItemView">
<TextBlock Name="text" Background="Transparent"/>
</UserControl>

View File

@@ -0,0 +1,31 @@
using Avalonia.Controls;
using Avalonia.Media;
using Млаумчерб.Клиент.классы;
namespace Млаумчерб.Клиент.видимое;
public partial class VersionItemView : ListBoxItem
{
public GameVersionProps Props { get; }
private SolidColorBrush _avaliableColor = new(Color.FromRgb(30, 130, 40));
private SolidColorBrush _unavaliableColor = new(Color.FromRgb(170, 70, 70));
public VersionItemView()
{
throw new NotImplementedException();
}
public VersionItemView(GameVersionProps props)
{
Props = props;
InitializeComponent();
text.Text = props.Name;
props.DownloadCompleted += UpdateBackground;
UpdateBackground();
}
private void UpdateBackground()
{
Background = Props.IsDownloaded ? _avaliableColor : _unavaliableColor;
}
}

View File

@@ -0,0 +1,106 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gif="clr-namespace:Avalonia.Labs.Gif;assembly=Avalonia.Labs.Gif"
xmlns:local="clr-namespace:Млаумчерб"
x:Class="Млаумчерб.Клиент.видимое.Окне"
Name="window"
Title="млаумчерб"
Icon="avares://млаумчерб/капитал/кубе.ico"
FontFamily="{StaticResource PlexMono}" FontSize="18"
MinWidth="800" MinHeight="500"
Width="800" Height="500"
WindowStartupLocation="CenterScreen">
<Grid>
<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_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">
News
</TextBlock>
</Border>
</Grid>
</Border>
<Border Grid.Column="1"
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"
BorderThickness="1"
BorderBrush="#777777"
Text="{Binding #window.MemoryLimit}">
</TextBox>
<Run>Mb</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>
</StackPanel>
<Button Grid.Row="1" Margin="10" Padding="0 0 0 4"
Classes="button_no_border"
Background="#BBFF5900"
Click="LaunchButtonHandler">
Launch
</Button>
</Grid>
</Border>
<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="#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>
</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"
Source="avares://млаумчерб/капитал/лисик.gif"/>
</StackPanel>
</Grid>
</Border>
</Grid>
</Window>

View File

@@ -0,0 +1,148 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
using Млаумчерб.Клиент.классы;
namespace Млаумчерб.Клиент.видимое;
public partial class Окне : Window
{
public static readonly StyledProperty<string> UsernameProperty =
AvaloniaProperty.Register<Окне, string>(nameof(Username),
defaultBindingMode: BindingMode.TwoWay);
public string Username
{
get => GetValue(UsernameProperty);
set => SetValue(UsernameProperty, value);
}
public static readonly StyledProperty<int> MemoryLimitProperty =
AvaloniaProperty.Register<Окне, int>(nameof(MemoryLimit),
defaultBindingMode: BindingMode.TwoWay, defaultValue: 2048);
public int MemoryLimit
{
get => GetValue(MemoryLimitProperty);
set => SetValue(MemoryLimitProperty, value);
}
public static readonly StyledProperty<bool> FullscreenProperty =
AvaloniaProperty.Register<Окне, bool>(nameof(Fullscreen),
defaultBindingMode: BindingMode.TwoWay, defaultValue: false);
public bool Fullscreen
{
get => GetValue(FullscreenProperty);
set => SetValue(FullscreenProperty, value);
}
public static readonly StyledProperty<bool> ForceUpdateGameFilesProperty =
AvaloniaProperty.Register<Окне, bool>(nameof(ForceUpdateGameFiles),
defaultBindingMode: BindingMode.TwoWay, defaultValue: false);
public bool ForceUpdateGameFiles
{
get => GetValue(ForceUpdateGameFilesProperty);
set => SetValue(ForceUpdateGameFilesProperty, value);
}
public Окне()
{
InitializeComponent();
}
protected override async void OnLoaded(RoutedEventArgs e)
{
try
{
Главне.Настройки = Настройки.ЗагрузитьИзФайла();
Username = Главне.Настройки.имя_пользователя;
MemoryLimit = Главне.Настройки.выделенная_память_мб;
Fullscreen = Главне.Настройки.открыватьаесь_экран;
Directory.Create(Пролетариат.GetVersionDescriptorDir());
VersionComboBox.SelectedIndex = 0;
VersionComboBox.IsEnabled = false;
var versions = await GameVersionDescriptor.GetAllVersionsAsync();
Dispatcher.UIThread.Invoke(() =>
{
foreach (var p in versions)
{
VersionComboBox.Items.Add(new VersionItemView(p));
if (Главне.Настройки.последняяапущенная_версия != null &&
p.Name == Главне.Настройки.последняяапущенная_версия)
VersionComboBox.SelectedIndex = VersionComboBox.Items.Count - 1;
}
VersionComboBox.IsEnabled = true;
});
}
catch (Exception ex)
{
Ошибки.ПоказатьСообщение(nameof(Окне), ex);
}
}
private async void LaunchButtonHandler(object? sender, RoutedEventArgs e)
{
try
{
var selectedVersionView = (VersionItemView?)VersionComboBox.SelectedItem;
var selectedVersion = selectedVersionView?.Props;
Главне.Настройки.последняяапущенная_версия = selectedVersion?.Name;
Главне.Настройки.имя_пользователя = Username;
Главне.Настройки.выделенная_память_мб = MemoryLimit;
Главне.Настройки.открыватьаесь_экран = Fullscreen;
Главне.Настройки.СохранитьВФайл();
if (selectedVersion == null)
return;
var v = await GameVersionDescriptor.CreateFromPropsAsync(selectedVersion);
v.BeginUpdate(ForceUpdateGameFiles);
Dispatcher.UIThread.Invoke(() => ForceUpdateGameFiles = false);
}
catch (Exception ex)
{
Ошибки.ПоказатьСообщение(nameof(Окне), ex);
}
}
private void OpenLogsDirectory(object? s, RoutedEventArgs e)
{
try
{
Launcher.LaunchDirectoryInfoAsync(new DirectoryInfo(LauncherLogger.LogsDirectory.ToString()))
.ConfigureAwait(false);
}
catch (Exception ex)
{
Ошибки.ПоказатьСообщение(nameof(Окне), ex);
}
}
private void OpenLogFile(object? sender, RoutedEventArgs e)
{
try
{
Launcher.LaunchFileInfoAsync(new FileInfo(Главне.Логгер.LogfileName.ToString()))
.ConfigureAwait(false);
}
catch (Exception ex)
{
Ошибки.ПоказатьСообщение(nameof(Окне), ex);
}
}
private void OpenSourceRepository(object? sender, RoutedEventArgs e)
{
try
{
Launcher.LaunchUriAsync(new Uri("https://timerix.ddns.net:3322/Timerix/mlaumcherb"))
.ConfigureAwait(false);
}
catch (Exception ex)
{
Ошибки.ПоказатьСообщение(nameof(Окне), ex);
}
}
}

View File

@@ -0,0 +1,38 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Млаумчерб.Клиент.видимое.Приложение"
RequestedThemeVariant="Dark">
<Application.Styles>
<SimpleTheme />
<Style Selector="Border.dark_tr_bg">
<Setter Property="Background" Value="#cc232333"/>
</Style>
<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>
<FontFamily x:Key="PlexMono">avares://млаумчерб/капитал/IBMPlexMono-Regular.ttf</FontFamily>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,24 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
namespace Млаумчерб.Клиент.видимое;
public class Приложение : Application
{
public override void Initialize()
{
Главне.Логгер.LogInfo(nameof(Приложение), "приложение запущено");
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new Окне();
}
base.OnFrameworkInitializationCompleted();
}
}