Add localization support for console spam reduction

Signed-off-by: yuyu <kawaiiyuyu@outlook.com>
This commit is contained in:
yuyu 2022-10-19 22:27:11 +08:00
parent ee2d9de205
commit 69e5e202de
No known key found for this signature in database
2 changed files with 17 additions and 8 deletions

View file

@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using Terraria.Localization;
namespace TShockAPI.Modules; namespace TShockAPI.Modules;
@ -32,6 +33,13 @@ public class ReduceConsoleSpam : Module
/// </summary> /// </summary>
private string _lastStatusText = null; 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");
/// <summary> /// <summary>
/// Aims to reduce the amount of console spam by filtering out load/save progress /// Aims to reduce the amount of console spam by filtering out load/save progress
/// </summary> /// </summary>
@ -59,11 +67,11 @@ public class ReduceConsoleSpam : Module
return false; return false;
} }
if (replace("Resetting game objects") if (replace(ResettingObjectText)
|| replace("Settling liquids") || replace(SettlingText)
|| replace("Loading world data") || replace(LoadingText)
|| replace("Saving world data") || replace(SavingText)
|| replace("Validating world save")) || replace(ValidatingText))
return; return;
// try parsing % - [text] - % // try parsing % - [text] - %
@ -84,10 +92,10 @@ public class ReduceConsoleSpam : Module
if (text.Length > 0 && !( if (text.Length > 0 && !(
// relogic has made a mess of this // relogic has made a mess of this
( (
_lastStatusText != "Validating world save" _lastStatusText != ValidatingText
|| _lastStatusText != "Saving world data" || _lastStatusText != SavingText
) )
&& text == "Finalizing world" && text == FinalizingText
)) ))
WriteIfChange(text); WriteIfChange(text);

View file

@ -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. --> * 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 ## Upcoming changes
* Added localization support for console spam reduction. (@KawaiiYuyu)
* Reduced load/save console spam. (@SignatureBeef, @YehnBeep) * Reduced load/save console spam. (@SignatureBeef, @YehnBeep)
* Replaced SQLite library with Microsoft.Data.Sqlite for arm64 support. (@SignatureBeef) * Replaced SQLite library with Microsoft.Data.Sqlite for arm64 support. (@SignatureBeef)
* Initial support for MonoMod hooks on Raspberry Pi (arm64). (@kevzhao2) * Initial support for MonoMod hooks on Raspberry Pi (arm64). (@kevzhao2)