コード例 #1
0
        public override void Step()
        {
            // 将棋エンジンからの入力が、input99 に溜まるものとします。
            if (0 < shogiGui.Input99.Length)
            {
                string message = "timer入力 input99=[" + shogiGui.Input99 + "]";
                Logger.Trace(message);

                //
                // 棋譜入力テキストボックスに、指し手「(例)6a6b」を入力するための一連の流れです。
                //
                {
                    shogiGui.ResponseData = new ResponseImpl();
                    shogiGui.ResponseData.SetAppendInputTextString(shogiGui.Input99); // 受信文字列を、上部テキストボックスに入れるよう、依頼します。
                    shogiGui.Response("Timer");                                       // テキストボックスに、受信文字列を入れます。
                    shogiGui.Input99 = "";                                            // 受信文字列の要求を空っぽにします。
                }

                //
                // コマ送り
                //
                {
                    string restText = Util_InGui.ReadLine_FromTextbox();
                    Util_InServer.Komaokuri_Srv(ref restText, shogiGui); // 棋譜の[コマ送り]を実行します。
                    Util_InGui.Komaokuri_Gui(restText, shogiGui);        //追加
                    // ↑チェンジターン済み
                    Util_Menace.Menace(shogiGui);                        // メナス
                }

                //
                // ここで、テキストボックスには「(例)6a6b」が入っています。
                //

                //
                // 駒を動かす一連の流れです。
                //
                {
                    //this.ShogiGui.ResponseData.InputTextString = "";//空っぽにすることを要求する。
                    shogiGui.Response("Timer");// GUIに反映させます。
                }
            }
        }
コード例 #2
0
        public virtual void Step3_SetEvent(object obj_shogiGui)
        {
            NarabeRoomViewModel shogiGui1 = (NarabeRoomViewModel)obj_shogiGui;

            //----------
            // [成る]ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnNaru");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Ui_PnlMain ui_PnlMain = ((Ui_ShogiForm1)shogiGui.OwnerForm).Ui_PnlMain1;


                    shogiGui.Shape_PnlTaikyoku.SetNaruFlag(true);
                    this.After_NaruNaranai(
                        shogiGui
                        , btnKoma_Selected
                        );
                };
            }

            //----------
            // [成らない]ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnNaranai");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Ui_PnlMain ui_PnlMain = ((Ui_ShogiForm1)shogiGui.OwnerForm).Ui_PnlMain1;

                    shogiGui.Shape_PnlTaikyoku.SetNaruFlag(false);
                    this.After_NaruNaranai(
                        shogiGui
                        , btnKoma_Selected
                        );
                };
            }

            //----------
            // [クリアー]ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnClear");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Util_Lua_KifuNarabe.ShogiGui = shogiGui;
                    Util_Lua_KifuNarabe.Perform("click_clearButton");
                };
            }

            //----------
            // [再生]ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnPlay");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Util_Lua_KifuNarabe.ShogiGui = shogiGui;
                    Util_Lua_KifuNarabe.Perform("click_playButton");
                };
            }

            //----------
            // [コマ送り]ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnForward");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    string restText = Util_InGui.ReadLine_FromTextbox();
                    Util_InServer.Komaokuri_Srv(ref restText, shogiGui);
                    Util_InGui.Komaokuri_Gui(restText, shogiGui);
                    Util_Menace.Menace(shogiGui);// メナス
                };
            }

            //----------
            // [巻戻し]ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnBackward");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Ui_PnlMain ui_PnlMain = ((Ui_ShogiForm1)shogiGui.OwnerForm).Ui_PnlMain1;

                    Finger movedKoma;
                    Finger foodKoma;//取られた駒
                    string fugoJStr;

                    if (!Util_InServer.Makimodosi_Srv(out movedKoma, out foodKoma, out fugoJStr, shogiGui))
                    {
                        goto gt_EndBlock;
                    }

                    Util_InGui.Makimodosi_Gui(shogiGui, movedKoma, foodKoma, fugoJStr, Util_InGui.ReadLine_FromTextbox());
                    Util_Menace.Menace(shogiGui);//メナス

