Exemplo n.º 1
0
        public int Perform(int x, int y, int yStep, int fontSize, string title, string[] items, int selectIndex, bool ポーズボタンでメニュー終了 = false, bool noPound = false)
        {
            DDCurtain.SetCurtain();
            DDEngine.FreezeInput();

            for (; ;)
            {
                // ★★★ キー押下は 1 マウス押下は -1 で判定する。

                if (this.MouseUsable)
                {
                    int musSelIdxY = DDMouse.Y - (y + yStep);
                    int musSelIdx  = musSelIdxY / yStep;

                    DDUtils.ToRange(ref musSelIdx, 0, items.Length - 1);

                    selectIndex = musSelIdx;

                    if (DDMouse.L.GetInput() == -1)
                    {
                        break;
                    }
                    if (DDMouse.R.GetInput() == -1)
                    {
                        selectIndex = items.Length - 1;
                        break;
                    }
                }

                if (ポーズボタンでメニュー終了 && DDInput.PAUSE.GetInput() == 1)
                {
                    selectIndex = items.Length - 1;
                    break;
                }

                bool chgsel = false;

                if (DDInput.A.GetInput() == 1)
                {
                    break;
                }
                if (DDInput.B.GetInput() == 1)
                {
                    if (selectIndex == items.Length - 1)
                    {
                        break;
                    }

                    selectIndex = items.Length - 1;
                    chgsel      = true;
                }
                if (noPound ? DDInput.DIR_8.GetInput() == 1 : DDInput.DIR_8.IsPound())
                {
                    selectIndex--;
                    chgsel = true;
                }
                if (noPound ? DDInput.DIR_2.GetInput() == 1 : DDInput.DIR_2.IsPound())
                {
                    selectIndex++;
                    chgsel = true;
                }

                selectIndex += items.Length;
                selectIndex %= items.Length;

                if (this.MouseUsable && chgsel)
                {
                    DDMouse.X = 0;
                    DDMouse.Y = y + (selectIndex + 1) * yStep + yStep / 2;

                    DDMouse.PosChanged();
                }

                this.WallDrawer();
                this.ResetPrint();

                // old
                //DDPrint.SetPrint(DDConsts.Screen_W - 45, 2);
                //DDPrint.Print("[M:" + (this.MouseUsable ? "E" : "D") + "]");

                DDPrint.SetPrint(x, y, yStep, fontSize);
                //DDPrint.SetPrint(16, 16, 32); // old
                DDPrint.PrintLine(title);

                for (int c = 0; c < items.Length; c++)
                {
                    DDPrint.PrintLine(string.Format("[{0}] {1}", selectIndex == c ? ">" : " ", items[c]));
                }
                DDPrint.Reset();

                DDEngine.EachFrame();
            }
            DDEngine.FreezeInput();

            return(selectIndex);
        }
