Browse Source

Removed unused multiple choice commands

master
chrisgregan 10 years ago
parent
commit
a937698ba3
  1. 2
      Assets/Fungus/Dialog/Deprecated/AddOption.cs
  2. 4
      Assets/Fungus/Dialog/Deprecated/Choose.cs
  3. 139
      Assets/Fungus/Dialog/Deprecated/ChooseOption.cs
  4. 8
      Assets/Fungus/Dialog/Deprecated/ChooseOption.cs.meta
  5. 110
      Assets/Fungus/Dialog/Deprecated/Editor/ChooseOptionEditor.cs
  6. 8
      Assets/Fungus/Dialog/Deprecated/Editor/ChooseOptionEditor.cs.meta
  7. 45
      Assets/Fungus/Dialog/Deprecated/Editor/OptionEditor.cs
  8. 8
      Assets/Fungus/Dialog/Deprecated/Editor/OptionEditor.cs.meta
  9. 98
      Assets/Fungus/Dialog/Deprecated/Option.cs
  10. 8
      Assets/Fungus/Dialog/Deprecated/Option.cs.meta

2
Assets/Fungus/Dialog/Deprecated/AddOption.cs

@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
[CommandInfo("Dialog", [CommandInfo("Deprecated",
"Add Option", "Add Option",
"Obsolete: This command will be removed in a future update. Please use the Option command instead.", "Obsolete: This command will be removed in a future update. Please use the Option command instead.",
-1)] -1)]

4
Assets/Fungus/Dialog/Deprecated/Choose.cs

@ -5,9 +5,9 @@ using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
[CommandInfo("Dialog", [CommandInfo("Deprecated",
"Choose", "Choose",
"Obsolete: This command will be removed in a future update. Please use the Option command instead.", "Obsolete: This command will be removed in a future update. Please use the Menu command instead.",
-1)] -1)]
[AddComponentMenu("")] [AddComponentMenu("")]
public class Choose : Command public class Choose : Command

139
Assets/Fungus/Dialog/Deprecated/ChooseOption.cs

@ -1,139 +0,0 @@
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
[CommandInfo("Dialog",
"Choose",
"Presents a list of options for the player to choose from using a Choose Dialog. " +
"Place Option commands after the Choose Option command to specify the player options, and terminate with an End command.")]
[AddComponentMenu("")]
public class ChooseOption : Command
{
[Tooltip("Story text to display to prompt player to choose an option")]
[TextArea(5,10)]
public string chooseText = "";
[Tooltip("Speaking character to use when prompting the player to choose an option")]
public Character character;
[Tooltip("Choose Dialog object to use to display the player options")]
public ChooseDialog chooseDialog;
[Tooltip("Portrait that represents speaking character")]
public Sprite portrait;
[Tooltip("Voiceover audio to play when prompting the player to choose an option")]
public AudioClip voiceOverClip;
[Tooltip("Time limit for player to choose an option. Set to 0 for no time limit.")]
public float timeoutDuration;
public override void OnEnter()
{
if (chooseDialog == null)
{
if (chooseDialog == null)
{
// Try to get any ChooseDialog in the scene
chooseDialog = GameObject.FindObjectOfType<ChooseDialog>();
}
}
// Build list of Option commands
End endCommand = null;
List<Option> options = new List<Option>();
for (int i = commandIndex + 1; i < parentSequence.commandList.Count; ++i)
{
Command command = parentSequence.commandList[i];
// Check for closing End command
if (command.GetType() == typeof(End) &&
command.indentLevel == indentLevel)
{
endCommand = command as End;
// Jump to End if no dialog is set
if (chooseDialog == null)
{
Continue (endCommand.commandIndex + 1);
return;
}
break;
}
Option option = command as Option;
if (option != null &&
option.indentLevel == indentLevel &&
!option.IsHidden())
{
options.Add(command as Option);
}
}
if (options.Count == 0)
{
Continue();
}
else
{
FungusScript fungusScript = GetFungusScript();
chooseDialog.ShowDialog(true);
chooseDialog.SetCharacter(character, fungusScript);
chooseDialog.SetCharacterImage(portrait);
List<ChooseDialog.Option> dialogOptions = new List<ChooseDialog.Option>();
foreach (Option option in options)
{
ChooseDialog.Option dialogOption = new ChooseDialog.Option();
dialogOption.text = fungusScript.SubstituteVariables(option.optionText);
Option theOption = option; // Needed to close over the option object in the delegate
dialogOption.onSelect = delegate {
chooseDialog.ShowDialog(false);
theOption.wasSelected = true;
Continue(theOption.commandIndex + 1);
};
dialogOptions.Add(dialogOption);
}
options.Clear();
if (voiceOverClip != null)
{
chooseDialog.PlayVoiceOver(voiceOverClip);
}
string subbedText = fungusScript.SubstituteVariables(chooseText);
chooseDialog.Choose(subbedText, dialogOptions, timeoutDuration, delegate {
// Timeout will execute the commands listed immediately after the Choose Option command
chooseDialog.ShowDialog(false);
Continue();
});
}
}
public override bool OpenBlock()
{
return true;
}
public override string GetSummary()
{
return "\"" + chooseText + "\"";
}
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
}
}

