diff --git a/assets b/assets index 61ddda8bd..ef79a6cf1 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 61ddda8bd98fac65b21b4c35d24ee78129b48f29 +Subproject commit ef79a6cf1ae3dcbd86a5b798f8117a6c692c0156 diff --git a/source/funkin/play/GameOverSubState.hx b/source/funkin/play/GameOverSubState.hx index a3aeb4139..c5d9b4b0b 100644 --- a/source/funkin/play/GameOverSubState.hx +++ b/source/funkin/play/GameOverSubState.hx @@ -102,6 +102,9 @@ class GameOverSubState extends MusicBeatSubState cameraFollowPoint = new FlxObject(PlayState.instance.cameraFollowPoint.x, PlayState.instance.cameraFollowPoint.y, 1, 1); cameraFollowPoint.x = boyfriend.getGraphicMidpoint().x; cameraFollowPoint.y = boyfriend.getGraphicMidpoint().y; + var offsets:Array = boyfriend.getDeathCameraOffsets(); + cameraFollowPoint.x += offsets[0]; + cameraFollowPoint.y += offsets[1]; add(cameraFollowPoint); FlxG.camera.target = null; diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 8b47e6ebd..048b6ed6e 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1641,7 +1641,7 @@ class PlayState extends MusicBeatSubState */ function onConversationComplete():Void { - isInCutscene = true; + isInCutscene = false; remove(currentConversation); currentConversation = null; diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index 30b549fd3..5346ced61 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -188,6 +188,11 @@ class BaseCharacter extends Bopper shouldBop = false; } + public function getDeathCameraOffsets():Array + { + return _data.death?.cameraOffsets ?? [0.0, 0.0]; + } + /** * Gets the value of flipX from the character data. * `!getFlipX()` is the direction Boyfriend should face. @@ -580,8 +585,7 @@ class BaseCharacter extends Bopper public override function playAnimation(name:String, restart:Bool = false, ignoreOther:Bool = false, reversed:Bool = false):Void { - FlxG.watch.addQuick('playAnim(${characterName})', name); - // trace('playAnim(${characterName}): ${name}'); + // FlxG.watch.addQuick('playAnim(${characterName})', name); super.playAnimation(name, restart, ignoreOther, reversed); } } diff --git a/source/funkin/play/character/CharacterData.hx b/source/funkin/play/character/CharacterData.hx index f1b316b7f..8be9f25c7 100644 --- a/source/funkin/play/character/CharacterData.hx +++ b/source/funkin/play/character/CharacterData.hx @@ -19,8 +19,10 @@ class CharacterDataParser * The current version string for the stage data format. * Handle breaking changes by incrementing this value * and adding migration to the `migrateStageData()` function. + * + * - Version 1.0.1 adds `death.cameraOffsets` */ - public static final CHARACTER_DATA_VERSION:String = '1.0.0'; + public static final CHARACTER_DATA_VERSION:String = '1.0.1'; /** * The current version rule check for the stage data format. @@ -603,6 +605,8 @@ typedef CharacterData = */ var healthIcon:Null; + var death:Null; + /** * The global offset to the character's position, in pixels. * @default [0, 0] @@ -695,3 +699,13 @@ typedef HealthIconData = */ var offsets:Null>; } + +typedef DeathData = +{ + /** + * The amount to offset the camera by while focusing on this character as they die. + * Default value focuses on the character's graphic midpoint. + * @default [0, 0] + */ + var ?cameraOffsets:Array; +} diff --git a/source/funkin/play/song/Song.hx b/source/funkin/play/song/Song.hx index 33363e1ff..f996d75ef 100644 --- a/source/funkin/play/song/Song.hx +++ b/source/funkin/play/song/Song.hx @@ -1,5 +1,6 @@ package funkin.play.song; +import funkin.util.SortUtil; import flixel.sound.FlxSound; import openfl.utils.Assets; import funkin.modding.events.ScriptEvent; @@ -252,32 +253,7 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry = new Map(); - for (difficulty in diffFiltered) - { - var num:Int = 0; - switch (difficulty) - { - case 'easy': - num = 0; - case 'normal': - num = 1; - case 'hard': - num = 2; - case 'erect': - num = 3; - case 'nightmare': - num = 4; - } - diffMap.set(difficulty, num); - } - - diffFiltered.sort(function(a:String, b:String) { - return (diffMap.get(a) ?? 0) - (diffMap.get(b) ?? 0); - }); + diffFiltered.sort(SortUtil.defaultsThenAlphabetically.bind(Constants.DEFAULT_DIFFICULTY_LIST)); return diffFiltered; } diff --git a/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx b/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx index 30f0381c6..91576f2ee 100644 --- a/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx +++ b/source/funkin/ui/debug/charting/ChartEditorDialogHandler.hx @@ -667,8 +667,6 @@ class ChartEditorDialogHandler timeChanges[0].bpm = event.value; } - Conductor.forceBPM(event.value); - newSongMetadata.timeChanges = timeChanges; }; @@ -677,6 +675,8 @@ class ChartEditorDialogHandler dialogContinue.onClick = (_event) -> { state.songMetadata.set(targetVariation, newSongMetadata); + Conductor.mapTimeChanges(state.currentSongMetadata.timeChanges); + dialog.hideDialog(DialogButton.APPLY); } @@ -696,6 +696,8 @@ class ChartEditorDialogHandler var charData:SongCharacterData = state.currentSongMetadata.playData.characters; + var hasClearedVocals:Bool = false; + charIdsForVocals.push(charData.player); charIdsForVocals.push(charData.opponent); @@ -715,6 +717,7 @@ class ChartEditorDialogHandler if (dialogNoVocals == null) throw 'Could not locate dialogNoVocals button in Upload Vocals dialog'; dialogNoVocals.onClick = function(_event) { // Dismiss + ChartEditorAudioHandler.stopExistingVocals(state); dialog.hideDialog(DialogButton.APPLY); }; @@ -738,6 +741,12 @@ class ChartEditorDialogHandler trace('Selected file: $pathStr'); var path:Path = new Path(pathStr); + if (!hasClearedVocals) + { + hasClearedVocals = true; + ChartEditorAudioHandler.stopExistingVocals(state); + } + if (ChartEditorAudioHandler.loadVocalsFromPath(state, path, charKey, instId)) { // Tell the user the load was successful. @@ -788,6 +797,11 @@ class ChartEditorDialogHandler if (selectedFile != null && selectedFile.bytes != null) { trace('Selected file: ' + selectedFile.name); + if (!hasClearedVocals) + { + hasClearedVocals = true; + ChartEditorAudioHandler.stopExistingVocals(state); + } if (ChartEditorAudioHandler.loadVocalsFromBytes(state, selectedFile.bytes, charKey, instId)) { // Tell the user the load was successful. diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index b4c8c3483..c28c1c8c7 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -1897,6 +1897,16 @@ class ChartEditorState extends HaxeUIState handleViewKeybinds(); handleTestKeybinds(); handleHelpKeybinds(); + + #if debug + handleQuickWatch(); + #end + } + + function handleQuickWatch():Void + { + FlxG.watch.addQuick('scrollPosInPixels', scrollPositionInPixels); + FlxG.watch.addQuick('playheadPosInPixels', playheadPositionInPixels); } /** @@ -3119,6 +3129,7 @@ class ChartEditorState extends HaxeUIState function quitChartEditor():Void { autoSave(); + stopWelcomeMusic(); FlxG.switchState(new MainMenuState()); } @@ -3342,6 +3353,7 @@ class ChartEditorState extends HaxeUIState if (!isHaxeUIDialogOpen && !isCursorOverHaxeUI && FlxG.keys.justPressed.ENTER) { var minimal = FlxG.keys.pressed.SHIFT; + ChartEditorToolboxHandler.hideAllToolboxes(this); testSongInPlayState(minimal); } } @@ -4153,14 +4165,13 @@ class ChartEditorState extends HaxeUIState */ function moveSongToScrollPosition():Void { - // Update the songPosition in the Conductor. - var targetPos = scrollPositionInMs; - Conductor.update(targetPos); - // Update the songPosition in the audio tracks. if (audioInstTrack != null) audioInstTrack.time = scrollPositionInMs + playheadPositionInMs; if (audioVocalTrackGroup != null) audioVocalTrackGroup.time = scrollPositionInMs + playheadPositionInMs; + // Update the songPosition in the Conductor. + Conductor.update(audioInstTrack.time); + // We need to update the note sprites because we changed the scroll position. noteDisplayDirty = true; } diff --git a/source/funkin/ui/debug/charting/ChartEditorToolboxHandler.hx b/source/funkin/ui/debug/charting/ChartEditorToolboxHandler.hx index 6f89b6b63..d92e43cf2 100644 --- a/source/funkin/ui/debug/charting/ChartEditorToolboxHandler.hx +++ b/source/funkin/ui/debug/charting/ChartEditorToolboxHandler.hx @@ -136,6 +136,18 @@ class ChartEditorToolboxHandler } } + public static function rememberOpenToolboxes(state:ChartEditorState):Void {} + + public static function openRememberedToolboxes(state:ChartEditorState):Void {} + + public static function hideAllToolboxes(state:ChartEditorState):Void + { + for (toolbox in state.activeToolboxes.values()) + { + toolbox.hideDialog(DialogButton.CANCEL); + } + } + public static function minimizeToolbox(state:ChartEditorState, id:String):Void { var toolbox:Null = state.activeToolboxes.get(id); @@ -634,9 +646,9 @@ class ChartEditorToolboxHandler timeChanges[0].bpm = event.value; } - Conductor.forceBPM(event.value); - state.currentSongMetadata.timeChanges = timeChanges; + + Conductor.mapTimeChanges(state.currentSongMetadata.timeChanges); }; inputBPM.value = state.currentSongMetadata.timeChanges[0].bpm; diff --git a/source/funkin/ui/story/Level.hx b/source/funkin/ui/story/Level.hx index c976cbfce..e86241277 100644 --- a/source/funkin/ui/story/Level.hx +++ b/source/funkin/ui/story/Level.hx @@ -1,5 +1,6 @@ package funkin.ui.story; +import funkin.util.SortUtil; import flixel.FlxSprite; import flixel.util.FlxColor; import funkin.play.song.Song; @@ -155,31 +156,7 @@ class Level implements IRegistryEntry } } - // sort the difficulties, since they may be out of order in the chart JSON - // also copy/pasted to Song.listDifficulties()! - var diffMap:Map = new Map(); - for (difficulty in difficulties) - { - var num:Int = 0; - switch (difficulty) - { - case 'easy': - num = 0; - case 'normal': - num = 1; - case 'hard': - num = 2; - case 'erect': - num = 3; - case 'nightmare': - num = 4; - } - diffMap.set(difficulty, num); - } - - difficulties.sort(function(a:String, b:String) { - return diffMap.get(a) - diffMap.get(b); - }); + difficulties.sort(SortUtil.defaultsThenAlphabetically.bind(Constants.DEFAULT_DIFFICULTY_LIST)); // Filter to only include difficulties that are present in all songs for (songIndex in 1...songList.length) diff --git a/source/funkin/util/Constants.hx b/source/funkin/util/Constants.hx index c606e469f..b27a7d2f5 100644 --- a/source/funkin/util/Constants.hx +++ b/source/funkin/util/Constants.hx @@ -121,6 +121,11 @@ class Constants */ public static final DEFAULT_DIFFICULTY:String = 'normal'; + /** + * Default list of difficulties for charts. + */ + public static final DEFAULT_DIFFICULTY_LIST:Array = ['easy', 'normal', 'hard']; + /** * Default player character for charts. */