diff --git a/Assets/Fungus/Resources/Prefabs/SaveMenu.prefab b/Assets/Fungus/Resources/Prefabs/SaveMenu.prefab index 86c129fa..acd4e22b 100644 --- a/Assets/Fungus/Resources/Prefabs/SaveMenu.prefab +++ b/Assets/Fungus/Resources/Prefabs/SaveMenu.prefab @@ -1706,7 +1706,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 76befdada4ed8754db75aeb0b0d42976, type: 3} m_Name: m_EditorClassIdentifier: - showLog: 0 + showLog: 1 previousLines: 1 narrativeLogView: {fileID: 114162492929892552} narrativeLogMenuGroup: {fileID: 225545614455694522} diff --git a/Assets/Fungus/Scripts/Components/NarrativeLog.cs b/Assets/Fungus/Scripts/Components/NarrativeLog.cs index 1654480f..3c80ad0a 100644 --- a/Assets/Fungus/Scripts/Components/NarrativeLog.cs +++ b/Assets/Fungus/Scripts/Components/NarrativeLog.cs @@ -83,11 +83,14 @@ namespace Fungus /// Show previous lines for display purposes /// /// - public string GetPrettyHistory() + public string GetPrettyHistory(bool previousOnly = false) { string output = ""; + int count; - for (int i = 0; i < history.lines.Count; i++) + count = previousOnly ? history.lines.Count - 1: history.lines.Count; + + for (int i = 0; i < count; i++) { output += "" + history.lines[i].name + "\n"; output += history.lines[i].text + "\n\n"; diff --git a/Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs b/Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs index 83c36029..81e3ce40 100644 --- a/Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs +++ b/Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs @@ -76,6 +76,7 @@ namespace Fungus WriterSignals.OnWriterState += OnWriterState; SaveManagerSignals.OnSavePointLoaded += OnSavePointLoaded; SaveManagerSignals.OnSaveReset += OnSaveReset; + BlockSignals.OnBlockEnd += OnBlockEnd; } protected virtual void OnDisable() @@ -83,6 +84,7 @@ namespace Fungus WriterSignals.OnWriterState -= OnWriterState; SaveManagerSignals.OnSavePointLoaded -= OnSavePointLoaded; SaveManagerSignals.OnSaveReset -= OnSaveReset; + BlockSignals.OnBlockEnd -= OnBlockEnd; } protected virtual void OnWriterState(Writer writer, WriterState writerState) @@ -104,6 +106,15 @@ namespace Fungus UpdateNarrativeLogText(); } + protected virtual void OnBlockEnd (Block block) + { + // At block end update to get the last line of the block + bool defaultPreviousLines = previousLines; + previousLines = false; + UpdateNarrativeLogText(); + previousLines = defaultPreviousLines; + } + protected void UpdateNarrativeLogText() { if (narrativeLogView.enabled) @@ -112,7 +123,7 @@ namespace Fungus var historyText = narrativeLogView.GetComponentInChildren(); if (historyText != null) { - historyText.text = FungusManager.Instance.NarrativeLog.GetPrettyHistory(); + historyText.text = FungusManager.Instance.NarrativeLog.GetPrettyHistory(previousLines); } } } diff --git a/Assets/FungusExamples/Conversation/Say History.unity b/Assets/FungusExamples/Conversation/Say History.unity index dade3e8a..94796eb4 100644 --- a/Assets/FungusExamples/Conversation/Say History.unity +++ b/Assets/FungusExamples/Conversation/Say History.unity @@ -833,8 +833,10 @@ MonoBehaviour: y: -340 width: 1114 height: 859 - selectedBlocks: [] - selectedCommands: [] + selectedBlocks: + - {fileID: 775007736} + selectedCommands: + - {fileID: 775007739} variables: [] description: stepPause: 0 @@ -859,7 +861,7 @@ MonoBehaviour: m_EditorClassIdentifier: itemId: 1 indentLevel: 0 - storyText: Save 1 -- Hi I hope this shows up in history + storyText: After Save 1! description: character: {fileID: 1021439244} portrait: {fileID: 0} @@ -993,7 +995,7 @@ MonoBehaviour: m_EditorClassIdentifier: itemId: 6 indentLevel: 0 - storyText: Save 4 -- Hi I hope this shows up in history + storyText: After Save 4 description: character: {fileID: 1021439244} portrait: {fileID: 0} @@ -1018,7 +1020,7 @@ MonoBehaviour: m_EditorClassIdentifier: itemId: 8 indentLevel: 0 - storyText: Save 3 -- Hi I hope this shows up in history + storyText: After Save 3! description: character: {fileID: 1021439244} portrait: {fileID: 0} @@ -1043,7 +1045,7 @@ MonoBehaviour: m_EditorClassIdentifier: itemId: 10 indentLevel: 0 - storyText: Save 2 -- Hi I hope this shows up in history + storyText: After Save 2! description: character: {fileID: 1021439244} portrait: {fileID: 0} @@ -1130,10 +1132,9 @@ MonoBehaviour: indentLevel: 0 conversationText: stringRef: {fileID: 0} - stringVal: 'john: This is the conversation we''ve all been waiting for!!! Hold - on to your britches this is going to get crazy, kids!! + stringVal: 'john: After Save 5 - sherlock: You have fun with that, I''m going to go solve that murder now...' + john: Hope everyone enjoyed my listing of saves!' --- !u!1 &794363962 GameObject: m_ObjectHideFlags: 0 @@ -1616,7 +1617,7 @@ Prefab: - target: {fileID: 224000012150207008, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_AnchoredPosition.y - value: -15 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224000012150207008, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} @@ -1626,7 +1627,7 @@ Prefab: - target: {fileID: 224000012150207008, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_SizeDelta.y - value: 30 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224000013898185038, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} @@ -1646,7 +1647,7 @@ Prefab: - target: {fileID: 224000013898185038, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_AnchoredPosition.y - value: -15 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224000013898185038, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} @@ -1656,7 +1657,7 @@ Prefab: - target: {fileID: 224000013898185038, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_SizeDelta.y - value: 30 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224000012687811630, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} @@ -1676,7 +1677,7 @@ Prefab: - target: {fileID: 224000012687811630, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_AnchoredPosition.y - value: -15 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224000012687811630, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} @@ -1686,7 +1687,7 @@ Prefab: - target: {fileID: 224000012687811630, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_SizeDelta.y - value: 30 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224000012590701094, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} @@ -1706,7 +1707,7 @@ Prefab: - target: {fileID: 224000012590701094, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_AnchoredPosition.y - value: -15 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224000012590701094, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} @@ -1716,7 +1717,7 @@ Prefab: - target: {fileID: 224000012590701094, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_SizeDelta.y - value: 30 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224000013149320576, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} @@ -1736,7 +1737,7 @@ Prefab: - target: {fileID: 224000013149320576, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_AnchoredPosition.y - value: -15 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224000013149320576, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} @@ -1746,32 +1747,132 @@ Prefab: - target: {fileID: 224000013149320576, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_SizeDelta.y - value: 30 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224058802661620446, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_AnchorMin.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224058802661620446, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_AnchorMax.y - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224058802661620446, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_AnchoredPosition.x - value: 10 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224058802661620446, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_AnchoredPosition.y - value: -10 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224058802661620446, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} propertyPath: m_SizeDelta.x - value: 352 + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 224000013748593462, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchorMin.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 224000013748593462, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 224000013748593462, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchoredPosition.x + value: 37.5 + objectReference: {fileID: 0} + - target: {fileID: 224000013748593462, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_SizeDelta.x + value: 35 + objectReference: {fileID: 0} + - target: {fileID: 224000013748593462, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_SizeDelta.y + value: 30 + objectReference: {fileID: 0} + - target: {fileID: 224000012525218478, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchorMin.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 224000012525218478, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 224000012525218478, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchoredPosition.x + value: 909.05035 + objectReference: {fileID: 0} + - target: {fileID: 224147037515329490, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchorMin.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 224147037515329490, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 224147037515329490, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchoredPosition.x + value: 931.05035 + objectReference: {fileID: 0} + - target: {fileID: 224147037515329490, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 224148166873360954, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchorMax.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 224148166873360954, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 224148166873360954, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_SizeDelta.x + value: -17 + objectReference: {fileID: 0} + - target: {fileID: 224148166873360954, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_SizeDelta.y + value: -17 + objectReference: {fileID: 0} + - target: {fileID: 224673677253739666, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchorMax.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 224673677253739666, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_SizeDelta.x + value: -17 + objectReference: {fileID: 0} + - target: {fileID: 224900434480553846, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 224900434480553846, guid: bd2b99773f3e0489aae9f9b5053ad360, + type: 2} + propertyPath: m_SizeDelta.y + value: -17 objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2}