Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.9.9.50 #826

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Daybreak.Tests/Daybreak.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
34 changes: 33 additions & 1 deletion Daybreak/Controls/Templates/TradeQuoteTemplate.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,39 @@
Grid.Column="1"
Margin="0, 0, 5, 0">
<TextBlock
Text="{Binding ElementName=_this, Path=DataContext.Price, Mode=OneWay}"
Text="B: "
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
VerticalAlignment="Center"
HorizontalAlignment="Right"
FontSize="16"
Grid.Column="0"
TextWrapping="Wrap"/>
<TextBlock
Text="{Binding ElementName=_this, Path=DataContext.BuyPrice, Mode=OneWay}"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
VerticalAlignment="Center"
HorizontalAlignment="Right"
FontSize="16"
Grid.Column="0"
TextWrapping="Wrap"/>
<TextBlock
Text="g"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
VerticalAlignment="Center"
HorizontalAlignment="Right"
FontSize="16"
Grid.Column="0"
TextWrapping="Wrap"/>
<TextBlock
Text=" | S: "
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
VerticalAlignment="Center"
HorizontalAlignment="Right"
FontSize="16"
Grid.Column="0"
TextWrapping="Wrap"/>
<TextBlock
Text="{Binding ElementName=_this, Path=DataContext.SellPrice, Mode=OneWay}"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Expand Down
5 changes: 2 additions & 3 deletions Daybreak/Controls/Templates/TradeQuoteTemplate.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Daybreak.Models.Trade;
using Daybreak.Services.IconRetrieve;
using Daybreak.Services.IconRetrieve;
using Daybreak.Services.Images;
using Microsoft.Extensions.DependencyInjection;
using System;
Expand Down Expand Up @@ -40,7 +39,7 @@ public TradeQuoteTemplate(

private async void UserControl_DataContextChanged(object _, DependencyPropertyChangedEventArgs __)
{
if (this.DataContext is not TraderQuote traderQuote)
if (this.DataContext is not TraderQuoteModel traderQuote)
{
return;
}
Expand Down
11 changes: 11 additions & 0 deletions Daybreak/Controls/Templates/TraderQuoteModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Daybreak.Models.Guildwars;
using System;

namespace Daybreak.Controls.Templates;
public sealed class TraderQuoteModel
{
public ItemBase? Item { get; set; }
public int BuyPrice { get; set; }
public int SellPrice { get; set; }
public DateTime TimeStamp { get; set; }
}
7 changes: 4 additions & 3 deletions Daybreak/Daybreak.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<LangVersion>preview</LangVersion>
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
<Version>0.9.9.49</Version>
<Version>0.9.9.50</Version>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<UserSecretsId>cfb2a489-db80-448d-a969-80270f314c46</UserSecretsId>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down Expand Up @@ -93,8 +93,7 @@
<ItemGroup>
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
<PackageReference Include="DiffPlex" Version="1.7.2" />
<PackageReference Include="DotNetZip" Version="1.16.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.66" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.67" />
<PackageReference Include="ini-parser-netstandard" Version="2.5.2" />
<PackageReference Include="LiteDB" Version="5.0.20" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.WPF" Version="2.0.0-rc2" />
Expand All @@ -114,10 +113,12 @@
<PackageReference Include="Slim" Version="1.9.2" />
<PackageReference Include="Svg" Version="3.4.7" />
<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Reflection.Metadata" Version="8.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="SystemExtensions.NetCore" Version="1.6.9" />
<PackageReference Include="SystemExtensions.NetStandard" Version="1.6.9" />
Expand Down
67 changes: 39 additions & 28 deletions Daybreak/Services/ReShade/ReShadeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Daybreak.Utils;
using HtmlAgilityPack;
using IniParser.Parser;
using Ionic.Zip;
using Microsoft.Extensions.Logging;
using Microsoft.Win32;
using System;
Expand All @@ -22,6 +21,7 @@
using System.Data;
using System.Extensions;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.Http;
using System.Threading;
Expand Down Expand Up @@ -276,7 +276,13 @@
return false;
}

using var archive = ZipFile.Read(result.Content.ReadAsStream(cancellationToken));
using var archive = new ZipArchive(result.Content.ReadAsStream(cancellationToken));
if (archive is null)
{
scopedLogger.LogError("Unable to open archive");
return false;
}

await this.InstallPackageInternal(archive, cancellationToken, package.InstallPath, package.TextureInstallPath, package.EffectFiles);
this.notificationService.NotifyInformation(
"ReShade package installed",
Expand All @@ -300,8 +306,13 @@
return false;
}

using var fs = new FileStream(fullPath, FileMode.Open);
using var archive = ZipFile.Read(fs);
using var archive = ZipFile.OpenRead(fullPath);
if (archive is null)
{
scopedLogger.LogError($"Unable to open archive");
return false;
}

await this.InstallPackageInternal(archive, cancellationToken);
this.notificationService.NotifyInformation(
"ReShade package installed",
Expand Down Expand Up @@ -426,26 +437,26 @@
}

private async Task InstallPackageInternal(
ZipFile archive,
ZipArchive archive,
CancellationToken cancellationToken,
string? desiredInstallationPath = default,
string? desiredTextureInstallationPath = default,
List<string>? fxFilter = default)
{
var scopedLogger = this.logger.CreateScopedLogger(nameof(this.InstallPackageInternal), archive.Name ?? string.Empty);
var scopedLogger = this.logger.CreateScopedLogger(nameof(this.InstallPackageInternal), string.Empty);
var basePath = Path.GetFullPath(ReShadePath);
desiredInstallationPath = desiredInstallationPath?.Replace(".\\", basePath + "\\");
desiredTextureInstallationPath = desiredTextureInstallationPath?.Replace(".\\", basePath + "\\");
foreach (var entry in archive.Entries)
{
if (FxExtensions.Any(entry.FileName.EndsWith))
if (FxExtensions.Any(entry.FullName.EndsWith))
{
scopedLogger.LogInformation($"[{entry.FileName}] Processing fx file");
var fileName = StripAfterToken(entry.FileName, "shaders/");
scopedLogger.LogInformation($"[{entry.FullName}] Processing fx file");
var fileName = StripAfterToken(entry.FullName, "shaders/");
if (fxFilter is not null &&
!fxFilter.Contains(fileName))
{
scopedLogger.LogInformation($"[{entry.FileName}] File not found in effects list. Skipping");
scopedLogger.LogInformation($"[{entry.FullName}] File not found in effects list. Skipping");
continue;
}

Expand All @@ -455,49 +466,49 @@
destination = Path.Combine(desiredInstallationPath, fileName);
}

scopedLogger.LogInformation($"[{entry.FileName}] Installing fx at {destination}");
scopedLogger.LogInformation($"[{entry.FullName}] Installing fx at {destination}");
new FileInfo(destination).Directory?.Create();
using var fs = new FileStream(destination, FileMode.Create);
using var reader = entry.OpenReader();
using var reader = entry.Open();
await reader.CopyToAsync(fs, cancellationToken);

scopedLogger.LogInformation($"[{entry.FileName}] Installed fx at {destination}");
scopedLogger.LogInformation($"[{entry.FullName}] Installed fx at {destination}");
}
else if (FxHeaderExtensions.Any(entry.FileName.EndsWith))
else if (FxHeaderExtensions.Any(entry.FullName.EndsWith))
{
scopedLogger.LogInformation($"[{entry.FileName}] Processing fxh file");
var fileName = StripAfterToken(entry.FileName, "shaders/");
scopedLogger.LogInformation($"[{entry.FullName}] Processing fxh file");
var fileName = StripAfterToken(entry.FullName, "shaders/");
var destination = Path.Combine(basePath, PresetsFolder, "Shaders", fileName);
if (desiredInstallationPath?.IsNullOrWhiteSpace() is false)
{
destination = Path.Combine(desiredInstallationPath, fileName);
}

scopedLogger.LogInformation($"[{entry.FileName}] Installing fxh at {destination}");
scopedLogger.LogInformation($"[{entry.FullName}] Installing fxh at {destination}");
new FileInfo(destination).Directory?.Create();
using var fs = new FileStream(destination, FileMode.Create);
using var reader = entry.OpenReader();
using var reader = entry.Open();
await reader.CopyToAsync(fs, cancellationToken);

scopedLogger.LogInformation($"[{entry.FileName}] Installed fxh at {destination}");
scopedLogger.LogInformation($"[{entry.FullName}] Installed fxh at {destination}");
}
else if (TextureExtensions.Any(entry.FileName.EndsWith))
else if (TextureExtensions.Any(entry.FullName.EndsWith))
{
scopedLogger.LogInformation($"Processing texture file {entry.FileName}");
var fileName = StripAfterToken(entry.FileName, "Textures/");
scopedLogger.LogInformation($"Processing texture file {entry.FullName}");
var fileName = StripAfterToken(entry.FullName, "Textures/");
var destination = Path.Combine(basePath, PresetsFolder, "Textures", fileName);
if (desiredTextureInstallationPath?.IsNullOrWhiteSpace() is false)
{
destination = Path.Combine(desiredTextureInstallationPath, fileName);
}

scopedLogger.LogInformation($"[{entry.FileName}] Installing texture at {destination}");
scopedLogger.LogInformation($"[{entry.FullName}] Installing texture at {destination}");
new FileInfo(destination).Directory?.Create();
using var fs = new FileStream(destination, FileMode.Create);
using var reader = entry.OpenReader();
using var reader = entry.Open();
await reader.CopyToAsync(fs, cancellationToken);

scopedLogger.LogInformation($"[{entry.FileName}] Installed texture at {destination}");
scopedLogger.LogInformation($"[{entry.FullName}] Installed texture at {destination}");
}
}
}
Expand Down Expand Up @@ -544,10 +555,10 @@
using var fs = File.OpenRead(pathToInstaller);
await SeekZipStart(fs, cancellationToken);
using var zipStream = new OffsetStream(fs);
using var zip = ZipFile.Read(zipStream);
using var zip = new ZipArchive(zipStream);