Exemplo n.º 2
0
        public void PadConfig(bool keyMode = false)
        {
            ButtonInfo[] btnInfos = new ButtonInfo[]
            {
#if false // 例
                new ButtonInfo(DDInput.DIR_2, "下"),
                new ButtonInfo(DDInput.DIR_4, "左"),
                new ButtonInfo(DDInput.DIR_6, "右"),
                new ButtonInfo(DDInput.DIR_8, "上"),
                new ButtonInfo(DDInput.A, "Aボタン"),
                new ButtonInfo(DDInput.B, "Bボタン"),
                new ButtonInfo(DDInput.C, "Cボタン"),
                //new ButtonInfo(DDInput.D, ""), // 使用しないボタン
                //new ButtonInfo(DDInput.E, ""), // 使用しないボタン
                //new ButtonInfo(DDInput.F, ""), // 使用しないボタン
                new ButtonInfo(DDInput.L, "Lボタン"),
                new ButtonInfo(DDInput.R, "Rボタン"),
                //new ButtonInfo(DDInput.PAUSE, ""), // 使用しないボタン
                //new ButtonInfo(DDInput.START, ""), // 使用しないボタン
#else
                // アプリ固有の設定 >

                new ButtonInfo(DDInput.DIR_8, "上"),
                new ButtonInfo(DDInput.DIR_2, "下"),
                new ButtonInfo(DDInput.DIR_4, "左"),
                new ButtonInfo(DDInput.DIR_6, "右"),
                new ButtonInfo(DDInput.A, "方向ロック・低速移動/決定"),
                new ButtonInfo(DDInput.B, "攻撃ボタン/キャンセル"),
                new ButtonInfo(DDInput.C, "武器切り替え"),
                //new ButtonInfo(DDInput.D, ""),
                //new ButtonInfo(DDInput.E, ""),
                //new ButtonInfo(DDInput.F, ""),
                new ButtonInfo(DDInput.L, "画面スライド/会話スキップ"),
                new ButtonInfo(DDInput.R, "高速移動"),
                new ButtonInfo(DDInput.PAUSE, "ポーズボタン"),
                //new ButtonInfo(DDInput.START, ""),

                // < アプリ固有の設定
#endif
            };

            foreach (ButtonInfo btnInfo in btnInfos)
            {
                btnInfo.Button.Backup();
            }

            bool?mouseDispModeBk = null;

            try
            {
                if (keyMode)
                {
                    mouseDispModeBk = DDUtils.GetMouseDispMode();
                    DDUtils.SetMouseDispMode(true);

                    foreach (ButtonInfo btnInfo in btnInfos)
                    {
                        btnInfo.Button.KeyId = -1;
                    }

                    DDCurtain.SetCurtain();
                    DDEngine.FreezeInput();

                    int currBtnIndex = 0;

                    while (currBtnIndex < btnInfos.Length)
                    {
                        if (DDMouse.R.GetInput() == -1)
                        {
                            return;
                        }
                        // スキップ禁止
                        //if (DDMouse.L.GetInput() == -1)
                        //{
                        //    currBtnIndex++;
                        //    goto endInput;
                        //}

                        {
                            int pressKeyId = -1;

                            foreach (KeyInfo keyInfo in KeyInfos)
                            {
                                if (DDKey.GetInput(keyInfo.KeyId) == 1)
                                {
                                    pressKeyId = keyInfo.KeyId;
                                }
                            }

                            for (int c = 0; c < currBtnIndex; c++)
                            {
                                if (btnInfos[c].Button.KeyId == pressKeyId)
                                {
                                    pressKeyId = -1;
                                }
                            }

                            if (pressKeyId != -1)
                            {
                                btnInfos[currBtnIndex].Button.KeyId = pressKeyId;
                                currBtnIndex++;
                            }
                        }
                        //endInput:

                        this.WallDrawer();
                        this.ResetPrint();
                        DDPrint.SetPrint(20, 20, 40, 20);
                        DDPrint.PrintLine("キーボードのキー設定");

                        for (int c = 0; c < btnInfos.Length; c++)
                        {
                            DDPrint.Print(string.Format("[{0}] {1}", currBtnIndex == c ? ">" : " ", btnInfos[c].Name));

                            if (c < currBtnIndex)
                            {
                                int keyId = btnInfos[c].Button.KeyId;

                                DDPrint.Print(" >>> ");

                                if (keyId == -1)
                                {
                                    DDPrint.Print("割り当てナシ");
                                }
                                else
                                {
                                    DDPrint.Print(KeyInfos.First(keyInfo => keyInfo.KeyId == keyId).Name);
                                }
                            }
                            DDPrint.PrintRet();
                        }
                        DDPrint.SetPrint(450, 420, 40, 20);
                        //DDPrint.SetPrint(410, 380, 40, 20); // スキップ禁止
                        DDPrint.PrintLine("/// TIPS ///");
                        DDPrint.PrintLine("カーソルの指す機能に割り当てるキーを押して下さい。");
                        //DDPrint.PrintLine("画面を左クリックするとキーの割り当てをスキップします。"); // スキップ禁止
                        DDPrint.SetColor(new I3Color(255, 255, 0));
                        DDPrint.SetBorder(new I3Color(100, 50, 0));
                        DDPrint.PrintLine("画面を右クリックするとキャンセルします。");
                        this.ResetPrint();

                        DDEngine.EachFrame();
                    }
                }
                else
                {
                    foreach (ButtonInfo btnInfo in btnInfos)
                    {
                        btnInfo.Button.BtnId = -1;
                    }

                    DDCurtain.SetCurtain();
                    DDEngine.FreezeInput();

                    int currBtnIndex = 0;

                    while (currBtnIndex < btnInfos.Length)
                    {
                        if (DDKey.GetInput(DX.KEY_INPUT_SPACE) == 1)
                        {
                            return;
                        }
                        if (DDKey.GetInput(DX.KEY_INPUT_Z) == 1)
                        {
                            currBtnIndex++;
                            goto endInput;
                        }

                        {
                            int pressBtnId = -1;

                            for (int padId = 0; padId < DDPad.GetPadCount(); padId++)
                            {
                                for (int btnId = 0; btnId < DDPad.PAD_BUTTON_MAX; btnId++)
                                {
                                    if (DDPad.GetInput(padId, btnId) == 1)
                                    {
                                        pressBtnId = btnId;
                                    }
                                }
                            }

                            for (int c = 0; c < currBtnIndex; c++)
                            {
                                if (btnInfos[c].Button.BtnId == pressBtnId)
                                {
                                    pressBtnId = -1;
                                }
                            }

                            if (pressBtnId != -1)
                            {
                                btnInfos[currBtnIndex].Button.BtnId = pressBtnId;
                                currBtnIndex++;
                            }
                        }
endInput:

                        this.WallDrawer();
                        this.ResetPrint();
                        DDPrint.SetPrint(20, 20, 40, 20);
                        DDPrint.PrintLine("ゲームパッドのボタン設定");

                        for (int c = 0; c < btnInfos.Length; c++)
                        {
                            DDPrint.Print(string.Format("[{0}] {1}", currBtnIndex == c ? ">" : " ", btnInfos[c].Name));

                            if (c < currBtnIndex)
                            {
                                int btnId = btnInfos[c].Button.BtnId;

                                DDPrint.Print(" >>> ");

                                if (btnId == -1)
                                {
                                    DDPrint.Print("割り当てナシ");
                                }
                                else
                                {
                                    DDPrint.Print(btnId.ToString("D2"));
                                }
                            }
                            DDPrint.PrintRet();
                        }
                        DDPrint.SetPrint(430, 380, 40, 20);
                        DDPrint.PrintLine("/// TIPS ///");
                        DDPrint.PrintLine("カーソルの指す機能に割り当てるボタンを押して下さい。");
                        DDPrint.PrintLine("Zキーを押すとボタンの割り当てをスキップします。");
                        DDPrint.SetColor(new I3Color(255, 255, 0));
                        DDPrint.SetBorder(new I3Color(100, 50, 0));

                        if (this.MouseUsable)
                        {
                            DDPrint.PrintLine("スペースキーまたは右クリックするとキャンセルします。");

                            if (DDMouse.R.GetInput() == -1)
                            {
                                return;
                            }
                        }
                        else
                        {
                            DDPrint.PrintLine("スペースキーを押すとキャンセルします。");
                        }

                        this.ResetPrint();

                        DDEngine.EachFrame();
                    }
                }
                btnInfos = null;

                // 最後の画面を維持
                {
                    DDMain.KeepMainScreen();

                    for (int c = 0; c < 30; c++)
                    {
                        DDDraw.DrawSimple(DDGround.KeptMainScreen.ToPicture(), 0, 0);
                        DDEngine.EachFrame();
                    }
                }
            }
            finally
            {
                if (btnInfos != null)
                {
                    foreach (ButtonInfo info in btnInfos)
                    {
                        info.Button.Restore();
                    }
                }

                if (mouseDispModeBk != null)
                {
                    DDUtils.SetMouseDispMode(mouseDispModeBk.Value);
                }

                DDEngine.FreezeInput();
            }
        }
