public ActionType(ActionType _actionType)
 {
     fileName = _actionType.fileName;
     category = _actionType.category;
     title = _actionType.title;
     description = _actionType.description;
     isEnabled = _actionType.isEnabled;
     color = _actionType.color;
 }
 public bool IsMatch(ActionType _actionType)
 {
     if (description == _actionType.description && title == _actionType.title && category == _actionType.category)
     {
         return true;
     }
     return false;
 }
        private void SearchSceneForType(string sceneFile, ActionType actionType)
        {
            string sceneLabel = "";

            if (sceneFile != "")
            {
                sceneLabel = "(Scene: " + sceneFile + ") ";
                if (EditorApplication.currentScene != sceneFile)
                {
                    EditorApplication.OpenScene (sceneFile);
                }
            }

            // Speech lines and journal entries
            ActionList[] actionLists = GameObject.FindObjectsOfType (typeof (ActionList)) as ActionList[];
            foreach (ActionList list in actionLists)
            {
                int numFinds = SearchActionsForType (list.GetActions (), actionType);
                if (numFinds > 0)
                {
                    ACDebug.Log (sceneLabel + " Found " + numFinds + " instances in '" + list.gameObject.name + "'");
                }
            }
        }
        public void ShowGUI()
        {
            EditorGUILayout.BeginVertical ("Button");
            GUILayout.Label ("Actionlist editing settings", EditorStyles.boldLabel);
            displayActionsInInspector = EditorGUILayout.ToggleLeft ("List Actions in Inspector window?", displayActionsInInspector);
            displayActionsInEditor = (DisplayActionsInEditor) EditorGUILayout.EnumPopup ("Actions in Editor are:", displayActionsInEditor);
            actionListEditorScrollWheel = (ActionListEditorScrollWheel) EditorGUILayout.EnumPopup ("Using scroll-wheel:", actionListEditorScrollWheel);
            invertPanning = EditorGUILayout.ToggleLeft ("Invert panning in ActionList Editor?", invertPanning);
            allowMultipleActionListWindows = EditorGUILayout.ToggleLeft ("Allow multiple ActionList Editor windows?", allowMultipleActionListWindows);
            EditorGUILayout.EndVertical ();
            EditorGUILayout.Space ();

            EditorGUILayout.BeginVertical ("Button");
            GUILayout.Label ("Custom Action scripts", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal ();
            GUILayout.Label ("Folder to search:", GUILayout.Width (110f));
            GUILayout.Label (customFolderPath, EditorStyles.textField);
            GUILayout.EndHorizontal ();
            GUILayout.BeginHorizontal ();
            if (GUILayout.Button ("Set directory"))
            {
                string path = EditorUtility.OpenFolderPanel("Set custom Actions directory", "Assets", "");
                string dataPath = Application.dataPath;
                if (path.Contains (dataPath))
                {
                    if (path == dataPath)
                    {
                        customFolderPath = "";
                    }
                    else
                    {
                        customFolderPath = path.Replace (dataPath + "/", "");
                    }
                }
                else
                {
                    ACDebug.LogError ("Cannot set new directory - be sure to select within the Assets directory.");
                }
            }
            GUILayout.EndHorizontal ();
            EditorGUILayout.EndVertical ();

            if (AllActions.Count > 0)
            {
                GUILayout.Space (10);

                foreach (ActionType subclass in AllActions)
                {
                    int enabledIndex = -1;
                    if (EnabledActions.Contains (subclass))
                    {
                        enabledIndex = EnabledActions.IndexOf (subclass);
                    }

                    if (selectedClass != null && subclass.category == selectedClass.category && subclass.title == selectedClass.title)
                    {
                        EditorGUILayout.BeginVertical ("Button");
                        SpeechLine.ShowField ("Name:", subclass.GetFullTitle (), false);
                        SpeechLine.ShowField ("Filename:", subclass.fileName, false);
                        SpeechLine.ShowField ("Description:", subclass.description, true);
                        subclass.isEnabled = true; // This is being set OnEnable anyway, because Action Types are now refreshed/generated automatically, so can't disable
                        //subclass.isEnabled = EditorGUILayout.Toggle ("Is enabled?", subclass.isEnabled);

                        EditorGUILayout.BeginHorizontal ();
                        if (enabledIndex >= 0)
                        {
                            if (enabledIndex == defaultClass)
                            {
                                EditorGUILayout.LabelField ("DEFAULT", EditorStyles.boldLabel, GUILayout.Width (140f));
                            }
                            else if (subclass.isEnabled)
                            {
                                if (GUILayout.Button ("Make default?", GUILayout.Width (140f)))
                                {
                                    if (EnabledActions.Contains (subclass))
                                    {
                                        defaultClass = EnabledActions.IndexOf (subclass);
                                    }
                                }
                            }
                        }
                        subclass.color = EditorGUILayout.ColorField ("Node colour:", subclass.color);

                        EditorGUILayout.EndHorizontal ();
                        EditorGUILayout.BeginHorizontal ();

                        if (GUILayout.Button ("Search local instances"))
                        {
                            SearchForInstances (true, subclass);
                        }
                        if (GUILayout.Button ("Search all instances"))
                        {
                            SearchForInstances (false, subclass);
                        }

                        EditorGUILayout.EndHorizontal ();
                        EditorGUILayout.EndVertical ();
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal ();
                        if (GUILayout.Button (subclass.GetFullTitle (), EditorStyles.label, GUILayout.Width (200f)))
                        {
                            selectedClass = subclass;
                        }
                        if (enabledIndex >= 0 && enabledIndex == defaultClass)
                        {
                            EditorGUILayout.LabelField ("DEFAULT", EditorStyles.boldLabel, GUILayout.Width (60f));
                        }
                        EditorGUILayout.EndHorizontal ();
                        GUILayout.Box ("", GUILayout.ExpandWidth (true), GUILayout.Height(1));
                    }
                }

                if (defaultClass > EnabledActions.Count - 1)
                {
                    defaultClass = EnabledActions.Count - 1;
                }
            }
            else
            {
                EditorGUILayout.HelpBox ("No Action subclass files found.", MessageType.Warning);
            }

            if (GUI.changed)
            {
                SetEnabled ();
                EditorUtility.SetDirty (this);
            }
        }
        private void SearchAssetForType(ActionListAsset actionListAsset, ActionType actionType)
        {
            if (searchedAssets.Contains (actionListAsset))
            {
                return;
            }

            searchedAssets.Add (actionListAsset);
            if (actionListAsset != null)
            {
                int numFinds = SearchActionsForType (actionListAsset.actions, actionType);
                if (numFinds > 0)
                {
                    ACDebug.Log ("(Asset: " + actionListAsset.name + ") Found " + numFinds + " instances of '" + actionType.GetFullTitle () + "'");
                }
            }
        }
        private void SearchForInstances(bool justLocal, ActionType actionType)
        {
            if (searchedAssets != null)
            {
                searchedAssets.Clear ();
            }

            if (justLocal)
            {
                SearchSceneForType ("", actionType);
                return;
            }

            string[] sceneFiles = AdvGame.GetSceneFiles ();

            // First look for lines that already have an assigned lineID
            foreach (string sceneFile in sceneFiles)
            {
                SearchSceneForType (sceneFile, actionType);
            }

            // Settings
            if (KickStarter.settingsManager)
            {
                SearchAssetForType (KickStarter.settingsManager.actionListOnStart, actionType);
                if (KickStarter.settingsManager.activeInputs != null)
                {
                    foreach (ActiveInput activeInput in KickStarter.settingsManager.activeInputs)
                    {
                        SearchAssetForType (activeInput.actionListAsset, actionType);
                    }
                }
            }

            // Inventory
            if (KickStarter.inventoryManager)
            {
                SearchAssetForType (KickStarter.inventoryManager.unhandledCombine, actionType);
                SearchAssetForType (KickStarter.inventoryManager.unhandledHotspot, actionType);
                SearchAssetForType (KickStarter.inventoryManager.unhandledGive, actionType);

                // Item-specific events
                if (KickStarter.inventoryManager.items.Count > 0)
                {
                    foreach (InvItem item in (KickStarter.inventoryManager.items))
                    {
                        SearchAssetForType (item.useActionList, actionType);
                        SearchAssetForType (item.lookActionList, actionType);
                        SearchAssetForType (item.unhandledActionList, actionType);
                        SearchAssetForType (item.unhandledCombineActionList, actionType);

                        foreach (ActionListAsset actionList in item.combineActionList)
                        {
                            SearchAssetForType (actionList, actionType);
                        }
                    }
                }

                foreach (Recipe recipe in KickStarter.inventoryManager.recipes)
                {
                    SearchAssetForType (recipe.invActionList, actionType);
                }
            }

            // Cursor
            if (KickStarter.cursorManager)
            {
                // Prefixes
                foreach (ActionListAsset actionListAsset in KickStarter.cursorManager.unhandledCursorInteractions)
                {
                    SearchAssetForType (actionListAsset, actionType);
                }
            }

            // Menus
            if (KickStarter.menuManager)
            {
                // Gather elements
                if (KickStarter.menuManager.menus.Count > 0)
                {
                    foreach (AC.Menu menu in KickStarter.menuManager.menus)
                    {
                        SearchAssetForType (menu.actionListOnTurnOff, actionType);
                        SearchAssetForType (menu.actionListOnTurnOn, actionType);

                        foreach (MenuElement element in menu.elements)
                        {
                            if (element is MenuButton)
                            {
                                MenuButton button = (MenuButton) element;
                                if (button.buttonClickType == AC_ButtonClickType.RunActionList)
                                {
                                    SearchAssetForType (button.actionList, actionType);
                                }
                            }
                            else if (element is MenuSavesList)
                            {
                                MenuSavesList button = (MenuSavesList) element;
                                SearchAssetForType (button.actionListOnSave, actionType);
                            }
                        }
                    }
                }
            }

            searchedAssets.Clear ();
        }
        private int SearchActionsForType(List<Action> actionList, ActionType actionType)
        {
            if (actionList == null)
            {
                return 0;
            }
            int numFinds = 0;
            foreach (Action action in actionList)
            {
                if ((action.category == actionType.category && action.title == actionType.title) ||
                    (action.category == actionType.category && action.title.Contains (actionType.title)))
                {
                    numFinds ++;
                }
            }

            return numFinds;
        }
Beispiel #8
0
        public void ShowGUI()
        {
            EditorGUILayout.BeginVertical ("Button");
            GUILayout.Label ("Actionlist editing settings", EditorStyles.boldLabel);
            displayActionsInInspector = EditorGUILayout.ToggleLeft ("List Actions in Inspector window?", displayActionsInInspector);
            displayActionsInEditor = (DisplayActionsInEditor) EditorGUILayout.EnumPopup ("Actions in Editor are:", displayActionsInEditor);
            actionListEditorScrollWheel = (ActionListEditorScrollWheel) EditorGUILayout.EnumPopup ("Using scroll-wheel:", actionListEditorScrollWheel);
            panSpeed = EditorGUILayout.FloatField ((actionListEditorScrollWheel == ActionListEditorScrollWheel.PansWindow) ? "Panning speed:" : "Zoom speed:", panSpeed);
            invertPanning = EditorGUILayout.ToggleLeft ("Invert panning in ActionList Editor?", invertPanning);
            allowMultipleActionListWindows = EditorGUILayout.ToggleLeft ("Allow multiple ActionList Editor windows?", allowMultipleActionListWindows);
            EditorGUILayout.EndVertical ();
            EditorGUILayout.Space ();

            EditorGUILayout.BeginVertical ("Button");
            GUILayout.Label ("Custom Action scripts", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal ();
            GUILayout.Label ("Folder to search:", GUILayout.Width (110f));
            GUILayout.Label (customFolderPath, EditorStyles.textField);
            GUILayout.EndHorizontal ();
            GUILayout.BeginHorizontal ();
            if (GUILayout.Button ("Set directory"))
            {
                string path = EditorUtility.OpenFolderPanel("Set custom Actions directory", "Assets", "");
                string dataPath = Application.dataPath;
                if (path.Contains (dataPath))
                {
                    if (path == dataPath)
                    {
                        customFolderPath = "";
                    }
                    else
                    {
                        customFolderPath = path.Replace (dataPath + "/", "");
                    }
                }
                else
                {
                    ACDebug.LogError ("Cannot set new directory - be sure to select within the Assets directory.");
                }
            }
            GUILayout.EndHorizontal ();
            EditorGUILayout.EndVertical ();

            if (AllActions.Count > 0)
            {
                GUILayout.Space (10);

                EditorGUILayout.BeginVertical ("Button");
                EditorGUILayout.LabelField ("Action categories", EditorStyles.boldLabel);
                ActionCategory[] categories = (ActionCategory[]) System.Enum.GetValues (typeof(ActionCategory));
                for (int i=0; i<categories.Length; i++)
                {
                    toggles[i] = GUILayout.Toggle (toggles[i], categories[i].ToString (), "Button");
                    if (toggles[i])
                    {
                        int j=-1;
                        foreach (ActionType subclass in AllActions)
                        {
                            if (subclass.category == categories[i])
                            {
                                j++;
                                int enabledIndex = -1;
                                if (EnabledActions.Contains (subclass))
                                {
                                    enabledIndex = EnabledActions.IndexOf (subclass);
                                }

                                if (selectedClass != null && subclass.category == selectedClass.category && subclass.title == selectedClass.title)
                                {
                                    EditorGUILayout.BeginVertical ("Button");
                                    SpeechLine.ShowField ("Name:", subclass.GetFullTitle (), false);
                                    SpeechLine.ShowField ("Filename:", subclass.fileName, false);
                                    SpeechLine.ShowField ("Description:", subclass.description, true);
                                    subclass.isEnabled = true;
                                    EditorGUILayout.BeginHorizontal ();
                                    if (enabledIndex >= 0)
                                    {
                                        if (enabledIndex == defaultClass)
                                        {
                                            EditorGUILayout.LabelField ("DEFAULT", EditorStyles.boldLabel, GUILayout.Width (140f));
                                        }
                                        else if (subclass.isEnabled)
                                        {
                                            if (GUILayout.Button ("Make default?", GUILayout.Width (140f)))
                                            {
                                                if (EnabledActions.Contains (subclass))
                                                {
                                                    defaultClass = EnabledActions.IndexOf (subclass);
                                                }
                                            }
                                        }
                                    }
                                    subclass.color = EditorGUILayout.ColorField ("Node colour:", subclass.color);

                                    EditorGUILayout.EndHorizontal ();
                                    EditorGUILayout.BeginHorizontal ();

                                    if (GUILayout.Button ("Search local instances"))
                                    {
                                        SearchForInstances (true, subclass);
                                    }
                                    if (GUILayout.Button ("Search all instances"))
                                    {
                                        if (UnityVersionHandler.SaveSceneIfUserWants ())
                                        {
                                            SearchForInstances (false, subclass);
                                        }
                                    }

                                    EditorGUILayout.EndHorizontal ();
                                    EditorGUILayout.EndVertical ();
                                }
                                else
                                {
                                    EditorGUILayout.BeginHorizontal ();
                                    if (GUILayout.Button (j.ToString () + ": " + subclass.GetFullTitle (), EditorStyles.label, GUILayout.Width (200f)))
                                    {
                                        selectedClass = subclass;
                                    }
                                    if (enabledIndex >= 0 && enabledIndex == defaultClass)
                                    {
                                        EditorGUILayout.LabelField ("DEFAULT", EditorStyles.boldLabel, GUILayout.Width (60f));
                                    }
                                    EditorGUILayout.EndHorizontal ();
                                    GUILayout.Box ("", GUILayout.ExpandWidth (true), GUILayout.Height(1));
                                }
                            }
                        }
                        if (j < 0)
                        {
                            EditorGUILayout.HelpBox ("There are no Actions of this category type present!", MessageType.Info);
                        }
                    }
                }
                EditorGUILayout.EndVertical ();

                if (defaultClass > EnabledActions.Count - 1)
                {
                    defaultClass = EnabledActions.Count - 1;
                }
            }
            else
            {
                EditorGUILayout.HelpBox ("No Action subclass files found.", MessageType.Warning);
            }

            if (GUI.changed)
            {
                SetEnabled ();
                EditorUtility.SetDirty (this);
            }
        }
Beispiel #9
0
        public static void RefreshActions()
        {
            if (AdvGame.GetReferences() == null || AdvGame.GetReferences().actionsManager == null)
            {
                return;
            }

            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            // Collect data to transfer
            List <ActionType> oldActionTypes = new List <ActionType>();

            foreach (ActionType actionType in actionsManager.AllActions)
            {
                oldActionTypes.Add(actionType);
            }

            actionsManager.AllActions.Clear();

            // Load default Actions
            string        targetDir = "Assets/" + actionsManager.FolderPath;
            DirectoryInfo dir       = new DirectoryInfo(targetDir);

            FileInfo[] info = dir.GetFiles("*.cs");
            foreach (FileInfo f in info)
            {
                try
                {
                    int    extentionPosition = f.Name.IndexOf(".cs");
                    string className         = f.Name.Substring(0, extentionPosition);

                    StreamReader streamReader = new StreamReader(f.FullName);
                    string       fileContents = streamReader.ReadToEnd();
                    streamReader.Close();

                    fileContents = fileContents.Replace(" ", "");

                    if (fileContents.Contains("class" + className + ":Action") ||
                        fileContents.Contains("class" + className + ":AC.Action"))
                    {
                        MonoScript script = AssetDatabase.LoadAssetAtPath <MonoScript> (targetDir + "/" + f.Name);
                        if (script == null)
                        {
                            continue;
                        }

                        Action tempAction = (Action)CreateInstance(script.GetClass());
                        if (tempAction != null && tempAction is Action)
                        {
                            ActionType newActionType = new ActionType(className, tempAction);

                            // Transfer back data
                            foreach (ActionType oldActionType in oldActionTypes)
                            {
                                if (newActionType.IsMatch(oldActionType))
                                {
                                    newActionType.color     = oldActionType.color;
                                    newActionType.isEnabled = oldActionType.isEnabled;
                                    if (newActionType.color == new Color(0f, 0f, 0f, 0f))
                                    {
                                        newActionType.color = Color.white;
                                    }
                                    if (newActionType.color.a < 1f)
                                    {
                                        newActionType.color = new Color(newActionType.color.r, newActionType.color.g, newActionType.color.b, 1f);
                                    }
                                }
                            }

                            actionsManager.AllActions.Add(newActionType);
                        }
                    }
                    else
                    {
                        ACDebug.LogError("The script '" + f.FullName + "' must derive from AC's Action class in order to be available as an Action.");
                    }
                }
                catch {}
            }

            // Load custom Actions
            if (!string.IsNullOrEmpty(actionsManager.customFolderPath) && actionsManager.UsingCustomActionsFolder)
            {
                targetDir = "Assets/" + actionsManager.customFolderPath;
                dir       = new DirectoryInfo(targetDir);

                try
                {
                    info = dir.GetFiles("*.cs");

                    foreach (FileInfo f in info)
                    {
                        try
                        {
                            int    extentionPosition = f.Name.IndexOf(".cs");
                            string className         = f.Name.Substring(0, extentionPosition);

                            StreamReader streamReader = new StreamReader(f.FullName);
                            string       fileContents = streamReader.ReadToEnd();
                            streamReader.Close();

                            fileContents = fileContents.Replace(" ", "");

                            if (fileContents.Contains("class" + className + ":Action") ||
                                fileContents.Contains("class" + className + ":AC.Action"))
                            {
                                MonoScript script = AssetDatabase.LoadAssetAtPath <MonoScript> (targetDir + "/" + f.Name);
                                if (script == null)
                                {
                                    continue;
                                }

                                Action tempAction = (Action)CreateInstance(script.GetClass());
                                if (tempAction != null && tempAction is Action)
                                {
                                    ActionType newActionType = new ActionType(className, tempAction);

                                    // Transfer back data
                                    foreach (ActionType oldActionType in oldActionTypes)
                                    {
                                        if (newActionType.IsMatch(oldActionType))
                                        {
                                            newActionType.color     = oldActionType.color;
                                            newActionType.isEnabled = oldActionType.isEnabled;
                                            if (newActionType.color == new Color(0f, 0f, 0f, 0f))
                                            {
                                                newActionType.color = Color.white;
                                            }
                                            if (newActionType.color.a < 1f)
                                            {
                                                newActionType.color = new Color(newActionType.color.r, newActionType.color.g, newActionType.color.b, 1f);
                                            }
                                        }
                                    }

                                    actionsManager.AllActions.Add(newActionType);
                                }
                            }
                            else
                            {
                                ACDebug.LogError("The script '" + f.FullName + "' must derive from AC's Action class in order to be available as an Action.");
                            }
                        }
                        catch
                        {}
                    }
                }
                catch (System.Exception e)
                {
                    ACDebug.LogWarning("Can't access directory " + "Assets/" + actionsManager.customFolderPath + " - does it exist?\n\nException: " + e);
                }
            }

            actionsManager.AllActions.Sort(delegate(ActionType i1, ActionType i2) { return(i1.GetFullTitle(true).CompareTo(i2.GetFullTitle(true))); });
        }
Beispiel #10
0
        private void SearchForInstances(bool justLocal, ActionType actionType)
        {
            if (searchedAssets != null)
            {
                searchedAssets.Clear();
            }

            if (justLocal)
            {
                SearchSceneForType("", actionType);
                return;
            }

            string[] sceneFiles = AdvGame.GetSceneFiles();

            // First look for lines that already have an assigned lineID
            foreach (string sceneFile in sceneFiles)
            {
                SearchSceneForType(sceneFile, actionType);
            }

            // Settings
            if (KickStarter.settingsManager)
            {
                SearchAssetForType(KickStarter.settingsManager.actionListOnStart, actionType);
                if (KickStarter.settingsManager.activeInputs != null)
                {
                    foreach (ActiveInput activeInput in KickStarter.settingsManager.activeInputs)
                    {
                        SearchAssetForType(activeInput.actionListAsset, actionType);
                    }
                }
            }

            // Inventory
            if (KickStarter.inventoryManager)
            {
                SearchAssetForType(KickStarter.inventoryManager.unhandledCombine, actionType);
                SearchAssetForType(KickStarter.inventoryManager.unhandledHotspot, actionType);
                SearchAssetForType(KickStarter.inventoryManager.unhandledGive, actionType);

                // Item-specific events
                if (KickStarter.inventoryManager.items.Count > 0)
                {
                    foreach (InvItem item in (KickStarter.inventoryManager.items))
                    {
                        SearchAssetForType(item.useActionList, actionType);
                        SearchAssetForType(item.lookActionList, actionType);
                        SearchAssetForType(item.unhandledActionList, actionType);
                        SearchAssetForType(item.unhandledCombineActionList, actionType);

                        foreach (ActionListAsset actionList in item.combineActionList)
                        {
                            SearchAssetForType(actionList, actionType);
                        }

                        foreach (InvInteraction interaction in item.interactions)
                        {
                            if (interaction.actionList != null)
                            {
                                SearchAssetForType(interaction.actionList, actionType);
                            }
                        }
                    }
                }

                foreach (Recipe recipe in KickStarter.inventoryManager.recipes)
                {
                    SearchAssetForType(recipe.invActionList, actionType);
                    SearchAssetForType(recipe.actionListOnCreate, actionType);
                }
            }

            // Cursor
            if (KickStarter.cursorManager)
            {
                // Prefixes
                foreach (ActionListAsset actionListAsset in KickStarter.cursorManager.unhandledCursorInteractions)
                {
                    SearchAssetForType(actionListAsset, actionType);
                }
            }

            // Menus
            if (KickStarter.menuManager)
            {
                // Gather elements
                if (KickStarter.menuManager.menus.Count > 0)
                {
                    foreach (AC.Menu menu in KickStarter.menuManager.menus)
                    {
                        SearchAssetForType(menu.actionListOnTurnOff, actionType);
                        SearchAssetForType(menu.actionListOnTurnOn, actionType);

                        foreach (MenuElement element in menu.elements)
                        {
                            if (element is MenuButton)
                            {
                                MenuButton button = (MenuButton)element;
                                if (button.buttonClickType == AC_ButtonClickType.RunActionList)
                                {
                                    SearchAssetForType(button.actionList, actionType);
                                }
                            }
                            else if (element is MenuSavesList)
                            {
                                MenuSavesList button = (MenuSavesList)element;
                                SearchAssetForType(button.actionListOnSave, actionType);
                            }
                            else if (element is MenuCycle)
                            {
                                MenuCycle cycle = (MenuCycle)element;
                                SearchAssetForType(cycle.actionListOnClick, actionType);
                            }
                            else if (element is MenuJournal)
                            {
                                MenuJournal journal = (MenuJournal)element;
                                SearchAssetForType(journal.actionListOnAddPage, actionType);
                            }
                            else if (element is MenuSlider)
                            {
                                MenuSlider slider = (MenuSlider)element;
                                SearchAssetForType(slider.actionListOnChange, actionType);
                            }
                            else if (element is MenuToggle)
                            {
                                MenuToggle toggle = (MenuToggle)element;
                                SearchAssetForType(toggle.actionListOnClick, actionType);
                            }
                            else if (element is MenuProfilesList)
                            {
                                MenuProfilesList profilesList = (MenuProfilesList)element;
                                SearchAssetForType(profilesList.actionListOnClick, actionType);
                            }
                        }
                    }
                }
            }

            searchedAssets.Clear();
        }
Beispiel #11
0
        public void ShowGUI()
        {
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showEditing = CustomGUILayout.ToggleHeader(showEditing, "ActionList editing settings");
            if (showEditing)
            {
                displayActionsInInspector   = CustomGUILayout.ToggleLeft("List Actions in Inspector window?", displayActionsInInspector, "AC.KickStarter.actionsManager.displayActionsInInspector");
                displayActionsInEditor      = (DisplayActionsInEditor)CustomGUILayout.EnumPopup("Actions in Editor are:", displayActionsInEditor, "AC.KickStarter.actionsManager.displayActionsInEditor");
                actionListEditorScrollWheel = (ActionListEditorScrollWheel)CustomGUILayout.EnumPopup("Using scroll-wheel:", actionListEditorScrollWheel, "AC.KickStarter.actionsManager.actionListEditorScrollWheel");
                panSpeed      = CustomGUILayout.FloatField((actionListEditorScrollWheel == ActionListEditorScrollWheel.PansWindow) ? "Panning speed:" : "Zoom speed:", panSpeed, "AC.KickStarter.actionsManager.panSpeed");
                invertPanning = CustomGUILayout.ToggleLeft("Invert panning in ActionList Editor?", invertPanning, "AC.KickStarter.actionsManager.invertPanning");
                allowMultipleActionListWindows = CustomGUILayout.ToggleLeft("Allow multiple ActionList Editor windows?", allowMultipleActionListWindows, "AC.KickStarter.actionsManager.allowMultipleActionListWindows");
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showCustom = CustomGUILayout.ToggleHeader(showCustom, "Custom Action scripts");
            if (showCustom)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Folder to search:", GUILayout.Width(110f));
                GUILayout.Label(customFolderPath, EditorStyles.textField);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Set directory"))
                {
                    string path     = EditorUtility.OpenFolderPanel("Set custom Actions directory", "Assets", "");
                    string dataPath = Application.dataPath;
                    if (path.Contains(dataPath))
                    {
                        if (path == dataPath)
                        {
                            customFolderPath = "";
                        }
                        else
                        {
                            customFolderPath = path.Replace(dataPath + "/", "");
                        }
                    }
                    else
                    {
                        ACDebug.LogError("Cannot set new directory - be sure to select within the Assets directory.");
                    }
                }
                GUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            if (AllActions.Count > 0)
            {
                GUILayout.Space(10);

                Upgrade();

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                showCategories = CustomGUILayout.ToggleHeader(showCategories, "Action categories");
                if (showCategories)
                {
                    ActionCategory[] categories = (ActionCategory[])System.Enum.GetValues(typeof(ActionCategory));

                    for (int i = 0; i < categories.Length; i++)
                    {
                        toggles[i] = GUILayout.Toggle(toggles[i], categories[i].ToString(), "Button");
                        if (toggles[i])
                        {
                            int j = -1;
                            foreach (ActionType subclass in AllActions)
                            {
                                if (subclass.category == categories[i])
                                {
                                    j++;
                                    int enabledIndex = -1;
                                    if (EnabledActions.Contains(subclass))
                                    {
                                        enabledIndex = EnabledActions.IndexOf(subclass);
                                    }

                                    if (selectedClass != null && subclass.category == selectedClass.category && subclass.title == selectedClass.title)
                                    {
                                        EditorGUILayout.BeginVertical("Button");
                                        SpeechLine.ShowField("Name:", subclass.GetFullTitle(), false);
                                        SpeechLine.ShowField("Filename:", subclass.fileName + ".cs", false);
                                        SpeechLine.ShowField("Description:", subclass.description, true);
                                        subclass.isEnabled = true;
                                        EditorGUILayout.BeginHorizontal();
                                        if (enabledIndex >= 0)
                                        {
                                            if (!string.IsNullOrEmpty(defaultClassName) && subclass.fileName == defaultClassName)
                                            {
                                                EditorGUILayout.LabelField("DEFAULT", CustomStyles.subHeader, GUILayout.Width(140f));
                                            }
                                            else if (subclass.isEnabled)
                                            {
                                                if (GUILayout.Button("Make default?", GUILayout.Width(140f)))
                                                {
                                                    if (EnabledActions.Contains(subclass))
                                                    {
                                                        defaultClassName = subclass.fileName;
                                                    }
                                                }
                                            }
                                        }
                                        subclass.color = EditorGUILayout.ColorField("Node colour:", subclass.color);

                                        EditorGUILayout.EndHorizontal();
                                        EditorGUILayout.BeginHorizontal();

                                        if (GUILayout.Button("Search local instances"))
                                        {
                                            SearchForInstances(true, subclass);
                                        }
                                        if (GUILayout.Button("Search all instances"))
                                        {
                                            if (UnityVersionHandler.SaveSceneIfUserWants())
                                            {
                                                SearchForInstances(false, subclass);
                                            }
                                        }

                                        EditorGUILayout.EndHorizontal();
                                        EditorGUILayout.EndVertical();
                                    }
                                    else
                                    {
                                        EditorGUILayout.BeginHorizontal();
                                        if (GUILayout.Button(j.ToString() + ": " + subclass.GetFullTitle(), EditorStyles.label, GUILayout.Width(200f)))
                                        {
                                            selectedClass = subclass;
                                        }
                                        if (!string.IsNullOrEmpty(defaultClassName) && subclass.fileName == defaultClassName)
                                        {
                                            EditorGUILayout.LabelField("DEFAULT", CustomStyles.subHeader, GUILayout.Width(60f));
                                        }
                                        EditorGUILayout.EndHorizontal();
                                        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
                                    }
                                }
                            }
                            if (j < 0)
                            {
                                EditorGUILayout.HelpBox("There are no Actions of this category type present!", MessageType.Info);
                            }
                        }
                    }
                }
                EditorGUILayout.EndVertical();

                if (defaultClass > EnabledActions.Count - 1)
                {
                    defaultClass = EnabledActions.Count - 1;
                }
            }
            else
            {
                EditorGUILayout.HelpBox("No Action subclass files found.", MessageType.Warning);
            }

            if (GUI.changed)
            {
                SetEnabled();
                Upgrade();
                EditorUtility.SetDirty(this);
            }
        }