// Validate archive contains the ReShade DLLs
if (zip.Entries.FirstOrDefault(e => e.FileName == DllName) is not ZipEntry entry)
if (zip.Entries.FirstOrDefault(e => e.FullName == DllName) is not ZipArchiveEntry entry)
{
throw new InvalidOperationException("File does not contain desired ReShade dll");
}
Expand All @@ -559,7 +570,7 @@
}

var dllDestination = Path.Combine(reshadePath, DllName);
using var reader = entry.OpenReader();
using var reader = entry.Open();
using var output = File.OpenWrite(dllDestination);
await reader.CopyToAsync(output, cancellationToken);
SetupAdditionalFiles();
Expand Down
10 changes: 5 additions & 5 deletions Daybreak/Services/TradeChat/PriceHistoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ private async Task<IEnumerable<TraderQuote>> FetchPricingHistoryInternal(ItemBas

if (!response.IsSuccessStatusCode)
{
return Enumerable.Empty<TraderQuote>();
return [];
}

var responseString = await response.Content.ReadAsStringAsync();
var responseList = JsonConvert.DeserializeObject<List<TraderQuotePayload>>(responseString);
return responseList?.Select(p => new TraderQuote { Item = itemBase, Price = p.Price, Timestamp = p.TimeStamp }) ??
Enumerable.Empty<TraderQuote>();
[];
}
catch (Exception ex)
{
scopedLogger.LogError(ex, "Encountered exception");
return Enumerable.Empty<TraderQuote>();
return [];
}
}

