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 == false) { throw new DDError(); } DDMain.SetMainWindowTitle(); MainWindowHandle = handle; } return(MainWindowHandle.Value); }
public static void Perform(Action routine) { ExceptionDam.Section(eDam => { eDam.Invoke(() => { DDMain.GameStart(); try { routine(); } catch (DDCoffeeBreak) { } }); DDMain.GameEnd(eDam); }); }
// // copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c // 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: { 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(w, h); } break; case 13: { 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; } break; case 14: goto endLoop; default: throw new DDError(); } } endLoop: ; }