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.44 #758

Merged
merged 9 commits into from
Jun 11, 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
2 changes: 1 addition & 1 deletion Daybreak.GWCA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif()
set(VERSION_MAJOR 0)
set(VERSION_MINOR 9)
set(VERSION_PATCH 9)
set(VERSION_TWEAK 43)
set(VERSION_TWEAK 44)

set(VERSION_RC "${CMAKE_CURRENT_BINARY_DIR}/version.rc")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${VERSION_RC}" @ONLY)
Expand Down
10 changes: 5 additions & 5 deletions Daybreak.GWCA/source/DebugModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ namespace Daybreak::Modules {
char buffer[20];
DebugPayload debugPayload;
const auto gameContext = GW::GetGameContext();
std::sprintf(buffer, "%p", static_cast<void*>(gameContext));
std::snprintf(buffer, 20, "%p", static_cast<void*>(gameContext));
debugPayload.GameContextAddress = std::string(buffer);
std::sprintf(buffer, "%p", static_cast<void*>(gameContext->agent));
std::snprintf(buffer, 20, "%p", static_cast<void*>(gameContext->agent));
debugPayload.AgentContextAddress = std::string(buffer);
std::sprintf(buffer, "%p", static_cast<void*>(gameContext->character));
std::snprintf(buffer, 20, "%p", static_cast<void*>(gameContext->character));
debugPayload.CharContextAddress = std::string(buffer);
std::sprintf(buffer, "%p", static_cast<void*>(gameContext->world));
std::snprintf(buffer, 20, "%p", static_cast<void*>(gameContext->world));
debugPayload.WorldContextAddress = std::string(buffer);
std::sprintf(buffer, "%p", static_cast<void*>(gameContext->map));
std::snprintf(buffer, 20, "%p", static_cast<void*>(gameContext->map));
debugPayload.MapContextAddress = std::string(buffer);

return debugPayload;
Expand Down
6 changes: 3 additions & 3 deletions Daybreak.Tests/Daybreak.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
144 changes: 75 additions & 69 deletions Daybreak/Configuration/ProjectConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
using Daybreak.Services.ApplicationArguments.ArgumentHandling;
using Daybreak.Services.Window;
using Daybreak.Launch;
using Daybreak.Utils;

namespace Daybreak.Configuration;

Expand All @@ -100,80 +101,14 @@ public override void RegisterResolvers(IServiceManager serviceManager)
serviceManager.RegisterOptionsManager<OptionsManager>();
serviceManager.RegisterResolver(new LoggerResolver());
serviceManager.RegisterResolver(new ClientWebSocketResolver());
serviceManager
.RegisterHttpClient<ApplicationUpdater>()
.WithMessageHandler(this.SetupLoggingAndMetrics<ApplicationUpdater>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<OnlinePictureClient>()
.WithMessageHandler(this.SetupLoggingAndMetrics<OnlinePictureClient>)
.WithDefaultRequestHeadersSetup(this.SetupChromeImpersonationUserAgent)
.Build()
.RegisterHttpClient<GraphClient>()
.WithMessageHandler(this.SetupLoggingAndMetrics<GraphClient>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<DownloadService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<DownloadService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<TradeChatService<KamadanTradeChatOptions>>()
.WithMessageHandler(this.SetupLoggingAndMetrics<TradeChatService<KamadanTradeChatOptions>>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<TradeChatService<AscalonTradeChatOptions>>()
.WithMessageHandler(this.SetupLoggingAndMetrics<TradeChatService<AscalonTradeChatOptions>>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<IconCache>()
.WithMessageHandler(this.SetupLoggingAndMetrics<IconCache>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<TraderQuoteService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<TraderQuoteService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<PriceHistoryService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<PriceHistoryService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<InternetCheckingService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<InternetCheckingService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<ChromiumBrowserWrapper>()
.WithMessageHandler(this.SetupLoggingAndMetrics<ChromiumBrowserWrapper>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<ToolboxClient>()
.WithMessageHandler(this.SetupLoggingAndMetrics<ToolboxClient>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<ReShadeService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<ReShadeService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<GWCAClient>()
.WithMessageHandler(this.SetupLoggingAndMetrics<GWCAClient>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.WithTimeout(TimeSpan.FromSeconds(5))
.Build()
.RegisterHttpClient<UModService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<UModService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<UBlockOriginService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<UBlockOriginService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build();
}

public override void RegisterServices(IServiceCollection services)
{
services.ThrowIfNull();

this.RegisterLiteCollections(services);

this.RegisterHttpClients(services);
services.AddSingleton<ILogsManager, JsonLogsManager>();
services.AddSingleton<IDebugLogsWriter, Services.Logging.DebugLogsWriter>();
services.AddSingleton<IEventViewerLogsWriter, EventViewerLogsWriter>();
Expand Down Expand Up @@ -201,7 +136,7 @@ public override void RegisterServices(IServiceCollection services)
services.AddSingleton<IPostUpdateActionProvider>(sp => sp.GetRequiredService<PostUpdateActionManager>());
services.AddSingleton<IMenuService, MenuService>();
services.AddSingleton<IMenuServiceInitializer, MenuService>(sp => sp.GetRequiredService<IMenuService>().Cast<MenuService>());
services.AddSingleton<ILiteDatabase, LiteDatabase>(sp => new LiteDatabase("Daybreak.db"));
services.AddSingleton<ILiteDatabase, LiteDatabase>(sp => new LiteDatabase(PathUtils.GetAbsolutePathFromRoot("Daybreak.db")));
services.AddSingleton<IMutexHandler, MutexHandler>();
services.AddSingleton<IShortcutManager, ShortcutManager>();
services.AddSingleton<IMetricsService, MetricsService>();
Expand Down Expand Up @@ -247,7 +182,7 @@ public override void RegisterServices(IServiceCollection services)
services.AddScoped<IExperienceCalculator, ExperienceCalculator>();
services.AddScoped<IAttributePointCalculator, AttributePointCalculator>();
services.AddScoped<IDownloadService, DownloadService>();
services.AddScoped<IGuildwarsInstaller, GuildwarsInstaller>();
services.AddScoped<IGuildwarsInstaller, IntegratedGuildwarsInstaller>();
services.AddScoped<IExceptionHandler, ExceptionHandler>();
services.AddScoped<IDrawingService, DrawingService>();
services.AddScoped<IDrawingModuleProducer, DrawingService>(sp => sp.GetRequiredService<IDrawingService>().As<DrawingService>()!);
Expand Down Expand Up @@ -490,4 +425,75 @@ private void RegisterLiteCollections(IServiceCollection services)
this.RegisterLiteCollection<NotificationDTO, NotificationStorageOptions>(services);
this.RegisterLiteCollection<TraderMessageDTO, TraderMessagesOptions>(services);
}

private IServiceCollection RegisterHttpClients(IServiceCollection services)
{
return services
.ThrowIfNull()
.RegisterHttpClient<ApplicationUpdater>()
.WithMessageHandler(this.SetupLoggingAndMetrics<ApplicationUpdater>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<OnlinePictureClient>()
.WithMessageHandler(this.SetupLoggingAndMetrics<OnlinePictureClient>)
.WithDefaultRequestHeadersSetup(this.SetupChromeImpersonationUserAgent)
.Build()
.RegisterHttpClient<GraphClient>()
.WithMessageHandler(this.SetupLoggingAndMetrics<GraphClient>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<DownloadService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<DownloadService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<TradeChatService<KamadanTradeChatOptions>>()
.WithMessageHandler(this.SetupLoggingAndMetrics<TradeChatService<KamadanTradeChatOptions>>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<TradeChatService<AscalonTradeChatOptions>>()
.WithMessageHandler(this.SetupLoggingAndMetrics<TradeChatService<AscalonTradeChatOptions>>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<IconCache>()
.WithMessageHandler(this.SetupLoggingAndMetrics<IconCache>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<TraderQuoteService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<TraderQuoteService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<PriceHistoryService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<PriceHistoryService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<InternetCheckingService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<InternetCheckingService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<ChromiumBrowserWrapper>()
.WithMessageHandler(this.SetupLoggingAndMetrics<ChromiumBrowserWrapper>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<ToolboxClient>()
.WithMessageHandler(this.SetupLoggingAndMetrics<ToolboxClient>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<ReShadeService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<ReShadeService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<GWCAClient>()
.WithMessageHandler(this.SetupLoggingAndMetrics<GWCAClient>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.WithTimeout(TimeSpan.FromSeconds(5))
.Build()
.RegisterHttpClient<UModService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<UModService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build()
.RegisterHttpClient<UBlockOriginService>()
.WithMessageHandler(this.SetupLoggingAndMetrics<UBlockOriginService>)
.WithDefaultRequestHeadersSetup(this.SetupDaybreakUserAgent)
.Build();
}
}
26 changes: 26 additions & 0 deletions Daybreak/Controls/AsyncImage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<UserControl x:Class="Daybreak.Controls.AsyncImage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Daybreak.Controls"
xmlns:converters="clr-namespace:Daybreak.Converters"
mc:Ignorable="d"
x:Name="_this"
Loaded="AsyncImage_Loaded"
Unloaded="AsyncImage_Unloaded"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<converters:BooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" TriggerValue="True"/>
</UserControl.Resources>
<Grid>
<Image x:Name="Image"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Width="{Binding ElementName=_this, Path=ActualWidth, Mode=OneWay}"
Height="{Binding ElementName=_this, Path=ActualWidth, Mode=OneWay}"
Source="{Binding ElementName=_this, Path=ImageSource, Mode=OneWay}"
Stretch="{Binding ElementName=_this, Path=Stretch, Mode=OneWay}"/>
</Grid>
</UserControl>
98 changes: 98 additions & 0 deletions Daybreak/Controls/AsyncImage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using Daybreak.Services.Images;
using Microsoft.Extensions.DependencyInjection;
using System.Core.Extensions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Extensions;
using System.Windows.Media;

namespace Daybreak.Controls;
/// <summary>
/// Interaction logic for AsyncImage.xaml
/// </summary>
public partial class AsyncImage : UserControl
{
private readonly IImageCache imageCache;

private string? imageUriCache;
private CancellationTokenSource? cancellationTokenSource;

[GenerateDependencyProperty]
private bool loading;
[GenerateDependencyProperty]
private ImageSource imageSource = default!;
[GenerateDependencyProperty]
private string imageUri = string.Empty;
[GenerateDependencyProperty]
private Stretch stretch;
[GenerateDependencyProperty(InitialValue = BitmapScalingMode.HighQuality)]
private BitmapScalingMode scalingMode = BitmapScalingMode.HighQuality;

public AsyncImage(
IImageCache imageCache)
{
this.imageCache = imageCache.ThrowIfNull();
this.InitializeComponent();
this.SetImageScalingMode();
}

public AsyncImage()
: this(Launch.Launcher.Instance.ApplicationServiceProvider.GetRequiredService<IImageCache>())
{
}

protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == ScalingModeProperty)
{
this.SetImageScalingMode();
}
else if (e.Property == ImageSourceProperty)
{
this.Loading = false;
}
else if (e.Property == ImageUriProperty &&
this.ImageUri != this.imageUriCache)
{
this.Loading = true;
this.UpdateImage(this.ImageUri);
}
}

private void SetImageScalingMode()
{
RenderOptions.SetBitmapScalingMode(this.Image, this.ScalingMode);
}

private void UpdateImage(string maybeUri)
{
this.cancellationTokenSource?.Dispose();
this.cancellationTokenSource = new();
var token = this.cancellationTokenSource.Token;
new TaskFactory().StartNew(() => this.imageCache.GetImage(maybeUri), token, TaskCreationOptions.LongRunning, TaskScheduler.Current)
.ContinueWith(async t =>
{
var result = await await t;
this.Dispatcher.Invoke(() =>
{
this.ImageSource = result;
this.Loading = false;
this.imageUriCache = maybeUri;
});
});
}

private void AsyncImage_Loaded(object sender, RoutedEventArgs e)
{

}

private void AsyncImage_Unloaded(object sender, RoutedEventArgs e)
{
this.cancellationTokenSource?.Dispose();
this.cancellationTokenSource = null;
}
}
2 changes: 1 addition & 1 deletion Daybreak/Controls/ChromiumBrowserWrapper.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private void InitializeEnvironment()
return;
}

CoreWebView2Environment ??= System.Extensions.TaskExtensions.RunSync(() => CoreWebView2Environment.CreateAsync(null, "BrowserData", new CoreWebView2EnvironmentOptions
CoreWebView2Environment ??= System.Extensions.TaskExtensions.RunSync(() => CoreWebView2Environment.CreateAsync(null, PathUtils.GetAbsolutePathFromRoot("BrowserData"), new CoreWebView2EnvironmentOptions
{
EnableTrackingPrevention = true,
AllowSingleSignOnUsingOSPrimaryAccount = true,
Expand Down
7 changes: 1 addition & 6 deletions Daybreak/Controls/ImageViewer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,11 @@ public ImageViewer()
this.Image2.Opacity = 0;
}

public async void ShowImage(ImageSource imageSource)
public void ShowImage(ImageSource imageSource)
{
var currentVisible = this.CurrentVisible();
var nextVisible = this.NextVisible();

if (nextVisible.Source is BitmapImage bitmapImage)
{
await bitmapImage.StreamSource.DisposeAsync().ConfigureAwait(true);
}

nextVisible.Source = imageSource;
Transition(currentVisible, nextVisible);
}
Expand Down
Loading
Loading