From 3cc7f7407d0052559a07ed882a74da3d09c055c4 Mon Sep 17 00:00:00 2001 From: nebulazorua Date: Wed, 8 May 2024 21:08:17 +0800 Subject: [PATCH 001/143] fix focuscamera CLASSIC breaking zooms and snapping --- source/funkin/play/event/FocusCameraSongEvent.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/play/event/FocusCameraSongEvent.hx b/source/funkin/play/event/FocusCameraSongEvent.hx index 074fafccf1..1bcac9ad37 100644 --- a/source/funkin/play/event/FocusCameraSongEvent.hx +++ b/source/funkin/play/event/FocusCameraSongEvent.hx @@ -127,7 +127,7 @@ class FocusCameraSongEvent extends SongEvent switch (ease) { case 'CLASSIC': // Old-school. No ease. Just set follow point. - PlayState.instance.resetCamera(false, true); + PlayState.instance.cancelCameraFollowTween(); PlayState.instance.cameraFollowPoint.setPosition(targetX, targetY); case 'INSTANT': // Instant ease. Duration is automatically 0. PlayState.instance.tweenCameraToPosition(targetX, targetY, 0); From fae625a795919fe8b46c29aaa2ebe535f4e95333 Mon Sep 17 00:00:00 2001 From: nebulazorua Date: Wed, 15 May 2024 20:42:11 +0800 Subject: [PATCH 002/143] last commit, if merged, would've likely caused issues if going from tween to classic should be fixed now? --- source/funkin/play/PlayState.hx | 4 ++-- source/funkin/play/event/FocusCameraSongEvent.hx | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 44ad819c41..8f2c2b6747 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -3128,7 +3128,7 @@ class PlayState extends MusicBeatSubState /** * Resets the camera's zoom level and focus point. */ - public function resetCamera(?resetZoom:Bool = true, ?cancelTweens:Bool = true):Void + public function resetCamera(?resetZoom:Bool = true, ?cancelTweens:Bool = true, ?snap:Bool = true):Void { // Cancel camera tweens if any are active. if (cancelTweens) @@ -3145,7 +3145,7 @@ class PlayState extends MusicBeatSubState } // Snap the camera to the follow point immediately. - FlxG.camera.focusOn(cameraFollowPoint.getPosition()); + if (snap) FlxG.camera.focusOn(cameraFollowPoint.getPosition()); } /** diff --git a/source/funkin/play/event/FocusCameraSongEvent.hx b/source/funkin/play/event/FocusCameraSongEvent.hx index 1bcac9ad37..ecb41de989 100644 --- a/source/funkin/play/event/FocusCameraSongEvent.hx +++ b/source/funkin/play/event/FocusCameraSongEvent.hx @@ -127,6 +127,7 @@ class FocusCameraSongEvent extends SongEvent switch (ease) { case 'CLASSIC': // Old-school. No ease. Just set follow point. + PlayState.instance.resetCamera(false, false, false); PlayState.instance.cancelCameraFollowTween(); PlayState.instance.cameraFollowPoint.setPosition(targetX, targetY); case 'INSTANT': // Instant ease. Duration is automatically 0. From e0fe7cb1ebed863111b7fffca389e9e603b47e3c Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 25 May 2024 01:11:34 +0200 Subject: [PATCH 003/143] add fps option --- source/Main.hx | 9 +- source/funkin/Preferences.hx | 29 +++ source/funkin/save/Save.hx | 10 +- source/funkin/ui/options/PreferencesMenu.hx | 211 ++++++++++++++++---- 4 files changed, 207 insertions(+), 52 deletions(-) diff --git a/source/Main.hx b/source/Main.hx index add5bbc67b..8105e6c4f1 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -2,6 +2,7 @@ package; import flixel.FlxGame; import flixel.FlxState; +import funkin.Preferences; import funkin.util.logging.CrashHandler; import funkin.ui.debug.MemoryCounter; import funkin.save.Save; @@ -22,12 +23,6 @@ class Main extends Sprite var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom). var initialState:Class = funkin.InitState; // The FlxState the game starts with. var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions. - #if web - var framerate:Int = 60; // How many frames per second the game should run at. - #else - // TODO: This should probably be in the options menu? - var framerate:Int = 144; // How many frames per second the game should run at. - #end var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode. var startFullscreen:Bool = false; // Whether to start the game in fullscreen on desktop targets @@ -103,7 +98,7 @@ class Main extends Sprite // George recommends binding the save before FlxGame is created. Save.load(); - var game:FlxGame = new FlxGame(gameWidth, gameHeight, initialState, framerate, framerate, skipSplash, startFullscreen); + var game:FlxGame = new FlxGame(gameWidth, gameHeight, initialState, Preferences.framerate, Preferences.framerate, skipSplash, startFullscreen); // FlxG.game._customSoundTray wants just the class, it calls new from // create() in there, which gets called when it's added to stage diff --git a/source/funkin/Preferences.hx b/source/funkin/Preferences.hx index b2050c6a24..7a322283dd 100644 --- a/source/funkin/Preferences.hx +++ b/source/funkin/Preferences.hx @@ -7,6 +7,35 @@ import funkin.save.Save; */ class Preferences { + /** + * FPS + * @default `60` + */ + public static var framerate(get, set):Int; + + static function get_framerate():Int + { + #if web + return 60; + #else + return Save?.instance?.options?.framerate ?? 60; + #end + } + + static function set_framerate(value:Int):Int + { + #if web + return 60; + #else + var save:Save = Save.instance; + save.options.framerate = value; + save.flush(); + FlxG.updateFramerate = value; + FlxG.drawFramerate = value; + return value; + #end + } + /** * Whether some particularly fowl language is displayed. * @default `true` diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index acbe59edda..3600e9741f 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -53,7 +53,8 @@ class Save public function new(?data:RawSaveData) { if (data == null) this.data = Save.getDefault(); - else this.data = data; + else + this.data = data; } public static function getDefault():RawSaveData @@ -80,6 +81,7 @@ class Save options: { // Reasonable defaults. + framerate: 60, naughtyness: true, downscroll: false, flashingLights: true, @@ -835,6 +837,12 @@ typedef SaveScoreTallyData = */ typedef SaveDataOptions = { + /** + * FPS + * @default `60` + */ + var framerate:Int; + /** * Whether some particularly fowl language is displayed. * @default `true` diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index 783aef0ba7..cf72965841 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -3,16 +3,16 @@ package funkin.ui.options; import flixel.FlxCamera; import flixel.FlxObject; import flixel.FlxSprite; +import flixel.math.FlxMath; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; import funkin.ui.AtlasText.AtlasFont; import funkin.ui.options.OptionsState.Page; import funkin.graphics.FunkinCamera; -import funkin.ui.TextMenuList.TextMenuItem; class PreferencesMenu extends Page { - var items:TextMenuList; - var preferenceItems:FlxTypedSpriteGroup; + var curSelected:Int = 0; + var prefs:FlxTypedSpriteGroup; var menuCamera:FlxCamera; var camFollow:FlxObject; @@ -26,22 +26,27 @@ class PreferencesMenu extends Page menuCamera.bgColor = 0x0; camera = menuCamera; - add(items = new TextMenuList()); - add(preferenceItems = new FlxTypedSpriteGroup()); + prefs = new FlxTypedSpriteGroup(); + add(prefs); createPrefItems(); camFollow = new FlxObject(FlxG.width / 2, 0, 140, 70); - if (items != null) camFollow.y = items.selectedItem.y; menuCamera.follow(camFollow, null, 0.06); var margin = 160; menuCamera.deadzone.set(0, margin, menuCamera.width, 40); menuCamera.minScrollY = 0; - items.onChange.add(function(selected) { - camFollow.y = selected.y; - }); + changeSelection(0); + } + + function addPref(pref:PreferenceItem):Void + { + pref.x = 0; + pref.y = 120 * prefs.length; + pref.ID = prefs.length; + prefs.add(pref); } /** @@ -49,50 +54,168 @@ class PreferencesMenu extends Page */ function createPrefItems():Void { - createPrefItemCheckbox('Naughtyness', 'Toggle displaying raunchy content', function(value:Bool):Void { - Preferences.naughtyness = value; - }, Preferences.naughtyness); - createPrefItemCheckbox('Downscroll', 'Enable to make notes move downwards', function(value:Bool):Void { - Preferences.downscroll = value; - }, Preferences.downscroll); - createPrefItemCheckbox('Flashing Lights', 'Disable to dampen flashing effects', function(value:Bool):Void { - Preferences.flashingLights = value; - }, 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', 'Enable to show FPS and other debug stats', function(value:Bool):Void { - Preferences.debugDisplay = value; - }, Preferences.debugDisplay); - createPrefItemCheckbox('Auto Pause', 'Automatically pause the game when it loses focus', function(value:Bool):Void { - Preferences.autoPause = value; - }, Preferences.autoPause); + #if !web + var pref:NumberedPreferenceItem = new NumberedPreferenceItem("FPS", "The framerate that the game is running on", Preferences.framerate, + function(value:Float):Void { + Preferences.framerate = Std.int(value); + }); + pref.minValue = 60; + pref.maxValue = 360; + pref.changeRate = 1; + pref.changeSpeed = 0.05; + addPref(pref); + #end + + // TODO: add these back + // createPrefItemCheckbox('Naughtyness', 'Toggle displaying raunchy content', function(value:Bool):Void { + // Preferences.naughtyness = value; + // }, Preferences.naughtyness); + // createPrefItemCheckbox('Downscroll', 'Enable to make notes move downwards', function(value:Bool):Void { + // Preferences.downscroll = value; + // }, Preferences.downscroll); + // createPrefItemCheckbox('Flashing Lights', 'Disable to dampen flashing effects', function(value:Bool):Void { + // Preferences.flashingLights = value; + // }, 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', 'Enable to show FPS and other debug stats', function(value:Bool):Void { + // Preferences.debugDisplay = value; + // }, Preferences.debugDisplay); + // createPrefItemCheckbox('Auto Pause', 'Automatically pause the game when it loses focus', function(value:Bool):Void { + // Preferences.autoPause = value; + // }, Preferences.autoPause); } - function createPrefItemCheckbox(prefName:String, prefDesc:String, onChange:Bool->Void, defaultValue:Bool):Void + function changeSelection(change:Int):Void { - var checkbox:CheckboxPreferenceItem = new CheckboxPreferenceItem(0, 120 * (items.length - 1 + 1), defaultValue); - - items.createItem(120, (120 * items.length) + 30, prefName, AtlasFont.BOLD, function() { - var value = !checkbox.currentValue; - onChange(value); - checkbox.currentValue = value; - }); + curSelected += change; + if (curSelected < 0) + { + curSelected = prefs.length - 1; + } + else if (curSelected >= prefs.length) + { + curSelected = 0; + } - preferenceItems.add(checkbox); + for (pref in prefs) + { + pref.x = 0; + if (pref.ID == curSelected) + { + pref.x = 20; + camFollow.y = pref.y; + } + } } - override function update(elapsed:Float) + override function update(elapsed:Float):Void { super.update(elapsed); - // Indent the selected item. - // TODO: Only do this on menu change? - items.forEach(function(daItem:TextMenuItem) { - if (items.selectedItem == daItem) daItem.x = 150; - else - daItem.x = 120; - }); + if (controls.UI_DOWN_P) + { + changeSelection(1); + } + else if (controls.UI_UP_P) + { + changeSelection(-1); + } + + var selectedPref:PreferenceItem = prefs.members[curSelected]; + selectedPref.handleInput(elapsed); + } +} + +class PreferenceItem extends FlxTypedSpriteGroup +{ + public var name:String = ""; + public var description:String = ""; + + public function handleInput(deltaTime:Float):Void {} +} + +class NumberedPreferenceItem extends PreferenceItem +{ + public var onChange:Float->Void; + public var changeRate:Float = 1.0; + public var changeSpeed:Float = 0.1; + + public var minValue(default, set):Null; + + function set_minValue(value:Float):Float + { + minValue = value; + currentValue = currentValue; + return value; + } + + public var maxValue(default, set):Null; + + function set_maxValue(value:Float):Float + { + maxValue = value; + currentValue = currentValue; + return value; + } + + public var currentValue(default, set):Float; + + function set_currentValue(value:Float):Float + { + currentValue = FlxMath.bound(value, minValue, maxValue); + onChange(currentValue); + updateText(); + return currentValue; + } + + var valueText:AtlasText; + var preferenceText:AtlasText; + + public function new(name:String, description:String, defaultValue:Float, onChange:Float->Void) + { + super(); + + this.valueText = new AtlasText(0, 0, '$defaultValue', AtlasFont.DEFAULT); + add(this.valueText); + + this.preferenceText = new AtlasText(this.valueText.width + 30, 0, '$name', AtlasFont.BOLD); + add(this.preferenceText); + + this.name = name; + this.description = description; + this.onChange = onChange; + this.currentValue = defaultValue; + } + + var timeToWait:Float = 0; + + public override function handleInput(deltaTime:Float):Void + { + timeToWait -= deltaTime; + + if (timeToWait > 0) + { + return; + } + + if (PlayerSettings.player1.controls.UI_RIGHT) + { + currentValue += changeRate; + timeToWait = changeSpeed; + } + else if (PlayerSettings.player1.controls.UI_LEFT) + { + currentValue -= changeRate; + timeToWait = changeSpeed; + } + } + + function updateText():Void + { + valueText.text = '$currentValue'; + preferenceText.x = valueText.width + 30; } } From dd6d12de2340563bcbe254b36977d119085a06aa Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 25 May 2024 01:20:10 +0200 Subject: [PATCH 004/143] rename vars --- source/funkin/ui/options/PreferencesMenu.hx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index cf72965841..87917ad70c 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -62,7 +62,7 @@ class PreferencesMenu extends Page pref.minValue = 60; pref.maxValue = 360; pref.changeRate = 1; - pref.changeSpeed = 0.05; + pref.changeDelay = 0.05; addPref(pref); #end @@ -133,14 +133,14 @@ class PreferenceItem extends FlxTypedSpriteGroup public var name:String = ""; public var description:String = ""; - public function handleInput(deltaTime:Float):Void {} + public function handleInput(elapsed:Float):Void {} } class NumberedPreferenceItem extends PreferenceItem { public var onChange:Float->Void; public var changeRate:Float = 1.0; - public var changeSpeed:Float = 0.1; + public var changeDelay:Float = 0.1; public var minValue(default, set):Null; @@ -191,9 +191,9 @@ class NumberedPreferenceItem extends PreferenceItem var timeToWait:Float = 0; - public override function handleInput(deltaTime:Float):Void + public override function handleInput(elapsed:Float):Void { - timeToWait -= deltaTime; + timeToWait -= elapsed; if (timeToWait > 0) { @@ -203,12 +203,12 @@ class NumberedPreferenceItem extends PreferenceItem if (PlayerSettings.player1.controls.UI_RIGHT) { currentValue += changeRate; - timeToWait = changeSpeed; + timeToWait = changeDelay; } else if (PlayerSettings.player1.controls.UI_LEFT) { currentValue -= changeRate; - timeToWait = changeSpeed; + timeToWait = changeDelay; } } From b75f6e58532534dd94cef1c93c24270e1f56425e Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 25 May 2024 02:19:11 +0200 Subject: [PATCH 005/143] Update PreferencesMenu.hx --- source/funkin/ui/options/PreferencesMenu.hx | 132 ++++++++++++-------- 1 file changed, 79 insertions(+), 53 deletions(-) diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index 87917ad70c..acbb575250 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -66,25 +66,41 @@ class PreferencesMenu extends Page addPref(pref); #end - // TODO: add these back - // createPrefItemCheckbox('Naughtyness', 'Toggle displaying raunchy content', function(value:Bool):Void { - // Preferences.naughtyness = value; - // }, Preferences.naughtyness); - // createPrefItemCheckbox('Downscroll', 'Enable to make notes move downwards', function(value:Bool):Void { - // Preferences.downscroll = value; - // }, Preferences.downscroll); - // createPrefItemCheckbox('Flashing Lights', 'Disable to dampen flashing effects', function(value:Bool):Void { - // Preferences.flashingLights = value; - // }, 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', 'Enable to show FPS and other debug stats', function(value:Bool):Void { - // Preferences.debugDisplay = value; - // }, Preferences.debugDisplay); - // createPrefItemCheckbox('Auto Pause', 'Automatically pause the game when it loses focus', function(value:Bool):Void { - // Preferences.autoPause = value; - // }, Preferences.autoPause); + var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Naughtyness', 'Toggle displaying raunchy content', Preferences.naughtyness, + function(value:Bool):Void { + Preferences.naughtyness = value; + }); + addPref(pref); + + var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Downscroll', 'Enable to make notes move downwards', Preferences.downscroll, + function(value:Bool):Void { + Preferences.downscroll = value; + }); + addPref(pref); + + var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Flashing Lights', 'Disable to dampen flashing effects', Preferences.flashingLights, + function(value:Bool):Void { + Preferences.flashingLights = value; + }); + addPref(pref); + + var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Camera Zooming on Beat', 'Disable to stop the camera bouncing to the song', + Preferences.zoomCamera, function(value:Bool):Void { + Preferences.zoomCamera = value; + }); + addPref(pref); + + var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Debug Display', 'Enable to show FPS and other debug stats', Preferences.debugDisplay, + function(value:Bool):Void { + Preferences.debugDisplay = value; + }); + addPref(pref); + + var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Auto Pause', 'Automatically pause the game when it loses focus', Preferences.autoPause, + function(value:Bool):Void { + Preferences.autoPause = value; + }); + addPref(pref); } function changeSelection(change:Int):Void @@ -104,7 +120,7 @@ class PreferencesMenu extends Page pref.x = 0; if (pref.ID == curSelected) { - pref.x = 20; + pref.x = 30; camFollow.y = pref.y; } } @@ -124,7 +140,7 @@ class PreferencesMenu extends Page } var selectedPref:PreferenceItem = prefs.members[curSelected]; - selectedPref.handleInput(elapsed); + selectedPref?.handleInput(elapsed); } } @@ -177,10 +193,10 @@ class NumberedPreferenceItem extends PreferenceItem { super(); - this.valueText = new AtlasText(0, 0, '$defaultValue', AtlasFont.DEFAULT); + this.valueText = new AtlasText(20, 30, '$defaultValue', AtlasFont.DEFAULT); add(this.valueText); - this.preferenceText = new AtlasText(this.valueText.width + 30, 0, '$name', AtlasFont.BOLD); + this.preferenceText = new AtlasText(this.valueText.x + this.valueText.width + 30, 30, '$name', AtlasFont.BOLD); add(this.preferenceText); this.name = name; @@ -215,52 +231,62 @@ class NumberedPreferenceItem extends PreferenceItem function updateText():Void { valueText.text = '$currentValue'; - preferenceText.x = valueText.width + 30; + preferenceText.x = valueText.x + valueText.width + 30; } } -class CheckboxPreferenceItem extends FlxSprite +class CheckboxPreferenceItem extends PreferenceItem { + public var onChange:Bool->Void; + public var currentValue(default, set):Bool; - public function new(x:Float, y:Float, defaultValue:Bool = false) + function set_currentValue(value:Bool):Bool { - super(x, y); + if (value) + { + checkBox.animation.play('checked', true); + checkBox.offset.set(17, 70); + } + else + { + checkBox.animation.play('static'); + checkBox.offset.set(); + } + currentValue = value; + onChange(value); + return value; + } - frames = Paths.getSparrowAtlas('checkboxThingie'); - animation.addByPrefix('static', 'Check Box unselected', 24, false); - animation.addByPrefix('checked', 'Check Box selecting animation', 24, false); + var checkBox:FlxSprite; + var preferenceText:AtlasText; - setGraphicSize(Std.int(width * 0.7)); - updateHitbox(); + public function new(name:String, description:String, defaultValue:Bool, onChange:Bool->Void) + { + super(); - this.currentValue = defaultValue; - } + this.checkBox = new FlxSprite(); + this.checkBox.frames = Paths.getSparrowAtlas('checkboxThingie'); + this.checkBox.animation.addByPrefix('static', 'Check Box unselected', 24, false); + this.checkBox.animation.addByPrefix('checked', 'Check Box selecting animation', 24, false); + this.checkBox.setGraphicSize(Std.int(this.checkBox.width * 0.7)); + this.checkBox.updateHitbox(); + add(this.checkBox); - override function update(elapsed:Float) - { - super.update(elapsed); + this.preferenceText = new AtlasText(120, 30, '$name', AtlasFont.BOLD); + add(this.preferenceText); - switch (animation.curAnim.name) - { - case 'static': - offset.set(); - case 'checked': - offset.set(17, 70); - } + this.name = name; + this.description = description; + this.onChange = onChange; + this.currentValue = defaultValue; } - function set_currentValue(value:Bool):Bool + public override function handleInput(elapsed:Float):Void { - if (value) + if (PlayerSettings.player1.controls.ACCEPT) { - animation.play('checked', true); + currentValue = !currentValue; } - else - { - animation.play('static'); - } - - return currentValue = value; } } From 814d72cb3f241c61896adda8e6f84435ff056f4a Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 25 May 2024 03:06:27 +0200 Subject: [PATCH 006/143] sounds --- source/funkin/ui/options/PreferencesMenu.hx | 28 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index acbb575250..75bc0fdb30 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -4,13 +4,20 @@ import flixel.FlxCamera; import flixel.FlxObject; import flixel.FlxSprite; import flixel.math.FlxMath; +import flixel.effects.FlxFlicker; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; import funkin.ui.AtlasText.AtlasFont; import funkin.ui.options.OptionsState.Page; import funkin.graphics.FunkinCamera; +import funkin.audio.FunkinSound; class PreferencesMenu extends Page { + /** + * Wether you can selected a different option + */ + public static var allowScrolling:Bool = true; + var curSelected:Int = 0; var prefs:FlxTypedSpriteGroup; @@ -130,12 +137,14 @@ class PreferencesMenu extends Page { super.update(elapsed); - if (controls.UI_DOWN_P) + if (controls.UI_DOWN_P && allowScrolling) { + FunkinSound.playOnce(Paths.sound('scrollMenu')); changeSelection(1); } - else if (controls.UI_UP_P) + else if (controls.UI_UP_P && allowScrolling) { + FunkinSound.playOnce(Paths.sound('scrollMenu')); changeSelection(-1); } @@ -220,11 +229,13 @@ class NumberedPreferenceItem extends PreferenceItem { currentValue += changeRate; timeToWait = changeDelay; + // FunkinSound.playOnce(Paths.sound('scrollMenu')); } else if (PlayerSettings.player1.controls.UI_LEFT) { currentValue -= changeRate; timeToWait = changeDelay; + // FunkinSound.playOnce(Paths.sound('scrollMenu')); } } @@ -282,11 +293,20 @@ class CheckboxPreferenceItem extends PreferenceItem this.currentValue = defaultValue; } + var isAccepting:Bool = false; + public override function handleInput(elapsed:Float):Void { - if (PlayerSettings.player1.controls.ACCEPT) + if (PlayerSettings.player1.controls.ACCEPT && !isAccepting) { - currentValue = !currentValue; + isAccepting = true; + PreferencesMenu.allowScrolling = false; + FunkinSound.playOnce(Paths.sound('confirmMenu')); + FlxFlicker.flicker(preferenceText, 1, 0.06, true, false, function(_) { + isAccepting = false; + PreferencesMenu.allowScrolling = true; + currentValue = !currentValue; + }); } } } From 267fd0eadcaceedc69bae06bf3d3344f4251bfdc Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 25 May 2024 16:30:08 +0200 Subject: [PATCH 007/143] alpha stuff and correct text positioning --- source/funkin/ui/options/PreferencesMenu.hx | 42 +++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index 75bc0fdb30..4e9e0bca82 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -124,12 +124,15 @@ class PreferencesMenu extends Page for (pref in prefs) { - pref.x = 0; if (pref.ID == curSelected) { - pref.x = 30; + pref.onSelect(true); camFollow.y = pref.y; } + else + { + pref.onSelect(false); + } } } @@ -159,6 +162,8 @@ class PreferenceItem extends FlxTypedSpriteGroup public var description:String = ""; public function handleInput(elapsed:Float):Void {} + + public function onSelect(isSelected:Bool):Void {} } class NumberedPreferenceItem extends PreferenceItem @@ -239,10 +244,27 @@ class NumberedPreferenceItem extends PreferenceItem } } + var isSelected:Bool = false; + + public override function onSelect(isSelected:Bool):Void + { + this.isSelected = isSelected; + if (isSelected) + { + preferenceText.x = valueText.x + valueText.width + 60; + preferenceText.alpha = 1.0; + } + else + { + preferenceText.x = valueText.x + valueText.width + 30; + preferenceText.alpha = 0.6; + } + } + function updateText():Void { valueText.text = '$currentValue'; - preferenceText.x = valueText.x + valueText.width + 30; + preferenceText.x = valueText.x + valueText.width + (isSelected ? 60 : 30); } } @@ -309,4 +331,18 @@ class CheckboxPreferenceItem extends PreferenceItem }); } } + + public override function onSelect(isSelected:Bool):Void + { + if (isSelected) + { + preferenceText.x = 150; + preferenceText.alpha = 1.0; + } + else + { + preferenceText.alpha = 0.6; + preferenceText.x = 120; + } + } } From 4a531888b550f10564f058b8d2155645d33a7867 Mon Sep 17 00:00:00 2001 From: lemz Date: Thu, 30 May 2024 00:22:10 +0200 Subject: [PATCH 008/143] Update PreferencesMenu.hx --- source/funkin/ui/options/PreferencesMenu.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index 4e9e0bca82..205ef18091 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -14,7 +14,7 @@ import funkin.audio.FunkinSound; class PreferencesMenu extends Page { /** - * Wether you can selected a different option + * Wether you can select a different option */ public static var allowScrolling:Bool = true; From 3b3b9d97ba08d8e315df0bcd755d79d1e6e27a81 Mon Sep 17 00:00:00 2001 From: lemz Date: Sun, 23 Jun 2024 21:03:30 +0200 Subject: [PATCH 009/143] use different implementation --- source/funkin/ui/AtlasText.hx | 26 ++ source/funkin/ui/options/PreferencesMenu.hx | 349 ++++-------------- .../options/items/CheckboxPreferenceItem.hx | 49 +++ .../ui/options/items/NumberPreferenceItem.hx | 107 ++++++ 4 files changed, 247 insertions(+), 284 deletions(-) create mode 100644 source/funkin/ui/options/items/CheckboxPreferenceItem.hx create mode 100644 source/funkin/ui/options/items/NumberPreferenceItem.hx diff --git a/source/funkin/ui/AtlasText.hx b/source/funkin/ui/AtlasText.hx index 186d87c2a1..ef74abc1e2 100644 --- a/source/funkin/ui/AtlasText.hx +++ b/source/funkin/ui/AtlasText.hx @@ -152,6 +152,32 @@ class AtlasText extends FlxTypedSpriteGroup } } + public function getWidth():Int + { + var width = 0; + for (char in this.text.split("")) + { + switch (char) + { + case " ": + { + width += 40; + } + case "\n": + {} + case char: + { + var sprite = new AtlasChar(atlas, char); + sprite.revive(); + sprite.char = char; + sprite.alpha = 1; + width += Std.int(sprite.width); + } + } + } + return width; + } + override function toString() { return "InputItem, " + FlxStringUtil.getDebugString([ diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index 205ef18091..d03fe90733 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -3,23 +3,18 @@ package funkin.ui.options; import flixel.FlxCamera; import flixel.FlxObject; import flixel.FlxSprite; -import flixel.math.FlxMath; -import flixel.effects.FlxFlicker; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; import funkin.ui.AtlasText.AtlasFont; import funkin.ui.options.OptionsState.Page; +import funkin.ui.options.items.CheckboxPreferenceItem; +import funkin.ui.options.items.NumberPreferenceItem; import funkin.graphics.FunkinCamera; -import funkin.audio.FunkinSound; +import funkin.ui.TextMenuList.TextMenuItem; class PreferencesMenu extends Page { - /** - * Wether you can select a different option - */ - public static var allowScrolling:Bool = true; - - var curSelected:Int = 0; - var prefs:FlxTypedSpriteGroup; + var items:TextMenuList; + var preferenceItems:FlxTypedSpriteGroup; var menuCamera:FlxCamera; var camFollow:FlxObject; @@ -33,27 +28,22 @@ class PreferencesMenu extends Page menuCamera.bgColor = 0x0; camera = menuCamera; - prefs = new FlxTypedSpriteGroup(); - add(prefs); + add(items = new TextMenuList()); + add(preferenceItems = new FlxTypedSpriteGroup()); createPrefItems(); camFollow = new FlxObject(FlxG.width / 2, 0, 140, 70); + if (items != null) camFollow.y = items.selectedItem.y; menuCamera.follow(camFollow, null, 0.06); var margin = 160; menuCamera.deadzone.set(0, margin, menuCamera.width, 40); menuCamera.minScrollY = 0; - changeSelection(0); - } - - function addPref(pref:PreferenceItem):Void - { - pref.x = 0; - pref.y = 120 * prefs.length; - pref.ID = prefs.length; - prefs.add(pref); + items.onChange.add(function(selected) { + camFollow.y = selected.y; + }); } /** @@ -62,287 +52,78 @@ class PreferencesMenu extends Page function createPrefItems():Void { #if !web - var pref:NumberedPreferenceItem = new NumberedPreferenceItem("FPS", "The framerate that the game is running on", Preferences.framerate, - function(value:Float):Void { - Preferences.framerate = Std.int(value); - }); - pref.minValue = 60; - pref.maxValue = 360; - pref.changeRate = 1; - pref.changeDelay = 0.05; - addPref(pref); + createPrefItemNumber('FPS', 'The framerate that the game is running on', function(value:Float) { + Preferences.framerate = Std.int(value); + }, Preferences.framerate, 60, 360, 1, 0); #end - - var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Naughtyness', 'Toggle displaying raunchy content', Preferences.naughtyness, - function(value:Bool):Void { - Preferences.naughtyness = value; - }); - addPref(pref); - - var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Downscroll', 'Enable to make notes move downwards', Preferences.downscroll, - function(value:Bool):Void { - Preferences.downscroll = value; - }); - addPref(pref); - - var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Flashing Lights', 'Disable to dampen flashing effects', Preferences.flashingLights, - function(value:Bool):Void { - Preferences.flashingLights = value; - }); - addPref(pref); - - var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Camera Zooming on Beat', 'Disable to stop the camera bouncing to the song', - Preferences.zoomCamera, function(value:Bool):Void { - Preferences.zoomCamera = value; - }); - addPref(pref); - - var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Debug Display', 'Enable to show FPS and other debug stats', Preferences.debugDisplay, - function(value:Bool):Void { - Preferences.debugDisplay = value; - }); - addPref(pref); - - var pref:CheckboxPreferenceItem = new CheckboxPreferenceItem('Auto Pause', 'Automatically pause the game when it loses focus', Preferences.autoPause, - function(value:Bool):Void { - Preferences.autoPause = value; - }); - addPref(pref); + createPrefItemCheckbox('Naughtyness', 'Toggle displaying raunchy content', function(value:Bool):Void { + Preferences.naughtyness = value; + }, Preferences.naughtyness); + createPrefItemCheckbox('Downscroll', 'Enable to make notes move downwards', function(value:Bool):Void { + Preferences.downscroll = value; + }, Preferences.downscroll); + createPrefItemCheckbox('Flashing Lights', 'Disable to dampen flashing effects', function(value:Bool):Void { + Preferences.flashingLights = value; + }, 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', 'Enable to show FPS and other debug stats', function(value:Bool):Void { + Preferences.debugDisplay = value; + }, Preferences.debugDisplay); + createPrefItemCheckbox('Auto Pause', 'Automatically pause the game when it loses focus', function(value:Bool):Void { + Preferences.autoPause = value; + }, Preferences.autoPause); } - function changeSelection(change:Int):Void + override function update(elapsed:Float):Void { - curSelected += change; - if (curSelected < 0) - { - curSelected = prefs.length - 1; - } - else if (curSelected >= prefs.length) - { - curSelected = 0; - } + super.update(elapsed); - for (pref in prefs) - { - if (pref.ID == curSelected) + // Indent the selected item. + // TODO: Only do this on menu change? + items.forEach(function(daItem:TextMenuItem) { + var thyOffset:Int = 0; + if (Std.isOfType(daItem, NumberPreferenceItem)) thyOffset = cast(daItem, NumberPreferenceItem).lefthandText.getWidth(); + + // Very messy but it works + if (thyOffset == 0) + { + if (items.selectedItem == daItem) thyOffset += 150; + else + thyOffset += 120; + } + else if (items.selectedItem == daItem) { - pref.onSelect(true); - camFollow.y = pref.y; + thyOffset += 70; } else { - pref.onSelect(false); + thyOffset += 25; } - } - } - - override function update(elapsed:Float):Void - { - super.update(elapsed); - - if (controls.UI_DOWN_P && allowScrolling) - { - FunkinSound.playOnce(Paths.sound('scrollMenu')); - changeSelection(1); - } - else if (controls.UI_UP_P && allowScrolling) - { - FunkinSound.playOnce(Paths.sound('scrollMenu')); - changeSelection(-1); - } - - var selectedPref:PreferenceItem = prefs.members[curSelected]; - selectedPref?.handleInput(elapsed); - } -} - -class PreferenceItem extends FlxTypedSpriteGroup -{ - public var name:String = ""; - public var description:String = ""; - - public function handleInput(elapsed:Float):Void {} - - public function onSelect(isSelected:Bool):Void {} -} - -class NumberedPreferenceItem extends PreferenceItem -{ - public var onChange:Float->Void; - public var changeRate:Float = 1.0; - public var changeDelay:Float = 0.1; - - public var minValue(default, set):Null; - - function set_minValue(value:Float):Float - { - minValue = value; - currentValue = currentValue; - return value; - } - - public var maxValue(default, set):Null; - - function set_maxValue(value:Float):Float - { - maxValue = value; - currentValue = currentValue; - return value; - } - - public var currentValue(default, set):Float; - - function set_currentValue(value:Float):Float - { - currentValue = FlxMath.bound(value, minValue, maxValue); - onChange(currentValue); - updateText(); - return currentValue; - } - - var valueText:AtlasText; - var preferenceText:AtlasText; - - public function new(name:String, description:String, defaultValue:Float, onChange:Float->Void) - { - super(); - - this.valueText = new AtlasText(20, 30, '$defaultValue', AtlasFont.DEFAULT); - add(this.valueText); - - this.preferenceText = new AtlasText(this.valueText.x + this.valueText.width + 30, 30, '$name', AtlasFont.BOLD); - add(this.preferenceText); - - this.name = name; - this.description = description; - this.onChange = onChange; - this.currentValue = defaultValue; - } - - var timeToWait:Float = 0; - - public override function handleInput(elapsed:Float):Void - { - timeToWait -= elapsed; - - if (timeToWait > 0) - { - return; - } - - if (PlayerSettings.player1.controls.UI_RIGHT) - { - currentValue += changeRate; - timeToWait = changeDelay; - // FunkinSound.playOnce(Paths.sound('scrollMenu')); - } - else if (PlayerSettings.player1.controls.UI_LEFT) - { - currentValue -= changeRate; - timeToWait = changeDelay; - // FunkinSound.playOnce(Paths.sound('scrollMenu')); - } - } - - var isSelected:Bool = false; - public override function onSelect(isSelected:Bool):Void - { - this.isSelected = isSelected; - if (isSelected) - { - preferenceText.x = valueText.x + valueText.width + 60; - preferenceText.alpha = 1.0; - } - else - { - preferenceText.x = valueText.x + valueText.width + 30; - preferenceText.alpha = 0.6; - } - } - - function updateText():Void - { - valueText.text = '$currentValue'; - preferenceText.x = valueText.x + valueText.width + (isSelected ? 60 : 30); - } -} - -class CheckboxPreferenceItem extends PreferenceItem -{ - public var onChange:Bool->Void; - - public var currentValue(default, set):Bool; - - function set_currentValue(value:Bool):Bool - { - if (value) - { - checkBox.animation.play('checked', true); - checkBox.offset.set(17, 70); - } - else - { - checkBox.animation.play('static'); - checkBox.offset.set(); - } - currentValue = value; - onChange(value); - return value; + daItem.x = thyOffset; + }); } - var checkBox:FlxSprite; - var preferenceText:AtlasText; - - public function new(name:String, description:String, defaultValue:Bool, onChange:Bool->Void) + function createPrefItemCheckbox(prefName:String, prefDesc:String, onChange:Bool->Void, defaultValue:Bool):Void { - super(); - - this.checkBox = new FlxSprite(); - this.checkBox.frames = Paths.getSparrowAtlas('checkboxThingie'); - this.checkBox.animation.addByPrefix('static', 'Check Box unselected', 24, false); - this.checkBox.animation.addByPrefix('checked', 'Check Box selecting animation', 24, false); - this.checkBox.setGraphicSize(Std.int(this.checkBox.width * 0.7)); - this.checkBox.updateHitbox(); - add(this.checkBox); + var checkbox:CheckboxPreferenceItem = new CheckboxPreferenceItem(0, 120 * (items.length - 1 + 1), defaultValue); - this.preferenceText = new AtlasText(120, 30, '$name', AtlasFont.BOLD); - add(this.preferenceText); - - this.name = name; - this.description = description; - this.onChange = onChange; - this.currentValue = defaultValue; - } - - var isAccepting:Bool = false; + items.createItem(120, (120 * items.length) + 30, prefName, AtlasFont.BOLD, function() { + var value = !checkbox.currentValue; + onChange(value); + checkbox.currentValue = value; + }); - public override function handleInput(elapsed:Float):Void - { - if (PlayerSettings.player1.controls.ACCEPT && !isAccepting) - { - isAccepting = true; - PreferencesMenu.allowScrolling = false; - FunkinSound.playOnce(Paths.sound('confirmMenu')); - FlxFlicker.flicker(preferenceText, 1, 0.06, true, false, function(_) { - isAccepting = false; - PreferencesMenu.allowScrolling = true; - currentValue = !currentValue; - }); - } + preferenceItems.add(checkbox); } - public override function onSelect(isSelected:Bool):Void + function createPrefItemNumber(prefName:String, prefDesc:String, onChange:Float->Void, defaultValue:Float, min:Float, max:Float, step:Float, + precision:Int):Void { - if (isSelected) - { - preferenceText.x = 150; - preferenceText.alpha = 1.0; - } - else - { - preferenceText.alpha = 0.6; - preferenceText.x = 120; - } + var item = new NumberPreferenceItem(145, (120 * items.length) + 30, prefName, defaultValue, min, max, step, precision, onChange); + items.addItem(prefName, item); + preferenceItems.add(item.lefthandText); } } diff --git a/source/funkin/ui/options/items/CheckboxPreferenceItem.hx b/source/funkin/ui/options/items/CheckboxPreferenceItem.hx new file mode 100644 index 0000000000..88c4fb6b00 --- /dev/null +++ b/source/funkin/ui/options/items/CheckboxPreferenceItem.hx @@ -0,0 +1,49 @@ +package funkin.ui.options.items; + +import flixel.FlxSprite.FlxSprite; + +class CheckboxPreferenceItem extends FlxSprite +{ + public var currentValue(default, set):Bool; + + public function new(x:Float, y:Float, defaultValue:Bool = false) + { + super(x, y); + + frames = Paths.getSparrowAtlas('checkboxThingie'); + animation.addByPrefix('static', 'Check Box unselected', 24, false); + animation.addByPrefix('checked', 'Check Box selecting animation', 24, false); + + setGraphicSize(Std.int(width * 0.7)); + updateHitbox(); + + this.currentValue = defaultValue; + } + + override function update(elapsed:Float) + { + super.update(elapsed); + + switch (animation.curAnim.name) + { + case 'static': + offset.set(); + case 'checked': + offset.set(17, 70); + } + } + + function set_currentValue(value:Bool):Bool + { + if (value) + { + animation.play('checked', true); + } + else + { + animation.play('static'); + } + + return currentValue = value; + } +} diff --git a/source/funkin/ui/options/items/NumberPreferenceItem.hx b/source/funkin/ui/options/items/NumberPreferenceItem.hx new file mode 100644 index 0000000000..795b6c9942 --- /dev/null +++ b/source/funkin/ui/options/items/NumberPreferenceItem.hx @@ -0,0 +1,107 @@ +package funkin.ui.options.items; + +import funkin.ui.TextMenuList; +import funkin.ui.AtlasText; +import funkin.input.Controls; + +/** + * Preference item that allows the player to pick a value between min and max + */ +class NumberPreferenceItem extends TextMenuItem +{ + function controls():Controls + { + return PlayerSettings.player1.controls; + } + + public var lefthandText:AtlasText; + + public var currentValue:Float; + public var min:Float; + public var max:Float; + public var step:Float; + public var precision:Int; + public var onChangeCallback:NullVoid>; + + public function new(x:Float, y:Float, name:String, defaultValue:Float, min:Float, max:Float, step:Float, precision:Int, ?callback:Float->Void):Void + { + super(x, y, name, function() { + callback(this.currentValue); + }); + lefthandText = new AtlasText(20, y, formatted(defaultValue), AtlasFont.DEFAULT); + + updateHitbox(); + + this.currentValue = defaultValue; + this.min = min; + this.max = max; + this.step = step; + this.precision = precision; + this.onChangeCallback = callback; + } + + static final HOLD_DELAY:Float = 0.5; // seconds + static final CHANGE_RATE:Float = 0.02; // seconds + + var holdDelayTimer:Float = HOLD_DELAY; // seconds + var changeRateTimer:Float = 0.0; // seconds + + override function update(elapsed:Float):Void + { + super.update(elapsed); + + // var fancyTextFancyColor:Color; + if (selected) + { + holdDelayTimer -= elapsed; + if (holdDelayTimer <= 0.0) + { + changeRateTimer -= elapsed; + } + + var jpLeft:Bool = controls().UI_LEFT_P; + var jpRight:Bool = controls().UI_RIGHT_P; + + if (jpLeft || jpRight) + { + holdDelayTimer = HOLD_DELAY; + changeRateTimer = 0.0; + } + + var shouldDecrease:Bool = jpLeft; + var shouldIncrease:Bool = jpRight; + + if (controls().UI_LEFT && holdDelayTimer <= 0.0 && changeRateTimer <= 0.0) + { + shouldDecrease = true; + changeRateTimer = CHANGE_RATE; + } + else if (controls().UI_RIGHT && holdDelayTimer <= 0.0 && changeRateTimer <= 0.0) + { + shouldIncrease = true; + changeRateTimer = CHANGE_RATE; + } + + if (shouldDecrease) currentValue -= step; + else if (shouldIncrease) currentValue += step; + currentValue = currentValue.clamp(min, max); + if (onChangeCallback != null && (shouldIncrease || shouldDecrease)) + { + onChangeCallback(currentValue); + } + } + + lefthandText.text = formatted(currentValue); + } + + function formatted(value:Float):String + { + return '${toFixed(value)}'; + } + + function toFixed(value:Float):Float + { + var multiplier:Float = Math.pow(10, precision); + return Math.floor(value * multiplier) / multiplier; + } +} From f3e04114ebd7418bee7eeada80a57704a13a3cbb Mon Sep 17 00:00:00 2001 From: lemz Date: Tue, 25 Jun 2024 17:05:15 +0200 Subject: [PATCH 010/143] use new offsets --- source/funkin/ui/options/PreferencesMenu.hx | 23 ++++++++++--------- .../ui/options/items/NumberPreferenceItem.hx | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index d03fe90733..d004a46c75 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -84,22 +84,23 @@ class PreferencesMenu extends Page // TODO: Only do this on menu change? items.forEach(function(daItem:TextMenuItem) { var thyOffset:Int = 0; - if (Std.isOfType(daItem, NumberPreferenceItem)) thyOffset = cast(daItem, NumberPreferenceItem).lefthandText.getWidth(); + // Initializing thy text width (if thou text present) + var thyTextWidth:Int = 0; + if (Std.isOfType(daItem, NumberPreferenceItem)) thyTextWidth = cast(daItem, NumberPreferenceItem).lefthandText.getWidth(); - // Very messy but it works - if (thyOffset == 0) + if (thyTextWidth != 0) { - if (items.selectedItem == daItem) thyOffset += 150; - else - thyOffset += 120; + // Magic number because of the weird offset thats being added by default + thyOffset += thyTextWidth - 75; } - else if (items.selectedItem == daItem) + + if (items.selectedItem == daItem) { - thyOffset += 70; + thyOffset += 150; } else { - thyOffset += 25; + thyOffset += 120; } daItem.x = thyOffset; @@ -110,7 +111,7 @@ class PreferencesMenu extends Page { var checkbox:CheckboxPreferenceItem = new CheckboxPreferenceItem(0, 120 * (items.length - 1 + 1), defaultValue); - items.createItem(120, (120 * items.length) + 30, prefName, AtlasFont.BOLD, function() { + items.createItem(0, (120 * items.length) + 30, prefName, AtlasFont.BOLD, function() { var value = !checkbox.currentValue; onChange(value); checkbox.currentValue = value; @@ -122,7 +123,7 @@ class PreferencesMenu extends Page function createPrefItemNumber(prefName:String, prefDesc:String, onChange:Float->Void, defaultValue:Float, min:Float, max:Float, step:Float, precision:Int):Void { - var item = new NumberPreferenceItem(145, (120 * items.length) + 30, prefName, defaultValue, min, max, step, precision, onChange); + var item = new NumberPreferenceItem(0, (120 * items.length) + 30, prefName, defaultValue, min, max, step, precision, onChange); items.addItem(prefName, item); preferenceItems.add(item.lefthandText); } diff --git a/source/funkin/ui/options/items/NumberPreferenceItem.hx b/source/funkin/ui/options/items/NumberPreferenceItem.hx index 795b6c9942..eeea3112e5 100644 --- a/source/funkin/ui/options/items/NumberPreferenceItem.hx +++ b/source/funkin/ui/options/items/NumberPreferenceItem.hx @@ -28,7 +28,7 @@ class NumberPreferenceItem extends TextMenuItem super(x, y, name, function() { callback(this.currentValue); }); - lefthandText = new AtlasText(20, y, formatted(defaultValue), AtlasFont.DEFAULT); + lefthandText = new AtlasText(15, y, formatted(defaultValue), AtlasFont.DEFAULT); updateHitbox(); From 927e37b35bda92888f0c0b47256884a0285cadd3 Mon Sep 17 00:00:00 2001 From: lemz Date: Tue, 2 Jul 2024 17:18:46 +0200 Subject: [PATCH 011/143] use new numberpreferenceitem --- source/funkin/ui/options/PreferencesMenu.hx | 8 +-- .../ui/options/items/NumberPreferenceItem.hx | 55 ++++++++++++++----- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index d004a46c75..80dad0241f 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -54,7 +54,7 @@ class PreferencesMenu extends Page #if !web createPrefItemNumber('FPS', 'The framerate that the game is running on', function(value:Float) { Preferences.framerate = Std.int(value); - }, Preferences.framerate, 60, 360, 1, 0); + }, null, Preferences.framerate, 60, 360, 1, 0); #end createPrefItemCheckbox('Naughtyness', 'Toggle displaying raunchy content', function(value:Bool):Void { Preferences.naughtyness = value; @@ -120,10 +120,10 @@ class PreferencesMenu extends Page preferenceItems.add(checkbox); } - function createPrefItemNumber(prefName:String, prefDesc:String, onChange:Float->Void, defaultValue:Float, min:Float, max:Float, step:Float, - precision:Int):Void + function createPrefItemNumber(prefName:String, prefDesc:String, onChange:Float->Void, ?valueFormatter:Float->String, defaultValue:Int, min:Int, max:Int, + step:Float = 0.1, precision:Int):Void { - var item = new NumberPreferenceItem(0, (120 * items.length) + 30, prefName, defaultValue, min, max, step, precision, onChange); + var item = new NumberPreferenceItem(0, (120 * items.length) + 30, prefName, defaultValue, min, max, step, precision, onChange, valueFormatter); items.addItem(prefName, item); preferenceItems.add(item.lefthandText); } diff --git a/source/funkin/ui/options/items/NumberPreferenceItem.hx b/source/funkin/ui/options/items/NumberPreferenceItem.hx index eeea3112e5..f3cd3cd46f 100644 --- a/source/funkin/ui/options/items/NumberPreferenceItem.hx +++ b/source/funkin/ui/options/items/NumberPreferenceItem.hx @@ -14,16 +14,35 @@ class NumberPreferenceItem extends TextMenuItem return PlayerSettings.player1.controls; } + // Widgets public var lefthandText:AtlasText; + // Constants + static final HOLD_DELAY:Float = 0.3; // seconds + static final CHANGE_RATE:Float = 0.08; // seconds + + // Constructor-initialized variables public var currentValue:Float; public var min:Float; public var max:Float; public var step:Float; public var precision:Int; public var onChangeCallback:NullVoid>; + public var valueFormatter:NullString>; + + // Variables + var holdDelayTimer:Float = HOLD_DELAY; // seconds + var changeRateTimer:Float = 0.0; // seconds - public function new(x:Float, y:Float, name:String, defaultValue:Float, min:Float, max:Float, step:Float, precision:Int, ?callback:Float->Void):Void + /** + * @param min Minimum value (example: 0) + * @param max Maximum value (example: 100) + * @param step The value to increment/decrement by (example: 10) + * @param callback Will get called every time the user changes the setting; use this to apply/save the setting. + * @param valueFormatter Will get called every time the game needs to display the float value; use this to change how the displayed string looks + */ + public function new(x:Float, y:Float, name:String, defaultValue:Float, min:Float, max:Float, step:Float, precision:Int, ?callback:Float->Void, + ?valueFormatter:Float->String):Void { super(x, y, name, function() { callback(this.currentValue); @@ -38,14 +57,9 @@ class NumberPreferenceItem extends TextMenuItem this.step = step; this.precision = precision; this.onChangeCallback = callback; + this.valueFormatter = valueFormatter; } - static final HOLD_DELAY:Float = 0.5; // seconds - static final CHANGE_RATE:Float = 0.02; // seconds - - var holdDelayTimer:Float = HOLD_DELAY; // seconds - var changeRateTimer:Float = 0.0; // seconds - override function update(elapsed:Float):Void { super.update(elapsed); @@ -82,21 +96,36 @@ class NumberPreferenceItem extends TextMenuItem changeRateTimer = CHANGE_RATE; } - if (shouldDecrease) currentValue -= step; - else if (shouldIncrease) currentValue += step; - currentValue = currentValue.clamp(min, max); - if (onChangeCallback != null && (shouldIncrease || shouldDecrease)) + // Actually increasing/decreasing the value + if (shouldDecrease) + { + var isBelowMin:Bool = currentValue - step < min; + currentValue = (currentValue - step).clamp(min, max); + if (onChangeCallback != null && !isBelowMin) onChangeCallback(currentValue); + } + else if (shouldIncrease) { - onChangeCallback(currentValue); + var isAboveMax:Bool = currentValue + step > max; + currentValue = (currentValue + step).clamp(min, max); + if (onChangeCallback != null && !isAboveMax) onChangeCallback(currentValue); } } lefthandText.text = formatted(currentValue); } + /** Turns the float into a string */ function formatted(value:Float):String { - return '${toFixed(value)}'; + var float:Float = toFixed(value); + if (valueFormatter != null) + { + return valueFormatter(float); + } + else + { + return '${float}'; + } } function toFixed(value:Float):Float From 0c5815c176c95e8fe8b5ca278f67da3fcd65801a Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 13 Jul 2024 21:27:14 +0200 Subject: [PATCH 012/143] add completion check --- source/funkin/save/Save.hx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index 2900ce2be6..5e3d1b7453 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -545,11 +545,14 @@ class Save return; } + var newCompletion = (newScoreData.tallies.sick + newScoreData.tallies.good) / newScoreData.tallies.totalNotes; + var previousCompletion = (previousScoreData.tallies.sick + previousScoreData.tallies.good) / previousScoreData.tallies.totalNotes; + // Set the high score and the high rank separately. var newScore:SaveScoreData = { score: (previousScoreData.score > newScoreData.score) ? previousScoreData.score : newScoreData.score, - tallies: (previousRank > newRank) ? previousScoreData.tallies : newScoreData.tallies + tallies: (previousRank > newRank || previousCompletion > newCompletion) ? previousScoreData.tallies : newScoreData.tallies }; song.set(difficultyId, newScore); From d43042fd36a74d789a3e439e0ecec5d8f1a07722 Mon Sep 17 00:00:00 2001 From: Hyper_ Date: Mon, 5 Aug 2024 20:02:23 -0300 Subject: [PATCH 013/143] Fix out of bounds note selection --- source/funkin/ui/debug/charting/ChartEditorState.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index f72cca77f6..98d8036e94 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -4223,8 +4223,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } else { - // Minimum of 0. - return 0; + // Minimum of -1. + return -1; } }); From 00c7767f8a82304a7b7595e041ad60dbbc8cb3ca Mon Sep 17 00:00:00 2001 From: cyn Date: Fri, 23 Aug 2024 20:17:10 -0700 Subject: [PATCH 014/143] Update FunkinSound.hx --- source/funkin/audio/FunkinSound.hx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/funkin/audio/FunkinSound.hx b/source/funkin/audio/FunkinSound.hx index c70f195d2f..7105a87357 100644 --- a/source/funkin/audio/FunkinSound.hx +++ b/source/funkin/audio/FunkinSound.hx @@ -543,11 +543,12 @@ class FunkinSound extends FlxSound implements ICloneable /** * Stop all sounds in the pool and allow them to be recycled. */ - public static function stopAllAudio(musicToo:Bool = false):Void + public static function stopAllAudio(musicToo:Bool = false, persistToo:Bool = false):Void { for (sound in pool) { if (sound == null) continue; + if (!persistToo && sound.persist) continue; if (!musicToo && sound == FlxG.sound.music) continue; sound.destroy(); } From df266e66d33e404727cfb30467f12582c44f7a75 Mon Sep 17 00:00:00 2001 From: cyn Date: Wed, 4 Sep 2024 19:24:14 -0700 Subject: [PATCH 015/143] dont do that --- source/funkin/modding/module/ModuleHandler.hx | 1 - 1 file changed, 1 deletion(-) diff --git a/source/funkin/modding/module/ModuleHandler.hx b/source/funkin/modding/module/ModuleHandler.hx index 4711e7419c..6c60b0f8c9 100644 --- a/source/funkin/modding/module/ModuleHandler.hx +++ b/source/funkin/modding/module/ModuleHandler.hx @@ -125,7 +125,6 @@ class ModuleHandler for (key => value in moduleCache) { ScriptEventDispatcher.callEvent(value, event); - moduleCache.remove(key); } moduleCache.clear(); From 77346696f834fa7e628c19c50e0f5e9d974cff33 Mon Sep 17 00:00:00 2001 From: lemz Date: Sat, 7 Sep 2024 19:49:08 +0200 Subject: [PATCH 016/143] Update MusicBeatSubState.hx --- source/funkin/ui/MusicBeatSubState.hx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source/funkin/ui/MusicBeatSubState.hx b/source/funkin/ui/MusicBeatSubState.hx index 9035d12ff3..614961d705 100644 --- a/source/funkin/ui/MusicBeatSubState.hx +++ b/source/funkin/ui/MusicBeatSubState.hx @@ -37,16 +37,24 @@ class MusicBeatSubState extends FlxSubState implements IEventHandler return _conductorInUse = value; } + var controls(get, never):Controls; + + inline function get_controls():Controls + return PlayerSettings.player1.controls; + public function new(bgColor:FlxColor = FlxColor.TRANSPARENT) { super(); this.bgColor = bgColor; - } - var controls(get, never):Controls; + initCallbacks(); + } - inline function get_controls():Controls - return PlayerSettings.player1.controls; + function initCallbacks() + { + subStateOpened.add(onOpenSubStateComplete); + subStateClosed.add(onCloseSubStateComplete); + } override function create():Void { From 178389ea0bd00bb7d1822abaff2aa3524f3f3f61 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 12 Sep 2024 23:28:43 -0400 Subject: [PATCH 017/143] Fix two song credits --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index bc7009b424..c3041be563 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit bc7009b4242691faa5c4552f7ca8a2f28e8cb1d2 +Subproject commit c3041be56396cda92f87d071f74d36113ed25e1f From 3fba55a4229139de0f64925f2bfc77ce1f689b0f Mon Sep 17 00:00:00 2001 From: FabsTheFabs Date: Fri, 13 Sep 2024 21:36:20 +0100 Subject: [PATCH 018/143] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 8762fd51c2..eaab81b1a7 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 8762fd51c26abdc9a45657eab9018aa48e972cd6 +Subproject commit eaab81b1a76d18f356cf0a38f3feed463aed28cb From 517984d1200f0fe43a7a7bec4bd62cd6032a8997 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 13 Sep 2024 18:46:49 -0400 Subject: [PATCH 019/143] Fix a bug where Shit judgement would always display with anti-aliasing. --- source/funkin/play/notes/notestyle/NoteStyle.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/play/notes/notestyle/NoteStyle.hx b/source/funkin/play/notes/notestyle/NoteStyle.hx index ee07703f1f..83aae6fcf6 100644 --- a/source/funkin/play/notes/notestyle/NoteStyle.hx +++ b/source/funkin/play/notes/notestyle/NoteStyle.hx @@ -575,7 +575,7 @@ class NoteStyle implements IRegistryEntry var result = _data.assets.judgementBad?.isPixel; if (result == null && fallback != null) result = fallback.isJudgementSpritePixel(rating); return result ?? false; - case "GO": + case "shit": var result = _data.assets.judgementShit?.isPixel; if (result == null && fallback != null) result = fallback.isJudgementSpritePixel(rating); return result ?? false; From df87d677e1b155049bc254904a965989b53fa160 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 14 Sep 2024 17:00:41 -0400 Subject: [PATCH 020/143] Typo lol --- source/funkin/modding/PolymodHandler.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx index 75c69e5065..e0b27e7443 100644 --- a/source/funkin/modding/PolymodHandler.hx +++ b/source/funkin/modding/PolymodHandler.hx @@ -258,7 +258,7 @@ class PolymodHandler Polymod.blacklistImport('cpp.Lib'); // `Unserializer` - // Unserializerr.DEFAULT_RESOLVER.resolveClass() can access blacklisted packages + // Unserializer.DEFAULT_RESOLVER.resolveClass() can access blacklisted packages Polymod.blacklistImport('Unserializer'); // `lime.system.CFFI` From 688abb557134d6b786628c206db126cfcba6d579 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 14 Sep 2024 20:25:45 -0400 Subject: [PATCH 021/143] Update example mod's API version so it actually loads. --- example_mods/introMod/_polymod_meta.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_mods/introMod/_polymod_meta.json b/example_mods/introMod/_polymod_meta.json index 4dc0cd8044..74c4a25040 100644 --- a/example_mods/introMod/_polymod_meta.json +++ b/example_mods/introMod/_polymod_meta.json @@ -6,7 +6,7 @@ "name": "EliteMasterEric" } ], - "api_version": "0.1.0", + "api_version": "0.5.0", "mod_version": "1.0.0", "license": "Apache-2.0" } From d5c7e4ffdb0076d1c54ee9e9703fb0a3a682fd96 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 14 Sep 2024 20:26:19 -0400 Subject: [PATCH 022/143] Fix bug where Pico would become locked on every game restart. --- source/funkin/save/Save.hx | 20 +++++++--- source/funkin/save/changelog.md | 6 +++ source/funkin/ui/mainmenu/MainMenuState.hx | 43 ++++++++++++---------- source/funkin/ui/title/TitleState.hx | 5 --- 4 files changed, 43 insertions(+), 31 deletions(-) diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index 2bbda15c00..eb9f6005ef 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -17,7 +17,7 @@ import thx.semver.Version; @:nullSafety class Save { - public static final SAVE_DATA_VERSION:thx.semver.Version = "2.0.5"; + public static final SAVE_DATA_VERSION:thx.semver.Version = "2.0.4"; public static final SAVE_DATA_VERSION_RULE:thx.semver.VersionRule = "2.0.x"; // We load this version's saves from a new save path, to maintain SOME level of backwards compatibility. @@ -34,19 +34,19 @@ class Save { if (_instance == null) { - _instance = new Save(FlxG.save.data); + return _instance = load(); } return _instance; } var data:RawSaveData; - public static function load():Void + public static function load():Save { trace("[SAVE] Loading save..."); // Bind save data. - loadFromSlot(1); + return loadFromSlot(1); } /** @@ -65,7 +65,9 @@ class Save public static function getDefault():RawSaveData { return { - version: Save.SAVE_DATA_VERSION, + // Version number is an abstract(Array) internally. + // This means it copies by reference, so merging save data overides the version number lol. + version: thx.Dynamics.clone(Save.SAVE_DATA_VERSION), volume: 1.0, mute: false, @@ -433,7 +435,9 @@ class Save { if (!data.unlocks.charactersSeen.contains(character)) { + trace('Character seen: ' + character); data.unlocks.charactersSeen.push(character); + trace('New characters seen list: ' + data.unlocks.charactersSeen); flush(); } } @@ -832,7 +836,7 @@ class Save * If you set slot to `2`, it will load an independe * @param slot */ - static function loadFromSlot(slot:Int):Void + static function loadFromSlot(slot:Int):Save { trace("[SAVE] Loading save from slot " + slot + "..."); @@ -850,12 +854,14 @@ class Save trace('[SAVE] Found legacy save data, converting...'); var gameSave = SaveDataMigrator.migrateFromLegacy(legacySaveData); FlxG.save.mergeData(gameSave.data, true); + return gameSave; } else { trace('[SAVE] No legacy save data found.'); var gameSave = new Save(); FlxG.save.mergeData(gameSave.data, true); + return gameSave; } } else @@ -863,6 +869,8 @@ class Save trace('[SAVE] Found existing save data.'); var gameSave = SaveDataMigrator.migrate(FlxG.save.data); FlxG.save.mergeData(gameSave.data, true); + + return gameSave; } } diff --git a/source/funkin/save/changelog.md b/source/funkin/save/changelog.md index e3038373d2..41d6e68aee 100644 --- a/source/funkin/save/changelog.md +++ b/source/funkin/save/changelog.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0.4] - 2024-09-12 +Note to self: Only update to 2.1.0 when migration is needed. +### Added +- `unlocks.charactersSeen:Array` to `Save` +- `unlocks.oldChar:Bool` to `Save` + ## [2.0.5] - 2024-05-21 ### Fixed - Resolved an issue where HTML5 wouldn't store the semantic version properly, causing the game to fail to load the save. diff --git a/source/funkin/ui/mainmenu/MainMenuState.hx b/source/funkin/ui/mainmenu/MainMenuState.hx index 13d68da6d9..a436848d2d 100644 --- a/source/funkin/ui/mainmenu/MainMenuState.hx +++ b/source/funkin/ui/mainmenu/MainMenuState.hx @@ -356,7 +356,7 @@ class MainMenuState extends MusicBeatState #if FEATURE_DEBUG_FUNCTIONS // Ctrl+Alt+Shift+P = Character Unlock screen // Ctrl+Alt+Shift+W = Meet requirements for Pico Unlock - // Ctrl+Alt+Shift+L = Revoke requirements for Pico Unlock + // Ctrl+Alt+Shift+M = Revoke requirements for Pico Unlock // Ctrl+Alt+Shift+R = Score/Rank conflict test // Ctrl+Alt+Shift+N = Mark all characters as not seen // Ctrl+Alt+Shift+E = Dump save data @@ -369,7 +369,7 @@ class MainMenuState extends MusicBeatState if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.ALT && FlxG.keys.pressed.SHIFT && FlxG.keys.justPressed.W) { FunkinSound.playOnce(Paths.sound('confirmMenu')); - // Give the user a score of 1 point on Weekend 1 story mode. + // Give the user a score of 1 point on Weekend 1 story mode (Easy difficulty). // This makes the level count as cleared and displays the songs in Freeplay. funkin.save.Save.instance.setLevelScore('weekend1', 'easy', { @@ -389,27 +389,30 @@ class MainMenuState extends MusicBeatState }); } - if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.ALT && FlxG.keys.pressed.SHIFT && FlxG.keys.justPressed.L) + if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.ALT && FlxG.keys.pressed.SHIFT && FlxG.keys.justPressed.M) { FunkinSound.playOnce(Paths.sound('confirmMenu')); - // Give the user a score of 0 points on Weekend 1 story mode. + // Give the user a score of 0 points on Weekend 1 story mode (all difficulties). // This makes the level count as uncleared and no longer displays the songs in Freeplay. - funkin.save.Save.instance.setLevelScore('weekend1', 'easy', - { - score: 1, - tallies: - { - sick: 0, - good: 0, - bad: 0, - shit: 0, - missed: 0, - combo: 0, - maxCombo: 0, - totalNotesHit: 0, - totalNotes: 0, - } - }); + for (diff in ['easy', 'normal', 'hard']) + { + funkin.save.Save.instance.setLevelScore('weekend1', diff, + { + score: 0, + tallies: + { + sick: 0, + good: 0, + bad: 0, + shit: 0, + missed: 0, + combo: 0, + maxCombo: 0, + totalNotesHit: 0, + totalNotes: 0, + } + }); + } } if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.ALT && FlxG.keys.pressed.SHIFT && FlxG.keys.justPressed.R) diff --git a/source/funkin/ui/title/TitleState.hx b/source/funkin/ui/title/TitleState.hx index f5c641d0c4..10e7dfaaec 100644 --- a/source/funkin/ui/title/TitleState.hx +++ b/source/funkin/ui/title/TitleState.hx @@ -273,11 +273,6 @@ class TitleState extends MusicBeatState } #end - if (Save.instance.charactersSeen.contains("pico")) - { - Save.instance.charactersSeen.remove("pico"); - Save.instance.oldChar = false; - } Conductor.instance.update(); /* if (FlxG.onMobile) From fd6ca6e267d5ffbbb63f9e01e7ca92935a6785f4 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 14 Sep 2024 20:26:33 -0400 Subject: [PATCH 023/143] Remove some spammy log traces. --- source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx | 2 +- source/funkin/ui/charSelect/CharSelectPlayer.hx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx index 952fa8b717..7ea97e39bf 100644 --- a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx +++ b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx @@ -184,7 +184,7 @@ class FlxAtlasSprite extends FlxAnimate // Move to the first frame of the animation. // goToFrameLabel(id); - trace('Playing animation $id'); + // trace('Playing animation $id'); if ((id == null || id == "") || this.anim.symbolDictionary.exists(id) || (this.anim.getByName(id) != null)) { this.anim.play(id, restart, false, startFrame); diff --git a/source/funkin/ui/charSelect/CharSelectPlayer.hx b/source/funkin/ui/charSelect/CharSelectPlayer.hx index b6319f16d8..1eef52bedc 100644 --- a/source/funkin/ui/charSelect/CharSelectPlayer.hx +++ b/source/funkin/ui/charSelect/CharSelectPlayer.hx @@ -47,7 +47,6 @@ class CharSelectPlayer extends FlxAtlasSprite implements IBPMSyncedScriptedClass // if (getCurrentAnimation() == "idle") { - trace('Player beat hit'); playAnimation("idle", true, false, false); } }; From e23a85682a89c049c41cd0b67e434fcce6cc0b29 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 14 Sep 2024 20:26:39 -0400 Subject: [PATCH 024/143] Update some script files. --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index bc7009b424..6165511460 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit bc7009b4242691faa5c4552f7ca8a2f28e8cb1d2 +Subproject commit 61655114603807b651109af282c2e2aefa9dccf2 From 9f3af1ab944d41ba56edc7336b6b795fdae89c32 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 14 Sep 2024 20:56:21 -0400 Subject: [PATCH 025/143] Add a separate Gold Perfect animation for modders --- assets | 2 +- source/funkin/data/freeplay/player/PlayerData.hx | 1 + source/funkin/ui/freeplay/charselect/PlayableCharacter.hx | 4 +++- source/funkin/util/Constants.hx | 4 ---- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/assets b/assets index bc7009b424..ef7386d741 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit bc7009b4242691faa5c4552f7ca8a2f28e8cb1d2 +Subproject commit ef7386d741e715bd809c913a7d50dfa7b8176e2d diff --git a/source/funkin/data/freeplay/player/PlayerData.hx b/source/funkin/data/freeplay/player/PlayerData.hx index de293c24e3..867fe71135 100644 --- a/source/funkin/data/freeplay/player/PlayerData.hx +++ b/source/funkin/data/freeplay/player/PlayerData.hx @@ -270,6 +270,7 @@ typedef PlayerResultsData = { var music:PlayerResultsMusicData; + var perfectGold:Array; var perfect:Array; var excellent:Array; var great:Array; diff --git a/source/funkin/ui/freeplay/charselect/PlayableCharacter.hx b/source/funkin/ui/freeplay/charselect/PlayableCharacter.hx index 93d643ae44..408a916729 100644 --- a/source/funkin/ui/freeplay/charselect/PlayableCharacter.hx +++ b/source/funkin/ui/freeplay/charselect/PlayableCharacter.hx @@ -113,7 +113,9 @@ class PlayableCharacter implements IRegistryEntry switch (rank) { - case PERFECT | PERFECT_GOLD: + case PERFECT_GOLD: + return _data.results.perfectGold; + case PERFECT: return _data.results.perfect; case EXCELLENT: return _data.results.excellent; diff --git a/source/funkin/util/Constants.hx b/source/funkin/util/Constants.hx index 57fc484b81..cf58d191a3 100644 --- a/source/funkin/util/Constants.hx +++ b/source/funkin/util/Constants.hx @@ -481,10 +481,6 @@ class Constants public static final JUDGEMENT_BAD_COMBO_BREAK:Bool = true; public static final JUDGEMENT_SHIT_COMBO_BREAK:Bool = true; - // % Sick - public static final RANK_PERFECT_PLAT_THRESHOLD:Float = 1.0; // % Sick - public static final RANK_PERFECT_GOLD_THRESHOLD:Float = 0.85; // % Sick - // % Hit public static final RANK_PERFECT_THRESHOLD:Float = 1.00; public static final RANK_EXCELLENT_THRESHOLD:Float = 0.90; From 16aff6e7c35152c4b3fd86ec73fc798b75847016 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 14 Sep 2024 21:37:02 -0400 Subject: [PATCH 026/143] Fix bugs with highscore display in Freeplay --- source/funkin/ui/freeplay/FreeplayState.hx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index af0a9b841d..15633ff9d1 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -586,13 +586,13 @@ class FreeplayState extends MusicBeatSubState } }; - exitMovers.set([fp, txtCompletion, fnfHighscoreSpr, txtCompletion, clearBoxSprite], + exitMovers.set([fp, txtCompletion, fnfHighscoreSpr, clearBoxSprite], { x: FlxG.width, speed: 0.3 }); - exitMoversCharSel.set([fp, txtCompletion, fnfHighscoreSpr, txtCompletion, clearBoxSprite], + exitMoversCharSel.set([fp, txtCompletion, fnfHighscoreSpr, clearBoxSprite], { y: -270, speed: 0.8, @@ -1376,7 +1376,7 @@ class FreeplayState extends MusicBeatSubState #if FEATURE_DEBUG_FUNCTIONS if (FlxG.keys.justPressed.P) { - FlxG.switchState(FreeplayState.build( + FlxG.switchState(() -> FreeplayState.build( { { character: currentCharacterId == "pico" ? Constants.DEFAULT_CHARACTER : "pico", @@ -1777,12 +1777,13 @@ class FreeplayState extends MusicBeatSubState FlxG.log.warn('WARN: could not find song with id (${daSong.songId})'); return; } - var targetVariation:String = targetSong.getFirstValidVariation(currentDifficulty) ?? ''; + var targetVariation:String = targetSong.getFirstValidVariation(currentDifficulty, currentCharacter) ?? ''; // TODO: This line of code makes me sad, but you can't really fix it without a breaking migration. var suffixedDifficulty = (targetVariation != Constants.DEFAULT_VARIATION && targetVariation != 'erect') ? '$currentDifficulty-${targetVariation}' : currentDifficulty; var songScore:Null = Save.instance.getSongScore(daSong.songId, suffixedDifficulty); + trace(songScore); intendedScore = songScore?.score ?? 0; intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes); rememberedDifficulty = suffixedDifficulty; From 367e3e90083f95a13a5b4e76339f2d4eac534203 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 16 Sep 2024 17:18:42 -0400 Subject: [PATCH 027/143] priv modules --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index be5e0aaa81..ad8099e602 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "assets"] path = assets - url = https://github.com/FunkinCrew/funkin.assets + url = https://github.com/FunkinCrew/Funkin-assets-secret [submodule "art"] path = art - url = https://github.com/FunkinCrew/funkin.art + url = https://github.com/FunkinCrew/Funkin-art-secret From 0b531c5b21931bc690ebe9f46d7111800e23704f Mon Sep 17 00:00:00 2001 From: Abnormal <86753001+AbnormalPoof@users.noreply.github.com> Date: Mon, 16 Sep 2024 22:13:16 +0000 Subject: [PATCH 028/143] add getPath --- source/funkin/Assets.hx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/funkin/Assets.hx b/source/funkin/Assets.hx index 5351676d4d..05423c5726 100644 --- a/source/funkin/Assets.hx +++ b/source/funkin/Assets.hx @@ -11,6 +11,11 @@ class Assets return openfl.utils.Assets.getText(path); } + public static function getPath(path:String):String + { + return openfl.utils.Assets.getPath(path); + } + public static function getMusic(path:String):openfl.media.Sound { return openfl.utils.Assets.getMusic(path); From 80fc0cd526d9dc22fe7c6afd141ee5c6814a3b84 Mon Sep 17 00:00:00 2001 From: lemz Date: Tue, 17 Sep 2024 00:16:27 +0200 Subject: [PATCH 029/143] Update Preferences.hx --- source/funkin/Preferences.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/funkin/Preferences.hx b/source/funkin/Preferences.hx index 7a322283dd..25bc32163e 100644 --- a/source/funkin/Preferences.hx +++ b/source/funkin/Preferences.hx @@ -15,7 +15,7 @@ class Preferences static function get_framerate():Int { - #if web + #if (web || CHEEMS) return 60; #else return Save?.instance?.options?.framerate ?? 60; @@ -24,7 +24,7 @@ class Preferences static function set_framerate(value:Int):Int { - #if web + #if (web || CHEEMS) return 60; #else var save:Save = Save.instance; From 224d930ae6e7b41f8c79b19f842a9175374f87c9 Mon Sep 17 00:00:00 2001 From: lemz Date: Tue, 17 Sep 2024 00:17:56 +0200 Subject: [PATCH 030/143] Update PreferencesMenu.hx --- source/funkin/ui/options/PreferencesMenu.hx | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index ca18c45be7..adbe1d356a 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -6,8 +6,6 @@ import flixel.FlxSprite; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; import funkin.ui.AtlasText.AtlasFont; import funkin.ui.options.OptionsState.Page; -import funkin.ui.options.items.CheckboxPreferenceItem; -import funkin.ui.options.items.NumberPreferenceItem; import funkin.graphics.FunkinCamera; import funkin.ui.TextMenuList.TextMenuItem; import funkin.audio.FunkinSound; From 535ac0e5283ecd83866907920cac52444fcd0e9c Mon Sep 17 00:00:00 2001 From: Kade <26305836+Kade-github@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:25:13 -0700 Subject: [PATCH 031/143] add milliseconds to the playbar in charting state remove laggy redundant traces Revert "remove laggy redundant traces" This reverts commit 204113840473dd5069f5d508d50e15e21104b45a. --- source/funkin/ui/debug/charting/ChartEditorState.hx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 811e08e5d8..f778b11f37 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -5139,10 +5139,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } var songPos:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset; + var songPosMilliseconds:String = Std.string(Math.floor(Math.abs(songPos) % 1000)).lpad('0', 2); var songPosSeconds:String = Std.string(Math.floor((Math.abs(songPos) / 1000) % 60)).lpad('0', 2); var songPosMinutes:String = Std.string(Math.floor((Math.abs(songPos) / 1000) / 60)).lpad('0', 2); if (songPos < 0) songPosMinutes = '-' + songPosMinutes; - var songPosString:String = '${songPosMinutes}:${songPosSeconds}'; + var songPosString:String = '${songPosMinutes}:${songPosSeconds}:${songPosMilliseconds}'; if (playbarSongPos.value != songPosString) playbarSongPos.value = songPosString; From 5a877a14a0d468d0592be6edfaa21b05dc8b3ebf Mon Sep 17 00:00:00 2001 From: Kade <26305836+Kade-github@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:39:56 -0700 Subject: [PATCH 032/143] only show last two digits digit --- source/funkin/ui/debug/charting/ChartEditorState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index f778b11f37..024de8ec68 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -5139,7 +5139,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } var songPos:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset; - var songPosMilliseconds:String = Std.string(Math.floor(Math.abs(songPos) % 1000)).lpad('0', 2); + var songPosMilliseconds:String = Std.string(Math.floor(Math.abs(songPos) % 1000)).lpad('0', 2).substr(0, 2); var songPosSeconds:String = Std.string(Math.floor((Math.abs(songPos) / 1000) % 60)).lpad('0', 2); var songPosMinutes:String = Std.string(Math.floor((Math.abs(songPos) / 1000) / 60)).lpad('0', 2); if (songPos < 0) songPosMinutes = '-' + songPosMinutes; From 7d2b946e9c1f885af6ccc9a937ed5af4774d9599 Mon Sep 17 00:00:00 2001 From: Kade <26305836+Kade-github@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:42:53 -0700 Subject: [PATCH 033/143] depreciated screen X/Y to view X/Y --- .../ui/debug/charting/ChartEditorState.hx | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 024de8ec68..c0c2e63091 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -700,7 +700,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState function get_isCursorOverHaxeUI():Bool { - return Screen.instance.hasSolidComponentUnderPoint(FlxG.mouse.screenX, FlxG.mouse.screenY); + return Screen.instance.hasSolidComponentUnderPoint(FlxG.mouse.viewX, FlxG.mouse.viewY); } /** @@ -3830,7 +3830,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState function handleScrollKeybinds():Void { // Don't scroll when the user is interacting with the UI, unless a playbar button (the << >> ones) is pressed. - if ((isHaxeUIFocused || isCursorOverHaxeUI) && playbarButtonPressed == null) return; + if ((isHaxeUIFocused || isHaxeUIDialogOpen) && playbarButtonPressed == null) return; var scrollAmount:Float = 0; // Amount to scroll the grid. var playheadAmount:Float = 0; // Amount to scroll the playhead relative to the grid. @@ -3840,7 +3840,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // Handle scroll anchor if (scrollAnchorScreenPos != null) { - var currentScreenPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY); + var currentScreenPos = new FlxPoint(FlxG.mouse.viewX, FlxG.mouse.viewX); var distance = currentScreenPos - scrollAnchorScreenPos; var verticalDistance = distance.y; @@ -4121,8 +4121,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState var overlapsRenderedEvents:Bool = FlxG.mouse.overlaps(renderedEvents); // Cursor position relative to the grid. - var cursorX:Float = FlxG.mouse.screenX - gridTiledSprite.x; - var cursorY:Float = FlxG.mouse.screenY - gridTiledSprite.y; + var cursorX:Float = FlxG.mouse.viewX - gridTiledSprite.x; + var cursorY:Float = FlxG.mouse.viewY - gridTiledSprite.y; var overlapsSelectionBorder:Bool = overlapsGrid && ((cursorX % 40) < (GRID_SELECTION_BORDER_WIDTH / 2) @@ -4137,7 +4137,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { if (scrollAnchorScreenPos == null) { - scrollAnchorScreenPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY); + scrollAnchorScreenPos = new FlxPoint(FlxG.mouse.viewX, FlxG.mouse.viewY); selectionBoxStartPos = null; } else @@ -4159,11 +4159,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState else if (notePreview != null && FlxG.mouse.overlaps(notePreview) && !isCursorOverHaxeUI) { // Clicked note preview - notePreviewScrollAreaStartPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY); + notePreviewScrollAreaStartPos = new FlxPoint(FlxG.mouse.viewX, FlxG.mouse.viewY); } else if (!isCursorOverHaxeUI && (!overlapsGrid || overlapsSelectionBorder)) { - selectionBoxStartPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY); + selectionBoxStartPos = new FlxPoint(FlxG.mouse.viewX, FlxG.mouse.viewY); // Drawing selection box. targetCursorMode = Crosshair; } @@ -4188,7 +4188,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { // Clicked on the playhead scroll area. // Move the playhead to the cursor position. - this.playheadPositionInPixels = FlxG.mouse.screenY - (GRID_INITIAL_Y_POS); + this.playheadPositionInPixels = FlxG.mouse.viewY - (GRID_INITIAL_Y_POS); moveSongToScrollPosition(); // Cursor should be a grabby hand. @@ -4313,27 +4313,27 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // Clicking and dragging. // Scroll the screen if the mouse is above or below the grid. - if (FlxG.mouse.screenY < MENU_BAR_HEIGHT) + if (FlxG.mouse.viewY < MENU_BAR_HEIGHT) { // Scroll up. - var diff:Float = MENU_BAR_HEIGHT - FlxG.mouse.screenY; + var diff:Float = MENU_BAR_HEIGHT - FlxG.mouse.viewY; scrollPositionInPixels -= diff * 0.5; // Too fast! moveSongToScrollPosition(); } - else if (FlxG.mouse.screenY > (playbarHeadLayout?.y ?? 0.0)) + else if (FlxG.mouse.viewY > (playbarHeadLayout?.y ?? 0.0)) { // Scroll down. - var diff:Float = FlxG.mouse.screenY - (playbarHeadLayout?.y ?? 0.0); + var diff:Float = FlxG.mouse.viewY - (playbarHeadLayout?.y ?? 0.0); scrollPositionInPixels += diff * 0.5; // Too fast! moveSongToScrollPosition(); } // Render the selection box. var selectionRect:FlxRect = new FlxRect(); - selectionRect.x = Math.min(FlxG.mouse.screenX, selectionBoxStartPos.x); - selectionRect.y = Math.min(FlxG.mouse.screenY, selectionBoxStartPos.y); - selectionRect.width = Math.abs(FlxG.mouse.screenX - selectionBoxStartPos.x); - selectionRect.height = Math.abs(FlxG.mouse.screenY - selectionBoxStartPos.y); + selectionRect.x = Math.min(FlxG.mouse.viewX, selectionBoxStartPos.x); + selectionRect.y = Math.min(FlxG.mouse.viewY, selectionBoxStartPos.y); + selectionRect.width = Math.abs(FlxG.mouse.viewX - selectionBoxStartPos.x); + selectionRect.height = Math.abs(FlxG.mouse.viewY - selectionBoxStartPos.y); setSelectionBoxBounds(selectionRect); targetCursorMode = Crosshair; @@ -4461,8 +4461,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // Player is clicking and holding on note preview to scrub around. targetCursorMode = Grabbing; - var clickedPosInPixels:Float = FlxMath.remapToRange(FlxG.mouse.screenY, (notePreview?.y ?? 0.0), - (notePreview?.y ?? 0.0) + (notePreview?.height ?? 0.0), 0, songLengthInPixels); + var clickedPosInPixels:Float = FlxMath.remapToRange(FlxG.mouse.viewY, (notePreview?.y ?? 0.0), (notePreview?.y ?? 0.0) + (notePreview?.height ?? 0.0), + 0, songLengthInPixels); scrollPositionInPixels = clickedPosInPixels; moveSongToScrollPosition(); @@ -4520,17 +4520,17 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState targetCursorMode = Grabbing; // Scroll the screen if the mouse is above or below the grid. - if (FlxG.mouse.screenY < MENU_BAR_HEIGHT) + if (FlxG.mouse.viewY < MENU_BAR_HEIGHT) { // Scroll up. - var diff:Float = MENU_BAR_HEIGHT - FlxG.mouse.screenY; + var diff:Float = MENU_BAR_HEIGHT - FlxG.mouse.viewY; scrollPositionInPixels -= diff * 0.5; // Too fast! moveSongToScrollPosition(); } - else if (FlxG.mouse.screenY > (playbarHeadLayout?.y ?? 0.0)) + else if (FlxG.mouse.viewY > (playbarHeadLayout?.y ?? 0.0)) { // Scroll down. - var diff:Float = FlxG.mouse.screenY - (playbarHeadLayout?.y ?? 0.0); + var diff:Float = FlxG.mouse.viewY - (playbarHeadLayout?.y ?? 0.0); scrollPositionInPixels += diff * 0.5; // Too fast! moveSongToScrollPosition(); } @@ -4811,11 +4811,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // Show the context menu connected to the note. if (useSingleNoteContextMenu) { - this.openNoteContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY, highlightedNote.noteData); + this.openNoteContextMenu(FlxG.mouse.viewX, FlxG.mouse.viewY, highlightedNote.noteData); } else { - this.openSelectionContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY); + this.openSelectionContextMenu(FlxG.mouse.viewX, FlxG.mouse.viewY); } } else @@ -4835,11 +4835,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState || (isHighlightedEventSelected && currentEventSelection.length == 1); if (useSingleEventContextMenu) { - this.openEventContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY, highlightedEvent.eventData); + this.openEventContextMenu(FlxG.mouse.viewX, FlxG.mouse.viewY, highlightedEvent.eventData); } else { - this.openSelectionContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY); + this.openSelectionContextMenu(FlxG.mouse.viewX, FlxG.mouse.viewY); } } else @@ -4860,11 +4860,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // Show the context menu connected to the note. if (useSingleNoteContextMenu) { - this.openHoldNoteContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY, highlightedHoldNote.noteData); + this.openHoldNoteContextMenu(FlxG.mouse.viewX, FlxG.mouse.viewY, highlightedHoldNote.noteData); } else { - this.openSelectionContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY); + this.openSelectionContextMenu(FlxG.mouse.viewX, FlxG.mouse.viewY); } } else From 9624b57e4447925a3f7764ffae8442585221bde3 Mon Sep 17 00:00:00 2001 From: Kade <26305836+Kade-github@users.noreply.github.com> Date: Mon, 16 Sep 2024 17:23:49 -0700 Subject: [PATCH 034/143] This does fix it now --- source/funkin/ui/debug/charting/ChartEditorState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index c0c2e63091..922138a103 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -3830,7 +3830,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState function handleScrollKeybinds():Void { // Don't scroll when the user is interacting with the UI, unless a playbar button (the << >> ones) is pressed. - if ((isHaxeUIFocused || isHaxeUIDialogOpen) && playbarButtonPressed == null) return; + if ((isHaxeUIFocused || isCursorOverHaxeUI) && playbarButtonPressed == null) return; var scrollAmount:Float = 0; // Amount to scroll the grid. var playheadAmount:Float = 0; // Amount to scroll the playhead relative to the grid. From d710318830c73d333fdaf347c8250169dc856857 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Mon, 16 Sep 2024 21:54:24 -0400 Subject: [PATCH 035/143] Update HaxeUI --- hmm.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hmm.json b/hmm.json index d967a69b31..edc0529aa6 100644 --- a/hmm.json +++ b/hmm.json @@ -77,14 +77,14 @@ "name": "haxeui-core", "type": "git", "dir": null, - "ref": "22f7c5a8ffca90d4677cffd6e570f53761709fbc", + "ref": "c9d96b168ea2a19274ad7c766ab1a34b57baa793", "url": "https://github.com/haxeui/haxeui-core" }, { "name": "haxeui-flixel", "type": "git", "dir": null, - "ref": "28bb710d0ae5d94b5108787593052165be43b980", + "ref": "013b9d4e56bfe9a034e028a8d685f0b274cb73c4", "url": "https://github.com/haxeui/haxeui-flixel" }, { From 811caf6b704674ffd0c9dd31ed6be5f8575c1b1f Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Mon, 16 Sep 2024 21:54:33 -0400 Subject: [PATCH 036/143] Suppress a spammy log trace --- source/funkin/ui/debug/charting/ChartEditorState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 922138a103..2e259d3f52 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -5615,7 +5615,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } else { - trace('Ignoring keybinds for View menu items because we are in live input mode (${currentLiveInputStyle}).'); + // trace('Ignoring keybinds for View menu items because we are in live input mode (${currentLiveInputStyle}).'); } } From b7c3f5ac9f3221efafc65196079a15b6fd435c3e Mon Sep 17 00:00:00 2001 From: Til Tjardes Date: Mon, 16 Sep 2024 20:04:04 -0600 Subject: [PATCH 037/143] Chart Editor Icons are fixed now! --- source/funkin/play/character/CharacterData.hx | 78 ++++++++++++++----- .../ChartEditorCharacterIconSelectorMenu.hx | 2 +- .../toolboxes/ChartEditorMetadataToolbox.hx | 6 +- 3 files changed, 62 insertions(+), 24 deletions(-) diff --git a/source/funkin/play/character/CharacterData.hx b/source/funkin/play/character/CharacterData.hx index bac2c7141e..40957818a3 100644 --- a/source/funkin/play/character/CharacterData.hx +++ b/source/funkin/play/character/CharacterData.hx @@ -12,6 +12,7 @@ import funkin.util.assets.DataAssets; import funkin.util.VersionUtil; import haxe.Json; import openfl.utils.Assets; +import flixel.graphics.frames.FlxFrame; class CharacterDataParser { @@ -281,41 +282,78 @@ class CharacterDataParser } /** - * TODO: Hardcode this. + * Returns the idle frame of a character. */ - public static function getCharPixelIconAsset(char:String):String + public static function getCharPixelIconAsset(char:String):FlxFrame { - var icon:String = char; + var charPath:String = "freeplay/icons/"; - switch (icon) + // FunkinCrew please dont skin me alive for copying pixelated icon and changing it a tiny bit + switch (char) { - case "bf-christmas" | "bf-car" | "bf-pixel" | "bf-holding-gf": - icon = "bf"; + case "bf-christmas" | "bf-car" | "bf-pixel" | "bf-holding-gf" | "bf-dark": + charPath += "bfpixel"; case "monster-christmas": - icon = "monster"; + charPath += "monsterpixel"; case "mom" | "mom-car": - icon = "mommy"; + charPath += "mommypixel"; case "pico-blazin" | "pico-playable" | "pico-speaker": - icon = "pico"; - case "gf-christmas" | "gf-car" | "gf-pixel" | "gf-tankmen": - icon = "gf"; + charPath += "picopixel"; + case "gf-christmas" | "gf-car" | "gf-pixel" | "gf-tankmen" | "gf-dark": + charPath += "gfpixel"; case "dad": - icon = "daddy"; + charPath += "dadpixel"; case "darnell-blazin": - icon = "darnell"; + charPath += "darnellpixel"; case "senpai-angry": - icon = "senpai"; + charPath += "senpaipixel"; case "spooky-dark": - icon = "spooky"; + charPath += "spookypixel"; case "tankman-atlas": - icon = "tankman"; + charPath += "tankmanpixel"; + case "pico-christmas" | "pico-dark": + charPath += "picopixel"; + default: + charPath += '${char}pixel'; } - var path = Paths.image("freeplay/icons/" + icon + "pixel"); - if (Assets.exists(path)) return path; + if (!Assets.exists(Paths.image(charPath))) + { + trace('[WARN] Character ${char} has no freeplay icon.'); + return null; + } - // TODO: Hardcode some additional behavior or a fallback. - return null; + var isAnimated = Assets.exists(Paths.file('images/$charPath.xml')); + var frame:FlxFrame = null; + + if (isAnimated) + { + var frames = Paths.getSparrowAtlas(charPath); + + var idleFrame:FlxFrame = frames.frames.find(function(frame:FlxFrame):Bool { + return frame.name.startsWith('idle'); + }); + + if (idleFrame == null) + { + trace('[WARN] Character ${char} has no idle in their freeplay icon.'); + return null; + } + + // so, haxe.ui.backend.AssetsImpl uses the parent width and height, which makes the image go crazy when rendered + // so this is a work around so that it uses the actual width and height + var imageGraphic = flixel.graphics.FlxGraphic.fromFrame(idleFrame, false, null, false); + + var imageFrame = flixel.graphics.frames.FlxImageFrame.fromImage(imageGraphic); + frame = imageFrame.frame; + } + else + { + var imageFrame = flixel.graphics.frames.FlxImageFrame.fromImage(Paths.image(charPath)); + frame = imageFrame.frame; + } + + return frame; } /** diff --git a/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx b/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx index 1edbb6c004..90d998a027 100644 --- a/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx +++ b/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx @@ -95,7 +95,7 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu } var LIMIT = 6; - charButton.icon = CharacterDataParser.getCharPixelIconAsset(charId); + charButton.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(charId)); charButton.text = charData.name.length > LIMIT ? '${charData.name.substr(0, LIMIT)}.' : '${charData.name}'; charButton.onClick = _ -> { diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx index c97e8142d4..f68776cabf 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx @@ -221,7 +221,7 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox var charDataOpponent:Null = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.opponent); if (charDataOpponent != null) { - buttonCharacterOpponent.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.opponent); + buttonCharacterOpponent.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.opponent)); buttonCharacterOpponent.text = charDataOpponent.name.length > LIMIT ? '${charDataOpponent.name.substr(0, LIMIT)}.' : '${charDataOpponent.name}'; } else @@ -233,7 +233,7 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox var charDataGirlfriend:Null = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.girlfriend); if (charDataGirlfriend != null) { - buttonCharacterGirlfriend.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.girlfriend); + buttonCharacterGirlfriend.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.girlfriend)); buttonCharacterGirlfriend.text = charDataGirlfriend.name.length > LIMIT ? '${charDataGirlfriend.name.substr(0, LIMIT)}.' : '${charDataGirlfriend.name}'; } else @@ -245,7 +245,7 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox var charDataPlayer:Null = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.player); if (charDataPlayer != null) { - buttonCharacterPlayer.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.player); + buttonCharacterPlayer.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.player)); buttonCharacterPlayer.text = charDataPlayer.name.length > LIMIT ? '${charDataPlayer.name.substr(0, LIMIT)}.' : '${charDataPlayer.name}'; } else From e6525d0129ae9e61ddd7941f50d9cd38904efe6e Mon Sep 17 00:00:00 2001 From: Til Tjardes Date: Mon, 16 Sep 2024 20:44:29 -0600 Subject: [PATCH 038/143] stop being on the kickstarter crack me --- source/funkin/play/character/CharacterData.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/play/character/CharacterData.hx b/source/funkin/play/character/CharacterData.hx index 40957818a3..052310a7e2 100644 --- a/source/funkin/play/character/CharacterData.hx +++ b/source/funkin/play/character/CharacterData.hx @@ -342,7 +342,7 @@ class CharacterDataParser // so, haxe.ui.backend.AssetsImpl uses the parent width and height, which makes the image go crazy when rendered // so this is a work around so that it uses the actual width and height - var imageGraphic = flixel.graphics.FlxGraphic.fromFrame(idleFrame, false, null, false); + var imageGraphic = flixel.graphics.FlxGraphic.fromFrame(idleFrame); var imageFrame = flixel.graphics.frames.FlxImageFrame.fromImage(imageGraphic); frame = imageFrame.frame; From aae7dcdada565307a22c80a82666a8e4e1837d2e Mon Sep 17 00:00:00 2001 From: AbnormalPoof Date: Mon, 16 Sep 2024 23:35:23 -0500 Subject: [PATCH 039/143] fix crash when opening urls --- source/funkin/ui/mainmenu/MainMenuState.hx | 4 ++-- source/funkin/util/WindowUtil.hx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/funkin/ui/mainmenu/MainMenuState.hx b/source/funkin/ui/mainmenu/MainMenuState.hx index 13d68da6d9..588e4cb29d 100644 --- a/source/funkin/ui/mainmenu/MainMenuState.hx +++ b/source/funkin/ui/mainmenu/MainMenuState.hx @@ -123,7 +123,7 @@ class MainMenuState extends MusicBeatState })); }); - #if CAN_OPEN_LINKS + #if FEATURE_OPEN_URL // In order to prevent popup blockers from triggering, // we need to open the link as an immediate result of a keypress event, // so we can't wait for the flicker animation to complete. @@ -234,7 +234,7 @@ class MainMenuState extends MusicBeatState camFollow.setPosition(selected.getGraphicMidpoint().x, selected.getGraphicMidpoint().y); } - #if CAN_OPEN_LINKS + #if FEATURE_OPEN_URL function selectDonate() { WindowUtil.openURL(Constants.URL_ITCH); diff --git a/source/funkin/util/WindowUtil.hx b/source/funkin/util/WindowUtil.hx index 0fe63fe324..aabaa495b3 100644 --- a/source/funkin/util/WindowUtil.hx +++ b/source/funkin/util/WindowUtil.hx @@ -22,7 +22,7 @@ class WindowUtil */ public static function openURL(targetUrl:String):Void { - #if CAN_OPEN_LINKS + #if FEATURE_OPEN_URL #if linux Sys.command('/usr/bin/xdg-open $targetUrl &'); #else @@ -40,7 +40,7 @@ class WindowUtil */ public static function openFolder(targetPath:String):Void { - #if CAN_OPEN_LINKS + #if FEATURE_OPEN_URL #if windows Sys.command('explorer', [targetPath.replace('/', '\\')]); #elseif mac @@ -59,7 +59,7 @@ class WindowUtil */ public static function openSelectFile(targetPath:String):Void { - #if CAN_OPEN_LINKS + #if FEATURE_OPEN_URL #if windows Sys.command('explorer', ['/select,' + targetPath.replace('/', '\\')]); #elseif mac From 4939b09fb0d7b404a1c8573305ac76c5d7f5fba6 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 17 Sep 2024 04:43:34 -0400 Subject: [PATCH 040/143] manual build artifacts --- .github/workflows/build-game.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-game.yml b/.github/workflows/build-game.yml index dff9a369d3..524bd1b324 100644 --- a/.github/workflows/build-game.yml +++ b/.github/workflows/build-game.yml @@ -2,6 +2,15 @@ name: Build and Upload nightly game builds on: workflow_dispatch: + inputs: + build-defines: + type: string + description: Build defines to use + default: '-DGITHUB_BUILD' + save-artifact: + type: boolean + description: Save the build artifact to Github Actions (sends to itch otherwise) + default: false push: paths-ignore: - '**/Dockerfile' @@ -53,13 +62,20 @@ jobs: - name: Build game if: ${{ matrix.target == 'windows' }} run: | - haxelib run lime build windows -v -release -DGITHUB_BUILD + haxelib run lime build windows -v -release ${{ github.event.inputs.build-defines }} timeout-minutes: 120 - name: Build game if: ${{ matrix.target != 'windows' }} run: | - haxelib run lime build ${{ matrix.target }} -v -release --times -DGITHUB_BUILD + haxelib run lime build ${{ matrix.target }} -v -release --times ${{ github.event.inputs.build-defines }} timeout-minutes: 120 + - name: Save build artifact to Github Actions + if: ${{ github.event.inputs.save-artifact }} + uses: actions/upload-artifact@v4 + with: + name: build-${{ matrix.target }} + path: export/release/${{matrix.target}}/bin/ + - name: Upload build artifacts uses: ./.github/actions/upload-itch @@ -125,7 +141,7 @@ jobs: - name: Build game run: | - haxelib run lime build ${{ matrix.target }} -v -release --times -DGITHUB_BUILD + haxelib run lime build ${{ matrix.target }} -v -release --times ${{ github.event.inputs.build-defines }} timeout-minutes: 120 - name: Upload build artifacts From 7fbbc5cf95f047cd2aec46087dcf2d555d45b9d9 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 17 Sep 2024 04:48:30 -0400 Subject: [PATCH 041/143] save artifacts on html5 and linux? --- .github/workflows/build-game.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-game.yml b/.github/workflows/build-game.yml index 524bd1b324..5eb13081db 100644 --- a/.github/workflows/build-game.yml +++ b/.github/workflows/build-game.yml @@ -144,6 +144,12 @@ jobs: haxelib run lime build ${{ matrix.target }} -v -release --times ${{ github.event.inputs.build-defines }} timeout-minutes: 120 + - name: Save build artifact to Github Actions + if: ${{ github.event.inputs.save-artifact }} + uses: actions/upload-artifact@v4 + with: + name: build-${{ matrix.target }} + path: export/release/${{matrix.target}}/bin/ - name: Upload build artifacts uses: ./.github/actions/upload-itch with: From 0706192cbe7863954351009a9825adf2bfbdd8c4 Mon Sep 17 00:00:00 2001 From: dombomb64 <49823019+dombomb64@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:50:59 -0400 Subject: [PATCH 042/143] Fix note scaling with one simple trick! --- source/funkin/play/notes/StrumlineNote.hx | 2 +- source/funkin/play/notes/notestyle/NoteStyle.hx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/funkin/play/notes/StrumlineNote.hx b/source/funkin/play/notes/StrumlineNote.hx index d8230aa282..c33c8b5787 100644 --- a/source/funkin/play/notes/StrumlineNote.hx +++ b/source/funkin/play/notes/StrumlineNote.hx @@ -85,7 +85,7 @@ class StrumlineNote extends FlxSprite noteStyle.applyStrumlineFrames(this); noteStyle.applyStrumlineAnimations(this, this.direction); - this.setGraphicSize(Std.int(Strumline.STRUMLINE_SIZE * noteStyle.getStrumlineScale())); + this.scale.set(noteStyle.getStrumlineScale()); this.updateHitbox(); noteStyle.applyStrumlineOffsets(this); diff --git a/source/funkin/play/notes/notestyle/NoteStyle.hx b/source/funkin/play/notes/notestyle/NoteStyle.hx index ee07703f1f..9079fee649 100644 --- a/source/funkin/play/notes/notestyle/NoteStyle.hx +++ b/source/funkin/play/notes/notestyle/NoteStyle.hx @@ -93,7 +93,7 @@ class NoteStyle implements IRegistryEntry buildNoteAnimations(target); // Set the scale. - target.setGraphicSize(Strumline.STRUMLINE_SIZE * getNoteScale()); + target.scale.set(getNoteScale()); target.updateHitbox(); } From 6e33cac9ec0636333156a308b65438c311bc92be Mon Sep 17 00:00:00 2001 From: dombomb64 <49823019+dombomb64@users.noreply.github.com> Date: Tue, 17 Sep 2024 16:47:16 -0400 Subject: [PATCH 043/143] ...Okay it wasn't that simple --- source/funkin/play/notes/StrumlineNote.hx | 3 ++- source/funkin/play/notes/SustainTrail.hx | 5 +++-- .../funkin/play/notes/notestyle/NoteStyle.hx | 19 +++++++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/source/funkin/play/notes/StrumlineNote.hx b/source/funkin/play/notes/StrumlineNote.hx index c33c8b5787..16df9f5020 100644 --- a/source/funkin/play/notes/StrumlineNote.hx +++ b/source/funkin/play/notes/StrumlineNote.hx @@ -85,7 +85,8 @@ class StrumlineNote extends FlxSprite noteStyle.applyStrumlineFrames(this); noteStyle.applyStrumlineAnimations(this, this.direction); - this.scale.set(noteStyle.getStrumlineScale()); + var scale = noteStyle.getStrumlineScale(); + this.scale.set(scale, scale); this.updateHitbox(); noteStyle.applyStrumlineOffsets(this); diff --git a/source/funkin/play/notes/SustainTrail.hx b/source/funkin/play/notes/SustainTrail.hx index 90b36b0099..a9af468b94 100644 --- a/source/funkin/play/notes/SustainTrail.hx +++ b/source/funkin/play/notes/SustainTrail.hx @@ -87,6 +87,7 @@ class SustainTrail extends FlxSprite public var bottomClip:Float = 0.9; public var isPixel:Bool; + public var noteStyleOffsets:Array; var graphicWidth:Float = 0; var graphicHeight:Float = 0; @@ -107,6 +108,7 @@ class SustainTrail extends FlxSprite this.noteDirection = noteDirection; setupHoldNoteGraphic(noteStyle); + noteStyleOffsets = noteStyle.getHoldNoteOffsets(); indices = new DrawData(12, true, TRIANGLE_VERTEX_INDICES); @@ -137,7 +139,6 @@ class SustainTrail extends FlxSprite zoom = 1.0; zoom *= noteStyle.fetchHoldNoteScale(); - zoom *= 0.7; // CALCULATE SIZE graphicWidth = graphic.width / 8 * zoom; // amount of notes * 2 @@ -202,7 +203,7 @@ class SustainTrail extends FlxSprite { width = graphicWidth; height = graphicHeight; - offset.set(0, 0); + offset.set(noteStyleOffsets[0], noteStyleOffsets[1]); origin.set(width * 0.5, height * 0.5); } diff --git a/source/funkin/play/notes/notestyle/NoteStyle.hx b/source/funkin/play/notes/notestyle/NoteStyle.hx index 9079fee649..a5ff19cba5 100644 --- a/source/funkin/play/notes/notestyle/NoteStyle.hx +++ b/source/funkin/play/notes/notestyle/NoteStyle.hx @@ -93,7 +93,8 @@ class NoteStyle implements IRegistryEntry buildNoteAnimations(target); // Set the scale. - target.scale.set(getNoteScale()); + var scale = getNoteScale(); + target.scale.set(scale, scale); target.updateHitbox(); } @@ -224,6 +225,13 @@ class NoteStyle implements IRegistryEntry return data?.scale ?? 1.0; } + public function getHoldNoteOffsets():Array + { + var data = _data?.assets?.holdNote; + if (data == null && fallback != null) return fallback.getHoldNoteOffsets(); + return data?.offsets ?? [0.0, 0.0]; + } + public function applyStrumlineFrames(target:StrumlineNote):Void { // TODO: Add support for multi-Sparrow. @@ -304,9 +312,16 @@ class NoteStyle implements IRegistryEntry return thx.Arrays.filterNull(result); } + public function getStrumlineOffsets():Array + { + var data = _data?.assets?.noteStrumline; + if (data == null && fallback != null) return fallback.getStrumlineOffsets(); + return data?.offsets ?? [0.0, 0.0]; + } + public function applyStrumlineOffsets(target:StrumlineNote):Void { - var offsets = _data?.assets?.noteStrumline?.offsets ?? [0.0, 0.0]; + var offsets = getStrumlineOffsets(); target.x += offsets[0]; target.y += offsets[1]; } From f2b3f47e73d4f29590fe1f4fd401a1c81cb9cb50 Mon Sep 17 00:00:00 2001 From: Michael <15317421+ActualMandM@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:46:47 -0700 Subject: [PATCH 044/143] Disable input in CharSelect until stayFunky plays --- source/funkin/ui/charSelect/CharSelectSubState.hx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/funkin/ui/charSelect/CharSelectSubState.hx b/source/funkin/ui/charSelect/CharSelectSubState.hx index 3109dc8f1b..c2dd18fd8a 100644 --- a/source/funkin/ui/charSelect/CharSelectSubState.hx +++ b/source/funkin/ui/charSelect/CharSelectSubState.hx @@ -71,6 +71,7 @@ class CharSelectSubState extends MusicBeatSubState var availableChars:Map = new Map(); var pressedSelect:Bool = false; var selectTimer:FlxTimer = new FlxTimer(); + var allowInput:Bool = false; var selectSound:FunkinSound; var unlockSound:FunkinSound; @@ -430,6 +431,8 @@ class CharSelectSubState extends MusicBeatSubState overrideExisting: true, restartTrack: true, onLoad: function() { + allowInput = true; + @:privateAccess gfChill.analyzer = new SpectralAnalyzer(FlxG.sound.music._channel.__audioSource, 7, 0.1); #if desktop @@ -573,6 +576,8 @@ class CharSelectSubState extends MusicBeatSubState overrideExisting: true, restartTrack: true, onLoad: function() { + allowInput = true; + @:privateAccess gfChill.analyzer = new SpectralAnalyzer(FlxG.sound.music._channel.__audioSource, 7, 0.1); #if desktop @@ -642,6 +647,7 @@ class CharSelectSubState extends MusicBeatSubState function goToFreeplay():Void { + allowInput = false; autoFollow = false; FlxTween.tween(cursor, {alpha: 0}, 0.8, {ease: FlxEase.expoOut}); @@ -695,7 +701,7 @@ class CharSelectSubState extends MusicBeatSubState syncAudio(elapsed); - if (!pressedSelect) + if (allowInput && !pressedSelect) { if (controls.UI_UP) holdTmrUp += elapsed; if (controls.UI_UP_R) @@ -789,7 +795,7 @@ class CharSelectSubState extends MusicBeatSubState gfChill.visible = true; curChar = availableChars.get(getCurrentSelected()); - if (!pressedSelect && controls.ACCEPT) + if (allowInput && !pressedSelect && controls.ACCEPT) { cursorConfirmed.visible = true; cursorConfirmed.x = cursor.x - 2; @@ -817,7 +823,7 @@ class CharSelectSubState extends MusicBeatSubState }); } - if (pressedSelect && controls.BACK) + if (allowInput && pressedSelect && controls.BACK) { cursorConfirmed.visible = false; grpCursors.visible = true; @@ -847,7 +853,7 @@ class CharSelectSubState extends MusicBeatSubState gfChill.visible = false; - if (controls.ACCEPT) + if (allowInput && controls.ACCEPT) { cursorDenied.visible = true; cursorDenied.x = cursor.x - 2; From ea9dab4b73cec21ffa5585b4915d386e6497834c Mon Sep 17 00:00:00 2001 From: Lethrial Date: Wed, 18 Sep 2024 00:25:20 +0100 Subject: [PATCH 045/143] Update Main.hx --- source/Main.hx | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/Main.hx b/source/Main.hx index 724b118f81..56634c86bd 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -123,8 +123,6 @@ class Main extends Sprite game.debugger.interaction.addTool(new funkin.util.TrackerToolButtonUtil()); #end - addChild(fpsCounter); - #if hxcpp_debug_server trace('hxcpp_debug_server is enabled! You can now connect to the game with a debugger.'); #else From de07497ae3967b981cc026d26997d717443dc280 Mon Sep 17 00:00:00 2001 From: Kade <26305836+Kade-github@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:29:12 -0700 Subject: [PATCH 046/143] Make addCharacter actually set the characters type --- source/funkin/play/stage/Stage.hx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/funkin/play/stage/Stage.hx b/source/funkin/play/stage/Stage.hx index c42e41cadb..ad768769c8 100644 --- a/source/funkin/play/stage/Stage.hx +++ b/source/funkin/play/stage/Stage.hx @@ -464,6 +464,9 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass implements #end } + // Set the characters type + character.characterType = charType; + // Add the character to the scene. this.add(character); From b70983a0e4c17f4be05d25449c5ddca04fb901a5 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 17 Sep 2024 20:50:09 -0400 Subject: [PATCH 047/143] Build arguments for Tracy --- .vscode/settings.json | 5 +++++ project.hxp | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 227cb94ec2..af5986fbf0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -96,6 +96,11 @@ "target": "windows", "args": ["-debug", "-DFEATURE_DEBUG_FUNCTIONS"] }, + { + "label": "Windows / Debug (Tracy)", + "target": "windows", + "args": ["-debug", "-DFEATURE_DEBUG_TRACY", "-DFEATURE_DEBUG_FUNCTIONS"] + }, { "label": "Linux / Debug", "target": "linux", diff --git a/project.hxp b/project.hxp index 1193a9cd42..934cc1d2da 100644 --- a/project.hxp +++ b/project.hxp @@ -149,6 +149,14 @@ class Project extends HXProject { */ static final FEATURE_DEBUG_FUNCTIONS:FeatureFlag = "FEATURE_DEBUG_FUNCTIONS"; + /** + * `-DFEATURE_DEBUG_TRACY` + * If this flag is enabled, the game will have the necessary hooks for the Tracy profiler. + * Only enable this if you're using the correct fork of Haxe to support this. + * @see https://github.com/HaxeFoundation/hxcpp/pull/1153 + */ + static final FEATURE_DEBUG_TRACY:FeatureFlag = "FEATURE_DEBUG_TRACY"; + /** * `-DFEATURE_DISCORD_RPC` * If this flag is enabled, the game will enable the Discord Remote Procedure Call library. @@ -516,6 +524,16 @@ class Project extends HXProject { // Cleaner looking compiler errors. setHaxedef("message.reporting", "pretty"); + + if (FEATURE_DEBUG_TRACY.isEnabled(this)) { + setHaxedef("HXCPP_TELEMETRY"); // Enable telemetry + setHaxedef("HXCPP_TRACY"); // Enable Tracy telemetry + setHaxedef("HXCPP_TRACY_MEMORY"); // Track memory allocations + setHaxedef("HXCPP_TRACY_ON_DEMAND"); // Only collect telemetry when Tracy is open and reachable + // setHaxedef("HXCPP_TRACY_INCLUDE_CALLSTACKS"); // Inspect callstacks per zone, inflating telemetry data + + setHaxedef("absolute-paths"); // Fix source locations so Tracy can see them + } } /** From 61d23b9985d629ef40b2630898aed006d5edfb41 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 17 Sep 2024 20:56:54 -0400 Subject: [PATCH 048/143] Use branch of HXCPP --- hmm.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hmm.json b/hmm.json index d967a69b31..4c473ed37c 100644 --- a/hmm.json +++ b/hmm.json @@ -105,8 +105,8 @@ "name": "hxcpp", "type": "git", "dir": null, - "ref": "904ea40643b050a5a154c5e4c33a83fd2aec18b1", - "url": "https://github.com/HaxeFoundation/hxcpp" + "ref": "c6bac3d6c7d683f25104296b2f4c50f8c90b8349", + "url": "https://github.com/cortex-engine/hxcpp" }, { "name": "hxcpp-debug-server", From 119148acf0b25de8af2f030c56d99cdfefcb4934 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 02:11:31 -0400 Subject: [PATCH 049/143] Define for enabling/disabling log trace --- project.hxp | 8 ++++++++ source/funkin/util/logging/AnsiTrace.hx | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/project.hxp b/project.hxp index 934cc1d2da..73a12538a7 100644 --- a/project.hxp +++ b/project.hxp @@ -157,6 +157,13 @@ class Project extends HXProject { */ static final FEATURE_DEBUG_TRACY:FeatureFlag = "FEATURE_DEBUG_TRACY"; + /** + * `-DFEATURE_LOG_TRACE` + * If this flag is enabled, the game will print debug traces to the console. + * Disable to improve performance a bunch. + */ + static final FEATURE_LOG_TRACE:FeatureFlag = "FEATURE_LOG_TRACE"; + /** * `-DFEATURE_DISCORD_RPC` * If this flag is enabled, the game will enable the Discord Remote Procedure Call library. @@ -461,6 +468,7 @@ class Project extends HXProject { // Should be true on debug builds or if GITHUB_BUILD is enabled. FEATURE_DEBUG_FUNCTIONS.apply(this, isDebug() || GITHUB_BUILD.isEnabled(this)); + FEATURE_LOG_TRACE.apply(this, isDebug()); // Should default to true on workspace builds and false on release builds. REDIRECT_ASSETS_FOLDER.apply(this, isDebug() && isDesktop()); diff --git a/source/funkin/util/logging/AnsiTrace.hx b/source/funkin/util/logging/AnsiTrace.hx index 322a66820f..18c6d1d926 100644 --- a/source/funkin/util/logging/AnsiTrace.hx +++ b/source/funkin/util/logging/AnsiTrace.hx @@ -6,7 +6,7 @@ class AnsiTrace // but adds nice cute ANSI things public static function trace(v:Dynamic, ?info:haxe.PosInfos) { - #if TREMOVE + #if NO_FEATURE_LOG_TRACE return; #end var str = formatOutput(v, info); From f7fb640e52ff8820579ae90d2fef6b001f54e6a3 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 02:29:11 -0400 Subject: [PATCH 050/143] Copy TracyProfiler from pull request --- source/cpp/vm/tracy/TracyProfiler.hx | 102 +++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 source/cpp/vm/tracy/TracyProfiler.hx diff --git a/source/cpp/vm/tracy/TracyProfiler.hx b/source/cpp/vm/tracy/TracyProfiler.hx new file mode 100644 index 0000000000..1bedd521d0 --- /dev/null +++ b/source/cpp/vm/tracy/TracyProfiler.hx @@ -0,0 +1,102 @@ +/* + * Pulled from Tracey profiler PR + * @see https://github.com/HaxeFoundation/haxe/pull/11772 + */ + +package cpp.vm.tracy; + +#if (!HXCPP_TRACY) +#error "This class cannot be used without -D HXCPP_TRACY" +#end +enum abstract PlotFormatType(cpp.UInt8) from cpp.UInt8 to cpp.UInt8 +{ + var Number = 0; + var Memory = 1; + var Percentage = 2; +} + +@:include('hx/TelemetryTracy.h') +extern class Native_TracyProfiler +{ + /** + Mark a frame. Call this at the end of each frame loop. + **/ + @:native('::__hxcpp_tracy_framemark') + public static function frameMark():Void; + + /** + Print a message into Tracy's log. + **/ + @:native('::__hxcpp_tracy_message') + public static function message(_msg:String, ?_color:Int = 0x000000):Void; + + /** + Tracy can collect additional information about the profiled application, + which will be available in the trace description. + This can include data such as the source repository revision, + the application’s environment (dev/prod), etc. + **/ + @:native('::__hxcpp_tracy_message_app_info') + public static function messageAppInfo(_info:String):Void; + + /** + Plot a named value to tracy. This will generate a graph in the profiler for you. + **/ + @:native('::__hxcpp_tracy_plot') + public static function plot(_name:String, _val:cpp.Float32):Void; + + /** + Configure how values are plotted and displayed. + **/ + @:native('::__hxcpp_tracy_plot_config') + public static function plotConfig(_name:String, _format:PlotFormatType, ?_step:Bool = false, ?_fill:Bool = false, ?_color:Int = 0x000000):Void; + + /** + Set a name for the current thread this function is called in. Supply an optional groupHint so threads become grouped in Tracy's UI. + **/ + @:native('::__hxcpp_tracy_set_thread_name_and_group') + public static function setThreadName(_name:String, ?_groupHint:Int = 1):Void; + + /** + Create a custom named scoped zone in your code. + **/ + @:native('HXCPP_TRACY_ZONE') + public static function zoneScoped(_name:String):Void; +} + +#if (scriptable || cppia) +class Cppia_TracyProfiler +{ + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.frameMark) + public static function frameMark() + Native_TracyProfiler.frameMark(); + + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.message) + public static function message(_msg:String, ?_color:Int = 0x000000) + Native_TracyProfiler.message(_msg, _color); + + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.messageAppInfo) + public static function messageAppInfo(_info:String) + Native_TracyProfiler.messageAppInfo(_info); + + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.plot) + public static function plot(_name:String, _val:Float) + Native_TracyProfiler.plot(_name, _val); + + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.plotConfig) + public static function plotConfig(_name:String, _format:PlotFormatType, ?_step:Bool = false, ?_fill:Bool = false, ?_color:Int = 0x000000) + Native_TracyProfiler.plotConfig(_name, _format, _step, _fill, _color); + + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.setThreadName) + public static function setThreadName(_name:String, ?_groupHint:Int = 1) + Native_TracyProfiler.setThreadName(_name, _groupHint); + + @:inheritDoc(cpp.vm.tracy.Native_TracyProfiler.zoneScoped) + public static function zoneScoped(_name:String) + Native_TracyProfiler.zoneScoped(_name); +} + +typedef TracyProfiler = Cppia_TracyProfiler; +#else +typedef TracyProfiler = Native_TracyProfiler; +#end From 2a5269c2a755068d0b1ad94de7030d7988671942 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 02:30:48 -0400 Subject: [PATCH 051/143] Disable on demand telemetry --- project.hxp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.hxp b/project.hxp index 73a12538a7..74402016fd 100644 --- a/project.hxp +++ b/project.hxp @@ -537,7 +537,7 @@ class Project extends HXProject { setHaxedef("HXCPP_TELEMETRY"); // Enable telemetry setHaxedef("HXCPP_TRACY"); // Enable Tracy telemetry setHaxedef("HXCPP_TRACY_MEMORY"); // Track memory allocations - setHaxedef("HXCPP_TRACY_ON_DEMAND"); // Only collect telemetry when Tracy is open and reachable + // setHaxedef("HXCPP_TRACY_ON_DEMAND"); // Only collect telemetry when Tracy is open and reachable // setHaxedef("HXCPP_TRACY_INCLUDE_CALLSTACKS"); // Inspect callstacks per zone, inflating telemetry data setHaxedef("absolute-paths"); // Fix source locations so Tracy can see them From 19e6029fb27ef0c52aeb632d8c0ce941cd133623 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 03:13:10 -0400 Subject: [PATCH 052/143] Fix some compilation errors --- source/funkin/play/PlayState.hx | 1 - source/funkin/play/components/PopUpStuff.hx | 9 --------- source/funkin/ui/debug/anim/DebugBoundingState.hx | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index a25d3b2318..1c82eb6b15 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -3046,7 +3046,6 @@ class PlayState extends MusicBeatSubState GameOverSubState.reset(); PauseSubState.reset(); Countdown.reset(); - PopUpStuff.reset(); // Clear the static reference to this state. instance = null; diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index e5e9b46816..a02291e4e2 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -125,13 +125,4 @@ class PopUpStuff extends FlxTypedGroup daLoop++; } } - - /** - * Reset the popup configuration to the default. - */ - public static function reset() - { - noteStyle = NoteStyleRegistry.instance.fetchDefault(); - isPixel = false; - } } diff --git a/source/funkin/ui/debug/anim/DebugBoundingState.hx b/source/funkin/ui/debug/anim/DebugBoundingState.hx index 19391f8d95..d2a27999f1 100644 --- a/source/funkin/ui/debug/anim/DebugBoundingState.hx +++ b/source/funkin/ui/debug/anim/DebugBoundingState.hx @@ -77,7 +77,7 @@ class DebugBoundingState extends FlxState { // get the screen position, according to the HUD camera, temp default to FlxG.camera juuust in case? var hudMousePos:FlxPoint = FlxG.mouse.getScreenPosition(hudCam ?? FlxG.camera); - return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y) || FlxG.mouse.overlaps(animDropDownMenu, hudCam); + return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y); } override function create() From 7b7d5deed5e56613b5ba10f2e2ad7dfe393a1a42 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 03:13:21 -0400 Subject: [PATCH 053/143] Tweaks to framerate preference --- source/funkin/Preferences.hx | 4 ++-- source/funkin/ui/options/PreferencesMenu.hx | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/source/funkin/Preferences.hx b/source/funkin/Preferences.hx index 1eac9f47f7..648880ad42 100644 --- a/source/funkin/Preferences.hx +++ b/source/funkin/Preferences.hx @@ -15,7 +15,7 @@ class Preferences static function get_framerate():Int { - #if (web || CHEEMS) + #if web return 60; #else return Save?.instance?.options?.framerate ?? 60; @@ -24,7 +24,7 @@ class Preferences static function set_framerate(value:Int):Int { - #if (web || CHEEMS) + #if web return 60; #else var save:Save = Save.instance; diff --git a/source/funkin/ui/options/PreferencesMenu.hx b/source/funkin/ui/options/PreferencesMenu.hx index adbe1d356a..fb49807625 100644 --- a/source/funkin/ui/options/PreferencesMenu.hx +++ b/source/funkin/ui/options/PreferencesMenu.hx @@ -54,11 +54,6 @@ class PreferencesMenu extends Page */ function createPrefItems():Void { - #if !web - createPrefItemNumber('FPS', 'The framerate that the game is running on', function(value:Float) { - Preferences.framerate = Std.int(value); - }, null, Preferences.framerate, 60, 360, 1, 0); - #end createPrefItemCheckbox('Naughtyness', 'Toggle displaying raunchy content', function(value:Bool):Void { Preferences.naughtyness = value; }, Preferences.naughtyness); @@ -82,6 +77,10 @@ class PreferencesMenu extends Page createPrefItemCheckbox('Unlocked Framerate', 'Enable to unlock the framerate', function(value:Bool):Void { Preferences.unlockedFramerate = value; }, Preferences.unlockedFramerate); + #else + 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 } From d30fe61ca07d9565a2142d5a044f2cd4558e7aa6 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 05:03:04 -0400 Subject: [PATCH 054/143] Add a bunch of other functions to funkin.Assets, and add documentation --- source/funkin/Assets.hx | 128 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 5 deletions(-) diff --git a/source/funkin/Assets.hx b/source/funkin/Assets.hx index 05423c5726..967e4b0ca8 100644 --- a/source/funkin/Assets.hx +++ b/source/funkin/Assets.hx @@ -1,43 +1,161 @@ package funkin; +import openfl.utils.Future; + /** * A wrapper around `openfl.utils.Assets` which disallows access to the harmful functions. * Later we'll add Funkin-specific caching to this. */ class Assets { + /** + * Get the file system path for an asset + * @param path The asset path to load from, relative to the assets folder + * @return The path to the asset on the file system + */ + public static function getPath(path:String):String + { + return openfl.utils.Assets.getPath(path); + } + + /** + * Load bytes from an asset + * May cause stutters or throw an error if the asset is not cached + * @param path The asset path to load from + * @return The byte contents of the file + */ + public static function getBytes(path:String):haxe.io.Bytes + { + return openfl.utils.Assets.getBytes(path); + } + + /** + * Load bytes from an asset asynchronously + * @param path The asset path to load from + * @return A future which promises to return the byte contents of the file + */ + public static function loadBytes(path:String):Future + { + return openfl.utils.Assets.loadBytes(path); + } + + /** + * Load text from an asset. + * May cause stutters or throw an error if the asset is not cached + * @param path The asset path to load from + * @return The text contents of the file + */ public static function getText(path:String):String { return openfl.utils.Assets.getText(path); } - public static function getPath(path:String):String + /** + * Load text from an asset asynchronously + * @param path The asset path to load from + * @return A future which promises to return the text contents of the file + */ + public static function loadText(path:String):Future { - return openfl.utils.Assets.getPath(path); + return openfl.utils.Assets.loadText(path); + } + + /** + * Load a Sound file from an asset + * May cause stutters or throw an error if the asset is not cached + * @param path The asset path to load from + * @return The loaded sound + */ + public static function getSound(path:String):openfl.media.Sound + { + return openfl.utils.Assets.getSound(path); } + /** + * Load a Sound file from an asset asynchronously + * @param path The asset path to load from + * @return A future which promises to return the loaded sound + */ + public static function loadSound(path:String):Future + { + return openfl.utils.Assets.loadSound(path); + } + + /** + * Load a Sound file from an asset, with optimizations specific to long-duration music + * May cause stutters or throw an error if the asset is not cached + * @param path The asset path to load from + * @return The loaded sound + */ public static function getMusic(path:String):openfl.media.Sound { return openfl.utils.Assets.getMusic(path); } + /** + * Load a Sound file from an asset asynchronously, with optimizations specific to long-duration music + * @param path The asset path to load from + * @return A future which promises to return the loaded sound + */ + public static function loadMusic(path:String):Future + { + return openfl.utils.Assets.loadMusic(path); + } + + /** + * Load a Bitmap from an asset + * May cause stutters or throw an error if the asset is not cached + * @param path The asset path to load from + * @return The loaded Bitmap image + */ public static function getBitmapData(path:String):openfl.display.BitmapData { return openfl.utils.Assets.getBitmapData(path); } - public static function getBytes(path:String):haxe.io.Bytes + /** + * Load a Bitmap from an asset asynchronously + * @param path The asset path to load from + * @return The future which promises to return the loaded Bitmap image + */ + public static function loadBitmapData(path:String):Future { - return openfl.utils.Assets.getBytes(path); + return openfl.utils.Assets.loadBitmapData(path); } + /** + * Determines whether the given asset of the given type exists. + * @param path The asset path to check + * @param type The asset type to check + * @return Whether the asset exists + */ public static function exists(path:String, ?type:openfl.utils.AssetType):Bool { return openfl.utils.Assets.exists(path, type); } - public static function list(type:openfl.utils.AssetType):Array + /** + * Retrieve a list of all assets of the given type + * @param type The asset type to check + * @return A list of asset paths + */ + public static function list(?type:openfl.utils.AssetType):Array { return openfl.utils.Assets.list(type); } + + public static function hasLibrary(name:String):Bool + { + return openfl.utils.Assets.hasLibrary(name); + } + + public static function getLibrary(name:String):lime.utils.AssetLibrary + { + return openfl.utils.Assets.getLibrary(name); + } + + public static function loadLibrary(name:String):Future + { + return openfl.utils.Assets.loadLibrary(name); + } } From b6b2248aa389143b855eab86c19c656f9edc4376 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 05:04:10 -0400 Subject: [PATCH 055/143] Make funkin.Assets and funkin.Paths default imports for all scripts --- assets | 2 +- source/funkin/modding/PolymodHandler.hx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/assets b/assets index bc7009b424..16c1d30478 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit bc7009b4242691faa5c4552f7ca8a2f28e8cb1d2 +Subproject commit 16c1d30478875a5acbe92e4ec7d11234d1028286 diff --git a/source/funkin/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx index 75c69e5065..258491552f 100644 --- a/source/funkin/modding/PolymodHandler.hx +++ b/source/funkin/modding/PolymodHandler.hx @@ -228,6 +228,8 @@ class PolymodHandler static function buildImports():Void { // Add default imports for common classes. + Polymod.addDefaultImport(funkin.Assets); + Polymod.addDefaultImport(funkin.Paths); // Add import aliases for certain classes. // NOTE: Scripted classes are automatically aliased to their parent class. From 1beb21e57a2c0ac6d1a04df8fa699b25f1aee504 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 05:04:32 -0400 Subject: [PATCH 056/143] Replace all instances of openfl/lime Assets with funkin.Assets --- source/funkin/Paths.hx | 5 ++--- .../funkin/graphics/adobeanimate/FlxAtlasSprite.hx | 1 - .../funkin/graphics/shaders/AdjustColorShader.hx | 2 -- source/funkin/graphics/shaders/BlendModesShader.hx | 2 -- .../funkin/graphics/shaders/GaussianBlurShader.hx | 2 -- source/funkin/graphics/shaders/Grayscale.hx | 2 -- source/funkin/graphics/shaders/HSVShader.hx | 2 -- source/funkin/graphics/shaders/MosaicEffect.hx | 2 -- .../graphics/shaders/RuntimeCustomBlendShader.hx | 1 - .../funkin/graphics/shaders/RuntimeRainShader.hx | 1 - source/funkin/import.hx | 1 + source/funkin/input/Cursor.hx | 1 - source/funkin/play/Countdown.hx | 1 - source/funkin/play/GameOverSubState.hx | 1 - source/funkin/play/character/CharacterData.hx | 1 - source/funkin/play/components/HealthIcon.hx | 1 - source/funkin/play/components/PopUpStuff.hx | 1 - source/funkin/play/song/Song.hx | 1 - source/funkin/ui/debug/anim/DebugBoundingState.hx | 1 - .../charting/components/ChartEditorEventSprite.hx | 1 - .../charting/handlers/ChartEditorAudioHandler.hx | 1 - source/funkin/ui/freeplay/AlbumRoll.hx | 1 - source/funkin/ui/freeplay/FreeplayState.hx | 3 +-- source/funkin/ui/freeplay/backcards/BackingCard.hx | 1 - .../funkin/ui/freeplay/backcards/BoyfriendCard.hx | 14 +++++++------- .../ui/freeplay/backcards/NewCharacterCard.hx | 1 - source/funkin/ui/freeplay/backcards/PicoCard.hx | 14 +++++++------- source/funkin/ui/options/FunkinSoundTray.hx | 1 - source/funkin/ui/story/StoryMenuState.hx | 1 - source/funkin/ui/transition/LoadingState.hx | 9 ++++----- source/funkin/ui/transition/StickerSubState.hx | 5 ++--- 31 files changed, 24 insertions(+), 57 deletions(-) diff --git a/source/funkin/Paths.hx b/source/funkin/Paths.hx index 285af7ca22..ae77ac2da5 100644 --- a/source/funkin/Paths.hx +++ b/source/funkin/Paths.hx @@ -2,7 +2,6 @@ package funkin; import flixel.graphics.frames.FlxAtlasFrames; import openfl.utils.AssetType; -import openfl.utils.Assets as OpenFlAssets; /** * A core class which handles determining asset paths. @@ -44,11 +43,11 @@ class Paths if (currentLevel != null) { var levelPath:String = getLibraryPathForce(file, currentLevel); - if (OpenFlAssets.exists(levelPath, type)) return levelPath; + if (Assets.exists(levelPath, type)) return levelPath; } var levelPath:String = getLibraryPathForce(file, 'shared'); - if (OpenFlAssets.exists(levelPath, type)) return levelPath; + if (Assets.exists(levelPath, type)) return levelPath; return getPreloadPath(file); } diff --git a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx index 952fa8b717..8a51e8c8b6 100644 --- a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx +++ b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx @@ -7,7 +7,6 @@ import flxanimate.frames.FlxAnimateFrames; import flixel.graphics.frames.FlxFrame; import flixel.system.FlxAssets.FlxGraphicAsset; import openfl.display.BitmapData; -import openfl.utils.Assets; import flixel.math.FlxPoint; import flxanimate.animate.FlxKeyFrame; diff --git a/source/funkin/graphics/shaders/AdjustColorShader.hx b/source/funkin/graphics/shaders/AdjustColorShader.hx index 2b0970eeb2..a6efc3e659 100644 --- a/source/funkin/graphics/shaders/AdjustColorShader.hx +++ b/source/funkin/graphics/shaders/AdjustColorShader.hx @@ -1,8 +1,6 @@ package funkin.graphics.shaders; import flixel.addons.display.FlxRuntimeShader; -import funkin.Paths; -import openfl.utils.Assets; class AdjustColorShader extends FlxRuntimeShader { diff --git a/source/funkin/graphics/shaders/BlendModesShader.hx b/source/funkin/graphics/shaders/BlendModesShader.hx index b7a405dd17..e6ae45dd7b 100644 --- a/source/funkin/graphics/shaders/BlendModesShader.hx +++ b/source/funkin/graphics/shaders/BlendModesShader.hx @@ -1,8 +1,6 @@ package funkin.graphics.shaders; import flixel.addons.display.FlxRuntimeShader; -import funkin.Paths; -import openfl.utils.Assets; import openfl.display.BitmapData; import openfl.display.ShaderInput; diff --git a/source/funkin/graphics/shaders/GaussianBlurShader.hx b/source/funkin/graphics/shaders/GaussianBlurShader.hx index cecfdab80d..023a668538 100644 --- a/source/funkin/graphics/shaders/GaussianBlurShader.hx +++ b/source/funkin/graphics/shaders/GaussianBlurShader.hx @@ -1,8 +1,6 @@ package funkin.graphics.shaders; import flixel.addons.display.FlxRuntimeShader; -import funkin.Paths; -import openfl.utils.Assets; /** * Note... not actually gaussian! diff --git a/source/funkin/graphics/shaders/Grayscale.hx b/source/funkin/graphics/shaders/Grayscale.hx index fbd0970e55..6fbdd1881a 100644 --- a/source/funkin/graphics/shaders/Grayscale.hx +++ b/source/funkin/graphics/shaders/Grayscale.hx @@ -1,8 +1,6 @@ package funkin.graphics.shaders; import flixel.addons.display.FlxRuntimeShader; -import funkin.Paths; -import openfl.utils.Assets; class Grayscale extends FlxRuntimeShader { diff --git a/source/funkin/graphics/shaders/HSVShader.hx b/source/funkin/graphics/shaders/HSVShader.hx index 587008ce2a..dda841ad96 100644 --- a/source/funkin/graphics/shaders/HSVShader.hx +++ b/source/funkin/graphics/shaders/HSVShader.hx @@ -1,8 +1,6 @@ package funkin.graphics.shaders; import flixel.addons.display.FlxRuntimeShader; -import funkin.Paths; -import openfl.utils.Assets; class HSVShader extends FlxRuntimeShader { diff --git a/source/funkin/graphics/shaders/MosaicEffect.hx b/source/funkin/graphics/shaders/MosaicEffect.hx index fc3737afff..76a6b6f3db 100644 --- a/source/funkin/graphics/shaders/MosaicEffect.hx +++ b/source/funkin/graphics/shaders/MosaicEffect.hx @@ -1,8 +1,6 @@ package funkin.graphics.shaders; import flixel.addons.display.FlxRuntimeShader; -import openfl.utils.Assets; -import funkin.Paths; import flixel.math.FlxPoint; class MosaicEffect extends FlxRuntimeShader diff --git a/source/funkin/graphics/shaders/RuntimeCustomBlendShader.hx b/source/funkin/graphics/shaders/RuntimeCustomBlendShader.hx index 3e8dfedd38..74ce7f4ea9 100644 --- a/source/funkin/graphics/shaders/RuntimeCustomBlendShader.hx +++ b/source/funkin/graphics/shaders/RuntimeCustomBlendShader.hx @@ -2,7 +2,6 @@ package funkin.graphics.shaders; import openfl.display.BitmapData; import openfl.display.BlendMode; -import openfl.utils.Assets; class RuntimeCustomBlendShader extends RuntimePostEffectShader { diff --git a/source/funkin/graphics/shaders/RuntimeRainShader.hx b/source/funkin/graphics/shaders/RuntimeRainShader.hx index d0c036623e..5d8df3f2c6 100644 --- a/source/funkin/graphics/shaders/RuntimeRainShader.hx +++ b/source/funkin/graphics/shaders/RuntimeRainShader.hx @@ -5,7 +5,6 @@ import openfl.display.BitmapData; import openfl.display.ShaderParameter; import openfl.display.ShaderParameterType; import flixel.util.FlxColor; -import openfl.utils.Assets; typedef Light = { diff --git a/source/funkin/import.hx b/source/funkin/import.hx index c8431be33b..a29e199778 100644 --- a/source/funkin/import.hx +++ b/source/funkin/import.hx @@ -3,6 +3,7 @@ package; #if !macro // Only import these when we aren't in a macro. import funkin.util.Constants; +import funkin.Assets; import funkin.Paths; import funkin.Preferences; import flixel.FlxG; // This one in particular causes a compile error if you're using macros. diff --git a/source/funkin/input/Cursor.hx b/source/funkin/input/Cursor.hx index 39f3994657..554a6b2c15 100644 --- a/source/funkin/input/Cursor.hx +++ b/source/funkin/input/Cursor.hx @@ -1,7 +1,6 @@ package funkin.input; import haxe.ui.backend.flixel.CursorHelper; -import openfl.utils.Assets; import lime.app.Future; import openfl.display.BitmapData; diff --git a/source/funkin/play/Countdown.hx b/source/funkin/play/Countdown.hx index 643883a43f..94a7548b9b 100644 --- a/source/funkin/play/Countdown.hx +++ b/source/funkin/play/Countdown.hx @@ -11,7 +11,6 @@ import funkin.modding.events.ScriptEvent.CountdownScriptEvent; import flixel.util.FlxTimer; import funkin.util.EaseUtil; import funkin.audio.FunkinSound; -import openfl.utils.Assets; import funkin.data.notestyle.NoteStyleRegistry; import funkin.play.notes.notestyle.NoteStyle; diff --git a/source/funkin/play/GameOverSubState.hx b/source/funkin/play/GameOverSubState.hx index f6a7148f81..bf8735647b 100644 --- a/source/funkin/play/GameOverSubState.hx +++ b/source/funkin/play/GameOverSubState.hx @@ -15,7 +15,6 @@ import funkin.ui.freeplay.FreeplayState; import funkin.ui.MusicBeatSubState; import funkin.ui.story.StoryMenuState; import funkin.util.MathUtil; -import openfl.utils.Assets; import funkin.effects.RetroCameraFade; import flixel.math.FlxPoint; diff --git a/source/funkin/play/character/CharacterData.hx b/source/funkin/play/character/CharacterData.hx index bac2c7141e..3a790bcf28 100644 --- a/source/funkin/play/character/CharacterData.hx +++ b/source/funkin/play/character/CharacterData.hx @@ -11,7 +11,6 @@ import funkin.play.character.ScriptedCharacter.ScriptedSparrowCharacter; import funkin.util.assets.DataAssets; import funkin.util.VersionUtil; import haxe.Json; -import openfl.utils.Assets; class CharacterDataParser { diff --git a/source/funkin/play/components/HealthIcon.hx b/source/funkin/play/components/HealthIcon.hx index c11850b2a8..c7854871cb 100644 --- a/source/funkin/play/components/HealthIcon.hx +++ b/source/funkin/play/components/HealthIcon.hx @@ -5,7 +5,6 @@ import flixel.FlxSprite; import flixel.math.FlxMath; import flixel.math.FlxPoint; import funkin.play.character.CharacterData.CharacterDataParser; -import openfl.utils.Assets; import funkin.graphics.FunkinSprite; import funkin.util.MathUtil; diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index a02291e4e2..fbc97283f2 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -8,7 +8,6 @@ import funkin.graphics.FunkinSprite; import funkin.play.PlayState; import funkin.util.TimerUtil; import funkin.util.EaseUtil; -import openfl.utils.Assets; import funkin.data.notestyle.NoteStyleRegistry; import funkin.play.notes.notestyle.NoteStyle; diff --git a/source/funkin/play/song/Song.hx b/source/funkin/play/song/Song.hx index 9d35902b01..9023b872e7 100644 --- a/source/funkin/play/song/Song.hx +++ b/source/funkin/play/song/Song.hx @@ -16,7 +16,6 @@ import funkin.modding.IScriptedClass.IPlayStateScriptedClass; import funkin.modding.events.ScriptEvent; import funkin.ui.freeplay.charselect.PlayableCharacter; import funkin.util.SortUtil; -import openfl.utils.Assets; /** * This is a data structure managing information about the current song. diff --git a/source/funkin/ui/debug/anim/DebugBoundingState.hx b/source/funkin/ui/debug/anim/DebugBoundingState.hx index 7bb42c89e3..5ed000e907 100644 --- a/source/funkin/ui/debug/anim/DebugBoundingState.hx +++ b/source/funkin/ui/debug/anim/DebugBoundingState.hx @@ -24,7 +24,6 @@ import haxe.ui.core.Screen; import haxe.ui.events.UIEvent; import haxe.ui.RuntimeComponentBuilder; import lime.utils.Assets as LimeAssets; -import openfl.Assets; import openfl.events.Event; import openfl.events.IOErrorEvent; import openfl.geom.Rectangle; diff --git a/source/funkin/ui/debug/charting/components/ChartEditorEventSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorEventSprite.hx index c996079bc7..4c4a8d2003 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorEventSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorEventSprite.hx @@ -3,7 +3,6 @@ package funkin.ui.debug.charting.components; import funkin.data.event.SongEventRegistry; import flixel.graphics.frames.FlxAtlasFrames; import openfl.display.BitmapData; -import openfl.utils.Assets; import flixel.FlxObject; import flixel.FlxBasic; import flixel.FlxSprite; diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx index 26e246371d..329873d682 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx @@ -13,7 +13,6 @@ import funkin.audio.waveform.WaveformSprite; import flixel.util.FlxColor; import haxe.io.Bytes; import haxe.io.Path; -import openfl.utils.Assets; /** * Functions for loading audio for the chart editor. diff --git a/source/funkin/ui/freeplay/AlbumRoll.hx b/source/funkin/ui/freeplay/AlbumRoll.hx index 4107369d2e..81a9fe858d 100644 --- a/source/funkin/ui/freeplay/AlbumRoll.hx +++ b/source/funkin/ui/freeplay/AlbumRoll.hx @@ -11,7 +11,6 @@ import funkin.data.freeplay.album.AlbumRegistry; import funkin.util.assets.FlxAnimationUtil; import funkin.graphics.FunkinSprite; import funkin.util.SortUtil; -import openfl.utils.Assets; /** * The graphic for the album roll in the FreeplayState. diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index af0a9b841d..c368c66329 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -51,7 +51,6 @@ import funkin.ui.transition.LoadingState; import funkin.ui.transition.StickerSubState; import funkin.util.MathUtil; import funkin.util.SortUtil; -import lime.utils.Assets; import openfl.display.BlendMode; import funkin.data.freeplay.style.FreeplayStyleRegistry; import funkin.data.song.SongData.SongMusicData; @@ -1859,7 +1858,7 @@ class FreeplayState extends MusicBeatSubState albumRoll.setDifficultyStars(daSong?.difficultyRating); } - // Clears the cache of songs, frees up memory, they' ll have to be loaded in later tho function clearDaCache(actualSongTho:String) + // Clears the cache of songs to free up memory, they'll have to be loaded in later tho function clearDaCache(actualSongTho:String):Void { for (song in songs) diff --git a/source/funkin/ui/freeplay/backcards/BackingCard.hx b/source/funkin/ui/freeplay/backcards/BackingCard.hx index bb662cc8dd..713b6edcfb 100644 --- a/source/funkin/ui/freeplay/backcards/BackingCard.hx +++ b/source/funkin/ui/freeplay/backcards/BackingCard.hx @@ -18,7 +18,6 @@ import funkin.graphics.adobeanimate.FlxAtlasSprite; import funkin.graphics.FunkinSprite; import funkin.ui.freeplay.charselect.PlayableCharacter; import funkin.ui.MusicBeatSubState; -import lime.utils.Assets; import openfl.display.BlendMode; import flixel.group.FlxSpriteGroup; diff --git a/source/funkin/ui/freeplay/backcards/BoyfriendCard.hx b/source/funkin/ui/freeplay/backcards/BoyfriendCard.hx index 597fd1a34b..a049c4f423 100644 --- a/source/funkin/ui/freeplay/backcards/BoyfriendCard.hx +++ b/source/funkin/ui/freeplay/backcards/BoyfriendCard.hx @@ -18,7 +18,6 @@ import funkin.graphics.adobeanimate.FlxAtlasSprite; import funkin.graphics.FunkinSprite; import funkin.ui.freeplay.charselect.PlayableCharacter; import funkin.ui.MusicBeatSubState; -import lime.utils.Assets; import openfl.display.BlendMode; import flixel.group.FlxSpriteGroup; @@ -177,20 +176,21 @@ class BoyfriendCard extends BackingCard } var beatFreq:Int = 1; - var beatFreqList:Array = [1,2,4,8]; + var beatFreqList:Array = [1, 2, 4, 8]; - public override function beatHit():Void { + public override function beatHit():Void + { // increases the amount of beats that need to go by to pulse the glow because itd flash like craazy at high bpms..... - beatFreq = beatFreqList[Math.floor(Conductor.instance.bpm/140)]; + beatFreq = beatFreqList[Math.floor(Conductor.instance.bpm / 140)]; - if(Conductor.instance.currentBeat % beatFreq != 0) return; + if (Conductor.instance.currentBeat % beatFreq != 0) return; FlxTween.cancelTweensOf(glow); FlxTween.cancelTweensOf(glowDark); glow.alpha = 0.8; - FlxTween.tween(glow, {alpha: 0}, 16/24, {ease: FlxEase.quartOut}); + FlxTween.tween(glow, {alpha: 0}, 16 / 24, {ease: FlxEase.quartOut}); glowDark.alpha = 0; - FlxTween.tween(glowDark, {alpha: 0.6}, 18/24, {ease: FlxEase.quartOut}); + FlxTween.tween(glowDark, {alpha: 0.6}, 18 / 24, {ease: FlxEase.quartOut}); } public override function introDone():Void diff --git a/source/funkin/ui/freeplay/backcards/NewCharacterCard.hx b/source/funkin/ui/freeplay/backcards/NewCharacterCard.hx index a44ff88a67..1e3d812997 100644 --- a/source/funkin/ui/freeplay/backcards/NewCharacterCard.hx +++ b/source/funkin/ui/freeplay/backcards/NewCharacterCard.hx @@ -20,7 +20,6 @@ import funkin.graphics.adobeanimate.FlxAtlasSprite; import funkin.graphics.FunkinSprite; import funkin.ui.freeplay.charselect.PlayableCharacter; import funkin.ui.MusicBeatSubState; -import lime.utils.Assets; import openfl.display.BlendMode; import flixel.group.FlxSpriteGroup; import funkin.graphics.shaders.AdjustColorShader; diff --git a/source/funkin/ui/freeplay/backcards/PicoCard.hx b/source/funkin/ui/freeplay/backcards/PicoCard.hx index f5db1ccc36..8cfe7756e6 100644 --- a/source/funkin/ui/freeplay/backcards/PicoCard.hx +++ b/source/funkin/ui/freeplay/backcards/PicoCard.hx @@ -20,7 +20,6 @@ import funkin.graphics.adobeanimate.FlxAtlasSprite; import funkin.graphics.FunkinSprite; import funkin.ui.freeplay.charselect.PlayableCharacter; import funkin.ui.MusicBeatSubState; -import lime.utils.Assets; import openfl.display.BlendMode; import flixel.group.FlxSpriteGroup; import funkin.graphics.shaders.AdjustColorShader; @@ -233,20 +232,21 @@ class PicoCard extends BackingCard } var beatFreq:Int = 1; - var beatFreqList:Array = [1,2,4,8]; + var beatFreqList:Array = [1, 2, 4, 8]; - public override function beatHit():Void { + public override function beatHit():Void + { // increases the amount of beats that need to go by to pulse the glow because itd flash like craazy at high bpms..... - beatFreq = beatFreqList[Math.floor(Conductor.instance.bpm/140)]; + beatFreq = beatFreqList[Math.floor(Conductor.instance.bpm / 140)]; - if(Conductor.instance.currentBeat % beatFreq != 0) return; + if (Conductor.instance.currentBeat % beatFreq != 0) return; FlxTween.cancelTweensOf(glow); FlxTween.cancelTweensOf(glowDark); glow.alpha = 1; - FlxTween.tween(glow, {alpha: 0}, 16/24, {ease: FlxEase.quartOut}); + FlxTween.tween(glow, {alpha: 0}, 16 / 24, {ease: FlxEase.quartOut}); glowDark.alpha = 0; - FlxTween.tween(glowDark, {alpha: 1}, 18/24, {ease: FlxEase.quartOut}); + FlxTween.tween(glowDark, {alpha: 1}, 18 / 24, {ease: FlxEase.quartOut}); } public override function introDone():Void diff --git a/source/funkin/ui/options/FunkinSoundTray.hx b/source/funkin/ui/options/FunkinSoundTray.hx index 170ad84972..8ae53524ad 100644 --- a/source/funkin/ui/options/FunkinSoundTray.hx +++ b/source/funkin/ui/options/FunkinSoundTray.hx @@ -6,7 +6,6 @@ import flixel.system.FlxAssets; import flixel.tweens.FlxEase; import openfl.display.Bitmap; import openfl.display.BitmapData; -import openfl.utils.Assets; import funkin.util.MathUtil; /** diff --git a/source/funkin/ui/story/StoryMenuState.hx b/source/funkin/ui/story/StoryMenuState.hx index 18614d414b..c0ed2712a6 100644 --- a/source/funkin/ui/story/StoryMenuState.hx +++ b/source/funkin/ui/story/StoryMenuState.hx @@ -23,7 +23,6 @@ import funkin.ui.MusicBeatState; import funkin.ui.transition.LoadingState; import funkin.ui.transition.StickerSubState; import funkin.util.MathUtil; -import openfl.utils.Assets; class StoryMenuState extends MusicBeatState { diff --git a/source/funkin/ui/transition/LoadingState.hx b/source/funkin/ui/transition/LoadingState.hx index 5b82cc7416..ef95da6c9d 100644 --- a/source/funkin/ui/transition/LoadingState.hx +++ b/source/funkin/ui/transition/LoadingState.hx @@ -3,24 +3,23 @@ package funkin.ui.transition; import flixel.FlxSprite; import flixel.math.FlxMath; import flixel.tweens.FlxEase; -import funkin.graphics.FunkinSprite; import flixel.tweens.FlxTween; import flixel.util.FlxTimer; +import flixel.util.typeLimit.NextState; +import funkin.graphics.FunkinSprite; import funkin.graphics.shaders.ScreenWipeShader; import funkin.play.PlayState; import funkin.play.PlayStatePlaylist; import funkin.play.song.Song.SongDifficulty; import funkin.ui.MusicBeatState; import haxe.io.Path; -import funkin.graphics.FunkinSprite; import lime.app.Future; import lime.app.Promise; import lime.utils.AssetLibrary; import lime.utils.AssetManifest; import lime.utils.Assets as LimeAssets; import openfl.filters.ShaderFilter; -import openfl.utils.Assets; -import flixel.util.typeLimit.NextState; +import openfl.utils.Assets as OpenFLAssets; class LoadingState extends MusicBeatSubState { @@ -98,7 +97,7 @@ class LoadingState extends MusicBeatSubState function checkLoadSong(path:String):Void { - if (!Assets.cache.hasSound(path)) + if (!OpenFLAssets.cache.hasSound(path)) { var library = Assets.getLibrary('songs'); var symbolPath = path.split(':').pop(); diff --git a/source/funkin/ui/transition/StickerSubState.hx b/source/funkin/ui/transition/StickerSubState.hx index e5abef8726..e8d6877d8c 100644 --- a/source/funkin/ui/transition/StickerSubState.hx +++ b/source/funkin/ui/transition/StickerSubState.hx @@ -2,7 +2,6 @@ package funkin.ui.transition; import flixel.FlxSprite; import haxe.Json; -import lime.utils.Assets; import funkin.graphics.FunkinSprite; // import flxtyped group import funkin.ui.MusicBeatSubState; @@ -56,7 +55,7 @@ class StickerSubState extends MusicBeatSubState // make sure that ONLY plays mp3/ogg files // if there's no mp3/ogg file, then it regenerates/reloads the random folder - var assetsInList = openfl.utils.Assets.list(); + var assetsInList = Assets.list(); var soundFilterFunc = function(a:String) { return a.startsWith('assets/shared/sounds/stickersounds/'); @@ -84,7 +83,7 @@ class StickerSubState extends MusicBeatSubState var filterFunc = function(a:String) { return a.startsWith('assets/shared/sounds/stickersounds/' + soundSelection + '/'); }; - var assetsInList3 = openfl.utils.Assets.list(); + var assetsInList3 = Assets.list(); sounds = assetsInList3.filter(filterFunc); for (i in 0...sounds.length) { From b28af79eb3246b7e540288230a59000654fe4aa5 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 05:18:16 -0400 Subject: [PATCH 057/143] Fix build issues --- source/funkin/play/PlayState.hx | 1 - source/funkin/play/components/PopUpStuff.hx | 9 --------- source/funkin/ui/debug/anim/DebugBoundingState.hx | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index a25d3b2318..1c82eb6b15 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -3046,7 +3046,6 @@ class PlayState extends MusicBeatSubState GameOverSubState.reset(); PauseSubState.reset(); Countdown.reset(); - PopUpStuff.reset(); // Clear the static reference to this state. instance = null; diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index e5e9b46816..a02291e4e2 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -125,13 +125,4 @@ class PopUpStuff extends FlxTypedGroup daLoop++; } } - - /** - * Reset the popup configuration to the default. - */ - public static function reset() - { - noteStyle = NoteStyleRegistry.instance.fetchDefault(); - isPixel = false; - } } diff --git a/source/funkin/ui/debug/anim/DebugBoundingState.hx b/source/funkin/ui/debug/anim/DebugBoundingState.hx index 19391f8d95..d2a27999f1 100644 --- a/source/funkin/ui/debug/anim/DebugBoundingState.hx +++ b/source/funkin/ui/debug/anim/DebugBoundingState.hx @@ -77,7 +77,7 @@ class DebugBoundingState extends FlxState { // get the screen position, according to the HUD camera, temp default to FlxG.camera juuust in case? var hudMousePos:FlxPoint = FlxG.mouse.getScreenPosition(hudCam ?? FlxG.camera); - return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y) || FlxG.mouse.overlaps(animDropDownMenu, hudCam); + return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y); } override function create() From b5ed7f40d4621006d5dc906020050095e2733e9c Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 05:24:57 -0400 Subject: [PATCH 058/143] Remove redundant character type assignment --- source/funkin/play/PlayState.hx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 0b2b8846d3..b304381cc8 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1612,7 +1612,7 @@ class PlayState extends MusicBeatSubState if (girlfriend != null) { - girlfriend.characterType = CharacterType.GF; + // Don't need to do anything. } else if (currentCharacterData.girlfriend != '') { @@ -1630,8 +1630,6 @@ class PlayState extends MusicBeatSubState if (dad != null) { - dad.characterType = CharacterType.DAD; - // // OPPONENT HEALTH ICON // @@ -1650,8 +1648,6 @@ class PlayState extends MusicBeatSubState if (boyfriend != null) { - boyfriend.characterType = CharacterType.BF; - // // PLAYER HEALTH ICON // @@ -1993,6 +1989,7 @@ class PlayState extends MusicBeatSubState // Skip this if the music is paused (GameOver, Pause menu, start-of-song offset, etc.) if (!(FlxG.sound.music?.playing ?? false)) return; + var timeToPlayAt:Float = Conductor.instance.songPosition - Conductor.instance.instrumentalOffset; FlxG.sound.music.pause(); vocals.pause(); From d54dc6179a305d05d33ebb360410076dcf03a566 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 06:02:13 -0400 Subject: [PATCH 059/143] Add several new Github Actions for issue management --- .github/label-actions.yml | 23 ++++++++ .github/workflows/label-actions.yml | 29 +++++++++++ .github/workflows/label-issue.yml | 52 +++++++++++++++++++ .../{labeler.yml => label-pull-request.yml} | 2 + 4 files changed, 106 insertions(+) create mode 100644 .github/label-actions.yml create mode 100644 .github/workflows/label-actions.yml create mode 100644 .github/workflows/label-issue.yml rename .github/workflows/{labeler.yml => label-pull-request.yml} (84%) diff --git a/.github/label-actions.yml b/.github/label-actions.yml new file mode 100644 index 0000000000..00fb390aa8 --- /dev/null +++ b/.github/label-actions.yml @@ -0,0 +1,23 @@ +# Configuration for Label Actions - https://github.com/dessant/label-actions + +# Automatically close issues and pull requests when the `status: duplicate` label is applied +'status: duplicate': + issues: + # Post a comment + comment: > + This issue is a duplicate. Please direct all discussion to the original issue. + # Close the issue + close: true + # Remove other status labels + unlabel: + - 'status: pending triage' + # Set a close reason + close-reason: 'not planned' + prs: + # Post a comment + comment: > + This pull request is a duplicate. Please direct all discussion to the original pull request. + # Close the pull request + close: true + # Set a close reason + close-reason: 'not planned' diff --git a/.github/workflows/label-actions.yml b/.github/workflows/label-actions.yml new file mode 100644 index 0000000000..bc4cf0add4 --- /dev/null +++ b/.github/workflows/label-actions.yml @@ -0,0 +1,29 @@ +# Perform actions when labels are applied to issues, discussions, or pull requests +# See .github/label-actions.yml +name: 'Label Actions' + +on: + issues: + types: + - labeled + - unlabeled + pull_request_target: + types: + - labeled + - unlabeled + discussion: + types: + - labeled + - unlabeled + +permissions: + contents: read + issues: write + pull-requests: write + discussions: write + +jobs: + action: + runs-on: ubuntu-latest + steps: + - uses: dessant/label-actions@v4 diff --git a/.github/workflows/label-issue.yml b/.github/workflows/label-issue.yml new file mode 100644 index 0000000000..eeb83350c6 --- /dev/null +++ b/.github/workflows/label-issue.yml @@ -0,0 +1,52 @@ +name: "Issue Labeler" +on: + issues: + types: + - opened + - reopened + - edited + +jobs: + # When an issue is opened, perform a similarity check for potential duplicates. + # If some are found, add a label and comment listing the potential duplicate issues. + potential-duplicate: + name: Detect potential duplicate issues + runs-on: ubuntu-latest + steps: + - uses: wow-actions/potential-duplicates@v1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Issue title filter work with anymatch https://www.npmjs.com/package/anymatch. + # Any matched issue will stop detection immediately. + # You can specify multi filters in each line. + filter: '' + # Exclude keywords in title before detecting. + exclude: '' + # Label to set, when potential duplicates are detected. + label: 'potential duplicate' + # Get issues with state to compare. Supported state: 'all', 'closed', 'open'. + state: all + # If similarity is higher than this threshold([0,1]), issue will be marked as duplicate. + # Turn this up if the detection is too sensitive + threshold: 0.6 + # Reactions to be add to comment when potential duplicates are detected. + # Available reactions: "-1", "+1", "confused", "laugh", "heart", "hooray", "rocket", "eyes" + # reactions: '-1' + # Comment to post when potential duplicates are detected. + comment: > + Potential duplicates: {{#issues}} + - [#{{ number }}] {{ title }} ({{ accuracy }}%) + {{/issues}} + # When an issue is opened, detect if it has an empty body or incomplete issue form. + # If it does, close the issue immediately. + empty-issues: + name: Close empty issues + runs-on: ubuntu-latest + steps: + - name: Run empty issues closer action + uses: rickstaa/empty-issues-closer-action@v1 + env: + github_token: ${{ secrets.GITHUB_TOKEN }} + with: + close_comment: Closing this issue because it appears to be empty. Please update the issue for it to be reopened. + open_comment: Reopening this issue because the author provided more information. diff --git a/.github/workflows/labeler.yml b/.github/workflows/label-pull-request.yml similarity index 84% rename from .github/workflows/labeler.yml rename to .github/workflows/label-pull-request.yml index a861af5781..525e1b5a65 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/label-pull-request.yml @@ -3,6 +3,7 @@ on: - pull_request_target jobs: + # Apply labels to pull requests based on which files were edited labeler: permissions: contents: read @@ -13,6 +14,7 @@ jobs: uses: actions/labeler@v5 with: sync-labels: true + # Apply labels to pull requests based on how many lines were edited changed-lines-count-labeler: permissions: contents: read From ba90a6abe04b15058a9c32a0ba1dd5338605c57a Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 06:08:18 -0400 Subject: [PATCH 060/143] Add behavior when setting status: rejected --- .github/label-actions.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/label-actions.yml b/.github/label-actions.yml index 00fb390aa8..1234d15262 100644 --- a/.github/label-actions.yml +++ b/.github/label-actions.yml @@ -17,7 +17,28 @@ # Post a comment comment: > This pull request is a duplicate. Please direct all discussion to the original pull request. + # Remove other status labels + unlabel: + - 'status: pending triage' + # Close the pull request + close: true + # Set a close reason + close-reason: 'not planned' + +'status: rejected': + issues: + # Close the issue + close: true + # Remove other status labels + unlabel: + - 'status: pending triage' + # Set a close reason + close-reason: 'not planned' + prs: # Close the pull request close: true + # Remove other status labels + unlabel: + - 'status: pending triage' # Set a close reason close-reason: 'not planned' From a469385cdba4288d166682874938b124fd2b7fcf Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 06:22:02 -0400 Subject: [PATCH 061/143] Resolve merge issues --- source/funkin/play/PlayState.hx | 1 - source/funkin/play/components/PopUpStuff.hx | 9 --------- source/funkin/ui/debug/anim/DebugBoundingState.hx | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index a25d3b2318..1c82eb6b15 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -3046,7 +3046,6 @@ class PlayState extends MusicBeatSubState GameOverSubState.reset(); PauseSubState.reset(); Countdown.reset(); - PopUpStuff.reset(); // Clear the static reference to this state. instance = null; diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index e5e9b46816..a02291e4e2 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -125,13 +125,4 @@ class PopUpStuff extends FlxTypedGroup daLoop++; } } - - /** - * Reset the popup configuration to the default. - */ - public static function reset() - { - noteStyle = NoteStyleRegistry.instance.fetchDefault(); - isPixel = false; - } } diff --git a/source/funkin/ui/debug/anim/DebugBoundingState.hx b/source/funkin/ui/debug/anim/DebugBoundingState.hx index 19391f8d95..d2a27999f1 100644 --- a/source/funkin/ui/debug/anim/DebugBoundingState.hx +++ b/source/funkin/ui/debug/anim/DebugBoundingState.hx @@ -77,7 +77,7 @@ class DebugBoundingState extends FlxState { // get the screen position, according to the HUD camera, temp default to FlxG.camera juuust in case? var hudMousePos:FlxPoint = FlxG.mouse.getScreenPosition(hudCam ?? FlxG.camera); - return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y) || FlxG.mouse.overlaps(animDropDownMenu, hudCam); + return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y); } override function create() From 5efbff044b1a04cd28006124e0305671d6b709e7 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 06:32:06 -0400 Subject: [PATCH 062/143] Resolve merge issues --- source/funkin/play/PlayState.hx | 1 - source/funkin/play/components/PopUpStuff.hx | 9 --------- source/funkin/ui/debug/anim/DebugBoundingState.hx | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index a25d3b2318..1c82eb6b15 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -3046,7 +3046,6 @@ class PlayState extends MusicBeatSubState GameOverSubState.reset(); PauseSubState.reset(); Countdown.reset(); - PopUpStuff.reset(); // Clear the static reference to this state. instance = null; diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index e5e9b46816..a02291e4e2 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -125,13 +125,4 @@ class PopUpStuff extends FlxTypedGroup daLoop++; } } - - /** - * Reset the popup configuration to the default. - */ - public static function reset() - { - noteStyle = NoteStyleRegistry.instance.fetchDefault(); - isPixel = false; - } } diff --git a/source/funkin/ui/debug/anim/DebugBoundingState.hx b/source/funkin/ui/debug/anim/DebugBoundingState.hx index 19391f8d95..d2a27999f1 100644 --- a/source/funkin/ui/debug/anim/DebugBoundingState.hx +++ b/source/funkin/ui/debug/anim/DebugBoundingState.hx @@ -77,7 +77,7 @@ class DebugBoundingState extends FlxState { // get the screen position, according to the HUD camera, temp default to FlxG.camera juuust in case? var hudMousePos:FlxPoint = FlxG.mouse.getScreenPosition(hudCam ?? FlxG.camera); - return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y) || FlxG.mouse.overlaps(animDropDownMenu, hudCam); + return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y); } override function create() From 9d5cde0bf1889be63b45016b4a292c69697befc8 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 18 Sep 2024 06:48:45 -0400 Subject: [PATCH 063/143] Update assets submodule --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index bc7009b424..68520d9eb9 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit bc7009b4242691faa5c4552f7ca8a2f28e8cb1d2 +Subproject commit 68520d9eb9ff9a4e8aa52852eab1ef56db302b91 From a4b59d14bf34270bf04520320eabf3f11b5f2d29 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:40:02 +0200 Subject: [PATCH 064/143] applySongRank fix fixes the bug with the percent being overriden when the song has the same letter rank but lower percent (eg. E Rank with 99% being overriden by E Rank with 93%) --- source/funkin/save/Save.hx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index 2bbda15c00..74af9994e8 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -598,11 +598,15 @@ class Save return; } + //percent also accounts for different ranks + var oldPerc = (previousScoreData.tallies.sick + previousScoreData.tallies.good) / previousScoreData.tallies.totalNotes; + var newPerc = (newScoreData.tallies.sick + newScoreData.tallies.good) / newScoreData.tallies.totalNotes; + // Set the high score and the high rank separately. var newScore:SaveScoreData = { - score: (previousScoreData.score > newScoreData.score) ? previousScoreData.score : newScoreData.score, - tallies: (previousRank > newRank) ? previousScoreData.tallies : newScoreData.tallies + score: Std.int(Math.max(previousScoreData.score, newScoreData.score)), + tallies: (oldPerc > newPerc ? previousScoreData.tallies : newScoreData.tallies) }; song.set(difficultyId, newScore); From 50a5304ad48b210cba62e8bc756b417b3c69cc96 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:30:23 +0200 Subject: [PATCH 065/143] Update PlayerData.hx --- source/funkin/data/freeplay/player/PlayerData.hx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/funkin/data/freeplay/player/PlayerData.hx b/source/funkin/data/freeplay/player/PlayerData.hx index de293c24e3..a5bf086f68 100644 --- a/source/funkin/data/freeplay/player/PlayerData.hx +++ b/source/funkin/data/freeplay/player/PlayerData.hx @@ -264,6 +264,12 @@ class PlayerCharSelectData */ @:optional public var position:Null; + + /** + * The GF name to assign for this character. + */ + @:optional + public var assignedGF:Null; } typedef PlayerResultsData = From 3bb981adb03371e1be5034d7997dc5135a7d8f04 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:32:37 +0200 Subject: [PATCH 066/143] Update CharSelectGF.hx --- source/funkin/ui/charSelect/CharSelectGF.hx | 37 ++++++++++++--------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/source/funkin/ui/charSelect/CharSelectGF.hx b/source/funkin/ui/charSelect/CharSelectGF.hx index e8eeded40f..79cfb585ca 100644 --- a/source/funkin/ui/charSelect/CharSelectGF.hx +++ b/source/funkin/ui/charSelect/CharSelectGF.hx @@ -11,6 +11,7 @@ import funkin.modding.IScriptedClass.IBPMSyncedScriptedClass; import flixel.math.FlxMath; import funkin.modding.events.ScriptEvent; import funkin.vis.dsp.SpectralAnalyzer; +import funkin.data.freeplay.player.PlayerRegistry; class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass { @@ -27,7 +28,7 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass var analyzer:SpectralAnalyzer; - var curGF:GFChar = GF; + var curGF:String = "gf"; public function new() { @@ -97,7 +98,7 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass function drawFFT() { - if (curGF == NENE) + if (curGF == "nene") { var levels = analyzer.getLevels(); var frame = anim.curSymbol.timeline.get("VIZ_bars").get(anim.curFrame); @@ -172,16 +173,21 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass */ public function switchGF(bf:String):Void { - var prevGF:GFChar = curGF; - switch (bf) - { - case "pico": - curGF = NENE; - case "bf": - curGF = GF; - default: - curGF = GF; - } + var prevGF = curGF; + + var bfObj = PlayerRegistry.instance.fetchEntry(bf); + curGF = bfObj?.getCharSelectData()?.assignedGF ?? "gf"; + + /*var prevGF:GFChar = curGF; + switch (bf) + { + case "pico": + curGF = NENE; + case "bf": + curGF = GF; + default: + curGF = GF; + }*/ // We don't need to update any anims if we didn't change GF if (prevGF != curGF) @@ -213,9 +219,8 @@ enum FadeStatus FADE_OUT; FADE_IN; } - -enum abstract GFChar(String) from String to String -{ +/*enum abstract GFChar(String) from String to String + { var GF = "gf"; var NENE = "nene"; -} +}*/ From 99657da1f984ff5842d714b2cde398cca6785e06 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:46:13 +0200 Subject: [PATCH 067/143] accidentally also put the save changes oops --- source/funkin/save/Save.hx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index 74af9994e8..2bbda15c00 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -598,15 +598,11 @@ class Save return; } - //percent also accounts for different ranks - var oldPerc = (previousScoreData.tallies.sick + previousScoreData.tallies.good) / previousScoreData.tallies.totalNotes; - var newPerc = (newScoreData.tallies.sick + newScoreData.tallies.good) / newScoreData.tallies.totalNotes; - // Set the high score and the high rank separately. var newScore:SaveScoreData = { - score: Std.int(Math.max(previousScoreData.score, newScoreData.score)), - tallies: (oldPerc > newPerc ? previousScoreData.tallies : newScoreData.tallies) + score: (previousScoreData.score > newScoreData.score) ? previousScoreData.score : newScoreData.score, + tallies: (previousRank > newRank) ? previousScoreData.tallies : newScoreData.tallies }; song.set(difficultyId, newScore); From ab3b976f3c979d04e713b47de607335a58917db7 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 18 Sep 2024 15:07:15 -0400 Subject: [PATCH 068/143] fix rounding for sound results sfx --- source/funkin/play/ResultState.hx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/funkin/play/ResultState.hx b/source/funkin/play/ResultState.hx index 739df167d8..33f3587eab 100644 --- a/source/funkin/play/ResultState.hx +++ b/source/funkin/play/ResultState.hx @@ -472,9 +472,12 @@ class ResultState extends MusicBeatSubState { ease: FlxEase.quartOut, onUpdate: _ -> { + clearPercentLerp = Math.round(clearPercentLerp); + clearPercentCounter.curNumber = Math.round(clearPercentCounter.curNumber); // Only play the tick sound if the number increased. if (clearPercentLerp != clearPercentCounter.curNumber) { + trace('$clearPercentLerp and ${clearPercentCounter.curNumber}'); clearPercentLerp = clearPercentCounter.curNumber; FunkinSound.playOnce(Paths.sound('scrollMenu')); } From 62149aea39687fc84f79e7a7ce4edf636cef416e Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 18 Sep 2024 15:16:56 -0400 Subject: [PATCH 069/143] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 6165511460..da96dc519a 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 61655114603807b651109af282c2e2aefa9dccf2 +Subproject commit da96dc519a00bb8eb24a164bae64a4c6c064e87d From fc6e194d20968d010c5d4c22511cd8fd400d9058 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 18 Sep 2024 15:20:15 -0400 Subject: [PATCH 070/143] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index ef7386d741..252d48f4c9 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit ef7386d741e715bd809c913a7d50dfa7b8176e2d +Subproject commit 252d48f4c996d5832cb981fb2f3ed945c020f289 From 472d41a893a3610ff6935844ecb50d44949e1851 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Wed, 18 Sep 2024 16:15:10 -0400 Subject: [PATCH 071/143] close sys.io.Process stuff when we're done with them --- project.hxp | 6 ++++++ source/funkin/util/macro/GitCommit.hx | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/project.hxp b/project.hxp index 1193a9cd42..ac047ff910 100644 --- a/project.hxp +++ b/project.hxp @@ -941,6 +941,8 @@ class Project extends HXProject { var commitHash:String = process.stdout.readLine(); var commitHashSplice:String = commitHash.substr(0, 7); + process.close(); + return commitHashSplice; } @@ -955,6 +957,8 @@ class Project extends HXProject { var branchName:String = branchProcess.stdout.readLine(); + branchProcess.close(); + return branchName; } @@ -979,6 +983,8 @@ class Project extends HXProject { } } + branchProcess.close(); + return output.length > 0; } diff --git a/source/funkin/util/macro/GitCommit.hx b/source/funkin/util/macro/GitCommit.hx index 161856caa4..9e3305c41b 100644 --- a/source/funkin/util/macro/GitCommit.hx +++ b/source/funkin/util/macro/GitCommit.hx @@ -23,6 +23,8 @@ class GitCommit var commitHash:String = process.stdout.readLine(); var commitHashSplice:String = commitHash.substr(0, 7); + process.close(); + trace('Git Commit ID: ${commitHashSplice}'); // Generates a string expression @@ -52,6 +54,7 @@ class GitCommit } var branchName:String = branchProcess.stdout.readLine(); + branchProcess.close(); trace('Git Branch Name: ${branchName}'); // Generates a string expression @@ -84,6 +87,7 @@ class GitCommit try { output = branchProcess.stdout.readLine(); + branchProcess.close(); } catch (e) { From 9f0bc2bd521f274f8ad9d214966538d95894277a Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 19 Sep 2024 04:16:40 -0400 Subject: [PATCH 072/143] Refactor char select GF data handling. --- assets | 2 +- .../funkin/data/freeplay/player/PlayerData.hx | 15 +++++- source/funkin/ui/charSelect/CharSelectGF.hx | 46 +++++++++---------- .../ui/charSelect/CharSelectSubState.hx | 1 - 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/assets b/assets index bc7009b424..4f7e8bb5cd 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit bc7009b4242691faa5c4552f7ca8a2f28e8cb1d2 +Subproject commit 4f7e8bb5cd2e9eb8f68d88c060e9cbe5bccc9e2f diff --git a/source/funkin/data/freeplay/player/PlayerData.hx b/source/funkin/data/freeplay/player/PlayerData.hx index a5bf086f68..9110854c8d 100644 --- a/source/funkin/data/freeplay/player/PlayerData.hx +++ b/source/funkin/data/freeplay/player/PlayerData.hx @@ -269,7 +269,20 @@ class PlayerCharSelectData * The GF name to assign for this character. */ @:optional - public var assignedGF:Null; + public var gf:PlayerCharSelectGFData; +} + +typedef PlayerCharSelectGFData = +{ + @:optional + public var assetPath:String; + + @:optional + public var animInfoPath:String; + + @:optional + @:default(false) + public var visualizer:Bool; } typedef PlayerResultsData = diff --git a/source/funkin/ui/charSelect/CharSelectGF.hx b/source/funkin/ui/charSelect/CharSelectGF.hx index 79cfb585ca..89fc6deb05 100644 --- a/source/funkin/ui/charSelect/CharSelectGF.hx +++ b/source/funkin/ui/charSelect/CharSelectGF.hx @@ -28,7 +28,8 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass var analyzer:SpectralAnalyzer; - var curGF:String = "gf"; + var currentGFPath:Null; + var enableVisualizer:Bool = false; public function new() { @@ -98,7 +99,7 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass function drawFFT() { - if (curGF == "nene") + if (enableVisualizer) { var levels = analyzer.getLevels(); var frame = anim.curSymbol.timeline.get("VIZ_bars").get(anim.curFrame); @@ -173,33 +174,33 @@ class CharSelectGF extends FlxAtlasSprite implements IBPMSyncedScriptedClass */ public function switchGF(bf:String):Void { - var prevGF = curGF; + var previousGFPath = currentGFPath; var bfObj = PlayerRegistry.instance.fetchEntry(bf); - curGF = bfObj?.getCharSelectData()?.assignedGF ?? "gf"; - - /*var prevGF:GFChar = curGF; - switch (bf) - { - case "pico": - curGF = NENE; - case "bf": - curGF = GF; - default: - curGF = GF; - }*/ + var gfData = bfObj?.getCharSelectData()?.gf; + currentGFPath = gfData?.assetPath != null ? Paths.animateAtlas(gfData?.assetPath) : null; // We don't need to update any anims if we didn't change GF - if (prevGF != curGF) + trace('currentGFPath(${currentGFPath})'); + if (currentGFPath == null) + { + this.visible = false; + return; + } + else if (previousGFPath != currentGFPath) { - loadAtlas(Paths.animateAtlas("charSelect/" + curGF + "Chill")); + this.visible = true; + loadAtlas(currentGFPath); - animInInfo = FramesJSFLParser.parse(Paths.file("images/charSelect/" + curGF + "AnimInfo/" + curGF + "In.txt")); - animOutInfo = FramesJSFLParser.parse(Paths.file("images/charSelect/" + curGF + "AnimInfo/" + curGF + "Out.txt")); + enableVisualizer = gfData?.visualizer ?? false; + + var animInfoPath = Paths.file('images/${gfData?.animInfoPath}'); + + animInInfo = FramesJSFLParser.parse(animInfoPath + '/In.txt'); + animOutInfo = FramesJSFLParser.parse(animInfoPath + '/Out.txt'); } playAnimation("idle", true, false, false); - // addFrameCallback(getNextFrameLabel("idle"), () -> playAnimation("idle", true, false, false)); updateHitbox(); } @@ -219,8 +220,3 @@ enum FadeStatus FADE_OUT; FADE_IN; } -/*enum abstract GFChar(String) from String to String - { - var GF = "gf"; - var NENE = "nene"; -}*/ diff --git a/source/funkin/ui/charSelect/CharSelectSubState.hx b/source/funkin/ui/charSelect/CharSelectSubState.hx index 3109dc8f1b..e7a87ade68 100644 --- a/source/funkin/ui/charSelect/CharSelectSubState.hx +++ b/source/funkin/ui/charSelect/CharSelectSubState.hx @@ -786,7 +786,6 @@ class CharSelectSubState extends MusicBeatSubState && availableChars.exists(getCurrentSelected()) && Save.instance.charactersSeen.contains(availableChars[getCurrentSelected()])) { - gfChill.visible = true; curChar = availableChars.get(getCurrentSelected()); if (!pressedSelect && controls.ACCEPT) From 25cafe7550304d20581da661948fc480ae82c39b Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 19 Sep 2024 04:22:05 -0400 Subject: [PATCH 073/143] Resolve merge issues. --- source/funkin/play/PlayState.hx | 1 - source/funkin/play/components/PopUpStuff.hx | 9 --------- source/funkin/ui/debug/anim/DebugBoundingState.hx | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index a25d3b2318..1c82eb6b15 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -3046,7 +3046,6 @@ class PlayState extends MusicBeatSubState GameOverSubState.reset(); PauseSubState.reset(); Countdown.reset(); - PopUpStuff.reset(); // Clear the static reference to this state. instance = null; diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index e5e9b46816..a02291e4e2 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -125,13 +125,4 @@ class PopUpStuff extends FlxTypedGroup daLoop++; } } - - /** - * Reset the popup configuration to the default. - */ - public static function reset() - { - noteStyle = NoteStyleRegistry.instance.fetchDefault(); - isPixel = false; - } } diff --git a/source/funkin/ui/debug/anim/DebugBoundingState.hx b/source/funkin/ui/debug/anim/DebugBoundingState.hx index 19391f8d95..d2a27999f1 100644 --- a/source/funkin/ui/debug/anim/DebugBoundingState.hx +++ b/source/funkin/ui/debug/anim/DebugBoundingState.hx @@ -77,7 +77,7 @@ class DebugBoundingState extends FlxState { // get the screen position, according to the HUD camera, temp default to FlxG.camera juuust in case? var hudMousePos:FlxPoint = FlxG.mouse.getScreenPosition(hudCam ?? FlxG.camera); - return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y) || FlxG.mouse.overlaps(animDropDownMenu, hudCam); + return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y); } override function create() From 8fd84f9d137848024fe94c084f52b370b5ef0304 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 19 Sep 2024 10:03:16 -0400 Subject: [PATCH 074/143] Functioning Discord Rich Presence! --- .vscode/settings.json | 5 + hmm.json | 23 ++- project.hxp | 7 +- source/funkin/InitState.hx | 38 ++-- source/funkin/api/discord/Discord.hx | 91 --------- source/funkin/api/discord/DiscordClient.hx | 188 ++++++++++++++++++ source/funkin/play/PlayState.hx | 128 ++++++++---- source/funkin/play/character/BaseCharacter.hx | 9 +- source/funkin/ui/freeplay/FreeplayState.hx | 5 +- source/funkin/ui/mainmenu/MainMenuState.hx | 5 +- source/funkin/ui/story/StoryMenuState.hx | 5 +- 11 files changed, 332 insertions(+), 172 deletions(-) delete mode 100644 source/funkin/api/discord/Discord.hx create mode 100644 source/funkin/api/discord/DiscordClient.hx diff --git a/.vscode/settings.json b/.vscode/settings.json index 227cb94ec2..8dc6d0e6b8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -106,6 +106,11 @@ "target": "hl", "args": ["-debug"] }, + { + "label": "Windows / Debug (Discord)", + "target": "windows", + "args": ["-debug", "-DFEATURE_DEBUG_FUNCTIONS", "-DFEATURE_DISCORD_RPC"] + }, { "label": "Windows / Debug (FlxAnimate Test)", "target": "windows", diff --git a/hmm.json b/hmm.json index edc0529aa6..42c63abed3 100644 --- a/hmm.json +++ b/hmm.json @@ -7,13 +7,6 @@ "ref": "a1eab7b9bf507b87200a3341719054fe427f3b15", "url": "https://github.com/FunkinCrew/FlxPartialSound.git" }, - { - "name": "discord_rpc", - "type": "git", - "dir": null, - "ref": "2d83fa863ef0c1eace5f1cf67c3ac315d1a3a8a5", - "url": "https://github.com/FunkinCrew/linc_discord-rpc" - }, { "name": "flixel", "type": "git", @@ -115,6 +108,13 @@ "ref": "147294123f983e35f50a966741474438069a7a8f", "url": "https://github.com/FunkinCrew/hxcpp-debugger" }, + { + "name": "hxdiscord_rpc", + "type": "git", + "dir": null, + "ref": "main", + "url": "https://github.com/MAJigsaw77/hxdiscord_rpc" + }, { "name": "hxjsonast", "type": "git", @@ -155,6 +155,13 @@ "ref": "fe3368f611a84a19afc03011353945ae4da8fffd", "url": "https://github.com/FunkinCrew/lime" }, + { + "name": "linc_discord-rpc", + "type": "git", + "dir": null, + "ref": "2d83fa863ef0c1eace5f1cf67c3ac315d1a3a8a5", + "url": "https://github.com/FunkinCrew/haxe-discord-rpc" + }, { "name": "mconsole", "type": "git", @@ -212,4 +219,4 @@ "url": "https://github.com/fponticelli/thx.semver" } ] -} +} \ No newline at end of file diff --git a/project.hxp b/project.hxp index 1193a9cd42..6d46b9278c 100644 --- a/project.hxp +++ b/project.hxp @@ -457,10 +457,9 @@ class Project extends HXProject { // Should default to true on workspace builds and false on release builds. REDIRECT_ASSETS_FOLDER.apply(this, isDebug() && isDesktop()); - // Should be true on release, non-tester builds. + // Should be true on desktop, release, non-tester builds. // We don't want testers to accidentally leak songs to their Discord friends! - // TODO: Re-enable this. - FEATURE_DISCORD_RPC.apply(this, false && !FEATURE_DEBUG_FUNCTIONS.isEnabled(this)); + FEATURE_DISCORD_RPC.apply(this, isDesktop() && !FEATURE_DEBUG_FUNCTIONS.isEnabled(this)); // Should be true only on web builds. // Audio context issues only exist there. @@ -618,7 +617,7 @@ class Project extends HXProject { } if (FEATURE_DISCORD_RPC.isEnabled(this)) { - addHaxelib('discord_rpc'); // Discord API + addHaxelib('hxdiscord_rpc'); // Discord API } if (FEATURE_NEWGROUNDS.isEnabled(this)) { diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index f71de00f4a..51640b0a02 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -1,42 +1,42 @@ package funkin; -import funkin.data.freeplay.player.PlayerRegistry; -import funkin.ui.debug.charting.ChartEditorState; -import funkin.ui.transition.LoadingState; -import flixel.FlxState; import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond; import flixel.addons.transition.TransitionData; +import flixel.FlxSprite; +import flixel.FlxState; import flixel.graphics.FlxGraphic; import flixel.math.FlxPoint; import flixel.math.FlxRect; -import flixel.FlxSprite; import flixel.system.debug.log.LogStyle; import flixel.util.FlxColor; -import funkin.util.macro.MacroUtil; -import funkin.util.WindowUtil; -import funkin.play.PlayStatePlaylist; -import openfl.display.BitmapData; -import funkin.data.story.level.LevelRegistry; -import funkin.data.notestyle.NoteStyleRegistry; -import funkin.data.freeplay.style.FreeplayStyleRegistry; -import funkin.data.event.SongEventRegistry; -import funkin.data.stage.StageRegistry; import funkin.data.dialogue.conversation.ConversationRegistry; import funkin.data.dialogue.dialoguebox.DialogueBoxRegistry; import funkin.data.dialogue.speaker.SpeakerRegistry; import funkin.data.freeplay.album.AlbumRegistry; +import funkin.data.freeplay.player.PlayerRegistry; +import funkin.data.freeplay.style.FreeplayStyleRegistry; +import funkin.data.notestyle.NoteStyleRegistry; import funkin.data.song.SongRegistry; +import funkin.data.event.SongEventRegistry; +import funkin.data.stage.StageRegistry; +import funkin.data.story.level.LevelRegistry; +import funkin.modding.module.ModuleHandler; import funkin.play.character.CharacterData.CharacterDataParser; import funkin.play.notes.notekind.NoteKindManager; -import funkin.modding.module.ModuleHandler; +import funkin.play.PlayStatePlaylist; +import funkin.ui.debug.charting.ChartEditorState; import funkin.ui.title.TitleState; +import funkin.ui.transition.LoadingState; import funkin.util.CLIUtil; import funkin.util.CLIUtil.CLIParams; +import funkin.util.macro.MacroUtil; import funkin.util.TimerUtil; import funkin.util.TrackerUtil; +import funkin.util.WindowUtil; +import openfl.display.BitmapData; #if FEATURE_DISCORD_RPC -import Discord.DiscordClient; +import funkin.api.discord.DiscordClient; #end /** @@ -125,10 +125,10 @@ class InitState extends FlxState // DISCORD API SETUP // #if FEATURE_DISCORD_RPC - DiscordClient.initialize(); + DiscordClient.instance.init(); - Application.current.onExit.add(function(exitCode) { - DiscordClient.shutdown(); + lime.app.Application.current.onExit.add(function(exitCode) { + DiscordClient.instance.shutdown(); }); #end diff --git a/source/funkin/api/discord/Discord.hx b/source/funkin/api/discord/Discord.hx deleted file mode 100644 index 9dd513bf79..0000000000 --- a/source/funkin/api/discord/Discord.hx +++ /dev/null @@ -1,91 +0,0 @@ -package funkin.api.discord; - -import Sys.sleep; -#if FEATURE_DISCORD_RPC -import discord_rpc.DiscordRpc; -#end - -class DiscordClient -{ - #if FEATURE_DISCORD_RPC - public function new() - { - trace("Discord Client starting..."); - DiscordRpc.start( - { - clientID: "814588678700924999", - onReady: onReady, - onError: onError, - onDisconnected: onDisconnected - }); - trace("Discord Client started."); - - while (true) - { - DiscordRpc.process(); - sleep(2); - // trace("Discord Client Update"); - } - - DiscordRpc.shutdown(); - } - - public static function shutdown() - { - DiscordRpc.shutdown(); - } - - static function onReady() - { - DiscordRpc.presence( - { - details: "In the Menus", - state: null, - largeImageKey: 'icon', - largeImageText: "Friday Night Funkin'" - }); - } - - static function onError(_code:Int, _message:String) - { - trace('Error! $_code : $_message'); - } - - static function onDisconnected(_code:Int, _message:String) - { - trace('Disconnected! $_code : $_message'); - } - - public static function initialize() - { - var DiscordDaemon = sys.thread.Thread.create(() -> { - new DiscordClient(); - }); - trace("Discord Client initialized"); - } - - public static function changePresence(details:String, ?state:String, ?smallImageKey:String, ?hasStartTimestamp:Bool, ?endTimestamp:Float) - { - var startTimestamp:Float = if (hasStartTimestamp) Date.now().getTime() else 0; - - if (endTimestamp > 0) - { - endTimestamp = startTimestamp + endTimestamp; - } - - DiscordRpc.presence( - { - details: details, - state: state, - largeImageKey: 'icon', - largeImageText: "Friday Night Funkin'", - smallImageKey: smallImageKey, - // Obtained times are in milliseconds so they are divided so Discord can use it - startTimestamp: Std.int(startTimestamp / 1000), - endTimestamp: Std.int(endTimestamp / 1000) - }); - - // trace('Discord RPC Updated. Arguments: $details, $state, $smallImageKey, $hasStartTimestamp, $endTimestamp'); - } - #end -} diff --git a/source/funkin/api/discord/DiscordClient.hx b/source/funkin/api/discord/DiscordClient.hx new file mode 100644 index 0000000000..c722762b0c --- /dev/null +++ b/source/funkin/api/discord/DiscordClient.hx @@ -0,0 +1,188 @@ +package funkin.api.discord; + +#if FEATURE_DISCORD_RPC +import hxdiscord_rpc.Discord; +import hxdiscord_rpc.Types; +import sys.thread.Thread; + +class DiscordClient +{ + static final CLIENT_ID:String = "814588678700924999"; + + public static var instance(get, never):DiscordClient; + static var _instance:Null = null; + + static function get_instance():DiscordClient + { + if (DiscordClient._instance == null) _instance = new DiscordClient(); + if (DiscordClient._instance == null) throw "Could not initialize singleton DiscordClient!"; + return DiscordClient._instance; + } + + var handlers:DiscordEventHandlers; + + private function new() + { + trace('[DISCORD] Initializing event handlers...'); + + handlers = DiscordEventHandlers.create(); + + handlers.ready = cpp.Function.fromStaticFunction(onReady); + handlers.disconnected = cpp.Function.fromStaticFunction(onDisconnected); + handlers.errored = cpp.Function.fromStaticFunction(onError); + } + + public function init():Void + { + trace('[DISCORD] Initializing connection...'); + + // Discord.initialize(CLIENT_ID, handlers, true, null); + Discord.Initialize(CLIENT_ID, cpp.RawPointer.addressOf(handlers), 1, null); + + createDaemon(); + } + + var daemon:Thread = null; + + function createDaemon():Void + { + daemon = Thread.create(doDaemonWork); + } + + function doDaemonWork():Void + { + while (true) + { + trace('[DISCORD] Performing client update...'); + + #if DISCORD_DISABLE_IO_THREAD + Discord.updateConnection(); + #end + + Discord.runCallbacks(); + Sys.sleep(2); + } + } + + public function shutdown():Void + { + trace('[DISCORD] Shutting down...'); + + Discord.shutdown(); + } + + public function setPresence(params:DiscordClientPresenceParams):Void + { + trace('[DISCORD] Updating presence... (${params})'); + + Discord.updatePresence(buildPresence(params)); + } + + function buildPresence(params:DiscordClientPresenceParams):DiscordRichPresence + { + var presence = DiscordRichPresence.create(); + + // Presence should always be playing the game. + presence.type = DiscordActivityType_Playing; + + // Text when hovering over the large image. We just leave this as the game name. + presence.largeImageText = "Friday Night Funkin'"; + + // State should be generally what the person is doing, like "In the Menus" or "Pico (Pico Mix) [Freeplay Hard]" + presence.state = cast(params.state, Null); + // Details should be what the person is specifically doing, including stuff like timestamps (maybe something like "03:24 elapsed"). + presence.details = cast(params.details, Null); + + // The large image displaying what the user is doing. + // This should probably be album art. + // IMPORTANT NOTE: This can be an asset key uploaded to Discord's developer panel OR any URL you like. + // presence.largeImageKey = "icon"; + presence.largeImageKey = "https://f4.bcbits.com/img/a3122193953_16.jpg"; + // The small inset image for what the user is doing. + // This can be the opponent's health icon? + presence.smallImageKey = cast(params.smallImageKey, Null); + + // Start timestamp, used to power elapsed/remaining data + // presence.startTimestamp + // End timestamp, used to power elapsed/remaining data + // presence.endTimestamp + + return presence; + } + + // TODO: WHAT THE FUCK get this pointer bullfuckery out of here + private static function onReady(request:cpp.RawConstPointer):Void + { + trace('[DISCORD] Client has connected!'); + + final username:String = request[0].username; + final globalName:String = request[0].username; + final discriminator:Int = Std.parseInt(request[0].discriminator); + + if (discriminator != 0) + { + trace('[DISCORD] User: ${username}#${discriminator} (${globalName})'); + } + else + { + trace('[DISCORD] User: @${username} (${globalName})'); + } + } + + private static function onDisconnected(errorCode:Int, message:cpp.ConstCharStar):Void + { + trace('[DISCORD] Client has disconnected! ($errorCode) "${cast (message, String)}"'); + } + + private static function onError(errorCode:Int, message:cpp.ConstCharStar):Void + { + trace('[DISCORD] Client has received an error! ($errorCode) "${cast (message, String)}"'); + } + + // public var type(get, set):DiscordActivityType; + // public var state(get, set):String; + // public var details(get, set):String; + // public var startTimestamp(get, set):Int; + // public var endTimestamp(get, set):Int; + // public var largeImageKey(get, set):String; + // public var largeImageText(get, set):String; + // public var smallImageKey(get, set):String; + // public var smallImageText(get, set):String; + // + // + // public var partyId(get, set) + // public var partySize(get, set) + // public var partyMax(get, set) + // public var partyPrivacy(get, set) + // + // public var buttons(get, set) + // + // public var matchSecret(get, set) + // public var joinSecret(get, set) + // public var spectateSecret(get, set) +} + +typedef DiscordClientPresenceParams = +{ + /** + * The first row of text below the game title. + */ + var state:String; + + /** + * The second row of text below the game title. + * Use `null` to display no text. + */ + var details:Null; + + /** + * A large, 4-row high image to the left of the content. + */ + var ?largeImageKey:String; + + /** + * A small, inset image to the bottom right of `largeImageKey`. + */ + var ?smallImageKey:String; +} +#end diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 0b2b8846d3..22ba22b714 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -15,8 +15,8 @@ import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.ui.FlxBar; import flixel.util.FlxColor; -import flixel.util.FlxTimer; import flixel.util.FlxStringUtil; +import flixel.util.FlxTimer; import funkin.api.newgrounds.NGio; import funkin.audio.FunkinSound; import funkin.audio.VoicesGroup; @@ -44,12 +44,12 @@ import funkin.play.cutscene.dialogue.Conversation; import funkin.play.cutscene.VanillaCutscenes; import funkin.play.cutscene.VideoCutscene; import funkin.play.notes.NoteDirection; +import funkin.play.notes.notekind.NoteKindManager; import funkin.play.notes.NoteSplash; import funkin.play.notes.NoteSprite; import funkin.play.notes.notestyle.NoteStyle; import funkin.play.notes.Strumline; import funkin.play.notes.SustainTrail; -import funkin.play.notes.notekind.NoteKindManager; import funkin.play.scoring.Scoring; import funkin.play.song.Song; import funkin.play.stage.Stage; @@ -68,7 +68,7 @@ import openfl.display.BitmapData; import openfl.geom.Rectangle; import openfl.Lib; #if FEATURE_DISCORD_RPC -import Discord.DiscordClient; +import funkin.api.discord.DiscordClient; #end /** @@ -447,10 +447,10 @@ class PlayState extends MusicBeatSubState #if FEATURE_DISCORD_RPC // Discord RPC variables - var storyDifficultyText:String = ''; - var iconRPC:String = ''; - var detailsText:String = ''; - var detailsPausedText:String = ''; + var discordRPCDifficulty:String = ''; + var discordRPCIcon:String = ''; + var discordRPCDetailsText:String = ''; + var discordRPCDetailsPausedText:String = ''; #end /** @@ -984,7 +984,12 @@ class PlayState extends MusicBeatSubState } #if FEATURE_DISCORD_RPC - DiscordClient.changePresence(detailsPausedText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC); + DiscordClient.instance.setPresence( + { + state: '${currentChart.songName} (${discordRPCDifficulty})', + details: discordRPCDetailsPausedText, + smallImageKey: discordRPCIcon + }); #end } } @@ -1073,8 +1078,12 @@ class PlayState extends MusicBeatSubState } #if FEATURE_DISCORD_RPC - // Game Over doesn't get his own variable because it's only used here - DiscordClient.changePresence('Game Over - ' + detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC); + DiscordClient.instance.setPresence( + { + state: '${currentChart.songName} [${discordRPCDifficulty}]', + details: 'Game Over - ${discordRPCDetailsText}', + smallImageKey: discordRPCIcon + }); #end } else if (isPlayerDying) @@ -1285,14 +1294,25 @@ class PlayState extends MusicBeatSubState Countdown.resumeCountdown(); #if FEATURE_DISCORD_RPC - if (startTimer.finished) + if (Conductor.instance.songPosition > 0) { - DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC, true, - currentSongLengthMs - Conductor.instance.songPosition); + // DiscordClient.changePresence(detailsText, '${currentChart.songName} ($discordRPCDifficulty)', discordRPCIcon, true, + // currentSongLengthMs - Conductor.instance.songPosition); + DiscordClient.instance.setPresence( + { + state: '${currentChart.songName} [${discordRPCDifficulty}]', + details: discordRPCDetailsText, + smallImageKey: discordRPCIcon + }); } else { - DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC); + DiscordClient.instance.setPresence( + { + state: '${currentChart.songName} [${discordRPCDifficulty}]', + details: discordRPCDetailsText, + smallImageKey: discordRPCIcon + }); } #end @@ -1318,16 +1338,28 @@ class PlayState extends MusicBeatSubState #end #if FEATURE_DISCORD_RPC - if (health > Constants.HEALTH_MIN && !paused && FlxG.autoPause) - { - if (Conductor.instance.songPosition > 0.0) DiscordClient.changePresence(detailsText, currentSong.song - + ' (' - + storyDifficultyText - + ')', iconRPC, true, - currentSongLengthMs - - Conductor.instance.songPosition); + if (health > Constants.HEALTH_MIN && !isGamePaused && FlxG.autoPause) + { + if (Conductor.instance.songPosition > 0.0) + { + DiscordClient.instance.setPresence( + { + state: '${currentChart.songName} [${discordRPCDifficulty}]', + details: discordRPCDetailsText, + smallImageKey: discordRPCIcon + }); + } else - DiscordClient.changePresence(detailsText, currentSong.song + ' (' + storyDifficultyText + ')', iconRPC); + { + DiscordClient.instance.setPresence( + { + state: '${currentChart.songName} [${discordRPCDifficulty}]', + details: discordRPCDetailsText, + smallImageKey: discordRPCIcon + }); + // DiscordClient.changePresence(detailsText, '${currentChart.songName} ($discordRPCDifficulty)', discordRPCIcon, true, + // currentSongLengthMs - Conductor.instance.songPosition); + } } #end @@ -1344,8 +1376,15 @@ class PlayState extends MusicBeatSubState #end #if FEATURE_DISCORD_RPC - if (health > Constants.HEALTH_MIN && !paused && FlxG.autoPause) DiscordClient.changePresence(detailsPausedText, - currentSong.song + ' (' + storyDifficultyText + ')', iconRPC); + if (health > Constants.HEALTH_MIN && !isGamePaused && FlxG.autoPause) + { + DiscordClient.instance.setPresence( + { + state: '${currentChart.songName} [${discordRPCDifficulty}]', + details: discordRPCDetailsText, + smallImageKey: discordRPCIcon + }); + } #end super.onFocusLost(); @@ -1641,6 +1680,10 @@ class PlayState extends MusicBeatSubState iconP2.zIndex = 850; add(iconP2); iconP2.cameras = [camHUD]; + + #if FEATURE_DISCORD_RPC + discordRPCIcon = currentCharacterData.opponent; + #end } // @@ -1758,26 +1801,19 @@ class PlayState extends MusicBeatSubState function initDiscord():Void { #if FEATURE_DISCORD_RPC - storyDifficultyText = difficultyString(); - iconRPC = currentSong.player2; - - // To avoid having duplicate images in Discord assets - switch (iconRPC) - { - case 'senpai-angry': - iconRPC = 'senpai'; - case 'monster-christmas': - iconRPC = 'monster'; - case 'mom-car': - iconRPC = 'mom'; - } + discordRPCDifficulty = PlayState.instance.currentDifficulty.replace('-', ' ').toTitleCase(); - // String that contains the mode defined here so it isn't necessary to call changePresence for each mode - detailsText = isStoryMode ? 'Story Mode: Week $storyWeek' : 'Freeplay'; - detailsPausedText = 'Paused - $detailsText'; + // Determine the details strings once and reuse them. + discordRPCDetailsText = PlayStatePlaylist.isStoryMode ? 'Story Mode: Week ${PlayStatePlaylist.campaignId}' : 'Freeplay'; + discordRPCDetailsPausedText = 'Paused - $discordRPCDetailsText'; // Updating Discord Rich Presence. - DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC); + DiscordClient.instance.setPresence( + { + state: '${currentChart.songName} [${discordRPCDifficulty}]', + details: discordRPCDetailsText, + smallImageKey: discordRPCIcon + }); #end } @@ -1972,7 +2008,13 @@ class PlayState extends MusicBeatSubState #if FEATURE_DISCORD_RPC // Updating Discord Rich Presence (with Time Left) - DiscordClient.changePresence(detailsText, '${currentChart.songName} ($storyDifficultyText)', iconRPC, true, currentSongLengthMs); + DiscordClient.instance.setPresence( + { + state: '${currentChart.songName} (${discordRPCDifficulty})', + details: discordRPCDetailsText, + smallImageKey: discordRPCIcon + }); + // DiscordClient.changePresence(detailsText, '${currentChart.songName} ($discordRPCDifficulty)', discordRPCIcon, true, currentSongLengthMs); #end if (startTimestamp > 0) diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index 365c8d112b..e29131d469 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -323,6 +323,11 @@ class BaseCharacter extends Bopper this.cameraFocusPoint = new FlxPoint(charCenterX + _data.cameraOffsets[0], charCenterY + _data.cameraOffsets[1]); } + public function getHealthIconId():String + { + return _data?.healthIcon?.id ?? Constants.DEFAULT_HEALTH_ICON; + } + public function initHealthIcon(isOpponent:Bool):Void { if (!isOpponent) @@ -332,7 +337,7 @@ class BaseCharacter extends Bopper trace('[WARN] Player 1 health icon not found!'); return; } - PlayState.instance.iconP1.configure(_data.healthIcon); + PlayState.instance.iconP1.configure(_data?.healthIcon); PlayState.instance.iconP1.flipX = !PlayState.instance.iconP1.flipX; // BF is looking the other way. } else @@ -342,7 +347,7 @@ class BaseCharacter extends Bopper trace('[WARN] Player 2 health icon not found!'); return; } - PlayState.instance.iconP2.configure(_data.healthIcon); + PlayState.instance.iconP2.configure(_data?.healthIcon); } } diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index 15633ff9d1..d8842d8128 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -55,6 +55,9 @@ import lime.utils.Assets; import openfl.display.BlendMode; import funkin.data.freeplay.style.FreeplayStyleRegistry; import funkin.data.song.SongData.SongMusicData; +#if FEATURE_DISCORD_RPC +import funkin.api.discord.DiscordClient; +#end /** * Parameters used to initialize the FreeplayState. @@ -313,7 +316,7 @@ class FreeplayState extends MusicBeatSubState #if FEATURE_DISCORD_RPC // Updating Discord Rich Presence - DiscordClient.changePresence('In the Menus', null); + DiscordClient.instance.setPresence({state: 'In the Menus', details: null}); #end var isDebug:Bool = false; diff --git a/source/funkin/ui/mainmenu/MainMenuState.hx b/source/funkin/ui/mainmenu/MainMenuState.hx index a436848d2d..80da33a354 100644 --- a/source/funkin/ui/mainmenu/MainMenuState.hx +++ b/source/funkin/ui/mainmenu/MainMenuState.hx @@ -28,7 +28,7 @@ import funkin.ui.story.StoryMenuState; import funkin.ui.Prompt; import funkin.util.WindowUtil; #if FEATURE_DISCORD_RPC -import Discord.DiscordClient; +import funkin.api.discord.DiscordClient; #end #if newgrounds import funkin.ui.NgPrompt; @@ -55,8 +55,7 @@ class MainMenuState extends MusicBeatState override function create():Void { #if FEATURE_DISCORD_RPC - // Updating Discord Rich Presence - DiscordClient.changePresence("In the Menus", null); + DiscordClient.instance.setPresence({state: "In the Menus", details: null}); #end FlxG.cameras.reset(new FunkinCamera('mainMenu')); diff --git a/source/funkin/ui/story/StoryMenuState.hx b/source/funkin/ui/story/StoryMenuState.hx index 18614d414b..09af08b22e 100644 --- a/source/funkin/ui/story/StoryMenuState.hx +++ b/source/funkin/ui/story/StoryMenuState.hx @@ -24,6 +24,9 @@ import funkin.ui.transition.LoadingState; import funkin.ui.transition.StickerSubState; import funkin.util.MathUtil; import openfl.utils.Assets; +#if FEATURE_DISCORD_RPC +import funkin.api.discord.DiscordClient; +#end class StoryMenuState extends MusicBeatState { @@ -218,7 +221,7 @@ class StoryMenuState extends MusicBeatState #if FEATURE_DISCORD_RPC // Updating Discord Rich Presence - DiscordClient.changePresence('In the Menus', null); + DiscordClient.instance.setPresence({state: 'In the Menus', details: null}); #end } From 35aa8731d0e94a6dfb7f97eabbf950e066c51906 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 19 Sep 2024 11:13:05 -0400 Subject: [PATCH 075/143] Better status messages, buttons, updated album art, basic chart editor support --- source/funkin/api/discord/DiscordClient.hx | 22 ++++-- source/funkin/play/PlayState.hx | 78 +++++++++++++------ .../ui/debug/charting/ChartEditorState.hx | 17 ++++ source/funkin/util/Constants.hx | 7 +- 4 files changed, 93 insertions(+), 31 deletions(-) diff --git a/source/funkin/api/discord/DiscordClient.hx b/source/funkin/api/discord/DiscordClient.hx index c722762b0c..3b6e891d3e 100644 --- a/source/funkin/api/discord/DiscordClient.hx +++ b/source/funkin/api/discord/DiscordClient.hx @@ -96,16 +96,28 @@ class DiscordClient // The large image displaying what the user is doing. // This should probably be album art. // IMPORTANT NOTE: This can be an asset key uploaded to Discord's developer panel OR any URL you like. + + // TODO: Make this use the song's album art. // presence.largeImageKey = "icon"; - presence.largeImageKey = "https://f4.bcbits.com/img/a3122193953_16.jpg"; + presence.largeImageKey = "https://f4.bcbits.com/img/a0746694746_16.jpg"; + // The small inset image for what the user is doing. // This can be the opponent's health icon? presence.smallImageKey = cast(params.smallImageKey, Null); - // Start timestamp, used to power elapsed/remaining data - // presence.startTimestamp - // End timestamp, used to power elapsed/remaining data - // presence.endTimestamp + // NOTE: In previous versions, this showed as "Elapsed", but now shows as playtime and doesn't look good + // presence.startTimestamp = time - 10; + // presence.endTimestamp = time + 30; + + final button1:DiscordButton = DiscordButton.create(); + button1.label = "Play on Web"; + button1.url = Constants.URL_NEWGROUNDS; + presence.buttons[0] = button1; + + final button2:DiscordButton = DiscordButton.create(); + button2.label = "Download"; + button2.url = Constants.URL_ITCH; + presence.buttons[1] = button2; return presence; } diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 22ba22b714..aeba619ffc 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -447,10 +447,7 @@ class PlayState extends MusicBeatSubState #if FEATURE_DISCORD_RPC // Discord RPC variables - var discordRPCDifficulty:String = ''; var discordRPCIcon:String = ''; - var discordRPCDetailsText:String = ''; - var discordRPCDetailsPausedText:String = ''; #end /** @@ -986,8 +983,10 @@ class PlayState extends MusicBeatSubState #if FEATURE_DISCORD_RPC DiscordClient.instance.setPresence( { - state: '${currentChart.songName} (${discordRPCDifficulty})', - details: discordRPCDetailsPausedText, + details: 'Paused - ${buildDiscordRPCDetails()}', + + state: buildDiscordRPCState(), + smallImageKey: discordRPCIcon }); #end @@ -1080,8 +1079,8 @@ class PlayState extends MusicBeatSubState #if FEATURE_DISCORD_RPC DiscordClient.instance.setPresence( { - state: '${currentChart.songName} [${discordRPCDifficulty}]', - details: 'Game Over - ${discordRPCDetailsText}', + details: 'Game Over - ${buildDiscordRPCDetails()}', + state: buildDiscordRPCState(), smallImageKey: discordRPCIcon }); #end @@ -1300,8 +1299,8 @@ class PlayState extends MusicBeatSubState // currentSongLengthMs - Conductor.instance.songPosition); DiscordClient.instance.setPresence( { - state: '${currentChart.songName} [${discordRPCDifficulty}]', - details: discordRPCDetailsText, + state: buildDiscordRPCState(), + details: 'Paused - ${buildDiscordRPCDetails()}', smallImageKey: discordRPCIcon }); } @@ -1309,8 +1308,8 @@ class PlayState extends MusicBeatSubState { DiscordClient.instance.setPresence( { - state: '${currentChart.songName} [${discordRPCDifficulty}]', - details: discordRPCDetailsText, + state: buildDiscordRPCState(), + details: 'Paused - ${buildDiscordRPCDetails()}', smallImageKey: discordRPCIcon }); } @@ -1344,8 +1343,8 @@ class PlayState extends MusicBeatSubState { DiscordClient.instance.setPresence( { - state: '${currentChart.songName} [${discordRPCDifficulty}]', - details: discordRPCDetailsText, + state: buildDiscordRPCState(), + details: buildDiscordRPCDetails(), smallImageKey: discordRPCIcon }); } @@ -1353,8 +1352,8 @@ class PlayState extends MusicBeatSubState { DiscordClient.instance.setPresence( { - state: '${currentChart.songName} [${discordRPCDifficulty}]', - details: discordRPCDetailsText, + state: buildDiscordRPCState(), + details: buildDiscordRPCDetails(), smallImageKey: discordRPCIcon }); // DiscordClient.changePresence(detailsText, '${currentChart.songName} ($discordRPCDifficulty)', discordRPCIcon, true, @@ -1380,8 +1379,8 @@ class PlayState extends MusicBeatSubState { DiscordClient.instance.setPresence( { - state: '${currentChart.songName} [${discordRPCDifficulty}]', - details: discordRPCDetailsText, + state: buildDiscordRPCState(), + details: buildDiscordRPCDetails(), smallImageKey: discordRPCIcon }); } @@ -1801,22 +1800,51 @@ class PlayState extends MusicBeatSubState function initDiscord():Void { #if FEATURE_DISCORD_RPC - discordRPCDifficulty = PlayState.instance.currentDifficulty.replace('-', ' ').toTitleCase(); - // Determine the details strings once and reuse them. - discordRPCDetailsText = PlayStatePlaylist.isStoryMode ? 'Story Mode: Week ${PlayStatePlaylist.campaignId}' : 'Freeplay'; - discordRPCDetailsPausedText = 'Paused - $discordRPCDetailsText'; // Updating Discord Rich Presence. DiscordClient.instance.setPresence( { - state: '${currentChart.songName} [${discordRPCDifficulty}]', - details: discordRPCDetailsText, + state: buildDiscordRPCState(), + details: buildDiscordRPCDetails(), smallImageKey: discordRPCIcon }); #end } + function buildDiscordRPCDetails():String + { + if (PlayStatePlaylist.isStoryMode) + { + return 'Story Mode: ${PlayStatePlaylist.campaignTitle}'; + } + else + { + if (isChartingMode) + { + return 'Chart Editor [Playtest]'; + } + else if (isPracticeMode) + { + return 'Freeplay [Practice]'; + } + else if (isBotPlayMode) + { + return 'Freeplay [Bot Play]'; + } + else + { + return 'Freeplay'; + } + } + } + + function buildDiscordRPCState():String + { + var discordRPCDifficulty = PlayState.instance.currentDifficulty.replace('-', ' ').toTitleCase(); + return '${currentChart.songName} [${discordRPCDifficulty}]'; + } + function initPreciseInputs():Void { PreciseInputManager.instance.onInputPressed.add(onKeyPress); @@ -2010,8 +2038,8 @@ class PlayState extends MusicBeatSubState // Updating Discord Rich Presence (with Time Left) DiscordClient.instance.setPresence( { - state: '${currentChart.songName} (${discordRPCDifficulty})', - details: discordRPCDetailsText, + state: buildDiscordRPCState(), + details: buildDiscordRPCDetails(), smallImageKey: discordRPCIcon }); // DiscordClient.changePresence(detailsText, '${currentChart.songName} ($discordRPCDifficulty)', discordRPCIcon, true, currentSongLengthMs); diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 2e259d3f52..458e5d5fbe 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -2274,7 +2274,24 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState this.openBackupAvailableDialog(welcomeDialog); } } + + #if FEATURE_DISCORD_RPC + updateDiscordRPC(); + #end + } + + #if FEATURE_DISCORD_RPC + function updateDiscordRPC():Void + { + funkin.api.discord.DiscordClient.instance.setPresence( + { + // TODO: Make this display the song name and update when it changes. + // state: '${currentSongName} [${selectedDifficulty}]', + state: null, + details: 'Chart Editor [Charting]' + }); } + #end function setupWelcomeMusic() { diff --git a/source/funkin/util/Constants.hx b/source/funkin/util/Constants.hx index cf58d191a3..b2fa46aeae 100644 --- a/source/funkin/util/Constants.hx +++ b/source/funkin/util/Constants.hx @@ -78,7 +78,12 @@ class Constants /** * Link to download the game on Itch.io. */ - public static final URL_ITCH:String = 'https://ninja-muffin24.itch.io/funkin/purchase'; + public static final URL_ITCH:String = 'https://ninja-muffin24.itch.io/funkin'; + + /** + * Link to play the game on Newgrounds. + */ + public static final URL_NEWGROUNDS:String = 'https://www.newgrounds.com/portal/view/770371'; /** * Link to the game's page on Kickstarter. From bfee63f588ab9836d81f16bd31af277a61af729d Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 19 Sep 2024 11:15:56 -0400 Subject: [PATCH 076/143] Update hmm.json --- hmm.json | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/hmm.json b/hmm.json index 42c63abed3..0d57cfbc8e 100644 --- a/hmm.json +++ b/hmm.json @@ -112,8 +112,8 @@ "name": "hxdiscord_rpc", "type": "git", "dir": null, - "ref": "main", - "url": "https://github.com/MAJigsaw77/hxdiscord_rpc" + "ref": "79955ce93f0392b245b3610b7697780c8618bc47", + "url": "https://github.com/FunkinCrew/hxdiscord_rpc" }, { "name": "hxjsonast", @@ -155,13 +155,6 @@ "ref": "fe3368f611a84a19afc03011353945ae4da8fffd", "url": "https://github.com/FunkinCrew/lime" }, - { - "name": "linc_discord-rpc", - "type": "git", - "dir": null, - "ref": "2d83fa863ef0c1eace5f1cf67c3ac315d1a3a8a5", - "url": "https://github.com/FunkinCrew/haxe-discord-rpc" - }, { "name": "mconsole", "type": "git", @@ -219,4 +212,4 @@ "url": "https://github.com/fponticelli/thx.semver" } ] -} \ No newline at end of file +} From 3cbba8ba29dda790597e29e01c9e7d620953169d Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 19 Sep 2024 04:22:05 -0400 Subject: [PATCH 077/143] Resolve merge issues. --- source/funkin/play/PlayState.hx | 1 - source/funkin/play/components/PopUpStuff.hx | 9 --------- source/funkin/ui/debug/anim/DebugBoundingState.hx | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index a25d3b2318..1c82eb6b15 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -3046,7 +3046,6 @@ class PlayState extends MusicBeatSubState GameOverSubState.reset(); PauseSubState.reset(); Countdown.reset(); - PopUpStuff.reset(); // Clear the static reference to this state. instance = null; diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index e5e9b46816..a02291e4e2 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -125,13 +125,4 @@ class PopUpStuff extends FlxTypedGroup daLoop++; } } - - /** - * Reset the popup configuration to the default. - */ - public static function reset() - { - noteStyle = NoteStyleRegistry.instance.fetchDefault(); - isPixel = false; - } } diff --git a/source/funkin/ui/debug/anim/DebugBoundingState.hx b/source/funkin/ui/debug/anim/DebugBoundingState.hx index 19391f8d95..d2a27999f1 100644 --- a/source/funkin/ui/debug/anim/DebugBoundingState.hx +++ b/source/funkin/ui/debug/anim/DebugBoundingState.hx @@ -77,7 +77,7 @@ class DebugBoundingState extends FlxState { // get the screen position, according to the HUD camera, temp default to FlxG.camera juuust in case? var hudMousePos:FlxPoint = FlxG.mouse.getScreenPosition(hudCam ?? FlxG.camera); - return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y) || FlxG.mouse.overlaps(animDropDownMenu, hudCam); + return Screen.instance.hasSolidComponentUnderPoint(hudMousePos.x, hudMousePos.y); } override function create() From b03c8a9cf8cfe8c00d88ed64d488dceac4992378 Mon Sep 17 00:00:00 2001 From: Kade <26305836+Kade-github@users.noreply.github.com> Date: Thu, 19 Sep 2024 00:02:59 -0700 Subject: [PATCH 078/143] Limit the song time to 0 and the songs max length use the new bool to tell if we should start the song add a public static bool to countdown: finished --- source/funkin/Conductor.hx | 10 +++++++--- source/funkin/play/Countdown.hx | 7 +++++++ source/funkin/play/PlayState.hx | 20 ++++++++++++++------ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/source/funkin/Conductor.hx b/source/funkin/Conductor.hx index e73b2860c7..3211f31f56 100644 --- a/source/funkin/Conductor.hx +++ b/source/funkin/Conductor.hx @@ -397,9 +397,12 @@ class Conductor */ public function update(?songPos:Float, applyOffsets:Bool = true, forceDispatch:Bool = false) { + var currentTime:Float = (FlxG.sound.music != null) ? FlxG.sound.music.time : 0.0; + var currentLength:Float = (FlxG.sound.music != null) ? FlxG.sound.music.length : 0.0; + if (songPos == null) { - songPos = (FlxG.sound.music != null) ? FlxG.sound.music.time : 0.0; + songPos = currentTime; } // Take into account instrumental and file format song offsets. @@ -410,7 +413,7 @@ class Conductor var oldStep:Float = this.currentStep; // Set the song position we are at (for purposes of calculating note positions, etc). - this.songPosition = songPos; + this.songPosition = Math.min(currentLength, Math.max(0, songPos)); currentTimeChange = timeChanges[0]; if (this.songPosition > 0.0) @@ -430,7 +433,8 @@ class Conductor else if (currentTimeChange != null && this.songPosition > 0.0) { // roundDecimal prevents representing 8 as 7.9999999 - this.currentStepTime = FlxMath.roundDecimal((currentTimeChange.beatTime * Constants.STEPS_PER_BEAT) + (this.songPosition - currentTimeChange.timeStamp) / stepLengthMs, 6); + this.currentStepTime = FlxMath.roundDecimal((currentTimeChange.beatTime * Constants.STEPS_PER_BEAT) + + (this.songPosition - currentTimeChange.timeStamp) / stepLengthMs, 6); this.currentBeatTime = currentStepTime / Constants.STEPS_PER_BEAT; this.currentMeasureTime = currentStepTime / stepsPerMeasure; this.currentStep = Math.floor(currentStepTime); diff --git a/source/funkin/play/Countdown.hx b/source/funkin/play/Countdown.hx index 643883a43f..c883006a01 100644 --- a/source/funkin/play/Countdown.hx +++ b/source/funkin/play/Countdown.hx @@ -29,6 +29,11 @@ class Countdown */ public static var soundSuffix:String = ''; + /** + * Whether the countdown has finished. + */ + public static var finished:Bool = false; + /** * Which alternate graphic on countdown to use. * You can set this via script. @@ -53,6 +58,7 @@ class Countdown */ public static function performCountdown():Bool { + finished = false; countdownStep = BEFORE; var cancelled:Bool = propagateCountdownEvent(countdownStep); if (cancelled) @@ -101,6 +107,7 @@ class Countdown if (countdownStep == AFTER) { + finished = true; stopCountdown(); } }, 5); // Before, 3, 2, 1, GO!, After diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 0b2b8846d3..06dd5f95e4 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -915,7 +915,11 @@ class PlayState extends MusicBeatSubState { // Do NOT apply offsets at this point, because they already got applied the previous frame! Conductor.instance.update(Conductor.instance.songPosition + elapsed * 1000, false); - if (Conductor.instance.songPosition >= (startTimestamp)) startSong(); + if (Conductor.instance.songPosition - Conductor.instance.instrumentalOffset >= (startTimestamp) && Countdown.finished) + { + trace("started song at " + Conductor.instance.songPosition); + startSong(); + } } } else @@ -1391,14 +1395,16 @@ class PlayState extends MusicBeatSubState // activeNotes.sort(SortUtil.byStrumtime, FlxSort.DESCENDING); } + var correctSync:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.instrumentalOffset)); + if (!startingSong && FlxG.sound.music != null - && (Math.abs(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 100 - || Math.abs(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 100)) + && (Math.abs(FlxG.sound.music.time - correctSync) > 100 || Math.abs(vocals.checkSyncError(correctSync)) > 100)) { trace("VOCALS NEED RESYNC"); - if (vocals != null) trace(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)); - trace(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)); + if (vocals != null) trace(vocals.checkSyncError(correctSync)); + trace(FlxG.sound.music.time); + trace(correctSync); resyncVocals(); } @@ -1993,7 +1999,9 @@ class PlayState extends MusicBeatSubState // Skip this if the music is paused (GameOver, Pause menu, start-of-song offset, etc.) if (!(FlxG.sound.music?.playing ?? false)) return; - var timeToPlayAt:Float = Conductor.instance.songPosition - Conductor.instance.instrumentalOffset; + + var timeToPlayAt:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.instrumentalOffset)); + trace('Resyncing vocals to ${timeToPlayAt}'); FlxG.sound.music.pause(); vocals.pause(); From 4d73e0cc475f7195261cfff3592eb01b9192aac2 Mon Sep 17 00:00:00 2001 From: Kade <26305836+Kade-github@users.noreply.github.com> Date: Thu, 19 Sep 2024 01:20:16 -0700 Subject: [PATCH 079/143] fix some interesting issues with this redundant trace removal --- source/funkin/Conductor.hx | 11 ++++++++++- source/funkin/play/Countdown.hx | 7 ------- source/funkin/play/PlayState.hx | 29 +++++++++++++++++------------ 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/source/funkin/Conductor.hx b/source/funkin/Conductor.hx index 3211f31f56..bd7c7196f7 100644 --- a/source/funkin/Conductor.hx +++ b/source/funkin/Conductor.hx @@ -412,8 +412,17 @@ class Conductor var oldBeat:Float = this.currentBeat; var oldStep:Float = this.currentStep; + // If the song is playing, limit the song position to the length of the song or beginning of the song. + if (FlxG.sound.music != null && FlxG.sound.music.playing) + { + this.songPosition = Math.min(currentLength, Math.max(0, songPos)); + } + else + { + this.songPosition = songPos; + } + // Set the song position we are at (for purposes of calculating note positions, etc). - this.songPosition = Math.min(currentLength, Math.max(0, songPos)); currentTimeChange = timeChanges[0]; if (this.songPosition > 0.0) diff --git a/source/funkin/play/Countdown.hx b/source/funkin/play/Countdown.hx index c883006a01..643883a43f 100644 --- a/source/funkin/play/Countdown.hx +++ b/source/funkin/play/Countdown.hx @@ -29,11 +29,6 @@ class Countdown */ public static var soundSuffix:String = ''; - /** - * Whether the countdown has finished. - */ - public static var finished:Bool = false; - /** * Which alternate graphic on countdown to use. * You can set this via script. @@ -58,7 +53,6 @@ class Countdown */ public static function performCountdown():Bool { - finished = false; countdownStep = BEFORE; var cancelled:Bool = propagateCountdownEvent(countdownStep); if (cancelled) @@ -107,7 +101,6 @@ class Countdown if (countdownStep == AFTER) { - finished = true; stopCountdown(); } }, 5); // Before, 3, 2, 1, GO!, After diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 06dd5f95e4..4e81d3a83c 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -687,7 +687,11 @@ class PlayState extends MusicBeatSubState } Conductor.instance.mapTimeChanges(currentChart.timeChanges); - Conductor.instance.update((Conductor.instance.beatLengthMs * -5) + startTimestamp); + var pre:Float = (Conductor.instance.beatLengthMs * -5) + startTimestamp; + + trace('Attempting to start at ' + pre); + + Conductor.instance.update(pre); // The song is now loaded. We can continue to initialize the play state. initCameras(); @@ -915,7 +919,7 @@ class PlayState extends MusicBeatSubState { // Do NOT apply offsets at this point, because they already got applied the previous frame! Conductor.instance.update(Conductor.instance.songPosition + elapsed * 1000, false); - if (Conductor.instance.songPosition - Conductor.instance.instrumentalOffset >= (startTimestamp) && Countdown.finished) + if (Conductor.instance.songPosition >= (startTimestamp + Conductor.instance.instrumentalOffset)) { trace("started song at " + Conductor.instance.songPosition); startSong(); @@ -1395,17 +1399,18 @@ class PlayState extends MusicBeatSubState // activeNotes.sort(SortUtil.byStrumtime, FlxSort.DESCENDING); } - var correctSync:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.instrumentalOffset)); - - if (!startingSong - && FlxG.sound.music != null - && (Math.abs(FlxG.sound.music.time - correctSync) > 100 || Math.abs(vocals.checkSyncError(correctSync)) > 100)) + if (FlxG.sound.music != null) { - trace("VOCALS NEED RESYNC"); - if (vocals != null) trace(vocals.checkSyncError(correctSync)); - trace(FlxG.sound.music.time); - trace(correctSync); - resyncVocals(); + var correctSync:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.instrumentalOffset)); + + if (!startingSong && (Math.abs(FlxG.sound.music.time - correctSync) > 100 || Math.abs(vocals.checkSyncError(correctSync)) > 100)) + { + trace("VOCALS NEED RESYNC"); + if (vocals != null) trace(vocals.checkSyncError(correctSync)); + trace(FlxG.sound.music.time); + trace(correctSync); + resyncVocals(); + } } // Only bop camera if zoom level is below 135% From a8aeae4f7fa97d99310a327cc0f218e404662d2c Mon Sep 17 00:00:00 2001 From: Kade <26305836+Kade-github@users.noreply.github.com> Date: Thu, 19 Sep 2024 10:24:02 -0700 Subject: [PATCH 080/143] do not include offset in vocal (they're offset by inst) Fix a tiny little issue with vocal resync @ start --- source/funkin/play/PlayState.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 4e81d3a83c..96bce85e59 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1979,6 +1979,7 @@ class PlayState extends MusicBeatSubState vocals.play(); vocals.volume = 1.0; vocals.pitch = playbackRate; + vocals.time = startTimestamp; resyncVocals(); #if FEATURE_DISCORD_RPC From f9186b67a7df74f81137374f9d0972114fa4b786 Mon Sep 17 00:00:00 2001 From: Kade <26305836+Kade-github@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:00:52 -0700 Subject: [PATCH 081/143] less tolerance --- source/funkin/play/PlayState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 96bce85e59..e2bff164e6 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1403,7 +1403,7 @@ class PlayState extends MusicBeatSubState { var correctSync:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.instrumentalOffset)); - if (!startingSong && (Math.abs(FlxG.sound.music.time - correctSync) > 100 || Math.abs(vocals.checkSyncError(correctSync)) > 100)) + if (!startingSong && (Math.abs(FlxG.sound.music.time - correctSync) > 5 || Math.abs(vocals.checkSyncError(correctSync)) > 5)) { trace("VOCALS NEED RESYNC"); if (vocals != null) trace(vocals.checkSyncError(correctSync)); From 9045ae2d9c65b870bb8079f69e94209050c70127 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 20 Sep 2024 00:25:38 -0400 Subject: [PATCH 082/143] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 252d48f4c9..b029e06783 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 252d48f4c996d5832cb981fb2f3ed945c020f289 +Subproject commit b029e067835b80be35ee4de149ac3c6cf2bb4c4c From 143ef88e6ff5a680328099e9f253e644ea9b81ac Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 20 Sep 2024 03:42:48 -0400 Subject: [PATCH 083/143] Update assets submodule --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 252d48f4c9..2c9025b007 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 252d48f4c996d5832cb981fb2f3ed945c020f289 +Subproject commit 2c9025b007b3823807404b73a11035c41e032e50 From 5f64d89d0e47f7c062f746ed8880b6287748a351 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 20 Sep 2024 16:51:21 -0400 Subject: [PATCH 084/143] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 2c9025b007..41980de1c2 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 2c9025b007b3823807404b73a11035c41e032e50 +Subproject commit 41980de1c2ec851ce99a33cb397ba0550b68ea2d From 78cde16af29f4f4ef5ef2cc3563592aeb1769528 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 20 Sep 2024 18:10:47 -0400 Subject: [PATCH 085/143] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 4f7e8bb5cd..2a0bc4f66d 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 4f7e8bb5cd2e9eb8f68d88c060e9cbe5bccc9e2f +Subproject commit 2a0bc4f66d79a6f590e7ed2c04884d8c1fa8c45e From a41d3033d5e7f518b3db1cd5943105bb22260052 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 20 Sep 2024 18:20:40 -0400 Subject: [PATCH 086/143] small Assets -> OpenFLAssets fix --- source/funkin/ui/transition/LoadingState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/ui/transition/LoadingState.hx b/source/funkin/ui/transition/LoadingState.hx index 3b4661425e..f3620c893c 100644 --- a/source/funkin/ui/transition/LoadingState.hx +++ b/source/funkin/ui/transition/LoadingState.hx @@ -276,7 +276,7 @@ class LoadingState extends MusicBeatSubState #if NO_PRELOAD_ALL static function isSoundLoaded(path:String):Bool { - return Assets.cache.hasSound(path); + return OpenFLAssets.cache.hasSound(path); } static function isLibraryLoaded(library:String):Bool From 690f3090b728a84a91e2878412eaf9049c1d8116 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 20 Sep 2024 20:11:12 -0400 Subject: [PATCH 087/143] proper audio scaling for hxcodec / desktop --- .../graphics/video/FunkinVideoSprite.hx | 32 +++++++++++++++++++ source/funkin/play/cutscene/VideoCutscene.hx | 6 ++-- source/funkin/ui/charSelect/IntroSubState.hx | 6 ++-- source/funkin/ui/title/AttractState.hx | 6 ++-- 4 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 source/funkin/graphics/video/FunkinVideoSprite.hx diff --git a/source/funkin/graphics/video/FunkinVideoSprite.hx b/source/funkin/graphics/video/FunkinVideoSprite.hx new file mode 100644 index 0000000000..e0086784bd --- /dev/null +++ b/source/funkin/graphics/video/FunkinVideoSprite.hx @@ -0,0 +1,32 @@ +package funkin.graphics.video; + +import hxcodec.flixel.FlxVideoSprite; + +/** + * Not to be confused with FlxVideo, this is a hxcodec based video class + * We override it simply to correct/control our volume easier. + */ +class FunkinVideoSprite extends FlxVideoSprite +{ + public var volume(default, set):Float = 1; + + public function new(x:Float = 0, y:Float = 0) + { + super(x, y); + + set_volume(1); + } + + override public function update(elapsed:Float):Void + { + super.update(elapsed); + set_volume(volume); + } + + function set_volume(value:Float):Float + { + volume = value; + bitmap.volume = Std.int((FlxG.sound.muted ? 0 : 1) * (FlxG.sound.logToLinear(FlxG.sound.volume) * 100) * volume); + return volume; + } +} diff --git a/source/funkin/play/cutscene/VideoCutscene.hx b/source/funkin/play/cutscene/VideoCutscene.hx index 60454b8811..b6e04004bd 100644 --- a/source/funkin/play/cutscene/VideoCutscene.hx +++ b/source/funkin/play/cutscene/VideoCutscene.hx @@ -11,7 +11,7 @@ import flixel.util.FlxTimer; import funkin.graphics.video.FlxVideo; #end #if hxCodec -import hxcodec.flixel.FlxVideoSprite; +import funkin.graphics.video.FunkinVideoSprite; #end /** @@ -26,7 +26,7 @@ class VideoCutscene static var vid:FlxVideo; #end #if hxCodec - static var vid:FlxVideoSprite; + static var vid:FunkinVideoSprite; #end /** @@ -138,7 +138,7 @@ class VideoCutscene static function playVideoNative(filePath:String):Void { // Video displays OVER the FlxState. - vid = new FlxVideoSprite(0, 0); + vid = new FunkinVideoSprite(0, 0); if (vid != null) { diff --git a/source/funkin/ui/charSelect/IntroSubState.hx b/source/funkin/ui/charSelect/IntroSubState.hx index 2c29084732..e731e5e9a7 100644 --- a/source/funkin/ui/charSelect/IntroSubState.hx +++ b/source/funkin/ui/charSelect/IntroSubState.hx @@ -4,7 +4,7 @@ package funkin.ui.charSelect; import funkin.graphics.video.FlxVideo; #end #if hxCodec -import hxcodec.flixel.FlxVideoSprite; +import funkin.graphics.video.FunkinVideoSprite; #end import funkin.ui.MusicBeatSubState; import funkin.audio.FunkinSound; @@ -72,12 +72,12 @@ class IntroSubState extends MusicBeatSubState #end #if hxCodec - var vid:FlxVideoSprite; + var vid:FunkinVideoSprite; function playVideoNative(filePath:String):Void { // Video displays OVER the FlxState. - vid = new FlxVideoSprite(0, 0); + vid = new FunkinVideoSprite(0, 0); vid.scrollFactor.set(); diff --git a/source/funkin/ui/title/AttractState.hx b/source/funkin/ui/title/AttractState.hx index c5a3d05048..f5f266b0d5 100644 --- a/source/funkin/ui/title/AttractState.hx +++ b/source/funkin/ui/title/AttractState.hx @@ -4,7 +4,7 @@ package funkin.ui.title; import funkin.graphics.video.FlxVideo; #end #if hxCodec -import hxcodec.flixel.FlxVideoSprite; +import funkin.graphics.video.FunkinVideoSprite; #end import funkin.ui.MusicBeatState; @@ -62,12 +62,12 @@ class AttractState extends MusicBeatState #end #if hxCodec - var vid:FlxVideoSprite; + var vid:FunkinVideoSprite; function playVideoNative(filePath:String):Void { // Video displays OVER the FlxState. - vid = new FlxVideoSprite(0, 0); + vid = new FunkinVideoSprite(0, 0); if (vid != null) { From 2c73b241e8f7f6be5a4af7b4a5f180bb8444c199 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 21 Sep 2024 06:33:47 -0400 Subject: [PATCH 088/143] Rework offset+vocal sync handling to fix the "Swing Mode" bug --- source/funkin/Conductor.hx | 7 +++++++ source/funkin/play/PlayState.hx | 25 +++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/source/funkin/Conductor.hx b/source/funkin/Conductor.hx index bd7c7196f7..ff72b1e125 100644 --- a/source/funkin/Conductor.hx +++ b/source/funkin/Conductor.hx @@ -275,6 +275,13 @@ class Conductor return Save.instance.options.audioVisualOffset; } + public var combinedOffset(get, never):Float; + + function get_combinedOffset():Float + { + return instrumentalOffset + audioVisualOffset + inputOffset; + } + /** * The number of beats in a measure. May be fractional depending on the time signature. */ diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index e2bff164e6..ad52dd6e69 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -861,7 +861,7 @@ class PlayState extends MusicBeatSubState // Reset music properly. if (FlxG.sound.music != null) { - FlxG.sound.music.time = startTimestamp - Conductor.instance.instrumentalOffset; + FlxG.sound.music.time = startTimestamp - Conductor.instance.combinedOffset; FlxG.sound.music.pitch = playbackRate; FlxG.sound.music.pause(); } @@ -878,7 +878,7 @@ class PlayState extends MusicBeatSubState } } vocals.pause(); - vocals.time = 0; + vocals.time = 0 - Conductor.instance.combinedOffset; if (FlxG.sound.music != null) FlxG.sound.music.volume = 1; vocals.volume = 1; @@ -919,7 +919,7 @@ class PlayState extends MusicBeatSubState { // Do NOT apply offsets at this point, because they already got applied the previous frame! Conductor.instance.update(Conductor.instance.songPosition + elapsed * 1000, false); - if (Conductor.instance.songPosition >= (startTimestamp + Conductor.instance.instrumentalOffset)) + if (Conductor.instance.songPosition >= (startTimestamp + Conductor.instance.combinedOffset)) { trace("started song at " + Conductor.instance.songPosition); startSong(); @@ -1401,7 +1401,7 @@ class PlayState extends MusicBeatSubState if (FlxG.sound.music != null) { - var correctSync:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.instrumentalOffset)); + var correctSync:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.combinedOffset)); if (!startingSong && (Math.abs(FlxG.sound.music.time - correctSync) > 5 || Math.abs(vocals.checkSyncError(correctSync)) > 5)) { @@ -1411,6 +1411,13 @@ class PlayState extends MusicBeatSubState trace(correctSync); resyncVocals(); } + else + { + trace("NO VOCAL SYNC NEEDED"); + if (vocals != null) trace(vocals.checkSyncError(correctSync)); + trace(FlxG.sound.music.time); + trace(correctSync); + } } // Only bop camera if zoom level is below 135% @@ -1967,7 +1974,7 @@ class PlayState extends MusicBeatSubState }; // A negative instrumental offset means the song skips the first few milliseconds of the track. // This just gets added into the startTimestamp behavior so we don't need to do anything extra. - FlxG.sound.music.play(true, startTimestamp - Conductor.instance.instrumentalOffset); + FlxG.sound.music.play(true, Math.max(0, startTimestamp - Conductor.instance.combinedOffset)); FlxG.sound.music.pitch = playbackRate; // Prevent the volume from being wrong. @@ -1979,7 +1986,9 @@ class PlayState extends MusicBeatSubState vocals.play(); vocals.volume = 1.0; vocals.pitch = playbackRate; - vocals.time = startTimestamp; + vocals.time = FlxG.sound.music.time; + trace('${FlxG.sound.music.time}'); + trace('${vocals.time}'); resyncVocals(); #if FEATURE_DISCORD_RPC @@ -1989,7 +1998,7 @@ class PlayState extends MusicBeatSubState if (startTimestamp > 0) { - // FlxG.sound.music.time = startTimestamp - Conductor.instance.instrumentalOffset; + // FlxG.sound.music.time = startTimestamp - Conductor.instance.combinedOffset; handleSkippedNotes(); } @@ -2006,7 +2015,7 @@ class PlayState extends MusicBeatSubState // Skip this if the music is paused (GameOver, Pause menu, start-of-song offset, etc.) if (!(FlxG.sound.music?.playing ?? false)) return; - var timeToPlayAt:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.instrumentalOffset)); + var timeToPlayAt:Float = Math.min(FlxG.sound.music.length, Math.max(0, Conductor.instance.songPosition - Conductor.instance.combinedOffset)); trace('Resyncing vocals to ${timeToPlayAt}'); FlxG.sound.music.pause(); vocals.pause(); From 01e9888839d8d498ba9868c96b52c2e5253a8d10 Mon Sep 17 00:00:00 2001 From: JVN-Pixels <146671762+JVNpixels@users.noreply.github.com> Date: Sat, 21 Sep 2024 10:07:41 -0700 Subject: [PATCH 089/143] Update CHANGELOG.md Fixes changelog for the 0.5.0 update! --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2031ba24c..469ba9bd09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,14 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Modding isn't 100% there but we're working on it! - Added Pico as a playable character! Unlock him by completing Weekend 1 (if you haven't already done that) - The songs from Weekend 1 have moved; you must now switch to Pico in Freeplay to access them -- Added 10 new Pico remixes! Access them by selecting Pico from in the Character Select screen +- Added 11 new Pico remixes! Access them by selecting Pico from in the Character Select screen - Bopeebo (Pico Mix) - Fresh (Pico Mix) - DadBattle (Pico Mix) - Spookeez (Pico Mix) - South (Pico Mix) + - Pico (Pico Mix) - Philly Nice (Pico Mix) - - Blammed (Pico Mix) + - Blammed (Pico Mix) - Eggnog (Pico Mix) - Ugh (Pico Mix) - Guns (Pico Mix) From ec8ecc616343bf52a2b3837c2a661f4402981b24 Mon Sep 17 00:00:00 2001 From: JVN-Pixels <146671762+JVNpixels@users.noreply.github.com> Date: Sat, 21 Sep 2024 10:14:09 -0700 Subject: [PATCH 090/143] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 469ba9bd09..e4053c1e53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Eggnog (Pico Mix) - Ugh (Pico Mix) - Guns (Pico Mix) -- Added 1 new Boyfriend remix! Access it by selecting Pico from in the Character Select screen +- Added 1 new Boyfriend remix! Access it by completing Weekend 1 as Pico and then selecting Boyfriend from in the Character Select screen - Darnell (BF Mix) - Added 2 new Erect remixes! Access them by switching difficulty on the song - Cocoa Erect From e535ae4ca61c05e0b44e5d5b76523f76629f145d Mon Sep 17 00:00:00 2001 From: JVN-Pixels <146671762+JVNpixels@users.noreply.github.com> Date: Sat, 21 Sep 2024 10:19:00 -0700 Subject: [PATCH 091/143] Change line 12 The songs from Weekend 1 have moved line --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4053c1e53..66926bd13a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added a new Character Select screen to switch between playable characters in Freeplay - Modding isn't 100% there but we're working on it! - Added Pico as a playable character! Unlock him by completing Weekend 1 (if you haven't already done that) - - The songs from Weekend 1 have moved; you must now switch to Pico in Freeplay to access them + - The songs from Weekend 1 have moved; you must now switch to Pico via Character Select screen in Freeplay to access them - Added 11 new Pico remixes! Access them by selecting Pico from in the Character Select screen - Bopeebo (Pico Mix) - Fresh (Pico Mix) From 3601b50e322d46e1f3fbfc94f3825f03de18c442 Mon Sep 17 00:00:00 2001 From: JVN-Pixels <146671762+JVNpixels@users.noreply.github.com> Date: Sat, 21 Sep 2024 10:29:08 -0700 Subject: [PATCH 092/143] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66926bd13a..a21455ef50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - These display on Pico remixes, as well as when playing Weekend 1. - Implemented support for scripted Note Kinds. You can use HScript define a different note style to display for these notes as well as custom behavior. (community feature by lemz1) - Implemented support for Numeric and Selector options in the Options menu. (community feature by FlooferLand) +- Implemented new animations for Tankman and Pico ## Changed - Girlfriend and Nene now perform previously unused animations when you achieve a large combo, or drop a large combo. - The pixel character icons in the Freeplay menu now display an animation! From e978f5df7624781f2b179a9039110fe818e896ba Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sat, 21 Sep 2024 16:32:44 -0400 Subject: [PATCH 093/143] fix for spirit's trail --- assets | 2 +- hmm.json | 4 +-- source/funkin/effects/FunkTrail.hx | 40 ++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 source/funkin/effects/FunkTrail.hx diff --git a/assets b/assets index 72bb24ac9b..59546b1ac7 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 72bb24ac9b0b9db4b2f9c38ef091e146ef16a1a4 +Subproject commit 59546b1ac78f591d1f7403b7a2209278bedfe63d diff --git a/hmm.json b/hmm.json index bbe4897b76..c6e3e7115e 100644 --- a/hmm.json +++ b/hmm.json @@ -25,7 +25,7 @@ "name": "flixel-addons", "type": "git", "dir": null, - "ref": "9c6fb47968e894eb36bf10e94725cd7640c49281", + "ref": "e7789a32cf068eaa0abcaebc8dc07f6cf8f0632c", "url": "https://github.com/FunkinCrew/flixel-addons" }, { @@ -205,4 +205,4 @@ "url": "https://github.com/fponticelli/thx.semver" } ] -} +} \ No newline at end of file diff --git a/source/funkin/effects/FunkTrail.hx b/source/funkin/effects/FunkTrail.hx new file mode 100644 index 0000000000..021a0e9b4c --- /dev/null +++ b/source/funkin/effects/FunkTrail.hx @@ -0,0 +1,40 @@ +package funkin.effects; + +import flixel.addons.effects.FlxTrail; +import funkin.play.stage.Bopper; +import flixel.FlxSprite; +import flixel.system.FlxAssets; + +/** + * An offshoot of FlxTrail, but accomodates the way Funkin + * does offsets for characters. example, fixes Spirits trail + */ +class FunkTrail extends FlxTrail +{ + /** + * Creates a new FunkTrail effect for a specific FlxSprite. + * + * @param Target The FlxSprite the trail is attached to. + * @param Graphic The image to use for the trailsprites. Optional, uses the sprite's graphic if null. + * @param Length The amount of trailsprites to create. + * @param Delay How often to update the trail. 0 updates every frame. + * @param Alpha The alpha value for the very first trailsprite. + * @param Diff How much lower the alpha of the next trailsprite is. + */ + public function new(Target:FlxSprite, ?Graphic:FlxGraphicAsset, Length:Int = 10, Delay:Int = 3, Alpha:Float = 0.4, Diff:Float = 0.05) + { + super(Target, Graphic, Length, Delay, Alpha, Diff); + } + + override public function updateTrail():Void + { + if (target is Bopper) + { + var targ:Bopper = cast target; + @:privateAccess effectOffset.set((targ.animOffsets[0] - targ.globalOffsets[0]) * targ.scale.x, + (targ.animOffsets[1] - targ.globalOffsets[1]) * targ.scale.y); + } + + super.updateTrail(); + } +} From 6c743b3b89b278f8250061b5110c28d1852a91b5 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 21 Sep 2024 20:33:51 -0400 Subject: [PATCH 094/143] Remove some spammy trace calls. --- source/funkin/play/PlayState.hx | 11 ++--------- source/funkin/play/components/PopUpStuff.hx | 1 - source/funkin/ui/mainmenu/MainMenuState.hx | 2 ++ 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index ad52dd6e69..9b6015b67c 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1411,13 +1411,6 @@ class PlayState extends MusicBeatSubState trace(correctSync); resyncVocals(); } - else - { - trace("NO VOCAL SYNC NEEDED"); - if (vocals != null) trace(vocals.checkSyncError(correctSync)); - trace(FlxG.sound.music.time); - trace(correctSync); - } } // Only bop camera if zoom level is below 135% @@ -2396,9 +2389,9 @@ class PlayState extends MusicBeatSubState if (targetNote == null) continue; // Judge and hit the note. - trace('Hit note! ${targetNote.noteData}'); + // trace('Hit note! ${targetNote.noteData}'); goodNoteHit(targetNote, input); - trace('Score: ${songScore}'); + // trace('Score: ${songScore}'); notesInDirection.remove(targetNote); diff --git a/source/funkin/play/components/PopUpStuff.hx b/source/funkin/play/components/PopUpStuff.hx index a02291e4e2..7ea5650f14 100644 --- a/source/funkin/play/components/PopUpStuff.hx +++ b/source/funkin/play/components/PopUpStuff.hx @@ -95,7 +95,6 @@ class PopUpStuff extends FlxTypedGroup if (numScore == null) continue; numScore.x = (FlxG.width * 0.507) - (36 * daLoop) - 65; - trace('numScore($daLoop) = ${numScore.x}'); numScore.y = (FlxG.camera.height * 0.44); numScore.x += offsets[0]; diff --git a/source/funkin/ui/mainmenu/MainMenuState.hx b/source/funkin/ui/mainmenu/MainMenuState.hx index 13d68da6d9..3f36dad81d 100644 --- a/source/funkin/ui/mainmenu/MainMenuState.hx +++ b/source/funkin/ui/mainmenu/MainMenuState.hx @@ -344,6 +344,8 @@ class MainMenuState extends MusicBeatState } } + Conductor.instance.update(); + // Open the debug menu, defaults to ` / ~ // This includes stuff like the Chart Editor, so it should be present on all builds. if (controls.DEBUG_MENU) From 5548fd52f4458520935814ac241a6a079fe72beb Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 21 Sep 2024 20:33:59 -0400 Subject: [PATCH 095/143] Update default mod so it actually loads --- example_mods/introMod/_polymod_meta.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_mods/introMod/_polymod_meta.json b/example_mods/introMod/_polymod_meta.json index 4dc0cd8044..74c4a25040 100644 --- a/example_mods/introMod/_polymod_meta.json +++ b/example_mods/introMod/_polymod_meta.json @@ -6,7 +6,7 @@ "name": "EliteMasterEric" } ], - "api_version": "0.1.0", + "api_version": "0.5.0", "mod_version": "1.0.0", "license": "Apache-2.0" } From 29a7005d8a5ca63f69531792b86d9ec457efae09 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sun, 22 Sep 2024 00:44:57 -0400 Subject: [PATCH 096/143] Fix a bug where you can hear the game a little when setting the volume to 0 ticks --- source/funkin/ui/options/FunkinSoundTray.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/ui/options/FunkinSoundTray.hx b/source/funkin/ui/options/FunkinSoundTray.hx index 8ae53524ad..eea30ae173 100644 --- a/source/funkin/ui/options/FunkinSoundTray.hx +++ b/source/funkin/ui/options/FunkinSoundTray.hx @@ -121,7 +121,7 @@ class FunkinSoundTray extends FlxSoundTray active = true; var globalVolume:Int = Math.round(FlxG.sound.logToLinear(FlxG.sound.volume) * 10); - if (FlxG.sound.muted) + if (FlxG.sound.muted || FlxG.sound.volume == 0) { globalVolume = 0; } From c7238fcfd114352924a6cca436e069523a86cced Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sun, 22 Sep 2024 00:45:30 -0400 Subject: [PATCH 097/143] Stop the volume tray from hiding as long as the game is muted --- source/funkin/ui/options/FunkinSoundTray.hx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/funkin/ui/options/FunkinSoundTray.hx b/source/funkin/ui/options/FunkinSoundTray.hx index eea30ae173..b2fb7fc044 100644 --- a/source/funkin/ui/options/FunkinSoundTray.hx +++ b/source/funkin/ui/options/FunkinSoundTray.hx @@ -79,10 +79,12 @@ class FunkinSoundTray extends FlxSoundTray y = MathUtil.coolLerp(y, lerpYPos, 0.1); alpha = MathUtil.coolLerp(alpha, alphaTarget, 0.25); + var shouldHide = (FlxG.sound.muted == false && FlxG.sound.volume > 0); + // Animate sound tray thing if (_timer > 0) { - _timer -= (MS / 1000); + if (shouldHide) _timer -= (MS / 1000); alphaTarget = 1; } else if (y >= -height) From 58508755f99600a676c8424389e9c776e4ef3c2d Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sun, 22 Sep 2024 10:57:00 -0400 Subject: [PATCH 098/143] revert extra flxtrail function --- hmm.json | 2 +- source/funkin/effects/FunkTrail.hx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hmm.json b/hmm.json index c6e3e7115e..bf4f39fea8 100644 --- a/hmm.json +++ b/hmm.json @@ -25,7 +25,7 @@ "name": "flixel-addons", "type": "git", "dir": null, - "ref": "e7789a32cf068eaa0abcaebc8dc07f6cf8f0632c", + "ref": "7424db4e9164ff46f224a7c47de1b732d2542dd7", "url": "https://github.com/FunkinCrew/flixel-addons" }, { diff --git a/source/funkin/effects/FunkTrail.hx b/source/funkin/effects/FunkTrail.hx index 021a0e9b4c..9633f830f2 100644 --- a/source/funkin/effects/FunkTrail.hx +++ b/source/funkin/effects/FunkTrail.hx @@ -26,7 +26,7 @@ class FunkTrail extends FlxTrail super(Target, Graphic, Length, Delay, Alpha, Diff); } - override public function updateTrail():Void + override public function update(elapsed:Float):Void { if (target is Bopper) { @@ -35,6 +35,6 @@ class FunkTrail extends FlxTrail (targ.animOffsets[1] - targ.globalOffsets[1]) * targ.scale.y); } - super.updateTrail(); + super.update(elapsed); } } From 0bf1bead03f1b477ebbd82781283e63cf6c2a3e9 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sun, 22 Sep 2024 12:14:15 -0400 Subject: [PATCH 099/143] Fix some issues causing the Input Offsets view to crash on web. --- source/funkin/play/notes/notestyle/NoteStyle.hx | 6 +++++- source/funkin/ui/debug/latency/LatencyState.hx | 12 ++++++++++-- source/funkin/ui/options/OptionsState.hx | 5 +++++ source/funkin/ui/transition/LoadingState.hx | 5 +++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/source/funkin/play/notes/notestyle/NoteStyle.hx b/source/funkin/play/notes/notestyle/NoteStyle.hx index c2f7ec009b..3318e90860 100644 --- a/source/funkin/play/notes/notestyle/NoteStyle.hx +++ b/source/funkin/play/notes/notestyle/NoteStyle.hx @@ -103,7 +103,11 @@ class NoteStyle implements IRegistryEntry function buildNoteFrames(force:Bool = false):Null { var noteAssetPath = getNoteAssetPath(); - if (noteAssetPath == null) return null; + if (noteAssetPath == null) + { + FlxG.log.warn('Note asset path not found: ${id}'); + return null; + } if (!FunkinSprite.isTextureCached(Paths.image(noteAssetPath))) { diff --git a/source/funkin/ui/debug/latency/LatencyState.hx b/source/funkin/ui/debug/latency/LatencyState.hx index 9624381544..63595655cd 100644 --- a/source/funkin/ui/debug/latency/LatencyState.hx +++ b/source/funkin/ui/debug/latency/LatencyState.hx @@ -16,6 +16,7 @@ import funkin.ui.debug.latency.CoolStatsGraph; import openfl.events.KeyboardEvent; import funkin.input.PreciseInputManager; import funkin.play.notes.Strumline; +import funkin.ui.mainmenu.MainMenuState; import funkin.play.notes.notestyle.NoteStyle; import funkin.data.notestyle.NoteStyleData; import funkin.data.notestyle.NoteStyleRegistry; @@ -188,6 +189,12 @@ class LatencyState extends MusicBeatSubState } override public function close():Void + { + cleanup(); + super.close(); + } + + function cleanup():Void { PreciseInputManager.instance.onInputPressed.remove(preciseInputPressed); PreciseInputManager.instance.onInputReleased.remove(preciseInputReleased); @@ -200,7 +207,6 @@ class LatencyState extends MusicBeatSubState FlxG.state.persistentDraw = prevPersistentDraw; FlxG.state.persistentUpdate = prevPersistentUpdate; - super.close(); } function regenNoteData() @@ -311,7 +317,9 @@ class LatencyState extends MusicBeatSubState if (controls.BACK) { - close(); + // close(); + cleanup(); + FlxG.switchState(() -> new MainMenuState()); } super.update(elapsed); diff --git a/source/funkin/ui/options/OptionsState.hx b/source/funkin/ui/options/OptionsState.hx index a2301e6a36..6bf637eb99 100644 --- a/source/funkin/ui/options/OptionsState.hx +++ b/source/funkin/ui/options/OptionsState.hx @@ -1,5 +1,6 @@ package funkin.ui.options; +import funkin.ui.transition.LoadingState; import funkin.ui.debug.latency.LatencyState; import flixel.FlxSprite; import flixel.FlxSubState; @@ -185,7 +186,11 @@ class OptionsMenu extends Page createItem("PREFERENCES", function() switchPage(Preferences)); createItem("CONTROLS", function() switchPage(Controls)); createItem("INPUT OFFSETS", function() { + #if web + LoadingState.transitionToState(() -> new LatencyState()); + #else FlxG.state.openSubState(new LatencyState()); + #end }); #if newgrounds diff --git a/source/funkin/ui/transition/LoadingState.hx b/source/funkin/ui/transition/LoadingState.hx index f3620c893c..a4fee0f8d3 100644 --- a/source/funkin/ui/transition/LoadingState.hx +++ b/source/funkin/ui/transition/LoadingState.hx @@ -451,6 +451,11 @@ class LoadingState extends MusicBeatSubState return promise.future; } + + public static function transitionToState(state:NextState, stopMusic:Bool = false):Void + { + FlxG.switchState(() -> new LoadingState(state, stopMusic)); + } } class MultiCallback From 2edb31890140a79396095ca477e20bde7cd8dd4b Mon Sep 17 00:00:00 2001 From: FabsTheFabs Date: Sun, 22 Sep 2024 20:11:37 +0100 Subject: [PATCH 100/143] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 72bb24ac9b..d586f038fb 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 72bb24ac9b0b9db4b2f9c38ef091e146ef16a1a4 +Subproject commit d586f038fb3b851398909904fc969e5b6755cd4a From 84ce43eff7b95670b3ade17b23be8b3bc18382da Mon Sep 17 00:00:00 2001 From: FabsTheFabs Date: Mon, 23 Sep 2024 03:46:14 +0100 Subject: [PATCH 101/143] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 72bb24ac9b..17894c11fb 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 72bb24ac9b0b9db4b2f9c38ef091e146ef16a1a4 +Subproject commit 17894c11fbc0f189b1f725b6c736aefc115ce566 From 299f4840cfc9e5144037b98232e32da9def903bf Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 23 Sep 2024 13:10:44 -0400 Subject: [PATCH 102/143] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index d586f038fb..9723dfaa3f 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit d586f038fb3b851398909904fc969e5b6755cd4a +Subproject commit 9723dfaa3fb882143b9904d59bcc09ee1af7bd5d From a86cfded2ac683610281ebf376c91257bda36bb6 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 23 Sep 2024 13:11:36 -0400 Subject: [PATCH 103/143] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 17894c11fb..f672c8ef43 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 17894c11fbc0f189b1f725b6c736aefc115ce566 +Subproject commit f672c8ef43893b207829dd2b1445c89501409ab9 From 0389cd676082ca9d6c6aa4082d32c2a77a73fd16 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Mon, 23 Sep 2024 14:45:12 -0400 Subject: [PATCH 104/143] Fix a compile issue on HTML5 with video sprites --- art | 2 +- source/funkin/graphics/video/FunkinVideoSprite.hx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/art b/art index bfca2ea98d..1f64f3e740 160000 --- a/art +++ b/art @@ -1 +1 @@ -Subproject commit bfca2ea98d11a0f4dee4a27b9390951fbc5701ea +Subproject commit 1f64f3e7403a090b164f4442d10152b2be5d3d0a diff --git a/source/funkin/graphics/video/FunkinVideoSprite.hx b/source/funkin/graphics/video/FunkinVideoSprite.hx index e0086784bd..2b7f42c039 100644 --- a/source/funkin/graphics/video/FunkinVideoSprite.hx +++ b/source/funkin/graphics/video/FunkinVideoSprite.hx @@ -1,5 +1,6 @@ package funkin.graphics.video; +#if hxcodec import hxcodec.flixel.FlxVideoSprite; /** @@ -30,3 +31,4 @@ class FunkinVideoSprite extends FlxVideoSprite return volume; } } +#end From 52f5c24f9696d30eb68cc4110f3852374e1b388b Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Mon, 23 Sep 2024 16:09:34 -0400 Subject: [PATCH 105/143] Add frame market support, and enable on demand tracing. --- project.hxp | 2 +- source/funkin/util/WindowUtil.hx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/project.hxp b/project.hxp index 74402016fd..73a12538a7 100644 --- a/project.hxp +++ b/project.hxp @@ -537,7 +537,7 @@ class Project extends HXProject { setHaxedef("HXCPP_TELEMETRY"); // Enable telemetry setHaxedef("HXCPP_TRACY"); // Enable Tracy telemetry setHaxedef("HXCPP_TRACY_MEMORY"); // Track memory allocations - // setHaxedef("HXCPP_TRACY_ON_DEMAND"); // Only collect telemetry when Tracy is open and reachable + setHaxedef("HXCPP_TRACY_ON_DEMAND"); // Only collect telemetry when Tracy is open and reachable // setHaxedef("HXCPP_TRACY_INCLUDE_CALLSTACKS"); // Inspect callstacks per zone, inflating telemetry data setHaxedef("absolute-paths"); // Fix source locations so Tracy can see them diff --git a/source/funkin/util/WindowUtil.hx b/source/funkin/util/WindowUtil.hx index 0fe63fe324..d9d43614ac 100644 --- a/source/funkin/util/WindowUtil.hx +++ b/source/funkin/util/WindowUtil.hx @@ -91,6 +91,14 @@ class WindowUtil windowExit.dispatch(exitCode); }); + #if FEATURE_DEBUG_TRACY + // Apply a marker to indicate frame end for the Tracy profiler. + // Do this only if Tracy is configured to prevent lag. + openfl.Lib.current.stage.addEventListener(openfl.events.Event.EXIT_FRAME, (e:openfl.events.Event) -> { + cpp.vm.tracy.TracyProfiler.frameMark(); + }); + #end + openfl.Lib.current.stage.addEventListener(openfl.events.KeyboardEvent.KEY_DOWN, (e:openfl.events.KeyboardEvent) -> { for (key in PlayerSettings.player1.controls.getKeysForAction(WINDOW_FULLSCREEN)) { From 7e7530842393e661771c7689dbc405ea391d7e3d Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 23 Sep 2024 18:51:48 -0400 Subject: [PATCH 106/143] capitalization hxCodec --- source/funkin/graphics/video/FunkinVideoSprite.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/graphics/video/FunkinVideoSprite.hx b/source/funkin/graphics/video/FunkinVideoSprite.hx index 2b7f42c039..356699b4d7 100644 --- a/source/funkin/graphics/video/FunkinVideoSprite.hx +++ b/source/funkin/graphics/video/FunkinVideoSprite.hx @@ -1,6 +1,6 @@ package funkin.graphics.video; -#if hxcodec +#if hxCodec import hxcodec.flixel.FlxVideoSprite; /** From ec9b5db2109ab39ed90f5e1d291de35471128884 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Mon, 23 Sep 2024 21:41:48 -0400 Subject: [PATCH 107/143] Create shader for Week 5 once and reuse it rather than recreating it every frame. --- assets | 2 +- source/funkin/graphics/shaders/AdjustColorShader.hx | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/assets b/assets index f672c8ef43..8140f8255c 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit f672c8ef43893b207829dd2b1445c89501409ab9 +Subproject commit 8140f8255c0db78135dbfa7b6d329f52c363f51b diff --git a/source/funkin/graphics/shaders/AdjustColorShader.hx b/source/funkin/graphics/shaders/AdjustColorShader.hx index a6efc3e659..cd3ac228b0 100644 --- a/source/funkin/graphics/shaders/AdjustColorShader.hx +++ b/source/funkin/graphics/shaders/AdjustColorShader.hx @@ -50,4 +50,9 @@ class AdjustColorShader extends FlxRuntimeShader return this.contrast; } + + public override function toString():String + { + return 'AdjustColorShader(${this.hue}, ${this.saturation}, ${this.brightness}, ${this.contrast})'; + } } From 84d8c029208a4a94ba3fd78f3c5812edf39e2514 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 25 Sep 2024 00:39:37 -0400 Subject: [PATCH 108/143] Update art repo --- art | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/art b/art index bfca2ea98d..cc347f5630 160000 --- a/art +++ b/art @@ -1 +1 @@ -Subproject commit bfca2ea98d11a0f4dee4a27b9390951fbc5701ea +Subproject commit cc347f5630dc8182e62990c66753940a275202f8 From 5693d626b590bf00f3569e88e90f7475fb43c310 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 25 Sep 2024 03:58:43 -0400 Subject: [PATCH 109/143] Update so that album art works. --- art | 2 +- source/funkin/api/discord/DiscordClient.hx | 8 +++++-- source/funkin/play/PlayState.hx | 25 +++++++++++++++++++--- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/art b/art index cc347f5630..fbd3e3df77 160000 --- a/art +++ b/art @@ -1 +1 @@ -Subproject commit cc347f5630dc8182e62990c66753940a275202f8 +Subproject commit fbd3e3df77734606d88516770b71b56e6fa04bce diff --git a/source/funkin/api/discord/DiscordClient.hx b/source/funkin/api/discord/DiscordClient.hx index 3b6e891d3e..3be2d4c879 100644 --- a/source/funkin/api/discord/DiscordClient.hx +++ b/source/funkin/api/discord/DiscordClient.hx @@ -7,7 +7,7 @@ import sys.thread.Thread; class DiscordClient { - static final CLIENT_ID:String = "814588678700924999"; + static final CLIENT_ID:String = "816168432860790794"; public static var instance(get, never):DiscordClient; static var _instance:Null = null; @@ -96,13 +96,17 @@ class DiscordClient // The large image displaying what the user is doing. // This should probably be album art. // IMPORTANT NOTE: This can be an asset key uploaded to Discord's developer panel OR any URL you like. + presence.largeImageKey = cast(params.largeImageKey, Null) ?? "album-volume1"; + + trace('[DISCORD] largeImageKey: ${presence.largeImageKey}'); // TODO: Make this use the song's album art. // presence.largeImageKey = "icon"; - presence.largeImageKey = "https://f4.bcbits.com/img/a0746694746_16.jpg"; + // presence.largeImageKey = "https://f4.bcbits.com/img/a0746694746_16.jpg"; // The small inset image for what the user is doing. // This can be the opponent's health icon? + // NOTE: Like largeImageKey, this can be a URL, or an asset key. presence.smallImageKey = cast(params.smallImageKey, Null); // NOTE: In previous versions, this showed as "Elapsed", but now shows as playtime and doesn't look good diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index aeba619ffc..e544df3412 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -447,6 +447,7 @@ class PlayState extends MusicBeatSubState #if FEATURE_DISCORD_RPC // Discord RPC variables + var discordRPCAlbum:String = ''; var discordRPCIcon:String = ''; #end @@ -987,6 +988,7 @@ class PlayState extends MusicBeatSubState state: buildDiscordRPCState(), + largeImageKey: discordRPCAlbum, smallImageKey: discordRPCIcon }); #end @@ -1081,6 +1083,8 @@ class PlayState extends MusicBeatSubState { details: 'Game Over - ${buildDiscordRPCDetails()}', state: buildDiscordRPCState(), + + largeImageKey: discordRPCAlbum, smallImageKey: discordRPCIcon }); #end @@ -1300,7 +1304,9 @@ class PlayState extends MusicBeatSubState DiscordClient.instance.setPresence( { state: buildDiscordRPCState(), - details: 'Paused - ${buildDiscordRPCDetails()}', + details: buildDiscordRPCDetails(), + + largeImageKey: discordRPCAlbum, smallImageKey: discordRPCIcon }); } @@ -1309,7 +1315,9 @@ class PlayState extends MusicBeatSubState DiscordClient.instance.setPresence( { state: buildDiscordRPCState(), - details: 'Paused - ${buildDiscordRPCDetails()}', + details: buildDiscordRPCDetails(), + + largeImageKey: discordRPCAlbum, smallImageKey: discordRPCIcon }); } @@ -1345,6 +1353,8 @@ class PlayState extends MusicBeatSubState { state: buildDiscordRPCState(), details: buildDiscordRPCDetails(), + + largeImageKey: discordRPCAlbum, smallImageKey: discordRPCIcon }); } @@ -1354,6 +1364,8 @@ class PlayState extends MusicBeatSubState { state: buildDiscordRPCState(), details: buildDiscordRPCDetails(), + + largeImageKey: discordRPCAlbum, smallImageKey: discordRPCIcon }); // DiscordClient.changePresence(detailsText, '${currentChart.songName} ($discordRPCDifficulty)', discordRPCIcon, true, @@ -1381,6 +1393,8 @@ class PlayState extends MusicBeatSubState { state: buildDiscordRPCState(), details: buildDiscordRPCDetails(), + + largeImageKey: discordRPCAlbum, smallImageKey: discordRPCIcon }); } @@ -1681,7 +1695,8 @@ class PlayState extends MusicBeatSubState iconP2.cameras = [camHUD]; #if FEATURE_DISCORD_RPC - discordRPCIcon = currentCharacterData.opponent; + discordRPCAlbum = 'album-${currentChart.album}'; + discordRPCIcon = 'icon-${currentCharacterData.opponent}'; #end } @@ -1807,6 +1822,8 @@ class PlayState extends MusicBeatSubState { state: buildDiscordRPCState(), details: buildDiscordRPCDetails(), + + largeImageKey: discordRPCAlbum, smallImageKey: discordRPCIcon }); #end @@ -2040,6 +2057,8 @@ class PlayState extends MusicBeatSubState { state: buildDiscordRPCState(), details: buildDiscordRPCDetails(), + + largeImageKey: discordRPCAlbum, smallImageKey: discordRPCIcon }); // DiscordClient.changePresence(detailsText, '${currentChart.songName} ($discordRPCDifficulty)', discordRPCIcon, true, currentSongLengthMs); From 8d02a3f98461c378302a3761d009c12a9a5fb024 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 25 Sep 2024 08:39:57 -0400 Subject: [PATCH 110/143] A bunch of controls fixes --- project.hxp | 10 +++ source/funkin/InitState.hx | 4 +- source/funkin/input/Controls.hx | 78 ++++++++++++++----- source/funkin/play/PlayState.hx | 6 +- source/funkin/ui/options/ControlsMenu.hx | 13 +++- .../funkin/util/plugins/ScreenshotPlugin.hx | 4 + 6 files changed, 91 insertions(+), 24 deletions(-) diff --git a/project.hxp b/project.hxp index 1a21989971..eaabf9d300 100644 --- a/project.hxp +++ b/project.hxp @@ -214,6 +214,12 @@ class Project extends HXProject { */ static final FEATURE_OPEN_URL:FeatureFlag = "FEATURE_OPEN_URL"; + /** + * `-DFEATURE_SCREENSHOTS` + * If this flag is enabled, the game will support the screenshots feature. + */ + static final FEATURE_SCREENSHOTS:FeatureFlag = "FEATURE_SCREENSHOTS"; + /** * `-DFEATURE_CHART_EDITOR` * If this flag is enabled, the Chart Editor will be accessible from the debug menu. @@ -494,6 +500,10 @@ class Project extends HXProject { // Should be true except on web builds. // Chart editor doesn't work there. FEATURE_CHART_EDITOR.apply(this, !isWeb()); + + // Should be true except on web builds. + // Screenshots doesn't work there. + FEATURE_SCREENSHOTS.apply(this, !isWeb()); } /** diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index f71de00f4a..30a6d253ab 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -148,10 +148,12 @@ class InitState extends FlxState #if FEATURE_DEBUG_FUNCTIONS funkin.util.plugins.MemoryGCPlugin.initialize(); #end + #if FEATURE_SCREENSHOTS + funkin.util.plugins.ScreenshotPlugin.initialize(); + #end funkin.util.plugins.EvacuateDebugPlugin.initialize(); funkin.util.plugins.ForceCrashPlugin.initialize(); funkin.util.plugins.ReloadAssetsDebugPlugin.initialize(); - funkin.util.plugins.ScreenshotPlugin.initialize(); funkin.util.plugins.VolumePlugin.initialize(); funkin.util.plugins.WatchPlugin.initialize(); diff --git a/source/funkin/input/Controls.hx b/source/funkin/input/Controls.hx index da5aaac58f..ab1d0e0a7e 100644 --- a/source/funkin/input/Controls.hx +++ b/source/funkin/input/Controls.hx @@ -59,7 +59,9 @@ class Controls extends FlxActionSet var _back = new FunkinAction(Action.BACK); var _pause = new FunkinAction(Action.PAUSE); var _reset = new FunkinAction(Action.RESET); + #if FEATURE_SCREENSHOTS var _window_screenshot = new FunkinAction(Action.WINDOW_SCREENSHOT); + #end var _window_fullscreen = new FunkinAction(Action.WINDOW_FULLSCREEN); var _freeplay_favorite = new FunkinAction(Action.FREEPLAY_FAVORITE); var _freeplay_left = new FunkinAction(Action.FREEPLAY_LEFT); @@ -67,8 +69,12 @@ class Controls extends FlxActionSet var _freeplay_char_select = new FunkinAction(Action.FREEPLAY_CHAR_SELECT); var _cutscene_advance = new FunkinAction(Action.CUTSCENE_ADVANCE); var _debug_menu = new FunkinAction(Action.DEBUG_MENU); + #if FEATURE_CHART_EDITOR var _debug_chart = new FunkinAction(Action.DEBUG_CHART); + #end + #if FEATURE_STAGE_EDITOR var _debug_stage = new FunkinAction(Action.DEBUG_STAGE); + #end var _volume_up = new FunkinAction(Action.VOLUME_UP); var _volume_down = new FunkinAction(Action.VOLUME_DOWN); var _volume_mute = new FunkinAction(Action.VOLUME_MUTE); @@ -243,10 +249,12 @@ class Controls extends FlxActionSet inline function get_WINDOW_FULLSCREEN() return _window_fullscreen.check(); + #if FEATURE_SCREENSHOTS public var WINDOW_SCREENSHOT(get, never):Bool; inline function get_WINDOW_SCREENSHOT() return _window_screenshot.check(); + #end public var FREEPLAY_FAVORITE(get, never):Bool; @@ -278,15 +286,19 @@ class Controls extends FlxActionSet inline function get_DEBUG_MENU() return _debug_menu.check(); + #if FEATURE_CHART_EDITOR public var DEBUG_CHART(get, never):Bool; inline function get_DEBUG_CHART() return _debug_chart.check(); + #end + #if FEATURE_STAGE_EDITOR public var DEBUG_STAGE(get, never):Bool; inline function get_DEBUG_STAGE() return _debug_stage.check(); + #end public var VOLUME_UP(get, never):Bool; @@ -319,7 +331,7 @@ class Controls extends FlxActionSet add(_back); add(_pause); add(_reset); - add(_window_screenshot); + #if FEATURE_SCREENSHOTS add(_window_screenshot); #end add(_window_fullscreen); add(_freeplay_favorite); add(_freeplay_left); @@ -327,8 +339,8 @@ class Controls extends FlxActionSet add(_freeplay_char_select); add(_cutscene_advance); add(_debug_menu); - add(_debug_chart); - add(_debug_stage); + #if FEATURE_CHART_EDITOR add(_debug_chart); #end + #if FEATURE_STAGE_EDITOR add(_debug_stage); #end add(_volume_up); add(_volume_down); add(_volume_mute); @@ -444,7 +456,7 @@ class Controls extends FlxActionSet case BACK: _back; case PAUSE: _pause; case RESET: _reset; - case WINDOW_SCREENSHOT: _window_screenshot; + #if FEATURE_SCREENSHOTS case WINDOW_SCREENSHOT: _window_screenshot; #end case WINDOW_FULLSCREEN: _window_fullscreen; case FREEPLAY_FAVORITE: _freeplay_favorite; case FREEPLAY_LEFT: _freeplay_left; @@ -452,8 +464,8 @@ class Controls extends FlxActionSet case FREEPLAY_CHAR_SELECT: _freeplay_char_select; case CUTSCENE_ADVANCE: _cutscene_advance; case DEBUG_MENU: _debug_menu; - case DEBUG_CHART: _debug_chart; - case DEBUG_STAGE: _debug_stage; + #if FEATURE_CHART_EDITOR case DEBUG_CHART: _debug_chart; #end + #if FEATURE_STAGE_EDITOR case DEBUG_STAGE: _debug_stage; #end case VOLUME_UP: _volume_up; case VOLUME_DOWN: _volume_down; case VOLUME_MUTE: _volume_mute; @@ -516,8 +528,10 @@ class Controls extends FlxActionSet func(_pause, JUST_PRESSED); case RESET: func(_reset, JUST_PRESSED); + #if FEATURE_SCREENSHOTS case WINDOW_SCREENSHOT: func(_window_screenshot, JUST_PRESSED); + #end case WINDOW_FULLSCREEN: func(_window_fullscreen, JUST_PRESSED); case FREEPLAY_FAVORITE: @@ -532,10 +546,14 @@ class Controls extends FlxActionSet func(_cutscene_advance, JUST_PRESSED); case DEBUG_MENU: func(_debug_menu, JUST_PRESSED); + #if FEATURE_CHART_EDITOR case DEBUG_CHART: func(_debug_chart, JUST_PRESSED); + #end + #if FEATURE_STAGE_EDITOR case DEBUG_STAGE: func(_debug_stage, JUST_PRESSED); + #end case VOLUME_UP: func(_volume_up, JUST_PRESSED); case VOLUME_DOWN: @@ -744,7 +762,9 @@ class Controls extends FlxActionSet bindKeys(Control.BACK, getDefaultKeybinds(scheme, Control.BACK)); bindKeys(Control.PAUSE, getDefaultKeybinds(scheme, Control.PAUSE)); bindKeys(Control.RESET, getDefaultKeybinds(scheme, Control.RESET)); + #if FEATURE_SCREENSHOTS bindKeys(Control.WINDOW_SCREENSHOT, getDefaultKeybinds(scheme, Control.WINDOW_SCREENSHOT)); + #end bindKeys(Control.WINDOW_FULLSCREEN, getDefaultKeybinds(scheme, Control.WINDOW_FULLSCREEN)); bindKeys(Control.FREEPLAY_FAVORITE, getDefaultKeybinds(scheme, Control.FREEPLAY_FAVORITE)); bindKeys(Control.FREEPLAY_LEFT, getDefaultKeybinds(scheme, Control.FREEPLAY_LEFT)); @@ -752,8 +772,12 @@ class Controls extends FlxActionSet bindKeys(Control.FREEPLAY_CHAR_SELECT, getDefaultKeybinds(scheme, Control.FREEPLAY_CHAR_SELECT)); bindKeys(Control.CUTSCENE_ADVANCE, getDefaultKeybinds(scheme, Control.CUTSCENE_ADVANCE)); bindKeys(Control.DEBUG_MENU, getDefaultKeybinds(scheme, Control.DEBUG_MENU)); + #if FEATURE_CHART_EDITOR bindKeys(Control.DEBUG_CHART, getDefaultKeybinds(scheme, Control.DEBUG_CHART)); + #end + #if FEATURE_STAGE_EDITOR bindKeys(Control.DEBUG_STAGE, getDefaultKeybinds(scheme, Control.DEBUG_STAGE)); + #end bindKeys(Control.VOLUME_UP, getDefaultKeybinds(scheme, Control.VOLUME_UP)); bindKeys(Control.VOLUME_DOWN, getDefaultKeybinds(scheme, Control.VOLUME_DOWN)); bindKeys(Control.VOLUME_MUTE, getDefaultKeybinds(scheme, Control.VOLUME_MUTE)); @@ -781,15 +805,15 @@ class Controls extends FlxActionSet case Control.PAUSE: return [P, ENTER, ESCAPE]; case Control.RESET: return [R]; case Control.WINDOW_FULLSCREEN: return [F11]; // We use F for other things LOL. - case Control.WINDOW_SCREENSHOT: return [F3]; + #if FEATURE_SCREENSHOTS case Control.WINDOW_SCREENSHOT: return [F3]; #end case Control.FREEPLAY_FAVORITE: return [F]; // Favorite a song on the menu case Control.FREEPLAY_LEFT: return [Q]; // Switch tabs on the menu case Control.FREEPLAY_RIGHT: return [E]; // Switch tabs on the menu case Control.FREEPLAY_CHAR_SELECT: return [TAB]; case Control.CUTSCENE_ADVANCE: return [Z, ENTER]; case Control.DEBUG_MENU: return [GRAVEACCENT]; - case Control.DEBUG_CHART: return []; - case Control.DEBUG_STAGE: return []; + #if FEATURE_CHART_EDITOR case Control.DEBUG_CHART: return []; #end + #if FEATURE_STAGE_EDITOR case Control.DEBUG_STAGE: return []; #end case Control.VOLUME_UP: return [PLUS, NUMPADPLUS]; case Control.VOLUME_DOWN: return [MINUS, NUMPADMINUS]; case Control.VOLUME_MUTE: return [ZERO, NUMPADZERO]; @@ -809,7 +833,7 @@ class Controls extends FlxActionSet case Control.BACK: return [H, X]; case Control.PAUSE: return [ONE]; case Control.RESET: return [R]; - case Control.WINDOW_SCREENSHOT: return [F3]; + #if FEATURE_SCREENSHOTS case Control.WINDOW_SCREENSHOT: return [F3]; #end case Control.WINDOW_FULLSCREEN: return [F11]; case Control.FREEPLAY_FAVORITE: return [F]; // Favorite a song on the menu case Control.FREEPLAY_LEFT: return [Q]; // Switch tabs on the menu @@ -817,8 +841,8 @@ class Controls extends FlxActionSet case Control.FREEPLAY_CHAR_SELECT: return [TAB]; case Control.CUTSCENE_ADVANCE: return [G, Z]; case Control.DEBUG_MENU: return [GRAVEACCENT]; - case Control.DEBUG_CHART: return []; - case Control.DEBUG_STAGE: return []; + #if FEATURE_CHART_EDITOR case Control.DEBUG_CHART: return []; #end + #if FEATURE_STAGE_EDITOR case Control.DEBUG_STAGE: return []; #end case Control.VOLUME_UP: return [PLUS]; case Control.VOLUME_DOWN: return [MINUS]; case Control.VOLUME_MUTE: return [ZERO]; @@ -838,7 +862,7 @@ class Controls extends FlxActionSet case Control.BACK: return [ESCAPE]; case Control.PAUSE: return [ONE]; case Control.RESET: return [R]; - case Control.WINDOW_SCREENSHOT: return []; + #if FEATURE_SCREENSHOTS case Control.WINDOW_SCREENSHOT: return []; #end case Control.WINDOW_FULLSCREEN: return []; case Control.FREEPLAY_FAVORITE: return []; case Control.FREEPLAY_LEFT: return []; @@ -846,8 +870,8 @@ class Controls extends FlxActionSet case Control.FREEPLAY_CHAR_SELECT: return []; case Control.CUTSCENE_ADVANCE: return [ENTER]; case Control.DEBUG_MENU: return []; - case Control.DEBUG_CHART: return []; - case Control.DEBUG_STAGE: return []; + #if FEATURE_CHART_EDITOR case Control.DEBUG_CHART: return []; #end + #if FEATURE_STAGE_EDITOR case Control.DEBUG_STAGE: return []; #end case Control.VOLUME_UP: return [NUMPADPLUS]; case Control.VOLUME_DOWN: return [NUMPADMINUS]; case Control.VOLUME_MUTE: return [NUMPADZERO]; @@ -952,7 +976,9 @@ class Controls extends FlxActionSet Control.PAUSE => getDefaultGamepadBinds(Control.PAUSE), Control.RESET => getDefaultGamepadBinds(Control.RESET), Control.WINDOW_FULLSCREEN => getDefaultGamepadBinds(Control.WINDOW_FULLSCREEN), + #if FEATURE_SCREENSHOTS Control.WINDOW_SCREENSHOT => getDefaultGamepadBinds(Control.WINDOW_SCREENSHOT), + #end Control.CUTSCENE_ADVANCE => getDefaultGamepadBinds(Control.CUTSCENE_ADVANCE), Control.FREEPLAY_FAVORITE => getDefaultGamepadBinds(Control.FREEPLAY_FAVORITE), Control.FREEPLAY_LEFT => getDefaultGamepadBinds(Control.FREEPLAY_LEFT), @@ -961,8 +987,12 @@ class Controls extends FlxActionSet Control.VOLUME_DOWN => getDefaultGamepadBinds(Control.VOLUME_DOWN), Control.VOLUME_MUTE => getDefaultGamepadBinds(Control.VOLUME_MUTE), Control.DEBUG_MENU => getDefaultGamepadBinds(Control.DEBUG_MENU), + #if FEATURE_CHART_EDITOR Control.DEBUG_CHART => getDefaultGamepadBinds(Control.DEBUG_CHART), + #end + #if FEATURE_STAGE_EDITOR Control.DEBUG_STAGE => getDefaultGamepadBinds(Control.DEBUG_STAGE), + #end ]); } @@ -996,8 +1026,10 @@ class Controls extends FlxActionSet return [FlxGamepadInputID.BACK]; // Back (i.e. Select) case Control.WINDOW_FULLSCREEN: []; + #if FEATURE_SCREENSHOTS case Control.WINDOW_SCREENSHOT: []; + #end case Control.CUTSCENE_ADVANCE: return [A]; case Control.FREEPLAY_FAVORITE: @@ -1014,10 +1046,14 @@ class Controls extends FlxActionSet []; case Control.DEBUG_MENU: []; + #if FEATURE_CHART_EDITOR case Control.DEBUG_CHART: []; + #end + #if FEATURE_STAGE_EDITOR case Control.DEBUG_STAGE: []; + #end default: // Fallthrough. } @@ -1582,7 +1618,7 @@ enum Control FREEPLAY_RIGHT; FREEPLAY_CHAR_SELECT; // WINDOW - WINDOW_SCREENSHOT; + #if FEATURE_SCREENSHOTS WINDOW_SCREENSHOT; #end WINDOW_FULLSCREEN; // VOLUME VOLUME_UP; @@ -1590,8 +1626,8 @@ enum Control VOLUME_MUTE; // DEBUG DEBUG_MENU; - DEBUG_CHART; - DEBUG_STAGE; + #if FEATURE_CHART_EDITOR DEBUG_CHART; #end + #if FEATURE_STAGE_EDITOR DEBUG_STAGE; #end } enum abstract Action(String) to String from String @@ -1628,7 +1664,9 @@ enum abstract Action(String) to String from String var RESET = "reset"; // WINDOW var WINDOW_FULLSCREEN = "window_fullscreen"; + #if FEATURE_SCREENSHOTS var WINDOW_SCREENSHOT = "window_screenshot"; + #end // CUTSCENE var CUTSCENE_ADVANCE = "cutscene_advance"; // FREEPLAY @@ -1642,8 +1680,12 @@ enum abstract Action(String) to String from String var VOLUME_MUTE = "volume_mute"; // DEBUG var DEBUG_MENU = "debug_menu"; + #if FEATURE_CHART_EDITOR var DEBUG_CHART = "debug_chart"; + #end + #if FEATURE_STAGE_EDITOR var DEBUG_STAGE = "debug_stage"; + #end } enum Device diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 2fcdaddf5f..206356e3d3 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -2578,7 +2578,7 @@ class PlayState extends MusicBeatSubState */ function debugKeyShit():Void { - #if FEATURE_CHART_EDITOR + #if FEATURE_STAGE_EDITOR // Open the stage editor overlaying the current state. if (controls.DEBUG_STAGE) { @@ -2587,7 +2587,9 @@ class PlayState extends MusicBeatSubState persistentUpdate = false; openSubState(new StageOffsetSubState()); } + #end + #if FEATURE_CHART_EDITOR // Redirect to the chart editor playing the current song. if (controls.DEBUG_CHART) { @@ -2595,11 +2597,13 @@ class PlayState extends MusicBeatSubState persistentUpdate = false; if (isChartingMode) { + // Close the playtest substate. FlxG.sound.music?.pause(); this.close(); } else { + // Move to the chart editor. FlxG.switchState(() -> new ChartEditorState( { targetSongId: currentSong.id, diff --git a/source/funkin/ui/options/ControlsMenu.hx b/source/funkin/ui/options/ControlsMenu.hx index 1f40a84556..3d68485a5f 100644 --- a/source/funkin/ui/options/ControlsMenu.hx +++ b/source/funkin/ui/options/ControlsMenu.hx @@ -28,10 +28,14 @@ class ControlsMenu extends funkin.ui.options.OptionsState.Page [NOTE_UP, NOTE_DOWN, NOTE_LEFT, NOTE_RIGHT], [UI_UP, UI_DOWN, UI_LEFT, UI_RIGHT, ACCEPT, BACK], [CUTSCENE_ADVANCE], - [FREEPLAY_FAVORITE, FREEPLAY_LEFT, FREEPLAY_RIGHT], - [WINDOW_FULLSCREEN, WINDOW_SCREENSHOT], + [FREEPLAY_FAVORITE, FREEPLAY_LEFT, FREEPLAY_RIGHT, FREEPLAY_CHAR_SELECT], + [WINDOW_FULLSCREEN, #if FEATURE_SCREENSHOTS WINDOW_SCREENSHOT, #end], [VOLUME_UP, VOLUME_DOWN, VOLUME_MUTE], - [DEBUG_MENU, DEBUG_CHART] + [ + DEBUG_MENU, + #if FEATURE_CHART_EDITOR DEBUG_CHART, #end + #if FEATURE_STAGE_EDITOR DEBUG_STAGE, #end + ] ]; var itemGroups:Array> = [for (i in 0...controlGroups.length) []]; @@ -137,7 +141,8 @@ class ControlsMenu extends funkin.ui.options.OptionsState.Page if (currentHeader != null && name.indexOf(currentHeader) == 0) name = name.substr(currentHeader.length); - var label = labels.add(new AtlasText(100, y, name, AtlasFont.BOLD)); + var formatName = name.replace('_', ' '); + var label = labels.add(new AtlasText(100, y, formatName, AtlasFont.BOLD)); label.alpha = 0.6; for (i in 0...COLUMNS) createItem(label.x + 550 + i * 400, y, control, i); diff --git a/source/funkin/util/plugins/ScreenshotPlugin.hx b/source/funkin/util/plugins/ScreenshotPlugin.hx index c859710dec..dcd82ecc5f 100644 --- a/source/funkin/util/plugins/ScreenshotPlugin.hx +++ b/source/funkin/util/plugins/ScreenshotPlugin.hx @@ -103,7 +103,11 @@ class ScreenshotPlugin extends FlxBasic public function hasPressedScreenshot():Bool { + #if FEATURE_SCREENSHOTS return PlayerSettings.player1.controls.WINDOW_SCREENSHOT; + #else + return false; + #end } public function updatePreferences():Void From a84ae6069ecfc267e2443e4d241e3eb6309226bf Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 25 Sep 2024 10:02:11 -0400 Subject: [PATCH 111/143] Fix an issue where Pico wouldn't shoot in Stress --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 8140f8255c..8706229c95 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 8140f8255c0db78135dbfa7b6d329f52c363f51b +Subproject commit 8706229c95fbebab5a10093223bceefec03e2f7f From 67126b33fa1f92724092cd73171ab4f1144fc6ef Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 25 Sep 2024 10:02:18 -0400 Subject: [PATCH 112/143] Suppress some spammy log calls --- source/funkin/play/PlayState.hx | 4 ++-- source/funkin/play/character/BaseCharacter.hx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 2fcdaddf5f..6f908512b4 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1976,8 +1976,8 @@ class PlayState extends MusicBeatSubState vocals.volume = 1.0; vocals.pitch = playbackRate; vocals.time = FlxG.sound.music.time; - trace('${FlxG.sound.music.time}'); - trace('${vocals.time}'); + // trace('${FlxG.sound.music.time}'); + // trace('${vocals.time}'); resyncVocals(); #if FEATURE_DISCORD_RPC diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index 365c8d112b..d87aca9f3f 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -305,7 +305,7 @@ class BaseCharacter extends Bopper { super.onAnimationFinished(animationName); - trace('${characterId} has finished animation: ${animationName}'); + // trace('${characterId} has finished animation: ${animationName}'); if ((animationName.endsWith(Constants.ANIMATION_END_SUFFIX) && !animationName.startsWith('idle') && !animationName.startsWith('dance')) || animationName.startsWith('combo') || animationName.startsWith('drop')) @@ -402,7 +402,7 @@ class BaseCharacter extends Bopper FlxG.watch.addQuick('singTimeSec-${characterId}', singTimeSec); if (holdTimer > singTimeSec && shouldStopSinging) { - trace('holdTimer reached ${holdTimer}sec (> ${singTimeSec}), stopping sing animation'); + // trace('holdTimer reached ${holdTimer}sec (> ${singTimeSec}), stopping sing animation'); holdTimer = 0; var currentAnimation:String = getCurrentAnimation(); @@ -636,7 +636,7 @@ class BaseCharacter extends Bopper var anim:String = 'sing${dir.nameUpper}${miss ? 'miss' : ''}${suffix != '' ? '-${suffix}' : ''}'; // restart even if already playing, because the character might sing the same note twice. - trace('Playing ${anim}...'); + // trace('Playing ${anim}...'); playAnimation(anim, true); } From ffd76963bd736195ce23f2526acdbbbea6513da1 Mon Sep 17 00:00:00 2001 From: Abnormal <86753001+AbnormalPoof@users.noreply.github.com> Date: Thu, 26 Sep 2024 21:04:23 +0000 Subject: [PATCH 113/143] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b1e16f6de6..34ec930f62 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Please check out our [Contributor's guide](./CONTRIBUTORS.md) on how you can act # Credits and Special Thanks -Full credits can be found in-game, or wherever the credits.json file is. +Full credits can be found in-game, or in the `credits.json` file which is located [here](https://github.com/FunkinCrew/funkin.assets/blob/main/exclude/data/credits.json). ## Programming - [ninjamuffin99](https://twitter.com/ninja_muffin99) - Lead Programmer From 2053f0d6913e32c816b208390dfd3aab59e74bbd Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 27 Sep 2024 02:51:31 -0400 Subject: [PATCH 114/143] Fix a missing import in Pico (Blazin) --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 8140f8255c..962e3d3a14 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 8140f8255c0db78135dbfa7b6d329f52c363f51b +Subproject commit 962e3d3a1439b64056333b350278d367510cd235 From c4ed31b246a2a204b0c09d705d63a400fca72c8d Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 27 Sep 2024 02:52:01 -0400 Subject: [PATCH 115/143] Fix a bug where force-ending a song could occasionally try to draw destroyed sprites. --- source/funkin/play/PlayState.hx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 6678cfc3cc..7a2b099e4f 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -817,6 +817,7 @@ class PlayState extends MusicBeatSubState } else { + this.remove(currentStage); FlxG.switchState(() -> new MainMenuState()); } return false; @@ -965,6 +966,7 @@ class PlayState extends MusicBeatSubState // It's a reference to Gitaroo Man, which doesn't let you pause the game. if (!isSubState && event.gitaroo) { + this.remove(currentStage); FlxG.switchState(() -> new GitarooPause( { targetSong: currentSong, @@ -1366,6 +1368,7 @@ class PlayState extends MusicBeatSubState { funkin.modding.PolymodHandler.forceReloadAssets(); lastParams.targetSong = SongRegistry.instance.fetchEntry(currentSong.id); + this.remove(currentStage); LoadingState.loadPlayState(lastParams); } @@ -2600,6 +2603,7 @@ class PlayState extends MusicBeatSubState } else { + this.remove(currentStage); FlxG.switchState(() -> new ChartEditorState( { targetSongId: currentSong.id, @@ -2949,6 +2953,7 @@ class PlayState extends MusicBeatSubState { targetVariation = targetSong.getFirstValidVariation(PlayStatePlaylist.campaignDifficulty) ?? Constants.DEFAULT_VARIATION; } + this.remove(currentStage); LoadingState.loadPlayState( { targetSong: targetSong, @@ -2966,6 +2971,7 @@ class PlayState extends MusicBeatSubState { targetVariation = targetSong.getFirstValidVariation(PlayStatePlaylist.campaignDifficulty) ?? Constants.DEFAULT_VARIATION; } + this.remove(currentStage); LoadingState.loadPlayState( { targetSong: targetSong, From e321861b9fce1ead530c913ad7b034c604677d3d Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 27 Sep 2024 03:09:59 -0400 Subject: [PATCH 116/143] Fix an issue where animations wouldn't loop properly on AnimateAtlasCharacters. --- source/funkin/play/character/AnimateAtlasCharacter.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/play/character/AnimateAtlasCharacter.hx b/source/funkin/play/character/AnimateAtlasCharacter.hx index b78aed983e..22af05b242 100644 --- a/source/funkin/play/character/AnimateAtlasCharacter.hx +++ b/source/funkin/play/character/AnimateAtlasCharacter.hx @@ -147,7 +147,7 @@ class AnimateAtlasCharacter extends BaseCharacter if (getAnimationData() != null && getAnimationData().looped) { - playAnimation(prefix, true, false); + playAnimation(currentAnimName, true, false); } else { From f1c1e63375e0348df8b94cef6e5c990e6d788186 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 27 Sep 2024 12:19:41 -0400 Subject: [PATCH 117/143] Use more dynamic API version rules for checking mod versions. --- source/funkin/modding/PolymodHandler.hx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/source/funkin/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx index ec3acf3b3f..125882161b 100644 --- a/source/funkin/modding/PolymodHandler.hx +++ b/source/funkin/modding/PolymodHandler.hx @@ -27,11 +27,18 @@ import polymod.Polymod; class PolymodHandler { /** - * The API version that mods should comply with. - * Indicates which mods are compatible with this version of the game. + * The API version for the current version of the game. Since 0.5.0, we've just made this the game version! * Minor updates rarely impact mods but major versions often do. */ - static final API_VERSION:String = "0.5.0"; // Constants.VERSION; + // static final API_VERSION:String = Constants.VERSION; + + /** + * The Semantic Versioning rule + * Indicates which mods are compatible with this version of the game. + * Using more complex rules allows mods from older compatible versions to stay functioning, + * while preventing mods made for future versions from being installed. + */ + static final API_VERSION_RULE:String = ">=0.5.0 <0.6.0"; /** * Where relative to the executable that mods are located. @@ -131,7 +138,7 @@ class PolymodHandler // Framework being used to load assets. framework: OPENFL, // The current version of our API. - apiVersionRule: API_VERSION, + apiVersionRule: API_VERSION_RULE, // Call this function any time an error occurs. errorCallback: PolymodErrorHandler.onPolymodError, // Enforce semantic version patterns for each mod. @@ -338,7 +345,7 @@ class PolymodHandler var modMetadata:Array = Polymod.scan( { modRoot: MOD_FOLDER, - apiVersionRule: API_VERSION, + apiVersionRule: API_VERSION_RULE, fileSystem: modFileSystem, errorCallback: PolymodErrorHandler.onPolymodError }); From 378179d1f75dd64f5f02f93744b9c8a5ad6ab925 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 27 Sep 2024 12:20:36 -0400 Subject: [PATCH 118/143] Change crash keybind to Ctrl-Alt-Shift-L --- source/funkin/ui/mainmenu/MainMenuState.hx | 1 + source/funkin/util/plugins/ForceCrashPlugin.hx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/funkin/ui/mainmenu/MainMenuState.hx b/source/funkin/ui/mainmenu/MainMenuState.hx index 8ba85fbba8..ee6abc0843 100644 --- a/source/funkin/ui/mainmenu/MainMenuState.hx +++ b/source/funkin/ui/mainmenu/MainMenuState.hx @@ -362,6 +362,7 @@ class MainMenuState extends MusicBeatState // Ctrl+Alt+Shift+R = Score/Rank conflict test // Ctrl+Alt+Shift+N = Mark all characters as not seen // Ctrl+Alt+Shift+E = Dump save data + // Ctrl+Alt+Shift+L = Force crash and create a log dump if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.ALT && FlxG.keys.pressed.SHIFT && FlxG.keys.justPressed.P) { diff --git a/source/funkin/util/plugins/ForceCrashPlugin.hx b/source/funkin/util/plugins/ForceCrashPlugin.hx index e8094eb3c0..6f402c4e04 100644 --- a/source/funkin/util/plugins/ForceCrashPlugin.hx +++ b/source/funkin/util/plugins/ForceCrashPlugin.hx @@ -22,8 +22,8 @@ class ForceCrashPlugin extends FlxBasic { super.update(elapsed); - // Ctrl + Shift + L = Crash the game for debugging purposes - if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.SHIFT && FlxG.keys.pressed.L) + // Ctrl + Alt + Shift + L = Crash the game for debugging purposes + if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.ALT && FlxG.keys.pressed.SHIFT && FlxG.keys.pressed.L) { // TODO: Make this message 87% funnier. throw "DEBUG: Crashing the game via debug keybind!"; From b5f399623659bbb0342ff10169d0229359e07e99 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 27 Sep 2024 12:21:17 -0400 Subject: [PATCH 119/143] Properly sort difficulties/variations. Validate variation IDs (alphanumeric only) --- source/funkin/play/song/Song.hx | 53 +++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/source/funkin/play/song/Song.hx b/source/funkin/play/song/Song.hx index 9023b872e7..a6449bc103 100644 --- a/source/funkin/play/song/Song.hx +++ b/source/funkin/play/song/Song.hx @@ -156,6 +156,11 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry = fetchVariationMetadata(id, vari); if (variMeta != null) { @@ -407,7 +412,6 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry { - if (char == null) return variations; + if (char == null) + { + var result = variations; + result.sort(SortUtil.defaultsThenAlphabetically.bind(Constants.DEFAULT_VARIATION_LIST)); + return result; + } var result = []; trace('Evaluating variations for ${this.id} ${char.id}: ${this.variations}'); @@ -445,6 +454,8 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry = difficulties.keys() - .array() - .map(function(diffId:String):Null { - var difficulty:Null = difficulties.get(diffId); - if (difficulty == null) return null; - if (variationIds.length > 0 && !variationIds.contains(difficulty.variation)) return null; - return difficulty.difficulty; - }) + var diffFiltered:Array = variationIds.map(function(variationId:String):Array { + var metadata = _metadata.get(variationId); + return metadata?.playData?.difficulties ?? []; + }) + .flatten() .filterNull() .distinct(); @@ -489,11 +493,15 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry, ?showLocked:Bool, ?showHidden:Bool):Array { var result = []; @@ -509,6 +517,8 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry = SongRegistry.instance.parseEntryMetadataWithMigration(id, vari, version); return meta; } + + static final VARIATION_REGEX = ~/^[a-z][a-z0-9]+$/; + + /** + * Validate that the variation ID is valid. + * Auto-accept if it's one of the base game default variations. + * Reject if the ID starts with a number, or contains invalid characters. + */ + static function validateVariationId(variation:String):Bool { + if (Constants.DEFAULT_VARIATION_LIST.contains(variation)) return true; + + return VARIATION_REGEX.match(variation); + } } class SongDifficulty From 2eb5208c46e44a663ee18c43e729a02a3ff1728c Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 27 Sep 2024 14:25:17 -0400 Subject: [PATCH 120/143] Hide the pixel icon in the Results screen when there's no matching character --- source/funkin/ui/PixelatedIcon.hx | 5 +++++ source/funkin/ui/freeplay/SongMenuItem.hx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/source/funkin/ui/PixelatedIcon.hx b/source/funkin/ui/PixelatedIcon.hx index 4252c96958..71d5d74ab2 100644 --- a/source/funkin/ui/PixelatedIcon.hx +++ b/source/funkin/ui/PixelatedIcon.hx @@ -50,8 +50,13 @@ class PixelatedIcon extends FlxFilteredSprite if (!openfl.utils.Assets.exists(Paths.image(charPath))) { trace('[WARN] Character ${char} has no freeplay icon.'); + this.visible = false; return; } + else + { + this.visible = true; + } var isAnimated = openfl.utils.Assets.exists(Paths.file('images/$charPath.xml')); diff --git a/source/funkin/ui/freeplay/SongMenuItem.hx b/source/funkin/ui/freeplay/SongMenuItem.hx index 11ca44d541..864fa2d1d2 100644 --- a/source/funkin/ui/freeplay/SongMenuItem.hx +++ b/source/funkin/ui/freeplay/SongMenuItem.hx @@ -678,7 +678,7 @@ class SongMenuItem extends FlxSpriteGroup public function confirm():Void { if (songText != null) songText.flickerText(); - if (pixelIcon != null) + if (pixelIcon != null && pixelIcon.visible) { pixelIcon.animation.play('confirm'); } From 067f52ca914e6cb39d545af6838656388c526a31 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 27 Sep 2024 14:25:32 -0400 Subject: [PATCH 121/143] Kill intro music when leaving Results state. --- source/funkin/play/ResultState.hx | 34 ++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/source/funkin/play/ResultState.hx b/source/funkin/play/ResultState.hx index 33f3587eab..7a2a015b7d 100644 --- a/source/funkin/play/ResultState.hx +++ b/source/funkin/play/ResultState.hx @@ -74,6 +74,8 @@ class ResultState extends MusicBeatSubState var playerCharacterId:Null; + var introMusicAudio:Null; + var rankBg:FunkinSprite; final cameraBG:FunkinCamera; final cameraScroll:FunkinCamera; @@ -413,7 +415,8 @@ class ResultState extends MusicBeatSubState if (Assets.exists(introMusic)) { // Play the intro music. - FunkinSound.load(introMusic, 1.0, false, true, true, () -> { + introMusicAudio = FunkinSound.load(introMusic, 1.0, false, true, true, () -> { + introMusicAudio = null; FunkinSound.playMusic(getMusicPath(playerCharacter, rank), { startingVolume: 1.0, @@ -727,9 +730,34 @@ class ResultState extends MusicBeatSubState if (controls.PAUSE) { - if (FlxG.sound.music != null) + if (introMusicAudio != null) { + @:nullSafety(Off) + introMusicAudio.onComplete = null; + + FlxTween.tween(introMusicAudio, {volume: 0}, 0.8, { + onComplete: _ -> { + if (introMusicAudio != null) { + introMusicAudio.stop(); + introMusicAudio.destroy(); + introMusicAudio = null; + } + } + }); + FlxTween.tween(introMusicAudio, {pitch: 3}, 0.1, + { + onComplete: _ -> { + FlxTween.tween(introMusicAudio, {pitch: 0.5}, 0.4); + } + }); + } + else if (FlxG.sound.music != null) { - FlxTween.tween(FlxG.sound.music, {volume: 0}, 0.8); + FlxTween.tween(FlxG.sound.music, {volume: 0}, 0.8, { + onComplete: _ -> { + FlxG.sound.music.stop(); + FlxG.sound.music.destroy(); + } + }); FlxTween.tween(FlxG.sound.music, {pitch: 3}, 0.1, { onComplete: _ -> { From 5630e74584f1e34a9fecd5958b57b15d925573c5 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 27 Sep 2024 14:26:08 -0400 Subject: [PATCH 122/143] Rework Freeplay variation handling... again. --- .../funkin/play/notes/notestyle/NoteStyle.hx | 217 +++++++++--------- source/funkin/ui/freeplay/FreeplayState.hx | 131 +++++++---- source/funkin/util/Constants.hx | 5 + 3 files changed, 198 insertions(+), 155 deletions(-) diff --git a/source/funkin/play/notes/notestyle/NoteStyle.hx b/source/funkin/play/notes/notestyle/NoteStyle.hx index 3318e90860..dd08857512 100644 --- a/source/funkin/play/notes/notestyle/NoteStyle.hx +++ b/source/funkin/play/notes/notestyle/NoteStyle.hx @@ -34,7 +34,12 @@ class NoteStyle implements IRegistryEntry * The note style to use if this one doesn't have a certain asset. * This can be recursive, ehe. */ - final fallback:Null; + var fallback(get, never):Null; + + function get_fallback():Null { + if (_data == null || _data.fallback == null) return null; + return NoteStyleRegistry.instance.fetchEntry(_data.fallback); + } /** * @param id The ID of the JSON file to parse. @@ -43,9 +48,6 @@ class NoteStyle implements IRegistryEntry { this.id = id; _data = _fetchData(id); - - var fallbackID = _data.fallback; - if (fallbackID != null) this.fallback = NoteStyleRegistry.instance.fetchEntry(fallbackID); } /** @@ -140,7 +142,7 @@ class NoteStyle implements IRegistryEntry if (raw) { var rawPath:Null = _data?.assets?.note?.assetPath; - if (rawPath == null && fallback != null) return fallback.getNoteAssetPath(true); + if (rawPath == null) return fallback?.getNoteAssetPath(true); return rawPath; } @@ -178,12 +180,13 @@ class NoteStyle implements IRegistryEntry public function isNoteAnimated():Bool { - return _data.assets?.note?.animated ?? false; + // LOL is double ?? bad practice? + return _data.assets?.note?.animated ?? fallback?.isNoteAnimated() ?? false; } public function getNoteScale():Float { - return _data.assets?.note?.scale ?? 1.0; + return _data.assets?.note?.scale ?? fallback?.getNoteScale() ?? 1.0; } function fetchNoteAnimationData(dir:NoteDirection):Null @@ -196,16 +199,15 @@ class NoteStyle implements IRegistryEntry case RIGHT: _data.assets?.note?.data?.right?.toNamed(); }; - return (result == null && fallback != null) ? fallback.fetchNoteAnimationData(dir) : result; + return result ?? fallback?.fetchNoteAnimationData(dir); } public function getHoldNoteAssetPath(raw:Bool = false):Null { if (raw) { - // TODO: figure out why ?. didn't work here - var rawPath:Null = (_data?.assets?.holdNote == null) ? null : _data?.assets?.holdNote?.assetPath; - return (rawPath == null && fallback != null) ? fallback.getHoldNoteAssetPath(true) : rawPath; + var rawPath:Null = _data?.assets?.holdNote?.assetPath; + return rawPath ?? fallback?.getHoldNoteAssetPath(true); } // library:path @@ -217,23 +219,17 @@ class NoteStyle implements IRegistryEntry public function isHoldNotePixel():Bool { - var data = _data?.assets?.holdNote; - if (data == null && fallback != null) return fallback.isHoldNotePixel(); - return data?.isPixel ?? false; + return _data?.assets?.holdNote?.isPixel ?? fallback?.isHoldNotePixel() ?? false; } public function fetchHoldNoteScale():Float { - var data = _data?.assets?.holdNote; - if (data == null && fallback != null) return fallback.fetchHoldNoteScale(); - return data?.scale ?? 1.0; + return _data?.assets?.holdNote?.scale ?? fallback?.fetchHoldNoteScale() ?? 1.0; } public function getHoldNoteOffsets():Array { - var data = _data?.assets?.holdNote; - if (data == null && fallback != null) return fallback.getHoldNoteOffsets(); - return data?.offsets ?? [0.0, 0.0]; + return _data?.assets?.holdNote?.offsets ?? fallback?.getHoldNoteOffsets() ?? [0.0, 0.0]; } public function applyStrumlineFrames(target:StrumlineNote):Void @@ -258,9 +254,7 @@ class NoteStyle implements IRegistryEntry { if (raw) { - var rawPath:Null = _data?.assets?.noteStrumline?.assetPath; - if (rawPath == null && fallback != null) return fallback.getStrumlineAssetPath(true); - return rawPath; + return _data?.assets?.noteStrumline?.assetPath ?? fallback?.getStrumlineAssetPath(true); } // library:path @@ -282,11 +276,19 @@ class NoteStyle implements IRegistryEntry FlxAnimationUtil.addAtlasAnimations(target, getStrumlineAnimationData(dir)); } + /** + * Fetch the animation data for the strumline. + * NOTE: This function only queries the fallback note style if all the animations are missing for a given direction. + * + * @param dir The direction to fetch the animation data for. + * @return The animation data for the strumline in that direction. + */ function getStrumlineAnimationData(dir:NoteDirection):Array { var result:Array> = switch (dir) { - case NoteDirection.LEFT: [ + case NoteDirection.LEFT: + [ _data.assets.noteStrumline?.data?.leftStatic?.toNamed('static'), _data.assets.noteStrumline?.data?.leftPress?.toNamed('press'), _data.assets.noteStrumline?.data?.leftConfirm?.toNamed('confirm'), @@ -313,14 +315,17 @@ class NoteStyle implements IRegistryEntry default: []; }; - return thx.Arrays.filterNull(result); + // New variable so we can change the type. + var filteredResult:Array = thx.Arrays.filterNull(result); + + if (filteredResult.length == 0) return fallback?.getStrumlineAnimationData(dir) ?? []; + + return filteredResult; } public function getStrumlineOffsets():Array { - var data = _data?.assets?.noteStrumline; - if (data == null && fallback != null) return fallback.getStrumlineOffsets(); - return data?.offsets ?? [0.0, 0.0]; + return _data?.assets?.noteStrumline?.offsets ?? fallback?.getStrumlineOffsets() ?? [0.0, 0.0]; } public function applyStrumlineOffsets(target:StrumlineNote):Void @@ -332,21 +337,17 @@ class NoteStyle implements IRegistryEntry public function getStrumlineScale():Float { - return _data?.assets?.noteStrumline?.scale ?? 1.0; + return _data?.assets?.noteStrumline?.scale ?? fallback?.getStrumlineScale() ?? 1.0; } public function isNoteSplashEnabled():Bool { - var data = _data?.assets?.noteSplash?.data; - if (data == null) return fallback?.isNoteSplashEnabled() ?? false; - return data.enabled ?? false; + return _data?.assets?.noteSplash?.data?.enabled ?? fallback?.isNoteSplashEnabled() ?? false; } public function isHoldNoteCoverEnabled():Bool { - var data = _data?.assets?.holdNoteCover?.data; - if (data == null) return fallback?.isHoldNoteCoverEnabled() ?? false; - return data.enabled ?? false; + return _data?.assets?.holdNoteCover?.data?.enabled ?? fallback?.isHoldNoteCoverEnabled() ?? false; } /** @@ -457,20 +458,20 @@ class NoteStyle implements IRegistryEntry { case THREE: var result = _data.assets.countdownThree?.isPixel; - if (result == null && fallback != null) result = fallback.isCountdownSpritePixel(step); - return result ?? false; + if (result == null) result = fallback?.isCountdownSpritePixel(step) ?? false; + return result; case TWO: var result = _data.assets.countdownTwo?.isPixel; - if (result == null && fallback != null) result = fallback.isCountdownSpritePixel(step); - return result ?? false; + if (result == null) result = fallback?.isCountdownSpritePixel(step) ?? false; + return result; case ONE: var result = _data.assets.countdownOne?.isPixel; - if (result == null && fallback != null) result = fallback.isCountdownSpritePixel(step); - return result ?? false; + if (result == null) result = fallback?.isCountdownSpritePixel(step) ?? false; + return result; case GO: var result = _data.assets.countdownGo?.isPixel; - if (result == null && fallback != null) result = fallback.isCountdownSpritePixel(step); - return result ?? false; + if (result == null) result = fallback?.isCountdownSpritePixel(step) ?? false; + return result; default: return false; } @@ -482,20 +483,20 @@ class NoteStyle implements IRegistryEntry { case THREE: var result = _data.assets.countdownThree?.offsets; - if (result == null && fallback != null) result = fallback.getCountdownSpriteOffsets(step); - return result ?? [0, 0]; + if (result == null) result = fallback?.getCountdownSpriteOffsets(step) ?? [0, 0]; + return result; case TWO: var result = _data.assets.countdownTwo?.offsets; - if (result == null && fallback != null) result = fallback.getCountdownSpriteOffsets(step); - return result ?? [0, 0]; + if (result == null) result = fallback?.getCountdownSpriteOffsets(step) ?? [0, 0]; + return result; case ONE: var result = _data.assets.countdownOne?.offsets; - if (result == null && fallback != null) result = fallback.getCountdownSpriteOffsets(step); - return result ?? [0, 0]; + if (result == null) result = fallback?.getCountdownSpriteOffsets(step) ?? [0, 0]; + return result; case GO: var result = _data.assets.countdownGo?.offsets; - if (result == null && fallback != null) result = fallback.getCountdownSpriteOffsets(step); - return result ?? [0, 0]; + if (result == null) result = fallback?.getCountdownSpriteOffsets(step) ?? [0, 0]; + return result; default: return [0, 0]; } @@ -520,7 +521,7 @@ class NoteStyle implements IRegistryEntry null; } - return (rawPath == null && fallback != null) ? fallback.getCountdownSoundPath(step, true) : rawPath; + return (rawPath == null) ? fallback?.getCountdownSoundPath(step, true) : rawPath; } // library:path @@ -584,20 +585,20 @@ class NoteStyle implements IRegistryEntry { case "sick": var result = _data.assets.judgementSick?.isPixel; - if (result == null && fallback != null) result = fallback.isJudgementSpritePixel(rating); - return result ?? false; + if (result == null) result = fallback?.isJudgementSpritePixel(rating) ?? false; + return result; case "good": var result = _data.assets.judgementGood?.isPixel; - if (result == null && fallback != null) result = fallback.isJudgementSpritePixel(rating); - return result ?? false; + if (result == null) result = fallback?.isJudgementSpritePixel(rating) ?? false; + return result; case "bad": var result = _data.assets.judgementBad?.isPixel; - if (result == null && fallback != null) result = fallback.isJudgementSpritePixel(rating); - return result ?? false; + if (result == null) result = fallback?.isJudgementSpritePixel(rating) ?? false; + return result; case "shit": var result = _data.assets.judgementShit?.isPixel; - if (result == null && fallback != null) result = fallback.isJudgementSpritePixel(rating); - return result ?? false; + if (result == null) result = fallback?.isJudgementSpritePixel(rating) ?? false; + return result; default: return false; } @@ -635,20 +636,20 @@ class NoteStyle implements IRegistryEntry { case "sick": var result = _data.assets.judgementSick?.offsets; - if (result == null && fallback != null) result = fallback.getJudgementSpriteOffsets(rating); - return result ?? [0, 0]; + if (result == null) result = fallback?.getJudgementSpriteOffsets(rating) ?? [0, 0]; + return result; case "good": var result = _data.assets.judgementGood?.offsets; - if (result == null && fallback != null) result = fallback.getJudgementSpriteOffsets(rating); - return result ?? [0, 0]; + if (result == null) result = fallback?.getJudgementSpriteOffsets(rating) ?? [0, 0]; + return result; case "bad": var result = _data.assets.judgementBad?.offsets; - if (result == null && fallback != null) result = fallback.getJudgementSpriteOffsets(rating); - return result ?? [0, 0]; + if (result == null) result = fallback?.getJudgementSpriteOffsets(rating) ?? [0, 0]; + return result; case "shit": var result = _data.assets.judgementShit?.offsets; - if (result == null && fallback != null) result = fallback.getJudgementSpriteOffsets(rating); - return result ?? [0, 0]; + if (result == null) result = fallback?.getJudgementSpriteOffsets(rating) ?? [0, 0]; + return result; default: return [0, 0]; } @@ -749,44 +750,44 @@ class NoteStyle implements IRegistryEntry { case 0: var result = _data.assets.comboNumber0?.isPixel; - if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit); - return result ?? false; + if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false; + return result; case 1: var result = _data.assets.comboNumber1?.isPixel; - if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit); - return result ?? false; + if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false; + return result; case 2: var result = _data.assets.comboNumber2?.isPixel; - if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit); - return result ?? false; + if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false; + return result; case 3: var result = _data.assets.comboNumber3?.isPixel; - if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit); - return result ?? false; + if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false; + return result; case 4: var result = _data.assets.comboNumber4?.isPixel; - if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit); - return result ?? false; + if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false; + return result; case 5: var result = _data.assets.comboNumber5?.isPixel; - if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit); - return result ?? false; + if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false; + return result; case 6: var result = _data.assets.comboNumber6?.isPixel; - if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit); - return result ?? false; + if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false; + return result; case 7: var result = _data.assets.comboNumber7?.isPixel; - if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit); - return result ?? false; + if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false; + return result; case 8: var result = _data.assets.comboNumber8?.isPixel; - if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit); - return result ?? false; + if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false; + return result; case 9: var result = _data.assets.comboNumber9?.isPixel; - if (result == null && fallback != null) result = fallback.isComboNumSpritePixel(digit); - return result ?? false; + if (result == null) result = fallback?.isComboNumSpritePixel(digit) ?? false; + return result; default: return false; } @@ -836,44 +837,44 @@ class NoteStyle implements IRegistryEntry { case 0: var result = _data.assets.comboNumber0?.offsets; - if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit); - return result ?? [0, 0]; + if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0]; + return result; case 1: var result = _data.assets.comboNumber1?.offsets; - if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit); - return result ?? [0, 0]; + if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0]; + return result; case 2: var result = _data.assets.comboNumber2?.offsets; - if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit); - return result ?? [0, 0]; + if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0]; + return result; case 3: var result = _data.assets.comboNumber3?.offsets; - if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit); - return result ?? [0, 0]; + if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0]; + return result; case 4: var result = _data.assets.comboNumber4?.offsets; - if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit); - return result ?? [0, 0]; + if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0]; + return result; case 5: var result = _data.assets.comboNumber5?.offsets; - if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit); - return result ?? [0, 0]; + if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0]; + return result; case 6: var result = _data.assets.comboNumber6?.offsets; - if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit); - return result ?? [0, 0]; + if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0]; + return result; case 7: var result = _data.assets.comboNumber7?.offsets; - if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit); - return result ?? [0, 0]; + if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0]; + return result; case 8: var result = _data.assets.comboNumber8?.offsets; - if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit); - return result ?? [0, 0]; + if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0]; + return result; case 9: var result = _data.assets.comboNumber9?.offsets; - if (result == null && fallback != null) result = fallback.getComboNumSpriteOffsets(digit); - return result ?? [0, 0]; + if (result == null) result = fallback?.getComboNumSpriteOffsets(digit) ?? [0, 0]; + return result; default: return [0, 0]; } diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index aef40ef916..044b78e22f 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -144,11 +144,37 @@ class FreeplayState extends MusicBeatSubState var songs:Array> = []; + // List of available difficulties for the current song, without `-variation` at the end (no duplicates or nulls). var diffIdsCurrent:Array = []; + // List of available difficulties for the total song list, without `-variation` at the end (no duplicates or nulls). var diffIdsTotal:Array = []; + // List of available difficulties for the current song, with `-variation` at the end (no duplicates or nulls). + var suffixedDiffIdsCurrent:Array = []; + // List of available difficulties for the total song list, with `-variation` at the end (no duplicates or nulls). + var suffixedDiffIdsTotal:Array = []; var curSelected:Int = 0; - var currentDifficulty:String = Constants.DEFAULT_DIFFICULTY; + var currentSuffixedDifficulty:String = Constants.DEFAULT_DIFFICULTY; + var currentUnsuffixedDifficulty(get, never):String; + + function get_currentUnsuffixedDifficulty():String + { + if (Constants.DEFAULT_DIFFICULTY_LIST_FULL.contains(currentSuffixedDifficulty)) return currentSuffixedDifficulty; + + // Else, we need to strip the suffix. + return currentSuffixedDifficulty.substring(0, currentSuffixedDifficulty.lastIndexOf('-')); + } + + var currentVariation(get, never):String; + + function get_currentVariation():String + { + if (Constants.DEFAULT_DIFFICULTY_LIST.contains(currentSuffixedDifficulty)) return Constants.DEFAULT_VARIATION; + if (Constants.DEFAULT_DIFFICULTY_LIST_ERECT.contains(currentSuffixedDifficulty)) return 'erect'; + + // Else, we need to isolate the suffix. + return currentSuffixedDifficulty.substring(currentSuffixedDifficulty.lastIndexOf('-') + 1, currentSuffixedDifficulty.length); + } public var fp:FreeplayScore; @@ -356,11 +382,15 @@ class FreeplayState extends MusicBeatSubState trace('Available Difficulties: $availableDifficultiesForSong'); if (availableDifficultiesForSong.length == 0) continue; - songs.push(new FreeplaySongData(levelId, songId, song, displayedVariations)); + songs.push(new FreeplaySongData(levelId, songId, song, currentCharacter, displayedVariations)); for (difficulty in unsuffixedDifficulties) { diffIdsTotal.pushUnique(difficulty); } + for (difficulty in availableDifficultiesForSong) + { + suffixedDiffIdsTotal.pushUnique(difficulty); + } } } @@ -453,7 +483,7 @@ class FreeplayState extends MusicBeatSubState wait: 0.1 }); - for (diffId in diffIdsTotal) + for (diffId in suffixedDiffIdsTotal) { var diffSprite:DifficultySprite = new DifficultySprite(diffId); diffSprite.difficultyId = diffId; @@ -467,7 +497,7 @@ class FreeplayState extends MusicBeatSubState for (diffSprite in grpDifficulties.group.members) { if (diffSprite == null) continue; - if (diffSprite.difficultyId == currentDifficulty) diffSprite.visible = true; + if (diffSprite.difficultyId == currentSuffixedDifficulty) diffSprite.visible = true; } albumRoll.albumId = null; @@ -743,17 +773,14 @@ class FreeplayState extends MusicBeatSubState { var tempSongs:Array> = songs; - // Remember just the difficulty because it's important for song sorting. - currentDifficulty = rememberedDifficulty; - if (filterStuff != null) tempSongs = sortSongs(tempSongs, filterStuff); // Filter further by current selected difficulty. - if (currentDifficulty != null) + if (currentSuffixedDifficulty != null) { tempSongs = tempSongs.filter(song -> { if (song == null) return true; // Random - return song.songDifficulties.contains(currentDifficulty); + return song.suffixedSongDifficulties.contains(currentSuffixedDifficulty); }); } @@ -1344,7 +1371,6 @@ class FreeplayState extends MusicBeatSubState var dyTouch:Float = 0; var velTouch:Float = 0; - var veloctiyLoopShit:Float = 0; var touchTimer:Float = 0; var initTouchPos:FlxPoint = new FlxPoint(); @@ -1756,16 +1782,18 @@ class FreeplayState extends MusicBeatSubState { touchTimer = 0; - var currentDifficultyIndex:Int = diffIdsCurrent.indexOf(currentDifficulty); + var currentDifficultyIndex:Int = suffixedDiffIdsCurrent.indexOf(currentSuffixedDifficulty); - if (currentDifficultyIndex == -1) currentDifficultyIndex = diffIdsCurrent.indexOf(Constants.DEFAULT_DIFFICULTY); + if (currentDifficultyIndex == -1) currentDifficultyIndex = suffixedDiffIdsCurrent.indexOf(Constants.DEFAULT_DIFFICULTY); currentDifficultyIndex += change; - if (currentDifficultyIndex < 0) currentDifficultyIndex = diffIdsCurrent.length - 1; - if (currentDifficultyIndex >= diffIdsCurrent.length) currentDifficultyIndex = 0; + if (currentDifficultyIndex < 0) currentDifficultyIndex = suffixedDiffIdsCurrent.length - 1; + if (currentDifficultyIndex >= suffixedDiffIdsCurrent.length) currentDifficultyIndex = 0; - currentDifficulty = diffIdsCurrent[currentDifficultyIndex]; + currentSuffixedDifficulty = suffixedDiffIdsCurrent[currentDifficultyIndex]; + + trace('Switching to difficulty: ${currentSuffixedDifficulty}'); var daSong:Null = grpCapsules.members[curSelected].songData; if (daSong != null) @@ -1776,22 +1804,20 @@ class FreeplayState extends MusicBeatSubState FlxG.log.warn('WARN: could not find song with id (${daSong.songId})'); return; } - var targetVariation:String = targetSong.getFirstValidVariation(currentDifficulty, currentCharacter) ?? ''; - // TODO: This line of code makes me sad, but you can't really fix it without a breaking migration. - var suffixedDifficulty = (targetVariation != Constants.DEFAULT_VARIATION - && targetVariation != 'erect') ? '$currentDifficulty-${targetVariation}' : currentDifficulty; + var suffixedDifficulty = suffixedDiffIdsCurrent[currentDifficultyIndex]; var songScore:Null = Save.instance.getSongScore(daSong.songId, suffixedDifficulty); trace(songScore); intendedScore = songScore?.score ?? 0; intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes); rememberedDifficulty = suffixedDifficulty; + currentSuffixedDifficulty = suffixedDifficulty; } else { intendedScore = 0; intendedCompletion = 0.0; - rememberedDifficulty = currentDifficulty; + rememberedDifficulty = currentSuffixedDifficulty; } if (intendedCompletion == Math.POSITIVE_INFINITY || intendedCompletion == Math.NEGATIVE_INFINITY || Math.isNaN(intendedCompletion)) @@ -1806,7 +1832,7 @@ class FreeplayState extends MusicBeatSubState for (diffSprite in grpDifficulties.group.members) { if (diffSprite == null) continue; - if (diffSprite.difficultyId == currentDifficulty) + if (diffSprite.difficultyId == currentSuffixedDifficulty) { if (change != 0) { @@ -1833,7 +1859,9 @@ class FreeplayState extends MusicBeatSubState if (songCapsule == null) continue; if (songCapsule.songData != null) { - songCapsule.songData.currentDifficulty = currentDifficulty; + songCapsule.songData.currentVariation = currentVariation; + songCapsule.songData.currentUnsuffixedDifficulty = currentUnsuffixedDifficulty; + songCapsule.songData.currentSuffixedDifficulty = currentSuffixedDifficulty; songCapsule.init(null, null, songCapsule.songData); songCapsule.checkClip(); } @@ -1921,8 +1949,9 @@ class FreeplayState extends MusicBeatSubState return; } var targetSong:Song = targetSongNullable; - var targetDifficultyId:String = currentDifficulty; - var targetVariation:Null = targetSong.getFirstValidVariation(targetDifficultyId, currentCharacter); + var targetDifficultyId:String = currentUnsuffixedDifficulty; + var targetVariation:Null = currentVariation; + trace('target song: ${targetSongId} (${targetVariation})'); var targetLevelId:Null = cap?.songData?.levelId; PlayStatePlaylist.campaignId = targetLevelId ?? null; @@ -2002,8 +2031,8 @@ class FreeplayState extends MusicBeatSubState return; } var targetSong:Song = targetSongNullable; - var targetDifficultyId:String = currentDifficulty; - var targetVariation:Null = targetSong.getFirstValidVariation(targetDifficultyId, currentCharacter); + var targetDifficultyId:String = currentUnsuffixedDifficulty; + var targetVariation:Null = currentVariation; var targetLevelId:Null = cap?.songData?.levelId; PlayStatePlaylist.campaignId = targetLevelId ?? null; @@ -2069,7 +2098,7 @@ class FreeplayState extends MusicBeatSubState if (rememberedDifficulty != null) { - currentDifficulty = rememberedDifficulty; + currentSuffixedDifficulty = rememberedDifficulty; } } @@ -2087,10 +2116,11 @@ class FreeplayState extends MusicBeatSubState var daSongCapsule:SongMenuItem = grpCapsules.members[curSelected]; if (daSongCapsule.songData != null) { - var songScore:Null = Save.instance.getSongScore(daSongCapsule.songData.songId, currentDifficulty); + var songScore:Null = Save.instance.getSongScore(daSongCapsule.songData.songId, currentSuffixedDifficulty); intendedScore = songScore?.score ?? 0; intendedCompletion = songScore == null ? 0.0 : ((songScore.tallies.sick + songScore.tallies.good) / songScore.tallies.totalNotes); diffIdsCurrent = daSongCapsule.songData.songDifficulties; + suffixedDiffIdsCurrent = daSongCapsule.songData.suffixedSongDifficulties; rememberedSongId = daSongCapsule.songData.songId; changeDiff(); } @@ -2099,6 +2129,7 @@ class FreeplayState extends MusicBeatSubState intendedScore = 0; intendedCompletion = 0.0; diffIdsCurrent = diffIdsTotal; + suffixedDiffIdsCurrent = suffixedDiffIdsTotal; rememberedSongId = null; rememberedDifficulty = Constants.DEFAULT_DIFFICULTY; albumRoll.albumId = null; @@ -2143,17 +2174,18 @@ class FreeplayState extends MusicBeatSubState if (previewSongId == null) return; var previewSong:Null = SongRegistry.instance.fetchEntry(previewSongId); - var currentVariation = previewSong?.getVariationsByCharacter(currentCharacter) ?? Constants.DEFAULT_VARIATION_LIST; - var songDifficulty:Null = previewSong?.getDifficulty(currentDifficulty, - previewSong?.getVariationsByCharacter(currentCharacter) ?? Constants.DEFAULT_VARIATION_LIST); - - var baseInstrumentalId:String = previewSong?.getBaseInstrumentalId(currentDifficulty, songDifficulty?.variation ?? Constants.DEFAULT_VARIATION) ?? ''; - var altInstrumentalIds:Array = previewSong?.listAltInstrumentalIds(currentDifficulty, + if (previewSong == null) return; + // var currentVariation = previewSong.getVariationsByCharacter(currentCharacter) ?? Constants.DEFAULT_VARIATION_LIST; + var targetDifficultyId:String = currentUnsuffixedDifficulty; + var targetVariation:Null = currentVariation; + var songDifficulty:Null = previewSong.getDifficulty(targetDifficultyId, targetVariation ?? Constants.DEFAULT_VARIATION); + + var baseInstrumentalId:String = previewSong.getBaseInstrumentalId(targetDifficultyId, songDifficulty?.variation ?? Constants.DEFAULT_VARIATION) ?? ''; + var altInstrumentalIds:Array = previewSong.listAltInstrumentalIds(targetDifficultyId, songDifficulty?.variation ?? Constants.DEFAULT_VARIATION) ?? []; var instSuffix:String = baseInstrumentalId; - // TODO: Make this a UI element. #if FEATURE_DEBUG_FUNCTIONS if (altInstrumentalIds.length > 0 && FlxG.keys.pressed.CONTROL) { @@ -2312,6 +2344,7 @@ class FreeplaySongData public var songId(default, null):String = ''; public var songDifficulties(default, null):Array = []; + public var suffixedSongDifficulties(default, null):Array = []; public var songName(default, null):String = ''; public var songCharacter(default, null):String = ''; @@ -2319,22 +2352,25 @@ class FreeplaySongData public var difficultyRating(default, null):Int = 0; public var albumId(default, null):Null = null; - public var currentDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY; + public var currentCharacter:PlayableCharacter; + public var currentVariation:String = Constants.DEFAULT_VARIATION; + public var currentSuffixedDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY; + public var currentUnsuffixedDifficulty:String = Constants.DEFAULT_DIFFICULTY; public var scoringRank:Null = null; var displayedVariations:Array = [Constants.DEFAULT_VARIATION]; - function set_currentDifficulty(value:String):String + function set_currentSuffixedDifficulty(value:String):String { - if (currentDifficulty == value) return value; + if (currentSuffixedDifficulty == value) return value; - currentDifficulty = value; + currentSuffixedDifficulty = value; updateValues(displayedVariations); return value; } - public function new(levelId:String, songId:String, song:Song, ?displayedVariations:Array) + public function new(levelId:String, songId:String, song:Song, currentCharacter:PlayableCharacter, ?displayedVariations:Array) { this.levelId = levelId; this.songId = songId; @@ -2342,6 +2378,7 @@ class FreeplaySongData this.isFav = Save.instance.isSongFavorited(songId); + this.currentCharacter = currentCharacter; if (displayedVariations != null) this.displayedVariations = displayedVariations; updateValues(displayedVariations); @@ -2368,15 +2405,18 @@ class FreeplaySongData function updateValues(variations:Array):Void { this.songDifficulties = song.listDifficulties(null, variations, false, false); - if (!this.songDifficulties.contains(currentDifficulty)) + this.suffixedSongDifficulties = song.listSuffixedDifficulties(variations, false, false); + if (!this.songDifficulties.contains(currentUnsuffixedDifficulty)) { - currentDifficulty = Constants.DEFAULT_DIFFICULTY; + currentSuffixedDifficulty = Constants.DEFAULT_DIFFICULTY; // This method gets called again by the setter-method // or the difficulty didn't change, so there's no need to continue. return; } - var songDifficulty:SongDifficulty = song.getDifficulty(currentDifficulty, null, variations); + var targetVariation:Null = currentVariation; + + var songDifficulty:SongDifficulty = song.getDifficulty(currentUnsuffixedDifficulty, targetVariation); if (songDifficulty == null) return; this.songStartingBpm = songDifficulty.getStartingBPM(); this.songName = songDifficulty.songName; @@ -2392,10 +2432,7 @@ class FreeplaySongData this.albumId = songDifficulty.album; } - // TODO: This line of code makes me sad, but you can't really fix it without a breaking migration. - // `easy`, `erect`, `normal-pico`, etc. - var suffixedDifficulty = (songDifficulty.variation != Constants.DEFAULT_VARIATION - && songDifficulty.variation != 'erect') ? '$currentDifficulty-${songDifficulty.variation}' : currentDifficulty; + var suffixedDifficulty = currentSuffixedDifficulty; this.scoringRank = Save.instance.getSongRank(songId, suffixedDifficulty); diff --git a/source/funkin/util/Constants.hx b/source/funkin/util/Constants.hx index cf58d191a3..9536a728fd 100644 --- a/source/funkin/util/Constants.hx +++ b/source/funkin/util/Constants.hx @@ -186,6 +186,11 @@ class Constants */ public static final DEFAULT_DIFFICULTY_LIST:Array = ['easy', 'normal', 'hard']; + /** + * Default list of difficulties for Erect mode. + */ + public static final DEFAULT_DIFFICULTY_LIST_ERECT:Array = ['erect', 'nightmare']; + /** * List of all difficulties used by the base game. * Includes Erect and Nightmare. From 8a8160dfe72b9a1c0b16f74a63367f11810cd9cd Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 27 Sep 2024 14:26:46 -0400 Subject: [PATCH 123/143] Update assets submodule --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 962e3d3a14..51ac128a3a 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 962e3d3a1439b64056333b350278d367510cd235 +Subproject commit 51ac128a3a658488408dc548c9845ac7d485ab24 From cd2b458da2ed2eeea46893dfccbb289f34ee8415 Mon Sep 17 00:00:00 2001 From: AbnormalPoof Date: Fri, 27 Sep 2024 15:15:35 -0500 Subject: [PATCH 124/143] add flipx and flipy --- source/funkin/data/stage/StageData.hx | 16 ++++++++++++++++ source/funkin/play/stage/Stage.hx | 3 +++ 2 files changed, 19 insertions(+) diff --git a/source/funkin/data/stage/StageData.hx b/source/funkin/data/stage/StageData.hx index eda8e31481..1e9172b00f 100644 --- a/source/funkin/data/stage/StageData.hx +++ b/source/funkin/data/stage/StageData.hx @@ -118,6 +118,22 @@ typedef StageDataProp = @:default(false) var isPixel:Bool; + /** + * If set to true, the prop will be flipped horizontally. + * @default false + */ + @:optional + @:default(false) + var flipX:Bool; + + /** + * If set to true, the prop will be flipped vertically. + * @default false + */ + @:optional + @:default(false) + var flipY:Bool; + /** * Either the scale of the prop as a float, or the [w, h] scale as an array of two floats. * Pro tip: On pixel-art levels, save the sprite small and set this value to 6 or so to save memory. diff --git a/source/funkin/play/stage/Stage.hx b/source/funkin/play/stage/Stage.hx index c42e41cadb..c237005cf9 100644 --- a/source/funkin/play/stage/Stage.hx +++ b/source/funkin/play/stage/Stage.hx @@ -258,6 +258,9 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass implements propSprite.zIndex = dataProp.zIndex; + propSprite.flipX = dataProp.flipX; + propSprite.flipY = dataProp.flipY; + switch (dataProp.animType) { case 'packer': From 007a32dc9cd11b8b9419e888e5d34fd768cd203a Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 27 Sep 2024 17:00:31 -0400 Subject: [PATCH 125/143] assets submod --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 8706229c95..228cf6dd81 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 8706229c95fbebab5a10093223bceefec03e2f7f +Subproject commit 228cf6dd815a44b3e806337ac3bd50465e3b407d From ac3e2b25609329e89ec2386c553357213d6a7a5f Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 27 Sep 2024 17:45:54 -0400 Subject: [PATCH 126/143] discord api mac --- hmm.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hmm.json b/hmm.json index 0d57cfbc8e..c136260234 100644 --- a/hmm.json +++ b/hmm.json @@ -112,7 +112,7 @@ "name": "hxdiscord_rpc", "type": "git", "dir": null, - "ref": "79955ce93f0392b245b3610b7697780c8618bc47", + "ref": "82c47ecc1a454b7dd644e4fcac7e91155f176dec", "url": "https://github.com/FunkinCrew/hxdiscord_rpc" }, { @@ -212,4 +212,4 @@ "url": "https://github.com/fponticelli/thx.semver" } ] -} +} \ No newline at end of file From 7ce7d7839ea296dad3d8abd3909dfdbf1592131f Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 28 Sep 2024 09:51:41 -0400 Subject: [PATCH 127/143] Update stage data version after adding new values. --- source/funkin/data/stage/CHANGELOG.md | 4 ++++ source/funkin/data/stage/StageRegistry.hx | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/funkin/data/stage/CHANGELOG.md b/source/funkin/data/stage/CHANGELOG.md index 879139db55..bf9d750cc7 100644 --- a/source/funkin/data/stage/CHANGELOG.md +++ b/source/funkin/data/stage/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.2] +### Added +- Added the ability to specify `flipX` and `flipY` on stage props to horizontally or vertically flip, respectively. + ## [1.0.1] ### Added - Added the ability to specify a hexadecimal color in the `assetPath` field instead of a texture key. diff --git a/source/funkin/data/stage/StageRegistry.hx b/source/funkin/data/stage/StageRegistry.hx index 87113ef051..e11166bddd 100644 --- a/source/funkin/data/stage/StageRegistry.hx +++ b/source/funkin/data/stage/StageRegistry.hx @@ -11,9 +11,9 @@ class StageRegistry extends BaseRegistry * Handle breaking changes by incrementing this value * and adding migration to the `migrateStageData()` function. */ - public static final STAGE_DATA_VERSION:thx.semver.Version = "1.0.0"; + public static final STAGE_DATA_VERSION:thx.semver.Version = "1.0.2"; - public static final STAGE_DATA_VERSION_RULE:thx.semver.VersionRule = "1.0.x"; + public static final STAGE_DATA_VERSION_RULE:thx.semver.VersionRule = ">=1.0.0 <=1.0.2"; public static var instance(get, never):StageRegistry; static var _instance:Null = null; From 93039c3d65a1ad4912623bb4dce67e515ec7db89 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sat, 28 Sep 2024 12:37:12 -0400 Subject: [PATCH 128/143] intro text stuff --- assets | 2 +- source/funkin/ui/title/TitleState.hx | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/assets b/assets index d22c7f8300..b2404b6b1c 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit d22c7f8300616bd9e0a78866cba7bc67f5756220 +Subproject commit b2404b6b1cba47da8eef4910f49985d54318186b diff --git a/source/funkin/ui/title/TitleState.hx b/source/funkin/ui/title/TitleState.hx index 10e7dfaaec..cdd1e39168 100644 --- a/source/funkin/ui/title/TitleState.hx +++ b/source/funkin/ui/title/TitleState.hx @@ -485,7 +485,13 @@ class TitleState extends MusicBeatState case 13: addMoreText('Friday'); case 14: - addMoreText('Night'); + // easter egg for when the game is trending with the wrong spelling + // the random intro text would be "trending--only on x" + + if (curWacky[0] == "trending") + addMoreText('Nigth'); + else + addMoreText('Night'); case 15: addMoreText('Funkin'); case 16: From e3ed153a7ce43d0842f153676808422e4cf33fcd Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sun, 29 Sep 2024 06:59:49 -0400 Subject: [PATCH 129/143] Add a "persist" argument to FunkinSound to prevent Results music from continuing in Freeplay. --- source/funkin/audio/FunkinSound.hx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/funkin/audio/FunkinSound.hx b/source/funkin/audio/FunkinSound.hx index aa0b4b00ac..98e0307ba1 100644 --- a/source/funkin/audio/FunkinSound.hx +++ b/source/funkin/audio/FunkinSound.hx @@ -430,12 +430,13 @@ class FunkinSound extends FlxSound implements ICloneable * @param autoDestroy Whether to destroy this sound when it finishes playing. * Leave this value set to `false` if you want to re-use this `FunkinSound` instance. * @param autoPlay Whether to play the sound immediately or wait for a `play()` call. + * @param persist Whether to keep this `FunkinSound` between states, or destroy it. * @param onComplete Called when the sound finished playing. * @param onLoad Called when the sound finished loading. Called immediately for succesfully loaded embedded sounds. * @return A `FunkinSound` object, or `null` if the sound could not be loaded. */ public static function load(embeddedSound:FlxSoundAsset, volume:Float = 1.0, looped:Bool = false, autoDestroy:Bool = false, autoPlay:Bool = false, - ?onComplete:Void->Void, ?onLoad:Void->Void):Null + persist:Bool = false, ?onComplete:Void->Void, ?onLoad:Void->Void):Null { @:privateAccess if (SoundMixer.__soundChannels.length >= SoundMixer.MAX_ACTIVE_CHANNELS) @@ -462,7 +463,7 @@ class FunkinSound extends FlxSound implements ICloneable if (autoPlay) sound.play(); sound.volume = volume; sound.group = FlxG.sound.defaultSoundGroup; - sound.persist = true; + sound.persist = persist; // Make sure to add the sound to the list. // If it's already in, it won't get re-added. From 90f6f80a7176a2b67d27f922bdffac2af4ad5ef4 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sun, 29 Sep 2024 07:06:11 -0400 Subject: [PATCH 130/143] Fix issues with animation offsets breaking on restart on characters with high offstes. --- source/funkin/play/character/BaseCharacter.hx | 8 +------- source/funkin/play/stage/Bopper.hx | 3 --- source/funkin/play/stage/Stage.hx | 7 +------ 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index 365c8d112b..1b5a68e96b 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -233,15 +233,9 @@ class BaseCharacter extends Bopper */ public function resetCharacter(resetCamera:Bool = true):Void { - // Reset the animation offsets. This will modify x and y to be the absolute position of the character. - // this.animOffsets = [0, 0]; - - // Now we can set the x and y to be their original values without having to account for animOffsets. + // Set the x and y to be their original values. this.resetPosition(); - // Then reapply animOffsets... - // applyAnimationOffsets(getCurrentAnimation()); - this.dance(true); // Force to avoid the old animation playing with the wrong offset at the start of the song. // Make sure we are playing the idle animation // ...then update the hitbox so that this.width and this.height are correct. diff --git a/source/funkin/play/stage/Bopper.hx b/source/funkin/play/stage/Bopper.hx index 721a60517c..4429e8d90b 100644 --- a/source/funkin/play/stage/Bopper.hx +++ b/source/funkin/play/stage/Bopper.hx @@ -150,11 +150,8 @@ class Bopper extends StageProp implements IPlayStateScriptedClass */ public function resetPosition() { - var oldAnimOffsets = [animOffsets[0], animOffsets[1]]; - animOffsets = [0, 0]; this.x = originalPosition.x; this.y = originalPosition.y; - animOffsets = oldAnimOffsets; } function update_shouldAlternate():Void diff --git a/source/funkin/play/stage/Stage.hx b/source/funkin/play/stage/Stage.hx index ad768769c8..15648249c6 100644 --- a/source/funkin/play/stage/Stage.hx +++ b/source/funkin/play/stage/Stage.hx @@ -440,12 +440,7 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass implements character.x = stageCharData.position[0] - character.characterOrigin.x; character.y = stageCharData.position[1] - character.characterOrigin.y; - @:privateAccess(funkin.play.stage.Bopper) - { - // Undo animOffsets before saving original position. - character.originalPosition.x = character.x + character.animOffsets[0]; - character.originalPosition.y = character.y + character.animOffsets[1]; - } + character.originalPosition.set(character.x, character.y); var finalScale = character.getBaseScale() * stageCharData.scale; character.setScale(finalScale); // Don't use scale.set for characters! From 136e7358b1daea113a359fe6b392a26fb36894f6 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 30 Sep 2024 10:40:19 -0400 Subject: [PATCH 131/143] bump project version --- project.hxp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.hxp b/project.hxp index 2f537935aa..5c04a24931 100644 --- a/project.hxp +++ b/project.hxp @@ -25,7 +25,7 @@ class Project extends HXProject { * REMEMBER TO CHANGE THIS WHEN THE GAME UPDATES! * You only have to change it here, the rest of the game will query this value. */ - static final VERSION:String = "0.5.0"; + static final VERSION:String = "0.5.1"; /** * The game's name. Used as the default window title. From 0971a0bb4c0e8f4bf6c5c143bcb158eeda8bb5af Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 30 Sep 2024 10:53:27 -0400 Subject: [PATCH 132/143] music persist fixes for title screen --- source/funkin/audio/FunkinSound.hx | 11 ++++++++--- source/funkin/ui/title/TitleState.hx | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/funkin/audio/FunkinSound.hx b/source/funkin/audio/FunkinSound.hx index 98e0307ba1..92da2b50a3 100644 --- a/source/funkin/audio/FunkinSound.hx +++ b/source/funkin/audio/FunkinSound.hx @@ -390,7 +390,7 @@ class FunkinSound extends FlxSound implements ICloneable } else { - var music = FunkinSound.load(pathToUse, params?.startingVolume ?? 1.0, params.loop ?? true, false, true, params.onComplete); + var music = FunkinSound.load(pathToUse, params?.startingVolume ?? 1.0, params.loop ?? true, false, true, params.persist ?? false, params.onComplete); if (music != null) { FlxG.sound.music = music; @@ -514,7 +514,7 @@ class FunkinSound extends FlxSound implements ICloneable }); soundRequest.future.onComplete(function(partialSound) { - var snd = FunkinSound.load(partialSound, volume, looped, autoDestroy, autoPlay, onComplete, onLoad); + var snd = FunkinSound.load(partialSound, volume, looped, autoDestroy, autoPlay, false, onComplete, onLoad); promise.complete(snd); }); } @@ -544,7 +544,7 @@ class FunkinSound extends FlxSound implements ICloneable */ public static function playOnce(key:String, volume:Float = 1.0, ?onComplete:Void->Void, ?onLoad:Void->Void):Null { - var result:Null = FunkinSound.load(key, volume, false, true, true, onComplete, onLoad); + var result:Null = FunkinSound.load(key, volume, false, true, true, false, onComplete, onLoad); return result; } @@ -630,6 +630,11 @@ typedef FunkinSoundPlayMusicParams = var ?partialParams:PartialSoundParams; + /** + * Whether the sound should be destroyed on state switches + */ + var ?persist:Bool; + var ?onComplete:Void->Void; var ?onLoad:Void->Void; } diff --git a/source/funkin/ui/title/TitleState.hx b/source/funkin/ui/title/TitleState.hx index cdd1e39168..1b28169367 100644 --- a/source/funkin/ui/title/TitleState.hx +++ b/source/funkin/ui/title/TitleState.hx @@ -232,7 +232,8 @@ class TitleState extends MusicBeatState { startingVolume: 0.0, overrideExisting: true, - restartTrack: true + restartTrack: false, + persist: true }); // Fade from 0.0 to 1 over 4 seconds if (shouldFadeIn) FlxG.sound.music.fadeIn(4.0, 0.0, 1.0); @@ -488,8 +489,7 @@ class TitleState extends MusicBeatState // easter egg for when the game is trending with the wrong spelling // the random intro text would be "trending--only on x" - if (curWacky[0] == "trending") - addMoreText('Nigth'); + if (curWacky[0] == "trending") addMoreText('Nigth'); else addMoreText('Night'); case 15: From 5d013a1aa7e18c7ce2e6e7b2793b0356f3bcfe08 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 30 Sep 2024 12:49:44 -0400 Subject: [PATCH 133/143] submods --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index ad8099e602..be5e0aaa81 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "assets"] path = assets - url = https://github.com/FunkinCrew/Funkin-assets-secret + url = https://github.com/FunkinCrew/funkin.assets [submodule "art"] path = art - url = https://github.com/FunkinCrew/Funkin-art-secret + url = https://github.com/FunkinCrew/funkin.art From 4a9ad536955b2c3b524b605b25bccfd6ebf1c158 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 30 Sep 2024 12:50:24 -0400 Subject: [PATCH 134/143] submods --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index be5e0aaa81..ad8099e602 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "assets"] path = assets - url = https://github.com/FunkinCrew/funkin.assets + url = https://github.com/FunkinCrew/Funkin-assets-secret [submodule "art"] path = art - url = https://github.com/FunkinCrew/funkin.art + url = https://github.com/FunkinCrew/Funkin-art-secret From 9324359d2fce6a7097077d169a0efcd80e6fefa1 Mon Sep 17 00:00:00 2001 From: gamerbross <55158797+gamerbross@users.noreply.github.com> Date: Wed, 25 Sep 2024 19:10:26 +0200 Subject: [PATCH 135/143] Some fixes to Character Select --- .../funkin/ui/charSelect/CharSelectSubState.hx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source/funkin/ui/charSelect/CharSelectSubState.hx b/source/funkin/ui/charSelect/CharSelectSubState.hx index 70731ac2e4..c8311ce974 100644 --- a/source/funkin/ui/charSelect/CharSelectSubState.hx +++ b/source/funkin/ui/charSelect/CharSelectSubState.hx @@ -175,6 +175,7 @@ class CharSelectSubState extends MusicBeatSubState playerChillOut = new CharSelectPlayer(0, 0); playerChillOut.switchChar("bf"); + playerChillOut.visible = false; add(playerChillOut); playerChill = new CharSelectPlayer(0, 0); @@ -543,6 +544,7 @@ class CharSelectSubState extends MusicBeatSubState nametag.switchChar(char); gfChill.switchGF(char); + gfChill.visible = true; var icon = new PixelatedIcon(0, 0); icon.setCharacter(char); @@ -797,8 +799,6 @@ class CharSelectSubState extends MusicBeatSubState if (allowInput && !pressedSelect && controls.ACCEPT) { cursorConfirmed.visible = true; - cursorConfirmed.x = cursor.x - 2; - cursorConfirmed.y = cursor.y - 4; cursorConfirmed.animation.play("idle", true); grpCursors.visible = false; @@ -855,8 +855,6 @@ class CharSelectSubState extends MusicBeatSubState if (allowInput && controls.ACCEPT) { cursorDenied.visible = true; - cursorDenied.x = cursor.x - 2; - cursorDenied.y = cursor.y - 4; playerChill.playAnimation("cannot select Label", true); @@ -892,6 +890,12 @@ class CharSelectSubState extends MusicBeatSubState cursorDarkBlue.x = MathUtil.coolLerp(cursorDarkBlue.x, cursorLocIntended.x, lerpAmnt * 0.2); cursorDarkBlue.y = MathUtil.coolLerp(cursorDarkBlue.y, cursorLocIntended.y, lerpAmnt * 0.2); + + cursorConfirmed.x = cursor.x - 2; + cursorConfirmed.y = cursor.y - 4; + + cursorDenied.x = cursor.x - 2; + cursorDenied.y = cursor.y - 4; } var bopTimer:Float = 0; @@ -1056,18 +1060,20 @@ class CharSelectSubState extends MusicBeatSubState staticSound.stop(); nametag.switchChar(value); + gfChill.visible = false; playerChill.visible = false; playerChillOut.visible = true; playerChillOut.playAnimation("slideout"); var index = playerChillOut.anim.getFrameLabel("slideout").index; playerChillOut.onAnimationFrame.add((_, frame:Int) -> { - if (frame == index + 1) + if (frame >= index + 1) { playerChill.visible = true; playerChill.switchChar(value); gfChill.switchGF(value); + gfChill.visible = true; } - if (frame == index + 2) + if (frame >= index + 2) { playerChillOut.switchChar(value); playerChillOut.visible = false; From 30a98871367b494c85934cd3fcfa91eeb774a7d5 Mon Sep 17 00:00:00 2001 From: gamerbross <55158797+gamerbross@users.noreply.github.com> Date: Wed, 25 Sep 2024 19:20:10 +0200 Subject: [PATCH 136/143] Fix bf changing twice on enter --- source/funkin/ui/charSelect/CharSelectSubState.hx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/funkin/ui/charSelect/CharSelectSubState.hx b/source/funkin/ui/charSelect/CharSelectSubState.hx index c8311ce974..3c0e7fa2f7 100644 --- a/source/funkin/ui/charSelect/CharSelectSubState.hx +++ b/source/funkin/ui/charSelect/CharSelectSubState.hx @@ -790,9 +790,7 @@ class CharSelectSubState extends MusicBeatSubState cursorY = -1; } - if (autoFollow - && availableChars.exists(getCurrentSelected()) - && Save.instance.charactersSeen.contains(availableChars[getCurrentSelected()])) + if (availableChars.exists(getCurrentSelected()) && Save.instance.charactersSeen.contains(availableChars[getCurrentSelected()])) { curChar = availableChars.get(getCurrentSelected()); @@ -846,7 +844,7 @@ class CharSelectSubState extends MusicBeatSubState selectTimer.cancel(); } } - else if (autoFollow) + else { curChar = "locked"; From c5a76cf1d5ef233aacd40f0edd0efd160a9e67c5 Mon Sep 17 00:00:00 2001 From: gamerbross <55158797+gamerbross@users.noreply.github.com> Date: Wed, 25 Sep 2024 20:11:58 +0200 Subject: [PATCH 137/143] another little fix --- source/funkin/ui/charSelect/CharSelectSubState.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/source/funkin/ui/charSelect/CharSelectSubState.hx b/source/funkin/ui/charSelect/CharSelectSubState.hx index 3c0e7fa2f7..daea963210 100644 --- a/source/funkin/ui/charSelect/CharSelectSubState.hx +++ b/source/funkin/ui/charSelect/CharSelectSubState.hx @@ -1063,6 +1063,7 @@ class CharSelectSubState extends MusicBeatSubState playerChillOut.visible = true; playerChillOut.playAnimation("slideout"); var index = playerChillOut.anim.getFrameLabel("slideout").index; + playerChillOut.onAnimationFrame.removeAll(); playerChillOut.onAnimationFrame.add((_, frame:Int) -> { if (frame >= index + 1) { From 399869cdccc9c5ac27cecfbcdc33c3d7eb4b348c Mon Sep 17 00:00:00 2001 From: Hundrec Date: Wed, 25 Sep 2024 15:25:45 -0700 Subject: [PATCH 138/143] docs(github): Improvements to Github Issues templates --- .github/ISSUE_TEMPLATE/bug.yml | 40 +++++++++++++----------- .github/ISSUE_TEMPLATE/crash.yml | 42 +++++++++++++++----------- .github/ISSUE_TEMPLATE/enhancement.yml | 7 +++-- 3 files changed, 53 insertions(+), 36 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 6be3f1245e..96aa06c3f2 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -6,41 +6,45 @@ body: - type: checkboxes attributes: label: Issue Checklist + description: Be sure to complete these steps to increase the chances of your issue being addressed! options: - - label: I have properly named the issue - - label: I have checked the issues/discussions pages to see if the issue has been previously reported + - label: I have properly named my issue + - label: I have checked the Issues/Discussions pages to see if my issue has already been reported - type: dropdown attributes: - label: What platform are you using? + label: Platform + description: Which platform are you playing on? options: - - Newgrounds (Web) - - Itch.io (Web) + - Newgrounds (Web/HTML5) + - Itch.io (Web/HTML5) - Itch.io (Downloadable Build) - Windows - Itch.io (Downloadable Build) - MacOS - Itch.io (Downloadable Build) - Linux + - Compiled from GitHub Source Code validations: required: true - type: dropdown attributes: - label: If you are playing on a browser, which one are you using? + label: Browser + description: (Web/HTML5 users only) Which browser are you playing on? options: - Google Chrome - Microsoft Edge - Firefox - Opera - Safari - - Other (Specify below) + - Other (Specify in Description field) - type: input attributes: label: Version - description: What version are you using? - placeholder: ex. 0.4.1 + description: Which version are you playing on? The game version is in the bottom left corner of the main menu. + placeholder: ex. 0.5.0 validations: required: true - + - type: markdown attributes: value: "## Describe your bug." @@ -49,14 +53,16 @@ body: attributes: value: "### Please do not report issues from other engines. These must be reported in their respective repositories." - - type: markdown - attributes: - value: "#### Provide as many details as you can." - - type: textarea attributes: - label: Context (Provide images, videos, etc.) - + label: Description (include any images, videos, errors, or crash logs) + description: Provide as much detail as you can. The better others understand your issue, the more they can help you! + placeholder: Describe your issue here... + validations: + required: true + - type: textarea attributes: - label: Steps to reproduce (or crash logs, errors, etc.) + label: Steps to Reproduce + description: What steps can other people take to reliably encounter this issue? + placeholder: 1. Open the game... diff --git a/.github/ISSUE_TEMPLATE/crash.yml b/.github/ISSUE_TEMPLATE/crash.yml index 6fb7c94374..3e8fb08dd3 100644 --- a/.github/ISSUE_TEMPLATE/crash.yml +++ b/.github/ISSUE_TEMPLATE/crash.yml @@ -6,65 +6,73 @@ body: - type: checkboxes attributes: label: Issue Checklist + description: Be sure to complete these steps to increase the chances of your issue being addressed! options: - - label: I have properly named the issue - - label: I have checked the issues/discussions pages to see if the issue has been previously reported + - label: I have properly named my issue + - label: I have checked the Issues/Discussions pages to see if my issue has already been reported - type: dropdown attributes: - label: What platform are you using? + label: Platform + description: Which platform are you playing on? options: - - Newgrounds (Web) - - Itch.io (Web) + - Newgrounds (Web/HTML5) + - Itch.io (Web/HTML5) - Itch.io (Downloadable Build) - Windows - Itch.io (Downloadable Build) - MacOS - Itch.io (Downloadable Build) - Linux + - Compiled from GitHub Source Code validations: required: true - type: dropdown attributes: - label: If you are playing on a browser, which one are you using? + label: Browser + description: (Web/HTML5 users only) Which browser are you playing on? options: - Google Chrome - Microsoft Edge - Firefox - Opera - Safari - - Other (Specify below) + - Other (Specify in Description field) - type: input attributes: label: Version - description: What version are you using? - placeholder: ex. 0.4.1 + description: Which version are you playing on? The game version is in the bottom left corner of the main menu. + placeholder: ex. 0.5.0 validations: required: true - type: markdown attributes: - value: "## Describe your issue." + value: "## Describe the crash." - type: markdown attributes: value: "### Please do not report issues from other engines. These must be reported in their respective repositories." - - type: markdown - attributes: - value: "#### Provide as many details as you can." - - type: textarea attributes: - label: Context (Provide screenshots or videos of the crash happening) + label: Description + description: Include screenshots or videos of the crash happening. Provide as much detail as you can. + placeholder: Describe the crash here... + validations: + required: true - type: textarea attributes: - label: Steps to reproduce + label: Steps to Reproduce + description: What steps can other people take to reliably trigger this crash? + placeholder: 1. Open the game... validations: required: true - type: textarea attributes: - label: Crash logs (can be found in the logs folder where Funkin.exe is) + label: Crash logs + description: These can be found in the logs folder where Funkin.exe is. + placeholder: Upload your logs here... validations: required: true diff --git a/.github/ISSUE_TEMPLATE/enhancement.yml b/.github/ISSUE_TEMPLATE/enhancement.yml index 816e4a12b1..dfb4ace959 100644 --- a/.github/ISSUE_TEMPLATE/enhancement.yml +++ b/.github/ISSUE_TEMPLATE/enhancement.yml @@ -6,10 +6,13 @@ body: - type: checkboxes attributes: label: Issue Checklist + description: Be sure to complete these steps to increase the chances of your suggestion being considered! options: - - label: I have properly named the enhancement - - label: I have checked the issues/discussions pages to see if the enhancement has been previously suggested + - label: I have properly named my enhancement + - label: I have checked the Issues/Discussions pages to see if my enhancement has already been suggested - type: textarea attributes: label: What is your suggestion, and why should it be implemented? + validations: + required: true From 67f7b638fb76840b868cbfa70a1c6063577984c5 Mon Sep 17 00:00:00 2001 From: Hundrec Date: Wed, 25 Sep 2024 15:25:45 -0700 Subject: [PATCH 139/143] docs(github): Improvements to Github Issues templates --- .github/ISSUE_TEMPLATE/bug.yml | 40 +++++++++++++----------- .github/ISSUE_TEMPLATE/crash.yml | 42 +++++++++++++++----------- .github/ISSUE_TEMPLATE/enhancement.yml | 7 +++-- 3 files changed, 53 insertions(+), 36 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 6be3f1245e..96aa06c3f2 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -6,41 +6,45 @@ body: - type: checkboxes attributes: label: Issue Checklist + description: Be sure to complete these steps to increase the chances of your issue being addressed! options: - - label: I have properly named the issue - - label: I have checked the issues/discussions pages to see if the issue has been previously reported + - label: I have properly named my issue + - label: I have checked the Issues/Discussions pages to see if my issue has already been reported - type: dropdown attributes: - label: What platform are you using? + label: Platform + description: Which platform are you playing on? options: - - Newgrounds (Web) - - Itch.io (Web) + - Newgrounds (Web/HTML5) + - Itch.io (Web/HTML5) - Itch.io (Downloadable Build) - Windows - Itch.io (Downloadable Build) - MacOS - Itch.io (Downloadable Build) - Linux + - Compiled from GitHub Source Code validations: required: true - type: dropdown attributes: - label: If you are playing on a browser, which one are you using? + label: Browser + description: (Web/HTML5 users only) Which browser are you playing on? options: - Google Chrome - Microsoft Edge - Firefox - Opera - Safari - - Other (Specify below) + - Other (Specify in Description field) - type: input attributes: label: Version - description: What version are you using? - placeholder: ex. 0.4.1 + description: Which version are you playing on? The game version is in the bottom left corner of the main menu. + placeholder: ex. 0.5.0 validations: required: true - + - type: markdown attributes: value: "## Describe your bug." @@ -49,14 +53,16 @@ body: attributes: value: "### Please do not report issues from other engines. These must be reported in their respective repositories." - - type: markdown - attributes: - value: "#### Provide as many details as you can." - - type: textarea attributes: - label: Context (Provide images, videos, etc.) - + label: Description (include any images, videos, errors, or crash logs) + description: Provide as much detail as you can. The better others understand your issue, the more they can help you! + placeholder: Describe your issue here... + validations: + required: true + - type: textarea attributes: - label: Steps to reproduce (or crash logs, errors, etc.) + label: Steps to Reproduce + description: What steps can other people take to reliably encounter this issue? + placeholder: 1. Open the game... diff --git a/.github/ISSUE_TEMPLATE/crash.yml b/.github/ISSUE_TEMPLATE/crash.yml index 6fb7c94374..3e8fb08dd3 100644 --- a/.github/ISSUE_TEMPLATE/crash.yml +++ b/.github/ISSUE_TEMPLATE/crash.yml @@ -6,65 +6,73 @@ body: - type: checkboxes attributes: label: Issue Checklist + description: Be sure to complete these steps to increase the chances of your issue being addressed! options: - - label: I have properly named the issue - - label: I have checked the issues/discussions pages to see if the issue has been previously reported + - label: I have properly named my issue + - label: I have checked the Issues/Discussions pages to see if my issue has already been reported - type: dropdown attributes: - label: What platform are you using? + label: Platform + description: Which platform are you playing on? options: - - Newgrounds (Web) - - Itch.io (Web) + - Newgrounds (Web/HTML5) + - Itch.io (Web/HTML5) - Itch.io (Downloadable Build) - Windows - Itch.io (Downloadable Build) - MacOS - Itch.io (Downloadable Build) - Linux + - Compiled from GitHub Source Code validations: required: true - type: dropdown attributes: - label: If you are playing on a browser, which one are you using? + label: Browser + description: (Web/HTML5 users only) Which browser are you playing on? options: - Google Chrome - Microsoft Edge - Firefox - Opera - Safari - - Other (Specify below) + - Other (Specify in Description field) - type: input attributes: label: Version - description: What version are you using? - placeholder: ex. 0.4.1 + description: Which version are you playing on? The game version is in the bottom left corner of the main menu. + placeholder: ex. 0.5.0 validations: required: true - type: markdown attributes: - value: "## Describe your issue." + value: "## Describe the crash." - type: markdown attributes: value: "### Please do not report issues from other engines. These must be reported in their respective repositories." - - type: markdown - attributes: - value: "#### Provide as many details as you can." - - type: textarea attributes: - label: Context (Provide screenshots or videos of the crash happening) + label: Description + description: Include screenshots or videos of the crash happening. Provide as much detail as you can. + placeholder: Describe the crash here... + validations: + required: true - type: textarea attributes: - label: Steps to reproduce + label: Steps to Reproduce + description: What steps can other people take to reliably trigger this crash? + placeholder: 1. Open the game... validations: required: true - type: textarea attributes: - label: Crash logs (can be found in the logs folder where Funkin.exe is) + label: Crash logs + description: These can be found in the logs folder where Funkin.exe is. + placeholder: Upload your logs here... validations: required: true diff --git a/.github/ISSUE_TEMPLATE/enhancement.yml b/.github/ISSUE_TEMPLATE/enhancement.yml index 816e4a12b1..dfb4ace959 100644 --- a/.github/ISSUE_TEMPLATE/enhancement.yml +++ b/.github/ISSUE_TEMPLATE/enhancement.yml @@ -6,10 +6,13 @@ body: - type: checkboxes attributes: label: Issue Checklist + description: Be sure to complete these steps to increase the chances of your suggestion being considered! options: - - label: I have properly named the enhancement - - label: I have checked the issues/discussions pages to see if the enhancement has been previously suggested + - label: I have properly named my enhancement + - label: I have checked the Issues/Discussions pages to see if my enhancement has already been suggested - type: textarea attributes: label: What is your suggestion, and why should it be implemented? + validations: + required: true From 6df80ba69d0e24269f40471f83462cab7d5e13cf Mon Sep 17 00:00:00 2001 From: Hundrec Date: Sat, 28 Sep 2024 17:51:50 -0700 Subject: [PATCH 140/143] style: Fix some misspellings and grammar in code documentation fowl -> foul, among other things --- source/funkin/Preferences.hx | 2 +- source/funkin/save/Save.hx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/funkin/Preferences.hx b/source/funkin/Preferences.hx index 648880ad42..b3da56f657 100644 --- a/source/funkin/Preferences.hx +++ b/source/funkin/Preferences.hx @@ -37,7 +37,7 @@ class Preferences } /** - * Whether some particularly fowl language is displayed. + * Whether some particularly foul language is displayed. * @default `true` */ public static var naughtyness(get, set):Bool; diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index dc92f7f1a6..77cdcafe5c 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -1152,7 +1152,7 @@ typedef SaveDataOptions = var framerate:Int; /** - * Whether some particularly fowl language is displayed. + * Whether some particularly foul language is displayed. * @default `true` */ var naughtyness:Bool; @@ -1188,20 +1188,20 @@ typedef SaveDataOptions = var autoPause:Bool; /** - * Offset the users inputs by this many ms. + * Offset the user's inputs by this many ms. * @default `0` */ var inputOffset:Int; /** - * Affects the delay between the audio and the visuals during gameplay + * Affects the delay between the audio and the visuals during gameplay. * @default `0` */ var audioVisualOffset:Int; /** * If we want the framerate to be unlocked on HTML5. - * @default `false + * @default `false` */ var unlockedFramerate:Bool; From 2175beaa651e009332202985be4b7eb4ed36e5a4 Mon Sep 17 00:00:00 2001 From: Hundrec Date: Sat, 28 Sep 2024 17:51:50 -0700 Subject: [PATCH 141/143] style: Fix some misspellings and grammar in code documentation fowl -> foul, among other things --- source/funkin/Preferences.hx | 2 +- source/funkin/save/Save.hx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/funkin/Preferences.hx b/source/funkin/Preferences.hx index 648880ad42..b3da56f657 100644 --- a/source/funkin/Preferences.hx +++ b/source/funkin/Preferences.hx @@ -37,7 +37,7 @@ class Preferences } /** - * Whether some particularly fowl language is displayed. + * Whether some particularly foul language is displayed. * @default `true` */ public static var naughtyness(get, set):Bool; diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index dc92f7f1a6..77cdcafe5c 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -1152,7 +1152,7 @@ typedef SaveDataOptions = var framerate:Int; /** - * Whether some particularly fowl language is displayed. + * Whether some particularly foul language is displayed. * @default `true` */ var naughtyness:Bool; @@ -1188,20 +1188,20 @@ typedef SaveDataOptions = var autoPause:Bool; /** - * Offset the users inputs by this many ms. + * Offset the user's inputs by this many ms. * @default `0` */ var inputOffset:Int; /** - * Affects the delay between the audio and the visuals during gameplay + * Affects the delay between the audio and the visuals during gameplay. * @default `0` */ var audioVisualOffset:Int; /** * If we want the framerate to be unlocked on HTML5. - * @default `false + * @default `false` */ var unlockedFramerate:Bool; From c255f35945bcff42121e551d3f60758222c03c60 Mon Sep 17 00:00:00 2001 From: ACrazyTown Date: Fri, 20 Sep 2024 18:13:17 +0200 Subject: [PATCH 142/143] fix: Stop allowing inputs after selecting a character --- source/funkin/ui/charSelect/CharSelectSubState.hx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/funkin/ui/charSelect/CharSelectSubState.hx b/source/funkin/ui/charSelect/CharSelectSubState.hx index daea963210..83bf15e9d5 100644 --- a/source/funkin/ui/charSelect/CharSelectSubState.hx +++ b/source/funkin/ui/charSelect/CharSelectSubState.hx @@ -796,6 +796,11 @@ class CharSelectSubState extends MusicBeatSubState if (allowInput && !pressedSelect && controls.ACCEPT) { + spamUp = false; + spamDown = false; + spamLeft = false; + spamRight = false; + cursorConfirmed.visible = true; cursorConfirmed.animation.play("idle", true); From 78521e613ac7459a12e1727f4530c748ad516036 Mon Sep 17 00:00:00 2001 From: Cartridge-Man Date: Fri, 2 Aug 2024 09:53:48 -0500 Subject: [PATCH 143/143] docs: Added modding docs link in readme Wrong Link, Whoops! --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 34ec930f62..29077d7f15 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ To learn how to install the necessary dependencies and compile the game from sou Please check out our [Contributor's guide](./CONTRIBUTORS.md) on how you can actively participate in the development of Friday Night Funkin'. +# Modding + +Feel free to start learning to mod the game by reading our [documentation](https://funkincrew.github.io/funkin-modding-docs/) and guide to modding. + # Credits and Special Thanks Full credits can be found in-game, or in the `credits.json` file which is located [here](https://github.com/FunkinCrew/funkin.assets/blob/main/exclude/data/credits.json).