Browse Source

Removed old dialog fade system

Say tag help now comes from TextTagParser
master
chrisgregan 10 years ago
parent
commit
383761d349
  1. 44
      Assets/Fungus/Narrative/Editor/SayEditor.cs
  2. 27
      Assets/Fungus/Narrative/Scripts/Commands/Say.cs
  3. 65
      Assets/Fungus/Narrative/Scripts/Dialog.cs
  4. 10
      Assets/Fungus/Narrative/Scripts/MenuDialog.cs

44
Assets/Fungus/Narrative/Editor/SayEditor.cs

@ -16,34 +16,7 @@ namespace Fungus
static public void DrawTagHelpLabel() static public void DrawTagHelpLabel()
{ {
string tagsText = ""; string tagsText = TextTagParser.GetTagHelp();
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";
if (CustomTag.activeCustomTags.Count > 0) if (CustomTag.activeCustomTags.Count > 0)
{ {
@ -105,8 +78,7 @@ namespace Fungus
protected SerializedProperty showAlwaysProp; protected SerializedProperty showAlwaysProp;
protected SerializedProperty showCountProp; protected SerializedProperty showCountProp;
protected SerializedProperty extendPreviousProp; protected SerializedProperty extendPreviousProp;
protected SerializedProperty fadeInProp; protected SerializedProperty fadeWhenDoneProp;
protected SerializedProperty fadeOutProp;
protected SerializedProperty waitForClickProp; protected SerializedProperty waitForClickProp;
protected SerializedProperty setSayDialogProp; protected SerializedProperty setSayDialogProp;
@ -123,8 +95,7 @@ namespace Fungus
showAlwaysProp = serializedObject.FindProperty("showAlways"); showAlwaysProp = serializedObject.FindProperty("showAlways");
showCountProp = serializedObject.FindProperty("showCount"); showCountProp = serializedObject.FindProperty("showCount");
extendPreviousProp = serializedObject.FindProperty("extendPrevious"); extendPreviousProp = serializedObject.FindProperty("extendPrevious");
fadeInProp = serializedObject.FindProperty("fadeIn"); fadeWhenDoneProp = serializedObject.FindProperty("fadeWhenDone");
fadeOutProp = serializedObject.FindProperty("fadeOut");
waitForClickProp = serializedObject.FindProperty("waitForClick"); waitForClickProp = serializedObject.FindProperty("waitForClick");
setSayDialogProp = serializedObject.FindProperty("setSayDialog"); setSayDialogProp = serializedObject.FindProperty("setSayDialog");
@ -217,14 +188,7 @@ namespace Fungus
rightButton.fontSize = 10; rightButton.fontSize = 10;
rightButton.font = EditorStyles.toolbarButton.font; rightButton.font = EditorStyles.toolbarButton.font;
EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(fadeWhenDoneProp);
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(waitForClickProp); EditorGUILayout.PropertyField(waitForClickProp);
EditorGUILayout.PropertyField(setSayDialogProp); EditorGUILayout.PropertyField(setSayDialogProp);

27
Assets/Fungus/Narrative/Scripts/Commands/Say.cs

@ -36,13 +36,10 @@ namespace Fungus
[Tooltip("Type this text in the previous dialog box.")] [Tooltip("Type this text in the previous dialog box.")]
public bool extendPrevious = false; public bool extendPrevious = false;
[Tooltip("Fade in this dialog box.")] [Tooltip("Fade out the dialog box when writing has finished and not waiting for input.")]
public bool fadeIn = false; public bool fadeWhenDone = true;
[Tooltip("Fade out this dialog box.")] [Tooltip("Wait for player to click before continuing.")]
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.")]
public bool waitForClick = true; 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.")] [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.SetCharacter(character, flowchart);
sayDialog.SetCharacterImage(portrait); 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; string displayText = storyText;
@ -105,13 +91,6 @@ namespace Fungus
string subbedText = flowchart.SubstituteVariables(displayText); string subbedText = flowchart.SubstituteVariables(displayText);
sayDialog.Say(subbedText, !extendPrevious, waitForClick, voiceOverClip, delegate { sayDialog.Say(subbedText, !extendPrevious, waitForClick, voiceOverClip, delegate {
if (waitForClick)
{
if (sayDialog.alwaysFadeDialog || fadeOut)
{
sayDialog.FadeOutDialog();
}
}
Continue(); Continue();
}); });
} }

65
Assets/Fungus/Narrative/Scripts/Dialog.cs

@ -14,9 +14,7 @@ namespace Fungus
public DialogAudio audioController = new DialogAudio(); public DialogAudio audioController = new DialogAudio();
public bool alwaysFadeDialog = false;
public float fadeDuration = 1f; public float fadeDuration = 1f;
public LeanTweenType fadeEaseType;
public Canvas dialogCanvas; public Canvas dialogCanvas;
public Text nameText; public Text nameText;
@ -32,16 +30,8 @@ namespace Fungus
public virtual void ShowDialog(bool visible) public virtual void ShowDialog(bool visible)
{ {
if (dialogCanvas != null) gameObject.SetActive(true);
{
LeanTween.cancel(dialogCanvas.gameObject);
CanvasGroup canvasGroup = dialogCanvas.GetComponent<CanvasGroup>();
if (canvasGroup != null)
{
canvasGroup.alpha = 1;
}
dialogCanvas.gameObject.SetActive(visible);
}
if (visible) if (visible)
{ {
// A new dialog is often shown as the result of a mouse click, so we need // 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<CanvasGroup>();
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<CanvasGroup>();
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) public virtual void SetCharacter(Character character, Flowchart flowchart = null)
{ {
if (character == null) if (character == null)

10
Assets/Fungus/Narrative/Scripts/MenuDialog.cs

@ -143,20 +143,10 @@ namespace Fungus
{ {
SayDialog sayDialog = SayDialog.GetSayDialog(); SayDialog sayDialog = SayDialog.GetSayDialog();
if (sayDialog != null) if (sayDialog != null)
{
bool fadingOut = false;
if (sayDialog.alwaysFadeDialog)
{
sayDialog.FadeOutDialog();
fadingOut = true;
}
if (!fadingOut)
{ {
sayDialog.ShowDialog(false); sayDialog.ShowDialog(false);
} }
} }
}
public virtual void ShowTimer(float duration, Block targetBlock) public virtual void ShowTimer(float duration, Block targetBlock)
{ {

Loading…
Cancel
Save