Expand All @@ -133,9 +133,9 @@ private string GetItemId(ItemBase itemBase)
{
return itemBase.Modifiers is null ?
itemBase.Id.ToString() :
$"{itemBase.Id}-{this.itemHashService.ComputeHash(itemBase).Replace("C0000000","")}";
$"{itemBase.Id}-{this.itemHashService.ComputeHash(itemBase)?.Replace("C0000000","")}";
}

return $"{itemBase.Id}-{itemModHash.ModHash.Replace("C0000000", "")}";
return $"{itemBase.Id}-{itemModHash.ModHash?.Replace("C0000000", "")}";
}
}
6 changes: 3 additions & 3 deletions Daybreak/Services/UBlockOrigin/UBlockOriginService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
using System.Extensions;
using System.Linq;
using Daybreak.Services.Downloads;
using Ionic.Zip;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Daybreak.Services.Notifications;
using Daybreak.Services.Browser;
using Daybreak.Utils;
using System.IO.Compression;

namespace Daybreak.Services.UBlockOrigin;
public sealed class UBlockOriginService : IBrowserExtension
Expand Down Expand Up @@ -112,8 +112,8 @@ private async Task CheckAndUpdateInternal(string _)
return;
}

using var zipFile = ZipFile.Read(zipFilePath);
zipFile.ExtractAll(InstallationPath, ExtractExistingFileAction.OverwriteSilently);
using var zipFile = ZipFile.OpenRead(zipFilePath);
zipFile.ExtractToDirectory(InstallationPath, true);
zipFile.Dispose();
File.Delete(zipFilePath);
VersionUpToDate = true;
Expand Down
Loading
Loading