From 383761d34984928f3e601adb9abba44ffcac9b15 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Fri, 21 Aug 2015 10:06:10 +0100 Subject: [PATCH] Removed old dialog fade system Say tag help now comes from TextTagParser --- Assets/Fungus/Narrative/Editor/SayEditor.cs | 44 ++----------- .../Fungus/Narrative/Scripts/Commands/Say.cs | 29 ++------- Assets/Fungus/Narrative/Scripts/Dialog.cs | 65 +------------------ Assets/Fungus/Narrative/Scripts/MenuDialog.cs | 12 +--- 4 files changed, 11 insertions(+), 139 deletions(-) diff --git a/Assets/Fungus/Narrative/Editor/SayEditor.cs b/Assets/Fungus/Narrative/Editor/SayEditor.cs index 3ae884e9..273b50c9 100644 --- a/Assets/Fungus/Narrative/Editor/SayEditor.cs +++ b/Assets/Fungus/Narrative/Editor/SayEditor.cs @@ -16,34 +16,7 @@ namespace Fungus static public void DrawTagHelpLabel() { - string tagsText = ""; - tagsText += "\n"; - tagsText += "\t-------- DEFAULT TAGS --------\n\n" + - "\t{b} Bold Text {/b}\n" + - "\t{i} Italic Text {/i}\n" + - "\t{color=red} Color Text (color){/color}\n" + - "\n" + - "\t{s}, {s=60} Writing speed (chars per sec){/s}\n" + - "\t{w}, {w=0.5} Wait (seconds)\n" + - "\t{wi} Wait for input\n" + - "\t{wc} Wait for input and clear\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" + - "\n" + - "\t{vpunch=0.5} Vertically punch screen (intensity)\n" + - "\t{hpunch=0.5} Horizontally punch screen (intensity)\n" + - "\t{shake=1} Shake screen (intensity)\n" + - "\t{shiver=1} Shiver screen (intensity)\n" + - "\t{flash=0.5} Flash screen (duration)\n" + - "\n" + - "\t{audio=AudioObjectName} Play Audio Once\n" + - "\t{audioloop=AudioObjectName} Play Audio Loop\n" + - "\t{audiopause=AudioObjectName} Pause Audio\n" + - "\t{audiostop=AudioObjectName} Stop Audio\n" + - "\n" + - "\t{m=MessageName} Broadcast message\n" + - "\t{$VarName} Substitute variable"; + string tagsText = TextTagParser.GetTagHelp(); if (CustomTag.activeCustomTags.Count > 0) { @@ -105,8 +78,7 @@ namespace Fungus protected SerializedProperty showAlwaysProp; protected SerializedProperty showCountProp; protected SerializedProperty extendPreviousProp; - protected SerializedProperty fadeInProp; - protected SerializedProperty fadeOutProp; + protected SerializedProperty fadeWhenDoneProp; protected SerializedProperty waitForClickProp; protected SerializedProperty setSayDialogProp; @@ -123,8 +95,7 @@ namespace Fungus showAlwaysProp = serializedObject.FindProperty("showAlways"); showCountProp = serializedObject.FindProperty("showCount"); extendPreviousProp = serializedObject.FindProperty("extendPrevious"); - fadeInProp = serializedObject.FindProperty("fadeIn"); - fadeOutProp = serializedObject.FindProperty("fadeOut"); + fadeWhenDoneProp = serializedObject.FindProperty("fadeWhenDone"); waitForClickProp = serializedObject.FindProperty("waitForClick"); setSayDialogProp = serializedObject.FindProperty("setSayDialog"); @@ -217,14 +188,7 @@ namespace Fungus rightButton.fontSize = 10; rightButton.font = EditorStyles.toolbarButton.font; - EditorGUILayout.BeginHorizontal(); - - EditorGUILayout.PrefixLabel("Fade"); - t.fadeIn = GUILayout.Toggle(t.fadeIn, "In", leftButton, GUILayout.Width(60)); - t.fadeOut = GUILayout.Toggle(t.fadeOut, "Out", rightButton, GUILayout.Width(60)); - - EditorGUILayout.EndHorizontal(); - + EditorGUILayout.PropertyField(fadeWhenDoneProp); EditorGUILayout.PropertyField(waitForClickProp); EditorGUILayout.PropertyField(setSayDialogProp); diff --git a/Assets/Fungus/Narrative/Scripts/Commands/Say.cs b/Assets/Fungus/Narrative/Scripts/Commands/Say.cs index 4231438f..e1439171 100644 --- a/Assets/Fungus/Narrative/Scripts/Commands/Say.cs +++ b/Assets/Fungus/Narrative/Scripts/Commands/Say.cs @@ -36,13 +36,10 @@ namespace Fungus [Tooltip("Type this text in the previous dialog box.")] public bool extendPrevious = false; - [Tooltip("Fade in this dialog box.")] - public bool fadeIn = false; + [Tooltip("Fade out the dialog box when writing has finished and not waiting for input.")] + public bool fadeWhenDone = true; - [Tooltip("Fade out this dialog box.")] - public bool fadeOut = false; - - [Tooltip("Wait for player to click before hiding the dialog and continuing. If false then the dialog will display and execution will continue immediately.")] + [Tooltip("Wait for player to click before continuing.")] public bool waitForClick = true; [Tooltip("Sets the active Say dialog with a reference to a Say Dialog object in the scene. All story text will now display using this Say Dialog.")] @@ -78,18 +75,7 @@ namespace Fungus sayDialog.SetCharacter(character, flowchart); sayDialog.SetCharacterImage(portrait); - bool fadingIn = false; - if (sayDialog.alwaysFadeDialog || fadeIn) - { - sayDialog.FadeInDialog(); - fadingIn = true; - } - - if (!fadingIn) - { - // Show immediately - sayDialog.ShowDialog(true); - } + sayDialog.ShowDialog(true); string displayText = storyText; @@ -105,13 +91,6 @@ namespace Fungus string subbedText = flowchart.SubstituteVariables(displayText); sayDialog.Say(subbedText, !extendPrevious, waitForClick, voiceOverClip, delegate { - if (waitForClick) - { - if (sayDialog.alwaysFadeDialog || fadeOut) - { - sayDialog.FadeOutDialog(); - } - } Continue(); }); } diff --git a/Assets/Fungus/Narrative/Scripts/Dialog.cs b/Assets/Fungus/Narrative/Scripts/Dialog.cs index 57d8f101..040eb10a 100644 --- a/Assets/Fungus/Narrative/Scripts/Dialog.cs +++ b/Assets/Fungus/Narrative/Scripts/Dialog.cs @@ -14,9 +14,7 @@ namespace Fungus public DialogAudio audioController = new DialogAudio(); - public bool alwaysFadeDialog = false; public float fadeDuration = 1f; - public LeanTweenType fadeEaseType; public Canvas dialogCanvas; public Text nameText; @@ -32,16 +30,8 @@ namespace Fungus public virtual void ShowDialog(bool visible) { - if (dialogCanvas != null) - { - LeanTween.cancel(dialogCanvas.gameObject); - CanvasGroup canvasGroup = dialogCanvas.GetComponent(); - if (canvasGroup != null) - { - canvasGroup.alpha = 1; - } - dialogCanvas.gameObject.SetActive(visible); - } + gameObject.SetActive(true); + if (visible) { // A new dialog is often shown as the result of a mouse click, so we need @@ -50,57 +40,6 @@ namespace Fungus } } - public virtual void FadeInDialog() - { - LeanTween.cancel(dialogCanvas.gameObject); - CanvasGroup canvasGroup = dialogCanvas.GetComponent(); - if (canvasGroup != null) - { - canvasGroup.alpha = 0; - } - dialogCanvas.gameObject.SetActive(true); - - if (fadeDuration == 0) - { - fadeDuration = float.Epsilon; - } - - LeanTween.value(dialogCanvas.gameObject,0,1,fadeDuration).setEase(fadeEaseType).setOnUpdate( (float fadeAmount)=> { - if (canvasGroup != null) - { - canvasGroup.alpha = fadeAmount; - } - }).setOnComplete( ()=> { - if (canvasGroup != null) - { - canvasGroup.alpha = 1; - } - }); - } - - public virtual void FadeOutDialog() - { - CanvasGroup canvasGroup = dialogCanvas.GetComponent(); - LeanTween.cancel(dialogCanvas.gameObject); - if (fadeDuration == 0) - { - fadeDuration = float.Epsilon; - } - - LeanTween.value(dialogCanvas.gameObject,1,0,fadeDuration).setEase(fadeEaseType).setOnUpdate( (float fadeAmount)=> { - if (canvasGroup != null) - { - canvasGroup.alpha = fadeAmount; - } - }).setOnComplete( ()=> { - dialogCanvas.gameObject.SetActive(false); - if (canvasGroup != null) - { - canvasGroup.alpha = 1; - } - }); - } - public virtual void SetCharacter(Character character, Flowchart flowchart = null) { if (character == null) diff --git a/Assets/Fungus/Narrative/Scripts/MenuDialog.cs b/Assets/Fungus/Narrative/Scripts/MenuDialog.cs index 6c13f5dd..39d878bb 100644 --- a/Assets/Fungus/Narrative/Scripts/MenuDialog.cs +++ b/Assets/Fungus/Narrative/Scripts/MenuDialog.cs @@ -144,17 +144,7 @@ namespace Fungus SayDialog sayDialog = SayDialog.GetSayDialog(); if (sayDialog != null) { - bool fadingOut = false; - if (sayDialog.alwaysFadeDialog) - { - sayDialog.FadeOutDialog(); - fadingOut = true; - } - - if (!fadingOut) - { - sayDialog.ShowDialog(false); - } + sayDialog.ShowDialog(false); } }