Browse Source

Added command categories

master
chrisgregan 10 years ago
parent
commit
585efc2526
  1. 1
      Assets/Fungus/Audio/Commands/PlayMusic.cs
  2. 1
      Assets/Fungus/Audio/Commands/PlaySound.cs
  3. 1
      Assets/Fungus/Audio/Commands/SetMusicVolume.cs
  4. 1
      Assets/Fungus/Audio/Commands/StopMusic.cs
  5. 1
      Assets/Fungus/Camera/Commands/FadeToView.cs
  6. 1
      Assets/Fungus/Camera/Commands/MoveToView.cs
  7. 1
      Assets/Fungus/Dialog/Commands/AddOption.cs
  8. 1
      Assets/Fungus/Dialog/Commands/Say.cs
  9. 1
      Assets/Fungus/FungusScript/Commands/Call.cs
  10. 1
      Assets/Fungus/FungusScript/Commands/If.cs
  11. 1
      Assets/Fungus/FungusScript/Commands/LoadGlobals.cs
  12. 1
      Assets/Fungus/FungusScript/Commands/LoadScene.cs
  13. 1
      Assets/Fungus/FungusScript/Commands/SaveGlobals.cs
  14. 1
      Assets/Fungus/FungusScript/Commands/Set.cs
  15. 1
      Assets/Fungus/FungusScript/Commands/Wait.cs
  16. 1
      Assets/Fungus/FungusScript/Editor/CallEditor.cs
  17. 78
      Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs
  18. 3
      Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs
  19. 10
      Assets/Fungus/FungusScript/Scripts/FungusCommand.cs
  20. 3
      Assets/Fungus/FungusScript/Scripts/FungusScript.cs
  21. 1
      Assets/Fungus/Sprite/Commands/FadeSprite.cs
  22. BIN
      Assets/Shuttle/ShuttleGame.unity

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

@ -3,6 +3,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Audio")]
[CommandName("Play Music")]
[HelpText("Plays game music. If any game music is already playing, it is stopped. Music continues playing across scene loads.")]
public class PlayMusic : FungusCommand

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

@ -3,6 +3,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Audio")]
[CommandName("Play Sound")]
[HelpText("Plays a sound effect. Multiple sound effects can play at the same time.")]
public class PlaySound : FungusCommand

1
Assets/Fungus/Audio/Commands/SetMusicVolume.cs

@ -3,6 +3,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Audio")]
[CommandName("Set Music Volume")]
[HelpText("Sets the game music volume level.")]
public class SetMusicVolume : FungusCommand

1
Assets/Fungus/Audio/Commands/StopMusic.cs

@ -3,6 +3,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Audio")]
[CommandName("Stop Music")]
[HelpText("Stops the currently playing game music.")]
public class StopMusic : FungusCommand

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

@ -4,6 +4,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Camera")]
[CommandName("Fade To View")]
[HelpText("Fades the camera out and in again at a location specified by a View object.")]
public class FadeToView : FungusCommand

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

@ -4,6 +4,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Camera")]
[CommandName("Move To View")]
[HelpText("Moves the camera to a location specified by a View object.")]
public class MoveToView : FungusCommand

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

