Ejemplo n.º 1
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            Stage t = target as Stage;

            // Format Enum names
            string[] displayLabels = StringFormatter.formatEnumNames(t.display, "<None>");
            displayProp.enumValueIndex = EditorGUILayout.Popup("Display", (int)displayProp.enumValueIndex, displayLabels);

            string replaceLabel = "Portrait Stage";

            if (t.display == stageDisplayType.Swap)
            {
                CommandEditor.ObjectField <PortraitStage>(replacedPortraitStageProp,
                                                          new GUIContent("Replace", "Character to swap with"),
                                                          new GUIContent("<Default>"),
                                                          PortraitStage.activePortraitStages);
                replaceLabel = "With";
            }

            if (PortraitStage.activePortraitStages.Count > 1)
            {
                CommandEditor.ObjectField <PortraitStage>(portraitStageProp,
                                                          new GUIContent(replaceLabel, "Stage to display the character portraits on"),
                                                          new GUIContent("<Default>"),
                                                          PortraitStage.activePortraitStages);
            }

            bool          showOptionalFields = true;
            PortraitStage ps = t.portraitStage;

            // Only show optional portrait fields once required fields have been filled...
            if (t.portraitStage != null)                            // Character is selected
            {
                ps = t.GetFungusScript().defaultPortraitStage;;     // Try to get game's default portrait stage
                if (t.portraitStage == null)                        // If no default specified, try to get any portrait stage in the scene
                {
                    ps = GameObject.FindObjectOfType <PortraitStage>();
                }
                if (ps == null)
                {
                    EditorGUILayout.HelpBox("No portrait stage has been set. Please create a new portrait stage using [Game Object > Fungus > Portrait > Portrait Stage].", MessageType.Error);
                    showOptionalFields = false;
                }
            }
            if (t.display != stageDisplayType.NULL && showOptionalFields)
            {
                EditorGUILayout.PropertyField(useDefaultSettingsProp);
                if (!t.useDefaultSettings)
                {
                    EditorGUILayout.PropertyField(fadeDurationProp);
                }
                EditorGUILayout.PropertyField(waitUntilFinishedProp);
            }
            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 2
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            CommandEditor.ObjectField <ChooseDialog>(chooseDialogProp,
                                                     new GUIContent("Choose Dialog", "Dialog to use when displaying options with the Choose command."),
                                                     new GUIContent("<None>"),
                                                     ChooseDialog.activeDialogs);
            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 3
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            CommandEditor.ObjectField <SayDialog>(sayDialogProp,
                                                  new GUIContent("Say Dialog", "Dialog to use when displaying Say command story text"),
                                                  new GUIContent("<None>"),
                                                  SayDialog.activeDialogs);

            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 4
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
            {
                showTagHelp = !showTagHelp;
            }
            EditorGUILayout.EndHorizontal();

            if (showTagHelp)
            {
                DrawTagHelpLabel();
            }

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PropertyField(storyTextProp);

            Say t = target as Say;

            if (t.character != null &&
                t.character.profileSprite != null &&
                t.character.profileSprite.texture != null)
            {
                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));
                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);

            EditorGUILayout.PropertyField(voiceOverClipProp,
                                          new GUIContent("Voice Over Clip", "Voice over audio to play when the say text is displayed"));

            EditorGUILayout.PropertyField(showOnceProp, new GUIContent("Show Once", "Show this text once and never show it again."));

            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 5
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            Portrait t = target as Portrait;

            if (Stage.activeStages.Count > 1)
            {
                CommandEditor.ObjectField <Stage>(stageProp,
                                                  new GUIContent("Portrait Stage", "Stage to display the character portraits on"),
                                                  new GUIContent("<Default>"),
                                                  Stage.activeStages);
            }
            else
            {
                t.stage = null;
            }
            // Format Enum names
            string[] displayLabels = StringFormatter.FormatEnumNames(t.display, "<None>");
            displayProp.enumValueIndex = EditorGUILayout.Popup("Display", (int)displayProp.enumValueIndex, displayLabels);

            string characterLabel = "Character";

            if (t.display == DisplayType.Replace)
            {
                CommandEditor.ObjectField <Character>(replacedCharacterProp,
                                                      new GUIContent("Replace", "Character to replace"),
                                                      new GUIContent("<None>"),
                                                      Character.activeCharacters);
                characterLabel = "With";
            }

            CommandEditor.ObjectField <Character>(characterProp,
                                                  new GUIContent(characterLabel, "Character to display"),
                                                  new GUIContent("<None>"),
                                                  Character.activeCharacters);

            bool  showOptionalFields = true;
            Stage s = t.stage;

            // Only show optional portrait fields once required fields have been filled...
            if (t.character != null)                  // Character is selected
            {
                if (t.character.portraits == null ||  // Character has a portraits field
                    t.character.portraits.Count <= 0) // Character has at least one portrait
                {
                    EditorGUILayout.HelpBox("This character has no portraits. Please add portraits to the character's prefab before using this command.", MessageType.Error);
                    showOptionalFields = false;
                }
                if (t.stage == null)            // If default portrait stage selected
                {
                    if (t.stage == null)        // If no default specified, try to get any portrait stage in the scene
                    {
                        s = GameObject.FindObjectOfType <Stage>();
                    }
                }
                if (s == null)
                {
                    EditorGUILayout.HelpBox("No portrait stage has been set.", MessageType.Error);
                    showOptionalFields = false;
                }
            }
            if (t.display != DisplayType.None && t.character != null && showOptionalFields)
            {
                if (t.display != DisplayType.Hide && t.display != DisplayType.MoveToFront)
                {
                    // PORTRAIT
                    CommandEditor.ObjectField <Sprite>(portraitProp,
                                                       new GUIContent("Portrait", "Portrait representing character"),
                                                       new GUIContent("<Previous>"),
                                                       t.character.portraits);
                    if (t.character.portraitsFace != FacingDirection.None)
                    {
                        // FACING
                        // Display the values of the facing enum as <-- and --> arrows to avoid confusion with position field
                        string[] facingArrows = new string[]
                        {
                            "<Previous>",
                            "<--",
                            "-->",
                        };
                        facingProp.enumValueIndex = EditorGUILayout.Popup("Facing", (int)facingProp.enumValueIndex, facingArrows);
                    }
                    else
                    {
                        t.facing = FacingDirection.None;
                    }
                }
                else
                {
                    t.portrait = null;
                    t.facing   = FacingDirection.None;
                }
                string toPositionPrefix = "";
                if (t.move)
                {
                    // MOVE
                    EditorGUILayout.PropertyField(moveProp);
                }
                if (t.move)
                {
                    if (t.display != DisplayType.Hide)
                    {
                        // START FROM OFFSET
                        EditorGUILayout.PropertyField(shiftIntoPlaceProp);
                    }
                }
                if (t.move)
                {
                    if (t.display != DisplayType.Hide)
                    {
                        if (t.shiftIntoPlace)
                        {
                            t.fromPosition = null;
                            // OFFSET
                            // Format Enum names
                            string[] offsetLabels = StringFormatter.FormatEnumNames(t.offset, "<Previous>");
                            offsetProp.enumValueIndex = EditorGUILayout.Popup("From Offset", (int)offsetProp.enumValueIndex, offsetLabels);
                        }
                        else
                        {
                            t.offset = PositionOffset.None;
                            // FROM POSITION
                            CommandEditor.ObjectField <RectTransform>(fromPositionProp,
                                                                      new GUIContent("From Position", "Move the portrait to this position"),
                                                                      new GUIContent("<Previous>"),
                                                                      s.positions);
                        }
                    }
                    toPositionPrefix = "To ";
                }
                else
                {
                    t.shiftIntoPlace = false;
                    t.fromPosition   = null;
                    toPositionPrefix = "At ";
                }
                if (t.display == DisplayType.Show || (t.display == DisplayType.Hide && t.move))
                {
                    // TO POSITION
                    CommandEditor.ObjectField <RectTransform>(toPositionProp,
                                                              new GUIContent(toPositionPrefix + "Position", "Move the portrait to this position"),
                                                              new GUIContent("<Previous>"),
                                                              s.positions);
                }
                else
                {
                    t.toPosition = null;
                }
                if (!t.move && t.display != DisplayType.MoveToFront)
                {
                    // MOVE
                    EditorGUILayout.PropertyField(moveProp);
                }
                if (t.display != DisplayType.MoveToFront)
                {
                    EditorGUILayout.Separator();

                    // USE DEFAULT SETTINGS
                    EditorGUILayout.PropertyField(useDefaultSettingsProp);
                    if (!t.useDefaultSettings)
                    {
                        // FADE DURATION
                        EditorGUILayout.PropertyField(fadeDurationProp);
                        if (t.move)
                        {
                            // MOVE SPEED
                            EditorGUILayout.PropertyField(moveDurationProp);
                        }
                        if (t.shiftIntoPlace)
                        {
                            // SHIFT OFFSET
                            EditorGUILayout.PropertyField(shiftOffsetProp);
                        }
                    }
                }
                else
                {
                    t.move = false;
                    t.useDefaultSettings = true;
                    EditorGUILayout.Separator();
                }

                EditorGUILayout.PropertyField(waitUntilFinishedProp);


                if (t.portrait != null && t.display != DisplayType.Hide)
                {
                    Texture2D characterTexture = t.portrait.texture;

                    float aspect      = (float)characterTexture.width / (float)characterTexture.height;
                    Rect  previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));

                    if (characterTexture != null)
                    {
                        GUI.DrawTexture(previewRect, characterTexture, ScaleMode.ScaleToFit, true, aspect);
                    }
                }

                if (t.display != DisplayType.Hide)
                {
                    string portraitName = "<Previous>";
                    if (t.portrait != null)
                    {
                        portraitName = t.portrait.name;
                    }
                    string   portraitSummary = " " + portraitName;
                    int      toolbarInt      = 1;
                    string[] toolbarStrings  = { "<--", portraitSummary, "-->" };
                    toolbarInt = GUILayout.Toolbar(toolbarInt, toolbarStrings, GUILayout.MinHeight(20));
                    int portraitIndex = -1;

                    if (toolbarInt != 1)
                    {
                        for (int i = 0; i < t.character.portraits.Count; i++)
                        {
                            if (portraitName == t.character.portraits[i].name)
                            {
                                portraitIndex = i;
                            }
                        }
                    }

                    if (toolbarInt == 0)
                    {
                        if (portraitIndex > 0)
                        {
                            t.portrait = t.character.portraits[--portraitIndex];
                        }
                        else
                        {
                            t.portrait = null;
                        }
                    }
                    if (toolbarInt == 2)
                    {
                        if (portraitIndex < t.character.portraits.Count - 1)
                        {
                            t.portrait = t.character.portraits[++portraitIndex];
                        }
                    }
                }
            }
            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 6
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            ChooseOption t = target as ChooseOption;

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

            bool showPortraits = false;

            // Only show portrait selection if...
            if (t.character != null &&                            // Character is selected
                t.character.portraits != null &&                  // Character has a portraits field
                t.character.portraits.Count > 0)                  // Selected Character has at least 1 portrait
            {
                showPortraits = true;
            }

            if (showPortraits)
            {
                CommandEditor.ObjectField <Sprite>(portraitProp,
                                                   new GUIContent("Portrait", "Portrait representing speaking character"),
                                                   new GUIContent("<None>"),
                                                   t.character.portraits);
            }
            else
            {
                t.portrait = null;
            }

            EditorGUILayout.PropertyField(chooseTextProp);

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
            {
                showTagHelp = !showTagHelp;
            }
            EditorGUILayout.EndHorizontal();

            if (showTagHelp)
            {
                SayEditor.DrawTagHelpLabel();
            }

            EditorGUILayout.Separator();

            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."));

            if (showPortraits && t.portrait != null)
            {
                Texture2D characterTexture = t.portrait.texture;

                float aspect = (float)characterTexture.width / (float)characterTexture.height;

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

            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 7
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            bool showPortraits         = false;
            bool showNarratorPortraits = false;

            CommandEditor.ObjectField <Character>(characterProp,
                                                  new GUIContent("Character", "Character that is speaking"),
                                                  new GUIContent("<None>"),
                                                  Character.activeCharacters);

            Say t = target as Say;

            // Only show portrait selection if...
            if (t.character != null &&                          // Character is selected
                t.character.portraits != null &&                // Character has a portraits field
                t.character.portraits.Count > 0)                // Selected Character has at least 1 portrait
            {
                showPortraits = true;
            }
            else
            {
                //MIKE SHIT: ADDED SHOWING PORTRAIT DURING NARRATOR
                EditorGUILayout.PropertyField(showNarratorPortraitProp);
                if (showNarratorPortraitProp.boolValue)
                {
                    CommandEditor.ObjectField <Character>(narratorCharacterProp,
                                                          new GUIContent("Narrator Character", "Character shown while narrator speaks"),
                                                          new GUIContent("<None>"),
                                                          Character.activeCharacters);

                    // Only show portrait selection if...
                    if (t.narratorCharacter != null &&             // Character is selected
                        t.narratorCharacter.portraits != null &&   // Character has a portraits field
                        t.narratorCharacter.portraits.Count > 0)   // Selected Character has at least 1 portrait
                    {
                        showNarratorPortraits = true;
                    }

                    if (showNarratorPortraits)
                    {
                        CommandEditor.ObjectField <Sprite>(narratorPortraitProp,
                                                           new GUIContent("Narrator Portrait", "Portrait shown while narrator speaks"),
                                                           new GUIContent("<None>"),
                                                           t.narratorCharacter.portraits);
                    }
                    else
                    {
                        if (!t.extendPrevious)
                        {
                            t.portrait = null;
                        }
                    }
                }
            }

            if (showPortraits)
            {
                CommandEditor.ObjectField <Sprite>(portraitProp,
                                                   new GUIContent("Portrait", "Portrait representing speaking character"),
                                                   new GUIContent("<None>"),
                                                   t.character.portraits);
            }
            else
            {
                if (!t.extendPrevious)
                {
                    t.portrait = null;
                }
            }

            EditorGUILayout.PropertyField(storyTextProp);

            EditorGUILayout.PropertyField(descriptionProp);

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PropertyField(extendPreviousProp);

            GUILayout.FlexibleSpace();

            if (GUILayout.Button(new GUIContent("Tag Help", "View available tags"), new GUIStyle(EditorStyles.miniButton)))
            {
                showTagHelp = !showTagHelp;
            }
            EditorGUILayout.EndHorizontal();

            if (showTagHelp)
            {
                DrawTagHelpLabel();
            }

            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(voiceOverClipProp,
                                          new GUIContent("Voice Over Clip", "Voice over audio to play when the text is displayed"));

            EditorGUILayout.PropertyField(showAlwaysProp);

            if (showAlwaysProp.boolValue == false)
            {
                EditorGUILayout.PropertyField(showCountProp);
            }

            GUIStyle centeredLabel = new GUIStyle(EditorStyles.label);

            centeredLabel.alignment = TextAnchor.MiddleCenter;
            GUIStyle leftButton = new GUIStyle(EditorStyles.miniButtonLeft);

            leftButton.fontSize = 10;
            leftButton.font     = EditorStyles.toolbarButton.font;
            GUIStyle rightButton = new GUIStyle(EditorStyles.miniButtonRight);

            rightButton.fontSize = 10;
            rightButton.font     = EditorStyles.toolbarButton.font;

            EditorGUILayout.PropertyField(fadeWhenDoneProp);
            EditorGUILayout.PropertyField(waitForClickProp);
            EditorGUILayout.PropertyField(setSayDialogProp);

            if (showPortraits && t.portrait != null)
            {
                Texture2D characterTexture = t.portrait.texture;
                float     aspect           = (float)characterTexture.width / (float)characterTexture.height;
                Rect      previewRect      = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));
                if (characterTexture != null)
                {
                    GUI.DrawTexture(previewRect, characterTexture, ScaleMode.ScaleToFit, true, aspect);
                }
            }
            else
            {
                if (showNarratorPortraits && t.narratorPortrait != null)
                {
                    Texture2D characterTexture = t.narratorPortrait.texture;
                    float     aspect           = (float)characterTexture.width / (float)characterTexture.height;
                    Rect      previewRect      = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));
                    if (characterTexture != null)
                    {
                        GUI.DrawTexture(previewRect, characterTexture, ScaleMode.ScaleToFit, true, aspect);
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 8
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            Say       t  = target as Say;
            SayDialog sd = t.sayDialog;

            if (t.sayDialog == null)                   // If default box selected
            {
                sd = t.GetFungusScript().defaultSay;   // Try to get character's default say dialog box
                if (sd == null)                        // If no default specified, try to get any SayDialog in the scene
                {
                    sd = GameObject.FindObjectOfType <SayDialog>();
                }
            }

            bool showPortraits = false;

            CommandEditor.ObjectField <SayDialog>(sayDialogProp,
                                                  new GUIContent("Say Dialog", "Say Dialog object to use to display the story text"),
                                                  new GUIContent("<Default>"),
                                                  SayDialog.activeDialogs);
            if (sd != null && sd.nameText != null)
            {
                CommandEditor.ObjectField <Character>(characterProp,
                                                      new GUIContent("Character", "Character to display in dialog"),
                                                      new GUIContent("<None>"),
                                                      Character.activeCharacters);
            }
            else
            {
                t.character = null;
            }
            // Only show portrait selection if...
            if (t.character != null &&                          // Character is selected
                t.character.portraits != null &&                // Character has a portraits field
                t.character.portraits.Count > 0)                // Selected Character has at least 1 portrait
            {
                if (sd != null && sd.characterImage != null)    // Check that selected say dialog has a character image
                {
                    showPortraits = true;
                }
            }

            if (showPortraits)
            {
                CommandEditor.ObjectField <Sprite>(portraitProp,
                                                   new GUIContent("Portrait", "Portrait representing speaking character"),
                                                   new GUIContent("<None>"),
                                                   t.character.portraits);
            }
            else
            {
                if (!t.extendPrevious)
                {
                    t.portrait = null;
                }
            }

            EditorGUILayout.PropertyField(storyTextProp);

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PropertyField(extendPreviousProp);

            GUILayout.FlexibleSpace();

            if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
            {
                showTagHelp = !showTagHelp;
            }
            EditorGUILayout.EndHorizontal();

            if (showTagHelp)
            {
                DrawTagHelpLabel();
            }

            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(voiceOverClipProp,
                                          new GUIContent("Voice Over Clip", "Voice over audio to play when the say text is displayed"));
            EditorGUILayout.PropertyField(fadeInProp);
            EditorGUILayout.PropertyField(fadeOutProp);
            EditorGUILayout.PropertyField(showAlwaysProp);

            if (showAlwaysProp.boolValue == false)
            {
                EditorGUILayout.PropertyField(showCountProp);
            }

            if (showPortraits && t.portrait != null)
            {
                Texture2D characterTexture = t.portrait.texture;

                float aspect = (float)characterTexture.width / (float)characterTexture.height;

                Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));
                if (characterTexture != null)
                {
                    EditorGUI.DrawPreviewTexture(previewRect,
                                                 characterTexture,
                                                 spriteMaterial);
                }
            }

            serializedObject.ApplyModifiedProperties();
        }