Skip to content

Commit

Permalink
Merge pull request #306 from WoWs-Builder-Team/development
Browse files Browse the repository at this point in the history
Update 2.5 (Desktop)
  • Loading branch information
floribe2000 authored Mar 18, 2024
2 parents dec53e6 + 91d0ef3 commit 8b7cc47
Show file tree
Hide file tree
Showing 86 changed files with 598 additions and 579 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ csharp_preferred_modifier_order = public, private, protected, internal, new, sta
csharp_style_var_elsewhere = true:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_using_directive_placement = outside_namespace:warning
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:suggestion
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:suggestion
Expand Down
21 changes: 3 additions & 18 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Update 2.4
# Update 2.5

## Download and Install

Expand All @@ -12,26 +12,11 @@ Download [**WoWsShipBuilderSetup.exe**](https://github.com/WoWs-Builder-Team/WoW
<summary>Click to show release notes</summary>

### Additions
- Secondaries now show dispersion data on the ship stats page
- A ship selector in the style of fitting tool has been added. This feature's behaviour can be configured in the app settings
- Build images can be copied to the clipboard without downloading them as files first (not supported on Firefox by default due to browser limitations)
- Navigation within the app can now carry over ships and build configurations from one page to another. Note: This does not work when user the browser's backwards and forwards navigation
- Ammo switch time is now visible in ship comparison

### Changes
- Improve secondary data display on the ship stats page
- The app now uses server prerendering to improve loading times and previews
- Existing builds can now be overwritten by new ones instead of always creating new builds when saving
- The desktop app window can now be resized again
- Modifier processing has been reworked completely to simplify adapting to changes in future game updates
- various other improvements
- Technical improvements to the application

### Bugfixes
- Ship Comparison crashed when trying to sort multi-value columns
- Ship Comparison sorting by tier now works as expected
- Kitakami should now show the correct loader configuration for her torpedoes
- Exported build images will now render all elements correctly
- (Desktop) App crashes when trying to export a build image
- Ships are now correctly imported into the ship comparison we navigating from ship stats page
- various other bug fixes

</details>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -21,12 +21,12 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="TestableIO.System.IO.Abstractions.TestingHelpers" Version="20.0.4" />
<PackageReference Include="TestableIO.System.IO.Abstractions.TestingHelpers" Version="21.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@using WoWsShipBuilder.Infrastructure.Localization.Resources
@using WoWsShipBuilder.Infrastructure.Metrics
@using WoWsShipBuilder.Infrastructure.Utility
@using System.Collections.Immutable

@inject ILocalizer Localizer
@inject IDialogService DialogService
Expand Down Expand Up @@ -125,7 +126,7 @@

NavManager.TryGetQueryString("shipIndexes", out string shipIndexesFromUrl);

IEnumerable<ShipBuildContainer>? buildContainers = SessionStateCache.GetAndResetBuildTransferContainers() ?? (!string.IsNullOrWhiteSpace(shipIndexesFromUrl) ? shipIndexesFromUrl.Split(',').Select(x => ShipBuildContainer.CreateNew(AppData.ShipDictionary[x], null, null)) : null);
IEnumerable<ShipBuildContainer>? buildContainers = SessionStateCache.GetAndResetBuildTransferContainers() ?? (!string.IsNullOrWhiteSpace(shipIndexesFromUrl) ? shipIndexesFromUrl.Split(',').Select(x => ShipBuildContainer.CreateNew(AppData.ShipDictionary[x], null, ImmutableArray<int>.Empty)) : null);

if (buildContainers is not null)
{
Expand Down Expand Up @@ -175,7 +176,7 @@

List<IEnumerable<ChartsHelper.Point>> shipData = new()
{
GetAccelerationData(shipWrapper.Ship, hull, engine, shipWrapper.Modifiers ?? new(), throttleList),
GetAccelerationData(shipWrapper.Ship, hull, engine, shipWrapper.Modifiers, throttleList),
};
var newChartData = new NewChartDataInput(shipWrapper.Id.ToString(), label, shipData, chartShipCounter);
newData.Add(newChartData);
Expand Down Expand Up @@ -211,7 +212,7 @@
hull = shipWrapper.Ship.Hulls.First().Value;
}

var updateChartData = new UpdateChartDataLabelInput(shipWrapper.Id.ToString(), shipWrapper.Id.ToString(), label, GetAccelerationData(shipWrapper.Ship, hull, engine, shipWrapper.Modifiers ?? new(), throttleList));
var updateChartData = new UpdateChartDataLabelInput(shipWrapper.Id.ToString(), shipWrapper.Id.ToString(), label, GetAccelerationData(shipWrapper.Ship, hull, engine, shipWrapper.Modifiers, throttleList));
updatedData.Add(updateChartData);
}

