private static void P2_SetScreenSize(int w, int h) { LiteStatusDlg.StartDisplay("ゲーム画面の位置とサイズを調整しています..."); foreach (DDSubScreen subScreen in DDSubScreenUtils.SubScreens) { subScreen.WasLoaded = subScreen.IsLoaded(); } bool mdm = DDUtils.GetMouseDispMode(); //DDDerivationUtils.UnloadAll(); // moved -> DDPictureUtils.UnloadAll DDPictureUtils.UnloadAll(); DDSubScreenUtils.UnloadAll(); DDFontUtils.UnloadAll(); //DDSoundUtils.UnloadAll(); // 不要 if (DX.SetGraphMode(w, h, 32) != DX.DX_CHANGESCREEN_OK) { throw new DDError(); } DX.SetDrawScreen(DX.DX_SCREEN_BACK); // DDSubScreenUtils.CurrDrawScreenHandle にするべきだが、このフレームだけの問題なので、無難なところで DX_SCREEN_BACK にしておく。 DX.SetDrawMode(DDConsts.DEFAULT_DX_DRAWMODE); DDUtils.SetMouseDispMode(mdm); DDGround.SystemTasks.Delay(1, DDPictureUtils.TouchGlobally); // ウィンドウ位置調整・初回描画を優先するため、遅延する。 //DDPictureUtils.TouchGlobally(); // old //DDTouch.Touch(); // old DDSubScreenUtils.DrawDummyScreenAll(); LiteStatusDlg.EndDisplayDelay(); }
private static void P2_SetScreenSize(int w, int h) { LiteStatusDlg.StartDisplay("ゲーム画面の位置とサイズを調整しています..."); bool mdm = DDUtils.GetMouseDispMode(); //DDDerivationUtils.UnloadAll(); // moved -> DDPictureUtils.UnloadAll DDPictureUtils.UnloadAll(); DDSubScreenUtils.UnloadAll(); DDFontUtils.UnloadAll(); //DDSoundUtils.UnloadAll(); // 不要 if (DX.SetGraphMode(w, h, 32) != DX.DX_CHANGESCREEN_OK) { throw new DDError(); } DX.SetDrawScreen(DX.DX_SCREEN_BACK); // DDSubScreenUtils.CurrDrawScreenHandle にするべきだが、このフレームだけの問題なので、無難なところで DX_SCREEN_BACK にしておく。 DX.SetDrawMode(DDConsts.DEFAULT_DX_DRAWMODE); DDUtils.SetMouseDispMode(mdm); DDTouch.Touch(); DDSubScreenUtils.DrawDummyScreenAll(); LiteStatusDlg.EndDisplayDelay(); }
public static void GameStart() { foreach (string dllFile in "DxLib.dll:DxLib_x64.dll:DxLibDotNet.dll".Split(':')) // DxLibDotNet.dll 等の存在確認 (1) { if (!File.Exists(dllFile)) { throw new DDError(); } } DX.GetColor(0, 0, 0); // DxLibDotNet.dll 等の存在確認 (2) DDConfig.Load(); // LogFile, LOG_ENABLED 等を含むので真っ先に // Log > File.WriteAllBytes(DDConfig.LogFile, SCommon.EMPTY_BYTES); 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(); Action showStartupMessage = () => LiteStatusDlg.StartDisplay("ゲームを起動しています..."); if (DDConfig.DisplayIndex == -2) // *** DDGround.MonitorRect 初期化 (DisplayIndex == -2 の場合) { I2Point mousePt = DDWin32.GetMousePosition(); I4Rect[] monitors = DDWin32.GetAllMonitor(); I4Rect activeMonitor = monitors[0]; // マウス位置のモニタを特定出来ない場合のモニタ foreach (I4Rect monitor in monitors) { if ( monitor.L <= mousePt.X && mousePt.X < monitor.R && monitor.T <= mousePt.Y && mousePt.Y < monitor.B ) { activeMonitor = monitor; break; } } DDGround.MonitorRect = activeMonitor; showStartupMessage(); } // DxLib > if (DDConfig.LOG_ENABLED) { DX.SetApplicationLogSaveDirectory(SCommon.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 (0 <= DDConfig.DisplayIndex) { 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(DDConsts.DEFAULT_DX_DRAWMODE); // これをデフォルトとする。 // < DxLib DDGround.MainScreen = new DDSubScreen(DDConsts.Screen_W, DDConsts.Screen_H); DDGround.MainScreen.ChangeDrawScreen(); DDGround.LastMainScreen = new DDSubScreen(DDConsts.Screen_W, DDConsts.Screen_H); DDGround.KeptMainScreen = new DDSubScreen(DDConsts.Screen_W, DDConsts.Screen_H); if (DDConfig.DisplayIndex != -2) // *** DDGround.MonitorRect 初期化 (DisplayIndex != -2 の場合) { int l; int t; int w; int h; int p1; int p2; int p3; int p4; //int p5; // for DxLibDotNet3_22c //int p6; // for DxLibDotNet3_22c DX.GetDefaultState(out w, out h, out p1, out p2, out l, out t, out p3, out p4); //DX.GetDefaultState(out w, out h, out p1, out p2, out l, out t, out p3, out p4, out p5, out p6); // for DxLibDotNet3_22c if ( w < 1 || SCommon.IMAX < w || h < 1 || SCommon.IMAX < h || l < -SCommon.IMAX || SCommon.IMAX < l || t < -SCommon.IMAX || SCommon.IMAX < t ) { throw new DDError(); } DDGround.MonitorRect = new I4Rect(l, t, w, h); showStartupMessage(); } PostSetScreenSize(DDGround.RealScreen_W, DDGround.RealScreen_H); // Font { //DDFontRegister.Add(@"e20200928_NovelAdv\Font\Genkai-Mincho-font\genkai-mincho.ttf"); //DDFontRegister.Add(@"e20200928_NovelAdv\Font\riitf\RiiT_F.otf"); DDFontRegister.Add(@"dat\Font\K Gothic\K Gothic.ttf"); DDFontRegister.Add(@"dat\Font\木漏れ日ゴシック\komorebi-gothic.ttf"); } Ground.I = new Ground(); Ground.I.Picture2 = new ResourcePicture2(); // Ground.I を参照しているので Ground のコンストラクタには書けない。 MainWin.I.PostGameStart_G3(); DDSaveData.Load_Delay(); Finalizers.Add(() => { DDSaveData.Save(); }); LiteStatusDlg.EndDisplayDelay(); }