From 8fcd145d534f35f97cb7f1471e75551e2c416e9e Mon Sep 17 00:00:00 2001 From: Lasercar Date: Mon, 10 Feb 2025 18:17:24 +1000 Subject: [PATCH] Option to only show the preview when a screenshot is saved Enabled by default, the idea is that the less tech savy players won't bother changing the option to false and end up reporting that they lost screenshots after changing states --- source/funkin/Preferences.hx | 19 ++++++++++++ source/funkin/save/Save.hx | 3 ++ source/funkin/ui/options/PreferencesMenu.hx | 29 ++++++++++--------- .../funkin/util/plugins/ScreenshotPlugin.hx | 10 ++++--- 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/source/funkin/Preferences.hx b/source/funkin/Preferences.hx index df75079f0..aa040231e 100644 --- a/source/funkin/Preferences.hx +++ b/source/funkin/Preferences.hx @@ -276,6 +276,25 @@ class Preferences return value; } + /** + * If enabled, the game will show the preview only after a screenshot is saved. + * @default `true` + */ + public static var previewOnSave(get, set):Bool; + + static function get_previewOnSave():Bool + { + return Save?.instance?.options?.screenshot?.previewOnSave ?? true; + } + + static function set_previewOnSave(value:Bool):Bool + { + var save:Save = Save.instance; + save.options.screenshot.previewOnSave = value; + save.flush(); + return value; + } + /** * The game will save any screenshots taken to this format. * @default `PNG` diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index a1953033d..62ff86305 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -111,6 +111,7 @@ class Save { shouldHideMouse: true, fancyPreview: true, + previewOnSave: true, saveFormat: 'PNG', jpegQuality: 80, }, @@ -1400,6 +1401,7 @@ typedef SaveDataOptions = * Screenshot options * @param shouldHideMouse Should the mouse be hidden when taking a screenshot? Default: `true` * @param fancyPreview Show a fancy preview? Default: `true` + * @param previewOnSave Only show the fancy preview after a screenshot is saved? Default: `true` * @param saveFormat The save format of the screenshot, PNG or JPEG. Default: `PNG` * @param jpegQuality The JPEG Quality, if we're saving to the format. Default: `80` */ @@ -1407,6 +1409,7 @@ typedef SaveDataOptions = { var shouldHideMouse:Bool; var fancyPreview:Bool; + var previewOnSave:Bool; var saveFormat:String; var jpegQuality:Int; }; diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index 1e20dfb5f..8470959fb 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -119,19 +119,6 @@ class PreferencesMenu extends Page Preferences.autoFullscreen = value; }, Preferences.autoFullscreen); - createPrefItemCheckbox('Hide Mouse', 'Enable to hide the mouse when taking a screenshot', function(value:Bool):Void { - Preferences.shouldHideMouse = value; - }, Preferences.shouldHideMouse); - createPrefItemCheckbox('Fancy Preview', 'Enable to show a preview after taking a screenshot', function(value:Bool):Void { - Preferences.fancyPreview = value; - }, Preferences.fancyPreview); - createPrefItemEnum('Save Format', 'Save screenshots to this format', ['PNG' => 'PNG', 'JPEG' => 'JPEG'], function(value:String):Void { - Preferences.saveFormat = value; - }, Preferences.saveFormat); - createPrefItemNumber('JPEG Quality', 'The quality of JPEG screenshots', function(value:Float) { - Preferences.jpegQuality = Std.int(value); - }, null, Preferences.jpegQuality, 0, 100, 5, 0); - #if web createPrefItemCheckbox('Unlocked Framerate', 'Enable to unlock the framerate', function(value:Bool):Void { Preferences.unlockedFramerate = value; @@ -141,6 +128,22 @@ class PreferencesMenu extends Page Preferences.framerate = Std.int(value); }, null, Preferences.framerate, 30, 300, 5, 0); #end + + createPrefItemCheckbox('Hide Mouse', 'Enable to hide the mouse when taking a screenshot', function(value:Bool):Void { + Preferences.shouldHideMouse = value; + }, Preferences.shouldHideMouse); + createPrefItemCheckbox('Fancy Preview', 'Enable to show a preview after taking a screenshot', function(value:Bool):Void { + Preferences.fancyPreview = value; + }, Preferences.fancyPreview); + createPrefItemCheckbox('Preview on save', 'Enable to have the preview show only after a screenshot is saved', function(value:Bool):Void { + Preferences.previewOnSave = value; + }, Preferences.previewOnSave); + createPrefItemEnum('Save Format', 'Save screenshots to this format', ['PNG' => 'PNG', 'JPEG' => 'JPEG'], function(value:String):Void { + Preferences.saveFormat = value; + }, Preferences.saveFormat); + createPrefItemNumber('JPEG Quality', 'The quality of JPEG screenshots', function(value:Float) { + Preferences.jpegQuality = Std.int(value); + }, null, Preferences.jpegQuality, 0, 100, 5, 0); } override function update(elapsed:Float):Void diff --git a/source/funkin/util/plugins/ScreenshotPlugin.hx b/source/funkin/util/plugins/ScreenshotPlugin.hx index 308ac2fde..c085d5067 100644 --- a/source/funkin/util/plugins/ScreenshotPlugin.hx +++ b/source/funkin/util/plugins/ScreenshotPlugin.hx @@ -289,7 +289,7 @@ class ScreenshotPlugin extends FlxBasic else throw "You've tried taking more than 100 screenshots at a time. Give the game a funkin break! Jeez. If you wanted those screenshots, well too bad!"; showCaptureFeedback(); - showFancyPreview(shot); + if (!Preferences.previewOnSave) showFancyPreview(shot); if (wasMouseHidden && !FlxG.mouse.visible && Preferences.flashingLights) // Just in case { wasMouseHidden = false; @@ -301,7 +301,7 @@ class ScreenshotPlugin extends FlxBasic saveScreenshot(shot, 'screenshot-${DateUtil.generateTimestamp()}', 1); // Show some feedback. showCaptureFeedback(); - showFancyPreview(shot); + if (!Preferences.previewOnSave) showFancyPreview(shot); if (wasMouseHidden && !FlxG.mouse.visible) { wasMouseHidden = false; @@ -422,6 +422,7 @@ class ScreenshotPlugin extends FlxBasic { trace('Saving screenshot to: ' + targetPath); FileUtil.writeBytesToPath(targetPath, pngData); + if (Preferences.previewOnSave) showFancyPreview(bitmap); // Only show the preview after a screenshot is saved } }); } @@ -440,7 +441,8 @@ class ScreenshotPlugin extends FlxBasic i++; }, 1); getCurrentState().add(asyncLoop); - if (!Preferences.flashingLights) showFancyPreview(screenshots[screenshots.length - 1]); // show the preview for the last screenshot + if (!Preferences.flashingLights && !Preferences.previewOnSave) + showFancyPreview(screenshots[screenshots.length - 1]); // show the preview for the last screenshot } public function returnEncoder(saveFormat:String):Any @@ -448,7 +450,7 @@ class ScreenshotPlugin extends FlxBasic return switch (saveFormat) { // JPEG encoder causes the game to crash????? - // case "JPEG": new openfl.display.JPEGEncoderOptions(); + // case "JPEG": new openfl.display.JPEGEncoderOptions(Preferences.jpegQuality); default: new openfl.display.PNGEncoderOptions(); } }