Expand All @@ -233,7 +234,7 @@
await ChartJsInterop.CreateChartAsync(AccelerationId, Localizer.GetAppLocalization(nameof(Translation.AccelerationChart_Acceleration)).Localization, Localizer.GetAppLocalization(nameof(Translation.AccelerationChart_Time)).Localization, Localizer.GetAppLocalization(nameof(Translation.ShipStats_Speed)).Localization, s, knots);
}

private static IEnumerable<ChartsHelper.Point> GetAccelerationData(Ship ship, Hull hull, Engine engine, List<Modifier> modifiers, List<int> throttles)
private static IEnumerable<ChartsHelper.Point> GetAccelerationData(Ship ship, Hull hull, Engine engine, ImmutableList<Modifier> modifiers, List<int> throttles)
{
decimal maxSpeedModifier = modifiers.ApplyModifiers("ManeuverabilityDataContainer.Speed", 1m);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
ShipConsumable = ImmutableList<ShipConsumable>.Empty,
};

var container = ShipBuildContainer.CreateNew(ship, null, null);
var container = ShipBuildContainer.CreateNew(ship, null, ImmutableArray<int>.Empty);
MudDialog.Close(DialogResult.Ok(container));
}

Expand Down
3 changes: 2 additions & 1 deletion WoWsShipBuilder.Common/Features/BallisticCharts/Charts.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@using WoWsShipBuilder.Infrastructure.Localization.Resources
@using WoWsShipBuilder.Infrastructure.Metrics
@using WoWsShipBuilder.Infrastructure.Utility
@using System.Collections.Immutable

