2022-09-07 19:07:08 -04:00
|
|
|
package funkin.ui.debug.charting;
|
|
|
|
|
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-10-26 05:46:22 -04:00
|
|
|
import flixel.addons.transition.FlxTransitionableState;
|
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;
|
2024-02-09 14:58:57 -05:00
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
2022-09-07 19:07:08 -04:00
|
|
|
import flixel.group.FlxSpriteGroup;
|
2024-01-06 01:06:10 -05:00
|
|
|
import flixel.input.gamepad.FlxGamepadInputID;
|
2023-07-22 20:16:43 -04:00
|
|
|
import flixel.input.keyboard.FlxKey;
|
2024-02-09 14:58:57 -05:00
|
|
|
import flixel.input.mouse.FlxMouseEvent;
|
2023-10-26 05:46:22 -04:00
|
|
|
import flixel.math.FlxMath;
|
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;
|
2024-02-09 14:58:57 -05:00
|
|
|
import flixel.system.debug.log.LogStyle;
|
2023-10-22 15:43:39 -04:00
|
|
|
import flixel.system.FlxAssets.FlxSoundAsset;
|
2024-02-09 14:58:57 -05:00
|
|
|
import flixel.text.FlxText;
|
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;
|
2024-02-09 14:58:57 -05:00
|
|
|
import funkin.audio.FunkinSound;
|
|
|
|
import funkin.audio.visualize.PolygonSpectogram;
|
2023-05-25 18:33:39 -04:00
|
|
|
import funkin.audio.VoicesGroup;
|
2024-02-09 14:58:57 -05:00
|
|
|
import funkin.audio.waveform.WaveformSprite;
|
2023-07-22 20:16:43 -04:00
|
|
|
import funkin.data.notestyle.NoteStyleRegistry;
|
2023-11-24 00:42:07 -05:00
|
|
|
import funkin.data.song.SongData.SongCharacterData;
|
2024-02-09 14:58:57 -05:00
|
|
|
import funkin.data.song.SongData.SongChartData;
|
|
|
|
import funkin.data.song.SongData.SongEventData;
|
2023-10-26 05:46:22 -04:00
|
|
|
import funkin.data.song.SongData.SongMetadata;
|
|
|
|
import funkin.data.song.SongData.SongNoteData;
|
2023-12-08 01:15:22 -05:00
|
|
|
import funkin.data.song.SongData.SongOffsets;
|
2023-10-26 05:46:22 -04:00
|
|
|
import funkin.data.song.SongDataUtils;
|
2023-11-24 00:42:07 -05:00
|
|
|
import funkin.data.song.SongRegistry;
|
2024-02-09 14:58:57 -05:00
|
|
|
import funkin.data.stage.StageData;
|
2024-03-16 00:55:57 -04:00
|
|
|
import funkin.graphics.FunkinCamera;
|
2024-02-09 14:58:57 -05:00
|
|
|
import funkin.graphics.FunkinSprite;
|
2022-12-17 15:19:42 -05:00
|
|
|
import funkin.input.Cursor;
|
2024-01-06 01:06:10 -05:00
|
|
|
import funkin.input.TurboActionHandler;
|
2024-02-13 03:18:51 -05:00
|
|
|
import funkin.input.TurboButtonHandler;
|
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;
|
2023-10-26 05:46:22 -04:00
|
|
|
import funkin.play.character.CharacterData;
|
2023-10-22 15:43:39 -04:00
|
|
|
import funkin.play.character.CharacterData.CharacterDataParser;
|
2023-11-07 04:04:22 -05:00
|
|
|
import funkin.play.components.HealthIcon;
|
2023-06-22 01:41:01 -04:00
|
|
|
import funkin.play.notes.NoteSprite;
|
2023-07-26 16:52:58 -04:00
|
|
|
import funkin.play.PlayState;
|
2024-03-27 01:40:22 -04:00
|
|
|
import funkin.play.PlayStatePlaylist;
|
2022-12-17 15:19:42 -05:00
|
|
|
import funkin.play.song.Song;
|
2023-10-22 15:43:39 -04:00
|
|
|
import funkin.save.Save;
|
2023-10-26 05:46:22 -04:00
|
|
|
import funkin.ui.debug.charting.commands.AddEventsCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.AddNotesCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.ChartEditorCommand;
|
2024-01-04 08:20:34 -05:00
|
|
|
import funkin.ui.debug.charting.commands.CopyItemsCommand;
|
2024-02-09 14:58:57 -05:00
|
|
|
import funkin.ui.debug.charting.commands.CutItemsCommand;
|
2023-10-26 05:46:22 -04:00
|
|
|
import funkin.ui.debug.charting.commands.DeselectAllItemsCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.DeselectItemsCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.ExtendNoteLengthCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.FlipNotesCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.InvertSelectedItemsCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.MoveEventsCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.MoveItemsCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.MoveNotesCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.PasteItemsCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.RemoveEventsCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.RemoveItemsCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.RemoveNotesCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.SelectAllItemsCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.SelectItemsCommand;
|
|
|
|
import funkin.ui.debug.charting.commands.SetItemSelectionCommand;
|
|
|
|
import funkin.ui.debug.charting.components.ChartEditorEventSprite;
|
|
|
|
import funkin.ui.debug.charting.components.ChartEditorHoldNoteSprite;
|
2024-02-09 14:58:57 -05:00
|
|
|
import funkin.ui.debug.charting.components.ChartEditorMeasureTicks;
|
2024-02-02 23:15:48 -05:00
|
|
|
import funkin.ui.debug.charting.components.ChartEditorMeasureTicks;
|
2023-10-26 05:46:22 -04:00
|
|
|
import funkin.ui.debug.charting.components.ChartEditorNotePreview;
|
|
|
|
import funkin.ui.debug.charting.components.ChartEditorNoteSprite;
|
2023-11-24 00:42:07 -05:00
|
|
|
import funkin.ui.debug.charting.components.ChartEditorPlaybarHead;
|
2023-10-26 05:46:22 -04:00
|
|
|
import funkin.ui.debug.charting.components.ChartEditorSelectionSquareSprite;
|
2023-11-24 00:42:07 -05:00
|
|
|
import funkin.ui.debug.charting.handlers.ChartEditorShortcutHandler;
|
2024-02-09 14:58:57 -05:00
|
|
|
import funkin.ui.debug.charting.toolboxes.ChartEditorBaseToolbox;
|
|
|
|
import funkin.ui.debug.charting.toolboxes.ChartEditorDifficultyToolbox;
|
|
|
|
import funkin.ui.debug.charting.toolboxes.ChartEditorFreeplayToolbox;
|
|
|
|
import funkin.ui.debug.charting.toolboxes.ChartEditorOffsetsToolbox;
|
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;
|
2023-11-24 00:42:07 -05:00
|
|
|
import funkin.ui.mainmenu.MainMenuState;
|
2024-03-16 00:55:57 -04:00
|
|
|
import funkin.ui.transition.LoadingState;
|
2022-10-26 01:14:29 -04:00
|
|
|
import funkin.util.Constants;
|
2023-11-24 00:42:07 -05:00
|
|
|
import funkin.util.FileUtil;
|
2024-02-09 14:58:57 -05:00
|
|
|
import funkin.util.logging.CrashHandler;
|
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;
|
2023-11-24 00:42:07 -05:00
|
|
|
import haxe.ui.backend.flixel.UIRuntimeState;
|
|
|
|
import haxe.ui.backend.flixel.UIState;
|
2024-02-09 14:58:57 -05:00
|
|
|
import haxe.ui.components.Button;
|
2023-10-26 05:46:22 -04:00
|
|
|
import haxe.ui.components.DropDown;
|
2024-02-09 14:58:57 -05:00
|
|
|
import haxe.ui.components.Image;
|
2022-10-26 01:14:29 -04:00
|
|
|
import haxe.ui.components.Label;
|
2023-10-26 05:46:22 -04:00
|
|
|
import haxe.ui.components.NumberStepper;
|
2022-10-13 21:32:19 -04:00
|
|
|
import haxe.ui.components.Slider;
|
2023-10-26 05:46:22 -04:00
|
|
|
import haxe.ui.components.TextField;
|
2024-02-09 14:58:57 -05:00
|
|
|
import haxe.ui.containers.Box;
|
2023-08-01 14:08:41 -04:00
|
|
|
import haxe.ui.containers.dialogs.CollapsibleDialog;
|
2023-10-26 05:46:22 -04:00
|
|
|
import haxe.ui.containers.Frame;
|
2024-02-09 14:58:57 -05:00
|
|
|
import haxe.ui.containers.Grid;
|
|
|
|
import haxe.ui.containers.HBox;
|
2023-10-22 15:43:39 -04:00
|
|
|
import haxe.ui.containers.menus.Menu;
|
2023-11-24 00:42:07 -05:00
|
|
|
import haxe.ui.containers.menus.MenuBar;
|
2023-12-01 17:14:48 -05:00
|
|
|
import haxe.ui.containers.menus.MenuCheckBox;
|
2024-02-09 14:58:57 -05:00
|
|
|
import haxe.ui.containers.menus.MenuItem;
|
|
|
|
import haxe.ui.containers.ScrollView;
|
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;
|
2023-11-24 00:42:07 -05:00
|
|
|
import haxe.ui.events.MouseEvent;
|
|
|
|
import haxe.ui.events.UIEvent;
|
2023-10-27 01:42:05 -04:00
|
|
|
import haxe.ui.focus.FocusManager;
|
2024-02-09 14:58:57 -05:00
|
|
|
import haxe.ui.Toolkit;
|
2022-09-07 19:07:08 -04:00
|
|
|
import openfl.display.BitmapData;
|
|
|
|
|
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.
|
|
|
|
*
|
2023-11-24 00:42:07 -05:00
|
|
|
* Some functionality is split into handler classes to help maintain my sanity.
|
2023-06-08 16:30:45 -04:00
|
|
|
*
|
2024-05-09 22:37:01 -04:00
|
|
|
* @author EliteMasterEric
|
2022-10-26 01:14:29 -04:00
|
|
|
*/
|
2023-11-24 00:42:07 -05:00
|
|
|
// @:nullSafety
|
|
|
|
|
|
|
|
@:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/chart-editor/main-view.xml"))
|
|
|
|
class ChartEditorState extends UIState // UIState derives from MusicBeatState
|
2022-09-07 19:07:08 -04:00
|
|
|
{
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* CONSTANTS
|
|
|
|
*/
|
|
|
|
// ==============================
|
2023-11-24 00:42:07 -05:00
|
|
|
// Layouts
|
2023-10-26 05:46:22 -04:00
|
|
|
public static final CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT:String = Paths.ui('chart-editor/toolbox/difficulty');
|
2024-02-09 14:58:57 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
public static final CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT:String = Paths.ui('chart-editor/toolbox/player-preview');
|
|
|
|
public static final CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT:String = Paths.ui('chart-editor/toolbox/opponent-preview');
|
2024-02-09 14:58:57 -05:00
|
|
|
public static final CHART_EDITOR_TOOLBOX_METADATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/metadata');
|
|
|
|
public static final CHART_EDITOR_TOOLBOX_OFFSETS_LAYOUT:String = Paths.ui('chart-editor/toolbox/offsets');
|
2024-02-16 22:01:47 -05:00
|
|
|
public static final CHART_EDITOR_TOOLBOX_NOTE_DATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/note-data');
|
|
|
|
public static final CHART_EDITOR_TOOLBOX_EVENT_DATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/event-data');
|
2024-02-09 14:58:57 -05:00
|
|
|
public static final CHART_EDITOR_TOOLBOX_FREEPLAY_LAYOUT:String = Paths.ui('chart-editor/toolbox/freeplay');
|
|
|
|
public static final CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT:String = Paths.ui('chart-editor/toolbox/playtest-properties');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-02-28 13:17:28 -05:00
|
|
|
// Validation
|
2024-02-09 14:58:57 -05:00
|
|
|
public static final SUPPORTED_MUSIC_FORMATS:Array<String> = #if sys ['ogg'] #else ['mp3'] #end;
|
2023-10-26 05:46:22 -04:00
|
|
|
|
|
|
|
// Layout
|
2023-02-28 13:17:28 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* The base grid size for the chart editor.
|
|
|
|
*/
|
|
|
|
public static final GRID_SIZE:Int = 40;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* The width of the scroll area.
|
|
|
|
*/
|
2024-01-05 02:35:41 -05:00
|
|
|
public static final PLAYHEAD_SCROLL_AREA_WIDTH:Int = Std.int(GRID_SIZE);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* The height of the playhead, in pixels.
|
|
|
|
*/
|
2023-01-22 19:55:30 -05:00
|
|
|
public static final PLAYHEAD_HEIGHT:Int = Std.int(GRID_SIZE / 8);
|
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The width of the border between grid squares, where the crosshair changes from "Place Notes" to "Select Notes".
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
public static final GRID_SELECTION_BORDER_WIDTH:Int = 6;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The height of the menu bar in the layout.
|
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
public static final MENU_BAR_HEIGHT:Int = 32;
|
2023-07-22 20:16:43 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The height of the playbar in the layout.
|
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
public static final PLAYBAR_HEIGHT:Int = 48;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
/**
|
|
|
|
* The height of the note selection buttons above the grid.
|
|
|
|
*/
|
|
|
|
public static final NOTE_SELECT_BUTTON_HEIGHT:Int = 24;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The amount of padding between the menu bar and the chart grid when fully scrolled up.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2024-01-04 08:20:34 -05:00
|
|
|
public static final GRID_TOP_PAD:Int = NOTE_SELECT_BUTTON_HEIGHT + 12;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The initial vertical position of the chart grid.
|
|
|
|
*/
|
|
|
|
public static final GRID_INITIAL_Y_POS:Int = MENU_BAR_HEIGHT + GRID_TOP_PAD;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The X position of the note preview area.
|
|
|
|
*/
|
2024-01-12 06:35:41 -05:00
|
|
|
public static final NOTE_PREVIEW_X_POS:Int = 320;
|
2024-01-04 08:20:34 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Y position of the note preview area.
|
|
|
|
*/
|
|
|
|
public static final NOTE_PREVIEW_Y_POS:Int = GRID_INITIAL_Y_POS - NOTE_SELECT_BUTTON_HEIGHT - 4;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The X position of the note grid.
|
|
|
|
*/
|
|
|
|
public static var GRID_X_POS(get, never):Float;
|
|
|
|
|
|
|
|
static function get_GRID_X_POS():Float
|
|
|
|
{
|
|
|
|
return FlxG.width / 2 - GRID_SIZE * STRUMLINE_SIZE;
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
|
|
|
|
// Colors
|
|
|
|
// Background color tint.
|
|
|
|
public static final CURSOR_COLOR:FlxColor = 0xE0FFFFFF;
|
|
|
|
public static final PREVIEW_BG_COLOR:FlxColor = 0xFF303030;
|
|
|
|
public static final PLAYHEAD_SCROLL_AREA_COLOR:FlxColor = 0xFF682B2F;
|
|
|
|
public static final SPECTROGRAM_COLOR:FlxColor = 0xFFFF0000;
|
|
|
|
public static final PLAYHEAD_COLOR:FlxColor = 0xC0BD0231;
|
|
|
|
|
|
|
|
// Timings
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* Duration, in seconds, for the scroll easing animation.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
public static final SCROLL_EASE_DURATION:Float = 0.2;
|
|
|
|
|
|
|
|
// Other
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* Number of notes in each player's strumline.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
public static final STRUMLINE_SIZE:Int = 4;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* How many pixels far the user needs to move the mouse before the cursor is considered to be dragged rather than clicked.
|
2023-06-08 16:53:52 -04:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
public static final DRAG_THRESHOLD:Float = 16.0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* Precisions of notes you can snap to.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
public static final SNAP_QUANTS:Array<Int> = [4, 8, 12, 16, 20, 24, 32, 48, 64, 96, 192];
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The default note snapping value.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
public static final BASE_QUANT:Int = 16;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* The index of thet default note snapping value in the `SNAP_QUANTS` array.
|
|
|
|
*/
|
|
|
|
public static final BASE_QUANT_INDEX:Int = 3;
|
2023-08-31 21:56:49 -04:00
|
|
|
|
2024-01-12 18:29:02 -05:00
|
|
|
/**
|
|
|
|
* The duration before the welcome music starts to fade back in after the user stops playing music in the chart editor.
|
|
|
|
*/
|
|
|
|
public static final WELCOME_MUSIC_FADE_IN_DELAY:Float = 30.0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The duration of the welcome music fade in.
|
|
|
|
*/
|
|
|
|
public static final WELCOME_MUSIC_FADE_IN_DURATION:Float = 10.0;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* INSTANCE DATA
|
|
|
|
*/
|
|
|
|
// ==============================
|
2023-10-26 05:46:22 -04:00
|
|
|
// Song Length
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-31 23:48:15 -04:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The length of the current instrumental, in milliseconds.
|
2023-08-31 23:48:15 -04:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
@:isVar var songLengthInMs(get, set):Float = 0;
|
|
|
|
|
|
|
|
function get_songLengthInMs():Float
|
|
|
|
{
|
|
|
|
if (songLengthInMs <= 0) return 1000;
|
|
|
|
return songLengthInMs;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_songLengthInMs(value:Float):Float
|
|
|
|
{
|
|
|
|
this.songLengthInMs = value;
|
|
|
|
|
2024-02-19 20:18:32 -05:00
|
|
|
updateGridHeight();
|
2023-12-08 01:15:22 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
return this.songLengthInMs;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-08-31 23:48:15 -04:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The length of the current instrumental, converted to steps.
|
|
|
|
* Dependant on BPM, because the size of a grid square does not change with BPM but the length of a beat does.
|
2023-08-31 23:48:15 -04:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var songLengthInSteps(get, set):Float;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
function get_songLengthInSteps():Float
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
return Conductor.instance.getTimeInSteps(songLengthInMs);
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_songLengthInSteps(value:Float):Float
|
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
// Getting a reasonable result from setting songLengthInSteps requires that Conductor.instance.mapBPMChanges be called first.
|
|
|
|
songLengthInMs = Conductor.instance.getStepTimeInMs(value);
|
2023-10-26 05:46:22 -04:00
|
|
|
return value;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-08-31 23:48:15 -04:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The length of the current instrumental, in PIXELS.
|
|
|
|
* Dependant on BPM, because the size of a grid square does not change with BPM but the length of a beat does.
|
2023-08-31 23:48:15 -04:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var songLengthInPixels(get, set):Int;
|
2023-08-31 23:48:15 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
function get_songLengthInPixels():Int
|
2023-08-31 23:48:15 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
return Std.int(songLengthInSteps * GRID_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_songLengthInPixels(value:Int):Int
|
|
|
|
{
|
|
|
|
songLengthInSteps = value / GRID_SIZE;
|
|
|
|
return value;
|
2023-08-31 23:48:15 -04:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Scroll Position
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The relative scroll position in the song, in pixels.
|
2023-01-22 19:55:30 -05:00
|
|
|
* One pixel is 1/40 of 1 step, and 1/160 of 1 beat.
|
|
|
|
*/
|
|
|
|
var scrollPositionInPixels(default, set):Float = -1.0;
|
|
|
|
|
2023-10-26 05:46:22 -04: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)
|
|
|
|
{
|
|
|
|
var amount:Float = scrollPositionInPixels - value;
|
|
|
|
playheadPositionInPixels -= amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
value = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value > songLengthInPixels) value = songLengthInPixels;
|
|
|
|
|
|
|
|
if (value == scrollPositionInPixels) return value;
|
|
|
|
|
|
|
|
// Difference in pixels.
|
|
|
|
var diff:Float = value - scrollPositionInPixels;
|
|
|
|
|
|
|
|
this.scrollPositionInPixels = value;
|
|
|
|
|
|
|
|
// Move the grid sprite to the correct position.
|
2024-01-05 02:35:41 -05:00
|
|
|
if (gridTiledSprite != null && measureTicks != null)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
if (isViewDownscroll)
|
|
|
|
{
|
2024-01-04 08:20:34 -05:00
|
|
|
gridTiledSprite.y = -scrollPositionInPixels + (GRID_INITIAL_Y_POS);
|
2024-01-05 02:35:41 -05:00
|
|
|
measureTicks.y = gridTiledSprite.y;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-04 08:20:34 -05:00
|
|
|
gridTiledSprite.y = -scrollPositionInPixels + (GRID_INITIAL_Y_POS);
|
2024-01-05 02:35:41 -05:00
|
|
|
measureTicks.y = gridTiledSprite.y;
|
2023-12-01 19:58:58 -05:00
|
|
|
|
2024-01-23 23:24:05 -05:00
|
|
|
for (member in audioWaveforms.members)
|
2023-12-08 18:44:45 -05:00
|
|
|
{
|
2024-01-23 23:24:05 -05:00
|
|
|
member.time = scrollPositionInMs / Constants.MS_PER_SEC;
|
|
|
|
|
|
|
|
// Doing this desyncs the waveforms from the grid.
|
|
|
|
// member.y = Math.max(this.gridTiledSprite?.y ?? 0.0, ChartEditorState.GRID_INITIAL_Y_POS - ChartEditorState.GRID_TOP_PAD);
|
2023-12-08 18:44:45 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move the rendered notes to the correct position.
|
|
|
|
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);
|
|
|
|
// Offset the selection box start position, if we are dragging.
|
|
|
|
if (selectionBoxStartPos != null) selectionBoxStartPos.y -= diff;
|
2024-01-08 21:26:24 -05:00
|
|
|
|
|
|
|
// Update the note preview.
|
2023-10-26 05:46:22 -04:00
|
|
|
setNotePreviewViewportBounds(calculateNotePreviewViewportBounds());
|
2024-01-08 21:26:24 -05:00
|
|
|
refreshNotePreviewPlayheadPosition();
|
|
|
|
|
2024-01-05 02:35:41 -05:00
|
|
|
// Update the measure tick display.
|
|
|
|
if (measureTicks != null) measureTicks.y = gridTiledSprite?.y ?? 0.0;
|
2023-10-26 05:46:22 -04:00
|
|
|
return this.scrollPositionInPixels;
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The relative scroll position in the song, 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
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The relative scroll position in the song, 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-12-14 16:56:20 -05:00
|
|
|
return Conductor.instance.getStepTimeInMs(scrollPositionInSteps);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_scrollPositionInMs(value:Float):Float
|
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
scrollPositionInSteps = Conductor.instance.getTimeInSteps(value);
|
2023-01-22 19:55:30 -05:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Playhead (on the grid)
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The position of the playhead, in pixels, relative to the `scrollPositionInPixels`.
|
|
|
|
* `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-01-22 19:55:30 -05:00
|
|
|
*/
|
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.
|
2024-01-04 08:20:34 -05:00
|
|
|
gridPlayhead.y = this.playheadPositionInPixels + GRID_INITIAL_Y_POS;
|
2023-07-19 01:30:36 -04:00
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
updatePlayheadGhostHoldNotes();
|
2024-01-08 21:26:24 -05:00
|
|
|
refreshNotePreviewPlayheadPosition();
|
2024-01-06 01:06:10 -05:00
|
|
|
|
2023-07-19 01:30:36 -04:00
|
|
|
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-12-14 16:56:20 -05:00
|
|
|
return Conductor.instance.getStepTimeInMs(playheadPositionInSteps);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
function set_playheadPositionInMs(value:Float):Float
|
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
playheadPositionInSteps = Conductor.instance.getTimeInSteps(value);
|
2023-12-01 19:58:58 -05:00
|
|
|
|
2023-08-28 15:03:29 -04:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Playbar (at the bottom)
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Tools Status
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2024-02-16 22:01:47 -05:00
|
|
|
* The note kind to use for notes being placed in the chart. Defaults to `null`.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2024-02-16 22:01:47 -05:00
|
|
|
var noteKindToPlace:Null<String> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The event type to use for events being placed in the chart. Defaults to `''`.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2024-01-03 19:53:17 -05:00
|
|
|
var eventKindToPlace:String = 'FocusCamera';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The event data to use for events being placed in the chart.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2024-01-03 19:53:17 -05:00
|
|
|
var eventDataToPlace:DynamicAccess<Dynamic> = {};
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -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.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var noteSnapQuantIndex:Int = BASE_QUANT_INDEX;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The current note snapping value.
|
|
|
|
* For example, `32` when snapping to 32nd notes.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var noteSnapQuant(get, never):Int;
|
|
|
|
|
|
|
|
function get_noteSnapQuant():Int
|
|
|
|
{
|
|
|
|
return SNAP_QUANTS[noteSnapQuantIndex];
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The ratio of the current note snapping value to the default.
|
|
|
|
* For example, `32` becomes `0.5` when snapping to 16th notes.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var noteSnapRatio(get, never):Float;
|
|
|
|
|
|
|
|
function get_noteSnapRatio():Float
|
|
|
|
{
|
|
|
|
return BASE_QUANT / noteSnapQuant;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The currently selected live input style.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var currentLiveInputStyle:ChartEditorLiveInputStyle = None;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* If true, playtesting a chart will skip to the current playhead position.
|
2023-06-08 16:53:52 -04:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var playtestStartTime:Bool = false;
|
|
|
|
|
2023-12-10 03:37:12 -05:00
|
|
|
/**
|
|
|
|
* If true, playtesting a chart will let you "gameover" / die when you lose ur health!
|
|
|
|
*/
|
|
|
|
var playtestPracticeMode:Bool = false;
|
|
|
|
|
2024-03-05 22:27:07 -05:00
|
|
|
/**
|
|
|
|
* If true, playtesting a chart will make the computer do it for you!
|
|
|
|
*/
|
|
|
|
var playtestBotPlayMode:Bool = false;
|
|
|
|
|
2023-12-15 02:29:32 -05:00
|
|
|
/**
|
|
|
|
* Enables or disables the "debugger" popup that appears when you run into a flixel error.
|
|
|
|
*/
|
|
|
|
var enabledDebuggerPopup:Bool = true;
|
|
|
|
|
2024-03-12 21:34:50 -04:00
|
|
|
/**
|
|
|
|
* Whether song scripts should be enabled during playtesting.
|
|
|
|
* You should probably check the box if the song has custom mechanics.
|
|
|
|
*/
|
|
|
|
var playtestSongScripts:Bool = true;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Visuals
|
2023-06-08 16:53:52 -04:00
|
|
|
|
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
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The current theme used by the editor.
|
|
|
|
* Dictates the appearance of many UI elements.
|
|
|
|
* Currently hardcoded to just Light and Dark.
|
2023-07-26 20:03:31 -04:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var currentTheme(default, set):ChartEditorTheme = ChartEditorTheme.Light;
|
2023-07-26 20:03:31 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
function set_currentTheme(value:ChartEditorTheme):ChartEditorTheme
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (value == null || value == currentTheme) return currentTheme;
|
|
|
|
|
|
|
|
currentTheme = value;
|
|
|
|
this.updateTheme();
|
|
|
|
return value;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The character sprite in the Player Preview window.
|
|
|
|
* `null` until accessed.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var currentPlayerCharacterPlayer:Null<CharacterPlayer> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The character sprite in the Opponent Preview window.
|
|
|
|
* `null` until accessed.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var currentOpponentCharacterPlayer:Null<CharacterPlayer> = null;
|
|
|
|
|
|
|
|
// HaxeUI
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-27 01:42:05 -04:00
|
|
|
* Whether the user is focused on an input in the Haxe UI, and inputs are being fed into it.
|
|
|
|
* If the user clicks off the input, focus will leave.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-27 01:42:05 -04:00
|
|
|
var isHaxeUIFocused(get, never):Bool;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-27 01:42:05 -04:00
|
|
|
function get_isHaxeUIFocused():Bool
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-27 01:42:05 -04:00
|
|
|
return FocusManager.instance.focus != null;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-11-21 02:12:34 -05:00
|
|
|
/**
|
|
|
|
* Whether the user's mouse cursor is hovering over a SOLID component of the HaxeUI.
|
|
|
|
* If so, we can ignore certain mouse events underneath.
|
|
|
|
*/
|
|
|
|
var isCursorOverHaxeUI(get, never):Bool;
|
|
|
|
|
|
|
|
function get_isCursorOverHaxeUI():Bool
|
|
|
|
{
|
|
|
|
return Screen.instance.hasSolidComponentUnderPoint(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The value of `isCursorOverHaxeUI` from the previous frame.
|
|
|
|
* This is useful because we may have just clicked a menu item, causing the menu to disappear.
|
|
|
|
*/
|
|
|
|
var wasCursorOverHaxeUI:Bool = false;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Set by ChartEditorDialogHandler, used to prevent background interaction while the dialog is open.
|
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var isHaxeUIDialogOpen:Bool = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The Dialog components representing the currently available tool windows.
|
|
|
|
* Dialogs are retained here even when collapsed or hidden.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var activeToolboxes:Map<String, CollapsibleDialog> = new Map<String, CollapsibleDialog>();
|
|
|
|
|
2024-02-01 15:52:50 -05:00
|
|
|
/**
|
|
|
|
* The camera component we're using for this state.
|
|
|
|
*/
|
|
|
|
var uiCamera:FlxCamera;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Audio
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
/**
|
2023-12-01 17:14:48 -05:00
|
|
|
* Whether to play a metronome sound while the playhead is moving, and what volume.
|
2023-09-26 17:46:07 -04:00
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var metronomeVolume:Float = 1.0;
|
|
|
|
|
|
|
|
/**
|
2024-02-19 20:18:32 -05:00
|
|
|
* The volume to play the player's hitsounds at.
|
2023-12-01 17:14:48 -05:00
|
|
|
*/
|
2024-02-19 20:18:32 -05:00
|
|
|
var hitsoundVolumePlayer:Float = 1.0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
2024-02-19 20:18:32 -05:00
|
|
|
* The volume to play the opponent's hitsounds at.
|
2023-10-26 05:46:22 -04:00
|
|
|
*/
|
2024-02-19 20:18:32 -05:00
|
|
|
var hitsoundVolumeOpponent:Float = 1.0;
|
2023-09-26 17:46:07 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Whether hitsounds are enabled for at least one character.
|
|
|
|
*/
|
|
|
|
var hitsoundsEnabled(get, never):Bool;
|
|
|
|
|
|
|
|
function get_hitsoundsEnabled():Bool
|
|
|
|
{
|
2024-02-19 20:18:32 -05:00
|
|
|
return hitsoundVolumePlayer + hitsoundVolumeOpponent > 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Auto-save
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* A timer used to auto-save the chart after a period of inactivity.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var autoSaveTimer:Null<FlxTimer> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Scrolling
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Whether the user's last mouse click was on the playhead scroll area.
|
|
|
|
*/
|
|
|
|
var gridPlayheadScrollAreaPressed:Bool = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -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.
|
|
|
|
*/
|
|
|
|
var notePreviewScrollAreaStartPos:Null<FlxPoint> = null;
|
2023-10-18 01:02:10 -04:00
|
|
|
|
2023-10-26 05:46:22 -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-12-01 17:14:48 -05:00
|
|
|
/**
|
|
|
|
* The position where the user middle clicked to place a scroll anchor.
|
|
|
|
* Scroll each frame with speed based on the distance between the mouse and the scroll anchor.
|
|
|
|
* `null` if no scroll anchor is present.
|
|
|
|
*/
|
|
|
|
var scrollAnchorScreenPos:Null<FlxPoint> = null;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Note Placement
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-09-26 17:46:07 -04:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The SongNoteData which is currently being placed.
|
|
|
|
* `null` if the user isn't currently placing a note.
|
|
|
|
* As the user drags, we will update this note's sustain length, and finalize the note when they release.
|
2023-09-26 17:46:07 -04:00
|
|
|
*/
|
2024-01-12 06:13:34 -05:00
|
|
|
var currentPlaceNoteData(default, set):Null<SongNoteData> = null;
|
|
|
|
|
|
|
|
function set_currentPlaceNoteData(value:Null<SongNoteData>):Null<SongNoteData>
|
|
|
|
{
|
|
|
|
noteDisplayDirty = true;
|
|
|
|
|
|
|
|
return currentPlaceNoteData = value;
|
|
|
|
}
|
2023-09-26 17:46:07 -04:00
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
/**
|
|
|
|
* The SongNoteData which is currently being placed, for each column.
|
|
|
|
* `null` if the user isn't currently placing a note.
|
|
|
|
* As the user moves down, we will update this note's sustain length, and finalize the note when they release.
|
|
|
|
*/
|
|
|
|
var currentLiveInputPlaceNoteData:Array<SongNoteData> = [];
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Note Movement
|
2023-09-26 17:46:07 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* The note sprite we are currently moving, if any.
|
|
|
|
*/
|
|
|
|
var dragTargetNote:Null<ChartEditorNoteSprite> = null;
|
2023-09-26 17:46:07 -04:00
|
|
|
|
2023-06-08 16:53:52 -04:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The song event sprite we are currently moving, if any.
|
2023-06-08 16:53:52 -04:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var dragTargetEvent:Null<ChartEditorEventSprite> = null;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* The amount of vertical steps the note sprite has moved by since the user started dragging.
|
|
|
|
*/
|
|
|
|
var dragTargetCurrentStep:Float = 0;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* The amount of horizontal columns the note sprite has moved by since the user started dragging.
|
|
|
|
*/
|
|
|
|
var dragTargetCurrentColumn:Int = 0;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Hold Note Dragging
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The current length of the hold note we are dragging, in steps.
|
|
|
|
* Play a sound when this value changes.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var dragLengthCurrent:Float = 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
/**
|
|
|
|
* The current length of the hold note we are placing with the playhead, in steps.
|
|
|
|
* Play a sound when this value changes.
|
|
|
|
*/
|
|
|
|
var playheadDragLengthCurrent:Array<Float> = [];
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Flip-flop to alternate between two stretching sounds.
|
|
|
|
*/
|
|
|
|
var stretchySounds:Bool = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Selection
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* The notes which are currently in the user's selection.
|
|
|
|
*/
|
2023-12-08 20:21:55 -05:00
|
|
|
var currentNoteSelection(default, set):Array<SongNoteData> = [];
|
|
|
|
|
|
|
|
function set_currentNoteSelection(value:Array<SongNoteData>):Array<SongNoteData>
|
|
|
|
{
|
2023-12-13 23:11:19 -05:00
|
|
|
// This value is true if all elements of the current selection are also in the new selection.
|
|
|
|
var isSuperset:Bool = currentNoteSelection.isSubset(value);
|
|
|
|
var isEqual:Bool = currentNoteSelection.isEqualUnordered(value);
|
|
|
|
|
2023-12-08 20:21:55 -05:00
|
|
|
currentNoteSelection = value;
|
|
|
|
|
2023-12-13 23:11:19 -05:00
|
|
|
if (!isEqual)
|
2023-12-08 20:21:55 -05:00
|
|
|
{
|
2023-12-13 23:11:19 -05:00
|
|
|
if (currentNoteSelection.length > 0 && isSuperset)
|
|
|
|
{
|
|
|
|
notePreview.addSelectedNotes(currentNoteSelection, Std.int(songLengthInMs));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// The new selection removes elements from the old selection, so we have to redraw the note preview.
|
|
|
|
notePreviewDirty = true;
|
|
|
|
}
|
2023-12-08 20:21:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return currentNoteSelection;
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The events which are currently in the user's selection.
|
|
|
|
*/
|
|
|
|
var currentEventSelection:Array<SongEventData> = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The position where the user clicked to start a selection.
|
|
|
|
* `null` if the user isn't currently selecting anything.
|
|
|
|
* The selection box extends from this point to the current mouse position.
|
|
|
|
*/
|
|
|
|
var selectionBoxStartPos:Null<FlxPoint> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// History
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Dirty Flags
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2024-03-21 23:57:26 -04:00
|
|
|
var noteTooltipsDirty: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
|
|
|
|
{
|
2024-06-05 19:25:53 -04:00
|
|
|
// trace('Note preview dirtied!');
|
2023-09-13 14:51:12 -04:00
|
|
|
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.
|
2023-10-26 05:46:22 -04:00
|
|
|
autoSaveTimer = new FlxTimer().start(Constants.AUTOSAVE_TIMER_DELAY_SEC, (_) -> autoSave());
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-10-24 15:50:02 -04:00
|
|
|
saveDataDirty = value;
|
|
|
|
applyWindowTitle();
|
|
|
|
return saveDataDirty;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-11-21 13:31:02 -05:00
|
|
|
var shouldShowBackupAvailableDialog(get, set):Bool;
|
|
|
|
|
|
|
|
function get_shouldShowBackupAvailableDialog():Bool
|
|
|
|
{
|
2024-03-04 16:37:42 -05:00
|
|
|
return Save.instance.chartEditorHasBackup;
|
2023-11-21 13:31:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_shouldShowBackupAvailableDialog(value:Bool):Bool
|
|
|
|
{
|
2024-03-04 16:37:42 -05:00
|
|
|
return Save.instance.chartEditorHasBackup = value;
|
2023-11-21 13:31:02 -05:00
|
|
|
}
|
|
|
|
|
2023-12-14 00:47:04 -05:00
|
|
|
/**
|
|
|
|
* A list of previous working file paths.
|
|
|
|
* Also known as the "recent files" list.
|
|
|
|
* The first element is [null] if the current working file has not been saved anywhere yet.
|
|
|
|
*/
|
|
|
|
public var previousWorkingFilePaths(default, set):Array<Null<String>> = [null];
|
|
|
|
|
|
|
|
function set_previousWorkingFilePaths(value:Array<Null<String>>):Array<Null<String>>
|
|
|
|
{
|
|
|
|
// Called only when the WHOLE LIST is overridden.
|
|
|
|
previousWorkingFilePaths = value;
|
|
|
|
applyWindowTitle();
|
|
|
|
populateOpenRecentMenu();
|
|
|
|
applyCanQuickSave();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current file path which the chart editor is working with.
|
|
|
|
* If `null`, the current chart has not been saved yet.
|
|
|
|
*/
|
|
|
|
public var currentWorkingFilePath(get, set):Null<String>;
|
|
|
|
|
|
|
|
function get_currentWorkingFilePath():Null<String>
|
|
|
|
{
|
|
|
|
return previousWorkingFilePaths[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentWorkingFilePath(value:Null<String>):Null<String>
|
|
|
|
{
|
|
|
|
if (value == previousWorkingFilePaths[0]) return value;
|
|
|
|
|
|
|
|
if (previousWorkingFilePaths.contains(null))
|
|
|
|
{
|
|
|
|
// Filter all instances of `null` from the array.
|
|
|
|
previousWorkingFilePaths = previousWorkingFilePaths.filter(function(x:Null<String>):Bool {
|
|
|
|
return x != null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (previousWorkingFilePaths.contains(value))
|
|
|
|
{
|
|
|
|
// Move the path to the front of the list.
|
|
|
|
previousWorkingFilePaths.remove(value);
|
|
|
|
previousWorkingFilePaths.unshift(value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Add the path to the front of the list.
|
|
|
|
previousWorkingFilePaths.unshift(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (previousWorkingFilePaths.length > Constants.MAX_PREVIOUS_WORKING_FILES)
|
|
|
|
{
|
|
|
|
// Remove the last path in the list.
|
|
|
|
previousWorkingFilePaths.pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
populateOpenRecentMenu();
|
|
|
|
applyWindowTitle();
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* Whether the undo/redo histories have changed since the last time the UI was updated.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var commandHistoryDirty:Bool = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-12-14 00:47:04 -05:00
|
|
|
/**
|
|
|
|
* If true, we are currently in the process of quitting the chart editor.
|
|
|
|
* Skip any update functions as most of them will call a crash.
|
|
|
|
*/
|
|
|
|
var criticalFailure:Bool = false;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Input
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
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);
|
|
|
|
|
2023-09-29 21:44:42 -04:00
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding the W keybind.
|
|
|
|
*/
|
|
|
|
var wKeyHandler:TurboKeyHandler = TurboKeyHandler.build(FlxKey.W);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding the S keybind.
|
|
|
|
*/
|
|
|
|
var sKeyHandler:TurboKeyHandler = TurboKeyHandler.build(FlxKey.S);
|
|
|
|
|
2023-02-28 21:06:09 -05:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding up on the dpad.
|
|
|
|
*/
|
|
|
|
var dpadUpGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.DPAD_UP);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding down on the dpad.
|
|
|
|
*/
|
|
|
|
var dpadDownGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.DPAD_DOWN);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding left on the dpad.
|
|
|
|
*/
|
|
|
|
var dpadLeftGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.DPAD_LEFT);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding right on the dpad.
|
|
|
|
*/
|
|
|
|
var dpadRightGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.DPAD_RIGHT);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding up on the left stick.
|
|
|
|
*/
|
|
|
|
var leftStickUpGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.LEFT_STICK_DIGITAL_UP);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding down on the left stick.
|
|
|
|
*/
|
|
|
|
var leftStickDownGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.LEFT_STICK_DIGITAL_DOWN);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding left on the left stick.
|
|
|
|
*/
|
|
|
|
var leftStickLeftGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.LEFT_STICK_DIGITAL_LEFT);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding right on the left stick.
|
|
|
|
*/
|
|
|
|
var leftStickRightGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.LEFT_STICK_DIGITAL_RIGHT);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding up on the right stick.
|
|
|
|
*/
|
|
|
|
var rightStickUpGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.RIGHT_STICK_DIGITAL_UP);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding down on the right stick.
|
|
|
|
*/
|
|
|
|
var rightStickDownGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.RIGHT_STICK_DIGITAL_DOWN);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding left on the right stick.
|
|
|
|
*/
|
|
|
|
var rightStickLeftGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.RIGHT_STICK_DIGITAL_LEFT);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Variable used to track how long the user has been holding right on the right stick.
|
|
|
|
*/
|
|
|
|
var rightStickRightGamepadHandler:TurboButtonHandler = TurboButtonHandler.build(FlxGamepadInputID.RIGHT_STICK_DIGITAL_RIGHT);
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* AUDIO AND SOUND DATA
|
|
|
|
*/
|
|
|
|
// ==============================
|
|
|
|
|
2023-09-29 22:29:32 -04:00
|
|
|
/**
|
2023-11-25 02:18:39 -05:00
|
|
|
* The chill audio track that plays in the chart editor.
|
|
|
|
* Plays when the main music is NOT being played.
|
2023-09-29 22:29:32 -04:00
|
|
|
*/
|
2024-03-23 17:50:48 -04:00
|
|
|
var welcomeMusic:FunkinSound = new FunkinSound();
|
2023-09-29 22:29:32 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* 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-12-08 01:15:22 -05:00
|
|
|
var audioInstTrack:Null<FunkinSound> = 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
|
|
|
*/
|
2024-02-02 21:53:45 -05:00
|
|
|
var audioVocalTrackGroup:VoicesGroup = new VoicesGroup();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-29 06:17:01 -05:00
|
|
|
/**
|
2024-01-23 23:24:05 -05:00
|
|
|
* The audio waveform visualization for the inst/vocals.
|
2023-11-29 06:17:01 -05:00
|
|
|
* `null` until vocal track(s) are loaded.
|
2024-01-23 23:24:05 -05:00
|
|
|
* When switching characters, the elements will be swapped to match the new character.
|
2023-11-29 06:17:01 -05:00
|
|
|
*/
|
2024-01-23 23:24:05 -05:00
|
|
|
var audioWaveforms:FlxTypedSpriteGroup<WaveformSprite> = new FlxTypedSpriteGroup<WaveformSprite>();
|
2023-11-29 06:17:01 -05:00
|
|
|
|
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);
|
2023-12-19 01:25:15 -05:00
|
|
|
return m?.playData?.difficulties ?? [Constants.DEFAULT_DIFFICULTY];
|
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)
|
|
|
|
{
|
2024-05-19 01:48:51 -04:00
|
|
|
result = new SongMetadata('Default Song Name', Constants.DEFAULT_ARTIST, selectedVariation);
|
2023-01-22 19:55:30 -05:00
|
|
|
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-12-19 01:25:15 -05:00
|
|
|
result = new SongChartData([Constants.DEFAULT_DIFFICULTY => 1.0], [], [Constants.DEFAULT_DIFFICULTY => []]);
|
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-10-17 02:42:52 -04:00
|
|
|
var result:Null<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-11-21 02:12:34 -05:00
|
|
|
trace('Initializing blank chart for difficulty ' + selectedDifficulty);
|
2023-01-22 19:55:30 -05:00
|
|
|
currentSongChartData.notes.set(selectedDifficulty, result);
|
2023-10-18 01:02:10 -04:00
|
|
|
currentSongMetadata.playData.difficulties.pushUnique(selectedDifficulty);
|
2023-01-22 19:55:30 -05:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongChartNoteData(value:Array<SongNoteData>):Array<SongNoteData>
|
|
|
|
{
|
|
|
|
currentSongChartData.notes.set(selectedDifficulty, value);
|
2023-10-18 01:02:10 -04:00
|
|
|
currentSongMetadata.playData.difficulties.pushUnique(selectedDifficulty);
|
2023-01-22 19:55:30 -05:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-02-08 19:22:28 -05:00
|
|
|
/**
|
|
|
|
* Convenience property to get the rating for this difficulty in the Freeplay menu.
|
|
|
|
*/
|
|
|
|
var currentSongChartDifficultyRating(get, set):Int;
|
|
|
|
|
|
|
|
function get_currentSongChartDifficultyRating():Int
|
|
|
|
{
|
|
|
|
var result:Null<Int> = currentSongMetadata.playData.ratings.get(selectedDifficulty);
|
|
|
|
if (result == null)
|
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
|
|
|
currentSongMetadata.playData.ratings.set(selectedDifficulty, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongChartDifficultyRating(value:Int):Int
|
|
|
|
{
|
|
|
|
currentSongMetadata.playData.ratings.set(selectedDifficulty, value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
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
|
|
|
{
|
2023-10-21 01:04:50 -04:00
|
|
|
if (currentSongMetadata.playData.noteStyle == null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
2023-10-21 01:04:50 -04:00
|
|
|
currentSongMetadata.playData.noteStyle = Constants.DEFAULT_NOTE_STYLE;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-21 01:04:50 -04:00
|
|
|
return currentSongMetadata.playData.noteStyle;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-09-25 23:24:07 -04:00
|
|
|
function set_currentSongNoteStyle(value:String):String
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-21 01:04:50 -04:00
|
|
|
return currentSongMetadata.playData.noteStyle = value;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2024-02-09 14:58:57 -05:00
|
|
|
var currentSongFreeplayPreviewStart(get, set):Int;
|
|
|
|
|
|
|
|
function get_currentSongFreeplayPreviewStart():Int
|
|
|
|
{
|
|
|
|
return currentSongMetadata.playData.previewStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongFreeplayPreviewStart(value:Int):Int
|
|
|
|
{
|
|
|
|
return currentSongMetadata.playData.previewStart = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
var currentSongFreeplayPreviewEnd(get, set):Int;
|
|
|
|
|
|
|
|
function get_currentSongFreeplayPreviewEnd():Int
|
|
|
|
{
|
|
|
|
return currentSongMetadata.playData.previewEnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongFreeplayPreviewEnd(value:Int):Int
|
|
|
|
{
|
|
|
|
return currentSongMetadata.playData.previewEnd = value;
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
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
|
|
|
|
{
|
2024-03-12 21:34:50 -04:00
|
|
|
return currentSongName.toLowerKebabCase().replace(' ', '-').sanitize();
|
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;
|
|
|
|
}
|
|
|
|
|
2024-01-19 23:02:43 -05:00
|
|
|
/**
|
|
|
|
* Convenience property to get the player charId for the current variation.
|
|
|
|
*/
|
|
|
|
var currentPlayerChar(get, set):String;
|
|
|
|
|
|
|
|
function get_currentPlayerChar():String
|
|
|
|
{
|
|
|
|
if (currentSongMetadata.playData.characters.player == null)
|
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
|
|
|
currentSongMetadata.playData.characters.player = Constants.DEFAULT_CHARACTER;
|
|
|
|
}
|
|
|
|
return currentSongMetadata.playData.characters.player;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentPlayerChar(value:String):String
|
|
|
|
{
|
|
|
|
return currentSongMetadata.playData.characters.player = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience property to get the opponent charId for the current variation.
|
|
|
|
*/
|
|
|
|
var currentOpponentChar(get, set):String;
|
|
|
|
|
|
|
|
function get_currentOpponentChar():String
|
|
|
|
{
|
|
|
|
if (currentSongMetadata.playData.characters.opponent == null)
|
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
|
|
|
currentSongMetadata.playData.characters.opponent = Constants.DEFAULT_CHARACTER;
|
|
|
|
}
|
|
|
|
return currentSongMetadata.playData.characters.opponent;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentOpponentChar(value:String):String
|
|
|
|
{
|
|
|
|
return currentSongMetadata.playData.characters.opponent = value;
|
|
|
|
}
|
|
|
|
|
2023-12-08 01:15:22 -05:00
|
|
|
/**
|
|
|
|
* Convenience property to get the song offset data for the current variation.
|
|
|
|
*/
|
|
|
|
var currentSongOffsets(get, set):SongOffsets;
|
|
|
|
|
|
|
|
function get_currentSongOffsets():SongOffsets
|
|
|
|
{
|
|
|
|
if (currentSongMetadata.offsets == null)
|
|
|
|
{
|
|
|
|
// Initialize to the default value if not set.
|
|
|
|
currentSongMetadata.offsets = new SongOffsets();
|
|
|
|
}
|
|
|
|
return currentSongMetadata.offsets;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentSongOffsets(value:SongOffsets):SongOffsets
|
|
|
|
{
|
|
|
|
return currentSongMetadata.offsets = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
var currentInstrumentalOffset(get, set):Float;
|
|
|
|
|
|
|
|
function get_currentInstrumentalOffset():Float
|
|
|
|
{
|
|
|
|
// TODO: Apply for alt instrumentals.
|
|
|
|
return currentSongOffsets.getInstrumentalOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentInstrumentalOffset(value:Float):Float
|
|
|
|
{
|
|
|
|
// TODO: Apply for alt instrumentals.
|
|
|
|
currentSongOffsets.setInstrumentalOffset(value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2024-01-27 03:24:49 -05:00
|
|
|
var currentVocalOffsetPlayer(get, set):Float;
|
2024-01-19 23:02:43 -05:00
|
|
|
|
2024-01-27 03:24:49 -05:00
|
|
|
function get_currentVocalOffsetPlayer():Float
|
2024-01-19 23:02:43 -05:00
|
|
|
{
|
|
|
|
return currentSongOffsets.getVocalOffset(currentPlayerChar);
|
|
|
|
}
|
|
|
|
|
2024-01-27 03:24:49 -05:00
|
|
|
function set_currentVocalOffsetPlayer(value:Float):Float
|
2024-01-19 23:02:43 -05:00
|
|
|
{
|
|
|
|
currentSongOffsets.setVocalOffset(currentPlayerChar, value);
|
2024-01-27 03:24:49 -05:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
var currentVocalOffsetOpponent(get, set):Float;
|
|
|
|
|
|
|
|
function get_currentVocalOffsetOpponent():Float
|
|
|
|
{
|
|
|
|
return currentSongOffsets.getVocalOffset(currentOpponentChar);
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentVocalOffsetOpponent(value:Float):Float
|
|
|
|
{
|
2024-01-19 23:02:43 -05:00
|
|
|
currentSongOffsets.setVocalOffset(currentOpponentChar, value);
|
|
|
|
return value;
|
2023-12-08 01:15:22 -05:00
|
|
|
}
|
|
|
|
|
2023-08-14 23:13:12 -04:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The variation ID for the difficulty which is currently being edited.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var selectedVariation(default, set):String = Constants.DEFAULT_VARIATION;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -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
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
function set_selectedVariation(value:String):String
|
|
|
|
{
|
|
|
|
// Don't update if we're already on the variation.
|
|
|
|
if (selectedVariation == value) return selectedVariation;
|
|
|
|
selectedVariation = value;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Make sure view is updated when the variation changes.
|
|
|
|
noteDisplayDirty = true;
|
|
|
|
notePreviewDirty = true;
|
2024-03-21 23:57:26 -04:00
|
|
|
noteTooltipsDirty = true;
|
2023-10-26 05:46:22 -04:00
|
|
|
notePreviewViewportBoundsDirty = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
switchToCurrentInstrumental();
|
2023-08-16 03:40:44 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
return selectedVariation;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* The difficulty ID for the difficulty which is currently being edited.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
var selectedDifficulty(default, set):String = Constants.DEFAULT_DIFFICULTY;
|
|
|
|
|
|
|
|
function set_selectedDifficulty(value:String):String
|
|
|
|
{
|
2023-12-19 01:25:15 -05:00
|
|
|
if (value == null) value = availableDifficulties[0] ?? Constants.DEFAULT_DIFFICULTY;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
selectedDifficulty = value;
|
|
|
|
|
|
|
|
// Make sure view is updated when the difficulty changes.
|
|
|
|
noteDisplayDirty = true;
|
|
|
|
notePreviewDirty = true;
|
2024-03-21 23:57:26 -04:00
|
|
|
noteTooltipsDirty = true;
|
2023-10-26 05:46:22 -04:00
|
|
|
notePreviewViewportBoundsDirty = true;
|
|
|
|
|
|
|
|
// Make sure the difficulty we selected is in the list of difficulties.
|
|
|
|
currentSongMetadata.playData.difficulties.pushUnique(selectedDifficulty);
|
|
|
|
|
|
|
|
return selectedDifficulty;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* HAXEUI COMPONENTS
|
|
|
|
*/
|
|
|
|
// ==============================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The layout containing the playbar.
|
|
|
|
* Constructed manually and added to the layout so we can control its position.
|
|
|
|
*/
|
|
|
|
var playbarHeadLayout:Null<ChartEditorPlaybarHead> = null;
|
|
|
|
|
|
|
|
// NOTE: All the components below are automatically assigned via HaxeUI macros.
|
2023-12-01 17:14:48 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The menubar at the top of the screen.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubar:MenuBar;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `File -> New Chart` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemNewChart:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `File -> Open Chart` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemOpenChart:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `File -> Open Recent` menu.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarOpenRecent:Menu;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `File -> Save Chart` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemSaveChart:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `File -> Save Chart As` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemSaveChartAs:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `File -> Preferences` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemPreferences:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `File -> Exit` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemExit:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `Edit -> Undo` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemUndo:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `Edit -> Redo` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemRedo:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `Edit -> Cut` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemCut:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `Edit -> Copy` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemCopy:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `Edit -> Paste` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemPaste:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `Edit -> Paste Unsnapped` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemPasteUnsnapped:MenuItem;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The `Edit -> Delete` menu item.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var menubarItemDelete:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Edit -> Flip Notes` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemFlipNotes:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Edit -> Select All` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemSelectAll:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Edit -> Select Inverse` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemSelectInverse:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Edit -> Select None` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemSelectNone:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Edit -> Select Region` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemSelectRegion:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Edit -> Select Before Cursor` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemSelectBeforeCursor:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Edit -> Select After Cursor` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemSelectAfterCursor:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Edit -> Decrease Note Snap Precision` menu item.
|
|
|
|
*/
|
|
|
|
var menuBarItemNoteSnapDecrease:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Edit -> Decrease Note Snap Precision` menu item.
|
|
|
|
*/
|
|
|
|
var menuBarItemNoteSnapIncrease:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `View -> Downscroll` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemDownscroll:MenuCheckBox;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `View -> Increase Difficulty` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemDifficultyUp:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `View -> Decrease Difficulty` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemDifficultyDown:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Audio -> Play/Pause` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemPlayPause:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Audio -> Load Instrumental` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemLoadInstrumental:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Audio -> Load Vocals` menu item.
|
|
|
|
*/
|
|
|
|
var menubarItemLoadVocals:MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Audio -> Metronome Volume` label.
|
|
|
|
*/
|
|
|
|
var menubarLabelVolumeMetronome:Label;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Audio -> Metronome Volume` slider.
|
|
|
|
*/
|
|
|
|
var menubarItemVolumeMetronome:Slider;
|
|
|
|
|
|
|
|
/**
|
2024-02-19 20:18:32 -05:00
|
|
|
* The `Audio -> Play Theme Music` menu checkbox.
|
2023-12-01 17:14:48 -05:00
|
|
|
*/
|
2024-02-19 20:18:32 -05:00
|
|
|
var menubarItemThemeMusic:MenuCheckBox;
|
2023-12-01 17:14:48 -05:00
|
|
|
|
|
|
|
/**
|
2024-02-19 20:18:32 -05:00
|
|
|
* The `Audio -> Player Hitsound Volume` label.
|
2023-12-01 17:14:48 -05:00
|
|
|
*/
|
2024-02-19 20:18:32 -05:00
|
|
|
var menubarLabelVolumeHitsoundPlayer:Label;
|
2023-12-01 17:14:48 -05:00
|
|
|
|
2024-01-12 18:29:02 -05:00
|
|
|
/**
|
2024-02-19 20:18:32 -05:00
|
|
|
* The `Audio -> Enemy Hitsound Volume` label.
|
2024-01-12 18:29:02 -05:00
|
|
|
*/
|
2024-02-19 20:18:32 -05:00
|
|
|
var menubarLabelVolumeHitsoundOpponent:Label;
|
2024-01-12 18:29:02 -05:00
|
|
|
|
2023-12-01 17:14:48 -05:00
|
|
|
/**
|
2024-02-19 20:18:32 -05:00
|
|
|
* The `Audio -> Player Hitsound Volume` slider.
|
2023-12-01 17:14:48 -05:00
|
|
|
*/
|
2024-02-19 20:18:32 -05:00
|
|
|
var menubarItemVolumeHitsoundPlayer:Slider;
|
2023-12-01 17:14:48 -05:00
|
|
|
|
|
|
|
/**
|
2024-02-19 20:18:32 -05:00
|
|
|
* The `Audio -> Enemy Hitsound Volume` slider.
|
2023-12-01 17:14:48 -05:00
|
|
|
*/
|
2024-02-19 20:18:32 -05:00
|
|
|
var menubarItemVolumeHitsoundOpponent:Slider;
|
2023-12-01 17:14:48 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Audio -> Instrumental Volume` label.
|
|
|
|
*/
|
|
|
|
var menubarLabelVolumeInstrumental:Label;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Audio -> Instrumental Volume` slider.
|
|
|
|
*/
|
|
|
|
var menubarItemVolumeInstrumental:Slider;
|
|
|
|
|
|
|
|
/**
|
2024-01-23 01:51:13 -05:00
|
|
|
* The `Audio -> Player Volume` label.
|
2023-12-01 17:14:48 -05:00
|
|
|
*/
|
2024-01-23 01:51:13 -05:00
|
|
|
var menubarLabelVolumeVocalsPlayer:Label;
|
2023-12-01 17:14:48 -05:00
|
|
|
|
|
|
|
/**
|
2024-01-23 01:51:13 -05:00
|
|
|
* The `Audio -> Enemy Volume` label.
|
2023-12-01 17:14:48 -05:00
|
|
|
*/
|
2024-01-23 01:51:13 -05:00
|
|
|
var menubarLabelVolumeVocalsOpponent:Label;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Audio -> Player Volume` slider.
|
2023-12-01 17:14:48 -05:00
|
|
|
*/
|
2024-01-23 01:51:13 -05:00
|
|
|
var menubarItemVolumeVocalsPlayer:Slider;
|
2023-12-01 17:14:48 -05:00
|
|
|
|
|
|
|
/**
|
2024-01-23 01:51:13 -05:00
|
|
|
* The `Audio -> Enemy Volume` slider.
|
2023-12-01 17:14:48 -05:00
|
|
|
*/
|
2024-01-23 01:51:13 -05:00
|
|
|
var menubarItemVolumeVocalsOpponent:Slider;
|
2023-12-01 17:14:48 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Audio -> Playback Speed` label.
|
|
|
|
*/
|
|
|
|
var menubarLabelPlaybackSpeed:Label;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The `Audio -> Playback Speed` slider.
|
|
|
|
*/
|
|
|
|
var menubarItemPlaybackSpeed:Slider;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The label by the playbar telling the song position.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var playbarSongPos:Label;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The label by the playbar telling the song time remaining.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var playbarSongRemaining:Label;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The label by the playbar telling the note snap.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var playbarNoteSnap:Label;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The button by the playbar to jump to the start of the song.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var playbarStart:Button;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The button by the playbar to jump backwards in the song.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var playbarBack:Button;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The button by the playbar to play or pause the song.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var playbarPlay:Button;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The button by the playbar to jump forwards in the song.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var playbarForward:Button;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
/**
|
|
|
|
* The button by the playbar to jump to the end of the song.
|
|
|
|
*/
|
2023-12-01 17:14:48 -05:00
|
|
|
var playbarEnd:Button;
|
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
/**
|
|
|
|
* The button above the grid that selects all notes on the opponent's side.
|
|
|
|
* Constructed manually and added to the layout so we can control its position.
|
|
|
|
*/
|
|
|
|
var buttonSelectOpponent:Button;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The button above the grid that selects all notes on the player's side.
|
|
|
|
* Constructed manually and added to the layout so we can control its position.
|
|
|
|
*/
|
|
|
|
var buttonSelectPlayer:Button;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The button above the grid that selects all song events.
|
|
|
|
* Constructed manually and added to the layout so we can control its position.
|
|
|
|
*/
|
|
|
|
var buttonSelectEvent:Button;
|
|
|
|
|
2024-01-17 18:24:03 -05:00
|
|
|
/**
|
|
|
|
* The slider above the grid that sets the volume of the player's sounds.
|
|
|
|
* Constructed manually and added to the layout so we can control its position.
|
|
|
|
*/
|
|
|
|
var sliderVolumePlayer:Slider;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The slider above the grid that sets the volume of the opponent's sounds.
|
|
|
|
* Constructed manually and added to the layout so we can control its position.
|
|
|
|
*/
|
|
|
|
var sliderVolumeOpponent:Slider;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* RENDER OBJECTS
|
|
|
|
*/
|
|
|
|
// ==============================
|
|
|
|
|
2023-11-29 05:49:59 -05:00
|
|
|
/**
|
|
|
|
* The group containing the visulizers! */
|
|
|
|
var visulizerGrps:FlxTypedGroup<PolygonSpectogram> = null;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* The IMAGE used for the grid. Updated by ChartEditorThemeHandler.
|
|
|
|
*/
|
|
|
|
var gridBitmap:Null<BitmapData> = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
var selectionSquareBitmap:Null<BitmapData> = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
var notePreviewViewportBitmap:Null<BitmapData> = null;
|
|
|
|
|
2024-01-20 14:07:31 -05:00
|
|
|
/**
|
2024-01-05 02:35:41 -05:00
|
|
|
* The IMAGE used for the measure ticks. Updated by ChartEditorThemeHandler.
|
|
|
|
*/
|
|
|
|
var measureTickBitmap:Null<BitmapData> = null;
|
|
|
|
|
2024-01-20 14:07:31 -05:00
|
|
|
/**
|
|
|
|
* The IMAGE used for the offset ticks. Updated by ChartEditorThemeHandler.
|
|
|
|
*/
|
|
|
|
var offsetTickBitmap:Null<BitmapData> = null;
|
|
|
|
|
2023-10-26 05:46:22 -04: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.
|
|
|
|
*/
|
|
|
|
var gridTiledSprite:Null<FlxSprite> = null;
|
|
|
|
|
|
|
|
/**
|
2024-01-05 02:35:41 -05:00
|
|
|
* The measure ticks area. Includes the numbers and the background sprite.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2024-01-05 02:35:41 -05:00
|
|
|
var measureTicks:Null<ChartEditorMeasureTicks> = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
2024-01-05 02:35:41 -05:00
|
|
|
* The playhead representing the current position in the song.
|
|
|
|
* Can move around on the grid independently of the view.
|
2023-10-26 05:46:22 -04:00
|
|
|
*/
|
2024-01-05 02:35:41 -05:00
|
|
|
var gridPlayhead:FlxSpriteGroup = new FlxSpriteGroup();
|
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
|
|
|
/**
|
2024-01-06 01:06:10 -05:00
|
|
|
* A sprite used to indicate the hold note that will be placed on click.
|
2023-09-11 19:42:10 -04:00
|
|
|
*/
|
|
|
|
var gridGhostHoldNote:Null<ChartEditorHoldNoteSprite> = null;
|
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
/**
|
|
|
|
* A sprite used to indicate the hold note that will be placed on button release.
|
|
|
|
*/
|
|
|
|
var gridPlayheadGhostHoldNotes:Array<ChartEditorHoldNoteSprite> = [];
|
|
|
|
|
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 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
|
|
|
|
2024-01-08 21:26:24 -05:00
|
|
|
/**
|
|
|
|
* The thin sprite used for representing the playhead on the note preview.
|
|
|
|
* We move this up and down to represent the current position.
|
|
|
|
*/
|
|
|
|
var notePreviewPlayhead:Null<FlxSprite> = null;
|
|
|
|
|
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
|
|
|
|
2023-12-08 22:28:34 -05:00
|
|
|
/**
|
|
|
|
* The text that pop's up when copying something
|
|
|
|
*/
|
|
|
|
var txtCopyNotif:Null<FlxText> = 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;
|
|
|
|
|
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-10-26 05:46:22 -04:00
|
|
|
var renderedSelectionSquares:FlxTypedSpriteGroup<ChartEditorSelectionSquareSprite> = new FlxTypedSpriteGroup<ChartEditorSelectionSquareSprite>();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* LIFE CYCLE FUNCTIONS
|
|
|
|
*/
|
|
|
|
// ==============================
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-21 01:04:50 -04:00
|
|
|
/**
|
|
|
|
* The params which were passed in when the Chart Editor was initialized.
|
|
|
|
*/
|
|
|
|
var params:Null<ChartEditorParams>;
|
|
|
|
|
|
|
|
public function new(?params:ChartEditorParams)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-11-24 00:42:07 -05:00
|
|
|
super();
|
2023-10-21 01:04:50 -04:00
|
|
|
this.params = params;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
public override function dispatchEvent(event:ScriptEvent):Void
|
|
|
|
{
|
|
|
|
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 UPDATE:
|
|
|
|
currentPlayerCharacterPlayer.onUpdate(cast event);
|
|
|
|
case SONG_BEAT_HIT:
|
|
|
|
currentPlayerCharacterPlayer.onBeatHit(cast event);
|
|
|
|
case SONG_STEP_HIT:
|
|
|
|
currentPlayerCharacterPlayer.onStepHit(cast event);
|
|
|
|
case NOTE_HIT:
|
|
|
|
currentPlayerCharacterPlayer.onNoteHit(cast event);
|
|
|
|
default: // Continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentOpponentCharacterPlayer != null)
|
|
|
|
{
|
|
|
|
switch (event.type)
|
|
|
|
{
|
|
|
|
case UPDATE:
|
|
|
|
currentOpponentCharacterPlayer.onUpdate(cast event);
|
|
|
|
case SONG_BEAT_HIT:
|
|
|
|
currentOpponentCharacterPlayer.onBeatHit(cast event);
|
|
|
|
case SONG_STEP_HIT:
|
|
|
|
currentOpponentCharacterPlayer.onStepHit(cast event);
|
|
|
|
case NOTE_HIT:
|
|
|
|
currentOpponentCharacterPlayer.onNoteHit(cast event);
|
|
|
|
default: // Continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
|
2023-11-24 00:42:07 -05:00
|
|
|
this.root.zIndex = 100;
|
2023-07-26 16:52:58 -04:00
|
|
|
|
2024-01-12 18:29:02 -05:00
|
|
|
// Get rid of any music from the previous state.
|
|
|
|
if (FlxG.sound.music != null) FlxG.sound.music.stop();
|
|
|
|
|
|
|
|
// Play the welcome music.
|
|
|
|
setupWelcomeMusic();
|
|
|
|
|
2023-09-12 18:37:59 -04:00
|
|
|
// Show the mouse cursor.
|
|
|
|
Cursor.show();
|
|
|
|
|
2023-10-22 15:43:39 -04:00
|
|
|
loadPreferences();
|
|
|
|
|
2024-04-10 14:45:07 -04:00
|
|
|
uiCamera = new FunkinCamera('chartEditorUI');
|
2024-02-01 15:52:50 -05:00
|
|
|
FlxG.cameras.reset(uiCamera);
|
2023-07-26 16:52:58 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
buildDefaultSongData();
|
|
|
|
|
|
|
|
buildBackground();
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
this.updateTheme();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
buildGrid();
|
2024-01-05 02:35:41 -05:00
|
|
|
buildMeasureTicks();
|
2023-06-08 16:53:52 -04:00
|
|
|
buildNotePreview();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
buildAdditionalUI();
|
2023-10-22 15:43:39 -04:00
|
|
|
populateOpenRecentMenu();
|
2023-11-21 13:31:02 -05:00
|
|
|
this.applyPlatformShortcutText();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// Setup the onClick listeners for the UI after it's been created.
|
|
|
|
setupUIListeners();
|
2024-01-03 19:53:17 -05:00
|
|
|
setupContextMenu();
|
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-10-21 01:04:50 -04:00
|
|
|
if (params != null && params.fnfcTargetPath != null)
|
|
|
|
{
|
|
|
|
// Chart editor was opened from the command line. Open the FNFC file now!
|
2023-11-21 13:31:02 -05:00
|
|
|
var result:Null<Array<String>> = this.loadFromFNFCPath(params.fnfcTargetPath);
|
2023-10-24 15:50:02 -04:00
|
|
|
if (result != null)
|
2023-10-21 01:04:50 -04:00
|
|
|
{
|
2023-11-22 19:16:38 -05:00
|
|
|
if (result.length == 0)
|
|
|
|
{
|
|
|
|
this.success('Loaded Chart', 'Loaded chart (${params.fnfcTargetPath})');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.warning('Loaded Chart', 'Loaded chart with issues (${params.fnfcTargetPath})\n${result.join("\n")}');
|
|
|
|
}
|
2023-10-21 01:04:50 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-22 19:16:38 -05:00
|
|
|
this.error('Failure', 'Failed to load chart (${params.fnfcTargetPath})');
|
2023-10-24 15:50:02 -04:00
|
|
|
|
2023-10-21 01:04:50 -04:00
|
|
|
// Song failed to load, open the Welcome dialog so we aren't in a broken state.
|
2023-11-22 19:17:35 -05:00
|
|
|
var welcomeDialog = this.openWelcomeDialog(false);
|
|
|
|
if (shouldShowBackupAvailableDialog)
|
|
|
|
{
|
|
|
|
this.openBackupAvailableDialog(welcomeDialog);
|
|
|
|
}
|
2023-10-21 01:04:50 -04:00
|
|
|
}
|
|
|
|
}
|
2023-11-16 00:02:42 -05:00
|
|
|
else if (params != null && params.targetSongId != null)
|
|
|
|
{
|
|
|
|
this.loadSongAsTemplate(params.targetSongId);
|
|
|
|
}
|
2023-10-21 01:04:50 -04:00
|
|
|
else
|
|
|
|
{
|
2023-11-22 19:16:38 -05:00
|
|
|
var welcomeDialog = this.openWelcomeDialog(false);
|
|
|
|
if (shouldShowBackupAvailableDialog)
|
|
|
|
{
|
|
|
|
this.openBackupAvailableDialog(welcomeDialog);
|
|
|
|
}
|
2023-10-21 01:04:50 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-09-29 22:29:32 -04:00
|
|
|
function setupWelcomeMusic()
|
|
|
|
{
|
|
|
|
this.welcomeMusic.loadEmbedded(Paths.music('chartEditorLoop/chartEditorLoop'));
|
2023-11-24 00:42:07 -05:00
|
|
|
FlxG.sound.list.add(this.welcomeMusic);
|
2023-09-29 22:29:32 -04:00
|
|
|
this.welcomeMusic.looped = true;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
|
2023-10-22 15:43:39 -04:00
|
|
|
public function loadPreferences():Void
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2024-03-04 16:37:42 -05:00
|
|
|
var save:Save = Save.instance;
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2023-10-24 15:50:02 -04:00
|
|
|
if (previousWorkingFilePaths[0] == null)
|
|
|
|
{
|
|
|
|
previousWorkingFilePaths = [null].concat(save.chartEditorPreviousFiles);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
previousWorkingFilePaths = [currentWorkingFilePath].concat(save.chartEditorPreviousFiles);
|
|
|
|
}
|
2023-10-22 15:43:39 -04:00
|
|
|
noteSnapQuantIndex = save.chartEditorNoteQuant;
|
|
|
|
currentLiveInputStyle = save.chartEditorLiveInputStyle;
|
|
|
|
isViewDownscroll = save.chartEditorDownscroll;
|
|
|
|
playtestStartTime = save.chartEditorPlaytestStartTime;
|
|
|
|
currentTheme = save.chartEditorTheme;
|
2023-12-01 17:14:48 -05:00
|
|
|
metronomeVolume = save.chartEditorMetronomeVolume;
|
2024-02-19 20:18:32 -05:00
|
|
|
hitsoundVolumePlayer = save.chartEditorHitsoundVolumePlayer;
|
|
|
|
hitsoundVolumePlayer = save.chartEditorHitsoundVolumeOpponent;
|
2024-01-12 18:29:02 -05:00
|
|
|
this.welcomeMusic.active = save.chartEditorThemeMusic;
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2023-10-22 15:43:39 -04:00
|
|
|
// audioInstTrack.volume = save.chartEditorInstVolume;
|
|
|
|
// audioInstTrack.pitch = save.chartEditorPlaybackSpeed;
|
|
|
|
// audioVocalTrackGroup.volume = save.chartEditorVoicesVolume;
|
|
|
|
// audioVocalTrackGroup.pitch = save.chartEditorPlaybackSpeed;
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2023-11-21 13:31:02 -05:00
|
|
|
public function writePreferences(hasBackup:Bool):Void
|
2023-10-22 15:43:39 -04:00
|
|
|
{
|
2024-03-04 16:37:42 -05:00
|
|
|
var save:Save = Save.instance;
|
2023-10-22 15:43:39 -04:00
|
|
|
|
2023-10-24 15:50:02 -04:00
|
|
|
// Can't use filter() because of null safety checking!
|
|
|
|
var filteredWorkingFilePaths:Array<String> = [];
|
|
|
|
for (chartPath in previousWorkingFilePaths)
|
|
|
|
if (chartPath != null) filteredWorkingFilePaths.push(chartPath);
|
|
|
|
save.chartEditorPreviousFiles = filteredWorkingFilePaths;
|
|
|
|
|
2023-11-22 19:17:35 -05:00
|
|
|
if (hasBackup) trace('Queuing backup prompt for next time!');
|
2023-11-21 13:31:02 -05:00
|
|
|
save.chartEditorHasBackup = hasBackup;
|
2023-11-22 19:17:35 -05:00
|
|
|
|
2023-10-22 15:43:39 -04:00
|
|
|
save.chartEditorNoteQuant = noteSnapQuantIndex;
|
|
|
|
save.chartEditorLiveInputStyle = currentLiveInputStyle;
|
|
|
|
save.chartEditorDownscroll = isViewDownscroll;
|
|
|
|
save.chartEditorPlaytestStartTime = playtestStartTime;
|
|
|
|
save.chartEditorTheme = currentTheme;
|
2023-12-01 17:14:48 -05:00
|
|
|
save.chartEditorMetronomeVolume = metronomeVolume;
|
2024-02-19 20:18:32 -05:00
|
|
|
save.chartEditorHitsoundVolumePlayer = hitsoundVolumePlayer;
|
|
|
|
save.chartEditorHitsoundVolumeOpponent = hitsoundVolumeOpponent;
|
2024-01-12 18:29:02 -05:00
|
|
|
save.chartEditorThemeMusic = this.welcomeMusic.active;
|
2023-10-22 15:43:39 -04:00
|
|
|
|
|
|
|
// save.chartEditorInstVolume = audioInstTrack.volume;
|
|
|
|
// save.chartEditorVoicesVolume = audioVocalTrackGroup.volume;
|
|
|
|
// save.chartEditorPlaybackSpeed = audioInstTrack.pitch;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-22 15:43:39 -04:00
|
|
|
public function populateOpenRecentMenu():Void
|
2023-09-29 22:29:32 -04:00
|
|
|
{
|
2023-10-22 15:43:39 -04:00
|
|
|
if (menubarOpenRecent == null) return;
|
|
|
|
|
|
|
|
#if sys
|
2023-10-23 12:22:29 -04:00
|
|
|
menubarOpenRecent.removeAllComponents();
|
2023-10-22 15:43:39 -04:00
|
|
|
|
|
|
|
for (chartPath in previousWorkingFilePaths)
|
|
|
|
{
|
2023-10-23 12:22:29 -04:00
|
|
|
if (chartPath == null) continue;
|
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
var menuItemRecentChart:MenuItem = new MenuItem();
|
2023-10-22 15:43:39 -04:00
|
|
|
menuItemRecentChart.text = chartPath;
|
|
|
|
menuItemRecentChart.onClick = function(_event) {
|
|
|
|
// Load chart from file
|
2023-11-21 13:31:02 -05:00
|
|
|
var result:Null<Array<String>> = this.loadFromFNFCPath(chartPath);
|
2023-10-24 15:50:02 -04:00
|
|
|
if (result != null)
|
|
|
|
{
|
2023-11-22 19:16:38 -05:00
|
|
|
if (result.length == 0)
|
|
|
|
{
|
|
|
|
this.success('Loaded Chart', 'Loaded chart (${chartPath.toString()})');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.warning('Loaded Chart', 'Loaded chart with issues (${chartPath.toString()})\n${result.join("\n")}');
|
|
|
|
}
|
2023-10-24 15:50:02 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-22 20:25:25 -05:00
|
|
|
this.error('Failure', 'Failed to load chart (${chartPath.toString()})');
|
2023-10-24 15:50:02 -04:00
|
|
|
}
|
2023-10-22 15:43:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!FileUtil.doesFileExist(chartPath))
|
|
|
|
{
|
2023-11-22 20:25:25 -05:00
|
|
|
trace('Previously loaded chart file (${chartPath.toString()}) does not exist, disabling link...');
|
2023-10-22 15:43:39 -04:00
|
|
|
menuItemRecentChart.disabled = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menuItemRecentChart.disabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
menubarOpenRecent.addComponent(menuItemRecentChart);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
menubarOpenRecent.hide();
|
|
|
|
#end
|
2023-09-29 22:29:32 -04:00
|
|
|
}
|
|
|
|
|
2023-11-25 02:18:39 -05:00
|
|
|
var bgMusicTimer:FlxTimer;
|
|
|
|
|
|
|
|
function fadeInWelcomeMusic(?extraWait:Float = 0, ?fadeInTime:Float = 5):Void
|
2023-09-29 22:29:32 -04:00
|
|
|
{
|
2024-01-12 18:29:02 -05:00
|
|
|
if (!this.welcomeMusic.active)
|
|
|
|
{
|
|
|
|
stopWelcomeMusic();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-11-25 02:18:39 -05:00
|
|
|
bgMusicTimer = new FlxTimer().start(extraWait, (_) -> {
|
|
|
|
this.welcomeMusic.volume = 0;
|
2024-01-12 18:29:02 -05:00
|
|
|
if (this.welcomeMusic.active)
|
|
|
|
{
|
|
|
|
this.welcomeMusic.play();
|
|
|
|
this.welcomeMusic.fadeIn(fadeInTime, 0, 1.0);
|
|
|
|
}
|
2023-11-25 02:18:39 -05:00
|
|
|
});
|
2023-09-29 22:29:32 -04:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
function stopWelcomeMusic():Void
|
2023-09-29 22:29:32 -04:00
|
|
|
{
|
2023-11-25 02:18:39 -05:00
|
|
|
if (bgMusicTimer != null) bgMusicTimer.cancel();
|
2023-09-29 22:29:32 -04:00
|
|
|
// this.welcomeMusic.fadeOut(4, 0);
|
|
|
|
this.welcomeMusic.pause();
|
|
|
|
}
|
|
|
|
|
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>();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
}
|
|
|
|
|
2023-11-29 01:43:59 -05:00
|
|
|
var oppSpectogram:PolygonSpectogram;
|
|
|
|
|
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);
|
2024-01-04 08:20:34 -05:00
|
|
|
gridTiledSprite.x = GRID_X_POS; // Center the grid.
|
|
|
|
gridTiledSprite.y = GRID_INITIAL_Y_POS; // Push down to account for the menu bar.
|
2023-01-22 19:55:30 -05:00
|
|
|
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;
|
2024-01-06 01:06:10 -05:00
|
|
|
gridGhostHoldNote.noteData = null;
|
2023-09-11 19:42:10 -04:00
|
|
|
gridGhostHoldNote.visible = false;
|
|
|
|
add(gridGhostHoldNote);
|
|
|
|
gridGhostHoldNote.zIndex = 11;
|
|
|
|
|
2024-01-04 10:00:39 -05:00
|
|
|
gridGhostEvent = new ChartEditorEventSprite(this, true);
|
2023-01-22 19:55:30 -05:00
|
|
|
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();
|
|
|
|
|
|
|
|
// 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);
|
2024-01-04 08:20:34 -05:00
|
|
|
var playheadBaseYPos:Float = GRID_INITIAL_Y_POS;
|
|
|
|
gridPlayhead.setPosition(GRID_X_POS, playheadBaseYPos);
|
2024-01-16 16:49:15 -05:00
|
|
|
var playheadSprite:FunkinSprite = new FunkinSprite().makeSolidColor(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);
|
|
|
|
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);
|
|
|
|
healthIconBF.flipX = true;
|
|
|
|
add(healthIconBF);
|
2023-07-26 16:52:58 -04:00
|
|
|
healthIconBF.zIndex = 30;
|
2023-11-29 05:49:59 -05:00
|
|
|
|
2024-01-23 23:24:05 -05:00
|
|
|
add(audioWaveforms);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2024-01-05 02:35:41 -05:00
|
|
|
function buildMeasureTicks():Void
|
|
|
|
{
|
|
|
|
measureTicks = new ChartEditorMeasureTicks(this);
|
|
|
|
var measureTicksWidth = (GRID_SIZE);
|
|
|
|
measureTicks.x = gridTiledSprite.x - measureTicksWidth;
|
|
|
|
measureTicks.y = MENU_BAR_HEIGHT + GRID_TOP_PAD;
|
|
|
|
measureTicks.zIndex = 20;
|
|
|
|
|
|
|
|
add(measureTicks);
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
function buildNotePreview():Void
|
|
|
|
{
|
2024-01-04 08:20:34 -05:00
|
|
|
var playbarHeightWithPad = PLAYBAR_HEIGHT + 10;
|
|
|
|
var notePreviewHeight:Int = FlxG.height - NOTE_PREVIEW_Y_POS - playbarHeightWithPad;
|
|
|
|
notePreview = new ChartEditorNotePreview(notePreviewHeight);
|
|
|
|
notePreview.x = NOTE_PREVIEW_X_POS;
|
|
|
|
notePreview.y = NOTE_PREVIEW_Y_POS;
|
2023-10-26 05:46:22 -04:00
|
|
|
add(notePreview);
|
|
|
|
|
|
|
|
if (notePreviewViewport == null) throw 'ERROR: Tried to build note preview, but notePreviewViewport is null! Check ChartEditorThemeHandler.updateTheme().';
|
|
|
|
|
|
|
|
notePreviewViewport.scrollFactor.set(0, 0);
|
|
|
|
add(notePreviewViewport);
|
|
|
|
notePreviewViewport.zIndex = 30;
|
|
|
|
|
2024-01-08 21:26:24 -05:00
|
|
|
notePreviewPlayhead = new FlxSprite().makeGraphic(2, 2, 0xFFFF0000);
|
|
|
|
notePreviewPlayhead.scrollFactor.set(0, 0);
|
|
|
|
notePreviewPlayhead.scale.set(notePreview.width / 2, 0.5); // Setting width does nothing.
|
|
|
|
notePreviewPlayhead.updateHitbox();
|
|
|
|
notePreviewPlayhead.x = notePreview.x;
|
|
|
|
notePreviewPlayhead.y = notePreview.y;
|
|
|
|
add(notePreviewPlayhead);
|
|
|
|
notePreviewPlayhead.zIndex = 31;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
setNotePreviewViewportBounds(calculateNotePreviewViewportBounds());
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-17 22:19:40 -05:00
|
|
|
/**
|
|
|
|
* Automatically goes through and calls render on everything you added.
|
|
|
|
*/
|
|
|
|
override public function draw():Void
|
|
|
|
{
|
|
|
|
super.draw();
|
|
|
|
}
|
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-01-12 06:13:34 -05:00
|
|
|
// trace('Note preview viewport bounds: ' + bounds.toString());
|
2024-01-05 02:35:41 -05:00
|
|
|
|
2023-08-16 03:40:44 -04:00
|
|
|
return bounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setNotePreviewViewportBounds(bounds:FlxRect = null):Void
|
|
|
|
{
|
2023-08-28 15:03:29 -04:00
|
|
|
if (notePreviewViewport == null)
|
2023-10-22 15:43:39 -04:00
|
|
|
{
|
|
|
|
trace('[WARN] Tried to set note preview viewport bounds, but notePreviewViewport is null!');
|
|
|
|
return;
|
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-01-08 21:26:24 -05:00
|
|
|
function refreshNotePreviewPlayheadPosition():Void
|
|
|
|
{
|
|
|
|
if (notePreviewPlayhead == null) return;
|
|
|
|
|
|
|
|
notePreviewPlayhead.y = notePreview.y + (notePreview.height * ((scrollPositionInPixels + playheadPositionInPixels) / songLengthInPixels));
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
{
|
2023-11-24 00:42:07 -05:00
|
|
|
playbarHeadLayout = new ChartEditorPlaybarHead();
|
2023-08-28 15:03:29 -04:00
|
|
|
|
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;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
playbarHeadLayout.playbarHead.allowFocus = false;
|
|
|
|
playbarHeadLayout.playbarHead.width = FlxG.width;
|
|
|
|
playbarHeadLayout.playbarHead.height = 10;
|
|
|
|
playbarHeadLayout.playbarHead.styleString = 'padding-left: 0px; padding-right: 0px; border-left: 0px; border-right: 0px;';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
playbarHeadLayout.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.
|
2023-12-08 01:15:22 -05:00
|
|
|
if (audioInstTrack != null && audioInstTrack.isPlaying)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
playbarHeadDraggingWasPlaying = true;
|
|
|
|
stopAudioPlayback();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
playbarHeadDraggingWasPlaying = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-24 00:49:51 -05:00
|
|
|
playbarHeadLayout.playbarHead.onDrag = function(_:DragEvent) {
|
2023-11-22 19:53:56 -05:00
|
|
|
if (playbarHeadDragging)
|
|
|
|
{
|
|
|
|
// Set the song position to where the playhead was moved to.
|
2023-12-08 16:12:36 -05:00
|
|
|
scrollPositionInPixels = (songLengthInPixels) * playbarHeadLayout.playbarHead.value / 100;
|
2023-11-22 19:53:56 -05:00
|
|
|
// Update the conductor and audio tracks to match.
|
|
|
|
moveSongToScrollPosition();
|
|
|
|
}
|
|
|
|
}
|
2023-11-21 02:12:34 -05:00
|
|
|
|
2023-11-24 00:49:51 -05:00
|
|
|
playbarHeadLayout.playbarHead.onDragEnd = function(_:DragEvent) {
|
2023-11-22 19:53:56 -05:00
|
|
|
playbarHeadDragging = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// 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
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
// Little text that shows up when you copy something.
|
2023-12-08 22:28:34 -05:00
|
|
|
txtCopyNotif = new FlxText(0, 0, 0, '', 24);
|
|
|
|
txtCopyNotif.setBorderStyle(OUTLINE, 0xFF074809, 1);
|
|
|
|
txtCopyNotif.color = 0xFF52FF77;
|
|
|
|
txtCopyNotif.zIndex = 120;
|
|
|
|
add(txtCopyNotif);
|
|
|
|
|
2023-11-21 02:12:34 -05:00
|
|
|
if (!Preferences.debugDisplay) menubar.paddingLeft = null;
|
|
|
|
|
2023-11-22 19:16:38 -05:00
|
|
|
this.setupNotifications();
|
2023-12-12 05:24:43 -05:00
|
|
|
|
|
|
|
// Setup character dropdowns.
|
|
|
|
FlxMouseEvent.add(healthIconDad, function(_) {
|
|
|
|
if (!isCursorOverHaxeUI)
|
|
|
|
{
|
|
|
|
this.openCharacterDropdown(CharacterType.DAD, true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
FlxMouseEvent.add(healthIconBF, function(_) {
|
|
|
|
if (!isCursorOverHaxeUI)
|
|
|
|
{
|
|
|
|
this.openCharacterDropdown(CharacterType.BF, true);
|
|
|
|
}
|
|
|
|
});
|
2024-01-04 08:20:34 -05:00
|
|
|
|
|
|
|
buttonSelectOpponent = new Button();
|
|
|
|
buttonSelectOpponent.allowFocus = false;
|
|
|
|
buttonSelectOpponent.text = "Opponent"; // Default text.
|
|
|
|
buttonSelectOpponent.x = GRID_X_POS;
|
|
|
|
buttonSelectOpponent.y = GRID_INITIAL_Y_POS - NOTE_SELECT_BUTTON_HEIGHT - 8;
|
|
|
|
buttonSelectOpponent.width = GRID_SIZE * 4;
|
|
|
|
buttonSelectOpponent.height = NOTE_SELECT_BUTTON_HEIGHT;
|
|
|
|
buttonSelectOpponent.tooltip = "Click to set selection to all notes on this side.\nShift-click to add all notes on this side to selection.";
|
|
|
|
buttonSelectOpponent.zIndex = 110;
|
|
|
|
add(buttonSelectOpponent);
|
|
|
|
|
|
|
|
buttonSelectOpponent.onClick = (_) -> {
|
|
|
|
var notesToSelect:Array<SongNoteData> = currentSongChartNoteData;
|
|
|
|
notesToSelect = SongDataUtils.getNotesInDataRange(notesToSelect, STRUMLINE_SIZE, STRUMLINE_SIZE * 2 - 1);
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand(notesToSelect, []));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SetItemSelectionCommand(notesToSelect, []));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buttonSelectPlayer = new Button();
|
|
|
|
buttonSelectPlayer.allowFocus = false;
|
|
|
|
buttonSelectPlayer.text = "Player"; // Default text.
|
|
|
|
buttonSelectPlayer.x = buttonSelectOpponent.x + buttonSelectOpponent.width;
|
|
|
|
buttonSelectPlayer.y = buttonSelectOpponent.y;
|
|
|
|
buttonSelectPlayer.width = GRID_SIZE * 4;
|
|
|
|
buttonSelectPlayer.height = NOTE_SELECT_BUTTON_HEIGHT;
|
|
|
|
buttonSelectPlayer.tooltip = "Click to set selection to all notes on this side.\nShift-click to add all notes on this side to selection.";
|
|
|
|
buttonSelectPlayer.zIndex = 110;
|
|
|
|
add(buttonSelectPlayer);
|
|
|
|
|
|
|
|
buttonSelectPlayer.onClick = (_) -> {
|
|
|
|
var notesToSelect:Array<SongNoteData> = currentSongChartNoteData;
|
|
|
|
notesToSelect = SongDataUtils.getNotesInDataRange(notesToSelect, 0, STRUMLINE_SIZE - 1);
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand(notesToSelect, []));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SetItemSelectionCommand(notesToSelect, []));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buttonSelectEvent = new Button();
|
|
|
|
buttonSelectEvent.allowFocus = false;
|
|
|
|
buttonSelectEvent.icon = Paths.image('ui/chart-editor/events/Default');
|
|
|
|
buttonSelectEvent.iconPosition = "top";
|
|
|
|
buttonSelectEvent.x = buttonSelectPlayer.x + buttonSelectPlayer.width;
|
|
|
|
buttonSelectEvent.y = buttonSelectPlayer.y;
|
|
|
|
buttonSelectEvent.width = GRID_SIZE;
|
|
|
|
buttonSelectEvent.height = NOTE_SELECT_BUTTON_HEIGHT;
|
|
|
|
buttonSelectEvent.tooltip = "Click to set selection to all events.\nShift-click to add all events to selection.";
|
|
|
|
buttonSelectEvent.zIndex = 110;
|
|
|
|
add(buttonSelectEvent);
|
|
|
|
|
|
|
|
buttonSelectEvent.onClick = (_) -> {
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand([], currentSongChartEventData));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SetItemSelectionCommand([], currentSongChartEventData));
|
|
|
|
}
|
|
|
|
}
|
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-11-24 00:42:07 -05:00
|
|
|
playbarStart.onClick = _ -> playbarButtonPressed = 'playbarStart';
|
|
|
|
playbarBack.onClick = _ -> playbarButtonPressed = 'playbarBack';
|
|
|
|
playbarPlay.onClick = _ -> toggleAudioPlayback();
|
|
|
|
playbarForward.onClick = _ -> playbarButtonPressed = 'playbarForward';
|
|
|
|
playbarEnd.onClick = _ -> playbarButtonPressed = 'playbarEnd';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-17 02:42:52 -04:00
|
|
|
// Cycle note snap quant.
|
2023-11-24 00:42:07 -05:00
|
|
|
playbarNoteSnap.onRightClick = _ -> {
|
2023-10-21 01:04:50 -04:00
|
|
|
noteSnapQuantIndex--;
|
|
|
|
if (noteSnapQuantIndex < 0) noteSnapQuantIndex = SNAP_QUANTS.length - 1;
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
|
|
|
playbarNoteSnap.onClick = _ -> {
|
2023-11-27 23:29:48 -05:00
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
noteSnapQuantIndex = BASE_QUANT_INDEX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
noteSnapQuantIndex++;
|
|
|
|
if (noteSnapQuantIndex >= SNAP_QUANTS.length) noteSnapQuantIndex = 0;
|
|
|
|
}
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
2023-10-17 02:42:52 -04:00
|
|
|
|
2023-11-28 04:30:29 -05:00
|
|
|
playbarBPM.onClick = _ -> {
|
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
this.setToolboxState(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
Conductor.instance.currentTimeChange.bpm += 1;
|
2023-12-12 05:24:43 -05:00
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
|
2023-11-28 04:30:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
playbarBPM.onRightClick = _ -> {
|
2023-12-14 16:56:20 -05:00
|
|
|
Conductor.instance.currentTimeChange.bpm -= 1;
|
2023-12-12 05:24:43 -05:00
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
|
2023-11-28 04:30:29 -05:00
|
|
|
}
|
|
|
|
|
2024-01-02 14:07:07 -05:00
|
|
|
playbarDifficulty.onClick = _ -> {
|
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
this.setToolboxState(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
incrementDifficulty(-1);
|
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
playbarDifficulty.onRightClick = _ -> {
|
|
|
|
incrementDifficulty(1);
|
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// Add functionality to the menu items.
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
// File
|
2023-11-24 00:49:51 -05:00
|
|
|
menubarItemNewChart.onClick = _ -> this.openWelcomeDialog(true);
|
|
|
|
menubarItemOpenChart.onClick = _ -> this.openBrowseFNFC(true);
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemSaveChart.onClick = _ -> {
|
2023-10-23 12:22:29 -04:00
|
|
|
if (currentWorkingFilePath != null)
|
|
|
|
{
|
2023-11-21 13:31:02 -05:00
|
|
|
this.exportAllSongData(true, currentWorkingFilePath);
|
2023-10-23 12:22:29 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-22 19:17:35 -05:00
|
|
|
this.exportAllSongData(false, null);
|
2023-10-23 12:22:29 -04:00
|
|
|
}
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
2023-11-24 00:49:51 -05:00
|
|
|
menubarItemSaveChartAs.onClick = _ -> this.exportAllSongData(false, null);
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemExit.onClick = _ -> quitChartEditor();
|
|
|
|
|
|
|
|
// Edit
|
|
|
|
menubarItemUndo.onClick = _ -> undoLastCommand();
|
|
|
|
menubarItemRedo.onClick = _ -> redoLastCommand();
|
|
|
|
menubarItemCopy.onClick = function(_) {
|
2024-01-03 19:53:17 -05:00
|
|
|
copySelection();
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
|
|
|
menubarItemCut.onClick = _ -> performCommand(new CutItemsCommand(currentNoteSelection, currentEventSelection));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemPaste.onClick = _ -> {
|
2023-09-26 20:36:41 -04:00
|
|
|
var targetMs:Float = scrollPositionInMs + playheadPositionInMs;
|
2023-12-14 16:56:20 -05:00
|
|
|
var targetStep:Float = Conductor.instance.getTimeInSteps(targetMs);
|
2023-09-26 20:36:41 -04:00
|
|
|
var targetSnappedStep:Float = Math.floor(targetStep / noteSnapRatio) * noteSnapRatio;
|
2023-12-14 16:56:20 -05:00
|
|
|
var targetSnappedMs:Float = Conductor.instance.getStepTimeInMs(targetSnappedStep);
|
2023-09-26 20:36:41 -04:00
|
|
|
performCommand(new PasteItemsCommand(targetSnappedMs));
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
2023-09-26 20:36:41 -04:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemPasteUnsnapped.onClick = _ -> {
|
2023-09-26 20:36:41 -04:00
|
|
|
var targetMs:Float = scrollPositionInMs + playheadPositionInMs;
|
|
|
|
performCommand(new PasteItemsCommand(targetMs));
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemDelete.onClick = _ -> {
|
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-11-24 00:42:07 -05:00
|
|
|
};
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemFlipNotes.onClick = _ -> performCommand(new FlipNotesCommand(currentNoteSelection));
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
menubarItemSelectAllNotes.onClick = _ -> performCommand(new SelectAllItemsCommand(true, false));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
menubarItemSelectAllEvents.onClick = _ -> performCommand(new SelectAllItemsCommand(false, true));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
menubarItemSelectInverse.onClick = _ -> performCommand(new InvertSelectedItemsCommand());
|
|
|
|
|
|
|
|
menubarItemSelectNone.onClick = _ -> performCommand(new DeselectAllItemsCommand());
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemPlaytestFull.onClick = _ -> testSongInPlayState(false);
|
|
|
|
menubarItemPlaytestMinimal.onClick = _ -> testSongInPlayState(true);
|
2023-07-26 16:52:58 -04:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menuBarItemNoteSnapDecrease.onClick = _ -> {
|
2023-11-20 11:26:58 -05:00
|
|
|
noteSnapQuantIndex--;
|
|
|
|
if (noteSnapQuantIndex < 0) noteSnapQuantIndex = SNAP_QUANTS.length - 1;
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
|
|
|
menuBarItemNoteSnapIncrease.onClick = _ -> {
|
2023-11-20 11:26:58 -05:00
|
|
|
noteSnapQuantIndex++;
|
|
|
|
if (noteSnapQuantIndex >= SNAP_QUANTS.length) noteSnapQuantIndex = 0;
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
2023-09-29 21:44:42 -04:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menuBarItemInputStyleNone.onClick = function(event:UIEvent) {
|
2023-09-29 21:44:42 -04:00
|
|
|
currentLiveInputStyle = None;
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
2024-02-28 21:19:21 -05:00
|
|
|
menuBarItemInputStyleNone.selected = currentLiveInputStyle == None;
|
2023-11-24 00:42:07 -05:00
|
|
|
menuBarItemInputStyleNumberKeys.onClick = function(event:UIEvent) {
|
2023-09-29 21:44:42 -04:00
|
|
|
currentLiveInputStyle = NumberKeys;
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
2024-02-28 21:19:21 -05:00
|
|
|
menuBarItemInputStyleNumberKeys.selected = currentLiveInputStyle == NumberKeys;
|
2023-11-24 00:42:07 -05:00
|
|
|
menuBarItemInputStyleWASD.onClick = function(event:UIEvent) {
|
2024-02-28 21:19:21 -05:00
|
|
|
currentLiveInputStyle = WASDKeys;
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
2024-02-28 21:19:21 -05:00
|
|
|
menuBarItemInputStyleWASD.selected = currentLiveInputStyle == WASDKeys;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemAbout.onClick = _ -> this.openAboutDialog();
|
|
|
|
menubarItemWelcomeDialog.onClick = _ -> this.openWelcomeDialog(true);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-22 19:42:28 -05:00
|
|
|
#if sys
|
2023-11-24 00:49:51 -05:00
|
|
|
menubarItemGoToBackupsFolder.onClick = _ -> this.openBackupsFolder();
|
2023-11-22 19:42:28 -05:00
|
|
|
#else
|
|
|
|
// Disable the menu item if we're not on a desktop platform.
|
2023-12-08 01:15:22 -05:00
|
|
|
menubarItemGoToBackupsFolder.disabled = true;
|
2023-11-22 19:42:28 -05:00
|
|
|
#end
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemUserGuide.onClick = _ -> this.openUserGuideDialog();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemDownscroll.onClick = event -> isViewDownscroll = event.value;
|
|
|
|
menubarItemDownscroll.selected = isViewDownscroll;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemDifficultyUp.onClick = _ -> incrementDifficulty(1);
|
|
|
|
menubarItemDifficultyDown.onClick = _ -> incrementDifficulty(-1);
|
2023-08-14 23:13:12 -04:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menuBarItemThemeLight.onChange = function(event:UIEvent) {
|
2023-01-22 22:25:45 -05:00
|
|
|
if (event.target.value) currentTheme = ChartEditorTheme.Light;
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
|
|
|
menuBarItemThemeLight.selected = currentTheme == ChartEditorTheme.Light;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menuBarItemThemeDark.onChange = function(event:UIEvent) {
|
2023-01-22 22:25:45 -05:00
|
|
|
if (event.target.value) currentTheme = ChartEditorTheme.Dark;
|
2023-11-24 00:42:07 -05:00
|
|
|
};
|
|
|
|
menuBarItemThemeDark.selected = currentTheme == ChartEditorTheme.Dark;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemPlayPause.onClick = _ -> toggleAudioPlayback();
|
2023-09-26 17:46:07 -04:00
|
|
|
|
2023-12-19 01:26:26 -05:00
|
|
|
menubarItemLoadInstrumental.onClick = _ -> {
|
|
|
|
var dialog = this.openUploadInstDialog(true);
|
|
|
|
// Ensure instrumental and vocals are reloaded properly.
|
|
|
|
dialog.onDialogClosed = function(_) {
|
|
|
|
this.isHaxeUIDialogOpen = false;
|
|
|
|
this.switchToCurrentInstrumental();
|
|
|
|
this.postLoadInstrumental();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
menubarItemLoadVocals.onClick = _ -> {
|
|
|
|
var dialog = this.openUploadVocalsDialog(true);
|
|
|
|
// Ensure instrumental and vocals are reloaded properly.
|
|
|
|
dialog.onDialogClosed = function(_) {
|
|
|
|
this.isHaxeUIDialogOpen = false;
|
|
|
|
this.switchToCurrentInstrumental();
|
|
|
|
this.postLoadInstrumental();
|
|
|
|
}
|
|
|
|
};
|
2023-09-26 17:46:07 -04:00
|
|
|
|
2023-12-01 17:14:48 -05:00
|
|
|
menubarItemVolumeMetronome.onChange = event -> {
|
2023-12-08 14:01:12 -05:00
|
|
|
var volume:Float = event.value.toFloat() / 100.0;
|
2023-12-01 17:14:48 -05:00
|
|
|
metronomeVolume = volume;
|
|
|
|
menubarLabelVolumeMetronome.text = 'Metronome - ${Std.int(event.value)}%';
|
|
|
|
};
|
|
|
|
menubarItemVolumeMetronome.value = Std.int(metronomeVolume * 100);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-12 18:29:02 -05:00
|
|
|
menubarItemThemeMusic.onChange = event -> {
|
|
|
|
this.welcomeMusic.active = event.value;
|
|
|
|
fadeInWelcomeMusic(WELCOME_MUSIC_FADE_IN_DELAY, WELCOME_MUSIC_FADE_IN_DURATION);
|
|
|
|
};
|
|
|
|
menubarItemThemeMusic.selected = this.welcomeMusic.active;
|
|
|
|
|
2024-02-19 20:18:32 -05:00
|
|
|
menubarItemVolumeHitsoundPlayer.onChange = event -> {
|
|
|
|
var volume:Float = event.value.toFloat() / 100.0;
|
|
|
|
hitsoundVolumePlayer = volume;
|
|
|
|
menubarLabelVolumeHitsoundPlayer.text = 'Player - ${Std.int(event.value)}%';
|
|
|
|
};
|
|
|
|
menubarItemVolumeHitsoundPlayer.value = Std.int(hitsoundVolumePlayer * 100);
|
|
|
|
|
|
|
|
menubarItemVolumeHitsoundOpponent.onChange = event -> {
|
2023-12-08 14:01:12 -05:00
|
|
|
var volume:Float = event.value.toFloat() / 100.0;
|
2024-02-19 20:18:32 -05:00
|
|
|
hitsoundVolumeOpponent = volume;
|
|
|
|
menubarLabelVolumeHitsoundOpponent.text = 'Enemy - ${Std.int(event.value)}%';
|
2023-12-01 17:14:48 -05:00
|
|
|
};
|
2024-02-19 20:18:32 -05:00
|
|
|
menubarItemVolumeHitsoundOpponent.value = Std.int(hitsoundVolumeOpponent * 100);
|
2023-12-01 17:14:48 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemVolumeInstrumental.onChange = event -> {
|
2023-12-08 14:01:12 -05:00
|
|
|
var volume:Float = event.value.toFloat() / 100.0;
|
2023-11-24 00:42:07 -05:00
|
|
|
if (audioInstTrack != null) audioInstTrack.volume = volume;
|
|
|
|
menubarLabelVolumeInstrumental.text = 'Instrumental - ${Std.int(event.value)}%';
|
|
|
|
};
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-23 01:51:13 -05:00
|
|
|
menubarItemVolumeVocalsPlayer.onChange = event -> {
|
2023-12-08 14:01:12 -05:00
|
|
|
var volume:Float = event.value.toFloat() / 100.0;
|
2024-02-02 21:53:45 -05:00
|
|
|
audioVocalTrackGroup.playerVolume = volume;
|
2024-01-23 01:51:13 -05:00
|
|
|
menubarLabelVolumeVocalsPlayer.text = 'Player - ${Std.int(event.value)}%';
|
|
|
|
};
|
|
|
|
|
|
|
|
menubarItemVolumeVocalsOpponent.onChange = event -> {
|
|
|
|
var volume:Float = event.value.toFloat() / 100.0;
|
2024-02-02 21:53:45 -05:00
|
|
|
audioVocalTrackGroup.opponentVolume = volume;
|
2024-01-23 01:51:13 -05:00
|
|
|
menubarLabelVolumeVocalsOpponent.text = 'Enemy - ${Std.int(event.value)}%';
|
|
|
|
};
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemPlaybackSpeed.onChange = event -> {
|
2024-01-25 23:05:54 -05:00
|
|
|
var pitch:Float = (event.value.toFloat() * 2.0) / 100.0;
|
2024-02-28 21:19:21 -05:00
|
|
|
pitch = Math.floor(pitch / 0.05) * 0.05; // Round to nearest 5%
|
|
|
|
pitch = Math.max(0.05, Math.min(2.0, pitch)); // Clamp to 5% to 200%
|
2023-11-24 00:42:07 -05:00
|
|
|
#if FLX_PITCH
|
|
|
|
if (audioInstTrack != null) audioInstTrack.pitch = pitch;
|
2024-02-02 21:53:45 -05:00
|
|
|
audioVocalTrackGroup.pitch = pitch;
|
2023-11-24 00:42:07 -05:00
|
|
|
#end
|
|
|
|
var pitchDisplay:Float = Std.int(pitch * 100) / 100; // Round to 2 decimal places.
|
|
|
|
menubarLabelPlaybackSpeed.text = 'Playback Speed - ${pitchDisplay}x';
|
2023-08-28 15:03:29 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemToggleToolboxDifficulty.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT, event.value);
|
|
|
|
menubarItemToggleToolboxMetadata.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT, event.value);
|
2024-01-20 14:07:31 -05:00
|
|
|
menubarItemToggleToolboxOffsets.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_OFFSETS_LAYOUT, event.value);
|
2024-02-16 22:01:47 -05:00
|
|
|
menubarItemToggleToolboxNoteData.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_NOTE_DATA_LAYOUT, event.value);
|
2024-01-03 19:53:17 -05:00
|
|
|
menubarItemToggleToolboxEventData.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_EVENT_DATA_LAYOUT, event.value);
|
2024-02-09 14:58:57 -05:00
|
|
|
menubarItemToggleToolboxFreeplay.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_FREEPLAY_LAYOUT, event.value);
|
2023-12-10 03:37:12 -05:00
|
|
|
menubarItemToggleToolboxPlaytestProperties.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT, event.value);
|
2023-11-24 00:42:07 -05:00
|
|
|
menubarItemToggleToolboxPlayerPreview.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT, event.value);
|
|
|
|
menubarItemToggleToolboxOpponentPreview.onChange = event -> this.setToolboxState(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.
|
2023-11-24 00:42:07 -05:00
|
|
|
// registerContextMenu(null, Paths.ui('chart-editor/context/test'));
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2024-01-03 19:53:17 -05:00
|
|
|
function setupContextMenu():Void
|
|
|
|
{
|
|
|
|
Screen.instance.registerEvent(MouseEvent.RIGHT_MOUSE_UP, function(e:MouseEvent) {
|
|
|
|
var xPos = e.screenX;
|
|
|
|
var yPos = e.screenY;
|
|
|
|
onContextMenu(xPos, yPos);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onContextMenu(xPos:Float, yPos:Float)
|
|
|
|
{
|
|
|
|
trace('User right clicked to open menu at (${xPos}, ${yPos})');
|
|
|
|
// this.openDefaultContextMenu(xPos, yPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
function copySelection():Void
|
|
|
|
{
|
|
|
|
// Doesn't use a command because it's not undoable.
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SongDataUtils.writeItemsToClipboard(
|
|
|
|
{
|
|
|
|
notes: SongDataUtils.buildNoteClipboard(currentNoteSelection, timeOffset),
|
|
|
|
events: SongDataUtils.buildEventClipboard(currentEventSelection, timeOffset),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
2024-01-06 01:06:10 -05:00
|
|
|
// Keyboard shortcuts
|
2023-02-28 21:06:09 -05:00
|
|
|
add(undoKeyHandler);
|
|
|
|
add(redoKeyHandler);
|
|
|
|
add(upKeyHandler);
|
|
|
|
add(downKeyHandler);
|
2023-09-29 21:44:42 -04:00
|
|
|
add(wKeyHandler);
|
|
|
|
add(sKeyHandler);
|
2023-02-28 21:06:09 -05:00
|
|
|
add(pageUpKeyHandler);
|
|
|
|
add(pageDownKeyHandler);
|
2024-01-06 01:06:10 -05:00
|
|
|
|
|
|
|
// Gamepad inputs
|
|
|
|
add(dpadUpGamepadHandler);
|
|
|
|
add(dpadDownGamepadHandler);
|
|
|
|
add(dpadLeftGamepadHandler);
|
|
|
|
add(dpadRightGamepadHandler);
|
|
|
|
add(leftStickUpGamepadHandler);
|
|
|
|
add(leftStickDownGamepadHandler);
|
|
|
|
add(leftStickLeftGamepadHandler);
|
|
|
|
add(leftStickRightGamepadHandler);
|
|
|
|
add(rightStickUpGamepadHandler);
|
|
|
|
add(rightStickDownGamepadHandler);
|
|
|
|
add(rightStickLeftGamepadHandler);
|
|
|
|
add(rightStickRightGamepadHandler);
|
2023-02-28 21:06:09 -05:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2023-11-21 13:31:02 -05:00
|
|
|
// Called when clicking the X button on the window.
|
2023-01-22 19:55:30 -05:00
|
|
|
WindowUtil.windowExit.add(onWindowClose);
|
2023-11-21 13:31:02 -05:00
|
|
|
|
|
|
|
// Called when the game crashes.
|
|
|
|
CrashHandler.errorSignal.add(onWindowCrash);
|
|
|
|
CrashHandler.criticalErrorSignal.add(onWindowCrash);
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
saveDataDirty = false;
|
|
|
|
}
|
|
|
|
|
2023-12-14 16:56:20 -05:00
|
|
|
var displayAutosavePopup:Bool = false;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* UPDATE FUNCTIONS
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-12-14 16:56:20 -05:00
|
|
|
function autoSave(?beforePlaytest:Bool = false):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-11-22 19:17:35 -05:00
|
|
|
var needsAutoSave:Bool = saveDataDirty;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
saveDataDirty = false;
|
|
|
|
|
2023-10-22 15:43:39 -04:00
|
|
|
// Auto-save preferences.
|
2023-11-22 19:17:35 -05:00
|
|
|
writePreferences(needsAutoSave);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-22 15:43:39 -04:00
|
|
|
// Auto-save the chart.
|
2023-01-22 19:55:30 -05:00
|
|
|
#if html5
|
|
|
|
// Auto-save to local storage.
|
2023-10-22 15:43:39 -04:00
|
|
|
// TODO: Implement this.
|
2023-01-22 19:55:30 -05:00
|
|
|
#else
|
|
|
|
// Auto-save to temp file.
|
2023-11-22 19:17:35 -05:00
|
|
|
if (needsAutoSave)
|
|
|
|
{
|
|
|
|
this.exportAllSongData(true, null);
|
2023-12-14 16:56:20 -05:00
|
|
|
if (beforePlaytest)
|
|
|
|
{
|
|
|
|
displayAutosavePopup = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
displayAutosavePopup = false;
|
|
|
|
var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]);
|
|
|
|
this.infoWithActions('Auto-Save', 'Chart auto-saved to ${absoluteBackupsPath}.', [
|
|
|
|
{
|
|
|
|
text: "Take Me There",
|
|
|
|
callback: openBackupsFolder,
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
}
|
2023-11-22 19:17:35 -05:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
#end
|
|
|
|
}
|
|
|
|
|
2023-11-22 19:42:28 -05:00
|
|
|
/**
|
|
|
|
* Open the backups folder in the file explorer.
|
|
|
|
* Don't call this on HTML5.
|
|
|
|
*/
|
2023-12-15 21:09:01 -05:00
|
|
|
function openBackupsFolder(?_):Bool
|
2023-11-22 19:42:28 -05:00
|
|
|
{
|
2023-11-28 21:19:07 -05:00
|
|
|
#if sys
|
2023-11-22 19:42:28 -05:00
|
|
|
// TODO: Is there a way to open a folder and highlight a file in it?
|
|
|
|
var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]);
|
|
|
|
WindowUtil.openFolder(absoluteBackupsPath);
|
2023-12-15 21:09:01 -05:00
|
|
|
return true;
|
2023-11-28 21:19:07 -05:00
|
|
|
#else
|
|
|
|
trace('No file system access, cannot open backups folder.');
|
2023-12-15 21:09:01 -05:00
|
|
|
return false;
|
2023-11-28 21:19:07 -05:00
|
|
|
#end
|
2023-11-22 19:42:28 -05:00
|
|
|
}
|
|
|
|
|
2023-11-21 13:31:02 -05:00
|
|
|
/**
|
|
|
|
* Called when the window was closed, to save a backup of the chart.
|
|
|
|
* @param exitCode The exit code of the window. We use `-1` when calling the function due to a game crash.
|
|
|
|
*/
|
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');
|
|
|
|
|
2023-11-21 13:31:02 -05:00
|
|
|
var needsAutoSave:Bool = saveDataDirty;
|
|
|
|
|
|
|
|
writePreferences(needsAutoSave);
|
|
|
|
|
|
|
|
if (needsAutoSave)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-11-22 19:17:35 -05:00
|
|
|
this.exportAllSongData(true, null);
|
2023-11-21 13:31:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onWindowCrash(message:String):Void
|
|
|
|
{
|
|
|
|
trace('Chart editor intercepted crash:');
|
|
|
|
trace('${message}');
|
|
|
|
|
|
|
|
trace('Should save chart? $saveDataDirty');
|
|
|
|
|
|
|
|
var needsAutoSave:Bool = saveDataDirty;
|
|
|
|
|
|
|
|
writePreferences(needsAutoSave);
|
|
|
|
|
|
|
|
if (needsAutoSave)
|
|
|
|
{
|
2023-11-22 19:17:35 -05:00
|
|
|
this.exportAllSongData(true, null);
|
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-11-21 13:31:02 -05:00
|
|
|
CrashHandler.errorSignal.remove(onWindowCrash);
|
|
|
|
CrashHandler.criticalErrorSignal.remove(onWindowCrash);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-02-28 13:17:28 -05:00
|
|
|
public override function update(elapsed:Float):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-11 00:39:16 -04:00
|
|
|
// Override F4 behavior to include the autosave.
|
2023-12-14 00:47:04 -05:00
|
|
|
if (FlxG.keys.justPressed.F4 && !criticalFailure)
|
2023-10-11 00:39:16 -04:00
|
|
|
{
|
|
|
|
quitChartEditor();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// dispatchEvent gets called here.
|
|
|
|
super.update(elapsed);
|
|
|
|
|
2023-12-14 00:47:04 -05:00
|
|
|
if (criticalFailure) return;
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// These ones happen even if the modal dialog is open.
|
2023-12-08 01:15:22 -05:00
|
|
|
handleMusicPlayback(elapsed);
|
2023-01-22 19:55:30 -05:00
|
|
|
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();
|
2023-10-17 16:57:06 -04:00
|
|
|
|
2024-02-13 00:29:46 -05:00
|
|
|
#if (debug || FORCE_DEBUG_VERSION)
|
2023-10-17 16:57:06 -04:00
|
|
|
handleQuickWatch();
|
|
|
|
#end
|
2023-11-21 02:12:34 -05:00
|
|
|
|
|
|
|
handlePostUpdate();
|
2023-10-17 16:57:06 -04:00
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* 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-12-08 01:16:16 -05:00
|
|
|
if (metronomeVolume > 0.0 && this.subState == null && (audioInstTrack != null && audioInstTrack.isPlaying))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2024-01-05 20:37:13 -05:00
|
|
|
playMetronomeTick(Conductor.instance.currentBeat % Conductor.instance.beatsPerMeasure == 0);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2024-01-03 19:53:17 -05:00
|
|
|
// Show the mouse cursor.
|
|
|
|
// Just throwing this somewhere convenient and infrequently called because sometimes Flixel's debug thing hides the cursor.
|
|
|
|
Cursor.show();
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
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-12-08 01:15:22 -05:00
|
|
|
if (audioInstTrack != null && audioInstTrack.isPlaying)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
if (healthIconDad != null) healthIconDad.onStepHit(Conductor.instance.currentStep);
|
|
|
|
if (healthIconBF != null) healthIconBF.onStepHit(Conductor.instance.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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* UPDATE HANDLERS
|
|
|
|
*/
|
|
|
|
// ====================
|
2023-08-31 19:14:01 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Handle syncronizing the conductor with the music playback.
|
|
|
|
*/
|
2023-12-08 01:15:22 -05:00
|
|
|
function handleMusicPlayback(elapsed:Float):Void
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2023-12-08 01:15:22 -05:00
|
|
|
if (audioInstTrack != null)
|
|
|
|
{
|
|
|
|
// This normally gets called by FlxG.sound.update()
|
|
|
|
// but we handle instrumental updates manually to prevent FlxG.sound.music.update()
|
|
|
|
// from being called twice when we move to the PlayState.
|
|
|
|
audioInstTrack.update(elapsed);
|
2023-12-08 16:12:36 -05:00
|
|
|
|
|
|
|
// If the song starts 50ms in, make sure we start the song there.
|
2023-12-14 16:56:20 -05:00
|
|
|
if (Conductor.instance.instrumentalOffset < 0)
|
2023-12-08 16:12:36 -05:00
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
if (audioInstTrack.time < -Conductor.instance.instrumentalOffset)
|
2023-12-08 16:12:36 -05:00
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
trace('Resetting instrumental time to ${- Conductor.instance.instrumentalOffset}ms');
|
|
|
|
audioInstTrack.time = -Conductor.instance.instrumentalOffset;
|
2023-12-08 16:12:36 -05:00
|
|
|
}
|
|
|
|
}
|
2023-12-08 01:15:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (audioInstTrack != null && audioInstTrack.isPlaying)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-12-01 17:14:48 -05:00
|
|
|
if (FlxG.keys.pressed.ALT)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
// If middle mouse panning during song playback, we move ONLY the playhead, without scrolling. Neat!
|
2023-09-29 21:44:42 -04:00
|
|
|
|
2023-12-14 16:56:20 -05:00
|
|
|
var oldStepTime:Float = Conductor.instance.currentStepTime;
|
|
|
|
var oldSongPosition:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset;
|
|
|
|
Conductor.instance.update(audioInstTrack.time);
|
|
|
|
handleHitsounds(oldSongPosition, Conductor.instance.songPosition + Conductor.instance.instrumentalOffset);
|
2023-10-26 05:46:22 -04:00
|
|
|
// Resync vocals.
|
2024-02-02 21:53:45 -05:00
|
|
|
if (Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
audioVocalTrackGroup.time = audioInstTrack.time;
|
|
|
|
}
|
2023-12-14 16:56:20 -05:00
|
|
|
var diffStepTime:Float = Conductor.instance.currentStepTime - oldStepTime;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Move the playhead.
|
|
|
|
playheadPositionInPixels += diffStepTime * GRID_SIZE;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// We don't move the song to scroll position, or update the note sprites.
|
2023-06-08 16:53:52 -04:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Else, move the entire view.
|
2023-12-14 16:56:20 -05:00
|
|
|
var oldSongPosition:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset;
|
|
|
|
Conductor.instance.update(audioInstTrack.time);
|
|
|
|
handleHitsounds(oldSongPosition, Conductor.instance.songPosition + Conductor.instance.instrumentalOffset);
|
2023-10-26 05:46:22 -04:00
|
|
|
// Resync vocals.
|
2024-02-02 21:53:45 -05:00
|
|
|
if (Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
audioVocalTrackGroup.time = audioInstTrack.time;
|
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// We need time in fractional steps here to allow the song to actually play.
|
|
|
|
// Also account for a potentially offset playhead.
|
2023-12-14 16:56:20 -05:00
|
|
|
scrollPositionInPixels = (Conductor.instance.currentStepTime + Conductor.instance.instrumentalOffsetSteps) * GRID_SIZE - playheadPositionInPixels;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// DO NOT move song to scroll position here specifically.
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// We need to update the note sprites.
|
|
|
|
noteDisplayDirty = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Update the note preview viewport box.
|
|
|
|
setNotePreviewViewportBounds(calculateNotePreviewViewportBounds());
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.SPACE && !isHaxeUIDialogOpen)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
toggleAudioPlayback();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* Handle using `renderedNotes` to display notes from `currentSongChartNoteData`.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
function handleNoteDisplay():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (noteDisplayDirty)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
noteDisplayDirty = false;
|
2023-09-12 18:37:59 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Update for whether downscroll is enabled.
|
|
|
|
renderedNotes.flipX = (isViewDownscroll);
|
2023-08-28 15:03:29 -04:00
|
|
|
|
2023-10-26 05:46:22 -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
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Remove notes that are no longer visible and list the ones that are.
|
|
|
|
var displayedNoteData:Array<SongNoteData> = [];
|
|
|
|
for (noteSprite in renderedNotes.members)
|
|
|
|
{
|
|
|
|
if (noteSprite == null || noteSprite.noteData == null || !noteSprite.exists || !noteSprite.visible) continue;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Resolve an issue where dragging an event too far would cause it to be hidden.
|
|
|
|
var isSelectedAndDragged = currentNoteSelection.fastContains(noteSprite.noteData) && (dragTargetCurrentStep != 0);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if ((noteSprite.isNoteVisible(viewAreaBottomPixels, viewAreaTopPixels)
|
|
|
|
&& currentSongChartNoteData.fastContains(noteSprite.noteData))
|
|
|
|
|| isSelectedAndDragged)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Note is already displayed and should remain displayed.
|
|
|
|
displayedNoteData.push(noteSprite.noteData);
|
|
|
|
|
|
|
|
// Update the note sprite's position.
|
|
|
|
noteSprite.updateNotePosition(renderedNotes);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
else
|
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// This sprite is off-screen or was deleted.
|
|
|
|
// Kill the note sprite and recycle it.
|
|
|
|
noteSprite.noteData = null;
|
2023-06-08 16:53:52 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -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-10-26 05:46:22 -04:00
|
|
|
var displayedHoldNoteData:Array<SongNoteData> = [];
|
|
|
|
for (holdNoteSprite in renderedHoldNotes.members)
|
2023-08-16 03:40:44 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (holdNoteSprite == null || holdNoteSprite.noteData == null || !holdNoteSprite.exists || !holdNoteSprite.visible) continue;
|
2023-08-16 03:40:44 -04:00
|
|
|
|
2024-01-12 06:13:34 -05:00
|
|
|
if (holdNoteSprite.noteData == currentPlaceNoteData)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2024-01-12 06:13:34 -05:00
|
|
|
// This hold note is for the note we are currently dragging.
|
|
|
|
// It will be displayed by gridGhostHoldNoteSprite instead.
|
|
|
|
holdNoteSprite.kill();
|
|
|
|
}
|
|
|
|
else if (!holdNoteSprite.isHoldNoteVisible(FlxG.height - MENU_BAR_HEIGHT, GRID_TOP_PAD))
|
|
|
|
{
|
|
|
|
// This hold note is off-screen.
|
|
|
|
// Kill the hold note sprite and recycle it.
|
2023-10-26 05:46:22 -04:00
|
|
|
holdNoteSprite.kill();
|
|
|
|
}
|
|
|
|
else if (!currentSongChartNoteData.fastContains(holdNoteSprite.noteData) || holdNoteSprite.noteData.length == 0)
|
|
|
|
{
|
|
|
|
// This hold note was deleted.
|
|
|
|
// Kill the hold note sprite and recycle it.
|
|
|
|
holdNoteSprite.kill();
|
|
|
|
}
|
|
|
|
else if (displayedHoldNoteData.fastContains(holdNoteSprite.noteData))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// This hold note is a duplicate.
|
|
|
|
// Kill the hold note sprite and recycle it.
|
|
|
|
holdNoteSprite.kill();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
displayedHoldNoteData.push(holdNoteSprite.noteData);
|
2024-01-12 06:13:34 -05:00
|
|
|
// Update the event sprite's height and position.
|
|
|
|
// var holdNoteHeight = holdNoteSprite.noteData.getStepLength() * GRID_SIZE;
|
|
|
|
// holdNoteSprite.setHeightDirectly(holdNoteHeight);
|
2023-10-26 05:46:22 -04:00
|
|
|
holdNoteSprite.updateHoldNotePosition(renderedNotes);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
2023-10-26 05:46:22 -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-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Remove events that are no longer visible and list the ones that are.
|
|
|
|
var displayedEventData:Array<SongEventData> = [];
|
|
|
|
for (eventSprite in renderedEvents.members)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (eventSprite == null || eventSprite.eventData == null || !eventSprite.exists || !eventSprite.visible) continue;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Resolve an issue where dragging an event too far would cause it to be hidden.
|
|
|
|
var isSelectedAndDragged = currentEventSelection.fastContains(eventSprite.eventData) && (dragTargetCurrentStep != 0);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
if ((eventSprite.isEventVisible(FlxG.height - PLAYBAR_HEIGHT, MENU_BAR_HEIGHT)
|
2023-10-26 05:46:22 -04:00
|
|
|
&& currentSongChartEventData.fastContains(eventSprite.eventData))
|
|
|
|
|| isSelectedAndDragged)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Event is already displayed and should remain displayed.
|
|
|
|
displayedEventData.push(eventSprite.eventData);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Update the event sprite's position.
|
|
|
|
eventSprite.updateEventPosition(renderedEvents);
|
2024-01-03 19:53:17 -05:00
|
|
|
// Update the sprite's graphic. TODO: Is this inefficient?
|
2024-02-18 03:02:36 -05:00
|
|
|
eventSprite.playAnimation(eventSprite.eventData.eventKind);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// This event was deleted.
|
|
|
|
// Kill the event sprite and recycle it.
|
|
|
|
eventSprite.eventData = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
2023-10-26 05:46:22 -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));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// 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?
|
2023-12-14 16:56:20 -05:00
|
|
|
var viewAreaTopMs:Float = scrollPositionInMs - (Conductor.instance.measureLengthMs * 2); // Is 2 measures enough?
|
|
|
|
var viewAreaBottomMs:Float = scrollPositionInMs + (Conductor.instance.measureLengthMs * 2); // Is 2 measures enough?
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Add notes that are now visible.
|
|
|
|
for (noteData in currentSongChartNoteData)
|
|
|
|
{
|
|
|
|
// Remember if we are already displaying this note.
|
|
|
|
if (noteData == null) continue;
|
|
|
|
// Check if we are outside a broad range around the view area.
|
|
|
|
if (noteData.time < viewAreaTopMs || noteData.time > viewAreaBottomMs) continue;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (displayedNoteData.fastContains(noteData))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
continue;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -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
|
|
|
|
2023-10-26 05:46:22 -04: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));
|
|
|
|
// trace('Creating new Note... (${renderedNotes.members.length})');
|
|
|
|
noteSprite.parentState = this;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// The note sprite handles animation playback and positioning.
|
|
|
|
noteSprite.noteData = noteData;
|
|
|
|
noteSprite.overrideStepTime = null;
|
|
|
|
noteSprite.overrideData = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -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-09-11 19:42:10 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Add hold notes that are now visible (and not already displayed).
|
2024-01-12 06:13:34 -05:00
|
|
|
if (noteSprite.noteData != null
|
|
|
|
&& noteSprite.noteData.length > 0
|
|
|
|
&& displayedHoldNoteData.indexOf(noteSprite.noteData) == -1
|
|
|
|
&& noteSprite.noteData != currentPlaceNoteData)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
var holdNoteSprite:ChartEditorHoldNoteSprite = renderedHoldNotes.recycle(() -> new ChartEditorHoldNoteSprite(this));
|
|
|
|
// trace('Creating new HoldNote... (${renderedHoldNotes.members.length})');
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
var noteLengthPixels:Float = noteSprite.noteData.getStepLength() * GRID_SIZE;
|
2023-09-12 18:37:59 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
holdNoteSprite.noteData = noteSprite.noteData;
|
|
|
|
holdNoteSprite.noteDirection = noteSprite.noteData.getDirection();
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
holdNoteSprite.setHeightDirectly(noteLengthPixels);
|
2023-09-12 18:37:59 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
holdNoteSprite.updateHoldNotePosition(renderedHoldNotes);
|
2024-01-12 06:13:34 -05:00
|
|
|
|
|
|
|
trace(holdNoteSprite.x + ', ' + holdNoteSprite.y + ', ' + holdNoteSprite.width + ', ' + holdNoteSprite.height);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add events that are now visible.
|
|
|
|
for (eventData in currentSongChartEventData)
|
|
|
|
{
|
|
|
|
// Remember if we are already displaying this event.
|
|
|
|
if (displayedEventData.indexOf(eventData) != -1)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
continue;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (!ChartEditorEventSprite.wouldEventBeVisible(viewAreaBottomPixels, viewAreaTopPixels, eventData, renderedNotes)) continue;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Else, this event is visible and we need to render it!
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Get an event sprite from the pool.
|
|
|
|
// If we can reuse a deleted event, do so.
|
|
|
|
// If a new event is needed, call buildEventSprite.
|
|
|
|
var eventSprite:ChartEditorEventSprite = renderedEvents.recycle(() -> new ChartEditorEventSprite(this), false, true);
|
|
|
|
eventSprite.parentState = this;
|
|
|
|
trace('Creating new Event... (${renderedEvents.members.length})');
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// The event sprite handles animation playback and positioning.
|
|
|
|
eventSprite.eventData = eventData;
|
|
|
|
eventSprite.overrideStepTime = null;
|
|
|
|
|
|
|
|
// Setting event data resets position relative to the grid so we fix that.
|
|
|
|
eventSprite.x += renderedEvents.x;
|
|
|
|
eventSprite.y += renderedEvents.y;
|
2024-01-04 10:00:39 -05:00
|
|
|
eventSprite.updateTooltipPosition();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
|
|
|
|
// Add hold notes that have been made visible (but not their parents)
|
|
|
|
for (noteData in currentSongChartNoteData)
|
2023-08-16 03:40:44 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Is the note a hold note?
|
|
|
|
if (noteData == null || noteData.length <= 0) continue;
|
2023-09-12 18:37:59 -04:00
|
|
|
|
2024-01-12 06:13:34 -05:00
|
|
|
// Is the note the one we are dragging? If so, ghostHoldNoteSprite will handle it.
|
|
|
|
if (noteData == currentPlaceNoteData) continue;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Is the hold note rendered already?
|
|
|
|
if (displayedHoldNoteData.indexOf(noteData) != -1) continue;
|
2023-08-16 03:40:44 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Is the hold note offscreen?
|
|
|
|
if (!ChartEditorHoldNoteSprite.wouldHoldNoteBeVisible(viewAreaBottomPixels, viewAreaTopPixels, noteData, renderedHoldNotes)) continue;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Hold note should be rendered.
|
|
|
|
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-09-11 19:42:10 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
var noteLengthPixels:Float = noteData.getStepLength() * GRID_SIZE;
|
2023-10-11 19:39:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
holdNoteSprite.noteData = noteData;
|
|
|
|
holdNoteSprite.noteDirection = noteData.getDirection();
|
2023-10-11 19:39:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
holdNoteSprite.setHeightDirectly(noteLengthPixels);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
holdNoteSprite.updateHoldNotePosition(renderedHoldNotes);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
displayedHoldNoteData.push(noteData);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
|
|
|
// TODO: Handle selection of hold notes.
|
|
|
|
if (isNoteSelected(noteSprite.noteData))
|
|
|
|
{
|
|
|
|
// Determine if the note is being dragged and offset the vertical position accordingly.
|
|
|
|
if (dragTargetCurrentStep != 0.0)
|
|
|
|
{
|
|
|
|
var stepTime:Float = (noteSprite.noteData == null) ? 0.0 : noteSprite.noteData.getStepTime();
|
|
|
|
// Update the note's "ghost" step time.
|
|
|
|
noteSprite.overrideStepTime = (stepTime + dragTargetCurrentStep).clamp(0, songLengthInSteps - (1 * noteSnapRatio));
|
|
|
|
// Then reapply the note sprite's position relative to the grid.
|
|
|
|
noteSprite.updateNotePosition(renderedNotes);
|
2023-10-17 02:42:52 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (noteSprite.overrideStepTime != null)
|
|
|
|
{
|
|
|
|
// Reset the note's "ghost" step time.
|
|
|
|
noteSprite.overrideStepTime = null;
|
|
|
|
// Then reapply the note sprite's position relative to the grid.
|
|
|
|
noteSprite.updateNotePosition(renderedNotes);
|
|
|
|
}
|
2023-10-17 02:42:52 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Determine if the note is being dragged and offset the horizontal position accordingly.
|
|
|
|
if (dragTargetCurrentColumn != 0)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
var data:Int = (noteSprite.noteData == null) ? 0 : noteSprite.noteData.data;
|
|
|
|
// Update the note's "ghost" column.
|
|
|
|
noteSprite.overrideData = gridColumnToNoteData((noteDataToGridColumn(data) + dragTargetCurrentColumn).clamp(0,
|
|
|
|
ChartEditorState.STRUMLINE_SIZE * 2 - 1));
|
|
|
|
// Then reapply the note sprite's position relative to the grid.
|
|
|
|
noteSprite.updateNotePosition(renderedNotes);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (noteSprite.overrideData != null)
|
|
|
|
{
|
|
|
|
// Reset the note's "ghost" column.
|
|
|
|
noteSprite.overrideData = null;
|
|
|
|
// Then reapply the note sprite's position relative to the grid.
|
|
|
|
noteSprite.updateNotePosition(renderedNotes);
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Then, render the selection square.
|
|
|
|
var selectionSquare:ChartEditorSelectionSquareSprite = renderedSelectionSquares.recycle(buildSelectionSquare);
|
|
|
|
|
|
|
|
// Set the position and size (because we might be recycling one with bad values).
|
|
|
|
selectionSquare.noteData = noteSprite.noteData;
|
|
|
|
selectionSquare.eventData = null;
|
|
|
|
selectionSquare.x = noteSprite.x;
|
|
|
|
selectionSquare.y = noteSprite.y;
|
|
|
|
selectionSquare.width = GRID_SIZE;
|
2024-01-12 06:13:34 -05:00
|
|
|
|
|
|
|
var stepLength = noteSprite.noteData.getStepLength();
|
|
|
|
selectionSquare.height = (stepLength <= 0) ? GRID_SIZE : ((stepLength + 1) * GRID_SIZE);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
|
|
|
|
for (eventSprite in renderedEvents.members)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (isEventSelected(eventSprite.eventData))
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Determine if the note is being dragged and offset the position accordingly.
|
|
|
|
if (dragTargetCurrentStep > 0 || dragTargetCurrentColumn > 0)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
var stepTime = (eventSprite.eventData == null) ? 0 : eventSprite.eventData.getStepTime();
|
|
|
|
eventSprite.overrideStepTime = (stepTime + dragTargetCurrentStep).clamp(0, songLengthInSteps);
|
|
|
|
// Then reapply the note sprite's position relative to the grid.
|
|
|
|
eventSprite.updateEventPosition(renderedEvents);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (eventSprite.overrideStepTime != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Reset the note's "ghost" column.
|
|
|
|
eventSprite.overrideStepTime = null;
|
|
|
|
// Then reapply the note sprite's position relative to the grid.
|
|
|
|
eventSprite.updateEventPosition(renderedEvents);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Then, render the selection square.
|
|
|
|
var selectionSquare:ChartEditorSelectionSquareSprite = renderedSelectionSquares.recycle(buildSelectionSquare);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Set the position and size (because we might be recycling one with bad values).
|
|
|
|
selectionSquare.noteData = null;
|
|
|
|
selectionSquare.eventData = eventSprite.eventData;
|
|
|
|
selectionSquare.x = eventSprite.x;
|
|
|
|
selectionSquare.y = eventSprite.y;
|
|
|
|
selectionSquare.width = eventSprite.width;
|
|
|
|
selectionSquare.height = eventSprite.height;
|
|
|
|
}
|
2024-03-21 23:57:26 -04:00
|
|
|
|
|
|
|
// Additional cleanup on notes.
|
|
|
|
if (noteTooltipsDirty) eventSprite.updateTooltipText();
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-03-21 23:57:26 -04:00
|
|
|
noteTooltipsDirty = false;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Sort the notes DESCENDING. This keeps the sustain behind the associated note.
|
|
|
|
renderedNotes.sort(FlxSort.byY, FlxSort.DESCENDING); // TODO: .group.insertionSort()
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Sort the events DESCENDING. This keeps the sustain behind the associated note.
|
|
|
|
renderedEvents.sort(FlxSort.byY, FlxSort.DESCENDING); // TODO: .group.insertionSort()
|
|
|
|
}
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Handle keybinds for scrolling the chart editor grid.
|
|
|
|
*/
|
|
|
|
function handleScrollKeybinds():Void
|
|
|
|
{
|
2023-11-05 00:14:44 -04:00
|
|
|
// Don't scroll when the user is interacting with the UI, unless a playbar button (the << >> ones) is pressed.
|
2023-11-21 02:12:34 -05:00
|
|
|
if ((isHaxeUIFocused || isCursorOverHaxeUI) && playbarButtonPressed == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -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-12-01 17:14:48 -05:00
|
|
|
// Handle scroll anchor
|
|
|
|
if (scrollAnchorScreenPos != null)
|
|
|
|
{
|
|
|
|
var currentScreenPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
|
|
|
var distance = currentScreenPos - scrollAnchorScreenPos;
|
|
|
|
|
|
|
|
var verticalDistance = distance.y;
|
|
|
|
|
|
|
|
// How much scrolling should be done based on the distance of the cursor from the anchor.
|
|
|
|
final ANCHOR_SCROLL_SPEED = 0.2;
|
|
|
|
|
|
|
|
scrollAmount = ANCHOR_SCROLL_SPEED * verticalDistance;
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Mouse Wheel = Scroll
|
|
|
|
if (FlxG.mouse.wheel != 0 && !FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
scrollAmount = -50 * FlxG.mouse.wheel;
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Up Arrow = Scroll Up
|
|
|
|
if (upKeyHandler.activated && currentLiveInputStyle == None)
|
|
|
|
{
|
2024-01-06 01:06:10 -05:00
|
|
|
scrollAmount = -GRID_SIZE * 4;
|
2023-10-26 05:46:22 -04:00
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
// Down Arrow = Scroll Down
|
|
|
|
if (downKeyHandler.activated && currentLiveInputStyle == None)
|
|
|
|
{
|
2024-01-06 01:06:10 -05:00
|
|
|
scrollAmount = GRID_SIZE * 4;
|
2023-10-26 05:46:22 -04:00
|
|
|
shouldPause = true;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// W = Scroll Up (doesn't work with Ctrl+Scroll)
|
|
|
|
if (wKeyHandler.activated && currentLiveInputStyle == None && !FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
2024-01-06 01:06:10 -05:00
|
|
|
scrollAmount = -GRID_SIZE * 4;
|
2023-10-26 05:46:22 -04:00
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
// S = Scroll Down (doesn't work with Ctrl+Scroll)
|
|
|
|
if (sKeyHandler.activated && currentLiveInputStyle == None && !FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
2024-01-06 01:06:10 -05:00
|
|
|
scrollAmount = GRID_SIZE * 4;
|
2023-10-26 05:46:22 -04:00
|
|
|
shouldPause = true;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
// GAMEPAD LEFT STICK UP = Scroll Up by 1 note snap
|
|
|
|
if (leftStickUpGamepadHandler.activated)
|
|
|
|
{
|
|
|
|
scrollAmount = -GRID_SIZE * noteSnapRatio;
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
// GAMEPAD LEFT STICK DOWN = Scroll Down by 1 note snap
|
|
|
|
if (leftStickDownGamepadHandler.activated)
|
|
|
|
{
|
|
|
|
scrollAmount = GRID_SIZE * noteSnapRatio;
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// GAMEPAD RIGHT STICK UP = Scroll Up by 1 note snap (playhead only)
|
|
|
|
if (rightStickUpGamepadHandler.activated)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2024-01-06 01:06:10 -05:00
|
|
|
playheadAmount = -GRID_SIZE * noteSnapRatio;
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
// GAMEPAD RIGHT STICK DOWN = Scroll Down by 1 note snap (playhead only)
|
|
|
|
if (rightStickDownGamepadHandler.activated)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2024-01-06 01:06:10 -05:00
|
|
|
playheadAmount = GRID_SIZE * noteSnapRatio;
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
var funcJumpUp = (playheadOnly:Bool) -> {
|
2023-12-14 16:56:20 -05:00
|
|
|
var measureHeight:Float = GRID_SIZE * 4 * Conductor.instance.beatsPerMeasure;
|
2023-10-26 05:46:22 -04:00
|
|
|
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
|
|
|
|
var targetScrollPosition:Float = Math.floor(playheadPos / measureHeight) * measureHeight;
|
|
|
|
// If we would move less than one grid, instead move to the top of the previous measure.
|
|
|
|
var targetScrollAmount = Math.abs(targetScrollPosition - playheadPos);
|
|
|
|
if (targetScrollAmount < GRID_SIZE)
|
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
targetScrollPosition -= GRID_SIZE * Constants.STEPS_PER_BEAT * Conductor.instance.beatsPerMeasure;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
if (playheadOnly)
|
|
|
|
{
|
|
|
|
playheadAmount = targetScrollPosition - playheadPos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scrollAmount = targetScrollPosition - playheadPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PAGE UP = Jump up to nearest measure
|
|
|
|
// GAMEPAD LEFT STICK LEFT = Jump up to nearest measure
|
|
|
|
if (pageUpKeyHandler.activated || leftStickLeftGamepadHandler.activated)
|
|
|
|
{
|
|
|
|
funcJumpUp(false);
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
if (rightStickLeftGamepadHandler.activated)
|
|
|
|
{
|
|
|
|
funcJumpUp(true);
|
2023-10-26 05:46:22 -04:00
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
if (playbarButtonPressed == 'playbarBack')
|
|
|
|
{
|
|
|
|
playbarButtonPressed = '';
|
2024-01-06 01:06:10 -05:00
|
|
|
funcJumpUp(false);
|
2023-10-26 05:46:22 -04:00
|
|
|
shouldPause = true;
|
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
var funcJumpDown = (playheadOnly:Bool) -> {
|
2023-12-14 16:56:20 -05:00
|
|
|
var measureHeight:Float = GRID_SIZE * 4 * Conductor.instance.beatsPerMeasure;
|
2023-10-26 05:46:22 -04:00
|
|
|
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
|
|
|
|
var targetScrollPosition:Float = Math.ceil(playheadPos / measureHeight) * measureHeight;
|
|
|
|
// If we would move less than one grid, instead move to the top of the next measure.
|
|
|
|
var targetScrollAmount = Math.abs(targetScrollPosition - playheadPos);
|
|
|
|
if (targetScrollAmount < GRID_SIZE)
|
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
targetScrollPosition += GRID_SIZE * Constants.STEPS_PER_BEAT * Conductor.instance.beatsPerMeasure;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
if (playheadOnly)
|
|
|
|
{
|
|
|
|
playheadAmount = targetScrollPosition - playheadPos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scrollAmount = targetScrollPosition - playheadPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PAGE DOWN = Jump down to nearest measure
|
|
|
|
// GAMEPAD LEFT STICK RIGHT = Jump down to nearest measure
|
|
|
|
if (pageDownKeyHandler.activated || leftStickRightGamepadHandler.activated)
|
|
|
|
{
|
|
|
|
funcJumpDown(false);
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
if (rightStickRightGamepadHandler.activated)
|
|
|
|
{
|
|
|
|
funcJumpDown(true);
|
2023-10-26 05:46:22 -04:00
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
if (playbarButtonPressed == 'playbarForward')
|
|
|
|
{
|
|
|
|
playbarButtonPressed = '';
|
2024-01-06 01:06:10 -05:00
|
|
|
funcJumpDown(false);
|
2023-10-26 05:46:22 -04:00
|
|
|
shouldPause = true;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// SHIFT + Scroll = Scroll Fast
|
2024-01-06 01:06:10 -05:00
|
|
|
// GAMEPAD LEFT STICK CLICK + Scroll = Scroll Fast
|
|
|
|
if (FlxG.keys.pressed.SHIFT || (FlxG.gamepads.firstActive?.pressed?.LEFT_STICK_CLICK ?? false))
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
scrollAmount *= 2;
|
|
|
|
}
|
|
|
|
// CONTROL + Scroll = Scroll Precise
|
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
2024-01-06 01:06:10 -05:00
|
|
|
scrollAmount /= 4;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
|
2023-12-01 17:14:48 -05:00
|
|
|
// Alt + Drag = Scroll but move the playhead the same amount.
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.pressed.ALT)
|
|
|
|
{
|
|
|
|
playheadAmount = scrollAmount;
|
|
|
|
scrollAmount = 0;
|
|
|
|
shouldPause = false;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04: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;
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
if (playbarButtonPressed == 'playbarStart')
|
|
|
|
{
|
|
|
|
playbarButtonPressed = '';
|
|
|
|
scrollAmount = 0 - this.scrollPositionInPixels;
|
|
|
|
playheadAmount = 0 - this.playheadPositionInPixels;
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
|
2023-10-26 05:46:22 -04: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;
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
|
|
|
if (playbarButtonPressed == 'playbarEnd')
|
|
|
|
{
|
|
|
|
playbarButtonPressed = '';
|
|
|
|
scrollAmount = this.songLengthInPixels - this.scrollPositionInPixels;
|
|
|
|
shouldPause = true;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (Math.abs(scrollAmount) > GRID_SIZE * 8)
|
|
|
|
{
|
|
|
|
shouldEase = true;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Resync the conductor and audio tracks.
|
|
|
|
if (scrollAmount != 0 || playheadAmount != 0)
|
|
|
|
{
|
|
|
|
this.playheadPositionInPixels += playheadAmount;
|
|
|
|
if (shouldEase)
|
|
|
|
{
|
|
|
|
easeSongToScrollPosition(this.scrollPositionInPixels + scrollAmount);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else
|
2023-09-12 18:37:59 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Apply the scroll amount.
|
|
|
|
this.scrollPositionInPixels += scrollAmount;
|
|
|
|
moveSongToScrollPosition();
|
2023-09-12 18:37:59 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
if (shouldPause) stopAudioPlayback();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle changing the note snapping level.
|
|
|
|
*/
|
|
|
|
function handleSnap():Void
|
|
|
|
{
|
|
|
|
if (currentLiveInputStyle == None)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.LEFT && !FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
noteSnapQuantIndex--;
|
2023-11-20 11:26:58 -05:00
|
|
|
if (noteSnapQuantIndex < 0) noteSnapQuantIndex = SNAP_QUANTS.length - 1;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.RIGHT && !FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
noteSnapQuantIndex++;
|
2023-11-20 11:26:58 -05:00
|
|
|
if (noteSnapQuantIndex >= SNAP_QUANTS.length) noteSnapQuantIndex = 0;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* Handle display of the mouse cursor.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
function handleCursor():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Mouse sounds
|
2024-03-23 17:50:48 -04:00
|
|
|
if (FlxG.mouse.justPressed) FunkinSound.playOnce(Paths.sound("chartingSounds/ClickDown"));
|
|
|
|
if (FlxG.mouse.justReleased) FunkinSound.playOnce(Paths.sound("chartingSounds/ClickUp"));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Note: If a menu is open in HaxeUI, don't handle cursor behavior.
|
2023-11-21 18:45:31 -05:00
|
|
|
var shouldHandleCursor:Bool = !(isHaxeUIFocused || playbarHeadDragging || isHaxeUIDialogOpen)
|
2023-10-26 05:46:22 -04:00
|
|
|
|| (selectionBoxStartPos != null)
|
|
|
|
|| (dragTargetNote != null || dragTargetEvent != null);
|
2023-11-21 18:45:31 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
var eventColumn:Int = (STRUMLINE_SIZE * 2 + 1) - 1;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-20 11:26:58 -05:00
|
|
|
// trace('shouldHandleCursor: $shouldHandleCursor');
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-03 19:53:17 -05:00
|
|
|
// TODO: TBH some of this should be using FlxMouseEventManager...
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (shouldHandleCursor)
|
|
|
|
{
|
|
|
|
// 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-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -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
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
var overlapsGrid:Bool = FlxG.mouse.overlaps(gridTiledSprite);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-12 06:13:34 -05:00
|
|
|
var overlapsRenderedNotes:Bool = FlxG.mouse.overlaps(renderedNotes);
|
|
|
|
var overlapsRenderedHoldNotes:Bool = FlxG.mouse.overlaps(renderedHoldNotes);
|
|
|
|
var overlapsRenderedEvents:Bool = FlxG.mouse.overlaps(renderedEvents);
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Cursor position relative to the grid.
|
|
|
|
var cursorX:Float = FlxG.mouse.screenX - gridTiledSprite.x;
|
|
|
|
var cursorY:Float = FlxG.mouse.screenY - gridTiledSprite.y;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
var overlapsSelectionBorder:Bool = overlapsGrid
|
|
|
|
&& ((cursorX % 40) < (GRID_SELECTION_BORDER_WIDTH / 2)
|
|
|
|
|| (cursorX % 40) > (40 - (GRID_SELECTION_BORDER_WIDTH / 2))
|
|
|
|
|| (cursorY % 40) < (GRID_SELECTION_BORDER_WIDTH / 2) || (cursorY % 40) > (40 - (GRID_SELECTION_BORDER_WIDTH / 2)));
|
2023-07-22 20:16:43 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
var overlapsSelection:Bool = FlxG.mouse.overlaps(renderedSelectionSquares);
|
|
|
|
|
2023-12-12 05:24:43 -05:00
|
|
|
var overlapsHealthIcons:Bool = FlxG.mouse.overlaps(healthIconBF) || FlxG.mouse.overlaps(healthIconDad);
|
|
|
|
|
2023-12-01 17:14:48 -05:00
|
|
|
if (FlxG.mouse.justPressedMiddle)
|
|
|
|
{
|
|
|
|
if (scrollAnchorScreenPos == null)
|
|
|
|
{
|
|
|
|
scrollAnchorScreenPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
|
|
|
selectionBoxStartPos = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scrollAnchorScreenPos = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.mouse.justPressed)
|
|
|
|
{
|
2023-12-01 17:14:48 -05:00
|
|
|
if (scrollAnchorScreenPos != null)
|
|
|
|
{
|
|
|
|
scrollAnchorScreenPos = null;
|
|
|
|
}
|
2024-01-05 02:35:41 -05:00
|
|
|
else if (measureTicks != null && FlxG.mouse.overlaps(measureTicks) && !isCursorOverHaxeUI)
|
2023-07-22 20:16:43 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
gridPlayheadScrollAreaPressed = true;
|
2023-07-22 20:16:43 -04:00
|
|
|
}
|
2023-12-12 05:24:43 -05:00
|
|
|
else if (notePreview != null && FlxG.mouse.overlaps(notePreview) && !isCursorOverHaxeUI)
|
2023-07-22 20:16:43 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Clicked note preview
|
|
|
|
notePreviewScrollAreaStartPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
2023-07-22 20:16:43 -04:00
|
|
|
}
|
2023-12-01 17:14:48 -05:00
|
|
|
else if (!isCursorOverHaxeUI && (!overlapsGrid || overlapsSelectionBorder))
|
2023-07-22 20:16:43 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
selectionBoxStartPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
|
|
|
// Drawing selection box.
|
|
|
|
targetCursorMode = Crosshair;
|
2023-07-22 20:16:43 -04:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else if (overlapsSelection)
|
2023-07-22 20:16:43 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Do nothing
|
|
|
|
trace('Clicked on a selected note!');
|
2023-07-22 20:16:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (gridPlayheadScrollAreaPressed && FlxG.mouse.released)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
gridPlayheadScrollAreaPressed = false;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (notePreviewScrollAreaStartPos != null && FlxG.mouse.released)
|
|
|
|
{
|
|
|
|
notePreviewScrollAreaStartPos = null;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (gridPlayheadScrollAreaPressed)
|
|
|
|
{
|
|
|
|
// Clicked on the playhead scroll area.
|
|
|
|
// Move the playhead to the cursor position.
|
2024-01-04 08:20:34 -05:00
|
|
|
this.playheadPositionInPixels = FlxG.mouse.screenY - (GRID_INITIAL_Y_POS);
|
2023-10-26 05:46:22 -04:00
|
|
|
moveSongToScrollPosition();
|
|
|
|
|
|
|
|
// Cursor should be a grabby hand.
|
|
|
|
if (targetCursorMode == null) targetCursorMode = Grabbing;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-09-13 14:51:12 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// The song position of the cursor, in steps.
|
|
|
|
var cursorFractionalStep:Float = cursorY / GRID_SIZE;
|
2023-12-14 16:56:20 -05:00
|
|
|
var cursorMs:Float = Conductor.instance.getStepTimeInMs(cursorFractionalStep);
|
2023-10-26 05:46:22 -04:00
|
|
|
// Round the cursor step to the nearest snap quant.
|
|
|
|
var cursorSnappedStep:Float = Math.floor(cursorFractionalStep / noteSnapRatio) * noteSnapRatio;
|
2023-12-14 16:56:20 -05:00
|
|
|
var cursorSnappedMs:Float = Conductor.instance.getStepTimeInMs(cursorSnappedStep);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// The direction value for the column at the cursor.
|
|
|
|
var cursorGridPos:Int = Math.floor(cursorX / GRID_SIZE);
|
|
|
|
var cursorColumn:Int = gridColumnToNoteData(cursorGridPos);
|
|
|
|
|
|
|
|
if (selectionBoxStartPos != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
var cursorXStart:Float = selectionBoxStartPos.x - gridTiledSprite.x;
|
|
|
|
var cursorYStart:Float = selectionBoxStartPos.y - gridTiledSprite.y;
|
2023-09-13 14:51:12 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
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)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// 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-12-14 16:56:20 -05:00
|
|
|
var cursorMsStart:Float = Conductor.instance.getStepTimeInMs(cursorStepStart);
|
2023-10-26 05:46:22 -04:00
|
|
|
var cursorColumnBase:Int = Math.floor(cursorX / GRID_SIZE);
|
|
|
|
var cursorColumnBaseStart:Int = Math.floor(cursorXStart / GRID_SIZE);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Since this selects based on noteData directly,
|
|
|
|
// we don't need to specifically exclude sustain pieces.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// 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));
|
|
|
|
var columns:Array<Int> = [for (i in columnStart...(columnEnd + 1)) i].map(function(i:Int):Int {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
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);
|
2023-09-08 17:41:20 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
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.
|
2024-01-04 08:20:34 -05:00
|
|
|
performCommand(new SetItemSelectionCommand(notesToSelect, eventsToSelect));
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We made a selection box, but it didn't select anything.
|
|
|
|
|
|
|
|
if (!FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
// Deselect all items.
|
2023-11-21 02:12:34 -05:00
|
|
|
var shouldDeselect:Bool = !wasCursorOverHaxeUI && (currentNoteSelection.length > 0 || currentEventSelection.length > 0);
|
|
|
|
if (shouldDeselect)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2024-01-04 08:20:34 -05:00
|
|
|
performCommand(new DeselectAllItemsCommand());
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We made a selection box, but it didn't select any columns.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear the selection box.
|
|
|
|
selectionBoxStartPos = null;
|
|
|
|
setSelectionBoxBounds();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Clicking and dragging.
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
else if (FlxG.mouse.screenY > (playbarHeadLayout?.y ?? 0.0))
|
|
|
|
{
|
|
|
|
// Scroll down.
|
|
|
|
var diff:Float = FlxG.mouse.screenY - (playbarHeadLayout?.y ?? 0.0);
|
|
|
|
scrollPositionInPixels += diff * 0.5; // Too fast!
|
|
|
|
moveSongToScrollPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Render the selection box.
|
|
|
|
var selectionRect:FlxRect = new FlxRect();
|
|
|
|
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-11 17:42:46 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
targetCursorMode = Crosshair;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (FlxG.mouse.justReleased)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Clear the selection box.
|
|
|
|
selectionBoxStartPos = null;
|
|
|
|
setSelectionBoxBounds();
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (overlapsGrid)
|
|
|
|
{
|
|
|
|
// We clicked on the grid without moving the mouse.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Find the first note that is at the cursor position.
|
|
|
|
var highlightedNote:Null<ChartEditorNoteSprite> = renderedNotes.members.find(function(note:ChartEditorNoteSprite):Bool {
|
|
|
|
// If note.alive is false, the note is dead and awaiting recycling.
|
|
|
|
return note.alive && FlxG.mouse.overlaps(note);
|
|
|
|
});
|
|
|
|
var highlightedEvent:Null<ChartEditorEventSprite> = null;
|
|
|
|
if (highlightedNote == null)
|
|
|
|
{
|
|
|
|
highlightedEvent = renderedEvents.members.find(function(event:ChartEditorEventSprite):Bool {
|
|
|
|
return event.alive && FlxG.mouse.overlaps(event);
|
|
|
|
});
|
|
|
|
}
|
2024-01-12 06:13:34 -05:00
|
|
|
var highlightedHoldNote:Null<ChartEditorHoldNoteSprite> = null;
|
|
|
|
if (highlightedNote == null && highlightedEvent == null)
|
|
|
|
{
|
|
|
|
highlightedHoldNote = renderedHoldNotes.members.find(function(holdNote:ChartEditorHoldNoteSprite):Bool {
|
|
|
|
return holdNote.alive && FlxG.mouse.overlaps(holdNote);
|
|
|
|
});
|
|
|
|
}
|
2023-07-22 20:16:43 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
if (highlightedNote != null && highlightedNote.noteData != null)
|
|
|
|
{
|
|
|
|
// Control click to select/deselect an individual note.
|
|
|
|
if (isNoteSelected(highlightedNote.noteData))
|
|
|
|
{
|
|
|
|
performCommand(new DeselectItemsCommand([highlightedNote.noteData], []));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand([highlightedNote.noteData], []));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (highlightedEvent != null && highlightedEvent.eventData != null)
|
|
|
|
{
|
|
|
|
// Control click to select/deselect an individual note.
|
|
|
|
if (isEventSelected(highlightedEvent.eventData))
|
|
|
|
{
|
|
|
|
performCommand(new DeselectItemsCommand([], [highlightedEvent.eventData]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand([], [highlightedEvent.eventData]));
|
|
|
|
}
|
|
|
|
}
|
2024-01-12 06:13:34 -05:00
|
|
|
else if (highlightedHoldNote != null && highlightedHoldNote.noteData != null)
|
|
|
|
{
|
|
|
|
// Control click to select/deselect an individual note.
|
|
|
|
if (isNoteSelected(highlightedNote.noteData))
|
|
|
|
{
|
|
|
|
performCommand(new DeselectItemsCommand([highlightedHoldNote.noteData], []));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand([highlightedHoldNote.noteData], []));
|
|
|
|
}
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Do nothing if you control-clicked on an empty space.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (highlightedNote != null && highlightedNote.noteData != null)
|
|
|
|
{
|
|
|
|
// Click a note to select it.
|
2024-01-04 08:20:34 -05:00
|
|
|
performCommand(new SetItemSelectionCommand([highlightedNote.noteData], []));
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
else if (highlightedEvent != null && highlightedEvent.eventData != null)
|
|
|
|
{
|
|
|
|
// Click an event to select it.
|
2024-01-04 08:20:34 -05:00
|
|
|
performCommand(new SetItemSelectionCommand([], [highlightedEvent.eventData]));
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2024-01-12 06:13:34 -05:00
|
|
|
else if (highlightedHoldNote != null && highlightedHoldNote.noteData != null)
|
|
|
|
{
|
|
|
|
// Click a hold note to select it.
|
2024-01-12 08:13:30 -05:00
|
|
|
performCommand(new SetItemSelectionCommand([highlightedHoldNote.noteData], []));
|
2024-01-12 06:13:34 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Click on an empty space to deselect everything.
|
2023-11-21 02:12:34 -05:00
|
|
|
var shouldDeselect:Bool = !wasCursorOverHaxeUI && (currentNoteSelection.length > 0 || currentEventSelection.length > 0);
|
|
|
|
if (shouldDeselect)
|
|
|
|
{
|
2024-01-04 08:20:34 -05:00
|
|
|
performCommand(new DeselectAllItemsCommand());
|
2023-11-21 02:12:34 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If we clicked and released outside the grid.
|
2023-07-22 20:16:43 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (!FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
// Deselect all items.
|
2023-11-21 02:12:34 -05:00
|
|
|
var shouldDeselect:Bool = !wasCursorOverHaxeUI && (currentNoteSelection.length > 0 || currentEventSelection.length > 0);
|
|
|
|
if (shouldDeselect)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2024-01-04 08:20:34 -05:00
|
|
|
performCommand(new DeselectAllItemsCommand());
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else if (notePreviewScrollAreaStartPos != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Player is clicking and holding on note preview to scrub around.
|
|
|
|
targetCursorMode = Grabbing;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -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-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
scrollPositionInPixels = clickedPosInPixels;
|
|
|
|
moveSongToScrollPosition();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-12-01 17:14:48 -05:00
|
|
|
else if (scrollAnchorScreenPos != null)
|
|
|
|
{
|
|
|
|
// Cursor should be a scroll anchor.
|
|
|
|
targetCursorMode = Scroll;
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else if (dragTargetNote != null || dragTargetEvent != null)
|
2023-07-22 20:16:43 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.mouse.justReleased)
|
|
|
|
{
|
|
|
|
// Perform the actual drag operation.
|
|
|
|
var dragDistanceSteps:Float = dragTargetCurrentStep;
|
|
|
|
var dragDistanceMs:Float = 0;
|
|
|
|
if (dragTargetNote != null && dragTargetNote.noteData != null)
|
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
dragDistanceMs = Conductor.instance.getStepTimeInMs(dragTargetNote.noteData.getStepTime() + dragDistanceSteps) - dragTargetNote.noteData.time;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
else if (dragTargetEvent != null && dragTargetEvent.eventData != null)
|
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
dragDistanceMs = Conductor.instance.getStepTimeInMs(dragTargetEvent.eventData.getStepTime() + dragDistanceSteps) - dragTargetEvent.eventData.time;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
var dragDistanceColumns:Int = dragTargetCurrentColumn;
|
2023-07-22 20:16:43 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (currentNoteSelection.length > 0 && currentEventSelection.length > 0)
|
|
|
|
{
|
|
|
|
// Both notes and events are selected.
|
|
|
|
performCommand(new MoveItemsCommand(currentNoteSelection, currentEventSelection, dragDistanceMs, dragDistanceColumns));
|
|
|
|
}
|
|
|
|
else if (currentNoteSelection.length > 0)
|
|
|
|
{
|
|
|
|
// Only notes are selected.
|
|
|
|
performCommand(new MoveNotesCommand(currentNoteSelection, dragDistanceMs, dragDistanceColumns));
|
|
|
|
}
|
|
|
|
else if (currentEventSelection.length > 0)
|
|
|
|
{
|
|
|
|
// Only events are selected.
|
|
|
|
performCommand(new MoveEventsCommand(currentEventSelection, dragDistanceMs));
|
|
|
|
}
|
2023-07-22 20:16:43 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Finished dragging. Release the note at the new position.
|
|
|
|
dragTargetNote = null;
|
|
|
|
dragTargetEvent = null;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
noteDisplayDirty = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
dragTargetCurrentStep = 0;
|
|
|
|
dragTargetCurrentColumn = 0;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Player is clicking and holding on a selected note or event to move the selection around.
|
|
|
|
targetCursorMode = Grabbing;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -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();
|
|
|
|
}
|
|
|
|
else if (FlxG.mouse.screenY > (playbarHeadLayout?.y ?? 0.0))
|
|
|
|
{
|
|
|
|
// Scroll down.
|
|
|
|
var diff:Float = FlxG.mouse.screenY - (playbarHeadLayout?.y ?? 0.0);
|
|
|
|
scrollPositionInPixels += diff * 0.5; // Too fast!
|
|
|
|
moveSongToScrollPosition();
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Calculate distance between the position dragged to and the original position.
|
|
|
|
var stepTime:Float = 0;
|
|
|
|
if (dragTargetNote != null && dragTargetNote.noteData != null)
|
|
|
|
{
|
|
|
|
stepTime = dragTargetNote.noteData.getStepTime();
|
|
|
|
}
|
|
|
|
else if (dragTargetEvent != null && dragTargetEvent.eventData != null)
|
|
|
|
{
|
|
|
|
stepTime = dragTargetEvent.eventData.getStepTime();
|
|
|
|
}
|
2023-12-14 16:56:20 -05:00
|
|
|
var dragDistanceSteps:Float = Conductor.instance.getTimeInSteps(cursorSnappedMs).clamp(0, songLengthInSteps - (1 * noteSnapRatio)) - stepTime;
|
2023-10-26 05:46:22 -04:00
|
|
|
var data:Int = 0;
|
|
|
|
var noteGridPos:Int = 0;
|
|
|
|
if (dragTargetNote != null && dragTargetNote.noteData != null)
|
|
|
|
{
|
|
|
|
data = dragTargetNote.noteData.data;
|
|
|
|
noteGridPos = noteDataToGridColumn(data);
|
|
|
|
}
|
|
|
|
else if (dragTargetEvent != null)
|
|
|
|
{
|
|
|
|
data = ChartEditorState.STRUMLINE_SIZE * 2 + 1;
|
|
|
|
}
|
|
|
|
var dragDistanceColumns:Int = cursorGridPos - noteGridPos;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (dragTargetCurrentStep != dragDistanceSteps || dragTargetCurrentColumn != dragDistanceColumns)
|
|
|
|
{
|
|
|
|
// Play a sound as we drag.
|
|
|
|
this.playSound(Paths.sound('chartingSounds/noteLay'));
|
2023-07-25 23:11:12 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
trace('Dragged ${dragDistanceColumns} X and ${dragDistanceSteps} Y.');
|
|
|
|
dragTargetCurrentStep = dragDistanceSteps;
|
|
|
|
dragTargetCurrentColumn = dragDistanceColumns;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
noteDisplayDirty = true;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-17 02:42:52 -04:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else if (currentPlaceNoteData != null)
|
2023-10-17 02:42:52 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// Handle extending the note as you drag.
|
2023-07-25 23:11:12 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
var stepTime:Float = inline currentPlaceNoteData.getStepTime();
|
2023-12-14 16:56:20 -05:00
|
|
|
var dragLengthSteps:Float = Conductor.instance.getTimeInSteps(cursorSnappedMs) - stepTime;
|
|
|
|
var dragLengthMs:Float = dragLengthSteps * Conductor.instance.stepLengthMs;
|
2023-10-26 05:46:22 -04:00
|
|
|
var dragLengthPixels:Float = dragLengthSteps * GRID_SIZE;
|
2023-09-26 17:46:07 -04:00
|
|
|
|
2024-01-12 06:13:34 -05:00
|
|
|
if (gridGhostHoldNote != null)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
if (dragLengthSteps > 0)
|
|
|
|
{
|
|
|
|
if (dragLengthCurrent != dragLengthSteps)
|
|
|
|
{
|
|
|
|
stretchySounds = !stretchySounds;
|
|
|
|
this.playSound(Paths.sound('chartingSounds/stretch' + (stretchySounds ? '1' : '2') + '_UI'));
|
2023-10-17 02:42:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
dragLengthCurrent = dragLengthSteps;
|
|
|
|
}
|
2023-09-13 14:51:12 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
gridGhostHoldNote.visible = true;
|
2024-05-19 19:38:52 -04:00
|
|
|
gridGhostHoldNote.noteData = currentPlaceNoteData;
|
|
|
|
gridGhostHoldNote.noteDirection = currentPlaceNoteData.getDirection();
|
2023-11-21 15:10:18 -05:00
|
|
|
gridGhostHoldNote.setHeightDirectly(dragLengthPixels, true);
|
2023-09-26 20:36:41 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
gridGhostHoldNote.updateHoldNotePosition(renderedHoldNotes);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gridGhostHoldNote.visible = false;
|
2023-11-21 15:10:18 -05:00
|
|
|
gridGhostHoldNote.setHeightDirectly(0);
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.mouse.justReleased)
|
|
|
|
{
|
|
|
|
if (dragLengthSteps > 0)
|
|
|
|
{
|
|
|
|
this.playSound(Paths.sound('chartingSounds/stretchSNAP_UI'));
|
|
|
|
// Apply the new length.
|
|
|
|
performCommand(new ExtendNoteLengthCommand(currentPlaceNoteData, dragLengthMs));
|
|
|
|
}
|
2024-01-12 06:13:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Apply the new (zero) length if we are changing the length.
|
|
|
|
if (currentPlaceNoteData.length > 0)
|
|
|
|
{
|
|
|
|
this.playSound(Paths.sound('chartingSounds/stretchSNAP_UI'));
|
|
|
|
performCommand(new ExtendNoteLengthCommand(currentPlaceNoteData, 0));
|
|
|
|
}
|
|
|
|
}
|
2023-08-28 15:03:29 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Finished dragging. Release the note.
|
|
|
|
currentPlaceNoteData = null;
|
|
|
|
}
|
2023-11-22 20:25:25 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Cursor should be a grabby hand.
|
|
|
|
if (targetCursorMode == null) targetCursorMode = Grabbing;
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FlxG.mouse.justPressed)
|
|
|
|
{
|
|
|
|
// Just clicked to place a note.
|
2023-12-10 04:10:57 -05:00
|
|
|
if (!isCursorOverHaxeUI && overlapsGrid && !overlapsSelectionBorder)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
// We clicked on the grid without moving the mouse.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Find the first note that is at the cursor position.
|
|
|
|
var highlightedNote:Null<ChartEditorNoteSprite> = renderedNotes.members.find(function(note:ChartEditorNoteSprite):Bool {
|
|
|
|
// If note.alive is false, the note is dead and awaiting recycling.
|
|
|
|
return note.alive && FlxG.mouse.overlaps(note);
|
|
|
|
});
|
|
|
|
var highlightedEvent:Null<ChartEditorEventSprite> = null;
|
|
|
|
if (highlightedNote == null)
|
|
|
|
{
|
|
|
|
highlightedEvent = renderedEvents.members.find(function(event:ChartEditorEventSprite):Bool {
|
|
|
|
// If event.alive is false, the event is dead and awaiting recycling.
|
|
|
|
return event.alive && FlxG.mouse.overlaps(event);
|
|
|
|
});
|
|
|
|
}
|
2024-01-12 06:13:34 -05:00
|
|
|
var highlightedHoldNote:Null<ChartEditorHoldNoteSprite> = null;
|
|
|
|
if (highlightedNote == null && highlightedEvent == null)
|
|
|
|
{
|
|
|
|
highlightedHoldNote = renderedHoldNotes.members.find(function(holdNote:ChartEditorHoldNoteSprite):Bool {
|
|
|
|
// If holdNote.alive is false, the holdNote is dead and awaiting recycling.
|
|
|
|
return holdNote.alive && FlxG.mouse.overlaps(holdNote);
|
|
|
|
});
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
// Control click to select/deselect an individual note.
|
|
|
|
if (highlightedNote != null && highlightedNote.noteData != null)
|
|
|
|
{
|
|
|
|
if (isNoteSelected(highlightedNote.noteData))
|
|
|
|
{
|
|
|
|
performCommand(new DeselectItemsCommand([highlightedNote.noteData], []));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand([highlightedNote.noteData], []));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (highlightedEvent != null && highlightedEvent.eventData != null)
|
|
|
|
{
|
|
|
|
if (isEventSelected(highlightedEvent.eventData))
|
|
|
|
{
|
|
|
|
performCommand(new DeselectItemsCommand([], [highlightedEvent.eventData]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand([], [highlightedEvent.eventData]));
|
|
|
|
}
|
|
|
|
}
|
2024-01-12 06:13:34 -05:00
|
|
|
else if (highlightedHoldNote != null && highlightedHoldNote.noteData != null)
|
|
|
|
{
|
|
|
|
if (isNoteSelected(highlightedNote.noteData))
|
|
|
|
{
|
|
|
|
performCommand(new DeselectItemsCommand([highlightedHoldNote.noteData], []));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
performCommand(new SelectItemsCommand([highlightedHoldNote.noteData], []));
|
|
|
|
}
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Do nothing when control clicking nothing.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (highlightedNote != null && highlightedNote.noteData != null)
|
|
|
|
{
|
|
|
|
if (isNoteSelected(highlightedNote.noteData))
|
|
|
|
{
|
|
|
|
// Clicked a selected event, start dragging.
|
|
|
|
dragTargetNote = highlightedNote;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If you click an unselected note, and aren't holding Control, deselect everything else.
|
2024-01-04 08:20:34 -05:00
|
|
|
performCommand(new SetItemSelectionCommand([highlightedNote.noteData], []));
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (highlightedEvent != null && highlightedEvent.eventData != null)
|
|
|
|
{
|
|
|
|
if (isEventSelected(highlightedEvent.eventData))
|
|
|
|
{
|
|
|
|
// Clicked a selected event, start dragging.
|
|
|
|
dragTargetEvent = highlightedEvent;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If you click an unselected event, and aren't holding Control, deselect everything else.
|
2024-01-04 08:20:34 -05:00
|
|
|
performCommand(new SetItemSelectionCommand([], [highlightedEvent.eventData]));
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
2024-01-12 06:13:34 -05:00
|
|
|
else if (highlightedHoldNote != null && highlightedHoldNote.noteData != null)
|
|
|
|
{
|
|
|
|
// Clicked a hold note, start dragging TO EXTEND NOTE LENGTH.
|
|
|
|
currentPlaceNoteData = highlightedHoldNote.noteData;
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Click a blank space to place a note and select it.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (cursorGridPos == eventColumn)
|
|
|
|
{
|
|
|
|
// Create an event and place it in the chart.
|
|
|
|
// TODO: Figure out configuring event data.
|
2024-03-06 14:13:48 -05:00
|
|
|
var newEventData:SongEventData = new SongEventData(cursorSnappedMs, eventKindToPlace, eventDataToPlace.copy());
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
performCommand(new AddEventsCommand([newEventData], FlxG.keys.pressed.CONTROL));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Create a note and place it in the chart.
|
2024-03-06 12:29:54 -05:00
|
|
|
var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
currentPlaceNoteData = newNoteData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-12-19 01:26:26 -05:00
|
|
|
// If we clicked and released outside the grid (or on HaxeUI), do nothing.
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
2023-09-08 16:44:10 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
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.
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Find the first note that is at the cursor position.
|
|
|
|
var highlightedNote:Null<ChartEditorNoteSprite> = renderedNotes.members.find(function(note:ChartEditorNoteSprite):Bool {
|
|
|
|
// If note.alive is false, the note is dead and awaiting recycling.
|
|
|
|
return note.alive && FlxG.mouse.overlaps(note);
|
|
|
|
});
|
|
|
|
var highlightedEvent:Null<ChartEditorEventSprite> = null;
|
|
|
|
if (highlightedNote == null)
|
|
|
|
{
|
|
|
|
highlightedEvent = renderedEvents.members.find(function(event:ChartEditorEventSprite):Bool {
|
|
|
|
// If event.alive is false, the event is dead and awaiting recycling.
|
|
|
|
return event.alive && FlxG.mouse.overlaps(event);
|
|
|
|
});
|
|
|
|
}
|
2024-01-12 06:13:34 -05:00
|
|
|
var highlightedHoldNote:Null<ChartEditorHoldNoteSprite> = null;
|
|
|
|
if (highlightedNote == null && highlightedEvent == null)
|
|
|
|
{
|
|
|
|
highlightedHoldNote = renderedHoldNotes.members.find(function(holdNote:ChartEditorHoldNoteSprite):Bool {
|
|
|
|
// If holdNote.alive is false, the holdNote is dead and awaiting recycling.
|
|
|
|
return holdNote.alive && FlxG.mouse.overlaps(holdNote);
|
|
|
|
});
|
|
|
|
}
|
2023-09-04 15:33:08 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (highlightedNote != null && highlightedNote.noteData != null)
|
|
|
|
{
|
|
|
|
// TODO: Handle the case of clicking on a sustain piece.
|
2024-01-03 19:53:17 -05:00
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
// Shift + Right click opens the context menu.
|
|
|
|
// If we are clicking a large selection, open the Selection context menu, otherwise open the Note context menu.
|
|
|
|
var isHighlightedNoteSelected:Bool = isNoteSelected(highlightedNote.noteData);
|
|
|
|
var useSingleNoteContextMenu:Bool = (!isHighlightedNoteSelected)
|
|
|
|
|| (isHighlightedNoteSelected && currentNoteSelection.length == 1);
|
|
|
|
// Show the context menu connected to the note.
|
|
|
|
if (useSingleNoteContextMenu)
|
|
|
|
{
|
|
|
|
this.openNoteContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY, highlightedNote.noteData);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.openSelectionContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Right click removes the note.
|
|
|
|
performCommand(new RemoveNotesCommand([highlightedNote.noteData]));
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
else if (highlightedEvent != null && highlightedEvent.eventData != null)
|
|
|
|
{
|
2024-01-03 19:53:17 -05:00
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
// Shift + Right click opens the context menu.
|
|
|
|
// If we are clicking a large selection, open the Selection context menu, otherwise open the Event context menu.
|
|
|
|
var isHighlightedEventSelected:Bool = isEventSelected(highlightedEvent.eventData);
|
|
|
|
var useSingleEventContextMenu:Bool = (!isHighlightedEventSelected)
|
|
|
|
|| (isHighlightedEventSelected && currentEventSelection.length == 1);
|
|
|
|
if (useSingleEventContextMenu)
|
|
|
|
{
|
|
|
|
this.openEventContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY, highlightedEvent.eventData);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.openSelectionContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Right click removes the event.
|
|
|
|
performCommand(new RemoveEventsCommand([highlightedEvent.eventData]));
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2024-01-12 06:13:34 -05:00
|
|
|
else if (highlightedHoldNote != null && highlightedHoldNote.noteData != null)
|
|
|
|
{
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
// Shift + Right click opens the context menu.
|
|
|
|
// If we are clicking a large selection, open the Selection context menu, otherwise open the Note context menu.
|
|
|
|
var isHighlightedNoteSelected:Bool = isNoteSelected(highlightedHoldNote.noteData);
|
|
|
|
var useSingleNoteContextMenu:Bool = (!isHighlightedNoteSelected)
|
|
|
|
|| (isHighlightedNoteSelected && currentNoteSelection.length == 1);
|
|
|
|
// Show the context menu connected to the note.
|
|
|
|
if (useSingleNoteContextMenu)
|
|
|
|
{
|
|
|
|
this.openHoldNoteContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY, highlightedHoldNote.noteData);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.openSelectionContextMenu(FlxG.mouse.screenX, FlxG.mouse.screenY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Right click removes hold from the note.
|
|
|
|
this.playSound(Paths.sound('chartingSounds/stretchSNAP_UI'));
|
|
|
|
performCommand(new ExtendNoteLengthCommand(highlightedHoldNote.noteData, 0));
|
|
|
|
}
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Right clicked on nothing.
|
|
|
|
}
|
|
|
|
}
|
2023-09-04 15:33:08 -04:00
|
|
|
|
2024-01-12 06:13:34 -05:00
|
|
|
var isOrWillSelect = overlapsSelection || dragTargetNote != null || dragTargetEvent != null || overlapsRenderedNotes || overlapsRenderedHoldNotes
|
|
|
|
|| overlapsRenderedEvents;
|
2023-10-26 05:46:22 -04:00
|
|
|
// Handle grid cursor.
|
2023-12-10 04:10:57 -05:00
|
|
|
if (!isCursorOverHaxeUI && overlapsGrid && !isOrWillSelect && !overlapsSelectionBorder && !gridPlayheadScrollAreaPressed)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
// Indicate that we can place a note here.
|
2023-09-25 23:24:07 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (cursorGridPos == eventColumn)
|
|
|
|
{
|
|
|
|
if (gridGhostNote != null) gridGhostNote.visible = false;
|
|
|
|
if (gridGhostHoldNote != null) gridGhostHoldNote.visible = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (gridGhostEvent == null) throw "ERROR: Tried to handle cursor, but gridGhostEvent is null! Check ChartEditorState.buildGrid()";
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-03 19:53:17 -05:00
|
|
|
var eventData:SongEventData = gridGhostEvent.eventData != null ? gridGhostEvent.eventData : new SongEventData(cursorMs, eventKindToPlace, null);
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2024-02-18 03:02:36 -05:00
|
|
|
if (eventKindToPlace != eventData.eventKind)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2024-02-18 03:02:36 -05:00
|
|
|
eventData.eventKind = eventKindToPlace;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
eventData.time = cursorSnappedMs;
|
|
|
|
|
|
|
|
gridGhostEvent.visible = true;
|
|
|
|
gridGhostEvent.eventData = eventData;
|
|
|
|
gridGhostEvent.updateEventPosition(renderedEvents);
|
2023-10-11 00:30:41 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
targetCursorMode = Cell;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gridGhostEvent != null) gridGhostEvent.visible = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (gridGhostNote == null) throw "ERROR: Tried to handle cursor, but gridGhostNote is null! Check ChartEditorState.buildGrid()";
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-03 19:53:17 -05:00
|
|
|
var noteData:SongNoteData = gridGhostNote.noteData != null ? gridGhostNote.noteData : new SongNoteData(cursorMs, cursorColumn, 0, noteKindToPlace);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-03 19:53:17 -05:00
|
|
|
if (cursorColumn != noteData.data || noteKindToPlace != noteData.kind)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2024-01-03 19:53:17 -05:00
|
|
|
noteData.kind = noteKindToPlace;
|
2023-10-26 05:46:22 -04:00
|
|
|
noteData.data = cursorColumn;
|
|
|
|
gridGhostNote.playNoteAnimation();
|
|
|
|
}
|
|
|
|
noteData.time = cursorSnappedMs;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
gridGhostNote.visible = true;
|
|
|
|
gridGhostNote.noteData = noteData;
|
|
|
|
gridGhostNote.updateNotePosition(renderedNotes);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
targetCursorMode = Cell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gridGhostNote != null) gridGhostNote.visible = false;
|
|
|
|
if (gridGhostHoldNote != null) gridGhostHoldNote.visible = false;
|
|
|
|
if (gridGhostEvent != null) gridGhostEvent.visible = false;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (targetCursorMode == null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.mouse.pressed)
|
|
|
|
{
|
|
|
|
if (overlapsSelection)
|
|
|
|
{
|
|
|
|
targetCursorMode = Grabbing;
|
|
|
|
}
|
|
|
|
if (overlapsSelectionBorder)
|
|
|
|
{
|
|
|
|
targetCursorMode = Crosshair;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-12-10 04:10:57 -05:00
|
|
|
if (!isCursorOverHaxeUI)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2023-12-10 04:10:57 -05:00
|
|
|
if (notePreview != null && FlxG.mouse.overlaps(notePreview))
|
|
|
|
{
|
|
|
|
targetCursorMode = Pointer;
|
|
|
|
}
|
2024-01-05 02:35:41 -05:00
|
|
|
else if (measureTicks != null && FlxG.mouse.overlaps(measureTicks))
|
2023-12-10 04:10:57 -05:00
|
|
|
{
|
|
|
|
targetCursorMode = Pointer;
|
|
|
|
}
|
|
|
|
else if (overlapsSelection)
|
|
|
|
{
|
|
|
|
targetCursorMode = Pointer;
|
|
|
|
}
|
|
|
|
else if (overlapsSelectionBorder)
|
|
|
|
{
|
|
|
|
targetCursorMode = Crosshair;
|
|
|
|
}
|
2024-01-12 06:13:34 -05:00
|
|
|
else if (overlapsRenderedNotes)
|
|
|
|
{
|
|
|
|
targetCursorMode = Pointer;
|
|
|
|
}
|
|
|
|
else if (overlapsRenderedHoldNotes)
|
|
|
|
{
|
|
|
|
targetCursorMode = Pointer;
|
|
|
|
}
|
|
|
|
else if (overlapsRenderedEvents)
|
|
|
|
{
|
|
|
|
targetCursorMode = Pointer;
|
|
|
|
}
|
2023-12-10 04:10:57 -05:00
|
|
|
else if (overlapsGrid)
|
|
|
|
{
|
|
|
|
targetCursorMode = Cell;
|
|
|
|
}
|
2023-12-13 22:42:09 -05:00
|
|
|
else if (overlapsHealthIcons)
|
|
|
|
{
|
|
|
|
targetCursorMode = Pointer;
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Actually set the cursor mode to the one we specified earlier.
|
|
|
|
Cursor.cursorMode = targetCursorMode ?? Default;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (gridGhostNote != null) gridGhostNote.visible = false;
|
|
|
|
if (gridGhostHoldNote != null) gridGhostHoldNote.visible = false;
|
|
|
|
if (gridGhostEvent != null) gridGhostEvent.visible = false;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Do not set Cursor.cursorMode here, because it will be set by the HaxeUI.
|
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;
|
|
|
|
|
2024-01-18 01:06:15 -05:00
|
|
|
var difficultyToolbox:ChartEditorDifficultyToolbox = cast this.getToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
2023-08-31 18:47:23 -04:00
|
|
|
if (difficultyToolbox == null) return;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-01-18 01:06:15 -05:00
|
|
|
difficultyToolbox.updateTree();
|
2023-01-22 19:55:30 -05: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-12-12 05:24:43 -05:00
|
|
|
var charPreviewToolbox:Null<CollapsibleDialog> = this.getToolbox_OLD(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
|
|
|
{
|
2024-01-04 08:20:34 -05: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-12-12 05:24:43 -05:00
|
|
|
var charPreviewToolbox:Null<CollapsibleDialog> = this.getToolbox_OLD(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
|
|
|
{
|
2024-01-04 08:20:34 -05: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
|
|
|
}
|
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
function handleSelectionButtons():Void
|
|
|
|
{
|
|
|
|
// Make sure buttons are never nudged out of the correct spot.
|
|
|
|
// TODO: Why do these even move in the first place? The camera never moves, LOL.
|
|
|
|
buttonSelectOpponent.y = GRID_INITIAL_Y_POS - NOTE_SELECT_BUTTON_HEIGHT - 2;
|
|
|
|
buttonSelectPlayer.y = GRID_INITIAL_Y_POS - NOTE_SELECT_BUTTON_HEIGHT - 2;
|
|
|
|
buttonSelectEvent.y = GRID_INITIAL_Y_POS - NOTE_SELECT_BUTTON_HEIGHT - 2;
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Handles display elements for the playbar at the bottom.
|
|
|
|
*/
|
|
|
|
function handlePlaybar():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (playbarHeadLayout == null) throw "ERROR: Tried to handle playbar, but playbarHeadLayout is null!";
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Make sure the playbar is never nudged out of the correct spot.
|
|
|
|
playbarHeadLayout.x = 4;
|
|
|
|
playbarHeadLayout.y = FlxG.height - 48 - 8;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Move the playhead to match the song position, if we aren't dragging it.
|
|
|
|
if (!playbarHeadDragging)
|
2023-08-14 23:13:12 -04:00
|
|
|
{
|
2023-12-08 16:12:36 -05:00
|
|
|
var songPosPercent = scrollPositionInPixels / (songLengthInPixels) * 100;
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
if (playbarHeadLayout.playbarHead.value != songPosPercent) playbarHeadLayout.playbarHead.value = songPosPercent;
|
2023-08-14 23:13:12 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-12-14 16:56:20 -05:00
|
|
|
var songPos:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset;
|
2023-12-08 01:15:22 -05:00
|
|
|
var songPosSeconds:String = Std.string(Math.floor((Math.abs(songPos) / 1000) % 60)).lpad('0', 2);
|
|
|
|
var songPosMinutes:String = Std.string(Math.floor((Math.abs(songPos) / 1000) / 60)).lpad('0', 2);
|
|
|
|
if (songPos < 0) songPosMinutes = '-' + songPosMinutes;
|
2023-10-26 05:46:22 -04:00
|
|
|
var songPosString:String = '${songPosMinutes}:${songPosSeconds}';
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
if (playbarSongPos.value != songPosString) playbarSongPos.value = songPosString;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-12-08 16:12:36 -05:00
|
|
|
var songRemaining:Float = Math.max(songLengthInMs - songPos, 0.0);
|
2023-10-26 05:46:22 -04: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-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
if (playbarSongRemaining.value != songRemainingString) playbarSongRemaining.value = songRemainingString;
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
playbarNoteSnap.text = '1/${noteSnapQuant}';
|
2024-01-02 14:07:07 -05:00
|
|
|
playbarDifficulty.text = '${selectedDifficulty.toTitleCase()}';
|
2024-03-22 03:04:33 -04:00
|
|
|
playbarBPM.text = 'BPM: ${(Conductor.instance.bpm ?? 0.0)}';
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
function handlePlayhead():Void
|
2023-08-15 16:08:12 -04:00
|
|
|
{
|
2024-01-06 01:06:10 -05:00
|
|
|
// Place notes at the playhead with the keyboard.
|
2023-10-26 05:46:22 -04:00
|
|
|
switch (currentLiveInputStyle)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2024-02-28 21:19:21 -05:00
|
|
|
case ChartEditorLiveInputStyle.WASDKeys:
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.A) placeNoteAtPlayhead(4);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.A) finishPlaceNoteAtPlayhead(4);
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.S) placeNoteAtPlayhead(5);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.S) finishPlaceNoteAtPlayhead(5);
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.W) placeNoteAtPlayhead(6);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.W) finishPlaceNoteAtPlayhead(6);
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.D) placeNoteAtPlayhead(7);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.D) finishPlaceNoteAtPlayhead(7);
|
2023-08-15 16:08:12 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.LEFT) placeNoteAtPlayhead(0);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.LEFT) finishPlaceNoteAtPlayhead(0);
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.DOWN) placeNoteAtPlayhead(1);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.DOWN) finishPlaceNoteAtPlayhead(1);
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.UP) placeNoteAtPlayhead(2);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.UP) finishPlaceNoteAtPlayhead(2);
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.RIGHT) placeNoteAtPlayhead(3);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.RIGHT) finishPlaceNoteAtPlayhead(3);
|
2023-10-26 05:46:22 -04:00
|
|
|
case ChartEditorLiveInputStyle.NumberKeys:
|
|
|
|
// Flipped because Dad is on the left but represents data 0-3.
|
|
|
|
if (FlxG.keys.justPressed.ONE) placeNoteAtPlayhead(4);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.ONE) finishPlaceNoteAtPlayhead(4);
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.TWO) placeNoteAtPlayhead(5);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.TWO) finishPlaceNoteAtPlayhead(5);
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.THREE) placeNoteAtPlayhead(6);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.THREE) finishPlaceNoteAtPlayhead(6);
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.FOUR) placeNoteAtPlayhead(7);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.FOUR) finishPlaceNoteAtPlayhead(7);
|
2023-08-15 16:08:12 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.FIVE) placeNoteAtPlayhead(0);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.FIVE) finishPlaceNoteAtPlayhead(0);
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.SIX) placeNoteAtPlayhead(1);
|
|
|
|
if (FlxG.keys.justPressed.SEVEN) placeNoteAtPlayhead(2);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.SEVEN) finishPlaceNoteAtPlayhead(2);
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.justPressed.EIGHT) placeNoteAtPlayhead(3);
|
2024-01-06 01:06:10 -05:00
|
|
|
if (FlxG.keys.justReleased.EIGHT) finishPlaceNoteAtPlayhead(3);
|
2023-10-26 05:46:22 -04:00
|
|
|
case ChartEditorLiveInputStyle.None:
|
|
|
|
// Do nothing.
|
2023-09-25 23:24:07 -04:00
|
|
|
}
|
2024-01-06 01:06:10 -05:00
|
|
|
|
2024-05-02 03:38:27 -04:00
|
|
|
// Place events at playhead.
|
|
|
|
if (FlxG.keys.justPressed.COMMA) placeEventAtPlayhead(true);
|
|
|
|
if (FlxG.keys.justPressed.PERIOD) placeEventAtPlayhead(false);
|
|
|
|
|
2024-01-08 21:26:24 -05:00
|
|
|
updatePlayheadGhostHoldNotes();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
function placeNoteAtPlayhead(column:Int):Void
|
2023-08-15 16:08:12 -04:00
|
|
|
{
|
2024-01-06 01:06:10 -05:00
|
|
|
// SHIFT + press or LEFT_SHOULDER + press to remove notes instead of placing them.
|
|
|
|
var removeNoteInstead:Bool = FlxG.keys.pressed.SHIFT || (FlxG.gamepads.firstActive?.pressed?.LEFT_SHOULDER ?? false);
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
|
|
|
|
var playheadPosFractionalStep:Float = playheadPos / GRID_SIZE / noteSnapRatio;
|
|
|
|
var playheadPosStep:Int = Std.int(Math.floor(playheadPosFractionalStep));
|
2023-12-14 16:56:20 -05:00
|
|
|
var playheadPosSnappedMs:Float = playheadPosStep * Conductor.instance.stepLengthMs * noteSnapRatio;
|
2023-09-25 23:24:07 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Look for notes within 1 step of the playhead.
|
|
|
|
var notesAtPos:Array<SongNoteData> = SongDataUtils.getNotesInTimeRange(currentSongChartNoteData, playheadPosSnappedMs,
|
2023-12-14 16:56:20 -05:00
|
|
|
playheadPosSnappedMs + Conductor.instance.stepLengthMs * noteSnapRatio);
|
2023-10-26 05:46:22 -04:00
|
|
|
notesAtPos = SongDataUtils.getNotesWithData(notesAtPos, [column]);
|
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
if (notesAtPos.length == 0 && !removeNoteInstead)
|
2023-09-25 23:24:07 -04:00
|
|
|
{
|
2024-01-08 21:26:24 -05:00
|
|
|
trace('Placing note. ${column}');
|
2024-01-03 19:53:17 -05:00
|
|
|
var newNoteData:SongNoteData = new SongNoteData(playheadPosSnappedMs, column, 0, noteKindToPlace);
|
2023-10-26 05:46:22 -04:00
|
|
|
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
|
2024-01-06 01:06:10 -05:00
|
|
|
currentLiveInputPlaceNoteData[column] = newNoteData;
|
|
|
|
}
|
|
|
|
else if (removeNoteInstead)
|
|
|
|
{
|
2024-01-08 21:26:24 -05:00
|
|
|
trace('Removing existing note at position. ${column}');
|
2024-01-06 01:06:10 -05:00
|
|
|
performCommand(new RemoveNotesCommand(notesAtPos));
|
2023-09-25 23:24:07 -04:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else
|
2023-09-25 23:24:07 -04:00
|
|
|
{
|
2024-01-08 21:26:24 -05:00
|
|
|
trace('Already a note there. ${column}');
|
2023-09-25 23:24:07 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2024-05-02 03:38:27 -04:00
|
|
|
function placeEventAtPlayhead(isOpponent:Bool):Void
|
|
|
|
{
|
|
|
|
// SHIFT + press or LEFT_SHOULDER + press to remove events instead of placing them.
|
|
|
|
var removeEventInstead:Bool = FlxG.keys.pressed.SHIFT || (FlxG.gamepads.firstActive?.pressed?.LEFT_SHOULDER ?? false);
|
|
|
|
|
|
|
|
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
|
|
|
|
var playheadPosFractionalStep:Float = playheadPos / GRID_SIZE / noteSnapRatio;
|
|
|
|
var playheadPosStep:Int = Std.int(Math.floor(playheadPosFractionalStep));
|
|
|
|
var playheadPosSnappedMs:Float = playheadPosStep * Conductor.instance.stepLengthMs * noteSnapRatio;
|
|
|
|
|
|
|
|
// Look for events within 1 step of the playhead.
|
|
|
|
var eventsAtPos:Array<SongEventData> = SongDataUtils.getEventsInTimeRange(currentSongChartEventData, playheadPosSnappedMs,
|
|
|
|
playheadPosSnappedMs + Conductor.instance.stepLengthMs * noteSnapRatio);
|
|
|
|
eventsAtPos = SongDataUtils.getEventsWithKind(eventsAtPos, ['FocusCamera']);
|
|
|
|
|
|
|
|
if (eventsAtPos.length == 0 && !removeEventInstead)
|
|
|
|
{
|
|
|
|
trace('Placing event ${isOpponent}');
|
|
|
|
var newEventData:SongEventData = new SongEventData(playheadPosSnappedMs, 'FocusCamera',
|
|
|
|
{
|
|
|
|
char: isOpponent ? 1 : 0,
|
|
|
|
});
|
|
|
|
performCommand(new AddEventsCommand([newEventData], FlxG.keys.pressed.CONTROL));
|
|
|
|
}
|
|
|
|
else if (removeEventInstead)
|
|
|
|
{
|
|
|
|
trace('Removing existing event at position.');
|
|
|
|
performCommand(new RemoveEventsCommand(eventsAtPos));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trace('Already an event there.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
function updatePlayheadGhostHoldNotes():Void
|
|
|
|
{
|
2024-01-08 21:26:24 -05:00
|
|
|
// Ensure all the ghost hold notes exist.
|
|
|
|
while (gridPlayheadGhostHoldNotes.length < (STRUMLINE_SIZE * 2))
|
|
|
|
{
|
|
|
|
var ghost = new ChartEditorHoldNoteSprite(this);
|
|
|
|
ghost.alpha = 0.6;
|
|
|
|
ghost.noteData = null;
|
|
|
|
ghost.visible = false;
|
|
|
|
ghost.zIndex = 11;
|
|
|
|
add(ghost); // Don't add to `renderedHoldNotes` because then it will get killed every frame.
|
|
|
|
|
|
|
|
gridPlayheadGhostHoldNotes.push(ghost);
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
2024-01-06 01:06:10 -05:00
|
|
|
// Update playhead ghost hold notes.
|
2024-01-08 21:26:24 -05:00
|
|
|
for (column in 0...gridPlayheadGhostHoldNotes.length)
|
2024-01-06 01:06:10 -05:00
|
|
|
{
|
2024-01-08 21:26:24 -05:00
|
|
|
var targetNoteData = currentLiveInputPlaceNoteData[column];
|
|
|
|
var ghostHold = gridPlayheadGhostHoldNotes[column];
|
|
|
|
|
|
|
|
if (targetNoteData == null && ghostHold.noteData != null)
|
|
|
|
{
|
|
|
|
// Remove the ghost hold note.
|
|
|
|
ghostHold.noteData = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (targetNoteData != null && ghostHold.noteData == null)
|
|
|
|
{
|
|
|
|
// Readd the new ghost hold note.
|
|
|
|
ghostHold.noteData = targetNoteData.clone();
|
|
|
|
ghostHold.noteDirection = ghostHold.noteData.getDirection();
|
|
|
|
ghostHold.visible = true;
|
|
|
|
ghostHold.alpha = 0.6;
|
|
|
|
ghostHold.setHeightDirectly(0);
|
|
|
|
ghostHold.updateHoldNotePosition(renderedHoldNotes);
|
|
|
|
}
|
2024-01-06 01:06:10 -05:00
|
|
|
|
|
|
|
if (ghostHold.noteData == null)
|
|
|
|
{
|
|
|
|
ghostHold.visible = false;
|
|
|
|
ghostHold.setHeightDirectly(0);
|
2024-01-08 21:26:24 -05:00
|
|
|
playheadDragLengthCurrent[column] = 0;
|
2024-01-06 01:06:10 -05:00
|
|
|
continue;
|
2024-01-08 21:26:24 -05:00
|
|
|
}
|
2024-01-06 01:06:10 -05:00
|
|
|
|
|
|
|
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
|
|
|
|
var playheadPosFractionalStep:Float = playheadPos / GRID_SIZE / noteSnapRatio;
|
|
|
|
var playheadPosStep:Int = Std.int(Math.floor(playheadPosFractionalStep));
|
|
|
|
var playheadPosSnappedMs:Float = playheadPosStep * Conductor.instance.stepLengthMs * noteSnapRatio;
|
|
|
|
|
|
|
|
var newNoteLength:Float = playheadPosSnappedMs - ghostHold.noteData.time;
|
|
|
|
trace('newNoteLength: ${newNoteLength}');
|
|
|
|
|
|
|
|
if (newNoteLength > 0)
|
|
|
|
{
|
|
|
|
ghostHold.noteData.length = newNoteLength;
|
|
|
|
var targetNoteLengthSteps:Float = ghostHold.noteData.getStepLength(true);
|
|
|
|
var targetNoteLengthStepsInt:Int = Std.int(Math.floor(targetNoteLengthSteps));
|
|
|
|
var targetNoteLengthPixels:Float = targetNoteLengthSteps * GRID_SIZE;
|
|
|
|
|
2024-01-08 21:26:24 -05:00
|
|
|
if (playheadDragLengthCurrent[column] != targetNoteLengthStepsInt)
|
2024-01-06 01:06:10 -05:00
|
|
|
{
|
|
|
|
stretchySounds = !stretchySounds;
|
|
|
|
this.playSound(Paths.sound('chartingSounds/stretch' + (stretchySounds ? '1' : '2') + '_UI'));
|
2024-01-08 21:26:24 -05:00
|
|
|
playheadDragLengthCurrent[column] = targetNoteLengthStepsInt;
|
2024-01-06 01:06:10 -05:00
|
|
|
}
|
|
|
|
ghostHold.visible = true;
|
2024-01-08 21:26:24 -05:00
|
|
|
ghostHold.alpha = 0.6;
|
2024-01-06 01:06:10 -05:00
|
|
|
ghostHold.setHeightDirectly(targetNoteLengthPixels, true);
|
|
|
|
ghostHold.updateHoldNotePosition(renderedHoldNotes);
|
2024-01-08 21:26:24 -05:00
|
|
|
trace('lerpLength: ${ghostHold.fullSustainLength}');
|
|
|
|
trace('position: ${ghostHold.x}, ${ghostHold.y}');
|
2024-01-06 01:06:10 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ghostHold.visible = false;
|
|
|
|
ghostHold.setHeightDirectly(0);
|
2024-01-08 21:26:24 -05:00
|
|
|
playheadDragLengthCurrent[column] = 0;
|
|
|
|
continue;
|
2024-01-06 01:06:10 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function finishPlaceNoteAtPlayhead(column:Int):Void
|
|
|
|
{
|
|
|
|
if (currentLiveInputPlaceNoteData[column] == null) return;
|
|
|
|
|
|
|
|
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
|
|
|
|
var playheadPosFractionalStep:Float = playheadPos / GRID_SIZE / noteSnapRatio;
|
|
|
|
var playheadPosStep:Int = Std.int(Math.floor(playheadPosFractionalStep));
|
|
|
|
var playheadPosSnappedMs:Float = playheadPosStep * Conductor.instance.stepLengthMs * noteSnapRatio;
|
|
|
|
|
|
|
|
var newNoteLength:Float = playheadPosSnappedMs - currentLiveInputPlaceNoteData[column].time;
|
|
|
|
trace('finishPlace newNoteLength: ${newNoteLength}');
|
|
|
|
|
|
|
|
if (newNoteLength < Conductor.instance.stepLengthMs)
|
|
|
|
{
|
|
|
|
// Don't extend the note if it's too short.
|
2024-01-08 21:26:24 -05:00
|
|
|
trace('Not extending note. ${column}');
|
2024-01-06 01:06:10 -05:00
|
|
|
currentLiveInputPlaceNoteData[column] = null;
|
|
|
|
gridPlayheadGhostHoldNotes[column].noteData = null;
|
2023-09-25 23:24:07 -04:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
else
|
2023-09-25 23:24:07 -04:00
|
|
|
{
|
2024-01-06 01:06:10 -05:00
|
|
|
// Extend the note to the playhead position.
|
2024-01-08 21:26:24 -05:00
|
|
|
trace('Extending note. ${column}');
|
2024-01-06 01:06:10 -05:00
|
|
|
this.playSound(Paths.sound('chartingSounds/stretchSNAP_UI'));
|
|
|
|
performCommand(new ExtendNoteLengthCommand(currentLiveInputPlaceNoteData[column], newNoteLength));
|
|
|
|
currentLiveInputPlaceNoteData[column] = null;
|
|
|
|
gridPlayheadGhostHoldNotes[column].noteData = null;
|
2023-09-25 23:24:07 -04:00
|
|
|
}
|
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.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-09-13 14:51:12 -04:00
|
|
|
function handleHealthIcons():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (healthIconsDirty)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
var charDataBF = CharacterDataParser.fetchCharacterData(currentSongMetadata.playData.characters.player);
|
|
|
|
var charDataDad = CharacterDataParser.fetchCharacterData(currentSongMetadata.playData.characters.opponent);
|
|
|
|
if (healthIconBF != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
healthIconBF.configure(charDataBF?.healthIcon);
|
|
|
|
healthIconBF.size *= 0.5; // Make the icon smaller in Chart Editor.
|
|
|
|
healthIconBF.flipX = !healthIconBF.flipX; // BF faces the other way.
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2024-01-04 08:20:34 -05:00
|
|
|
if (buttonSelectPlayer != null)
|
|
|
|
{
|
|
|
|
buttonSelectPlayer.text = charDataBF?.name ?? 'Player';
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
if (healthIconDad != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
healthIconDad.configure(charDataDad?.healthIcon);
|
|
|
|
healthIconDad.size *= 0.5; // Make the icon smaller in Chart Editor.
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2024-01-04 08:20:34 -05:00
|
|
|
if (buttonSelectOpponent != null)
|
|
|
|
{
|
|
|
|
buttonSelectOpponent.text = charDataDad?.name ?? 'Opponent';
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
healthIconsDirty = false;
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Right align, and visibly center, the BF health icon.
|
|
|
|
if (healthIconBF != null)
|
|
|
|
{
|
|
|
|
// Base X position to the right of the grid.
|
2024-01-04 08:20:34 -05:00
|
|
|
var xOffset = 45 - (healthIconBF.width / 2);
|
|
|
|
healthIconBF.x = (gridTiledSprite == null) ? (0) : (GRID_X_POS + gridTiledSprite.width + xOffset);
|
|
|
|
var yOffset = 30 - (healthIconBF.height / 2);
|
|
|
|
healthIconBF.y = (gridTiledSprite == null) ? (0) : (GRID_INITIAL_Y_POS - NOTE_SELECT_BUTTON_HEIGHT) + yOffset;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// Visibly center the Dad health icon.
|
|
|
|
if (healthIconDad != null)
|
|
|
|
{
|
2024-01-12 06:35:41 -05:00
|
|
|
var xOffset = 75 + (healthIconDad.width / 2);
|
2024-01-04 08:20:34 -05:00
|
|
|
healthIconDad.x = (gridTiledSprite == null) ? (0) : (GRID_X_POS - xOffset);
|
|
|
|
var yOffset = 30 - (healthIconDad.height / 2);
|
|
|
|
healthIconDad.y = (gridTiledSprite == null) ? (0) : (GRID_INITIAL_Y_POS - NOTE_SELECT_BUTTON_HEIGHT) + yOffset;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* Handle keybinds for File menu items.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
function handleFileKeybinds():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// CTRL + N = New Chart
|
2023-11-24 00:42:07 -05:00
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.N && !isHaxeUIDialogOpen)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
this.openWelcomeDialog(true);
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// CTRL + O = Open Chart
|
2023-11-24 00:42:07 -05:00
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.O && !isHaxeUIDialogOpen)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2023-11-04 23:51:15 -04:00
|
|
|
this.openBrowseFNFC(true);
|
2023-09-04 15:33:08 -04:00
|
|
|
}
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.S && !isHaxeUIDialogOpen)
|
2023-10-24 15:50:02 -04:00
|
|
|
{
|
|
|
|
if (currentWorkingFilePath == null || FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
// CTRL + SHIFT + S = Save As
|
2023-11-22 20:25:25 -05:00
|
|
|
this.exportAllSongData(false, null, function(path:String) {
|
|
|
|
// CTRL + SHIFT + S Successful
|
|
|
|
this.success('Saved Chart', 'Chart saved successfully to ${path}.');
|
|
|
|
}, function() {
|
|
|
|
// CTRL + SHIFT + S Cancelled
|
|
|
|
});
|
2023-10-24 15:50:02 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// CTRL + S = Save Chart
|
2023-11-21 13:31:02 -05:00
|
|
|
this.exportAllSongData(true, currentWorkingFilePath);
|
2023-11-22 20:25:25 -05:00
|
|
|
this.success('Saved Chart', 'Chart saved successfully to ${currentWorkingFilePath}.');
|
2023-10-24 15:50:02 -04:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-08-16 03:40:44 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// CTRL + Q = Quit to Menu
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.Q)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
quitChartEditor();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-21 01:04:50 -04:00
|
|
|
@:nullSafety(Off)
|
2023-10-11 00:30:41 -04:00
|
|
|
function quitChartEditor():Void
|
|
|
|
{
|
|
|
|
autoSave();
|
2023-10-17 17:59:01 -04:00
|
|
|
stopWelcomeMusic();
|
2023-10-21 01:04:50 -04:00
|
|
|
// TODO: PR Flixel to make onComplete nullable.
|
|
|
|
if (audioInstTrack != null) audioInstTrack.onComplete = null;
|
2024-02-05 21:35:58 -05:00
|
|
|
FlxG.switchState(() -> new MainMenuState());
|
2023-10-24 15:50:02 -04:00
|
|
|
|
|
|
|
resetWindowTitle();
|
2023-12-14 00:47:04 -05:00
|
|
|
|
|
|
|
criticalFailure = true;
|
2023-10-11 00:30:41 -04:00
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* Handle keybinds for edit menu items.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
function handleEditKeybinds():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
// CTRL + Z = Undo
|
|
|
|
if (undoKeyHandler.activated)
|
|
|
|
{
|
|
|
|
undoLastCommand();
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// CTRL + Y = Redo
|
|
|
|
if (redoKeyHandler.activated)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
redoLastCommand();
|
|
|
|
}
|
2023-07-19 21:16:39 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// CTRL + C = Copy
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.C)
|
|
|
|
{
|
2024-01-04 08:20:34 -05:00
|
|
|
performCommand(new CopyItemsCommand(currentNoteSelection, currentEventSelection));
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// CTRL + X = Cut
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.X)
|
|
|
|
{
|
|
|
|
// Cut selected notes.
|
|
|
|
performCommand(new CutItemsCommand(currentNoteSelection, currentEventSelection));
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// CTRL + V = Paste
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.V)
|
|
|
|
{
|
|
|
|
// CTRL + SHIFT + V = Paste Unsnapped.
|
|
|
|
var targetMs:Float = if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
scrollPositionInMs + playheadPositionInMs;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var targetMs:Float = scrollPositionInMs + playheadPositionInMs;
|
2023-12-14 16:56:20 -05:00
|
|
|
var targetStep:Float = Conductor.instance.getTimeInSteps(targetMs);
|
2023-10-26 05:46:22 -04:00
|
|
|
var targetSnappedStep:Float = Math.floor(targetStep / noteSnapRatio) * noteSnapRatio;
|
2023-12-14 16:56:20 -05:00
|
|
|
var targetSnappedMs:Float = Conductor.instance.getStepTimeInMs(targetSnappedStep);
|
2023-10-26 05:46:22 -04:00
|
|
|
targetSnappedMs;
|
|
|
|
}
|
|
|
|
performCommand(new PasteItemsCommand(targetMs));
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// DELETE = Delete
|
2023-12-09 18:00:32 -05:00
|
|
|
var delete:Bool = FlxG.keys.justPressed.DELETE;
|
|
|
|
|
|
|
|
// on macbooks, Delete == backspace
|
|
|
|
#if mac
|
|
|
|
delete = delete || FlxG.keys.justPressed.BACKSPACE;
|
|
|
|
#end
|
|
|
|
|
|
|
|
if (delete)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
// 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));
|
|
|
|
}
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-11-21 02:12:34 -05:00
|
|
|
// CTRL + F = Flip Notes
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.F)
|
|
|
|
{
|
|
|
|
// Flip selected notes.
|
|
|
|
performCommand(new FlipNotesCommand(currentNoteSelection));
|
|
|
|
}
|
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
// CTRL + A = Select All Notes
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.A)
|
|
|
|
{
|
|
|
|
// Select all items.
|
2024-01-04 08:20:34 -05:00
|
|
|
if (FlxG.keys.pressed.ALT)
|
|
|
|
{
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
// CTRL + ALT + SHIFT + A = Append All Events to Selection
|
|
|
|
performCommand(new SelectItemsCommand([], currentSongChartEventData));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// CTRL + ALT + A = Set Selection to All Events
|
|
|
|
performCommand(new SelectAllItemsCommand(false, true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
// CTRL + SHIFT + A = Append All Notes to Selection
|
|
|
|
performCommand(new SelectItemsCommand(currentSongChartNoteData, []));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// CTRL + A = Set Selection to All Notes
|
|
|
|
performCommand(new SelectAllItemsCommand(true, false));
|
|
|
|
}
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CTRL + I = Select Inverse
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.I)
|
|
|
|
{
|
|
|
|
// Select unselected items and deselect selected items.
|
2024-01-04 08:20:34 -05:00
|
|
|
performCommand(new InvertSelectedItemsCommand());
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// CTRL + D = Select None
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.D)
|
|
|
|
{
|
|
|
|
// Deselect all items.
|
2024-01-04 08:20:34 -05:00
|
|
|
performCommand(new DeselectAllItemsCommand());
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Handle keybinds for View menu items.
|
|
|
|
*/
|
|
|
|
function handleViewKeybinds():Void
|
|
|
|
{
|
|
|
|
if (currentLiveInputStyle == None)
|
|
|
|
{
|
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.LEFT)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
incrementDifficulty(-1);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.RIGHT)
|
|
|
|
{
|
|
|
|
incrementDifficulty(1);
|
|
|
|
}
|
|
|
|
// Would bind Ctrl+A and Ctrl+D here, but they are already bound to Select All and Select None.
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2024-02-28 21:19:21 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
trace('Ignoring keybinds for View menu items because we are in live input mode (${currentLiveInputStyle}).');
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Handle keybinds for the Test menu items.
|
|
|
|
*/
|
|
|
|
function handleTestKeybinds():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-11-05 00:14:44 -04:00
|
|
|
if (!isHaxeUIDialogOpen && !isHaxeUIFocused && FlxG.keys.justPressed.ENTER)
|
2023-08-28 15:03:29 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
var minimal = FlxG.keys.pressed.SHIFT;
|
|
|
|
this.hideAllToolboxes();
|
|
|
|
testSongInPlayState(minimal);
|
2023-08-28 15:03:29 -04:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-02-28 21:06:09 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Handle keybinds for Help menu items.
|
|
|
|
*/
|
|
|
|
function handleHelpKeybinds():Void
|
|
|
|
{
|
|
|
|
// F1 = Open Help
|
|
|
|
if (FlxG.keys.justPressed.F1) this.openUserGuideDialog();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2024-01-03 19:53:17 -05:00
|
|
|
function handleQuickWatch():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-12-08 01:15:22 -05:00
|
|
|
FlxG.watch.addQuick('musicTime', audioInstTrack?.time ?? 0.0);
|
|
|
|
|
2024-02-16 22:01:47 -05:00
|
|
|
FlxG.watch.addQuick('noteKindToPlace', noteKindToPlace);
|
|
|
|
FlxG.watch.addQuick('eventKindToPlace', eventKindToPlace);
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
FlxG.watch.addQuick('scrollPosInPixels', scrollPositionInPixels);
|
|
|
|
FlxG.watch.addQuick('playheadPosInPixels', playheadPositionInPixels);
|
2023-02-28 21:06:09 -05:00
|
|
|
|
2024-01-02 14:07:07 -05:00
|
|
|
FlxG.watch.addQuick("tapNotesRendered", renderedNotes?.members?.length);
|
|
|
|
FlxG.watch.addQuick("holdNotesRendered", renderedHoldNotes?.members?.length);
|
|
|
|
FlxG.watch.addQuick("eventsRendered", renderedEvents?.members?.length);
|
|
|
|
FlxG.watch.addQuick("notesSelected", currentNoteSelection?.length);
|
|
|
|
FlxG.watch.addQuick("eventsSelected", currentEventSelection?.length);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-11-21 02:12:34 -05:00
|
|
|
function handlePostUpdate():Void
|
|
|
|
{
|
|
|
|
wasCursorOverHaxeUI = isCursorOverHaxeUI;
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* PLAYTEST FUNCTIONS
|
|
|
|
*/
|
|
|
|
// ====================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transitions to the Play State to test the song
|
|
|
|
*/
|
|
|
|
function testSongInPlayState(minimal:Bool = false):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
autoSave(true);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-12-08 01:15:22 -05:00
|
|
|
stopWelcomeMusic();
|
2024-01-18 00:00:57 -05:00
|
|
|
stopAudioPlayback();
|
2023-12-08 01:15:22 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
var startTimestamp:Float = 0;
|
|
|
|
if (playtestStartTime) startTimestamp = scrollPositionInMs + playheadPositionInMs;
|
|
|
|
|
2024-03-02 22:46:13 -05:00
|
|
|
var playbackRate:Float = ((menubarItemPlaybackSpeed.value ?? 1.0) * 2.0) / 100.0;
|
2024-02-29 18:49:20 -05:00
|
|
|
playbackRate = Math.floor(playbackRate / 0.05) * 0.05; // Round to nearest 5%
|
|
|
|
playbackRate = Math.max(0.05, Math.min(2.0, playbackRate)); // Clamp to 5% to 200%
|
|
|
|
|
2023-11-28 20:36:59 -05:00
|
|
|
var targetSong:Song;
|
|
|
|
try
|
|
|
|
{
|
2024-03-12 21:34:50 -04:00
|
|
|
targetSong = Song.buildRaw(currentSongId, songMetadata.values(), availableVariations, songChartData, playtestSongScripts, false);
|
2023-11-28 20:36:59 -05:00
|
|
|
}
|
|
|
|
catch (e)
|
|
|
|
{
|
2024-03-16 00:55:57 -04:00
|
|
|
this.error('Could Not Playtest', 'Got an error trying to playtest the song.\n${e}');
|
2023-11-28 20:36:59 -05:00
|
|
|
return;
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2024-03-16 00:55:57 -04:00
|
|
|
// TODO: Rework asset system so we can remove this jank.
|
2023-10-26 05:46:22 -04:00
|
|
|
switch (currentSongStage)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
case 'mainStage':
|
2024-03-16 00:55:57 -04:00
|
|
|
PlayStatePlaylist.campaignId = 'week1';
|
2023-10-26 05:46:22 -04:00
|
|
|
case 'spookyMansion':
|
2024-03-16 00:55:57 -04:00
|
|
|
PlayStatePlaylist.campaignId = 'week2';
|
2023-10-26 05:46:22 -04:00
|
|
|
case 'phillyTrain':
|
2024-03-16 00:55:57 -04:00
|
|
|
PlayStatePlaylist.campaignId = 'week3';
|
2023-10-26 05:46:22 -04:00
|
|
|
case 'limoRide':
|
2024-03-16 00:55:57 -04:00
|
|
|
PlayStatePlaylist.campaignId = 'week4';
|
2023-10-26 05:46:22 -04:00
|
|
|
case 'mallXmas' | 'mallEvil':
|
2024-03-16 00:55:57 -04:00
|
|
|
PlayStatePlaylist.campaignId = 'week5';
|
2023-10-26 05:46:22 -04:00
|
|
|
case 'school' | 'schoolEvil':
|
2024-03-16 00:55:57 -04:00
|
|
|
PlayStatePlaylist.campaignId = 'week6';
|
2023-10-26 05:46:22 -04:00
|
|
|
case 'tankmanBattlefield':
|
2024-03-16 00:55:57 -04:00
|
|
|
PlayStatePlaylist.campaignId = 'week7';
|
2024-03-12 21:34:50 -04:00
|
|
|
case 'phillyStreets' | 'phillyBlazin' | 'phillyBlazin2':
|
2024-03-16 00:55:57 -04:00
|
|
|
PlayStatePlaylist.campaignId = 'weekend1';
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2024-03-16 00:55:57 -04:00
|
|
|
Paths.setCurrentLevel(PlayStatePlaylist.campaignId);
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2024-02-01 15:52:50 -05:00
|
|
|
subStateClosed.add(reviveUICamera);
|
2023-10-26 05:46:22 -04:00
|
|
|
subStateClosed.add(resetConductorAfterTest);
|
2023-09-29 21:44:42 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
FlxTransitionableState.skipNextTransIn = false;
|
|
|
|
FlxTransitionableState.skipNextTransOut = false;
|
2023-09-29 21:44:42 -04:00
|
|
|
|
2024-03-16 00:55:57 -04:00
|
|
|
var targetStateParams =
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
targetSong: targetSong,
|
|
|
|
targetDifficulty: selectedDifficulty,
|
2024-02-05 21:35:58 -05:00
|
|
|
targetVariation: selectedVariation,
|
2023-12-10 03:37:12 -05:00
|
|
|
practiceMode: playtestPracticeMode,
|
2024-03-05 22:27:07 -05:00
|
|
|
botPlayMode: playtestBotPlayMode,
|
2023-10-26 05:46:22 -04:00
|
|
|
minimalMode: minimal,
|
|
|
|
startTimestamp: startTimestamp,
|
2024-02-29 18:49:20 -05:00
|
|
|
playbackRate: playbackRate,
|
2023-10-26 05:46:22 -04:00
|
|
|
overrideMusic: true,
|
2024-03-16 00:55:57 -04:00
|
|
|
};
|
2023-10-26 05:46:22 -04:00
|
|
|
|
|
|
|
// Override music.
|
2023-12-08 01:15:22 -05:00
|
|
|
if (audioInstTrack != null)
|
|
|
|
{
|
|
|
|
FlxG.sound.music = audioInstTrack;
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2024-02-01 15:52:50 -05:00
|
|
|
// Kill and replace the UI camera so it doesn't get destroyed during the state transition.
|
|
|
|
uiCamera.kill();
|
|
|
|
FlxG.cameras.remove(uiCamera, false);
|
2024-04-10 14:45:07 -04:00
|
|
|
FlxG.cameras.reset(new FunkinCamera('chartEditorUI2'));
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2023-11-28 20:36:59 -05:00
|
|
|
this.persistentUpdate = false;
|
|
|
|
this.persistentDraw = false;
|
2023-11-25 03:50:22 -05:00
|
|
|
stopWelcomeMusic();
|
2024-03-16 00:55:57 -04:00
|
|
|
|
|
|
|
LoadingState.loadPlayState(targetStateParams, false, true, function(targetState) {
|
|
|
|
targetState.vocals = audioVocalTrackGroup;
|
|
|
|
});
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* COMMAND FUNCTIONS
|
|
|
|
*/
|
|
|
|
// ====================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform (or redo) a command, then add it to the undo stack.
|
|
|
|
*
|
|
|
|
* @param command The command to perform.
|
2024-01-04 08:20:34 -05:00
|
|
|
* @param purgeRedoStack If `true`, the redo stack will be cleared after performing the command.
|
2023-10-26 05:46:22 -04:00
|
|
|
*/
|
|
|
|
function performCommand(command:ChartEditorCommand, purgeRedoStack:Bool = true):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
command.execute(this);
|
2024-01-04 08:20:34 -05:00
|
|
|
if (command.shouldAddToHistory(this))
|
|
|
|
{
|
|
|
|
undoHistory.push(command);
|
|
|
|
commandHistoryDirty = true;
|
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
if (purgeRedoStack) redoHistory = [];
|
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04: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);
|
2024-01-04 08:20:34 -05:00
|
|
|
// Note, if we are undoing a command, it should already be in the history,
|
|
|
|
// therefore we don't need to check `shouldAddToHistory(state)`
|
2023-10-26 05:46:22 -04:00
|
|
|
redoHistory.push(command);
|
|
|
|
commandHistoryDirty = true;
|
|
|
|
}
|
2023-09-29 21:44:42 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Undo the last command in the undo stack, then add it to the redo stack.
|
|
|
|
*/
|
|
|
|
function undoLastCommand():Void
|
|
|
|
{
|
|
|
|
var command:Null<ChartEditorCommand> = undoHistory.pop();
|
|
|
|
if (command == null)
|
2023-09-29 21:44:42 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
trace('No actions to undo.');
|
|
|
|
return;
|
2023-09-29 21:44:42 -04:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
undoCommand(command);
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Redo the last command in the redo stack, then add it to the undo stack.
|
|
|
|
*/
|
|
|
|
function redoLastCommand():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
var command:Null<ChartEditorCommand> = redoHistory.pop();
|
|
|
|
if (command == null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
trace('No actions to redo.');
|
|
|
|
return;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
performCommand(command, false);
|
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* GRAPHICS FUNCTIONS
|
|
|
|
*/
|
|
|
|
// ====================
|
2023-08-04 16:15:07 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* This is for the smaller green squares that appear over each note when you select them.
|
|
|
|
*/
|
|
|
|
function buildSelectionSquare():ChartEditorSelectionSquareSprite
|
|
|
|
{
|
|
|
|
if (selectionSquareBitmap == null)
|
|
|
|
throw "ERROR: Tried to build selection square, but selectionSquareBitmap is null! Check ChartEditorThemeHandler.updateSelectionSquare()";
|
2023-08-04 16:15:07 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
// FlxG.bitmapLog.add(selectionSquareBitmap, "selectionSquareBitmap");
|
2024-01-12 06:13:34 -05:00
|
|
|
var result = new ChartEditorSelectionSquareSprite(this);
|
2023-10-26 05:46:22 -04:00
|
|
|
result.loadGraphic(selectionSquareBitmap);
|
|
|
|
return result;
|
2023-07-26 16:52:58 -04:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
2024-02-01 15:52:50 -05:00
|
|
|
* Revive the UI camera and re-establish it as the main camera so UI elements depending on it don't explode.
|
2023-10-26 05:46:22 -04:00
|
|
|
*/
|
2024-02-01 15:52:50 -05:00
|
|
|
function reviveUICamera(_:FlxSubState = null):Void
|
2023-07-26 16:52:58 -04:00
|
|
|
{
|
2024-02-01 15:52:50 -05:00
|
|
|
uiCamera.revive();
|
|
|
|
FlxG.cameras.reset(uiCamera);
|
2023-07-26 16:52:58 -04:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
add(this.root);
|
2023-07-26 16:52:58 -04:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* AUDIO FUNCTIONS
|
|
|
|
*/
|
|
|
|
// ====================
|
|
|
|
|
|
|
|
function startAudioPlayback():Void
|
2023-07-26 21:34:38 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
if (audioInstTrack != null)
|
|
|
|
{
|
|
|
|
audioInstTrack.play(false, audioInstTrack.time);
|
2024-02-02 21:53:45 -05:00
|
|
|
audioVocalTrackGroup.play(false, audioInstTrack.time);
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
playbarPlay.text = '||'; // Pause
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Play the metronome tick sound.
|
|
|
|
* @param high Whether to play the full beat sound rather than the quarter beat sound.
|
|
|
|
*/
|
|
|
|
function playMetronomeTick(high:Bool = false):Void
|
|
|
|
{
|
2023-12-01 17:14:48 -05:00
|
|
|
this.playSound(Paths.sound('chartingSounds/metronome${high ? '1' : '2'}'), metronomeVolume);
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function switchToCurrentInstrumental():Void
|
|
|
|
{
|
|
|
|
// ChartEditorAudioHandler
|
|
|
|
this.switchToInstrumental(currentInstrumentalId, currentSongMetadata.playData.characters.player, currentSongMetadata.playData.characters.opponent);
|
2023-07-26 21:34:38 -04:00
|
|
|
}
|
|
|
|
|
2024-02-19 20:18:32 -05:00
|
|
|
public function updateGridHeight():Void
|
2023-12-08 01:15:22 -05:00
|
|
|
{
|
2024-02-19 20:18:32 -05:00
|
|
|
// Make sure playhead doesn't go outside the song after we update the grid height.
|
|
|
|
if (playheadPositionInMs > songLengthInMs) playheadPositionInMs = songLengthInMs;
|
|
|
|
|
2024-01-05 02:35:41 -05:00
|
|
|
if (gridTiledSprite != null)
|
2023-12-08 01:15:22 -05:00
|
|
|
{
|
2024-01-05 02:35:41 -05:00
|
|
|
gridTiledSprite.height = songLengthInPixels;
|
|
|
|
}
|
|
|
|
if (measureTicks != null)
|
2023-12-08 01:15:22 -05:00
|
|
|
{
|
2024-01-05 02:35:41 -05:00
|
|
|
measureTicks.setHeight(songLengthInPixels);
|
2023-12-08 01:15:22 -05:00
|
|
|
}
|
|
|
|
|
2023-12-08 16:12:36 -05:00
|
|
|
// Remove any notes past the end of the song.
|
|
|
|
var songCutoffPointSteps:Float = songLengthInSteps - 0.1;
|
2023-12-14 16:56:20 -05:00
|
|
|
var songCutoffPointMs:Float = Conductor.instance.getStepTimeInMs(songCutoffPointSteps);
|
2023-12-08 16:12:36 -05:00
|
|
|
currentSongChartNoteData = SongDataUtils.clampSongNoteData(currentSongChartNoteData, 0.0, songCutoffPointMs);
|
|
|
|
currentSongChartEventData = SongDataUtils.clampSongEventData(currentSongChartEventData, 0.0, songCutoffPointMs);
|
|
|
|
|
2023-12-08 01:15:22 -05:00
|
|
|
scrollPositionInPixels = 0;
|
|
|
|
playheadPositionInPixels = 0;
|
|
|
|
notePreviewDirty = true;
|
|
|
|
notePreviewViewportBoundsDirty = true;
|
|
|
|
noteDisplayDirty = true;
|
|
|
|
moveSongToScrollPosition();
|
|
|
|
}
|
|
|
|
|
2023-07-25 23:11:12 -04:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* CHART DATA FUNCTIONS
|
|
|
|
*/
|
|
|
|
// ====================
|
|
|
|
|
|
|
|
function sortChartData():Void
|
|
|
|
{
|
|
|
|
// TODO: .insertionSort()
|
|
|
|
currentSongChartNoteData.sort(function(a:SongNoteData, b:SongNoteData):Int {
|
|
|
|
return FlxSort.byValues(FlxSort.ASCENDING, a.time, b.time);
|
|
|
|
});
|
|
|
|
|
|
|
|
// TODO: .insertionSort()
|
|
|
|
currentSongChartEventData.sort(function(a:SongEventData, b:SongEventData):Int {
|
|
|
|
return FlxSort.byValues(FlxSort.ASCENDING, a.time, b.time);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function isEventSelected(event:Null<SongEventData>):Bool
|
|
|
|
{
|
|
|
|
return event != null && currentEventSelection.indexOf(event) != -1;
|
|
|
|
}
|
|
|
|
|
2024-01-18 01:06:15 -05:00
|
|
|
function createDifficulty(variation:String, difficulty:String, scrollSpeed:Float = 1.0):Void
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
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.
|
|
|
|
}
|
|
|
|
|
2024-01-18 01:06:15 -05:00
|
|
|
function removeDifficulty(variation:String, difficulty:String):Void
|
|
|
|
{
|
|
|
|
var variationMetadata:Null<SongMetadata> = songMetadata.get(variation);
|
|
|
|
if (variationMetadata == null) return;
|
|
|
|
|
|
|
|
variationMetadata.playData.difficulties.remove(difficulty);
|
|
|
|
|
|
|
|
var resultChartData = songChartData.get(variation);
|
|
|
|
if (resultChartData != null)
|
|
|
|
{
|
|
|
|
resultChartData.scrollSpeed.remove(difficulty);
|
|
|
|
resultChartData.notes.remove(difficulty);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (songMetadata.size() > 1)
|
|
|
|
{
|
|
|
|
if (variationMetadata.playData.difficulties.length == 0)
|
|
|
|
{
|
|
|
|
songMetadata.remove(variation);
|
|
|
|
songChartData.remove(variation);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (variation == selectedVariation)
|
|
|
|
{
|
|
|
|
var firstVariation = songMetadata.keyValues()[0];
|
|
|
|
if (firstVariation != null) selectedVariation = firstVariation;
|
|
|
|
variationMetadata = songMetadata.get(selectedVariation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectedDifficulty == difficulty
|
|
|
|
|| !variationMetadata.playData.difficulties.contains(selectedDifficulty)) selectedDifficulty = variationMetadata.playData.difficulties[0];
|
|
|
|
|
|
|
|
difficultySelectDirty = true; // Force the Difficulty toolbox to update.
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
trace('Decrement difficulty.');
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2023-12-14 16:56:20 -05:00
|
|
|
Conductor.instance.mapTimeChanges(this.currentSongMetadata.timeChanges);
|
2024-01-05 02:35:41 -05:00
|
|
|
updateTimeSignature();
|
2023-11-28 20:36:59 -05:00
|
|
|
|
2023-12-12 05:24:43 -05:00
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
|
2024-01-18 01:06:15 -05:00
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Go to previous difficulty in this variation.
|
|
|
|
var prevDifficulty = availableDifficulties[currentDifficultyIndex - 1];
|
|
|
|
selectedDifficulty = prevDifficulty;
|
|
|
|
|
2023-12-12 05:24:43 -05:00
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
|
2024-01-18 01:06:15 -05:00
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trace('Increment difficulty.');
|
|
|
|
|
|
|
|
// 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-12-12 05:24:43 -05:00
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
|
2024-01-18 01:06:15 -05:00
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Go to next difficulty in this variation.
|
|
|
|
var nextDifficulty = availableDifficulties[currentDifficultyIndex + 1];
|
|
|
|
selectedDifficulty = nextDifficulty;
|
|
|
|
|
2024-01-18 01:06:15 -05:00
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);
|
2023-12-12 05:24:43 -05:00
|
|
|
this.refreshToolbox(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-02 14:07:07 -05:00
|
|
|
// Removed this notification because you can see your difficulty in the playbar now.
|
|
|
|
// this.success('Switch Difficulty', 'Switched difficulty to ${selectedDifficulty.toTitleCase()}');
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SCROLLING FUNCTIONS
|
2023-07-25 23:11:12 -04:00
|
|
|
*/
|
2023-10-26 05:46:22 -04:00
|
|
|
// ====================
|
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 audio tracks.
|
2023-10-18 01:02:10 -04:00
|
|
|
if (audioInstTrack != null)
|
|
|
|
{
|
2023-12-14 16:56:20 -05:00
|
|
|
audioInstTrack.time = scrollPositionInMs + playheadPositionInMs - Conductor.instance.instrumentalOffset;
|
2023-10-18 01:02:10 -04:00
|
|
|
// Update the songPosition in the Conductor.
|
2023-12-14 16:56:20 -05:00
|
|
|
Conductor.instance.update(audioInstTrack.time);
|
2024-02-02 21:53:45 -05:00
|
|
|
audioVocalTrackGroup.time = audioInstTrack.time;
|
2023-10-18 01:02:10 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
// We need to update the note sprites because we changed the scroll position.
|
|
|
|
noteDisplayDirty = true;
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Smoothly ease the song to a new scroll position over a duration.
|
|
|
|
* @param targetScrollPosition The desired value for the `scrollPositionInPixels`.
|
|
|
|
*/
|
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
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Callback function executed every frame that the scroll position is being eased.
|
|
|
|
* @param _
|
|
|
|
*/
|
2023-06-08 16:53:52 -04:00
|
|
|
function onScrollEaseUpdate(_:FlxTween):Void
|
|
|
|
{
|
|
|
|
moveSongToScrollPosition();
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Callback function executed when cancelling an existing scroll position ease.
|
|
|
|
* Ensures that the ease is immediately cancelled and the scroll position is set to the target value.
|
|
|
|
*/
|
2023-06-08 16:53:52 -04:00
|
|
|
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
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* Fix the current scroll position after exiting the PlayState used when testing.
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2023-11-20 11:27:58 -05:00
|
|
|
@:nullSafety(Off)
|
2023-10-26 05:46:22 -04:00
|
|
|
function resetConductorAfterTest(_:FlxSubState = null):Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-11-28 20:36:59 -05:00
|
|
|
this.persistentUpdate = true;
|
|
|
|
this.persistentDraw = true;
|
|
|
|
|
2023-12-14 16:56:20 -05:00
|
|
|
if (displayAutosavePopup)
|
|
|
|
{
|
|
|
|
displayAutosavePopup = false;
|
2024-01-10 20:58:06 -05:00
|
|
|
#if sys
|
2023-12-14 16:56:20 -05:00
|
|
|
Toolkit.callLater(() -> {
|
|
|
|
var absoluteBackupsPath:String = Path.join([Sys.getCwd(), ChartEditorImportExportHandler.BACKUPS_PATH]);
|
|
|
|
this.infoWithActions('Auto-Save', 'Chart auto-saved to ${absoluteBackupsPath}.', [
|
|
|
|
{
|
|
|
|
text: "Take Me There",
|
|
|
|
callback: openBackupsFolder,
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
});
|
2024-01-10 20:58:06 -05:00
|
|
|
#else
|
|
|
|
// TODO: No auto-save on HTML5?
|
|
|
|
#end
|
2023-12-14 16:56:20 -05:00
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
moveSongToScrollPosition();
|
2023-11-13 18:56:07 -05:00
|
|
|
|
2024-01-12 18:29:02 -05:00
|
|
|
fadeInWelcomeMusic(WELCOME_MUSIC_FADE_IN_DELAY, WELCOME_MUSIC_FADE_IN_DURATION);
|
2023-12-08 01:15:22 -05:00
|
|
|
|
2023-11-13 18:56:07 -05:00
|
|
|
// Reapply the volume.
|
2023-11-24 00:42:07 -05:00
|
|
|
var instTargetVolume:Float = menubarItemVolumeInstrumental.value ?? 1.0;
|
2024-01-23 01:51:13 -05:00
|
|
|
var vocalPlayerTargetVolume:Float = menubarItemVolumeVocalsPlayer.value ?? 1.0;
|
|
|
|
var vocalOpponentTargetVolume:Float = menubarItemVolumeVocalsOpponent.value ?? 1.0;
|
2023-11-13 18:56:07 -05:00
|
|
|
|
2023-11-20 11:27:58 -05:00
|
|
|
if (audioInstTrack != null)
|
|
|
|
{
|
|
|
|
audioInstTrack.volume = instTargetVolume;
|
|
|
|
audioInstTrack.onComplete = null;
|
|
|
|
}
|
2024-01-17 18:24:03 -05:00
|
|
|
if (audioVocalTrackGroup != null)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
2024-01-23 01:51:13 -05:00
|
|
|
audioVocalTrackGroup.playerVolume = vocalPlayerTargetVolume;
|
|
|
|
audioVocalTrackGroup.opponentVolume = vocalOpponentTargetVolume;
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2024-01-05 02:35:41 -05:00
|
|
|
function updateTimeSignature():Void
|
|
|
|
{
|
|
|
|
// Redo the grid bitmap to be 4/4.
|
|
|
|
this.updateTheme();
|
|
|
|
gridTiledSprite.loadGraphic(gridBitmap);
|
|
|
|
measureTicks.reloadTickBitmap();
|
|
|
|
}
|
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* HAXEUI FUNCTIONS
|
2023-01-22 19:55:30 -05:00
|
|
|
*/
|
2024-01-12 06:13:34 -05:00
|
|
|
// ==================
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* STATIC FUNCTIONS
|
|
|
|
*/
|
2024-01-12 06:13:34 -05:00
|
|
|
// ==================
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
function handleNotePreview():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-11-15 01:10:26 -05:00
|
|
|
if (notePreviewDirty && notePreview != null)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-11-15 01:10:26 -05:00
|
|
|
notePreviewDirty = false;
|
2023-09-29 21:44:42 -04:00
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
// TODO: Only update the notes that have changed.
|
|
|
|
notePreview.erase();
|
|
|
|
notePreview.addNotes(currentSongChartNoteData, Std.int(songLengthInMs));
|
2023-12-13 23:11:19 -05:00
|
|
|
notePreview.addSelectedNotes(currentNoteSelection, Std.int(songLengthInMs));
|
2023-11-15 01:10:26 -05:00
|
|
|
notePreview.addEvents(currentSongChartEventData, Std.int(songLengthInMs));
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
if (notePreviewViewportBoundsDirty)
|
2023-09-29 21:44:42 -04:00
|
|
|
{
|
2023-11-15 01:10:26 -05:00
|
|
|
setNotePreviewViewportBounds(calculateNotePreviewViewportBounds());
|
2024-01-05 02:35:41 -05:00
|
|
|
notePreviewViewportBoundsDirty = false;
|
2023-09-29 21:44:42 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-11-15 01:10:26 -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.
|
|
|
|
*/
|
|
|
|
function handleMenubar():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-11-15 01:10:26 -05:00
|
|
|
if (commandHistoryDirty)
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
2023-11-15 01:10:26 -05:00
|
|
|
commandHistoryDirty = false;
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
// Update the Undo and Redo buttons.
|
2023-11-24 00:42:07 -05:00
|
|
|
if (undoHistory.length == 0)
|
2023-09-08 17:27:14 -04:00
|
|
|
{
|
2023-11-24 00:42:07 -05:00
|
|
|
// Disable the Undo button.
|
|
|
|
menubarItemUndo.disabled = true;
|
|
|
|
menubarItemUndo.text = 'Undo';
|
2023-09-08 17:27:14 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-24 00:42:07 -05:00
|
|
|
// Change the label to the last command.
|
|
|
|
menubarItemUndo.disabled = false;
|
|
|
|
menubarItemUndo.text = 'Undo ${undoHistory[undoHistory.length - 1].toString()}';
|
2023-09-08 17:27:14 -04:00
|
|
|
}
|
2023-07-26 20:03:31 -04:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
if (redoHistory.length == 0)
|
2023-11-15 01:10:26 -05:00
|
|
|
{
|
2023-11-24 00:42:07 -05:00
|
|
|
// Disable the Redo button.
|
|
|
|
menubarItemRedo.disabled = true;
|
|
|
|
menubarItemRedo.text = 'Redo';
|
2023-11-15 01:10:26 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-24 00:42:07 -05:00
|
|
|
// Change the label to the last command.
|
|
|
|
menubarItemRedo.disabled = false;
|
|
|
|
menubarItemRedo.text = 'Redo ${redoHistory[redoHistory.length - 1].toString()}';
|
2023-11-15 01:10:26 -05:00
|
|
|
}
|
2023-08-02 10:15:54 -04:00
|
|
|
}
|
2023-11-15 01:10:26 -05:00
|
|
|
}
|
2023-08-02 10:15:54 -04:00
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
/**
|
|
|
|
* Handle the playback of hitsounds.
|
|
|
|
*/
|
|
|
|
function handleHitsounds(oldSongPosition:Float, newSongPosition:Float):Void
|
|
|
|
{
|
|
|
|
if (!hitsoundsEnabled) return;
|
2023-07-26 16:52:58 -04:00
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
// Assume notes are sorted by time.
|
|
|
|
for (noteData in currentSongChartNoteData)
|
|
|
|
{
|
|
|
|
// Check for notes between the old and new song positions.
|
2023-08-02 18:08:49 -04:00
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
if (noteData.time < oldSongPosition) // Note is in the past.
|
|
|
|
continue;
|
2023-08-04 16:15:07 -04:00
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
if (noteData.time > newSongPosition) // Note is in the future.
|
|
|
|
return; // Assume all notes are also in the future.
|
2023-08-04 16:15:07 -04:00
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
// Note was just hit.
|
|
|
|
|
|
|
|
// Character preview.
|
|
|
|
|
|
|
|
// NoteScriptEvent takes a sprite, ehe. Need to rework that.
|
|
|
|
var tempNote:NoteSprite = new NoteSprite(NoteStyleRegistry.instance.fetchDefault());
|
|
|
|
tempNote.noteData = noteData;
|
|
|
|
tempNote.scrollFactor.set(0, 0);
|
2024-05-08 08:26:17 -04:00
|
|
|
var event:NoteScriptEvent = new HitNoteScriptEvent(tempNote, 0.0, 0, 'perfect', false, 0);
|
2023-11-15 01:10:26 -05:00
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
|
|
|
if (event.eventCanceled) continue;
|
|
|
|
|
|
|
|
// Hitsounds.
|
|
|
|
switch (noteData.getStrumlineIndex())
|
|
|
|
{
|
|
|
|
case 0: // Player
|
2024-02-19 20:18:32 -05:00
|
|
|
if (hitsoundVolumePlayer > 0) this.playSound(Paths.sound('chartingSounds/hitNotePlayer'), hitsoundVolumePlayer);
|
2023-11-15 01:10:26 -05:00
|
|
|
case 1: // Opponent
|
2024-02-19 20:18:32 -05:00
|
|
|
if (hitsoundVolumeOpponent > 0) this.playSound(Paths.sound('chartingSounds/hitNoteOpponent'), hitsoundVolumeOpponent);
|
2023-11-15 01:10:26 -05:00
|
|
|
}
|
|
|
|
}
|
2023-07-26 16:52:58 -04:00
|
|
|
}
|
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
function stopAudioPlayback():Void
|
2023-07-26 16:52:58 -04:00
|
|
|
{
|
2023-11-15 01:10:26 -05:00
|
|
|
if (audioInstTrack != null) audioInstTrack.pause();
|
2024-02-02 21:53:45 -05:00
|
|
|
audioVocalTrackGroup.pause();
|
2023-07-26 16:52:58 -04:00
|
|
|
|
2023-11-24 00:42:07 -05:00
|
|
|
playbarPlay.text = '>';
|
2023-07-26 16:52:58 -04:00
|
|
|
}
|
|
|
|
|
2023-11-15 01:10:26 -05:00
|
|
|
function toggleAudioPlayback():Void
|
2023-07-26 21:34:38 -04:00
|
|
|
{
|
2023-11-15 01:10:26 -05:00
|
|
|
if (audioInstTrack == null) return;
|
|
|
|
|
2023-12-08 01:15:22 -05:00
|
|
|
if (audioInstTrack.isPlaying)
|
2023-11-15 01:10:26 -05:00
|
|
|
{
|
2023-12-08 01:15:22 -05:00
|
|
|
// Pause
|
2023-11-15 01:10:26 -05:00
|
|
|
stopAudioPlayback();
|
2024-01-12 18:29:02 -05:00
|
|
|
fadeInWelcomeMusic(WELCOME_MUSIC_FADE_IN_DELAY, WELCOME_MUSIC_FADE_IN_DURATION);
|
2023-11-15 01:10:26 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-12-08 01:15:22 -05:00
|
|
|
// Play
|
2023-11-15 01:10:26 -05:00
|
|
|
startAudioPlayback();
|
2023-12-08 01:15:22 -05:00
|
|
|
stopWelcomeMusic();
|
2023-11-15 01:10:26 -05:00
|
|
|
}
|
2023-07-26 21:34:38 -04:00
|
|
|
}
|
|
|
|
|
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() {
|
2023-12-08 16:12:36 -05:00
|
|
|
if (audioInstTrack != null)
|
|
|
|
{
|
|
|
|
audioInstTrack.pause();
|
|
|
|
// Keep the track at the end.
|
|
|
|
audioInstTrack.time = audioInstTrack.length;
|
|
|
|
}
|
2024-02-02 21:53:45 -05:00
|
|
|
audioVocalTrackGroup.pause();
|
2023-08-28 15:03:29 -04:00
|
|
|
};
|
|
|
|
}
|
2023-09-26 17:46:07 -04:00
|
|
|
else
|
|
|
|
{
|
2023-12-08 01:15:22 -05:00
|
|
|
trace('ERROR: Instrumental track is null!');
|
2023-09-26 17:46:07 -04:00
|
|
|
}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
2023-12-14 16:56:20 -05:00
|
|
|
this.songLengthInMs = (audioInstTrack?.length ?? 1000.0) + Conductor.instance.instrumentalOffset;
|
2023-12-08 01:15:22 -05:00
|
|
|
|
|
|
|
// Many things get reset when song length changes.
|
2023-09-26 17:46:07 -04:00
|
|
|
healthIconsDirty = true;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2024-02-02 21:53:45 -05:00
|
|
|
function hardRefreshOffsetsToolbox():Void
|
|
|
|
{
|
|
|
|
var offsetsToolbox:ChartEditorOffsetsToolbox = cast this.getToolbox(CHART_EDITOR_TOOLBOX_OFFSETS_LAYOUT);
|
|
|
|
if (offsetsToolbox != null)
|
|
|
|
{
|
|
|
|
offsetsToolbox.refreshAudioPreview();
|
|
|
|
offsetsToolbox.refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-09 14:58:57 -05:00
|
|
|
function hardRefreshFreeplayToolbox():Void
|
|
|
|
{
|
|
|
|
var freeplayToolbox:ChartEditorFreeplayToolbox = cast this.getToolbox(CHART_EDITOR_TOOLBOX_FREEPLAY_LAYOUT);
|
|
|
|
if (freeplayToolbox != null)
|
|
|
|
{
|
|
|
|
freeplayToolbox.refreshAudioPreview();
|
|
|
|
freeplayToolbox.refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-25 23:11:12 -04:00
|
|
|
/**
|
|
|
|
* Clear the voices group.
|
|
|
|
*/
|
|
|
|
public function clearVocals():Void
|
|
|
|
{
|
2024-02-02 21:53:45 -05:00
|
|
|
audioVocalTrackGroup.clear();
|
2023-07-25 23:11:12 -04: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-02-28 21:06:09 -05:00
|
|
|
override function destroy():Void
|
2023-01-22 19:55:30 -05:00
|
|
|
{
|
|
|
|
super.destroy();
|
|
|
|
|
|
|
|
cleanupAutoSave();
|
|
|
|
|
2024-01-03 19:53:17 -05:00
|
|
|
this.closeAllMenus();
|
|
|
|
|
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;
|
2024-01-04 08:20:34 -05:00
|
|
|
|
|
|
|
// Stop the music.
|
2024-01-12 21:52:28 -05:00
|
|
|
if (welcomeMusic != null) welcomeMusic.destroy();
|
|
|
|
if (audioInstTrack != null) audioInstTrack.destroy();
|
|
|
|
if (audioVocalTrackGroup != null) audioVocalTrackGroup.destroy();
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
|
|
|
|
2023-10-23 12:22:29 -04:00
|
|
|
function applyCanQuickSave():Void
|
|
|
|
{
|
2023-10-24 15:50:02 -04:00
|
|
|
if (menubarItemSaveChart == null) return;
|
|
|
|
|
|
|
|
if (currentWorkingFilePath == null)
|
|
|
|
{
|
|
|
|
menubarItemSaveChart.disabled = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menubarItemSaveChart.disabled = false;
|
|
|
|
}
|
2023-10-23 12:22:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function applyWindowTitle():Void
|
|
|
|
{
|
2023-10-24 15:50:02 -04:00
|
|
|
var inner:String = 'New Chart';
|
|
|
|
var cwfp:Null<String> = currentWorkingFilePath;
|
|
|
|
if (cwfp != null)
|
2023-10-23 12:22:29 -04:00
|
|
|
{
|
2023-10-24 15:50:02 -04:00
|
|
|
inner = cwfp;
|
2023-10-23 12:22:29 -04:00
|
|
|
}
|
2023-10-24 15:50:02 -04:00
|
|
|
if (currentWorkingFilePath == null || saveDataDirty)
|
2023-10-23 12:22:29 -04:00
|
|
|
{
|
2023-10-24 15:50:02 -04:00
|
|
|
inner += '*';
|
2023-10-23 12:22:29 -04:00
|
|
|
}
|
2023-10-24 15:50:02 -04:00
|
|
|
WindowUtil.setWindowTitle('Friday Night Funkin\' Chart Editor - ${inner}');
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetWindowTitle():Void
|
|
|
|
{
|
|
|
|
WindowUtil.setWindowTitle('Friday Night Funkin\'');
|
2023-10-23 12:22:29 -04:00
|
|
|
}
|
2023-11-15 01:10:26 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Convert a note data value into a chart editor grid column number.
|
|
|
|
*/
|
|
|
|
public static function noteDataToGridColumn(input:Int):Int
|
|
|
|
{
|
|
|
|
if (input < 0) input = 0;
|
|
|
|
if (input >= (ChartEditorState.STRUMLINE_SIZE * 2 + 1))
|
|
|
|
{
|
|
|
|
// Don't invert the Event column.
|
|
|
|
input = (ChartEditorState.STRUMLINE_SIZE * 2 + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Invert player and opponent columns.
|
|
|
|
if (input >= ChartEditorState.STRUMLINE_SIZE)
|
|
|
|
{
|
|
|
|
input -= ChartEditorState.STRUMLINE_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
input += ChartEditorState.STRUMLINE_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a chart editor grid column number into a note data value.
|
|
|
|
*/
|
|
|
|
public static function gridColumnToNoteData(input:Int):Int
|
|
|
|
{
|
|
|
|
if (input < 0) input = 0;
|
|
|
|
if (input >= (ChartEditorState.STRUMLINE_SIZE * 2 + 1))
|
|
|
|
{
|
|
|
|
// Don't invert the Event column.
|
|
|
|
input = (ChartEditorState.STRUMLINE_SIZE * 2 + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Invert player and opponent columns.
|
|
|
|
if (input >= ChartEditorState.STRUMLINE_SIZE)
|
|
|
|
{
|
|
|
|
input -= ChartEditorState.STRUMLINE_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
input += ChartEditorState.STRUMLINE_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return input;
|
|
|
|
}
|
2022-09-07 19:07:08 -04:00
|
|
|
}
|
2023-06-08 16:53:52 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
2024-02-28 21:19:21 -05:00
|
|
|
* Available input modes for the chart editor state. Numbers/arrows/WASD available for other keybinds.
|
2023-10-26 05:46:22 -04:00
|
|
|
*/
|
|
|
|
enum ChartEditorLiveInputStyle
|
2023-06-08 16:53:52 -04:00
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* No hotkeys to place notes at the playbar.
|
|
|
|
*/
|
2023-06-08 16:53:52 -04:00
|
|
|
None;
|
2023-10-26 05:46:22 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 1/2/3/4 to place notes on opponent's side, 5/6/7/8 to place notes on player's side.
|
|
|
|
*/
|
2023-06-08 16:53:52 -04:00
|
|
|
NumberKeys;
|
2023-10-26 05:46:22 -04:00
|
|
|
|
|
|
|
/**
|
2024-02-28 21:19:21 -05:00
|
|
|
* WASD to place notes on opponent's side, Arrow keys to place notes on player's side.
|
2023-10-26 05:46:22 -04:00
|
|
|
*/
|
2024-02-28 21:19:21 -05:00
|
|
|
WASDKeys;
|
2023-06-08 16:53:52 -04:00
|
|
|
}
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2023-10-21 01:04:50 -04:00
|
|
|
typedef ChartEditorParams =
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* If non-null, load this song immediately instead of the welcome screen.
|
|
|
|
*/
|
|
|
|
var ?fnfcTargetPath:String;
|
2023-11-16 00:02:42 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If non-null, load this song immediately instead of the welcome screen.
|
|
|
|
*/
|
|
|
|
var ?targetSongId:String;
|
2023-10-21 01:04:50 -04:00
|
|
|
};
|
2023-11-04 23:51:15 -04:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Available themes for the chart editor state.
|
|
|
|
*/
|
|
|
|
enum ChartEditorTheme
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The default theme for the chart editor.
|
|
|
|
*/
|
|
|
|
Light;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A theme which introduces darker colors.
|
|
|
|
*/
|
|
|
|
Dark;
|
|
|
|
}
|