Skip to content

Commit b156827

Browse files
authored
feat: set up interactions in Loading Docs (#25)
1 parent 7a5ef38 commit b156827

File tree

94 files changed

+18449
-1917
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+18449
-1917
lines changed

Assets/Editor/Typewriter/CsvConverter.cs

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
using Aarthificial.Typewriter;
22
using Aarthificial.Typewriter.Blackboards;
3-
using Aarthificial.Typewriter.Editor.Common;
4-
using Aarthificial.Typewriter.Editor.Localization;
53
using Aarthificial.Typewriter.Entries;
64
using Aarthificial.Typewriter.References;
75
using Interactions;
86
using System;
97
using System.Collections.Generic;
108
using System.Text;
119
using Typewriter;
12-
using UnityEditor.Localization;
1310
using UnityEngine;
14-
using UnityEngine.Localization;
1511
using Object = UnityEngine.Object;
1612

1713
namespace Editor.Typewriter {
@@ -51,7 +47,6 @@ public ParsingException(string message, ParsingContext context) : base(
5147
private static readonly List<BlackboardCriterion> _criteria = new();
5248
private static readonly List<BlackboardModification> _modifications = new();
5349
private static readonly HashSet<int> _convertedIds = new();
54-
private static StringTableCollection _collection;
5550

5651
public static void Convert(
5752
DatabaseTable table,
@@ -64,17 +59,17 @@ Object context
6459
_lookup.Clear();
6560

6661
foreach (var entry in table.Facts) {
67-
_lookup.Add(entry.GetKey(), (EntryReference)entry);
62+
_lookup.Add(entry.Key, (EntryReference)entry);
6863
}
6964
foreach (var entry in table.Rules) {
70-
_lookup.Add(entry.GetKey(), (EntryReference)entry);
65+
_lookup.Add(entry.Key, (EntryReference)entry);
7166
}
7267
foreach (var entry in table.Events) {
73-
_lookup.Add(entry.GetKey(), (EntryReference)entry);
68+
_lookup.Add(entry.Key, (EntryReference)entry);
7469
}
7570

76-
_collection =
77-
LocalizationEditorSettings.GetStringTableCollection("Dialogue");
71+
// _collection =
72+
// LocalizationEditorSettings.GetStringTableCollection("Dialogue");
7873

7974
_lookup.Add("LT", InteractionContext.LT);
8075
_lookup.Add("RT", InteractionContext.RT);
@@ -89,6 +84,10 @@ Object context
8984
BaseEntry previous = null;
9085
for (var i = 1; i < rows.Count; i++) {
9186
var cells = rows[i].Cells;
87+
if (cells.Key() == "") {
88+
continue;
89+
}
90+
9291
Type type;
9392
switch (cells.Type()) {
9493
case "event":
@@ -107,7 +106,7 @@ Object context
107106
type = typeof(FactEntry);
108107
break;
109108
default:
110-
Debug.LogError($"Unknown type {cells.Type()}", context);
109+
Debug.LogError($"Row {i + 1}: Unknown type {cells.Type()}", context);
111110
continue;
112111
}
113112

@@ -139,10 +138,15 @@ Object context
139138

140139
for (var i = 1; i < rows.Count; i++) {
141140
var cells = rows[i].Cells;
141+
if (cells.Key() == "") {
142+
previous = null;
143+
continue;
144+
}
145+
142146
try {
143147
switch (cells.Type()) {
144148
case "fact":
145-
previous = CreateFactEntry(cells, previous);
149+
CreateFactEntry(cells, previous);
146150
break;
147151
case "event":
148152
previous = CreateEventEntry(cells, previous);
@@ -242,6 +246,7 @@ BaseEntry previous
242246
throw new Exception($"Missing speaker {cells.Speaker()}.");
243247
}
244248

249+
/* TODO: Switch to localized strings later
245250
var textEntry = _collection.StringTables[0].GetEntry(entry.Key);
246251
long textId;
247252
if (textEntry == null) {
@@ -262,6 +267,8 @@ BaseEntry previous
262267
_collection.SharedData.TableCollectionName,
263268
textId
264269
);
270+
*/
271+
entry.Content = cells.Text();
265272

266273
if (cells.Actions() != "") {
267274
_events.Clear();
@@ -569,16 +576,15 @@ private static string GetErrorFrame(ParsingContext context) {
569576
}
570577

571578
private static string Key(this List<string> list) => list[0];
572-
private static string Type(this List<string> list) => list[1];
573-
private static string Speaker(this List<string> list) => list[2];
574-
private static bool Once(this List<string> list) => list[3] == "TRUE";
575-
576-
private static bool Cancel(this List<string> list) => list[4] == "TRUE";
577-
private static string Text(this List<string> list) => list[5];
578-
private static string Triggers(this List<string> list) => list[6];
579-
private static string Criteria(this List<string> list) => list[7];
580-
private static string Modifications(this List<string> list) => list[8];
581-
private static string Padding(this List<string> list) => list[9];
582-
private static string Actions(this List<string> list) => list[11];
579+
private static string Type(this List<string> list) => list[2];
580+
private static string Speaker(this List<string> list) => list[3];
581+
private static bool Once(this List<string> list) => list[4] == "TRUE";
582+
private static bool Cancel(this List<string> list) => list[5] == "TRUE";
583+
private static string Text(this List<string> list) => list[6];
584+
private static string Triggers(this List<string> list) => list[7];
585+
private static string Criteria(this List<string> list) => list[8];
586+
private static string Modifications(this List<string> list) => list[9];
587+
private static string Padding(this List<string> list) => list[10];
588+
private static string Actions(this List<string> list) => list[12];
583589
}
584590
}

Assets/Editor/Typewriter/CsvParser.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static IReadOnlyList<Row> Parse(string text) {
1616
var cells = new List<string>();
1717

1818
var isInsideField = false;
19+
var previousEmpty = false;
1920
_builder.Clear();
2021
_rows.Clear();
2122

@@ -36,9 +37,7 @@ public static IReadOnlyList<Row> Parse(string text) {
3637
break;
3738
case '\n' when !isInsideField:
3839
AddCell(cells);
39-
if (cells.Count > 0 && cells[0] != "") {
40-
_rows.Add(new Row { Cells = cells });
41-
}
40+
_rows.Add(new Row { Cells = cells });
4241
cells = new List<string>();
4342
break;
4443
default:

Assets/Editor/Typewriter/DialogueEntryDescriptor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Editor.Typewriter
55
{
66
[CustomEntryDescriptor(typeof(DialogueEntry))]
7-
public class DialogueEntryDescriptor : LocalizedRuleEntryDescriptor
7+
public class DialogueEntryDescriptor : RuleEntryDescriptor
88
{
99
public override string Name => "Dialogue";
1010
}

Assets/Environment/LookAtCamera.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using UnityEngine;
2+
using Utils;
3+
using View.Overlay;
4+
5+
namespace Environment {
6+
[DefaultExecutionOrder(1000)]
7+
public class LookAtCamera : MonoBehaviour {
8+
[Inject] [SerializeField] private OverlayChannel _overlay;
9+
10+
private void LateUpdate() {
11+
if (_overlay.IsReady) {
12+
transform.rotation =
13+
_overlay.CameraManager.MainCamera.transform.rotation;
14+
}
15+
}
16+
}
17+
}

Assets/Environment/LookAtCamera.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Environment/MainCamera.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

Assets/Environment/MainCamera.cs.meta

Lines changed: 0 additions & 3 deletions
This file was deleted.

Assets/Environment/Materials/BoxSDFUI.mat

Lines changed: 88 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Environment/Materials/BoxSDFUI.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Environment/Materials/BoxSDF.mat renamed to Assets/Environment/Materials/BoxSDFWorldSpace.mat

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)