Ejemplo n.º 1
0
        private static void MixInput(Button button)
        {
            bool keyDown = 1 <= DDKey.GetInput(button.KeyId);
            bool btnDown = 1 <= DDPad.GetInput(DDGround.PrimaryPadId, button.BtnId);

            DDUtils.UpdateInput(ref button.Status, keyDown || btnDown);
        }
Ejemplo n.º 2
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public void PadConfig()
        {
            ButtonInfo[] btnInfos = new ButtonInfo[]
            {
                // app > @ btnInfos

                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.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, ""),

                // < app
            };

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

            try
            {
                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:

                    DDCurtain.DrawCurtain();

                    if (this.WallColor != null)
                    {
                        DX.DrawBox(0, 0, DDConsts.Screen_W, DDConsts.Screen_H, DDUtils.GetColor(this.WallColor.Value), 1);
                    }

                    if (this.WallPicture != null)
                    {
                        DDDraw.DrawRect(this.WallPicture, 0, 0, DDConsts.Screen_W, DDConsts.Screen_H);
                        //DDDraw.DrawCenter(this.WallPicture, DDConsts.Screen_W / 2.0, DDConsts.Screen_H / 2.0); // old
                        DDCurtain.DrawCurtain(this.WallCurtain);
                    }
                    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.Print("ゲームパッドのボタン設定");
                    DDPrint.PrintRet();

                    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);
                            }
                        }
                        DDPrint.PrintRet();
                    }
                    DDPrint.Print("★ カーソルの機能に割り当てるボタンを押して下さい。");
                    DDPrint.PrintRet();
                    DDPrint.Print("★ [Z]を押すとボタンの割り当てをスキップします。");
                    DDPrint.PrintRet();
                    DDPrint.Print("★ スペースを押すとキャンセルします。");
                    DDPrint.PrintRet();

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

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

                    DDEngine.EachFrame();
                }
                btnInfos = null;
            }
            finally
            {
                if (btnInfos != null)
                {
                    foreach (ButtonInfo info in btnInfos)
                    {
                        info.Button.Restore();
                    }
                }

                DDEngine.FreezeInput();
            }
        }
Ejemplo n.º 3
0
        public static void EachFrame()
        {
            // app > @ enter EachFrame

            //Ground.EL.ExecuteAllTask();

            // < app

            DDGround.EL.ExecuteAllTask();
            DDMouse.ApplyPosNowIfNeeded();
            DDCurtain.EachFrame();

            if (DDSEUtils.EachFrame() == false)
            {
                DDMusicUtils.EachFrame();
            }
            if (DDGround.MainScreen != null && DDSubScreenUtils.CurrDrawScreenHandle == DDGround.MainScreen.GetHandle())
            {
                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();
                    }

                    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();
                    }
                }
            }

            GC.Collect(0);

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

            if (FrameProcessingMillis_Worst < FrameProcessingMillis || DDUtils.CountDown(ref FrameProcessingMillis_WorstFrame) == false)
            {
                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 (IntTools.IMAX < ProcFrame)             // 192.9日程度でカンスト
            {
                ProcFrame = IntTools.IMAX;             // 2bs
                throw new DDError();
            }

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

            if (DDGround.RealScreen_W != DDConsts.Screen_W || DDGround.RealScreen_H != DDConsts.Screen_H || DDGround.RealScreenDraw_W != -1)
            {
                if (DDGround.MainScreen == null)
                {
                    DDGround.MainScreen = new DDSubScreen(DDConsts.Screen_W, DDConsts.Screen_H);
                }

                DDGround.MainScreen.ChangeDrawScreen();
            }
            else
            {
                if (DDGround.MainScreen != null)
                {
                    DDGround.MainScreen.Dispose();
                    DDGround.MainScreen = null;
                }
            }

            // app > @ leave EachFrame

            // < app
        }