Exemplo n.º 3
0
        public int IntVolumeConfig(string title, int value, int minval, int maxval, int valStep, int valFastStep, Action <int> valChanged, Action pulse)
        {
            const int PULSE_FRM = 60;

            int origval = value;

            DDCurtain.SetCurtain();
            DDEngine.FreezeInput();

            for (; ;)
            {
                bool chgval = false;

                if (DDInput.A.GetInput() == 1 || this.MouseUsable && DDMouse.L.GetInput() == -1)
                {
                    break;
                }
                if (DDInput.B.GetInput() == 1 || this.MouseUsable && DDMouse.R.GetInput() == -1)
                {
                    if (value == origval)
                    {
                        break;
                    }

                    value  = origval;
                    chgval = true;
                }
                if (this.MouseUsable)
                {
                    value += DDMouse.Rot;
                    chgval = true;
                }
                if (DDInput.DIR_8.IsPound())
                {
                    value += valFastStep;
                    chgval = true;
                }
                if (DDInput.DIR_6.IsPound())
                {
                    value += valStep;
                    chgval = true;
                }
                if (DDInput.DIR_4.IsPound())
                {
                    value -= valStep;
                    chgval = true;
                }
                if (DDInput.DIR_2.IsPound())
                {
                    value -= valFastStep;
                    chgval = true;
                }
                if (chgval)
                {
                    value = SCommon.ToRange(value, minval, maxval);
                    valChanged(value);
                }
                if (DDEngine.ProcFrame % PULSE_FRM == 0)
                {
                    pulse();
                }

                this.WallDrawer();
                this.ResetPrint();

                DDPrint.SetPrint(40, 40, 40);
                DDPrint.PrintLine(title);
                //DDPrint.PrintLine(string.Format("[{0}] 最小={1} 最大={2}", value, minval, maxval)); // old
                DDPrint.SetPrint(40, 170, 40);
                DDPrint.PrintLine(GetMeterString(value, minval, maxval, 67));

                if (this.MouseUsable)
                {
                    DDPrint.SetPrint(210, 320, 40);
                    DDPrint.PrintLine("/// TIPS ///");
                    DDPrint.PrintLine("右・ホイール上・上 = 上げる");
                    DDPrint.PrintLine("左・ホイール下・下 = 下げる");
                    DDPrint.PrintLine("調整が終わったら左クリック・決定ボタンを押して下さい。");
                    DDPrint.PrintLine("右クリック・キャンセルボタンを押すと変更をキャンセルします。");
                }
                else
                {
                    DDPrint.SetPrint(345, 320, 40);
                    DDPrint.PrintLine("/// TIPS ///");
                    DDPrint.PrintLine("右 または 上 = 上げる");
                    DDPrint.PrintLine("左 または 下 = 下げる");
                    DDPrint.PrintLine("調整が終わったら決定ボタンを押して下さい。");
                    DDPrint.PrintLine("キャンセルボタンを押すと変更をキャンセルします。");
                }
                DDPrint.Reset();

                DDEngine.EachFrame();
            }
            DDEngine.FreezeInput();

            return(value);
        }
