Browse Source

Integrated Say & Choose dialog pull request from lynxelia

[Tweaked the image sizes to avoid horizontal scroll bar appearing in
insepctor]
[Reverted changes to .gitignore file]
master
chrisgregan 10 years ago
parent
commit
ba8d7f430d
  1. 6
      Assets/Fungus/Dialog/Editor/AddOptionEditor.cs
  2. 8
      Assets/Fungus/Dialog/Editor/CharacterEditor.cs
  3. 43
      Assets/Fungus/Dialog/Editor/ChooseEditor.cs
  4. 55
      Assets/Fungus/Dialog/Editor/SayEditor.cs
  5. 2
      Assets/Fungus/Dialog/Scripts/Character.cs
  6. 9
      Assets/Fungus/Dialog/Scripts/Commands/Choose.cs
  7. 16
      Assets/Fungus/Dialog/Scripts/Commands/Say.cs

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

@ -36,11 +36,13 @@ namespace Fungus
new GUIContent("<Continue>"),
t.GetFungusScript());
EditorGUILayout.PropertyField(hideOnSelectedProp, new GUIContent("Hide On Selected", "Hide this option forever once the player has selected it."));
serializedObject.ApplyModifiedProperties();
base.DrawCommandGUI();
serializedObject.Update();
EditorGUILayout.PropertyField(hideOnSelectedProp, new GUIContent("Hide On Selected", "Hide this option forever once the player has selected it."));
serializedObject.ApplyModifiedProperties();
}
}

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();

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

@ -32,7 +32,24 @@ 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 +62,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 +77,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(100), 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(100), 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