57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
|
|||
|
|
namespace Ichni.Story.Dialogue
|
|||
|
|
{
|
|||
|
|
/// <summary>对话记录中一条已经实际显示或采用的内容。</summary>
|
|||
|
|
[Serializable]
|
|||
|
|
public sealed class DialogueHistoryEntry
|
|||
|
|
{
|
|||
|
|
public string speakerName;
|
|||
|
|
public string content;
|
|||
|
|
public bool isChoice;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 当前一次 TextBlock 对话专用的临时记录。
|
|||
|
|
/// <para>记录不会写入 ES3;开始下一次对话、正常结束或点击 Back 取消时都会清空,
|
|||
|
|
/// 因而它只承担 DialogUIPage 内的“本次对话回顾”职责。</para>
|
|||
|
|
/// </summary>
|
|||
|
|
public static class DialogueHistory
|
|||
|
|
{
|
|||
|
|
private static readonly List<DialogueHistoryEntry> EntriesInternal = new();
|
|||
|
|
|
|||
|
|
public static IReadOnlyList<DialogueHistoryEntry> Entries => EntriesInternal;
|
|||
|
|
|
|||
|
|
public static void BeginSession() => EntriesInternal.Clear();
|
|||
|
|
|
|||
|
|
public static void AddLine(string speakerName, string content)
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrWhiteSpace(content))
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
EntriesInternal.Add(new DialogueHistoryEntry
|
|||
|
|
{
|
|||
|
|
speakerName = speakerName ?? string.Empty,
|
|||
|
|
content = content,
|
|||
|
|
isChoice = false
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void AddChoice(string content)
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrWhiteSpace(content))
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
EntriesInternal.Add(new DialogueHistoryEntry
|
|||
|
|
{
|
|||
|
|
speakerName = string.Empty,
|
|||
|
|
content = content,
|
|||
|
|
isChoice = true
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void Clear() => EntriesInternal.Clear();
|
|||
|
|
}
|
|||
|
|
}
|