8
Assets/Fungus/Dialog/Deprecated/ChooseOption.cs.meta

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 14d1bf29d0098422daf85e7bfd9896cc
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

110
Assets/Fungus/Dialog/Deprecated/Editor/ChooseOptionEditor.cs

@ -1,110 +0,0 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Rotorz.ReorderableList;
namespace Fungus
{
[CustomEditor (typeof(ChooseOption))]
public class ChooseOptionEditor : CommandEditor
{
static public bool showTagHelp;
protected SerializedProperty chooseTextProp;
protected SerializedProperty characterProp;
protected SerializedProperty chooseDialogProp;
protected SerializedProperty portraitProp;
protected SerializedProperty voiceOverClipProp;
protected SerializedProperty timeoutDurationProp;
protected virtual void OnEnable()
{
chooseTextProp = serializedObject.FindProperty("chooseText");
characterProp = serializedObject.FindProperty("character");
portraitProp = serializedObject.FindProperty("portrait");
chooseDialogProp = serializedObject.FindProperty("chooseDialog");
voiceOverClipProp = serializedObject.FindProperty("voiceOverClip");
timeoutDurationProp = serializedObject.FindProperty("timeoutDuration");
}
public override void DrawCommandGUI()
{
serializedObject.Update();
ChooseOption t = target as ChooseOption;
CommandEditor.ObjectField<Character>(characterProp,
new GUIContent("Character", "Character to display in dialog"),
new GUIContent("<None>"),
Character.activeCharacters);
CommandEditor.ObjectField<ChooseDialog>(chooseDialogProp,
new GUIContent("Choose Dialog", "Choose Dialog object to use to display the multiple player choices"),
new GUIContent("<Default>"),
ChooseDialog.activeDialogs);
bool showPortraits = false;
// Only show portrait selection if...
if (t.character != null && // Character is selected
t.character.portraits != null && // Character has a portraits field
t.character.portraits.Count > 0 ) // Selected Character has at least 1 portrait
{
showPortraits = true;
}
if (showPortraits)
{
CommandEditor.ObjectField<Sprite>(portraitProp,
new GUIContent("Portrait", "Portrait representing speaking character"),
new GUIContent("<None>"),
t.character.portraits);
}
else
{
t.portrait = null;
}
EditorGUILayout.PropertyField(chooseTextProp);
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
{
showTagHelp = !showTagHelp;
}
EditorGUILayout.EndHorizontal();
if (showTagHelp)
{
SayEditor.DrawTagHelpLabel();
}
EditorGUILayout.Separator();
EditorGUILayout.PropertyField(voiceOverClipProp, new GUIContent("Voice Over Clip", "Voice over audio to play when the choose text is displayed"));
EditorGUILayout.PropertyField(timeoutDurationProp, new GUIContent("Timeout Duration", "Time limit for player to make a choice. Set to 0 for no limit."));
/*
if (showPortraits && t.portrait != null)
{
Texture2D characterTexture = t.portrait.texture;
float aspect = (float)characterTexture.width / (float)characterTexture.height;
Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));
CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor;
characterEditor.DrawPreview(previewRect, characterTexture);
DestroyImmediate(characterEditor);
}
*/
serializedObject.ApplyModifiedProperties();
}
}
}

