Browse Source

Move Narrative Log maxCharacters closer to view

Add test to validate that a limit of 1000 characters does infact result in ... and then ~1000 characters.
master
Steve Halliwell 3 years ago
parent
commit
e5ac24f769
  1. 1
      Assets/Fungus/Docs/CHANGELOG.txt
  2. 7
      Assets/Fungus/Scripts/Components/NarrativeLog.cs
  3. 9
      Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs
  4. 2144
      Assets/Tests/NarrativeLogTooManyCharacters.unity
  5. 8
      Assets/Tests/NarrativeLogTooManyCharacters.unity.meta

1
Assets/Fungus/Docs/CHANGELOG.txt

@ -17,6 +17,7 @@ Unreleased
- Add special case that skips variation logic for sequences that contains no elements, making no change. - Add special case that skips variation logic for sequences that contains no elements, making no change.
- Add NotifyEnd to Writer WaitForInputAndClear logic. Thanks to wolfrug. - Add NotifyEnd to Writer WaitForInputAndClear logic. Thanks to wolfrug.
- Drag event handlers now only trigger from direct drags, not just movement. Thanks to CG-Tespy. - Drag event handlers now only trigger from direct drags, not just movement. Thanks to CG-Tespy.
- NarrativeLogMenu can limit the length of it's output, quick fix for narrative logs that would overflow the max ushort vert limit. Thanks to breadnone.
v3.13.6 v3.13.6
====== ======

7
Assets/Fungus/Scripts/Components/NarrativeLog.cs

@ -35,7 +35,6 @@ namespace Fungus
/// </summary> /// </summary>
public static event NarrativeAddedHandler OnNarrativeAdded; public static event NarrativeAddedHandler OnNarrativeAdded;
public delegate void NarrativeAddedHandler(NarrativeLogEntry data); public delegate void NarrativeAddedHandler(NarrativeLogEntry data);
public static int maxSize {get; set;} = 10000;
public static void DoNarrativeAdded(NarrativeLogEntry data) public static void DoNarrativeAdded(NarrativeLogEntry data)
{ {
if (OnNarrativeAdded != null) if (OnNarrativeAdded != null)
@ -141,12 +140,6 @@ namespace Fungus
output += "<b>" + history.entries[i].name + "</b>\n"; output += "<b>" + history.entries[i].name + "</b>\n";
output += history.entries[i].text + "\n\n"; output += history.entries[i].text + "\n\n";
} }
if (output.Length > maxSize)
{
output = "... " + output.Substring(output.Length - maxSize, maxSize);
}
return output; return output;
} }

9
Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs

@ -135,8 +135,13 @@ namespace Fungus
{ {
if (narrativeLogView.enabled) if (narrativeLogView.enabled)
{ {
NarrativeLog.maxSize = maxCharacters; var prettyHistory = FungusManager.Instance.NarrativeLog.GetPrettyHistory();
narLogViewtextAdapter.Text = FungusManager.Instance.NarrativeLog.GetPrettyHistory();
if (prettyHistory.Length > maxCharacters)
{
prettyHistory = "... " + prettyHistory.Substring(prettyHistory.Length - maxCharacters, maxCharacters);
}
narLogViewtextAdapter.Text = prettyHistory;
Canvas.ForceUpdateCanvases(); Canvas.ForceUpdateCanvases();
narrativeLogView.verticalNormalizedPosition = 0f; narrativeLogView.verticalNormalizedPosition = 0f;

2144
Assets/Tests/NarrativeLogTooManyCharacters.unity

File diff suppressed because it is too large Load Diff

8
Assets/Tests/NarrativeLogTooManyCharacters.unity.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ce31cac8076ecf846addda8bb51b85e5
timeCreated: 1487954686
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save