void DrawMasterFileHeader()
        {
            EditorGUILayout.LabelField("Master File", EditorStyles.boldLabel);
            if (!InkSettings.Instance.compileAutomatically)
            {
                inkFile.compileAutomatically = EditorGUILayout.Toggle("Compile Automatially", inkFile.compileAutomatically);
                EditorApplication.RepaintProjectWindow();
            }
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.ObjectField("JSON Asset", inkFile.jsonAsset, typeof(TextAsset), false);
            EditorGUI.EndDisabledGroup();

            if (inkFile.jsonAsset != null && inkFile.metaInfo.errors.Count == 0 && GUILayout.Button("Play"))
            {
                InkPlayerWindow.LoadAndPlay(inkFile.jsonAsset);
            }

//				if(!checkedStoryForErrors) {
//					if(GUILayout.Button("Check for errors")) {
//						GetStoryErrors();
//					}
//				} else {
//					if(exception != null) {
//						EditorGUILayout.HelpBox("Story is invalid\n"+exception.ToString(), MessageType.Error);
//					} else {
//						EditorGUILayout.HelpBox("Story is valid", MessageType.Info);
//					}
//				}
        }
        /// <summary>
        /// Draws a property field for a story using GUI, allowing you to attach stories to the player window for debugging.
        /// </summary>
        /// <param name="position">Position.</param>
        /// <param name="story">Story.</param>
        /// <param name="label">Label.</param>
        public static void DrawStoryPropertyField(Rect position, Story story, GUIContent label)
        {
            position = EditorGUI.PrefixLabel(position, label);
            InkPlayerWindow window = InkPlayerWindow.GetWindow(false);

            if (EditorApplication.isPlaying && story != null /* && story.state != null*/)
            {
                if (window.attached && window.story == story)
                {
                    if (GUI.Button(position, "Detach"))
                    {
                        InkPlayerWindow.Detach();
                    }
                }
                else
                {
                    if (GUI.Button(position, "Attach"))
                    {
                        InkPlayerWindow.Attach(story);
                    }
                }
            }
            else
            {
                EditorGUI.BeginDisabledGroup(true);
                GUI.Button(position, "Enter play mode to attach to editor");
                EditorGUI.EndDisabledGroup();
            }
        }
Exemple #3
0
        public static void Detach()
        {
            InkPlayerWindow window = GetWindow();

            window.attached = false;
            window.story    = null;
        }
Exemple #4
0
        // Requires testing - would allow users to attach a run-time story to this window for testing purposes.
        public static InkPlayerWindow Attach(Story story)
        {
            InkPlayerWindow window = GetWindow();

            window.Clear();
            window.story    = story;
            window.attached = true;
            return(window);
        }
Exemple #5
0
        // Requires testing - would allow users to attach a run-time story to this window for testing purposes.
        public static InkPlayerWindow Attach(Story story)
        {
            InkPlayerWindow window = GetWindow();

            window.Clear();
            window.playerOptions.continueAutomatically = true;
            window.playerOptions.chooseAutomatically   = true;
            window.story    = story;
            window.attached = true;
            return(window);
        }
