Browse Source

Added say and choose dialog boxes to character prefab. Added character name prefix to Say command summary. Rearranged layout of Say,Choose,Option Editors.

master
Lynxelia 10 years ago
parent
commit
1e3133ea37
  1. 1
      .gitignore
  2. 3
      Assets/Fungus/Dialog/Editor/AddOptionEditor.cs
  3. 8
      Assets/Fungus/Dialog/Editor/CharacterEditor.cs
  4. 45
      Assets/Fungus/Dialog/Editor/ChooseEditor.cs
  5. 55
      Assets/Fungus/Dialog/Editor/SayEditor.cs
  6. 2
      Assets/Fungus/Dialog/Scripts/Character.cs
  7. 9
      Assets/Fungus/Dialog/Scripts/Commands/Choose.cs
  8. 16
      Assets/Fungus/Dialog/Scripts/Commands/Say.cs

1
.gitignore vendored

@ -2,6 +2,7 @@
[Tt]emp/ [Tt]emp/
[Oo]bj/ [Oo]bj/
[Bb]uild/ [Bb]uild/
[Aa]ssets/FungusExamples/Tutorial
# Autogenerated VS/MD solution and project files # Autogenerated VS/MD solution and project files
*.csproj *.csproj

3
Assets/Fungus/Dialog/Editor/AddOptionEditor.cs

@ -35,12 +35,13 @@ namespace Fungus
new GUIContent("Target Sequence", "Sequence to execute when this option is selected by the player."), new GUIContent("Target Sequence", "Sequence to execute when this option is selected by the player."),
new GUIContent("<Continue>"), new GUIContent("<Continue>"),
t.GetFungusScript()); t.GetFungusScript());
base.DrawCommandGUI();
EditorGUILayout.PropertyField(hideOnSelectedProp, new GUIContent("Hide On Selected", "Hide this option forever once the player has selected it.")); EditorGUILayout.PropertyField(hideOnSelectedProp, new GUIContent("Hide On Selected", "Hide this option forever once the player has selected it."));
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
base.DrawCommandGUI();
} }
} }

8
Assets/Fungus/Dialog/Editor/CharacterEditor.cs

@ -12,6 +12,8 @@ namespace Fungus
protected SerializedProperty nameTextProp; protected SerializedProperty nameTextProp;
protected SerializedProperty nameColorProp; protected SerializedProperty nameColorProp;
protected SerializedProperty sayDialogBoxProp;
protected SerializedProperty chooseDialogBoxProp;
protected SerializedProperty profileSpriteProp; protected SerializedProperty profileSpriteProp;
protected SerializedProperty soundEffectProp; protected SerializedProperty soundEffectProp;
protected SerializedProperty notesProp; protected SerializedProperty notesProp;
@ -20,6 +22,8 @@ namespace Fungus
{ {
nameTextProp = serializedObject.FindProperty ("nameText"); nameTextProp = serializedObject.FindProperty ("nameText");
nameColorProp = serializedObject.FindProperty ("nameColor"); nameColorProp = serializedObject.FindProperty ("nameColor");
sayDialogBoxProp = serializedObject.FindProperty ("sayDialogBox");
chooseDialogBoxProp = serializedObject.FindProperty ("chooseDialogBox");
profileSpriteProp = serializedObject.FindProperty ("profileSprite"); profileSpriteProp = serializedObject.FindProperty ("profileSprite");
soundEffectProp = serializedObject.FindProperty ("soundEffect"); soundEffectProp = serializedObject.FindProperty ("soundEffect");
notesProp = serializedObject.FindProperty ("notes"); notesProp = serializedObject.FindProperty ("notes");
@ -43,6 +47,8 @@ namespace Fungus
EditorGUILayout.PropertyField(nameTextProp, new GUIContent("Name Text", "Name of the character display in the dialog")); EditorGUILayout.PropertyField(nameTextProp, new GUIContent("Name Text", "Name of the character display in the dialog"));
EditorGUILayout.PropertyField(nameColorProp, new GUIContent("Name Color", "Color of name text display in the dialog")); EditorGUILayout.PropertyField(nameColorProp, new GUIContent("Name Color", "Color of name text display in the dialog"));
EditorGUILayout.PropertyField(sayDialogBoxProp, new GUIContent("Say Dialog", "Say dialog box this character should use"));
EditorGUILayout.PropertyField(chooseDialogBoxProp, new GUIContent("Choose Dialog", "Choose dialog box this character should use"));
EditorGUILayout.PropertyField(profileSpriteProp, new GUIContent("Image", "Character image sprite to display in the dialog")); EditorGUILayout.PropertyField(profileSpriteProp, new GUIContent("Image", "Character image sprite to display in the dialog"));
EditorGUILayout.PropertyField(soundEffectProp, new GUIContent("Sound Effect", "Sound to play when the character is talking. Overrides the setting in the Dialog.")); EditorGUILayout.PropertyField(soundEffectProp, new GUIContent("Sound Effect", "Sound to play when the character is talking. Overrides the setting in the Dialog."));
EditorGUILayout.PropertyField(notesProp, new GUIContent("Notes", "Notes about this story character (personality, attibutes, etc.)")); EditorGUILayout.PropertyField(notesProp, new GUIContent("Notes", "Notes about this story character (personality, attibutes, etc.)"));
@ -56,7 +62,7 @@ namespace Fungus
EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
float aspect = (float)t.profileSprite.texture.width / (float)t.profileSprite.texture.height; float aspect = (float)t.profileSprite.texture.width / (float)t.profileSprite.texture.height;
Rect imagePreviewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(150), GUILayout.ExpandWidth(false)); Rect imagePreviewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(250), GUILayout.ExpandWidth(true));
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal();

