From 4b9bac6ac78aa058d4d7be1e9a8d09c08b6d6b28 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Sun, 26 May 2024 22:04:28 +0800 Subject: [PATCH] =?UTF-8?q?Fixed=20an=20issue=20where=20banners=20would=20?= =?UTF-8?q?not=20display=20properly.=20=E4=BF=AE=E5=A4=8D=E6=A0=87?= =?UTF-8?q?=E8=AF=AD=E4=B8=8D=E8=83=BD=E6=AD=A3=E5=B8=B8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locals/slogan.csv.import | 8 ++-- locals/slogan.en.translation | Bin 634 -> 634 bytes locals/slogan.jp.translation | Bin 769 -> 769 bytes locals/slogan.zh.translation | Bin 701 -> 701 bytes project.godot | 2 +- scripts/SloganProvider.cs | 45 ++-------------------- scripts/loader/uiLoader/MainMenuLoader.cs | 3 -- 7 files changed, 8 insertions(+), 50 deletions(-) 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 bb72914933746290ec70802649701d154feae40c..641c2399d29e464fa6d4fbfc5923a76f709727b5 100644 GIT binary patch delta 35 rcmeyx@{47HEeE@LV-zC*5t9vh diff --git a/locals/slogan.jp.translation b/locals/slogan.jp.translation index 384a262296f338beca369493736fea182faf5da8..c5d3c858ac5bc132124642d73df41a474c681d5b 100644 GIT binary patch delta 35 rcmZod6*^VJO% delta 35 rcmZod6*_v;On diff --git a/locals/slogan.zh.translation b/locals/slogan.zh.translation index ca53706cb80a5287e3c551d17ff1465b523e5c89..bb08eec7ecd646ccc35ad7590d069ff250901ed1 100644 GIT binary patch delta 35 rcmdnXx|el=Er(OFL|w+UTUrwX6(%O|Oe|c*nwpWDpSoFraV{eO@yZPs delta 35 rcmdnXx|el=Ek}#_lHU^VFX>MVRG65+GqG?LYpF?YM$Tph#<`3D24@Y( 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);