Make launcher semi-functional after 11.0.10 upgrade.

This commit is contained in:
vddCore 2024-03-28 08:29:12 +01:00
parent a9d07ba1db
commit 485b27614c
17 changed files with 79 additions and 102 deletions

View file

@ -93,8 +93,7 @@
</Application.Resources>
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseDark.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml" />
<SimpleTheme />
<StyleInclude Source="avares://Saradomin/Resources/Styles/TopBarNavigation.axaml" />
<StyleInclude Source="avares://Saradomin/Resources/Styles/CloseButton.axaml" />

View file

@ -16,8 +16,8 @@
</Canvas>
<ContentPresenter Grid.Column="1"
TextBlock.Foreground="{TemplateBinding Foreground}"
TextBlock.FontSize="13"
TextElement.Foreground="{TemplateBinding Foreground}"
TextElement.FontSize="13"
Margin="2,0,0,0"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
@ -45,8 +45,8 @@
</Canvas>
<ContentPresenter Grid.Column="1"
TextBlock.Foreground="{TemplateBinding Foreground}"
TextBlock.FontSize="13"
TextElement.Foreground="{TemplateBinding Foreground}"
TextElement.FontSize="13"
Margin="2,0,0,0"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"

View file

@ -21,8 +21,8 @@
Content="{TemplateBinding Content}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
TextBlock.FontSize="13"
TextBlock.Foreground="{TemplateBinding Foreground}" />
TextElement.FontSize="13"
TextElement.Foreground="{TemplateBinding Foreground}" />
</Grid>
</ControlTemplate>
</Setter>
@ -49,8 +49,8 @@
Content="{TemplateBinding Content}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
TextBlock.FontSize="13"
TextBlock.Foreground="{TemplateBinding Foreground}" />
TextElement.FontSize="13"
TextElement.Foreground="{TemplateBinding Foreground}" />
</Grid>
</ControlTemplate>
</Setter>

View file

@ -10,7 +10,7 @@
<Setter Property="Margin" Value="4,0,0,0" />
</Style>
<Style Selector="TabControl.PageSelector &gt; TabItem">
<Style Selector="TabControl.PageSelector > TabItem">
<Setter Property="FontSize" Value="13" />
<Setter Property="FontWeight" Value="Light" />
<Setter Property="Height" Value="20" />
@ -23,18 +23,22 @@
<Setter Property="Padding" Value="6,0,6,1" />
</Style>
<Style Selector="TabControl.PageSelector &gt; TabItem:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Style Selector="TabControl.PageSelector /template/ Border">
<Setter Property="Padding" Value="0" />
</Style>
<Style Selector="TabControl.PageSelector > TabItem:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{StaticResource DarkMediumBackgroundBrush}" />
</Style>
<Style Selector="TabControl.PageSelector &gt; TabItem:focus /template/ ContentPresenter#PART_ContentPresenter">
<Style Selector="TabControl.PageSelector > TabItem:focus /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
</Style>
<Style Selector="TabControl.PageSelector &gt; TabItem:selected">
<Style Selector="TabControl.PageSelector > TabItem:selected">
<Setter Property="Foreground" Value="{StaticResource AccentBrush}" />
</Style>
<Style Selector="TabControl.PageSelector &gt; TabItem:selected /template/ ContentPresenter#PART_ContentPresenter">
<Style Selector="TabControl.PageSelector > TabItem:selected /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{StaticResource DarkBackgroundBrush}" />
</Style>
</Styles>

View file

@ -24,12 +24,13 @@
</Target>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="11.0.10" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.10" />
<!--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.18" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.10" />
<PackageReference Include="Avalonia.Themes.Simple" Version="11.0.10" />
<PackageReference Include="GitLabApiClient" Version="1.8.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.60" />
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
<PackageReference Include="NSubsys" Version="1.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View file

@ -29,11 +29,10 @@
ZIndex="9999"
Width="425" />
<ListBox Classes="PluginList"
Items="{Binding PluginList}"
ItemsSource="{Binding PluginList}"
SelectionMode="Single"
ClipToBounds="True"
IsVisible="{Binding PluginList.Count}"
VirtualizationMode="Simple">
IsVisible="{Binding PluginList.Count}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type model:PluginInfo}">
<Grid ColumnDefinitions="250,50,100" RowDefinitions="*" >

View file