Exemplo n.º 4
0
        public static void EachFrame()
        {
            //Ground.EL.ExecuteAllTask();

            DDGround.EL.ExecuteAllTask();
            DispDebug();
            DDMouse.PosChanged_Delay();
            DDCurtain.EachFrame();

            if (!DDSEUtils.EachFrame())
            {
                DDMusicUtils.EachFrame();
            }

            DDSubScreenUtils.ChangeDrawScreen(DX.DX_SCREEN_BACK);

            if (DDGround.RealScreenDraw_W == -1)
            {
                if (DX.DrawExtendGraph(0, 0, DDGround.RealScreen_W, DDGround.RealScreen_H, DDGround.MainScreen.GetHandle(), 0) != 0)                 // ? 失敗
                {
                    throw new DDError();
                }
            }
            else
            {
                if (DX.DrawBox(0, 0, DDGround.RealScreen_W, DDGround.RealScreen_H, DX.GetColor(0, 0, 0), 1) != 0)                 // ? 失敗
                {
                    throw new DDError();
                }

                bool mosaicFlag =
                    DDConfig.DrawScreen_MosaicFlag &&
                    DDGround.RealScreenDraw_W == DDConsts.Screen_W * 2 &&
                    DDGround.RealScreenDraw_H == DDConsts.Screen_H * 2;

                if (mosaicFlag)
                {
                    DX.SetDrawMode(DX.DX_DRAWMODE_NEAREST);
                }

                if (DX.DrawExtendGraph(
                        DDGround.RealScreenDraw_L,
                        DDGround.RealScreenDraw_T,
                        DDGround.RealScreenDraw_L + DDGround.RealScreenDraw_W,
                        DDGround.RealScreenDraw_T + DDGround.RealScreenDraw_H, DDGround.MainScreen.GetHandle(), 0) != 0)                 // ? 失敗
                {
                    throw new DDError();
                }

                if (mosaicFlag)
                {
                    DX.SetDrawMode(DDConsts.DEFAULT_DX_DRAWMODE);                     // restore
                }
            }

            GC.Collect(0);

            FrameProcessingMillis = (int)(DDUtils.GetCurrTime() - FrameStartTime);

            if (FrameProcessingMillis_Worst < FrameProcessingMillis || !DDUtils.CountDown(ref FrameProcessingMillis_WorstFrame))
            {
                FrameProcessingMillis_Worst      = FrameProcessingMillis;
                FrameProcessingMillis_WorstFrame = 120;
            }

            // DxLib >

            DX.ScreenFlip();

            if (DX.CheckHitKey(DX.KEY_INPUT_ESCAPE) == 1 || DX.ProcessMessage() == -1)
            {
                throw new DDCoffeeBreak();
            }

            // < DxLib

            CheckHz();

            ProcFrame++;
            DDUtils.CountDown(ref FreezeInputFrame);
            WindowIsActive = DDUtils.IsWindowActive();

            if (SCommon.IMAX < ProcFrame)             // 192.9日程度でカンスト
            {
                ProcFrame = SCommon.IMAX;             // 2bs
                throw new DDError();
            }

            DDPad.EachFrame();
            DDKey.EachFrame();
            DDInput.EachFrame();
            DDMouse.EachFrame();

            // Swap MainScreen
            {
                DDSubScreen tmp = DDGround.MainScreen;
                DDGround.MainScreen     = DDGround.LastMainScreen;
                DDGround.LastMainScreen = tmp;
            }

            DDGround.MainScreen.ChangeDrawScreen();

            // ? ALT + ENTER -> フルスクリーン切り替え
            if ((1 <= DDKey.GetInput(DX.KEY_INPUT_LALT) || 1 <= DDKey.GetInput(DX.KEY_INPUT_RALT)) && DDKey.GetInput(DX.KEY_INPUT_RETURN) == 1)
            {
                // ? 現在フルスクリーン -> フルスクリーン解除
                if (
                    DDGround.RealScreen_W == DDGround.MonitorRect.W &&
                    DDGround.RealScreen_H == DDGround.MonitorRect.H
                    )
                {
                    DDMain.SetScreenSize(DDGround.UnfullScreen_W, DDGround.UnfullScreen_H);
                }
                else                 // ? 現在フルスクリーンではない -> フルスクリーンにする
                {
                    DDGround.UnfullScreen_W = DDGround.RealScreen_W;
                    DDGround.UnfullScreen_H = DDGround.RealScreen_H;

                    DDMain.SetFullScreen();
                }
                DDEngine.FreezeInput(30);                 // エンターキー押下がゲームに影響しないように
            }

            //DX.ClearDrawScreen();
        }