@inject NavigationManager NavManager
@inject ILocalizer Localizer
Expand Down Expand Up @@ -338,7 +339,7 @@
await SetupChartsAsync();
if (shipIndexesFromUrl.Any())
{
IEnumerable<ShipBuildContainer>? buildContainers = SessionStateCache.GetAndResetBuildTransferContainers() ?? (shipIndexesFromUrl.Any() ? shipIndexesFromUrl.Select(x => ShipBuildContainer.CreateNew(AppData.ShipDictionary[x], null, null) with { ShipDataContainer = DataContainerUtility.GetStockShipDataContainer(AppData.ShipDictionary[x]) }) : null);
IEnumerable<ShipBuildContainer>? buildContainers = SessionStateCache.GetAndResetBuildTransferContainers() ?? (shipIndexesFromUrl.Any() ? shipIndexesFromUrl.Select(x => ShipBuildContainer.CreateNew(AppData.ShipDictionary[x], null, ImmutableArray<int>.Empty) with { ShipDataContainer = DataContainerUtility.GetStockShipDataContainer(AppData.ShipDictionary[x]) }) : null);
if (buildContainers is not null)
{
List<ChartsDataWrapper> shipsToAdd = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
var shipConfiguration = Helpers.GetStockShipConfiguration(ship);
UpgradeModuleInShipConfiguration(shipConfiguration, commonHull);
UpgradeModuleInShipConfiguration(shipConfiguration, commonArtillery);
var dataContainer = ShipDataContainer.CreateFromShip(ship, shipConfiguration, wrapper.ShipBuildContainer.Modifiers ?? new());
var dataContainer = ShipDataContainer.CreateFromShip(ship, shipConfiguration.ToImmutableList(), wrapper.ShipBuildContainer.Modifiers);
Build build = new(string.Empty, ship.Index, ship.ShipNation, shipConfiguration.Select(x => x.Name.NameToIndex()).ToList(), ImmutableArray<string>.Empty, GetStockConsumableNames(ship), "PCW001", ImmutableArray<int>.Empty, ImmutableArray<string>.Empty);
var container = wrapper.ShipBuildContainer with { ShipDataContainer = dataContainer, Build = build };
var newWrapper = wrapper with { ShipBuildContainer = container };
Expand All @@ -245,7 +245,7 @@
var shipConfiguration = Helpers.GetShipConfigurationFromBuild(build.Modules, ship.ShipUpgradeInfo.ShipUpgrades);
UpgradeModuleInShipConfiguration(shipConfiguration, commonHull);
UpgradeModuleInShipConfiguration(shipConfiguration, commonArtillery);
var dataContainer = ShipDataContainer.CreateFromShip(ship, shipConfiguration, wrapper.ShipBuildContainer.Modifiers ?? new());
var dataContainer = ShipDataContainer.CreateFromShip(ship, shipConfiguration.ToImmutableList(), wrapper.ShipBuildContainer.Modifiers);
Build newBuild = new(build.BuildName, ship.Index, ship.ShipNation, shipConfiguration.Select(x => x.Name.NameToIndex()).ToList(), build.Upgrades.ToList(), build.Consumables.ToList(), build.Captain, build.Skills.ToList(), build.Signals.ToList());
var container = wrapper.ShipBuildContainer with { ShipDataContainer = dataContainer, Build = newBuild };
var newWrapper = wrapper with { ShipBuildContainer = container };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@using Prometheus
@using System.Collections.Concurrent
@using System.Collections.Immutable
@using Microsoft.Extensions.Hosting
@using Microsoft.Extensions.Options
@using WoWsShipBuilder.DataStructures.Ship
Expand Down Expand Up @@ -274,7 +275,7 @@
using (MetricsService.ShipViewModelInitDuration.NewTimer())
{
var vm = ShipBuildViewModel.Create(shipBuildContainer);
foreach (int slot in shipBuildContainer.ActivatedConsumableSlots ?? Array.Empty<int>())
foreach (int slot in shipBuildContainer.ActivatedConsumableSlots)
{
vm.ConsumableViewModel.ConsumableSlots[slot].ConsumableActivated = true;
}
Expand All @@ -295,7 +296,7 @@

private async Task ResetBuild()
{
var vm = LoadShipViewModel(SelectedContainer with { Build = null, ActivatedConsumableSlots = null, SpecialAbilityActive = false });
var vm = LoadShipViewModel(SelectedContainer with { Build = null, ActivatedConsumableSlots = ImmutableArray<int>.Empty, SpecialAbilityActive = false });
ViewModel = vm;
vmCache[SelectedContainer.Id] = vm;
await Task.Delay(1); // needed for the captain skill selector to rerender properly
Expand All @@ -317,7 +318,7 @@
throw new FormatException();
}

ViewModel = LoadShipViewModel(ShipBuildContainer.CreateNew(ship, build, null));
ViewModel = LoadShipViewModel(ShipBuildContainer.CreateNew(ship, build, ImmutableArray<int>.Empty));
inputBuildString = string.Empty;
buildString = string.Empty;
vmCache[SelectedContainer.Id] = ViewModel;
Expand Down
15 changes: 8 additions & 7 deletions WoWsShipBuilder.Common/Features/Builds/ShipBuildViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ReactiveUI;
using System.Collections.Immutable;
using ReactiveUI;
using WoWsShipBuilder.DataStructures.Modifiers;
using WoWsShipBuilder.DataStructures.Ship;
using WoWsShipBuilder.Features.DataContainers;
Expand Down Expand Up @@ -80,8 +81,8 @@ public static ShipBuildViewModel Create(ShipBuildContainer shipBuildContainer)
public ShipBuildContainer CreateShipBuildContainer(ShipBuildContainer baseContainer)
{
var build = this.DumpToBuild();
List<int>? activatedConsumables = this.ConsumableViewModel.ActivatedSlots.Any() ? this.ConsumableViewModel.ActivatedSlots.ToList() : null;
List<Modifier> modifiers = this.GenerateModifierList();
var activatedConsumables = this.ConsumableViewModel.ActivatedSlots.Any() ? this.ConsumableViewModel.ActivatedSlots.ToImmutableArray() : ImmutableArray<int>.Empty;
ImmutableList<Modifier> modifiers = this.GenerateModifierList();
return baseContainer with
{
Build = build,
Expand All @@ -92,19 +93,19 @@ public ShipBuildContainer CreateShipBuildContainer(ShipBuildContainer baseContai
};
}

private ShipDataContainer CreateDataContainer(List<Modifier> modifiers)
private ShipDataContainer CreateDataContainer(ImmutableList<Modifier> modifiers)
{
return ShipDataContainer.CreateFromShip(this.CurrentShip, this.ShipModuleViewModel.SelectedModules.ToList(), modifiers);
return ShipDataContainer.CreateFromShip(this.CurrentShip, this.ShipModuleViewModel.SelectedModules.ToImmutableList(), modifiers);
}

private List<Modifier> GenerateModifierList()
private ImmutableList<Modifier> GenerateModifierList()
{
var modifiers = new List<Modifier>();

modifiers.AddRange(this.UpgradePanelViewModel.GetModifierList());
modifiers.AddRange(this.SignalSelectorViewModel.GetModifierList());
modifiers.AddRange(this.CaptainSkillSelectorViewModel.GetModifiersList());
modifiers.AddRange(this.ConsumableViewModel.GetModifiersList());
return modifiers;
return modifiers.ToImmutableList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace WoWsShipBuilder.Features.DataContainers;

[DataContainer]
public partial record AirstrikeDataContainer : DataContainerBase
public partial class AirstrikeDataContainer : DataContainerBase
{
public string Header { get; set; } = default!;

Expand Down Expand Up @@ -50,7 +50,7 @@ public partial record AirstrikeDataContainer : DataContainerBase

public ProjectileDataContainer? Weapon { get; set; }

public static AirstrikeDataContainer? FromShip(Ship ship, List<Modifier> modifiers, bool isAsw)
public static AirstrikeDataContainer? FromShip(Ship ship, ImmutableList<Modifier> modifiers, bool isAsw)
{
string header = isAsw ? "ShipStats_AswAirstrike" : "ShipStats_Airstrike";
ImmutableDictionary<string, AirStrike> airstrikes = ship.AirStrikes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Immutable;
using System.Globalization;
using WoWsShipBuilder.DataElements;
using WoWsShipBuilder.DataElements.DataElementAttributes;
Expand All @@ -11,7 +12,7 @@
namespace WoWsShipBuilder.Features.DataContainers;

[DataContainer]
public partial record CvAircraftDataContainer : DataContainerBase
public partial class CvAircraftDataContainer : DataContainerBase
{
public string Name { get; set; } = default!;

Expand Down Expand Up @@ -99,7 +100,7 @@ public partial record CvAircraftDataContainer : DataContainerBase

public ProjectileDataContainer? Weapon { get; set; }

public List<ConsumableDataContainer> PlaneConsumables { get; set; } = default!;
public ImmutableList<ConsumableDataContainer> PlaneConsumables { get; set; } = ImmutableList<ConsumableDataContainer>.Empty;

// TODO
public decimal ArmamentReloadTime { get; set; }
Expand All @@ -108,7 +109,7 @@ public partial record CvAircraftDataContainer : DataContainerBase

public decimal BoostReloadTime { get; set; }

public static List<CvAircraftDataContainer>? FromShip(Ship ship, List<ShipUpgrade> shipConfiguration, List<Modifier> modifiers)
public static List<CvAircraftDataContainer>? FromShip(Ship ship, ImmutableList<ShipUpgrade> shipConfiguration, ImmutableList<Modifier> modifiers)
{
if (ship.CvPlanes.IsEmpty)
{
Expand Down Expand Up @@ -158,7 +159,7 @@ public partial record CvAircraftDataContainer : DataContainerBase
return list;
}

private static CvAircraftDataContainer ProcessCvPlane(Aircraft plane, int shipTier, List<Modifier> modifiers)
private static CvAircraftDataContainer ProcessCvPlane(Aircraft plane, int shipTier, ImmutableList<Modifier> modifiers)
{
int maxOnDeck = modifiers.ApplyModifiers("CvAircraftDataContainer.MaxOnDeck", plane.MaxPlaneInHangar);

Expand Down Expand Up @@ -307,7 +308,7 @@ private static CvAircraftDataContainer ProcessCvPlane(Aircraft plane, int shipTi
JatoSpeedMultiplier = Math.Round(jatoSpeedMultiplier, 0),
WeaponType = weaponType.ProjectileTypeToString(),
Weapon = weapon,
PlaneConsumables = consumables,
PlaneConsumables = consumables.ToImmutableList(),
AimingTime = Math.Round(aimingTime, 1),
PreparationTime = plane.PreparationTime,
PostAttackInvulnerabilityDuration = plane.PostAttackInvulnerabilityDuration,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System.Collections.Immutable;
using WoWsShipBuilder.DataElements;
using WoWsShipBuilder.DataElements.DataElementAttributes;
using WoWsShipBuilder.DataStructures;
using WoWsShipBuilder.DataStructures.Modifiers;
using WoWsShipBuilder.DataStructures.Ship;
using WoWsShipBuilder.Infrastructure.Utility;

namespace WoWsShipBuilder.Features.DataContainers;

[DataContainer]
public partial record DepthChargesLauncherDataContainer : DataContainerBase
public partial class DepthChargesLauncherDataContainer : DataContainerBase
{
[DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "S")]
public decimal Reload { get; set; }
Expand All @@ -21,7 +21,7 @@ public partial record DepthChargesLauncherDataContainer : DataContainerBase

public DepthChargeDataContainer? DepthCharge { get; set; }

public static DepthChargesLauncherDataContainer? FromShip(Ship ship, List<ShipUpgrade> shipConfiguration, List<Modifier> modifiers)
public static DepthChargesLauncherDataContainer? FromShip(Ship ship, ImmutableList<ShipUpgrade> shipConfiguration, ImmutableList<Modifier> modifiers)
{
var shipHull = ship.Hulls[shipConfiguration.First(upgrade => upgrade.UcType == ComponentType.Hull).Components[ComponentType.Hull][0]];

Expand Down
Loading

0 comments on commit 8b7cc47

Please sign in to comment.