mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-08-20 07:25:59 +00:00
Fix for vocals not loading properly and not getting cleared properly.
This commit is contained in:
parent
328bb7b938
commit
3e65e7ecc5
|
@ -2548,8 +2548,25 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
|
||||
menubarItemPlayPause.onClick = _ -> toggleAudioPlayback();
|
||||
|
||||
menubarItemLoadInstrumental.onClick = _ -> this.openUploadInstDialog(true);
|
||||
menubarItemLoadVocals.onClick = _ -> this.openUploadVocalsDialog(true);
|
||||
menubarItemLoadInstrumental.onClick = _ -> {
|
||||
var dialog = this.openUploadInstDialog(true);
|
||||
// Ensure instrumental and vocals are reloaded properly.
|
||||
dialog.onDialogClosed = function(_) {
|
||||
this.isHaxeUIDialogOpen = false;
|
||||
this.switchToCurrentInstrumental();
|
||||
this.postLoadInstrumental();
|
||||
}
|
||||
};
|
||||
|
||||
menubarItemLoadVocals.onClick = _ -> {
|
||||
var dialog = this.openUploadVocalsDialog(true);
|
||||
// Ensure instrumental and vocals are reloaded properly.
|
||||
dialog.onDialogClosed = function(_) {
|
||||
this.isHaxeUIDialogOpen = false;
|
||||
this.switchToCurrentInstrumental();
|
||||
this.postLoadInstrumental();
|
||||
}
|
||||
};
|
||||
|
||||
menubarItemVolumeMetronome.onChange = event -> {
|
||||
var volume:Float = event.value.toFloat() / 100.0;
|
||||
|
@ -4047,7 +4064,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
|||
}
|
||||
else
|
||||
{
|
||||
// If we clicked and released outside the grid, do nothing.
|
||||
// If we clicked and released outside the grid (or on HaxeUI), do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ class ChartEditorAudioHandler
|
|||
* @param instId The instrumental this vocal track will be for.
|
||||
* @return Success or failure.
|
||||
*/
|
||||
public static function loadVocalsFromPath(state:ChartEditorState, path:Path, charId:String, instId:String = ''):Bool
|
||||
public static function loadVocalsFromPath(state:ChartEditorState, path:Path, charId:String, instId:String = '', wipeFirst:Bool = false):Bool
|
||||
{
|
||||
#if sys
|
||||
var fileBytes:Bytes = sys.io.File.getBytes(path.toString());
|
||||
return loadVocalsFromBytes(state, fileBytes, charId, instId);
|
||||
return loadVocalsFromBytes(state, fileBytes, charId, instId, wipeFirst);
|
||||
#else
|
||||
trace("[WARN] This platform can't load audio from a file path, you'll need to fetch the bytes some other way.");
|
||||
return false;
|
||||
|
@ -47,12 +47,12 @@ class ChartEditorAudioHandler
|
|||
* @param instId The instrumental this vocal track will be for.
|
||||
* @return Success or failure.
|
||||
*/
|
||||
public static function loadVocalsFromAsset(state:ChartEditorState, path:String, charId:String, instId:String = ''):Bool
|
||||
public static function loadVocalsFromAsset(state:ChartEditorState, path:String, charId:String, instId:String = '', wipeFirst:Bool = false):Bool
|
||||
{
|
||||
var trackData:Null<Bytes> = Assets.getBytes(path);
|
||||
if (trackData != null)
|
||||
{
|
||||
return loadVocalsFromBytes(state, trackData, charId, instId);
|
||||
return loadVocalsFromBytes(state, trackData, charId, instId, wipeFirst);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -63,10 +63,12 @@ class ChartEditorAudioHandler
|
|||
* @param bytes The audio byte data.
|
||||
* @param charId The character this vocal track will be for.
|
||||
* @param instId The instrumental this vocal track will be for.
|
||||
* @param wipeFirst Whether to wipe the existing vocal data before loading.
|
||||
*/
|
||||
public static function loadVocalsFromBytes(state:ChartEditorState, bytes:Bytes, charId:String, instId:String = ''):Bool
|
||||
public static function loadVocalsFromBytes(state:ChartEditorState, bytes:Bytes, charId:String, instId:String = '', wipeFirst:Bool = false):Bool
|
||||
{
|
||||
var trackId:String = '${charId}${instId == '' ? '' : '-${instId}'}';
|
||||
if (wipeFirst) wipeVocalData(state);
|
||||
state.audioVocalTrackData.set(trackId, bytes);
|
||||
return true;
|
||||
}
|
||||
|
@ -78,11 +80,11 @@ class ChartEditorAudioHandler
|
|||
* @param instId The instrumental this vocal track will be for.
|
||||
* @return Success or failure.
|
||||
*/
|
||||
public static function loadInstFromPath(state:ChartEditorState, path:Path, instId:String = ''):Bool
|
||||
public static function loadInstFromPath(state:ChartEditorState, path:Path, instId:String = '', wipeFirst:Bool = false):Bool
|
||||
{
|
||||
#if sys
|
||||
var fileBytes:Bytes = sys.io.File.getBytes(path.toString());
|
||||
return loadInstFromBytes(state, fileBytes, instId);
|
||||
return loadInstFromBytes(state, fileBytes, instId, wipeFirst);
|
||||
#else
|
||||
trace("[WARN] This platform can't load audio from a file path, you'll need to fetch the bytes some other way.");
|
||||
return false;
|
||||
|
@ -96,12 +98,12 @@ class ChartEditorAudioHandler
|
|||
* @param instId The instrumental this vocal track will be for.
|
||||
* @return Success or failure.
|
||||
*/
|
||||
public static function loadInstFromAsset(state:ChartEditorState, path:String, instId:String = ''):Bool
|
||||
public static function loadInstFromAsset(state:ChartEditorState, path:String, instId:String = '', wipeFirst:Bool = false):Bool
|
||||
{
|
||||
var trackData:Null<Bytes> = Assets.getBytes(path);
|
||||
if (trackData != null)
|
||||
{
|
||||
return loadInstFromBytes(state, trackData, instId);
|
||||
return loadInstFromBytes(state, trackData, instId, wipeFirst);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -113,9 +115,10 @@ class ChartEditorAudioHandler
|
|||
* @param charId The character this vocal track will be for.
|
||||
* @param instId The instrumental this vocal track will be for.
|
||||
*/
|
||||
public static function loadInstFromBytes(state:ChartEditorState, bytes:Bytes, instId:String = ''):Bool
|
||||
public static function loadInstFromBytes(state:ChartEditorState, bytes:Bytes, instId:String = '', wipeFirst:Bool = false):Bool
|
||||
{
|
||||
if (instId == '') instId = 'default';
|
||||
if (wipeFirst) wipeInstrumentalData(state);
|
||||
state.audioInstTrackData.set(instId, bytes);
|
||||
return true;
|
||||
}
|
||||
|
@ -127,9 +130,9 @@ class ChartEditorAudioHandler
|
|||
|
||||
stopExistingVocals(state);
|
||||
result = playVocals(state, BF, playerId, instId);
|
||||
if (!result) return false;
|
||||
// if (!result) return false;
|
||||
result = playVocals(state, DAD, opponentId, instId);
|
||||
if (!result) return false;
|
||||
// if (!result) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -758,14 +758,9 @@ class ChartEditorDialogHandler
|
|||
trace('Selected file: $pathStr');
|
||||
var path:Path = new Path(pathStr);
|
||||
|
||||
if (!hasClearedVocals)
|
||||
if (state.loadVocalsFromPath(path, charKey, instId, !hasClearedVocals))
|
||||
{
|
||||
hasClearedVocals = true;
|
||||
state.stopExistingVocals();
|
||||
}
|
||||
|
||||
if (state.loadVocalsFromPath(path, charKey, instId))
|
||||
{
|
||||
// Tell the user the load was successful.
|
||||
state.success('Loaded Vocals', 'Loaded vocals for $charName (${path.file}.${path.ext}), variation ${state.selectedVariation}');
|
||||
#if FILE_DROP_SUPPORTED
|
||||
|
@ -799,13 +794,10 @@ class ChartEditorDialogHandler
|
|||
if (selectedFile != null && selectedFile.bytes != null)
|
||||
{
|
||||
trace('Selected file: ' + selectedFile.name);
|
||||
if (!hasClearedVocals)
|
||||
|
||||
if (state.loadVocalsFromBytes(selectedFile.bytes, charKey, instId, !hasClearedVocals))
|
||||
{
|
||||
hasClearedVocals = true;
|
||||
state.stopExistingVocals();
|
||||
}
|
||||
if (state.loadVocalsFromBytes(selectedFile.bytes, charKey, instId))
|
||||
{
|
||||
// Tell the user the load was successful.
|
||||
state.success('Loaded Vocals', 'Loaded vocals for $charName (${selectedFile.name}), variation ${state.selectedVariation}');
|
||||
|
||||
|
|
Loading…
Reference in a new issue