diff --git a/locals/slogan.csv.import b/locals/slogan.csv.import index f9d7def..0da607d 100644 --- a/locals/slogan.csv.import +++ b/locals/slogan.csv.import @@ -2,14 +2,14 @@ importer="csv_translation" type="Translation" -uid="uid://cjtdm8ddsrd7e" +uid="uid://dbgkevd34vb0d" [deps] -files=["res://locals/slogan.zh.translation", "res://locals/slogan.en.translation", "res://locals/slogan.jp.translation"] +files=["res://locals/Slogan.zh.translation", "res://locals/Slogan.en.translation", "res://locals/Slogan.jp.translation"] -source_file="res://locals/slogan.csv" -dest_files=["res://locals/slogan.zh.translation", "res://locals/slogan.en.translation", "res://locals/slogan.jp.translation"] +source_file="res://locals/Slogan.csv" +dest_files=["res://locals/Slogan.zh.translation", "res://locals/Slogan.en.translation", "res://locals/Slogan.jp.translation"] [params] diff --git a/locals/slogan.en.translation b/locals/slogan.en.translation index bb72914..641c239 100644 Binary files a/locals/slogan.en.translation and b/locals/slogan.en.translation differ diff --git a/locals/slogan.jp.translation b/locals/slogan.jp.translation index 384a262..c5d3c85 100644 Binary files a/locals/slogan.jp.translation and b/locals/slogan.jp.translation differ diff --git a/locals/slogan.zh.translation b/locals/slogan.zh.translation index ca53706..bb08eec 100644 Binary files a/locals/slogan.zh.translation and b/locals/slogan.zh.translation differ diff --git a/project.godot b/project.godot index 41005f1..f17d619 100644 --- a/project.godot +++ b/project.godot @@ -146,7 +146,7 @@ hotbar_previous={ [internationalization] -locale/translations=PackedStringArray("res://locals/UI.en.translation", "res://locals/UI.zh.translation", "res://locals/slogan.en.translation", "res://locals/slogan.zh.translation", "res://locals/Log.en.translation", "res://locals/Log.zh.translation", "res://locals/Weapon.en.translation", "res://locals/Weapon.zh.translation", "res://locals/InputMapping.en.translation", "res://locals/InputMapping.zh.translation", "res://locals/InputMapping.jp.translation", "res://locals/Log.jp.translation", "res://locals/slogan.jp.translation", "res://locals/UI.jp.translation", "res://locals/Weapon.jp.translation") +locale/translations=PackedStringArray("res://locals/UI.en.translation", "res://locals/UI.zh.translation", "res://locals/Log.en.translation", "res://locals/Log.zh.translation", "res://locals/Weapon.en.translation", "res://locals/Weapon.zh.translation", "res://locals/InputMapping.en.translation", "res://locals/InputMapping.zh.translation", "res://locals/InputMapping.jp.translation", "res://locals/Log.jp.translation", "res://locals/UI.jp.translation", "res://locals/Weapon.jp.translation", "res://locals/Slogan.en.translation", "res://locals/Slogan.jp.translation", "res://locals/Slogan.zh.translation") [layer_names] diff --git a/scripts/SloganProvider.cs b/scripts/SloganProvider.cs index 8c9a37a..10f46ca 100644 --- a/scripts/SloganProvider.cs +++ b/scripts/SloganProvider.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using ColdMint.scripts.utils; using Godot; -using FileAccess = Godot.FileAccess; namespace ColdMint.scripts; @@ -11,42 +10,8 @@ namespace ColdMint.scripts; /// public static class SloganProvider { - private static string _csvPath = "res://locals/slogan.csv"; + private const int MaxSloganIndex = 5; - private static string[]? _sloganKeys; - - /// - /// Loading CSV file - /// 加载CSV文件 - /// - public static void LoadSloganCsv() - { - var exists = FileAccess.FileExists(_csvPath); - if (!exists) - { - return; - } - - using var file = FileAccess.Open(_csvPath, FileAccess.ModeFlags.Read); - var content = file.GetAsText(); - var lineStrings = content.Split('\n'); - var keys = new List(); - foreach (var lineString in lineStrings) - { - var index = lineString.IndexOf(','); - if (index > -1) - { - keys.Add(lineString[..index]); - } - } - - if (keys.Count > 0) - { - keys.RemoveAt(0); - } - - _sloganKeys = keys.ToArray(); - } /// /// Swipe the machine to get a slogan @@ -55,11 +20,7 @@ public static class SloganProvider /// public static string? GetSlogan() { - if (_sloganKeys == null || _sloganKeys.Length == 0) - { - return null; - } - - return TranslationServerUtils.Translate(_sloganKeys[GD.Randi() % _sloganKeys.Length]); + var index = GD.Randi() % MaxSloganIndex + 1; + return TranslationServerUtils.Translate("slogan_" + index); } } \ No newline at end of file diff --git a/scripts/loader/uiLoader/MainMenuLoader.cs b/scripts/loader/uiLoader/MainMenuLoader.cs index 8ac6850..6ecc1c8 100644 --- a/scripts/loader/uiLoader/MainMenuLoader.cs +++ b/scripts/loader/uiLoader/MainMenuLoader.cs @@ -35,9 +35,6 @@ public partial class MainMenuLoader : UiLoaderTemplate //在发行版禁用所有日志。 LogCat.MinLogLevel = LogCat.DisableAllLogLevel; } - //Load the slogan - //加载标语 - SloganProvider.LoadSloganCsv(); //Register the corresponding encoding provider to solve the problem of garbled Chinese path of the compressed package //注册对应的编码提供程序,解决压缩包中文路径乱码问题 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);