mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2025-07-29 15:30:10 -04:00
File drop feature flag fix
This commit is contained in:
parent
edb270d15e
commit
923c54bbbc
3 changed files with 75 additions and 41 deletions
source/funkin/ui/debug/charting
|
@ -50,7 +50,9 @@ class ChartEditorUploadChartDialog extends ChartEditorBaseDialog
|
|||
|
||||
for (dropTarget in dialog.dropHandlers)
|
||||
{
|
||||
#if FEATURE_FILE_DROP
|
||||
state.addDropHandler(dropTarget);
|
||||
#end
|
||||
}
|
||||
|
||||
dialog.showDialog(modal ?? true);
|
||||
|
|
|
@ -80,23 +80,30 @@ class ChartEditorUploadVocalsDialog extends ChartEditorBaseDialog
|
|||
this.hasClearedVocals = true;
|
||||
// Tell the user the load was successful.
|
||||
chartEditorState.success('Loaded Vocals', 'Loaded vocals for $charName (${path.file}.${path.ext}), variation ${chartEditorState.selectedVariation}');
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
vocalsEntry.vocalsEntryLabel.text = 'Voices for $charName (drag and drop, or click to browse)\nSelected file: ${path.file}.${path.ext}';
|
||||
#else
|
||||
vocalsEntry.vocalsEntryLabel.text = 'Voices for $charName (click to browse)\n${path.file}.${path.ext}';
|
||||
#end
|
||||
|
||||
dialogNoVocals.hidden = true;
|
||||
chartEditorState.removeDropHandler(dropHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
var message:String = if (!ChartEditorState.SUPPORTED_MUSIC_FORMATS.contains(path.ext ?? ''))
|
||||
{
|
||||
'File format (${path.ext}) not supported for vocal track (${path.file}.${path.ext})';
|
||||
}
|
||||
else
|
||||
{
|
||||
'Failed to load vocal track (${path.file}.${path.ext}) for variation (${chartEditorState.selectedVariation})';
|
||||
}
|
||||
|
||||
trace('Failed to load vocal track (${path.file}.${path.ext})');
|
||||
|
||||
chartEditorState.error('Failed to Load Vocals',
|
||||
'Failed to load vocal track (${path.file}.${path.ext}) for variation (${chartEditorState.selectedVariation})');
|
||||
chartEditorState.error('Failed to Load Vocals', message);
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
vocalsEntry.vocalsEntryLabel.text = 'Drag and drop vocals for $charName here, or click to browse.';
|
||||
#else
|
||||
vocalsEntry.vocalsEntryLabel.text = 'Click to browse for vocals for $charName.';
|
||||
|
@ -118,7 +125,7 @@ class ChartEditorUploadVocalsDialog extends ChartEditorBaseDialog
|
|||
chartEditorState.success('Loaded Vocals',
|
||||
'Loaded vocals for $charName (${selectedFile.name}), variation ${chartEditorState.selectedVariation}');
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
vocalsEntry.vocalsEntryLabel.text = 'Voices for $charName (drag and drop, or click to browse)\nSelected file: ${selectedFile.name}';
|
||||
#else
|
||||
vocalsEntry.vocalsEntryLabel.text = 'Voices for $charName (click to browse)\n${selectedFile.name}';
|
||||
|
@ -133,7 +140,7 @@ class ChartEditorUploadVocalsDialog extends ChartEditorBaseDialog
|
|||
chartEditorState.error('Failed to Load Vocals',
|
||||
'Failed to load vocal track (${selectedFile.name}) for variation (${chartEditorState.selectedVariation})');
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
vocalsEntry.vocalsEntryLabel.text = 'Drag and drop vocals for $charName here, or click to browse.';
|
||||
#else
|
||||
vocalsEntry.vocalsEntryLabel.text = 'Click to browse for vocals for $charName.';
|
||||
|
@ -146,9 +153,8 @@ class ChartEditorUploadVocalsDialog extends ChartEditorBaseDialog
|
|||
dropHandler.handler = onDropFile;
|
||||
|
||||
// onDropFile
|
||||
#if FILE_DROP_SUPPORTED
|
||||
dropHandlers.push(dropHandler);
|
||||
#end
|
||||
|
||||
|
||||
vocalContainer.addComponent(vocalsEntry);
|
||||
}
|
||||
|
@ -164,7 +170,9 @@ class ChartEditorUploadVocalsDialog extends ChartEditorBaseDialog
|
|||
|
||||
for (dropTarget in dialog.dropHandlers)
|
||||
{
|
||||
#if FEATURE_FILE_DROP
|
||||
state.addDropHandler(dropTarget);
|
||||
#end
|
||||
}
|
||||
|
||||
dialog.showDialog(modal ?? true);
|
||||
|
@ -291,7 +299,7 @@ class ChartEditorUploadVocalsEntry extends Box
|
|||
|
||||
this.charName = charName;
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
vocalsEntryLabel.text = 'Drag and drop vocals for $charName here, or click to browse.';
|
||||
#else
|
||||
vocalsEntryLabel.text = 'Click to browse for vocals for $charName.';
|
||||
|
|
|
@ -487,10 +487,6 @@ class ChartEditorDialogHandler
|
|||
var buttonCancel:Null<Button> = dialog.findComponent('dialogCancel', Button);
|
||||
if (buttonCancel == null) throw 'Could not locate dialogCancel button in Upload Instrumental dialog';
|
||||
|
||||
buttonCancel.onClick = function(_) {
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
}
|
||||
|
||||
var instrumentalBox:Null<Box> = dialog.findComponent('instrumentalBox', Box);
|
||||
if (instrumentalBox == null) throw 'Could not locate instrumentalBox in Upload Instrumental dialog';
|
||||
|
||||
|
@ -504,10 +500,15 @@ class ChartEditorDialogHandler
|
|||
Cursor.cursorMode = Default;
|
||||
}
|
||||
|
||||
var instId:String = state.currentInstrumentalId;
|
||||
|
||||
var dropHandler:DialogDropTarget = {component: instrumentalBox, handler: null};
|
||||
|
||||
buttonCancel.onClick = function(_) {
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
state.removeDropHandler(dropHandler);
|
||||
}
|
||||
|
||||
var instId:String = state.currentInstrumentalId;
|
||||
|
||||
instrumentalBox.onClick = function(_) {
|
||||
Dialogs.openBinaryFile('Open Instrumental', [
|
||||
{label: 'Audio File (.ogg)', extension: 'ogg'}], function(selectedFile:SelectedFileInfo) {
|
||||
|
@ -552,14 +553,18 @@ class ChartEditorDialogHandler
|
|||
'Failed to load instrumental track (${path.file}.${path.ext}) for variation (${state.selectedVariation})';
|
||||
}
|
||||
|
||||
// Tell the user the load was successful.
|
||||
trace('Failed to load instrumental track (${path.file}.${path.ext})');
|
||||
|
||||
// Tell the user the load was unsuccessful.
|
||||
state.error('Failed to Load Instrumental', message);
|
||||
}
|
||||
};
|
||||
|
||||
dropHandler.handler = onDropFile;
|
||||
|
||||
#if FEATURE_FILE_DROP
|
||||
state.addDropHandler(dropHandler);
|
||||
#end
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
@ -738,6 +743,7 @@ class ChartEditorDialogHandler
|
|||
if (buttonCancel == null) throw 'Could not locate dialogCancel button in Open Chart dialog';
|
||||
buttonCancel.onClick = function(_) {
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
state.clearDropHandlers();
|
||||
}
|
||||
|
||||
var chartContainerA:Null<Component> = dialog.findComponent('chartContainerA');
|
||||
|
@ -754,6 +760,7 @@ class ChartEditorDialogHandler
|
|||
state.loadSong(songMetadata, songChartData);
|
||||
|
||||
dialog.hideDialog(DialogButton.APPLY);
|
||||
state.clearDropHandlers();
|
||||
}
|
||||
|
||||
var onDropFileMetadataVariation:String->Label->String->Void;
|
||||
|
@ -772,18 +779,20 @@ class ChartEditorDialogHandler
|
|||
var songDefaultChartDataEntry:Component = RuntimeComponentBuilder.fromAsset(CHART_EDITOR_DIALOG_OPEN_CHART_PARTS_ENTRY_LAYOUT);
|
||||
var songDefaultChartDataEntryLabel:Null<Label> = songDefaultChartDataEntry.findComponent('chartEntryLabel', Label);
|
||||
if (songDefaultChartDataEntryLabel == null) throw 'Could not locate chartEntryLabel in Open Chart dialog';
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
songDefaultChartDataEntryLabel.text = 'Drag and drop <song>-chart.json file, or click to browse.';
|
||||
#else
|
||||
songDefaultChartDataEntryLabel.text = 'Click to browse for <song>-chart.json file.';
|
||||
#end
|
||||
|
||||
songDefaultChartDataEntry.onClick = onClickChartDataVariation.bind(Constants.DEFAULT_VARIATION).bind(songDefaultChartDataEntryLabel);
|
||||
#if FEATURE_FILE_DROP
|
||||
state.addDropHandler(
|
||||
{
|
||||
component: songDefaultChartDataEntry,
|
||||
handler: onDropFileChartDataVariation.bind(Constants.DEFAULT_VARIATION).bind(songDefaultChartDataEntryLabel)
|
||||
});
|
||||
#end
|
||||
chartContainerB.addComponent(songDefaultChartDataEntry);
|
||||
|
||||
for (variation in variations)
|
||||
|
@ -792,7 +801,7 @@ class ChartEditorDialogHandler
|
|||
var songVariationMetadataEntry:Component = RuntimeComponentBuilder.fromAsset(CHART_EDITOR_DIALOG_OPEN_CHART_PARTS_ENTRY_LAYOUT);
|
||||
var songVariationMetadataEntryLabel:Null<Label> = songVariationMetadataEntry.findComponent('chartEntryLabel', Label);
|
||||
if (songVariationMetadataEntryLabel == null) throw 'Could not locate chartEntryLabel in Open Chart dialog';
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
songVariationMetadataEntryLabel.text = 'Drag and drop <song>-metadata-${variation}.json file, or click to browse.';
|
||||
#else
|
||||
songVariationMetadataEntryLabel.text = 'Click to browse for <song>-metadata-${variation}.json file.';
|
||||
|
@ -807,7 +816,7 @@ class ChartEditorDialogHandler
|
|||
Cursor.cursorMode = Default;
|
||||
}
|
||||
songVariationMetadataEntry.onClick = onClickMetadataVariation.bind(variation).bind(songVariationMetadataEntryLabel);
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
state.addDropHandler(
|
||||
{
|
||||
component: songVariationMetadataEntry,
|
||||
|
@ -820,7 +829,7 @@ class ChartEditorDialogHandler
|
|||
var songVariationChartDataEntry:Component = RuntimeComponentBuilder.fromAsset(CHART_EDITOR_DIALOG_OPEN_CHART_PARTS_ENTRY_LAYOUT);
|
||||
var songVariationChartDataEntryLabel:Null<Label> = songVariationChartDataEntry.findComponent('chartEntryLabel', Label);
|
||||
if (songVariationChartDataEntryLabel == null) throw 'Could not locate chartEntryLabel in Open Chart dialog';
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
songVariationChartDataEntryLabel.text = 'Drag and drop <song>-chart-${variation}.json file, or click to browse.';
|
||||
#else
|
||||
songVariationChartDataEntryLabel.text = 'Click to browse for <song>-chart-${variation}.json file.';
|
||||
|
@ -835,7 +844,7 @@ class ChartEditorDialogHandler
|
|||
Cursor.cursorMode = Default;
|
||||
}
|
||||
songVariationChartDataEntry.onClick = onClickChartDataVariation.bind(variation).bind(songVariationChartDataEntryLabel);
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
state.addDropHandler(
|
||||
{
|
||||
component: songVariationChartDataEntry,
|
||||
|
@ -875,7 +884,7 @@ class ChartEditorDialogHandler
|
|||
// Tell the user the load was successful.
|
||||
state.success('Loaded Metadata', 'Loaded metadata file (${path.file}.${path.ext})');
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
label.text = 'Metadata file (drag and drop, or click to browse)\nSelected file: ${path.file}.${path.ext}';
|
||||
#else
|
||||
label.text = 'Metadata file (click to browse)\n${path.file}.${path.ext}';
|
||||
|
@ -911,7 +920,7 @@ class ChartEditorDialogHandler
|
|||
// Tell the user the load was successful.
|
||||
state.success('Loaded Metadata', 'Loaded metadata file (${selectedFile.name})');
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
label.text = 'Metadata file (drag and drop, or click to browse)\nSelected file: ${selectedFile.name}';
|
||||
#else
|
||||
label.text = 'Metadata file (click to browse)\n${selectedFile.name}';
|
||||
|
@ -955,7 +964,7 @@ class ChartEditorDialogHandler
|
|||
// Tell the user the load was successful.
|
||||
state.success('Loaded Chart Data', 'Loaded chart data file (${path.file}.${path.ext})');
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
label.text = 'Chart data file (drag and drop, or click to browse)\nSelected file: ${path.file}.${path.ext}';
|
||||
#else
|
||||
label.text = 'Chart data file (click to browse)\n${path.file}.${path.ext}';
|
||||
|
@ -998,7 +1007,7 @@ class ChartEditorDialogHandler
|
|||
// Tell the user the load was successful.
|
||||
state.success('Loaded Chart Data', 'Loaded chart data file (${selectedFile.name})');
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
label.text = 'Chart data file (drag and drop, or click to browse)\nSelected file: ${selectedFile.name}';
|
||||
#else
|
||||
label.text = 'Chart data file (click to browse)\n${selectedFile.name}';
|
||||
|
@ -1012,14 +1021,20 @@ class ChartEditorDialogHandler
|
|||
var metadataEntryLabel:Null<Label> = metadataEntry.findComponent('chartEntryLabel', Label);
|
||||
if (metadataEntryLabel == null) throw 'Could not locate chartEntryLabel in Open Chart dialog';
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
#if FEATURE_FILE_DROP
|
||||
metadataEntryLabel.text = 'Drag and drop <song>-metadata.json file, or click to browse.';
|
||||
#else
|
||||
metadataEntryLabel.text = 'Click to browse for <song>-metadata.json file.';
|
||||
#end
|
||||
|
||||
metadataEntry.onClick = onClickMetadataVariation.bind(Constants.DEFAULT_VARIATION).bind(metadataEntryLabel);
|
||||
state.addDropHandler({component: metadataEntry, handler: onDropFileMetadataVariation.bind(Constants.DEFAULT_VARIATION).bind(metadataEntryLabel)});
|
||||
#if FEATURE_FILE_DROP
|
||||
state.addDropHandler(
|
||||
{
|
||||
component: metadataEntry,
|
||||
handler: onDropFileMetadataVariation.bind(Constants.DEFAULT_VARIATION).bind(metadataEntryLabel)
|
||||
});
|
||||
#end
|
||||
metadataEntry.onMouseOver = function(_event) {
|
||||
metadataEntry.swapClass('upload-bg', 'upload-bg-hover');
|
||||
Cursor.cursorMode = Pointer;
|
||||
|
@ -1046,6 +1061,20 @@ class ChartEditorDialogHandler
|
|||
var dialog:Null<Dialog> = openDialog(state, CHART_EDITOR_DIALOG_IMPORT_CHART_LAYOUT, true, closable);
|
||||
if (dialog == null) return null;
|
||||
|
||||
var importBox:Null<Box> = dialog.findComponent('importBox', Box);
|
||||
if (importBox == null) throw 'Could not locate importBox in Import Chart dialog';
|
||||
|
||||
importBox.onMouseOver = function(_) {
|
||||
importBox.swapClass('upload-bg', 'upload-bg-hover');
|
||||
Cursor.cursorMode = Pointer;
|
||||
}
|
||||
importBox.onMouseOut = function(_) {
|
||||
importBox.swapClass('upload-bg-hover', 'upload-bg');
|
||||
Cursor.cursorMode = Default;
|
||||
}
|
||||
|
||||
var dropHandler:DialogDropTarget = {component: importBox, handler: null};
|
||||
|
||||
var prettyFormat:String = switch (format)
|
||||
{
|
||||
case 'legacy': 'FNF Legacy';
|
||||
|
@ -1067,18 +1096,7 @@ class ChartEditorDialogHandler
|
|||
buttonCancel.onClick = function(_) {
|
||||
state.isHaxeUIDialogOpen = false;
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
}
|
||||
|
||||
var importBox:Null<Box> = dialog.findComponent('importBox', Box);
|
||||
if (importBox == null) throw 'Could not locate importBox in Import Chart dialog';
|
||||
|
||||
importBox.onMouseOver = function(_) {
|
||||
importBox.swapClass('upload-bg', 'upload-bg-hover');
|
||||
Cursor.cursorMode = Pointer;
|
||||
}
|
||||
importBox.onMouseOut = function(_) {
|
||||
importBox.swapClass('upload-bg-hover', 'upload-bg');
|
||||
Cursor.cursorMode = Default;
|
||||
state.removeDropHandler(dropHandler);
|
||||
}
|
||||
|
||||
var onDropFile:String->Void;
|
||||
|
@ -1103,6 +1121,7 @@ class ChartEditorDialogHandler
|
|||
state.loadSong([Constants.DEFAULT_VARIATION => songMetadata], [Constants.DEFAULT_VARIATION => songChartData]);
|
||||
|
||||
dialog.hideDialog(DialogButton.APPLY);
|
||||
state.removeDropHandler(dropHandler);
|
||||
state.success('Success', 'Loaded chart file (${selectedFile.name})');
|
||||
}
|
||||
});
|
||||
|
@ -1118,10 +1137,15 @@ class ChartEditorDialogHandler
|
|||
state.loadSong([Constants.DEFAULT_VARIATION => songMetadata], [Constants.DEFAULT_VARIATION => songChartData]);
|
||||
|
||||
dialog.hideDialog(DialogButton.APPLY);
|
||||
state.removeDropHandler(dropHandler);
|
||||
state.success('Success', 'Loaded chart file (${path.file}.${path.ext})');
|
||||
};
|
||||
|
||||
state.addDropHandler({component: importBox, handler: onDropFile});
|
||||
dropHandler.handler = onDropFile;
|
||||
|
||||
#if FEATURE_FILE_DROP
|
||||
state.addDropHandler(dropHandler);
|
||||
#end
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue