From 586a183c9df6a6ad0245cb91ba5eed1bf7abc67a Mon Sep 17 00:00:00 2001 From: ketmar Date: Mon, 3 Sep 2018 05:08:34 +0000 Subject: [PATCH] some fixes to video init/deinit FossilOrigin-Name: 0eeefe2e74c5eb1d47853d7ae97f667cf80bccf97cd56c2ba9d1488054c6204f --- spelunky_main.vc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/spelunky_main.vc b/spelunky_main.vc index 4df477c..e9d35ae 100644 --- a/spelunky_main.vc +++ b/spelunky_main.vc @@ -518,8 +518,7 @@ final UIPane createOptionsPane () { UICheckBox.Create(pane, &config.scumMetric, "METRIC UNITS", "DEPTH WILL BE MEASURED IN METRES INSTEAD OF FEET."); auto startfs = UICheckBox.Create(pane, &config.startFullscreen, "START FULLSCREEN", "START THE GAME IN FULLSCREEN MODE?"); startfs.onValueChanged = delegate void (int newval) { - Video.showMouseCursor(); - Video.closeScreen(); + closeVideo(); fullscreen = newval; initializeVideo(); }; @@ -528,8 +527,7 @@ final UIPane createOptionsPane () { fsmode.names[$] = "SCALED"; fsmode.onValueChanged = delegate void (int newval) { if (fullscreen) { - Video.showMouseCursor(); - Video.closeScreen(); + closeVideo(); initializeVideo(); } }; @@ -2119,6 +2117,12 @@ void levelExited () { } +void closeVideo () { + if (fullscreen && Video.isInitialized) Video.showMouseCursor(); + Video.closeScreen(); +} + + void initializeVideo () { Video.openScreen("Spelunky/VaVoom C", 320*(fullscreen ? 4 : 3), 240*(fullscreen ? 4 : 3), (fullscreen ? global.config.fsmode : 0)); if (Video.realStencilBits < 8) { @@ -2146,8 +2150,7 @@ void initializeVideo () { void toggleFullscreen () { - Video.showMouseCursor(); - Video.closeScreen(); + closeVideo(); fullscreen = !fullscreen; initializeVideo(); } @@ -2276,8 +2279,7 @@ final void runGameLoop () { //writeln(Video.swapInterval); Video.runEventLoop(); - Video.showMouseCursor(); - Video.closeScreen(); + closeVideo(); SoundSystem.Shutdown(); if (doGameSavingPlaying == Replay.Saving) saveGameMovement(dbgSessionMovementFileName, packit:true); -- 2.11.4.GIT