WIP on new chart wizard
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package funkin.ui.debug.charting;
|
||||
|
||||
import funkin.input.Cursor;
|
||||
import haxe.ui.containers.Box;
|
||||
import haxe.ui.containers.dialogs.Dialogs;
|
||||
import haxe.ui.components.Link;
|
||||
import flixel.util.FlxTimer;
|
||||
import flixel.FlxSprite;
|
||||
import haxe.ui.containers.dialogs.Dialog;
|
||||
@@ -9,7 +13,8 @@ import haxe.ui.components.Image;
|
||||
class ChartEditorDialogHandler
|
||||
{
|
||||
static final CHART_EDITOR_DIALOG_ABOUT_LAYOUT = Paths.ui('chart-editor/dialogs/about');
|
||||
static final CHART_EDITOR_DIALOG_SPLASH_LAYOUT = Paths.ui('chart-editor/dialogs/splash');
|
||||
static final CHART_EDITOR_DIALOG_WELCOME_LAYOUT = Paths.ui('chart-editor/dialogs/welcome');
|
||||
static final CHART_EDITOR_DIALOG_UPLOAD_INST_LAYOUT = Paths.ui('chart-editor/dialogs/upload-inst');
|
||||
static final CHART_EDITOR_DIALOG_USER_GUIDE_LAYOUT = Paths.ui('chart-editor/dialogs/user-guide');
|
||||
|
||||
/**
|
||||
@@ -23,9 +28,9 @@ class ChartEditorDialogHandler
|
||||
/**
|
||||
* Builds and opens a dialog letting the user create a new chart, open a recent chart, or load from a template.
|
||||
*/
|
||||
public static function openSplashDialog(state:ChartEditorState, closable:Bool = true):Void
|
||||
public static function openWelcomeDialog(state:ChartEditorState, closable:Bool = true):Void
|
||||
{
|
||||
var dialog:Dialog = openDialog(state, CHART_EDITOR_DIALOG_SPLASH_LAYOUT, true, closable);
|
||||
var dialog:Dialog = openDialog(state, CHART_EDITOR_DIALOG_WELCOME_LAYOUT, true, closable);
|
||||
|
||||
// TODO: Add callbacks to the dialog buttons
|
||||
|
||||
@@ -57,6 +62,77 @@ class ChartEditorDialogHandler
|
||||
bfSprite.visible = true;
|
||||
});
|
||||
}
|
||||
|
||||
// Add handlers to the "Create From Song" section.
|
||||
var linkCreateBasic:Link = dialog.findComponent('splashCreateFromSongBasic', Link);
|
||||
linkCreateBasic.onClick = (_event) ->
|
||||
{
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
openUploadInstDialog(state, false);
|
||||
};
|
||||
|
||||
// Get the list of songs and insert them as links into the "Create From Song" section.
|
||||
}
|
||||
|
||||
public static function openUploadInstDialog(state:ChartEditorState, ?closable:Bool = true):Void
|
||||
{
|
||||
var dialog:Dialog = openDialog(state, CHART_EDITOR_DIALOG_UPLOAD_INST_LAYOUT, true, closable);
|
||||
|
||||
var instrumentalBox:Box = dialog.findComponent('instrumentalBox', Box);
|
||||
|
||||
instrumentalBox.onMouseOver = (_event) ->
|
||||
{
|
||||
instrumentalBox.swapClass('upload-bg', 'upload-bg-hover');
|
||||
Cursor.cursorMode = Pointer;
|
||||
}
|
||||
|
||||
instrumentalBox.onMouseOut = (_event) ->
|
||||
{
|
||||
instrumentalBox.swapClass('upload-bg-hover', 'upload-bg');
|
||||
Cursor.cursorMode = Default;
|
||||
}
|
||||
|
||||
var onDropFile:String->Void;
|
||||
|
||||
instrumentalBox.onClick = (_event) ->
|
||||
{
|
||||
Dialogs.openBinaryFile("Open Instrumental", [{label: "Audio File (.ogg)", extension: "ogg"}], function(selectedFile)
|
||||
{
|
||||
if (selectedFile != null)
|
||||
{
|
||||
trace('Selected file: ' + selectedFile);
|
||||
state.loadInstrumentalFromBytes(selectedFile.bytes);
|
||||
dialog.hideDialog(DialogButton.APPLY);
|
||||
removeDropHandler(onDropFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onDropFile = (path:String) ->
|
||||
{
|
||||
trace('Dropped file: ' + path);
|
||||
state.loadInstrumentalFromPath(path);
|
||||
dialog.hideDialog(DialogButton.APPLY);
|
||||
removeDropHandler(onDropFile);
|
||||
};
|
||||
|
||||
addDropHandler(onDropFile);
|
||||
}
|
||||
|
||||
static function addDropHandler(handler:String->Void)
|
||||
{
|
||||
#if desktop
|
||||
FlxG.stage.window.onDropFile.add(handler);
|
||||
#else
|
||||
trace('addDropHandler not implemented for this platform');
|
||||
#end
|
||||
}
|
||||
|
||||
static function removeDropHandler(handler:String->Void)
|
||||
{
|
||||
#if desktop
|
||||
FlxG.stage.window.onDropFile.remove(handler);
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user