Esempio n. 1
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public int Perform(string title, string[] items, int selectIndex)
        {
            DDCurtain.SetCurtain();
            DDEngine.FreezeInput();

            for (; ;)
            {
                if (this.MouseUsable)
                {
                    DDMouse.UpdatePos();

                    int musSelIdxY = DDMouse.Y - (this.Y + this.YStep);

                    if (0 <= musSelIdxY)
                    {
                        int musSelIdx = musSelIdxY / this.YStep;

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

                bool chgsel = false;

                if (DDInput.A.IsPound())
                {
                    break;
                }
                if (DDInput.B.IsPound())
                {
                    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.ApplyPos();
                }

                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(title + " (Mouse=" + this.MouseUsable + ")");
                DDPrint.PrintRet();

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

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

            return(selectIndex);
        }
Esempio n. 2
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
        }