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 static void GameStart()
        {
            foreach (string dllFile in "DxLib.dll:DxLib_x64.dll:DxLibDotNet.dll".Split(':'))             // DxLibDotNet.dll 等の存在確認 (1)
            {
                if (File.Exists(dllFile) == false)
                {
                    throw new DDError();
                }
            }

            DX.GetColor(0, 0, 0);        // DxLibDotNet.dll 等の存在確認 (2)

            DDConfig.Load();             // LogFile, LOG_ENABLED 等を含むので真っ先に

            // Log >

            File.WriteAllBytes(DDConfig.LogFile, BinTools.EMPTY);

            ProcMain.WriteLog = message =>
            {
                if (LogCount < DDConfig.LogCountMax)
                {
                    using (StreamWriter writer = new StreamWriter(DDConfig.LogFile, true, Encoding.UTF8))
                    {
                        writer.WriteLine("[" + DateTime.Now + "] " + message);
                    }
                    LogCount++;
                }
            };

            // < Log

            // *.INIT
            {
                DDGround.INIT();
                DDResource.INIT();
                DDDatStrings.INIT();
                DDUserDatStrings.INIT();
                DDFontRegister.INIT();
                DDKey.INIT();
            }

            DDSaveData.Load();

            // DxLib >

            if (DDConfig.LOG_ENABLED)
            {
                DX.SetApplicationLogSaveDirectory(FileTools.MakeFullPath(DDConfig.ApplicationLogSaveDirectory));
            }

            DX.SetOutApplicationLogValidFlag(DDConfig.LOG_ENABLED ? 1 : 0); // DxLib のログを出力 1: する 0: しない

            DX.SetAlwaysRunFlag(1);                                         // ? 非アクティブ時に 1: 動く 0: 止まる

            SetMainWindowTitle();

            //DX.SetGraphMode(DDConsts.Screen_W, DDConsts.Screen_H, 32);
            DX.SetGraphMode(DDGround.RealScreen_W, DDGround.RealScreen_H, 32);
            DX.ChangeWindowMode(1);             // 1: ウィンドウ 0: フルスクリーン

            //DX.SetFullSceneAntiAliasingMode(4, 2); // 適当な値が分からん。フルスクリーン廃止したので不要

            DX.SetWindowIconHandle(GetAppIcon());             // ウィンドウ左上のアイコン

            if (DDConfig.DisplayIndex != -1)
            {
                DX.SetUseDirectDrawDeviceIndex(DDConfig.DisplayIndex);
            }

            if (DX.DxLib_Init() != 0)             // ? 失敗
            {
                throw new DDError();
            }

            Finalizers.Add(() =>
            {
                if (DX.DxLib_End() != 0)                 // ? 失敗
                {
                    throw new DDError();
                }
            });

            DDUtils.SetMouseDispMode(DDGround.RO_MouseDispMode); // ? マウスを表示する。
            DX.SetWindowSizeChangeEnableFlag(0);                 // ウィンドウの右下をドラッグで伸縮 1: する 0: しない

            DX.SetDrawScreen(DX.DX_SCREEN_BACK);
            DX.SetDrawMode(DX.DX_DRAWMODE_BILINEAR);             // これをデフォルトとする。

            // < DxLib

            {
                int l;
                int t;
                int w;
                int h;
                int p1;
                int p2;
                int p3;
                int p4;

                DX.GetDefaultState(out w, out h, out p1, out p2, out l, out t, out p3, out p4);

                if (
                    w < 1 || IntTools.IMAX < w ||
                    h < 1 || IntTools.IMAX < h ||
                    l < -IntTools.IMAX || IntTools.IMAX < l ||
                    t < -IntTools.IMAX || IntTools.IMAX < t
                    )
                {
                    throw new DDError();
                }

                DDGround.MonitorRect = new I4Rect(l, t, w, h);
            }

            PostSetScreenSize(DDGround.RealScreen_W, DDGround.RealScreen_H);

            DDGround.GeneralResource = new DDGeneralResource();

            DDAdditionalEvents.PostGameStart();
            DDAdditionalEvents.PostGameStart_G2();

            DDSaveData.Load_Delay();
        }
Ejemplo n.º 3
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.º 4
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
        }