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.45 #773

Merged
merged 7 commits into from
Jul 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
2 changes: 1 addition & 1 deletion Daybreak.GWCA/source/GameModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ namespace Daybreak::Modules {
return gamePayload;
}

auto playerAgentId = GW::Agents::GetPlayerId();
auto playerAgentId = GW::Agents::GetControlledCharacterId();

std::list<MapIcon> mapIcons;
for (const auto& icon : worldContext->mission_map_icons) {
Expand Down
2 changes: 1 addition & 1 deletion Daybreak.GWCA/source/MainPlayerModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ namespace Daybreak::Modules {
if (mapAgents.empty()) {
return mainPlayer;
}
auto playerAgentId = GW::Agents::GetPlayerId();
auto playerAgentId = GW::Agents::GetControlledCharacterId();

auto foundMainAttr = std::find_if(attributes.begin(), attributes.end(), [&](GW::PartyAttribute attribute) {
return playerAgentId == attribute.agent_id;
Expand Down
13 changes: 9 additions & 4 deletions Daybreak/Configuration/ProjectConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
using Daybreak.Services.Drawing.Modules.Entities;
using Daybreak.Services.Drawing.Modules.MapIcons;
using Daybreak.Services.Drawing.Modules;
using Daybreak.Services.Guildwars;
using Daybreak.Services.GuildWars;
using Daybreak.Configuration.Options;
using System.Configuration;
using Daybreak.Services.UMod;
Expand Down Expand Up @@ -89,6 +89,7 @@
using Daybreak.Services.Window;
using Daybreak.Launch;
using Daybreak.Utils;
using Daybreak.Views.Installation;

namespace Daybreak.Configuration;

Expand Down Expand Up @@ -182,7 +183,7 @@ public override void RegisterServices(IServiceCollection services)
services.AddScoped<IExperienceCalculator, ExperienceCalculator>();
services.AddScoped<IAttributePointCalculator, AttributePointCalculator>();
services.AddScoped<IDownloadService, DownloadService>();
services.AddScoped<IGuildwarsInstaller, IntegratedGuildwarsInstaller>();
services.AddScoped<IGuildWarsInstaller, IntegratedGuildwarsInstaller>();
services.AddScoped<IExceptionHandler, ExceptionHandler>();
services.AddScoped<IDrawingService, DrawingService>();
services.AddScoped<IDrawingModuleProducer, DrawingService>(sp => sp.GetRequiredService<IDrawingService>().As<DrawingService>()!);
Expand All @@ -193,7 +194,7 @@ public override void RegisterServices(IServiceCollection services)
services.AddScoped<IPriceHistoryService, PriceHistoryService>();
services.AddScoped<IWordHighlightingService, WordHighlightingService>();
services.AddScoped<ITradeHistoryDatabase, TradeHistoryDatabase>();
services.AddScoped<IGuildwarsCopyService, GuildwarsCopyService>();
services.AddScoped<IGuildWarsCopyService, GuildWarsCopyService>();
services.AddScoped<IItemHashService, ItemHashService>();
services.AddScoped<IRegistryService, RegistryService>();
services.AddScoped<IEventNotifierService, EventNotifierService>();
Expand Down Expand Up @@ -227,7 +228,8 @@ public override void RegisterViews(IViewProducer viewProducer)
viewProducer.RegisterView<BuildsSynchronizationView>();
viewProducer.RegisterView<LauncherOnboardingView>();
viewProducer.RegisterView<MetricsView>();
viewProducer.RegisterView<GuildwarsDownloadView>();
viewProducer.RegisterView<GuildWarsDownloadView>();
viewProducer.RegisterView<GuildWarsDownloadSelectionView>();
viewProducer.RegisterView<UModInstallingView>();
viewProducer.RegisterView<UModInstallationChoiceView>();
viewProducer.RegisterView<UModOnboardingEntryView>();
Expand Down Expand Up @@ -393,6 +395,8 @@ public override void RegisterNotificationHandlers(INotificationHandlerProducer n
notificationHandlerProducer.RegisterNotificationHandler<UpdateNotificationHandler>();
notificationHandlerProducer.RegisterNotificationHandler<ReShadeConfigChangedHandler>();
notificationHandlerProducer.RegisterNotificationHandler<NavigateToCalendarViewHandler>();
notificationHandlerProducer.RegisterNotificationHandler<GuildWarsUpdateNotificationHandler>();
notificationHandlerProducer.RegisterNotificationHandler<GuildWarsBatchUpdateNotificationHandler>();
}

public override void RegisterMods(IModsManager modsManager)
Expand All @@ -404,6 +408,7 @@ public override void RegisterMods(IModsManager modsManager)
modsManager.RegisterMod<IGuildwarsScreenPlacer, GuildwarsScreenPlacer>();
modsManager.RegisterMod<IGWCAInjector, GWCAInjector>();
modsManager.RegisterMod<IDirectSongService, DirectSongService>(singleton: true);
modsManager.RegisterMod<IGuildWarsVersionChecker, GuildWarsVersionChecker>();
}

public override void RegisterBrowserExtensions(IBrowserExtensionsProducer browserExtensionsProducer)
Expand Down
1 change: 0 additions & 1 deletion Daybreak/Controls/CircularLoadingWidget.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@
<BeginStoryboard x:Name="ProgressAnimation_BeginStoryboard" Storyboard="{StaticResource ProgressAnimation}"/>
</EventTrigger>
</UserControl.Triggers>

<Viewbox>
<Canvas x:Name="LayoutRoot" VerticalAlignment="Top" Height="88" Width="88">
<Grid Width="10.734" Height="10.004" Canvas.Left="38.614" Canvas.Top="0.331">
Expand Down
3 changes: 2 additions & 1 deletion Daybreak/Controls/MenuList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Daybreak.Services.Notifications;
using Daybreak.Views;
using Daybreak.Views.Copy;
using Daybreak.Views.Installation;
using Daybreak.Views.Launch;
using Daybreak.Views.Onboarding.DirectSong;
using Daybreak.Views.Onboarding.DSOAL;
Expand Down Expand Up @@ -100,7 +101,7 @@ private void MetricsButton_Clicked(object sender, EventArgs e)

private void DownloadGuildwarsButton_Clicked(object sender, EventArgs e)
{
this.viewManager.ShowView<GuildwarsDownloadView>();
this.viewManager.ShowView<GuildWarsDownloadSelectionView>();
}

private void CopyGuildwarsButton_Clicked(object sender, EventArgs e)
Expand Down
35 changes: 33 additions & 2 deletions Daybreak/Controls/Templates/GuildwarsPathTemplate.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
xmlns:converters="clr-namespace:Daybreak.Converters"
xmlns:local="clr-namespace:Daybreak.Controls"
xmlns:buttons="clr-namespace:Daybreak.Controls.Buttons"
xmlns:glyphs="clr-namespace:Daybreak.Controls.Glyphs"
Unloaded="UserControl_Unloaded"
mc:Ignorable="d"
x:Name="_this"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter"></converters:InverseBooleanConverter>
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
<converters:BooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" TriggerValue="True" IsHidden="False"/>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" TriggerValue="False" IsHidden="False"/>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
Expand All @@ -34,10 +38,37 @@
ToolTip="Path to Gw.exe"/>
</Grid>
<WrapPanel Grid.Column="1">
<Grid Margin="5"
Height="30"
Width="30"
Visibility="{Binding ElementName=_this, Path=CheckingVersion, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
<TextBlock Text="{Binding ElementName=_this, Path=UpdateProgress, Mode=OneWay}"
FontSize="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"/>
<local:CircularLoadingWidget Width="30" />
</Grid>
<Grid Margin="5"
Visibility="{Binding ElementName=_this, Path=CheckingVersion, Mode=OneWay, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
<Grid Visibility="{Binding ElementName=_this, Path=NoUpdateResult, Mode=OneWay, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
<glyphs:GoodGlyph Height="30" Width="30" Foreground="{StaticResource MahApps.Brushes.Accent}"
Visibility="{Binding ElementName=_this, Path=UpToDate, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<buttons:BackButton Height="30" Width="30"
Visibility="{Binding ElementName=_this, Path=UpToDate, Mode=OneWay, Converter={StaticResource InverseBooleanToVisibilityConverter}}"
RenderTransformOrigin="0.5 0.5"
ToolTip="Update executable"
Clicked="UpdateButton_Clicked">
<buttons:BackButton.RenderTransform>
<RotateTransform Angle="270"/>
</buttons:BackButton.RenderTransform>
</buttons:BackButton>
</Grid>
</Grid>
<buttons:FilePickerButton Width="30" Height="30" VerticalAlignment="Top" Margin="5"
Clicked="FilePickerGlyph_Clicked"
ToolTip="Open path dialog"/>
<buttons:BinButton Grid.Column="2" Height="30" Width="30" VerticalAlignment="Top" Margin="5"
<buttons:BinButton Height="30" Width="30" VerticalAlignment="Top" Margin="5"
Clicked="BinButton_Clicked"
ToolTip="Remove entry"/>
</WrapPanel>
Expand Down
150 changes: 147 additions & 3 deletions Daybreak/Controls/Templates/GuildwarsPathTemplate.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
using Daybreak.Models;
using Daybreak.Controls.Buttons;
using Daybreak.Models;
using Daybreak.Models.Progress;
using Daybreak.Models.Versioning;
using Daybreak.Services.GuildWars;
using Daybreak.Services.Navigation;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Win32;
using System;
using System.Core.Extensions;
using System.Data;
using System.Extensions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Extensions;
Expand All @@ -15,16 +25,57 @@ namespace Daybreak.Controls;
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0052:Remove unread private members", Justification = "Used by source generators")]
public partial class GuildwarsPathTemplate : UserControl
{
private readonly IGuildWarsInstaller guildWarsInstaller;

private CancellationTokenSource? tokenSource;

public event EventHandler? RemoveClicked;

[GenerateDependencyProperty]
private string path = string.Empty;
private bool noUpdateResult;
[GenerateDependencyProperty]
private bool checkingVersion;
[GenerateDependencyProperty]
private bool upToDate;
[GenerateDependencyProperty]
private string updateProgress = string.Empty;

public GuildwarsPathTemplate()
public GuildwarsPathTemplate() :
this(Launch.Launcher.Instance.ApplicationServiceProvider.GetRequiredService<IGuildWarsInstaller>())
{
}

public GuildwarsPathTemplate(
IGuildWarsInstaller guildWarsInstaller)
{
this.guildWarsInstaller = guildWarsInstaller.ThrowIfNull();
this.InitializeComponent();
}

protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == DataContextProperty)
{
if (e.OldValue is ExecutablePath oldPath)
{
oldPath.PropertyChanged -= this.ExecutablePath_PropertyChanged;
}

if (e.NewValue is ExecutablePath newPath)
{
newPath.PropertyChanged += this.ExecutablePath_PropertyChanged;
}

this.CheckExecutable();
}
}

private void ExecutablePath_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
throw new NotImplementedException();
}

private void BinButton_Clicked(object sender, EventArgs e)
{
this.RemoveClicked?.Invoke(this, e);
Expand All @@ -42,6 +93,99 @@ private void FilePickerGlyph_Clicked(object sender, EventArgs e)
if (filePicker.ShowDialog() is true)
{
this.DataContext.As<ExecutablePath>()!.Path = filePicker.FileName;
this.CheckExecutable();
}
}

private void UserControl_Unloaded(object sender, RoutedEventArgs e)
{
this.tokenSource?.Dispose();
}

private void CheckExecutable()
{
if (this.DataContext is not ExecutablePath executablePath)
{
return;
}

this.tokenSource?.Dispose();
this.tokenSource = new CancellationTokenSource();
new TaskFactory().StartNew(async () =>
{
await this.Dispatcher.InvokeAsync(() => this.CheckingVersion = true);
await this.Dispatcher.InvokeAsync(() => this.NoUpdateResult = false);
if (await this.guildWarsInstaller.GetLatestVersionId(this.tokenSource.Token) is not int latestVersion)
{
await this.Dispatcher.InvokeAsync(() => this.CheckingVersion = false);
await this.Dispatcher.InvokeAsync(() => this.NoUpdateResult = true);
return;
}

if (await this.guildWarsInstaller.GetVersionId(executablePath.Path, this.tokenSource.Token) is not int version)
{
await this.Dispatcher.InvokeAsync(() => this.CheckingVersion = false);
await this.Dispatcher.InvokeAsync(() => this.NoUpdateResult = false);
await this.Dispatcher.InvokeAsync(() => this.UpToDate = false);
return;
}

await this.Dispatcher.InvokeAsync(() => this.CheckingVersion = false);
await this.Dispatcher.InvokeAsync(() => this.NoUpdateResult = false);
await this.Dispatcher.InvokeAsync(() => this.UpToDate = version == latestVersion);
}, this.tokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Current);
}

private async void UpdateButton_Clicked(object sender, EventArgs e)
{
if (this.DataContext is not ExecutablePath path)
{
return;
}

if (sender is not BackButton updateButton)
{
return;
}

await this.Dispatcher.InvokeAsync(() => updateButton.IsEnabled = false);
await this.Dispatcher.InvokeAsync(() => this.CheckingVersion = true);
await this.Dispatcher.InvokeAsync(() => this.NoUpdateResult = false);
this.tokenSource?.Dispose();
this.tokenSource = new CancellationTokenSource();
var status = new GuildwarsInstallationStatus();
status.PropertyChanged += this.UpdateStatus_PropertyChanged;
try
{
var result = await this.guildWarsInstaller.UpdateGuildwars(path.Path, status, this.tokenSource.Token);
await this.Dispatcher.InvokeAsync(() => this.CheckingVersion = false);
await this.Dispatcher.InvokeAsync(() => this.NoUpdateResult = false);
await this.Dispatcher.InvokeAsync(() => this.UpToDate = result);
}
finally
{
status.PropertyChanged -= this.UpdateStatus_PropertyChanged;
}
}

private void UpdateStatus_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (sender is not GuildwarsInstallationStatus status)
{
return;
}

if (status.CurrentStep is DownloadStatus.DownloadProgressStep progressStep)
{
// TODO: Kinda hacky way to display a continuous progress widget
if (progressStep is GuildwarsInstallationStatus.UnpackingProgressStep)
{
this.Dispatcher.Invoke(() => this.UpdateProgress = $"{(int)(50 + (progressStep.Progress * 50))}%");
}
else
{
this.Dispatcher.Invoke(() => this.UpdateProgress = $"{(int)(progressStep.Progress * 50)}%");
}
}
}
}
5 changes: 3 additions & 2 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.44</Version>
<Version>0.9.9.45</Version>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<UserSecretsId>cfb2a489-db80-448d-a969-80270f314c46</UserSecretsId>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down Expand Up @@ -103,10 +103,11 @@
<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.1" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2535.41" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2592.51" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="PeNet" Version="4.0.5" />
<PackageReference Include="Plumsy" Version="1.1.0" />
<PackageReference Include="securifybv.ShellLink" Version="0.1.0" />
<PackageReference Include="SharpNav" Version="0.9.2" />
Expand Down
1 change: 1 addition & 0 deletions Daybreak/Models/Guildwars/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ public sealed class Map : IWikiEntity
public static readonly Map DwaynaVsGrenth = new() { Id = 253, Name = "Dwayna Vs Grenth", WikiUrl = "https://wiki.guildwars.com/wiki/Dwayna_Vs_Grenth" };
public static readonly Map SunjiangDistrictExplorable = new() { Id = 254, Name = "Sunjiang District", WikiUrl = "https://wiki.guildwars.com/wiki/Sunjiang_District" };
public static readonly Map NahpuiQuarterExplorable = new() { Id = 257, Name = "Nahpui Quarter", WikiUrl = "https://wiki.guildwars.com/wiki/Nahpui_Quarter" };
public static readonly Map NahpuiQuarterExplorable2 = new() { Id = 265, Name = "Nahpui Quarter", WikiUrl = "https://wiki.guildwars.com/wiki/Nahpui_Quarter" };
public static readonly Map UrgozsWarren = new() { Id = 266, Name = "Urgozs Warren", WikiUrl = "https://wiki.guildwars.com/wiki/Urgozs_Warren" };
public static readonly Map TahnnakaiTempleExplorable = new() { Id = 267, Name = "Tahnnakai Temple", WikiUrl = "https://wiki.guildwars.com/wiki/Tahnnakai_Temple" };
public static readonly Map AltrummRuins = new() { Id = 270, Name = "Altrumm Ruins", WikiUrl = "https://wiki.guildwars.com/wiki/Altrumm_Ruins" };
Expand Down
2 changes: 1 addition & 1 deletion Daybreak/Models/Progress/DownloadStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal DownloadStep(string name) : base(name)
}
}

public sealed class DownloadProgressStep : DownloadStep
public class DownloadProgressStep : DownloadStep
{
public TimeSpan? ETA { get; set; }

Expand Down
Loading
Loading