mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-30 03:25:47 -05:00
Merge remote-tracking branch 'origin/bugfix-squashed/macos-file-browse' into HEAD
This commit is contained in:
commit
e8952d101a
4 changed files with 79 additions and 5 deletions
|
@ -200,6 +200,12 @@
|
|||
<postbuild haxe="source/Prebuild.hx"/> -->
|
||||
<postbuild haxe="source/Postbuild.hx"/> -->
|
||||
|
||||
<!-- Enable this on platforms which do not support dropping files onto the window. -->
|
||||
<set name="FILE_DROP_UNSUPPORTED" if="mac" />
|
||||
<section unless="FILE_DROP_UNSUPPORTED">
|
||||
<set name="FILE_DROP_SUPPORTED" />
|
||||
</section>
|
||||
|
||||
<!-- Options for Polymod -->
|
||||
<section if="polymod">
|
||||
<!-- Turns on additional debug logging. -->
|
||||
|
|
|
@ -391,6 +391,15 @@ class ChartEditorDialogHandler
|
|||
handler:(String->Void)
|
||||
}> = [];
|
||||
|
||||
/**
|
||||
* Add a callback for when a file is dropped on a component.
|
||||
*
|
||||
* On OS X you can’t drop on the application window, but rather only the app icon
|
||||
* (either in the dock while running or the icon on the hard drive) so this must be disabled
|
||||
* and UI updated appropriately.
|
||||
* @param component
|
||||
* @param handler
|
||||
*/
|
||||
static function addDropHandler(component:Component, handler:String->Void):Void
|
||||
{
|
||||
#if desktop
|
||||
|
@ -655,7 +664,11 @@ class ChartEditorDialogHandler
|
|||
|
||||
var vocalsEntryLabel:Null<Label> = vocalsEntry.findComponent('vocalsEntryLabel', Label);
|
||||
if (vocalsEntryLabel == null) throw 'Could not locate vocalsEntryLabel in Upload Vocals dialog';
|
||||
#if FILE_DROP_SUPPORTED
|
||||
vocalsEntryLabel.text = 'Drag and drop vocals for $charName here, or click to browse.';
|
||||
#else
|
||||
vocalsEntryLabel.text = 'Click to browse for vocals for $charName.';
|
||||
#end
|
||||
|
||||
var onDropFile:String->Void = function(pathStr:String) {
|
||||
trace('Selected file: $pathStr');
|
||||
|
@ -673,7 +686,12 @@ class ChartEditorDialogHandler
|
|||
expiryMs: ChartEditorState.NOTIFICATION_DISMISS_TIME
|
||||
});
|
||||
#end
|
||||
#if FILE_DROP_SUPPORTED
|
||||
vocalsEntryLabel.text = 'Vocals for $charName (drag and drop, or click to browse)\nSelected file: ${path.file}.${path.ext}';
|
||||
#else
|
||||
vocalsEntryLabel.text = 'Vocals for $charName (click to browse)\n${path.file}.${path.ext}';
|
||||
#end
|
||||
|
||||
dialogNoVocals.hidden = true;
|
||||
removeDropHandler(onDropFile);
|
||||
}
|
||||
|
@ -699,7 +717,11 @@ class ChartEditorDialogHandler
|
|||
});
|
||||
#end
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
vocalsEntryLabel.text = 'Drag and drop vocals for $charName here, or click to browse.';
|
||||
#else
|
||||
vocalsEntryLabel.text = 'Click to browse for vocals for $charName.';
|
||||
#end
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -709,7 +731,11 @@ class ChartEditorDialogHandler
|
|||
if (selectedFile != null && selectedFile.bytes != null)
|
||||
{
|
||||
trace('Selected file: ' + selectedFile.name);
|
||||
#if FILE_DROP_SUPPORTED
|
||||
vocalsEntryLabel.text = 'Vocals for $charName (drag and drop, or click to browse)\nSelected file: ${selectedFile.name}';
|
||||
#else
|
||||
vocalsEntryLabel.text = 'Vocals for $charName (click to browse)\n${selectedFile.name}';
|
||||
#end
|
||||
state.loadVocalsFromBytes(selectedFile.bytes, charKey);
|
||||
dialogNoVocals.hidden = true;
|
||||
removeDropHandler(onDropFile);
|
||||
|
@ -718,7 +744,9 @@ class ChartEditorDialogHandler
|
|||
}
|
||||
|
||||
// onDropFile
|
||||
#if FILE_DROP_SUPPORTED
|
||||
addDropHandler(vocalsEntry, onDropFile);
|
||||
#end
|
||||
dialogContainer.addComponent(vocalsEntry);
|
||||
}
|
||||
|
||||
|
@ -782,7 +810,11 @@ class ChartEditorDialogHandler
|
|||
var songDefaultChartDataEntry:Component = state.buildComponent(CHART_EDITOR_DIALOG_OPEN_CHART_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
|
||||
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);
|
||||
addDropHandler(songDefaultChartDataEntry, onDropFileChartDataVariation.bind(Constants.DEFAULT_VARIATION).bind(songDefaultChartDataEntryLabel));
|
||||
|
@ -794,20 +826,32 @@ class ChartEditorDialogHandler
|
|||
var songVariationMetadataEntry:Component = state.buildComponent(CHART_EDITOR_DIALOG_OPEN_CHART_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
|
||||
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.';
|
||||
#end
|
||||
|
||||
songVariationMetadataEntry.onClick = onClickMetadataVariation.bind(variation).bind(songVariationMetadataEntryLabel);
|
||||
#if FILE_DROP_SUPPORTED
|
||||
addDropHandler(songVariationMetadataEntry, onDropFileMetadataVariation.bind(variation).bind(songVariationMetadataEntryLabel));
|
||||
#end
|
||||
chartContainerB.addComponent(songVariationMetadataEntry);
|
||||
|
||||
// Build entries for -chart-<variation>.json.
|
||||
var songVariationChartDataEntry:Component = state.buildComponent(CHART_EDITOR_DIALOG_OPEN_CHART_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
|
||||
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.';
|
||||
#end
|
||||
|
||||
songVariationChartDataEntry.onClick = onClickChartDataVariation.bind(variation).bind(songVariationChartDataEntryLabel);
|
||||
#if FILE_DROP_SUPPORTED
|
||||
addDropHandler(songVariationChartDataEntry, onDropFileChartDataVariation.bind(variation).bind(songVariationChartDataEntryLabel));
|
||||
#end
|
||||
chartContainerB.addComponent(songVariationChartDataEntry);
|
||||
}
|
||||
}
|
||||
|
@ -848,7 +892,11 @@ class ChartEditorDialogHandler
|
|||
});
|
||||
#end
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
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}';
|
||||
#end
|
||||
|
||||
if (variation == Constants.DEFAULT_VARIATION) constructVariationEntries(songMetadataVariation.playData.songVariations);
|
||||
};
|
||||
|
@ -878,7 +926,11 @@ class ChartEditorDialogHandler
|
|||
});
|
||||
#end
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
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}';
|
||||
#end
|
||||
|
||||
if (variation == Constants.DEFAULT_VARIATION) constructVariationEntries(songMetadataVariation.playData.songVariations);
|
||||
}
|
||||
|
@ -909,7 +961,11 @@ class ChartEditorDialogHandler
|
|||
});
|
||||
#end
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
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}';
|
||||
#end
|
||||
};
|
||||
|
||||
onClickChartDataVariation = function(variation:String, label:Label, _event:UIEvent) {
|
||||
|
@ -939,7 +995,11 @@ class ChartEditorDialogHandler
|
|||
});
|
||||
#end
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
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}';
|
||||
#end
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -947,7 +1007,12 @@ class ChartEditorDialogHandler
|
|||
var metadataEntry:Component = state.buildComponent(CHART_EDITOR_DIALOG_OPEN_CHART_ENTRY_LAYOUT);
|
||||
var metadataEntryLabel:Null<Label> = metadataEntry.findComponent('chartEntryLabel', Label);
|
||||
if (metadataEntryLabel == null) throw 'Could not locate chartEntryLabel in Open Chart dialog';
|
||||
|
||||
#if FILE_DROP_SUPPORTED
|
||||
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);
|
||||
addDropHandler(metadataEntry, onDropFileMetadataVariation.bind(Constants.DEFAULT_VARIATION).bind(metadataEntryLabel));
|
||||
|
|
|
@ -2598,8 +2598,7 @@ class ChartEditorState extends HaxeUIState
|
|||
|
||||
if (gridGhostNote == null) throw "ERROR: Tried to handle cursor, but gridGhostNote is null! Check ChartEditorState.buildGrid()";
|
||||
|
||||
var noteData:SongNoteData = gridGhostNote.noteData != null ? gridGhostNote.noteData : new SongNoteData(cursorMs, cursorColumn, 0,
|
||||
selectedNoteKind);
|
||||
var noteData:SongNoteData = gridGhostNote.noteData != null ? gridGhostNote.noteData : new SongNoteData(cursorMs, cursorColumn, 0, selectedNoteKind);
|
||||
|
||||
if (cursorColumn != noteData.data || selectedNoteKind != noteData.kind)
|
||||
{
|
||||
|
@ -2760,12 +2759,12 @@ class ChartEditorState extends HaxeUIState
|
|||
trace('Creating new Note... (${renderedNotes.members.length})');
|
||||
noteSprite.parentState = this;
|
||||
|
||||
// The note sprite handles animation playback and positioning.
|
||||
noteSprite.noteData = noteData;
|
||||
|
||||
// Setting note data resets position relative to the grid so we fix that.
|
||||
noteSprite.updateNotePosition(renderedNotes);
|
||||
|
||||
// The note sprite handles animation playback and positioning.
|
||||
noteSprite.noteData = noteData;
|
||||
|
||||
// Add hold notes that are now visible (and not already displayed).
|
||||
if (noteSprite.noteData != null && noteSprite.noteData.length > 0 && displayedHoldNoteData.indexOf(noteSprite.noteData) == -1)
|
||||
{
|
||||
|
|
|
@ -240,6 +240,10 @@ class FileUtil
|
|||
onSaveAll(paths);
|
||||
}
|
||||
|
||||
trace('Browsing for directory to save individual files to...');
|
||||
#if mac
|
||||
defaultPath = null;
|
||||
#end
|
||||
browseForDirectory(null, onSelectDir, onCancel, defaultPath, 'Choose directory to save all files to...');
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue