Beispiel #1
0
        bool findWord(string target_word, SearchBox.Option option)
        {
            string target = target_word;
            string word   = option.search_word;

            // 正規表現チェックが入っている場合は他のオプションをとりあえず無視する仕様で
            if (option.regex)
            {
                return(findWordRegex(target, word));
            }

            // 大文字小文字を区別しない
            if (option.charactor)
            {
                target = target_word.ToLower();
                word   = option.search_word.ToLower();
            }

            // 完全一致
            if (option.complete)
            {
                if (target.Length != word.Length)
                {
                    return(false);
                }
            }

            return(findWordNormal(target, word));
        }
Beispiel #2
0
        private bool findWord(ConversationNode node, SearchBox.Option option)
        {
            string word = option.search_word;

            if (option.id)
            {
                // 有効かどうかはわからん0は普通に無いので0なら無効にするか?
                if (node.id > 0)
                {
                    uint id   = node.id;
                    bool find = findWord(id.ToString(), option);
                    if (find)
                    {
                        return(true);
                    }
                }
            }
            if (option.speaker)
            {
                if (node.speaker != null)
                {
                    bool find = findWord(node.speaker, option);
                    if (find)
                    {
                        return(true);
                    }
                }
            }
            if (option.listener)
            {
                if (node.listener != null)
                {
                    bool find = findWord(node.listener, option);
                    if (find)
                    {
                        return(true);
                    }
                }
            }

            // 一番長いのでそれまでに見つかっていたらいいな
            if (option.text)
            {
                if (node.conversation != null)
                {
                    bool find = findWord(node.conversation, option);
                    if (find)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #3
0
        // remake
        private ConversationNode findNode(TreeNode begin, TreeNode end, bool forward, SearchBox.Option option, Module module)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // delegate
            GetNode get_node = null;

            if (forward)
            {
                if (option.expand)
                {
                    get_node = new GetNode(getNextExpand);
                }
                else
                {
                    get_node = new GetNode(getNext);
                }
            }
            else
            {
                if (option.expand)
                {
                    get_node = new GetNode(getPrevExpand);
                }
                else
                {
                    get_node = new GetNode(getPrev);
                }
            }

            TreeNode current = begin;

            // ねんのためnullもチェック
            while (current != end && current != null)
            {
                ConversationNode cn = current as ConversationNode;
                if (cn != null)
                {
                    if (findWord(cn, option))
                    {
                        sw.Stop();
                        System.Console.WriteLine("time: " + sw.ElapsedMilliseconds.ToString() + "ms");
                        return(cn);
                    }
                    //current = getNext2( current );
                }
                else
                {
                    switch (( string )current.Tag)
                    {
                    case "dlg":
                        if (current.Nodes.Count == 1 && ( string )current.Nodes[0].Tag == "dummy")
                        {
                            // まだ読んでない
                            current.Nodes.Clear();

                            //string path = module_directory + "/" + current.Parent.Text + "/" + current.Text + ".txt";
                            string path = module.directory + "/" + current.FullPath + ".txt";

                            uint[]             start = null;
                            ConversationNode[] nodes = null;

                            loadDlg(path, ref start, ref nodes, module);

                            // error?
                            if (start == null || nodes == null)
                            {
                                continue;
                            }

                            module.tree.SuspendLayout();

                            createDlgTree(ref start, ref nodes, ref current);

                            module.tree.ResumeLayout();
                            module.tree.PerformLayout();
                        }
                        //current = getNext2( current );
                        break;

                    //case "rim":
                    // preloaded
                    //current = getNext2( current );
                    //break;
                    default:
                        break;
                    }
                }

                current = get_node(current);   // delegate
            }

            sw.Stop();
            System.Console.WriteLine("time: " + sw.ElapsedMilliseconds.ToString() + "ms");

            return(null);
        }
Beispiel #4
0
        private TreeNode searchPrev(SearchBox.Option option, TreeNode selected, Module module)
        {
            if (option.search_word != null && option.search_word.Length > 0)
            {
                // あまりないと思うが、状態によってはオプションが変更される可能性があるので
                SearchBox.Option new_option = new SearchBox.Option(option);
                TreeNode         current    = selected;
                // あんまり無いと思うが、何も選択されていなかったら頭から
                // prevの場合はケツからかな?
                if (current == null)
                {
                    if (module.tree.Nodes.Count < 1)
                    {
                        return(null);
                    }
                    current = module.tree.Nodes[0];
                    // 範囲は全検索に変更かな?
                    new_option.range = SearchBox.SearchRange.ByAll;
                }
                // 選択されていたらそのノードの前から

                // ALL
                TreeNode end = null;
                // bydlgなのにないがな
                if (new_option.range == SearchBox.SearchRange.ByDlg)
                {
                    TreeNode dlg  = current;
                    bool     find = false;
                    while (dlg != null)
                    {
                        if (( string )dlg.Tag == "dlg")
                        {
                            // それでもnullなら親のrimのnext
                            if (dlg.PrevNode != null)
                            {
                                end = dlg.PrevNode;
                            }
                            else
                            {
                                end = dlg.Parent.PrevNode;
                            }
                            find = true;
                            break;
                        }
                        dlg = dlg.Parent;
                    }
                    // nullなら上位ノードか終端
                    // 終端なら検索する必要する必要があるが…そうでない場合はrimで指定がおかしいので検索すると最後までいっちゃう
                    // この辺はコンボボックスの中身変えたり事前に正当性チェックしたほうがいいんかねえ
                    //if ( dlg == null ) {
                    //}
                    if (find == false)
                    {
                        return(null);
                    }
                }
                // byrimなのにないがな
                if (new_option.range == SearchBox.SearchRange.ByRim)
                {
                    TreeNode rim = current;
                    while (rim != null)
                    {
                        if (( string )rim.Tag == "rim")
                        {
                            // それでもnullならこれは終端
                            end = rim.PrevNode;
                            break;
                        }
                        rim = rim.Parent;
                    }
                }

                // bynode
                if (new_option.range == SearchBox.SearchRange.ByNode)
                {
                    TreeNode next = current;
                    while (next != null)
                    {
                        if (next.PrevNode != null)
                        {
                            end = next.PrevNode;
                            break;
                        }
                        next = next.Parent;
                    }
                }

                ConversationNode cn = current as ConversationNode;
                if (cn != null)
                {
                    // 選択ノード以下なのに子ノードがなかた
                    if (current.Nodes.Count < 1)
                    {
                        //if ( new_option.range == SearchBox.SearchRange.ByNode ) {
                        //    return null;
                        //}
                    }
                    // selectedは飛ばす
                    current = getPrev(current);
                }
                //ConversationNode findnode = findNodePrev( current, new_option );
                ConversationNode findnode = findNode(current, end, false, new_option, module);

                // loop editing
                if (findnode == null && new_option.loop && selected != null && module.tree.Nodes.Count > 0)
                {
                    TreeNode start = module.tree.Nodes[module.tree.Nodes.Count - 1];
                    if (new_option.range == SearchBox.SearchRange.ByDlg)
                    {
                        TreeNode dlg = current;
                        while (dlg != null)
                        {
                            if (( string )dlg.Tag == "dlg")
                            {
                                break;
                            }
                            dlg = dlg.Parent;
                        }
                        // nullなら上位ノードでした
                        // 検索する必要なし?
                        // まあ一応
                        //if ( dlg == null ) {
                        //    return null;
                        //}
                        start = dlg;
                    }
                    if (new_option.range == SearchBox.SearchRange.ByRim)
                    {
                        TreeNode rim = current;
                        while (rim != null)
                        {
                            if (( string )rim.Tag == "rim")
                            {
                                break;
                            }
                            rim = rim.Parent;
                        }
                        //if ( rim == null ) {
                        //    return null;
                        //}
                        start = rim;
                    }
                    // これは成立せんよなあ?
                    if (new_option.range == SearchBox.SearchRange.ByNode)
                    {
                        return(null);
                    }
                    findnode = findNode(start, selected, false, new_option, module);
                }
                return(findnode);
            }
            return(null);
        }