45
Assets/Fungus/Dialog/Editor/ChooseEditor.cs

@ -32,7 +32,26 @@ namespace Fungus
{ {
serializedObject.Update(); serializedObject.Update();
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);
EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(chooseTextProp);
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton))) if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
{ {
@ -45,9 +64,11 @@ namespace Fungus
SayEditor.DrawTagHelpLabel(); SayEditor.DrawTagHelpLabel();
} }
EditorGUILayout.BeginHorizontal(); EditorGUILayout.Separator();
EditorGUILayout.PropertyField(chooseTextProp); 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."));
Choose t = target as Choose; Choose t = target as Choose;
@ -58,30 +79,12 @@ namespace Fungus
Texture2D characterTexture = t.character.profileSprite.texture; Texture2D characterTexture = t.character.profileSprite.texture;
float aspect = (float)characterTexture.width / (float)characterTexture.height; float aspect = (float)characterTexture.width / (float)characterTexture.height;
Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(50), GUILayout.ExpandWidth(false)); Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(250), GUILayout.ExpandWidth(true));
CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor; CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor;
characterEditor.DrawPreview(previewRect, characterTexture); characterEditor.DrawPreview(previewRect, characterTexture);
DestroyImmediate(characterEditor); DestroyImmediate(characterEditor);
} }
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
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("<None>"),
ChooseDialog.activeDialogs);
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."));
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }
} }

55
Assets/Fungus/Dialog/Editor/SayEditor.cs

