From 36600abe82ec5962704c5f4e776db5b311e6ef43 Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Sat, 7 Apr 2018 14:29:11 +1000 Subject: [PATCH] Conversation support for setting default clear, wait for input and fade options via command -support to change the defaults per line with say params -Conversation documentation updated --- .../Scripts/Utils/ConversationManager.cs | 47 ++++++++++++++++++- Assets/Fungus/Scripts/Utils/TextTagParser.cs | 1 + Docs/fungus_docs/conversation_system.md | 5 +- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Assets/Fungus/Scripts/Utils/ConversationManager.cs b/Assets/Fungus/Scripts/Utils/ConversationManager.cs index ef22d3e0..04d5209e 100644 --- a/Assets/Fungus/Scripts/Utils/ConversationManager.cs +++ b/Assets/Fungus/Scripts/Utils/ConversationManager.cs @@ -23,11 +23,24 @@ namespace Fungus public bool Hide { get; set; } public FacingDirection FacingDirection { get; set; } public bool Flip { get; set; } + public bool ClearPrev { get; set; } + public bool WaitForInput { get; set; } + public bool FadeDone { get; set; } } protected Character[] characters; protected bool exitSayWait; + public bool ClearPrev { get; set; } + public bool WaitForInput { get; set; } + public bool FadeDone { get; set; } + + public ConversationManager() + { + ClearPrev = true; + FadeDone = true; + WaitForInput = true; + } /// /// Splits the string passed in by the delimiters passed in. @@ -147,6 +160,9 @@ namespace Fungus protected virtual ConversationItem CreateConversationItem(string[] sayParams, string text, Character currentCharacter) { var item = new ConversationItem(); + item.ClearPrev = ClearPrev; + item.FadeDone = FadeDone; + item.WaitForInput = WaitForInput; // Populate the story text to be written item.Text = text; @@ -157,6 +173,35 @@ namespace Fungus return item; } + //TODO this needs a refactor + for (int i = 0; i < sayParams.Length; i++) + { + if (string.Compare(sayParams[i], "clear", true) == 0) + { + item.ClearPrev = true; + } + else if (string.Compare(sayParams[i], "noclear", true) == 0) + { + item.ClearPrev = false; + } + else if (string.Compare(sayParams[i], "fade", true) == 0) + { + item.FadeDone = true; + } + else if (string.Compare(sayParams[i], "nofade", true) == 0) + { + item.FadeDone = false; + } + else if (string.Compare(sayParams[i], "wait", true) == 0) + { + item.WaitForInput = true; + } + else if (string.Compare(sayParams[i], "nowait", true) == 0) + { + item.WaitForInput = false; + } + } + // try to find the character param first, since we need to get its portrait int characterIndex = -1; if (characters == null) @@ -380,7 +425,7 @@ namespace Fungus if (!string.IsNullOrEmpty(item.Text)) { exitSayWait = false; - sayDialog.Say(item.Text, true, true, true, true, false, null, () => { + sayDialog.Say(item.Text, item.ClearPrev, item.WaitForInput, item.FadeDone, true, false, null, () => { exitSayWait = true; }); diff --git a/Assets/Fungus/Scripts/Utils/TextTagParser.cs b/Assets/Fungus/Scripts/Utils/TextTagParser.cs index 6fb14a72..36b36451 100644 --- a/Assets/Fungus/Scripts/Utils/TextTagParser.cs +++ b/Assets/Fungus/Scripts/Utils/TextTagParser.cs @@ -209,6 +209,7 @@ namespace Fungus "\t{w}, {w=0.5} Wait (seconds)\n" + "\t{wi} Wait for input\n" + "\t{wc} Wait for input and clear\n" + + "\t{wvo} Wait for voice over line to complete\n" + "\t{wp}, {wp=0.5} Wait on punctuation (seconds){/wp}\n" + "\t{c} Clear\n" + "\t{x} Exit, advance to the next command without waiting for input\n" + diff --git a/Docs/fungus_docs/conversation_system.md b/Docs/fungus_docs/conversation_system.md index ae3befba..7ca80e5e 100644 --- a/Docs/fungus_docs/conversation_system.md +++ b/Docs/fungus_docs/conversation_system.md @@ -38,7 +38,7 @@ sherlock hide: The format for conversation text is: ```text -[character] [portrait] [position] [hide] [<<< | >>>]: [Dialogue text] +[character] [portrait] [position] [hide] [<<< | >>>] [clear | noclear] [wait | nowait] [fade | nofade]: [Dialogue text] ``` - character: The gameobject name or Name Text value of the speaking character. @@ -47,6 +47,9 @@ The format for conversation text is: - hide: Hides the character - <<<: Portrait face left - >>>: Portrait face right +- clear | noclear: override the ClearPreviousLine default with true on clear or with false with noclear +- wait | nowait: override the WaitForInput default with true on wait or with false with nowait +- fade | nofade: override the FadeDone default with true on fade or with false with nofade. This is rarely required as it only really makes a difference on the last say of the conversation anyway. Parameters go on the left of the colon and the dialogue text goes on the right. You can omit any parameter and specify them in any order. Parameters are separated by spaces. If you need to use a name which contains spaces, wrap it in quotation marks e.g. "John Watson". Parameters are case insensitive. Blank lines and comment lines starting with -- are ignored. A line of dialogue text on its own will be spoken by the most recent character. You can omit dialogue text, but remember you still need to add the : character at the end of the line.