From e2b0ed98dd0a48435d222a8442ff6364e7c057db Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 13 Dec 2023 23:11:19 -0500 Subject: [PATCH 01/17] Fix a bug where making one selection and then making a different one would leave the original highlighted --- .../ui/debug/charting/ChartEditorState.hx | 21 +++++--- .../components/ChartEditorNotePreview.hx | 17 +++++- source/funkin/util/tools/ArrayTools.hx | 52 +++++++++++++++++++ 3 files changed, 82 insertions(+), 8 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 78de08fdf..b24bc1d95 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -753,15 +753,23 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState function set_currentNoteSelection(value:Array):Array { + // This value is true if all elements of the current selection are also in the new selection. + var isSuperset:Bool = currentNoteSelection.isSubset(value); + var isEqual:Bool = currentNoteSelection.isEqualUnordered(value); + currentNoteSelection = value; - if (currentNoteSelection.length > 0) + if (!isEqual) { - notePreview.addNotes(currentNoteSelection, Std.int(songLengthInMs), true); - } - else - { - notePreviewDirty = true; + if (currentNoteSelection.length > 0 && isSuperset) + { + notePreview.addSelectedNotes(currentNoteSelection, Std.int(songLengthInMs)); + } + else + { + // The new selection removes elements from the old selection, so we have to redraw the note preview. + notePreviewDirty = true; + } } return currentNoteSelection; @@ -5295,6 +5303,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // TODO: Only update the notes that have changed. notePreview.erase(); notePreview.addNotes(currentSongChartNoteData, Std.int(songLengthInMs)); + notePreview.addSelectedNotes(currentNoteSelection, Std.int(songLengthInMs)); notePreview.addEvents(currentSongChartEventData, Std.int(songLengthInMs)); } diff --git a/source/funkin/ui/debug/charting/components/ChartEditorNotePreview.hx b/source/funkin/ui/debug/charting/components/ChartEditorNotePreview.hx index 09c99531d..598cbb544 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorNotePreview.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorNotePreview.hx @@ -80,11 +80,24 @@ class ChartEditorNotePreview extends FlxSprite * @param notes The data for the notes. * @param songLengthInMs The total length of the song in milliseconds. */ - public function addNotes(notes:Array, songLengthInMs:Int, ?isSelection:Bool = false):Void + public function addNotes(notes:Array, songLengthInMs:Int):Void { for (note in notes) { - addNote(note, songLengthInMs, isSelection); + addNote(note, songLengthInMs, false); + } + } + + /** + * Add an array of selected notes to the preview. + * @param notes The data for the notes. + * @param songLengthInMs The total length of the song in milliseconds. + */ + public function addSelectedNotes(notes:Array, songLengthInMs:Int):Void + { + for (note in notes) + { + addNote(note, songLengthInMs, true); } } diff --git a/source/funkin/util/tools/ArrayTools.hx b/source/funkin/util/tools/ArrayTools.hx index a88f8a861..925bb67a5 100644 --- a/source/funkin/util/tools/ArrayTools.hx +++ b/source/funkin/util/tools/ArrayTools.hx @@ -76,4 +76,56 @@ class ArrayTools while (array.length > 0) array.pop(); } + + /** + * Return true only if both arrays contain the same elements (possibly in a different order). + * @param a The first array to compare. + * @param b The second array to compare. + * @return Weather both arrays contain the same elements. + */ + public static function isEqualUnordered(a:Array, b:Array):Bool + { + if (a.length != b.length) return false; + for (element in a) + { + if (!b.contains(element)) return false; + } + for (element in b) + { + if (!a.contains(element)) return false; + } + return true; + } + + /** + * Returns true if `superset` contains all elements of `subset`. + * @param superset The array to query for each element. + * @param subset The array containing the elements to query for. + * @return Weather `superset` contains all elements of `subset`. + */ + public static function isSuperset(superset:Array, subset:Array):Bool + { + // Shortcuts. + if (subset.length == 0) return true; + if (subset.length > superset.length) return false; + + // Check each element. + for (element in subset) + { + if (!superset.contains(element)) return false; + } + return true; + } + + /** + * Returns true if `superset` contains all elements of `subset`. + * @param subset The array containing the elements to query for. + * @param superset The array to query for each element. + * @return Weather `superset` contains all elements of `subset`. + */ + public static function isSubset(subset:Array, superset:Array):Bool + { + // Switch it around. + return isSuperset(superset, subset); + } } From 3f2d1b4c1b188bba6fbe5ad0413abebf43db3bfa Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 14 Dec 2023 17:34:02 -0500 Subject: [PATCH 02/17] Update haxelibs, add flixel-text-input to fix overlapping text --- .vscode/settings.json | 3 +-- Project.xml | 10 ++++++---- hmm.json | 13 +++++++++---- .../funkin/play/character/MultiSparrowCharacter.hx | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 92d49c3d4..cefbadcf6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,8 +4,7 @@ "editor.formatOnSave": true, "editor.formatOnPaste": true, "editor.codeActionsOnSave": { - // Compilation server issues can cause auto-cleanup to remove valid imports. - "source.organizeImports": false + "source.organizeImports": "never" }, "editor.defaultFormatter": "nadako.vshaxe", "editor.tabSize": 2 diff --git a/Project.xml b/Project.xml index 4c0ffdce7..e0677b026 100644 --- a/Project.xml +++ b/Project.xml @@ -99,18 +99,20 @@ - + + - + + + + - - diff --git a/hmm.json b/hmm.json index a10eed1a6..b85413bae 100644 --- a/hmm.json +++ b/hmm.json @@ -11,7 +11,7 @@ "name": "flixel", "type": "git", "dir": null, - "ref": "da04cbda49a4c5eebe93fb61296dbaf4f0f1b556", + "ref": "9bdea914f3d0485b9b3ec158f28875b5ac95d476", "url": "https://github.com/EliteMasterEric/flixel" }, { @@ -21,6 +21,11 @@ "ref": "c8c41e26d463aaf2edc0582fb23b6e228235bd16", "url": "https://github.com/EliteMasterEric/flixel-addons" }, + { + "name": "flixel-text-input", + "type": "haxelib", + "version": "1.1.0" + }, { "name": "flixel-ui", "type": "git", @@ -32,8 +37,8 @@ "name": "flxanimate", "type": "git", "dir": null, - "ref": "dd2903f7dc7024335b981edf2a770760cec912e1", - "url": "https://github.com/ninjamuffin99/flxanimate" + "ref": "d7c5621be742e2c98d523dfe5af7528835eaff1e", + "url": "https://github.com/EliteMasterEric/flxanimate" }, { "name": "format", @@ -158,4 +163,4 @@ "version": "0.11.0" } ] -} +} \ No newline at end of file diff --git a/source/funkin/play/character/MultiSparrowCharacter.hx b/source/funkin/play/character/MultiSparrowCharacter.hx index 968f613ff..0fc07399c 100644 --- a/source/funkin/play/character/MultiSparrowCharacter.hx +++ b/source/funkin/play/character/MultiSparrowCharacter.hx @@ -205,7 +205,7 @@ class MultiSparrowCharacter extends BaseCharacter graphic = value.parent; this.frames = value; this.frame = value.getByIndex(0); - this.numFrames = value.numFrames; + // this.numFrames = value.numFrames; resetHelpers(); this.bakedRotationAngle = 0; this.animation.frameIndex = 0; From 8dd6f29e2682aa7d9828ee62a9b44edeb10c3ec4 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 15 Dec 2023 04:34:59 -0500 Subject: [PATCH 03/17] Move all haxelib forks to the FunkinCrew organization. --- hmm.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/hmm.json b/hmm.json index b85413bae..96ee75bc1 100644 --- a/hmm.json +++ b/hmm.json @@ -12,14 +12,14 @@ "type": "git", "dir": null, "ref": "9bdea914f3d0485b9b3ec158f28875b5ac95d476", - "url": "https://github.com/EliteMasterEric/flixel" + "url": "https://github.com/FunkinCrew/flixel" }, { "name": "flixel-addons", "type": "git", "dir": null, - "ref": "c8c41e26d463aaf2edc0582fb23b6e228235bd16", - "url": "https://github.com/EliteMasterEric/flixel-addons" + "ref": "fd3aecdeb5635fa0428dffee204fc78fc26b5885", + "url": "https://github.com/FunkinCrew/flixel-addons" }, { "name": "flixel-text-input", @@ -38,7 +38,7 @@ "type": "git", "dir": null, "ref": "d7c5621be742e2c98d523dfe5af7528835eaff1e", - "url": "https://github.com/EliteMasterEric/flxanimate" + "url": "https://github.com/FunkinCrew/flxanimate" }, { "name": "format", @@ -54,14 +54,14 @@ "name": "haxeui-core", "type": "git", "dir": null, - "ref": "032192e849cdb7d1070c0a3241c58ee555ffaccc", + "ref": "7021f1fbab928268d9196a73e7f47461ca3c3e4d", "url": "https://github.com/haxeui/haxeui-core" }, { "name": "haxeui-flixel", "type": "git", "dir": null, - "ref": "d90758b229d05206400df867d333c79d9fdbd478", + "ref": "26b6bb132c92dfa9b77b4a61eaeda8f9a9efda98", "url": "https://github.com/haxeui/haxeui-flixel" }, { @@ -100,15 +100,15 @@ "name": "json2object", "type": "git", "dir": null, - "ref": "f4df19cfa196f85eece55c3367021fc965f1fa9a", - "url": "https://github.com/EliteMasterEric/json2object" + "ref": "a0a78b60c41e47bae8bfa422488a199a58b4474e", + "url": "https://github.com/FunkinCrew/json2object" }, { "name": "lime", "type": "git", "dir": null, "ref": "737b86f121cdc90358d59e2e527934f267c94a2c", - "url": "https://github.com/EliteMasterEric/lime" + "url": "https://github.com/FunkinCrew/lime" }, { "name": "mconsole", @@ -129,21 +129,21 @@ "type": "git", "dir": "src", "ref": "master", - "url": "https://github.com/EliteMasterEric/mockatoo" + "url": "https://github.com/FunkinCrew/mockatoo" }, { "name": "munit", "type": "git", "dir": "src", "ref": "master", - "url": "https://github.com/EliteMasterEric/MassiveUnit" + "url": "https://github.com/FunkinCrew/MassiveUnit" }, { "name": "openfl", "type": "git", "dir": null, "ref": "f229d76361c7e31025a048fe7909847f75bb5d5e", - "url": "https://github.com/EliteMasterEric/openfl" + "url": "https://github.com/FunkinCrew/openfl" }, { "name": "polymod", @@ -163,4 +163,4 @@ "version": "0.11.0" } ] -} \ No newline at end of file +} From 88ca58f9e22ed96d835ef28cd42dfc2aaa8997e0 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Fri, 15 Dec 2023 21:09:01 -0500 Subject: [PATCH 04/17] Fixes for updated HaxeUI and Flixel. --- source/funkin/play/PlayState.hx | 21 +---- .../ui/debug/charting/ChartEditorState.hx | 4 +- .../dialogs/ChartEditorAboutDialog.hx | 8 +- .../charting/dialogs/ChartEditorBaseDialog.hx | 8 +- .../charting/dialogs/ChartEditorBaseMenu.hx | 6 +- .../ChartEditorCharacterIconSelectorMenu.hx | 28 +++---- .../dialogs/ChartEditorUploadChartDialog.hx | 21 ++--- .../dialogs/ChartEditorWelcomeDialog.hx | 26 +++---- .../toolboxes/ChartEditorBaseToolbox.hx | 6 +- .../toolboxes/ChartEditorMetadataToolbox.hx | 78 +++++++++---------- source/funkin/ui/freeplay/FreeplayState.hx | 5 +- 11 files changed, 99 insertions(+), 112 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 81757bcae..e0932e756 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1097,23 +1097,6 @@ class PlayState extends MusicBeatSubState } #end - /** - * This function is called whenever Flixel switches switching to a new FlxState. - * @return Whether to actually switch to the new state. - */ - @:haxe.warning("-WDeprecated") - override function switchTo(nextState:FlxState):Bool - { - var result:Bool = super.switchTo(nextState); - - if (result) - { - performCleanup(); - } - - return result; - } - /** * Removes any references to the current stage, then clears the stage cache, * then reloads all the stages. @@ -1251,7 +1234,7 @@ class PlayState extends MusicBeatSubState return true; } - override function destroy():Void + public override function destroy():Void { if (currentConversation != null) { @@ -1259,6 +1242,8 @@ class PlayState extends MusicBeatSubState currentConversation.kill(); } + performCleanup(); + super.destroy(); } diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 78de08fdf..fa55750bf 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -2675,14 +2675,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState * Open the backups folder in the file explorer. * Don't call this on HTML5. */ - function openBackupsFolder(?_):Void + function openBackupsFolder(?_):Bool { #if sys // TODO: Is there a way to open a folder and highlight a file in it? var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]); WindowUtil.openFolder(absoluteBackupsPath); + return true; #else trace('No file system access, cannot open backups folder.'); + return false; #end } diff --git a/source/funkin/ui/debug/charting/dialogs/ChartEditorAboutDialog.hx b/source/funkin/ui/debug/charting/dialogs/ChartEditorAboutDialog.hx index e6f57c49f..8b55be540 100644 --- a/source/funkin/ui/debug/charting/dialogs/ChartEditorAboutDialog.hx +++ b/source/funkin/ui/debug/charting/dialogs/ChartEditorAboutDialog.hx @@ -5,14 +5,14 @@ import funkin.ui.debug.charting.dialogs.ChartEditorBaseDialog.DialogParams; @:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/chart-editor/dialogs/about.xml")) class ChartEditorAboutDialog extends ChartEditorBaseDialog { - public function new(state2:ChartEditorState, params2:DialogParams) + public function new(chartEditorState2:ChartEditorState, params2:DialogParams) { - super(state2, params2); + super(chartEditorState2, params2); } - public static function build(state:ChartEditorState, ?closable:Bool, ?modal:Bool):ChartEditorAboutDialog + public static function build(chartEditorState:ChartEditorState, ?closable:Bool, ?modal:Bool):ChartEditorAboutDialog { - var dialog = new ChartEditorAboutDialog(state, + var dialog = new ChartEditorAboutDialog(chartEditorState, { closable: closable ?? true, modal: modal ?? true diff --git a/source/funkin/ui/debug/charting/dialogs/ChartEditorBaseDialog.hx b/source/funkin/ui/debug/charting/dialogs/ChartEditorBaseDialog.hx index 6f76e543e..5b7cb15e1 100644 --- a/source/funkin/ui/debug/charting/dialogs/ChartEditorBaseDialog.hx +++ b/source/funkin/ui/debug/charting/dialogs/ChartEditorBaseDialog.hx @@ -11,16 +11,16 @@ import haxe.ui.core.Component; @:access(funkin.ui.debug.charting.ChartEditorState) class ChartEditorBaseDialog extends Dialog { - var state:ChartEditorState; + var chartEditorState:ChartEditorState; var params:DialogParams; var locked:Bool = false; - public function new(state:ChartEditorState, params:DialogParams) + public function new(chartEditorState:ChartEditorState, params:DialogParams) { super(); - this.state = state; + this.chartEditorState = chartEditorState; this.params = params; this.destroyOnClose = true; @@ -47,7 +47,7 @@ class ChartEditorBaseDialog extends Dialog */ public function onClose(event:DialogEvent):Void { - state.isHaxeUIDialogOpen = false; + chartEditorState.isHaxeUIDialogOpen = false; } /** diff --git a/source/funkin/ui/debug/charting/dialogs/ChartEditorBaseMenu.hx b/source/funkin/ui/debug/charting/dialogs/ChartEditorBaseMenu.hx index cb4cb447b..19ca2535c 100644 --- a/source/funkin/ui/debug/charting/dialogs/ChartEditorBaseMenu.hx +++ b/source/funkin/ui/debug/charting/dialogs/ChartEditorBaseMenu.hx @@ -11,13 +11,13 @@ import haxe.ui.containers.menus.Menu; @:access(funkin.ui.debug.charting.ChartEditorState) class ChartEditorBaseMenu extends Menu { - var state:ChartEditorState; + var chartEditorState:ChartEditorState; - public function new(state:ChartEditorState) + public function new(chartEditorState:ChartEditorState) { super(); - this.state = state; + this.chartEditorState = chartEditorState; // this.destroyOnClose = true; } diff --git a/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx b/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx index d7e9c259b..eb60cb6db 100644 --- a/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx +++ b/source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx @@ -24,9 +24,9 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu public var charSelectScroll:ScrollView; public var charIconName:Label; - public function new(state2:ChartEditorState, charType:CharacterType, lockPosition:Bool = false) + public function new(chartEditorState2:ChartEditorState, charType:CharacterType, lockPosition:Bool = false) { - super(state2); + super(chartEditorState2); initialize(charType, lockPosition); this.alpha = 0; @@ -38,17 +38,17 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu { var currentCharId:String = switch (charType) { - case BF: state.currentSongMetadata.playData.characters.player; - case GF: state.currentSongMetadata.playData.characters.girlfriend; - case DAD: state.currentSongMetadata.playData.characters.opponent; + case BF: chartEditorState.currentSongMetadata.playData.characters.player; + case GF: chartEditorState.currentSongMetadata.playData.characters.girlfriend; + case DAD: chartEditorState.currentSongMetadata.playData.characters.opponent; default: throw 'Invalid charType: ' + charType; }; // Position this menu. var targetHealthIcon:Null = switch (charType) { - case BF: state.healthIconBF; - case DAD: state.healthIconDad; + case BF: chartEditorState.healthIconBF; + case DAD: chartEditorState.healthIconDad; default: null; }; @@ -101,14 +101,14 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu charButton.onClick = _ -> { switch (charType) { - case BF: state.currentSongMetadata.playData.characters.player = charId; - case GF: state.currentSongMetadata.playData.characters.girlfriend = charId; - case DAD: state.currentSongMetadata.playData.characters.opponent = charId; + case BF: chartEditorState.currentSongMetadata.playData.characters.player = charId; + case GF: chartEditorState.currentSongMetadata.playData.characters.girlfriend = charId; + case DAD: chartEditorState.currentSongMetadata.playData.characters.opponent = charId; default: throw 'Invalid charType: ' + charType; }; - state.healthIconsDirty = true; - state.refreshToolbox(ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); + chartEditorState.healthIconsDirty = true; + chartEditorState.refreshToolbox(ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); }; charButton.onMouseOver = _ -> { @@ -123,9 +123,9 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu charIconName.text = defaultText; } - public static function build(state2:ChartEditorState, charType:CharacterType, lockPosition:Bool = false):ChartEditorCharacterIconSelectorMenu + public static function build(chartEditorState:ChartEditorState, charType:CharacterType, lockPosition:Bool = false):ChartEditorCharacterIconSelectorMenu { - var menu = new ChartEditorCharacterIconSelectorMenu(state2, charType, lockPosition); + var menu = new ChartEditorCharacterIconSelectorMenu(chartEditorState, charType, lockPosition); Screen.instance.addComponent(menu); diff --git a/source/funkin/ui/debug/charting/dialogs/ChartEditorUploadChartDialog.hx b/source/funkin/ui/debug/charting/dialogs/ChartEditorUploadChartDialog.hx index 4b7a950be..5b84148c6 100644 --- a/source/funkin/ui/debug/charting/dialogs/ChartEditorUploadChartDialog.hx +++ b/source/funkin/ui/debug/charting/dialogs/ChartEditorUploadChartDialog.hx @@ -64,12 +64,12 @@ class ChartEditorUploadChartDialog extends ChartEditorBaseDialog if (event.button != DialogButton.APPLY && !this.closable) { // User cancelled the wizard! Back to the welcome dialog. - state.openWelcomeDialog(this.closable); + chartEditorState.openWelcomeDialog(this.closable); } for (dropTarget in dropHandlers) { - state.removeDropHandler(dropTarget); + chartEditorState.removeDropHandler(dropTarget); } } @@ -111,20 +111,21 @@ class ChartEditorUploadChartDialog extends ChartEditorBaseDialog try { - var result:Null> = ChartEditorImportExportHandler.loadFromFNFCPath(state, path.toString()); + var result:Null> = ChartEditorImportExportHandler.loadFromFNFCPath(chartEditorState, path.toString()); if (result != null) { - state.success('Loaded Chart', result.length == 0 ? 'Loaded chart (${path.toString()})' : 'Loaded chart (${path.toString()})\n${result.join("\n")}'); + chartEditorState.success('Loaded Chart', + result.length == 0 ? 'Loaded chart (${path.toString()})' : 'Loaded chart (${path.toString()})\n${result.join("\n")}'); this.hideDialog(DialogButton.APPLY); } else { - state.failure('Failed to Load Chart', 'Failed to load chart (${path.toString()})'); + chartEditorState.failure('Failed to Load Chart', 'Failed to load chart (${path.toString()})'); } } catch (err) { - state.failure('Failed to Load Chart', 'Failed to load chart (${path.toString()}): ${err}'); + chartEditorState.failure('Failed to Load Chart', 'Failed to load chart (${path.toString()}): ${err}'); } } @@ -139,19 +140,19 @@ class ChartEditorUploadChartDialog extends ChartEditorBaseDialog { try { - var result:Null> = ChartEditorImportExportHandler.loadFromFNFC(state, selectedFile.bytes); + var result:Null> = ChartEditorImportExportHandler.loadFromFNFC(chartEditorState, selectedFile.bytes); if (result != null) { - state.success('Loaded Chart', + chartEditorState.success('Loaded Chart', result.length == 0 ? 'Loaded chart (${selectedFile.name})' : 'Loaded chart (${selectedFile.name})\n${result.join("\n")}'); - if (selectedFile.fullPath != null) state.currentWorkingFilePath = selectedFile.fullPath; + if (selectedFile.fullPath != null) chartEditorState.currentWorkingFilePath = selectedFile.fullPath; this.hideDialog(DialogButton.APPLY); } } catch (err) { - state.failure('Failed to Load Chart', 'Failed to load chart (${selectedFile.name}): ${err}'); + chartEditorState.failure('Failed to Load Chart', 'Failed to load chart (${selectedFile.name}): ${err}'); } } } diff --git a/source/funkin/ui/debug/charting/dialogs/ChartEditorWelcomeDialog.hx b/source/funkin/ui/debug/charting/dialogs/ChartEditorWelcomeDialog.hx index 2a30c7d9e..7539b9725 100644 --- a/source/funkin/ui/debug/charting/dialogs/ChartEditorWelcomeDialog.hx +++ b/source/funkin/ui/debug/charting/dialogs/ChartEditorWelcomeDialog.hx @@ -41,26 +41,26 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog // Add items to the Recent Charts list #if sys - for (chartPath in state.previousWorkingFilePaths) + for (chartPath in chartEditorState.previousWorkingFilePaths) { if (chartPath == null) continue; - this.addRecentFilePath(state, chartPath); + this.addRecentFilePath(chartEditorState, chartPath); } #else this.addHTML5RecentFileMessage(); #end // Add items to the Load From Template list - this.buildTemplateSongList(state); + this.buildTemplateSongList(chartEditorState); } /** * @param state The current state of the chart editor. * @return A newly created `ChartEditorWelcomeDialog`. */ - public static function build(state:ChartEditorState, ?closable:Bool, ?modal:Bool):ChartEditorWelcomeDialog + public static function build(chartEditorState:ChartEditorState, ?closable:Bool, ?modal:Bool):ChartEditorWelcomeDialog { - var dialog = new ChartEditorWelcomeDialog(state, + var dialog = new ChartEditorWelcomeDialog(chartEditorState, { closable: closable ?? false, modal: modal ?? true @@ -102,12 +102,12 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog var result:Null> = ChartEditorImportExportHandler.loadFromFNFCPath(state, chartPath); if (result != null) { - state.success('Loaded Chart', + chartEditorState.success('Loaded Chart', result.length == 0 ? 'Loaded chart (${chartPath.toString()})' : 'Loaded chart (${chartPath.toString()})\n${result.join("\n")}'); } else { - state.error('Failed to Load Chart', 'Failed to load chart (${chartPath.toString()})'); + chartEditorState.error('Failed to Load Chart', 'Failed to load chart (${chartPath.toString()})'); } } @@ -157,7 +157,7 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog this.hideDialog(DialogButton.CANCEL); // Load song from template - state.loadSongAsTemplate(targetSongId); + chartEditorState.loadSongAsTemplate(targetSongId); }); } } @@ -184,7 +184,7 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog this.hideDialog(DialogButton.CANCEL); // Open the "Open Chart" dialog - state.openBrowseFNFC(false); + chartEditorState.openBrowseFNFC(false); } /** @@ -199,7 +199,7 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog // // Create Song Wizard // - state.openCreateSongWizardBasicOnly(false); + chartEditorState.openCreateSongWizardBasicOnly(false); } /** @@ -214,7 +214,7 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog // // Create Song Wizard // - state.openCreateSongWizardErectOnly(false); + chartEditorState.openCreateSongWizardErectOnly(false); } /** @@ -229,7 +229,7 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog // // Create Song Wizard // - state.openCreateSongWizardBasicErect(false); + chartEditorState.openCreateSongWizardBasicErect(false); } /** @@ -242,6 +242,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog this.hideDialog(DialogButton.CANCEL); // Open the "Import Chart" dialog - state.openImportChartWizard('legacy', false); + chartEditorState.openImportChartWizard('legacy', false); } } diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorBaseToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorBaseToolbox.hx index c4c532205..7df06c249 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorBaseToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorBaseToolbox.hx @@ -12,13 +12,13 @@ import haxe.ui.core.Component; @:access(funkin.ui.debug.charting.ChartEditorState) class ChartEditorBaseToolbox extends CollapsibleDialog { - var state:ChartEditorState; + var chartEditorState:ChartEditorState; - private function new(state:ChartEditorState) + private function new(chartEditorState:ChartEditorState) { super(); - this.state = state; + this.chartEditorState = chartEditorState; } /** diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx index e0ee4aca3..509aa5b07 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx @@ -40,9 +40,9 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox var frameVariation:Frame; var frameDifficulty:Frame; - public function new(state2:ChartEditorState) + public function new(chartEditorState2:ChartEditorState) { - super(state2); + super(chartEditorState2); initialize(); @@ -51,7 +51,7 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox function onClose(event:UIEvent) { - state.menubarItemToggleToolboxMetadata.selected = false; + chartEditorState.menubarItemToggleToolboxMetadata.selected = false; } function initialize():Void @@ -67,11 +67,11 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox if (valid) { inputSongName.removeClass('invalid-value'); - state.currentSongMetadata.songName = event.target.text; + chartEditorState.currentSongMetadata.songName = event.target.text; } else { - state.currentSongMetadata.songName = ''; + chartEditorState.currentSongMetadata.songName = ''; } }; @@ -81,11 +81,11 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox if (valid) { inputSongArtist.removeClass('invalid-value'); - state.currentSongMetadata.artist = event.target.text; + chartEditorState.currentSongMetadata.artist = event.target.text; } else { - state.currentSongMetadata.artist = ''; + chartEditorState.currentSongMetadata.artist = ''; } }; @@ -94,41 +94,41 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox if (valid) { - state.currentSongMetadata.playData.stage = event.data.id; + chartEditorState.currentSongMetadata.playData.stage = event.data.id; } }; - var startingValueStage = ChartEditorDropdowns.populateDropdownWithStages(inputStage, state.currentSongMetadata.playData.stage); + var startingValueStage = ChartEditorDropdowns.populateDropdownWithStages(inputStage, chartEditorState.currentSongMetadata.playData.stage); inputStage.value = startingValueStage; inputNoteStyle.onChange = function(event:UIEvent) { if (event.data?.id == null) return; - state.currentSongNoteStyle = event.data.id; + chartEditorState.currentSongNoteStyle = event.data.id; }; inputBPM.onChange = function(event:UIEvent) { if (event.value == null || event.value <= 0) return; // Use a command so we can undo/redo this action. - var startingBPM = state.currentSongMetadata.timeChanges[0].bpm; + var startingBPM = chartEditorState.currentSongMetadata.timeChanges[0].bpm; if (event.value != startingBPM) { - state.performCommand(new ChangeStartingBPMCommand(event.value)); + chartEditorState.performCommand(new ChangeStartingBPMCommand(event.value)); } }; inputOffsetInst.onChange = function(event:UIEvent) { if (event.value == null) return; - state.currentInstrumentalOffset = event.value; + chartEditorState.currentInstrumentalOffset = event.value; Conductor.instrumentalOffset = event.value; // Update song length. - state.songLengthInMs = (state.audioInstTrack?.length ?? 1000.0) + Conductor.instrumentalOffset; + chartEditorState.songLengthInMs = (chartEditorState.audioInstTrack?.length ?? 1000.0) + Conductor.instrumentalOffset; }; inputOffsetVocal.onChange = function(event:UIEvent) { if (event.value == null) return; - state.currentSongMetadata.offsets.setVocalOffset(state.currentSongMetadata.playData.characters.player, event.value); + chartEditorState.currentSongMetadata.offsets.setVocalOffset(chartEditorState.currentSongMetadata.playData.characters.player, event.value); }; inputScrollSpeed.onChange = function(event:UIEvent) { var valid:Bool = event.target.value != null && event.target.value > 0; @@ -136,25 +136,25 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox if (valid) { inputScrollSpeed.removeClass('invalid-value'); - state.currentSongChartScrollSpeed = event.target.value; + chartEditorState.currentSongChartScrollSpeed = event.target.value; } else { - state.currentSongChartScrollSpeed = 1.0; + chartEditorState.currentSongChartScrollSpeed = 1.0; } - labelScrollSpeed.text = 'Scroll Speed: ${state.currentSongChartScrollSpeed}x'; + labelScrollSpeed.text = 'Scroll Speed: ${chartEditorState.currentSongChartScrollSpeed}x'; }; buttonCharacterOpponent.onClick = function(_) { - state.openCharacterDropdown(CharacterType.DAD, false); + chartEditorState.openCharacterDropdown(CharacterType.DAD, false); }; buttonCharacterGirlfriend.onClick = function(_) { - state.openCharacterDropdown(CharacterType.GF, false); + chartEditorState.openCharacterDropdown(CharacterType.GF, false); }; buttonCharacterPlayer.onClick = function(_) { - state.openCharacterDropdown(CharacterType.BF, false); + chartEditorState.openCharacterDropdown(CharacterType.BF, false); }; refresh(); @@ -162,17 +162,17 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox public override function refresh():Void { - inputSongName.value = state.currentSongMetadata.songName; - inputSongArtist.value = state.currentSongMetadata.artist; - inputStage.value = state.currentSongMetadata.playData.stage; - inputNoteStyle.value = state.currentSongMetadata.playData.noteStyle; - inputBPM.value = state.currentSongMetadata.timeChanges[0].bpm; - inputScrollSpeed.value = state.currentSongChartScrollSpeed; - labelScrollSpeed.text = 'Scroll Speed: ${state.currentSongChartScrollSpeed}x'; - frameVariation.text = 'Variation: ${state.selectedVariation.toTitleCase()}'; - frameDifficulty.text = 'Difficulty: ${state.selectedDifficulty.toTitleCase()}'; + inputSongName.value = chartEditorState.currentSongMetadata.songName; + inputSongArtist.value = chartEditorState.currentSongMetadata.artist; + inputStage.value = chartEditorState.currentSongMetadata.playData.stage; + inputNoteStyle.value = chartEditorState.currentSongMetadata.playData.noteStyle; + inputBPM.value = chartEditorState.currentSongMetadata.timeChanges[0].bpm; + inputScrollSpeed.value = chartEditorState.currentSongChartScrollSpeed; + labelScrollSpeed.text = 'Scroll Speed: ${chartEditorState.currentSongChartScrollSpeed}x'; + frameVariation.text = 'Variation: ${chartEditorState.selectedVariation.toTitleCase()}'; + frameDifficulty.text = 'Difficulty: ${chartEditorState.selectedDifficulty.toTitleCase()}'; - var stageId:String = state.currentSongMetadata.playData.stage; + var stageId:String = chartEditorState.currentSongMetadata.playData.stage; var stageData:Null = StageDataParser.parseStageData(stageId); if (inputStage != null) { @@ -183,21 +183,21 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox var LIMIT = 6; - var charDataOpponent:CharacterData = CharacterDataParser.fetchCharacterData(state.currentSongMetadata.playData.characters.opponent); - buttonCharacterOpponent.icon = CharacterDataParser.getCharPixelIconAsset(state.currentSongMetadata.playData.characters.opponent); + var charDataOpponent:CharacterData = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.opponent); + buttonCharacterOpponent.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.opponent); buttonCharacterOpponent.text = charDataOpponent.name.length > LIMIT ? '${charDataOpponent.name.substr(0, LIMIT)}.' : '${charDataOpponent.name}'; - var charDataGirlfriend:CharacterData = CharacterDataParser.fetchCharacterData(state.currentSongMetadata.playData.characters.girlfriend); - buttonCharacterGirlfriend.icon = CharacterDataParser.getCharPixelIconAsset(state.currentSongMetadata.playData.characters.girlfriend); + var charDataGirlfriend:CharacterData = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.girlfriend); + buttonCharacterGirlfriend.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.girlfriend); buttonCharacterGirlfriend.text = charDataGirlfriend.name.length > LIMIT ? '${charDataGirlfriend.name.substr(0, LIMIT)}.' : '${charDataGirlfriend.name}'; - var charDataPlayer:CharacterData = CharacterDataParser.fetchCharacterData(state.currentSongMetadata.playData.characters.player); - buttonCharacterPlayer.icon = CharacterDataParser.getCharPixelIconAsset(state.currentSongMetadata.playData.characters.player); + var charDataPlayer:CharacterData = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.player); + buttonCharacterPlayer.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.player); buttonCharacterPlayer.text = charDataPlayer.name.length > LIMIT ? '${charDataPlayer.name.substr(0, LIMIT)}.' : '${charDataPlayer.name}'; } - public static function build(state:ChartEditorState):ChartEditorMetadataToolbox + public static function build(chartEditorState:ChartEditorState):ChartEditorMetadataToolbox { - return new ChartEditorMetadataToolbox(state); + return new ChartEditorMetadataToolbox(chartEditorState); } } diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index 371021114..7c69804d9 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -874,15 +874,14 @@ class FreeplayState extends MusicBeatSubState } } - @:haxe.warning("-WDeprecated") - override function switchTo(nextState:FlxState):Bool + public override function destroy():Void { + super.destroy(); var daSong = songs[curSelected]; if (daSong != null) { clearDaCache(daSong.songName); } - return super.switchTo(nextState); } function changeDiff(change:Int = 0) From 4fc56a22800aa2311f3726fb2feea1e8652ed473 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Fri, 15 Dec 2023 21:46:09 -0500 Subject: [PATCH 05/17] small fix to backups folder not existing --- assets | 2 +- .../debug/charting/handlers/ChartEditorImportExportHandler.hx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/assets b/assets index dfaf23dfa..c354795f7 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit dfaf23dfa11ff67be2eea9113a80ff5dc0040f76 +Subproject commit c354795f7f560fa096b855c6e6bca745f77fa414 diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx index 0c8d6a205..267d2208a 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorImportExportHandler.hx @@ -315,6 +315,8 @@ class ChartEditorImportExportHandler public static function getLatestBackupPath():Null { #if sys + if (!sys.FileSystem.exists(BACKUPS_PATH)) sys.FileSystem.createDirectory(BACKUPS_PATH); + var entries:Array = sys.FileSystem.readDirectory(BACKUPS_PATH); entries.sort(SortUtil.alphabetically); From 9e27095659faa8a458516fc43fd6848653fe891a Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 19 Dec 2023 01:21:26 -0500 Subject: [PATCH 06/17] Update assets. --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index c354795f7..6f17eb051 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit c354795f7f560fa096b855c6e6bca745f77fa414 +Subproject commit 6f17eb051e2609d59a591d4e6eb78e37c6e90adb From 4ff5bd21df738f2b63e7679330afd56a0b53a975 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 19 Dec 2023 01:23:42 -0500 Subject: [PATCH 07/17] Fixes to the FNF Legacy JSON parser --- source/funkin/data/DataParse.hx | 45 +++++++++++++++---- source/funkin/data/level/LevelRegistry.hx | 2 + .../data/notestyle/NoteStyleRegistry.hx | 2 + source/funkin/data/song/SongData.hx | 2 +- source/funkin/data/song/SongDataUtils.hx | 1 + source/funkin/data/song/SongRegistry.hx | 14 ++++++ .../data/song/importer/ChartManifestData.hx | 1 + .../data/song/importer/FNFLegacyData.hx | 3 +- .../data/song/importer/FNFLegacyImporter.hx | 22 ++++++++- .../source/funkin/data/BaseRegistryTest.hx | 2 + 10 files changed, 83 insertions(+), 11 deletions(-) diff --git a/source/funkin/data/DataParse.hx b/source/funkin/data/DataParse.hx index cbd168a61..49dde0198 100644 --- a/source/funkin/data/DataParse.hx +++ b/source/funkin/data/DataParse.hx @@ -178,7 +178,31 @@ class DataParse switch (json.value) { case JObject(fields): - return cast Tools.getValue(json); + var result:LegacyNoteSection = + { + mustHitSection: false, + sectionNotes: [], + }; + for (field in fields) + { + switch (field.name) + { + case 'sectionNotes': + result.sectionNotes = legacyNotes(field.value, field.name); + + case 'mustHitSection': + result.mustHitSection = Tools.getValue(field.value); + case 'typeOfSection': + result.typeOfSection = Tools.getValue(field.value); + case 'lengthInSteps': + result.lengthInSteps = Tools.getValue(field.value); + case 'changeBPM': + result.changeBPM = Tools.getValue(field.value); + case 'bpm': + result.bpm = Tools.getValue(field.value); + } + } + return result; default: throw 'Expected property $name to be an object, but it was ${json.value}.'; } @@ -189,7 +213,12 @@ class DataParse switch (json.value) { case JObject(fields): - return cast Tools.getValue(json); + var result = {}; + for (field in fields) + { + Reflect.setField(result, field.name, legacyNoteSectionArray(field.value, field.name)); + } + return result; default: throw 'Expected property $name to be an object, but it was ${json.value}.'; } @@ -211,13 +240,13 @@ class DataParse switch (json.value) { case JArray(values): - // var time:Null = values[0] == null ? null : Tools.getValue(values[0]); - // var data:Null = values[1] == null ? null : Tools.getValue(values[1]); - // var length:Null = values[2] == null ? null : Tools.getValue(values[2]); - // var alt:Null = values[3] == null ? null : Tools.getValue(values[3]); + var time:Null = values[0] == null ? null : Tools.getValue(values[0]); + var data:Null = values[1] == null ? null : Tools.getValue(values[1]); + var length:Null = values[2] == null ? null : Tools.getValue(values[2]); + var alt:Null = values[3] == null ? null : Tools.getValue(values[3]); - // return new LegacyNote(time, data, length, alt); - return null; + return new LegacyNote(time, data, length, alt); + // return null; default: throw 'Expected property $name to be a note, but it was ${json.value}.'; } diff --git a/source/funkin/data/level/LevelRegistry.hx b/source/funkin/data/level/LevelRegistry.hx index 75b0b11f6..b5c15de0f 100644 --- a/source/funkin/data/level/LevelRegistry.hx +++ b/source/funkin/data/level/LevelRegistry.hx @@ -30,6 +30,7 @@ class LevelRegistry extends BaseRegistry // JsonParser does not take type parameters, // otherwise this function would be in BaseRegistry. var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; switch (loadEntryFile(id)) { @@ -57,6 +58,7 @@ class LevelRegistry extends BaseRegistry public function parseEntryDataRaw(contents:String, ?fileName:String):Null { var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; parser.fromJson(contents, fileName); if (parser.errors.length > 0) diff --git a/source/funkin/data/notestyle/NoteStyleRegistry.hx b/source/funkin/data/notestyle/NoteStyleRegistry.hx index 4255a644b..ffb9bf490 100644 --- a/source/funkin/data/notestyle/NoteStyleRegistry.hx +++ b/source/funkin/data/notestyle/NoteStyleRegistry.hx @@ -35,6 +35,7 @@ class NoteStyleRegistry extends BaseRegistry // JsonParser does not take type parameters, // otherwise this function would be in BaseRegistry. var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; switch (loadEntryFile(id)) { @@ -62,6 +63,7 @@ class NoteStyleRegistry extends BaseRegistry public function parseEntryDataRaw(contents:String, ?fileName:String):Null { var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; parser.fromJson(contents, fileName); if (parser.errors.length > 0) diff --git a/source/funkin/data/song/SongData.hx b/source/funkin/data/song/SongData.hx index 7886ada4f..600871e2f 100644 --- a/source/funkin/data/song/SongData.hx +++ b/source/funkin/data/song/SongData.hx @@ -747,7 +747,7 @@ class SongNoteDataRaw /** * The kind of the note. * This can allow the note to include information used for custom behavior. - * Defaults to blank or `"normal"`. + * Defaults to blank or `Constants.DEFAULT_DIFFICULTY`. */ @:alias("k") @:default("normal") diff --git a/source/funkin/data/song/SongDataUtils.hx b/source/funkin/data/song/SongDataUtils.hx index 4ae4b1426..309676884 100644 --- a/source/funkin/data/song/SongDataUtils.hx +++ b/source/funkin/data/song/SongDataUtils.hx @@ -230,6 +230,7 @@ class SongDataUtils trace('Read ${notesString.length} characters from clipboard.'); var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; parser.fromJson(notesString, 'clipboard'); if (parser.errors.length > 0) { diff --git a/source/funkin/data/song/SongRegistry.hx b/source/funkin/data/song/SongRegistry.hx index 850654eb7..5a0835f57 100644 --- a/source/funkin/data/song/SongRegistry.hx +++ b/source/funkin/data/song/SongRegistry.hx @@ -126,6 +126,8 @@ class SongRegistry extends BaseRegistry variation = variation == null ? Constants.DEFAULT_VARIATION : variation; var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; + switch (loadEntryMetadataFile(id, variation)) { case {fileName: fileName, contents: contents}: @@ -147,6 +149,7 @@ class SongRegistry extends BaseRegistry variation = variation == null ? Constants.DEFAULT_VARIATION : variation; var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; parser.fromJson(contents, fileName); if (parser.errors.length > 0) @@ -206,6 +209,8 @@ class SongRegistry extends BaseRegistry variation = variation == null ? Constants.DEFAULT_VARIATION : variation; var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; + switch (loadEntryMetadataFile(id, variation)) { case {fileName: fileName, contents: contents}: @@ -226,6 +231,8 @@ class SongRegistry extends BaseRegistry variation = variation == null ? Constants.DEFAULT_VARIATION : variation; var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; + switch (loadEntryMetadataFile(id, variation)) { case {fileName: fileName, contents: contents}: @@ -244,6 +251,7 @@ class SongRegistry extends BaseRegistry function parseEntryMetadataRaw_v2_1_0(contents:String, ?fileName:String = 'raw'):Null { var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; parser.fromJson(contents, fileName); if (parser.errors.length > 0) @@ -257,6 +265,7 @@ class SongRegistry extends BaseRegistry function parseEntryMetadataRaw_v2_0_0(contents:String, ?fileName:String = 'raw'):Null { var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; parser.fromJson(contents, fileName); if (parser.errors.length > 0) @@ -272,6 +281,8 @@ class SongRegistry extends BaseRegistry variation = variation == null ? Constants.DEFAULT_VARIATION : variation; var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; + switch (loadMusicDataFile(id, variation)) { case {fileName: fileName, contents: contents}: @@ -291,6 +302,7 @@ class SongRegistry extends BaseRegistry public function parseMusicDataRaw(contents:String, ?fileName:String = 'raw'):Null { var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; parser.fromJson(contents, fileName); if (parser.errors.length > 0) @@ -334,6 +346,7 @@ class SongRegistry extends BaseRegistry variation = variation == null ? Constants.DEFAULT_VARIATION : variation; var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; switch (loadEntryChartFile(id, variation)) { @@ -356,6 +369,7 @@ class SongRegistry extends BaseRegistry variation = variation == null ? Constants.DEFAULT_VARIATION : variation; var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; parser.fromJson(contents, fileName); if (parser.errors.length > 0) diff --git a/source/funkin/data/song/importer/ChartManifestData.hx b/source/funkin/data/song/importer/ChartManifestData.hx index 0c7d2f0b0..dd0d28479 100644 --- a/source/funkin/data/song/importer/ChartManifestData.hx +++ b/source/funkin/data/song/importer/ChartManifestData.hx @@ -68,6 +68,7 @@ class ChartManifestData public static function deserialize(contents:String):Null { var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; parser.fromJson(contents, 'manifest.json'); if (parser.errors.length > 0) diff --git a/source/funkin/data/song/importer/FNFLegacyData.hx b/source/funkin/data/song/importer/FNFLegacyData.hx index 5b75368c9..52380d344 100644 --- a/source/funkin/data/song/importer/FNFLegacyData.hx +++ b/source/funkin/data/song/importer/FNFLegacyData.hx @@ -19,7 +19,8 @@ class LegacySongData @:jcustomparse(funkin.data.DataParse.eitherLegacyScrollSpeeds) public var speed:Either; - public var stageDefault:String; + @:optional + public var stageDefault:Null; public var bpm:Float; @:jcustomparse(funkin.data.DataParse.eitherLegacyNoteData) diff --git a/source/funkin/data/song/importer/FNFLegacyImporter.hx b/source/funkin/data/song/importer/FNFLegacyImporter.hx index ee68513dc..ab2abda8e 100644 --- a/source/funkin/data/song/importer/FNFLegacyImporter.hx +++ b/source/funkin/data/song/importer/FNFLegacyImporter.hx @@ -14,6 +14,7 @@ class FNFLegacyImporter public static function parseLegacyDataRaw(input:String, fileName:String = 'raw'):FNFLegacyData { var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = true; // Set to true to ignore extra variables that might be included in the JSON. parser.fromJson(input, fileName); if (parser.errors.length > 0) @@ -185,15 +186,34 @@ class FNFLegacyImporter return result; } + static final STRUMLINE_SIZE = 4; + static function migrateNoteSections(input:Array):Array { var result:Array = []; for (section in input) { + var mustHitSection = section.mustHitSection ?? false; for (note in section.sectionNotes) { - result.push(new SongNoteData(note.time, note.data, note.length, note.getKind())); + // Handle the dumb logic for mustHitSection. + var noteData = note.data; + + // Flip notes if mustHitSection is FALSE (not true lol). + if (!mustHitSection) + { + if (noteData >= STRUMLINE_SIZE) + { + noteData -= STRUMLINE_SIZE; + } + else + { + noteData += STRUMLINE_SIZE; + } + } + + result.push(new SongNoteData(note.time, noteData, note.length, note.getKind())); } } diff --git a/tests/unit/source/funkin/data/BaseRegistryTest.hx b/tests/unit/source/funkin/data/BaseRegistryTest.hx index 0be932d35..5f837ba97 100644 --- a/tests/unit/source/funkin/data/BaseRegistryTest.hx +++ b/tests/unit/source/funkin/data/BaseRegistryTest.hx @@ -156,6 +156,7 @@ class MyTypeRegistry extends BaseRegistry // JsonParser does not take type parameters, // otherwise this function would be in BaseRegistry. var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; switch (loadEntryFile(id)) { @@ -181,6 +182,7 @@ class MyTypeRegistry extends BaseRegistry // JsonParser does not take type parameters, // otherwise this function would be in BaseRegistry. var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; switch (loadEntryFile(id)) { From 328bb7b938d65406926cf268a2b47fd78fc60870 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 19 Dec 2023 01:25:15 -0500 Subject: [PATCH 08/17] Fixes to Erect/Nightmare only --- source/funkin/input/Cursor.hx | 12 ++++++++++++ source/funkin/play/stage/StageData.hx | 1 + source/funkin/ui/debug/charting/ChartEditorState.hx | 6 ++++-- .../charting/handlers/ChartEditorDialogHandler.hx | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/source/funkin/input/Cursor.hx b/source/funkin/input/Cursor.hx index b4bf43808..39f399465 100644 --- a/source/funkin/input/Cursor.hx +++ b/source/funkin/input/Cursor.hx @@ -34,6 +34,18 @@ class Cursor Cursor.cursorMode = null; } + public static inline function toggle():Void + { + if (FlxG.mouse.visible) + { + hide(); + } + else + { + show(); + } + } + public static final CURSOR_DEFAULT_PARAMS:CursorParams = { graphic: "assets/images/cursor/cursor-default.png", diff --git a/source/funkin/play/stage/StageData.hx b/source/funkin/play/stage/StageData.hx index d89995ef3..2d87dec31 100644 --- a/source/funkin/play/stage/StageData.hx +++ b/source/funkin/play/stage/StageData.hx @@ -164,6 +164,7 @@ class StageDataParser try { var parser = new json2object.JsonParser(); + parser.ignoreUnknownVariables = false; parser.fromJson(rawJson, '$stageId.json'); if (parser.errors.length > 0) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index fa55750bf..afb0a114d 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -1010,7 +1010,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState function get_availableDifficulties():Array { var m:Null = songMetadata.get(selectedVariation); - return m?.playData?.difficulties ?? []; + return m?.playData?.difficulties ?? [Constants.DEFAULT_DIFFICULTY]; } /** @@ -1069,7 +1069,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState var result:Null = songChartData.get(selectedVariation); if (result == null) { - result = new SongChartData(["normal" => 1.0], [], ["normal" => []]); + result = new SongChartData([Constants.DEFAULT_DIFFICULTY => 1.0], [], [Constants.DEFAULT_DIFFICULTY => []]); songChartData.set(selectedVariation, result); } return result; @@ -1293,6 +1293,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState function set_selectedDifficulty(value:String):String { + if (value == null) value = availableDifficulties[0] ?? Constants.DEFAULT_DIFFICULTY; + selectedDifficulty = value; // Make sure view is updated when the difficulty changes. diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx index 666b3656c..a595b8195 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx @@ -687,6 +687,9 @@ class ChartEditorDialogHandler Conductor.instrumentalOffset = state.currentInstrumentalOffset; // Loads from the metadata. Conductor.mapTimeChanges(state.currentSongMetadata.timeChanges); + state.selectedVariation = Constants.DEFAULT_VARIATION; + state.selectedDifficulty = state.availableDifficulties[0]; + state.difficultySelectDirty = true; dialog.hideDialog(DialogButton.APPLY); From 3e65e7ecc59970d6060bd6f54f6097395d16f24a Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 19 Dec 2023 01:26:26 -0500 Subject: [PATCH 09/17] Fix for vocals not loading properly and not getting cleared properly. --- .../ui/debug/charting/ChartEditorState.hx | 23 +++++++++++++--- .../handlers/ChartEditorAudioHandler.hx | 27 ++++++++++--------- .../handlers/ChartEditorDialogHandler.hx | 14 +++------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index afb0a114d..8369e95b9 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -2548,8 +2548,25 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState menubarItemPlayPause.onClick = _ -> toggleAudioPlayback(); - menubarItemLoadInstrumental.onClick = _ -> this.openUploadInstDialog(true); - menubarItemLoadVocals.onClick = _ -> this.openUploadVocalsDialog(true); + menubarItemLoadInstrumental.onClick = _ -> { + var dialog = this.openUploadInstDialog(true); + // Ensure instrumental and vocals are reloaded properly. + dialog.onDialogClosed = function(_) { + this.isHaxeUIDialogOpen = false; + this.switchToCurrentInstrumental(); + this.postLoadInstrumental(); + } + }; + + menubarItemLoadVocals.onClick = _ -> { + var dialog = this.openUploadVocalsDialog(true); + // Ensure instrumental and vocals are reloaded properly. + dialog.onDialogClosed = function(_) { + this.isHaxeUIDialogOpen = false; + this.switchToCurrentInstrumental(); + this.postLoadInstrumental(); + } + }; menubarItemVolumeMetronome.onChange = event -> { var volume:Float = event.value.toFloat() / 100.0; @@ -4047,7 +4064,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } else { - // If we clicked and released outside the grid, do nothing. + // If we clicked and released outside the grid (or on HaxeUI), do nothing. } } diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx index 272291a94..990ab41ae 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx @@ -28,11 +28,11 @@ class ChartEditorAudioHandler * @param instId The instrumental this vocal track will be for. * @return Success or failure. */ - public static function loadVocalsFromPath(state:ChartEditorState, path:Path, charId:String, instId:String = ''):Bool + public static function loadVocalsFromPath(state:ChartEditorState, path:Path, charId:String, instId:String = '', wipeFirst:Bool = false):Bool { #if sys var fileBytes:Bytes = sys.io.File.getBytes(path.toString()); - return loadVocalsFromBytes(state, fileBytes, charId, instId); + return loadVocalsFromBytes(state, fileBytes, charId, instId, wipeFirst); #else trace("[WARN] This platform can't load audio from a file path, you'll need to fetch the bytes some other way."); return false; @@ -47,12 +47,12 @@ class ChartEditorAudioHandler * @param instId The instrumental this vocal track will be for. * @return Success or failure. */ - public static function loadVocalsFromAsset(state:ChartEditorState, path:String, charId:String, instId:String = ''):Bool + public static function loadVocalsFromAsset(state:ChartEditorState, path:String, charId:String, instId:String = '', wipeFirst:Bool = false):Bool { var trackData:Null = Assets.getBytes(path); if (trackData != null) { - return loadVocalsFromBytes(state, trackData, charId, instId); + return loadVocalsFromBytes(state, trackData, charId, instId, wipeFirst); } return false; } @@ -63,10 +63,12 @@ class ChartEditorAudioHandler * @param bytes The audio byte data. * @param charId The character this vocal track will be for. * @param instId The instrumental this vocal track will be for. + * @param wipeFirst Whether to wipe the existing vocal data before loading. */ - public static function loadVocalsFromBytes(state:ChartEditorState, bytes:Bytes, charId:String, instId:String = ''):Bool + public static function loadVocalsFromBytes(state:ChartEditorState, bytes:Bytes, charId:String, instId:String = '', wipeFirst:Bool = false):Bool { var trackId:String = '${charId}${instId == '' ? '' : '-${instId}'}'; + if (wipeFirst) wipeVocalData(state); state.audioVocalTrackData.set(trackId, bytes); return true; } @@ -78,11 +80,11 @@ class ChartEditorAudioHandler * @param instId The instrumental this vocal track will be for. * @return Success or failure. */ - public static function loadInstFromPath(state:ChartEditorState, path:Path, instId:String = ''):Bool + public static function loadInstFromPath(state:ChartEditorState, path:Path, instId:String = '', wipeFirst:Bool = false):Bool { #if sys var fileBytes:Bytes = sys.io.File.getBytes(path.toString()); - return loadInstFromBytes(state, fileBytes, instId); + return loadInstFromBytes(state, fileBytes, instId, wipeFirst); #else trace("[WARN] This platform can't load audio from a file path, you'll need to fetch the bytes some other way."); return false; @@ -96,12 +98,12 @@ class ChartEditorAudioHandler * @param instId The instrumental this vocal track will be for. * @return Success or failure. */ - public static function loadInstFromAsset(state:ChartEditorState, path:String, instId:String = ''):Bool + public static function loadInstFromAsset(state:ChartEditorState, path:String, instId:String = '', wipeFirst:Bool = false):Bool { var trackData:Null = Assets.getBytes(path); if (trackData != null) { - return loadInstFromBytes(state, trackData, instId); + return loadInstFromBytes(state, trackData, instId, wipeFirst); } return false; } @@ -113,9 +115,10 @@ class ChartEditorAudioHandler * @param charId The character this vocal track will be for. * @param instId The instrumental this vocal track will be for. */ - public static function loadInstFromBytes(state:ChartEditorState, bytes:Bytes, instId:String = ''):Bool + public static function loadInstFromBytes(state:ChartEditorState, bytes:Bytes, instId:String = '', wipeFirst:Bool = false):Bool { if (instId == '') instId = 'default'; + if (wipeFirst) wipeInstrumentalData(state); state.audioInstTrackData.set(instId, bytes); return true; } @@ -127,9 +130,9 @@ class ChartEditorAudioHandler stopExistingVocals(state); result = playVocals(state, BF, playerId, instId); - if (!result) return false; + // if (!result) return false; result = playVocals(state, DAD, opponentId, instId); - if (!result) return false; + // if (!result) return false; return true; } diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx index a595b8195..2ede1a39f 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx @@ -758,14 +758,9 @@ class ChartEditorDialogHandler trace('Selected file: $pathStr'); var path:Path = new Path(pathStr); - if (!hasClearedVocals) + if (state.loadVocalsFromPath(path, charKey, instId, !hasClearedVocals)) { hasClearedVocals = true; - state.stopExistingVocals(); - } - - if (state.loadVocalsFromPath(path, charKey, instId)) - { // Tell the user the load was successful. state.success('Loaded Vocals', 'Loaded vocals for $charName (${path.file}.${path.ext}), variation ${state.selectedVariation}'); #if FILE_DROP_SUPPORTED @@ -799,13 +794,10 @@ class ChartEditorDialogHandler if (selectedFile != null && selectedFile.bytes != null) { trace('Selected file: ' + selectedFile.name); - if (!hasClearedVocals) + + if (state.loadVocalsFromBytes(selectedFile.bytes, charKey, instId, !hasClearedVocals)) { hasClearedVocals = true; - state.stopExistingVocals(); - } - if (state.loadVocalsFromBytes(selectedFile.bytes, charKey, instId)) - { // Tell the user the load was successful. state.success('Loaded Vocals', 'Loaded vocals for $charName (${selectedFile.name}), variation ${state.selectedVariation}'); From bb0fb0281372c5843995a19cda7a9bba5545783f Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 19 Dec 2023 01:26:43 -0500 Subject: [PATCH 10/17] Fix to launching directly into Chart Editor --- source/funkin/Conductor.hx | 14 +++++++------- .../funkin/ui/debug/charting/ChartEditorState.hx | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/funkin/Conductor.hx b/source/funkin/Conductor.hx index c531678ad..7b34bffe2 100644 --- a/source/funkin/Conductor.hx +++ b/source/funkin/Conductor.hx @@ -37,7 +37,7 @@ class Conductor /** * The most recent time change for the current song position. */ - public static var currentTimeChange(default, null):SongTimeChange; + public static var currentTimeChange(default, null):Null; /** * The current position in the song in milliseconds. @@ -132,32 +132,32 @@ class Conductor /** * Current position in the song, in measures. */ - public static var currentMeasure(default, null):Int; + public static var currentMeasure(default, null):Int = 0; /** * Current position in the song, in beats. */ - public static var currentBeat(default, null):Int; + public static var currentBeat(default, null):Int = 0; /** * Current position in the song, in steps. */ - public static var currentStep(default, null):Int; + public static var currentStep(default, null):Int = 0; /** * Current position in the song, in measures and fractions of a measure. */ - public static var currentMeasureTime(default, null):Float; + public static var currentMeasureTime(default, null):Float = 0; /** * Current position in the song, in beats and fractions of a measure. */ - public static var currentBeatTime(default, null):Float; + public static var currentBeatTime(default, null):Float = 0; /** * Current position in the song, in steps and fractions of a step. */ - public static var currentStepTime(default, null):Float; + public static var currentStepTime(default, null):Float = 0; /** * An offset tied to the current chart file to compensate for a delay in the instrumental. diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 8369e95b9..de38a8fda 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -4387,7 +4387,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState playbarNoteSnap.text = '1/${noteSnapQuant}'; playbarDifficulty.text = "Difficulty: " + selectedDifficulty.toTitleCase(); - playbarBPM.text = "BPM: " + Conductor.currentTimeChange.bpm; + playbarBPM.text = "BPM: " + (Conductor.currentTimeChange?.bpm ?? 0.0); } function handlePlayhead():Void From ad02bf2ee0c4d0bc8437069ada3d19fd0ab156dc Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 19 Dec 2023 01:27:58 -0500 Subject: [PATCH 11/17] Fix to GameOverSubstate exiting to Freeplay instead of Chart Editor --- source/funkin/play/GameOverSubState.hx | 24 ++++++++++++++++++++-- source/funkin/play/PlayState.hx | 5 ++++- source/funkin/ui/freeplay/FreeplayState.hx | 2 +- source/funkin/ui/story/StoryMenuState.hx | 2 +- source/funkin/util/Constants.hx | 1 + 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/source/funkin/play/GameOverSubState.hx b/source/funkin/play/GameOverSubState.hx index 6eb53e2d5..18e3e0280 100644 --- a/source/funkin/play/GameOverSubState.hx +++ b/source/funkin/play/GameOverSubState.hx @@ -64,9 +64,13 @@ class GameOverSubState extends MusicBeatSubState */ var isEnding:Bool = false; - public function new() + var isChartingMode:Bool = false; + + public function new(?params:GameOverParams) { super(); + + this.isChartingMode = params?.isChartingMode ?? false; } /** @@ -176,9 +180,20 @@ class GameOverSubState extends MusicBeatSubState // PlayState.seenCutscene = false; // old thing... gameOverMusic.stop(); - if (PlayStatePlaylist.isStoryMode) FlxG.switchState(new StoryMenuState()); + if (isChartingMode) + { + this.close(); + if (FlxG.sound.music != null) FlxG.sound.music.pause(); // Don't reset song position! + PlayState.instance.close(); // This only works because PlayState is a substate! + } + else if (PlayStatePlaylist.isStoryMode) + { + FlxG.switchState(new StoryMenuState()); + } else + { FlxG.switchState(new FreeplayState()); + } } if (gameOverMusic.playing) @@ -307,3 +322,8 @@ class GameOverSubState extends MusicBeatSubState }); } } + +typedef GameOverParams = +{ + var isChartingMode:Bool; +} diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index e0932e756..c834e0abe 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -922,7 +922,10 @@ class PlayState extends MusicBeatSubState } #end - var gameOverSubState = new GameOverSubState(); + var gameOverSubState = new GameOverSubState( + { + isChartingMode: isChartingMode + }); FlxTransitionableSubState.skipNextTransIn = true; FlxTransitionableSubState.skipNextTransOut = true; openSubState(gameOverSubState); diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index 7c69804d9..f17c3d91e 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -97,7 +97,7 @@ class FreeplayState extends MusicBeatSubState var stickerSubState:StickerSubState; // - static var rememberedDifficulty:Null = "normal"; + static var rememberedDifficulty:Null = Constants.DEFAULT_DIFFICULTY; static var rememberedSongId:Null = null; public function new(?stickers:StickerSubState = null) diff --git a/source/funkin/ui/story/StoryMenuState.hx b/source/funkin/ui/story/StoryMenuState.hx index 456988873..6e4cdacaf 100644 --- a/source/funkin/ui/story/StoryMenuState.hx +++ b/source/funkin/ui/story/StoryMenuState.hx @@ -106,7 +106,7 @@ class StoryMenuState extends MusicBeatState var stickerSubState:StickerSubState; static var rememberedLevelId:Null = null; - static var rememberedDifficulty:Null = "normal"; + static var rememberedDifficulty:Null = Constants.DEFAULT_DIFFICULTY; public function new(?stickers:StickerSubState = null) { diff --git a/source/funkin/util/Constants.hx b/source/funkin/util/Constants.hx index f8749567b..123267a49 100644 --- a/source/funkin/util/Constants.hx +++ b/source/funkin/util/Constants.hx @@ -123,6 +123,7 @@ class Constants /** * Default list of difficulties for charts. + * Assumes no Erect mode, etc. */ public static final DEFAULT_DIFFICULTY_LIST:Array = ['easy', 'normal', 'hard']; From 70b7de94aa672bd607583c5763bf6e2d8921369c Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 19 Dec 2023 01:28:13 -0500 Subject: [PATCH 12/17] Fix to Metadata toolbox causing crash when no GF :( --- .../toolboxes/ChartEditorMetadataToolbox.hx | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx index 509aa5b07..bc9384cf3 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx @@ -183,17 +183,41 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox var LIMIT = 6; - var charDataOpponent:CharacterData = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.opponent); - buttonCharacterOpponent.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.opponent); - buttonCharacterOpponent.text = charDataOpponent.name.length > LIMIT ? '${charDataOpponent.name.substr(0, LIMIT)}.' : '${charDataOpponent.name}'; + var charDataOpponent:Null = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.opponent); + if (charDataOpponent != null) + { + buttonCharacterOpponent.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.opponent); + buttonCharacterOpponent.text = charDataOpponent.name.length > LIMIT ? '${charDataOpponent.name.substr(0, LIMIT)}.' : '${charDataOpponent.name}'; + } + else + { + buttonCharacterOpponent.icon = null; + buttonCharacterOpponent.text = "None"; + } - var charDataGirlfriend:CharacterData = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.girlfriend); - buttonCharacterGirlfriend.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.girlfriend); - buttonCharacterGirlfriend.text = charDataGirlfriend.name.length > LIMIT ? '${charDataGirlfriend.name.substr(0, LIMIT)}.' : '${charDataGirlfriend.name}'; + var charDataGirlfriend:Null = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.girlfriend); + if (charDataGirlfriend != null) + { + buttonCharacterGirlfriend.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.girlfriend); + buttonCharacterGirlfriend.text = charDataGirlfriend.name.length > LIMIT ? '${charDataGirlfriend.name.substr(0, LIMIT)}.' : '${charDataGirlfriend.name}'; + } + else + { + buttonCharacterGirlfriend.icon = null; + buttonCharacterGirlfriend.text = "None"; + } - var charDataPlayer:CharacterData = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.player); - buttonCharacterPlayer.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.player); - buttonCharacterPlayer.text = charDataPlayer.name.length > LIMIT ? '${charDataPlayer.name.substr(0, LIMIT)}.' : '${charDataPlayer.name}'; + var charDataPlayer:Null = CharacterDataParser.fetchCharacterData(chartEditorState.currentSongMetadata.playData.characters.player); + if (charDataPlayer != null) + { + buttonCharacterPlayer.icon = CharacterDataParser.getCharPixelIconAsset(chartEditorState.currentSongMetadata.playData.characters.player); + buttonCharacterPlayer.text = charDataPlayer.name.length > LIMIT ? '${charDataPlayer.name.substr(0, LIMIT)}.' : '${charDataPlayer.name}'; + } + else + { + buttonCharacterPlayer.icon = null; + buttonCharacterPlayer.text = "None"; + } } public static function build(chartEditorState:ChartEditorState):ChartEditorMetadataToolbox From f01535e43165e9e0f833d6b9c283480af5c26e9d Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 19 Dec 2023 01:28:24 -0500 Subject: [PATCH 13/17] Don't forget to update hmm! --- hmm.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hmm.json b/hmm.json index 96ee75bc1..8a903eed6 100644 --- a/hmm.json +++ b/hmm.json @@ -100,7 +100,7 @@ "name": "json2object", "type": "git", "dir": null, - "ref": "a0a78b60c41e47bae8bfa422488a199a58b4474e", + "ref": "a8c26f18463c98da32f744c214fe02273e1823fa", "url": "https://github.com/FunkinCrew/json2object" }, { From 8fea7eb73427994bda74e04b3193feb11a3d6389 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 19 Dec 2023 01:57:39 -0500 Subject: [PATCH 14/17] Fix a bug where the background of the game over screen is pink --- source/funkin/play/GameOverSubState.hx | 16 +++++++++++++--- source/funkin/play/PlayState.hx | 5 ++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/source/funkin/play/GameOverSubState.hx b/source/funkin/play/GameOverSubState.hx index 6eb53e2d5..dce2229e1 100644 --- a/source/funkin/play/GameOverSubState.hx +++ b/source/funkin/play/GameOverSubState.hx @@ -64,9 +64,13 @@ class GameOverSubState extends MusicBeatSubState */ var isEnding:Bool = false; - public function new() + var transparent:Bool; + + public function new(params:GameOverParams) { super(); + + transparent = params.transparent; } /** @@ -87,9 +91,10 @@ class GameOverSubState extends MusicBeatSubState // // Add a black background to the screen. - // We make this transparent so that we can see the stage underneath during debugging. var bg = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK); - bg.alpha = 0.25; + // We make this transparent so that we can see the stage underneath during debugging, + // but it's normally opaque. + bg.alpha = transparent ? 0.25 : 1.0; bg.scrollFactor.set(); add(bg); @@ -307,3 +312,8 @@ class GameOverSubState extends MusicBeatSubState }); } } + +typedef GameOverParams = +{ + var transparent:Bool; +} diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index e0932e756..85f60be4e 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -922,7 +922,10 @@ class PlayState extends MusicBeatSubState } #end - var gameOverSubState = new GameOverSubState(); + var gameOverSubState = new GameOverSubState( + { + transparent: persistentDraw, + }); FlxTransitionableSubState.skipNextTransIn = true; FlxTransitionableSubState.skipNextTransOut = true; openSubState(gameOverSubState); From 711253a2023046c97698f8ff7c893574b1513d8c Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 19 Dec 2023 16:12:25 -0500 Subject: [PATCH 15/17] Update HaxeUI to latest --- hmm.json | 4 ++-- source/funkin/ui/haxeui/components/CharacterPlayer.hx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hmm.json b/hmm.json index 96ee75bc1..e31a405ae 100644 --- a/hmm.json +++ b/hmm.json @@ -54,14 +54,14 @@ "name": "haxeui-core", "type": "git", "dir": null, - "ref": "7021f1fbab928268d9196a73e7f47461ca3c3e4d", + "ref": "c8e0cbfef33b955f009023c27c28b161e894b65e", "url": "https://github.com/haxeui/haxeui-core" }, { "name": "haxeui-flixel", "type": "git", "dir": null, - "ref": "26b6bb132c92dfa9b77b4a61eaeda8f9a9efda98", + "ref": "9a1abf4b450118e5222d7456024db31cc3b9f8d1", "url": "https://github.com/haxeui/haxeui-flixel" }, { diff --git a/source/funkin/ui/haxeui/components/CharacterPlayer.hx b/source/funkin/ui/haxeui/components/CharacterPlayer.hx index 66b94bfa2..c7171fac7 100644 --- a/source/funkin/ui/haxeui/components/CharacterPlayer.hx +++ b/source/funkin/ui/haxeui/components/CharacterPlayer.hx @@ -35,7 +35,7 @@ class CharacterPlayer extends Box public function new(defaultToBf:Bool = true) { super(); - _overrideSkipTransformChildren = false; + // _overrideSkipTransformChildren = false; if (defaultToBf) { From a4c993f733859ac0d48336aaee2fdfad495fc219 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Sat, 23 Dec 2023 16:25:50 -0500 Subject: [PATCH 16/17] Update HaxeUI and Flixel --- hmm.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hmm.json b/hmm.json index e31a405ae..ddaf375c6 100644 --- a/hmm.json +++ b/hmm.json @@ -11,7 +11,7 @@ "name": "flixel", "type": "git", "dir": null, - "ref": "9bdea914f3d0485b9b3ec158f28875b5ac95d476", + "ref": "a83738673e7edbf8acba3a1426af284dfe6719fe", "url": "https://github.com/FunkinCrew/flixel" }, { @@ -54,14 +54,14 @@ "name": "haxeui-core", "type": "git", "dir": null, - "ref": "c8e0cbfef33b955f009023c27c28b161e894b65e", + "ref": "e765a3e0b7a653823e8dec765e04623f27f573f8", "url": "https://github.com/haxeui/haxeui-core" }, { "name": "haxeui-flixel", "type": "git", "dir": null, - "ref": "9a1abf4b450118e5222d7456024db31cc3b9f8d1", + "ref": "7a517d561eff49d8123c128bf9f5c1123b84d014", "url": "https://github.com/haxeui/haxeui-flixel" }, { From 92e0022fedcba609bb1d5320c2cffc6d70708676 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 1 Jan 2024 19:13:51 -0500 Subject: [PATCH 17/17] derp comma! --- source/funkin/play/PlayState.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index ea38d833f..3dcabf953 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -924,8 +924,8 @@ class PlayState extends MusicBeatSubState var gameOverSubState = new GameOverSubState( { - isChartingMode: isChartingMode - transparent: persistentDraw, + isChartingMode: isChartingMode, + transparent: persistentDraw }); FlxTransitionableSubState.skipNextTransIn = true; FlxTransitionableSubState.skipNextTransOut = true;