@ -53,8 +53,26 @@ namespace Fungus
{ {
serializedObject.Update(); serializedObject.Update();
CommandEditor.ObjectField<Character>(characterProp,
new GUIContent("Character", "Character to display in dialog"),
new GUIContent("<None>"),
Character.activeCharacters);
CommandEditor.ObjectField<SayDialog>(sayDialogProp,
new GUIContent("Say Dialog", "Say Dialog object to use to display the story text"),
new GUIContent("<Default>"),
SayDialog.activeDialogs);
EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(storyTextProp);
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton))) if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
{ {
showTagHelp = !showTagHelp; showTagHelp = !showTagHelp;
@ -66,9 +84,17 @@ namespace Fungus
DrawTagHelpLabel(); DrawTagHelpLabel();
} }
EditorGUILayout.BeginHorizontal(); EditorGUILayout.Separator();
EditorGUILayout.PropertyField(storyTextProp); EditorGUILayout.PropertyField(voiceOverClipProp,
new GUIContent("Voice Over Clip", "Voice over audio to play when the say text is displayed"));
EditorGUILayout.PropertyField(showAlwaysProp);
if (showAlwaysProp.boolValue == false)
{
EditorGUILayout.PropertyField(showCountProp);
}
Say t = target as Say; Say t = target as Say;
@ -79,35 +105,12 @@ namespace Fungus
Texture2D characterTexture = t.character.profileSprite.texture; Texture2D characterTexture = t.character.profileSprite.texture;
float aspect = (float)characterTexture.width / (float)characterTexture.height; float aspect = (float)characterTexture.width / (float)characterTexture.height;
Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(50), GUILayout.ExpandWidth(false)); Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(250), GUILayout.ExpandWidth(true));
CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor; CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor;
characterEditor.DrawPreview(previewRect, characterTexture); characterEditor.DrawPreview(previewRect, characterTexture);
DestroyImmediate(characterEditor); DestroyImmediate(characterEditor);
} }
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
CommandEditor.ObjectField<Character>(characterProp,
new GUIContent("Character", "Character to display in dialog"),
new GUIContent("<None>"),
Character.activeCharacters);
CommandEditor.ObjectField<SayDialog>(sayDialogProp,
new GUIContent("Say Dialog", "Say Dialog object to use to display the story text"),
new GUIContent("<None>"),
SayDialog.activeDialogs);
EditorGUILayout.PropertyField(voiceOverClipProp);
EditorGUILayout.PropertyField(showAlwaysProp);
if (showAlwaysProp.boolValue == false)
{
EditorGUILayout.PropertyField(showCountProp);
}
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }
} }

2
Assets/Fungus/Dialog/Scripts/Character.cs

@ -10,6 +10,8 @@ namespace Fungus
{ {
public string nameText; // We need a separate name as the object name is used for character variations (e.g. "Smurf Happy", "Smurf Sad") public string nameText; // We need a separate name as the object name is used for character variations (e.g. "Smurf Happy", "Smurf Sad")
public Color nameColor = Color.white; public Color nameColor = Color.white;
public SayDialog sayDialogBox;
public ChooseDialog chooseDialogBox;
public Sprite profileSprite; public Sprite profileSprite;
public AudioClip soundEffect; public AudioClip soundEffect;

9
Assets/Fungus/Dialog/Scripts/Commands/Choose.cs

@ -42,10 +42,19 @@ namespace Fungus
public override void OnEnter() public override void OnEnter()
{ {
showBasicGUI = false; showBasicGUI = false;
if (chooseDialog == null)
{
if ( character != null ) {
// Try to get character's choose box
chooseDialog = character.chooseDialogBox;
}
if (chooseDialog == null) if (chooseDialog == null)
{ {
// Try to get any SayDialog in the scene // Try to get any SayDialog in the scene
chooseDialog = GameObject.FindObjectOfType<ChooseDialog>(); chooseDialog = GameObject.FindObjectOfType<ChooseDialog>();
}
if (chooseDialog == null) if (chooseDialog == null)
{ {
showBasicGUI = true; showBasicGUI = true;

16
Assets/Fungus/Dialog/Scripts/Commands/Say.cs

@ -46,12 +46,21 @@ namespace Fungus
executionCount++; executionCount++;
showBasicGUI = false; showBasicGUI = false;
if (sayDialog == null)
{
if ( character != null ) {
// Try to get character's dialog box
sayDialog = character.sayDialogBox;
}
if (sayDialog == null) if (sayDialog == null)
{ {
// Try to get any SayDialog in the scene // Try to get any SayDialog in the scene
sayDialog = GameObject.FindObjectOfType<SayDialog>(); sayDialog = GameObject.FindObjectOfType<SayDialog>();
}
if (sayDialog == null) if (sayDialog == null)
{ {
// No custom dialog box exists, just use basic gui
showBasicGUI = true; showBasicGUI = true;
return; return;
} }
@ -77,7 +86,12 @@ namespace Fungus
public override string GetSummary() public override string GetSummary()
{ {
return "\"" + storyText + "\""; string namePrefix = "";
if (character != null)
{
namePrefix = character.nameText + ": ";
}
return namePrefix + "\"" + storyText + "\"";
} }
protected virtual void OnGUI() protected virtual void OnGUI()

Loading…
Cancel
Save