diff --git a/game/.gitignore b/game/.gitignore index 26c1e02..d609af2 100644 --- a/game/.gitignore +++ b/game/.gitignore @@ -88,4 +88,4 @@ config.txt # Generated dialogue files [Aa]ssets/Data/Dialogue/token* -[Aa]ssets/Data/Dialogue/dialogue.csv* +[Aa]ssets/Data/Dialogue/dialogue.data* diff --git a/game/Assets/Scripts/Dialogue/DialogueDatabase.cs b/game/Assets/Scripts/Dialogue/DialogueDatabase.cs index 4b3d504..256964c 100644 --- a/game/Assets/Scripts/Dialogue/DialogueDatabase.cs +++ b/game/Assets/Scripts/Dialogue/DialogueDatabase.cs @@ -16,6 +16,7 @@ using UnityEditor; public static partial class DialogueDatabase { + public static string EDITOR_DialogueFile => Path.Combine(Application.dataPath, "Data", "Dialogue", DIALOGUE_FILENAME); @@ -62,18 +63,16 @@ public static partial class DialogueDatabase } Debug.Log($":: importing dialogue"); - var sbFile = new StringBuilder(); - var sbLog = new StringBuilder(); + var sb = new StringBuilder(); var lines = 0; foreach (var row in values) { - sbLog.AppendLine($"{row[0]} {row[1]}"); - sbFile.AppendLine($"{row[0]},{row[1]},"); + sb.AppendLine($"{row[0]}{SPLIT_CHAR}{row[1]}"); lines++; } - Debug.Log($":: imported {lines} lines of dialogue\n{sbLog}"); + Debug.Log($":: imported {lines} lines of dialogue\n{sb}"); - File.WriteAllText(EDITOR_DialogueFile, sbFile.ToString()); + File.WriteAllText(EDITOR_DialogueFile, sb.ToString()); if (!File.Exists(EDITOR_DialogueFile)) { Debug.LogError($":: import failed: file doesn't exist: {EDITOR_DialogueFile}"); @@ -95,7 +94,9 @@ public static partial class DialogueDatabase public static partial class DialogueDatabase { - public const string DIALOGUE_FILENAME = "dialogue.csv"; + private const char SPLIT_CHAR = '|'; + + public const string DIALOGUE_FILENAME = "dialogue.data"; public static string DialogueFile { @@ -119,7 +120,7 @@ public static partial class DialogueDatabase int count = 0; foreach (var line in File.ReadLines(DialogueFile)) { - var parts = line.Split(','); + var parts = line.Split(SPLIT_CHAR); var key = parts[0]; var text = parts[1]; @@ -144,5 +145,4 @@ public static partial class DialogueDatabase ? _dict[key] : $"MISSING[{key}]"; } - } \ No newline at end of file