Beispiel #1
0
    public void checkIndexCorrectness()
    {
        SequencerSectionModel sectionModel = sequencerData.getSectionModel(sectionName);
        if (commandIndex == -1 || commandIndex == sectionModel.commandList.Count || sectionModel.commandList [commandIndex] != targetCommand)
        {
            bool found = false;
            foreach (SequencerCommandBase cmd in sectionModel.commandList)
            {
                if (cmd == targetCommand)
                {
                    commandIndex = sectionModel.commandList.IndexOf(cmd);
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                Debug.LogWarning("Couldnt find jump target command after index change ! Will use whatever is at previous index! " +
                    "Was looking for index:" + commandIndex + " in section: " + sectionModel.name + " is jump command at index: " +
                    sequencerData.getSectionModel(sectionName).commandList.IndexOf(this));

                if (commandIndex != -1)
                    targetCommand = sectionModel.commandList [commandIndex];
                else if (commandIndex == -1 && sectionModel.commandList.Count == 0)
                    Debug.LogWarning("The section might be empty! Empty Sections cant be jumped to correctly !");
                else if (commandIndex == -1 && sectionModel.commandList.Count > 0)
                {
                    commandIndex = 0;
                    targetCommand = sectionModel.commandList [commandIndex];
                }
            }
        }
    }
 public SequencerCommandBase clone(SequencerCommandBase cmd)
 {
     cmd.sectionIndex  = sectionIndex;
     cmd.listIndex     = listIndex;
     cmd.currIndex     = currIndex;
     cmd.targetIndex   = targetIndex;
     cmd.sequencerData = sequencerData;
     return(cmd);
 }
 public SequencerCommandBase clone(SequencerCommandBase cmd)
 {
     cmd.sectionName = sectionName;
     cmd.listIndex = listIndex;
     cmd.currIndex = currIndex;
     cmd.targetIndex = targetIndex;
     cmd.sequencerData = sequencerData;
     return cmd;
 }
 public int findIndexOf(SequencerCommandBase command)
 {
     for (int i = 0; i < sequencerData.sections [sectionIndex].commandList.Count; i++)
     {
         if (sequencerData.sections [sectionIndex].commandList [i].GetInstanceID() == command.GetInstanceID())
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #5
0
    private void drawSections()
    {
        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Label("Sections");
            if (GUILayout.Button("New Section"))
            {
                doAddNewSection();
            }

            if (GUILayout.Button("Duplicate Selected Section"))
            {
                if (sequencerData.sections != null && lastSelectedSection > -1)
                {
                    doDuplicateSection(sequencerData.sections [lastSelectedSection]);
                }
            }

//            if (GUILayout.Button("Fix Commands to have reference to data object"))
//                doFixCommands();
        }
        EditorGUILayout.EndHorizontal();

        //spacer
        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

        if (sequencerData != null && sequencerData.getSectionNames().Length > 0)
        {
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Label("Select Section:");
                lastSelectedSection = EditorGUILayout.Popup(lastSelectedSection, sequencerData.getSectionNames(), GUILayout.Width(100));

                GUILayout.Label("Rename to this:");
                renameBoxString = GUILayout.TextField(renameBoxString);

                if (GUILayout.Button("Rename this Section"))
                {
                    doRenameSection(sequencerData.sections [lastSelectedSection], renameBoxString);
                }

                if (GUILayout.Button("Delete this Section"))
                {
                    doDeleteSection(sequencerData.getSectionNames() [lastSelectedSection]);
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Label("Available Commands:");
            lastSelectedCommand = EditorGUILayout.Popup(lastSelectedCommand, SequencerCommandTypes.getAsStringArray(), GUILayout.Width(100));

            if (GUILayout.Button("Add Command"))
            {
                doAddCommandToSection(lastSelectedSection, lastSelectedCommand);
            }

            insertIndex = EditorGUILayout.IntField(insertIndex);
            if (GUILayout.Button("Add Command At"))
            {
                doAddCommandToSectionAt(lastSelectedSection, lastSelectedCommand, insertIndex);
            }
        }
        EditorGUILayout.EndHorizontal();

        //spacer
        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

        if (lastSelectedSection > -1 && lastSelectedSection < sequencerData.sections.Count && sequencerData.sections [lastSelectedSection] != null && sequencerData.sections [lastSelectedSection].commandList != null)
        {
            scrollPosSections = EditorGUILayout.BeginScrollView(scrollPosSections);
            {
                EditorGUILayout.BeginVertical();
                {
                    SequencerCommandBase[] tempCommands = new SequencerCommandBase[sequencerData.sections [lastSelectedSection].commandList.Count];
                    sequencerData.sections [lastSelectedSection].commandList.CopyTo(tempCommands);

                    for (int i = 0; i < tempCommands.Length; i++)
                    {
                        if (i % 2 == 0)
                        {
                            EditorGUILayout.BeginHorizontal(guiBGAltColorA);
                        }
                        else
                        {
                            EditorGUILayout.BeginHorizontal();
                        }
                        {
                            tempCommands [i].drawFrontUi();
                            tempCommands [i].drawCustomUi();
                            tempCommands [i].drawBackUi();
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndScrollView();
        }
        else
        {
            lastSelectedSection -= 1;
        }
    }
Beispiel #6
0
    void initCommandAndAddToSection(SequencerSectionModel sectionModel, SequencerCommandBase command, SequencerData data)
    {
        if ( sectionModel == null)
        {
            Debug.LogWarning( "No Section to add command to ! ");
            return;
        }

        command.init(sectionModel.name, data);
        sectionModel.commandList.Add(command);
        command.updateAllIndex();
    }
Beispiel #7
0
    public override void drawCustomUi()
    {
        string[] nicks = sequencerData.getSectionNames();

        GUILayout.Label("Jump to Section:");
        targetSectionName = nicks [EditorGUILayout.Popup(sequencerData.getIndexOfSection(targetSectionName), nicks, GUILayout.Width(100))];

        int commandIndexMax = sequencerData.sections [sequencerData.getIndexOfSection(targetSectionName)].commandList.Count;
        if (commandIndexMax < 46) //max show for in popup style, otherwise use input field
        {
            if (targetSectionName != previousTargetSectionName)
            {
                previousTargetSectionName = targetSectionName;
                int[] numberRange = Enumerable.Range(0, commandIndexMax).ToArray();
                commandIndexes = new string[numberRange.Length];
                for (int i = 0; i < numberRange.Length; i++)
                {
                    commandIndexes [i] = numberRange [i].ToString();
                }

                commandIndex = Mathf.Clamp(commandIndex, 0, commandIndexes.Length - 1);
            }

            GUILayout.Label("Command Index:");
            commandIndex = EditorGUILayout.Popup(commandIndex, commandIndexes, GUILayout.Width(100));
        } else
        {
            commandIndex = Mathf.Clamp(EditorGUILayout.IntField(commandIndex), 0, commandIndexMax - 1);
        }

        SequencerSectionModel sectionModel = sequencerData.getSectionModel(targetSectionName);
        if (sectionModel.commandList != null && sectionModel.commandList.Count > 0 && sectionModel.commandList.Count > commandIndex)
            targetCommand = sectionModel.commandList [commandIndex];
    }
Beispiel #8
0
    private void drawSections()
    {
        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Label("Sections");

            paging = GUILayout.Toggle(paging, "Use Paging:");

            if (GUILayout.Button("New Section"))
                doAddNewSection();

            if (GUILayout.Button("Duplicate Selected Section"))
            {
                if (sequencerData.sections != null && lastSelectedSection > -1)
                    doDuplicateSection(sequencerData.sections [lastSelectedSection]);
            }

            //developer fix tool
        //            if (GUILayout.Button("Fix Commands"))
        //                doFixCommands();
        }
        EditorGUILayout.EndHorizontal();

        //spacer
        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

        if (sequencerData != null && sequencerData.getSectionNames().Length > 0)
        {
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Label("Select Section:");
                lastSelectedSection = EditorGUILayout.Popup(lastSelectedSection, sequencerData.getSectionNames(), GUILayout.Width(100));

                GUILayout.Label("Rename to this:");
                renameBoxString = GUILayout.TextField(renameBoxString);

                if (GUILayout.Button("Rename this Section"))
                    doRenameSection(sequencerData.sections [lastSelectedSection], renameBoxString);

                if (GUILayout.Button("Delete this Section"))
                    doDeleteSection(sequencerData.getSectionNames() [lastSelectedSection]);
            }
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Label("Available Commands:");
            lastSelectedCommand = EditorGUILayout.Popup(lastSelectedCommand, SequencerCommandTypes.getAsStringArray(), GUILayout.Width(100));

            if (GUILayout.Button("Add Command"))
                doAddCommandToSection(lastSelectedSection, lastSelectedCommand);

            insertIndex = EditorGUILayout.IntField(insertIndex);
            if (GUILayout.Button("Add Command At"))
                doAddCommandToSectionAt(lastSelectedSection, lastSelectedCommand, insertIndex);
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Label("Filter by Command type:");
            lastSelectedCommandFilter = EditorGUILayout.Popup(lastSelectedCommandFilter, SequencerCommandTypes.getAsStringArray(), GUILayout.Width(100));

            doTypeFilter = GUILayout.Toggle(doTypeFilter, "Toggle Filter");
        }
        EditorGUILayout.EndHorizontal();

        //spacer
        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

        if (lastSelectedSection > -1 && lastSelectedSection < sequencerData.sections.Count && sequencerData.sections [lastSelectedSection] != null && sequencerData.sections [lastSelectedSection].commandList != null)
        {
            scrollPosSections = EditorGUILayout.BeginScrollView(scrollPosSections);
            {
                int pageStartIndex = 0;
                int pageEndIndex;
                int totalPages = 1;

                SequencerCommandBase[] tempCommands = new SequencerCommandBase[sequencerData.sections [lastSelectedSection].commandList.Count];
                sequencerData.sections [lastSelectedSection].commandList.CopyTo(tempCommands);

                pageEndIndex = tempCommands.Length;

                if (paging)
                {
                    if (tempCommands.Length > pagingSize)
                    {
                        totalPages = Mathf.FloorToInt((float)tempCommands.Length / (float)pagingSize);
                    }

                    if (totalPages > 1)
                    {
                        pageStartIndex = page * pagingSize;
                        pageEndIndex = Mathf.Min(pageStartIndex + pagingSize, tempCommands.Length);
                    } else
                        page = 0;

                    if (totalPages > 1)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            if (GUILayout.Button("< previous page"))
                                page = Mathf.Max(0, page - 1);

                            GUILayout.Label(" Page: " + page + " out of " + totalPages);

                            if (GUILayout.Button(" > next page"))
                                page = Mathf.Min(totalPages, page + 1);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }

                EditorGUILayout.BeginVertical();
                {
                    for (int i = pageStartIndex; i < pageEndIndex; i++)
                    {
                        if (doTypeFilter && tempCommands [i].GetType() != SequencerCommandTypes.commandTypes [lastSelectedCommandFilter])
                            continue;

                        if (i % 2 == 0)
                            EditorGUILayout.BeginHorizontal(guiBGAltColorA);
                        else
                            EditorGUILayout.BeginHorizontal();
                        {
                            tempCommands [i].drawFrontUi();
                            tempCommands [i].drawCustomUi();
                            tempCommands [i].drawBackUi();
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
                EditorGUILayout.EndVertical();

                if (paging)
                {
                    if (totalPages > 1)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            if (GUILayout.Button("< previous page"))
                                page = Mathf.Max(0, page - 1);

                            GUILayout.Label(" Page: " + page + " out of " + totalPages);

                            if (GUILayout.Button(" > next page"))
                                page = Mathf.Min(totalPages, page + 1);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.EndScrollView();
        } else
        {
            lastSelectedSection -= 1;
        }
    }
    public int findIndexOf(SequencerCommandBase command)
    {
        SequencerSectionModel sectionModel = sequencerData.getSectionModel(sectionName);

        for (int i = 0; i < sectionModel.commandList.Count; i++)
        {
            if (sectionModel.commandList [i].GetInstanceID() == command.GetInstanceID())
            {
                return i;
            }
        }
        return -1;
    }