Browse Source

Command error messages and enabled checkbox.

master
chrisgregan 10 years ago
parent
commit
efee8e808b
  1. 2
      Assets/Fungus/Audio/Commands/PlayMusic.cs
  2. 2
      Assets/Fungus/Audio/Commands/PlaySound.cs
  3. 2
      Assets/Fungus/Camera/Commands/FadeToView.cs
  4. 2
      Assets/Fungus/Camera/Commands/MoveToView.cs
  5. 6
      Assets/Fungus/Dialog/Commands/AddOption.cs
  6. 65
      Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs
  7. 2
      Assets/Fungus/FungusScript/Scripts/If.cs
  8. 7
      Assets/Fungus/FungusScript/Scripts/Sequence.cs
  9. 2
      Assets/Fungus/FungusScript/Scripts/Set.cs
  10. 12
      Assets/Fungus/Sprite/Commands/FadeSprite.cs
  11. BIN
      Assets/Shuttle/ShuttleGame.unity

2
Assets/Fungus/Audio/Commands/PlayMusic.cs

@ -24,7 +24,7 @@ namespace Fungus.Script
{ {
if (musicClip == null) if (musicClip == null)
{ {
return "No music clip selected"; return "Error: No music clip selected";
} }
return musicClip.name; return musicClip.name;

2
Assets/Fungus/Audio/Commands/PlaySound.cs

@ -27,7 +27,7 @@ namespace Fungus.Script
{ {
if (soundClip == null) if (soundClip == null)
{ {
return "No sound clip selected"; return "Error: No music clip selected";
} }
return soundClip.name; return soundClip.name;

2
Assets/Fungus/Camera/Commands/FadeToView.cs

@ -56,7 +56,7 @@ namespace Fungus.Script
{ {
if (targetView == null) if (targetView == null)
{ {
return "<no view selected>"; return "Error: No view selected";
} }
else else
{ {

2
Assets/Fungus/Camera/Commands/MoveToView.cs

@ -43,7 +43,7 @@ namespace Fungus.Script
{ {
if (targetView == null) if (targetView == null)
{ {
return "<no view selected>"; return "Error: No view selected";
} }
else else
{ {

6
Assets/Fungus/Dialog/Commands/AddOption.cs

@ -80,7 +80,11 @@ namespace Fungus.Script
public override string GetSummary() public override string GetSummary()
{ {
string description = "\"" + optionText + "\""; string description = "\"" + optionText + "\"";
if (targetSequence != null) if (targetSequence == null)
{
description += " <Continue>";
}
else
{ {
description += " (" + targetSequence.name + ")"; description += " (" + targetSequence.name + ")";
} }

65
Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs

@ -34,35 +34,67 @@ namespace Fungus.Script
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
if (t.expanded) bool error = false;
string summary = t.GetSummary().Replace("\n", "").Replace("\r", "");
if (summary.Length > 80)
{
summary = summary.Substring(0, 80) + "...";
}
if (summary.StartsWith("Error:"))
{
error = true;
}
if (!t.enabled)
{
GUI.backgroundColor = Color.grey;
}
else if (error)
{
GUI.backgroundColor = Color.red;
}
else if (t.expanded)
{ {
GUI.backgroundColor = Color.yellow; GUI.backgroundColor = Color.yellow;
} }
string commandName = FungusScriptEditor.GetCommandName(t.GetType()); string commandName = FungusScriptEditor.GetCommandName(t.GetType());
if (GUILayout.Button(commandName, EditorStyles.miniButton)) if (GUILayout.Button(commandName, EditorStyles.miniButton, GUILayout.MinWidth(80)))
{ {
Undo.RecordObject(t, "Toggle Expanded"); Undo.RecordObject(t, "Toggle Expanded");
t.expanded = !t.expanded; t.expanded = !t.expanded;
} }
GUI.backgroundColor = Color.white; GUI.backgroundColor = Color.white;
if (!t.expanded) GUIStyle labelStyle = new GUIStyle(EditorStyles.whiteMiniLabel);
labelStyle.wordWrap = true;
if (!t.enabled)
{ {
GUIStyle labelStyle = EditorStyles.miniLabel; labelStyle.normal.textColor = Color.grey;
labelStyle.wordWrap = true;
string summary = t.GetSummary().Replace("\n", "").Replace("\r", "");
if (summary.Length > 80)
{
summary = summary.Substring(0, 80) + "...";
}
GUILayout.Label(summary, labelStyle);
GUILayout.FlexibleSpace();
} }
else else if (error)
{ {
labelStyle.normal.textColor = Color.red;
}
GUILayout.Label(summary, labelStyle);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
if (t.expanded)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
bool enabled = GUILayout.Toggle(t.enabled, "");
if (t.enabled != enabled)
{
Undo.RecordObject(t, "Set Enabled");
t.enabled = enabled;
}
if (GUILayout.Button("Up", EditorStyles.miniButtonLeft)) if (GUILayout.Button("Up", EditorStyles.miniButtonLeft))
{ {
UnityEditorInternal.ComponentUtility.MoveComponentUp(t); UnityEditorInternal.ComponentUtility.MoveComponentUp(t);
@ -95,13 +127,8 @@ namespace Fungus.Script
Undo.DestroyObjectImmediate(t); Undo.DestroyObjectImmediate(t);
return; return;
} }
}
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
if (t.expanded)
{
//EditorGUILayout.Separator();
DrawCommandGUI(); DrawCommandGUI();

2
Assets/Fungus/FungusScript/Scripts/If.cs

@ -166,7 +166,7 @@ namespace Fungus.Script
{ {
if (variable == null) if (variable == null)
{ {
return "No variable selected"; return "Error: No variable selected";
} }
string summary = variable.key; string summary = variable.key;

7
Assets/Fungus/FungusScript/Scripts/Sequence.cs

@ -96,8 +96,11 @@ namespace Fungus.Script
} }
else if (executeNext) else if (executeNext)
{ {
nextCommand = command; if (command.enabled)
break; {
nextCommand = command;
break;
}
} }
} }

2
Assets/Fungus/FungusScript/Scripts/Set.cs

@ -123,7 +123,7 @@ namespace Fungus.Script
{ {
if (variable == null) if (variable == null)
{ {
return "<Variable not selected>"; return "Error: Variable not selected";
} }
string description = variable.key; string description = variable.key;

12
Assets/Fungus/Sprite/Commands/FadeSprite.cs

@ -8,8 +8,8 @@ namespace Fungus.Script
[HelpText("Fades a sprite to a target color over a period of time.")] [HelpText("Fades a sprite to a target color over a period of time.")]
public class FadeSprite : FungusCommand public class FadeSprite : FungusCommand
{ {
public float duration;
public SpriteRenderer spriteRenderer; public SpriteRenderer spriteRenderer;
public float duration;
public Color targetColor = Color.white; public Color targetColor = Color.white;
public bool waitUntilFinished = true; public bool waitUntilFinished = true;
@ -35,6 +35,16 @@ namespace Fungus.Script
Continue(); Continue();
} }
} }
public override string GetSummary()
{
if (spriteRenderer == null)
{
return "Error: No sprite renderer selected";
}
return spriteRenderer.name + " to " + targetColor.ToString();
}
} }
} }

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save