From 37a4df0403ed8305eda6eccb4786867acd3ccd27 Mon Sep 17 00:00:00 2001 From: floribe2000 Date: Tue, 10 Oct 2023 00:34:35 +0200 Subject: [PATCH] add TextKind type to better specify how a type should be treated --- .../Aircraft/AirstrikeDataContainer.cs | 2 +- .../Armament/MainBatteryDataContainer.cs | 2 +- .../Armament/PingerGunDataContainer.cs | 4 +- .../Armament/SecondaryBatteryDataContainer.cs | 2 +- .../Armament/TorpedoArmamentDataContainer.cs | 6 +- .../Projectiles/BombDataContainer.cs | 4 +- .../Projectiles/RocketDataContainer.cs | 4 +- .../Projectiles/ShellDataContainer.cs | 2 +- .../Projectiles/TorpedoDataContainer.cs | 48 ++++++------- .../Ship/ManeuverabilityDataContainer.cs | 8 +-- .../Ship/SurvivabilityDataContainer.cs | 30 ++++---- .../Components/SharedFragments.razor | 15 ++-- .../Features/ShipStats/FormattedTextHelper.cs | 20 +++--- .../DataElementAnalyzerTest.cs | 1 + .../DataElementAnalyzerTests/FormattedText.cs | 14 ++-- .../DataElementAnalyzerTests/KeyValue.cs | 10 +-- .../DataElementAnalyzerTests/KeyValueUnit.cs | 18 ++--- .../DataElementAnalyzerTests/Tooltip.cs | 16 ++--- .../DataElementAnalyzerTests/Value.cs | 12 ++-- .../DataElementGeneratorTest.cs | 1 + .../FormattedText.cs | 28 ++++---- .../DataElementGeneratorTests/Grouped.cs | 12 ++-- .../DataElementGeneratorTests/KeyValue.cs | 10 +-- .../DataElementGeneratorTests/Mixed.cs | 8 +-- .../DataElementGeneratorTests/Value.cs | 10 +-- .../DataElementGenerator/AttributeHelper.cs | 69 ++++++++++++------- .../DataElementAnalyzer.cs | 68 +++++------------- .../DataElementGenerator.cs | 6 +- .../Model/FormattedTextData.cs | 2 +- .../Model/PropertyDisplayOptions.cs | 2 +- .../DataElementGenerator/PropertyHelper.cs | 10 ++- .../DataElementGenerator/TextKind.cs | 8 +++ .../DataElements/DataElementTextKind.cs | 8 +++ .../DataElements/FormattedTextDataElement.cs | 8 +-- .../DataElements/KeyValueDataElement.cs | 5 +- .../DataElements/ValueDataElement.cs | 5 +- 36 files changed, 245 insertions(+), 233 deletions(-) create mode 100644 WoWsShipBuilder.Data.Generator/DataElementGenerator/TextKind.cs create mode 100644 WoWsShipBuilder.DataElements/DataElements/DataElementTextKind.cs diff --git a/WoWsShipBuilder.Common/DataContainers/Aircraft/AirstrikeDataContainer.cs b/WoWsShipBuilder.Common/DataContainers/Aircraft/AirstrikeDataContainer.cs index d6d109cc2..55c73f6a9 100644 --- a/WoWsShipBuilder.Common/DataContainers/Aircraft/AirstrikeDataContainer.cs +++ b/WoWsShipBuilder.Common/DataContainers/Aircraft/AirstrikeDataContainer.cs @@ -12,7 +12,7 @@ public partial record AirstrikeDataContainer : DataContainerBase { public string Header { get; set; } = default!; - [DataElementType(DataElementTypes.KeyValue, IsValueLocalizationKey = true)] + [DataElementType(DataElementTypes.KeyValue, ValueTextKind = TextKind.LocalizationKey)] public string Name { get; set; } = default!; [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "HP")] diff --git a/WoWsShipBuilder.Common/DataContainers/Armament/MainBatteryDataContainer.cs b/WoWsShipBuilder.Common/DataContainers/Armament/MainBatteryDataContainer.cs index da9faeb9e..6c141fb00 100644 --- a/WoWsShipBuilder.Common/DataContainers/Armament/MainBatteryDataContainer.cs +++ b/WoWsShipBuilder.Common/DataContainers/Armament/MainBatteryDataContainer.cs @@ -13,7 +13,7 @@ namespace WoWsShipBuilder.DataContainers; [DataContainer] public partial record MainBatteryDataContainer : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName = "TurretNames", ArePropertyNameValuesKeys = true)] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = "TurretNames", ArgumentsTextKind = TextKind.LocalizationKey)] public string Name { get; set; } = default!; public List TurretNames { get; set; } = new(); diff --git a/WoWsShipBuilder.Common/DataContainers/Armament/PingerGunDataContainer.cs b/WoWsShipBuilder.Common/DataContainers/Armament/PingerGunDataContainer.cs index 8f9d235ed..0c3a2040a 100644 --- a/WoWsShipBuilder.Common/DataContainers/Armament/PingerGunDataContainer.cs +++ b/WoWsShipBuilder.Common/DataContainers/Armament/PingerGunDataContainer.cs @@ -22,10 +22,10 @@ public partial record PingerGunDataContainer : DataContainerBase [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "KM")] public decimal Range { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "PingDuration", UnitKey = "S", NameLocalizationKey = "First")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "PingDuration", UnitKey = "S", LocalizationKeyOverride = "First")] public decimal FirstPingDuration { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "PingDuration", UnitKey = "S", NameLocalizationKey = "Second")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "PingDuration", UnitKey = "S", LocalizationKeyOverride = "Second")] public decimal SecondPingDuration { get; set; } [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "M")] diff --git a/WoWsShipBuilder.Common/DataContainers/Armament/SecondaryBatteryDataContainer.cs b/WoWsShipBuilder.Common/DataContainers/Armament/SecondaryBatteryDataContainer.cs index d9b5a44fe..0fa04014a 100644 --- a/WoWsShipBuilder.Common/DataContainers/Armament/SecondaryBatteryDataContainer.cs +++ b/WoWsShipBuilder.Common/DataContainers/Armament/SecondaryBatteryDataContainer.cs @@ -93,7 +93,7 @@ public partial record SecondaryBatteryDataContainer : DataContainerBase { Name = arrangementString, TurretName = turretName, - TurretSetup = new(arrangementString, turretName, AreValuesKeys: true), + TurretSetup = new(arrangementString, turretName, ArgumentsTextKind: DataElementTextKind.LocalizationKey), BarrelsLayout = $"{secondaryGroup.Count} x {secondaryGun.NumBarrels}", BarrelsCount = secondaryGroup.Count * secondaryGun.NumBarrels, GunCaliber = Math.Round(secondaryGun.BarrelDiameter * 1000), diff --git a/WoWsShipBuilder.Common/DataContainers/Armament/TorpedoArmamentDataContainer.cs b/WoWsShipBuilder.Common/DataContainers/Armament/TorpedoArmamentDataContainer.cs index 582897712..a90d43716 100644 --- a/WoWsShipBuilder.Common/DataContainers/Armament/TorpedoArmamentDataContainer.cs +++ b/WoWsShipBuilder.Common/DataContainers/Armament/TorpedoArmamentDataContainer.cs @@ -11,7 +11,7 @@ namespace WoWsShipBuilder.DataContainers; [DataContainer] public partial record TorpedoArmamentDataContainer : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName = "LauncherNames", ArePropertyNameValuesKeys = true)] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = "LauncherNames", ArgumentsTextKind = TextKind.LocalizationKey)] public string Name { get; set; } = default!; public List LauncherNames { get; set; } = new(); @@ -40,10 +40,10 @@ public partial record TorpedoArmamentDataContainer : DataContainerBase [DataElementType(DataElementTypes.KeyValue)] public string FullSalvoDamage { get; set; } = default!; - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValue, GroupKey = "FullSalvoDamage", NameLocalizationKey = "FirstOption")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValue, GroupKey = "FullSalvoDamage", LocalizationKeyOverride = "FirstOption")] public string TorpFullSalvoDmg { get; set; } = default!; - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValue, GroupKey = "FullSalvoDamage", NameLocalizationKey = "SecondOption")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValue, GroupKey = "FullSalvoDamage", LocalizationKeyOverride = "SecondOption")] public string AltTorpFullSalvoDmg { get; set; } = default!; public int LoadersCount { get; set; } diff --git a/WoWsShipBuilder.Common/DataContainers/Projectiles/BombDataContainer.cs b/WoWsShipBuilder.Common/DataContainers/Projectiles/BombDataContainer.cs index cb1138e8e..5ff69265f 100644 --- a/WoWsShipBuilder.Common/DataContainers/Projectiles/BombDataContainer.cs +++ b/WoWsShipBuilder.Common/DataContainers/Projectiles/BombDataContainer.cs @@ -10,10 +10,10 @@ namespace WoWsShipBuilder.DataContainers; [DataContainer] public partial record BombDataContainer : ProjectileDataContainer { - [DataElementType(DataElementTypes.KeyValue, IsValueLocalizationKey = true, IsValueAppLocalization = true)] + [DataElementType(DataElementTypes.KeyValue, ValueTextKind = TextKind.AppLocalizationKey)] public string BombType { get; set; } = default!; - [DataElementType(DataElementTypes.KeyValue, IsValueLocalizationKey = true)] + [DataElementType(DataElementTypes.KeyValue, ValueTextKind = TextKind.LocalizationKey)] public string Name { get; set; } = default!; [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "MM")] diff --git a/WoWsShipBuilder.Common/DataContainers/Projectiles/RocketDataContainer.cs b/WoWsShipBuilder.Common/DataContainers/Projectiles/RocketDataContainer.cs index 29d3d6d1f..e432d1a77 100644 --- a/WoWsShipBuilder.Common/DataContainers/Projectiles/RocketDataContainer.cs +++ b/WoWsShipBuilder.Common/DataContainers/Projectiles/RocketDataContainer.cs @@ -10,10 +10,10 @@ namespace WoWsShipBuilder.DataContainers; [DataContainer] public partial record RocketDataContainer : ProjectileDataContainer { - [DataElementType(DataElementTypes.KeyValue, IsValueLocalizationKey = true, IsValueAppLocalization = true)] + [DataElementType(DataElementTypes.KeyValue, ValueTextKind = TextKind.AppLocalizationKey)] public string RocketType { get; set; } = default!; - [DataElementType(DataElementTypes.KeyValue, IsValueLocalizationKey = true)] + [DataElementType(DataElementTypes.KeyValue, ValueTextKind = TextKind.LocalizationKey)] public string Name { get; set; } = default!; [DataElementType(DataElementTypes.KeyValue)] diff --git a/WoWsShipBuilder.Common/DataContainers/Projectiles/ShellDataContainer.cs b/WoWsShipBuilder.Common/DataContainers/Projectiles/ShellDataContainer.cs index 3d3559c8d..6d642aef7 100644 --- a/WoWsShipBuilder.Common/DataContainers/Projectiles/ShellDataContainer.cs +++ b/WoWsShipBuilder.Common/DataContainers/Projectiles/ShellDataContainer.cs @@ -15,7 +15,7 @@ public partial record ShellDataContainer : DataContainerBase { public string Name { get; set; } = default!; - [DataElementType(DataElementTypes.KeyValue, IsValueLocalizationKey = true, IsValueAppLocalization = true)] + [DataElementType(DataElementTypes.KeyValue, ValueTextKind = TextKind.AppLocalizationKey)] public string Type { get; set; } = default!; [DataElementType(DataElementTypes.KeyValue)] diff --git a/WoWsShipBuilder.Common/DataContainers/Projectiles/TorpedoDataContainer.cs b/WoWsShipBuilder.Common/DataContainers/Projectiles/TorpedoDataContainer.cs index fdc8c1d90..1753f4ab1 100644 --- a/WoWsShipBuilder.Common/DataContainers/Projectiles/TorpedoDataContainer.cs +++ b/WoWsShipBuilder.Common/DataContainers/Projectiles/TorpedoDataContainer.cs @@ -10,10 +10,10 @@ namespace WoWsShipBuilder.DataContainers; [DataContainer] public partial record TorpedoDataContainer : ProjectileDataContainer { - [DataElementType(DataElementTypes.KeyValue, IsValueLocalizationKey = true, IsValueAppLocalization = true)] + [DataElementType(DataElementTypes.KeyValue, ValueTextKind = TextKind.AppLocalizationKey)] public string TorpedoType { get; set; } = default!; - [DataElementType(DataElementTypes.KeyValue, IsValueLocalizationKey = true)] + [DataElementType(DataElementTypes.KeyValue, ValueTextKind = TextKind.LocalizationKey)] [DataElementFiltering(true, "ShouldDisplayName")] public string Name { get; set; } = default!; @@ -45,70 +45,70 @@ public partial record TorpedoDataContainer : ProjectileDataContainer [DataElementFiltering(false)] public decimal SplashCoeff { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxTurningSpeed", UnitKey = "DegreePerSecond", NameLocalizationKey = "FirstPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxTurningSpeed", UnitKey = "DegreePerSecond", LocalizationKeyOverride = "FirstPing")] public decimal MaxTurningSpeedFirstPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxTurningSpeed", UnitKey = "DegreePerSecond", NameLocalizationKey = "SecondPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxTurningSpeed", UnitKey = "DegreePerSecond", LocalizationKeyOverride = "SecondPing")] public decimal MaxTurningSpeedSecondPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "TurningAcceleration", UnitKey = "DegreePerSecond2", NameLocalizationKey = "FirstPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "TurningAcceleration", UnitKey = "DegreePerSecond2", LocalizationKeyOverride = "FirstPing")] public decimal TurningAccelerationFirstPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "TurningAcceleration", UnitKey = "DegreePerSecond2", NameLocalizationKey = "SecondPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "TurningAcceleration", UnitKey = "DegreePerSecond2", LocalizationKeyOverride = "SecondPing")] public decimal TurningAccelerationSecondPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxVerticalSpeed", UnitKey = "MPS", NameLocalizationKey = "FirstPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxVerticalSpeed", UnitKey = "MPS", LocalizationKeyOverride = "FirstPing")] public decimal MaxVerticalSpeedFirstPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxVerticalSpeed", UnitKey = "MPS", NameLocalizationKey = "SecondPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxVerticalSpeed", UnitKey = "MPS", LocalizationKeyOverride = "SecondPing")] public decimal MaxVerticalSpeedSecondPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "VerticalAcceleration", UnitKey = "MPS2", NameLocalizationKey = "FirstPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "VerticalAcceleration", UnitKey = "MPS2", LocalizationKeyOverride = "FirstPing")] public decimal VerticalAccelerationFirstPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "VerticalAcceleration", UnitKey = "MPS2", NameLocalizationKey = "SecondPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "VerticalAcceleration", UnitKey = "MPS2", LocalizationKeyOverride = "SecondPing")] public decimal VerticalAccelerationSecondPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "SearchRadius", UnitKey = "KM", NameLocalizationKey = "FirstPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "SearchRadius", UnitKey = "KM", LocalizationKeyOverride = "FirstPing")] public decimal SearchRadiusFirstPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "SearchRadius", UnitKey = "KM", NameLocalizationKey = "SecondPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "SearchRadius", UnitKey = "KM", LocalizationKeyOverride = "SecondPing")] public decimal SearchRadiusSecondPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "SearchAngle", UnitKey = "Degree", NameLocalizationKey = "FirstPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "SearchAngle", UnitKey = "Degree", LocalizationKeyOverride = "FirstPing")] public decimal SearchAngleFirstPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "SearchAngle", UnitKey = "Degree", NameLocalizationKey = "SecondPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "SearchAngle", UnitKey = "Degree", LocalizationKeyOverride = "SecondPing")] public decimal SearchAngleSecondPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Destroyer", UnitKey = "M", NameLocalizationKey = "FirstPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Destroyer", UnitKey = "M", LocalizationKeyOverride = "FirstPing")] public decimal DestroyerCutOffFirstPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Destroyer", UnitKey = "M", NameLocalizationKey = "SecondPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Destroyer", UnitKey = "M", LocalizationKeyOverride = "SecondPing")] public decimal DestroyerCutOffSecondPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Battleship", UnitKey = "M", NameLocalizationKey = "FirstPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Battleship", UnitKey = "M", LocalizationKeyOverride = "FirstPing")] public decimal BattleshipCutOffFirstPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Battleship", UnitKey = "M", NameLocalizationKey = "SecondPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Battleship", UnitKey = "M", LocalizationKeyOverride = "SecondPing")] public decimal BattleshipCutOffSecondPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Cruiser", UnitKey = "M", NameLocalizationKey = "FirstPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Cruiser", UnitKey = "M", LocalizationKeyOverride = "FirstPing")] public decimal CruiserCutOffFirstPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Cruiser", UnitKey = "M", NameLocalizationKey = "SecondPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Cruiser", UnitKey = "M", LocalizationKeyOverride = "SecondPing")] public decimal CruiserCutOffSecondPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Submarine", UnitKey = "M", NameLocalizationKey = "FirstPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Submarine", UnitKey = "M", LocalizationKeyOverride = "FirstPing")] public decimal SubCutOffFirstPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Submarine", UnitKey = "M", NameLocalizationKey = "SecondPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Submarine", UnitKey = "M", LocalizationKeyOverride = "SecondPing")] public decimal SubCutOffSecondPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "AirCarrier", UnitKey = "M", NameLocalizationKey = "FirstPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "AirCarrier", UnitKey = "M", LocalizationKeyOverride = "FirstPing")] public decimal CvCutOffFirstPing { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "AirCarrier", UnitKey = "M", NameLocalizationKey = "SecondPing")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "AirCarrier", UnitKey = "M", LocalizationKeyOverride = "SecondPing")] public decimal CvCutOffSecondPing { get; set; } public List? CanHitClasses { get; set; } diff --git a/WoWsShipBuilder.Common/DataContainers/Ship/ManeuverabilityDataContainer.cs b/WoWsShipBuilder.Common/DataContainers/Ship/ManeuverabilityDataContainer.cs index 5143b6aa9..a0848658e 100644 --- a/WoWsShipBuilder.Common/DataContainers/Ship/ManeuverabilityDataContainer.cs +++ b/WoWsShipBuilder.Common/DataContainers/Ship/ManeuverabilityDataContainer.cs @@ -12,7 +12,7 @@ public partial record ManeuverabilityDataContainer : DataContainerBase [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Knots")] public decimal ManeuverabilityMaxSpeed { get; set; } - [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Knots", NameLocalizationKey = "MaxReverseSpeed")] + [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Knots", LocalizationKeyOverride = "MaxReverseSpeed")] public decimal ManeuverabilityMaxReverseSpeed { get; set; } [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxSpeed", UnitKey = "Knots")] @@ -24,13 +24,13 @@ public partial record ManeuverabilityDataContainer : DataContainerBase [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxSpeed", UnitKey = "Knots")] public decimal ManeuverabilitySubsMaxSpeedAtMaxDepth { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxReverseSpeed", UnitKey = "Knots", NameLocalizationKey = "ManeuverabilitySubsMaxSpeedOnSurface")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxReverseSpeed", UnitKey = "Knots", LocalizationKeyOverride = "ManeuverabilitySubsMaxSpeedOnSurface")] public decimal ManeuverabilitySubsMaxReverseSpeedOnSurface { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxReverseSpeed", UnitKey = "Knots", NameLocalizationKey = "ManeuverabilitySubsMaxSpeedAtPeriscope")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxReverseSpeed", UnitKey = "Knots", LocalizationKeyOverride = "ManeuverabilitySubsMaxSpeedAtPeriscope")] public decimal ManeuverabilitySubsMaxReverseSpeedAtPeriscope { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxReverseSpeed", UnitKey = "Knots", NameLocalizationKey = "ManeuverabilitySubsMaxSpeedAtMaxDepth")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "MaxReverseSpeed", UnitKey = "Knots", LocalizationKeyOverride = "ManeuverabilitySubsMaxSpeedAtMaxDepth")] public decimal ManeuverabilitySubsMaxReverseSpeedAtMaxDepth { get; set; } [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "MPS")] diff --git a/WoWsShipBuilder.Common/DataContainers/Ship/SurvivabilityDataContainer.cs b/WoWsShipBuilder.Common/DataContainers/Ship/SurvivabilityDataContainer.cs index 42ca46e7a..de9bb6727 100644 --- a/WoWsShipBuilder.Common/DataContainers/Ship/SurvivabilityDataContainer.cs +++ b/WoWsShipBuilder.Common/DataContainers/Ship/SurvivabilityDataContainer.cs @@ -11,49 +11,49 @@ namespace WoWsShipBuilder.DataContainers; [DataContainer] public partial record SurvivabilityDataContainer : DataContainerBase { - [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "HP", NameLocalizationKey = "ShipHp")] + [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "HP", LocalizationKeyOverride = "ShipHp")] public int HitPoints { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Citadel", UnitKey = "HP", NameLocalizationKey = "HitPoints")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Citadel", UnitKey = "HP", LocalizationKeyOverride = "HitPoints")] public int CitadelHp { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Citadel", UnitKey = "PerCent", NameLocalizationKey = "RegenRatio")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Citadel", UnitKey = "PerCent", LocalizationKeyOverride = "RegenRatio")] public decimal CitadelRegenRatio { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Casemate", UnitKey = "HP", NameLocalizationKey = "HitPoints")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Casemate", UnitKey = "HP", LocalizationKeyOverride = "HitPoints")] public int CasemateHp { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Casemate", UnitKey = "PerCent", NameLocalizationKey = "RegenRatio")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Casemate", UnitKey = "PerCent", LocalizationKeyOverride = "RegenRatio")] public decimal CasemateRegenRatio { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Bow", UnitKey = "HP", NameLocalizationKey = "HitPoints")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Bow", UnitKey = "HP", LocalizationKeyOverride = "HitPoints")] public int BowHp { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Bow", UnitKey = "PerCent", NameLocalizationKey = "RegenRatio")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Bow", UnitKey = "PerCent", LocalizationKeyOverride = "RegenRatio")] public decimal BowRegenRatio { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Stern", UnitKey = "HP", NameLocalizationKey = "HitPoints")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Stern", UnitKey = "HP", LocalizationKeyOverride = "HitPoints")] public int SternHp { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Stern", UnitKey = "PerCent", NameLocalizationKey = "RegenRatio")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Stern", UnitKey = "PerCent", LocalizationKeyOverride = "RegenRatio")] public decimal SternRegenRatio { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Superstructure", UnitKey = "HP", NameLocalizationKey = "HitPoints")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Superstructure", UnitKey = "HP", LocalizationKeyOverride = "HitPoints")] public int SuperstructureHp { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Superstructure", UnitKey = "PerCent", NameLocalizationKey = "RegenRatio")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Superstructure", UnitKey = "PerCent", LocalizationKeyOverride = "RegenRatio")] public decimal SuperstructureRegenRatio { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "AuxiliaryRooms", UnitKey = "HP", NameLocalizationKey = "HitPoints")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "AuxiliaryRooms", UnitKey = "HP", LocalizationKeyOverride = "HitPoints")] public int AuxiliaryRoomsHp { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "AuxiliaryRooms", UnitKey = "PerCent", NameLocalizationKey = "RegenRatio")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "AuxiliaryRooms", UnitKey = "PerCent", LocalizationKeyOverride = "RegenRatio")] public decimal AuxiliaryRoomsRegenRatio { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Hull", UnitKey = "HP", NameLocalizationKey = "HitPoints")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Hull", UnitKey = "HP", LocalizationKeyOverride = "HitPoints")] public int HullHp { get; set; } - [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Hull", UnitKey = "PerCent", NameLocalizationKey = "RegenRatio")] + [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Hull", UnitKey = "PerCent", LocalizationKeyOverride = "RegenRatio")] public decimal HullRegenRatio { get; set; } [DataElementType(DataElementTypes.Grouped | DataElementTypes.KeyValueUnit, GroupKey = "Battery", UnitKey = "U")] diff --git a/WoWsShipBuilder.Common/Features/ShipStats/Components/SharedFragments.razor b/WoWsShipBuilder.Common/Features/ShipStats/Components/SharedFragments.razor index 3a5e69e9b..59db4f6b5 100644 --- a/WoWsShipBuilder.Common/Features/ShipStats/Components/SharedFragments.razor +++ b/WoWsShipBuilder.Common/Features/ShipStats/Components/SharedFragments.razor @@ -22,7 +22,7 @@ case KeyValueDataElement element:
@group.localizer.GetAppLocalization(element.Key).Localization - @ConvertValue(element.Value, element.IsValueKey, element.IsValueAppLocalization, group.localizer) + @ConvertValue(element.Value, element.ValueTextKind, group.localizer)
break; case KeyValueUnitDataElement element: @@ -52,7 +52,7 @@ break; case ValueDataElement element: - @ConvertValue(element.Value, element.IsValueKey, element.IsValueAppLocalization, group.localizer) + @ConvertValue(element.Value, element.ValueTextKind, group.localizer) break; case FormattedTextDataElement element: @@ -74,9 +74,14 @@ } } - private static string ConvertValue(string value, bool isValueKey, bool isAppLocalizationKey, ILocalizer localizer) + private static string ConvertValue(string value, DataElementTextKind valueTextKind, ILocalizer localizer) { - return !isValueKey ? value : (isAppLocalizationKey ? localizer.GetAppLocalization(value) : localizer.GetGameLocalization(value)).Localization; + return valueTextKind switch { + DataElementTextKind.Plain => value, + DataElementTextKind.LocalizationKey => localizer.SimpleGameLocalization(value), + DataElementTextKind.AppLocalizationKey => localizer.SimpleAppLocalization(value), + _ => throw new ArgumentOutOfRangeException(nameof(valueTextKind), valueTextKind, "Unknown DataElementTextKind"), + }; } -} \ No newline at end of file +} diff --git a/WoWsShipBuilder.Common/Features/ShipStats/FormattedTextHelper.cs b/WoWsShipBuilder.Common/Features/ShipStats/FormattedTextHelper.cs index 6ae93b43b..66b4cc532 100644 --- a/WoWsShipBuilder.Common/Features/ShipStats/FormattedTextHelper.cs +++ b/WoWsShipBuilder.Common/Features/ShipStats/FormattedTextHelper.cs @@ -8,17 +8,21 @@ public static class FormattedTextHelper { public static string ConvertFormattedText(FormattedTextDataElement formattedTextDataElement, ILocalizer localizer) { - string text = formattedTextDataElement.Text; - if (formattedTextDataElement.IsTextKey) + string text = formattedTextDataElement.ValueTextKind switch { - text = formattedTextDataElement.IsTextAppLocalization ? localizer.GetAppLocalization(text).Localization : localizer.GetGameLocalization(text).Localization; - } + DataElementTextKind.Plain => formattedTextDataElement.Text, + DataElementTextKind.LocalizationKey => localizer.SimpleGameLocalization(formattedTextDataElement.Text), + DataElementTextKind.AppLocalizationKey => localizer.SimpleAppLocalization(formattedTextDataElement.Text), + _ => throw new NotSupportedException("Invalid value for ValueTextKind"), + }; - IEnumerable values = formattedTextDataElement.Values; - if (formattedTextDataElement.AreValuesKeys) + IEnumerable values = formattedTextDataElement.ArgumentsTextKind switch { - values = formattedTextDataElement.AreValuesAppLocalization ? values.Select(x => localizer.GetAppLocalization(x).Localization) : values.Select(x => localizer.GetGameLocalization(x).Localization); - } + DataElementTextKind.Plain => formattedTextDataElement.Arguments, + DataElementTextKind.LocalizationKey => formattedTextDataElement.Arguments.Select(localizer.SimpleGameLocalization), + DataElementTextKind.AppLocalizationKey => formattedTextDataElement.Arguments.Select(localizer.SimpleAppLocalization), + _ => throw new NotSupportedException("Invalid value for ArgumentsTextKind"), + }; return string.Format(CultureInfo.InvariantCulture, text, values.Cast().ToArray()); } diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/DataElementAnalyzerTest.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/DataElementAnalyzerTest.cs index bcce5e110..4bc649473 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/DataElementAnalyzerTest.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/DataElementAnalyzerTest.cs @@ -64,6 +64,7 @@ protected static bool ShouldAdd(object? value) Sources = { AttributeHelper.DataElementTypesEnum, + AttributeHelper.DataElementTextKindEnum, AttributeHelper.DataContainerAttribute, AttributeHelper.DataElementTypeAttribute, AttributeHelper.DataElementFilteringAttribute, diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/FormattedText.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/FormattedText.cs index c41ce5eb9..dfe5d1027 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/FormattedText.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/FormattedText.cs @@ -14,7 +14,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName="Test")] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName="Test")] public decimal Prop1 { get; set; } } """; @@ -54,7 +54,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName="Test", ArePropertyNameValuesKeys=true)] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = "Test", ArgumentsTextKind = TextKind.LocalizationKey)] public decimal Prop1 { get; set; } } """; @@ -74,7 +74,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName="Test", IsPropertyNameValuesAppLocalization=true)] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = "Test", ArgumentsTextKind = TextKind.AppLocalizationKey)] public decimal Prop1 { get; set; } } """; @@ -83,7 +83,7 @@ public partial record TestRecord : DataContainerBase } [Test] - public async Task AnalyzeFormattedText_NameLocalizationKeySpecified_Diagnostics() + public async Task AnalyzeFormattedText_LocalizationKeyOverrideSpecified_Diagnostics() { var source = """ using WoWsShipBuilder.DataElements.DataElementAttributes; @@ -94,7 +94,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName="Test", NameLocalizationKey="Test")] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = "Test", LocalizationKeyOverride = "Test")] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -114,7 +114,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName="Test", UnitKey="Test")] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = "Test", UnitKey = "Test")] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -134,7 +134,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName="Test", TooltipKey="Test")] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = "Test", TooltipKey = "Test")] public decimal {|SB1003:Prop1|} { get; set; } } """; diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValue.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValue.cs index 181e74641..fcb7425ae 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValue.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValue.cs @@ -23,7 +23,7 @@ public partial record TestRecord : DataContainerBase } [Test] - public async Task AnalyzeKeyValue_NameLocalizationKeySpecified_NoDiagnostics() + public async Task AnalyzeKeyValue_LocalizationKeyOverrideSpecified_NoDiagnostics() { var source = """ using WoWsShipBuilder.DataElements.DataElementAttributes; @@ -34,7 +34,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValue, NameLocalizationKey="Test")] + [DataElementType(DataElementTypes.KeyValue, LocalizationKeyOverride = "Test")] public decimal Prop1 { get; set; } } """; @@ -54,7 +54,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValue, ValuesPropertyName="Values")] + [DataElementType(DataElementTypes.KeyValue, ArgumentsCollectionName = "Values")] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -74,7 +74,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValue, ArePropertyNameValuesKeys=true)] + [DataElementType(DataElementTypes.KeyValue, ArgumentsTextKind = TextKind.LocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -94,7 +94,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValue, IsPropertyNameValuesAppLocalization=true)] + [DataElementType(DataElementTypes.KeyValue, ArgumentsTextKind = TextKind.AppLocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValueUnit.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValueUnit.cs index 883b7cc01..24124e401 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValueUnit.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/KeyValueUnit.cs @@ -14,7 +14,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValueUnit, UnitKey="Test")] + [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Test")] public decimal Prop1 { get; set; } } """; @@ -23,7 +23,7 @@ public partial record TestRecord : DataContainerBase } [Test] - public async Task AnalyzeKeyValueUnit_NameLocalizationKeySpecified_NoDiagnostics() + public async Task AnalyzeKeyValueUnit_LocalizationKeyOverrideSpecified_NoDiagnostics() { var source = """ using WoWsShipBuilder.DataElements.DataElementAttributes; @@ -34,7 +34,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValueUnit, UnitKey="Test", NameLocalizationKey="Test")] + [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Test", LocalizationKeyOverride = "Test")] public decimal Prop1 { get; set; } } """; @@ -74,7 +74,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValueUnit, UnitKey="Test", ValuesPropertyName="Values")] + [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Test", ArgumentsCollectionName = "Values")] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -94,7 +94,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValueUnit, UnitKey="Test", ArePropertyNameValuesKeys=true)] + [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Test", ArgumentsTextKind = TextKind.LocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -114,7 +114,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValueUnit, UnitKey="Test", IsPropertyNameValuesAppLocalization=true)] + [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Test", ArgumentsTextKind = TextKind.LocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -134,7 +134,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValueUnit, UnitKey="Test", TooltipKey="Test")] + [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Test", TooltipKey = "Test")] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -154,7 +154,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValueUnit, UnitKey="Test", IsValueLocalizationKey=true)] + [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Test", ValueTextKind = TextKind.LocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -174,7 +174,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValueUnit, UnitKey="Test", IsValueAppLocalization=true)] + [DataElementType(DataElementTypes.KeyValueUnit, UnitKey = "Test", ValueTextKind = TextKind.AppLocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/Tooltip.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/Tooltip.cs index 7c338cc36..b13635d5c 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/Tooltip.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/Tooltip.cs @@ -14,7 +14,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Tooltip, TooltipKey="Test")] + [DataElementType(DataElementTypes.Tooltip, TooltipKey = "Test")] public decimal Prop1 { get; set; } } """; @@ -54,7 +54,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Tooltip, TooltipKey="Test", UnitKey="Test")] + [DataElementType(DataElementTypes.Tooltip, TooltipKey = "Test", UnitKey = "Test")] public decimal Prop1 { get; set; } } """; @@ -74,7 +74,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Tooltip, TooltipKey="Test", NameLocalizationKey="Test")] + [DataElementType(DataElementTypes.Tooltip, TooltipKey = "Test", LocalizationKeyOverride = "Test")] public decimal Prop1 { get; set; } } """; @@ -94,7 +94,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Tooltip, TooltipKey="Test", ValuesPropertyName="Values")] + [DataElementType(DataElementTypes.Tooltip, TooltipKey = "Test", ArgumentsCollectionName = "Values")] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -114,7 +114,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Tooltip, TooltipKey="Test", ArePropertyNameValuesKeys=true)] + [DataElementType(DataElementTypes.Tooltip, TooltipKey = "Test", ArgumentsTextKind = TextKind.LocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -134,7 +134,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Tooltip, TooltipKey="Test", IsPropertyNameValuesAppLocalization=true)] + [DataElementType(DataElementTypes.Tooltip, TooltipKey = "Test", ArgumentsTextKind = TextKind.AppLocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -154,7 +154,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Tooltip, TooltipKey="Test", IsValueLocalizationKey=true)] + [DataElementType(DataElementTypes.Tooltip, TooltipKey = "Test", ValueTextKind = TextKind.LocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -174,7 +174,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Tooltip, TooltipKey="Test", IsValueAppLocalization=true)] + [DataElementType(DataElementTypes.Tooltip, TooltipKey = "Test", ValueTextKind = TextKind.AppLocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/Value.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/Value.cs index 54988b665..a7965ea2c 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/Value.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementAnalyzerTests/Value.cs @@ -34,7 +34,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Value, ValuesPropertyName="Values")] + [DataElementType(DataElementTypes.Value, ArgumentsCollectionName = "Values")] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -54,7 +54,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Value, ArePropertyNameValuesKeys=true)] + [DataElementType(DataElementTypes.Value, ArgumentsTextKind = TextKind.LocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -74,7 +74,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Value, IsPropertyNameValuesAppLocalization=true)] + [DataElementType(DataElementTypes.Value, ArgumentsTextKind = TextKind.AppLocalizationKey)] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -94,7 +94,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Value, UnitKey="Test")] + [DataElementType(DataElementTypes.Value, UnitKey = "Test")] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -114,7 +114,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Value, TooltipKey="Test")] + [DataElementType(DataElementTypes.Value, TooltipKey = "Test")] public decimal {|SB1003:Prop1|} { get; set; } } """; @@ -134,7 +134,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Value, NameLocalizationKey="Test")] + [DataElementType(DataElementTypes.Value, LocalizationKeyOverride = "Test")] public decimal {|SB1003:Prop1|} { get; set; } } """; diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/DataElementGeneratorTest.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/DataElementGeneratorTest.cs index 077d9a80b..2752df7b8 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/DataElementGeneratorTest.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/DataElementGeneratorTest.cs @@ -43,6 +43,7 @@ protected static bool ShouldAdd(object? value) GeneratedSources = { (typeof(DataElementGenerator.DataElementGenerator), "DataElementTypes.g.cs", AttributeHelper.DataElementTypesEnum), + (typeof(DataElementGenerator.DataElementGenerator), "TextKind.g.cs", AttributeHelper.DataElementTextKindEnum), (typeof(DataElementGenerator.DataElementGenerator), "DataContainerAttribute.g.cs", AttributeHelper.DataContainerAttribute), (typeof(DataElementGenerator.DataElementGenerator), "DataElementTypeAttribute.g.cs", AttributeHelper.DataElementTypeAttribute), (typeof(DataElementGenerator.DataElementGenerator), "DataElementFilteringAttribute.g.cs", AttributeHelper.DataElementFilteringAttribute), diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/FormattedText.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/FormattedText.cs index 7ecdff91e..2a459ce11 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/FormattedText.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/FormattedText.cs @@ -17,7 +17,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName = nameof(TestValues))] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = nameof(TestValues))] public string Test { get; set; } = default!; public List TestValues { get; set; } = new(); @@ -36,7 +36,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Test)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, false, false, false, false)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } } } @@ -62,7 +62,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName = nameof(TestValues), ArePropertyNameValuesKeys = true)] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = nameof(TestValues), ArgumentsTextKind = TextKind.LocalizationKey)] public string Test { get; set; } = default!; public List TestValues { get; set; } = new(); @@ -81,7 +81,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Test)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, false, false, true, false)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.LocalizationKey)); } } } @@ -107,7 +107,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName = nameof(TestValues), IsValueLocalizationKey = true)] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = nameof(TestValues), ValueTextKind = TextKind.LocalizationKey)] public string Test { get; set; } = default!; public List TestValues { get; set; } = new(); @@ -126,7 +126,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Test)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, true, false, false, false)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.LocalizationKey, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } } } @@ -152,7 +152,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName = nameof(TestValues), IsValueLocalizationKey = true, ArePropertyNameValuesKeys = true)] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = nameof(TestValues), ValueTextKind = TextKind.LocalizationKey, ArgumentsTextKind = TextKind.LocalizationKey)] public string Test { get; set; } = default!; public List TestValues { get; set; } = new(); @@ -171,7 +171,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Test)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, true, false, true, false)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.LocalizationKey, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.LocalizationKey)); } } } @@ -197,7 +197,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName = nameof(TestValues), IsPropertyNameValuesAppLocalization = true)] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = nameof(TestValues), ArgumentsTextKind = TextKind.AppLocalizationKey)] public string Test { get; set; } = default!; public List TestValues { get; set; } = new(); @@ -216,7 +216,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Test)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, false, false, false, true)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.AppLocalizationKey)); } } } @@ -242,7 +242,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName = nameof(TestValues), IsValueAppLocalization = true)] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = nameof(TestValues), ValueTextKind = TextKind.AppLocalizationKey)] public string Test { get; set; } = default!; public List TestValues { get; set; } = new(); @@ -261,7 +261,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Test)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, false, true, false, false)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.AppLocalizationKey, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } } } @@ -287,7 +287,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName = nameof(TestValues), IsValueAppLocalization = true, IsPropertyNameValuesAppLocalization = true)] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = nameof(TestValues), ValueTextKind = TextKind.AppLocalizationKey, ArgumentsTextKind = TextKind.AppLocalizationKey)] public string Test { get; set; } = default!; public List TestValues { get; set; } = new(); @@ -306,7 +306,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Test)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, false, true, false, true)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Test, this.TestValues, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.AppLocalizationKey, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.AppLocalizationKey)); } } } diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Grouped.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Grouped.cs index a96356218..72f65b860 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Grouped.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Grouped.cs @@ -36,12 +36,12 @@ private void UpdateDataElements() var LoadersList = new global::System.Collections.Generic.List(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.BowLoaders)) { - LoadersList.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_BowLoaders", this.BowLoaders, false, false)); + LoadersList.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_BowLoaders", this.BowLoaders, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.SternLoaders)) { - LoadersList.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_SternLoaders", this.SternLoaders, false, false)); + LoadersList.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_SternLoaders", this.SternLoaders, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } if (LoadersList.Count > 0) @@ -97,12 +97,12 @@ private void UpdateDataElements() var Group1List = new global::System.Collections.Generic.List(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop1)) { - Group1List.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop1", this.Prop1, false, false)); + Group1List.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop1", this.Prop1, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop3)) { - Group1List.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop3", this.Prop3, false, false)); + Group1List.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop3", this.Prop3, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } if (Group1List.Count > 0) @@ -113,12 +113,12 @@ private void UpdateDataElements() var Group2List = new global::System.Collections.Generic.List(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop2)) { - Group2List.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop2", this.Prop2, false, false)); + Group2List.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop2", this.Prop2, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop4)) { - Group2List.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop4", this.Prop4, false, false)); + Group2List.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop4", this.Prop4, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } if (Group2List.Count > 0) diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/KeyValue.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/KeyValue.cs index c9d0e145e..ce4c5ec7d 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/KeyValue.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/KeyValue.cs @@ -32,7 +32,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop1)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop1", this.Prop1.ToString(), false, false)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop1", this.Prop1.ToString(), global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } } } @@ -56,7 +56,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValue, IsValueLocalizationKey=true)] + [DataElementType(DataElementTypes.KeyValue, ValueTextKind = TextKind.LocalizationKey)] public decimal Prop1 { get; set; } } """; @@ -73,7 +73,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop1)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop1", this.Prop1.ToString(), true, false)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop1", this.Prop1.ToString(), global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.LocalizationKey)); } } } @@ -97,7 +97,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValue, IsValueAppLocalization=true)] + [DataElementType(DataElementTypes.KeyValue, ValueTextKind = TextKind.AppLocalizationKey)] public decimal Prop1 { get; set; } } """; @@ -114,7 +114,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop1)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop1", this.Prop1.ToString(), false, true)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop1", this.Prop1.ToString(), global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.AppLocalizationKey)); } } } diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Mixed.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Mixed.cs index 8b19b9929..a848ce0ea 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Mixed.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Mixed.cs @@ -96,7 +96,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.KeyValue, IsValueLocalizationKey=true)] + [DataElementType(DataElementTypes.KeyValue, ValueTextKind = TextKind.LocalizationKey)] public string Prop1 { get; set; } = default!; [DataElementType(DataElementTypes.KeyValueUnit, UnitKey="Knots")] @@ -105,7 +105,7 @@ public partial record TestRecord : DataContainerBase [DataElementType(DataElementTypes.Tooltip, TooltipKey = "TestTooltip")] public string Prop3 { get; set; } = default!; - [DataElementType(DataElementTypes.FormattedText, ValuesPropertyName = nameof(TestValues))] + [DataElementType(DataElementTypes.FormattedText, ArgumentsCollectionName = nameof(TestValues))] public string Prop4 { get; set; } = default!; public List TestValues { get; set; } = new(); @@ -124,7 +124,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop1)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop1", this.Prop1, true, false)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.KeyValueDataElement("ShipStats_Prop1", this.Prop1, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.LocalizationKey)); } if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop2)) @@ -139,7 +139,7 @@ private void UpdateDataElements() if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop4)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Prop4, this.TestValues, false, false, false, false)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.FormattedTextDataElement(this.Prop4, this.TestValues, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain, global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } } } diff --git a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Value.cs b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Value.cs index dca48344a..6c70f49bc 100644 --- a/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Value.cs +++ b/WoWsShipBuilder.Data.Generator.Test/DataElementGeneratorTests/Value.cs @@ -32,7 +32,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop1)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.ValueDataElement(this.Prop1.ToString(), false, false)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.ValueDataElement(this.Prop1.ToString(), global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.Plain)); } } } @@ -56,7 +56,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Value, IsValueLocalizationKey=true)] + [DataElementType(DataElementTypes.Value, ValueTextKind = TextKind.LocalizationKey)] public decimal Prop1 { get; set; } } """; @@ -73,7 +73,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop1)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.ValueDataElement(this.Prop1.ToString(), true, false)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.ValueDataElement(this.Prop1.ToString(), global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.LocalizationKey)); } } } @@ -97,7 +97,7 @@ namespace Test; [DataContainer] public partial record TestRecord : DataContainerBase { - [DataElementType(DataElementTypes.Value, IsValueAppLocalization=true)] + [DataElementType(DataElementTypes.Value, ValueTextKind = TextKind.AppLocalizationKey)] public decimal Prop1 { get; set; } } """; @@ -114,7 +114,7 @@ private void UpdateDataElements() this.DataElements.Clear(); if (global::WoWsShipBuilder.DataElements.DataElements.DataContainerBase.ShouldAdd(this.Prop1)) { - this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.ValueDataElement(this.Prop1.ToString(), false, true)); + this.DataElements.Add(new global::WoWsShipBuilder.DataElements.DataElements.ValueDataElement(this.Prop1.ToString(), global::WoWsShipBuilder.DataElements.DataElements.DataElementTextKind.AppLocalizationKey)); } } } diff --git a/WoWsShipBuilder.Data.Generator/DataElementGenerator/AttributeHelper.cs b/WoWsShipBuilder.Data.Generator/DataElementGenerator/AttributeHelper.cs index d684ebcc2..1c80e0d8a 100644 --- a/WoWsShipBuilder.Data.Generator/DataElementGenerator/AttributeHelper.cs +++ b/WoWsShipBuilder.Data.Generator/DataElementGenerator/AttributeHelper.cs @@ -26,6 +26,36 @@ internal enum {{DataElementTypesEnumName}} } """; + public const string DataElementTextKindEnumName = "TextKind"; + + // language=csharp + public const string DataElementTextKindEnum = $$""" + // + #nullable enable + namespace {{AttributeNamespace}}; + + /// + /// Specifies how a text value of a property marked by will be interpreted. + /// + internal enum {{DataElementTextKindEnumName}} + { + /// + /// Identifies a plain text value that will be displayed as is. + /// + Plain, + + /// + /// Identifies a text value that will be used as game localization key. + /// + LocalizationKey, + + /// + /// Identifies a text value that will be used as app localization key. + /// + AppLocalizationKey, + } + """; + public const string DataContainerAttributeName = "DataContainerAttribute"; // language=csharp @@ -62,16 +92,16 @@ internal class {{DataElementTypeAttributeName}} : global::System.Attribute public global::{{AttributeNamespace}}.DataElementTypes Type { get; } /// - /// Gets or sets the unit localization key for the property marked by this attribute.
- /// Only valid for and . + /// Gets or sets the property name localization key override for the property marked by this attribute.
+ /// Only valid for , , and . ///
- public string? UnitKey { get; set; } + public string? LocalizationKeyOverride { get; set; } /// - /// Gets or sets the property name localization key for the property marked by this attribute.
- /// Only valid for , , and . + /// Gets or sets the unit localization key for the property marked by this attribute.
+ /// Only valid for and . ///
- public string? NameLocalizationKey { get; set; } + public string? UnitKey { get; set; } /// /// Gets or sets the tooltip localization key for the property marked by this attribute.
@@ -86,34 +116,22 @@ internal class {{DataElementTypeAttributeName}} : global::System.Attribute public string? GroupKey { get; set; } /// - /// Gets or set the name of the property containing the list of values that will replace the placeholder. Requires the value of the property marked by this attribute to follow the specifications.
- /// Only valid for . - ///
- public string? ValuesPropertyName { get; set; } - - /// - /// Gets or sets if the value of the property marked by this attribute is a localization key.
+ /// Gets or sets the of the value of the property marked by this attribute.
/// Only valid for , and ///
- public bool IsValueLocalizationKey { get; set; } + public global::{{AttributeNamespace}}.{{DataElementTextKindEnumName}} ValueTextKind { get; set; } /// - /// Gets or sets if the values indicated by are localization keys.
- /// Only valid for - ///
- public bool ArePropertyNameValuesKeys { get; set; } - - /// - /// Gets or sets if the value of the property marked by this attribute is an app localization key.
- /// Only valid for , and + /// Gets or set the name of the property containing the list of values that will replace the placeholder. Requires the value of the property marked by this attribute to follow the specifications.
+ /// Only valid for . ///
- public bool IsValueAppLocalization { get; set; } + public string? ArgumentsCollectionName { get; set; } /// - /// Gets or sets if the values indicated by are app localization keys.
+ /// Gets or sets the of the argument values of the property marked by this attribute.
/// Only valid for ///
- public bool IsPropertyNameValuesAppLocalization { get; set; } + public global::{{AttributeNamespace}}.{{DataElementTextKindEnumName}} ArgumentsTextKind { get; set; } } """; @@ -143,6 +161,7 @@ internal class {{DataElementFilteringAttributeName}} : global::System.Attribute public static void GenerateAttributes(IncrementalGeneratorPostInitializationContext context) { context.AddSource("DataElementTypes.g.cs", DataElementTypesEnum); + context.AddSource("TextKind.g.cs", DataElementTextKindEnum); context.AddSource("DataContainerAttribute.g.cs", DataContainerAttribute); context.AddSource("DataElementTypeAttribute.g.cs", DataElementTypeAttribute); context.AddSource("DataElementFilteringAttribute.g.cs", DataElementFilteringAttribute); diff --git a/WoWsShipBuilder.Data.Generator/DataElementGenerator/DataElementAnalyzer.cs b/WoWsShipBuilder.Data.Generator/DataElementGenerator/DataElementAnalyzer.cs index 3fdc2ed55..571ac26cb 100644 --- a/WoWsShipBuilder.Data.Generator/DataElementGenerator/DataElementAnalyzer.cs +++ b/WoWsShipBuilder.Data.Generator/DataElementGenerator/DataElementAnalyzer.cs @@ -95,17 +95,12 @@ private static void CheckKeyValueDataElement(SymbolAnalysisContext context, ISym if (propertyData.FormattedTextData.ArgumentsCollectionName is not null) { - incompatibleParameters.Add("ValuesPropertyName"); + incompatibleParameters.Add("ArgumentsCollectionName"); } - if (propertyData.FormattedTextData.TreatArgumentsAsLocalizationKeys) + if (propertyData.FormattedTextData.ArgumentsTextKind != TextKind.Plain) { - incompatibleParameters.Add("ArePropertyNameValuesKeys"); - } - - if (propertyData.FormattedTextData.TreatArgumentsAsAppLocalizationKeys) - { - incompatibleParameters.Add("IsPropertyNameValuesAppLocalization"); + incompatibleParameters.Add("ArgumentsTextKind"); } if (propertyData.DisplayOptions.UnitKey is not null) @@ -130,17 +125,12 @@ private static void CheckKeyValueUnitDataElement(SymbolAnalysisContext context, if (propertyData.FormattedTextData.ArgumentsCollectionName is not null) { - errors.Add("ValuesPropertyName"); + errors.Add("ArgumentsCollectionName"); } - if (propertyData.FormattedTextData.TreatArgumentsAsLocalizationKeys) + if (propertyData.FormattedTextData.ArgumentsTextKind != TextKind.Plain) { - errors.Add("ArePropertyNameValuesKeys"); - } - - if (propertyData.FormattedTextData.TreatArgumentsAsAppLocalizationKeys) - { - errors.Add("IsPropertyNameValuesAppLocalization"); + errors.Add("ArgumentsTextKind"); } if (propertyData.DisplayOptions.TooltipKey is not null) @@ -148,14 +138,9 @@ private static void CheckKeyValueUnitDataElement(SymbolAnalysisContext context, errors.Add("TooltipKey"); } - if (propertyData.DisplayOptions.TreatValueAsLocalizationKey) - { - errors.Add("IsValueLocalizationKey"); - } - - if (propertyData.DisplayOptions.TreatValueAsAppLocalizationKey) + if (propertyData.DisplayOptions.ValueTextKind != TextKind.Plain) { - errors.Add("IsValueAppLocalizationKey"); + errors.Add("ValueTextKind"); } if (errors.Count > 0) @@ -175,17 +160,12 @@ private static void CheckValueDataElement(SymbolAnalysisContext context, ISymbol if (propertyData.FormattedTextData.ArgumentsCollectionName is not null) { - incompatibleParameters.Add("ValuesPropertyName"); + incompatibleParameters.Add("ArgumentsCollectionName"); } - if (propertyData.FormattedTextData.TreatArgumentsAsLocalizationKeys) + if (propertyData.FormattedTextData.ArgumentsTextKind != TextKind.Plain) { - incompatibleParameters.Add("ArePropertyNameValuesKeys"); - } - - if (propertyData.FormattedTextData.TreatArgumentsAsAppLocalizationKeys) - { - incompatibleParameters.Add("IsPropertyNameValuesAppLocalization"); + incompatibleParameters.Add("ArgumentsTextKind"); } if (propertyData.DisplayOptions.UnitKey is not null) @@ -200,7 +180,7 @@ private static void CheckValueDataElement(SymbolAnalysisContext context, ISymbol if (!propertyData.DisplayOptions.LocalizationKey.Equals(propertySymbol.Name)) { - incompatibleParameters.Add("NameLocalizationKey"); + incompatibleParameters.Add("LocalizationKeyOverride"); } if (incompatibleParameters.Count > 0) @@ -215,27 +195,17 @@ private static void CheckTooltipDataElement(SymbolAnalysisContext context, ISymb if (propertyData.FormattedTextData.ArgumentsCollectionName is not null) { - errors.Add("ValuesPropertyName"); - } - - if (propertyData.FormattedTextData.TreatArgumentsAsLocalizationKeys) - { - errors.Add("ArePropertyNameValuesKeys"); - } - - if (propertyData.FormattedTextData.TreatArgumentsAsAppLocalizationKeys) - { - errors.Add("IsPropertyNameValuesAppLocalization"); + errors.Add("ArgumentsCollectionName"); } - if (propertyData.DisplayOptions.TreatValueAsLocalizationKey) + if (propertyData.FormattedTextData.ArgumentsTextKind != TextKind.Plain) { - errors.Add("IsValueLocalizationKey"); + errors.Add("ArgumentsTextKind"); } - if (propertyData.DisplayOptions.TreatValueAsAppLocalizationKey) + if (propertyData.DisplayOptions.ValueTextKind != TextKind.Plain) { - errors.Add("IsValueAppLocalizationKey"); + errors.Add("ValueTextKind"); } if (errors.Count > 0) @@ -265,7 +235,7 @@ private static void CheckFormattedTextDataElement(SymbolAnalysisContext context, if (!propertyData.DisplayOptions.LocalizationKey.Equals(propertySymbol.Name)) { - errors.Add("NameLocalizationKey"); + errors.Add("LocalizationKeyOverride"); } if (errors.Count > 0) @@ -275,7 +245,7 @@ private static void CheckFormattedTextDataElement(SymbolAnalysisContext context, if (string.IsNullOrEmpty(propertyData.FormattedTextData.ArgumentsCollectionName)) { - context.ReportDiagnostic(Diagnostic.Create(Rules.MissingAttributeParametersRule, propertySymbol.Locations[0], "ValuesPropertyName")); + context.ReportDiagnostic(Diagnostic.Create(Rules.MissingAttributeParametersRule, propertySymbol.Locations[0], "ArgumentsCollectionName")); } } diff --git a/WoWsShipBuilder.Data.Generator/DataElementGenerator/DataElementGenerator.cs b/WoWsShipBuilder.Data.Generator/DataElementGenerator/DataElementGenerator.cs index fe8db464f..1c32e2531 100644 --- a/WoWsShipBuilder.Data.Generator/DataElementGenerator/DataElementGenerator.cs +++ b/WoWsShipBuilder.Data.Generator/DataElementGenerator/DataElementGenerator.cs @@ -166,10 +166,10 @@ private static string GenerateDataElementCreationCode(SinglePropertyData propert { return propertyData.DataElementType switch { - DataElementTypes.Value => $"new {DataElementNamespace}.ValueDataElement({GeneratePropertyAccess(propertyData)}, {propertyData.DisplayOptions.TreatValueAsLocalizationKey.ToLowerString()}, {propertyData.DisplayOptions.TreatValueAsAppLocalizationKey.ToLowerString()})", - DataElementTypes.KeyValue => $"""new {DataElementNamespace}.KeyValueDataElement("ShipStats_{propertyData.DisplayOptions.LocalizationKey}", {GeneratePropertyAccess(propertyData)}, {propertyData.DisplayOptions.TreatValueAsLocalizationKey.ToLowerString()}, {propertyData.DisplayOptions.TreatValueAsAppLocalizationKey.ToLowerString()})""", + DataElementTypes.Value => $"new {DataElementNamespace}.ValueDataElement({GeneratePropertyAccess(propertyData)}, {DataElementNamespace}.DataElementTextKind.{propertyData.DisplayOptions.ValueTextKind})", + DataElementTypes.KeyValue => $$"""new {{DataElementNamespace}}.KeyValueDataElement("ShipStats_{{propertyData.DisplayOptions.LocalizationKey}}", {{GeneratePropertyAccess(propertyData)}}, {{DataElementNamespace}}.DataElementTextKind.{{propertyData.DisplayOptions.ValueTextKind}})""", DataElementTypes.KeyValueUnit => $"""new {DataElementNamespace}.KeyValueUnitDataElement("ShipStats_{propertyData.DisplayOptions.LocalizationKey}", {GeneratePropertyAccess(propertyData)}, "Unit_{propertyData.DisplayOptions.UnitKey}")""", - DataElementTypes.FormattedText => $"new {DataElementNamespace}.FormattedTextDataElement({GeneratePropertyAccess(propertyData)}, this.{propertyData.FormattedTextData.ArgumentsCollectionName}, {propertyData.DisplayOptions.TreatValueAsLocalizationKey.ToLowerString()}, {propertyData.DisplayOptions.TreatValueAsAppLocalizationKey.ToLowerString()}, {propertyData.FormattedTextData.TreatArgumentsAsLocalizationKeys.ToLowerString()}, {propertyData.FormattedTextData.TreatArgumentsAsAppLocalizationKeys.ToLowerString()})", + DataElementTypes.FormattedText => $"new {DataElementNamespace}.FormattedTextDataElement({GeneratePropertyAccess(propertyData)}, this.{propertyData.FormattedTextData.ArgumentsCollectionName}, {DataElementNamespace}.DataElementTextKind.{propertyData.DisplayOptions.ValueTextKind}, {DataElementNamespace}.DataElementTextKind.{propertyData.FormattedTextData.ArgumentsTextKind})", DataElementTypes.Tooltip => $"""new {DataElementNamespace}.TooltipDataElement("ShipStats_{propertyData.DisplayOptions.LocalizationKey}", {GeneratePropertyAccess(propertyData)}, "ShipStats_{propertyData.DisplayOptions.TooltipKey}", "{ComputeNullableUnitValue(propertyData.DisplayOptions)}")""", _ => string.Empty, }; diff --git a/WoWsShipBuilder.Data.Generator/DataElementGenerator/Model/FormattedTextData.cs b/WoWsShipBuilder.Data.Generator/DataElementGenerator/Model/FormattedTextData.cs index 86bb0045d..9d9c804d3 100644 --- a/WoWsShipBuilder.Data.Generator/DataElementGenerator/Model/FormattedTextData.cs +++ b/WoWsShipBuilder.Data.Generator/DataElementGenerator/Model/FormattedTextData.cs @@ -1,3 +1,3 @@ namespace WoWsShipBuilder.Data.Generator.DataElementGenerator.Model; -internal sealed record FormattedTextData(string? ArgumentsCollectionName, bool TreatArgumentsAsLocalizationKeys, bool TreatArgumentsAsAppLocalizationKeys); +internal sealed record FormattedTextData(string? ArgumentsCollectionName, TextKind ArgumentsTextKind); diff --git a/WoWsShipBuilder.Data.Generator/DataElementGenerator/Model/PropertyDisplayOptions.cs b/WoWsShipBuilder.Data.Generator/DataElementGenerator/Model/PropertyDisplayOptions.cs index 0d8d3d296..4659f9e49 100644 --- a/WoWsShipBuilder.Data.Generator/DataElementGenerator/Model/PropertyDisplayOptions.cs +++ b/WoWsShipBuilder.Data.Generator/DataElementGenerator/Model/PropertyDisplayOptions.cs @@ -1,3 +1,3 @@ namespace WoWsShipBuilder.Data.Generator.DataElementGenerator.Model; -internal sealed record PropertyDisplayOptions(string? UnitKey, string LocalizationKey, string? TooltipKey, string? GroupKey, bool TreatValueAsLocalizationKey, bool TreatValueAsAppLocalizationKey); +internal sealed record PropertyDisplayOptions(string? UnitKey, string LocalizationKey, string? TooltipKey, string? GroupKey, TextKind ValueTextKind); diff --git a/WoWsShipBuilder.Data.Generator/DataElementGenerator/PropertyHelper.cs b/WoWsShipBuilder.Data.Generator/DataElementGenerator/PropertyHelper.cs index 1c830e38c..c78ba7ea3 100644 --- a/WoWsShipBuilder.Data.Generator/DataElementGenerator/PropertyHelper.cs +++ b/WoWsShipBuilder.Data.Generator/DataElementGenerator/PropertyHelper.cs @@ -12,20 +12,18 @@ internal static class PropertyHelper public static FormattedTextData ExtractFormattedTextOptions(AttributeData dataElementAttribute) { return new( - dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "ValuesPropertyName").Value.Value?.ToString(), - (bool?)dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "ArePropertyNameValuesKeys").Value.Value ?? false, - (bool?)dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "IsPropertyNameValuesAppLocalization").Value.Value ?? false); + dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "ArgumentsCollectionName").Value.Value?.ToString(), + (TextKind)(dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "ArgumentsTextKind").Value.Value ?? TextKind.Plain)); } public static PropertyDisplayOptions ExtractDisplayOptions(ISymbol propertySymbol, AttributeData dataElementAttribute) { return new( dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "UnitKey").Value.Value?.ToString(), - dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "NameLocalizationKey").Value.Value?.ToString() ?? propertySymbol.Name, + dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "LocalizationKeyOverride").Value.Value?.ToString() ?? propertySymbol.Name, dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "TooltipKey").Value.Value?.ToString(), dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "GroupKey").Value.Value?.ToString(), - (bool?)dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "IsValueLocalizationKey").Value.Value ?? false, - (bool?)dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "IsValueAppLocalization").Value.Value ?? false); + (TextKind)(dataElementAttribute.NamedArguments.FirstOrDefault(arg => arg.Key == "ValueTextKind").Value.Value ?? TextKind.Plain)); } public static PropertyFilter ExtractFilterOptions(IPropertySymbol propertySymbol) diff --git a/WoWsShipBuilder.Data.Generator/DataElementGenerator/TextKind.cs b/WoWsShipBuilder.Data.Generator/DataElementGenerator/TextKind.cs new file mode 100644 index 000000000..7433c5d63 --- /dev/null +++ b/WoWsShipBuilder.Data.Generator/DataElementGenerator/TextKind.cs @@ -0,0 +1,8 @@ +namespace WoWsShipBuilder.Data.Generator.DataElementGenerator; + +internal enum TextKind +{ + Plain, + LocalizationKey, + AppLocalizationKey, +} diff --git a/WoWsShipBuilder.DataElements/DataElements/DataElementTextKind.cs b/WoWsShipBuilder.DataElements/DataElements/DataElementTextKind.cs new file mode 100644 index 000000000..548a1e97e --- /dev/null +++ b/WoWsShipBuilder.DataElements/DataElements/DataElementTextKind.cs @@ -0,0 +1,8 @@ +namespace WoWsShipBuilder.DataElements.DataElements; + +public enum DataElementTextKind +{ + Plain, + LocalizationKey, + AppLocalizationKey, +} diff --git a/WoWsShipBuilder.DataElements/DataElements/FormattedTextDataElement.cs b/WoWsShipBuilder.DataElements/DataElements/FormattedTextDataElement.cs index 17ddeba30..72ddeb338 100644 --- a/WoWsShipBuilder.DataElements/DataElements/FormattedTextDataElement.cs +++ b/WoWsShipBuilder.DataElements/DataElements/FormattedTextDataElement.cs @@ -6,7 +6,7 @@ namespace WoWsShipBuilder.DataElements.DataElements; /// A record that represent a formatted text data element. ///
/// The text to format. Need to respect specifications. -/// The enumerable that will be used by . -/// If is a localization key and not actual text. -/// If are localization keys and not actual values. -public sealed record FormattedTextDataElement(string Text, IEnumerable Values, bool IsTextKey = false, bool IsTextAppLocalization = false, bool AreValuesKeys = false, bool AreValuesAppLocalization = false) : IDataElement; +/// The enumerable that will be used by . +/// The of the text. +/// The of the arguments. +public sealed record FormattedTextDataElement(string Text, IEnumerable Arguments, DataElementTextKind ValueTextKind = DataElementTextKind.Plain, DataElementTextKind ArgumentsTextKind = DataElementTextKind.Plain) : IDataElement; diff --git a/WoWsShipBuilder.DataElements/DataElements/KeyValueDataElement.cs b/WoWsShipBuilder.DataElements/DataElements/KeyValueDataElement.cs index 8e7f5eef7..e02805387 100644 --- a/WoWsShipBuilder.DataElements/DataElements/KeyValueDataElement.cs +++ b/WoWsShipBuilder.DataElements/DataElements/KeyValueDataElement.cs @@ -5,6 +5,5 @@ /// /// The key of the element. /// The value of the element. -/// If the value is a localizer key. -/// If the value is an app localization key. -public readonly record struct KeyValueDataElement(string Key, string Value, bool IsValueKey, bool IsValueAppLocalization) : IDataElement; +/// The of the . +public readonly record struct KeyValueDataElement(string Key, string Value, DataElementTextKind ValueTextKind) : IDataElement; diff --git a/WoWsShipBuilder.DataElements/DataElements/ValueDataElement.cs b/WoWsShipBuilder.DataElements/DataElements/ValueDataElement.cs index 74d3332b0..715b289ef 100644 --- a/WoWsShipBuilder.DataElements/DataElements/ValueDataElement.cs +++ b/WoWsShipBuilder.DataElements/DataElements/ValueDataElement.cs @@ -4,6 +4,5 @@ /// A record that represent a single value. /// /// The value of the element. -/// If the value is a localizer key. -/// If the value is an app localization key. -public readonly record struct ValueDataElement(string Value, bool IsValueKey, bool IsValueAppLocalization) : IDataElement; +/// The of the value. +public readonly record struct ValueDataElement(string Value, DataElementTextKind ValueTextKind) : IDataElement;