56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace BriarQueen.Data.Identifiers
|
|
{
|
|
public enum SubtitleKey
|
|
{
|
|
None = 0,
|
|
// Example:
|
|
// IntroLine = 1,
|
|
// TutorialTip = 2
|
|
}
|
|
|
|
public readonly struct SubtitleEntry
|
|
{
|
|
public SubtitleEntry(string text, float preferredDurationSeconds = 0f)
|
|
{
|
|
Text = text;
|
|
PreferredDurationSeconds = preferredDurationSeconds;
|
|
}
|
|
|
|
public string Text { get; }
|
|
public float PreferredDurationSeconds { get; }
|
|
}
|
|
|
|
public static class SubtitleIdentifiers
|
|
{
|
|
private static readonly IReadOnlyDictionary<SubtitleKey, SubtitleEntry> _subtitles =
|
|
new ReadOnlyDictionary<SubtitleKey, SubtitleEntry>(
|
|
new Dictionary<SubtitleKey, SubtitleEntry>
|
|
{
|
|
// { SubtitleKey.IntroLine, new SubtitleEntry("Example subtitle.", 2.5f) },
|
|
});
|
|
|
|
public static bool TryGet(SubtitleKey key, out SubtitleEntry entry)
|
|
{
|
|
return _subtitles.TryGetValue(key, out entry);
|
|
}
|
|
|
|
public static string GetText(SubtitleKey key)
|
|
{
|
|
return _subtitles.TryGetValue(key, out var entry) ? entry.Text : string.Empty;
|
|
}
|
|
|
|
public static float GetPreferredDuration(SubtitleKey key)
|
|
{
|
|
return _subtitles.TryGetValue(key, out var entry) ? entry.PreferredDurationSeconds : 0f;
|
|
}
|
|
|
|
public static IEnumerable<SubtitleKey> GetAllKeys()
|
|
{
|
|
return _subtitles.Keys;
|
|
}
|
|
}
|
|
}
|