8
Assets/Fungus/Dialog/Deprecated/Editor/ChooseOptionEditor.cs.meta

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 92f79083287204bfcbfe02069f0ec4d2
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

45
Assets/Fungus/Dialog/Deprecated/Editor/OptionEditor.cs

@ -1,45 +0,0 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Rotorz.ReorderableList;
namespace Fungus
{
[CustomEditor (typeof(Option))]
public class OptionEditor : IfEditor
{
protected SerializedProperty optionTextProp;
protected SerializedProperty hideOnSelectedProp;
protected SerializedProperty hideOnConditionProp;
protected override void OnEnable()
{
base.OnEnable();
optionTextProp = serializedObject.FindProperty("optionText");
hideOnSelectedProp = serializedObject.FindProperty("hideOnSelected");
hideOnConditionProp = serializedObject.FindProperty("hideOnCondition");
}
public override void DrawCommandGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField(optionTextProp);
EditorGUILayout.PropertyField(hideOnSelectedProp);
EditorGUILayout.PropertyField(hideOnConditionProp);
serializedObject.ApplyModifiedProperties();
if (hideOnConditionProp.boolValue)
{
EditorGUI.indentLevel++;
base.DrawCommandGUI();
EditorGUI.indentLevel--;
}
}
}
}

8
Assets/Fungus/Dialog/Deprecated/Editor/OptionEditor.cs.meta

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 7d495a449ea3144118349a7c5d989c52
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

98
Assets/Fungus/Dialog/Deprecated/Option.cs

@ -1,98 +0,0 @@
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
[CommandInfo("Dialog",
"Option",
"Adds an option for the player to select. When the option is selected all commands in the following block are executed.")]
[AddComponentMenu("")]
public class Option : If
{
[Tooltip("Option text to display when presenting the option to the player")]
public string optionText = "";
[Tooltip("Hide this option once it has been selected so that it won't appear again even if executed again")]
public bool hideOnSelected;
[Tooltip("Hide if a variable condition evaluates to true.")]
public bool hideOnCondition;
[NonSerialized]
public bool wasSelected;
public virtual bool IsHidden()
{
if (hideOnSelected && wasSelected)
{
return true;
}
if (hideOnCondition)
{
// If no variable is selected then assume the option is visible
if (variable == null)
{
return true;
}
return EvaluateCondition();
}
return false;
}
public override void OnEnter()
{
// Find next End statement at same indent level
for (int i = commandIndex + 1; i < parentSequence.commandList.Count; ++i)
{
End endCommand = parentSequence.commandList[i] as End;
if (endCommand != null &&
endCommand.indentLevel == indentLevel)
{
// Continue at next command after End
Continue (endCommand.commandIndex + 1);
return;
}
}
Continue();
}
public override string GetSummary()
{
if (optionText == "")
{
return "Error: Option text is blank";
}
return optionText;
}
public override bool OpenBlock()
{
return true;
}
public override bool CloseBlock ()
{
return true;
}
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
public override void OnReset()
{
wasSelected = false;
}
}
}

8
Assets/Fungus/Dialog/Deprecated/Option.cs.meta

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: a5c5b93481b9848e593f07aca6b1f636
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
Loading…
Cancel
Save