gt_EndBlock:
                    ;
                };
            }


            //----------
            // ログ出せボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnLogdase");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Ui_PnlMain ui_PnlMain = ((Ui_ShogiForm1)shogiGui.OwnerForm).Ui_PnlMain1;

                    ui_PnlMain.ShogiGui.Logdase();
                };
            }



            //----------
            // [壁置く]ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnKabeOku");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Ui_PnlMain ui_PnlMain = ((Ui_ShogiForm1)shogiGui.OwnerForm).Ui_PnlMain1;

                    // [壁置く]←→[駒動かす]切替
                    switch (widget.Text)
                    {
                    case "壁置く":
                        widget.Text = "駒動かす";
                        break;

                    default:
                        widget.Text = "壁置く";
                        break;
                    }

                    shogiGui.ResponseData.ToRedraw();
                };
            }


            //----------
            // [出力切替]ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnSyuturyokuKirikae");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Ui_PnlMain ui_PnlMain = ((Ui_ShogiForm1)shogiGui.OwnerForm).Ui_PnlMain1;

                    switch (shogiGui.Shape_PnlTaikyoku.SyuturyokuKirikae)
                    {
                    case SyuturyokuKirikae.Japanese:
                        shogiGui.Shape_PnlTaikyoku.SetSyuturyokuKirikae(SyuturyokuKirikae.Sfen);
                        break;

                    case SyuturyokuKirikae.Sfen:
                        shogiGui.Shape_PnlTaikyoku.SetSyuturyokuKirikae(SyuturyokuKirikae.Html);
                        break;

                    case SyuturyokuKirikae.Html:
                        shogiGui.Shape_PnlTaikyoku.SetSyuturyokuKirikae(SyuturyokuKirikae.Japanese);
                        break;
                    }

                    shogiGui.ResponseData.OutputTxt = ResponseGedanTxt.Kifu;
                };
            }

            //----------
            // [▲]~[打]符号ボタン
            //----------
            {
                string[] buttonNames = new string[] {
                    "BtnFugo_Sente"    // [▲]~[打]符号ボタン
                    , "BtnFugo_Gote"
                    , "BtnFugo_1"
                    , "BtnFugo_2"
                    , "BtnFugo_3"
                    , "BtnFugo_4"
                    , "BtnFugo_5"
                    , "BtnFugo_6"
                    , "BtnFugo_7"
                    , "BtnFugo_8"
                    , "BtnFugo_9"
                    , "BtnFugo_Dou"
                    , "BtnFugo_Fu"
                    , "BtnFugo_Hisya"
                    , "BtnFugo_Kaku"
                    , "BtnFugo_Kyo"
                    , "BtnFugo_Kei"
                    , "BtnFugo_Gin"
                    , "BtnFugo_Kin"
                    , "BtnFugo_Oh"
                    , "BtnFugo_Gyoku"
                    , "BtnFugo_Tokin"
                    , "BtnFugo_Narikyo"
                    , "BtnFugo_Narikei"
                    , "BtnFugo_Narigin"
                    , "BtnFugo_Ryu"
                    , "BtnFugo_Uma"
                    , "BtnFugo_Yoru"
                    , "BtnFugo_Hiku"
                    , "BtnFugo_Agaru"
                    , "BtnFugo_Migi"
                    , "BtnFugo_Hidari"
                    , "BtnFugo_Sugu"
                    , "BtnFugo_Nari"
                    , "BtnFugo_Funari"
                    , "BtnFugo_Da"
                };

                foreach (string buttonName in buttonNames)
                {
                    UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget(buttonName);
                    widget.Delegate_MouseHitEvent = (
                        object obj_shogiGui2
                        , Shape_BtnKoma btnKoma_Selected
                        ) =>
                    {
                        NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                        Ui_PnlMain ui_PnlMain = ((Ui_ShogiForm1)shogiGui.OwnerForm).Ui_PnlMain1;

                        shogiGui.ResponseData.SetAppendInputTextString(shogiGui.Shape_PnlTaikyoku.GetWidget(buttonName).Fugo);
                    };
                }
            }


            //----------
            // [全消]ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnFugo_Zenkesi");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Ui_PnlMain ui_PnlMain = ((Ui_ShogiForm1)shogiGui.OwnerForm).Ui_PnlMain1;

                    shogiGui.ResponseData.InputTextString = "";
                };
            }


            //----------
            // [ここから採譜]ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnFugo_KokokaraSaifu");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Ui_PnlMain ui_PnlMain = ((Ui_ShogiForm1)shogiGui.OwnerForm).Ui_PnlMain1;

                    ui_PnlMain.ShogiGui.GameViewModel.Kifu.SetStartpos_KokokaraSaifu(Util_InServer.CurPside(ui_PnlMain.ShogiGui));
                    shogiGui.ResponseData.OutputTxt = ResponseGedanTxt.Kifu;
                };
            }

            //----------
            // 初期配置ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnSyokihaichi");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Ui_PnlMain ui_PnlMain = ((Ui_ShogiForm1)shogiGui.OwnerForm).Ui_PnlMain1;

                    WidgetsLoader_KifuNarabe.Perform_SyokiHaichi(ui_PnlMain);
                };
            }


            //----------
            // [向き]ボタン
            //----------
            {
                UserWidget widget = shogiGui1.Shape_PnlTaikyoku.GetWidget("BtnMuki");
                widget.Delegate_MouseHitEvent = (
                    object obj_shogiGui2
                    , Shape_BtnKoma btnKoma_Selected
                    ) =>
                {
                    NarabeRoomViewModel shogiGui = (NarabeRoomViewModel)obj_shogiGui2;

                    Ui_PnlMain ui_PnlMain = ((Ui_ShogiForm1)shogiGui.OwnerForm).Ui_PnlMain1;

                    Shape_BtnKoma movedKoma = shogiGui.Shape_PnlTaikyoku.Btn_MovedKoma();

                    RO_Star_Koma koma;
                    Finger       figKoma = Fingers.Error_1;

                    if (null != movedKoma)
                    {
                        //>>>>> 移動直後の駒があるとき
                        koma    = Util_Koma.AsKoma(ui_PnlMain.ShogiGui.GameViewModel.GuiSkyConst.StarlightIndexOf(movedKoma.Finger).Now);
                        figKoma = movedKoma.Finger;
                    }
                    else if (null != btnKoma_Selected)
                    {
                        //>>>>> 選択されている駒があるとき
                        koma    = Util_Koma.AsKoma(ui_PnlMain.ShogiGui.GameViewModel.GuiSkyConst.StarlightIndexOf(btnKoma_Selected.Koma).Now);
                        figKoma = btnKoma_Selected.Koma;
                    }
                    else
                    {
                        koma = null;
                    }

                    if (null != koma)
                    {
                        switch (koma.Pside)
                        {
                        case Playerside.P1:
                        {
                            SkyBuffer buffer_Sky = new SkyBuffer(ui_PnlMain.ShogiGui.GameViewModel.GuiSkyConst);

                            buffer_Sky.AddOverwriteStarlight(figKoma, new RO_MotionlessStarlight(
                                                                 //figKoma,
                                                                 new RO_Star_Koma(Playerside.P2,
                                                                                  koma.Masu,
                                                                                  Haiyaku184Array.Syurui(koma.Haiyaku))
                                                                 ));

                            KifuNode modifyNode = new KifuNodeImpl(
                                ui_PnlMain.ShogiGui.GameViewModel.Kifu.CurNode.Key,                                //現在の局面を流用
                                new KyokumenWrapper(new SkyConst(buffer_Sky)),
                                ((KifuNode)ui_PnlMain.ShogiGui.GameViewModel.Kifu.CurNode).Tebanside
                                );

                            // ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
                            // ここで局面データを変更します。
                            // ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
                            Util_InServer.SetCurNode_Srv(ui_PnlMain.ShogiGui, modifyNode);
                            ui_PnlMain.ShogiGui.ResponseData.ToRedraw();
                        }
                        break;

                        case Playerside.P2:
                        {
                            SkyBuffer buffer_Sky = new SkyBuffer(ui_PnlMain.ShogiGui.GameViewModel.GuiSkyConst);

                            buffer_Sky.AddOverwriteStarlight(figKoma, new RO_MotionlessStarlight(
                                                                 //figKoma,
                                                                 new RO_Star_Koma(Playerside.P1,
                                                                                  koma.Masu,
                                                                                  Haiyaku184Array.Syurui(koma.Haiyaku))
                                                                 ));

                            KifuNode modifyNode =
                                new KifuNodeImpl(
                                    ui_PnlMain.ShogiGui.GameViewModel.Kifu.CurNode.Key,        //現在の局面を流用
                                    new KyokumenWrapper(new SkyConst(buffer_Sky)),
                                    ((KifuNode)ui_PnlMain.ShogiGui.GameViewModel.Kifu.CurNode).Tebanside
                                    );


                            // ここで局面データを変更します。
                            Util_InServer.SetCurNode_Srv(ui_PnlMain.ShogiGui, modifyNode);
                            ui_PnlMain.ShogiGui.ResponseData.ToRedraw();
                        }
                        break;
                        }
                    }
                };
            }
        }