Exemplo n.º 5
0
        public int IntVolumeConfig(string title, int value, int minval, int maxval, int valStep, int valFastStep, Action <int> valChanged, Action pulse)
        {
            const int PULSE_FRM = 60;

            int origval = value;

            DDCurtain.SetCurtain();
            DDEngine.FreezeInput();

            for (; ;)
            {
                bool chgval = false;

                if (DDInput.A.GetInput() == 1 || this.MouseUsable && DDMouse.L.GetInput() == -1)
                {
                    break;
                }
                if (DDInput.B.GetInput() == 1 || this.MouseUsable && DDMouse.R.GetInput() == -1)
                {
                    if (value == origval)
                    {
                        break;
                    }

                    value  = origval;
                    chgval = true;
                }
                if (this.MouseUsable)
                {
                    value += DDMouse.Rot;
                    chgval = true;
                }
                if (DDInput.DIR_8.IsPound())
                {
                    value += valFastStep;
                    chgval = true;
                }
                if (DDInput.DIR_6.IsPound())
                {
                    value += valStep;
                    chgval = true;
                }
                if (DDInput.DIR_4.IsPound())
                {
                    value -= valStep;
                    chgval = true;
                }
                if (DDInput.DIR_2.IsPound())
                {
                    value -= valFastStep;
                    chgval = true;
                }
                if (chgval)
                {
                    value = SCommon.ToRange(value, minval, maxval);
                    valChanged(value);
                }
                if (DDEngine.ProcFrame % PULSE_FRM == 0)
                {
                    pulse();
                }

                this.DrawWall();

                if (this.Color != null)
                {
                    DDPrint.SetColor(this.Color.Value);
                }

                if (this.BorderColor != null)
                {
                    DDPrint.SetBorder(this.BorderColor.Value);
                }

                DDPrint.SetPrint(this.X, this.Y, this.YStep);
                DDPrint.PrintLine(title);
                DDPrint.PrintLine(string.Format("[{0}] 最小={1} 最大={2}", value, minval, maxval));

                if (this.MouseUsable)
                {
                    DDPrint.PrintLine("★ ホイール上・右=上げる");
                    DDPrint.PrintLine("★ ホイール下・左=下げる");
                    DDPrint.PrintLine("★ 上=速く上げる");
                    DDPrint.PrintLine("★ 下=速く下げる");
                    DDPrint.PrintLine("★ 調整が終わったら左クリック・決定ボタンを押して下さい。");
                    DDPrint.PrintLine("★ 右クリック・キャンセルボタンを押すと変更をキャンセルします。");
                }
                else
                {
                    DDPrint.PrintLine("★ 右=上げる");
                    DDPrint.PrintLine("★ 左=下げる");
                    DDPrint.PrintLine("★ 上=速く上げる");
                    DDPrint.PrintLine("★ 下=速く下げる");
                    DDPrint.PrintLine("★ 調整が終わったら決定ボタンを押して下さい。");
                    DDPrint.PrintLine("★ キャンセルボタンを押すと変更をキャンセルします。");
                }
                DDPrint.Reset();

                DDEngine.EachFrame();
            }
            DDEngine.FreezeInput();

            return(value);
        }
Exemplo n.º 6
0
        public int Perform(string title, string[] items, int selectIndex)
        {
            DDCurtain.SetCurtain();
            DDEngine.FreezeInput();

            for (; ;)
            {
                // ★★★ キー押下は 1 マウス押下は -1 で判定する。

                if (this.MouseUsable)
                {
                    int musSelIdxY = DDMouse.Y - (this.Y + this.YStep);
                    int musSelIdx  = musSelIdxY / this.YStep;

                    DDUtils.ToRange(ref musSelIdx, 0, items.Length - 1);

                    selectIndex = musSelIdx;

                    if (DDMouse.L.GetInput() == -1)
                    {
                        break;
                    }
                    if (DDMouse.R.GetInput() == -1)
                    {
                        selectIndex = items.Length - 1;
                        break;
                    }
                }

                bool chgsel = false;

                if (DDInput.A.GetInput() == 1)
                {
                    break;
                }
                if (DDInput.B.GetInput() == 1)
                {
                    if (selectIndex == items.Length - 1)
                    {
                        break;
                    }

                    selectIndex = items.Length - 1;
                    chgsel      = true;
                }
                if (DDInput.DIR_8.IsPound())
                {
                    selectIndex--;
                    chgsel = true;
                }
                if (DDInput.DIR_2.IsPound())
                {
                    selectIndex++;
                    chgsel = true;
                }

                selectIndex += items.Length;
                selectIndex %= items.Length;

                if (this.MouseUsable && chgsel)
                {
                    DDMouse.X = 0;
                    DDMouse.Y = this.Y + (selectIndex + 1) * this.YStep + this.YStep / 2;

                    DDMouse.PosChanged();
                }

                this.DrawWall();

                if (this.Color != null)
                {
                    DDPrint.SetColor(this.Color.Value);
                }

                if (this.BorderColor != null)
                {
                    DDPrint.SetBorder(this.BorderColor.Value);
                }

                DDPrint.SetPrint(DDConsts.Screen_W - 80, 4);
                DDPrint.Print("[M:" + (this.MouseUsable ? "E" : "D") + "]");

                DDPrint.SetPrint(this.X, this.Y, this.YStep);
                //DDPrint.SetPrint(16, 16, 32); // old
                DDPrint.PrintLine(title);

                for (int c = 0; c < items.Length; c++)
                {
                    DDPrint.PrintLine(string.Format("[{0}] {1}", selectIndex == c ? ">" : " ", items[c]));
                }
                DDPrint.Reset();

                DDEngine.EachFrame();
            }
            DDEngine.FreezeInput();

            return(selectIndex);
        }
