public void WindowSizeConfig() { string[] items = new string[] { string.Format("{0} x {1} (デフォルト)", DDConsts.Screen_W, DDConsts.Screen_H), string.Format("{0} x {1}", WinSzExp(DDConsts.Screen_W, 1), WinSzExp(DDConsts.Screen_H, 1)), string.Format("{0} x {1}", WinSzExp(DDConsts.Screen_W, 2), WinSzExp(DDConsts.Screen_H, 2)), string.Format("{0} x {1}", WinSzExp(DDConsts.Screen_W, 3), WinSzExp(DDConsts.Screen_H, 3)), string.Format("{0} x {1}", WinSzExp(DDConsts.Screen_W, 4), WinSzExp(DDConsts.Screen_H, 4)), string.Format("{0} x {1}", WinSzExp(DDConsts.Screen_W, 5), WinSzExp(DDConsts.Screen_H, 5)), string.Format("{0} x {1}", WinSzExp(DDConsts.Screen_W, 6), WinSzExp(DDConsts.Screen_H, 6)), string.Format("{0} x {1}", WinSzExp(DDConsts.Screen_W, 7), WinSzExp(DDConsts.Screen_H, 7)), string.Format("{0} x {1}", WinSzExp(DDConsts.Screen_W, 8), WinSzExp(DDConsts.Screen_H, 8)), string.Format("{0} x {1}", WinSzExp(DDConsts.Screen_W, 9), WinSzExp(DDConsts.Screen_H, 9)), string.Format("{0} x {1}", WinSzExp(DDConsts.Screen_W, 10), WinSzExp(DDConsts.Screen_H, 10)), "フルスクリーン 画面に合わせる (非推奨)", "フルスクリーン 縦横比を維持する (推奨)", "戻る", }; int selectIndex = 0; for (; ;) { selectIndex = Perform("ウィンドウサイズ設定", items, selectIndex); switch (selectIndex) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: DDMain.SetScreenSize(WinSzExp(DDConsts.Screen_W, selectIndex), WinSzExp(DDConsts.Screen_H, selectIndex)); break; case 11: DDMain.SetScreenSize(DDGround.MonitorRect.W, DDGround.MonitorRect.H); break; case 12: DDMain.SetFullScreen(); break; case 13: goto endLoop; default: throw new DDError(); } } endLoop: ; }
public static void Perform(Action routine) { List <Exception> errors = new List <Exception>(); try { DDMain.GameStart(); try { routine(); } catch (DDCoffeeBreak) { } catch (Exception e) { errors.Add(e); } } catch (Exception e) { errors.Add(e); } DDMain.GameEnd(errors); if (1 <= errors.Count) { throw new AggregateException("ゲーム中にエラーが発生しました。", errors); } }
public static IntPtr GetMainWindowHandle() { if (MainWindowHandle == null) { string markTitle = Guid.NewGuid().ToString("B"); IntPtr handle = IntPtr.Zero; bool handleFound = false; DX.SetMainWindowText(markTitle); EnumWindowsHandleTitle((hWnd, title) => { if (title == markTitle) { handle = hWnd; handleFound = true; return(false); } return(true); }); if (!handleFound) { throw new DDError(); } DDMain.SetMainWindowTitle(); MainWindowHandle = handle; } return(MainWindowHandle.Value); }
public static void SetFullScreen() { int w = DDGround.MonitorRect.W; int h = (DDConsts.Screen_H * DDGround.MonitorRect.W) / DDConsts.Screen_W; if (DDGround.MonitorRect.H < h) { h = DDGround.MonitorRect.H; w = (DDConsts.Screen_W * DDGround.MonitorRect.H) / DDConsts.Screen_H; if (DDGround.MonitorRect.W < w) { throw new DDError(); } } DDMain.SetScreenSize(DDGround.MonitorRect.W, DDGround.MonitorRect.H); DDGround.RealScreenDraw_L = (DDGround.MonitorRect.W - w) / 2; DDGround.RealScreenDraw_T = (DDGround.MonitorRect.H - h) / 2; DDGround.RealScreenDraw_W = w; DDGround.RealScreenDraw_H = h; }
public static void EachFrame() { //Ground.EL.ExecuteAllTask(); DDGround.EL.ExecuteAllTask(); DDGround.SystemTasks.ExecuteAllTask(); DispDebug(); DDMouse.PosChanged_Delay(); DDCurtain.EachFrame(); if (!DDSEUtils.EachFrame()) { DDMusicUtils.EachFrame(); } DDSubScreenUtils.ChangeDrawScreen(DX.DX_SCREEN_BACK); if (DDGround.RealScreenDraw_W == -1) { bool mosaicFlag = DDConfig.DrawScreen_MosaicFlag && DDGround.RealScreen_W % DDConsts.Screen_W == 0 && DDGround.RealScreen_H % DDConsts.Screen_H == 0; if (mosaicFlag) { DX.SetDrawMode(DX.DX_DRAWMODE_NEAREST); } if (DX.DrawExtendGraph(0, 0, DDGround.RealScreen_W, DDGround.RealScreen_H, DDGround.MainScreen.GetHandle(), 0) != 0) // ? 失敗 { throw new DDError(); } if (mosaicFlag) { DX.SetDrawMode(DDConsts.DEFAULT_DX_DRAWMODE); // restore } } 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 == 0 && DDGround.RealScreenDraw_H % DDConsts.Screen_H == 0; 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(); }
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.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.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 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.PrintLine("★ カーソルの指す機能に割り当てるキーを押して下さい。"); DDPrint.PrintLine("★ 画面を左クリックするとキーの割り当てをスキップします。(非推奨)"); DDPrint.PrintLine("★ 画面を右クリックするとキャンセルします。"); 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.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 btnId = btnInfos[c].Button.BtnId; DDPrint.Print(" -> "); if (btnId == -1) { DDPrint.Print("割り当てナシ"); } else { DDPrint.Print("" + 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(); } }
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(); } }