1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-02 11:44:23 +00:00

Merge pull request #278 from FunkinCrew/feature/toggle-charting-theme

Add theme music toggle and extend fade in to 30 seconds
This commit is contained in:
Cameron Taylor 2024-01-12 18:54:01 -05:00 committed by GitHub
commit 9b400bf7a1
3 changed files with 69 additions and 13 deletions

2
assets

@ -1 +1 @@
Subproject commit f1e42601b6ea2026c6e2f4627c5738bfb8b7b524
Subproject commit 9d305889f2e310afeddcda6a4be775eb630fb9ac

View file

@ -14,8 +14,8 @@ import thx.semver.Version;
@:forward(volume, mute)
abstract Save(RawSaveData)
{
// Version 2.0.1 adds attributes to `optionsChartEditor`, that should return default values if they are null.
public static final SAVE_DATA_VERSION:thx.semver.Version = "2.0.1";
// Version 2.0.2 adds attributes to `optionsChartEditor`, that should return default values if they are null.
public static final SAVE_DATA_VERSION:thx.semver.Version = "2.0.2";
public static final SAVE_DATA_VERSION_RULE:thx.semver.VersionRule = "2.0.x";
// We load this version's saves from a new save path, to maintain SOME level of backwards compatibility.
@ -108,6 +108,7 @@ abstract Save(RawSaveData)
metronomeVolume: 1.0,
hitsoundsEnabledPlayer: true,
hitsoundsEnabledOpponent: true,
themeMusic: true,
instVolume: 1.0,
voicesVolume: 1.0,
playbackSpeed: 1.0,
@ -347,6 +348,23 @@ abstract Save(RawSaveData)
return this.optionsChartEditor.hitsoundsEnabledOpponent;
}
public var chartEditorThemeMusic(get, set):Bool;
function get_chartEditorThemeMusic():Bool
{
if (this.optionsChartEditor.themeMusic == null) this.optionsChartEditor.themeMusic = true;
return this.optionsChartEditor.themeMusic;
}
function set_chartEditorThemeMusic(value:Bool):Bool
{
// Set and apply.
this.optionsChartEditor.themeMusic = value;
flush();
return this.optionsChartEditor.themeMusic;
}
public var chartEditorInstVolume(get, set):Float;
function get_chartEditorInstVolume():Float
@ -1027,6 +1045,12 @@ typedef SaveDataChartEditorOptions =
*/
var ?hitsoundsEnabledOpponent:Bool;
/**
* Theme music in the Chart Editor.
* @default `true`
*/
var ?themeMusic:Bool;
/**
* Instrumental volume in the Chart Editor.
* @default `1.0`

View file

@ -272,6 +272,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
*/
public static final BASE_QUANT_INDEX:Int = 3;
/**
* The duration before the welcome music starts to fade back in after the user stops playing music in the chart editor.
*/
public static final WELCOME_MUSIC_FADE_IN_DELAY:Float = 30.0;
/**
* The duration of the welcome music fade in.
*/
public static final WELCOME_MUSIC_FADE_IN_DURATION:Float = 10.0;
/**
* INSTANCE DATA
*/
@ -1636,6 +1646,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
*/
var menubarItemOpponentHitsounds:MenuCheckBox;
/**
* The `Audio -> Play Theme Music` menu checkbox.
*/
var menubarItemThemeMusic:MenuCheckBox;
/**
* The `Audio -> Hitsound Volume` label.
*/
@ -1921,6 +1936,12 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Set the z-index of the HaxeUI.
this.root.zIndex = 100;
// Get rid of any music from the previous state.
if (FlxG.sound.music != null) FlxG.sound.music.stop();
// Play the welcome music.
setupWelcomeMusic();
// Show the mouse cursor.
Cursor.show();
@ -1928,12 +1949,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
fixCamera();
// Get rid of any music from the previous state.
if (FlxG.sound.music != null) FlxG.sound.music.stop();
// Play the welcome music.
setupWelcomeMusic();
buildDefaultSongData();
buildBackground();
@ -2027,6 +2042,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
hitsoundVolume = save.chartEditorHitsoundVolume;
hitsoundsEnabledPlayer = save.chartEditorHitsoundsEnabledPlayer;
hitsoundsEnabledOpponent = save.chartEditorHitsoundsEnabledOpponent;
this.welcomeMusic.active = save.chartEditorThemeMusic;
// audioInstTrack.volume = save.chartEditorInstVolume;
// audioInstTrack.pitch = save.chartEditorPlaybackSpeed;
@ -2056,6 +2072,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
save.chartEditorHitsoundVolume = hitsoundVolume;
save.chartEditorHitsoundsEnabledPlayer = hitsoundsEnabledPlayer;
save.chartEditorHitsoundsEnabledOpponent = hitsoundsEnabledOpponent;
save.chartEditorThemeMusic = this.welcomeMusic.active;
// save.chartEditorInstVolume = audioInstTrack.volume;
// save.chartEditorVoicesVolume = audioVocalTrackGroup.volume;
@ -2116,10 +2133,19 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
function fadeInWelcomeMusic(?extraWait:Float = 0, ?fadeInTime:Float = 5):Void
{
if (!this.welcomeMusic.active)
{
stopWelcomeMusic();
return;
}
bgMusicTimer = new FlxTimer().start(extraWait, (_) -> {
this.welcomeMusic.volume = 0;
this.welcomeMusic.play();
this.welcomeMusic.fadeIn(fadeInTime, 0, 1.0);
if (this.welcomeMusic.active)
{
this.welcomeMusic.play();
this.welcomeMusic.fadeIn(fadeInTime, 0, 1.0);
}
});
}
@ -2750,6 +2776,12 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
menubarItemOpponentHitsounds.onChange = event -> hitsoundsEnabledOpponent = event.value;
menubarItemOpponentHitsounds.selected = hitsoundsEnabledOpponent;
menubarItemThemeMusic.onChange = event -> {
this.welcomeMusic.active = event.value;
fadeInWelcomeMusic(WELCOME_MUSIC_FADE_IN_DELAY, WELCOME_MUSIC_FADE_IN_DURATION);
};
menubarItemThemeMusic.selected = this.welcomeMusic.active;
menubarItemVolumeHitsound.onChange = event -> {
var volume:Float = event.value.toFloat() / 100.0;
hitsoundVolume = volume;
@ -5619,7 +5651,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
moveSongToScrollPosition();
fadeInWelcomeMusic(7, 10);
fadeInWelcomeMusic(WELCOME_MUSIC_FADE_IN_DELAY, WELCOME_MUSIC_FADE_IN_DURATION);
// Reapply the volume.
var instTargetVolume:Float = menubarItemVolumeInstrumental.value ?? 1.0;
@ -5855,7 +5887,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
{
// Pause
stopAudioPlayback();
fadeInWelcomeMusic(7, 10);
fadeInWelcomeMusic(WELCOME_MUSIC_FADE_IN_DELAY, WELCOME_MUSIC_FADE_IN_DURATION);
}
else
{