Skip to content

Commit 785cb2d

Browse files
authored
Merge pull request #695 from MUnique/dev/localizedstring-fixes
Fixes for LocalizedString issues
2 parents 6f5c73a + d0e30ab commit 785cb2d

29 files changed

Lines changed: 5668 additions & 274 deletions

src/DataModel/Configuration/ConfigurationUpdate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ public class ConfigurationUpdate
2323
/// <summary>
2424
/// Gets or sets the name of the update.
2525
/// </summary>
26-
public LocalizedString? Name { get; set; }
26+
public LocalizedString Name { get; set; }
2727

2828
/// <summary>
2929
/// Gets or sets the description of the update with further information.
3030
/// </summary>
31-
public LocalizedString? Description { get; set; }
31+
public LocalizedString Description { get; set; }
3232

3333
/// <summary>
3434
/// Gets or sets the release date.

src/DataModel/Configuration/MiniGameChangeEvent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ public partial class MiniGameChangeEvent
4545
/// <summary>
4646
/// Gets or sets the description about the event.
4747
/// </summary>
48-
public LocalizedString? Description { get; set; }
48+
public LocalizedString Description { get; set; }
4949

5050
/// <summary>
5151
/// Gets or sets the (golden) message which should be shown to the player.
5252
/// One placeholder can be used to show the triggering player name.
5353
/// </summary>
54-
public LocalizedString? Message { get; set; }
54+
public LocalizedString Message { get; set; }
5555

5656
/// <summary>
5757
/// Gets or sets the targets which need to be killed to reach the required <see cref="NumberOfKills"/>.

src/DataModel/Configuration/MiniGameSpawnWave.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public partial class MiniGameSpawnWave
2121
/// <summary>
2222
/// Gets or sets the description about this wave.
2323
/// </summary>
24-
public LocalizedString? Description { get; set; }
24+
public LocalizedString Description { get; set; }
2525

2626
/// <summary>
2727
/// Gets or sets a message which is shown to the player when the wave starts.
2828
/// </summary>
29-
public LocalizedString? Message { get; set; }
29+
public LocalizedString Message { get; set; }
3030

3131
/// <summary>
3232
/// Gets or sets the starting time of the wave.

src/Directory.Packages.props

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@
1414
<PackageVersion Include="Dapr.AspNetCore" Version="1.16.1" />
1515
<PackageVersion Include="Dapr.Client" Version="1.16.1" />
1616
<PackageVersion Include="Mapster" Version="7.4.0" />
17-
<PackageVersion Include="Microsoft.AspNetCore.Components.QuickGrid" Version="10.0.1" />
18-
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="10.0.1" />
17+
<PackageVersion Include="Microsoft.AspNetCore.Components.QuickGrid" Version="10.0.2" />
18+
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="10.0.2" />
1919
<PackageVersion Include="Microsoft.AspNetCore.Mvc" Version="2.3.0" />
2020
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Core" Version="2.3.0" />
21-
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
22-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
23-
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
24-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.1" />
25-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.1" />
26-
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="10.0.1" />
27-
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.1" />
28-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.1" />
29-
<PackageVersion Include="Microsoft.Extensions.FileProviders.Physical" Version="10.0.1" />
30-
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.1" />
31-
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.1" />
32-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
33-
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="10.0.1" />
21+
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
22+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
23+
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.2" />
24+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.2" />
25+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.2" />
26+
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="10.0.2" />
27+
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.2" />
28+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.2" />
29+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.2" />
30+
<PackageVersion Include="Microsoft.Extensions.FileProviders.Physical" Version="10.0.2" />
31+
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.2" />
32+
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.2" />
33+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.2" />
34+
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="10.0.2" />
3435
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
3536
<PackageVersion Include="Microsoft.OpenApi" Version="1.6.22" />
3637
<PackageVersion Include="Microsoft.TypeScript.MSBuild" Version="5.9.3" />
@@ -56,7 +57,7 @@
5657
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
5758
<PackageVersion Include="Swashbuckle.AspNetCore" Version="7.0.0" />
5859
<PackageVersion Include="System.ComponentModel.Annotations" Version="6.0.0-preview.4.21253.7" />
59-
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="10.0.1" />
60+
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="10.0.2" />
6061
<PackageVersion Include="System.IO.Pipelines" Version="10.0.1" />
6162
<PackageVersion Include="System.Linq.Dynamic.Core" Version="1.7.1" />
6263
<PackageVersion Include="System.Memory" Version="4.6.3" />

src/GameLogic/MUnique.OpenMU.GameLogic.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<PackageReference Include="MathParser.org-mXparser" />
2727
<PackageReference Include="Microsoft.Extensions.ObjectPool" />
2828
<PackageReference Include="Nito.AsyncEx" />
29-
<PackageReference Include="System.Memory" />
3029
</ItemGroup>
3130

3231
<ItemGroup>

