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. 57
      Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs
  7. 2
      Assets/Fungus/FungusScript/Scripts/If.cs
  8. 3
      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 + ")";
} }

57
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);
{
GUIStyle labelStyle = EditorStyles.miniLabel;
labelStyle.wordWrap = true; labelStyle.wordWrap = true;
string summary = t.GetSummary().Replace("\n", "").Replace("\r", ""); if (!t.enabled)
if (summary.Length > 80)
{ {
summary = summary.Substring(0, 80) + "..."; labelStyle.normal.textColor = Color.grey;
} }
else if (error)
{
labelStyle.normal.textColor = Color.red;
}
GUILayout.Label(summary, labelStyle); GUILayout.Label(summary, labelStyle);
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
}
else 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,14 +127,9 @@ namespace Fungus.Script
Undo.DestroyObjectImmediate(t); Undo.DestroyObjectImmediate(t);
return; return;
} }
}
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
if (t.expanded)
{
//EditorGUILayout.Separator();
DrawCommandGUI(); DrawCommandGUI();
EditorGUILayout.Separator(); EditorGUILayout.Separator();

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;

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

@ -95,11 +95,14 @@ namespace Fungus.Script
executeNext = true; executeNext = true;
} }
else if (executeNext) else if (executeNext)
{
if (command.enabled)
{ {
nextCommand = command; nextCommand = command;
break; break;
} }
} }
}
if (nextCommand == null) if (nextCommand == null)
{ {

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