0
0
mirror of https://github.com/sp-tarkov/launcher.git synced 2025-02-12 17:30:42 -05:00

update to avalonia 11

This commit is contained in:
IsWaffle 2024-07-06 11:48:16 -04:00
parent a584088944
commit 0963264dfe
18 changed files with 89 additions and 82 deletions

View File

@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>

View File

@ -1,14 +1,16 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SPT.Launcher"
x:Class="SPT.Launcher.App">
x:Class="SPT.Launcher.App"
RequestedThemeVariant="Dark"
>
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
<StyleInclude Source="avares://DialogHost.Avalonia/Styles.xaml"/>
<FluentTheme Mode="Light"/>
<FluentTheme />
</Application.Styles>
<Application.Resources>

View File

@ -1,7 +1,6 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="using:SPT.Launcher.CustomControls"
xmlns:rxui="using:Avalonia.ReactiveUI"
>
<Design.PreviewWith>
<StackPanel Spacing="5" Background="{StaticResource SPT_Background_Dark}" Margin="50">
@ -17,8 +16,8 @@
<!-- Notification Manager Styles -->
<Style Selector="WindowNotificationManager">
<Setter Property="Margin" Value="0 35 0 0"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<!-- <Setter Property="VerticalAlignment" Value="Bottom"/> -->
<!-- <Setter Property="HorizontalAlignment" Value="Center"/> -->
<Setter Property="MaxItems" Value="2"/>
</Style>
@ -41,48 +40,48 @@
</ControlTemplate>
</Setter>
<Style.Animations>
<Animation Duration="0:0:0.45" Easing="SineEaseIn" FillMode="Forward">
<KeyFrame Cue="0%">
<Setter Property="Opacity" Value="0"/>
<Setter Property="ZIndex" Value="0"/>
<Setter Property="TranslateTransform.Y" Value="-100"/>
<Setter Property="ScaleTransform.ScaleX" Value="1"/>
<Setter Property="ScaleTransform.ScaleY" Value="1"/>
</KeyFrame>
<KeyFrame Cue="30%">
<Setter Property="Opacity" Value="0"/>
</KeyFrame>
<KeyFrame Cue="99%">
<Setter Property="ZIndex" Value="0"/>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="Opacity" Value="1"/>
<Setter Property="ZIndex" Value="1"/>
<Setter Property="TranslateTransform.Y" Value="0"/>
<Setter Property="ScaleTransform.ScaleX" Value="1"/>
<Setter Property="ScaleTransform.ScaleY" Value="1"/>
</KeyFrame>
</Animation>
</Style.Animations>
<!-- <Style.Animations> -->
<!-- <Animation Duration="0:0:0.45" Easing="SineEaseIn" FillMode="Forward"> -->
<!-- <KeyFrame Cue="0%"> -->
<!-- <Setter Property="Opacity" Value="0"/> -->
<!-- <Setter Property="ZIndex" Value="0"/> -->
<!-- <Setter Property="TranslateTransform.Y" Value="-100"/> -->
<!-- <Setter Property="ScaleTransform.ScaleX" Value="1"/> -->
<!-- <Setter Property="ScaleTransform.ScaleY" Value="1"/> -->
<!-- </KeyFrame> -->
<!-- <KeyFrame Cue="30%"> -->
<!-- <Setter Property="Opacity" Value="0"/> -->
<!-- </KeyFrame> -->
<!-- <KeyFrame Cue="99%"> -->
<!-- <Setter Property="ZIndex" Value="0"/> -->
<!-- </KeyFrame> -->
<!-- <KeyFrame Cue="100%"> -->
<!-- <Setter Property="Opacity" Value="1"/> -->
<!-- <Setter Property="ZIndex" Value="1"/> -->
<!-- <Setter Property="TranslateTransform.Y" Value="0"/> -->
<!-- <Setter Property="ScaleTransform.ScaleX" Value="1"/> -->
<!-- <Setter Property="ScaleTransform.ScaleY" Value="1"/> -->
<!-- </KeyFrame> -->
<!-- </Animation> -->
<!-- </Style.Animations> -->
</Style>
<Style Selector="NotificationCard[IsClosing=true] /template/ LayoutTransformControl#PART_LayoutTransformControl">
<Style.Animations>
<Animation Duration="0:0:0.3" Easing="SineEaseOut" FillMode="Backward">
<KeyFrame Cue="0%">
<Setter Property="Opacity" Value="1"/>
<Setter Property="TranslateTransform.X" Value="0"/>
<Setter Property="TranslateTransform.Y" Value="0"/>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="Opacity" Value="0"/>
<Setter Property="TranslateTransform.X" Value="0"/>
<Setter Property="TranslateTransform.Y" Value="-100"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
<!-- <Style Selector="NotificationCard[IsClosing=true] /template/ LayoutTransformControl#PART_LayoutTransformControl"> -->
<!-- <Style.Animations> -->
<!-- <Animation Duration="0:0:0.3" Easing="SineEaseOut" FillMode="Backward"> -->
<!-- <KeyFrame Cue="0%"> -->
<!-- <Setter Property="Opacity" Value="1"/> -->
<!-- <Setter Property="TranslateTransform.X" Value="0"/> -->
<!-- <Setter Property="TranslateTransform.Y" Value="0"/> -->
<!-- </KeyFrame> -->
<!-- <KeyFrame Cue="100%"> -->
<!-- <Setter Property="Opacity" Value="0"/> -->
<!-- <Setter Property="TranslateTransform.X" Value="0"/> -->
<!-- <Setter Property="TranslateTransform.Y" Value="-100"/> -->
<!-- </KeyFrame> -->
<!-- </Animation> -->
<!-- </Style.Animations> -->
<!-- </Style> -->
<!-- TitleBar Styles -->
<Style Selector="cc|TitleBar">
@ -423,11 +422,9 @@
<ScrollViewer HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ItemsPresenter Name="PART_ItemsPresenter"
Items="{TemplateBinding Items}"
Margin="{DynamicResource ComboBoxDropdownContentMargin}"
ItemsPanel="{TemplateBinding ItemsPanel}"
ItemTemplate="{TemplateBinding ItemTemplate}"
VirtualizationMode="{TemplateBinding VirtualizationMode}" />
/>
</ScrollViewer>
</Border>
</Popup>