@ -1,21 +1,14 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using PropertyChanged;
namespace Saradomin.View.Controls
{
[DoNotNotify]
public class PluginManagerView : UserControl
public partial class PluginManagerView : UserControl
{
public PluginManagerView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View file

@ -70,7 +70,7 @@
<ComboBox Grid.Row="1"
Margin="2,0,0,2"
Items="{Binding ServerProfiles}"
ItemsSource="{Binding ServerProfiles}"
SelectedItem="{Binding ServerProfile, Converter={StaticResource EnumDescriptionConverter}, Mode=TwoWay}">
<ComboBox.Styles>
<Style Selector="ComboBoxItem">

View file

@ -5,16 +5,11 @@ using PropertyChanged;
namespace Saradomin.View.Controls
{
[DoNotNotify]
public class SettingsView : UserControl
public partial class SettingsView : UserControl
{
public SettingsView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View file

@ -5,16 +5,11 @@ using PropertyChanged;
namespace Saradomin.View.Controls
{
[DoNotNotify]
public class SingleplayerView : UserControl
public partial class SingleplayerView : UserControl
{
public SingleplayerView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View file

@ -5,13 +5,12 @@
xmlns:glitonea="clr-namespace:Glitonea;assembly=Glitonea"
xmlns:mvvm="clr-namespace:Glitonea.Mvvm;assembly=Glitonea"
xmlns:vm="clr-namespace:Saradomin.ViewModel.Windows"
Name="MainWindow"
Title="{Binding Title}"
DataContext="{mvvm:DataContextSource vm:MainWindowViewModel}"
Title="{Binding Title, Mode=TwoWay}"
Width="800"
Height="550"
Background="{StaticResource WindowBackgroundBrush}"
CanResize="False"
DataContext="{mvvm:DataContextSource vm:MainWindowViewModel}"
Icon="avares://Saradomin/Resources/Icons/saradomin.ico"
SystemDecorations="None"
WindowStartupLocation="CenterScreen">
@ -43,7 +42,7 @@
FontSize="14"
FontWeight="Light"
Foreground="{StaticResource AccentBrush}"
Text="{Binding #MainWindow.Title}"
Text="{Binding Title, Mode=TwoWay}"
TextAlignment="Center" />
<Button Grid.Column="2"
@ -86,15 +85,15 @@
</Grid>
<TabControl Grid.Row="1"
Grid.RowSpan="1"
Background="Transparent"
BorderBrush="{StaticResource DarkBorderBrush}"
Padding="0"
Classes="PageSelector">
<TabItem Width="95"
HorizontalContentAlignment="Center"
CornerRadius="0,0,0,8"
Header="what's new">
<Border Margin="4,0,4,0"
<Border Margin="4,4,4,0"
Background="{StaticResource MediumBackgroundBrush}"
BorderBrush="{StaticResource SemiLightMediumBorderBrush}"
BorderThickness="1,1,1,0"

View file

@ -10,14 +10,11 @@ using Saradomin.Infrastructure.Messaging;
namespace Saradomin.View.Windows
{
[DoNotNotify]
public class MainWindow : Window
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
protected override void OnOpened(EventArgs e)
@ -26,11 +23,6 @@ namespace Saradomin.View.Windows
.Broadcast();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private void TitleBar_MouseDown(object _, PointerPressedEventArgs e)
{
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)

View file

@ -4,7 +4,6 @@
xmlns:glitonea="clr-namespace:Glitonea;assembly=Glitonea"
xmlns:mvvm="clr-namespace:Glitonea.Mvvm;assembly=Glitonea"
xmlns:windows="clr-namespace:Saradomin.ViewModel.Windows"
Name="NotificationBox"
Title="{Binding Title}"
Height="120"
MaxWidth="400"

View file

@ -2,7 +2,6 @@ using System.Collections.Generic;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Glitonea;
using Glitonea.Extensions;
using PropertyChanged;
@ -11,19 +10,16 @@ using Saradomin.Infrastructure.Messaging;
namespace Saradomin.View.Windows
{
[DoNotNotify]
public class NotificationBox : WindowEx
public partial class NotificationBox : WindowEx
{
private static Queue<NotificationBox> _notificationQueue = new();
public static NotificationBox Current { get; private set; }
public static readonly StyledProperty<string> MessageProperty = new(
public static readonly StyledProperty<string> MessageProperty = AvaloniaProperty.Register<NotificationBox, string>(
nameof(Message),
typeof(NotificationBox),
new StyledPropertyMetadata<string>(
"This is supposed to be a message.\n" +
"Someone messed up, though, so have this placeholder instead."
)
);
public string Message
@ -87,10 +83,5 @@ namespace Saradomin.View.Windows
.Broadcast();
}
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View file

@ -39,8 +39,11 @@ namespace Saradomin.ViewModel.Controls
PluginList = new ObservableCollection<PluginInfo>(remotePlugins.OrderByDescending(x => x.Installed));
}
public async Task InstallRemotePlugin(PluginInfo pluginInfo)
public async Task InstallRemotePlugin(object parameter)
{
if (parameter is not PluginInfo pluginInfo)
return;
if (IsTransactionInProgress)
return;
@ -68,8 +71,11 @@ namespace Saradomin.ViewModel.Controls
}
}
public async Task UninstallLocalPlugin(PluginInfo pluginInfo)
public async Task UninstallLocalPlugin(object parameter)
{
if (parameter is not PluginInfo pluginInfo)
return;
if (IsTransactionInProgress)
return;
@ -125,8 +131,11 @@ namespace Saradomin.ViewModel.Controls
}
}
public async Task UpdateLocalPlugin (PluginInfo info)
public async Task UpdateLocalPlugin(object parameter)
{
if (parameter is not PluginInfo pluginInfo)
return;
if (IsTransactionInProgress)
return;
@ -134,15 +143,15 @@ namespace Saradomin.ViewModel.Controls
{
IsTransactionInProgress = true;
await _pluginDownloadService.DownloadPluginFiles(info.Name, _pluginManagementService.PluginRepositoryPath);
await _pluginDownloadService.DownloadPluginFiles(pluginInfo.Name, _pluginManagementService.PluginRepositoryPath);
await RefreshPluginCollections();
var newInfo = PluginList.First(x => x.Name == info.Name);
if (newInfo.Version != info.Version)
var newInfo = PluginList.First(x => x.Name == pluginInfo.Name);
if (newInfo.Version != pluginInfo.Version)
{
NotificationBox.DisplayNotification(
"Success!",
$"Successfully updated {info.Name} to version {newInfo.Version}!"
$"Successfully updated {pluginInfo.Name} to version {newInfo.Version}!"
);
}
}

View file

@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Platform.Storage;
using Glitonea.Extensions;
using Glitonea.Mvvm;
using Glitonea.Mvvm.Messaging;
@ -79,6 +77,26 @@ namespace Saradomin.ViewModel.Controls
Message.Subscribe<MainViewLoadedMessage>(this, OnMainViewLoaded);
}
public async Task BrowseForJavaExecutable()
{
var window = Application.Current.GetMainWindow();
var pickerOptions = new FilePickerOpenOptions
{
Title = "Browse for Java...",
AllowMultiple = false,
SuggestedStartLocation =await window.StorageProvider.TryGetFolderFromPathAsync(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
)
};
var storageFiles = await window.StorageProvider.OpenFilePickerAsync(pickerOptions);
if (storageFiles.Count > 0)
{
Launcher.JavaExecutableLocation = storageFiles[0].Path.AbsolutePath;
}
}
private void LaunchScapeWebsite()
{
CrossPlatform.LaunchURL("https://2009scape.org");
@ -103,22 +121,5 @@ namespace Saradomin.ViewModel.Controls
{
_settingsService.SaveAll();
}
private async Task BrowseForJavaExecutable()
{
var ofd = new OpenFileDialog
{
Title = "Browse for Java...",
AllowMultiple = false,
Directory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
};
var paths = await ofd.ShowAsync(Application.Current.GetMainWindow());
if (paths != null && paths.Length > 0)
{
Launcher.JavaExecutableLocation = paths[0];
}
}
}
}

View file

@ -105,7 +105,7 @@ namespace Saradomin.ViewModel.Windows
DimContent = msg.WasOpened;
}
public void LaunchPage(string parameter)
public void LaunchPage(object parameter)
{
var url = parameter switch
{
@ -121,7 +121,7 @@ namespace Saradomin.ViewModel.Windows
}
[DependsOn(nameof(CanLaunch))]
public bool CanExecuteLaunchSequence(object param)
public bool CanExecuteLaunchSequence(object parameter)
=> CanLaunch;
//Stub to maintain compatibility with AXAML