コード例 #3
0
        public override void Step()
        {
            // 入っているマウス操作イベントは、全部捨てていきます。
            SaiseiEventState[] queue = this.SaiseiEventQueue.ToArray();
            this.SaiseiEventQueue.Clear();
            foreach (SaiseiEventState eventState in queue)
            {
                switch (eventState.Name2)
                {
                case SaiseiEventStateName.Start:
                {
                    #region スタート
                    //MessageBox.Show("再生を実行します2。");

                    shogiGui.ResponseData = new ResponseImpl();

                    this.restText = Util_InGui.ReadLine_FromTextbox();
                    this.SaiseiEventQueue.Enqueue(new SaiseiEventState(SaiseiEventStateName.Step));
                    #endregion
                }
                break;

                case SaiseiEventStateName.Step:
                {
                    #region ステップ

                    // [コマ送り]に成功している間、コマ送りし続けます。
                    bool toBreak = false;
                    Util_InServer.ReadLine_TuginoItteSusumu_Srv(ref restText, shogiGui, out toBreak, "再生ボタン");

                    //TimedC.Saisei_Step(restText, shogiGui, eventState.Flg_logTag);// 再描画(ループが1回も実行されなかったとき用)
                    // 他のアプリが固まらないようにします。
                    Application.DoEvents();

                    // 早すぎると描画されないので、ウェイトを入れます。
                    System.Threading.Thread.Sleep(90);        //45


                    //------------------------------
                    // 再描画
                    //------------------------------
                    Util_InGui.Komaokuri_Gui(restText, shogiGui);        //追加

                    //------------------------------
                    // メナス
                    //------------------------------
                    Util_Menace.Menace(shogiGui);

                    shogiGui.Response("Saisei");        // 再描画

                    if (toBreak)
                    {
                        // 終了
                        this.SaiseiEventQueue.Enqueue(new SaiseiEventState(SaiseiEventStateName.Finished));
                    }
                    else
                    {
                        // 続行
                        this.SaiseiEventQueue.Enqueue(new SaiseiEventState(SaiseiEventStateName.Step));
                    }
                    #endregion
                }
                break;
                }
            }
        }