mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-23 08:07:54 -05:00
Merge branch 'bugfix/chart-editor-null-safety' into HEAD
This commit is contained in:
commit
ee900fd7aa
21 changed files with 305 additions and 173 deletions
|
@ -47,7 +47,7 @@ class Conductor
|
|||
/**
|
||||
* Beats per minute of the current song at the current time.
|
||||
*/
|
||||
public static var bpm(get, null):Float;
|
||||
public static var bpm(get, never):Float;
|
||||
|
||||
static function get_bpm():Float
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ class Conductor
|
|||
/**
|
||||
* Duration of a measure in milliseconds. Calculated based on bpm.
|
||||
*/
|
||||
public static var measureLengthMs(get, null):Float;
|
||||
public static var measureLengthMs(get, never):Float;
|
||||
|
||||
static function get_measureLengthMs():Float
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ class Conductor
|
|||
/**
|
||||
* Duration of a beat (quarter note) in milliseconds. Calculated based on bpm.
|
||||
*/
|
||||
public static var beatLengthMs(get, null):Float;
|
||||
public static var beatLengthMs(get, never):Float;
|
||||
|
||||
static function get_beatLengthMs():Float
|
||||
{
|
||||
|
@ -88,14 +88,14 @@ class Conductor
|
|||
/**
|
||||
* Duration of a step (sixtennth note) in milliseconds. Calculated based on bpm.
|
||||
*/
|
||||
public static var stepLengthMs(get, null):Float;
|
||||
public static var stepLengthMs(get, never):Float;
|
||||
|
||||
static function get_stepLengthMs():Float
|
||||
{
|
||||
return beatLengthMs / timeSignatureNumerator;
|
||||
}
|
||||
|
||||
public static var timeSignatureNumerator(get, null):Int;
|
||||
public static var timeSignatureNumerator(get, never):Int;
|
||||
|
||||
static function get_timeSignatureNumerator():Int
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ class Conductor
|
|||
return currentTimeChange.timeSignatureNum;
|
||||
}
|
||||
|
||||
public static var timeSignatureDenominator(get, null):Int;
|
||||
public static var timeSignatureDenominator(get, never):Int;
|
||||
|
||||
static function get_timeSignatureDenominator():Int
|
||||
{
|
||||
|
@ -151,7 +151,7 @@ class Conductor
|
|||
public static var audioOffset:Float = 0;
|
||||
public static var offset:Float = 0;
|
||||
|
||||
public static var beatsPerMeasure(get, null):Float;
|
||||
public static var beatsPerMeasure(get, never):Float;
|
||||
|
||||
static function get_beatsPerMeasure():Float
|
||||
{
|
||||
|
@ -159,7 +159,7 @@ class Conductor
|
|||
return stepsPerMeasure / Constants.STEPS_PER_BEAT;
|
||||
}
|
||||
|
||||
public static var stepsPerMeasure(get, null):Int;
|
||||
public static var stepsPerMeasure(get, never):Int;
|
||||
|
||||
static function get_stepsPerMeasure():Int
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ class TurboKeyHandler extends FlxBasic
|
|||
/**
|
||||
* Whether all of the keys for this handler are pressed.
|
||||
*/
|
||||
public var allPressed(get, null):Bool;
|
||||
public var allPressed(get, never):Bool;
|
||||
|
||||
/**
|
||||
* Whether all of the keys for this handler are activated,
|
||||
|
|
|
@ -251,14 +251,14 @@ class PlayState extends MusicBeatSubState
|
|||
|
||||
var overrideMusic:Bool = false;
|
||||
|
||||
public var isSubState(get, null):Bool;
|
||||
public var isSubState(get, never):Bool;
|
||||
|
||||
function get_isSubState():Bool
|
||||
{
|
||||
return this._parentState != null;
|
||||
}
|
||||
|
||||
public var isChartingMode(get, null):Bool;
|
||||
public var isChartingMode(get, never):Bool;
|
||||
|
||||
function get_isChartingMode():Bool
|
||||
{
|
||||
|
@ -427,7 +427,7 @@ class PlayState extends MusicBeatSubState
|
|||
* Data for the current difficulty for the current song.
|
||||
* Includes chart data, scroll speed, and other information.
|
||||
*/
|
||||
public var currentChart(get, null):SongDifficulty;
|
||||
public var currentChart(get, never):SongDifficulty;
|
||||
|
||||
function get_currentChart():SongDifficulty
|
||||
{
|
||||
|
@ -439,7 +439,7 @@ class PlayState extends MusicBeatSubState
|
|||
* The internal ID of the currently active Stage.
|
||||
* Used to retrieve the data required to build the `currentStage`.
|
||||
*/
|
||||
public var currentStageId(get, null):String;
|
||||
public var currentStageId(get, never):String;
|
||||
|
||||
function get_currentStageId():String
|
||||
{
|
||||
|
|
|
@ -66,7 +66,7 @@ class BaseCharacter extends Bopper
|
|||
* The offset between the corner of the sprite and the origin of the sprite (at the character's feet).
|
||||
* cornerPosition = stageData - characterOrigin
|
||||
*/
|
||||
public var characterOrigin(get, null):FlxPoint;
|
||||
public var characterOrigin(get, never):FlxPoint;
|
||||
|
||||
function get_characterOrigin():FlxPoint
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ class BaseCharacter extends Bopper
|
|||
/**
|
||||
* The absolute position of the character's feet, at the bottom-center of the sprite.
|
||||
*/
|
||||
public var feetPosition(get, null):FlxPoint;
|
||||
public var feetPosition(get, never):FlxPoint;
|
||||
|
||||
function get_feetPosition():FlxPoint
|
||||
{
|
||||
|
@ -264,7 +264,7 @@ class BaseCharacter extends Bopper
|
|||
/**
|
||||
* The per-character camera offset.
|
||||
*/
|
||||
var characterCameraOffsets(get, null):Array<Float>;
|
||||
var characterCameraOffsets(get, never):Array<Float>;
|
||||
|
||||
function get_characterCameraOffsets():Array<Float>
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ class Conversation extends FlxSpriteGroup implements IDialogueScriptedClass
|
|||
*/
|
||||
var currentDialogueEntry:Int = 0;
|
||||
|
||||
var currentDialogueEntryCount(get, null):Int;
|
||||
var currentDialogueEntryCount(get, never):Int;
|
||||
|
||||
function get_currentDialogueEntryCount():Int
|
||||
{
|
||||
|
@ -62,14 +62,14 @@ class Conversation extends FlxSpriteGroup implements IDialogueScriptedClass
|
|||
* **/
|
||||
var currentDialogueLine:Int = 0;
|
||||
|
||||
var currentDialogueLineCount(get, null):Int;
|
||||
var currentDialogueLineCount(get, never):Int;
|
||||
|
||||
function get_currentDialogueLineCount():Int
|
||||
{
|
||||
return currentDialogueEntryData.text.length;
|
||||
}
|
||||
|
||||
var currentDialogueEntryData(get, null):DialogueEntryData;
|
||||
var currentDialogueEntryData(get, never):DialogueEntryData;
|
||||
|
||||
function get_currentDialogueEntryData():DialogueEntryData
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ class Conversation extends FlxSpriteGroup implements IDialogueScriptedClass
|
|||
return conversationData.dialogue[currentDialogueEntry];
|
||||
}
|
||||
|
||||
var currentDialogueLineString(get, null):String;
|
||||
var currentDialogueLineString(get, never):String;
|
||||
|
||||
function get_currentDialogueLineString():String
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ import flixel.util.FlxColor;
|
|||
class DialogueBox extends FlxSpriteGroup implements IDialogueScriptedClass
|
||||
{
|
||||
public final dialogueBoxId:String;
|
||||
public var dialogueBoxName(get, null):String;
|
||||
public var dialogueBoxName(get, never):String;
|
||||
|
||||
function get_dialogueBoxName():String
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ class Speaker extends FlxSprite implements IDialogueScriptedClass
|
|||
/**
|
||||
* A readable name for this speaker.
|
||||
*/
|
||||
public var speakerName(get, null):String;
|
||||
public var speakerName(get, never):String;
|
||||
|
||||
function get_speakerName():String
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ class Strumline extends FlxSpriteGroup
|
|||
static final KEY_COUNT:Int = 4;
|
||||
static final NOTE_SPLASH_CAP:Int = 6;
|
||||
|
||||
static var RENDER_DISTANCE_MS(get, null):Float;
|
||||
static var RENDER_DISTANCE_MS(get, never):Float;
|
||||
|
||||
static function get_RENDER_DISTANCE_MS():Float
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ class SustainTrail extends FlxSprite
|
|||
public var noteDirection:NoteDirection = 0;
|
||||
public var sustainLength(default, set):Float = 0; // millis
|
||||
public var fullSustainLength:Float = 0;
|
||||
public var noteData:SongNoteData;
|
||||
public var noteData:Null<SongNoteData>;
|
||||
|
||||
public var cover:NoteHoldCover = null;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class SongValidator
|
|||
public static final DEFAULT_STAGE:String = "mainStage";
|
||||
public static final DEFAULT_SCROLLSPEED:Float = 1.0;
|
||||
|
||||
public static var DEFAULT_GENERATEDBY(get, null):String;
|
||||
public static var DEFAULT_GENERATEDBY(get, never):String;
|
||||
|
||||
static function get_DEFAULT_GENERATEDBY():String
|
||||
{
|
||||
|
|
|
@ -35,6 +35,7 @@ interface ChartEditorCommand
|
|||
public function toString():String;
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class AddNotesCommand implements ChartEditorCommand
|
||||
{
|
||||
var notes:Array<SongNoteData>;
|
||||
|
@ -98,6 +99,7 @@ class AddNotesCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class RemoveNotesCommand implements ChartEditorCommand
|
||||
{
|
||||
var notes:Array<SongNoteData>;
|
||||
|
@ -153,6 +155,7 @@ class RemoveNotesCommand implements ChartEditorCommand
|
|||
/**
|
||||
* Appends one or more items to the selection.
|
||||
*/
|
||||
@:nullSafety
|
||||
class SelectItemsCommand implements ChartEditorCommand
|
||||
{
|
||||
var notes:Array<SongNoteData>;
|
||||
|
@ -220,6 +223,7 @@ class SelectItemsCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class AddEventsCommand implements ChartEditorCommand
|
||||
{
|
||||
var events:Array<SongEventData>;
|
||||
|
@ -278,6 +282,7 @@ class AddEventsCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class RemoveEventsCommand implements ChartEditorCommand
|
||||
{
|
||||
var events:Array<SongEventData>;
|
||||
|
@ -327,6 +332,7 @@ class RemoveEventsCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class RemoveItemsCommand implements ChartEditorCommand
|
||||
{
|
||||
var notes:Array<SongNoteData>;
|
||||
|
@ -385,6 +391,7 @@ class RemoveItemsCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class SwitchDifficultyCommand implements ChartEditorCommand
|
||||
{
|
||||
var prevDifficulty:String;
|
||||
|
@ -424,6 +431,7 @@ class SwitchDifficultyCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class DeselectItemsCommand implements ChartEditorCommand
|
||||
{
|
||||
var notes:Array<SongNoteData>;
|
||||
|
@ -478,6 +486,7 @@ class DeselectItemsCommand implements ChartEditorCommand
|
|||
* Sets the selection rather than appends it.
|
||||
* Deselects any notes that are not in the new selection.
|
||||
*/
|
||||
@:nullSafety
|
||||
class SetItemSelectionCommand implements ChartEditorCommand
|
||||
{
|
||||
var notes:Array<SongNoteData>;
|
||||
|
@ -518,6 +527,7 @@ class SetItemSelectionCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class SelectAllItemsCommand implements ChartEditorCommand
|
||||
{
|
||||
var previousNoteSelection:Array<SongNoteData>;
|
||||
|
@ -553,6 +563,7 @@ class SelectAllItemsCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class InvertSelectedItemsCommand implements ChartEditorCommand
|
||||
{
|
||||
var previousNoteSelection:Array<SongNoteData>;
|
||||
|
@ -587,6 +598,7 @@ class InvertSelectedItemsCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class DeselectAllItemsCommand implements ChartEditorCommand
|
||||
{
|
||||
var previousNoteSelection:Array<SongNoteData>;
|
||||
|
@ -622,6 +634,7 @@ class DeselectAllItemsCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class CutItemsCommand implements ChartEditorCommand
|
||||
{
|
||||
var notes:Array<SongNoteData>;
|
||||
|
@ -679,14 +692,16 @@ class CutItemsCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class FlipNotesCommand implements ChartEditorCommand
|
||||
{
|
||||
var notes:Array<SongNoteData>;
|
||||
var flippedNotes:Array<SongNoteData>;
|
||||
var notes:Array<SongNoteData> = [];
|
||||
var flippedNotes:Array<SongNoteData> = [];
|
||||
|
||||
public function new(notes:Array<SongNoteData>)
|
||||
{
|
||||
this.notes = notes;
|
||||
this.flippedNotes = SongDataUtils.flipNotes(notes);
|
||||
}
|
||||
|
||||
public function execute(state:ChartEditorState):Void
|
||||
|
@ -695,7 +710,6 @@ class FlipNotesCommand implements ChartEditorCommand
|
|||
state.currentSongChartNoteData = SongDataUtils.subtractNotes(state.currentSongChartNoteData, notes);
|
||||
|
||||
// Add the flipped notes.
|
||||
flippedNotes = SongDataUtils.flipNotes(notes);
|
||||
state.currentSongChartNoteData = state.currentSongChartNoteData.concat(flippedNotes);
|
||||
|
||||
state.currentNoteSelection = flippedNotes;
|
||||
|
@ -729,12 +743,13 @@ class FlipNotesCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class PasteItemsCommand implements ChartEditorCommand
|
||||
{
|
||||
var targetTimestamp:Float;
|
||||
// Notes we added with this command, for undo.
|
||||
var addedNotes:Array<SongNoteData>;
|
||||
var addedEvents:Array<SongEventData>;
|
||||
var addedNotes:Array<SongNoteData> = [];
|
||||
var addedEvents:Array<SongEventData> = [];
|
||||
|
||||
public function new(targetTimestamp:Float)
|
||||
{
|
||||
|
@ -787,6 +802,7 @@ class PasteItemsCommand implements ChartEditorCommand
|
|||
}
|
||||
}
|
||||
|
||||
@:nullSafety
|
||||
class ExtendNoteLengthCommand implements ChartEditorCommand
|
||||
{
|
||||
var note:SongNoteData;
|
||||
|
|
|
@ -40,6 +40,7 @@ using Lambda;
|
|||
/**
|
||||
* Handles dialogs for the new Chart Editor.
|
||||
*/
|
||||
@:nullSafety
|
||||
class ChartEditorDialogHandler
|
||||
{
|
||||
static final CHART_EDITOR_DIALOG_ABOUT_LAYOUT:String = Paths.ui('chart-editor/dialogs/about');
|
||||
|
@ -59,7 +60,7 @@ class ChartEditorDialogHandler
|
|||
* @param state The current chart editor state.
|
||||
* @return The dialog that was opened.
|
||||
*/
|
||||
public static inline function openAboutDialog(state:ChartEditorState):Dialog
|
||||
public static inline function openAboutDialog(state:ChartEditorState):Null<Dialog>
|
||||
{
|
||||
return openDialog(state, CHART_EDITOR_DIALOG_ABOUT_LAYOUT, true, true);
|
||||
}
|
||||
|
@ -70,12 +71,14 @@ class ChartEditorDialogHandler
|
|||
* @param closable Whether the dialog can be closed by the user.
|
||||
* @return The dialog that was opened.
|
||||
*/
|
||||
public static function openWelcomeDialog(state:ChartEditorState, closable:Bool = true):Dialog
|
||||
public static function openWelcomeDialog(state:ChartEditorState, closable:Bool = true):Null<Dialog>
|
||||
{
|
||||
var dialog:Dialog = openDialog(state, CHART_EDITOR_DIALOG_WELCOME_LAYOUT, true, closable);
|
||||
var dialog:Null<Dialog> = openDialog(state, CHART_EDITOR_DIALOG_WELCOME_LAYOUT, true, closable);
|
||||
if (dialog == null) throw 'Could not locate Welcome dialog';
|
||||
|
||||
// Add handlers to the "Create From Song" section.
|
||||
var linkCreateBasic:Link = dialog.findComponent('splashCreateFromSongBasic', Link);
|
||||
var linkCreateBasic:Null<Link> = dialog.findComponent('splashCreateFromSongBasic', Link);
|
||||
if (linkCreateBasic == null) throw 'Could not locate splashCreateFromSongBasic link in Welcome dialog';
|
||||
linkCreateBasic.onClick = function(_event) {
|
||||
// Hide the welcome dialog
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
|
@ -86,7 +89,8 @@ class ChartEditorDialogHandler
|
|||
openCreateSongWizard(state, false);
|
||||
}
|
||||
|
||||
var linkImportChartLegacy:Link = dialog.findComponent('splashImportChartLegacy', Link);
|
||||
var linkImportChartLegacy:Null<Link> = dialog.findComponent('splashImportChartLegacy', Link);
|
||||
if (linkImportChartLegacy == null) throw 'Could not locate splashImportChartLegacy link in Welcome dialog';
|
||||
linkImportChartLegacy.onClick = function(_event) {
|
||||
// Hide the welcome dialog
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
|
@ -95,7 +99,8 @@ class ChartEditorDialogHandler
|
|||
openImportChartWizard(state, 'legacy', false);
|
||||
};
|
||||
|
||||
var buttonBrowse:Button = dialog.findComponent('splashBrowse', Button);
|
||||
var buttonBrowse:Null<Button> = dialog.findComponent('splashBrowse', Button);
|
||||
if (buttonBrowse == null) throw 'Could not locate splashBrowse button in Welcome dialog';
|
||||
buttonBrowse.onClick = function(_event) {
|
||||
// Hide the welcome dialog
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
|
@ -104,22 +109,29 @@ class ChartEditorDialogHandler
|
|||
openBrowseWizard(state, false);
|
||||
}
|
||||
|
||||
var splashTemplateContainer:VBox = dialog.findComponent('splashTemplateContainer', VBox);
|
||||
var splashTemplateContainer:Null<VBox> = dialog.findComponent('splashTemplateContainer', VBox);
|
||||
if (splashTemplateContainer == null) throw 'Could not locate splashTemplateContainer in Welcome dialog';
|
||||
|
||||
var songList:Array<String> = SongDataParser.listSongIds();
|
||||
songList.sort(SortUtil.alphabetically);
|
||||
|
||||
for (targetSongId in songList)
|
||||
{
|
||||
var songData:Song = SongDataParser.fetchSong(targetSongId);
|
||||
var songData:Null<Song> = SongDataParser.fetchSong(targetSongId);
|
||||
|
||||
if (songData == null) continue;
|
||||
|
||||
var songName:Null<String> = songData.getDifficulty('normal') ?.songName;
|
||||
if (songName == null) songName = songData.getDifficulty() ?.songName;
|
||||
var diffNormal:Null<SongDifficulty> = songData.getDifficulty('normal');
|
||||
var songName:Null<String> = diffNormal?.songName;
|
||||
if (songName == null)
|
||||
{
|
||||
var diffDefault:Null<SongDifficulty> = songData.getDifficulty();
|
||||
songName = diffDefault?.songName;
|
||||
}
|
||||
if (songName == null)
|
||||
{
|
||||
trace('[WARN] Could not fetch song name for ${targetSongId}');
|
||||
continue;
|
||||
}
|
||||
|
||||
var linkTemplateSong:Link = new Link();
|
||||
|
@ -184,7 +196,8 @@ class ChartEditorDialogHandler
|
|||
{
|
||||
// Open the "Open Chart" wizard
|
||||
// Step 1. Open Chart
|
||||
var openChartDialog:Dialog = openImportChartDialog(state, format);
|
||||
var openChartDialog:Null<Dialog> = openImportChartDialog(state, format);
|
||||
if (openChartDialog == null) throw 'Could not locate Import Chart dialog';
|
||||
openChartDialog.onDialogClosed = function(_event) {
|
||||
state.isHaxeUIDialogOpen = false;
|
||||
if (_event.button == DialogButton.APPLY)
|
||||
|
@ -260,15 +273,18 @@ class ChartEditorDialogHandler
|
|||
@:haxe.warning("-WVarInit") // Hide the warning about the onDropFile handler.
|
||||
public static function openUploadInstDialog(state:ChartEditorState, closable:Bool = true):Dialog
|
||||
{
|
||||
var dialog:Dialog = openDialog(state, CHART_EDITOR_DIALOG_UPLOAD_INST_LAYOUT, true, closable);
|
||||
var dialog:Null<Dialog> = openDialog(state, CHART_EDITOR_DIALOG_UPLOAD_INST_LAYOUT, true, closable);
|
||||
if (dialog == null) throw 'Could not locate Upload Instrumental dialog';
|
||||
|
||||
var buttonCancel:Button = dialog.findComponent('dialogCancel', Button);
|
||||
var buttonCancel:Null<Button> = dialog.findComponent('dialogCancel', Button);
|
||||
if (buttonCancel == null) throw 'Could not locate dialogCancel button in Upload Instrumental dialog';
|
||||
|
||||
buttonCancel.onClick = function(_event) {
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
}
|
||||
|
||||
var instrumentalBox:Box = dialog.findComponent('instrumentalBox', Box);
|
||||
var instrumentalBox:Null<Box> = dialog.findComponent('instrumentalBox', Box);
|
||||
if (instrumentalBox == null) throw 'Could not locate instrumentalBox in Upload Instrumental dialog';
|
||||
|
||||
instrumentalBox.onMouseOver = function(_event) {
|
||||
instrumentalBox.swapClass('upload-bg', 'upload-bg-hover');
|
||||
|
@ -285,7 +301,7 @@ class ChartEditorDialogHandler
|
|||
instrumentalBox.onClick = function(_event) {
|
||||
Dialogs.openBinaryFile('Open Instrumental', [
|
||||
{label: 'Audio File (.ogg)', extension: 'ogg'}], function(selectedFile:SelectedFileInfo) {
|
||||
if (selectedFile != null)
|
||||
if (selectedFile != null && selectedFile.bytes != null)
|
||||
{
|
||||
if (state.loadInstrumentalFromBytes(selectedFile.bytes))
|
||||
{
|
||||
|
@ -336,7 +352,7 @@ class ChartEditorDialogHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
var message:String = if (!ChartEditorState.SUPPORTED_MUSIC_FORMATS.contains(path.ext))
|
||||
var message:String = if (!ChartEditorState.SUPPORTED_MUSIC_FORMATS.contains(path.ext ?? ''))
|
||||
{
|
||||
'File format (${path.ext}) not supported for instrumental track (${path.file}.${path.ext})';
|
||||
}
|
||||
|
@ -420,15 +436,17 @@ class ChartEditorDialogHandler
|
|||
@:haxe.warning("-WVarInit")
|
||||
public static function openSongMetadataDialog(state:ChartEditorState):Dialog
|
||||
{
|
||||
var dialog:Dialog = openDialog(state, CHART_EDITOR_DIALOG_SONG_METADATA_LAYOUT, true, false);
|
||||
|
||||
var buttonCancel:Button = dialog.findComponent('dialogCancel', Button);
|
||||
var dialog:Null<Dialog> = openDialog(state, CHART_EDITOR_DIALOG_SONG_METADATA_LAYOUT, true, false);
|
||||
if (dialog == null) throw 'Could not locate Song Metadata dialog';
|
||||
|
||||
var buttonCancel:Null<Button> = dialog.findComponent('dialogCancel', Button);
|
||||
if (buttonCancel == null) throw 'Could not locate dialogCancel button in Song Metadata dialog';
|
||||
buttonCancel.onClick = function(_event) {
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
}
|
||||
|
||||
var dialogSongName:TextField = dialog.findComponent('dialogSongName', TextField);
|
||||
var dialogSongName:Null<TextField> = dialog.findComponent('dialogSongName', TextField);
|
||||
if (dialogSongName == null) throw 'Could not locate dialogSongName TextField in Song Metadata dialog';
|
||||
dialogSongName.onChange = function(event:UIEvent) {
|
||||
var valid:Bool = event.target.text != null && event.target.text != '';
|
||||
|
||||
|
@ -439,12 +457,13 @@ class ChartEditorDialogHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
state.currentSongMetadata.songName = null;
|
||||
state.currentSongMetadata.songName = "";
|
||||
}
|
||||
};
|
||||
state.currentSongMetadata.songName = null;
|
||||
state.currentSongMetadata.songName = "";
|
||||
|
||||
var dialogSongArtist:TextField = dialog.findComponent('dialogSongArtist', TextField);
|
||||
var dialogSongArtist:Null<TextField> = dialog.findComponent('dialogSongArtist', TextField);
|
||||
if (dialogSongArtist == null) throw 'Could not locate dialogSongArtist TextField in Song Metadata dialog';
|
||||
dialogSongArtist.onChange = function(event:UIEvent) {
|
||||
var valid:Bool = event.target.text != null && event.target.text != '';
|
||||
|
||||
|
@ -455,26 +474,29 @@ class ChartEditorDialogHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
state.currentSongMetadata.artist = null;
|
||||
state.currentSongMetadata.artist = "";
|
||||
}
|
||||
};
|
||||
state.currentSongMetadata.artist = null;
|
||||
state.currentSongMetadata.artist = "";
|
||||
|
||||
var dialogStage:DropDown = dialog.findComponent('dialogStage', DropDown);
|
||||
var dialogStage:Null<DropDown> = dialog.findComponent('dialogStage', DropDown);
|
||||
if (dialogStage == null) throw 'Could not locate dialogStage DropDown in Song Metadata dialog';
|
||||
dialogStage.onChange = function(event:UIEvent) {
|
||||
if (event.data == null && event.data.id == null) return;
|
||||
state.currentSongMetadata.playData.stage = event.data.id;
|
||||
};
|
||||
state.currentSongMetadata.playData.stage = null;
|
||||
state.currentSongMetadata.playData.stage = 'mainStage';
|
||||
|
||||
var dialogNoteSkin:DropDown = dialog.findComponent('dialogNoteSkin', DropDown);
|
||||
var dialogNoteSkin:Null<DropDown> = dialog.findComponent('dialogNoteSkin', DropDown);
|
||||
if (dialogNoteSkin == null) throw 'Could not locate dialogNoteSkin DropDown in Song Metadata dialog';
|
||||
dialogNoteSkin.onChange = function(event:UIEvent) {
|
||||
if (event.data.id == null) return;
|
||||
state.currentSongMetadata.playData.noteSkin = event.data.id;
|
||||
};
|
||||
state.currentSongMetadata.playData.noteSkin = null;
|
||||
state.currentSongMetadata.playData.noteSkin = 'funkin';
|
||||
|
||||
var dialogBPM:NumberStepper = dialog.findComponent('dialogBPM', NumberStepper);
|
||||
var dialogBPM:Null<NumberStepper> = dialog.findComponent('dialogBPM', NumberStepper);
|
||||
if (dialogBPM == null) throw 'Could not locate dialogBPM NumberStepper in Song Metadata dialog';
|
||||
dialogBPM.onChange = function(event:UIEvent) {
|
||||
if (event.value == null || event.value <= 0) return;
|
||||
|
||||
|
@ -493,8 +515,10 @@ class ChartEditorDialogHandler
|
|||
state.currentSongMetadata.timeChanges = timeChanges;
|
||||
};
|
||||
|
||||
var dialogCharGrid:PropertyGrid = dialog.findComponent('dialogCharGrid', PropertyGrid);
|
||||
var dialogCharAdd:Button = dialog.findComponent('dialogCharAdd', Button);
|
||||
var dialogCharGrid:Null<PropertyGrid> = dialog.findComponent('dialogCharGrid', PropertyGrid);
|
||||
if (dialogCharGrid == null) throw 'Could not locate dialogCharGrid PropertyGrid in Song Metadata dialog';
|
||||
var dialogCharAdd:Null<Button> = dialog.findComponent('dialogCharAdd', Button);
|
||||
if (dialogCharAdd == null) throw 'Could not locate dialogCharAdd Button in Song Metadata dialog';
|
||||
dialogCharAdd.onClick = function(event:UIEvent) {
|
||||
var charGroup:PropertyGroup;
|
||||
charGroup = buildCharGroup(state, null, () -> dialogCharGrid.removeComponent(charGroup));
|
||||
|
@ -504,15 +528,16 @@ class ChartEditorDialogHandler
|
|||
// Empty the character list.
|
||||
state.currentSongMetadata.playData.playableChars = {};
|
||||
// Add at least one character group with no Remove button.
|
||||
dialogCharGrid.addComponent(buildCharGroup(state, 'bf', null));
|
||||
dialogCharGrid.addComponent(buildCharGroup(state, 'bf'));
|
||||
|
||||
var dialogContinue:Button = dialog.findComponent('dialogContinue', Button);
|
||||
var dialogContinue:Null<Button> = dialog.findComponent('dialogContinue', Button);
|
||||
if (dialogContinue == null) throw 'Could not locate dialogContinue button in Song Metadata dialog';
|
||||
dialogContinue.onClick = (_event) -> dialog.hideDialog(DialogButton.APPLY);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
static function buildCharGroup(state:ChartEditorState, key:String = null, removeFunc:Void->Void):PropertyGroup
|
||||
static function buildCharGroup(state:ChartEditorState, key:String = '', removeFunc:Void->Void = null):PropertyGroup
|
||||
{
|
||||
var groupKey:String = key;
|
||||
|
||||
|
@ -537,32 +562,36 @@ class ChartEditorDialogHandler
|
|||
|
||||
var removeGroup:Void->Void = function() {
|
||||
state.currentSongMetadata.playData.playableChars.remove(groupKey);
|
||||
removeFunc();
|
||||
if (removeFunc != null) removeFunc();
|
||||
}
|
||||
|
||||
var charData:SongPlayableChar = getCharData();
|
||||
|
||||
var charGroup:PropertyGroup = cast state.buildComponent(CHART_EDITOR_DIALOG_SONG_METADATA_CHARGROUP_LAYOUT);
|
||||
|
||||
var charGroupPlayer:DropDown = charGroup.findComponent('charGroupPlayer', DropDown);
|
||||
var charGroupPlayer:Null<DropDown> = charGroup.findComponent('charGroupPlayer', DropDown);
|
||||
if (charGroupPlayer == null) throw 'Could not locate charGroupPlayer DropDown in Song Metadata dialog';
|
||||
charGroupPlayer.onChange = function(event:UIEvent) {
|
||||
charGroup.text = event.data.text;
|
||||
moveCharGroup(event.data.id);
|
||||
};
|
||||
|
||||
var charGroupOpponent:DropDown = charGroup.findComponent('charGroupOpponent', DropDown);
|
||||
var charGroupOpponent:Null<DropDown> = charGroup.findComponent('charGroupOpponent', DropDown);
|
||||
if (charGroupOpponent == null) throw 'Could not locate charGroupOpponent DropDown in Song Metadata dialog';
|
||||
charGroupOpponent.onChange = function(event:UIEvent) {
|
||||
charData.opponent = event.data.id;
|
||||
};
|
||||
charGroupOpponent.value = getCharData().opponent;
|
||||
|
||||
var charGroupGirlfriend:DropDown = charGroup.findComponent('charGroupGirlfriend', DropDown);
|
||||
var charGroupGirlfriend:Null<DropDown> = charGroup.findComponent('charGroupGirlfriend', DropDown);
|
||||
if (charGroupGirlfriend == null) throw 'Could not locate charGroupGirlfriend DropDown in Song Metadata dialog';
|
||||
charGroupGirlfriend.onChange = function(event:UIEvent) {
|
||||
charData.girlfriend = event.data.id;
|
||||
};
|
||||
charGroupGirlfriend.value = getCharData().girlfriend;
|
||||
|
||||
var charGroupRemove:Button = charGroup.findComponent('charGroupRemove', Button);
|
||||
var charGroupRemove:Null<Button> = charGroup.findComponent('charGroupRemove', Button);
|
||||
if (charGroupRemove == null) throw 'Could not locate charGroupRemove Button in Song Metadata dialog';
|
||||
charGroupRemove.onClick = function(event:UIEvent) {
|
||||
removeGroup();
|
||||
};
|
||||
|
@ -589,16 +618,20 @@ class ChartEditorDialogHandler
|
|||
if (charData.opponent != null) charIdsForVocals.push(charData.opponent);
|
||||
}
|
||||
|
||||
var dialog:Dialog = openDialog(state, CHART_EDITOR_DIALOG_UPLOAD_VOCALS_LAYOUT, true, closable);
|
||||
var dialog:Null<Dialog> = openDialog(state, CHART_EDITOR_DIALOG_UPLOAD_VOCALS_LAYOUT, true, closable);
|
||||
if (dialog == null) throw 'Could not locate Upload Vocals dialog';
|
||||
|
||||
var dialogContainer:Component = dialog.findComponent('vocalContainer');
|
||||
var dialogContainer:Null<Component> = dialog.findComponent('vocalContainer');
|
||||
if (dialogContainer == null) throw 'Could not locate vocalContainer in Upload Vocals dialog';
|
||||
|
||||
var buttonCancel:Button = dialog.findComponent('dialogCancel', Button);
|
||||
var buttonCancel:Null<Button> = dialog.findComponent('dialogCancel', Button);
|
||||
if (buttonCancel == null) throw 'Could not locate dialogCancel button in Upload Vocals dialog';
|
||||
buttonCancel.onClick = function(_event) {
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
}
|
||||
|
||||
var dialogNoVocals:Button = dialog.findComponent('dialogNoVocals', Button);
|
||||
var dialogNoVocals:Null<Button> = dialog.findComponent('dialogNoVocals', Button);
|
||||
if (dialogNoVocals == null) throw 'Could not locate dialogNoVocals button in Upload Vocals dialog';
|
||||
dialogNoVocals.onClick = function(_event) {
|
||||
// Dismiss
|
||||
dialog.hideDialog(DialogButton.APPLY);
|
||||
|
@ -607,12 +640,13 @@ class ChartEditorDialogHandler
|
|||
for (charKey in charIdsForVocals)
|
||||
{
|
||||
trace('Adding vocal upload for character ${charKey}');
|
||||
var charMetadata:CharacterData = CharacterDataParser.fetchCharacterData(charKey);
|
||||
var charMetadata:Null<CharacterData> = CharacterDataParser.fetchCharacterData(charKey);
|
||||
var charName:String = charMetadata != null ? charMetadata.name : charKey;
|
||||
|
||||
var vocalsEntry:Component = state.buildComponent(CHART_EDITOR_DIALOG_UPLOAD_VOCALS_ENTRY_LAYOUT);
|
||||
|
||||
var vocalsEntryLabel:Label = vocalsEntry.findComponent('vocalsEntryLabel', Label);
|
||||
var vocalsEntryLabel:Null<Label> = vocalsEntry.findComponent('vocalsEntryLabel', Label);
|
||||
if (vocalsEntryLabel == null) throw 'Could not locate vocalsEntryLabel in Upload Vocals dialog';
|
||||
vocalsEntryLabel.text = 'Drag and drop vocals for $charName here, or click to browse.';
|
||||
|
||||
var onDropFile:String->Void = function(pathStr:String) {
|
||||
|
@ -635,7 +669,7 @@ class ChartEditorDialogHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
var message:String = if (!ChartEditorState.SUPPORTED_MUSIC_FORMATS.contains(path.ext))
|
||||
var message:String = if (!ChartEditorState.SUPPORTED_MUSIC_FORMATS.contains(path.ext ?? ''))
|
||||
{
|
||||
'File format (${path.ext}) not supported for vocal track (${path.file}.${path.ext})';
|
||||
}
|
||||
|
@ -660,7 +694,7 @@ class ChartEditorDialogHandler
|
|||
vocalsEntry.onClick = function(_event) {
|
||||
Dialogs.openBinaryFile('Open $charName Vocals', [
|
||||
{label: 'Audio File (.ogg)', extension: 'ogg'}], function(selectedFile) {
|
||||
if (selectedFile != null)
|
||||
if (selectedFile != null && selectedFile.bytes != null)
|
||||
{
|
||||
trace('Selected file: ' + selectedFile.name);
|
||||
vocalsEntryLabel.text = 'Vocals for $charName (click to browse)\n${selectedFile.name}';
|
||||
|
@ -676,7 +710,8 @@ class ChartEditorDialogHandler
|
|||
dialogContainer.addComponent(vocalsEntry);
|
||||
}
|
||||
|
||||
var dialogContinue:Button = dialog.findComponent('dialogContinue', Button);
|
||||
var dialogContinue:Null<Button> = dialog.findComponent('dialogContinue', Button);
|
||||
if (dialogContinue == null) throw 'Could not locate dialogContinue button in Upload Vocals dialog';
|
||||
dialogContinue.onClick = function(_event) {
|
||||
// Dismiss
|
||||
dialog.hideDialog(DialogButton.APPLY);
|
||||
|
@ -694,20 +729,25 @@ class ChartEditorDialogHandler
|
|||
@:haxe.warning('-WVarInit')
|
||||
public static function openChartDialog(state:ChartEditorState, closable:Bool = true):Dialog
|
||||
{
|
||||
var dialog:Dialog = openDialog(state, CHART_EDITOR_DIALOG_OPEN_CHART_LAYOUT, true, closable);
|
||||
var dialog:Null<Dialog> = openDialog(state, CHART_EDITOR_DIALOG_OPEN_CHART_LAYOUT, true, closable);
|
||||
if (dialog == null) throw 'Could not locate Open Chart dialog';
|
||||
|
||||
var buttonCancel:Button = dialog.findComponent('dialogCancel', Button);
|
||||
var buttonCancel:Null<Button> = dialog.findComponent('dialogCancel', Button);
|
||||
if (buttonCancel == null) throw 'Could not locate dialogCancel button in Open Chart dialog';
|
||||
buttonCancel.onClick = function(_event) {
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
}
|
||||
|
||||
var chartContainerA:Component = dialog.findComponent('chartContainerA');
|
||||
var chartContainerB:Component = dialog.findComponent('chartContainerB');
|
||||
var chartContainerA:Null<Component> = dialog.findComponent('chartContainerA');
|
||||
if (chartContainerA == null) throw 'Could not locate chartContainerA in Open Chart dialog';
|
||||
var chartContainerB:Null<Component> = dialog.findComponent('chartContainerB');
|
||||
if (chartContainerB == null) throw 'Could not locate chartContainerB in Open Chart dialog';
|
||||
|
||||
var songMetadata:Map<String, SongMetadata> = [];
|
||||
var songChartData:Map<String, SongChartData> = [];
|
||||
|
||||
var buttonContinue:Button = dialog.findComponent('dialogContinue', Button);
|
||||
var buttonContinue:Null<Button> = dialog.findComponent('dialogContinue', Button);
|
||||
if (buttonContinue == null) throw 'Could not locate dialogContinue button in Open Chart dialog';
|
||||
buttonContinue.onClick = function(_event) {
|
||||
state.loadSong(songMetadata, songChartData);
|
||||
|
||||
|
@ -728,7 +768,8 @@ class ChartEditorDialogHandler
|
|||
|
||||
// Build an entry for -chart.json.
|
||||
var songDefaultChartDataEntry:Component = state.buildComponent(CHART_EDITOR_DIALOG_OPEN_CHART_ENTRY_LAYOUT);
|
||||
var songDefaultChartDataEntryLabel:Label = songDefaultChartDataEntry.findComponent('chartEntryLabel', Label);
|
||||
var songDefaultChartDataEntryLabel:Null<Label> = songDefaultChartDataEntry.findComponent('chartEntryLabel', Label);
|
||||
if (songDefaultChartDataEntryLabel == null) throw 'Could not locate chartEntryLabel in Open Chart dialog';
|
||||
songDefaultChartDataEntryLabel.text = 'Drag and drop <song>-chart.json file, or click to browse.';
|
||||
|
||||
songDefaultChartDataEntry.onClick = onClickChartDataVariation.bind(Constants.DEFAULT_VARIATION).bind(songDefaultChartDataEntryLabel);
|
||||
|
@ -739,7 +780,8 @@ class ChartEditorDialogHandler
|
|||
{
|
||||
// Build entries for -metadata-<variation>.json.
|
||||
var songVariationMetadataEntry:Component = state.buildComponent(CHART_EDITOR_DIALOG_OPEN_CHART_ENTRY_LAYOUT);
|
||||
var songVariationMetadataEntryLabel:Label = songVariationMetadataEntry.findComponent('chartEntryLabel', Label);
|
||||
var songVariationMetadataEntryLabel:Null<Label> = songVariationMetadataEntry.findComponent('chartEntryLabel', Label);
|
||||
if (songVariationMetadataEntryLabel == null) throw 'Could not locate chartEntryLabel in Open Chart dialog';
|
||||
songVariationMetadataEntryLabel.text = 'Drag and drop <song>-metadata-${variation}.json file, or click to browse.';
|
||||
|
||||
songVariationMetadataEntry.onClick = onClickMetadataVariation.bind(variation).bind(songVariationMetadataEntryLabel);
|
||||
|
@ -748,7 +790,8 @@ class ChartEditorDialogHandler
|
|||
|
||||
// Build entries for -chart-<variation>.json.
|
||||
var songVariationChartDataEntry:Component = state.buildComponent(CHART_EDITOR_DIALOG_OPEN_CHART_ENTRY_LAYOUT);
|
||||
var songVariationChartDataEntryLabel:Label = songVariationChartDataEntry.findComponent('chartEntryLabel', Label);
|
||||
var songVariationChartDataEntryLabel:Null<Label> = songVariationChartDataEntry.findComponent('chartEntryLabel', Label);
|
||||
if (songVariationChartDataEntryLabel == null) throw 'Could not locate chartEntryLabel in Open Chart dialog';
|
||||
songVariationChartDataEntryLabel.text = 'Drag and drop <song>-chart-${variation}.json file, or click to browse.';
|
||||
|
||||
songVariationChartDataEntry.onClick = onClickChartDataVariation.bind(variation).bind(songVariationChartDataEntryLabel);
|
||||
|
@ -797,7 +840,7 @@ class ChartEditorDialogHandler
|
|||
onClickMetadataVariation = function(variation:String, label:Label, _event:UIEvent) {
|
||||
Dialogs.openBinaryFile('Open Chart ($variation) Metadata', [
|
||||
{label: 'JSON File (.json)', extension: 'json'}], function(selectedFile) {
|
||||
if (selectedFile != null)
|
||||
if (selectedFile != null && selectedFile.bytes != null)
|
||||
{
|
||||
trace('Selected file: ' + selectedFile.name);
|
||||
|
||||
|
@ -852,7 +895,7 @@ class ChartEditorDialogHandler
|
|||
onClickChartDataVariation = function(variation:String, label:Label, _event:UIEvent) {
|
||||
Dialogs.openBinaryFile('Open Chart ($variation) Metadata', [
|
||||
{label: 'JSON File (.json)', extension: 'json'}], function(selectedFile) {
|
||||
if (selectedFile != null)
|
||||
if (selectedFile != null && selectedFile.bytes != null)
|
||||
{
|
||||
trace('Selected file: ' + selectedFile.name);
|
||||
|
||||
|
@ -880,7 +923,8 @@ class ChartEditorDialogHandler
|
|||
}
|
||||
|
||||
var metadataEntry:Component = state.buildComponent(CHART_EDITOR_DIALOG_OPEN_CHART_ENTRY_LAYOUT);
|
||||
var metadataEntryLabel:Label = metadataEntry.findComponent('chartEntryLabel', Label);
|
||||
var metadataEntryLabel:Null<Label> = metadataEntry.findComponent('chartEntryLabel', Label);
|
||||
if (metadataEntryLabel == null) throw 'Could not locate chartEntryLabel in Open Chart dialog';
|
||||
metadataEntryLabel.text = 'Drag and drop <song>-metadata.json file, or click to browse.';
|
||||
|
||||
metadataEntry.onClick = onClickMetadataVariation.bind(Constants.DEFAULT_VARIATION).bind(metadataEntryLabel);
|
||||
|
@ -898,9 +942,10 @@ class ChartEditorDialogHandler
|
|||
* @param closable
|
||||
* @return Dialog
|
||||
*/
|
||||
public static function openImportChartDialog(state:ChartEditorState, format:String, closable:Bool = true):Dialog
|
||||
public static function openImportChartDialog(state:ChartEditorState, format:String, closable:Bool = true):Null<Dialog>
|
||||
{
|
||||
var dialog:Dialog = openDialog(state, CHART_EDITOR_DIALOG_IMPORT_CHART_LAYOUT, true, closable);
|
||||
var dialog:Null<Dialog> = openDialog(state, CHART_EDITOR_DIALOG_IMPORT_CHART_LAYOUT, true, closable);
|
||||
if (dialog == null) return null;
|
||||
|
||||
var prettyFormat:String = switch (format)
|
||||
{
|
||||
|
@ -916,13 +961,15 @@ class ChartEditorDialogHandler
|
|||
|
||||
dialog.title = 'Import Chart - ${prettyFormat}';
|
||||
|
||||
var buttonCancel:Button = dialog.findComponent('dialogCancel', Button);
|
||||
var buttonCancel:Null<Button> = dialog.findComponent('dialogCancel', Button);
|
||||
if (buttonCancel == null) throw 'Could not locate dialogCancel button in Import Chart dialog';
|
||||
|
||||
buttonCancel.onClick = function(_event) {
|
||||
dialog.hideDialog(DialogButton.CANCEL);
|
||||
}
|
||||
|
||||
var importBox:Box = dialog.findComponent('importBox', Box);
|
||||
var importBox:Null<Box> = dialog.findComponent('importBox', Box);
|
||||
if (importBox == null) throw 'Could not locate importBox in Import Chart dialog';
|
||||
|
||||
importBox.onMouseOver = function(_event) {
|
||||
importBox.swapClass('upload-bg', 'upload-bg-hover');
|
||||
|
@ -937,8 +984,8 @@ class ChartEditorDialogHandler
|
|||
var onDropFile:String->Void;
|
||||
|
||||
importBox.onClick = function(_event) {
|
||||
Dialogs.openBinaryFile('Import Chart - ${prettyFormat}', [fileFilter], function(selectedFile:SelectedFileInfo) {
|
||||
if (selectedFile != null)
|
||||
Dialogs.openBinaryFile('Import Chart - ${prettyFormat}', fileFilter != null ? [fileFilter] : [], function(selectedFile:SelectedFileInfo) {
|
||||
if (selectedFile != null && selectedFile.bytes != null)
|
||||
{
|
||||
trace('Selected file: ' + selectedFile.fullPath);
|
||||
var selectedFileJson:Dynamic = SerializerUtil.fromJSONBytes(selectedFile.bytes);
|
||||
|
@ -988,7 +1035,7 @@ class ChartEditorDialogHandler
|
|||
* @param state The current chart editor state.
|
||||
* @return The dialog that was opened.
|
||||
*/
|
||||
public static inline function openUserGuideDialog(state:ChartEditorState):Dialog
|
||||
public static inline function openUserGuideDialog(state:ChartEditorState):Null<Dialog>
|
||||
{
|
||||
return openDialog(state, CHART_EDITOR_DIALOG_USER_GUIDE_LAYOUT, true, true);
|
||||
}
|
||||
|
@ -998,9 +1045,9 @@ class ChartEditorDialogHandler
|
|||
* @param modal Makes the background uninteractable while the dialog is open.
|
||||
* @param closable Hides the close button on the dialog, preventing it from being closed unless the user interacts with the dialog.
|
||||
*/
|
||||
static function openDialog(state:ChartEditorState, key:String, modal:Bool = true, closable:Bool = true):Dialog
|
||||
static function openDialog(state:ChartEditorState, key:String, modal:Bool = true, closable:Bool = true):Null<Dialog>
|
||||
{
|
||||
var dialog:Dialog = cast state.buildComponent(key);
|
||||
var dialog:Null<Dialog> = cast state.buildComponent(key);
|
||||
if (dialog == null) return null;
|
||||
|
||||
dialog.destroyOnClose = true;
|
||||
|
|
|
@ -16,6 +16,7 @@ import funkin.play.song.SongData.SongEventData;
|
|||
* A event sprite that can be used to display a song event in a chart.
|
||||
* Designed to be used and reused efficiently. Has no gameplay functionality.
|
||||
*/
|
||||
@:nullSafety
|
||||
class ChartEditorEventSprite extends FlxSprite
|
||||
{
|
||||
public static final DEFAULT_EVENT = 'Default';
|
||||
|
@ -45,16 +46,18 @@ class ChartEditorEventSprite extends FlxSprite
|
|||
refresh();
|
||||
}
|
||||
|
||||
static var eventFrames:Null<FlxFramesCollection> = null;
|
||||
|
||||
/**
|
||||
* Build a set of animations to allow displaying different types of chart events.
|
||||
* @param force `true` to force rebuilding the frames.
|
||||
*/
|
||||
static function buildFrames(force:Bool = false):FlxFramesCollection
|
||||
{
|
||||
static var eventFrames:FlxFramesCollection = null;
|
||||
|
||||
if (eventFrames != null && !force) return eventFrames;
|
||||
eventFrames = new FlxAtlasFrames(null);
|
||||
|
||||
initEmptyEventFrames();
|
||||
if (eventFrames == null) throw 'Failed to initialize empty event frames.';
|
||||
|
||||
// Push the default event as a frame.
|
||||
var defaultFrames:FlxAtlasFrames = Paths.getSparrowAtlas('ui/chart-editor/events/$DEFAULT_EVENT');
|
||||
|
@ -83,6 +86,12 @@ class ChartEditorEventSprite extends FlxSprite
|
|||
return eventFrames;
|
||||
}
|
||||
|
||||
@:nullSafety(Off)
|
||||
static function initEmptyEventFrames():Void
|
||||
{
|
||||
eventFrames = new FlxAtlasFrames(null);
|
||||
}
|
||||
|
||||
function buildAnimations():Void
|
||||
{
|
||||
var eventNames:Array<String> = [DEFAULT_EVENT].concat(SongEventParser.listEventIds());
|
||||
|
@ -133,6 +142,8 @@ class ChartEditorEventSprite extends FlxSprite
|
|||
|
||||
public function updateEventPosition(?origin:FlxObject)
|
||||
{
|
||||
if (this.eventData == null) return;
|
||||
|
||||
this.x = (ChartEditorState.STRUMLINE_SIZE * 2 + 1 - 1) * ChartEditorState.GRID_SIZE;
|
||||
if (this.eventData.stepTime >= 0) this.y = this.eventData.stepTime * ChartEditorState.GRID_SIZE;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import funkin.play.song.SongData.SongNoteData;
|
|||
* A hold note sprite that can be used to display a note in a chart.
|
||||
* Designed to be used and reused efficiently. Has no gameplay functionality.
|
||||
*/
|
||||
@:nullSafety
|
||||
class ChartEditorHoldNoteSprite extends SustainTrail
|
||||
{
|
||||
/**
|
||||
|
@ -110,8 +111,10 @@ class ChartEditorHoldNoteSprite extends SustainTrail
|
|||
return !aboveViewArea && !belowViewArea;
|
||||
}
|
||||
|
||||
public function updateHoldNotePosition(?origin:FlxObject)
|
||||
public function updateHoldNotePosition(?origin:FlxObject):Void
|
||||
{
|
||||
if (this.noteData == null) return;
|
||||
|
||||
var cursorColumn:Int = this.noteData.data;
|
||||
|
||||
if (cursorColumn < 0) cursorColumn = 0;
|
||||
|
|
|
@ -10,6 +10,7 @@ import flixel.util.FlxSpriteUtil;
|
|||
/**
|
||||
* Handles the note scrollbar preview in the chart editor.
|
||||
*/
|
||||
@:nullSafety
|
||||
class ChartEditorNotePreview extends FlxSprite
|
||||
{
|
||||
//
|
||||
|
|
|
@ -3,6 +3,8 @@ package funkin.ui.debug.charting;
|
|||
import flixel.FlxObject;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxFramesCollection;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.graphics.frames.FlxFrame;
|
||||
import flixel.graphics.frames.FlxTileFrames;
|
||||
import flixel.math.FlxPoint;
|
||||
import funkin.play.song.SongData.SongNoteData;
|
||||
|
@ -11,6 +13,7 @@ import funkin.play.song.SongData.SongNoteData;
|
|||
* A note sprite that can be used to display a note in a chart.
|
||||
* Designed to be used and reused efficiently. Has no gameplay functionality.
|
||||
*/
|
||||
@:nullSafety
|
||||
class ChartEditorNoteSprite extends FlxSprite
|
||||
{
|
||||
/**
|
||||
|
@ -32,7 +35,7 @@ class ChartEditorNoteSprite extends FlxSprite
|
|||
/**
|
||||
* The name of the note style currently in use.
|
||||
*/
|
||||
public var noteStyle(get, null):String;
|
||||
public var noteStyle(get, never):String;
|
||||
|
||||
public function new(parent:ChartEditorState)
|
||||
{
|
||||
|
@ -45,6 +48,8 @@ class ChartEditorNoteSprite extends FlxSprite
|
|||
initFrameCollection();
|
||||
}
|
||||
|
||||
if (noteFrameCollection == null) throw 'ERROR: Could not initialize note sprite animations.';
|
||||
|
||||
this.frames = noteFrameCollection;
|
||||
|
||||
// Initialize all the animations, not just the one we're going to use immediately,
|
||||
|
@ -77,18 +82,19 @@ class ChartEditorNoteSprite extends FlxSprite
|
|||
*/
|
||||
static function initFrameCollection():Void
|
||||
{
|
||||
noteFrameCollection = new FlxFramesCollection(null, ATLAS, null);
|
||||
buildEmptyFrameCollection();
|
||||
if (noteFrameCollection == null) return;
|
||||
|
||||
// TODO: Automatically iterate over the list of note skins.
|
||||
|
||||
// Normal notes
|
||||
var frameCollectionNormal = Paths.getSparrowAtlas('NOTE_assets');
|
||||
var frameCollectionNormal:FlxAtlasFrames = Paths.getSparrowAtlas('NOTE_assets');
|
||||
|
||||
for (frame in frameCollectionNormal.frames)
|
||||
{
|
||||
noteFrameCollection.pushFrame(frame);
|
||||
}
|
||||
var frameCollectionNormal2 = Paths.getSparrowAtlas('NoteHoldNormal');
|
||||
var frameCollectionNormal2:FlxAtlasFrames = Paths.getSparrowAtlas('NoteHoldNormal');
|
||||
|
||||
for (frame in frameCollectionNormal2.frames)
|
||||
{
|
||||
|
@ -101,13 +107,20 @@ class ChartEditorNoteSprite extends FlxSprite
|
|||
var frameCollectionPixel = FlxTileFrames.fromGraphic(graphicPixel, new FlxPoint(17, 17));
|
||||
for (i in 0...frameCollectionPixel.frames.length)
|
||||
{
|
||||
var frame = frameCollectionPixel.frames[i];
|
||||
var frame:Null<FlxFrame> = frameCollectionPixel.frames[i];
|
||||
if (frame == null) continue;
|
||||
|
||||
frame.name = 'pixel' + i;
|
||||
noteFrameCollection.pushFrame(frame);
|
||||
}
|
||||
}
|
||||
|
||||
@:nullSafety(Off)
|
||||
static function buildEmptyFrameCollection():Void
|
||||
{
|
||||
noteFrameCollection = new FlxFramesCollection(null, ATLAS, null);
|
||||
}
|
||||
|
||||
function set_noteData(value:Null<SongNoteData>):Null<SongNoteData>
|
||||
{
|
||||
this.noteData = value;
|
||||
|
@ -180,6 +193,8 @@ class ChartEditorNoteSprite extends FlxSprite
|
|||
|
||||
public function playNoteAnimation():Void
|
||||
{
|
||||
if (this.noteData == null) return;
|
||||
|
||||
// Decide whether to display a note or a sustain.
|
||||
var baseAnimationName:String = 'tap';
|
||||
|
||||
|
|
|
@ -2644,7 +2644,7 @@ class ChartEditorState extends HaxeUIState
|
|||
var displayedHoldNoteData:Array<SongNoteData> = [];
|
||||
for (holdNoteSprite in renderedHoldNotes.members)
|
||||
{
|
||||
if (holdNoteSprite == null || !holdNoteSprite.exists || !holdNoteSprite.visible) continue;
|
||||
if (holdNoteSprite == null || holdNoteSprite.noteData == null || !holdNoteSprite.exists || !holdNoteSprite.visible) continue;
|
||||
|
||||
if (!holdNoteSprite.isHoldNoteVisible(FlxG.height - MENU_BAR_HEIGHT, GRID_TOP_PAD))
|
||||
{
|
||||
|
@ -3127,7 +3127,8 @@ class ChartEditorState extends HaxeUIState
|
|||
difficultySelectDirty = false;
|
||||
|
||||
// Manage the Select Difficulty tree view.
|
||||
var difficultyToolbox:CollapsibleDialog = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
||||
var difficultyToolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
||||
if (difficultyToolbox == null) return;
|
||||
|
||||
var treeView:Null<TreeView> = difficultyToolbox.findComponent('difficultyToolboxTree');
|
||||
if (treeView == null) return;
|
||||
|
@ -3173,7 +3174,7 @@ class ChartEditorState extends HaxeUIState
|
|||
if (treeView == null)
|
||||
{
|
||||
// Manage the Select Difficulty tree view.
|
||||
var difficultyToolbox:CollapsibleDialog = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
||||
var difficultyToolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
||||
if (difficultyToolbox == null) return;
|
||||
|
||||
treeView = difficultyToolbox.findComponent('difficultyToolboxTree');
|
||||
|
@ -3187,7 +3188,7 @@ class ChartEditorState extends HaxeUIState
|
|||
function handlePlayerPreviewToolbox():Void
|
||||
{
|
||||
// Manage the Select Difficulty tree view.
|
||||
var charPreviewToolbox:CollapsibleDialog = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT);
|
||||
var charPreviewToolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT);
|
||||
if (charPreviewToolbox == null) return;
|
||||
|
||||
var charPlayer:Null<CharacterPlayer> = charPreviewToolbox.findComponent('charPlayer');
|
||||
|
@ -3222,7 +3223,7 @@ class ChartEditorState extends HaxeUIState
|
|||
function handleOpponentPreviewToolbox():Void
|
||||
{
|
||||
// Manage the Select Difficulty tree view.
|
||||
var charPreviewToolbox:CollapsibleDialog = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT);
|
||||
var charPreviewToolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT);
|
||||
if (charPreviewToolbox == null) return;
|
||||
|
||||
var charPlayer:Null<CharacterPlayer> = charPreviewToolbox.findComponent('charPlayer');
|
||||
|
@ -3294,7 +3295,7 @@ class ChartEditorState extends HaxeUIState
|
|||
{
|
||||
if (treeView == null)
|
||||
{
|
||||
var difficultyToolbox:CollapsibleDialog = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
||||
var difficultyToolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
||||
if (difficultyToolbox == null) return null;
|
||||
|
||||
treeView = difficultyToolbox.findComponent('difficultyToolboxTree');
|
||||
|
@ -3357,7 +3358,8 @@ class ChartEditorState extends HaxeUIState
|
|||
*/
|
||||
function refreshSongMetadataToolbox():Void
|
||||
{
|
||||
var toolbox:CollapsibleDialog = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
|
||||
var toolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
|
||||
if (toolbox == null) return;
|
||||
|
||||
var inputSongName:Null<TextField> = toolbox.findComponent('inputSongName', TextField);
|
||||
if (inputSongName != null) inputSongName.value = currentSongMetadata.songName;
|
||||
|
|
|
@ -20,6 +20,7 @@ enum ChartEditorTheme
|
|||
/**
|
||||
* Static functions which handle building themed UI elements for a provided ChartEditorState.
|
||||
*/
|
||||
@:nullSafety
|
||||
class ChartEditorThemeHandler
|
||||
{
|
||||
// TODO: There's probably a better system of organization for these colors.
|
||||
|
@ -92,6 +93,7 @@ class ChartEditorThemeHandler
|
|||
*/
|
||||
static function updateBackground(state:ChartEditorState):Void
|
||||
{
|
||||
if (state.menuBG == null) return;
|
||||
state.menuBG.color = switch (state.currentTheme)
|
||||
{
|
||||
case ChartEditorTheme.Light: BACKGROUND_COLOR_LIGHT;
|
||||
|
|
|
@ -39,6 +39,7 @@ enum ChartEditorToolMode
|
|||
/**
|
||||
* Static functions which handle building themed UI elements for a provided ChartEditorState.
|
||||
*/
|
||||
@:nullSafety
|
||||
@:allow(funkin.ui.debug.charting.ChartEditorState)
|
||||
class ChartEditorToolboxHandler
|
||||
{
|
||||
|
@ -56,7 +57,7 @@ class ChartEditorToolboxHandler
|
|||
|
||||
public static function showToolbox(state:ChartEditorState, id:String):Void
|
||||
{
|
||||
var toolbox:CollapsibleDialog = state.activeToolboxes.get(id);
|
||||
var toolbox:Null<CollapsibleDialog> = state.activeToolboxes.get(id);
|
||||
|
||||
if (toolbox == null) toolbox = initToolbox(state, id);
|
||||
|
||||
|
@ -95,7 +96,7 @@ class ChartEditorToolboxHandler
|
|||
|
||||
public static function hideToolbox(state:ChartEditorState, id:String):Void
|
||||
{
|
||||
var toolbox:CollapsibleDialog = state.activeToolboxes.get(id);
|
||||
var toolbox:Null<CollapsibleDialog> = state.activeToolboxes.get(id);
|
||||
|
||||
if (toolbox == null) toolbox = initToolbox(state, id);
|
||||
|
||||
|
@ -134,7 +135,7 @@ class ChartEditorToolboxHandler
|
|||
|
||||
public static function minimizeToolbox(state:ChartEditorState, id:String):Void
|
||||
{
|
||||
var toolbox:CollapsibleDialog = state.activeToolboxes.get(id);
|
||||
var toolbox:Null<CollapsibleDialog> = state.activeToolboxes.get(id);
|
||||
|
||||
if (toolbox == null) return;
|
||||
|
||||
|
@ -143,16 +144,16 @@ class ChartEditorToolboxHandler
|
|||
|
||||
public static function maximizeToolbox(state:ChartEditorState, id:String):Void
|
||||
{
|
||||
var toolbox:CollapsibleDialog = state.activeToolboxes.get(id);
|
||||
var toolbox:Null<CollapsibleDialog> = state.activeToolboxes.get(id);
|
||||
|
||||
if (toolbox == null) return;
|
||||
|
||||
toolbox.minimized = false;
|
||||
}
|
||||
|
||||
public static function initToolbox(state:ChartEditorState, id:String):CollapsibleDialog
|
||||
public static function initToolbox(state:ChartEditorState, id:String):Null<CollapsibleDialog>
|
||||
{
|
||||
var toolbox:CollapsibleDialog = null;
|
||||
var toolbox:Null<CollapsibleDialog> = null;
|
||||
switch (id)
|
||||
{
|
||||
case ChartEditorState.CHART_EDITOR_TOOLBOX_TOOLS_LAYOUT:
|
||||
|
@ -193,9 +194,9 @@ class ChartEditorToolboxHandler
|
|||
* @param id The asset ID of the toolbox layout.
|
||||
* @return The toolbox.
|
||||
*/
|
||||
public static function getToolbox(state:ChartEditorState, id:String):CollapsibleDialog
|
||||
public static function getToolbox(state:ChartEditorState, id:String):Null<CollapsibleDialog>
|
||||
{
|
||||
var toolbox:CollapsibleDialog = state.activeToolboxes.get(id);
|
||||
var toolbox:Null<CollapsibleDialog> = state.activeToolboxes.get(id);
|
||||
|
||||
// Initialize the toolbox without showing it.
|
||||
if (toolbox == null) toolbox = initToolbox(state, id);
|
||||
|
@ -205,7 +206,7 @@ class ChartEditorToolboxHandler
|
|||
return toolbox;
|
||||
}
|
||||
|
||||
static function buildToolboxToolsLayout(state:ChartEditorState):CollapsibleDialog
|
||||
static function buildToolboxToolsLayout(state:ChartEditorState):Null<CollapsibleDialog>
|
||||
{
|
||||
var toolbox:CollapsibleDialog = cast state.buildComponent(ChartEditorState.CHART_EDITOR_TOOLBOX_TOOLS_LAYOUT);
|
||||
|
||||
|
@ -219,7 +220,8 @@ class ChartEditorToolboxHandler
|
|||
state.setUICheckboxSelected('menubarItemToggleToolboxTools', false);
|
||||
}
|
||||
|
||||
var toolsGroup:Group = toolbox.findComponent('toolboxToolsGroup', Group);
|
||||
var toolsGroup:Null<Group> = toolbox.findComponent('toolboxToolsGroup', Group);
|
||||
if (toolsGroup == null) throw 'ChartEditorToolboxHandler.buildToolboxToolsLayout() - Could not find toolboxToolsGroup component.';
|
||||
|
||||
if (toolsGroup == null) return null;
|
||||
|
||||
|
@ -242,7 +244,7 @@ class ChartEditorToolboxHandler
|
|||
|
||||
static function onHideToolboxTools(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
|
||||
|
||||
static function buildToolboxNoteDataLayout(state:ChartEditorState):CollapsibleDialog
|
||||
static function buildToolboxNoteDataLayout(state:ChartEditorState):Null<CollapsibleDialog>
|
||||
{
|
||||
var toolbox:CollapsibleDialog = cast state.buildComponent(ChartEditorState.CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT);
|
||||
|
||||
|
@ -256,9 +258,13 @@ class ChartEditorToolboxHandler
|
|||
state.setUICheckboxSelected('menubarItemToggleToolboxNotes', false);
|
||||
}
|
||||
|
||||
var toolboxNotesNoteKind:DropDown = toolbox.findComponent('toolboxNotesNoteKind', DropDown);
|
||||
var toolboxNotesCustomKindLabel:Label = toolbox.findComponent('toolboxNotesCustomKindLabel', Label);
|
||||
var toolboxNotesCustomKind:TextField = toolbox.findComponent('toolboxNotesCustomKind', TextField);
|
||||
var toolboxNotesNoteKind:Null<DropDown> = toolbox.findComponent('toolboxNotesNoteKind', DropDown);
|
||||
if (toolboxNotesNoteKind == null) throw 'ChartEditorToolboxHandler.buildToolboxNoteDataLayout() - Could not find toolboxNotesNoteKind component.';
|
||||
var toolboxNotesCustomKindLabel:Null<Label> = toolbox.findComponent('toolboxNotesCustomKindLabel', Label);
|
||||
if (toolboxNotesCustomKindLabel == null)
|
||||
throw 'ChartEditorToolboxHandler.buildToolboxNoteDataLayout() - Could not find toolboxNotesCustomKindLabel component.';
|
||||
var toolboxNotesCustomKind:Null<TextField> = toolbox.findComponent('toolboxNotesCustomKind', TextField);
|
||||
if (toolboxNotesCustomKind == null) throw 'ChartEditorToolboxHandler.buildToolboxNoteDataLayout() - Could not find toolboxNotesCustomKind component.';
|
||||
|
||||
toolboxNotesNoteKind.onChange = function(event:UIEvent) {
|
||||
var isCustom:Bool = (event.data.id == '~CUSTOM~');
|
||||
|
@ -290,7 +296,7 @@ class ChartEditorToolboxHandler
|
|||
|
||||
static function onHideToolboxNoteData(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
|
||||
|
||||
static function buildToolboxEventDataLayout(state:ChartEditorState):CollapsibleDialog
|
||||
static function buildToolboxEventDataLayout(state:ChartEditorState):Null<CollapsibleDialog>
|
||||
{
|
||||
var toolbox:CollapsibleDialog = cast state.buildComponent(ChartEditorState.CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT);
|
||||
|
||||
|
@ -304,8 +310,10 @@ class ChartEditorToolboxHandler
|
|||
state.setUICheckboxSelected('menubarItemToggleToolboxEvents', false);
|
||||
}
|
||||
|
||||
var toolboxEventsEventKind:DropDown = toolbox.findComponent('toolboxEventsEventKind', DropDown);
|
||||
var toolboxEventsDataGrid:Grid = toolbox.findComponent('toolboxEventsDataGrid', Grid);
|
||||
var toolboxEventsEventKind:Null<DropDown> = toolbox.findComponent('toolboxEventsEventKind', DropDown);
|
||||
if (toolboxEventsEventKind == null) throw 'ChartEditorToolboxHandler.buildToolboxEventDataLayout() - Could not find toolboxEventsEventKind component.';
|
||||
var toolboxEventsDataGrid:Null<Grid> = toolbox.findComponent('toolboxEventsDataGrid', Grid);
|
||||
if (toolboxEventsDataGrid == null) throw 'ChartEditorToolboxHandler.buildToolboxEventDataLayout() - Could not find toolboxEventsDataGrid component.';
|
||||
|
||||
toolboxEventsEventKind.dataSource = new ArrayDataSource();
|
||||
|
||||
|
@ -349,6 +357,8 @@ class ChartEditorToolboxHandler
|
|||
|
||||
for (field in schema)
|
||||
{
|
||||
if (field == null) continue;
|
||||
|
||||
// Add a label.
|
||||
var label:Label = new Label();
|
||||
label.text = field.title;
|
||||
|
@ -360,33 +370,36 @@ class ChartEditorToolboxHandler
|
|||
case INTEGER:
|
||||
var numberStepper:NumberStepper = new NumberStepper();
|
||||
numberStepper.id = field.name;
|
||||
numberStepper.step = field.step == null ? 1.0 : field.step;
|
||||
numberStepper.min = field.min;
|
||||
numberStepper.max = field.max;
|
||||
numberStepper.value = field.defaultValue;
|
||||
numberStepper.step = field.step ?? 1.0;
|
||||
numberStepper.min = field.min ?? 0.0;
|
||||
numberStepper.max = field.max ?? 10.0;
|
||||
if (field.defaultValue != null) numberStepper.value = field.defaultValue;
|
||||
input = numberStepper;
|
||||
case FLOAT:
|
||||
var numberStepper:NumberStepper = new NumberStepper();
|
||||
numberStepper.id = field.name;
|
||||
numberStepper.step = field.step == null ? 0.1 : field.step;
|
||||
numberStepper.min = field.min;
|
||||
numberStepper.max = field.max;
|
||||
numberStepper.value = field.defaultValue;
|
||||
numberStepper.step = field.step ?? 0.1;
|
||||
numberStepper.min = field.min ?? 0.0;
|
||||
numberStepper.max = field.max ?? 1.0;
|
||||
if (field.defaultValue != null) numberStepper.value = field.defaultValue;
|
||||
input = numberStepper;
|
||||
case BOOL:
|
||||
var checkBox:CheckBox = new CheckBox();
|
||||
checkBox.id = field.name;
|
||||
checkBox.selected = field.defaultValue;
|
||||
if (field.defaultValue != null) checkBox.selected = field.defaultValue;
|
||||
input = checkBox;
|
||||
case ENUM:
|
||||
var dropDown:DropDown = new DropDown();
|
||||
dropDown.id = field.name;
|
||||
dropDown.dataSource = new ArrayDataSource();
|
||||
|
||||
if (field.keys == null) throw 'Field "${field.name}" is of Enum type but has no keys.';
|
||||
|
||||
// Add entries to the dropdown.
|
||||
|
||||
for (optionName in field.keys.keys())
|
||||
{
|
||||
var optionValue:String = field.keys.get(optionName);
|
||||
var optionValue:Null<String> = field.keys.get(optionName);
|
||||
trace('$optionName : $optionValue');
|
||||
dropDown.dataSource.add({value: optionValue, text: optionName});
|
||||
}
|
||||
|
@ -397,7 +410,7 @@ class ChartEditorToolboxHandler
|
|||
case STRING:
|
||||
input = new TextField();
|
||||
input.id = field.name;
|
||||
input.text = field.defaultValue;
|
||||
if (field.defaultValue != null) input.text = field.defaultValue;
|
||||
default:
|
||||
// Unknown type. Display a label so we know what it is.
|
||||
input = new Label();
|
||||
|
@ -417,7 +430,7 @@ class ChartEditorToolboxHandler
|
|||
}
|
||||
}
|
||||
|
||||
static function buildToolboxDifficultyLayout(state:ChartEditorState):CollapsibleDialog
|
||||
static function buildToolboxDifficultyLayout(state:ChartEditorState):Null<CollapsibleDialog>
|
||||
{
|
||||
var toolbox:CollapsibleDialog = cast state.buildComponent(ChartEditorState.CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
||||
|
||||
|
@ -431,11 +444,20 @@ class ChartEditorToolboxHandler
|
|||
state.setUICheckboxSelected('menubarItemToggleToolboxDifficulty', false);
|
||||
}
|
||||
|
||||
var difficultyToolboxSaveMetadata:Button = toolbox.findComponent('difficultyToolboxSaveMetadata', Button);
|
||||
var difficultyToolboxSaveChart:Button = toolbox.findComponent('difficultyToolboxSaveChart', Button);
|
||||
var difficultyToolboxSaveAll:Button = toolbox.findComponent('difficultyToolboxSaveAll', Button);
|
||||
var difficultyToolboxLoadMetadata:Button = toolbox.findComponent('difficultyToolboxLoadMetadata', Button);
|
||||
var difficultyToolboxLoadChart:Button = toolbox.findComponent('difficultyToolboxLoadChart', Button);
|
||||
var difficultyToolboxSaveMetadata:Null<Button> = toolbox.findComponent('difficultyToolboxSaveMetadata', Button);
|
||||
if (difficultyToolboxSaveMetadata == null)
|
||||
throw 'ChartEditorToolboxHandler.buildToolboxDifficultyLayout() - Could not find difficultyToolboxSaveMetadata component.';
|
||||
var difficultyToolboxSaveChart:Null<Button> = toolbox.findComponent('difficultyToolboxSaveChart', Button);
|
||||
if (difficultyToolboxSaveChart == null)
|
||||
throw 'ChartEditorToolboxHandler.buildToolboxDifficultyLayout() - Could not find difficultyToolboxSaveChart component.';
|
||||
var difficultyToolboxSaveAll:Null<Button> = toolbox.findComponent('difficultyToolboxSaveAll', Button);
|
||||
if (difficultyToolboxSaveAll == null) throw 'ChartEditorToolboxHandler.buildToolboxDifficultyLayout() - Could not find difficultyToolboxSaveAll component.';
|
||||
var difficultyToolboxLoadMetadata:Null<Button> = toolbox.findComponent('difficultyToolboxLoadMetadata', Button);
|
||||
if (difficultyToolboxLoadMetadata == null)
|
||||
throw 'ChartEditorToolboxHandler.buildToolboxDifficultyLayout() - Could not find difficultyToolboxLoadMetadata component.';
|
||||
var difficultyToolboxLoadChart:Null<Button> = toolbox.findComponent('difficultyToolboxLoadChart', Button);
|
||||
if (difficultyToolboxLoadChart == null)
|
||||
throw 'ChartEditorToolboxHandler.buildToolboxDifficultyLayout() - Could not find difficultyToolboxLoadChart component.';
|
||||
|
||||
difficultyToolboxSaveMetadata.onClick = function(event:UIEvent) {
|
||||
SongSerializer.exportSongMetadata(state.currentSongMetadata, state.currentSongId);
|
||||
|
@ -472,16 +494,18 @@ class ChartEditorToolboxHandler
|
|||
static function onShowToolboxDifficulty(state:ChartEditorState, toolbox:CollapsibleDialog):Void
|
||||
{
|
||||
// Update the selected difficulty when reopening the toolbox.
|
||||
var treeView:TreeView = toolbox.findComponent('difficultyToolboxTree');
|
||||
var treeView:Null<TreeView> = toolbox.findComponent('difficultyToolboxTree');
|
||||
if (treeView == null) return;
|
||||
|
||||
treeView.selectedNode = state.getCurrentTreeDifficultyNode(treeView);
|
||||
var current = state.getCurrentTreeDifficultyNode(treeView);
|
||||
if (current == null) return;
|
||||
treeView.selectedNode = current;
|
||||
trace('selected node: ${treeView.selectedNode}');
|
||||
}
|
||||
|
||||
static function onHideToolboxDifficulty(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
|
||||
|
||||
static function buildToolboxMetadataLayout(state:ChartEditorState):CollapsibleDialog
|
||||
static function buildToolboxMetadataLayout(state:ChartEditorState):Null<CollapsibleDialog>
|
||||
{
|
||||
var toolbox:CollapsibleDialog = cast state.buildComponent(ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
|
||||
|
||||
|
@ -495,7 +519,8 @@ class ChartEditorToolboxHandler
|
|||
state.setUICheckboxSelected('menubarItemToggleToolboxMetadata', false);
|
||||
}
|
||||
|
||||
var inputSongName:TextField = toolbox.findComponent('inputSongName', TextField);
|
||||
var inputSongName:Null<TextField> = toolbox.findComponent('inputSongName', TextField);
|
||||
if (inputSongName == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputSongName component.';
|
||||
inputSongName.onChange = function(event:UIEvent) {
|
||||
var valid:Bool = event.target.text != null && event.target.text != '';
|
||||
|
||||
|
@ -506,12 +531,13 @@ class ChartEditorToolboxHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
state.currentSongMetadata.songName = null;
|
||||
state.currentSongMetadata.songName = '';
|
||||
}
|
||||
};
|
||||
inputSongName.value = state.currentSongMetadata.songName;
|
||||
|
||||
var inputSongArtist:TextField = toolbox.findComponent('inputSongArtist', TextField);
|
||||
var inputSongArtist:Null<TextField> = toolbox.findComponent('inputSongArtist', TextField);
|
||||
if (inputSongArtist == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputSongArtist component.';
|
||||
inputSongArtist.onChange = function(event:UIEvent) {
|
||||
var valid:Bool = event.target.text != null && event.target.text != '';
|
||||
|
||||
|
@ -522,12 +548,13 @@ class ChartEditorToolboxHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
state.currentSongMetadata.artist = null;
|
||||
state.currentSongMetadata.artist = '';
|
||||
}
|
||||
};
|
||||
inputSongArtist.value = state.currentSongMetadata.artist;
|
||||
|
||||
var inputStage:DropDown = toolbox.findComponent('inputStage', DropDown);
|
||||
var inputStage:Null<DropDown> = toolbox.findComponent('inputStage', DropDown);
|
||||
if (inputStage == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputStage component.';
|
||||
inputStage.onChange = function(event:UIEvent) {
|
||||
var valid:Bool = event.data != null && event.data.id != null;
|
||||
|
||||
|
@ -538,14 +565,16 @@ class ChartEditorToolboxHandler
|
|||
};
|
||||
inputStage.value = state.currentSongMetadata.playData.stage;
|
||||
|
||||
var inputNoteSkin:DropDown = toolbox.findComponent('inputNoteSkin', DropDown);
|
||||
var inputNoteSkin:Null<DropDown> = toolbox.findComponent('inputNoteSkin', DropDown);
|
||||
if (inputNoteSkin == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputNoteSkin component.';
|
||||
inputNoteSkin.onChange = function(event:UIEvent) {
|
||||
if ((event?.data?.id ?? null) == null) return;
|
||||
state.currentSongMetadata.playData.noteSkin = event.data.id;
|
||||
};
|
||||
inputNoteSkin.value = state.currentSongMetadata.playData.noteSkin;
|
||||
|
||||
var inputBPM:NumberStepper = toolbox.findComponent('inputBPM', NumberStepper);
|
||||
var inputBPM:Null<NumberStepper> = toolbox.findComponent('inputBPM', NumberStepper);
|
||||
if (inputBPM == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputBPM component.';
|
||||
inputBPM.onChange = function(event:UIEvent) {
|
||||
if (event.value == null || event.value <= 0) return;
|
||||
|
||||
|
@ -565,9 +594,11 @@ class ChartEditorToolboxHandler
|
|||
};
|
||||
inputBPM.value = state.currentSongMetadata.timeChanges[0].bpm;
|
||||
|
||||
var labelScrollSpeed:Label = toolbox.findComponent('labelScrollSpeed', Label);
|
||||
var labelScrollSpeed:Null<Label> = toolbox.findComponent('labelScrollSpeed', Label);
|
||||
if (labelScrollSpeed == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find labelScrollSpeed component.';
|
||||
|
||||
var inputScrollSpeed:Slider = toolbox.findComponent('inputScrollSpeed', Slider);
|
||||
var inputScrollSpeed:Null<Slider> = toolbox.findComponent('inputScrollSpeed', Slider);
|
||||
if (inputScrollSpeed == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputScrollSpeed component.';
|
||||
inputScrollSpeed.onChange = function(event:UIEvent) {
|
||||
var valid:Bool = event.target.value != null && event.target.value > 0;
|
||||
|
||||
|
@ -585,10 +616,12 @@ class ChartEditorToolboxHandler
|
|||
inputScrollSpeed.value = state.currentSongChartScrollSpeed;
|
||||
labelScrollSpeed.text = 'Scroll Speed: ${state.currentSongChartScrollSpeed}x';
|
||||
|
||||
var frameVariation:Frame = toolbox.findComponent('frameVariation', Frame);
|
||||
var frameVariation:Null<Frame> = toolbox.findComponent('frameVariation', Frame);
|
||||
if (frameVariation == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find frameVariation component.';
|
||||
frameVariation.text = 'Variation: ${state.selectedVariation.toTitleCase()}';
|
||||
|
||||
var frameDifficulty:Frame = toolbox.findComponent('frameDifficulty', Frame);
|
||||
var frameDifficulty:Null<Frame> = toolbox.findComponent('frameDifficulty', Frame);
|
||||
if (frameDifficulty == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find frameDifficulty component.';
|
||||
frameDifficulty.text = 'Difficulty: ${state.selectedDifficulty.toTitleCase()}';
|
||||
|
||||
return toolbox;
|
||||
|
@ -601,7 +634,7 @@ class ChartEditorToolboxHandler
|
|||
|
||||
static function onHideToolboxMetadata(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
|
||||
|
||||
static function buildToolboxCharactersLayout(state:ChartEditorState):CollapsibleDialog
|
||||
static function buildToolboxCharactersLayout(state:ChartEditorState):Null<CollapsibleDialog>
|
||||
{
|
||||
var toolbox:CollapsibleDialog = cast state.buildComponent(ChartEditorState.CHART_EDITOR_TOOLBOX_CHARACTERS_LAYOUT);
|
||||
|
||||
|
@ -622,7 +655,7 @@ class ChartEditorToolboxHandler
|
|||
|
||||
static function onHideToolboxCharacters(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
|
||||
|
||||
static function buildToolboxPlayerPreviewLayout(state:ChartEditorState):CollapsibleDialog
|
||||
static function buildToolboxPlayerPreviewLayout(state:ChartEditorState):Null<CollapsibleDialog>
|
||||
{
|
||||
var toolbox:CollapsibleDialog = cast state.buildComponent(ChartEditorState.CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT);
|
||||
|
||||
|
@ -636,7 +669,8 @@ class ChartEditorToolboxHandler
|
|||
state.setUICheckboxSelected('menubarItemToggleToolboxPlayerPreview', false);
|
||||
}
|
||||
|
||||
var charPlayer:CharacterPlayer = toolbox.findComponent('charPlayer');
|
||||
var charPlayer:Null<CharacterPlayer> = toolbox.findComponent('charPlayer');
|
||||
if (charPlayer == null) throw 'ChartEditorToolboxHandler.buildToolboxPlayerPreviewLayout() - Could not find charPlayer component.';
|
||||
// TODO: We need to implement character swapping in ChartEditorState.
|
||||
charPlayer.loadCharacter('bf');
|
||||
charPlayer.characterType = CharacterType.BF;
|
||||
|
@ -650,7 +684,7 @@ class ChartEditorToolboxHandler
|
|||
|
||||
static function onHideToolboxPlayerPreview(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
|
||||
|
||||
static function buildToolboxOpponentPreviewLayout(state:ChartEditorState):CollapsibleDialog
|
||||
static function buildToolboxOpponentPreviewLayout(state:ChartEditorState):Null<CollapsibleDialog>
|
||||
{
|
||||
var toolbox:CollapsibleDialog = cast state.buildComponent(ChartEditorState.CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT);
|
||||
|
||||
|
@ -664,7 +698,8 @@ class ChartEditorToolboxHandler
|
|||
state.setUICheckboxSelected('menubarItemToggleToolboxOpponentPreview', false);
|
||||
}
|
||||
|
||||
var charPlayer:CharacterPlayer = toolbox.findComponent('charPlayer');
|
||||
var charPlayer:Null<CharacterPlayer> = toolbox.findComponent('charPlayer');
|
||||
if (charPlayer == null) throw 'ChartEditorToolboxHandler.buildToolboxOpponentPreviewLayout() - Could not find charPlayer component.';
|
||||
// TODO: We need to implement character swapping in ChartEditorState.
|
||||
charPlayer.loadCharacter('dad');
|
||||
charPlayer.characterType = CharacterType.DAD;
|
||||
|
|
|
@ -56,7 +56,7 @@ class CharacterPlayer extends Box
|
|||
return value;
|
||||
}
|
||||
|
||||
public var charName(get, null):String;
|
||||
public var charName(get, never):String;
|
||||
|
||||
function get_charName():String
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ class Constants
|
|||
* The current version number of the game.
|
||||
* Modify this in the `project.xml` file.
|
||||
*/
|
||||
public static var VERSION(get, null):String;
|
||||
public static var VERSION(get, never):String;
|
||||
|
||||
/**
|
||||
* A suffix to add to the game version.
|
||||
|
|
Loading…
Reference in a new issue