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/
[Oo]bj/
[Bb]uild/
[Aa]ssets/FungusExamples/Tutorial
# Autogenerated VS/MD solution and project files
*.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("<Continue>"),
t.GetFungusScript());
base.DrawCommandGUI();
EditorGUILayout.PropertyField(hideOnSelectedProp, new GUIContent("Hide On Selected", "Hide this option forever once the player has selected it."));
serializedObject.ApplyModifiedProperties();
base.DrawCommandGUI();
}
}

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

@ -12,6 +12,8 @@ namespace Fungus
protected SerializedProperty nameTextProp;
protected SerializedProperty nameColorProp;
protected SerializedProperty sayDialogBoxProp;
protected SerializedProperty chooseDialogBoxProp;
protected SerializedProperty profileSpriteProp;
protected SerializedProperty soundEffectProp;
protected SerializedProperty notesProp;
@ -20,6 +22,8 @@ namespace Fungus
{
nameTextProp = serializedObject.FindProperty ("nameText");
nameColorProp = serializedObject.FindProperty ("nameColor");
sayDialogBoxProp = serializedObject.FindProperty ("sayDialogBox");
chooseDialogBoxProp = serializedObject.FindProperty ("chooseDialogBox");
profileSpriteProp = serializedObject.FindProperty ("profileSprite");
soundEffectProp = serializedObject.FindProperty ("soundEffect");
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(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(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.)"));
@ -56,7 +62,7 @@ namespace Fungus
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
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();
EditorGUILayout.EndHorizontal();

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

@ -32,7 +32,26 @@ namespace Fungus
{
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.PropertyField(chooseTextProp);
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
{
@ -45,9 +64,11 @@ namespace Fungus
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;
@ -58,30 +79,12 @@ namespace Fungus
Texture2D characterTexture = t.character.profileSprite.texture;
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.DrawPreview(previewRect, characterTexture);
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();
}
}

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

@ -53,8 +53,26 @@ namespace Fungus
{
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.PropertyField(storyTextProp);
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
{
showTagHelp = !showTagHelp;
@ -66,9 +84,17 @@ namespace Fungus
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;
@ -79,35 +105,12 @@ namespace Fungus
Texture2D characterTexture = t.character.profileSprite.texture;
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.DrawPreview(previewRect, characterTexture);
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();
}
}

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 Color nameColor = Color.white;
public SayDialog sayDialogBox;
public ChooseDialog chooseDialogBox;
public Sprite profileSprite;
public AudioClip soundEffect;

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

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

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

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

Loading…
Cancel
Save