Merge pull request #232 from FunkinCrew/polish/charting-music-bg

charting song polish + recents menu fix
This commit is contained in:
Eric 2023-11-27 19:35:11 -05:00 committed by GitHub
commit 0704e9530b
2 changed files with 18 additions and 16 deletions

View file

@ -874,7 +874,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// ============================== // ==============================
/** /**
* The chill audio track that plays when you open the Chart Editor. * The chill audio track that plays in the chart editor.
* Plays when the main music is NOT being played.
*/ */
var welcomeMusic:FlxSound = new FlxSound(); var welcomeMusic:FlxSound = new FlxSound();
@ -1709,8 +1710,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
var menuItemRecentChart:MenuItem = new MenuItem(); var menuItemRecentChart:MenuItem = new MenuItem();
menuItemRecentChart.text = chartPath; menuItemRecentChart.text = chartPath;
menuItemRecentChart.onClick = function(_event) { menuItemRecentChart.onClick = function(_event) {
stopWelcomeMusic();
// Load chart from file // Load chart from file
var result:Null<Array<String>> = this.loadFromFNFCPath(chartPath); var result:Null<Array<String>> = this.loadFromFNFCPath(chartPath);
if (result != null) if (result != null)
@ -1747,14 +1746,20 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
#end #end
} }
function fadeInWelcomeMusic():Void var bgMusicTimer:FlxTimer;
function fadeInWelcomeMusic(?extraWait:Float = 0, ?fadeInTime:Float = 5):Void
{ {
this.welcomeMusic.play(); bgMusicTimer = new FlxTimer().start(extraWait, (_) -> {
this.welcomeMusic.fadeIn(4, 0, 1.0); this.welcomeMusic.volume = 0;
this.welcomeMusic.play();
this.welcomeMusic.fadeIn(fadeInTime, 0, 1.0);
});
} }
function stopWelcomeMusic():Void function stopWelcomeMusic():Void
{ {
if (bgMusicTimer != null) bgMusicTimer.cancel();
// this.welcomeMusic.fadeOut(4, 0); // this.welcomeMusic.fadeOut(4, 0);
this.welcomeMusic.pause(); this.welcomeMusic.pause();
} }
@ -4347,7 +4352,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Override music. // Override music.
if (audioInstTrack != null) FlxG.sound.music = audioInstTrack; if (audioInstTrack != null) FlxG.sound.music = audioInstTrack;
if (audioVocalTrackGroup != null) targetState.vocals = audioVocalTrackGroup; if (audioVocalTrackGroup != null) targetState.vocals = audioVocalTrackGroup;
stopWelcomeMusic();
openSubState(targetState); openSubState(targetState);
} }
@ -4979,10 +4984,12 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (audioInstTrack.playing) if (audioInstTrack.playing)
{ {
fadeInWelcomeMusic(7, 10);
stopAudioPlayback(); stopAudioPlayback();
} }
else else
{ {
stopWelcomeMusic();
startAudioPlayback(); startAudioPlayback();
} }
} }

View file

@ -74,7 +74,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
public override function onClose(event:DialogEvent):Void public override function onClose(event:DialogEvent):Void
{ {
super.onClose(event); super.onClose(event);
state.stopWelcomeMusic();
} }
/** /**
@ -84,10 +83,12 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
public function addRecentFilePath(state:ChartEditorState, chartPath:String):Void public function addRecentFilePath(state:ChartEditorState, chartPath:String):Void
{ {
var linkRecentChart:Link = new Link(); var linkRecentChart:Link = new Link();
linkRecentChart.text = chartPath; var fileNamePattern:EReg = new EReg("([^/\\\\]+)$", "");
var fileName:String = fileNamePattern.match(chartPath) ? fileNamePattern.matched(1) : chartPath;
linkRecentChart.text = fileName;
linkRecentChart.tooltip = chartPath;
linkRecentChart.onClick = function(_event) { linkRecentChart.onClick = function(_event) {
this.hideDialog(DialogButton.CANCEL); this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
// Load chart from file // Load chart from file
var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFCPath(state, chartPath); var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFCPath(state, chartPath);
@ -161,7 +162,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
this.addTemplateSong(songName, targetSongId, (_) -> { this.addTemplateSong(songName, targetSongId, (_) -> {
this.hideDialog(DialogButton.CANCEL); this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
// Load song from template // Load song from template
state.loadSongAsTemplate(targetSongId); state.loadSongAsTemplate(targetSongId);
@ -189,7 +189,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
{ {
// Hide the welcome dialog // Hide the welcome dialog
this.hideDialog(DialogButton.CANCEL); this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
// Open the "Open Chart" dialog // Open the "Open Chart" dialog
state.openBrowseFNFC(false); state.openBrowseFNFC(false);
@ -203,7 +202,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
{ {
// Hide the welcome dialog // Hide the welcome dialog
this.hideDialog(DialogButton.CANCEL); this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
// //
// Create Song Wizard // Create Song Wizard
@ -219,7 +217,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
{ {
// Hide the welcome dialog // Hide the welcome dialog
this.hideDialog(DialogButton.CANCEL); this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
// //
// Create Song Wizard // Create Song Wizard
@ -235,7 +232,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
{ {
// Hide the welcome dialog // Hide the welcome dialog
this.hideDialog(DialogButton.CANCEL); this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
// //
// Create Song Wizard // Create Song Wizard
@ -251,7 +247,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
{ {
// Hide the welcome dialog // Hide the welcome dialog
this.hideDialog(DialogButton.CANCEL); this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
// Open the "Import Chart" dialog // Open the "Import Chart" dialog
state.openImportChartWizard('legacy', false); state.openImportChartWizard('legacy', false);