Exemplo n.º 7
0
        public void PadConfig(bool keyMode = false)
        {
            ButtonInfo[] btnInfos = new ButtonInfo[]
            {
#if false // 例
                new ButtonInfo(DDInput.DIR_2, "下"),
                new ButtonInfo(DDInput.DIR_4, "左"),
                new ButtonInfo(DDInput.DIR_6, "右"),
                new ButtonInfo(DDInput.DIR_8, "上"),
                new ButtonInfo(DDInput.A, "Aボタン"),
                new ButtonInfo(DDInput.B, "Bボタン"),
                new ButtonInfo(DDInput.C, "Cボタン"),
                //new ButtonInfo(DDInput.D, ""), // 使用しないボタン
                //new ButtonInfo(DDInput.E, ""), // 使用しないボタン
                //new ButtonInfo(DDInput.F, ""), // 使用しないボタン
                new ButtonInfo(DDInput.L, "Lボタン"),
                new ButtonInfo(DDInput.R, "Rボタン"),
                //new ButtonInfo(DDInput.PAUSE, ""), // 使用しないボタン
                //new ButtonInfo(DDInput.START, ""), // 使用しないボタン
#else
                // アプリ固有の設定 >

                new ButtonInfo(DDInput.DIR_2, "下"),
                new ButtonInfo(DDInput.DIR_4, "左"),
                new ButtonInfo(DDInput.DIR_6, "右"),
                new ButtonInfo(DDInput.DIR_8, "上"),
                new ButtonInfo(DDInput.A, "決定"),
                new ButtonInfo(DDInput.B, "キャンセル"),
                //new ButtonInfo(DDInput.C, ""),
                //new ButtonInfo(DDInput.E, ""),
                //new ButtonInfo(DDInput.F, ""),
                new ButtonInfo(DDInput.L, "メッセージ・スキップ"),
                //new ButtonInfo(DDInput.R, ""),
                //new ButtonInfo(DDInput.PAUSE, ""),
                //new ButtonInfo(DDInput.START, ""),

                // < アプリ固有の設定
#endif
            };

            foreach (ButtonInfo btnInfo in btnInfos)
            {
                btnInfo.Button.Backup();
            }

            bool?mouseDispModeBk = null;

            try
            {
                if (keyMode)
                {
                    mouseDispModeBk = DDUtils.GetMouseDispMode();
                    DDUtils.SetMouseDispMode(true);

                    foreach (ButtonInfo btnInfo in btnInfos)
                    {
                        btnInfo.Button.KeyIds = new int[0];
                    }

                    DDCurtain.SetCurtain();
                    DDEngine.FreezeInput();

                    int currBtnIndex = 0;

                    while (currBtnIndex < btnInfos.Length)
                    {
                        if (DDMouse.R.GetInput() == -1)
                        {
                            return;
                        }
                        if (DDMouse.L.GetInput() == -1)
                        {
                            currBtnIndex++;
                            goto endInput;
                        }

                        {
                            int pressKeyId = -1;

                            foreach (KeyInfo keyInfo in KeyInfos)
                            {
                                if (DDKey.GetInput(keyInfo.KeyId) == 1)
                                {
                                    pressKeyId = keyInfo.KeyId;
                                }
                            }

                            for (int c = 0; c < currBtnIndex; c++)
                            {
                                if (btnInfos[c].Button.KeyIds.Any(keyId => keyId == pressKeyId))
                                {
                                    pressKeyId = -1;
                                }
                            }

                            if (pressKeyId != -1)
                            {
                                int[] keyIds;

                                switch (pressKeyId)
                                {
                                case DX.KEY_INPUT_LCONTROL:
                                case DX.KEY_INPUT_RCONTROL:
                                    keyIds = new int[] { DX.KEY_INPUT_LCONTROL, DX.KEY_INPUT_RCONTROL };
                                    break;

                                case DX.KEY_INPUT_LSHIFT:
                                case DX.KEY_INPUT_RSHIFT:
                                    keyIds = new int[] { DX.KEY_INPUT_LSHIFT, DX.KEY_INPUT_RSHIFT };
                                    break;

                                case DX.KEY_INPUT_LALT:
                                case DX.KEY_INPUT_RALT:
                                    keyIds = new int[] { DX.KEY_INPUT_LALT, DX.KEY_INPUT_RALT };
                                    break;

                                default:
                                    keyIds = new int[] { pressKeyId };
                                    break;
                                }
                                btnInfos[currBtnIndex].Button.KeyIds = keyIds;
                                currBtnIndex++;
                            }
                        }
endInput:

                        this.DrawWall();

                        if (this.Color != null)
                        {
                            DDPrint.SetColor(this.Color.Value);
                        }

                        if (this.BorderColor != null)
                        {
                            DDPrint.SetBorder(this.BorderColor.Value);
                        }

                        DDPrint.SetPrint(this.X, this.Y, this.YStep);
                        //DDPrint.SetPrint(16, 16, 32); // old
                        DDPrint.PrintLine("キーボードのキー設定");

                        for (int c = 0; c < btnInfos.Length; c++)
                        {
                            DDPrint.Print(string.Format("[{0}] {1}", currBtnIndex == c ? ">" : " ", btnInfos[c].Name));

                            if (c < currBtnIndex)
                            {
                                int[] keyIds = btnInfos[c].Button.KeyIds;

                                DDPrint.Print(" -> ");

                                if (keyIds.Length == 0)
                                {
                                    DDPrint.Print("割り当てナシ");
                                }
                                else
                                {
                                    DDPrint.Print(string.Join(", ", keyIds.Select(keyId => KeyInfos.First(keyInfo => keyInfo.KeyId == keyId).Name)));
                                }
                            }
                            DDPrint.PrintRet();
                        }
                        DDPrint.PrintLine("★ カーソルの指す機能に割り当てるキーを押して下さい。");
                        DDPrint.PrintLine("★ 画面を左クリックするとキーの割り当てをスキップします。(非推奨)");
                        DDPrint.PrintLine("★ 画面を右クリックするとキャンセルします。");

                        DDEngine.EachFrame();
                    }
                }
                else
                {
                    foreach (ButtonInfo btnInfo in btnInfos)
                    {
                        btnInfo.Button.BtnIds = new int[0];
                    }

                    DDCurtain.SetCurtain();
                    DDEngine.FreezeInput();

                    int currBtnIndex = 0;

                    while (currBtnIndex < btnInfos.Length)
                    {
                        if (DDKey.GetInput(DX.KEY_INPUT_SPACE) == 1)
                        {
                            return;
                        }
                        if (DDKey.GetInput(DX.KEY_INPUT_Z) == 1)
                        {
                            currBtnIndex++;
                            goto endInput;
                        }

                        {
                            int pressBtnId = -1;

                            for (int padId = 0; padId < DDPad.GetPadCount(); padId++)
                            {
                                for (int btnId = 0; btnId < DDPad.PAD_BUTTON_MAX; btnId++)
                                {
                                    if (DDPad.GetInput(padId, btnId) == 1)
                                    {
                                        pressBtnId = btnId;
                                    }
                                }
                            }

                            for (int c = 0; c < currBtnIndex; c++)
                            {
                                if (btnInfos[c].Button.BtnIds.Any(btnId => btnId == pressBtnId))
                                {
                                    pressBtnId = -1;
                                }
                            }

                            if (pressBtnId != -1)
                            {
                                btnInfos[currBtnIndex].Button.BtnIds = new int[] { pressBtnId };
                                currBtnIndex++;
                            }
                        }
endInput:

                        this.DrawWall();

                        if (this.Color != null)
                        {
                            DDPrint.SetColor(this.Color.Value);
                        }

                        if (this.BorderColor != null)
                        {
                            DDPrint.SetBorder(this.BorderColor.Value);
                        }

                        DDPrint.SetPrint(this.X, this.Y, this.YStep);
                        //DDPrint.SetPrint(16, 16, 32); // old
                        DDPrint.PrintLine("ゲームパッドのボタン設定");

                        for (int c = 0; c < btnInfos.Length; c++)
                        {
                            DDPrint.Print(string.Format("[{0}] {1}", currBtnIndex == c ? ">" : " ", btnInfos[c].Name));

                            if (c < currBtnIndex)
                            {
                                int[] btnIds = btnInfos[c].Button.BtnIds;

                                DDPrint.Print(" -> ");

                                if (btnIds.Length == 0)
                                {
                                    DDPrint.Print("割り当てナシ");
                                }
                                else
                                {
                                    DDPrint.Print(string.Join(", ", btnIds.Select(btnId => "" + btnId)));
                                }
                            }
                            DDPrint.PrintRet();
                        }
                        DDPrint.PrintLine("★ カーソルの指す機能に割り当てるボタンを押して下さい。");
                        DDPrint.PrintLine("★ [Z]キーを押すとボタンの割り当てをスキップします。");
                        DDPrint.PrintLine("★ スペースキーを押すとキャンセルします。");

                        if (this.MouseUsable)
                        {
                            DDPrint.PrintLine("★ 右クリックするとキャンセルします。");

                            if (DDMouse.R.GetInput() == -1)
                            {
                                return;
                            }
                        }

                        DDEngine.EachFrame();
                    }
                }
                btnInfos = null;

                // 最後の画面を維持
                {
                    DDMain.KeepMainScreen();

                    for (int c = 0; c < 30; c++)
                    {
                        DDDraw.DrawSimple(DDGround.KeptMainScreen.ToPicture(), 0, 0);
                        DDEngine.EachFrame();
                    }
                }
            }
            finally
            {
                if (btnInfos != null)
                {
                    foreach (ButtonInfo info in btnInfos)
                    {
                        info.Button.Restore();
                    }
                }

                if (mouseDispModeBk != null)
                {
                    DDUtils.SetMouseDispMode(mouseDispModeBk.Value);
                }

                DDEngine.FreezeInput();
            }
        }