@ -4,6 +4,7 @@ using System.Collections.Generic;
namespace Fungus.Script
{
[CommandCategory("Dialog")]
[CommandName("Add Option")]
[HelpText("Adds an option button to be displayed by the next Say command. The target sequence is run when the player selects the option. A condition can be specified for when the option should be shown.")]
public class AddOption : FungusCommand

1
Assets/Fungus/Dialog/Commands/Say.cs

@ -5,6 +5,7 @@ using System.Collections.Generic;
namespace Fungus.Script
{
[CommandCategory("Dialog")]
[HelpText("Writes a line of story text to the dialog. A condition can be specified for when the story text should be shown.")]
public class Say : FungusCommand
{

1
Assets/Fungus/FungusScript/Commands/Call.cs

@ -4,6 +4,7 @@ using System.Collections.Generic;
namespace Fungus.Script
{
[CommandCategory("Scripting")]
[HelpText("Execute another sequence.")]
public class Call : FungusCommand
{

1
Assets/Fungus/FungusScript/Commands/If.cs

@ -14,6 +14,7 @@ namespace Fungus.Script
GreaterThanOrEquals // >=
}
[CommandCategory("Scripting")]
[HelpText("Execute another sequence IF a condition is true. Sequences can be specified for both true (THEN) and false (ELSE) conditions.")]
public class If : FungusCommand
{

1
Assets/Fungus/FungusScript/Commands/LoadGlobals.cs

@ -4,6 +4,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Scripting")]
[CommandName("Load Globals")]
[HelpText("Loads a set of global variables previously saved using the SaveGlobals command.")]
public class LoadGlobals : FungusCommand

1
Assets/Fungus/FungusScript/Commands/LoadScene.cs

@ -4,6 +4,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Scripting")]
[CommandName("Load Scene")]
[HelpText("Loads a new scene and displays an optional loading image. This is useful " +
"for splitting a large game across multiple scene files to reduce peak memory " +

1
Assets/Fungus/FungusScript/Commands/SaveGlobals.cs

@ -4,6 +4,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Scripting")]
[CommandName("Save Globals")]
[HelpText("Saves all current global variables to be loaded again later using the LoadGlobals command. This provides a basic save game system.")]
public class SaveGlobals : FungusCommand

1
Assets/Fungus/FungusScript/Commands/Set.cs

@ -3,6 +3,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Scripting")]
[HelpText("Sets a variable to a new value using simple arithmetic operations. The value can be a constant or another variable.")]
public class Set : FungusCommand
{

1
Assets/Fungus/FungusScript/Commands/Wait.cs

@ -4,6 +4,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Scripting")]
[HelpText("Waits for period of time before executing the next command in the sequence.")]
public class Wait : FungusCommand
{

1
Assets/Fungus/FungusScript/Editor/CallEditor.cs

@ -5,7 +5,6 @@ using System.Collections.Generic;
namespace Fungus.Script
{
[CustomEditor (typeof(Call))]
public class CallEditor : FungusCommandEditor
{

78
Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs

@ -95,9 +95,7 @@ namespace Fungus.Script
sequence.description = desc;
}
GUI.backgroundColor = Color.yellow;
GUILayout.Box("Commands", GUILayout.ExpandWidth(true));
GUI.backgroundColor = Color.white;
FungusCommand[] commands = sequence.GetComponents<FungusCommand>();
int index = 1;
@ -114,51 +112,89 @@ namespace Fungus.Script
EditorGUILayout.Separator();
GUI.backgroundColor = Color.yellow;
GUILayout.Box("New Command", GUILayout.ExpandWidth(true));
GUI.backgroundColor = Color.white;
List<string> categories = new List<string>();
// Build list of categories
List<System.Type> commandTypes = EditorExtensions.FindDerivedTypes(typeof(FungusCommand)).ToList();
if (commandTypes.Count == 0)
List<System.Type> subTypes = EditorExtensions.FindDerivedTypes(typeof(FungusCommand)).ToList();
foreach(System.Type type in subTypes)
{
return;
object[] attributes = type.GetCustomAttributes(false);
foreach (object obj in attributes)
{
CommandCategoryAttribute categoryAttr = obj as CommandCategoryAttribute;
if (categoryAttr != null)
{
if (!categories.Contains(categoryAttr.Category))
{
categories.Add(categoryAttr.Category);
}
}
}
}
categories.Sort();
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
int selectedCategoryIndex = EditorGUILayout.Popup(fungusScript.selectedCategoryIndex, categories.ToArray());
List<string> commandNames = new List<string>();
foreach(System.Type type in commandTypes)
List<System.Type> commandTypes = new List<System.Type>();
string categoryName = categories[selectedCategoryIndex];
foreach (System.Type type in subTypes)
{
commandNames.Add(GetCommandName(type));
object[] attributes = type.GetCustomAttributes(false);
foreach (object obj in attributes)
{
CommandCategoryAttribute categoryAttr = obj as CommandCategoryAttribute;
if (categoryAttr != null)
{
if (categoryAttr.Category == categoryName)
{
commandNames.Add(type.Name);
commandTypes.Add(type);
}
}
}
}
EditorGUI.BeginChangeCheck();
int selectedCommandIndex = EditorGUILayout.Popup(fungusScript.selectedCommandIndex, commandNames.ToArray());
int selectedCommandIndex = EditorGUILayout.Popup("Command", fungusScript.selectedCommandIndex, commandNames.ToArray());
if (selectedCategoryIndex != fungusScript.selectedCategoryIndex)
{
// Default to first item in list if category has changed
selectedCommandIndex = 0;
}
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(fungusScript, "Select Command");
fungusScript.selectedCategoryIndex = selectedCategoryIndex;
fungusScript.selectedCommandIndex = selectedCommandIndex;
}
System.Type selectedType = commandTypes[selectedCommandIndex];
if (selectedType == null)
if (fungusScript.selectedSequence == null ||
selectedType == null)
{
EditorGUILayout.EndHorizontal();
return;
}
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button(new GUIContent("Add Command", "Add the selected command to the sequence")))
if (GUILayout.Button(new GUIContent("Add", "Add the selected command to the sequence"), EditorStyles.miniButton))
{
Undo.AddComponent(sequence.gameObject, selectedType);
Undo.AddComponent(fungusScript.selectedSequence.gameObject, selectedType);
}
GUILayout.EndHorizontal();
EditorGUILayout.Separator();
EditorGUILayout.EndHorizontal();
object[] attributes = selectedType.GetCustomAttributes(typeof(HelpTextAttribute), false);
foreach (object obj in attributes)
object[] helpAttributes = selectedType.GetCustomAttributes(typeof(HelpTextAttribute), false);
foreach (object obj in helpAttributes)
{
HelpTextAttribute helpTextAttr = obj as HelpTextAttribute;
if (helpTextAttr != null)
@ -169,6 +205,8 @@ namespace Fungus.Script
break;
}
}
EditorGUILayout.Separator();
}
public void DrawVariablesGUI()

3
Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

@ -190,10 +190,7 @@ namespace Fungus.Script
EditorGUILayout.BeginVertical();
EditorGUILayout.Separator();
GUI.backgroundColor = Color.yellow;
GUILayout.Box("Sequence", GUILayout.ExpandWidth(true));
GUI.backgroundColor = Color.white;
GUILayout.BeginHorizontal();

10
Assets/Fungus/FungusScript/Scripts/FungusCommand.cs

@ -28,6 +28,16 @@ namespace Fungus.Script
public string HelpText { get; set; }
}
public class CommandCategoryAttribute : Attribute
{
public CommandCategoryAttribute(string categoryText)
{
this.Category = categoryText;
}
public string Category { get; set; }
}
[RequireComponent(typeof(Sequence))]
public class FungusCommand : MonoBehaviour
{

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

@ -15,6 +15,9 @@ namespace Fungus.Script
[System.NonSerialized]
public FungusCommand copyCommand;
[HideInInspector]
public int selectedCategoryIndex;
[HideInInspector]
public int selectedCommandIndex;

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

@ -4,6 +4,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandCategory("Sprite")]
[CommandName("Fade Sprite")]
[HelpText("Fades a sprite to a target color over a period of time.")]
public class FadeSprite : FungusCommand

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save