fix: 诊疗记录异常空格缺失

This commit is contained in:
2026-08-20 21:01:47 +08:00
parent 8adde58a88
commit 3e50d426de
4 changed files with 18 additions and 55 deletions
@@ -1,5 +1,4 @@
using System;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using AibisDream.Framework;
@@ -190,9 +189,9 @@ namespace AibisDream
public string GetRecordLine()
{
const string allowedTagsPattern = @"(<|{)(?!\/?(b|i|color)(?=>|\s|=))[^(>|})]+(>|})";
var res = Regex.Replace(lineText, allowedTagsPattern, "");
return res;
var localeKind = LocalizationKit.CurrentLocaleKind;
var replaceBrWithSpace = localeKind is not (LocaleKind.Cn or LocaleKind.Ja);
return lineText.ToRecordLineText(replaceBrWithSpace);
}
public int CalcAutoDelayTime()
@@ -565,30 +565,5 @@ namespace AibisDream.Kit
RemoveMusic(key);
}
}
public interface IAudioManager
{
// Yarn音频接口
public void PlayMusic(string eventName, string audioKey);
public void StopMusic(string eventName, STOP_MODE stopMode);
public void SetMusicParam(string eventName, string paramName, float paramValue);
// AMB参数变化
public void ChangeAmb(AmbState state);
public void SetGlobalParam(string paramName, float value);
// 语音相关
public void OnLineStart(DialogText dialogText);
public void OnLineShown();
// 交互相关
public void PlaySfx(string eventName, string audioKey);
public void StopSfx(string eventName, STOP_MODE stopMode);
public void SetSfxParam(string eventName, string paramName, float paramValue);
// 暂停
public void PauseAll();
public void UnPauseAll();
}
}
-26
View File
@@ -52,32 +52,6 @@ namespace AibisDream
Selected
}
public struct DialogText
{
public bool isOption;
public string line;
public CharacterVo actor;
public string lineId;
public static DialogText GetLine(LocalizedLine dialogueLine)
{
return new DialogText
{
isOption = false,
line = dialogueLine.TextWithoutCharacterName.Text,
lineId = dialogueLine.TextID,
actor = dialogueLine.GetCharacterVo()
};
}
public string GetRecordLine()
{
const string allowedTagsPattern = @"(<|{)(?!\/?(b|i|color)(?=>|\s|=))[^(>|})]+(>|})";
var res = Regex.Replace(line, allowedTagsPattern, "");
return res;
}
}
public enum StorageEvent
{
VariableSet,
+15
View File
@@ -270,6 +270,21 @@ namespace AibisDream.Utility
return Regex.Replace(str.Replace("<br>", "\n"), "[<|{].*?[>|}]", string.Empty);
}
/// <summary>
/// 诊疗记录展示用:去掉非 b/i/color 的富文本标签。
/// CJK 语言可直接去掉换行;其他语言需把 br 换成空格,避免单词粘连。
/// </summary>
public static string ToRecordLineText(this string str, bool replaceBrWithSpace)
{
const string brPattern = @"<br\s*/?>";
var text = replaceBrWithSpace
? Regex.Replace(str, brPattern, " ", RegexOptions.IgnoreCase)
: Regex.Replace(str, brPattern, string.Empty, RegexOptions.IgnoreCase);
const string allowedTagsPattern = @"(<|{)(?!\/?(b|i|color)(?=>|\s|=))[^(>|})]+(>|})";
return Regex.Replace(text, allowedTagsPattern, string.Empty);
}
public static int[,] DeserializeIntArray(string str)
{
if (string.IsNullOrWhiteSpace(str))