diff --git a/Winch.Examples/ExampleItems/Assets/Characters/exampleitems.alex.json b/Winch.Examples/ExampleItems/Assets/Characters/exampleitems.alex.json
index b3c5c220..0adc0468 100644
--- a/Winch.Examples/ExampleItems/Assets/Characters/exampleitems.alex.json
+++ b/Winch.Examples/ExampleItems/Assets/Characters/exampleitems.alex.json
@@ -1,6 +1,6 @@
{
"speakerNameKey": "exampleitems.alex.name",
- "paralinguisticsNameKey": "TRAVELLING_MERCHANT_NAME_KEY",
+ "paralinguisticsNameKey": "TRAVELLING_MERCHANT",
"portraitSprite": "Alex",
"smallPortraitSprite": "AlexSmall"
}
\ No newline at end of file
diff --git a/Winch.Examples/ExampleItems/Assets/Characters/exampleitems.steve.json b/Winch.Examples/ExampleItems/Assets/Characters/exampleitems.steve.json
index c0465a85..028f59f7 100644
--- a/Winch.Examples/ExampleItems/Assets/Characters/exampleitems.steve.json
+++ b/Winch.Examples/ExampleItems/Assets/Characters/exampleitems.steve.json
@@ -1,6 +1,6 @@
{
"speakerNameKey": "exampleitems.steve.name",
- "paralinguisticsNameKey": "MAYOR_NAME_KEY",
+ "paralinguisticsNameKey": "MAYOR",
"portraitSprite": "Steve",
"smallPortraitSprite": "SteveSmall"
}
\ No newline at end of file
diff --git a/Winch.Examples/ExampleItems/Assets/Characters/exampleitems.test.json b/Winch.Examples/ExampleItems/Assets/Characters/exampleitems.test.json
new file mode 100644
index 00000000..d30ecf9c
--- /dev/null
+++ b/Winch.Examples/ExampleItems/Assets/Characters/exampleitems.test.json
@@ -0,0 +1,4 @@
+{
+ "speakerNameKey": "exampleitems.test.name",
+ "paralinguisticsNameKey": "COLLECTOR_REVEALED"
+}
\ No newline at end of file
diff --git a/Winch/Data/Character/AdvancedSpeakerData.cs b/Winch/Data/Character/AdvancedSpeakerData.cs
index 7f5806b3..0bed91f9 100644
--- a/Winch/Data/Character/AdvancedSpeakerData.cs
+++ b/Winch/Data/Character/AdvancedSpeakerData.cs
@@ -8,13 +8,22 @@ namespace Winch.Data.Character
{
public class AdvancedSpeakerData : SpeakerData
{
- public string id;
+ ///
+ /// The id of this speaker data
+ ///
+ public string id = string.Empty;
- public string paralinguisticsNameKey;
+ ///
+ /// The character you'd like to copy the paralinguistics from.
+ ///
+ public ParalinguisticsNameKey paralinguisticsNameKey = ParalinguisticsNameKey.NONE;
+ ///
+ /// The image of the character. This will show up when you are talking to them.
+ ///
public Sprite portraitSprite;
- public void AddPortraitPrefab()
+ public virtual void MakePortraitPrefab()
{
portraitPrefab = new GameObject($"{id} PortraitPrefab", typeof(RectTransform), typeof(Canvas), typeof(GraphicRaycaster), typeof(SpeakerPortraitAnimator)).Prefabitize();
portraitPrefab.layer = Layer.UI;
diff --git a/Winch/Data/Character/ParalinguisticsNameKey.cs b/Winch/Data/Character/ParalinguisticsNameKey.cs
new file mode 100644
index 00000000..d1d5bcd5
--- /dev/null
+++ b/Winch/Data/Character/ParalinguisticsNameKey.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Winch.Data.Character
+{
+ public enum ParalinguisticsNameKey
+ {
+ NONE,
+ FISHMONGER,
+ SHIPWRIGHT,
+ MAYOR,
+ DOCKWORKER,
+ COLLECTOR,
+ COLLECTOR_REVEALED,
+ TRADER,
+ BUILDER,
+ GRIEVING_FATHER,
+ LIGHTHOUSE_KEEPER,
+ INGFELL_RESIDENT,
+ CASTAWAY,
+ HOODED_FIGURE,
+ TRAVELLING_MERCHANT,
+ RETIRED_WHALER,
+ HERMIT,
+ RESEARCHER,
+ SOLDIER,
+ OLD_MAYOR,
+ FANATIC,
+ COURIER,
+ PLAYER,
+ PHOTOGRAPHER,
+ PAINTER,
+ SOUL
+ }
+}
diff --git a/Winch/Serialization/Character/AdvancedSpeakerDataConverter.cs b/Winch/Serialization/Character/AdvancedSpeakerDataConverter.cs
index 8a45df67..560b2493 100644
--- a/Winch/Serialization/Character/AdvancedSpeakerDataConverter.cs
+++ b/Winch/Serialization/Character/AdvancedSpeakerDataConverter.cs
@@ -3,6 +3,7 @@
using UnityEngine;
using UnityEngine.Localization;
using Winch.Core;
+using Winch.Data.Character;
using Winch.Util;
namespace Winch.Serialization.Character;
@@ -12,7 +13,7 @@ public class AdvancedSpeakerDataConverter : SpeakerDataConverter
private readonly Dictionary _definitions = new()
{
{ "id", new(null, null) },
- { "paralinguisticsNameKey", new(null, null) },
+ { "paralinguisticsNameKey", new(ParalinguisticsNameKey.NONE, o=> DredgeTypeHelpers.GetEnumValue(o)) },
{ "portraitSprite", new(TextureUtil.GetSprite("EmptyPortrait"), o=> TextureUtil.GetSprite(o.ToString())) },
};
diff --git a/Winch/Serialization/Character/SpeakerDataConverter.cs b/Winch/Serialization/Character/SpeakerDataConverter.cs
index 37e3b0e5..f9c9c957 100644
--- a/Winch/Serialization/Character/SpeakerDataConverter.cs
+++ b/Winch/Serialization/Character/SpeakerDataConverter.cs
@@ -1,6 +1,7 @@
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using UnityEngine;
+using UnityEngine.AddressableAssets;
using UnityEngine.Localization;
using UnityEngine.UI;
using Winch.Core;
@@ -25,6 +26,7 @@ public class SpeakerDataConverter : DredgeTypeConverter
{ "speakerNameKeyOverrides", new(new List(), null) },
{ "portraitOverrideConditions", new(new List(), null) },
{ "highlightConditions", new(new List(), null) },
+ { "paralinguistics", new(new Dictionary>(), null) },
{ "paralinguisticOverrideConditions", new(new List(), null) }
};
diff --git a/Winch/Util/CharacterUtil.cs b/Winch/Util/CharacterUtil.cs
index 69cdcde2..7d49d04e 100644
--- a/Winch/Util/CharacterUtil.cs
+++ b/Winch/Util/CharacterUtil.cs
@@ -35,9 +35,9 @@ public static void AddModdedSpeakerData(IDictionary lookupT
{
foreach (var speaker in ModdedSpeakerDataDict.Values)
{
- if (lookupTable.TryGetValue(speaker.paralinguisticsNameKey, out SpeakerData data))
+ if (lookupTable.TryGetParalinguisticsFromNameKey(speaker.paralinguisticsNameKey, out var paralinguistics))
{
- speaker.paralinguistics = data.paralinguistics;
+ speaker.paralinguistics = paralinguistics;
}
lookupTable.Add(speaker.id, speaker);
}
@@ -83,7 +83,7 @@ internal static void AddCharacterFromMeta(string metaPath)
if (PopulateSpeakerDataFromMetaWithConverter(speaker, meta))
{
ModdedSpeakerDataDict.Add(id, speaker);
- speaker.AddPortraitPrefab();
+ speaker.MakePortraitPrefab();
}
else
{
diff --git a/Winch/Util/WinchExtensions.cs b/Winch/Util/WinchExtensions.cs
index f95e26d2..67e6417b 100644
--- a/Winch/Util/WinchExtensions.cs
+++ b/Winch/Util/WinchExtensions.cs
@@ -8,10 +8,12 @@
using System.Reflection;
using System.Text.RegularExpressions;
using UnityEngine;
+using UnityEngine.AddressableAssets;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.ResourceManagement.AsyncOperations;
using Winch.Core;
+using Winch.Data.Character;
using Winch.Data.Item;
public static class WinchExtensions
@@ -95,6 +97,38 @@ public static void ShowNotificationWithItemName(this UIController UI, Notificati
}
};
}
+
+ public static bool TryGetParalinguisticsFromNameKey(this IDictionary lookupTable, ParalinguisticsNameKey nameKey, out Dictionary> paralinguistics)
+ {
+ var stringNameKey = nameKey.ToString();
+ switch (nameKey)
+ {
+ case ParalinguisticsNameKey.NONE:
+ break;
+ case ParalinguisticsNameKey.COLLECTOR_REVEALED:
+ if (lookupTable.TryGetValue("COLLECTOR_NAME_KEY", out SpeakerData collectorData))
+ {
+ paralinguistics = collectorData.paralinguisticOverrideConditions.First().config.paralinguistics;
+ return true;
+ }
+ break;
+ case ParalinguisticsNameKey.HOODED_FIGURE:
+ stringNameKey += "_1";
+ goto default;
+ case ParalinguisticsNameKey.SOUL:
+ stringNameKey += "_MIDDLE";
+ goto default;
+ default:
+ if (lookupTable.TryGetValue(stringNameKey + "_NAME_KEY", out SpeakerData data))
+ {
+ paralinguistics = data.paralinguistics;
+ return true;
+ }
+ break;
+ }
+ paralinguistics = null;
+ return false;
+ }
#endregion
#region Reflection