2022-09-07 19:07:08 -04:00
|
|
|
package funkin.ui.debug.charting;
|
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
import funkin.play.stage.StageData;
|
|
|
|
import funkin.play.character.CharacterData.CharacterDataParser;
|
|
|
|
import funkin.play.character.CharacterData;
|
2023-08-28 15:03:29 -04:00
|
|
|
import flixel.system.FlxAssets.FlxSoundAsset;
|
2023-08-16 03:40:44 -04:00
|
|
|
import flixel.math.FlxMath;
|
2023-08-15 16:08:12 -04:00
|
|
|
import haxe.ui.components.TextField;
|
|
|
|
import haxe.ui.components.DropDown;
|
|
|
|
import haxe.ui.components.NumberStepper;
|
|
|
|
import haxe.ui.containers.Frame;
|
2022-10-26 01:14:29 -04:00
|
|
|
import flixel.addons.display.FlxSliceSprite;
|
2022-10-07 00:37:21 -04:00
|
|
|
import flixel.addons.display.FlxTiledSprite;
|
2023-07-26 16:52:58 -04:00
|
|
|
import flixel.FlxCamera;
|
2022-12-17 15:19:42 -05:00
|
|
|
import flixel.FlxSprite;
|
2023-07-26 16:52:58 -04:00
|
|
|
import flixel.FlxSubState;
|
2022-09-07 19:07:08 -04:00
|
|
|
import flixel.group.FlxSpriteGroup;
|
2023-08-02 18:08:49 -04:00
|
|
|
import flixel.addons.transition.FlxTransitionableState;
|
2023-07-22 20:16:43 -04:00
|
|
|
import flixel.input.keyboard.FlxKey;
|
2022-10-26 01:14:29 -04:00
|
|
|
import flixel.math.FlxPoint;
|
|
|
|
import flixel.math.FlxRect;
|
2023-08-22 04:27:30 -04:00
|
|
|
import flixel.sound.FlxSound;
|
2023-06-08 16:53:52 -04:00
|
|
|
import flixel.tweens.FlxEase;
|
|
|
|
import flixel.tweens.FlxTween;
|
|
|
|
import flixel.tweens.misc.VarTween;
|
2022-09-07 19:07:08 -04:00
|
|
|
import flixel.util.FlxColor;
|
2022-10-07 00:37:21 -04:00
|
|
|
import flixel.util.FlxSort;
|
2022-10-13 21:32:19 -04:00
|
|
|
import flixel.util.FlxTimer;
|
2022-10-07 00:37:21 -04:00
|
|
|
import funkin.audio.visualize.PolygonSpectogram;
|
2023-05-25 18:33:39 -04:00
|
|
|
import funkin.audio.VoicesGroup;
|
2023-07-22 20:16:43 -04:00
|
|
|
import funkin.data.notestyle.NoteStyleRegistry;
|
2023-08-01 14:08:41 -04:00
|
|
|
import funkin.data.notestyle.NoteStyleRegistry;
|
2022-12-17 15:19:42 -05:00
|
|
|
import funkin.input.Cursor;
|
2023-07-22 20:16:43 -04:00
|
|
|
import funkin.input.TurboKeyHandler;
|
2022-12-17 15:19:42 -05:00
|
|
|
import funkin.modding.events.ScriptEvent;
|
2023-08-01 14:08:41 -04:00
|
|
|
import funkin.play.character.BaseCharacter.CharacterType;
|
2022-10-07 00:37:21 -04:00
|
|
|
import funkin.play.HealthIcon;
|
2023-06-22 01:41:01 -04:00
|
|
|
import funkin.play.notes.NoteSprite;
|
2023-07-22 20:16:43 -04:00
|
|
|
import funkin.play.notes.Strumline;
|
2023-07-26 16:52:58 -04:00
|
|
|
import funkin.play.PlayState;
|
2022-12-17 15:19:42 -05:00
|
|
|
import funkin.play.song.Song;
|
2023-09-08 17:46:44 -04:00
|
|
|
import funkin.data.song.SongData.SongChartData;
|
|
|
|
import funkin.data.song.SongRegistry;
|
|
|
|
import funkin.data.song.SongData.SongEventData;
|
|
|
|
import funkin.data.song.SongData.SongMetadata;
|
|
|
|
import funkin.data.song.SongData.SongNoteData;
|
2023-09-25 23:24:07 -04:00
|
|
|
import funkin.data.song.SongData.SongCharacterData;
|
2023-09-08 17:46:44 -04:00
|
|
|
import funkin.data.song.SongDataUtils;
|
2023-07-22 20:16:43 -04:00
|
|
|
import funkin.ui.debug.charting.ChartEditorCommand;
|
2023-08-01 14:08:41 -04:00
|
|
|
import funkin.ui.debug.charting.ChartEditorCommand;
|
2022-10-26 01:14:29 -04:00
|
|
|
import funkin.ui.debug.charting.ChartEditorThemeHandler.ChartEditorTheme;
|
|
|
|
import funkin.ui.debug.charting.ChartEditorToolboxHandler.ChartEditorToolMode;
|
2022-12-17 15:19:42 -05:00
|
|
|
import funkin.ui.haxeui.components.CharacterPlayer;
|
2022-09-07 19:07:08 -04:00
|
|
|
import funkin.ui.haxeui.HaxeUIState;
|
2022-10-26 01:14:29 -04:00
|
|
|
import funkin.util.Constants;
|
2023-01-02 17:40:53 -05:00
|
|
|
import funkin.util.DateUtil;
|
2023-07-22 20:16:43 -04:00
|
|
|
import funkin.util.FileUtil;
|
2022-12-17 15:19:42 -05:00
|
|
|
import funkin.util.SerializerUtil;
|
2023-07-22 20:16:43 -04:00
|
|
|
import funkin.util.SortUtil;
|
|
|
|
import funkin.util.WindowUtil;
|
|
|
|
import haxe.DynamicAccess;
|
2023-06-08 16:53:52 -04:00
|
|
|
import haxe.io.Bytes;
|
2023-07-22 20:16:43 -04:00
|
|
|
import haxe.io.Path;
|
2022-10-26 01:14:29 -04:00
|
|
|
import haxe.ui.components.Label;
|
2022-10-13 21:32:19 -04:00
|
|
|
import haxe.ui.components.Slider;
|
2023-08-01 14:08:41 -04:00
|
|
|
import haxe.ui.containers.dialogs.CollapsibleDialog;
|
2022-09-07 19:07:08 -04:00
|
|
|
import haxe.ui.containers.menus.MenuItem;
|
2022-12-17 15:19:42 -05:00
|
|
|
import haxe.ui.containers.TreeView;
|
|
|
|
import haxe.ui.containers.TreeViewNode;
|
2022-09-07 19:07:08 -04:00
|
|
|
import haxe.ui.core.Component;
|
2022-10-14 23:01:41 -04:00
|
|
|
import haxe.ui.core.Screen;
|
2022-10-13 21:32:19 -04:00
|
|
|
import haxe.ui.events.DragEvent;
|
2022-10-07 00:37:21 -04:00
|
|
|
import haxe.ui.events.UIEvent;
|
2023-07-22 20:16:43 -04:00
|
|
|
import haxe.ui.notifications.NotificationManager;
|
|
|
|
import haxe.ui.notifications.NotificationType;
|
2023-08-01 14:08:41 -04:00
|
|
|
import openfl.Assets;
|
2022-09-07 19:07:08 -04:00
|
|
|
import openfl.display.BitmapData;
|
2022-10-07 00:37:21 -04:00
|
|
|
import openfl.geom.Rectangle;
|
2022-09-07 19:07:08 -04:00
|
|
|
|
2022-10-11 03:14:57 -04:00
|
|
|
using Lambda;
|
|
|
|
|
2022-10-26 01:14:29 -04:00
|
|
|
/**
|
|
|
|
* A state dedicated to allowing the user to create and edit song charts.
|
|
|
|
* Built with HaxeUI for use by both developers and modders.
|
|
|
|
*
|
|
|
|
* Some functionality is moved to other classes to help maintain my sanity.
|
2023-06-08 16:30:45 -04:00
|
|
|
*
|
2022-10-26 01:14:29 -04:00
|
|
|
* @author MasterEric
|
|
|
|
*/
|
|
|
|
// Give other classes access to private instance fields
|
2023-08-30 18:31:59 -04:00
|
|
|
// @:nullSafety(Loose) // Enable this while developing, then disable to keep unit tests functional!
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2022-10-07 00:37:21 -04:00
|
|
|
@:allow(funkin.ui.debug.charting.ChartEditorCommand)
|
2023-09-25 23:24:07 -04:00
|
|
|
@:allow(funkin.ui.debug.charting.ChartEditorDropdowns)
|
2022-10-26 01:14:29 -04:00
|
|
|
@:allow(funkin.ui.debug.charting.ChartEditorDialogHandler)
|
|
|
|
@:allow(funkin.ui.debug.charting.ChartEditorThemeHandler)
|
2023-09-25 23:24:07 -04:00
|
|
|
@:allow(funkin.ui.debug.charting.ChartEditorAudioHandler)
|
|
|
|
@:allow(funkin.ui.debug.charting.ChartEditorImportExportHandler)
|
2022-10-26 01:14:29 -04:00
|
|
|
@:allow(funkin.ui.debug.charting.ChartEditorToolboxHandler)
|
2022-09-07 19:07:08 -04:00
|
|
|
class ChartEditorState extends HaxeUIState
|
|
|
|
{
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* CONSTANTS
|
|
|
|
*/
|
|
|
|
// ==============================
|
|
|
|
// XML Layouts
|
2023-06-08 16:53:52 -04:00
|
|
|
static final CHART_EDITOR_LAYOUT:String = Paths.ui('chart-editor/main-view');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
static final CHART_EDITOR_NOTIFBAR_LAYOUT:String = Paths.ui('chart-editor/components/notifbar');
|
|
|
|
static final CHART_EDITOR_PLAYBARHEAD_LAYOUT:String = Paths.ui('chart-editor/components/playbar-head');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
static final CHART_EDITOR_TOOLBOX_TOOLS_LAYOUT:String = Paths.ui('chart-editor/toolbox/tools');
|
|
|
|
static final CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/notedata');
|
|
|
|
static final CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/eventdata');
|
|
|
|
static final CHART_EDITOR_TOOLBOX_METADATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/metadata');
|
|
|
|
static final CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT:String = Paths.ui('chart-editor/toolbox/difficulty');
|
|
|
|
static final CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT:String = Paths.ui('chart-editor/toolbox/player-preview');
|
|
|
|
static final CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT:String = Paths.ui('chart-editor/toolbox/opponent-preview');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 13:17:28 -05:00
|
|
|
// Validation
|
|
|
|
static final SUPPORTED_MUSIC_FORMATS:Array<String> = ['ogg'];
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* The base grid size for the chart editor.
|
|
|
|
*/
|
|
|
|
public static final GRID_SIZE:Int = 40;
|
|
|
|
|
|
|
|
public static final PLAYHEAD_SCROLL_AREA_WIDTH:Int = 12;
|
|
|
|
|
|
|
|
public static final PLAYHEAD_HEIGHT:Int = Std.int(GRID_SIZE / 8);
|
|
|
|
|
|
|
|
public static final GRID_SELECTION_BORDER_WIDTH:Int = 6;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of notes in each player's strumline.
|
|
|
|
*/
|
2023-06-08 16:53:52 -04:00
|
|
|
public static final STRUMLINE_SIZE:Int = 4;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The height of the menu bar in the layout.
|
|
|
|
*/
|
2023-07-22 20:16:43 -04:00
|
|
|
static final MENU_BAR_HEIGHT:Int = 32;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The height of the playbar in the layout.
|
|
|
|
*/
|
|
|
|
static final PLAYBAR_HEIGHT:Int = 48;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Duration to wait before autosaving the chart.
|
|
|
|
*/
|
|
|
|
static final AUTOSAVE_TIMER_DELAY:Float = 60.0 * 5.0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The amount of padding between the menu bar and the chart grid when fully scrolled up.
|
|
|
|
*/
|
|
|
|
static final GRID_TOP_PAD:Int = 8;
|
|
|
|
|
|
|
|
/**
|
2023-02-28 13:17:28 -05:00
|
|
|
* Duration, in milliseconds, until toast notifications are automatically hidden.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-02-28 13:17:28 -05:00
|
|
|
static final NOTIFICATION_DISMISS_TIME:Int = 5000;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
/**
|
|
|
|
* Duration, in seconds, for the scroll easing animation.
|
|
|
|
*/
|
|
|
|
static final SCROLL_EASE_DURATION:Float = 0.2;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// UI Element Colors
|
|
|
|
// Background color tint.
|
|
|
|
static final CURSOR_COLOR:FlxColor = 0xE0FFFFFF;
|
|
|
|
static final PREVIEW_BG_COLOR:FlxColor = 0xFF303030;
|
|
|
|
static final PLAYHEAD_SCROLL_AREA_COLOR:FlxColor = 0xFF682B2F;
|
|
|
|
static final SPECTROGRAM_COLOR:FlxColor = 0xFFFF0000;
|
|
|
|
static final PLAYHEAD_COLOR:FlxColor = 0xC0BD0231;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How many pixels far the user needs to move the mouse before the cursor is considered to be dragged rather than clicked.
|
|
|
|
*/
|
|
|
|
static final DRAG_THRESHOLD:Float = 16.0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Types of notes you can snap to.
|
|
|
|
*/
|
|
|
|
static final SNAP_QUANTS:Array<Int> = [4, 8, 12, 16, 20, 24, 32, 48, 64, 96, 192];
|
|
|
|
|
2023-08-31 21:56:49 -04:00
|
|
|
static final BASE_QUANT:Int = 16;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* INSTANCE DATA
|
|
|
|
*/
|
|
|
|
// ==============================
|
|
|
|
|
2023-08-31 23:48:15 -04:00
|
|
|
/**
|
|
|
|
* The internal index of what note snapping value is in use.
|
|
|
|
* Increment to make placement more preceise and decrement to make placement less precise.
|
|
|
|
*/
|
|
|
|
var noteSnapQuantIndex:Int = 3; // default is 16
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-31 23:48:15 -04:00
|
|
|
/**
|
|
|
|
* The current note snapping value.
|
|
|
|
* For example, `32` when snapping to 32nd notes.
|
|
|
|
*/
|
2023-01-22 19:55:30 -05:00
|
|
|
public var noteSnapQuant(get, never):Int;
|
|
|
|
|
|
|
|
function get_noteSnapQuant():Int
|
|
|
|
{
|
|
|
|
return SNAP_QUANTS[noteSnapQuantIndex];
|
|
|
|
}
|
|
|
|
|
2023-08-31 23:48:15 -04:00
|
|
|
/**
|
|
|
|
* The ratio of the current note snapping value to the default.
|
|
|
|
* For example, `32` becomes `0.5` when snapping to 16th notes.
|
|
|
|
*/
|
|
|
|
public var noteSnapRatio(get, never):Float;
|
|
|
|
|
|
|
|
function get_noteSnapRatio():Float
|
|
|
|
{
|
|
|
|
return BASE_QUANT / noteSnapQuant;
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* scrollPosition is the current position in the song, in pixels.
|
|
|
|
* One pixel is 1/40 of 1 step, and 1/160 of 1 beat.
|
|
|
|
*/
|
|
|
|
var scrollPositionInPixels(default, set):Float = -1.0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* scrollPosition, converted to steps.
|
2023-07-19 01:30:36 -04:00
|
|
|
* NOT dependant on BPM, because the size of a grid square does not change with BPM.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-07-19 01:30:36 -04:00
|
|
|
var scrollPositionInSteps(get, set):Float;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
function get_scrollPositionInSteps():Float
|
|
|
|
{
|
|
|
|
return scrollPositionInPixels / GRID_SIZE;
|
|
|
|
}
|
|
|
|
|
2023-07-19 01:30:36 -04:00
|
|
|
function set_scrollPositionInSteps(value:Float):Float
|
|
|
|
{
|
|
|
|
scrollPositionInPixels = value * GRID_SIZE;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* scrollPosition, converted to milliseconds.
|
2023-07-19 01:30:36 -04:00
|
|
|
* DEPENDANT on BPM, because the duration of a grid square changes with BPM.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
|
|
|
var scrollPositionInMs(get, set):Float;
|
|
|
|
|
|
|
|
function get_scrollPositionInMs():Float
|
|
|
|
{
|
2023-07-19 01:30:36 -04:00
|
|
|
return Conductor.getStepTimeInMs(scrollPositionInSteps);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_scrollPositionInMs(value:Float):Float
|
|
|
|
{
|
2023-07-19 01:30:36 -04:00
|
|
|
scrollPositionInSteps = Conductor.getTimeInSteps(value);
|
2023-01-22 19:55:30 -05:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The position of the playhead, in pixels, relative to the scrollPosition.
|
|
|
|
* 0 means playhead is at the top of the grid.
|
|
|
|
* 40 means the playhead is 1 grid length below the base position.
|
|
|
|
* -40 means the playhead is 1 grid length above the base position.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var playheadPositionInPixels(default, set):Float = 0.0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-07-19 01:30:36 -04:00
|
|
|
function set_playheadPositionInPixels(value:Float):Float
|
|
|
|
{
|
|
|
|
// Make sure playhead doesn't go outside the song.
|
|
|
|
if (value + scrollPositionInPixels < 0) value = -scrollPositionInPixels;
|
|
|
|
if (value + scrollPositionInPixels > songLengthInPixels) value = songLengthInPixels - scrollPositionInPixels;
|
|
|
|
|
|
|
|
this.playheadPositionInPixels = value;
|
|
|
|
|
|
|
|
// Move the playhead sprite to the correct position.
|
|
|
|
gridPlayhead.y = this.playheadPositionInPixels + (MENU_BAR_HEIGHT + GRID_TOP_PAD);
|
|
|
|
|
|
|
|
return this.playheadPositionInPixels;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* playheadPosition, converted to steps.
|
2023-07-19 01:30:36 -04:00
|
|
|
* NOT dependant on BPM, because the size of a grid square does not change with BPM.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var playheadPositionInSteps(get, set):Float;
|
2023-07-19 01:30:36 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
function get_playheadPositionInSteps():Float
|
|
|
|
{
|
|
|
|
return playheadPositionInPixels / GRID_SIZE;
|
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
function set_playheadPositionInSteps(value:Float):Float
|
|
|
|
{
|
|
|
|
playheadPositionInPixels = value * GRID_SIZE;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* playheadPosition, converted to milliseconds.
|
2023-07-19 01:30:36 -04:00
|
|
|
* DEPENDANT on BPM, because the duration of a grid square changes with BPM.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var playheadPositionInMs(get, set):Float;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
function get_playheadPositionInMs():Float
|
|
|
|
{
|
2023-07-19 01:30:36 -04:00
|
|
|
return Conductor.getStepTimeInMs(playheadPositionInSteps);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
function set_playheadPositionInMs(value:Float):Float
|
|
|
|
{
|
|
|
|
playheadPositionInSteps = Conductor.getTimeInSteps(value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2023-07-19 01:30:36 -04:00
|
|
|
* songLength, in milliseconds.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
@:isVar var songLengthInMs(get, set):Float = 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-07-19 01:30:36 -04:00
|
|
|
function get_songLengthInMs():Float
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-07-19 01:30:36 -04:00
|
|
|
if (songLengthInMs <= 0) return 1000;
|
|
|
|
return songLengthInMs;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_songLengthInMs(value:Float):Float
|
|
|
|
{
|
|
|
|
this.songLengthInMs = value;
|
|
|
|
|
|
|
|
// Make sure playhead doesn't go outside the song.
|
|
|
|
if (playheadPositionInMs > songLengthInMs) playheadPositionInMs = songLengthInMs;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-07-19 01:30:36 -04:00
|
|
|
return this.songLengthInMs;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* songLength, converted to steps.
|
2023-07-19 01:30:36 -04:00
|
|
|
* Dependant on BPM, because the size of a grid square does not change with BPM but the length of a beat does.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
|
|
|
var songLengthInSteps(get, set):Float;
|
|
|
|
|
|
|
|
function get_songLengthInSteps():Float
|
|
|
|
{
|
2023-07-19 01:30:36 -04:00
|
|
|
return Conductor.getTimeInSteps(songLengthInMs);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_songLengthInSteps(value:Float):Float
|
|
|
|
{
|
2023-07-19 01:30:36 -04:00
|
|
|
// Getting a reasonable result from setting songLengthInSteps requires that Conductor.mapBPMChanges be called first.
|
|
|
|
songLengthInMs = Conductor.getStepTimeInMs(value);
|
2023-01-22 19:55:30 -05:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-07-19 01:30:36 -04:00
|
|
|
* This is the song's length in PIXELS, same format as scrollPosition.
|
|
|
|
* Dependant on BPM, because the size of a grid square does not change with BPM but the length of a beat does.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-07-19 01:30:36 -04:00
|
|
|
var songLengthInPixels(get, set):Int;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-07-19 01:30:36 -04:00
|
|
|
function get_songLengthInPixels():Int
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-07-19 01:30:36 -04:00
|
|
|
return Std.int(songLengthInSteps * GRID_SIZE);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-07-19 01:30:36 -04:00
|
|
|
function set_songLengthInPixels(value:Int):Int
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-07-19 01:30:36 -04:00
|
|
|
songLengthInSteps = value / GRID_SIZE;
|
2023-01-22 19:55:30 -05:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2023-07-19 01:30:36 -04:00
|
|
|
/**
|
|
|
|
* The current theme used by the editor.
|
|
|
|
* Dictates the appearance of many UI elements.
|
|
|
|
* Currently hardcoded to just Light and Dark.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var currentTheme(default, set):ChartEditorTheme = ChartEditorTheme.Light;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
function set_currentTheme(value:ChartEditorTheme):ChartEditorTheme
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
if (value == null || value == currentTheme) return currentTheme;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
currentTheme = value;
|
|
|
|
ChartEditorThemeHandler.updateTheme(this);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether a skip button has been pressed on the playbar, and which one.
|
2023-08-28 15:03:29 -04:00
|
|
|
* `null` if no button has been pressed.
|
2023-01-22 19:55:30 -05:00
|
|
|
* This will be used to update the scrollPosition (in the same function that handles the scroll wheel), then cleared.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var playbarButtonPressed:Null<String> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the head of the playbar is currently being dragged with the mouse by the user.
|
|
|
|
*/
|
|
|
|
var playbarHeadDragging:Bool = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether music was playing before we started dragging the playbar head.
|
|
|
|
* If so, then when we stop dragging the playbar head, we should resume song playback.
|
|
|
|
*/
|
|
|
|
var playbarHeadDraggingWasPlaying:Bool = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The note kind to use for notes being placed in the chart. Defaults to `''`.
|
|
|
|
*/
|
|
|
|
var selectedNoteKind:String = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The note kind to use for notes being placed in the chart. Defaults to `''`.
|
|
|
|
*/
|
|
|
|
var selectedEventKind:String = 'FocusCamera';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The note data as a struct.
|
|
|
|
*/
|
|
|
|
var selectedEventData:DynamicAccess<Dynamic> = {};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to play a metronome sound while the playhead is moving.
|
|
|
|
*/
|
2023-08-09 18:11:50 -04:00
|
|
|
var isMetronomeEnabled:Bool = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Use the tool window to affect how the user interacts with the program.
|
|
|
|
*/
|
|
|
|
var currentToolMode:ChartEditorToolMode = ChartEditorToolMode.Select;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The character sprite in the Player Preview window.
|
2023-08-28 15:03:29 -04:00
|
|
|
* `null` until accessed.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var currentPlayerCharacterPlayer:Null<CharacterPlayer> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The character sprite in the Opponent Preview window.
|
2023-08-28 15:03:29 -04:00
|
|
|
* `null` until accessed.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var currentOpponentCharacterPlayer:Null<CharacterPlayer> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
/**
|
|
|
|
* The currently selected live input style.
|
|
|
|
*/
|
|
|
|
var currentLiveInputStyle:LiveInputStyle = LiveInputStyle.None;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Whether the current view is in downscroll mode.
|
|
|
|
*/
|
|
|
|
var isViewDownscroll(default, set):Bool = false;
|
|
|
|
|
|
|
|
function set_isViewDownscroll(value:Bool):Bool
|
|
|
|
{
|
|
|
|
isViewDownscroll = value;
|
|
|
|
|
|
|
|
// Make sure view is updated when we change view modes.
|
|
|
|
noteDisplayDirty = true;
|
|
|
|
notePreviewDirty = true;
|
2023-08-16 03:40:44 -04:00
|
|
|
notePreviewViewportBoundsDirty = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
this.scrollPositionInPixels = this.scrollPositionInPixels;
|
2023-09-26 17:46:07 -04:00
|
|
|
// Characters have probably changed too.
|
|
|
|
healthIconsDirty = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
return isViewDownscroll;
|
|
|
|
}
|
|
|
|
|
2023-07-26 20:03:31 -04:00
|
|
|
/**
|
|
|
|
* If true, playtesting a chart will skip to the current playhead position.
|
|
|
|
*/
|
|
|
|
var playtestStartTime:Bool = false;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Whether hitsounds are enabled for at least one character.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var hitsoundsEnabled(get, never):Bool;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
function get_hitsoundsEnabled():Bool
|
|
|
|
{
|
|
|
|
return hitsoundsEnabledPlayer || hitsoundsEnabledOpponent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether hitsounds are enabled for the player.
|
|
|
|
*/
|
|
|
|
var hitsoundsEnabledPlayer:Bool = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether hitsounds are enabled for the opponent.
|
|
|
|
*/
|
|
|
|
var hitsoundsEnabledOpponent:Bool = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the user's mouse cursor is hovering over a SOLID component of the HaxeUI.
|
|
|
|
* If so, ignore mouse events underneath.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var isCursorOverHaxeUI(get, never):Bool;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
function get_isCursorOverHaxeUI():Bool
|
|
|
|
{
|
|
|
|
return Screen.instance.hasSolidComponentUnderPoint(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var isCursorOverHaxeUIButton(get, never):Bool;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
function get_isCursorOverHaxeUIButton():Bool
|
|
|
|
{
|
|
|
|
return Screen.instance.hasSolidComponentUnderPoint(FlxG.mouse.screenX, FlxG.mouse.screenY, haxe.ui.components.Button)
|
|
|
|
|| Screen.instance.hasSolidComponentUnderPoint(FlxG.mouse.screenX, FlxG.mouse.screenY, haxe.ui.components.Link);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set by ChartEditorDialogHandler, used to prevent background interaction while the dialog is open.
|
|
|
|
*/
|
|
|
|
public var isHaxeUIDialogOpen:Bool = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The variation ID for the difficulty which is currently being edited.
|
|
|
|
*/
|
|
|
|
var selectedVariation(default, set):String = Constants.DEFAULT_VARIATION;
|
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
/**
|
|
|
|
* Setter called when we are switching variations.
|
|
|
|
* We will likely need to switch instrumentals as well.
|
|
|
|
*/
|
2023-01-22 19:55:30 -05:00
|
|
|
function set_selectedVariation(value:String):String
|
|
|
|
{
|
2023-09-26 17:46:07 -04:00
|
|
|
// Don't update if we're already on the variation.
|
|
|
|
if (selectedVariation == value) return selectedVariation;
|
2023-01-22 19:55:30 -05:00
|
|
|
selectedVariation = value;
|
|
|
|
|
|
|
|
// Make sure view is updated when the variation changes.
|
|
|
|
noteDisplayDirty = true;
|
|
|
|
notePreviewDirty = true;
|
2023-08-16 03:40:44 -04:00
|
|
|
notePreviewViewportBoundsDirty = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
switchToCurrentInstrumental();
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
return selectedVariation;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The difficulty ID for the difficulty which is currently being edited.
|
|
|
|
*/
|
|
|
|
var selectedDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY;
|
|
|
|
|
|
|
|
function set_selectedDifficulty(value:String):String
|
|
|
|
{
|
|
|
|
selectedDifficulty = value;
|
|
|
|
|
|
|
|
// Make sure view is updated when the difficulty changes.
|
|
|
|
noteDisplayDirty = true;
|
|
|
|
notePreviewDirty = true;
|
2023-08-16 03:40:44 -04:00
|
|
|
notePreviewViewportBoundsDirty = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
return selectedDifficulty;
|
|
|
|
}
|
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
/**
|
|
|
|
* The instrumental ID which is currently selected.
|
|
|
|
*/
|
|
|
|
var currentInstrumentalId(get, set):String;
|
|
|
|
|
|
|
|
function get_currentInstrumentalId():String
|
|
|
|
{
|
|
|
|
var instId:Null<String> = currentSongMetadata.playData.characters.instrumental;
|
|
|
|
if (instId == null || instId == '') instId = (selectedVariation == Constants.DEFAULT_VARIATION) ? '' : selectedVariation;
|
|
|
|
return instId;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentInstrumentalId(value:String):String
|
|
|
|
{
|
|
|
|
return currentSongMetadata.playData.characters.instrumental = value;
|
|
|
|
}
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
/**
|
|
|
|
* The character ID for the character which is currently selected.
|
|
|
|
*/
|
|
|
|
var selectedCharacter(default, set):String = Constants.DEFAULT_CHARACTER;
|
|
|
|
|
|
|
|
function set_selectedCharacter(value:String):String
|
|
|
|
{
|
|
|
|
selectedCharacter = value;
|
|
|
|
|
|
|
|
// Make sure view is updated when the character changes.
|
|
|
|
noteDisplayDirty = true;
|
|
|
|
notePreviewDirty = true;
|
2023-08-16 03:40:44 -04:00
|
|
|
notePreviewViewportBoundsDirty = true;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
|
|
|
return selectedCharacter;
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Whether the user is currently in Pattern Mode.
|
|
|
|
* This overrides the chart editor's normal behavior.
|
|
|
|
*/
|
|
|
|
var isInPatternMode(default, set):Bool = false;
|
|
|
|
|
|
|
|
function set_isInPatternMode(value:Bool):Bool
|
|
|
|
{
|
|
|
|
isInPatternMode = value;
|
|
|
|
|
|
|
|
// Make sure view is updated when we change modes.
|
|
|
|
noteDisplayDirty = true;
|
|
|
|
notePreviewDirty = true;
|
2023-08-16 03:40:44 -04:00
|
|
|
notePreviewViewportBoundsDirty = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
this.scrollPositionInPixels = 0;
|
|
|
|
|
|
|
|
return isInPatternMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
var currentPattern:String = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the note display render group has been modified and needs to be updated.
|
|
|
|
* This happens when we scroll or add/remove notes, and need to update what notes are displayed and where.
|
|
|
|
*/
|
|
|
|
var noteDisplayDirty:Bool = true;
|
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
/**
|
|
|
|
* Whether the selected charactesr have been modified and the health icons need to be updated.
|
|
|
|
*/
|
|
|
|
var healthIconsDirty:Bool = true;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Whether the note preview graphic needs to be FULLY rebuilt.
|
|
|
|
*/
|
2023-09-13 14:51:12 -04:00
|
|
|
var notePreviewDirty(default, set):Bool = true;
|
|
|
|
|
|
|
|
function set_notePreviewDirty(value:Bool):Bool
|
|
|
|
{
|
|
|
|
trace('Note preview dirtied!');
|
|
|
|
return notePreviewDirty = value;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
var notePreviewViewportBoundsDirty:Bool = true;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Whether the chart has been modified since it was last saved.
|
|
|
|
* Used to determine whether to auto-save, etc.
|
|
|
|
*/
|
|
|
|
var saveDataDirty(default, set):Bool = false;
|
|
|
|
|
|
|
|
function set_saveDataDirty(value:Bool):Bool
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
if (value == saveDataDirty) return value;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
// Start the auto-save timer.
|
|
|
|
autoSaveTimer = new FlxTimer().start(AUTOSAVE_TIMER_DELAY, (_) -> autoSave());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (autoSaveTimer != null)
|
|
|
|
{
|
|
|
|
// Stop the auto-save timer.
|
|
|
|
autoSaveTimer.cancel();
|
|
|
|
autoSaveTimer.destroy();
|
|
|
|
autoSaveTimer = null;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return saveDataDirty = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A timer used to auto-save the chart after a period of inactivity.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var autoSaveTimer:Null<FlxTimer> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the difficulty tree view in the toolbox has been modified and needs to be updated.
|
|
|
|
* This happens when we add/remove difficulties.
|
|
|
|
*/
|
|
|
|
var difficultySelectDirty:Bool = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the character select view in the toolbox has been modified and needs to be updated.
|
|
|
|
* This happens when we add/remove characters.
|
|
|
|
*/
|
|
|
|
var characterSelectDirty:Bool = true;
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
/**
|
|
|
|
* Whether the player preview toolbox have been modified and need to be updated.
|
|
|
|
* This happens when we switch characters.
|
|
|
|
*/
|
|
|
|
var playerPreviewDirty:Bool = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the opponent preview toolbox have been modified and need to be updated.
|
|
|
|
* This happens when we switch characters.
|
|
|
|
*/
|
|
|
|
var opponentPreviewDirty:Bool = true;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
var isInPlaytestMode:Bool = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The list of command previously performed. Used for undoing previous actions.
|
|
|
|
*/
|
|
|
|
var undoHistory:Array<ChartEditorCommand> = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The list of commands that have been undone. Used for redoing previous actions.
|
|
|
|
*/
|
|
|
|
var redoHistory:Array<ChartEditorCommand> = [];
|
|
|
|
|
|
|
|
/**
|
2023-02-28 21:06:09 -05:00
|
|
|
* Handler used to track how long the user has been holding the undo keybind.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
var undoKeyHandler:TurboKeyHandler = TurboKeyHandler.build([FlxKey.CONTROL, FlxKey.Z]);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding the redo keybind.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
var redoKeyHandler:TurboKeyHandler = TurboKeyHandler.build([FlxKey.CONTROL, FlxKey.Y]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding the up keybind.
|
|
|
|
*/
|
|
|
|
var upKeyHandler:TurboKeyHandler = TurboKeyHandler.build(FlxKey.UP);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding the down keybind.
|
|
|
|
*/
|
|
|
|
var downKeyHandler:TurboKeyHandler = TurboKeyHandler.build(FlxKey.DOWN);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding the page-up keybind.
|
|
|
|
*/
|
|
|
|
var pageUpKeyHandler:TurboKeyHandler = TurboKeyHandler.build(FlxKey.PAGEUP);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding the page-down keybind.
|
|
|
|
*/
|
|
|
|
var pageDownKeyHandler:TurboKeyHandler = TurboKeyHandler.build(FlxKey.PAGEDOWN);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the undo/redo histories have changed since the last time the UI was updated.
|
|
|
|
*/
|
|
|
|
var commandHistoryDirty:Bool = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The notes which are currently in the user's selection.
|
|
|
|
*/
|
|
|
|
var currentNoteSelection:Array<SongNoteData> = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The events which are currently in the user's selection.
|
|
|
|
*/
|
|
|
|
var currentEventSelection:Array<SongEventData> = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The position where the user clicked to start a selection.
|
2023-08-28 15:03:29 -04:00
|
|
|
* `null` if the user isn't currently selecting anything.
|
2023-01-22 19:55:30 -05:00
|
|
|
* The selection box extends from this point to the current mouse position.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var selectionBoxStartPos:Null<FlxPoint> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the user's last mouse click was on the playhead scroll area.
|
|
|
|
*/
|
|
|
|
var gridPlayheadScrollAreaPressed:Bool = false;
|
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
/**
|
|
|
|
* Where the user's last mouse click was on the note preview scroll area.
|
|
|
|
* `null` if the user isn't clicking on the note preview.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var notePreviewScrollAreaStartPos:Null<FlxPoint> = null;
|
2023-08-16 03:40:44 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* The SongNoteData which is currently being placed.
|
2023-08-28 15:03:29 -04:00
|
|
|
* `null` if the user isn't currently placing a note.
|
2023-01-22 19:55:30 -05:00
|
|
|
* As the user drags, we will update this note's sustain length.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var currentPlaceNoteData:Null<SongNoteData> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Dialog components representing the currently available tool windows.
|
|
|
|
* Dialogs are retained here even when collapsed or hidden.
|
|
|
|
*/
|
2023-06-08 16:53:52 -04:00
|
|
|
var activeToolboxes:Map<String, CollapsibleDialog> = new Map<String, CollapsibleDialog>();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* AUDIO AND SOUND DATA
|
|
|
|
*/
|
|
|
|
// ==============================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The audio track for the instrumental.
|
2023-09-26 17:46:07 -04:00
|
|
|
* Replaced when switching instrumentals.
|
2023-08-28 15:03:29 -04:00
|
|
|
* `null` until an instrumental track is loaded.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var audioInstTrack:Null<FlxSound> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
/**
|
2023-09-26 17:46:07 -04:00
|
|
|
* The raw byte data for the instrumental audio tracks.
|
|
|
|
* Key is the instrumental name.
|
2023-08-28 15:03:29 -04:00
|
|
|
* `null` until an instrumental track is loaded.
|
2023-06-08 16:53:52 -04:00
|
|
|
*/
|
2023-09-26 17:46:07 -04:00
|
|
|
var audioInstTrackData:Map<String, Bytes> = [];
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* The audio track for the vocals.
|
2023-08-28 15:03:29 -04:00
|
|
|
* `null` until vocal track(s) are loaded.
|
2023-09-26 17:46:07 -04:00
|
|
|
* When switching characters, the elements of the VoicesGroup will be swapped to match the new character.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var audioVocalTrackGroup:Null<VoicesGroup> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A map of the audio tracks for each character's vocals.
|
2023-09-26 17:46:07 -04:00
|
|
|
* - Keys are `characterId-variation` (with `characterId` being the default variation).
|
|
|
|
* - Values are the byte data for the audio track.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-06-08 16:53:52 -04:00
|
|
|
var audioVocalTrackData:Map<String, Bytes> = [];
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CHART DATA
|
|
|
|
*/
|
|
|
|
// ==============================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The song metadata.
|
|
|
|
* - Keys are the variation IDs. At least one (`default`) must exist.
|
|
|
|
* - Values are the relevant metadata, ready to be serialized to JSON.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var songMetadata:Map<String, SongMetadata> = [];
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-14 23:13:12 -04:00
|
|
|
/**
|
|
|
|
* Retrieves the list of variations for the current song.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var availableVariations(get, never):Array<String>;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
function get_availableVariations():Array<String>
|
|
|
|
{
|
2023-08-14 23:13:12 -04:00
|
|
|
var variations:Array<String> = [for (x in songMetadata.keys()) x];
|
|
|
|
variations.sort(SortUtil.defaultThenAlphabetically.bind('default'));
|
|
|
|
return variations;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the list of difficulties for the current variation of the current song.
|
|
|
|
* ONLY CONTAINS DIFFICULTIES FOR THE CURRENT VARIATION so if on the default variation, erect/nightmare won't be included.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var availableDifficulties(get, never):Array<String>;
|
2023-08-14 23:13:12 -04:00
|
|
|
|
|
|
|
function get_availableDifficulties():Array<String>
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
var m:Null<SongMetadata> = songMetadata.get(selectedVariation);
|
|
|
|
return m?.playData?.difficulties ?? [];
|
2023-08-14 23:13:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the list of difficulties for ALL variations of the current song.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var allDifficulties(get, never):Array<String>;
|
2023-08-14 23:13:12 -04:00
|
|
|
|
|
|
|
function get_allDifficulties():Array<String>
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
var result:Array<Array<String>> = [
|
|
|
|
for (x in availableVariations)
|
|
|
|
{
|
|
|
|
var m:Null<SongMetadata> = songMetadata.get(x);
|
|
|
|
m?.playData?.difficulties ?? [];
|
|
|
|
}
|
|
|
|
];
|
2023-08-14 23:13:12 -04:00
|
|
|
return result.flatten();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The song chart data.
|
|
|
|
* - Keys are the variation IDs. At least one (`default`) must exist.
|
|
|
|
* - Values are the relevant chart data, ready to be serialized to JSON.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var songChartData:Map<String, SongChartData> = [];
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience property to get the chart data for the current variation.
|
|
|
|
*/
|
|
|
|
var currentSongMetadata(get, set):SongMetadata;
|
|
|
|
|
|
|
|
function get_currentSongMetadata():SongMetadata
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
var result:Null<SongMetadata> = songMetadata.get(selectedVariation);
|
2023-01-22 19:55:30 -05:00
|
|
|
if (result == null)
|
|
|
|
{
|
|
|
|
result = new SongMetadata('Dad Battle', 'Kawai Sprite', selectedVariation);
|
|
|
|
songMetadata.set(selectedVariation, result);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongMetadata(value:SongMetadata):SongMetadata
|
|
|
|
{
|
|
|
|
songMetadata.set(selectedVariation, value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience property to get the chart data for the current variation.
|
|
|
|
*/
|
|
|
|
var currentSongChartData(get, set):SongChartData;
|
|
|
|
|
|
|
|
function get_currentSongChartData():SongChartData
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
var result:Null<SongChartData> = songChartData.get(selectedVariation);
|
2023-01-22 19:55:30 -05:00
|
|
|
if (result == null)
|
|
|
|
{
|
2023-09-08 17:46:44 -04:00
|
|
|
result = new SongChartData(["normal" => 1.0], [], ["normal" => []]);
|
2023-01-22 19:55:30 -05:00
|
|
|
songChartData.set(selectedVariation, result);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongChartData(value:SongChartData):SongChartData
|
|
|
|
{
|
|
|
|
songChartData.set(selectedVariation, value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience property to get (and set) the scroll speed for the current difficulty.
|
|
|
|
*/
|
|
|
|
var currentSongChartScrollSpeed(get, set):Float;
|
|
|
|
|
|
|
|
function get_currentSongChartScrollSpeed():Float
|
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
var result:Null<Float> = currentSongChartData.scrollSpeed.get(selectedDifficulty);
|
2023-01-22 19:55:30 -05:00
|
|
|
if (result == null)
|
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
|
|
|
currentSongChartData.scrollSpeed.set(selectedDifficulty, 1.0);
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongChartScrollSpeed(value:Float):Float
|
|
|
|
{
|
|
|
|
currentSongChartData.scrollSpeed.set(selectedDifficulty, value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience property to get the note data for the current difficulty.
|
|
|
|
*/
|
|
|
|
var currentSongChartNoteData(get, set):Array<SongNoteData>;
|
|
|
|
|
|
|
|
function get_currentSongChartNoteData():Array<SongNoteData>
|
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
var result:Array<SongNoteData> = currentSongChartData.notes.get(selectedDifficulty);
|
2023-01-22 19:55:30 -05:00
|
|
|
if (result == null)
|
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
|
|
|
result = [];
|
2023-06-08 16:53:52 -04:00
|
|
|
trace('Initializing blank note data for difficulty ' + selectedDifficulty);
|
2023-01-22 19:55:30 -05:00
|
|
|
currentSongChartData.notes.set(selectedDifficulty, result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongChartNoteData(value:Array<SongNoteData>):Array<SongNoteData>
|
|
|
|
{
|
|
|
|
currentSongChartData.notes.set(selectedDifficulty, value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience property to get the event data for the current difficulty.
|
|
|
|
*/
|
|
|
|
var currentSongChartEventData(get, set):Array<SongEventData>;
|
|
|
|
|
|
|
|
function get_currentSongChartEventData():Array<SongEventData>
|
|
|
|
{
|
|
|
|
if (currentSongChartData.events == null)
|
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
|
|
|
currentSongChartData.events = [];
|
|
|
|
}
|
|
|
|
return currentSongChartData.events;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongChartEventData(value:Array<SongEventData>):Array<SongEventData>
|
|
|
|
{
|
2023-02-28 21:06:09 -05:00
|
|
|
return currentSongChartData.events = value;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
public var currentSongNoteStyle(get, set):String;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
function get_currentSongNoteStyle():String
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
if (currentSongMetadata.playData.noteSkin == null)
|
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
2023-09-25 23:24:07 -04:00
|
|
|
currentSongMetadata.playData.noteSkin = 'funkin';
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
return currentSongMetadata.playData.noteSkin;
|
|
|
|
}
|
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
function set_currentSongNoteStyle(value:String):String
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
return currentSongMetadata.playData.noteSkin = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
var currentSongStage(get, set):String;
|
|
|
|
|
|
|
|
function get_currentSongStage():String
|
|
|
|
{
|
|
|
|
if (currentSongMetadata.playData.stage == null)
|
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
|
|
|
currentSongMetadata.playData.stage = 'mainStage';
|
|
|
|
}
|
|
|
|
return currentSongMetadata.playData.stage;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongStage(value:String):String
|
|
|
|
{
|
|
|
|
return currentSongMetadata.playData.stage = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
var currentSongName(get, set):String;
|
|
|
|
|
|
|
|
function get_currentSongName():String
|
|
|
|
{
|
|
|
|
if (currentSongMetadata.songName == null)
|
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
|
|
|
currentSongMetadata.songName = 'New Song';
|
|
|
|
}
|
|
|
|
return currentSongMetadata.songName;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongName(value:String):String
|
|
|
|
{
|
|
|
|
return currentSongMetadata.songName = value;
|
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var currentSongId(get, never):String;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
function get_currentSongId():String
|
|
|
|
{
|
2023-08-09 18:11:50 -04:00
|
|
|
return currentSongName.toLowerKebabCase().replace('.', '').replace(' ', '-');
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
var currentSongArtist(get, set):String;
|
|
|
|
|
|
|
|
function get_currentSongArtist():String
|
|
|
|
{
|
|
|
|
if (currentSongMetadata.artist == null)
|
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
|
|
|
currentSongMetadata.artist = 'Unknown';
|
|
|
|
}
|
|
|
|
return currentSongMetadata.artist;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongArtist(value:String):String
|
|
|
|
{
|
|
|
|
return currentSongMetadata.artist = value;
|
|
|
|
}
|
|
|
|
|
2023-08-14 23:13:12 -04:00
|
|
|
/**
|
|
|
|
* SIGNALS
|
|
|
|
*/
|
|
|
|
// ==============================
|
2023-08-28 15:03:29 -04:00
|
|
|
// public var onDifficultyChange(default, never):FlxTypedSignal<ChartEditorState->Void> = new FlxTypedSignal<ChartEditorState->Void>();
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* RENDER OBJECTS
|
|
|
|
*/
|
|
|
|
// ==============================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The IMAGE used for the grid. Updated by ChartEditorThemeHandler.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var gridBitmap:Null<BitmapData> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The IMAGE used for the selection squares. Updated by ChartEditorThemeHandler.
|
|
|
|
* Used two ways:
|
|
|
|
* 1. A sprite is given this bitmap and placed over selected notes.
|
|
|
|
* 2. The image is split and used for a 9-slice sprite for the selection box.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var selectionSquareBitmap:Null<BitmapData> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
/**
|
|
|
|
* The IMAGE used for the note preview bitmap. Updated by ChartEditorThemeHandler.
|
|
|
|
* The image is split and used for a 9-slice sprite for the box over the note preview.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var notePreviewViewportBitmap:Null<BitmapData> = null;
|
2023-08-16 03:40:44 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* The tiled sprite used to display the grid.
|
|
|
|
* The height is the length of the song, and scrolling is done by simply the sprite.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var gridTiledSprite:Null<FlxSprite> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The playhead representing the current position in the song.
|
|
|
|
* Can move around on the grid independently of the view.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var gridPlayhead:FlxSpriteGroup = new FlxSpriteGroup();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var gridPlayheadScrollArea:Null<FlxSprite> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A sprite used to indicate the note that will be placed on click.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var gridGhostNote:Null<ChartEditorNoteSprite> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-11 19:42:10 -04:00
|
|
|
/**
|
|
|
|
* A sprite used to indicate the note that will be placed on click.
|
|
|
|
*/
|
|
|
|
var gridGhostHoldNote:Null<ChartEditorHoldNoteSprite> = null;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* A sprite used to indicate the event that will be placed on click.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var gridGhostEvent:Null<ChartEditorEventSprite> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The waveform which (optionally) displays over the grid, underneath the notes and playhead.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var gridSpectrogram:Null<PolygonSpectogram> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The sprite used to display the note preview area.
|
|
|
|
* We move this up and down to scroll the preview.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var notePreview:Null<ChartEditorNotePreview> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
/**
|
|
|
|
* The rectangular sprite used for representing the current viewport on the note preview.
|
|
|
|
* We move this up and down and resize it to represent the visible area.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var notePreviewViewport:Null<FlxSliceSprite> = null;
|
2023-08-16 03:40:44 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* The rectangular sprite used for rendering the selection box.
|
|
|
|
* Uses a 9-slice to stretch the selection box to the correct size without warping.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var selectionBoxSprite:Null<FlxSliceSprite> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The opponent's health icon.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var healthIconDad:Null<HealthIcon> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The player's health icon.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var healthIconBF:Null<HealthIcon> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The purple background sprite.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var menuBG:Null<FlxSprite> = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The layout containing the playbar head slider.
|
|
|
|
*/
|
|
|
|
var playbarHeadLayout:Null<Component> = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The playbar head slider.
|
|
|
|
*/
|
|
|
|
var playbarHead:Null<Slider> = null;
|
|
|
|
|
2023-09-13 14:51:12 -04:00
|
|
|
/**
|
|
|
|
* The label by the playbar telling the song position.
|
|
|
|
*/
|
|
|
|
var playbarSongPos:Null<Label> = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The label by the playbar telling the song time remaining.
|
|
|
|
*/
|
|
|
|
var playbarSongRemaining:Null<Label> = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The label by the playbar telling the note snap.
|
|
|
|
*/
|
|
|
|
var playbarNoteSnap:Null<Label> = null;
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
/**
|
|
|
|
* The current process that is lerping the scroll position.
|
|
|
|
* Used to cancel the previous lerp if the user scrolls again.
|
|
|
|
*/
|
|
|
|
var currentScrollEase:Null<VarTween>;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The sprite group containing the note graphics.
|
|
|
|
* Only displays a subset of the data from `currentSongChartNoteData`,
|
|
|
|
* and kills notes that are off-screen to be recycled later.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var renderedNotes:FlxTypedSpriteGroup<ChartEditorNoteSprite> = new FlxTypedSpriteGroup<ChartEditorNoteSprite>();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-07-22 20:16:43 -04:00
|
|
|
/**
|
|
|
|
* The sprite group containing the hold note graphics.
|
|
|
|
* Only displays a subset of the data from `currentSongChartNoteData`,
|
|
|
|
* and kills notes that are off-screen to be recycled later.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var renderedHoldNotes:FlxTypedSpriteGroup<ChartEditorHoldNoteSprite> = new FlxTypedSpriteGroup<ChartEditorHoldNoteSprite>();
|
2023-07-19 21:16:39 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* The sprite group containing the song events.
|
|
|
|
* Only displays a subset of the data from `currentSongChartEventData`,
|
|
|
|
* and kills events that are off-screen to be recycled later.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
var renderedEvents:FlxTypedSpriteGroup<ChartEditorEventSprite> = new FlxTypedSpriteGroup<ChartEditorEventSprite>();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var renderedSelectionSquares:FlxTypedSpriteGroup<FlxSprite> = new FlxTypedSpriteGroup<FlxSprite>();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
public function new()
|
|
|
|
{
|
|
|
|
// Load the HaxeUI XML file.
|
|
|
|
super(CHART_EDITOR_LAYOUT);
|
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
override function create():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-07-26 16:52:58 -04:00
|
|
|
// super.create() must be called first, the HaxeUI components get created here.
|
|
|
|
super.create();
|
|
|
|
// Set the z-index of the HaxeUI.
|
|
|
|
this.component.zIndex = 100;
|
|
|
|
|
2023-09-12 18:37:59 -04:00
|
|
|
// Show the mouse cursor.
|
|
|
|
Cursor.show();
|
|
|
|
|
2023-07-26 16:52:58 -04:00
|
|
|
fixCamera();
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// Get rid of any music from the previous state.
|
|
|
|
FlxG.sound.music.stop();
|
|
|
|
|
|
|
|
buildDefaultSongData();
|
|
|
|
|
|
|
|
buildBackground();
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
ChartEditorThemeHandler.updateTheme(this);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
buildGrid();
|
2023-06-08 16:53:52 -04:00
|
|
|
// buildSpectrogram(audioInstTrack);
|
|
|
|
buildNotePreview();
|
2023-01-22 19:55:30 -05:00
|
|
|
buildSelectionBox();
|
|
|
|
|
|
|
|
buildAdditionalUI();
|
|
|
|
|
|
|
|
// Setup the onClick listeners for the UI after it's been created.
|
|
|
|
setupUIListeners();
|
2023-02-28 21:06:09 -05:00
|
|
|
setupTurboKeyHandlers();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
setupAutoSave();
|
|
|
|
|
2023-07-26 16:52:58 -04:00
|
|
|
refresh();
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
ChartEditorDialogHandler.openWelcomeDialog(this, false);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function buildDefaultSongData():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
selectedVariation = Constants.DEFAULT_VARIATION;
|
|
|
|
selectedDifficulty = Constants.DEFAULT_DIFFICULTY;
|
|
|
|
|
|
|
|
// Initialize the song metadata.
|
|
|
|
songMetadata = new Map<String, SongMetadata>();
|
|
|
|
|
|
|
|
// Initialize the song chart data.
|
|
|
|
songChartData = new Map<String, SongChartData>();
|
|
|
|
|
2023-05-25 18:33:39 -04:00
|
|
|
audioVocalTrackGroup = new VoicesGroup();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds and displays the background sprite.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function buildBackground():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
menuBG = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
|
|
|
|
add(menuBG);
|
|
|
|
|
|
|
|
menuBG.setGraphicSize(Std.int(menuBG.width * 1.1));
|
|
|
|
menuBG.updateHitbox();
|
|
|
|
menuBG.screenCenter();
|
|
|
|
menuBG.scrollFactor.set(0, 0);
|
2023-07-26 16:52:58 -04:00
|
|
|
menuBG.zIndex = -100;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds and displays the chart editor grid, including the playhead and cursor.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function buildGrid():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (gridBitmap == null) throw 'ERROR: Tried to build grid, but gridBitmap is null! Check ChartEditorThemeHandler.updateTheme().';
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
gridTiledSprite = new FlxTiledSprite(gridBitmap, gridBitmap.width, 1000, false, true);
|
|
|
|
gridTiledSprite.x = FlxG.width / 2 - GRID_SIZE * STRUMLINE_SIZE; // Center the grid.
|
|
|
|
gridTiledSprite.y = MENU_BAR_HEIGHT + GRID_TOP_PAD; // Push down to account for the menu bar.
|
|
|
|
add(gridTiledSprite);
|
2023-07-26 16:52:58 -04:00
|
|
|
gridTiledSprite.zIndex = 10;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
gridGhostNote = new ChartEditorNoteSprite(this);
|
|
|
|
gridGhostNote.alpha = 0.6;
|
2023-07-22 20:16:43 -04:00
|
|
|
gridGhostNote.noteData = new SongNoteData(0, 0, 0, "");
|
2023-01-22 19:55:30 -05:00
|
|
|
gridGhostNote.visible = false;
|
|
|
|
add(gridGhostNote);
|
2023-07-26 16:52:58 -04:00
|
|
|
gridGhostNote.zIndex = 11;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-11 19:42:10 -04:00
|
|
|
gridGhostHoldNote = new ChartEditorHoldNoteSprite(this);
|
|
|
|
gridGhostHoldNote.alpha = 0.6;
|
|
|
|
gridGhostHoldNote.noteData = new SongNoteData(0, 0, 0, "");
|
|
|
|
gridGhostHoldNote.visible = false;
|
|
|
|
add(gridGhostHoldNote);
|
|
|
|
gridGhostHoldNote.zIndex = 11;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
gridGhostEvent = new ChartEditorEventSprite(this);
|
|
|
|
gridGhostEvent.alpha = 0.6;
|
2023-06-08 16:53:52 -04:00
|
|
|
gridGhostEvent.eventData = new SongEventData(-1, '', {});
|
2023-01-22 19:55:30 -05:00
|
|
|
gridGhostEvent.visible = false;
|
|
|
|
add(gridGhostEvent);
|
2023-07-26 16:52:58 -04:00
|
|
|
gridGhostEvent.zIndex = 12;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
buildNoteGroup();
|
|
|
|
|
2023-09-08 17:27:14 -04:00
|
|
|
gridPlayheadScrollArea = new FlxSprite(0, 0);
|
|
|
|
gridPlayheadScrollArea.makeGraphic(10, 10, PLAYHEAD_SCROLL_AREA_COLOR); // Make it 10x10px and then scale it as needed.
|
2023-01-22 19:55:30 -05:00
|
|
|
add(gridPlayheadScrollArea);
|
2023-09-08 17:27:14 -04:00
|
|
|
gridPlayheadScrollArea.setGraphicSize(PLAYHEAD_SCROLL_AREA_WIDTH, 3000);
|
|
|
|
gridPlayheadScrollArea.updateHitbox();
|
|
|
|
gridPlayheadScrollArea.x = gridTiledSprite.x - PLAYHEAD_SCROLL_AREA_WIDTH;
|
|
|
|
gridPlayheadScrollArea.y = MENU_BAR_HEIGHT + GRID_TOP_PAD;
|
2023-07-26 16:52:58 -04:00
|
|
|
gridPlayheadScrollArea.zIndex = 25;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// The playhead that show the current position in the song.
|
|
|
|
add(gridPlayhead);
|
2023-07-26 16:52:58 -04:00
|
|
|
gridPlayhead.zIndex = 30;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
var playheadWidth:Int = GRID_SIZE * (STRUMLINE_SIZE * 2 + 1) + (PLAYHEAD_SCROLL_AREA_WIDTH * 2);
|
|
|
|
var playheadBaseYPos:Float = MENU_BAR_HEIGHT + GRID_TOP_PAD;
|
2023-01-22 19:55:30 -05:00
|
|
|
gridPlayhead.setPosition(gridTiledSprite.x, playheadBaseYPos);
|
2023-06-08 16:53:52 -04:00
|
|
|
var playheadSprite:FlxSprite = new FlxSprite().makeGraphic(playheadWidth, PLAYHEAD_HEIGHT, PLAYHEAD_COLOR);
|
2023-01-22 19:55:30 -05:00
|
|
|
playheadSprite.x = -PLAYHEAD_SCROLL_AREA_WIDTH;
|
|
|
|
playheadSprite.y = 0;
|
|
|
|
gridPlayhead.add(playheadSprite);
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
var playheadBlock:FlxSprite = ChartEditorThemeHandler.buildPlayheadBlock();
|
2023-01-22 19:55:30 -05:00
|
|
|
playheadBlock.x = -PLAYHEAD_SCROLL_AREA_WIDTH;
|
|
|
|
playheadBlock.y = -PLAYHEAD_HEIGHT / 2;
|
|
|
|
gridPlayhead.add(playheadBlock);
|
|
|
|
|
|
|
|
// Character icons.
|
2023-09-26 17:46:07 -04:00
|
|
|
healthIconDad = new HealthIcon(currentSongMetadata.playData.characters.opponent);
|
2023-01-22 19:55:30 -05:00
|
|
|
healthIconDad.autoUpdate = false;
|
|
|
|
healthIconDad.size.set(0.5, 0.5);
|
|
|
|
healthIconDad.x = gridTiledSprite.x - 15 - (HealthIcon.HEALTH_ICON_SIZE * 0.5);
|
|
|
|
healthIconDad.y = gridTiledSprite.y + 5;
|
|
|
|
add(healthIconDad);
|
2023-07-26 16:52:58 -04:00
|
|
|
healthIconDad.zIndex = 30;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
healthIconBF = new HealthIcon(currentSongMetadata.playData.characters.player);
|
2023-01-22 19:55:30 -05:00
|
|
|
healthIconBF.autoUpdate = false;
|
|
|
|
healthIconBF.size.set(0.5, 0.5);
|
2023-08-30 18:29:09 -04:00
|
|
|
healthIconBF.x = gridTiledSprite.x + gridTiledSprite.width + 15;
|
2023-01-22 19:55:30 -05:00
|
|
|
healthIconBF.y = gridTiledSprite.y + 5;
|
|
|
|
healthIconBF.flipX = true;
|
|
|
|
add(healthIconBF);
|
2023-07-26 16:52:58 -04:00
|
|
|
healthIconBF.zIndex = 30;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function buildSelectionBox():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (selectionBoxSprite == null) throw 'ERROR: Tried to build selection box, but selectionBoxSprite is null! Check ChartEditorThemeHandler.updateTheme().';
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
selectionBoxSprite.scrollFactor.set(0, 0);
|
|
|
|
add(selectionBoxSprite);
|
2023-07-26 16:52:58 -04:00
|
|
|
selectionBoxSprite.zIndex = 30;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
setSelectionBoxBounds();
|
|
|
|
}
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
function setSelectionBoxBounds(bounds:FlxRect = null):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (selectionBoxSprite == null)
|
|
|
|
throw 'ERROR: Tried to set selection box bounds, but selectionBoxSprite is null! Check ChartEditorThemeHandler.updateTheme().';
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
if (bounds == null)
|
|
|
|
{
|
|
|
|
selectionBoxSprite.visible = false;
|
|
|
|
selectionBoxSprite.x = -9999;
|
|
|
|
selectionBoxSprite.y = -9999;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
selectionBoxSprite.visible = true;
|
|
|
|
selectionBoxSprite.x = bounds.x;
|
|
|
|
selectionBoxSprite.y = bounds.y;
|
|
|
|
selectionBoxSprite.width = bounds.width;
|
|
|
|
selectionBoxSprite.height = bounds.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
function buildNotePreview():Void
|
|
|
|
{
|
2023-08-16 03:40:44 -04:00
|
|
|
var height:Int = FlxG.height - MENU_BAR_HEIGHT - GRID_TOP_PAD - PLAYBAR_HEIGHT - GRID_TOP_PAD - GRID_TOP_PAD;
|
2023-06-08 16:53:52 -04:00
|
|
|
notePreview = new ChartEditorNotePreview(height);
|
2023-08-16 03:40:44 -04:00
|
|
|
notePreview.x = 350;
|
2023-06-08 16:53:52 -04:00
|
|
|
notePreview.y = MENU_BAR_HEIGHT + GRID_TOP_PAD;
|
2023-08-16 03:40:44 -04:00
|
|
|
add(notePreview);
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
if (notePreviewViewport == null) throw 'ERROR: Tried to build note preview, but notePreviewViewport is null! Check ChartEditorThemeHandler.updateTheme().';
|
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
notePreviewViewport.scrollFactor.set(0, 0);
|
|
|
|
add(notePreviewViewport);
|
|
|
|
notePreviewViewport.zIndex = 30;
|
|
|
|
|
|
|
|
setNotePreviewViewportBounds(calculateNotePreviewViewportBounds());
|
|
|
|
}
|
|
|
|
|
|
|
|
function calculateNotePreviewViewportBounds():FlxRect
|
|
|
|
{
|
|
|
|
var bounds:FlxRect = new FlxRect();
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
// Return 0, 0, 0, 0 if the note preview doesn't exist for some reason.
|
|
|
|
if (notePreview == null) return bounds;
|
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
// Horizontal position and width are constant.
|
|
|
|
bounds.x = notePreview.x;
|
|
|
|
bounds.width = notePreview.width;
|
|
|
|
|
|
|
|
// Vertical position depends on scroll position.
|
|
|
|
bounds.y = notePreview.y + (notePreview.height * (scrollPositionInPixels / songLengthInPixels));
|
|
|
|
|
|
|
|
// Height depends on the viewport size.
|
|
|
|
bounds.height = notePreview.height * (FlxG.height / songLengthInPixels);
|
|
|
|
|
|
|
|
// Make sure the viewport doesn't go off the top or bottom of the note preview.
|
|
|
|
if (bounds.y < notePreview.y)
|
|
|
|
{
|
|
|
|
bounds.height -= notePreview.y - bounds.y;
|
|
|
|
bounds.y = notePreview.y;
|
|
|
|
}
|
|
|
|
else if (bounds.y + bounds.height > notePreview.y + notePreview.height)
|
|
|
|
{
|
|
|
|
bounds.height -= (bounds.y + bounds.height) - (notePreview.y + notePreview.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
var MIN_HEIGHT:Int = 8;
|
|
|
|
if (bounds.height < MIN_HEIGHT)
|
|
|
|
{
|
|
|
|
bounds.y -= MIN_HEIGHT - bounds.height;
|
|
|
|
bounds.height = MIN_HEIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bounds;
|
|
|
|
}
|
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
public function switchToCurrentInstrumental():Void
|
|
|
|
{
|
|
|
|
ChartEditorAudioHandler.switchToInstrumental(this, currentInstrumentalId, currentSongMetadata.playData.characters.player,
|
|
|
|
currentSongMetadata.playData.characters.opponent);
|
|
|
|
}
|
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
function setNotePreviewViewportBounds(bounds:FlxRect = null):Void
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (notePreviewViewport == null)
|
|
|
|
throw 'ERROR: Tried to set note preview viewport bounds, but notePreviewViewport is null! Check ChartEditorThemeHandler.updateTheme().';
|
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
if (bounds == null)
|
|
|
|
{
|
|
|
|
notePreviewViewport.visible = false;
|
|
|
|
notePreviewViewport.x = -9999;
|
|
|
|
notePreviewViewport.y = -9999;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
notePreviewViewport.visible = true;
|
|
|
|
notePreviewViewport.x = bounds.x;
|
|
|
|
notePreviewViewport.y = bounds.y;
|
|
|
|
notePreviewViewport.width = bounds.width;
|
|
|
|
notePreviewViewport.height = bounds.height;
|
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function buildSpectrogram(target:FlxSound):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
gridSpectrogram = new PolygonSpectogram(FlxG.sound.music, FlxColor.RED, FlxG.height / 2, Math.floor(FlxG.height / 2));
|
|
|
|
gridSpectrogram.x += 170;
|
|
|
|
gridSpectrogram.scrollFactor.set();
|
2023-01-22 19:55:30 -05:00
|
|
|
gridSpectrogram.waveAmplitude = 50;
|
2023-06-08 16:53:52 -04:00
|
|
|
gridSpectrogram.visType = UPDATED;
|
2023-01-22 19:55:30 -05:00
|
|
|
add(gridSpectrogram);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds the group that will hold all the notes.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function buildNoteGroup():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (gridTiledSprite == null) throw 'ERROR: Tried to build note groups, but gridTiledSprite is null! Check ChartEditorState.buildGrid().';
|
|
|
|
|
2023-07-22 20:16:43 -04:00
|
|
|
renderedHoldNotes.setPosition(gridTiledSprite.x, gridTiledSprite.y);
|
|
|
|
add(renderedHoldNotes);
|
2023-07-26 16:52:58 -04:00
|
|
|
renderedHoldNotes.zIndex = 24;
|
2023-07-22 20:16:43 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
renderedNotes.setPosition(gridTiledSprite.x, gridTiledSprite.y);
|
|
|
|
add(renderedNotes);
|
2023-07-26 16:52:58 -04:00
|
|
|
renderedNotes.zIndex = 25;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
renderedEvents.setPosition(gridTiledSprite.x, gridTiledSprite.y);
|
|
|
|
add(renderedEvents);
|
2023-09-26 20:36:41 -04:00
|
|
|
renderedEvents.zIndex = 25;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
renderedSelectionSquares.setPosition(gridTiledSprite.x, gridTiledSprite.y);
|
|
|
|
add(renderedSelectionSquares);
|
2023-09-26 20:36:41 -04:00
|
|
|
renderedSelectionSquares.zIndex = 26;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function buildAdditionalUI():Void
|
|
|
|
{
|
|
|
|
playbarHeadLayout = buildComponent(CHART_EDITOR_PLAYBARHEAD_LAYOUT);
|
2023-08-28 15:03:29 -04:00
|
|
|
|
|
|
|
if (playbarHeadLayout == null) throw 'ERROR: Failed to construct playbarHeadLayout! Check "${CHART_EDITOR_PLAYBARHEAD_LAYOUT}".';
|
|
|
|
|
2023-07-26 16:52:58 -04:00
|
|
|
playbarHeadLayout.zIndex = 110;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
playbarHeadLayout.width = FlxG.width - 8;
|
|
|
|
playbarHeadLayout.height = 10;
|
|
|
|
playbarHeadLayout.x = 4;
|
|
|
|
playbarHeadLayout.y = FlxG.height - 48 - 8;
|
|
|
|
|
|
|
|
playbarHead = playbarHeadLayout.findComponent('playbarHead', Slider);
|
2023-08-28 15:03:29 -04:00
|
|
|
if (playbarHead == null) throw 'ERROR: Failed to fetch playbarHead from playbarHeadLayout! Check "${CHART_EDITOR_PLAYBARHEAD_LAYOUT}".';
|
2023-01-22 19:55:30 -05:00
|
|
|
playbarHead.allowFocus = false;
|
|
|
|
playbarHead.width = FlxG.width;
|
|
|
|
playbarHead.height = 10;
|
2023-06-08 16:53:52 -04:00
|
|
|
playbarHead.styleString = 'padding-left: 0px; padding-right: 0px; border-left: 0px; border-right: 0px;';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-02 18:26:03 -05:00
|
|
|
playbarHead.onDragStart = function(_:DragEvent) {
|
2023-01-22 19:55:30 -05:00
|
|
|
playbarHeadDragging = true;
|
|
|
|
|
|
|
|
// If we were dragging the playhead while the song was playing, resume playing.
|
|
|
|
if (audioInstTrack != null && audioInstTrack.playing)
|
|
|
|
{
|
|
|
|
playbarHeadDraggingWasPlaying = true;
|
|
|
|
stopAudioPlayback();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
playbarHeadDraggingWasPlaying = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-02 18:26:03 -05:00
|
|
|
playbarHead.onDragEnd = function(_:DragEvent) {
|
2023-01-22 19:55:30 -05:00
|
|
|
playbarHeadDragging = false;
|
|
|
|
|
|
|
|
// Set the song position to where the playhead was moved to.
|
2023-08-28 15:03:29 -04:00
|
|
|
scrollPositionInPixels = songLengthInPixels * (playbarHead?.value ?? 0 / 100);
|
2023-01-22 19:55:30 -05:00
|
|
|
// Update the conductor and audio tracks to match.
|
|
|
|
moveSongToScrollPosition();
|
|
|
|
|
|
|
|
// If we were dragging the playhead while the song was playing, resume playing.
|
|
|
|
if (playbarHeadDraggingWasPlaying)
|
|
|
|
{
|
|
|
|
playbarHeadDraggingWasPlaying = false;
|
2023-06-08 16:53:52 -04:00
|
|
|
// Disabled code to resume song playback on drag.
|
|
|
|
// startAudioPlayback();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-02 18:26:03 -05:00
|
|
|
add(playbarHeadLayout);
|
2023-06-08 16:53:52 -04:00
|
|
|
|
|
|
|
// Setup notifications.
|
|
|
|
@:privateAccess
|
|
|
|
// NotificationManager.GUTTER_SIZE = 56;
|
|
|
|
NotificationManager.GUTTER_SIZE = 20;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets up the onClick listeners for the UI.
|
|
|
|
*/
|
|
|
|
function setupUIListeners():Void
|
|
|
|
{
|
|
|
|
// Add functionality to the playbar.
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('playbarPlay', _ -> toggleAudioPlayback());
|
|
|
|
addUIClickListener('playbarStart', _ -> playbarButtonPressed = 'playbarStart');
|
|
|
|
addUIClickListener('playbarBack', _ -> playbarButtonPressed = 'playbarBack');
|
|
|
|
addUIClickListener('playbarForward', _ -> playbarButtonPressed = 'playbarForward');
|
|
|
|
addUIClickListener('playbarEnd', _ -> playbarButtonPressed = 'playbarEnd');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Add functionality to the menu items.
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemNewChart', _ -> ChartEditorDialogHandler.openWelcomeDialog(this, true));
|
2023-06-08 16:53:52 -04:00
|
|
|
addUIClickListener('menubarItemOpenChart', _ -> ChartEditorDialogHandler.openBrowseWizard(this, true));
|
2023-09-25 23:24:07 -04:00
|
|
|
addUIClickListener('menubarItemSaveChartAs', _ -> ChartEditorImportExportHandler.exportAllSongData(this));
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemLoadInst', _ -> ChartEditorDialogHandler.openUploadInstDialog(this, true));
|
2023-06-08 16:53:52 -04:00
|
|
|
addUIClickListener('menubarItemImportChart', _ -> ChartEditorDialogHandler.openImportChartDialog(this, 'legacy', true));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemUndo', _ -> undoLastCommand());
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemRedo', _ -> redoLastCommand());
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemCopy', function(_) {
|
2023-01-22 19:55:30 -05:00
|
|
|
// Doesn't use a command because it's not undoable.
|
2023-06-08 16:53:52 -04:00
|
|
|
|
|
|
|
// Calculate a single time offset for all the notes and events.
|
|
|
|
var timeOffset:Null<Int> = currentNoteSelection.length > 0 ? Std.int(currentNoteSelection[0].time) : null;
|
|
|
|
if (currentEventSelection.length > 0)
|
|
|
|
{
|
|
|
|
if (timeOffset == null || currentEventSelection[0].time < timeOffset)
|
|
|
|
{
|
|
|
|
timeOffset = Std.int(currentEventSelection[0].time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
SongDataUtils.writeItemsToClipboard(
|
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
notes: SongDataUtils.buildNoteClipboard(currentNoteSelection, timeOffset),
|
|
|
|
events: SongDataUtils.buildEventClipboard(currentEventSelection, timeOffset),
|
2023-01-22 22:25:45 -05:00
|
|
|
});
|
2023-01-22 19:55:30 -05:00
|
|
|
});
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemCut', _ -> performCommand(new CutItemsCommand(currentNoteSelection, currentEventSelection)));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-26 20:36:41 -04:00
|
|
|
addUIClickListener('menubarItemPaste', _ -> {
|
|
|
|
var targetMs:Float = scrollPositionInMs + playheadPositionInMs;
|
|
|
|
var targetStep:Float = Conductor.getTimeInSteps(targetMs);
|
|
|
|
var targetSnappedStep:Float = Math.floor(targetStep / noteSnapRatio) * noteSnapRatio;
|
|
|
|
var targetSnappedMs:Float = Conductor.getStepTimeInMs(targetSnappedStep);
|
|
|
|
performCommand(new PasteItemsCommand(targetSnappedMs));
|
|
|
|
});
|
|
|
|
|
|
|
|
addUIClickListener('menubarItemPasteUnsnapped', _ -> {
|
|
|
|
var targetMs:Float = scrollPositionInMs + playheadPositionInMs;
|
|
|
|
performCommand(new PasteItemsCommand(targetMs));
|
|
|
|
});
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemDelete', function(_) {
|
2023-01-22 19:55:30 -05:00
|
|
|
if (currentNoteSelection.length > 0 && currentEventSelection.length > 0)
|
|
|
|
{
|
|
|
|
performCommand(new RemoveItemsCommand(currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
|
|
|
else if (currentNoteSelection.length > 0)
|
|
|
|
{
|
|
|
|
performCommand(new RemoveNotesCommand(currentNoteSelection));
|
|
|
|
}
|
|
|
|
else if (currentEventSelection.length > 0)
|
|
|
|
{
|
|
|
|
performCommand(new RemoveEventsCommand(currentEventSelection));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Do nothing???
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemSelectAll', _ -> performCommand(new SelectAllItemsCommand(currentNoteSelection, currentEventSelection)));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemSelectInverse', _ -> performCommand(new InvertSelectedItemsCommand(currentNoteSelection, currentEventSelection)));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemSelectNone', _ -> performCommand(new DeselectAllItemsCommand(currentNoteSelection, currentEventSelection)));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
// TODO: Implement these.
|
|
|
|
// addUIClickListener('menubarItemSelectRegion', _ -> doSomething());
|
|
|
|
// addUIClickListener('menubarItemSelectBeforeCursor', _ -> doSomething());
|
|
|
|
// addUIClickListener('menubarItemSelectAfterCursor', _ -> doSomething());
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-07-26 16:52:58 -04:00
|
|
|
addUIClickListener('menubarItemPlaytestFull', _ -> testSongInPlayState(false));
|
|
|
|
addUIClickListener('menubarItemPlaytestMinimal', _ -> testSongInPlayState(true));
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
addUIChangeListener('menubarItemInputStyleGroup', function(event:UIEvent) {
|
|
|
|
trace('Change input style: ${event.target}');
|
|
|
|
});
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemAbout', _ -> ChartEditorDialogHandler.openAboutDialog(this));
|
2023-09-26 17:46:07 -04:00
|
|
|
addUIClickListener('menubarItemWelcomeDialog', _ -> ChartEditorDialogHandler.openWelcomeDialog(this, true));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIClickListener('menubarItemUserGuide', _ -> ChartEditorDialogHandler.openUserGuideDialog(this));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIChangeListener('menubarItemDownscroll', event -> isViewDownscroll = event.value);
|
2023-01-22 19:55:30 -05:00
|
|
|
setUICheckboxSelected('menubarItemDownscroll', isViewDownscroll);
|
|
|
|
|
2023-08-14 23:13:12 -04:00
|
|
|
addUIClickListener('menubarItemDifficultyUp', _ -> incrementDifficulty(1));
|
|
|
|
addUIClickListener('menubarItemDifficultyDown', _ -> incrementDifficulty(-1));
|
|
|
|
|
2023-07-26 20:03:31 -04:00
|
|
|
addUIChangeListener('menubarItemPlaytestStartTime', event -> playtestStartTime = event.value);
|
|
|
|
setUICheckboxSelected('menubarItemPlaytestStartTime', playtestStartTime);
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIChangeListener('menuBarItemThemeLight', function(event:UIEvent) {
|
2023-01-22 22:25:45 -05:00
|
|
|
if (event.target.value) currentTheme = ChartEditorTheme.Light;
|
2023-01-22 19:55:30 -05:00
|
|
|
});
|
|
|
|
setUICheckboxSelected('menuBarItemThemeLight', currentTheme == ChartEditorTheme.Light);
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIChangeListener('menuBarItemThemeDark', function(event:UIEvent) {
|
2023-01-22 22:25:45 -05:00
|
|
|
if (event.target.value) currentTheme = ChartEditorTheme.Dark;
|
2023-01-22 19:55:30 -05:00
|
|
|
});
|
|
|
|
setUICheckboxSelected('menuBarItemThemeDark', currentTheme == ChartEditorTheme.Dark);
|
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
addUIClickListener('menubarItemPlayPause', _ -> toggleAudioPlayback());
|
|
|
|
|
|
|
|
addUIClickListener('menubarItemLoadInstrumental', _ -> ChartEditorDialogHandler.openUploadInstDialog(this, true));
|
|
|
|
addUIClickListener('menubarItemLoadVocals', _ -> ChartEditorDialogHandler.openUploadVocalsDialog(this, true));
|
|
|
|
|
2023-08-09 18:11:50 -04:00
|
|
|
addUIChangeListener('menubarItemMetronomeEnabled', event -> isMetronomeEnabled = event.value);
|
|
|
|
setUICheckboxSelected('menubarItemMetronomeEnabled', isMetronomeEnabled);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIChangeListener('menubarItemPlayerHitsounds', event -> hitsoundsEnabledPlayer = event.value);
|
2023-01-22 19:55:30 -05:00
|
|
|
setUICheckboxSelected('menubarItemPlayerHitsounds', hitsoundsEnabledPlayer);
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIChangeListener('menubarItemOpponentHitsounds', event -> hitsoundsEnabledOpponent = event.value);
|
2023-01-22 19:55:30 -05:00
|
|
|
setUICheckboxSelected('menubarItemOpponentHitsounds', hitsoundsEnabledOpponent);
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var instVolumeLabel:Null<Label> = findComponent('menubarLabelVolumeInstrumental', Label);
|
|
|
|
if (instVolumeLabel != null)
|
|
|
|
{
|
|
|
|
addUIChangeListener('menubarItemVolumeInstrumental', function(event:UIEvent) {
|
2023-09-26 17:46:07 -04:00
|
|
|
var volume:Float = (event?.value ?? 0) / 100.0;
|
2023-08-28 15:03:29 -04:00
|
|
|
if (audioInstTrack != null) audioInstTrack.volume = volume;
|
|
|
|
instVolumeLabel.text = 'Instrumental - ${Std.int(event.value)}%';
|
|
|
|
});
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var vocalsVolumeLabel:Null<Label> = findComponent('menubarLabelVolumeVocals', Label);
|
|
|
|
if (vocalsVolumeLabel != null)
|
|
|
|
{
|
|
|
|
addUIChangeListener('menubarItemVolumeVocals', function(event:UIEvent) {
|
2023-09-26 17:46:07 -04:00
|
|
|
var volume:Float = (event?.value ?? 0) / 100.0;
|
2023-08-28 15:03:29 -04:00
|
|
|
if (audioVocalTrackGroup != null) audioVocalTrackGroup.volume = volume;
|
|
|
|
vocalsVolumeLabel.text = 'Vocals - ${Std.int(event.value)}%';
|
|
|
|
});
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var playbackSpeedLabel:Null<Label> = findComponent('menubarLabelPlaybackSpeed', Label);
|
|
|
|
if (playbackSpeedLabel != null)
|
|
|
|
{
|
|
|
|
addUIChangeListener('menubarItemPlaybackSpeed', function(event:UIEvent) {
|
|
|
|
var pitch:Float = event.value * 2.0 / 100.0;
|
|
|
|
pitch = Math.floor(pitch / 0.25) * 0.25; // Round to nearest 0.25.
|
|
|
|
#if FLX_PITCH
|
|
|
|
if (audioInstTrack != null) audioInstTrack.pitch = pitch;
|
|
|
|
if (audioVocalTrackGroup != null) audioVocalTrackGroup.pitch = pitch;
|
|
|
|
#end
|
|
|
|
var pitchDisplay:Float = Std.int(pitch * 100) / 100; // Round to 2 decimal places.
|
|
|
|
playbackSpeedLabel.text = 'Playback Speed - ${pitchDisplay}x';
|
|
|
|
});
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIChangeListener('menubarItemToggleToolboxDifficulty',
|
|
|
|
event -> ChartEditorToolboxHandler.setToolboxState(this, CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT, event.value));
|
|
|
|
addUIChangeListener('menubarItemToggleToolboxMetadata',
|
|
|
|
event -> ChartEditorToolboxHandler.setToolboxState(this, CHART_EDITOR_TOOLBOX_METADATA_LAYOUT, event.value));
|
2023-09-25 23:24:07 -04:00
|
|
|
addUIChangeListener('menubarItemToggleToolboxNotes',
|
|
|
|
event -> ChartEditorToolboxHandler.setToolboxState(this, CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT, event.value));
|
|
|
|
addUIChangeListener('menubarItemToggleToolboxEvents',
|
|
|
|
event -> ChartEditorToolboxHandler.setToolboxState(this, CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT, event.value));
|
2023-02-28 21:06:09 -05:00
|
|
|
addUIChangeListener('menubarItemToggleToolboxPlayerPreview',
|
|
|
|
event -> ChartEditorToolboxHandler.setToolboxState(this, CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT, event.value));
|
|
|
|
addUIChangeListener('menubarItemToggleToolboxOpponentPreview',
|
|
|
|
event -> ChartEditorToolboxHandler.setToolboxState(this, CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT, event.value));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// TODO: Pass specific HaxeUI components to add context menus to them.
|
|
|
|
registerContextMenu(null, Paths.ui('chart-editor/context/test'));
|
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
/**
|
|
|
|
* Initialize TurboKeyHandlers and add them to the state (so `update()` is called)
|
|
|
|
* We can then probe `keyHandler.activated` to see if the key combo's action should be taken.
|
|
|
|
*/
|
|
|
|
function setupTurboKeyHandlers():Void
|
|
|
|
{
|
|
|
|
add(undoKeyHandler);
|
|
|
|
add(redoKeyHandler);
|
|
|
|
add(upKeyHandler);
|
|
|
|
add(downKeyHandler);
|
|
|
|
add(pageUpKeyHandler);
|
|
|
|
add(pageDownKeyHandler);
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Setup timers and listerners to handle auto-save.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function setupAutoSave():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
WindowUtil.windowExit.add(onWindowClose);
|
|
|
|
saveDataDirty = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called after 5 minutes without saving.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function autoSave():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
saveDataDirty = false;
|
|
|
|
|
|
|
|
// Auto-save the chart.
|
|
|
|
|
|
|
|
#if html5
|
|
|
|
// Auto-save to local storage.
|
|
|
|
#else
|
|
|
|
// Auto-save to temp file.
|
2023-09-25 23:24:07 -04:00
|
|
|
ChartEditorImportExportHandler.exportAllSongData(this, true, true);
|
2023-01-22 19:55:30 -05:00
|
|
|
#end
|
|
|
|
}
|
|
|
|
|
2023-02-28 13:17:28 -05:00
|
|
|
function onWindowClose(exitCode:Int):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
trace('Window exited with exit code: $exitCode');
|
|
|
|
trace('Should save chart? $saveDataDirty');
|
|
|
|
|
|
|
|
if (saveDataDirty)
|
|
|
|
{
|
2023-09-25 23:24:07 -04:00
|
|
|
ChartEditorImportExportHandler.exportAllSongData(this, true);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 13:17:28 -05:00
|
|
|
function cleanupAutoSave():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
WindowUtil.windowExit.remove(onWindowClose);
|
|
|
|
}
|
|
|
|
|
2023-02-28 13:17:28 -05:00
|
|
|
public override function update(elapsed:Float):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// dispatchEvent gets called here.
|
|
|
|
super.update(elapsed);
|
|
|
|
|
|
|
|
// These ones happen even if the modal dialog is open.
|
|
|
|
handleMusicPlayback();
|
|
|
|
handleNoteDisplay();
|
|
|
|
|
|
|
|
// These ones only happen if the modal dialog is not open.
|
|
|
|
handleScrollKeybinds();
|
2023-08-31 21:56:49 -04:00
|
|
|
handleSnap();
|
2023-01-22 19:55:30 -05:00
|
|
|
handleCursor();
|
|
|
|
|
|
|
|
handleMenubar();
|
|
|
|
handleToolboxes();
|
|
|
|
handlePlaybar();
|
|
|
|
handlePlayhead();
|
2023-08-16 03:40:44 -04:00
|
|
|
handleNotePreview();
|
2023-09-13 14:51:12 -04:00
|
|
|
handleHealthIcons();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
handleFileKeybinds();
|
|
|
|
handleEditKeybinds();
|
|
|
|
handleViewKeybinds();
|
2023-07-26 16:52:58 -04:00
|
|
|
handleTestKeybinds();
|
2023-01-22 19:55:30 -05:00
|
|
|
handleHelpKeybinds();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Beat hit while the song is playing.
|
|
|
|
*/
|
|
|
|
override function beatHit():Bool
|
|
|
|
{
|
|
|
|
// dispatchEvent gets called here.
|
2023-01-22 22:25:45 -05:00
|
|
|
if (!super.beatHit()) return false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-09 18:11:50 -04:00
|
|
|
if (isMetronomeEnabled && this.subState == null && (audioInstTrack != null && audioInstTrack.playing))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
playMetronomeTick(Conductor.currentBeat % 4 == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Step hit while the song is playing.
|
|
|
|
*/
|
|
|
|
override function stepHit():Bool
|
|
|
|
{
|
|
|
|
// dispatchEvent gets called here.
|
2023-01-22 22:25:45 -05:00
|
|
|
if (!super.stepHit()) return false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 13:17:28 -05:00
|
|
|
if (audioInstTrack != null && audioInstTrack.playing)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (healthIconDad != null) healthIconDad.onStepHit(Conductor.currentStep);
|
|
|
|
if (healthIconBF != null) healthIconBF.onStepHit(Conductor.currentStep);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
// Updating these every step keeps it more accurate.
|
|
|
|
// playerPreviewDirty = true;
|
|
|
|
// opponentPreviewDirty = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle keybinds for scrolling the chart editor grid.
|
|
|
|
**/
|
2023-02-28 13:17:28 -05:00
|
|
|
function handleScrollKeybinds():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-31 19:14:01 -04:00
|
|
|
// Don't scroll when the cursor is over the UI, unless a playbar button (the << >> ones) is pressed.
|
|
|
|
if (isCursorOverHaxeUI && playbarButtonPressed == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
var scrollAmount:Float = 0; // Amount to scroll the grid.
|
|
|
|
var playheadAmount:Float = 0; // Amount to scroll the playhead relative to the grid.
|
|
|
|
var shouldPause:Bool = false; // Whether to pause the song when scrolling.
|
|
|
|
var shouldEase:Bool = false; // Whether to ease the scroll.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-31 19:14:01 -04:00
|
|
|
// Mouse Wheel = Scroll
|
|
|
|
if (FlxG.mouse.wheel != 0 && !FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
scrollAmount = -10 * FlxG.mouse.wheel;
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// Up Arrow = Scroll Up
|
2023-06-08 16:53:52 -04:00
|
|
|
if (upKeyHandler.activated && currentLiveInputStyle != LiveInputStyle.WASD)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-02-28 21:06:09 -05:00
|
|
|
scrollAmount = -GRID_SIZE * 0.25 * 5.0;
|
|
|
|
shouldPause = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
// Down Arrow = Scroll Down
|
2023-06-08 16:53:52 -04:00
|
|
|
if (downKeyHandler.activated && currentLiveInputStyle != LiveInputStyle.WASD)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-02-28 21:06:09 -05:00
|
|
|
scrollAmount = GRID_SIZE * 0.25 * 5.0;
|
|
|
|
shouldPause = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
// PAGE UP = Jump up to nearest measure
|
2023-02-28 21:06:09 -05:00
|
|
|
if (pageUpKeyHandler.activated)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
var measureHeight:Float = GRID_SIZE * 4 * Conductor.beatsPerMeasure;
|
2023-09-12 19:40:58 -04:00
|
|
|
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
|
|
|
|
var targetScrollPosition:Float = Math.floor(playheadPos / measureHeight) * measureHeight;
|
2023-06-08 16:53:52 -04:00
|
|
|
// If we would move less than one grid, instead move to the top of the previous measure.
|
2023-09-12 19:40:58 -04:00
|
|
|
var targetScrollAmount = Math.abs(targetScrollPosition - playheadPos);
|
|
|
|
if (targetScrollAmount < GRID_SIZE)
|
2023-06-08 16:53:52 -04:00
|
|
|
{
|
2023-09-12 19:40:58 -04:00
|
|
|
targetScrollPosition -= GRID_SIZE * Constants.STEPS_PER_BEAT * Conductor.beatsPerMeasure;
|
2023-06-08 16:53:52 -04:00
|
|
|
}
|
2023-09-12 19:40:58 -04:00
|
|
|
scrollAmount = targetScrollPosition - playheadPos;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
shouldPause = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
if (playbarButtonPressed == 'playbarBack')
|
|
|
|
{
|
|
|
|
playbarButtonPressed = '';
|
|
|
|
scrollAmount = -GRID_SIZE * 4 * Conductor.beatsPerMeasure;
|
2023-02-28 21:06:09 -05:00
|
|
|
shouldPause = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
// PAGE DOWN = Jump down to nearest measure
|
2023-02-28 21:06:09 -05:00
|
|
|
if (pageDownKeyHandler.activated)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
var measureHeight:Float = GRID_SIZE * 4 * Conductor.beatsPerMeasure;
|
2023-09-12 19:40:58 -04:00
|
|
|
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
|
|
|
|
var targetScrollPosition:Float = Math.ceil(playheadPos / measureHeight) * measureHeight;
|
2023-06-08 16:53:52 -04:00
|
|
|
// If we would move less than one grid, instead move to the top of the next measure.
|
2023-09-12 19:40:58 -04:00
|
|
|
var targetScrollAmount = Math.abs(targetScrollPosition - playheadPos);
|
|
|
|
if (targetScrollAmount < GRID_SIZE)
|
2023-06-08 16:53:52 -04:00
|
|
|
{
|
2023-09-12 19:40:58 -04:00
|
|
|
targetScrollPosition += GRID_SIZE * Constants.STEPS_PER_BEAT * Conductor.beatsPerMeasure;
|
2023-06-08 16:53:52 -04:00
|
|
|
}
|
2023-09-12 19:40:58 -04:00
|
|
|
scrollAmount = targetScrollPosition - playheadPos;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
shouldPause = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
if (playbarButtonPressed == 'playbarForward')
|
|
|
|
{
|
|
|
|
playbarButtonPressed = '';
|
|
|
|
scrollAmount = GRID_SIZE * 4 * Conductor.beatsPerMeasure;
|
2023-02-28 21:06:09 -05:00
|
|
|
shouldPause = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Middle Mouse + Drag = Scroll but move the playhead the same amount.
|
|
|
|
if (FlxG.mouse.pressedMiddle)
|
|
|
|
{
|
|
|
|
if (FlxG.mouse.deltaY != 0)
|
|
|
|
{
|
|
|
|
// Scroll down by the amount dragged.
|
|
|
|
scrollAmount += -FlxG.mouse.deltaY;
|
|
|
|
// Move the playhead by the same amount in the other direction so it is stationary.
|
|
|
|
playheadAmount += FlxG.mouse.deltaY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SHIFT + Scroll = Scroll Fast
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
scrollAmount *= 5;
|
|
|
|
}
|
|
|
|
// CONTROL + Scroll = Scroll Precise
|
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
scrollAmount /= 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ALT = Move playhead instead.
|
|
|
|
if (FlxG.keys.pressed.ALT)
|
|
|
|
{
|
|
|
|
playheadAmount = scrollAmount;
|
|
|
|
scrollAmount = 0;
|
2023-02-28 21:06:09 -05:00
|
|
|
shouldPause = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// HOME = Scroll to Top
|
|
|
|
if (FlxG.keys.justPressed.HOME)
|
|
|
|
{
|
|
|
|
// Scroll amount is the difference between the current position and the top.
|
|
|
|
scrollAmount = 0 - this.scrollPositionInPixels;
|
|
|
|
playheadAmount = 0 - this.playheadPositionInPixels;
|
2023-02-28 21:06:09 -05:00
|
|
|
shouldPause = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
if (playbarButtonPressed == 'playbarStart')
|
|
|
|
{
|
|
|
|
playbarButtonPressed = '';
|
|
|
|
scrollAmount = 0 - this.scrollPositionInPixels;
|
|
|
|
playheadAmount = 0 - this.playheadPositionInPixels;
|
2023-02-28 21:06:09 -05:00
|
|
|
shouldPause = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// END = Scroll to Bottom
|
|
|
|
if (FlxG.keys.justPressed.END)
|
|
|
|
{
|
|
|
|
// Scroll amount is the difference between the current position and the bottom.
|
|
|
|
scrollAmount = this.songLengthInPixels - this.scrollPositionInPixels;
|
2023-02-28 21:06:09 -05:00
|
|
|
shouldPause = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
if (playbarButtonPressed == 'playbarEnd')
|
|
|
|
{
|
|
|
|
playbarButtonPressed = '';
|
|
|
|
scrollAmount = this.songLengthInPixels - this.scrollPositionInPixels;
|
2023-02-28 21:06:09 -05:00
|
|
|
shouldPause = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
if (Math.abs(scrollAmount) > GRID_SIZE * 8)
|
|
|
|
{
|
|
|
|
shouldEase = true;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Resync the conductor and audio tracks.
|
2023-06-08 16:53:52 -04:00
|
|
|
if (scrollAmount != 0 || playheadAmount != 0)
|
|
|
|
{
|
|
|
|
this.playheadPositionInPixels += playheadAmount;
|
|
|
|
if (shouldEase)
|
|
|
|
{
|
|
|
|
easeSongToScrollPosition(this.scrollPositionInPixels + scrollAmount);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Apply the scroll amount.
|
|
|
|
this.scrollPositionInPixels += scrollAmount;
|
|
|
|
moveSongToScrollPosition();
|
|
|
|
}
|
|
|
|
}
|
2023-02-28 21:06:09 -05:00
|
|
|
if (shouldPause) stopAudioPlayback();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function handleSnap():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-09-08 16:44:10 -04:00
|
|
|
if (FlxG.keys.justPressed.LEFT && !FlxG.keys.pressed.CONTROL)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
noteSnapQuantIndex--;
|
|
|
|
}
|
|
|
|
|
2023-09-08 16:44:10 -04:00
|
|
|
if (FlxG.keys.justPressed.RIGHT && !FlxG.keys.pressed.CONTROL)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
noteSnapQuantIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle display of the mouse cursor.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function handleCursor():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Note: If a menu is open in HaxeUI, don't handle cursor behavior.
|
2023-06-08 16:53:52 -04:00
|
|
|
var shouldHandleCursor:Bool = !isCursorOverHaxeUI || (selectionBoxStartPos != null);
|
|
|
|
var eventColumn:Int = (STRUMLINE_SIZE * 2 + 1) - 1;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
if (shouldHandleCursor)
|
|
|
|
{
|
2023-09-12 18:37:59 -04:00
|
|
|
// Over the course of this big conditional block,
|
|
|
|
// we determine what the cursor should look like,
|
|
|
|
// and fall back to the default cursor if none of the conditions are met.
|
|
|
|
var targetCursorMode:Null<CursorMode> = null;
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
if (gridTiledSprite == null) throw "ERROR: Tried to handle cursor, but gridTiledSprite is null! Check ChartEditorState.buildGrid()";
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
var overlapsGrid:Bool = FlxG.mouse.overlaps(gridTiledSprite);
|
|
|
|
|
|
|
|
// Cursor position relative to the grid.
|
|
|
|
var cursorX:Float = FlxG.mouse.screenX - gridTiledSprite.x;
|
|
|
|
var cursorY:Float = FlxG.mouse.screenY - gridTiledSprite.y;
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
var overlapsSelectionBorder:Bool = overlapsGrid
|
2023-09-12 18:37:59 -04:00
|
|
|
&& ((cursorX % 40) < (GRID_SELECTION_BORDER_WIDTH / 2)
|
2023-01-22 19:55:30 -05:00
|
|
|
|| (cursorX % 40) > (40 - (GRID_SELECTION_BORDER_WIDTH / 2))
|
2023-09-12 18:37:59 -04:00
|
|
|
|| (cursorY % 40) < (GRID_SELECTION_BORDER_WIDTH / 2) || (cursorY % 40) > (40 - (GRID_SELECTION_BORDER_WIDTH / 2)));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
if (FlxG.mouse.justPressed)
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (gridPlayheadScrollArea != null && FlxG.mouse.overlaps(gridPlayheadScrollArea))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
gridPlayheadScrollAreaPressed = true;
|
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
else if (notePreview != null && FlxG.mouse.overlaps(notePreview))
|
2023-08-16 03:40:44 -04:00
|
|
|
{
|
|
|
|
// Clicked note preview
|
|
|
|
notePreviewScrollAreaStartPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
else if (!overlapsGrid || overlapsSelectionBorder)
|
|
|
|
{
|
|
|
|
selectionBoxStartPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
2023-09-12 18:37:59 -04:00
|
|
|
// Drawing selection box.
|
|
|
|
targetCursorMode = Crosshair;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Deselect all items.
|
2023-09-13 14:51:12 -04:00
|
|
|
if (currentNoteSelection.length > 0 || currentEventSelection.length > 0)
|
|
|
|
{
|
|
|
|
trace('Clicked outside grid, deselecting all items.');
|
|
|
|
performCommand(new DeselectAllItemsCommand(currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gridPlayheadScrollAreaPressed && FlxG.mouse.released)
|
|
|
|
{
|
|
|
|
gridPlayheadScrollAreaPressed = false;
|
|
|
|
}
|
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
if (notePreviewScrollAreaStartPos != null && FlxG.mouse.released)
|
|
|
|
{
|
|
|
|
notePreviewScrollAreaStartPos = null;
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
if (gridPlayheadScrollAreaPressed)
|
|
|
|
{
|
|
|
|
// Clicked on the playhead scroll area.
|
|
|
|
// Move the playhead to the cursor position.
|
|
|
|
this.playheadPositionInPixels = FlxG.mouse.screenY - MENU_BAR_HEIGHT - GRID_TOP_PAD;
|
|
|
|
moveSongToScrollPosition();
|
2023-09-12 18:37:59 -04:00
|
|
|
|
|
|
|
// Cursor should be a grabby hand.
|
|
|
|
if (targetCursorMode == null) targetCursorMode = Grabbing;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// The song position of the cursor, in steps.
|
2023-08-31 23:48:15 -04:00
|
|
|
var cursorFractionalStep:Float = cursorY / GRID_SIZE;
|
2023-07-22 20:16:43 -04:00
|
|
|
var cursorMs:Float = Conductor.getStepTimeInMs(cursorFractionalStep);
|
2023-08-31 23:48:15 -04:00
|
|
|
// Round the cursor step to the nearest snap quant.
|
|
|
|
var cursorSnappedStep:Float = Math.floor(cursorFractionalStep / noteSnapRatio) * noteSnapRatio;
|
|
|
|
var cursorSnappedMs:Float = Conductor.getStepTimeInMs(cursorSnappedStep);
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// The direction value for the column at the cursor.
|
|
|
|
var cursorColumn:Int = Math.floor(cursorX / GRID_SIZE);
|
2023-01-22 22:25:45 -05:00
|
|
|
if (cursorColumn < 0) cursorColumn = 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
if (cursorColumn >= (STRUMLINE_SIZE * 2 + 1 - 1))
|
|
|
|
{
|
|
|
|
// Don't invert the event column.
|
|
|
|
cursorColumn = (STRUMLINE_SIZE * 2 + 1 - 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Invert player and opponent columns.
|
|
|
|
if (cursorColumn >= STRUMLINE_SIZE)
|
|
|
|
{
|
|
|
|
cursorColumn -= STRUMLINE_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cursorColumn += STRUMLINE_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectionBoxStartPos != null)
|
|
|
|
{
|
|
|
|
var cursorXStart:Float = selectionBoxStartPos.x - gridTiledSprite.x;
|
|
|
|
var cursorYStart:Float = selectionBoxStartPos.y - gridTiledSprite.y;
|
|
|
|
|
|
|
|
var hasDraggedMouse:Bool = Math.abs(cursorX - cursorXStart) > DRAG_THRESHOLD || Math.abs(cursorY - cursorYStart) > DRAG_THRESHOLD;
|
|
|
|
|
|
|
|
// Determine if we dragged the mouse at all.
|
|
|
|
if (hasDraggedMouse)
|
|
|
|
{
|
|
|
|
// Handle releasing the selection box.
|
|
|
|
if (FlxG.mouse.justReleased)
|
|
|
|
{
|
|
|
|
// We released the mouse. Select the notes in the box.
|
|
|
|
var cursorFractionalStepStart:Float = cursorYStart / GRID_SIZE;
|
|
|
|
var cursorStepStart:Int = Math.floor(cursorFractionalStepStart);
|
2023-07-19 01:30:36 -04:00
|
|
|
var cursorMsStart:Float = Conductor.getStepTimeInMs(cursorStepStart);
|
2023-01-22 19:55:30 -05:00
|
|
|
var cursorColumnBase:Int = Math.floor(cursorX / GRID_SIZE);
|
|
|
|
var cursorColumnBaseStart:Int = Math.floor(cursorXStart / GRID_SIZE);
|
|
|
|
|
|
|
|
// Since this selects based on noteData directly,
|
|
|
|
// we don't need to specifically exclude sustain pieces.
|
|
|
|
|
|
|
|
// This logic is gross because the columns go 4567-0123-8.
|
|
|
|
// We build a list of columns to select.
|
|
|
|
var columnStart:Int = Std.int(Math.min(cursorColumnBase, cursorColumnBaseStart));
|
|
|
|
var columnEnd:Int = Std.int(Math.max(cursorColumnBase, cursorColumnBaseStart));
|
2023-02-02 18:26:03 -05:00
|
|
|
var columns:Array<Int> = [for (i in columnStart...(columnEnd + 1)) i].map(function(i:Int):Int {
|
2023-01-22 19:55:30 -05:00
|
|
|
if (i >= eventColumn)
|
|
|
|
{
|
|
|
|
// Don't invert the event column.
|
|
|
|
return eventColumn;
|
|
|
|
}
|
|
|
|
else if (i >= STRUMLINE_SIZE)
|
|
|
|
{
|
|
|
|
// Invert the player columns.
|
|
|
|
return i - STRUMLINE_SIZE;
|
|
|
|
}
|
|
|
|
else if (i >= 0)
|
|
|
|
{
|
|
|
|
// Invert the opponent columns.
|
|
|
|
return i + STRUMLINE_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Minimum of 0.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (columns.length > 0)
|
|
|
|
{
|
|
|
|
var notesToSelect:Array<SongNoteData> = currentSongChartNoteData;
|
|
|
|
notesToSelect = SongDataUtils.getNotesInTimeRange(notesToSelect, Math.min(cursorMsStart, cursorMs), Math.max(cursorMsStart, cursorMs));
|
|
|
|
notesToSelect = SongDataUtils.getNotesWithData(notesToSelect, columns);
|
|
|
|
|
|
|
|
var eventsToSelect:Array<SongEventData> = [];
|
|
|
|
|
|
|
|
if (columns.indexOf(eventColumn) != -1)
|
|
|
|
{
|
|
|
|
// The drag selection included the event column.
|
|
|
|
eventsToSelect = currentSongChartEventData;
|
|
|
|
eventsToSelect = SongDataUtils.getEventsInTimeRange(eventsToSelect, Math.min(cursorMsStart, cursorMs), Math.max(cursorMsStart, cursorMs));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (notesToSelect.length > 0 || eventsToSelect.length > 0)
|
|
|
|
{
|
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
// Add to the selection.
|
|
|
|
performCommand(new SelectItemsCommand(notesToSelect, eventsToSelect));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Set the selection.
|
|
|
|
performCommand(new SetItemSelectionCommand(notesToSelect, eventsToSelect, currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We made a selection box, but it didn't select anything.
|
2023-06-08 16:53:52 -04:00
|
|
|
|
|
|
|
if (!FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
// Deselect all items.
|
2023-09-13 14:51:12 -04:00
|
|
|
if (currentNoteSelection.length > 0 || currentEventSelection.length > 0)
|
|
|
|
{
|
|
|
|
trace('Clicked and dragged outside grid, deselecting all items.');
|
|
|
|
performCommand(new DeselectAllItemsCommand(currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We made a selection box, but it didn't select any columns.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear the selection box.
|
|
|
|
selectionBoxStartPos = null;
|
|
|
|
setSelectionBoxBounds();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-09-11 19:42:10 -04:00
|
|
|
// Clicking and dragging.
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
// Scroll the screen if the mouse is above or below the grid.
|
|
|
|
if (FlxG.mouse.screenY < MENU_BAR_HEIGHT)
|
|
|
|
{
|
|
|
|
// Scroll up.
|
|
|
|
var diff:Float = MENU_BAR_HEIGHT - FlxG.mouse.screenY;
|
|
|
|
scrollPositionInPixels -= diff * 0.5; // Too fast!
|
|
|
|
moveSongToScrollPosition();
|
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
else if (FlxG.mouse.screenY > (playbarHeadLayout?.y ?? 0.0))
|
2023-06-08 16:53:52 -04:00
|
|
|
{
|
|
|
|
// Scroll down.
|
2023-08-28 15:03:29 -04:00
|
|
|
var diff:Float = FlxG.mouse.screenY - (playbarHeadLayout?.y ?? 0.0);
|
2023-06-08 16:53:52 -04:00
|
|
|
scrollPositionInPixels += diff * 0.5; // Too fast!
|
|
|
|
moveSongToScrollPosition();
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// Render the selection box.
|
2023-06-08 16:53:52 -04:00
|
|
|
var selectionRect:FlxRect = new FlxRect();
|
2023-01-22 19:55:30 -05:00
|
|
|
selectionRect.x = Math.min(FlxG.mouse.screenX, selectionBoxStartPos.x);
|
|
|
|
selectionRect.y = Math.min(FlxG.mouse.screenY, selectionBoxStartPos.y);
|
|
|
|
selectionRect.width = Math.abs(FlxG.mouse.screenX - selectionBoxStartPos.x);
|
|
|
|
selectionRect.height = Math.abs(FlxG.mouse.screenY - selectionBoxStartPos.y);
|
|
|
|
setSelectionBoxBounds(selectionRect);
|
2023-09-12 18:37:59 -04:00
|
|
|
|
|
|
|
targetCursorMode = Crosshair;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (FlxG.mouse.justReleased)
|
|
|
|
{
|
|
|
|
// Clear the selection box.
|
|
|
|
selectionBoxStartPos = null;
|
|
|
|
setSelectionBoxBounds();
|
|
|
|
|
|
|
|
if (overlapsGrid)
|
|
|
|
{
|
|
|
|
// We clicked on the grid without moving the mouse.
|
|
|
|
|
|
|
|
// Find the first note that is at the cursor position.
|
2023-08-28 15:03:29 -04:00
|
|
|
var highlightedNote:Null<ChartEditorNoteSprite> = renderedNotes.members.find(function(note:ChartEditorNoteSprite):Bool {
|
2023-01-22 19:55:30 -05:00
|
|
|
// If note.alive is false, the note is dead and awaiting recycling.
|
|
|
|
return note.alive && FlxG.mouse.overlaps(note);
|
|
|
|
});
|
2023-08-28 15:03:29 -04:00
|
|
|
var highlightedEvent:Null<ChartEditorEventSprite> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
if (highlightedNote == null)
|
|
|
|
{
|
2023-02-02 18:26:03 -05:00
|
|
|
highlightedEvent = renderedEvents.members.find(function(event:ChartEditorEventSprite):Bool {
|
2023-01-22 19:55:30 -05:00
|
|
|
return event.alive && FlxG.mouse.overlaps(event);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (highlightedNote != null && highlightedNote.noteData != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-07-19 21:16:39 -04:00
|
|
|
// TODO: Handle the case of clicking on a sustain piece.
|
2023-01-22 19:55:30 -05:00
|
|
|
// Control click to select/deselect an individual note.
|
|
|
|
if (isNoteSelected(highlightedNote.noteData))
|
|
|
|
{
|
|
|
|
performCommand(new DeselectItemsCommand([highlightedNote.noteData], []));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand([highlightedNote.noteData], []));
|
|
|
|
}
|
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
else if (highlightedEvent != null && highlightedEvent.eventData != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Control click to select/deselect an individual note.
|
|
|
|
if (isEventSelected(highlightedEvent.eventData))
|
|
|
|
{
|
|
|
|
performCommand(new DeselectItemsCommand([], [highlightedEvent.eventData]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand([], [highlightedEvent.eventData]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Do nothing if you control-clicked on an empty space.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (highlightedNote != null && highlightedNote.noteData != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Click a note to select it.
|
|
|
|
performCommand(new SetItemSelectionCommand([highlightedNote.noteData], [], currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
else if (highlightedEvent != null && highlightedEvent.eventData != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Click an event to select it.
|
|
|
|
performCommand(new SetItemSelectionCommand([], [highlightedEvent.eventData], currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Click on an empty space to deselect everything.
|
|
|
|
performCommand(new DeselectAllItemsCommand(currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
// If we clicked and released outside the grid.
|
|
|
|
|
|
|
|
if (!FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
// Deselect all items.
|
2023-09-13 14:51:12 -04:00
|
|
|
if (currentNoteSelection.length > 0 || currentEventSelection.length > 0)
|
|
|
|
{
|
|
|
|
trace('Clicked outside grid, deselecting all items.');
|
|
|
|
performCommand(new DeselectAllItemsCommand(currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-08-16 03:40:44 -04:00
|
|
|
else if (notePreviewScrollAreaStartPos != null)
|
|
|
|
{
|
2023-09-12 18:37:59 -04:00
|
|
|
// Player is clicking and holding on note preview to scrub around.
|
|
|
|
targetCursorMode = Grabbing;
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var clickedPosInPixels:Float = FlxMath.remapToRange(FlxG.mouse.screenY, (notePreview?.y ?? 0.0),
|
|
|
|
(notePreview?.y ?? 0.0) + (notePreview?.height ?? 0.0), 0, songLengthInPixels);
|
2023-08-16 03:40:44 -04:00
|
|
|
|
|
|
|
scrollPositionInPixels = clickedPosInPixels;
|
|
|
|
moveSongToScrollPosition();
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
else if (currentPlaceNoteData != null)
|
|
|
|
{
|
|
|
|
// Handle extending the note as you drag.
|
|
|
|
|
2023-09-13 14:51:12 -04:00
|
|
|
var stepTime:Float = inline currentPlaceNoteData.getStepTime();
|
|
|
|
var dragLengthSteps:Float = Conductor.getTimeInSteps(cursorSnappedMs) - stepTime;
|
2023-09-11 19:42:10 -04:00
|
|
|
var dragLengthMs:Float = dragLengthSteps * Conductor.stepLengthMs;
|
|
|
|
var dragLengthPixels:Float = dragLengthSteps * GRID_SIZE;
|
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
if (dragLengthSteps > 0)
|
|
|
|
{
|
|
|
|
gridGhostHoldNote.visible = true;
|
|
|
|
gridGhostHoldNote.noteData = gridGhostNote.noteData;
|
|
|
|
gridGhostHoldNote.noteDirection = gridGhostNote.noteData.getDirection();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
gridGhostHoldNote.setHeightDirectly(dragLengthPixels);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
gridGhostHoldNote.updateHoldNotePosition(renderedHoldNotes);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gridGhostHoldNote.visible = false;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
if (FlxG.mouse.justReleased)
|
|
|
|
{
|
|
|
|
if (dragLengthSteps > 0)
|
|
|
|
{
|
|
|
|
// Apply the new length.
|
|
|
|
performCommand(new ExtendNoteLengthCommand(currentPlaceNoteData, dragLengthMs));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finished dragging. Release the note.
|
|
|
|
currentPlaceNoteData = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FlxG.mouse.justPressed)
|
|
|
|
{
|
|
|
|
// Just clicked to place a note.
|
|
|
|
if (overlapsGrid && !overlapsSelectionBorder)
|
|
|
|
{
|
|
|
|
// We clicked on the grid without moving the mouse.
|
|
|
|
|
|
|
|
// Find the first note that is at the cursor position.
|
2023-08-28 15:03:29 -04:00
|
|
|
var highlightedNote:Null<ChartEditorNoteSprite> = renderedNotes.members.find(function(note:ChartEditorNoteSprite):Bool {
|
2023-01-22 19:55:30 -05:00
|
|
|
// If note.alive is false, the note is dead and awaiting recycling.
|
|
|
|
return note.alive && FlxG.mouse.overlaps(note);
|
|
|
|
});
|
2023-08-28 15:03:29 -04:00
|
|
|
var highlightedEvent:Null<ChartEditorEventSprite> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
if (highlightedNote == null)
|
|
|
|
{
|
2023-02-02 18:26:03 -05:00
|
|
|
highlightedEvent = renderedEvents.members.find(function(event:ChartEditorEventSprite):Bool {
|
2023-01-22 19:55:30 -05:00
|
|
|
// If event.alive is false, the event is dead and awaiting recycling.
|
|
|
|
return event.alive && FlxG.mouse.overlaps(event);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
// Control click to select/deselect an individual note.
|
2023-08-28 15:03:29 -04:00
|
|
|
if (highlightedNote != null && highlightedNote.noteData != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
if (isNoteSelected(highlightedNote.noteData))
|
|
|
|
{
|
|
|
|
performCommand(new DeselectItemsCommand([highlightedNote.noteData], []));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand([highlightedNote.noteData], []));
|
|
|
|
}
|
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
else if (highlightedEvent != null && highlightedEvent.eventData != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
if (isEventSelected(highlightedEvent.eventData))
|
|
|
|
{
|
|
|
|
performCommand(new DeselectItemsCommand([], [highlightedEvent.eventData]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand([], [highlightedEvent.eventData]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Do nothing when control clicking nothing.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (highlightedNote != null && highlightedNote.noteData != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Click a note to select it.
|
|
|
|
performCommand(new SetItemSelectionCommand([highlightedNote.noteData], [], currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
else if (highlightedEvent != null && highlightedEvent.eventData != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Click an event to select it.
|
|
|
|
performCommand(new SetItemSelectionCommand([], [highlightedEvent.eventData], currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Click a blank space to place a note and select it.
|
|
|
|
|
|
|
|
if (cursorColumn == eventColumn)
|
|
|
|
{
|
|
|
|
// Create an event and place it in the chart.
|
|
|
|
// TODO: Figure out configuring event data.
|
2023-09-11 18:29:08 -04:00
|
|
|
var newEventData:SongEventData = new SongEventData(cursorSnappedMs, selectedEventKind, selectedEventData);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
performCommand(new AddEventsCommand([newEventData], FlxG.keys.pressed.CONTROL));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Create a note and place it in the chart.
|
2023-09-11 18:29:08 -04:00
|
|
|
var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, selectedNoteKind);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
|
|
|
|
|
|
|
|
currentPlaceNoteData = newNoteData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If we clicked and released outside the grid, do nothing.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var rightMouseUpdated:Bool = (FlxG.mouse.justPressedRight)
|
|
|
|
|| (FlxG.mouse.pressedRight && (FlxG.mouse.deltaX > 0 || FlxG.mouse.deltaY > 0));
|
|
|
|
if (rightMouseUpdated && overlapsGrid)
|
|
|
|
{
|
|
|
|
// We right clicked on the grid.
|
|
|
|
|
|
|
|
// Find the first note that is at the cursor position.
|
2023-08-28 15:03:29 -04:00
|
|
|
var highlightedNote:Null<ChartEditorNoteSprite> = renderedNotes.members.find(function(note:ChartEditorNoteSprite):Bool {
|
2023-01-22 19:55:30 -05:00
|
|
|
// If note.alive is false, the note is dead and awaiting recycling.
|
|
|
|
return note.alive && FlxG.mouse.overlaps(note);
|
|
|
|
});
|
2023-08-28 15:03:29 -04:00
|
|
|
var highlightedEvent:Null<ChartEditorEventSprite> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
if (highlightedNote == null)
|
|
|
|
{
|
2023-02-02 18:26:03 -05:00
|
|
|
highlightedEvent = renderedEvents.members.find(function(event:ChartEditorEventSprite):Bool {
|
2023-01-22 19:55:30 -05:00
|
|
|
// If event.alive is false, the event is dead and awaiting recycling.
|
|
|
|
return event.alive && FlxG.mouse.overlaps(event);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
if (highlightedNote != null && highlightedNote.noteData != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-07-19 21:16:39 -04:00
|
|
|
// TODO: Handle the case of clicking on a sustain piece.
|
2023-01-22 19:55:30 -05:00
|
|
|
// Remove the note.
|
|
|
|
performCommand(new RemoveNotesCommand([highlightedNote.noteData]));
|
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
else if (highlightedEvent != null && highlightedEvent.eventData != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Remove the event.
|
|
|
|
performCommand(new RemoveEventsCommand([highlightedEvent.eventData]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Right clicked on nothing.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle grid cursor.
|
|
|
|
if (overlapsGrid && !overlapsSelectionBorder && !gridPlayheadScrollAreaPressed)
|
|
|
|
{
|
|
|
|
// Indicate that we can place a note here.
|
|
|
|
|
|
|
|
if (cursorColumn == eventColumn)
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (gridGhostNote != null) gridGhostNote.visible = false;
|
2023-09-11 19:42:10 -04:00
|
|
|
gridGhostHoldNote.visible = false;
|
2023-08-28 15:03:29 -04:00
|
|
|
|
|
|
|
if (gridGhostEvent == null) throw "ERROR: Tried to handle cursor, but gridGhostEvent is null! Check ChartEditorState.buildGrid()";
|
|
|
|
|
|
|
|
var eventData:SongEventData = gridGhostEvent.eventData != null ? gridGhostEvent.eventData : new SongEventData(cursorMs, selectedEventKind, null);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
if (selectedEventKind != eventData.event)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
eventData.event = selectedEventKind;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-08-31 23:48:15 -04:00
|
|
|
eventData.time = cursorSnappedMs;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
gridGhostEvent.visible = true;
|
|
|
|
gridGhostEvent.eventData = eventData;
|
2023-01-22 19:55:30 -05:00
|
|
|
gridGhostEvent.updateEventPosition(renderedEvents);
|
2023-09-12 18:37:59 -04:00
|
|
|
|
|
|
|
targetCursorMode = Cell;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (gridGhostEvent != null) gridGhostEvent.visible = false;
|
|
|
|
|
|
|
|
if (gridGhostNote == null) throw "ERROR: Tried to handle cursor, but gridGhostNote is null! Check ChartEditorState.buildGrid()";
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-08 17:41:20 -04:00
|
|
|
var noteData:SongNoteData = gridGhostNote.noteData != null ? gridGhostNote.noteData : new SongNoteData(cursorMs, cursorColumn, 0, selectedNoteKind);
|
2023-08-28 15:03:29 -04:00
|
|
|
|
|
|
|
if (cursorColumn != noteData.data || selectedNoteKind != noteData.kind)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
noteData.kind = selectedNoteKind;
|
|
|
|
noteData.data = cursorColumn;
|
2023-01-22 19:55:30 -05:00
|
|
|
gridGhostNote.playNoteAnimation();
|
|
|
|
}
|
2023-08-31 23:48:15 -04:00
|
|
|
noteData.time = cursorSnappedMs;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
gridGhostNote.visible = true;
|
|
|
|
gridGhostNote.noteData = noteData;
|
2023-01-22 19:55:30 -05:00
|
|
|
gridGhostNote.updateNotePosition(renderedNotes);
|
|
|
|
|
2023-09-12 18:37:59 -04:00
|
|
|
targetCursorMode = Cell;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (gridGhostNote != null) gridGhostNote.visible = false;
|
2023-09-11 19:42:10 -04:00
|
|
|
if (gridGhostHoldNote != null) gridGhostHoldNote.visible = false;
|
2023-08-28 15:03:29 -04:00
|
|
|
if (gridGhostEvent != null) gridGhostEvent.visible = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
2023-09-12 18:37:59 -04:00
|
|
|
|
|
|
|
if (targetCursorMode == null)
|
|
|
|
{
|
|
|
|
if (FlxG.mouse.pressed)
|
|
|
|
{
|
|
|
|
if (overlapsSelectionBorder)
|
|
|
|
{
|
|
|
|
targetCursorMode = Crosshair;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FlxG.mouse.overlaps(notePreview))
|
|
|
|
{
|
|
|
|
targetCursorMode = Pointer;
|
|
|
|
}
|
|
|
|
else if (FlxG.mouse.overlaps(gridPlayheadScrollArea))
|
|
|
|
{
|
|
|
|
targetCursorMode = Pointer;
|
|
|
|
}
|
|
|
|
else if (overlapsSelectionBorder)
|
|
|
|
{
|
|
|
|
targetCursorMode = Crosshair;
|
|
|
|
}
|
|
|
|
else if (overlapsGrid)
|
|
|
|
{
|
|
|
|
targetCursorMode = Cell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Actually set the cursor mode to the one we specified earlier.
|
|
|
|
Cursor.cursorMode = targetCursorMode ?? Default;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (gridGhostNote != null) gridGhostNote.visible = false;
|
2023-09-11 19:42:10 -04:00
|
|
|
if (gridGhostHoldNote != null) gridGhostHoldNote.visible = false;
|
2023-08-28 15:03:29 -04:00
|
|
|
if (gridGhostEvent != null) gridGhostEvent.visible = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-12 18:37:59 -04:00
|
|
|
// Do not set Cursor.cursorMode here, because it will be set by the HaxeUI.
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle using `renderedNotes` to display notes from `currentSongChartNoteData`.
|
|
|
|
*/
|
2023-02-28 13:17:28 -05:00
|
|
|
function handleNoteDisplay():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
if (noteDisplayDirty)
|
|
|
|
{
|
|
|
|
noteDisplayDirty = false;
|
|
|
|
|
|
|
|
// Update for whether downscroll is enabled.
|
|
|
|
renderedNotes.flipX = (isViewDownscroll);
|
|
|
|
|
2023-07-22 20:16:43 -04:00
|
|
|
// Calculate the top and bottom of the view area.
|
|
|
|
var viewAreaTopPixels:Float = MENU_BAR_HEIGHT;
|
|
|
|
var visibleGridHeightPixels:Float = FlxG.height - MENU_BAR_HEIGHT - PLAYBAR_HEIGHT; // The area underneath the menu bar and playbar is not visible.
|
|
|
|
var viewAreaBottomPixels:Float = viewAreaTopPixels + visibleGridHeightPixels;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Remove notes that are no longer visible and list the ones that are.
|
|
|
|
var displayedNoteData:Array<SongNoteData> = [];
|
|
|
|
for (noteSprite in renderedNotes.members)
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (noteSprite == null || noteSprite.noteData == null || !noteSprite.exists || !noteSprite.visible) continue;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-07-22 20:16:43 -04:00
|
|
|
if (!noteSprite.isNoteVisible(viewAreaBottomPixels, viewAreaTopPixels))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// This sprite is off-screen.
|
|
|
|
// Kill the note sprite and recycle it.
|
|
|
|
noteSprite.noteData = null;
|
|
|
|
}
|
2023-09-13 14:51:12 -04:00
|
|
|
else if (!currentSongChartNoteData.fastContains(noteSprite.noteData))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// This note was deleted.
|
|
|
|
// Kill the note sprite and recycle it.
|
|
|
|
noteSprite.noteData = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Note is already displayed and should remain displayed.
|
|
|
|
displayedNoteData.push(noteSprite.noteData);
|
|
|
|
|
|
|
|
// Update the note sprite's position.
|
|
|
|
noteSprite.updateNotePosition(renderedNotes);
|
|
|
|
}
|
|
|
|
}
|
2023-09-13 14:51:12 -04:00
|
|
|
// Sort the note data array, using an algorithm that is fast on nearly-sorted data.
|
|
|
|
// We need this sorted to optimize indexing later.
|
|
|
|
displayedNoteData.insertionSort(SortUtil.noteDataByTime.bind(FlxSort.ASCENDING));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-07-22 20:16:43 -04:00
|
|
|
var displayedHoldNoteData:Array<SongNoteData> = [];
|
|
|
|
for (holdNoteSprite in renderedHoldNotes.members)
|
|
|
|
{
|
2023-08-31 18:47:23 -04:00
|
|
|
if (holdNoteSprite == null || holdNoteSprite.noteData == null || !holdNoteSprite.exists || !holdNoteSprite.visible) continue;
|
2023-07-22 20:16:43 -04:00
|
|
|
|
|
|
|
if (!holdNoteSprite.isHoldNoteVisible(FlxG.height - MENU_BAR_HEIGHT, GRID_TOP_PAD))
|
|
|
|
{
|
|
|
|
holdNoteSprite.kill();
|
|
|
|
}
|
2023-09-13 14:51:12 -04:00
|
|
|
else if (!currentSongChartNoteData.fastContains(holdNoteSprite.noteData) || holdNoteSprite.noteData.length == 0)
|
2023-07-22 20:16:43 -04:00
|
|
|
{
|
|
|
|
// This hold note was deleted.
|
|
|
|
// Kill the hold note sprite and recycle it.
|
|
|
|
holdNoteSprite.kill();
|
|
|
|
}
|
2023-09-13 14:51:12 -04:00
|
|
|
else if (displayedHoldNoteData.fastContains(holdNoteSprite.noteData))
|
2023-07-22 20:16:43 -04:00
|
|
|
{
|
|
|
|
// This hold note is a duplicate.
|
|
|
|
// Kill the hold note sprite and recycle it.
|
|
|
|
holdNoteSprite.kill();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
displayedHoldNoteData.push(holdNoteSprite.noteData);
|
|
|
|
// Update the event sprite's position.
|
|
|
|
holdNoteSprite.updateHoldNotePosition(renderedNotes);
|
|
|
|
}
|
|
|
|
}
|
2023-09-13 14:51:12 -04:00
|
|
|
// Sort the note data array, using an algorithm that is fast on nearly-sorted data.
|
|
|
|
// We need this sorted to optimize indexing later.
|
|
|
|
displayedHoldNoteData.insertionSort(SortUtil.noteDataByTime.bind(FlxSort.ASCENDING));
|
2023-07-22 20:16:43 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// Remove events that are no longer visible and list the ones that are.
|
|
|
|
var displayedEventData:Array<SongEventData> = [];
|
|
|
|
for (eventSprite in renderedEvents.members)
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (eventSprite == null || eventSprite.eventData == null || !eventSprite.exists || !eventSprite.visible) continue;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-07-22 20:16:43 -04:00
|
|
|
if (!eventSprite.isEventVisible(FlxG.height - MENU_BAR_HEIGHT, GRID_TOP_PAD))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// This sprite is off-screen.
|
|
|
|
// Kill the event sprite and recycle it.
|
|
|
|
eventSprite.eventData = null;
|
|
|
|
}
|
2023-09-13 14:51:12 -04:00
|
|
|
else if (!currentSongChartEventData.fastContains(eventSprite.eventData))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// This event was deleted.
|
|
|
|
// Kill the event sprite and recycle it.
|
|
|
|
eventSprite.eventData = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Event is already displayed and should remain displayed.
|
|
|
|
displayedEventData.push(eventSprite.eventData);
|
|
|
|
|
|
|
|
// Update the event sprite's position.
|
|
|
|
eventSprite.updateEventPosition(renderedEvents);
|
|
|
|
}
|
|
|
|
}
|
2023-09-13 14:51:12 -04:00
|
|
|
// Sort the note data array, using an algorithm that is fast on nearly-sorted data.
|
|
|
|
// We need this sorted to optimize indexing later.
|
|
|
|
displayedEventData.insertionSort(SortUtil.eventDataByTime.bind(FlxSort.ASCENDING));
|
|
|
|
|
|
|
|
// Let's try testing only notes within a certain range of the view area.
|
|
|
|
// TODO: I don't think this messes up really long sustains, does it?
|
|
|
|
var viewAreaTopMs:Float = scrollPositionInMs - (Conductor.measureLengthMs * 2); // Is 2 measures enough?
|
|
|
|
var viewAreaBottomMs:Float = scrollPositionInMs + (Conductor.measureLengthMs * 2); // Is 2 measures enough?
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Add notes that are now visible.
|
|
|
|
for (noteData in currentSongChartNoteData)
|
|
|
|
{
|
|
|
|
// Remember if we are already displaying this note.
|
2023-09-13 14:51:12 -04:00
|
|
|
if (noteData == null) continue;
|
|
|
|
// Check if we are outside a broad range around the view area.
|
|
|
|
if (noteData.time < viewAreaTopMs || noteData.time > viewAreaBottomMs) continue;
|
|
|
|
|
|
|
|
if (displayedNoteData.fastContains(noteData))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-07-22 20:16:43 -04:00
|
|
|
if (!ChartEditorNoteSprite.wouldNoteBeVisible(viewAreaBottomPixels, viewAreaTopPixels, noteData,
|
|
|
|
renderedNotes)) continue; // Else, this note is visible and we need to render it!
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Get a note sprite from the pool.
|
|
|
|
// If we can reuse a deleted note, do so.
|
|
|
|
// If a new note is needed, call buildNoteSprite.
|
|
|
|
var noteSprite:ChartEditorNoteSprite = renderedNotes.recycle(() -> new ChartEditorNoteSprite(this));
|
2023-09-13 14:51:12 -04:00
|
|
|
// trace('Creating new Note... (${renderedNotes.members.length})');
|
2023-01-22 19:55:30 -05:00
|
|
|
noteSprite.parentState = this;
|
|
|
|
|
2023-09-08 17:41:20 -04:00
|
|
|
// The note sprite handles animation playback and positioning.
|
|
|
|
noteSprite.noteData = noteData;
|
|
|
|
|
2023-09-11 17:42:46 -04:00
|
|
|
// Setting note data resets the position relative to the group!
|
|
|
|
// If we don't update the note position AFTER setting the note data, the note will be rendered offscreen at y=5000.
|
|
|
|
noteSprite.updateNotePosition(renderedNotes);
|
|
|
|
|
2023-07-22 20:16:43 -04:00
|
|
|
// Add hold notes that are now visible (and not already displayed).
|
2023-08-28 15:03:29 -04:00
|
|
|
if (noteSprite.noteData != null && noteSprite.noteData.length > 0 && displayedHoldNoteData.indexOf(noteSprite.noteData) == -1)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-07-22 20:16:43 -04:00
|
|
|
var holdNoteSprite:ChartEditorHoldNoteSprite = renderedHoldNotes.recycle(() -> new ChartEditorHoldNoteSprite(this));
|
2023-09-13 14:51:12 -04:00
|
|
|
// trace('Creating new HoldNote... (${renderedHoldNotes.members.length})');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-13 14:51:12 -04:00
|
|
|
var noteLengthPixels:Float = noteSprite.noteData.getStepLength() * GRID_SIZE;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-07-22 20:16:43 -04:00
|
|
|
holdNoteSprite.noteData = noteSprite.noteData;
|
|
|
|
holdNoteSprite.noteDirection = noteSprite.noteData.getDirection();
|
|
|
|
|
|
|
|
holdNoteSprite.setHeightDirectly(noteLengthPixels);
|
|
|
|
|
|
|
|
holdNoteSprite.updateHoldNotePosition(renderedHoldNotes);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add events that are now visible.
|
|
|
|
for (eventData in currentSongChartEventData)
|
|
|
|
{
|
|
|
|
// Remember if we are already displaying this event.
|
|
|
|
if (displayedEventData.indexOf(eventData) != -1)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-07-22 20:16:43 -04:00
|
|
|
if (!ChartEditorEventSprite.wouldEventBeVisible(viewAreaBottomPixels, viewAreaTopPixels, eventData, renderedNotes)) continue;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Else, this event is visible and we need to render it!
|
|
|
|
|
|
|
|
// Get an event sprite from the pool.
|
|
|
|
// If we can reuse a deleted event, do so.
|
|
|
|
// If a new event is needed, call buildEventSprite.
|
2023-07-19 01:30:36 -04:00
|
|
|
var eventSprite:ChartEditorEventSprite = renderedEvents.recycle(() -> new ChartEditorEventSprite(this), false, true);
|
2023-01-22 19:55:30 -05:00
|
|
|
eventSprite.parentState = this;
|
2023-07-22 20:16:43 -04:00
|
|
|
trace('Creating new Event... (${renderedEvents.members.length})');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// The event sprite handles animation playback and positioning.
|
|
|
|
eventSprite.eventData = eventData;
|
|
|
|
|
|
|
|
// Setting event data resets position relative to the grid so we fix that.
|
|
|
|
eventSprite.x += renderedEvents.x;
|
|
|
|
eventSprite.y += renderedEvents.y;
|
|
|
|
}
|
|
|
|
|
2023-07-22 20:16:43 -04:00
|
|
|
// Add hold notes that have been made visible (but not their parents)
|
|
|
|
for (noteData in currentSongChartNoteData)
|
|
|
|
{
|
|
|
|
// Is the note a hold note?
|
2023-08-28 15:03:29 -04:00
|
|
|
if (noteData == null || noteData.length <= 0) continue;
|
2023-07-22 20:16:43 -04:00
|
|
|
|
|
|
|
// Is the hold note rendered already?
|
|
|
|
if (displayedHoldNoteData.indexOf(noteData) != -1) continue;
|
|
|
|
|
|
|
|
// Is the hold note offscreen?
|
|
|
|
if (!ChartEditorHoldNoteSprite.wouldHoldNoteBeVisible(viewAreaBottomPixels, viewAreaTopPixels, noteData, renderedHoldNotes)) continue;
|
|
|
|
|
|
|
|
// Hold note should be rendered.
|
2023-07-25 23:11:12 -04:00
|
|
|
var holdNoteFactory = function() {
|
|
|
|
// TODO: Print some kind of warning if `renderedHoldNotes.members` is too high?
|
|
|
|
return new ChartEditorHoldNoteSprite(this);
|
|
|
|
}
|
|
|
|
var holdNoteSprite:ChartEditorHoldNoteSprite = renderedHoldNotes.recycle(holdNoteFactory);
|
2023-07-22 20:16:43 -04:00
|
|
|
|
2023-09-13 14:51:12 -04:00
|
|
|
var noteLengthPixels:Float = noteData.getStepLength() * GRID_SIZE;
|
2023-07-22 20:16:43 -04:00
|
|
|
|
|
|
|
holdNoteSprite.noteData = noteData;
|
|
|
|
holdNoteSprite.noteDirection = noteData.getDirection();
|
|
|
|
|
|
|
|
holdNoteSprite.setHeightDirectly(noteLengthPixels);
|
|
|
|
|
|
|
|
holdNoteSprite.updateHoldNotePosition(renderedHoldNotes);
|
|
|
|
|
|
|
|
displayedHoldNoteData.push(noteData);
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// Destroy all existing selection squares.
|
|
|
|
for (member in renderedSelectionSquares.members)
|
|
|
|
{
|
|
|
|
// Killing the sprite is cheap because we can recycle it.
|
|
|
|
member.kill();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Readd selection squares for selected notes.
|
|
|
|
// Recycle selection squares if possible.
|
|
|
|
for (noteSprite in renderedNotes.members)
|
|
|
|
{
|
2023-07-19 21:16:39 -04:00
|
|
|
// TODO: Handle selection of hold notes.
|
|
|
|
if (isNoteSelected(noteSprite.noteData))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
var selectionSquare:FlxSprite = renderedSelectionSquares.recycle(buildSelectionSquare);
|
|
|
|
|
|
|
|
// Set the position and size (because we might be recycling one with bad values).
|
|
|
|
selectionSquare.x = noteSprite.x;
|
|
|
|
selectionSquare.y = noteSprite.y;
|
2023-09-26 20:36:41 -04:00
|
|
|
selectionSquare.width = GRID_SIZE;
|
|
|
|
selectionSquare.height = GRID_SIZE;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (eventSprite in renderedEvents.members)
|
|
|
|
{
|
|
|
|
if (isEventSelected(eventSprite.eventData))
|
|
|
|
{
|
|
|
|
var selectionSquare:FlxSprite = renderedSelectionSquares.recycle(buildSelectionSquare);
|
|
|
|
|
|
|
|
// Set the position and size (because we might be recycling one with bad values).
|
|
|
|
selectionSquare.x = eventSprite.x;
|
|
|
|
selectionSquare.y = eventSprite.y;
|
|
|
|
selectionSquare.width = eventSprite.width;
|
|
|
|
selectionSquare.height = eventSprite.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort the notes DESCENDING. This keeps the sustain behind the associated note.
|
2023-09-12 18:37:59 -04:00
|
|
|
renderedNotes.sort(FlxSort.byY, FlxSort.DESCENDING); // TODO: .group.insertionSort()
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Sort the events DESCENDING. This keeps the sustain behind the associated note.
|
2023-09-12 18:37:59 -04:00
|
|
|
renderedEvents.sort(FlxSort.byY, FlxSort.DESCENDING); // TODO: .group.insertionSort()
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-07-25 23:11:12 -04:00
|
|
|
|
|
|
|
// Add a debug value which displays the current size of the note pool.
|
|
|
|
// The pool will grow as more notes need to be rendered at once.
|
|
|
|
// If this gets too big, something needs to be optimized somewhere! -Eric
|
|
|
|
FlxG.watch.addQuick("tapNotesRendered", renderedNotes.members.length);
|
|
|
|
FlxG.watch.addQuick("holdNotesRendered", renderedHoldNotes.members.length);
|
2023-09-18 20:02:17 -04:00
|
|
|
FlxG.watch.addQuick("eventsRendered", renderedEvents.members.length);
|
2023-09-26 20:36:41 -04:00
|
|
|
FlxG.watch.addQuick("notesSelected", currentNoteSelection.length);
|
|
|
|
FlxG.watch.addQuick("eventsSelected", currentEventSelection.length);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-09-13 14:51:12 -04:00
|
|
|
/**
|
|
|
|
* Handle aligning the health icons next to the grid.
|
|
|
|
*/
|
|
|
|
function handleHealthIcons():Void
|
|
|
|
{
|
2023-09-26 17:46:07 -04:00
|
|
|
if (healthIconsDirty)
|
|
|
|
{
|
|
|
|
if (healthIconBF != null) healthIconBF.characterId = currentSongMetadata.playData.characters.player;
|
|
|
|
if (healthIconDad != null) healthIconDad.characterId = currentSongMetadata.playData.characters.opponent;
|
|
|
|
}
|
|
|
|
|
2023-09-13 14:51:12 -04:00
|
|
|
// Right align the BF health icon.
|
|
|
|
if (healthIconBF != null)
|
|
|
|
{
|
|
|
|
// Base X position to the right of the grid.
|
|
|
|
var baseHealthIconXPos:Float = (gridTiledSprite == null) ? (0) : (gridTiledSprite.x + gridTiledSprite.width + 15);
|
|
|
|
// Will be 0 when not bopping. When bopping, will increase to push the icon left.
|
|
|
|
var healthIconOffset:Float = healthIconBF.width - (HealthIcon.HEALTH_ICON_SIZE * 0.5);
|
|
|
|
healthIconBF.x = baseHealthIconXPos - healthIconOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
function buildSelectionSquare():FlxSprite
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (selectionSquareBitmap == null)
|
|
|
|
throw "ERROR: Tried to build selection square, but selectionSquareBitmap is null! Check ChartEditorThemeHandler.updateSelectionSquare()";
|
|
|
|
|
2023-09-26 20:36:41 -04:00
|
|
|
FlxG.bitmapLog.add(selectionSquareBitmap, "selectionSquareBitmap");
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
return new FlxSprite().loadGraphic(selectionSquareBitmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles display elements for the playbar at the bottom.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function handlePlaybar():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (playbarHeadLayout == null) throw "ERROR: Tried to handle playbar, but playbarHeadLayout is null!";
|
|
|
|
if (playbarHead == null) throw "ERROR: Tried to handle playbar, but playbarHeadLayout is null!";
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// Make sure the playbar is never nudged out of the correct spot.
|
|
|
|
playbarHeadLayout.x = 4;
|
|
|
|
playbarHeadLayout.y = FlxG.height - 48 - 8;
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
var songPos:Float = Conductor.songPosition;
|
|
|
|
var songRemaining:Float = Math.max(songLengthInMs - songPos, 0.0);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Move the playhead to match the song position, if we aren't dragging it.
|
|
|
|
if (!playbarHeadDragging)
|
|
|
|
{
|
2023-09-13 14:51:12 -04:00
|
|
|
var songPosPercent:Float = songPos / songLengthInMs * 100;
|
|
|
|
if (playbarHead.value != songPosPercent) playbarHead.value = songPosPercent;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
var songPosSeconds:String = Std.string(Math.floor((songPos / 1000) % 60)).lpad('0', 2);
|
|
|
|
var songPosMinutes:String = Std.string(Math.floor((songPos / 1000) / 60)).lpad('0', 2);
|
|
|
|
var songPosString:String = '${songPosMinutes}:${songPosSeconds}';
|
|
|
|
|
2023-09-13 14:51:12 -04:00
|
|
|
if (playbarSongPos == null) playbarSongPos = findComponent('playbarSongPos', Label);
|
|
|
|
if (playbarSongPos != null && playbarSongPos.value != songPosString) playbarSongPos.value = songPosString;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
var songRemainingSeconds:String = Std.string(Math.floor((songRemaining / 1000) % 60)).lpad('0', 2);
|
|
|
|
var songRemainingMinutes:String = Std.string(Math.floor((songRemaining / 1000) / 60)).lpad('0', 2);
|
|
|
|
var songRemainingString:String = '-${songRemainingMinutes}:${songRemainingSeconds}';
|
|
|
|
|
2023-09-13 14:51:12 -04:00
|
|
|
if (playbarSongRemaining == null) playbarSongRemaining = findComponent('playbarSongRemaining', Label);
|
|
|
|
if (playbarSongRemaining != null
|
|
|
|
&& playbarSongRemaining.value != songRemainingString) playbarSongRemaining.value = songRemainingString;
|
2023-09-08 16:44:10 -04:00
|
|
|
|
2023-09-13 14:51:12 -04:00
|
|
|
if (playbarNoteSnap == null) playbarNoteSnap = findComponent('playbarNoteSnap', Label);
|
|
|
|
if (playbarNoteSnap != null && playbarNoteSnap.value != '1/${noteSnapQuant}') playbarNoteSnap.value = '1/${noteSnapQuant}';
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle keybinds for File menu items.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function handleFileKeybinds():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-09-04 15:33:08 -04:00
|
|
|
// CTRL + N = New Chart
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.N)
|
|
|
|
{
|
|
|
|
ChartEditorDialogHandler.openWelcomeDialog(this, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// CTRL + O = Open Chart
|
2023-09-12 22:34:49 -04:00
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.O)
|
2023-09-04 15:33:08 -04:00
|
|
|
{
|
|
|
|
ChartEditorDialogHandler.openBrowseWizard(this, true);
|
|
|
|
}
|
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
// CTRL + SHIFT + S = Save As
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.pressed.SHIFT && FlxG.keys.justPressed.S)
|
|
|
|
{
|
|
|
|
ChartEditorImportExportHandler.exportAllSongData(this, false);
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// CTRL + Q = Quit to Menu
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.Q)
|
|
|
|
{
|
|
|
|
FlxG.switchState(new MainMenuState());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle keybinds for edit menu items.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function handleEditKeybinds():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// CTRL + Z = Undo
|
2023-02-28 21:06:09 -05:00
|
|
|
if (undoKeyHandler.activated)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
undoLastCommand();
|
|
|
|
}
|
|
|
|
|
|
|
|
// CTRL + Y = Redo
|
2023-02-28 21:06:09 -05:00
|
|
|
if (redoKeyHandler.activated)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
redoLastCommand();
|
|
|
|
}
|
|
|
|
|
|
|
|
// CTRL + C = Copy
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.C)
|
|
|
|
{
|
|
|
|
// Copy selected notes.
|
|
|
|
// We don't need a command for this since we can't undo it.
|
2023-01-22 22:25:45 -05:00
|
|
|
SongDataUtils.writeItemsToClipboard(
|
|
|
|
{
|
|
|
|
notes: SongDataUtils.buildNoteClipboard(currentNoteSelection),
|
|
|
|
events: SongDataUtils.buildEventClipboard(currentEventSelection),
|
|
|
|
});
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// CTRL + X = Cut
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.X)
|
|
|
|
{
|
|
|
|
// Cut selected notes.
|
|
|
|
performCommand(new CutItemsCommand(currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
|
|
|
|
|
|
|
// CTRL + V = Paste
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.V)
|
|
|
|
{
|
2023-09-26 20:36:41 -04:00
|
|
|
// CTRL + SHIFT + V = Paste Unsnapped.
|
|
|
|
var targetMs:Float = if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
scrollPositionInMs + playheadPositionInMs;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var targetMs:Float = scrollPositionInMs + playheadPositionInMs;
|
|
|
|
var targetStep:Float = Conductor.getTimeInSteps(targetMs);
|
|
|
|
var targetSnappedStep:Float = Math.floor(targetStep / noteSnapRatio) * noteSnapRatio;
|
|
|
|
var targetSnappedMs:Float = Conductor.getStepTimeInMs(targetSnappedStep);
|
|
|
|
targetSnappedMs;
|
|
|
|
}
|
|
|
|
performCommand(new PasteItemsCommand(targetMs));
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// DELETE = Delete
|
|
|
|
if (FlxG.keys.justPressed.DELETE)
|
|
|
|
{
|
|
|
|
// Delete selected items.
|
|
|
|
if (currentNoteSelection.length > 0 && currentEventSelection.length > 0)
|
|
|
|
{
|
|
|
|
performCommand(new RemoveItemsCommand(currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
|
|
|
else if (currentNoteSelection.length > 0)
|
|
|
|
{
|
|
|
|
performCommand(new RemoveNotesCommand(currentNoteSelection));
|
|
|
|
}
|
|
|
|
else if (currentEventSelection.length > 0)
|
|
|
|
{
|
|
|
|
performCommand(new RemoveEventsCommand(currentEventSelection));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CTRL + A = Select All
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.A)
|
|
|
|
{
|
|
|
|
// Select all items.
|
|
|
|
performCommand(new SelectAllItemsCommand(currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
|
|
|
|
|
|
|
// CTRL + I = Select Inverse
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.I)
|
|
|
|
{
|
|
|
|
// Select unselected items and deselect selected items.
|
|
|
|
performCommand(new InvertSelectedItemsCommand(currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
|
|
|
|
|
|
|
// CTRL + D = Select None
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.D)
|
|
|
|
{
|
|
|
|
// Deselect all items.
|
|
|
|
performCommand(new DeselectAllItemsCommand(currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle keybinds for View menu items.
|
|
|
|
*/
|
2023-08-14 23:13:12 -04:00
|
|
|
function handleViewKeybinds():Void
|
|
|
|
{
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.LEFT)
|
|
|
|
{
|
|
|
|
incrementDifficulty(-1);
|
|
|
|
}
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.RIGHT)
|
|
|
|
{
|
|
|
|
incrementDifficulty(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function incrementDifficulty(change:Int):Void
|
|
|
|
{
|
|
|
|
var currentDifficultyIndex:Int = availableDifficulties.indexOf(selectedDifficulty);
|
|
|
|
var currentAllDifficultyIndex:Int = allDifficulties.indexOf(selectedDifficulty);
|
|
|
|
|
|
|
|
if (currentDifficultyIndex == -1 || currentAllDifficultyIndex == -1)
|
|
|
|
{
|
|
|
|
trace('ERROR determining difficulty index!');
|
|
|
|
}
|
|
|
|
|
|
|
|
var isFirstDiff:Bool = currentAllDifficultyIndex == 0;
|
|
|
|
var isLastDiff:Bool = (currentAllDifficultyIndex == allDifficulties.length - 1);
|
|
|
|
|
|
|
|
var isFirstDiffInVariation:Bool = currentDifficultyIndex == 0;
|
|
|
|
var isLastDiffInVariation:Bool = (currentDifficultyIndex == availableDifficulties.length - 1);
|
|
|
|
|
|
|
|
trace(allDifficulties);
|
|
|
|
|
|
|
|
if (change < 0 && isFirstDiff)
|
|
|
|
{
|
|
|
|
trace('At lowest difficulty! Do nothing.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (change > 0 && isLastDiff)
|
|
|
|
{
|
|
|
|
trace('At highest difficulty! Do nothing.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (change < 0)
|
|
|
|
{
|
2023-08-15 16:08:12 -04:00
|
|
|
trace('Decrement difficulty.');
|
|
|
|
|
2023-08-14 23:13:12 -04:00
|
|
|
// If we reached this point, we are not at the lowest difficulty.
|
|
|
|
if (isFirstDiffInVariation)
|
|
|
|
{
|
|
|
|
// Go to the previous variation, then last difficulty in that variation.
|
|
|
|
var currentVariationIndex:Int = availableVariations.indexOf(selectedVariation);
|
|
|
|
var prevVariation = availableVariations[currentVariationIndex - 1];
|
|
|
|
selectedVariation = prevVariation;
|
|
|
|
|
|
|
|
var prevDifficulty = availableDifficulties[availableDifficulties.length - 1];
|
|
|
|
selectedDifficulty = prevDifficulty;
|
|
|
|
|
|
|
|
refreshDifficultyTreeSelection();
|
2023-09-25 23:24:07 -04:00
|
|
|
refreshMetadataToolbox();
|
2023-08-14 23:13:12 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Go to previous difficulty in this variation.
|
|
|
|
var prevDifficulty = availableDifficulties[currentDifficultyIndex - 1];
|
|
|
|
selectedDifficulty = prevDifficulty;
|
|
|
|
|
|
|
|
refreshDifficultyTreeSelection();
|
2023-09-25 23:24:07 -04:00
|
|
|
refreshMetadataToolbox();
|
2023-08-14 23:13:12 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-15 16:08:12 -04:00
|
|
|
trace('Increment difficulty.');
|
|
|
|
|
2023-08-14 23:13:12 -04:00
|
|
|
// If we reached this point, we are not at the highest difficulty.
|
|
|
|
if (isLastDiffInVariation)
|
|
|
|
{
|
|
|
|
// Go to next variation, then first difficulty in that variation.
|
|
|
|
var currentVariationIndex:Int = availableVariations.indexOf(selectedVariation);
|
|
|
|
var nextVariation = availableVariations[currentVariationIndex + 1];
|
|
|
|
selectedVariation = nextVariation;
|
|
|
|
|
|
|
|
var nextDifficulty = availableDifficulties[0];
|
|
|
|
selectedDifficulty = nextDifficulty;
|
2023-08-15 16:08:12 -04:00
|
|
|
|
|
|
|
refreshDifficultyTreeSelection();
|
2023-09-25 23:24:07 -04:00
|
|
|
refreshMetadataToolbox();
|
2023-08-14 23:13:12 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Go to next difficulty in this variation.
|
|
|
|
var nextDifficulty = availableDifficulties[currentDifficultyIndex + 1];
|
|
|
|
selectedDifficulty = nextDifficulty;
|
2023-08-15 16:08:12 -04:00
|
|
|
|
|
|
|
refreshDifficultyTreeSelection();
|
2023-09-25 23:24:07 -04:00
|
|
|
refreshMetadataToolbox();
|
2023-08-14 23:13:12 -04:00
|
|
|
}
|
|
|
|
}
|
2023-09-08 16:44:10 -04:00
|
|
|
|
|
|
|
#if !mac
|
|
|
|
NotificationManager.instance.addNotification(
|
|
|
|
{
|
|
|
|
title: 'Switch Difficulty',
|
|
|
|
body: 'Switched difficulty to ${selectedDifficulty.toTitleCase()}',
|
|
|
|
type: NotificationType.Success,
|
|
|
|
expiryMs: ChartEditorState.NOTIFICATION_DISMISS_TIME
|
|
|
|
});
|
|
|
|
#end
|
2023-08-14 23:13:12 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-07-26 16:52:58 -04:00
|
|
|
/**
|
|
|
|
* Handle keybinds for the Test menu items.
|
|
|
|
*/
|
|
|
|
function handleTestKeybinds():Void
|
|
|
|
{
|
2023-08-04 11:18:00 -04:00
|
|
|
if (!isHaxeUIDialogOpen && FlxG.keys.justPressed.ENTER)
|
2023-07-26 16:52:58 -04:00
|
|
|
{
|
|
|
|
var minimal = FlxG.keys.pressed.SHIFT;
|
|
|
|
testSongInPlayState(minimal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Handle keybinds for Help menu items.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function handleHelpKeybinds():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// F1 = Open Help
|
2023-01-22 22:25:45 -05:00
|
|
|
if (FlxG.keys.justPressed.F1) ChartEditorDialogHandler.openUserGuideDialog(this);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function handleToolboxes():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
handleDifficultyToolbox();
|
|
|
|
handlePlayerPreviewToolbox();
|
|
|
|
handleOpponentPreviewToolbox();
|
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function handleDifficultyToolbox():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
if (difficultySelectDirty)
|
|
|
|
{
|
|
|
|
difficultySelectDirty = false;
|
|
|
|
|
|
|
|
// Manage the Select Difficulty tree view.
|
2023-08-31 18:47:23 -04:00
|
|
|
var difficultyToolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
|
|
|
if (difficultyToolbox == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var treeView:Null<TreeView> = difficultyToolbox.findComponent('difficultyToolboxTree');
|
2023-01-22 22:25:45 -05:00
|
|
|
if (treeView == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Clear the tree view so we can rebuild it.
|
|
|
|
treeView.clearNodes();
|
|
|
|
|
2023-08-14 23:13:12 -04:00
|
|
|
// , icon: 'haxeui-core/styles/default/haxeui_tiny.png'
|
|
|
|
var treeSong:TreeViewNode = treeView.addNode({id: 'stv_song', text: 'S: $currentSongName'});
|
2023-01-22 19:55:30 -05:00
|
|
|
treeSong.expanded = true;
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
for (curVariation in availableVariations)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
var variationMetadata:Null<SongMetadata> = songMetadata.get(curVariation);
|
|
|
|
if (variationMetadata == null) continue;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
var treeVariation:TreeViewNode = treeSong.addNode(
|
2023-01-22 22:25:45 -05:00
|
|
|
{
|
|
|
|
id: 'stv_variation_$curVariation',
|
2023-06-08 16:53:52 -04:00
|
|
|
text: 'V: ${curVariation.toTitleCase()}'
|
2023-01-22 22:25:45 -05:00
|
|
|
});
|
2023-01-22 19:55:30 -05:00
|
|
|
treeVariation.expanded = true;
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
var difficultyList:Array<String> = variationMetadata.playData.difficulties;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
for (difficulty in difficultyList)
|
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
var _treeDifficulty:TreeViewNode = treeVariation.addNode(
|
2023-01-22 22:25:45 -05:00
|
|
|
{
|
|
|
|
id: 'stv_difficulty_${curVariation}_$difficulty',
|
2023-06-08 16:53:52 -04:00
|
|
|
text: 'D: ${difficulty.toTitleCase()}'
|
2023-01-22 22:25:45 -05:00
|
|
|
});
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
treeView.onChange = onChangeTreeDifficulty;
|
2023-08-14 23:13:12 -04:00
|
|
|
refreshDifficultyTreeSelection(treeView);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
public function createDifficulty(variation:String, difficulty:String, scrollSpeed:Float = 1.0)
|
|
|
|
{
|
|
|
|
var variationMetadata:Null<SongMetadata> = songMetadata.get(variation);
|
|
|
|
if (variationMetadata == null) return;
|
|
|
|
|
|
|
|
variationMetadata.playData.difficulties.push(difficulty);
|
|
|
|
|
|
|
|
var resultChartData = songChartData.get(variation);
|
|
|
|
if (resultChartData == null)
|
|
|
|
{
|
|
|
|
resultChartData = new SongChartData([difficulty => scrollSpeed], [], [difficulty => []]);
|
|
|
|
songChartData.set(variation, resultChartData);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resultChartData.scrollSpeed.set(difficulty, scrollSpeed);
|
|
|
|
resultChartData.notes.set(difficulty, []);
|
|
|
|
}
|
|
|
|
|
|
|
|
difficultySelectDirty = true; // Force the Difficulty toolbox to update.
|
|
|
|
}
|
|
|
|
|
2023-08-14 23:13:12 -04:00
|
|
|
function refreshDifficultyTreeSelection(?treeView:TreeView):Void
|
|
|
|
{
|
|
|
|
if (treeView == null)
|
|
|
|
{
|
|
|
|
// Manage the Select Difficulty tree view.
|
2023-08-31 18:47:23 -04:00
|
|
|
var difficultyToolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
2023-08-14 23:13:12 -04:00
|
|
|
if (difficultyToolbox == null) return;
|
|
|
|
|
|
|
|
treeView = difficultyToolbox.findComponent('difficultyToolboxTree');
|
|
|
|
if (treeView == null) return;
|
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var currentTreeDifficultyNode = getCurrentTreeDifficultyNode(treeView);
|
|
|
|
if (currentTreeDifficultyNode != null) treeView.selectedNode = currentTreeDifficultyNode;
|
2023-08-14 23:13:12 -04:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function handlePlayerPreviewToolbox():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Manage the Select Difficulty tree view.
|
2023-08-31 18:47:23 -04:00
|
|
|
var charPreviewToolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT);
|
2023-01-22 22:25:45 -05:00
|
|
|
if (charPreviewToolbox == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-13 14:51:12 -04:00
|
|
|
// TODO: Re-enable the player preview once we figure out the performance issues.
|
|
|
|
var charPlayer:Null<CharacterPlayer> = null; // charPreviewToolbox.findComponent('charPlayer');
|
2023-01-22 22:25:45 -05:00
|
|
|
if (charPlayer == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
currentPlayerCharacterPlayer = charPlayer;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
|
|
|
if (playerPreviewDirty)
|
|
|
|
{
|
|
|
|
playerPreviewDirty = false;
|
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
if (currentSongMetadata.playData.characters.player != charPlayer.charId)
|
2023-06-08 16:53:52 -04:00
|
|
|
{
|
2023-09-26 17:46:07 -04:00
|
|
|
if (healthIconBF != null) healthIconBF.characterId = currentSongMetadata.playData.characters.player;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
charPlayer.loadCharacter(currentSongMetadata.playData.characters.player);
|
2023-06-08 16:53:52 -04:00
|
|
|
charPlayer.characterType = CharacterType.BF;
|
|
|
|
charPlayer.flip = true;
|
|
|
|
charPlayer.targetScale = 0.5;
|
|
|
|
|
|
|
|
charPreviewToolbox.title = 'Player Preview - ${charPlayer.charName}';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (charPreviewToolbox != null && !charPreviewToolbox.minimized)
|
|
|
|
{
|
|
|
|
charPreviewToolbox.width = charPlayer.width + 32;
|
|
|
|
charPreviewToolbox.height = charPlayer.height + 64;
|
|
|
|
}
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function handleOpponentPreviewToolbox():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Manage the Select Difficulty tree view.
|
2023-08-31 18:47:23 -04:00
|
|
|
var charPreviewToolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT);
|
2023-01-22 22:25:45 -05:00
|
|
|
if (charPreviewToolbox == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-13 14:51:12 -04:00
|
|
|
// TODO: Re-enable the player preview once we figure out the performance issues.
|
|
|
|
var charPlayer:Null<CharacterPlayer> = null; // charPreviewToolbox.findComponent('charPlayer');
|
2023-01-22 22:25:45 -05:00
|
|
|
if (charPlayer == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
currentOpponentCharacterPlayer = charPlayer;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
|
|
|
if (opponentPreviewDirty)
|
|
|
|
{
|
|
|
|
opponentPreviewDirty = false;
|
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
if (currentSongMetadata.playData.characters.opponent != charPlayer.charId)
|
2023-06-08 16:53:52 -04:00
|
|
|
{
|
2023-09-26 17:46:07 -04:00
|
|
|
if (healthIconDad != null) healthIconDad.characterId = currentSongMetadata.playData.characters.opponent;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
charPlayer.loadCharacter(currentSongMetadata.playData.characters.opponent);
|
2023-06-08 16:53:52 -04:00
|
|
|
charPlayer.characterType = CharacterType.DAD;
|
|
|
|
charPlayer.flip = false;
|
|
|
|
charPlayer.targetScale = 0.5;
|
|
|
|
|
|
|
|
charPreviewToolbox.title = 'Opponent Preview - ${charPlayer.charName}';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (charPreviewToolbox != null && !charPreviewToolbox.minimized)
|
|
|
|
{
|
|
|
|
charPreviewToolbox.width = charPlayer.width + 32;
|
|
|
|
charPreviewToolbox.height = charPlayer.height + 64;
|
|
|
|
}
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-06-16 17:37:56 -04:00
|
|
|
public override function dispatchEvent(event:ScriptEvent):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
super.dispatchEvent(event);
|
|
|
|
|
|
|
|
// We can't use the ScriptedEventDispatcher with currentCharPlayer because we can't use the IScriptedClass interface on it.
|
|
|
|
if (currentPlayerCharacterPlayer != null)
|
|
|
|
{
|
|
|
|
switch (event.type)
|
|
|
|
{
|
|
|
|
case ScriptEvent.UPDATE:
|
|
|
|
currentPlayerCharacterPlayer.onUpdate(cast event);
|
|
|
|
case ScriptEvent.SONG_BEAT_HIT:
|
|
|
|
currentPlayerCharacterPlayer.onBeatHit(cast event);
|
|
|
|
case ScriptEvent.SONG_STEP_HIT:
|
|
|
|
currentPlayerCharacterPlayer.onStepHit(cast event);
|
|
|
|
case ScriptEvent.NOTE_HIT:
|
|
|
|
currentPlayerCharacterPlayer.onNoteHit(cast event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentOpponentCharacterPlayer != null)
|
|
|
|
{
|
|
|
|
switch (event.type)
|
|
|
|
{
|
|
|
|
case ScriptEvent.UPDATE:
|
|
|
|
currentOpponentCharacterPlayer.onUpdate(cast event);
|
|
|
|
case ScriptEvent.SONG_BEAT_HIT:
|
|
|
|
currentOpponentCharacterPlayer.onBeatHit(cast event);
|
|
|
|
case ScriptEvent.SONG_STEP_HIT:
|
|
|
|
currentOpponentCharacterPlayer.onStepHit(cast event);
|
|
|
|
case ScriptEvent.NOTE_HIT:
|
|
|
|
currentOpponentCharacterPlayer.onNoteHit(cast event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
function getCurrentTreeDifficultyNode(?treeView:TreeView = null):Null<TreeViewNode>
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-14 23:13:12 -04:00
|
|
|
if (treeView == null)
|
|
|
|
{
|
2023-08-31 18:47:23 -04:00
|
|
|
var difficultyToolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
2023-08-14 23:13:12 -04:00
|
|
|
if (difficultyToolbox == null) return null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-14 23:13:12 -04:00
|
|
|
treeView = difficultyToolbox.findComponent('difficultyToolboxTree');
|
|
|
|
if (treeView == null) return null;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
var result:TreeViewNode = treeView.findNodeByPath('stv_song/stv_variation_$selectedVariation/stv_difficulty_${selectedVariation}_$selectedDifficulty',
|
|
|
|
'id');
|
2023-01-22 22:25:45 -05:00
|
|
|
if (result == null) return null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-08-14 23:13:12 -04:00
|
|
|
/**
|
|
|
|
* Called when selecting a tree element in the Difficulty toolbox.
|
|
|
|
* @param event The click event.
|
|
|
|
*/
|
2023-01-22 19:55:30 -05:00
|
|
|
function onChangeTreeDifficulty(event:UIEvent):Void
|
|
|
|
{
|
|
|
|
// Get the newly selected node.
|
|
|
|
var treeView:TreeView = cast event.target;
|
|
|
|
var targetNode:TreeViewNode = treeView.selectedNode;
|
|
|
|
|
|
|
|
if (targetNode == null)
|
|
|
|
{
|
|
|
|
trace('No target node!');
|
|
|
|
// Reset the user's selection.
|
2023-08-28 15:03:29 -04:00
|
|
|
var currentTreeDifficultyNode = getCurrentTreeDifficultyNode(treeView);
|
|
|
|
if (currentTreeDifficultyNode != null) treeView.selectedNode = currentTreeDifficultyNode;
|
2023-01-22 19:55:30 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (targetNode.data.id.split('_')[1])
|
|
|
|
{
|
|
|
|
case 'difficulty':
|
2023-06-08 16:53:52 -04:00
|
|
|
var variation:String = targetNode.data.id.split('_')[2];
|
|
|
|
var difficulty:String = targetNode.data.id.split('_')[3];
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
if (variation != null && difficulty != null)
|
|
|
|
{
|
2023-08-15 16:08:12 -04:00
|
|
|
trace('Changing difficulty to "$variation:$difficulty"');
|
2023-01-22 19:55:30 -05:00
|
|
|
selectedVariation = variation;
|
|
|
|
selectedDifficulty = difficulty;
|
2023-08-14 23:13:12 -04:00
|
|
|
// refreshDifficultyTreeSelection(treeView);
|
2023-09-25 23:24:07 -04:00
|
|
|
refreshMetadataToolbox();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
// case 'song':
|
|
|
|
// case 'variation':
|
|
|
|
default:
|
|
|
|
// Reset the user's selection.
|
|
|
|
trace('Selected wrong node type, resetting selection.');
|
2023-08-28 15:03:29 -04:00
|
|
|
var currentTreeDifficultyNode = getCurrentTreeDifficultyNode(treeView);
|
|
|
|
if (currentTreeDifficultyNode != null) treeView.selectedNode = currentTreeDifficultyNode;
|
2023-09-25 23:24:07 -04:00
|
|
|
refreshMetadataToolbox();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-15 16:08:12 -04:00
|
|
|
/**
|
|
|
|
* When the difficulty changes, update the song metadata toolbox to reflect the new data.
|
|
|
|
*/
|
2023-09-25 23:24:07 -04:00
|
|
|
function refreshMetadataToolbox():Void
|
2023-08-15 16:08:12 -04:00
|
|
|
{
|
2023-08-31 18:47:23 -04:00
|
|
|
var toolbox:Null<CollapsibleDialog> = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
|
|
|
|
if (toolbox == null) return;
|
2023-08-15 16:08:12 -04:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var inputSongName:Null<TextField> = toolbox.findComponent('inputSongName', TextField);
|
|
|
|
if (inputSongName != null) inputSongName.value = currentSongMetadata.songName;
|
2023-08-15 16:08:12 -04:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var inputSongArtist:Null<TextField> = toolbox.findComponent('inputSongArtist', TextField);
|
|
|
|
if (inputSongArtist != null) inputSongArtist.value = currentSongMetadata.artist;
|
2023-08-15 16:08:12 -04:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var inputStage:Null<DropDown> = toolbox.findComponent('inputStage', DropDown);
|
|
|
|
if (inputStage != null) inputStage.value = currentSongMetadata.playData.stage;
|
2023-08-15 16:08:12 -04:00
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
var inputNoteStyle:Null<DropDown> = toolbox.findComponent('inputNoteStyle', DropDown);
|
|
|
|
if (inputNoteStyle != null) inputNoteStyle.value = currentSongMetadata.playData.noteSkin;
|
2023-08-15 16:08:12 -04:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var inputBPM:Null<NumberStepper> = toolbox.findComponent('inputBPM', NumberStepper);
|
|
|
|
if (inputBPM != null) inputBPM.value = currentSongMetadata.timeChanges[0].bpm;
|
2023-08-15 16:08:12 -04:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var labelScrollSpeed:Null<Label> = toolbox.findComponent('labelScrollSpeed', Label);
|
|
|
|
if (labelScrollSpeed != null) labelScrollSpeed.text = 'Scroll Speed: ${currentSongChartScrollSpeed}x';
|
2023-08-15 16:08:12 -04:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var inputScrollSpeed:Null<Slider> = toolbox.findComponent('inputScrollSpeed', Slider);
|
|
|
|
if (inputScrollSpeed != null) inputScrollSpeed.value = currentSongChartScrollSpeed;
|
2023-08-15 16:08:12 -04:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var frameVariation:Null<Frame> = toolbox.findComponent('frameVariation', Frame);
|
|
|
|
if (frameVariation != null) frameVariation.text = 'Variation: ${selectedVariation.toTitleCase()}';
|
|
|
|
var frameDifficulty:Null<Frame> = toolbox.findComponent('frameDifficulty', Frame);
|
|
|
|
if (frameDifficulty != null) frameDifficulty.text = 'Difficulty: ${selectedDifficulty.toTitleCase()}';
|
2023-08-15 16:08:12 -04:00
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
var inputStage:Null<DropDown> = toolbox.findComponent('inputStage', DropDown);
|
|
|
|
var stageId:String = currentSongMetadata.playData.stage;
|
|
|
|
var stageData:Null<StageData> = StageDataParser.parseStageData(stageId);
|
|
|
|
if (stageData != null)
|
|
|
|
{
|
|
|
|
inputStage.value = {id: stageId, text: stageData.name};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inputStage.value = {id: "mainStage", text: "Main Stage"};
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
var inputCharacterPlayer:Null<DropDown> = toolbox.findComponent('inputCharacterPlayer', DropDown);
|
|
|
|
var charIdPlayer:String = currentSongMetadata.playData.characters.player;
|
|
|
|
var charDataPlayer:Null<CharacterData> = CharacterDataParser.fetchCharacterData(charIdPlayer);
|
|
|
|
if (charDataPlayer != null)
|
|
|
|
{
|
|
|
|
inputCharacterPlayer.value = {id: charIdPlayer, text: charDataPlayer.name};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inputCharacterPlayer.value = {id: "bf", text: "Boyfriend"};
|
|
|
|
}
|
|
|
|
|
|
|
|
var inputCharacterOpponent:Null<DropDown> = toolbox.findComponent('inputCharacterOpponent', DropDown);
|
|
|
|
var charIdOpponent:String = currentSongMetadata.playData.characters.opponent;
|
|
|
|
var charDataOpponent:Null<CharacterData> = CharacterDataParser.fetchCharacterData(charIdOpponent);
|
|
|
|
if (charDataOpponent != null)
|
|
|
|
{
|
|
|
|
inputCharacterOpponent.value = {id: charIdOpponent, text: charDataOpponent.name};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inputCharacterOpponent.value = {id: "dad", text: "Dad"};
|
|
|
|
}
|
|
|
|
|
|
|
|
var inputCharacterGirlfriend:Null<DropDown> = toolbox.findComponent('inputCharacterGirlfriend', DropDown);
|
|
|
|
var charIdGirlfriend:String = currentSongMetadata.playData.characters.girlfriend;
|
|
|
|
var charDataGirlfriend:Null<CharacterData> = CharacterDataParser.fetchCharacterData(charIdGirlfriend);
|
|
|
|
if (charDataGirlfriend != null)
|
|
|
|
{
|
|
|
|
inputCharacterGirlfriend.value = {id: charIdGirlfriend, text: charDataGirlfriend.name};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inputCharacterGirlfriend.value = {id: "none", text: "None"};
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the player preview/gameplay test area on the left side.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function handlePlayerDisplay():Void {}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the note preview/scroll area on the right side.
|
|
|
|
* Notes are rendered here as small bars.
|
|
|
|
* This function also handles:
|
|
|
|
* - Moving the viewport preview box around based on its current position.
|
|
|
|
* - Scrolling the note preview area down if the note preview is taller than the screen,
|
|
|
|
* and the viewport nears the end of the visible area.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function handleNotePreview():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (notePreviewDirty && notePreview != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
notePreviewDirty = false;
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
// TODO: Only update the notes that have changed.
|
|
|
|
notePreview.erase();
|
|
|
|
notePreview.addNotes(currentSongChartNoteData, Std.int(songLengthInMs));
|
|
|
|
notePreview.addEvents(currentSongChartEventData, Std.int(songLengthInMs));
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
if (notePreviewViewportBoundsDirty)
|
|
|
|
{
|
|
|
|
setNotePreviewViewportBounds(calculateNotePreviewViewportBounds());
|
|
|
|
}
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles passive behavior of the menu bar, such as updating labels or enabled/disabled status.
|
|
|
|
* Does not handle onClick ACTIONS of the menubar.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function handleMenubar():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
if (commandHistoryDirty)
|
|
|
|
{
|
|
|
|
commandHistoryDirty = false;
|
|
|
|
|
|
|
|
// Update the Undo and Redo buttons.
|
2023-08-28 15:03:29 -04:00
|
|
|
var undoButton:Null<MenuItem> = findComponent('menubarItemUndo', MenuItem);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
if (undoButton != null)
|
|
|
|
{
|
|
|
|
if (undoHistory.length == 0)
|
|
|
|
{
|
|
|
|
// Disable the Undo button.
|
|
|
|
undoButton.disabled = true;
|
2023-06-08 16:53:52 -04:00
|
|
|
undoButton.text = 'Undo';
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Change the label to the last command.
|
|
|
|
undoButton.disabled = false;
|
|
|
|
undoButton.text = 'Undo ${undoHistory[undoHistory.length - 1].toString()}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
trace('undoButton is null');
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
var redoButton:Null<MenuItem> = findComponent('menubarItemRedo', MenuItem);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
if (redoButton != null)
|
|
|
|
{
|
|
|
|
if (redoHistory.length == 0)
|
|
|
|
{
|
|
|
|
// Disable the Redo button.
|
|
|
|
redoButton.disabled = true;
|
2023-06-08 16:53:52 -04:00
|
|
|
redoButton.text = 'Redo';
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Change the label to the last command.
|
|
|
|
redoButton.disabled = false;
|
|
|
|
redoButton.text = 'Redo ${redoHistory[redoHistory.length - 1].toString()}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
trace('redoButton is null');
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle syncronizing the conductor with the music playback.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function handleMusicPlayback():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
if (audioInstTrack != null && audioInstTrack.playing)
|
|
|
|
{
|
|
|
|
if (FlxG.mouse.pressedMiddle)
|
|
|
|
{
|
|
|
|
// If middle mouse panning during song playback, we move ONLY the playhead, without scrolling. Neat!
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
var oldStepTime:Float = Conductor.currentStepTime;
|
|
|
|
var oldSongPosition:Float = Conductor.songPosition;
|
2023-01-22 19:55:30 -05:00
|
|
|
Conductor.update(audioInstTrack.time);
|
|
|
|
handleHitsounds(oldSongPosition, Conductor.songPosition);
|
|
|
|
// Resync vocals.
|
2023-06-08 16:53:52 -04:00
|
|
|
if (audioVocalTrackGroup != null && Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100)
|
|
|
|
{
|
|
|
|
audioVocalTrackGroup.time = audioInstTrack.time;
|
|
|
|
}
|
|
|
|
var diffStepTime:Float = Conductor.currentStepTime - oldStepTime;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Move the playhead.
|
|
|
|
playheadPositionInPixels += diffStepTime * GRID_SIZE;
|
|
|
|
|
|
|
|
// We don't move the song to scroll position, or update the note sprites.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Else, move the entire view.
|
2023-06-08 16:53:52 -04:00
|
|
|
var oldSongPosition:Float = Conductor.songPosition;
|
2023-01-22 19:55:30 -05:00
|
|
|
Conductor.update(audioInstTrack.time);
|
|
|
|
handleHitsounds(oldSongPosition, Conductor.songPosition);
|
|
|
|
// Resync vocals.
|
2023-06-08 16:53:52 -04:00
|
|
|
if (audioVocalTrackGroup != null && Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100)
|
|
|
|
{
|
|
|
|
audioVocalTrackGroup.time = audioInstTrack.time;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// We need time in fractional steps here to allow the song to actually play.
|
|
|
|
// Also account for a potentially offset playhead.
|
|
|
|
scrollPositionInPixels = Conductor.currentStepTime * GRID_SIZE - playheadPositionInPixels;
|
|
|
|
|
|
|
|
// DO NOT move song to scroll position here specifically.
|
|
|
|
|
|
|
|
// We need to update the note sprites.
|
|
|
|
noteDisplayDirty = true;
|
2023-08-16 03:40:44 -04:00
|
|
|
|
|
|
|
// Update the note preview viewport box.
|
|
|
|
setNotePreviewViewportBounds(calculateNotePreviewViewportBounds());
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.SPACE && !isHaxeUIDialogOpen)
|
|
|
|
{
|
|
|
|
toggleAudioPlayback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the playback of hitsounds.
|
|
|
|
*/
|
|
|
|
function handleHitsounds(oldSongPosition:Float, newSongPosition:Float):Void
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
if (!hitsoundsEnabled) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Assume notes are sorted by time.
|
|
|
|
for (noteData in currentSongChartNoteData)
|
|
|
|
{
|
2023-07-19 21:16:39 -04:00
|
|
|
// Check for notes between the old and new song positions.
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
if (noteData.time < oldSongPosition) // Note is in the past.
|
2023-01-22 19:55:30 -05:00
|
|
|
continue;
|
|
|
|
|
2023-07-19 21:16:39 -04:00
|
|
|
if (noteData.time > newSongPosition) // Note is in the future.
|
|
|
|
return; // Assume all notes are also in the future.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Note was just hit.
|
|
|
|
|
|
|
|
// Character preview.
|
|
|
|
|
2023-06-22 01:41:01 -04:00
|
|
|
// NoteScriptEvent takes a sprite, ehe. Need to rework that.
|
2023-07-13 20:27:45 -04:00
|
|
|
var tempNote:NoteSprite = new NoteSprite(NoteStyleRegistry.instance.fetchDefault());
|
2023-06-22 01:41:01 -04:00
|
|
|
tempNote.noteData = noteData;
|
2023-01-22 19:55:30 -05:00
|
|
|
tempNote.scrollFactor.set(0, 0);
|
|
|
|
var event:NoteScriptEvent = new NoteScriptEvent(ScriptEvent.NOTE_HIT, tempNote, 1, true);
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
2023-01-22 22:25:45 -05:00
|
|
|
if (event.eventCanceled) continue;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Hitsounds.
|
|
|
|
switch (noteData.getStrumlineIndex())
|
|
|
|
{
|
|
|
|
case 0: // Player
|
2023-09-26 17:46:07 -04:00
|
|
|
if (hitsoundsEnabledPlayer) ChartEditorAudioHandler.playSound(Paths.sound('ui/chart-editor/playerHitsound'));
|
2023-01-22 19:55:30 -05:00
|
|
|
case 1: // Opponent
|
2023-09-26 17:46:07 -04:00
|
|
|
if (hitsoundsEnabledOpponent) ChartEditorAudioHandler.playSound(Paths.sound('ui/chart-editor/opponentHitsound'));
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function startAudioPlayback():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (audioInstTrack != null)
|
|
|
|
{
|
|
|
|
audioInstTrack.play(false, audioInstTrack.time);
|
|
|
|
if (audioVocalTrackGroup != null) audioVocalTrackGroup.play(false, audioInstTrack.time);
|
|
|
|
}
|
2023-02-28 21:06:09 -05:00
|
|
|
|
|
|
|
setComponentText('playbarPlay', '||');
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function stopAudioPlayback():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
if (audioInstTrack != null) audioInstTrack.pause();
|
|
|
|
if (audioVocalTrackGroup != null) audioVocalTrackGroup.pause();
|
2023-02-28 21:06:09 -05:00
|
|
|
|
|
|
|
setComponentText('playbarPlay', '>');
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function toggleAudioPlayback():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
if (audioInstTrack == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
if (audioInstTrack.playing)
|
|
|
|
{
|
|
|
|
stopAudioPlayback();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
startAudioPlayback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function handlePlayhead():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Place notes at the playhead.
|
2023-06-08 16:53:52 -04:00
|
|
|
switch (currentLiveInputStyle)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
case LiveInputStyle.WASD:
|
|
|
|
if (FlxG.keys.justPressed.A) placeNoteAtPlayhead(0);
|
|
|
|
if (FlxG.keys.justPressed.S) placeNoteAtPlayhead(1);
|
|
|
|
if (FlxG.keys.justPressed.W) placeNoteAtPlayhead(2);
|
|
|
|
if (FlxG.keys.justPressed.D) placeNoteAtPlayhead(3);
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.LEFT) placeNoteAtPlayhead(4);
|
|
|
|
if (FlxG.keys.justPressed.DOWN) placeNoteAtPlayhead(5);
|
|
|
|
if (FlxG.keys.justPressed.UP) placeNoteAtPlayhead(6);
|
|
|
|
if (FlxG.keys.justPressed.RIGHT) placeNoteAtPlayhead(7);
|
|
|
|
case LiveInputStyle.NumberKeys:
|
|
|
|
if (FlxG.keys.justPressed.ONE) placeNoteAtPlayhead(0);
|
|
|
|
if (FlxG.keys.justPressed.TWO) placeNoteAtPlayhead(1);
|
|
|
|
if (FlxG.keys.justPressed.THREE) placeNoteAtPlayhead(2);
|
|
|
|
if (FlxG.keys.justPressed.FOUR) placeNoteAtPlayhead(3);
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.FIVE) placeNoteAtPlayhead(4);
|
|
|
|
if (FlxG.keys.justPressed.SIX) placeNoteAtPlayhead(5);
|
|
|
|
if (FlxG.keys.justPressed.SEVEN) placeNoteAtPlayhead(6);
|
|
|
|
if (FlxG.keys.justPressed.EIGHT) placeNoteAtPlayhead(7);
|
|
|
|
case LiveInputStyle.None:
|
|
|
|
// Do nothing.
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function placeNoteAtPlayhead(column:Int):Void
|
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
|
|
|
|
var playheadPosFractionalStep:Float = playheadPos / GRID_SIZE / (16 / noteSnapQuant);
|
|
|
|
var playheadPosStep:Int = Std.int(Math.floor(playheadPosFractionalStep));
|
2023-07-03 13:16:02 -04:00
|
|
|
var playheadPosMs:Float = playheadPosStep * Conductor.stepLengthMs * (16 / noteSnapQuant);
|
2023-06-08 16:53:52 -04:00
|
|
|
|
|
|
|
var newNoteData:SongNoteData = new SongNoteData(playheadPosMs, column, 0, selectedNoteKind);
|
|
|
|
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_scrollPositionInPixels(value:Float):Float
|
|
|
|
{
|
|
|
|
if (value < 0)
|
|
|
|
{
|
|
|
|
// If we're scrolling up, and we hit the top,
|
|
|
|
// but the playhead is in the middle, move the playhead up.
|
|
|
|
if (playheadPositionInPixels > 0)
|
|
|
|
{
|
2023-06-08 16:53:52 -04:00
|
|
|
var amount:Float = scrollPositionInPixels - value;
|
2023-01-22 19:55:30 -05:00
|
|
|
playheadPositionInPixels -= amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
value = 0;
|
|
|
|
}
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
if (value > songLengthInPixels) value = songLengthInPixels;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
if (value == scrollPositionInPixels) return value;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
// Difference in pixels.
|
|
|
|
var diff:Float = value - scrollPositionInPixels;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
this.scrollPositionInPixels = value;
|
|
|
|
|
|
|
|
// Move the grid sprite to the correct position.
|
2023-09-08 17:27:14 -04:00
|
|
|
if (gridTiledSprite != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-09-08 17:27:14 -04:00
|
|
|
if (isViewDownscroll)
|
|
|
|
{
|
|
|
|
gridTiledSprite.y = -scrollPositionInPixels + (MENU_BAR_HEIGHT + GRID_TOP_PAD);
|
|
|
|
gridPlayheadScrollArea.y = gridTiledSprite.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gridTiledSprite.y = -scrollPositionInPixels + (MENU_BAR_HEIGHT + GRID_TOP_PAD);
|
|
|
|
gridPlayheadScrollArea.y = gridTiledSprite.y;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-09-08 17:27:14 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// Move the rendered notes to the correct position.
|
2023-08-28 15:03:29 -04:00
|
|
|
renderedNotes.setPosition(gridTiledSprite?.x ?? 0.0, gridTiledSprite?.y ?? 0.0);
|
|
|
|
renderedHoldNotes.setPosition(gridTiledSprite?.x ?? 0.0, gridTiledSprite?.y ?? 0.0);
|
|
|
|
renderedEvents.setPosition(gridTiledSprite?.x ?? 0.0, gridTiledSprite?.y ?? 0.0);
|
|
|
|
renderedSelectionSquares.setPosition(gridTiledSprite?.x ?? 0.0, gridTiledSprite?.y ?? 0.0);
|
2023-06-08 16:53:52 -04:00
|
|
|
// Offset the selection box start position, if we are dragging.
|
|
|
|
if (selectionBoxStartPos != null) selectionBoxStartPos.y -= diff;
|
2023-08-16 03:40:44 -04:00
|
|
|
// Update the note preview viewport box.
|
|
|
|
setNotePreviewViewportBounds(calculateNotePreviewViewportBounds());
|
2023-01-22 19:55:30 -05:00
|
|
|
return this.scrollPositionInPixels;
|
|
|
|
}
|
|
|
|
|
2023-07-26 16:52:58 -04:00
|
|
|
/**
|
|
|
|
* Transitions to the Play State to test the song
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
public function testSongInPlayState(minimal:Bool = false):Void
|
2023-07-26 16:52:58 -04:00
|
|
|
{
|
2023-07-26 20:03:31 -04:00
|
|
|
var startTimestamp:Float = 0;
|
|
|
|
if (playtestStartTime) startTimestamp = scrollPositionInMs + playheadPositionInMs;
|
|
|
|
|
2023-07-26 16:52:58 -04:00
|
|
|
var targetSong:Song = Song.buildRaw(currentSongId, songMetadata.values(), availableVariations, songChartData, false);
|
|
|
|
|
2023-08-02 10:15:54 -04:00
|
|
|
// TODO: Rework asset system so we can remove this.
|
2023-08-10 14:21:10 -04:00
|
|
|
switch (currentSongStage)
|
2023-08-02 10:15:54 -04:00
|
|
|
{
|
2023-08-10 14:21:10 -04:00
|
|
|
case 'mainStage':
|
2023-08-02 10:15:54 -04:00
|
|
|
Paths.setCurrentLevel('week1');
|
2023-08-10 14:21:10 -04:00
|
|
|
case 'spookyMansion':
|
2023-08-02 10:15:54 -04:00
|
|
|
Paths.setCurrentLevel('week2');
|
2023-08-10 14:21:10 -04:00
|
|
|
case 'phillyTrain':
|
2023-08-02 10:15:54 -04:00
|
|
|
Paths.setCurrentLevel('week3');
|
2023-08-10 14:21:10 -04:00
|
|
|
case 'limoRide':
|
2023-08-02 10:15:54 -04:00
|
|
|
Paths.setCurrentLevel('week4');
|
2023-08-10 14:21:10 -04:00
|
|
|
case 'mallXmas' | 'mallEvil':
|
2023-08-02 10:15:54 -04:00
|
|
|
Paths.setCurrentLevel('week5');
|
2023-08-10 14:21:10 -04:00
|
|
|
case 'school' | 'schoolEvil':
|
2023-08-02 10:15:54 -04:00
|
|
|
Paths.setCurrentLevel('week6');
|
2023-08-10 14:21:10 -04:00
|
|
|
case 'tankmanBattlefield':
|
2023-08-02 10:15:54 -04:00
|
|
|
Paths.setCurrentLevel('week7');
|
2023-08-10 14:21:10 -04:00
|
|
|
case 'phillyStreets' | 'phillyBlazin':
|
2023-08-02 10:15:54 -04:00
|
|
|
Paths.setCurrentLevel('weekend1');
|
|
|
|
}
|
|
|
|
|
2023-07-26 16:52:58 -04:00
|
|
|
subStateClosed.add(fixCamera);
|
2023-07-26 21:34:38 -04:00
|
|
|
subStateClosed.add(updateConductor);
|
2023-07-26 16:52:58 -04:00
|
|
|
|
2023-08-02 18:08:49 -04:00
|
|
|
FlxTransitionableState.skipNextTransIn = false;
|
|
|
|
FlxTransitionableState.skipNextTransOut = false;
|
|
|
|
|
2023-08-04 16:15:07 -04:00
|
|
|
var targetState = new PlayState(
|
2023-07-26 16:52:58 -04:00
|
|
|
{
|
|
|
|
targetSong: targetSong,
|
|
|
|
targetDifficulty: selectedDifficulty,
|
|
|
|
// TODO: Add this.
|
|
|
|
// targetCharacter: targetCharacter,
|
|
|
|
practiceMode: true,
|
|
|
|
minimalMode: minimal,
|
2023-07-26 20:03:31 -04:00
|
|
|
startTimestamp: startTimestamp,
|
2023-08-04 16:15:07 -04:00
|
|
|
overrideMusic: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
// Override music.
|
2023-08-28 15:03:29 -04:00
|
|
|
if (audioInstTrack != null) FlxG.sound.music = audioInstTrack;
|
|
|
|
if (audioVocalTrackGroup != null) targetState.vocals = audioVocalTrackGroup;
|
2023-08-04 16:15:07 -04:00
|
|
|
|
|
|
|
openSubState(targetState);
|
2023-07-26 16:52:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function fixCamera(_:FlxSubState = null):Void
|
|
|
|
{
|
|
|
|
FlxG.cameras.reset(new FlxCamera());
|
|
|
|
FlxG.camera.focusOn(new FlxPoint(FlxG.width / 2, FlxG.height / 2));
|
2023-07-26 21:34:38 -04:00
|
|
|
FlxG.camera.zoom = 1.0;
|
2023-07-26 16:52:58 -04:00
|
|
|
|
|
|
|
add(this.component);
|
|
|
|
}
|
|
|
|
|
2023-07-26 21:34:38 -04:00
|
|
|
function updateConductor(_:FlxSubState = null):Void
|
|
|
|
{
|
|
|
|
var targetPos = scrollPositionInMs;
|
|
|
|
Conductor.update(targetPos);
|
|
|
|
}
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
public function postLoadInstrumental():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (audioInstTrack != null)
|
|
|
|
{
|
|
|
|
// Prevent the time from skipping back to 0 when the song ends.
|
|
|
|
audioInstTrack.onComplete = function() {
|
|
|
|
if (audioInstTrack != null) audioInstTrack.pause();
|
|
|
|
if (audioVocalTrackGroup != null) audioVocalTrackGroup.pause();
|
|
|
|
};
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
songLengthInMs = audioInstTrack.length;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
if (gridTiledSprite != null) gridTiledSprite.height = songLengthInPixels;
|
2023-09-08 17:27:14 -04:00
|
|
|
if (gridPlayheadScrollArea != null)
|
|
|
|
{
|
|
|
|
gridPlayheadScrollArea.setGraphicSize(Std.int(gridPlayheadScrollArea.width), songLengthInPixels);
|
|
|
|
gridPlayheadScrollArea.updateHitbox();
|
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
buildSpectrogram(audioInstTrack);
|
|
|
|
}
|
2023-09-26 17:46:07 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
trace('[WARN] Instrumental track was null!');
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
// Pretty much everything is going to need to be reset.
|
2023-01-22 19:55:30 -05:00
|
|
|
scrollPositionInPixels = 0;
|
|
|
|
playheadPositionInPixels = 0;
|
2023-08-30 18:29:09 -04:00
|
|
|
notePreviewDirty = true;
|
|
|
|
notePreviewViewportBoundsDirty = true;
|
|
|
|
noteDisplayDirty = true;
|
2023-09-26 17:46:07 -04:00
|
|
|
healthIconsDirty = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
moveSongToScrollPosition();
|
|
|
|
}
|
|
|
|
|
2023-07-25 23:11:12 -04:00
|
|
|
/**
|
|
|
|
* Clear the voices group.
|
|
|
|
*/
|
|
|
|
public function clearVocals():Void
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (audioVocalTrackGroup != null) audioVocalTrackGroup.clear();
|
2023-07-25 23:11:12 -04:00
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* When setting the scroll position, except when automatically scrolling during song playback,
|
|
|
|
* we need to update the conductor's current step time and the timestamp of the audio tracks.
|
|
|
|
*/
|
2023-02-28 21:06:09 -05:00
|
|
|
function moveSongToScrollPosition():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Update the songPosition in the Conductor.
|
2023-07-22 20:16:43 -04:00
|
|
|
var targetPos = scrollPositionInMs;
|
|
|
|
Conductor.update(targetPos);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Update the songPosition in the audio tracks.
|
2023-01-22 22:25:45 -05:00
|
|
|
if (audioInstTrack != null) audioInstTrack.time = scrollPositionInMs + playheadPositionInMs;
|
|
|
|
if (audioVocalTrackGroup != null) audioVocalTrackGroup.time = scrollPositionInMs + playheadPositionInMs;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// We need to update the note sprites because we changed the scroll position.
|
|
|
|
noteDisplayDirty = true;
|
|
|
|
}
|
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
function easeSongToScrollPosition(targetScrollPosition:Float):Void
|
|
|
|
{
|
|
|
|
if (currentScrollEase != null) cancelScrollEase(currentScrollEase);
|
|
|
|
|
|
|
|
currentScrollEase = FlxTween.tween(this, {scrollPositionInPixels: targetScrollPosition}, SCROLL_EASE_DURATION,
|
|
|
|
{
|
|
|
|
ease: FlxEase.quintInOut,
|
|
|
|
onUpdate: this.onScrollEaseUpdate,
|
|
|
|
onComplete: this.cancelScrollEase,
|
|
|
|
type: ONESHOT
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onScrollEaseUpdate(_:FlxTween):Void
|
|
|
|
{
|
|
|
|
moveSongToScrollPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
function cancelScrollEase(_:FlxTween):Void
|
|
|
|
{
|
|
|
|
if (currentScrollEase != null)
|
|
|
|
{
|
|
|
|
@:privateAccess
|
|
|
|
var targetScrollPosition:Float = currentScrollEase._properties.scrollPositionInPixels;
|
|
|
|
|
|
|
|
currentScrollEase.cancel();
|
|
|
|
currentScrollEase = null;
|
|
|
|
this.scrollPositionInPixels = targetScrollPosition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Perform (or redo) a command, then add it to the undo stack.
|
2023-06-08 16:30:45 -04:00
|
|
|
*
|
2023-01-22 19:55:30 -05:00
|
|
|
* @param command The command to perform.
|
|
|
|
* @param purgeRedoStack If true, the redo stack will be cleared.
|
|
|
|
*/
|
2023-08-28 15:03:29 -04:00
|
|
|
function performCommand(command:ChartEditorCommand, purgeRedoStack:Bool = true):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
command.execute(this);
|
|
|
|
undoHistory.push(command);
|
|
|
|
commandHistoryDirty = true;
|
2023-01-22 22:25:45 -05:00
|
|
|
if (purgeRedoStack) redoHistory = [];
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Undo a command, then add it to the redo stack.
|
|
|
|
* @param command The command to undo.
|
|
|
|
*/
|
|
|
|
function undoCommand(command:ChartEditorCommand):Void
|
|
|
|
{
|
|
|
|
command.undo(this);
|
|
|
|
redoHistory.push(command);
|
|
|
|
commandHistoryDirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Undo the last command in the undo stack, then add it to the redo stack.
|
|
|
|
*/
|
|
|
|
function undoLastCommand():Void
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
var command:Null<ChartEditorCommand> = undoHistory.pop();
|
|
|
|
if (command == null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
trace('No actions to undo.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
undoCommand(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Redo the last command in the redo stack, then add it to the undo stack.
|
|
|
|
*/
|
|
|
|
function redoLastCommand():Void
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
var command:Null<ChartEditorCommand> = redoHistory.pop();
|
|
|
|
if (command == null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
trace('No actions to redo.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
performCommand(command, false);
|
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
function sortChartData():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-09-12 18:37:59 -04:00
|
|
|
// TODO: .insertionSort()
|
2023-02-02 18:26:03 -05:00
|
|
|
currentSongChartNoteData.sort(function(a:SongNoteData, b:SongNoteData):Int {
|
2023-01-22 19:55:30 -05:00
|
|
|
return FlxSort.byValues(FlxSort.ASCENDING, a.time, b.time);
|
|
|
|
});
|
|
|
|
|
2023-09-12 18:37:59 -04:00
|
|
|
// TODO: .insertionSort()
|
2023-02-02 18:26:03 -05:00
|
|
|
currentSongChartEventData.sort(function(a:SongEventData, b:SongEventData):Int {
|
2023-01-22 19:55:30 -05:00
|
|
|
return FlxSort.byValues(FlxSort.ASCENDING, a.time, b.time);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
function playMetronomeTick(high:Bool = false):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-09-25 23:24:07 -04:00
|
|
|
ChartEditorAudioHandler.playSound(Paths.sound('pianoStuff/piano-${high ? '001' : '008'}'));
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
function isNoteSelected(note:Null<SongNoteData>):Bool
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
return note != null && currentNoteSelection.indexOf(note) != -1;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
function isEventSelected(event:Null<SongEventData>):Bool
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
return event != null && currentEventSelection.indexOf(event) != -1;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
override function destroy():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
super.destroy();
|
|
|
|
|
|
|
|
cleanupAutoSave();
|
|
|
|
|
2023-09-12 18:37:59 -04:00
|
|
|
// Hide the mouse cursor on other states.
|
|
|
|
Cursor.hide();
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
@:privateAccess
|
|
|
|
ChartEditorNoteSprite.noteFrameCollection = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dismiss any existing notifications, if there are any.
|
|
|
|
*/
|
2023-02-28 13:17:28 -05:00
|
|
|
function dismissNotifications():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-02-28 13:17:28 -05:00
|
|
|
NotificationManager.instance.clearNotifications();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2022-09-07 19:07:08 -04:00
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
|
|
|
|
enum LiveInputStyle
|
|
|
|
{
|
|
|
|
None;
|
|
|
|
NumberKeys;
|
|
|
|
WASD;
|
|
|
|
}
|