mirror of
https://gitlab.com/2009scape/Saradomin-Launcher.git
synced 2026-08-01 14:19:14 -06:00
initial port to avalonia 11
This commit is contained in:
parent
b354aff1fe
commit
06d6d90e48
22 changed files with 91 additions and 106 deletions
2
.gitmodules
vendored
2
.gitmodules
vendored
|
|
@ -1,3 +1,3 @@
|
|||
[submodule "Glitonea"]
|
||||
path = Glitonea
|
||||
url = https://github.com/Ciastex/Glitonea
|
||||
url = https://github.com/vddCore/Glitonea
|
||||
|
|
|
|||
2
Glitonea
2
Glitonea
|
|
@ -1 +1 @@
|
|||
Subproject commit 132a10de55d6ef4f16abc5daab6179d2e9cad5ee
|
||||
Subproject commit 5e9a57c6014dc3776199121548fd4977ba923393
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
|
||||
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">/usr/share/dotnet/sdk/7.0.100/MSBuild.dll</s:String>
|
||||
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">C:\Program Files\dotnet\sdk\7.0.201\MSBuild.dll</s:String>
|
||||
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">4294967293</s:Int64>
|
||||
<s:String x:Key="/Default/Environment/Hierarchy/Build/SolBuilderDuo/UseMsbuildSolutionBuilder/@EntryValue">No</s:String></wpf:ResourceDictionary>
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
<Application x:Class="Saradomin.App"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:Saradomin.View.Controls"
|
||||
xmlns:default="clr-namespace:Avalonia.Themes.Default;assembly=Avalonia.Themes.Default">
|
||||
xmlns:controls="clr-namespace:Saradomin.View.Controls">
|
||||
<Application.Resources>
|
||||
<Color x:Key="DarkBackgroundColor">#3E3529</Color>
|
||||
<Color x:Key="DarkTranslucentBackgroundColor">#CC3E3529</Color>
|
||||
|
|
@ -93,8 +92,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" />
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
using Glitonea.Mvvm.Messaging;
|
||||
|
||||
namespace Saradomin.Infrastructure.Messaging
|
||||
{
|
||||
public class MainViewLoadedMessage : Message
|
||||
{
|
||||
}
|
||||
}
|
||||
8
Saradomin/Infrastructure/Messaging/Messages.cs
Normal file
8
Saradomin/Infrastructure/Messaging/Messages.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
using Glitonea.Mvvm.Messaging;
|
||||
|
||||
namespace Saradomin.Infrastructure.Messaging
|
||||
{
|
||||
public sealed record MainViewLoadedMessage : Message;
|
||||
public sealed record NotificationBoxStateChangedMessage(bool WasOpened) : Message;
|
||||
public sealed record SettingsModifiedMessage(string SettingName) : Message;
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
using Glitonea.Mvvm.Messaging;
|
||||
|
||||
namespace Saradomin.Infrastructure.Messaging
|
||||
{
|
||||
public class NotificationBoxStateChangedMessage : Message
|
||||
{
|
||||
public bool WasOpened { get; }
|
||||
|
||||
public NotificationBoxStateChangedMessage(bool wasOpened)
|
||||
{
|
||||
WasOpened = wasOpened;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
using Glitonea.Mvvm.Messaging;
|
||||
|
||||
namespace Saradomin.Infrastructure.Messaging
|
||||
{
|
||||
public class SettingsModifiedMessage : Message
|
||||
{
|
||||
public string SettingName { get; }
|
||||
|
||||
public SettingsModifiedMessage(string settingName)
|
||||
{
|
||||
SettingName = settingName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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}"
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Version>1.5.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
@ -11,19 +11,21 @@
|
|||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishReadyToRun>true</PublishReadyToRun>
|
||||
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||
|
||||
<GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
|
||||
<UapAppxPackageBuildMode>StoreUpload</UapAppxPackageBuildMode>
|
||||
<NoWarn>IL2026;CS0067</NoWarn>
|
||||
|
||||
<ApplicationIcon>Resources\Icons\saradomin.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="0.10.18" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
|
||||
<PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-rc1.1" />
|
||||
<!--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.0-rc1.1" />
|
||||
<PackageReference Include="Avalonia.Themes.Simple" Version="11.0.0-rc1.1" />
|
||||
<PackageReference Include="GitLabApiClient" Version="1.8.0" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.48" />
|
||||
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
|
||||
<ListBox Classes="PluginList"
|
||||
Items="{Binding LocalPlugins}"
|
||||
ItemsSource="{Binding LocalPlugins}"
|
||||
SelectionMode="Single">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type model:PluginInfo}">
|
||||
|
|
@ -91,7 +91,7 @@
|
|||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Visible">
|
||||
<ListBox Classes="PluginList"
|
||||
Items="{Binding RemotePlugins}"
|
||||
ItemsSource="{Binding RemotePlugins}"
|
||||
SelectionMode="Single">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type model:PluginInfo}">
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using PropertyChanged;
|
|||
namespace Saradomin.View.Controls
|
||||
{
|
||||
[DoNotNotify]
|
||||
public class PluginManagerView : UserControl
|
||||
public partial class PluginManagerView : UserControl
|
||||
{
|
||||
public PluginManagerView()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -103,7 +103,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">
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using PropertyChanged;
|
|||
namespace Saradomin.View.Controls
|
||||
{
|
||||
[DoNotNotify]
|
||||
public class SettingsView : UserControl
|
||||
public partial class SettingsView : UserControl
|
||||
{
|
||||
public SettingsView()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@
|
|||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:Saradomin.View.Controls"
|
||||
xmlns:glitonea="clr-namespace:Glitonea;assembly=Glitonea"
|
||||
xmlns:glitonea="clr-namespace:Glitonea.Controls;assembly=Glitonea"
|
||||
xmlns:mvvm="clr-namespace:Glitonea.Mvvm;assembly=Glitonea"
|
||||
xmlns:vm="clr-namespace:Saradomin.ViewModel.Windows"
|
||||
Name="MainWindow"
|
||||
Title="{Binding Title}"
|
||||
Width="800"
|
||||
Height="550"
|
||||
|
|
@ -43,7 +42,7 @@
|
|||
FontSize="14"
|
||||
FontWeight="Light"
|
||||
Foreground="{StaticResource AccentBrush}"
|
||||
Text="{Binding #MainWindow.Title}"
|
||||
Text="{Binding $parent[Window].Title}"
|
||||
TextAlignment="Center" />
|
||||
|
||||
<Button Grid.Column="2"
|
||||
|
|
@ -144,4 +143,4 @@
|
|||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</glitonea:WindowEx>
|
||||
</glitonea:WindowEx>
|
||||
|
|
@ -10,7 +10,7 @@ using Saradomin.Infrastructure.Messaging;
|
|||
namespace Saradomin.View.Windows
|
||||
{
|
||||
[DoNotNotify]
|
||||
public class MainWindow : Window
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
<glitonea:WindowEx x:Class="Saradomin.View.Windows.NotificationBox"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:glitonea="clr-namespace:Glitonea;assembly=Glitonea"
|
||||
xmlns:glitonea="clr-namespace:Glitonea.Controls;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"
|
||||
Background="{StaticResource WindowBackgroundBrush}"
|
||||
CanResize="False"
|
||||
DataContext="{Binding #NotificationBox}"
|
||||
DataContext="{Binding}"
|
||||
ShowActivated="True"
|
||||
ShowInTaskbar="False"
|
||||
SizeToContent="WidthAndHeight"
|
||||
|
|
@ -26,7 +25,7 @@
|
|||
FontSize="14"
|
||||
FontWeight="Light"
|
||||
Foreground="{StaticResource AccentBrush}"
|
||||
Text="{Binding #NotificationBox.Title}"
|
||||
Text="{Binding $parent[Window].Title}"
|
||||
TextAlignment="Center">
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using Avalonia;
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Glitonea;
|
||||
using Glitonea.Controls;
|
||||
using Glitonea.Extensions;
|
||||
using PropertyChanged;
|
||||
using Saradomin.Infrastructure.Messaging;
|
||||
|
|
@ -11,19 +12,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(
|
||||
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 static readonly StyledProperty<string> MessageProperty = AvaloniaProperty.Register<NotificationBox, string>(
|
||||
nameof(Message),
|
||||
"This is supposed to be a message.\n" +
|
||||
"Someone messed up, though, so have this placeholder instead."
|
||||
);
|
||||
|
||||
public string Message
|
||||
|
|
@ -48,7 +46,7 @@ namespace Saradomin.View.Windows
|
|||
=> DisplayNotification("Notification", message);
|
||||
|
||||
public static void DisplayNotification(string title, string message)
|
||||
=> DisplayNotification(title, message, Application.Current.GetMainWindow());
|
||||
=> DisplayNotification(title, message, Application.Current!.GetMainWindow());
|
||||
|
||||
public static void DisplayNotification(string title, string message, Window owner)
|
||||
{
|
||||
|
|
@ -82,7 +80,8 @@ namespace Saradomin.View.Windows
|
|||
if (_notificationQueue.Any())
|
||||
{
|
||||
Current = _notificationQueue.Dequeue();
|
||||
Current.ShowDialog(Current.Owner as Window);
|
||||
Current.ShowDialog((Window)Current.Owner!);
|
||||
|
||||
new NotificationBoxStateChangedMessage(true)
|
||||
.Broadcast();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,8 +56,11 @@ namespace Saradomin.ViewModel.Controls
|
|||
);
|
||||
}
|
||||
|
||||
public async Task InstallRemotePlugin(PluginInfo pluginInfo)
|
||||
public async Task InstallRemotePlugin(object parameter)
|
||||
{
|
||||
if (parameter is not PluginInfo pluginInfo)
|
||||
return;
|
||||
|
||||
if (IsTransactionInProgress)
|
||||
return;
|
||||
|
||||
|
|
@ -88,8 +91,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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
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;
|
||||
|
|
@ -76,61 +78,68 @@ namespace Saradomin.ViewModel.Controls
|
|||
{
|
||||
_settingsService = settingsService;
|
||||
|
||||
Message.Subscribe<MainViewLoadedMessage>(this, OnMainViewLoaded);
|
||||
Message.Subscribe<MainViewLoadedMessage>(this, OnMainViewLoaded);
|
||||
}
|
||||
|
||||
private void LaunchScapeWebsite()
|
||||
public void LaunchScapeWebsite()
|
||||
{
|
||||
CrossPlatform.LaunchURL("https://2009scape.org");
|
||||
}
|
||||
|
||||
private void OpenPluginTutorial()
|
||||
public void OpenPluginTutorial()
|
||||
{
|
||||
CrossPlatform.LaunchURL("https://gitlab.com/2009scape/tools/client-plugins");
|
||||
}
|
||||
|
||||
private void LaunchProjectWebsite()
|
||||
public void LaunchProjectWebsite()
|
||||
{
|
||||
CrossPlatform.LaunchURL("https://gitlab.com/2009scape/Saradomin-Launcher");
|
||||
}
|
||||
|
||||
private void OnMainViewLoaded(MainViewLoadedMessage _)
|
||||
public void OnMainViewLoaded(MainViewLoadedMessage _)
|
||||
{
|
||||
Message.Subscribe<SettingsModifiedMessage>(this, OnSettingsModified);
|
||||
}
|
||||
|
||||
private void OnSettingsModified(SettingsModifiedMessage _)
|
||||
public void OnSettingsModified(SettingsModifiedMessage _)
|
||||
{
|
||||
_settingsService.SaveAll();
|
||||
}
|
||||
|
||||
private async Task BrowseForJavaExecutable()
|
||||
public async Task BrowseForJavaExecutable()
|
||||
{
|
||||
var ofd = new OpenFileDialog
|
||||
var storageProvider = Application.Current!.GetMainWindow()!.StorageProvider;
|
||||
|
||||
var storageFile = (await storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = "Browse for Java...",
|
||||
AllowMultiple = false,
|
||||
Directory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
|
||||
};
|
||||
SuggestedStartLocation = await storageProvider.TryGetFolderFromPathAsync(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
|
||||
)
|
||||
})).FirstOrDefault();
|
||||
|
||||
var paths = await ofd.ShowAsync(Application.Current.GetMainWindow());
|
||||
|
||||
if (paths != null && paths.Length > 0)
|
||||
if (storageFile != null)
|
||||
{
|
||||
Launcher.JavaExecutableLocation = paths[0];
|
||||
Launcher.JavaExecutableLocation = storageFile.TryGetLocalPath();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task BrowseForInstallationDirectory()
|
||||
|
||||
public async Task BrowseForInstallationDirectory()
|
||||
{
|
||||
var ofd = new OpenFolderDialog
|
||||
var storageProvider = Application.Current!.GetMainWindow()!.StorageProvider;
|
||||
|
||||
var storageFolder = (await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = "Browse for Installation Directory...",
|
||||
Directory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
|
||||
};
|
||||
|
||||
var path = await ofd.ShowAsync(Application.Current.GetMainWindow());
|
||||
AllowMultiple = false,
|
||||
SuggestedStartLocation = await storageProvider.TryGetFolderFromPathAsync(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
|
||||
)
|
||||
})).FirstOrDefault();
|
||||
|
||||
var path = storageFolder?.TryGetLocalPath();
|
||||
|
||||
if (path != null)
|
||||
{
|
||||
if (CrossPlatform.IsDirectoryWritable(path))
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ namespace Saradomin.ViewModel.Windows
|
|||
DimContent = msg.WasOpened;
|
||||
}
|
||||
|
||||
public void LaunchPage(string parameter)
|
||||
public void LaunchPage(object parameter)
|
||||
{
|
||||
var url = parameter switch
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue