예제 #1
0
        public override void DoLoad()
        {
            //DXライブラリのリソースを破棄
            Media.ClearResources();

            //内部DB
            this.FlagBySystem = true;
            base.DoLoad();
            this.ApplyToManager <mgrDBEffect, mgrDBEffect.EffectOneData>(this.mgr);

            //独自コマンドとして使用するスクリプトのリスト
            this.mgr.UserCommandScripts.Clear();
            using (var R = new StreamReader(Common.OpenFileReadOnly(ProjectManager.ProjectPath + Resources.Path_DBs_EffectScriptCenter), Common.SJIS)) {
                var buf = R.ReadLine();     //1行目:コメント
                buf = R.ReadLine();
                while (buf != null)
                {
                    this.mgr.UserCommandScripts.Add(SQ.CutDoubleQuotation(SQ.GetArgumentListByCall(buf)[0]).Replace("\\\\", "\\"));
                    buf = R.ReadLine();
                }
            }
            this.mgr.IsUserCommandsDirty = false;

            //単独エフェクトスクリプト
            foreach (var effect in this.mgr.Data)
            {
                effect.LoadFile();
            }

            this.edittingListChanged(this, null);
            this.FlagBySystem = false;
            this.IsDirty      = false;
        }
예제 #2
0
        /// <summary>
        /// コード逆探索
        /// </summary>
        private void tolInsertReserchCode_Click(object sender, EventArgs e)
        {
            //カーソル部分の単語を抽出する
            var doc = this.azkEditor.Document;

            this.azkEditor.Document.GetSelection(out var x, out var y);
            string word, line;

            try {
                line = Common.CutHeadTabs(this.azkEditor.Document.GetLineContent(
                                              this.azkEditor.Document.GetLineIndexFromCharIndex(this.azkEditor.Document.AnchorIndex)))
                       .Trim();

                if (x == y && x > 0)
                {
                    //カーソルにある単語を選択状態にする
                    word = this.azkEditor.Document.GetTextInRange(
                        this.azkEditor.Document.WordProc.PrevWordStart(this.azkEditor.Document, x - 1),
                        this.azkEditor.Document.WordProc.NextWordStart(this.azkEditor.Document, x))
                           .Replace("\r\n", "");
                    this.azkEditor.Document.SetSelection(
                        this.azkEditor.Document.WordProc.PrevWordStart(this.azkEditor.Document, x - 1),
                        this.azkEditor.Document.WordProc.NextWordStart(this.azkEditor.Document, x)
                        );
                }
                else
                {
                    word = this.azkEditor.Document.GetTextInRange(x, y);
                }

                if (string.IsNullOrEmpty(word))
                {
                    //見つからなかった
                    throw new Exception();
                }
                else if (word.Length > 2 && word.Substring(0, 2) == "0x")
                {
                    //16進数と見られる文字列は接頭辞を削除する
                    word = word.Substring(2);
                }

                if (int.TryParse(word, System.Globalization.NumberStyles.AllowHexSpecifier, null, out var id) ||
                    int.TryParse(word, out id))
                {
                    //数値の場合はデータベースのIDとして検索する
                    var list = this.DBCtrl.FindDBRow(id);
                    if (list.Count > 0)
                    {
                        var index = 0;
                        if (list.Count > 1)
                        {
                            //複数見つかった場合は重複解決ダイアログを開く
                            var Dlg = new Dialog.Common.dlgSelectInList("データベースの選択");
                            for (var i = 0; i < list.Count; i++)
                            {
                                Dlg.AddItem(i + 1, list[i].Item2.Tag?.ToString());
                            }
                            if (Dlg.ShowDialog() != DialogResult.OK)
                            {
                                //キャンセル中断
                                return;
                            }
                            index = Dlg.GetResultID();
                        }
                        MessageBox.Show("次のデータベース項目に該当しました:\r\n" + list[index].Item2.Tag?.ToString() + "\r\n" + list[index].Item1, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        //見つからなかった
                        throw new Exception();
                    }
                }
                else if (line.IndexOf(Resources.SQ_EVMessage.Substring(0, Resources.SQ_EVMessage.IndexOf("("))) != -1)
                {
                    //メッセージ表示のコマンドがある場合
                    this.azkEditor.Document.SetSelection(
                        this.azkEditor.Document.GetLineHeadIndexFromCharIndex(x),
                        this.azkEditor.Document.GetLineEndIndexFromCharIndex(
                            this.azkEditor.Document.GetLineHeadIndex(this.azkEditor.Document.GetLineIndexFromCharIndex(x))
                            ) - 2
                        );
                    this.FoundCommandNode?.Invoke(this, new FoundCommandNodeEventArgs(CtrlComponent.Text.ctlCommandTree.TagToolMessage, line));
                }
                else if (line.IndexOf(Resources.SQ_ChangeMap.Substring(0, Resources.SQ_ChangeMap.IndexOf("("))) != -1)
                {
                    //場所移動のコマンドがある場合
                    this.azkEditor.Document.SetSelection(
                        this.azkEditor.Document.GetLineHeadIndexFromCharIndex(x),
                        this.azkEditor.Document.GetLineEndIndexFromCharIndex(
                            this.azkEditor.Document.GetLineHeadIndex(this.azkEditor.Document.GetLineIndexFromCharIndex(x))
                            ) - 2
                        );
                    this.FoundCommandNode?.Invoke(this, new FoundCommandNodeEventArgs(CtrlComponent.Text.ctlCommandTree.TagToolChangeMap, line));
                }
                else
                {
                    //文字列の場合はコードとみなしてコマンドツリーで検索にかける
                    var foundNodes  = ctlCommandTree.FindNodes(word);
                    var targetIndex = 0;

                    if (foundNodes == null || foundNodes.Count == 0)
                    {
                        //見つからなかった
                        throw new Exception();
                    }

                    if (foundNodes.Count > 1)
                    {
                        // 複数見つかったときはユーザーに選ばせる
                        var Dlg   = new dlgSelectInList("複数の候補 - コード逆探索");
                        var count = 1;
                        foreach (var node in foundNodes)
                        {
                            Dlg.AddItem(count, node.FullPath);
                            count++;
                        }
                        if (Dlg.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        targetIndex = Dlg.GetResultIndex();
                    }

                    //引数リストもすべて選択する
                    var      foundNode = foundNodes[targetIndex];
                    var      start     = line.IndexOf(word) + word.Length;
                    var      depth     = 0;
                    string[] args      = null;

                    if (line.IndexOf("(", start) == start)
                    {
                        //すぐ後ろに引数リストがある場合は選択範囲を伸ばす
                        //ただし、閉じ括弧がないときは伸ばさない
                        for (var index = start + 1; index < line.Length; index++)
                        {
                            var temp = line.Substring(index, 1);
                            if (temp == "(")
                            {
                                depth++;
                                continue;
                            }
                            if (temp == ")")
                            {
                                depth--;
                            }

                            if (depth < 0)
                            {
                                //関数呼び出しの括弧が閉じられたらここで終わる
                                word += line.Substring(start, index - start + 1);

                                //引数リストを取得
                                args = SQ.GetArgumentListByCall(word);

                                //選択範囲を伸ばす
                                this.azkEditor.Document.SetSelection(
                                    this.azkEditor.Document.AnchorIndex,
                                    this.azkEditor.Document.AnchorIndex + word.Length
                                    );
                                break;
                            }
                        }
                    }
                    this.FoundCommandNode?.Invoke(this, new FoundCommandNodeEventArgs(foundNode, args));
                }
            } catch {
                //見つからなかったらビープ音を鳴らす
                System.Media.SystemSounds.Beep.Play();
            }
        }
예제 #3
0
            public override void LoadFile()
            {
                var fileName = Resources.Path_DBs_EffectScripts + this.FixedID + Resources.Extension_SQ;

                if (!File.Exists(ProjectManager.ProjectPath + fileName))
                {
                    return;       //ファイルが見つからない場合は初期状態
                }

                //読み込み開始
                using (var R = new StreamReader(Common.OpenFileReadOnly(ProjectManager.ProjectPath + fileName), Common.SJIS)) {
                    var buf = "";
                    R.ReadLine();   //1行目:共通スクリプトインクルード
                    R.ReadLine();   //2行目:空行
                    R.ReadLine();   //3行目:コメント
                    R.ReadLine();   //4行目:関数名
                    R.ReadLine();   //5行目:local Effect = ...
                    R.ReadLine();   //6行目:switch分岐
                    R.ReadLine();   //7行目:case -1: ...

                    //以降読み込み開始
                    buf = R.ReadLine();
                    var i = 0;      //現在のフレームインデックス
                    while (buf.Replace("\t", "").Replace(" ", "") != "}")
                    {
                        buf = buf.Substring(buf.IndexOf(":") + 1);      //case N: の後ろ以降に絞る

                        //文ごとに区切る
                        var spl = buf.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        if (spl != null)
                        {
                            for (var n = 0; n < spl.Length; n++)
                            {
                                if ((spl[n] + ";") == Resources.SQ_BlockBreak)
                                {
                                    continue;       //break; は無視する
                                }

                                var args = SQ.GetArgumentListByCall(spl[n]);       //引数リストにする
                                if (n < this.Layers.Count)
                                {
                                    //各レイヤーのフレーム情報
                                    this.Layers[int.Parse(args[0])].Frames[i] = new mgrDBEffect.EffectOneData.EffectLayer.EffectFrame(
                                        new Point(int.Parse(args[1]), int.Parse(args[2])),
                                        new Point(int.Parse(args[3]), int.Parse(args[4])),
                                        (Media.BlendMode) int.Parse(args[5]),
                                        int.Parse(args[6]),
                                        int.Parse(args[7]),
                                        int.Parse(args[8])
                                        );
                                }
                                else
                                {
                                    //命令情報
                                    var funcName = SQ.GetFunctionNameByCall(spl[n]);
                                    if (funcName == SQ.GetFunctionNameByCall(Resources.SQ_EffectSound))
                                    {
                                        var pars = new string[Common.GetEnumCount <mgrDBEffect.EffectOneData.EffectOrder.SoundOptionIndices>()];
                                        for (var p = 0; p < pars.Length; p++)
                                        {
                                            if (p == (int)mgrDBEffect.EffectOneData.EffectOrder.SoundOptionIndices.IDName)
                                            {
                                                //この時点では空白にする
                                                pars[p] = "";
                                            }
                                            else
                                            {
                                                pars[p] = args[p];
                                            }
                                        }

                                        this.AddOrder(new mgrDBEffect.EffectOneData.EffectOrder(null,
                                                                                                i, mgrDBEffect.EffectOneData.EffectOrder.OrderType.Sound,
                                                                                                pars
                                                                                                ));
                                    }
                                    else if (funcName == SQ.GetFunctionNameByCall(Resources.SQ_EffectFlash))
                                    {
                                        var pars = new string[Common.GetEnumCount <mgrDBEffect.EffectOneData.EffectOrder.FlashOptionIndices>()];
                                        for (var p = 0; p < pars.Length; p++)
                                        {
                                            if (p == (int)mgrDBEffect.EffectOneData.EffectOrder.FlashOptionIndices.Color)
                                            {
                                                pars[p] = Common.LinkStringArray(SQ.GetArgumentListByCall(args[p]), Resources.Split_ColorRGB.ToCharArray()[0]);
                                            }
                                            else
                                            {
                                                pars[p] = args[p];
                                            }
                                        }

                                        this.AddOrder(new mgrDBEffect.EffectOneData.EffectOrder(null,
                                                                                                i, mgrDBEffect.EffectOneData.EffectOrder.OrderType.Flash,
                                                                                                pars
                                                                                                ));
                                    }
                                    else if (funcName == SQ.GetFunctionNameByCall(Resources.SQ_EffectShake))
                                    {
                                        this.AddOrder(new mgrDBEffect.EffectOneData.EffectOrder(null,
                                                                                                i, mgrDBEffect.EffectOneData.EffectOrder.OrderType.Shake,
                                                                                                new string[] { args[0] })
                                                      );
                                    }
                                    else if (funcName == SQ.GetFunctionNameByCall(Resources.SQ_EffectWaitBreak))
                                    {
                                        this.AddOrder(new mgrDBEffect.EffectOneData.EffectOrder(null,
                                                                                                i, mgrDBEffect.EffectOneData.EffectOrder.OrderType.WaitBreak,
                                                                                                new string[] { "" })
                                                      );
                                    }
                                    else
                                    {
                                        this.AddOrder(new mgrDBEffect.EffectOneData.EffectOrder(null,
                                                                                                i, mgrDBEffect.EffectOneData.EffectOrder.OrderType.User,
                                                                                                new string[] { spl[n] })
                                                      );
                                    }
                                }
                            }
                        }

                        buf = R.ReadLine();
                        i++;
                    }
                }
                this.IsDirty = false;
            }