Update to .net8.0 (#486)

Fix uMod installation steps
ReShade monitor config changes
This commit is contained in:
2023-11-19 00:40:09 +01:00
committed by GitHub
parent cd2a529381
commit e1dfd1f0d0
19 changed files with 164 additions and 76 deletions
+2 -2
View File
@@ -52,7 +52,7 @@ jobs:
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.x'
dotnet-version: '8.x'
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.3.1
@@ -83,7 +83,7 @@ jobs:
echo "::set-env name=Version::$version"
- name: Create publish launcher files
run: dotnet publish .\Daybreak\Daybreak.csproj -c $env:Configuration -r $env:RuntimeIdentifier --property:SolutionDir=$env:GITHUB_WORKSPACE -p:PublishReadyToRun=true -p:PublishSingleFile=true --self-contained true -o .\Publish
run: dotnet publish .\Daybreak\Daybreak.csproj -c $env:Configuration -r $env:RuntimeIdentifier --property:SolutionDir=$env:GITHUB_WORKSPACE -p:PublishReadyToRun=true -p:PublishSingleFile=true -p:PublishTrimmed --self-contained true -o .\Publish
env:
RuntimeIdentifier: win-${{ matrix.targetplatform }}
+1 -1
View File
@@ -38,7 +38,7 @@ jobs:
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.x'
dotnet-version: '8.x'
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.3.1
+1 -1
View File
@@ -72,7 +72,7 @@ jobs:
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.x'
dotnet-version: '8.x'
#- name: Autobuild
# uses: github/codeql-action/autobuild@v2
+6 -1
View File
@@ -28,7 +28,12 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Get Latest Tag
id: getLatestTag
uses: WyriHaximus/github-action-get-previous-tag@v1
@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Daybreak._7ZipExtractor</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
+1 -1
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<IsPackable>false</IsPackable>
<Platforms>AnyCPU;x86;x64</Platforms>
</PropertyGroup>
@@ -8,10 +8,6 @@ namespace Daybreak.Configuration.Options;
[OptionsName(Name = "uMod")]
public sealed class UModOptions
{
[JsonProperty(nameof(DllPath))]
[OptionName(Name = "Dll Path", Description = "The path to the uMod dll")]
public string? DllPath { get; set; }
[JsonProperty(nameof(Enabled))]
[OptionName(Name = "Enabled", Description = "If true, Daybreak will also launch uMod when launching GuildWars")]
public bool Enabled { get; set; }
@@ -81,6 +81,7 @@ using Daybreak.Services.GWCA;
using Daybreak.Services.DirectSong;
using Daybreak.Views.Onboarding.DirectSong;
using Daybreak.Services.SevenZip;
using Daybreak.Services.ReShade.Notifications;
namespace Daybreak.Configuration;
@@ -427,6 +428,7 @@ public class ProjectConfiguration : PluginConfigurationBase
notificationHandlerProducer.RegisterNotificationHandler<TradeMessageNotificationHandler>();
notificationHandlerProducer.RegisterNotificationHandler<FixSymbolicLinkNotificationHandler>();
notificationHandlerProducer.RegisterNotificationHandler<UpdateNotificationHandler>();
notificationHandlerProducer.RegisterNotificationHandler<ReShadeConfigChangedHandler>();
}
public override void RegisterMods(IModsManager modsManager)
+10 -10
View File
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<RootNamespace>Daybreak</RootNamespace>
<!--Unable to migrate to .net 7 due to issues with font families not being found #140-->
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
@@ -13,7 +13,7 @@
<LangVersion>preview</LangVersion>
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
<Version>0.9.8.149</Version>
<Version>0.9.8.150</Version>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<UserSecretsId>cfb2a489-db80-448d-a969-80270f314c46</UserSecretsId>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
@@ -93,12 +93,12 @@
<PackageReference Include="HtmlAgilityPack" Version="1.11.54" />
<PackageReference Include="ini-parser-netstandard" Version="2.5.2" />
<PackageReference Include="LiteDB" Version="5.0.17" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.WPF" Version="2.0.0-rc1.2" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.WPF" Version="2.0.0-rc2" />
<PackageReference Include="MahApps.Metro" Version="2.4.10" />
<PackageReference Include="Microsoft.CorrelationVector" Version="1.0.42" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2151.40" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
<PackageReference Include="NAudio" Version="2.2.1" />
@@ -106,10 +106,10 @@
<PackageReference Include="Plumsy" Version="1.1.0" />
<PackageReference Include="securifybv.ShellLink" Version="0.1.0" />
<PackageReference Include="Slim" Version="1.9.2" />
<PackageReference Include="Svg" Version="3.4.5" />
<PackageReference Include="Svg" Version="3.4.6" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="System.Reflection.Metadata" Version="7.0.2" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
<PackageReference Include="System.Reflection.Metadata" Version="8.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
<PackageReference Include="SystemExtensions.NetCore" Version="1.0.1" />
<PackageReference Include="SystemExtensions.NetStandard" Version="1.6.2" />
<PackageReference Include="SystemExtensions.NetStandard.DependencyInjection" Version="1.3.1" />
@@ -188,8 +188,8 @@ public class ApplicationLauncher : IApplicationLauncher
args.Add($"\"{character}\"");
}
var mods = this.modsManager.GetMods().Where(m => m.IsEnabled).ToList();
var disabledmods = this.modsManager.GetMods().Where(m => !m.IsEnabled).ToList();
var mods = this.modsManager.GetMods().Where(m => m.IsEnabled && m.IsInstalled).ToList();
var disabledmods = this.modsManager.GetMods().Where(m => !m.IsEnabled && m.IsInstalled).ToList();
foreach(var mod in mods)
{
args.AddRange(mod.GetCustomArguments());
@@ -1,6 +1,7 @@
using Daybreak.Models.Metrics;
using Daybreak.Models.Trade;
using LiveChartsCore;
using LiveChartsCore.Kernel;
using LiveChartsCore.SkiaSharpView;
using System;
using System.Windows.Extensions.Services;
@@ -20,15 +21,13 @@ public sealed class LiveChartInitializer : ILiveChartInitializer, IApplicationLi
.AddDefaultMappers()
.AddDarkTheme()
.AddLightTheme()
.HasMap<Metric>((metric, point) =>
.HasMap<Metric>((metric, index) =>
{
point.SecondaryValue = metric.Timestamp.Ticks;
point.PrimaryValue = Convert.ToDouble(metric.Measurement);
return new Coordinate(Convert.ToDouble(metric.Measurement), metric.Timestamp.Ticks);
})
.HasMap<TraderQuote>((quote, point) =>
{
point.SecondaryValue = quote.Timestamp?.Ticks ?? 0;
point.PrimaryValue = ((double)quote.Price) / 20d;
return new Coordinate(((double)quote.Price) / 20d, quote.Timestamp?.Ticks ?? 0);
}));
}
}
@@ -18,4 +18,5 @@ public interface IReShadeService : IModService
Task<bool> SaveConfig(string config, CancellationToken cancellationToken);
Task<string> GetPreset(CancellationToken cancellationToken);
Task<bool> SavePreset(string config, CancellationToken cancellationToken);
Task<bool> UpdateIniFromPath(string pathToIni, CancellationToken cancellationToken);
}
@@ -0,0 +1,28 @@
using Daybreak.Models.Notifications;
using Daybreak.Models.Notifications.Handling;
using System.Core.Extensions;
using System.IO;
using System.Threading;
namespace Daybreak.Services.ReShade.Notifications;
internal sealed class ReShadeConfigChangedHandler : INotificationHandler
{
private readonly IReShadeService reShadeService;
public ReShadeConfigChangedHandler(
IReShadeService reShadeService)
{
this.reShadeService = reShadeService.ThrowIfNull();
}
public async void OpenNotification(Notification notification)
{
var presetPath = Path.GetFullPath(notification.Metadata);
if (!File.Exists(presetPath))
{
return;
}
await this.reShadeService.UpdateIniFromPath(presetPath, CancellationToken.None);
}
}
+100 -6
View File
@@ -5,6 +5,7 @@ using Daybreak.Models.ReShade;
using Daybreak.Services.Downloads;
using Daybreak.Services.Injection;
using Daybreak.Services.Notifications;
using Daybreak.Services.ReShade.Notifications;
using Daybreak.Services.ReShade.Utils;
using Daybreak.Services.Scanner;
using HtmlAgilityPack;
@@ -16,12 +17,10 @@ using System;
using System.Collections.Generic;
using System.Configuration;
using System.Core.Extensions;
using System.Diagnostics;
using System.Extensions;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Extensions.Services;
@@ -44,9 +43,9 @@ public sealed class ReShadeService : IReShadeService, IApplicationLifetimeServic
private static readonly string ReShadePresetPath = Path.Combine(Path.GetFullPath(ReShadePath), ReShadePreset);
private static readonly string ReShadeLogPath = Path.Combine(Path.GetFullPath(ReShadePath), ReShadeLog);
private static readonly string SourcePresetsFolderPath = Path.Combine(Path.GetFullPath(ReShadePath), PresetsFolder);
private static readonly string[] TextureExtensions = new string[] { ".png", ".jpg", ".jpeg" };
private static readonly string[] FxExtensions = new string[] { ".fx", };
private static readonly string[] FxHeaderExtensions = new string[] { ".fxh" };
private static readonly string[] TextureExtensions = [".png", ".jpg", ".jpeg"];
private static readonly string[] FxExtensions = [".fx",];
private static readonly string[] FxHeaderExtensions = [".fxh"];
private readonly IGuildwarsMemoryCache guildwarsMemoryCache;
private readonly INotificationService notificationService;
@@ -140,7 +139,14 @@ public sealed class ReShadeService : IReShadeService, IApplicationLifetimeServic
}
}
public Task OnGuildWarsStarted(ApplicationLauncherContext applicationLauncherContext, CancellationToken cancellationToken) => Task.CompletedTask;
public Task OnGuildWarsStarted(ApplicationLauncherContext applicationLauncherContext, CancellationToken cancellationToken)
{
var destinationDirectory = Path.GetFullPath(new FileInfo(applicationLauncherContext.ExecutablePath).DirectoryName!);
var destinationPreset = Path.Combine(destinationDirectory, ReShadePreset);
var destinationIni = Path.Combine(destinationDirectory, ConfigIni);
this.PeriodicallyCheckPresetChanges(applicationLauncherContext, destinationPreset, destinationIni);
return Task.CompletedTask;
}
public Task OnGuildWarsStarting(ApplicationLauncherContext applicationLauncherContext, CancellationToken cancellationToken)
{
@@ -325,6 +331,94 @@ public sealed class ReShadeService : IReShadeService, IApplicationLifetimeServic
return true;
}
public async Task<bool> UpdateIniFromPath(string pathToIni, CancellationToken cancellationToken)
{
pathToIni = Path.GetFullPath(pathToIni);
var scopedLogger = this.logger.CreateScopedLogger(nameof(this.UpdateIniFromPath), pathToIni);
if (!File.Exists(pathToIni))
{
scopedLogger.LogError("File doesn't exist");
return false;
}
var config = await File.ReadAllTextAsync(pathToIni, cancellationToken);
if (pathToIni.Contains(ConfigIni))
{
await this.SaveConfig(config, cancellationToken);
}
if (pathToIni.Contains(ReShadePreset))
{
await this.SavePreset(config, cancellationToken);
}
return true;
}
private async void PeriodicallyCheckPresetChanges(ApplicationLauncherContext applicationLauncherContext, string presetsFile, string configFile)
{
var scopedLogger = this.logger.CreateScopedLogger(nameof(this.PeriodicallyCheckPresetChanges), presetsFile);
if (!File.Exists(presetsFile))
{
scopedLogger.LogError("File does not exist");
return;
}
var presetsCache = File.ReadAllText(presetsFile);
var configCache = File.ReadAllText(configFile);
try
{
while (true)
{
if (applicationLauncherContext.Process.HasExited)
{
scopedLogger.LogInformation("Process has exited");
return;
}
await Task.Delay(1000);
if (!File.Exists(presetsFile))
{
scopedLogger.LogError("Preset file has been deleted");
return;
}
if (!File.Exists(configFile))
{
scopedLogger.LogError("Config file has been deleted");
return;
}
var currentPresets = File.ReadAllText(presetsFile);
if (currentPresets != presetsCache)
{
presetsCache = currentPresets;
this.notificationService.NotifyInformation<ReShadeConfigChangedHandler>(
title: "ReShade presets changed",
description: $"ReShade presets have been changed by {applicationLauncherContext.ExecutablePath}. Click on this notification to save the changes in Daybreak",
metaData: presetsFile);
continue;
}
var currentConfig = File.ReadAllText(configFile);
if (currentConfig != configCache)
{
configCache = currentConfig;
this.notificationService.NotifyInformation<ReShadeConfigChangedHandler>(
title: "ReShade config changed",
description: $"ReShade config has been changed by {applicationLauncherContext.ExecutablePath}. Click on this notification to save the changes in Daybreak",
metaData: configFile);
continue;
}
}
}
catch(Exception e)
{
scopedLogger.LogError(e, "Encountered exception. Cancelling preset monitoring");
return;
}
}
private async Task InstallPackageInternal(
ZipFile archive,
CancellationToken cancellationToken,
-2
View File
@@ -8,8 +8,6 @@ using System.Threading.Tasks;
namespace Daybreak.Services.UMod;
public interface IUModService : IModService
{
bool LoadUModFromDisk();
Task<bool> SetupUMod(UModInstallationStatus uModInstallationStatus);
Task CheckAndUpdateUMod(CancellationToken cancellationToken);
+1 -29
View File
@@ -8,7 +8,6 @@ using Daybreak.Services.Injection;
using Daybreak.Services.Notifications;
using Daybreak.Services.Toolbox.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Configuration;
@@ -52,8 +51,7 @@ public sealed class UModService : IUModService
}
}
public bool IsInstalled => File.Exists(this.uModOptions.Value.DllPath) &&
Path.GetFileName(this.uModOptions.Value.DllPath) == UModDll;
public bool IsInstalled => File.Exists(Path.GetFullPath(Path.Combine(UModDirectory, UModDll)));
public UModService(
IProcessInjector processInjector,
@@ -107,26 +105,6 @@ public sealed class UModService : IUModService
public Task OnGuildWarsStarted(ApplicationLauncherContext applicationLauncherContext, CancellationToken cancellationToken) => Task.CompletedTask;
public bool LoadUModFromDisk()
{
var filePicker = new OpenFileDialog
{
Filter = "Dll Files (uMod.dll)|uMod.dll",
Multiselect = false,
RestoreDirectory = true,
Title = "Please select the uMod.dll"
};
if (filePicker.ShowDialog() is false)
{
return false;
}
var fileName = filePicker.FileName;
this.uModOptions.Value.DllPath = Path.GetFullPath(fileName);
this.uModOptions.UpdateOption();
return true;
}
public async Task<bool> SetupUMod(UModInstallationStatus uModInstallationStatus)
{
if ((await this.SetupUModDll(uModInstallationStatus)) is false)
@@ -272,12 +250,6 @@ public sealed class UModService : IUModService
return false;
}
Directory.CreateDirectory(Path.GetFullPath(UModDirectory));
var uModPath = Path.GetFullPath(Path.Combine(UModDirectory, UModDll));
var uModOptions = this.uModOptions.Value;
uModOptions.DllPath = uModPath;
this.uModOptions.UpdateOption();
return true;
}
@@ -12,7 +12,7 @@
<Border BorderBrush="{StaticResource MahApps.Brushes.ThemeForeground}"
BorderThickness="1"/>
<StackPanel VerticalAlignment="Center">
<TextBlock Text="Do you already have uMod installed on your PC?" Margin="10, 0, 10, 0" Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
<TextBlock Text="Do you want to install uMod?" Margin="10, 0, 10, 0" Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
TextWrapping="Wrap" HorizontalAlignment="Center" FontSize="16"></TextBlock>
<Grid MaxWidth="600"
Margin="10">
@@ -1,5 +1,4 @@
using Daybreak.Services.Navigation;
using Daybreak.Services.UMod;
using Microsoft.Extensions.Logging;
using System.Core.Extensions;
using System.Windows.Controls;
@@ -10,16 +9,13 @@ namespace Daybreak.Views.Onboarding.UMod;
/// </summary>
public partial class UModInstallationChoiceView : UserControl
{
private readonly IUModService uModService;
private readonly IViewManager viewManager;
private readonly ILogger<UModInstallationChoiceView> logger;
public UModInstallationChoiceView(
IUModService uModService,
IViewManager viewManager,
ILogger<UModInstallationChoiceView> logger)
{
this.uModService = uModService.ThrowIfNull();
this.viewManager = viewManager.ThrowIfNull();
this.logger = logger.ThrowIfNull();
@@ -28,14 +24,11 @@ public partial class UModInstallationChoiceView : UserControl
private void OpaqueButtonNo_Clicked(object sender, System.EventArgs e)
{
this.viewManager.ShowView<UModInstallingView>();
this.viewManager.ShowView<LauncherView>();
}
private void OpaqueButtonYes_Clicked(object sender, System.EventArgs e)
{
if (this.uModService.LoadUModFromDisk())
{
this.viewManager.ShowView<UModMainView>();
}
this.viewManager.ShowView<UModInstallingView>();
}
}