예제 #1
0
    public void createBlankSnippet()
    {
        TagHandler        tagHandler        = new TagHandler(this);
        AssocationHandler assocationHandler = new AssocationHandler();

        Snippet blankSnippet = SnippetState.CreateBlankSnippet(1);

        GameObject instantiatedSnippet = Instantiate(snippetPrefab) as GameObject;

        SnippetState instSnippetState = instantiatedSnippet.GetComponent <SnippetState>();

        instSnippetState.loadState(tagHandler.GetTagBySnippetId(blankSnippet.Snippet_Id),
                                   blankSnippet,
                                   assocationHandler.GetAssociationViewForSnippet(blankSnippet.Snippet_Id));

        instantiatedSnippet.name = instSnippetState.title;  //names each snippet by its title

        snippetObjectDict.Add(instSnippetState.id, instantiatedSnippet);
    }
예제 #2
0
    public void filterByTagAndYarn(string tagQuery, int yarnQuery)
    {
        int yarnQueryID = -1;

        //Get the actual yarnID from the dropdown seletion value
        if (yarnQuery >= 0)
        {
            yarnQueryID = yarnManager.allYarnLines.Keys.ElementAt <int>(yarnQuery);
        }


        //If both filters exist
        if (tagQuery != "" && yarnQueryID >= 0)
        {
            Debug.Log("Searching tag: " + tagQuery + "and yarn: " + yarnQueryID);

            //First hide all snippets
            hideAllSnippets();

            //Apply both filters:

            //Get all the snippetIDs attached to the given yarnID
            List <int> snippetsToShow = yarnManager.getAttachedSnippetsByYarnID(yarnQueryID);

            //Search the list of snippet objects
            foreach (KeyValuePair <int, GameObject> snippetObject in snippetObjectDict)
            {
                //Get the SnippetState component
                SnippetState snippetState = snippetObject.Value.GetComponent <SnippetState>();

                //If the snippet matches both filters, show it
                if (snippetState && snippetState.tags.Contains(tagQuery) && snippetsToShow.Contains(snippetState.id))
                {
                    snippetObject.Value.SetActive(true);
                }
            }

            yarnManager.adaptiveHide();
        }
        //If only tag query
        else if (tagQuery != "" && yarnQueryID < 0)
        {
            Debug.Log("Searching tag: " + tagQuery);

            //First hide all snippets
            hideAllSnippets();

            //Search the list of snippet objects
            foreach (KeyValuePair <int, GameObject> snippetObject in snippetObjectDict)
            {
                //Get the SnippetState component
                SnippetState snippetState = snippetObject.Value.GetComponent <SnippetState>();

                //If the snippet contains the tag, show it
                if (snippetState && snippetState.tags.Contains(tagQuery))
                {
                    snippetObject.Value.SetActive(true);
                }
            }

            yarnManager.adaptiveHide();
        }
        //If only yarn query
        else if (tagQuery == "" && yarnQueryID >= 0)
        {
            Debug.Log("Searching yarn: " + yarnQueryID);

            //First hide all snippets
            hideAllSnippets();

            //Get all the snippetIDs attached to the given yarnID
            List <int> snippetsToShow = yarnManager.getAttachedSnippetsByYarnID(yarnQueryID);

            //Search the list of snippet objects
            foreach (KeyValuePair <int, GameObject> snippetObject in snippetObjectDict)
            {
                //Get the SnippetState component
                SnippetState snippetState = snippetObject.Value.GetComponent <SnippetState>();

                //If the snippet is in the list, show it
                if (snippetState && snippetsToShow.Contains(snippetState.id))
                {
                    snippetObject.Value.SetActive(true);
                }
            }

            yarnManager.adaptiveHide();
        }
        //The filters are empty, so show everything
        else
        {
            showAllSnippets();
            yarnManager.showAll();
        }
        //Set the current filter
        currentTagFilter  = tagQuery;
        currentYarnFilter = yarnQueryID;
    }
예제 #3
0
    public void deleteSnippet(SnippetState target)
    {
        SnippetHandler snippetHandler = new SnippetHandler();

        snippetHandler.Delete(target.GetBaseInterFace());
    }