Fixed volume sliders, Load Instrumental button, and fixed hitsounds.

This commit is contained in:
EliteMasterEric
2023-09-26 17:46:07 -04:00
parent be4fd74d40
commit 2fcb906edf
7 changed files with 498 additions and 210 deletions
@@ -461,6 +461,8 @@ class ChartEditorState extends HaxeUIState
notePreviewDirty = true;
notePreviewViewportBoundsDirty = true;
this.scrollPositionInPixels = this.scrollPositionInPixels;
// Characters have probably changed too.
healthIconsDirty = true;
return isViewDownscroll;
}
@@ -519,8 +521,14 @@ class ChartEditorState extends HaxeUIState
*/
var selectedVariation(default, set):String = Constants.DEFAULT_VARIATION;
/**
* Setter called when we are switching variations.
* We will likely need to switch instrumentals as well.
*/
function set_selectedVariation(value:String):String
{
// Don't update if we're already on the variation.
if (selectedVariation == value) return selectedVariation;
selectedVariation = value;
// Make sure view is updated when the variation changes.
@@ -528,6 +536,8 @@ class ChartEditorState extends HaxeUIState
notePreviewDirty = true;
notePreviewViewportBoundsDirty = true;
switchToCurrentInstrumental();
return selectedVariation;
}
@@ -548,6 +558,23 @@ class ChartEditorState extends HaxeUIState
return selectedDifficulty;
}
/**
* The instrumental ID which is currently selected.
*/
var currentInstrumentalId(get, set):String;
function get_currentInstrumentalId():String
{
var instId:Null<String> = currentSongMetadata.playData.characters.instrumental;
if (instId == null || instId == '') instId = (selectedVariation == Constants.DEFAULT_VARIATION) ? '' : selectedVariation;
return instId;
}
function set_currentInstrumentalId(value:String):String
{
return currentSongMetadata.playData.characters.instrumental = value;
}
/**
* The character ID for the character which is currently selected.
*/
@@ -592,6 +619,11 @@ class ChartEditorState extends HaxeUIState
*/
var noteDisplayDirty:Bool = true;
/**
* Whether the selected charactesr have been modified and the health icons need to be updated.
*/
var healthIconsDirty:Bool = true;
/**
* Whether the note preview graphic needs to be FULLY rebuilt.
*/
@@ -758,28 +790,29 @@ class ChartEditorState extends HaxeUIState
/**
* The audio track for the instrumental.
* Replaced when switching instrumentals.
* `null` until an instrumental track is loaded.
*/
var audioInstTrack:Null<FlxSound> = null;
/**
* The raw byte data for the instrumental audio track.
* The raw byte data for the instrumental audio tracks.
* Key is the instrumental name.
* `null` until an instrumental track is loaded.
*/
var audioInstTrackData:Null<Bytes> = null;
var audioInstTrackData:Map<String, Bytes> = [];
/**
* The audio track for the vocals.
* `null` until vocal track(s) are loaded.
* When switching characters, the elements of the VoicesGroup will be swapped to match the new character.
*/
var audioVocalTrackGroup:Null<VoicesGroup> = null;
/**
* A map of the audio tracks for each character's vocals.
* - Keys are the character IDs.
* - Values are the FlxSound objects to play that character's vocals.
*
* When switching characters, the elements of the VoicesGroup will be swapped to match the new character.
* - Keys are `characterId-variation` (with `characterId` being the default variation).
* - Values are the byte data for the audio track.
*/
var audioVocalTrackData:Map<String, Bytes> = [];
@@ -1030,30 +1063,6 @@ class ChartEditorState extends HaxeUIState
return currentSongMetadata.artist = value;
}
var currentSongCharacterPlayer(get, set):String;
function get_currentSongCharacterPlayer():String
{
return currentSongMetadata.playData.characters.player;
}
function set_currentSongCharacterPlayer(value:String):String
{
return currentSongMetadata.playData.characters.player = value;
}
var currentSongCharacterOpponent(get, set):String;
function get_currentSongCharacterOpponent():String
{
return currentSongMetadata.playData.characters.opponent;
}
function set_currentSongCharacterOpponent(value:String):String
{
return currentSongMetadata.playData.characters.opponent = value;
}
/**
* SIGNALS
*/
@@ -1341,7 +1350,7 @@ class ChartEditorState extends HaxeUIState
gridPlayhead.add(playheadBlock);
// Character icons.
healthIconDad = new HealthIcon(currentSongCharacterOpponent);
healthIconDad = new HealthIcon(currentSongMetadata.playData.characters.opponent);
healthIconDad.autoUpdate = false;
healthIconDad.size.set(0.5, 0.5);
healthIconDad.x = gridTiledSprite.x - 15 - (HealthIcon.HEALTH_ICON_SIZE * 0.5);
@@ -1349,7 +1358,7 @@ class ChartEditorState extends HaxeUIState
add(healthIconDad);
healthIconDad.zIndex = 30;
healthIconBF = new HealthIcon(currentSongCharacterPlayer);
healthIconBF = new HealthIcon(currentSongMetadata.playData.characters.player);
healthIconBF.autoUpdate = false;
healthIconBF.size.set(0.5, 0.5);
healthIconBF.x = gridTiledSprite.x + gridTiledSprite.width + 15;
@@ -1446,6 +1455,12 @@ class ChartEditorState extends HaxeUIState
return bounds;
}
public function switchToCurrentInstrumental():Void
{
ChartEditorAudioHandler.switchToInstrumental(this, currentInstrumentalId, currentSongMetadata.playData.characters.player,
currentSongMetadata.playData.characters.opponent);
}
function setNotePreviewViewportBounds(bounds:FlxRect = null):Void
{
if (notePreviewViewport == null)
@@ -1648,6 +1663,7 @@ class ChartEditorState extends HaxeUIState
});
addUIClickListener('menubarItemAbout', _ -> ChartEditorDialogHandler.openAboutDialog(this));
addUIClickListener('menubarItemWelcomeDialog', _ -> ChartEditorDialogHandler.openWelcomeDialog(this, true));
addUIClickListener('menubarItemUserGuide', _ -> ChartEditorDialogHandler.openUserGuideDialog(this));
@@ -1670,6 +1686,11 @@ class ChartEditorState extends HaxeUIState
});
setUICheckboxSelected('menuBarItemThemeDark', currentTheme == ChartEditorTheme.Dark);
addUIClickListener('menubarItemPlayPause', _ -> toggleAudioPlayback());
addUIClickListener('menubarItemLoadInstrumental', _ -> ChartEditorDialogHandler.openUploadInstDialog(this, true));
addUIClickListener('menubarItemLoadVocals', _ -> ChartEditorDialogHandler.openUploadVocalsDialog(this, true));
addUIChangeListener('menubarItemMetronomeEnabled', event -> isMetronomeEnabled = event.value);
setUICheckboxSelected('menubarItemMetronomeEnabled', isMetronomeEnabled);
@@ -1683,7 +1704,7 @@ class ChartEditorState extends HaxeUIState
if (instVolumeLabel != null)
{
addUIChangeListener('menubarItemVolumeInstrumental', function(event:UIEvent) {
var volume:Float = event?.value ?? 0 / 100.0;
var volume:Float = (event?.value ?? 0) / 100.0;
if (audioInstTrack != null) audioInstTrack.volume = volume;
instVolumeLabel.text = 'Instrumental - ${Std.int(event.value)}%';
});
@@ -1693,7 +1714,7 @@ class ChartEditorState extends HaxeUIState
if (vocalsVolumeLabel != null)
{
addUIChangeListener('menubarItemVolumeVocals', function(event:UIEvent) {
var volume:Float = event?.value ?? 0 / 100.0;
var volume:Float = (event?.value ?? 0) / 100.0;
if (audioVocalTrackGroup != null) audioVocalTrackGroup.volume = volume;
vocalsVolumeLabel.text = 'Vocals - ${Std.int(event.value)}%';
});
@@ -2918,6 +2939,12 @@ class ChartEditorState extends HaxeUIState
*/
function handleHealthIcons():Void
{
if (healthIconsDirty)
{
if (healthIconBF != null) healthIconBF.characterId = currentSongMetadata.playData.characters.player;
if (healthIconDad != null) healthIconDad.characterId = currentSongMetadata.playData.characters.opponent;
}
// Right align the BF health icon.
if (healthIconBF != null)
{
@@ -3335,11 +3362,11 @@ class ChartEditorState extends HaxeUIState
{
playerPreviewDirty = false;
if (currentSongCharacterPlayer != charPlayer.charId)
if (currentSongMetadata.playData.characters.player != charPlayer.charId)
{
if (healthIconBF != null) healthIconBF.characterId = currentSongCharacterPlayer;
if (healthIconBF != null) healthIconBF.characterId = currentSongMetadata.playData.characters.player;
charPlayer.loadCharacter(currentSongCharacterPlayer);
charPlayer.loadCharacter(currentSongMetadata.playData.characters.player);
charPlayer.characterType = CharacterType.BF;
charPlayer.flip = true;
charPlayer.targetScale = 0.5;
@@ -3371,11 +3398,11 @@ class ChartEditorState extends HaxeUIState
{
opponentPreviewDirty = false;
if (currentSongCharacterOpponent != charPlayer.charId)
if (currentSongMetadata.playData.characters.opponent != charPlayer.charId)
{
if (healthIconDad != null) healthIconDad.characterId = currentSongCharacterOpponent;
if (healthIconDad != null) healthIconDad.characterId = currentSongMetadata.playData.characters.opponent;
charPlayer.loadCharacter(currentSongCharacterOpponent);
charPlayer.loadCharacter(currentSongMetadata.playData.characters.opponent);
charPlayer.characterType = CharacterType.DAD;
charPlayer.flip = false;
charPlayer.targetScale = 0.5;
@@ -3755,9 +3782,9 @@ class ChartEditorState extends HaxeUIState
switch (noteData.getStrumlineIndex())
{
case 0: // Player
if (hitsoundsEnabledPlayer) ChartEditorAudioHandler.playSound(Paths.sound('funnyNoise/funnyNoise-09'));
if (hitsoundsEnabledPlayer) ChartEditorAudioHandler.playSound(Paths.sound('ui/chart-editor/playerHitsound'));
case 1: // Opponent
if (hitsoundsEnabledOpponent) ChartEditorAudioHandler.playSound(Paths.sound('funnyNoise/funnyNoise-010'));
if (hitsoundsEnabledOpponent) ChartEditorAudioHandler.playSound(Paths.sound('ui/chart-editor/opponentHitsound'));
}
}
}
@@ -3979,12 +4006,18 @@ class ChartEditorState extends HaxeUIState
buildSpectrogram(audioInstTrack);
}
else
{
trace('[WARN] Instrumental track was null!');
}
// Pretty much everything is going to need to be reset.
scrollPositionInPixels = 0;
playheadPositionInPixels = 0;
notePreviewDirty = true;
notePreviewViewportBoundsDirty = true;
noteDisplayDirty = true;
healthIconsDirty = true;
moveSongToScrollPosition();
}