Exemple #6
0
        void DrawMasterFileHeader()
        {
            if (inkFile.isMaster)
            {
                EditorGUILayout.LabelField("Master File", EditorStyles.boldLabel);
            }
            if (!inkFile.isMaster)
            {
                EditorGUILayout.LabelField("Include treated as Master", EditorStyles.boldLabel);
            }
            if (!InkSettings.instance.compileAllFilesAutomatically)
            {
                EditorGUI.BeginChangeCheck();
                var newCompileAutomatically = EditorGUILayout.Toggle(new GUIContent("Compile Automatially", "If true, this file recompiles automatically when any changes are detected."), InkSettings.instance.ShouldCompileInkFileAutomatically(inkFile));
                if (EditorGUI.EndChangeCheck())
                {
                    if (newCompileAutomatically)
                    {
                        InkSettings.instance.filesToCompileAutomatically.Add(inkFile.inkAsset);
                        EditorUtility.SetDirty(InkSettings.instance);
                    }
                    else
                    {
                        InkSettings.instance.filesToCompileAutomatically.Remove(inkFile.inkAsset);
                        EditorUtility.SetDirty(InkSettings.instance);
                    }
                }
                EditorApplication.RepaintProjectWindow();
            }
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.ObjectField("JSON Asset", inkFile.jsonAsset, typeof(TextAsset), false);
            EditorGUI.EndDisabledGroup();

            if (inkFile.jsonAsset != null && inkFile.errors.Count == 0 && GUILayout.Button("Play"))
            {
                InkPlayerWindow.LoadAndPlay(inkFile.jsonAsset);
            }

//				if(!checkedStoryForErrors) {
//					if(GUILayout.Button("Check for errors")) {
//						GetStoryErrors();
//					}
//				} else {
//					if(exception != null) {
//						EditorGUILayout.HelpBox("Story is invalid\n"+exception.ToString(), MessageType.Error);
//					} else {
//						EditorGUILayout.HelpBox("Story is valid", MessageType.Info);
//					}
//				}
        }
 /// <summary>
 /// Draws a property field for a story using GUILayout, allowing you to attach stories to the player window for debugging.
 /// </summary>
 /// <param name="story">Story.</param>
 /// <param name="label">Label.</param>
 public static void DrawStoryPropertyField(Story story, GUIContent label)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.PrefixLabel(label);
     if (EditorApplication.isPlaying)
     {
         if (story != null)
         {
             if (InkPlayerWindow.isOpen)
             {
                 InkPlayerWindow window = InkPlayerWindow.GetWindow(false);
                 if (window.attached && window.story == story)
                 {
                     if (GUILayout.Button("Detach"))
                     {
                         InkPlayerWindow.Detach();
                     }
                 }
                 else
                 {
                     if (GUILayout.Button("Attach"))
                     {
                         InkPlayerWindow.Attach(story);
                     }
                 }
             }
             else
             {
                 if (GUILayout.Button("Open Player Window"))
                 {
                     InkPlayerWindow.GetWindow();
                 }
             }
         }
         else
         {
             EditorGUI.BeginDisabledGroup(true);
             GUILayout.Button("Story cannot be null to attach to editor");
             EditorGUI.EndDisabledGroup();
         }
     }
     else
     {
         EditorGUI.BeginDisabledGroup(true);
         GUILayout.Button("Enter play mode to attach to editor");
         EditorGUI.EndDisabledGroup();
     }
     EditorGUILayout.EndHorizontal();
 }
Exemple #8
0
        public static void LoadAndPlay(string storyJSON)
        {
            InkPlayerWindow window = GetWindow();

            if (window.story != null)
            {
                if (EditorUtility.DisplayDialog("Story in progress", "The Ink Player Window is already playing a story. Would you like to stop it and load the new story?", "Stop and load", "Cancel"))
                {
                    window.Stop();
                    window.Play(storyJSON);
                }
            }
            else
            {
                window.Play(storyJSON);
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            if (inkFile == null)
            {
                return;
            }

            InkFile masterInkFile = inkFile;

            if (inkFile.master == null)
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.ObjectField("JSON Asset", inkFile.jsonAsset, typeof(TextAsset), false);
                EditorGUI.EndDisabledGroup();

                if (GUILayout.Button("Play"))
                {
                    InkPlayerWindow.LoadAndPlay(inkFile.jsonAsset);
                }
                if (includesFileList != null)
                {
                    includesFileList.DoLayoutList();
                }
            }
            else
            {
                masterInkFile = inkFile.master;
                EditorGUILayout.HelpBox("This file is included by a master file.", MessageType.Info);
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.ObjectField("Master Ink File", masterInkFile.inkFile, typeof(Object), false);
                EditorGUI.EndDisabledGroup();
            }

            DateTime lastEditDate = File.GetLastWriteTime(inkFile.absoluteFilePath);

            EditorGUILayout.LabelField("Last edit date " + lastEditDate.ToString());

            if (masterInkFile.jsonAsset == null)
            {
                EditorGUILayout.HelpBox("Ink file has not been compiled", MessageType.Info);
                if (GUILayout.Button("Compile"))
                {
                    InkCompiler.CompileInk(masterInkFile);
                }
            }
            else
            {
                DateTime lastCompileDate = File.GetLastWriteTime(Path.Combine(Application.dataPath, AssetDatabase.GetAssetPath(masterInkFile.jsonAsset).Substring(7)));
                EditorGUILayout.LabelField("Last compile date " + lastCompileDate.ToString());

                if (lastEditDate > lastCompileDate && GUILayout.Button("Recompile"))
                {
                    InkCompiler.CompileInk(masterInkFile);
                }

                if (exception != null)
                {
                    EditorGUILayout.HelpBox("Story is invalid\n" + exception.ToString(), MessageType.Error);
                }
            }

            if (todosList != null)
            {
                todosList.DoLayoutList();
            }

            DrawFileContents();

            serializedObject.ApplyModifiedProperties();
        }