From 4491465bf9c6b047f6970b6d32c45861036fae3b Mon Sep 17 00:00:00 2001 From: EliteMasterEric <ericmyllyoja@gmail.com> Date: Thu, 8 Feb 2024 19:22:28 -0500 Subject: [PATCH] Implement difficulty rank into Metadata toolbox. --- assets | 2 +- source/funkin/data/song/SongData.hx | 4 ++-- .../ui/debug/charting/ChartEditorState.hx | 23 +++++++++++++++++++ .../toolboxes/ChartEditorMetadataToolbox.hx | 5 ++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/assets b/assets index 251d4640b..02da1c72a 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 251d4640bd77ee0f0b6122a13f123274c43dd3f5 +Subproject commit 02da1c72a22ddf8cc167f014888a94ebf468d5b1 diff --git a/source/funkin/data/song/SongData.hx b/source/funkin/data/song/SongData.hx index 52b9c19d6..5959041a7 100644 --- a/source/funkin/data/song/SongData.hx +++ b/source/funkin/data/song/SongData.hx @@ -418,10 +418,10 @@ class SongPlayData implements ICloneable<SongPlayData> /** * The difficulty ratings for this song as displayed in Freeplay. - * Key is a difficulty ID or `default`. + * Key is a difficulty ID. */ @:optional - @:default(['default' => 1]) + @:default(['normal' => 0]) public var ratings:Map<String, Int>; /** diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index d0326be30..14d3c606f 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -1294,6 +1294,29 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState return currentSongChartData.events = value; } + /** + * Convenience property to get the rating for this difficulty in the Freeplay menu. + */ + var currentSongChartDifficultyRating(get, set):Int; + + function get_currentSongChartDifficultyRating():Int + { + var result:Null<Int> = currentSongMetadata.playData.ratings.get(selectedDifficulty); + if (result == null) + { + // Initialize to the default value if not set. + currentSongMetadata.playData.ratings.set(selectedDifficulty, 0); + return 0; + } + return result; + } + + function set_currentSongChartDifficultyRating(value:Int):Int + { + currentSongMetadata.playData.ratings.set(selectedDifficulty, value); + return value; + } + var currentSongNoteStyle(get, set):String; function get_currentSongNoteStyle():String diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx index 5d8c25bae..f85307c64 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx @@ -151,6 +151,10 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox labelScrollSpeed.text = 'Scroll Speed: ${chartEditorState.currentSongChartScrollSpeed}x'; }; + inputDifficultyRating.onChange = function(event:UIEvent) { + chartEditorState.currentSongChartDifficultyRating = event.target.value; + }; + buttonCharacterOpponent.onClick = function(_) { chartEditorState.openCharacterDropdown(CharacterType.DAD, false); }; @@ -175,6 +179,7 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox inputStage.value = chartEditorState.currentSongMetadata.playData.stage; inputNoteStyle.value = chartEditorState.currentSongMetadata.playData.noteStyle; inputBPM.value = chartEditorState.currentSongMetadata.timeChanges[0].bpm; + inputDifficultyRating.value = chartEditorState.currentSongChartDifficultyRating; inputScrollSpeed.value = chartEditorState.currentSongChartScrollSpeed; labelScrollSpeed.text = 'Scroll Speed: ${chartEditorState.currentSongChartScrollSpeed}x'; frameVariation.text = 'Variation: ${chartEditorState.selectedVariation.toTitleCase()}';