View File

@ -61,7 +61,7 @@ namespace SPT.Launcher.CustomControls
}
}
comboBox.Items = actionsList;
comboBox.ItemsSource = actionsList;
foreach(var item in comboBox.Items)
{

View File

@ -7,6 +7,7 @@ using Avalonia.Controls.Notifications;
using Splat;
using System.Collections.Generic;
using System.Threading.Tasks;
using DialogHostAvalonia;
namespace SPT.Launcher.Models
{
@ -30,7 +31,7 @@ namespace SPT.Launcher.Models
var localeText = string.Format(LocalizationProvider.Instance.file_mismatch_dialog_message, serverVersion);
var result = await DialogHost.DialogHost.Show(new ConfirmationDialogViewModel(null, localeText, null, null, LauncherSettingsProvider.Instance.IsDevMode));
var result = await DialogHost.Show(new ConfirmationDialogViewModel(null, localeText, null, null, LauncherSettingsProvider.Instance.IsDevMode));
if(result != null && result is bool confirmation && !confirmation)
{

View File

@ -22,12 +22,13 @@
<Content Include="Assets\icon.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.15" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.15" />
<PackageReference Include="Avalonia" Version="11.1.0-rc2" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.0-rc2" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.12" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.15" />
<PackageReference Include="DialogHost.Avalonia" Version="0.5.0" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.0-rc2" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.0-rc2" />
<PackageReference Include="DialogHost.Avalonia" Version="0.8.0-avalonia11dot1-3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SPT.ByteBanger\SPT.ByteBanger.csproj" />

View File

@ -7,7 +7,7 @@ namespace SPT.Launcher
{
public class ViewLocator : IDataTemplate
{
public IControl Build(object data)
public Control Build(object data)
{
var name = data.GetType().FullName!.Replace("ViewModel", "View");
var type = Type.GetType(name);

View File

@ -9,7 +9,7 @@ using SPT.Launcher.Models.SPT;
using SPT.Launcher.Helpers;
using SPT.Launcher.ViewModels.Dialogs;
using Avalonia.Threading;
using dialogHost = DialogHost.DialogHost;
using DialogHostAvalonia;
namespace SPT.Launcher.ViewModels
@ -48,7 +48,7 @@ namespace SPT.Launcher.ViewModels
LocalizationProvider.Instance.yes,
LocalizationProvider.Instance.no);
var confirmCopySettings = await dialogHost.Show(viewModel);
var confirmCopySettings = await DialogHost.Show(viewModel);
if (confirmCopySettings is bool and true)
{

View File

@ -10,6 +10,7 @@ using SPT.Launcher.ViewModels.Dialogs;
using Avalonia.Threading;
using System.Diagnostics;
using System.IO;
using Avalonia.Controls.ApplicationLifetimes;
using SPT.Launcher.Models.SPT;
namespace SPT.Launcher.ViewModels
@ -221,9 +222,14 @@ namespace SPT.Launcher.ViewModels
public async Task CopyCommand(object parameter)
{
if (Application.Current.Clipboard != null && parameter != null && parameter is string text)
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop && parameter is string text)
{
await Application.Current.Clipboard.SetTextAsync(text);
if (desktop?.MainWindow?.Clipboard == null)
{
return;
}
await desktop.MainWindow.Clipboard.SetTextAsync(text);
SendNotification("", $"{text} {LocalizationProvider.Instance.copied}", Avalonia.Controls.Notifications.NotificationType.Success);
}
}

View File

@ -8,7 +8,7 @@ using ReactiveUI;
using Splat;
using System;
using System.Threading.Tasks;
using dialogHost = DialogHost.DialogHost;
using DialogHostAvalonia;
namespace SPT.Launcher.ViewModels
{
@ -162,7 +162,7 @@ namespace SPT.Launcher.ViewModels
/// <returns></returns>
public async Task<object?> ShowDialog(object ViewModel)
{
return await dialogHost.Show(ViewModel);
return await DialogHost.Show(ViewModel);
}
public ViewModelBase(IScreen Host)

View File

@ -3,7 +3,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:helpers="using:SPT.Launcher.Helpers"
xmlns:dialogHost="clr-namespace:DialogHost;assembly=DialogHost.Avalonia"
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
xmlns:s="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SPT.Launcher.Views.Dialogs.ChangeEditionDialogView"
@ -16,7 +16,7 @@
Foreground="IndianRed"
/>
<ComboBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2"
Items="{Binding editions.AvailableEditions}"
ItemsSource="{Binding editions.AvailableEditions}"
SelectedItem="{Binding editions.SelectedEdition}"
PlaceholderText="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=select_edition}"
>

View File

@ -2,7 +2,7 @@
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:dialogHost="clr-namespace:DialogHost;assembly=DialogHost.Avalonia"
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
xmlns:s="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SPT.Launcher.Views.Dialogs.ConfirmationDialogView"

View File

@ -2,7 +2,7 @@
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:dialogHost="clr-namespace:DialogHost;assembly=DialogHost.Avalonia"
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
xmlns:helpers="using:SPT.Launcher.Helpers"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SPT.Launcher.Views.Dialogs.RegisterDialogView"
@ -19,13 +19,13 @@
/>
<!-- Editions Combo Selection -->
<ComboBox Items="{Binding Editions.AvailableEditions}"
Margin="0 10"
Grid.Row="1" Grid.ColumnSpan="2"
HorizontalAlignment="Stretch"
SelectedItem="{Binding Editions.SelectedEdition}"
PlaceholderText="{Binding ComboBoxPlaceholderText}"
>
<ComboBox ItemsSource="{Binding Editions.AvailableEditions}"
Margin="0 10"
Grid.Row="1" Grid.ColumnSpan="2"
HorizontalAlignment="Stretch"
SelectedItem="{Binding Editions.SelectedEdition}"
PlaceholderText="{Binding ComboBoxPlaceholderText}"
>
<ComboBox.ItemTemplate>
<DataTemplate>
<Label Background="Transparent" Content="{Binding Name}" ToolTip.Tip="{Binding Description}"/>

View File

@ -3,7 +3,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:helpers="using:SPT.Launcher.Helpers"
xmlns:dialogHost="clr-namespace:DialogHost;assembly=DialogHost.Avalonia"
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SPT.Launcher.Views.Dialogs.WarningDialogView"
Background="{StaticResource SPT_Background_Dark}"

View File

@ -15,9 +15,9 @@
<Grid RowDefinitions="20,*,AUTO,*,20" ColumnDefinitions="20,4*,2*,20">
<ScrollViewer Grid.Row="1" Grid.RowSpan="3" Grid.Column="1">
<ItemsControl Items="{Binding ExistingProfiles}"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
>
<ItemsControl ItemsSource="{Binding ExistingProfiles}"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="launcher:ProfileInfo">
<Button Classes="profileinfo" Margin="0 10 10 10" HorizontalAlignment="Stretch"

View File

@ -7,7 +7,7 @@
xmlns:rxui="using:Avalonia.ReactiveUI"
xmlns:helpers="using:SPT.Launcher.Helpers"
xmlns:cvt="using:SPT.Launcher.Converters"
xmlns:dialogHost="clr-namespace:DialogHost;assembly=DialogHost.Avalonia"
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
mc:Ignorable="d" d:DesignWidth="750" d:DesignHeight="450"
x:Class="SPT.Launcher.Views.MainWindow"
Icon="/Assets/spt-logo.ico"

View File

@ -44,7 +44,7 @@
<!-- Active Mods List -->
<ScrollViewer Grid.Row="5" Grid.Column="1">
<ItemsControl Items="{Binding ModsCollection.ActiveMods}">
<ItemsControl ItemsSource="{Binding ModsCollection.ActiveMods}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type launcher:SPTMod}">
<cc:ModInfoCard ModName="{Binding Name}"
@ -86,7 +86,7 @@
</Border>
<!-- Inactive Mods List -->
<ScrollViewer Grid.Row="5" Grid.Column="3" >
<ItemsControl Items="{Binding ModsCollection.InactiveMods}">
<ItemsControl ItemsSource="{Binding ModsCollection.InactiveMods}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type launcher:SPTMod}">
<cc:ModInfoCard ModName="{Binding Name}"

View File

@ -50,9 +50,9 @@
<Label Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=default_language}"
/>
<!-- LocaleCollection reloads the locale from file when the selected loacle changes -->
<ComboBox Items="{Binding Locales.AvailableLocales}" MinWidth="200"
<ComboBox ItemsSource="{Binding Locales.AvailableLocales}" MinWidth="200"
SelectedItem="{Binding Locales.SelectedLocale, Mode=TwoWay}"
/>
/>
</StackPanel>
<!-- Game Start Action -->