Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved screenshot plugin + screenshot effects in screenshot / after state change fix #4082

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a3198c4
screenshot preview in screenshot fix
Lasercar Feb 1, 2025
1ae50a3
Improved? screenshotting
Lasercar Feb 1, 2025
7d0edc7
Popup no longer shows up in screenshots
Lasercar Feb 2, 2025
00215cf
Show a preview of last image in the image buffer
Lasercar Feb 2, 2025
1731dbd
asynchronous screenshot buffer saving
Lasercar Feb 2, 2025
34e8cf6
forgot a thing
Lasercar Feb 2, 2025
52a09be
idk
Lasercar Feb 2, 2025
98cb9e1
another whoops
Lasercar Feb 2, 2025
6942c52
forgot to uncomment the bit making the async loop null
Lasercar Feb 2, 2025
863af1e
screenshot options
Lasercar Feb 5, 2025
801d601
didn't reverse my test of the JPEG encoder
Lasercar Feb 5, 2025
5229b52
idk
Lasercar Feb 5, 2025
28f2895
small fix
Lasercar Feb 5, 2025
10a931b
frame delayed screenshots + timer'd screenshot save
Lasercar Feb 6, 2025
eb4b8c2
fixed duplicate screenshot handling code
Lasercar Feb 6, 2025
c8faa0a
now it's actually asynchronous
Lasercar Feb 6, 2025
66aca22
comment typo
Lasercar Feb 6, 2025
004cf68
comment cleanup
Lasercar Feb 7, 2025
9fa15bf
Option to only show the preview when a screenshot is saved
Lasercar Feb 10, 2025
4df2637
Merge branch 'develop' into screenshot-preview-in-screenshot-fix
Lasercar Feb 16, 2025
cd86fb7
whoops
Lasercar Feb 16, 2025
f823e83
Merge branch 'screenshot-preview-in-screenshot-fix' of github.com:Las…
Lasercar Feb 16, 2025
50ce6e0
Save unsaved screenshots in buffer before state change
Lasercar Feb 16, 2025
a2d2184
another whoops
Lasercar Feb 16, 2025
54f502c
Set screenshotBeingSpammed to false after state change
Lasercar Feb 16, 2025
254748e
Fancy preview is back!
Lasercar Feb 21, 2025
d3ac112
Fixed cursor & preview not being reset for state changes
Lasercar Feb 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions source/funkin/Preferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,101 @@ class Preferences
public static var lockedFramerateFunction = untyped js.Syntax.code("window.requestAnimationFrame");
#end

/**
* If enabled, the game will hide the mouse when taking a screenshot.
* @default `true`
*/
public static var shouldHideMouse(get, set):Bool;

static function get_shouldHideMouse():Bool
{
return Save?.instance?.options?.screenshot?.shouldHideMouse ?? true;
}

static function set_shouldHideMouse(value:Bool):Bool
{
var save:Save = Save.instance;
save.options.screenshot.shouldHideMouse = value;
save.flush();
return value;
}

/**
* If enabled, the game will show a preview after taking a screenshot.
* @default `true`
*/
public static var fancyPreview(get, set):Bool;

static function get_fancyPreview():Bool
{
return Save?.instance?.options?.screenshot?.fancyPreview ?? true;
}

static function set_fancyPreview(value:Bool):Bool
{
var save:Save = Save.instance;
save.options.screenshot.fancyPreview = value;
save.flush();
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`
*/
public static var saveFormat(get, set):Any;

static function get_saveFormat():Any
{
return Save?.instance?.options?.screenshot?.saveFormat ?? 'PNG';
}

static function set_saveFormat(value):Any
{
var save:Save = Save.instance;
save.options.screenshot.saveFormat = value;
save.flush();
return value;
}

/**
* The game will save JPEG screenshots with this quality percentage.
* @default `80`
*/
public static var jpegQuality(get, set):Int;

static function get_jpegQuality():Int
{
return Save?.instance?.options?.screenshot?.jpegQuality ?? 80;
}

static function set_jpegQuality(value:Int):Int
{
var save:Save = Save.instance;
save.options.screenshot.jpegQuality = value;
save.flush();
return value;
}

/**
* Loads the user's preferences from the save data and apply them.
*/
Expand Down
26 changes: 26 additions & 0 deletions source/funkin/save/Save.hx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ class Save
audioVisualOffset: 0,
unlockedFramerate: false,

screenshot:
{
shouldHideMouse: true,
fancyPreview: true,
previewOnSave: true,
saveFormat: 'PNG',
jpegQuality: 80,
},

controls:
{
// Leave controls blank so defaults are loaded.
Expand Down Expand Up @@ -1357,6 +1366,23 @@ typedef SaveDataOptions =
*/
var unlockedFramerate:Bool;

/**
* 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`
*/
var screenshot:
{
var shouldHideMouse:Bool;
var fancyPreview:Bool;
var previewOnSave:Bool;
var saveFormat:String;
var jpegQuality:Int;
};

var controls:
{
var p1:
Expand Down
27 changes: 22 additions & 5 deletions source/funkin/ui/options/PreferencesMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ class PreferencesMenu extends Page
}, Preferences.downscroll);
createPrefItemCheckbox('Flashing Lights', 'If disabled, it will dampen flashing effects. Useful for people with photosensitive epilepsy.',
function(value:Bool):Void {
Preferences.flashingLights = value;
}, Preferences.flashingLights);
createPrefItemCheckbox('Camera Zooms', 'If disabled, camera stops bouncing to the song.', function(value:Bool):Void {
Preferences.flashingLights = value;
funkin.util.plugins.ScreenshotPlugin.instance.updateFlashColor(); // immediately update the flash color of the screenshot plugin
}, Preferences.flashingLights);
createPrefItemCheckbox('Camera Zooming on Beat', 'Disable to stop the camera bouncing to the song', function(value:Bool):Void {
Preferences.zoomCamera = value;
}, Preferences.zoomCamera);
createPrefItemCheckbox('Debug Display', 'If enabled, FPS and other debug stats will be displayed.', function(value:Bool):Void {
Expand All @@ -116,14 +117,30 @@ class PreferencesMenu extends Page
}, Preferences.autoPause);

#if web
createPrefItemCheckbox('Unlocked Framerate', 'Enable to unlock the framerate', function(value:Bool):Void {
createPrefItemCheckbox('Unlocked Framerate', 'If enabled, the framerate will be unlocked.', function(value:Bool):Void {
Preferences.unlockedFramerate = value;
}, Preferences.unlockedFramerate);
#else
createPrefItemNumber('FPS', 'The maximum framerate that the game targets', function(value:Float) {
createPrefItemNumber('FPS', 'The maximum framerate that the game targets.', function(value:Float) {
Preferences.framerate = Std.int(value);
}, null, Preferences.framerate, 30, 300, 5, 0);
#end

createPrefItemCheckbox('Hide Mouse', 'If enabled, the mouse will be hidden when taking a screenshot.', function(value:Bool):Void {
Preferences.shouldHideMouse = value;
}, Preferences.shouldHideMouse);
createPrefItemCheckbox('Fancy Preview', 'If enabled, a preview will be shown after taking a screenshot.', function(value:Bool):Void {
Preferences.fancyPreview = value;
}, Preferences.fancyPreview);
createPrefItemCheckbox('Preview on save', 'If enabled, the preview will be shown 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
Expand Down
Loading