Browse Source

Single line and multi-line StringData variants

master
chrisgregan 9 years ago
parent
commit
8286971205
  1. 2
      Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs
  2. 10
      Assets/Fungus/Flowchart/Editor/VariableEditor.cs
  3. 2
      Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs
  4. 2
      Assets/Fungus/Flowchart/Scripts/Commands/If.cs
  5. 2
      Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs
  6. 2
      Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs
  7. 52
      Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs
  8. 2
      Assets/Fungus/UI/Scripts/Commands/SetText.cs
  9. 2
      Assets/Fungus/UI/Scripts/Commands/Write.cs

2
Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs

@ -16,7 +16,7 @@
public Transform ParentTransform = null; public Transform ParentTransform = null;
[Tooltip("Settings string which describes the audio")] [Tooltip("Settings string which describes the audio")]
public StringData _SettingsString = new StringData(""); public StringDataMulti _SettingsString = new StringDataMulti("");
[Tooltip("Time to wait before executing the next command")] [Tooltip("Time to wait before executing the next command")]
public float waitDuration = 0; public float waitDuration = 0;

10
Assets/Fungus/Flowchart/Editor/VariableEditor.cs

@ -295,9 +295,13 @@ namespace Fungus
public class FloatDataDrawer : VariableDataDrawer<FloatVariable> public class FloatDataDrawer : VariableDataDrawer<FloatVariable>
{} {}
[CustomPropertyDrawer (typeof(StringData))] [CustomPropertyDrawer (typeof(StringData))]
public class StringDataDrawer : VariableDataDrawer<StringVariable> public class StringDataDrawer : VariableDataDrawer<StringVariable>
{} {}
[CustomPropertyDrawer (typeof(StringDataMulti))]
public class StringDataMultiDrawer : VariableDataDrawer<StringVariable>
{}
[CustomPropertyDrawer (typeof(ColorData))] [CustomPropertyDrawer (typeof(ColorData))]
public class ColorDataDrawer : VariableDataDrawer<ColorVariable> public class ColorDataDrawer : VariableDataDrawer<ColorVariable>

2
Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs

@ -20,7 +20,7 @@ namespace Fungus
public DebugLogType logType; public DebugLogType logType;
[Tooltip("Text to write to the debug log. Supports variable substitution, e.g. {$Myvar}")] [Tooltip("Text to write to the debug log. Supports variable substitution, e.g. {$Myvar}")]
public StringData logMessage; public StringDataMulti logMessage;
public override void OnEnter () public override void OnEnter ()
{ {

2
Assets/Fungus/Flowchart/Scripts/Commands/If.cs

@ -28,7 +28,7 @@ namespace Fungus
public FloatData floatData; public FloatData floatData;
[Tooltip("String value to compare against")] [Tooltip("String value to compare against")]
public StringData stringData; public StringDataMulti stringData;
public override void OnEnter() public override void OnEnter()
{ {

2
Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs

@ -56,7 +56,7 @@ namespace Fungus
public FloatEvent floatEvent = new FloatEvent(); public FloatEvent floatEvent = new FloatEvent();
[Tooltip("String parameter to pass to the invoked methods.")] [Tooltip("String parameter to pass to the invoked methods.")]
public StringData stringParameter; public StringDataMulti stringParameter;
[Tooltip("List of methods to call. Supports methods with one string parameter.")] [Tooltip("List of methods to call. Supports methods with one string parameter.")]
public StringEvent stringEvent = new StringEvent(); public StringEvent stringEvent = new StringEvent();

2
Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs

@ -39,7 +39,7 @@ namespace Fungus
public FloatData floatData; public FloatData floatData;
[Tooltip("String value to set with")] [Tooltip("String value to set with")]
public StringData stringData; public StringDataMulti stringData;
public override void OnEnter() public override void OnEnter()
{ {

52
Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs

@ -30,6 +30,11 @@ namespace Fungus
} }
} }
/// <summary>
/// Can contain a reference to a StringVariable or a string constant.
/// Appears as a single line property in the inspector.
/// For a multi-line property, use StringDataMulti.
/// </summary>
[System.Serializable] [System.Serializable]
public struct StringData public struct StringData
{ {
@ -37,7 +42,6 @@ namespace Fungus
[VariableProperty("<Value>", typeof(StringVariable))] [VariableProperty("<Value>", typeof(StringVariable))]
public StringVariable stringRef; public StringVariable stringRef;
[TextArea(1,10)]
[SerializeField] [SerializeField]
public string stringVal; public string stringVal;
@ -71,4 +75,50 @@ namespace Fungus
} }
} }
/// <summary>
/// Can contain a reference to a StringVariable or a string constant.
/// Appears as a multi-line property in the inspector.
/// For a single-line property, use StringData.
/// </summary>
[System.Serializable]
public struct StringDataMulti
{
[SerializeField]
[VariableProperty("<Value>", typeof(StringVariable))]
public StringVariable stringRef;
[TextArea(1,10)]
[SerializeField]
public string stringVal;
public StringDataMulti(string v)
{
stringVal = v;
stringRef = null;
}
public static implicit operator string(StringDataMulti spriteData)
{
return spriteData.Value;
}
public string Value
{
get { return (stringRef == null) ? stringVal : stringRef.value; }
set { if (stringRef == null) { stringVal = value; } else { stringRef.value = value; } }
}
public string GetDescription()
{
if (stringRef == null)
{
return stringVal;
}
else
{
return stringRef.key;
}
}
}
} }

2
Assets/Fungus/UI/Scripts/Commands/SetText.cs

@ -18,7 +18,7 @@ namespace Fungus
[Tooltip("String value to assign to the text object")] [Tooltip("String value to assign to the text object")]
[FormerlySerializedAs("stringData")] [FormerlySerializedAs("stringData")]
public StringData text; public StringDataMulti text;
[Tooltip("Notes about this story text for other authors, localization, etc.")] [Tooltip("Notes about this story text for other authors, localization, etc.")]
public string description; public string description;

2
Assets/Fungus/UI/Scripts/Commands/Write.cs

@ -17,7 +17,7 @@ namespace Fungus
public GameObject textObject; public GameObject textObject;
[Tooltip("String value to assign to the text object")] [Tooltip("String value to assign to the text object")]
public StringData text; public StringDataMulti text;
[Tooltip("Notes about this story text for other authors, localization, etc.")] [Tooltip("Notes about this story text for other authors, localization, etc.")]
public string description; public string description;

Loading…
Cancel
Save