Exemplo n.º 8
0
        public void Perform()
        {
            if (this.Columns.Count == 0)             // ? 列が無い。
            {
                throw new DDError();
            }

            foreach (ColumnInfo column in this.Columns)
            {
                if (column.Items.Count == 0)                 // ? 列に項目が無い。
                {
                    throw new DDError();
                }
            }

            // 最終項目(一番右の列の一番下の項目)の位置
            //
            int lastItem_X = this.Columns.Count - 1;
            int lastItem_Y = this.Columns[lastItem_X].Items.Count - 1;

            DDCurtain.SetCurtain();
            DDEngine.FreezeInput();

            for (; ;)
            {
                // 最終項目を「終了」と見なす。

                if (DDInput.PAUSE.GetInput() == 1)                 // 即_終了
                {
                    this.Selected_X = lastItem_X;
                    this.Selected_Y = lastItem_Y;
                    break;
                }
                if (DDInput.A.GetInput() == 1)                 // 決定
                {
                    break;
                }
                if (DDInput.B.GetInput() == 1)                 // 一旦カーソルを終了に合わせて、尚もボタンが押されたら終了する。
                {
                    if (
                        this.Selected_X == lastItem_X &&
                        this.Selected_Y == lastItem_Y
                        )
                    {
                        break;
                    }

                    this.Selected_X = lastItem_X;
                    this.Selected_Y = lastItem_Y;
                }

                bool へ移動した  = false;
                bool 横へ移動した = false;

                if (DDInput.DIR_8.IsPound())
                {
                    this.Selected_Y--;
                    へ移動した = true;
                }
                if (DDInput.DIR_2.IsPound())
                {
                    this.Selected_Y++;
                }
                if (DDInput.DIR_4.IsPound())
                {
                    this.Selected_X--;
                    横へ移動した = true;
                }
                if (DDInput.DIR_6.IsPound())
                {
                    this.Selected_X++;
                    横へ移動した = true;
                }

                this.Selected_X += this.Columns.Count;
                this.Selected_X %= this.Columns.Count;

                if (横へ移動した)
                {
                    this.Selected_Y = Math.Min(this.Selected_Y, this.Columns[this.Selected_X].Items.Count - 1);
                }

                this.Selected_Y += this.Columns[this.Selected_X].Items.Count;
                this.Selected_Y %= this.Columns[this.Selected_X].Items.Count;

                if (this.Columns[this.Selected_X].Items[this.Selected_Y].GroupFlag)
                {
                    if (へ移動した)
                    {
                        this.Selected_Y--;
                    }
                    else
                    {
                        this.Selected_Y++;
                    }

                    this.Selected_Y += this.Columns[this.Selected_X].Items.Count;
                    this.Selected_Y %= this.Columns[this.Selected_X].Items.Count;
                }

                this.WallDrawer();

                for (int x = 0; x < this.Columns.Count; x++)
                {
                    ColumnInfo column = this.Columns[x];

                    DDPrint.SetPrint(column.X, this.T, this.YStep, this.FontSize);

                    for (int y = 0; y < column.Items.Count; y++)
                    {
                        ItemInfo item     = column.Items[y];
                        bool     selected = x == this.Selected_X && y == this.Selected_Y;
                        string   line;

                        if (item.GroupFlag)
                        {
                            if (selected)
                            {
                                line = "* " + item.Title;                                 // 通常はここに到達しない。
                            }
                            else
                            {
                                line = item.Title;
                            }
                        }
                        else
                        {
                            if (selected)
                            {
                                line = " [>] " + item.Title;
                            }
                            else
                            {
                                line = " [ ] " + item.Title;
                            }
                        }

                        DDPrint.SetColor(item.Color);
                        DDPrint.SetBorder(item.BorderColor);
                        DDPrint.PrintLine(line);
                        DDPrint.Reset();
                    }
                }
                DDEngine.EachFrame();
            }

            {
                ColumnInfo column = this.Columns[this.Selected_X];
                ItemInfo   item   = column.Items[this.Selected_Y];

                item.A_Desided();
            }

            DDEngine.FreezeInput();

            this.Columns.Clear();
        }