src/GameLogic/MiniGames/MiniGameContext.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,16 @@ protected async ValueTask SaveRankingAsync(IEnumerable<(int Rank, Character Char
530530
/// </param>
531531
protected async ValueTask ShowGoldenMessageAsync(LocalizedString message, params object?[] args)
532532
{
533-
await this.ForEachPlayerAsync(player => player.InvokeViewPlugInAsync<IShowMessagePlugIn>(p => p.ShowMessageAsync(string.Format(message.GetTranslation(player.Culture), args), MessageType.GoldenCenter)).AsTask()).ConfigureAwait(false);
533+
if (string.IsNullOrEmpty(message.Value))
534+
{
535+
return;
536+
}
537+
538+
await this.ForEachPlayerAsync(player => player.InvokeViewPlugInAsync<IShowMessagePlugIn>(p =>
539+
message.GetTranslation(player.Culture) is { Length: > 0 } translation
540+
? p.ShowMessageAsync(string.Format(translation, args), MessageType.GoldenCenter)
541+
: ValueTask.CompletedTask)
542+
.AsTask()).ConfigureAwait(false);
534543
}
535544

536545
/// <summary>

src/GameLogic/PlugIns/ChatCommands/ClearInventoryChatCommandPlugIn.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ protected override async ValueTask DoHandleCommandAsync(Player player, Arguments
7575
if (!this.pendingConfirmations.TryGetValue(playerId, out var confirmationTime) || (DateTime.UtcNow - confirmationTime).TotalSeconds > ConfirmationTimeoutSeconds)
7676
{
7777
this.pendingConfirmations[playerId] = DateTime.UtcNow;
78-
await player.ShowBlueMessageAsync(configuration.ConfirmationMessage.GetTranslation(player.Culture)).ConfigureAwait(false);
78+
if (configuration.ConfirmationMessage.GetTranslation(player.Culture) is { Length: > 0 } message)
79+
{
80+
await player.ShowBlueMessageAsync(message).ConfigureAwait(false);
81+
}
82+
7983
return;
8084
}
8185

@@ -94,7 +98,11 @@ protected override async ValueTask DoHandleCommandAsync(Player player, Arguments
9498

9599
if (removeMoney && !player.TryRemoveMoney(configuration.MoneyCost))
96100
{
97-
await player.ShowBlueMessageAsync(configuration.NotEnoughMoneyMessage.GetTranslation(player.Culture)).ConfigureAwait(false);
101+
if (configuration.NotEnoughMoneyMessage.GetTranslation(player.Culture) is { Length: > 0 } notEnoughMoneyMessage)
102+
{
103+
await player.ShowBlueMessageAsync(notEnoughMoneyMessage).ConfigureAwait(false);
104+
}
105+
98106
return;
99107
}
100108

@@ -103,7 +111,10 @@ protected override async ValueTask DoHandleCommandAsync(Player player, Arguments
103111
await targetPlayer.DestroyInventoryItemAsync(item).ConfigureAwait(false);
104112
}
105113

106-
await player.ShowBlueMessageAsync(configuration.InventoryClearedMessage.GetTranslation(player.Culture)).ConfigureAwait(false);
114+
if (configuration.InventoryClearedMessage.GetTranslation(player.Culture) is { Length: > 0 } clearedMessage)
115+
{
116+
await player.ShowBlueMessageAsync(clearedMessage).ConfigureAwait(false);
117+
}
107118
}
108119

109120
/// <summary>

src/GameLogic/PlugIns/ChatCommands/NpcChatCommandPlugIn.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ protected override async ValueTask DoHandleCommandAsync(Player player, Arguments
8282

8383
if (configuration.MinimumVipLevel > 0 && (player.Attributes?[Stats.IsVip] ?? 0) < configuration.MinimumVipLevel)
8484
{
85-
await player.ShowBlueMessageAsync(configuration.InsufficientVipLevelMessage.GetTranslation(player.Culture)).ConfigureAwait(false);
85+
if (configuration.InsufficientVipLevelMessage.GetTranslation(player.Culture) is { Length: > 0 } message)
86+
{
87+
await player.ShowBlueMessageAsync(message).ConfigureAwait(false);
88+
}
89+
8690
return;
8791
}
8892

src/GameLogic/PlugIns/ChatCommands/OpenWarehouseChatCommandPlugIn.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ protected override async ValueTask DoHandleCommandAsync(Player player, Arguments
5353

5454
if (configuration.MinimumVipLevel > 0 && (player.Attributes?[Stats.IsVip] ?? 0) < configuration.MinimumVipLevel)
5555
{
56-
await player.ShowBlueMessageAsync(configuration.InsufficientVipLevelMessage.GetTranslation(player.Culture)).ConfigureAwait(false);
56+
if (configuration.InsufficientVipLevelMessage.GetTranslation(player.Culture) is { Length: > 0 } message)
57+
{
58+
await player.ShowBlueMessageAsync(message).ConfigureAwait(false);
59+
}
60+
5761
return;
5862
}
5963

src/GameLogic/PlugIns/InvasionEvents/BaseInvasionPlugIn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ protected async Task TrySendStartMessageAsync(Player player, LocalizedString map
217217
return;
218218
}
219219

220-
var message = (configuration.Message?.ToString() ?? PlugInResources.BaseInvasionPlugIn_DefaultStartMessage).Replace("{mapName}", mapName.GetTranslation(player.Culture), StringComparison.InvariantCulture);
220+
var message = (configuration.Message.GetTranslation(player.Culture) ?? PlugInResources.BaseInvasionPlugIn_DefaultStartMessage).Replace("{mapName}", mapName.GetTranslation(player.Culture), StringComparison.InvariantCulture);
221221

222222
if (this.IsPlayerOnMap(player))
223223
{

0 commit comments

Comments
 (0)