From 7876b07c37f564bfe20988e70ef7204e3ed30052 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sat, 9 Dec 2023 18:00:32 -0500 Subject: [PATCH 01/14] mac delete key fix --- source/funkin/ui/debug/charting/ChartEditorState.hx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 66effc775..7f556c05f 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -4480,7 +4480,14 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } // DELETE = Delete - if (FlxG.keys.justPressed.DELETE) + var delete:Bool = FlxG.keys.justPressed.DELETE; + + // on macbooks, Delete == backspace + #if mac + delete = delete || FlxG.keys.justPressed.BACKSPACE; + #end + + if (delete) { // Delete selected items. if (currentNoteSelection.length > 0 && currentEventSelection.length > 0) From 8cec180353b90c8479b3f3421118efd1052152a3 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sun, 10 Dec 2023 03:37:12 -0500 Subject: [PATCH 02/14] practice mode in progress --- assets | 2 +- .../ui/debug/charting/ChartEditorState.hx | 9 +++++- .../handlers/ChartEditorToolboxHandler.hx | 29 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/assets b/assets index 3c8ac202b..b5a90d795 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 3c8ac202bbb93bf84c7dcd0697a9d7121d3c5283 +Subproject commit b5a90d79524c2e1d770b447bf88bd6ebbe65bd85 diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 66effc775..dc5ef67dc 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -138,6 +138,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState public static final CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/notedata'); public static final CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/eventdata'); + public static final CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT:String = Paths.ui('chart-editor/toolbox/playtest-properties'); public static final CHART_EDITOR_TOOLBOX_METADATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/metadata'); public static final CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT:String = Paths.ui('chart-editor/toolbox/difficulty'); public static final CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT:String = Paths.ui('chart-editor/toolbox/player-preview'); @@ -515,6 +516,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState */ var playtestStartTime:Bool = false; + /** + * If true, playtesting a chart will let you "gameover" / die when you lose ur health! + */ + var playtestPracticeMode:Bool = false; + // Visuals /** @@ -2516,6 +2522,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState menubarItemToggleToolboxMetadata.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT, event.value); menubarItemToggleToolboxNotes.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT, event.value); menubarItemToggleToolboxEvents.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT, event.value); + menubarItemToggleToolboxPlaytestProperties.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT, event.value); menubarItemToggleToolboxPlayerPreview.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT, event.value); menubarItemToggleToolboxOpponentPreview.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT, event.value); @@ -4657,7 +4664,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState targetDifficulty: selectedDifficulty, // TODO: Add this. // targetCharacter: targetCharacter, - practiceMode: true, + practiceMode: playtestPracticeMode, minimalMode: minimal, startTimestamp: startTimestamp, overrideMusic: true, diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx index 5834de2ee..28716bd14 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx @@ -80,6 +80,8 @@ class ChartEditorToolboxHandler onShowToolboxNoteData(state, toolbox); case ChartEditorState.CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT: onShowToolboxEventData(state, toolbox); + case ChartEditorState.CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT: + onShowToolboxPlaytestProperties(state, toolbox); case ChartEditorState.CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT: onShowToolboxDifficulty(state, toolbox); case ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT: @@ -117,6 +119,8 @@ class ChartEditorToolboxHandler onHideToolboxNoteData(state, toolbox); case ChartEditorState.CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT: onHideToolboxEventData(state, toolbox); + case ChartEditorState.CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT: + onHideToolboxPlaytestProperties(state, toolbox); case ChartEditorState.CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT: onHideToolboxDifficulty(state, toolbox); case ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT: @@ -175,6 +179,8 @@ class ChartEditorToolboxHandler toolbox = buildToolboxNoteDataLayout(state); case ChartEditorState.CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT: toolbox = buildToolboxEventDataLayout(state); + case ChartEditorState.CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT: + toolbox = buildToolboxPlaytestPropertiesLayout(state); case ChartEditorState.CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT: toolbox = buildToolboxDifficultyLayout(state); case ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT: @@ -321,8 +327,12 @@ class ChartEditorToolboxHandler static function onShowToolboxEventData(state:ChartEditorState, toolbox:CollapsibleDialog):Void {} + static function onShowToolboxPlaytestProperties(state:ChartEditorState, toolbox:CollapsibleDialog):Void {} + static function onHideToolboxEventData(state:ChartEditorState, toolbox:CollapsibleDialog):Void {} + static function onHideToolboxPlaytestProperties(state:ChartEditorState, toolbox:CollapsibleDialog):Void {} + static function buildEventDataFormFromSchema(state:ChartEditorState, target:Box, schema:SongEventSchema):Void { trace(schema); @@ -418,6 +428,25 @@ class ChartEditorToolboxHandler } } + static function buildToolboxPlaytestPropertiesLayout(state:ChartEditorState):Null + { + // fill with playtest properties + var toolbox:CollapsibleDialog = cast RuntimeComponentBuilder.fromAsset(ChartEditorState.CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT); + + if (toolbox == null) return null; + + var checkboxPracticeMode:Null = toolbox.findComponent('practiceModeCheckbox', CheckBox); + if (checkboxPracticeMode == null) throw 'ChartEditorToolboxHandler.buildToolboxPlaytestPropertiesLayout() - Could not find practiceModeCheckbox component.'; + + state.playtestPracticeMode = checkboxPracticeMode.selected; + + checkboxPracticeMode.onClick = _ -> { + state.playtestPracticeMode = checkboxPracticeMode.selected; + }; + + return toolbox; + } + static function buildToolboxDifficultyLayout(state:ChartEditorState):Null { var toolbox:CollapsibleDialog = cast RuntimeComponentBuilder.fromAsset(ChartEditorState.CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT); From 3a70ca4e08e489b502123e52ccc86228f1021e7a Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sun, 10 Dec 2023 03:49:24 -0500 Subject: [PATCH 03/14] menubar selected fix --- assets | 2 +- .../ui/debug/charting/handlers/ChartEditorToolboxHandler.hx | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/assets b/assets index b5a90d795..d29187aea 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit b5a90d79524c2e1d770b447bf88bd6ebbe65bd85 +Subproject commit d29187aeafbb560ec62b15c52fff8c0281912431 diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx index 28716bd14..2876ce2fa 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorToolboxHandler.hx @@ -435,6 +435,10 @@ class ChartEditorToolboxHandler if (toolbox == null) return null; + toolbox.onDialogClosed = function(_) { + state.menubarItemToggleToolboxPlaytestProperties.selected = false; + } + var checkboxPracticeMode:Null = toolbox.findComponent('practiceModeCheckbox', CheckBox); if (checkboxPracticeMode == null) throw 'ChartEditorToolboxHandler.buildToolboxPlaytestPropertiesLayout() - Could not find practiceModeCheckbox component.'; From c3fa793d971b04ef5e8fa22883a2af261bba79ff Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Sun, 10 Dec 2023 04:10:57 -0500 Subject: [PATCH 04/14] adds !isCursorOverHaxeUI around --- .../ui/debug/charting/ChartEditorState.hx | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index dc5ef67dc..fe538966d 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -3409,7 +3409,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { gridPlayheadScrollAreaPressed = true; } - else if (notePreview != null && FlxG.mouse.overlaps(notePreview)) + else if (notePreview != null && !isCursorOverHaxeUI && FlxG.mouse.overlaps(notePreview)) { // Clicked note preview notePreviewScrollAreaStartPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY); @@ -3861,7 +3861,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState if (FlxG.mouse.justPressed) { // Just clicked to place a note. - if (overlapsGrid && !overlapsSelectionBorder) + if (!isCursorOverHaxeUI && overlapsGrid && !overlapsSelectionBorder) { // We clicked on the grid without moving the mouse. @@ -4006,7 +4006,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState var isOrWillSelect = overlapsSelection || dragTargetNote != null || dragTargetEvent != null; // Handle grid cursor. - if (overlapsGrid && !isOrWillSelect && !overlapsSelectionBorder && !gridPlayheadScrollAreaPressed) + if (!isCursorOverHaxeUI && overlapsGrid && !isOrWillSelect && !overlapsSelectionBorder && !gridPlayheadScrollAreaPressed) { // Indicate that we can place a note here. @@ -4077,25 +4077,28 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } else { - if (notePreview != null && FlxG.mouse.overlaps(notePreview)) + if (!isCursorOverHaxeUI) { - targetCursorMode = Pointer; - } - else if (gridPlayheadScrollArea != null && FlxG.mouse.overlaps(gridPlayheadScrollArea)) - { - targetCursorMode = Pointer; - } - else if (overlapsSelection) - { - targetCursorMode = Pointer; - } - else if (overlapsSelectionBorder) - { - targetCursorMode = Crosshair; - } - else if (overlapsGrid) - { - targetCursorMode = Cell; + if (notePreview != null && FlxG.mouse.overlaps(notePreview)) + { + targetCursorMode = Pointer; + } + else if (gridPlayheadScrollArea != null && FlxG.mouse.overlaps(gridPlayheadScrollArea)) + { + targetCursorMode = Pointer; + } + else if (overlapsSelection) + { + targetCursorMode = Pointer; + } + else if (overlapsSelectionBorder) + { + targetCursorMode = Crosshair; + } + else if (overlapsGrid) + { + targetCursorMode = Cell; + } } } } From ac3f27edd48a6ad0f89a475148db8b97c47be006 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 11 Dec 2023 00:19:33 -0500 Subject: [PATCH 05/14] icon char select in progres --- assets | 2 +- source/funkin/play/character/CharacterData.hx | 27 ++++++++ .../ui/debug/charting/ChartEditorState.hx | 62 +++++++++++++++++++ source/funkin/ui/freeplay/SongMenuItem.hx | 1 + 4 files changed, 91 insertions(+), 1 deletion(-) diff --git a/assets b/assets index 3c8ac202b..32364eacf 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 3c8ac202bbb93bf84c7dcd0697a9d7121d3c5283 +Subproject commit 32364eacf09940cdba39457a2bb32ac1bca958be diff --git a/source/funkin/play/character/CharacterData.hx b/source/funkin/play/character/CharacterData.hx index abe8bf992..f1f5ebebe 100644 --- a/source/funkin/play/character/CharacterData.hx +++ b/source/funkin/play/character/CharacterData.hx @@ -280,6 +280,33 @@ class CharacterDataParser return characterCache.keys().array(); } + public static function getCharPixelIconAsset(char:String):String + { + var icon:String = char; + + switch (icon) + { + case "bf-christmas" | "bf-car" | "bf-pixel" | "bf-holding-gf": + icon = "bf"; + case "monster-christmas": + icon = "monster"; + case "mom-car": + icon = "mommy"; + case "pico-blazin": + icon = "pico"; + case "gf-christmas" | "gf-car" | "gf-pixel" | "gf-tankmen": + icon = "gf"; + case "dad": + icon = "daddy"; + case "darnell-blazin": + icon = "darnell"; + case "senpai-angry": + icon = "senpai"; + } + + return Paths.image("freeplay/icons/" + icon + "pixel"); + } + /** * Clears the character data cache. */ diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 66effc775..2cab863b8 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -1,6 +1,9 @@ package funkin.ui.debug.charting; import funkin.util.logging.CrashHandler; +import haxe.ui.containers.HBox; +import haxe.ui.containers.Grid; +import haxe.ui.containers.ScrollView; import haxe.ui.containers.menus.MenuBar; import flixel.addons.display.FlxSliceSprite; import flixel.addons.display.FlxTiledSprite; @@ -106,6 +109,7 @@ import haxe.ui.containers.menus.MenuItem; import haxe.ui.containers.menus.MenuCheckBox; import haxe.ui.containers.TreeView; import haxe.ui.containers.TreeViewNode; +import haxe.ui.components.Image; import haxe.ui.core.Component; import haxe.ui.core.Screen; import haxe.ui.events.DragEvent; @@ -114,6 +118,7 @@ import haxe.ui.events.UIEvent; import haxe.ui.events.UIEvent; import haxe.ui.focus.FocusManager; import openfl.display.BitmapData; +import flixel.input.mouse.FlxMouseEvent; using Lambda; @@ -2082,6 +2087,63 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState healthIconBF.flipX = true; add(healthIconBF); healthIconBF.zIndex = 30; + + FlxMouseEvent.add(healthIconDad, function(_) { + trace("clicked dad"); + + var toolbox:CollapsibleDialog = cast haxe.ui.RuntimeComponentBuilder.fromAsset(Paths.ui('chart-editor/toolbox/iconselector')); + toolbox.showDialog(false); + var scrollView = toolbox.findComponent('charSelectScroll'); + + var hbox = new Grid(); + hbox.columns = 5; + hbox.width = 100; + scrollView.addComponent(hbox); + + var charIds:Array = CharacterDataParser.listCharacterIds(); + + charIds.sort(function(a, b) { + var result:Int = 0; + + if (a < b) + { + result = -1; + } + else if (a > b) + { + result = 1; + } + + return result; + }); + + for (char in charIds) + { + var image = new haxe.ui.components.Button(); + image.width = 70; + image.height = 70; + + image.icon = CharacterDataParser.getCharPixelIconAsset(char); + image.onClick = _ -> { + toolbox.hideDialog(haxe.ui.containers.dialogs.Dialog.DialogButton.APPLY); + // var label = toolbox.findComponent('charIconName'); + // label.text = char; + }; + + image.onMouseOver = _ -> { + var label = toolbox.findComponent('charIconName'); + label.text = char; + }; + hbox.addComponent(image); + } + + toolbox.x = FlxG.mouse.screenX; + toolbox.y = FlxG.mouse.screenY; + }); + + FlxMouseEvent.add(healthIconBF, function(_) { + trace("clicked bf"); + }); } function buildNotePreview():Void diff --git a/source/funkin/ui/freeplay/SongMenuItem.hx b/source/funkin/ui/freeplay/SongMenuItem.hx index 477047c68..4e0772dfe 100644 --- a/source/funkin/ui/freeplay/SongMenuItem.hx +++ b/source/funkin/ui/freeplay/SongMenuItem.hx @@ -175,6 +175,7 @@ class SongMenuItem extends FlxSpriteGroup trace(char); // TODO: Put this in the character metadata where it belongs. + // TODO: Also, can use CharacterDataParser.getCharPixelIconAsset() switch (char) { case "monster-christmas": From 181e3f85b851fd7a9e580a54b9e85251e1675cf8 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 11 Dec 2023 02:26:37 -0500 Subject: [PATCH 06/14] switching opp --- source/funkin/ui/debug/charting/ChartEditorState.hx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 2cab863b8..b6f687c75 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -2123,9 +2123,14 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState image.width = 70; image.height = 70; + if (char == currentSongMetadata.playData.characters.opponent) image.selected = true; + image.icon = CharacterDataParser.getCharPixelIconAsset(char); image.onClick = _ -> { + healthIconsDirty = true; + currentSongMetadata.playData.characters.opponent = char; toolbox.hideDialog(haxe.ui.containers.dialogs.Dialog.DialogButton.APPLY); + // var label = toolbox.findComponent('charIconName'); // label.text = char; }; From 9ffffe9c8afdde6ab256933ed1aa739b523e30e4 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 11 Dec 2023 02:40:58 -0500 Subject: [PATCH 07/14] player char select --- .../ui/debug/charting/ChartEditorState.hx | 130 ++++++++++-------- 1 file changed, 74 insertions(+), 56 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index b6f687c75..d5f6fd9ae 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -2089,68 +2089,86 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState healthIconBF.zIndex = 30; FlxMouseEvent.add(healthIconDad, function(_) { - trace("clicked dad"); - - var toolbox:CollapsibleDialog = cast haxe.ui.RuntimeComponentBuilder.fromAsset(Paths.ui('chart-editor/toolbox/iconselector')); - toolbox.showDialog(false); - var scrollView = toolbox.findComponent('charSelectScroll'); - - var hbox = new Grid(); - hbox.columns = 5; - hbox.width = 100; - scrollView.addComponent(hbox); - - var charIds:Array = CharacterDataParser.listCharacterIds(); - - charIds.sort(function(a, b) { - var result:Int = 0; - - if (a < b) - { - result = -1; - } - else if (a > b) - { - result = 1; - } - - return result; - }); - - for (char in charIds) - { - var image = new haxe.ui.components.Button(); - image.width = 70; - image.height = 70; - - if (char == currentSongMetadata.playData.characters.opponent) image.selected = true; - - image.icon = CharacterDataParser.getCharPixelIconAsset(char); - image.onClick = _ -> { - healthIconsDirty = true; - currentSongMetadata.playData.characters.opponent = char; - toolbox.hideDialog(haxe.ui.containers.dialogs.Dialog.DialogButton.APPLY); - - // var label = toolbox.findComponent('charIconName'); - // label.text = char; - }; - - image.onMouseOver = _ -> { - var label = toolbox.findComponent('charIconName'); - label.text = char; - }; - hbox.addComponent(image); - } - - toolbox.x = FlxG.mouse.screenX; - toolbox.y = FlxG.mouse.screenY; + createAndOpenCharSelect(1); }); FlxMouseEvent.add(healthIconBF, function(_) { - trace("clicked bf"); + createAndOpenCharSelect(0); }); } + /** + * @param charType 0 == BF, 1 == Dad + */ + function createAndOpenCharSelect(charType:Int = 0):Void + { + var charData = currentSongMetadata.playData.characters; + var currentChar:String = switch (charType) + { + case 0: charData.player; + case 1: charData.opponent; + default: throw 'Invalid charType: ' + charType; + }; + var toolbox:CollapsibleDialog = cast haxe.ui.RuntimeComponentBuilder.fromAsset(Paths.ui('chart-editor/toolbox/iconselector')); + toolbox.showDialog(false); + var scrollView = toolbox.findComponent('charSelectScroll'); + + var hbox = new Grid(); + hbox.columns = 5; + hbox.width = 100; + scrollView.addComponent(hbox); + + var charIds:Array = CharacterDataParser.listCharacterIds(); + + charIds.sort(function(a, b) { + var result:Int = 0; + + if (a < b) + { + result = -1; + } + else if (a > b) + { + result = 1; + } + + return result; + }); + + for (char in charIds) + { + var image = new haxe.ui.components.Button(); + image.width = 70; + image.height = 70; + + if (char == currentChar) image.selected = true; + + image.icon = CharacterDataParser.getCharPixelIconAsset(char); + image.onClick = _ -> { + healthIconsDirty = true; + switch (charType) + { + case 0: currentSongMetadata.playData.characters.player = char; + case 1: currentSongMetadata.playData.characters.opponent = char; + default: throw 'Invalid charType: ' + charType; + }; + toolbox.hideDialog(haxe.ui.containers.dialogs.Dialog.DialogButton.APPLY); + + // var label = toolbox.findComponent('charIconName'); + // label.text = char; + }; + + image.onMouseOver = _ -> { + var label = toolbox.findComponent('charIconName'); + label.text = char; + }; + hbox.addComponent(image); + } + + toolbox.x = FlxG.mouse.screenX; + toolbox.y = FlxG.mouse.screenY; + } + function buildNotePreview():Void { var height:Int = FlxG.height - MENU_BAR_HEIGHT - GRID_TOP_PAD - PLAYBAR_HEIGHT - GRID_TOP_PAD - GRID_TOP_PAD; From 05f977f85fcf38987f9da2dd6c978be94127c06d Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 11 Dec 2023 03:38:44 -0500 Subject: [PATCH 08/14] character selector --- .../ui/debug/charting/ChartEditorState.hx | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index d5f6fd9ae..76247bde2 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -2089,11 +2089,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState healthIconBF.zIndex = 30; FlxMouseEvent.add(healthIconDad, function(_) { - createAndOpenCharSelect(1); + if (!isCursorOverHaxeUI) createAndOpenCharSelect(1); }); FlxMouseEvent.add(healthIconBF, function(_) { - createAndOpenCharSelect(0); + if (!isCursorOverHaxeUI) createAndOpenCharSelect(0); }); } @@ -2110,7 +2110,28 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState default: throw 'Invalid charType: ' + charType; }; var toolbox:CollapsibleDialog = cast haxe.ui.RuntimeComponentBuilder.fromAsset(Paths.ui('chart-editor/toolbox/iconselector')); + toolbox.title += " - " + switch (charType) + { + case 0: "Player"; + case 1: "Opponent"; + default: throw 'Invalid charType: ' + charType; + }; + + var _overlay = new Component(); + _overlay.id = "modal-background"; + _overlay.addClass("modal-background"); + _overlay.percentWidth = _overlay.percentHeight = 100; + _overlay.opacity = 0; + FlxTween.tween(_overlay, {opacity: 0.2}, 0.1, {ease: FlxEase.quartOut}); + _overlay.onClick = function(_) { + toolbox.hideDialog(haxe.ui.containers.dialogs.Dialog.DialogButton.CANCEL); + Screen.instance.removeComponent(_overlay); + }; + + Screen.instance.addComponent(_overlay); + toolbox.showDialog(false); + toolbox.closable = false; var scrollView = toolbox.findComponent('charSelectScroll'); var hbox = new Grid(); @@ -2153,7 +2174,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState default: throw 'Invalid charType: ' + charType; }; toolbox.hideDialog(haxe.ui.containers.dialogs.Dialog.DialogButton.APPLY); - + Screen.instance.removeComponent(_overlay); // var label = toolbox.findComponent('charIconName'); // label.text = char; }; @@ -2165,8 +2186,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState hbox.addComponent(image); } - toolbox.x = FlxG.mouse.screenX; - toolbox.y = FlxG.mouse.screenY; + toolbox.x = FlxG.mouse.screenX - toolbox.width / 2; + toolbox.y = FlxG.mouse.screenY - 16; } function buildNotePreview():Void From b33f27f0973c5eb12e3f2babb4c2041129d34c47 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 11 Dec 2023 04:35:39 -0500 Subject: [PATCH 09/14] tiny lil polish and cleanin --- .../ui/debug/charting/ChartEditorState.hx | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 76247bde2..e49dde838 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -2110,6 +2110,10 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState default: throw 'Invalid charType: ' + charType; }; var toolbox:CollapsibleDialog = cast haxe.ui.RuntimeComponentBuilder.fromAsset(Paths.ui('chart-editor/toolbox/iconselector')); + + toolbox.x = FlxG.mouse.screenX - toolbox.width / 2; + toolbox.y = FlxG.mouse.screenY - 16; + toolbox.title += " - " + switch (charType) { case 0: "Player"; @@ -2118,21 +2122,38 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState }; var _overlay = new Component(); + + var hideCharIconPicker = function() { + FlxTween.tween(_overlay, {opacity: 0}, 0.05, + { + ease: FlxEase.quartOut + }); + FlxTween.tween(toolbox, {opacity: 0, y: toolbox.y + 10}, 0.1, + { + ease: FlxEase.quartOut, + onComplete: function(_) { + toolbox.hideDialog(haxe.ui.containers.dialogs.Dialog.DialogButton.CANCEL); + Screen.instance.removeComponent(_overlay); + } + }); + }; + _overlay.id = "modal-background"; _overlay.addClass("modal-background"); _overlay.percentWidth = _overlay.percentHeight = 100; _overlay.opacity = 0; FlxTween.tween(_overlay, {opacity: 0.2}, 0.1, {ease: FlxEase.quartOut}); _overlay.onClick = function(_) { - toolbox.hideDialog(haxe.ui.containers.dialogs.Dialog.DialogButton.CANCEL); - Screen.instance.removeComponent(_overlay); + hideCharIconPicker(); }; Screen.instance.addComponent(_overlay); toolbox.showDialog(false); + toolbox.opacity = 0; + FlxTween.tween(toolbox, {opacity: 1, y: toolbox.y + 10}, 0.1, {ease: FlxEase.quartOut}); toolbox.closable = false; - var scrollView = toolbox.findComponent('charSelectScroll'); + var scrollView:ScrollView = cast toolbox.findComponent('charSelectScroll'); var hbox = new Grid(); hbox.columns = 5; @@ -2156,13 +2177,19 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState return result; }); - for (char in charIds) + for (ind => char in charIds) { var image = new haxe.ui.components.Button(); image.width = 70; image.height = 70; + image.iconPosition = "top"; + image.text = char; - if (char == currentChar) image.selected = true; + if (char == currentChar) + { + scrollView.hscrollPos = Math.floor(ind / 5) * 80; + image.selected = true; + } image.icon = CharacterDataParser.getCharPixelIconAsset(char); image.onClick = _ -> { @@ -2173,8 +2200,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState case 1: currentSongMetadata.playData.characters.opponent = char; default: throw 'Invalid charType: ' + charType; }; - toolbox.hideDialog(haxe.ui.containers.dialogs.Dialog.DialogButton.APPLY); - Screen.instance.removeComponent(_overlay); + hideCharIconPicker(); + // var label = toolbox.findComponent('charIconName'); // label.text = char; }; @@ -2185,9 +2212,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState }; hbox.addComponent(image); } - - toolbox.x = FlxG.mouse.screenX - toolbox.width / 2; - toolbox.y = FlxG.mouse.screenY - 16; } function buildNotePreview():Void From 52f16ce457e57985228df1d81d07c24ec704009d Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Tue, 12 Dec 2023 05:24:43 -0500 Subject: [PATCH 10/14] Redo icon dialog and add support to metadata dialog. --- assets | 2 +- source/funkin/play/character/CharacterData.hx | 7 +- .../ui/debug/charting/ChartEditorState.hx | 253 +++--------------- .../charting/dialogs/ChartEditorBaseDialog.hx | 35 +++ .../charting/dialogs/ChartEditorBaseMenu.hx | 24 ++ .../ChartEditorCharacterIconSelectorMenu.hx | 129 +++++++++ .../dialogs/ChartEditorUploadChartDialog.hx | 1 + .../handlers/ChartEditorDialogHandler.hx | 11 + .../ChartEditorImportExportHandler.hx | 2 +- .../handlers/ChartEditorToolboxHandler.hx | 207 +++----------- .../toolboxes/ChartEditorBaseToolbox.hx | 28 ++ .../toolboxes/ChartEditorMetadataToolbox.hx | 203 ++++++++++++++ 12 files changed, 511 insertions(+), 391 deletions(-) create mode 100644 source/funkin/ui/debug/charting/dialogs/ChartEditorBaseMenu.hx create mode 100644 source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx create mode 100644 source/funkin/ui/debug/charting/toolboxes/ChartEditorBaseToolbox.hx create mode 100644 source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx diff --git a/assets b/assets index 32364eacf..e591e9acc 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 32364eacf09940cdba39457a2bb32ac1bca958be +Subproject commit e591e9acc12b9aba6124332c4d66453f1f83368c diff --git a/source/funkin/play/character/CharacterData.hx b/source/funkin/play/character/CharacterData.hx index f1f5ebebe..16cc8b299 100644 --- a/source/funkin/play/character/CharacterData.hx +++ b/source/funkin/play/character/CharacterData.hx @@ -280,6 +280,9 @@ class CharacterDataParser return characterCache.keys().array(); } + /** + * TODO: Hardcode this. + */ public static function getCharPixelIconAsset(char:String):String { var icon:String = char; @@ -290,9 +293,9 @@ class CharacterDataParser icon = "bf"; case "monster-christmas": icon = "monster"; - case "mom-car": + case "mom" | "mom-car": icon = "mommy"; - case "pico-blazin": + case "pico-blazin" | "pico-playable" | "pico-speaker": icon = "pico"; case "gf-christmas" | "gf-car" | "gf-pixel" | "gf-tankmen": icon = "gf"; diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index e49dde838..2f7df7330 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -110,6 +110,7 @@ import haxe.ui.containers.menus.MenuCheckBox; import haxe.ui.containers.TreeView; import haxe.ui.containers.TreeViewNode; import haxe.ui.components.Image; +import funkin.ui.debug.charting.toolboxes.ChartEditorBaseToolbox; import haxe.ui.core.Component; import haxe.ui.core.Screen; import haxe.ui.events.DragEvent; @@ -2087,131 +2088,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState healthIconBF.flipX = true; add(healthIconBF); healthIconBF.zIndex = 30; - - FlxMouseEvent.add(healthIconDad, function(_) { - if (!isCursorOverHaxeUI) createAndOpenCharSelect(1); - }); - - FlxMouseEvent.add(healthIconBF, function(_) { - if (!isCursorOverHaxeUI) createAndOpenCharSelect(0); - }); - } - - /** - * @param charType 0 == BF, 1 == Dad - */ - function createAndOpenCharSelect(charType:Int = 0):Void - { - var charData = currentSongMetadata.playData.characters; - var currentChar:String = switch (charType) - { - case 0: charData.player; - case 1: charData.opponent; - default: throw 'Invalid charType: ' + charType; - }; - var toolbox:CollapsibleDialog = cast haxe.ui.RuntimeComponentBuilder.fromAsset(Paths.ui('chart-editor/toolbox/iconselector')); - - toolbox.x = FlxG.mouse.screenX - toolbox.width / 2; - toolbox.y = FlxG.mouse.screenY - 16; - - toolbox.title += " - " + switch (charType) - { - case 0: "Player"; - case 1: "Opponent"; - default: throw 'Invalid charType: ' + charType; - }; - - var _overlay = new Component(); - - var hideCharIconPicker = function() { - FlxTween.tween(_overlay, {opacity: 0}, 0.05, - { - ease: FlxEase.quartOut - }); - FlxTween.tween(toolbox, {opacity: 0, y: toolbox.y + 10}, 0.1, - { - ease: FlxEase.quartOut, - onComplete: function(_) { - toolbox.hideDialog(haxe.ui.containers.dialogs.Dialog.DialogButton.CANCEL); - Screen.instance.removeComponent(_overlay); - } - }); - }; - - _overlay.id = "modal-background"; - _overlay.addClass("modal-background"); - _overlay.percentWidth = _overlay.percentHeight = 100; - _overlay.opacity = 0; - FlxTween.tween(_overlay, {opacity: 0.2}, 0.1, {ease: FlxEase.quartOut}); - _overlay.onClick = function(_) { - hideCharIconPicker(); - }; - - Screen.instance.addComponent(_overlay); - - toolbox.showDialog(false); - toolbox.opacity = 0; - FlxTween.tween(toolbox, {opacity: 1, y: toolbox.y + 10}, 0.1, {ease: FlxEase.quartOut}); - toolbox.closable = false; - var scrollView:ScrollView = cast toolbox.findComponent('charSelectScroll'); - - var hbox = new Grid(); - hbox.columns = 5; - hbox.width = 100; - scrollView.addComponent(hbox); - - var charIds:Array = CharacterDataParser.listCharacterIds(); - - charIds.sort(function(a, b) { - var result:Int = 0; - - if (a < b) - { - result = -1; - } - else if (a > b) - { - result = 1; - } - - return result; - }); - - for (ind => char in charIds) - { - var image = new haxe.ui.components.Button(); - image.width = 70; - image.height = 70; - image.iconPosition = "top"; - image.text = char; - - if (char == currentChar) - { - scrollView.hscrollPos = Math.floor(ind / 5) * 80; - image.selected = true; - } - - image.icon = CharacterDataParser.getCharPixelIconAsset(char); - image.onClick = _ -> { - healthIconsDirty = true; - switch (charType) - { - case 0: currentSongMetadata.playData.characters.player = char; - case 1: currentSongMetadata.playData.characters.opponent = char; - default: throw 'Invalid charType: ' + charType; - }; - hideCharIconPicker(); - - // var label = toolbox.findComponent('charIconName'); - // label.text = char; - }; - - image.onMouseOver = _ -> { - var label = toolbox.findComponent('charIconName'); - label.text = char; - }; - hbox.addComponent(image); - } } function buildNotePreview():Void @@ -2406,6 +2282,21 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState if (!Preferences.debugDisplay) menubar.paddingLeft = null; this.setupNotifications(); + + // Setup character dropdowns. + FlxMouseEvent.add(healthIconDad, function(_) { + if (!isCursorOverHaxeUI) + { + this.openCharacterDropdown(CharacterType.DAD, true); + } + }); + + FlxMouseEvent.add(healthIconBF, function(_) { + if (!isCursorOverHaxeUI) + { + this.openCharacterDropdown(CharacterType.BF, true); + } + }); } /** @@ -2446,13 +2337,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState else { Conductor.currentTimeChange.bpm += 1; - refreshMetadataToolbox(); + this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); } } playbarBPM.onRightClick = _ -> { Conductor.currentTimeChange.bpm -= 1; - refreshMetadataToolbox(); + this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); } // Add functionality to the menu items. @@ -3509,6 +3400,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState var overlapsSelection:Bool = FlxG.mouse.overlaps(renderedSelectionSquares); + var overlapsHealthIcons:Bool = FlxG.mouse.overlaps(healthIconBF) || FlxG.mouse.overlaps(healthIconDad); + if (FlxG.mouse.justPressedMiddle) { if (scrollAnchorScreenPos == null) @@ -3528,11 +3421,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { scrollAnchorScreenPos = null; } - else if (gridPlayheadScrollArea != null && FlxG.mouse.overlaps(gridPlayheadScrollArea)) + else if (gridPlayheadScrollArea != null && FlxG.mouse.overlaps(gridPlayheadScrollArea) && !isCursorOverHaxeUI) { gridPlayheadScrollAreaPressed = true; } - else if (notePreview != null && FlxG.mouse.overlaps(notePreview)) + else if (notePreview != null && FlxG.mouse.overlaps(notePreview) && !isCursorOverHaxeUI) { // Clicked note preview notePreviewScrollAreaStartPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY); @@ -4220,6 +4113,10 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { targetCursorMode = Cell; } + else if (overlapsHealthIcons) + { + targetCursorMode = Pointer; + } } } @@ -4250,7 +4147,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState difficultySelectDirty = false; // Manage the Select Difficulty tree view. - var difficultyToolbox:Null = this.getToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT); + var difficultyToolbox:Null = this.getToolbox_OLD(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT); if (difficultyToolbox == null) return; var treeView:Null = difficultyToolbox.findComponent('difficultyToolboxTree'); @@ -4297,7 +4194,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState function handlePlayerPreviewToolbox():Void { // Manage the Select Difficulty tree view. - var charPreviewToolbox:Null = this.getToolbox(CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT); + var charPreviewToolbox:Null = this.getToolbox_OLD(CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT); if (charPreviewToolbox == null) return; // TODO: Re-enable the player preview once we figure out the performance issues. @@ -4333,7 +4230,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState function handleOpponentPreviewToolbox():Void { // Manage the Select Difficulty tree view. - var charPreviewToolbox:Null = this.getToolbox(CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT); + var charPreviewToolbox:Null = this.getToolbox_OLD(CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT); if (charPreviewToolbox == null) return; // TODO: Re-enable the player preview once we figure out the performance issues. @@ -5042,7 +4939,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState Conductor.mapTimeChanges(this.currentSongMetadata.timeChanges); refreshDifficultyTreeSelection(); - refreshMetadataToolbox(); + this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); } else { @@ -5051,7 +4948,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState selectedDifficulty = prevDifficulty; refreshDifficultyTreeSelection(); - refreshMetadataToolbox(); + this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); } } else @@ -5070,7 +4967,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState selectedDifficulty = nextDifficulty; refreshDifficultyTreeSelection(); - refreshMetadataToolbox(); + this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); } else { @@ -5079,7 +4976,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState selectedDifficulty = nextDifficulty; refreshDifficultyTreeSelection(); - refreshMetadataToolbox(); + this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); } } @@ -5192,7 +5089,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState if (treeView == null) { // Manage the Select Difficulty tree view. - var difficultyToolbox:Null = this.getToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT); + var difficultyToolbox:Null = this.getToolbox_OLD(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT); if (difficultyToolbox == null) return; treeView = difficultyToolbox.findComponent('difficultyToolboxTree'); @@ -5212,7 +5109,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState { if (treeView == null) { - var difficultyToolbox:Null = this.getToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT); + var difficultyToolbox:Null = this.getToolbox_OLD(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT); if (difficultyToolbox == null) return null; treeView = difficultyToolbox.findComponent('difficultyToolboxTree'); @@ -5256,8 +5153,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState trace('Changing difficulty to "$variation:$difficulty"'); selectedVariation = variation; selectedDifficulty = difficulty; - // refreshDifficultyTreeSelection(treeView); - refreshMetadataToolbox(); + this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); } // case 'song': // case 'variation': @@ -5266,82 +5162,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState trace('Selected wrong node type, resetting selection.'); var currentTreeDifficultyNode = getCurrentTreeDifficultyNode(treeView); if (currentTreeDifficultyNode != null) treeView.selectedNode = currentTreeDifficultyNode; - refreshMetadataToolbox(); - } - } - - /** - * When the difficulty changes, update the song metadata toolbox to reflect the new data. - */ - function refreshMetadataToolbox():Void - { - var toolbox:Null = this.getToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT); - if (toolbox == null) return; - - var inputSongName:Null = toolbox.findComponent('inputSongName', TextField); - if (inputSongName != null) inputSongName.value = currentSongMetadata.songName; - - var inputSongArtist:Null = toolbox.findComponent('inputSongArtist', TextField); - if (inputSongArtist != null) inputSongArtist.value = currentSongMetadata.artist; - - var inputStage:Null = toolbox.findComponent('inputStage', DropDown); - if (inputStage != null) inputStage.value = currentSongMetadata.playData.stage; - - var inputNoteStyle:Null = toolbox.findComponent('inputNoteStyle', DropDown); - if (inputNoteStyle != null) inputNoteStyle.value = currentSongMetadata.playData.noteStyle; - - var inputBPM:Null = toolbox.findComponent('inputBPM', NumberStepper); - if (inputBPM != null) inputBPM.value = currentSongMetadata.timeChanges[0].bpm; - - var labelScrollSpeed:Null