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();
@ -1709,8 +1710,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
var menuItemRecentChart:MenuItem = new MenuItem();
menuItemRecentChart.text = chartPath;
menuItemRecentChart.onClick = function(_event) {
stopWelcomeMusic();
// Load chart from file
var result:Null<Array<String>> = this.loadFromFNFCPath(chartPath);
if (result != null)
@ -1747,14 +1746,20 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
#end
}
function fadeInWelcomeMusic():Void
var bgMusicTimer:FlxTimer;
function fadeInWelcomeMusic(?extraWait:Float = 0, ?fadeInTime:Float = 5):Void
{
bgMusicTimer = new FlxTimer().start(extraWait, (_) -> {
this.welcomeMusic.volume = 0;
this.welcomeMusic.play();
this.welcomeMusic.fadeIn(4, 0, 1.0);
this.welcomeMusic.fadeIn(fadeInTime, 0, 1.0);
});
}
function stopWelcomeMusic():Void
{
if (bgMusicTimer != null) bgMusicTimer.cancel();
// this.welcomeMusic.fadeOut(4, 0);
this.welcomeMusic.pause();
}
@ -4347,7 +4352,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Override music.
if (audioInstTrack != null) FlxG.sound.music = audioInstTrack;
if (audioVocalTrackGroup != null) targetState.vocals = audioVocalTrackGroup;
stopWelcomeMusic();
openSubState(targetState);
}
@ -4979,10 +4984,12 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (audioInstTrack.playing)
{
fadeInWelcomeMusic(7, 10);
stopAudioPlayback();
}
else
{
stopWelcomeMusic();
startAudioPlayback();
}
}

View file

@ -74,7 +74,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
public override function onClose(event:DialogEvent):Void
{
super.onClose(event);
state.stopWelcomeMusic();
}
/**
@ -84,10 +83,12 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
public function addRecentFilePath(state:ChartEditorState, chartPath:String):Void
{
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) {
this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
// Load chart from file
var result:Null<Array<String>> = ChartEditorImportExportHandler.loadFromFNFCPath(state, chartPath);
@ -161,7 +162,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
this.addTemplateSong(songName, targetSongId, (_) -> {
this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
// Load song from template
state.loadSongAsTemplate(targetSongId);
@ -189,7 +189,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
{
// Hide the welcome dialog
this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
// Open the "Open Chart" dialog
state.openBrowseFNFC(false);
@ -203,7 +202,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
{
// Hide the welcome dialog
this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
//
// Create Song Wizard
@ -219,7 +217,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
{
// Hide the welcome dialog
this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
//
// Create Song Wizard
@ -235,7 +232,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
{
// Hide the welcome dialog
this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
//
// Create Song Wizard
@ -251,7 +247,6 @@ class ChartEditorWelcomeDialog extends ChartEditorBaseDialog
{
// Hide the welcome dialog
this.hideDialog(DialogButton.CANCEL);
state.stopWelcomeMusic();
// Open the "Import Chart" dialog
state.openImportChartWizard('legacy', false);