Fixed an issue where banners would not display properly.

修复标语不能正常显示的问题。
This commit is contained in:
Cold-Mint 2024-05-26 22:04:28 +08:00
parent fdb8b88c1e
commit 4b9bac6ac7
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
7 changed files with 8 additions and 50 deletions

View File

@ -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]

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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]

View File

@ -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;
/// </summary>
public static class SloganProvider
{
private static string _csvPath = "res://locals/slogan.csv";
private const int MaxSloganIndex = 5;
private static string[]? _sloganKeys;
/// <summary>
/// <para>Loading CSV file</para>
/// <para>加载CSV文件</para>
/// </summary>
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<string>();
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();
}
/// <summary>
/// <para>Swipe the machine to get a slogan</para>
@ -55,11 +20,7 @@ public static class SloganProvider
/// <returns></returns>
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);
}
}

View File

@ -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);