From 69e5e202dede45717af938ae064188562b3dc442 Mon Sep 17 00:00:00 2001 From: yuyu Date: Wed, 19 Oct 2022 22:27:11 +0800 Subject: [PATCH 1/2] Add localization support for console spam reduction Signed-off-by: yuyu --- TShockAPI/Modules/ReduceConsoleSpam.cs | 24 ++++++++++++++++-------- docs/changelog.md | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/TShockAPI/Modules/ReduceConsoleSpam.cs b/TShockAPI/Modules/ReduceConsoleSpam.cs index 40e0fbfc..0d34f61b 100644 --- a/TShockAPI/Modules/ReduceConsoleSpam.cs +++ b/TShockAPI/Modules/ReduceConsoleSpam.cs @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ using System; +using Terraria.Localization; namespace TShockAPI.Modules; @@ -32,6 +33,13 @@ public class ReduceConsoleSpam : Module /// private string _lastStatusText = null; + private static readonly string ResettingObjectText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.47"); + private static readonly string LoadingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.51"); + private static readonly string SettlingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.27"); + private static readonly string SavingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.49"); + private static readonly string ValidatingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.73"); + private static readonly string FinalizingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.87"); + /// /// Aims to reduce the amount of console spam by filtering out load/save progress /// @@ -59,11 +67,11 @@ public class ReduceConsoleSpam : Module return false; } - if (replace("Resetting game objects") - || replace("Settling liquids") - || replace("Loading world data") - || replace("Saving world data") - || replace("Validating world save")) + if (replace(ResettingObjectText) + || replace(SettlingText) + || replace(LoadingText) + || replace(SavingText) + || replace(ValidatingText)) return; // try parsing % - [text] - % @@ -84,10 +92,10 @@ public class ReduceConsoleSpam : Module if (text.Length > 0 && !( // relogic has made a mess of this ( - _lastStatusText != "Validating world save" - || _lastStatusText != "Saving world data" + _lastStatusText != ValidatingText + || _lastStatusText != SavingText ) - && text == "Finalizing world" + && text == FinalizingText )) WriteIfChange(text); diff --git a/docs/changelog.md b/docs/changelog.md index 81f0aae3..e3bdabc9 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -15,6 +15,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. --> ## Upcoming changes +* Added localization support for console spam reduction. (@KawaiiYuyu) * Reduced load/save console spam. (@SignatureBeef, @YehnBeep) * Replaced SQLite library with Microsoft.Data.Sqlite for arm64 support. (@SignatureBeef) * Initial support for MonoMod hooks on Raspberry Pi (arm64). (@kevzhao2) From 9e4028fb9d49b7c0c32c38c71b5ef1a9cc6b5adf Mon Sep 17 00:00:00 2001 From: yuyu Date: Wed, 19 Oct 2022 23:20:41 +0800 Subject: [PATCH 2/2] Change strings to instanced; Move the changelog to bottom; --- TShockAPI/Modules/ReduceConsoleSpam.cs | 28 +++++++++++++------------- docs/changelog.md | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/TShockAPI/Modules/ReduceConsoleSpam.cs b/TShockAPI/Modules/ReduceConsoleSpam.cs index 0d34f61b..854536dc 100644 --- a/TShockAPI/Modules/ReduceConsoleSpam.cs +++ b/TShockAPI/Modules/ReduceConsoleSpam.cs @@ -33,12 +33,12 @@ public class ReduceConsoleSpam : Module /// private string _lastStatusText = null; - private static readonly string ResettingObjectText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.47"); - private static readonly string LoadingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.51"); - private static readonly string SettlingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.27"); - private static readonly string SavingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.49"); - private static readonly string ValidatingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.73"); - private static readonly string FinalizingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.87"); + private readonly string _resettingObjectText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.47"); + private readonly string _loadingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.51"); + private readonly string _settlingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.27"); + private readonly string _savingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.49"); + private readonly string _validatingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.73"); + private readonly string _finalizingText = LanguageManager.Instance.GetTextValue("LegacyWorldGen.87"); /// /// Aims to reduce the amount of console spam by filtering out load/save progress @@ -67,11 +67,11 @@ public class ReduceConsoleSpam : Module return false; } - if (replace(ResettingObjectText) - || replace(SettlingText) - || replace(LoadingText) - || replace(SavingText) - || replace(ValidatingText)) + if (replace(_resettingObjectText) + || replace(_settlingText) + || replace(_loadingText) + || replace(_savingText) + || replace(_validatingText)) return; // try parsing % - [text] - % @@ -92,10 +92,10 @@ public class ReduceConsoleSpam : Module if (text.Length > 0 && !( // relogic has made a mess of this ( - _lastStatusText != ValidatingText - || _lastStatusText != SavingText + _lastStatusText != _validatingText + || _lastStatusText != _savingText ) - && text == FinalizingText + && text == _finalizingText )) WriteIfChange(text); diff --git a/docs/changelog.md b/docs/changelog.md index e3bdabc9..13e82edc 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -15,7 +15,6 @@ Use past tense when adding new entries; sign your name off when you add or chang * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. --> ## Upcoming changes -* Added localization support for console spam reduction. (@KawaiiYuyu) * Reduced load/save console spam. (@SignatureBeef, @YehnBeep) * Replaced SQLite library with Microsoft.Data.Sqlite for arm64 support. (@SignatureBeef) * Initial support for MonoMod hooks on Raspberry Pi (arm64). (@kevzhao2) @@ -61,6 +60,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Added new tile provider. Use `-constileation` or `-c` to use it. Constileation is an alternative tile provider to Tiled and HeapTile. (@SignatureBeef) * Fixed an exploit with grass mowing not removing hanging vines. (@punchready) * Added `-additionalplugins` command line argument to load additional plugins. (@pontaoski) +* Added localization support for console spam reduction. (@KawaiiYuyu) ## TShock 4.5.18 * Fixed `TSPlayer.GiveItem` not working if the player is in lava. (@PotatoCider)