private int Handle = -1; // -1 == Unloaded public DDSubScreen(int w, int h, bool aFlag = false) { this.W = w; this.H = h; this.AFlag = aFlag; this.Handle = -1; DDSubScreenUtils.Add(this); }
public void Dispose() { if (this.W == -1) // ? Already disposed { return; } DDSubScreenUtils.Remove(this); this.Unload(); this.W = -1; this.H = -1; this.AFlag = false; this.Picture = null; }
// // copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c // public static void ApplyScreenSize(int w, int h) { bool mdm = DDUtils.GetMouseDispMode(); //DDDerivationUtils.UnloadAll(); // -> DDPictureUtils.UnloadAll DDPictureUtils.UnloadAll(); DDSubScreenUtils.UnloadAll(); DDFontUtils.UnloadAll(); if (DX.SetGraphMode(w, h, 32) != DX.DX_CHANGESCREEN_OK) { throw new DDError(); } DX.SetDrawScreen(DX.DX_SCREEN_BACK); DX.SetDrawMode(DX.DX_DRAWMODE_BILINEAR); DDUtils.SetMouseDispMode(mdm); }
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 }
public IDisposable Section() { this.ChangeDrawScreen(); return(new AnonyDisposable(() => DDSubScreenUtils.RestoreDrawScreen())); }
public void ChangeDrawScreen() { DDSubScreenUtils.ChangeDrawScreen(this); }