-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathChartEditorState.hx
6547 lines (5587 loc) · 213 KB
/
ChartEditorState.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package funkin.ui.debug.charting;
import flixel.addons.display.FlxSliceSprite;
import flixel.addons.display.FlxTiledSprite;
import flixel.addons.transition.FlxTransitionableState;
import flixel.FlxCamera;
import flixel.FlxSprite;
import flixel.FlxSubState;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.group.FlxSpriteGroup;
import flixel.input.gamepad.FlxGamepadInputID;
import flixel.input.keyboard.FlxKey;
import flixel.input.mouse.FlxMouseEvent;
import flixel.math.FlxMath;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.sound.FlxSound;
import flixel.system.debug.log.LogStyle;
import flixel.system.FlxAssets.FlxSoundAsset;
import flixel.text.FlxText;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.tweens.misc.VarTween;
import flixel.util.FlxColor;
import flixel.util.FlxSort;
import flixel.util.FlxTimer;
import funkin.audio.FunkinSound;
import funkin.audio.visualize.PolygonSpectogram;
import funkin.audio.VoicesGroup;
import funkin.audio.waveform.WaveformSprite;
import funkin.data.notestyle.NoteStyleRegistry;
import funkin.data.song.SongData.SongCharacterData;
import funkin.data.song.SongData.SongChartData;
import funkin.data.song.SongData.SongEventData;
import funkin.data.song.SongData.SongMetadata;
import funkin.data.song.SongData.SongNoteData;
import funkin.data.song.SongData.SongOffsets;
import funkin.data.song.SongData.NoteParamData;
import funkin.data.song.SongDataUtils;
import funkin.data.song.SongRegistry;
import funkin.data.stage.StageData;
import funkin.graphics.FunkinCamera;
import funkin.graphics.FunkinSprite;
import funkin.input.Cursor;
import funkin.input.TurboActionHandler;
import funkin.input.TurboButtonHandler;
import funkin.input.TurboKeyHandler;
import funkin.modding.events.ScriptEvent;
import funkin.play.notes.notekind.NoteKindManager;
import funkin.play.character.BaseCharacter.CharacterType;
import funkin.play.character.CharacterData;
import funkin.play.character.CharacterData.CharacterDataParser;
import funkin.play.components.HealthIcon;
import funkin.play.notes.NoteSprite;
import funkin.play.PlayState;
import funkin.play.PlayStatePlaylist;
import funkin.play.song.Song;
import funkin.save.Save;
import funkin.ui.debug.charting.commands.AddEventsCommand;
import funkin.ui.debug.charting.commands.AddNotesCommand;
import funkin.ui.debug.charting.commands.ChartEditorCommand;
import funkin.ui.debug.charting.commands.CopyItemsCommand;
import funkin.ui.debug.charting.commands.CutItemsCommand;
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;
import funkin.ui.debug.charting.components.ChartEditorMeasureTicks;
import funkin.ui.debug.charting.components.ChartEditorNotePreview;
import funkin.ui.debug.charting.components.ChartEditorNoteSprite;
import funkin.ui.debug.charting.components.ChartEditorPlaybarHead;
import funkin.ui.debug.charting.components.ChartEditorSelectionSquareSprite;
import funkin.ui.debug.charting.handlers.ChartEditorShortcutHandler;
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;
import funkin.ui.haxeui.components.CharacterPlayer;
import funkin.ui.haxeui.HaxeUIState;
import funkin.ui.mainmenu.MainMenuState;
import funkin.ui.transition.LoadingState;
import funkin.util.Constants;
import funkin.util.FileUtil;
import funkin.util.MathUtil;
import funkin.util.logging.CrashHandler;
import funkin.util.SortUtil;
import funkin.util.WindowUtil;
import haxe.DynamicAccess;
import haxe.io.Bytes;
import haxe.io.Path;
import haxe.ui.backend.flixel.UIRuntimeState;
import haxe.ui.backend.flixel.UIState;
import haxe.ui.components.Button;
import haxe.ui.components.DropDown;
import haxe.ui.components.Image;
import haxe.ui.components.Label;
import haxe.ui.components.NumberStepper;
import haxe.ui.components.Slider;
import haxe.ui.components.TextField;
import haxe.ui.containers.Box;
import haxe.ui.containers.dialogs.CollapsibleDialog;
import haxe.ui.containers.Frame;
import haxe.ui.containers.Grid;
import haxe.ui.containers.HBox;
import haxe.ui.containers.menus.Menu;
import haxe.ui.containers.menus.MenuBar;
import haxe.ui.containers.menus.MenuCheckBox;
import haxe.ui.containers.menus.MenuItem;
import haxe.ui.containers.ScrollView;
import haxe.ui.containers.TreeView;
import haxe.ui.containers.TreeViewNode;
import haxe.ui.core.Component;
import haxe.ui.core.Screen;
import haxe.ui.events.DragEvent;
import haxe.ui.events.MouseEvent;
import haxe.ui.events.UIEvent;
import haxe.ui.focus.FocusManager;
import haxe.ui.Toolkit;
import openfl.display.BitmapData;
using Lambda;
/**
* A state dedicated to allowing the user to create and edit song charts.
* Built with HaxeUI for use by both developers and modders.
*
* Some functionality is split into handler classes to help maintain my sanity.
*
* @author EliteMasterEric
*/
// @:nullSafety
@:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/chart-editor/main-view.xml"))
class ChartEditorState extends UIState // UIState derives from MusicBeatState
{
/**
* CONSTANTS
*/
// ==============================
// Layouts
public static final CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT:String = Paths.ui('chart-editor/toolbox/difficulty');
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');
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');
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');
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');
// Validation
public static final SUPPORTED_MUSIC_FORMATS:Array<String> = #if sys ['ogg'] #else ['mp3'] #end;
// Layout
/**
* The base grid size for the chart editor.
*/
public static final GRID_SIZE:Int = 40;
/**
* The width of the scroll area.
*/
public static final PLAYHEAD_SCROLL_AREA_WIDTH:Int = Std.int(GRID_SIZE);
/**
* The height of the playhead, in pixels.
*/
public static final PLAYHEAD_HEIGHT:Int = Std.int(GRID_SIZE / 8);
/**
* The width of the border between grid squares, where the crosshair changes from "Place Notes" to "Select Notes".
*/
public static final GRID_SELECTION_BORDER_WIDTH:Int = 6;
/**
* The height of the menu bar in the layout.
*/
public static final MENU_BAR_HEIGHT:Int = 32;
/**
* The height of the playbar in the layout.
*/
public static final PLAYBAR_HEIGHT:Int = 48;
/**
* The height of the note selection buttons above the grid.
*/
public static final NOTE_SELECT_BUTTON_HEIGHT:Int = 24;
/**
* The amount of padding between the menu bar and the chart grid when fully scrolled up.
*/
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.
*/
public static final NOTE_PREVIEW_X_POS:Int = 320;
/**
* 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;
}
// 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
/**
* Duration, in seconds, for the scroll easing animation.
*/
public static final SCROLL_EASE_DURATION:Float = 0.4;
// Other
/**
* Number of notes in each player's strumline.
*/
public static final STRUMLINE_SIZE:Int = 4;
/**
* How many pixels far the user needs to move the mouse before the cursor is considered to be dragged rather than clicked.
*/
public static final DRAG_THRESHOLD:Float = 16.0;
/**
* Precisions of notes you can snap to.
*/
public static final SNAP_QUANTS:Array<Int> = [4, 8, 12, 16, 20, 24, 32, 48, 64, 96, 192];
/**
* The default note snapping value.
*/
public static final BASE_QUANT:Int = 16;
/**
* The index of thet default note snapping value in the `SNAP_QUANTS` array.
*/
public static final BASE_QUANT_INDEX:Int = 3;
/**
* 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;
/**
* A map of the keys for every live input style.
*/
public static final LIVE_INPUT_KEYS:Map<ChartEditorLiveInputStyle, Array<FlxKey>> = [
NumberKeys => [
FIVE, SIX, SEVEN, EIGHT,
ONE, TWO, THREE, FOUR
],
WASDKeys => [
LEFT, DOWN, UP, RIGHT,
A, S, W, D
],
None => []
];
/**
* INSTANCE DATA
*/
// ==============================
// Song Length
/**
* The length of the current instrumental, in milliseconds.
*/
@: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;
updateGridHeight();
return this.songLengthInMs;
}
/**
* 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.
*/
var songLengthInSteps(get, set):Float;
function get_songLengthInSteps():Float
{
return Conductor.instance.getTimeInSteps(songLengthInMs);
}
function set_songLengthInSteps(value:Float):Float
{
// Getting a reasonable result from setting songLengthInSteps requires that Conductor.instance.mapBPMChanges be called first.
songLengthInMs = Conductor.instance.getStepTimeInMs(value);
return value;
}
/**
* 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.
*/
var songLengthInPixels(get, set):Int;
function get_songLengthInPixels():Int
{
return Std.int(songLengthInSteps * GRID_SIZE);
}
function set_songLengthInPixels(value:Int):Int
{
songLengthInSteps = value / GRID_SIZE;
return value;
}
// Scroll Position
/**
* The relative scroll position in the song, in pixels.
* One pixel is 1/40 of 1 step, and 1/160 of 1 beat.
*/
var scrollPositionInPixels(default, set):Float = -1.0;
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.
if (gridTiledSprite != null && measureTicks != null)
{
if (isViewDownscroll)
{
gridTiledSprite.y = -scrollPositionInPixels + (GRID_INITIAL_Y_POS);
measureTicks.y = gridTiledSprite.y;
}
else
{
gridTiledSprite.y = -scrollPositionInPixels + (GRID_INITIAL_Y_POS);
measureTicks.y = gridTiledSprite.y;
for (member in audioWaveforms.members)
{
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);
}
}
}
// 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;
// Update the note preview.
setNotePreviewViewportBounds(calculateNotePreviewViewportBounds());
refreshNotePreviewPlayheadPosition();
// Update the measure tick display.
if (measureTicks != null) measureTicks.y = gridTiledSprite?.y ?? 0.0;
return this.scrollPositionInPixels;
}
/**
* The relative scroll position in the song, converted to steps.
* NOT dependant on BPM, because the size of a grid square does not change with BPM.
*/
var scrollPositionInSteps(get, set):Float;
function get_scrollPositionInSteps():Float
{
return scrollPositionInPixels / GRID_SIZE;
}
function set_scrollPositionInSteps(value:Float):Float
{
scrollPositionInPixels = value * GRID_SIZE;
return value;
}
/**
* The relative scroll position in the song, converted to milliseconds.
* DEPENDANT on BPM, because the duration of a grid square changes with BPM.
*/
var scrollPositionInMs(get, set):Float;
function get_scrollPositionInMs():Float
{
return Conductor.instance.getStepTimeInMs(scrollPositionInSteps);
}
function set_scrollPositionInMs(value:Float):Float
{
scrollPositionInSteps = Conductor.instance.getTimeInSteps(value);
return value;
}
// Playhead (on the grid)
/**
* 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.
*/
var playheadPositionInPixels(default, set):Float = 0.0;
function set_playheadPositionInPixels(value:Float):Float
{
// Make sure playhead doesn't go outside the song.
if (value + scrollPositionInPixels < 0) value = -scrollPositionInPixels;
if (value + scrollPositionInPixels > songLengthInPixels) value = songLengthInPixels - scrollPositionInPixels;
this.playheadPositionInPixels = value;
// Move the playhead sprite to the correct position.
gridPlayhead.y = this.playheadPositionInPixels + GRID_INITIAL_Y_POS;
updatePlayheadGhostHoldNotes();
refreshNotePreviewPlayheadPosition();
return this.playheadPositionInPixels;
}
/**
* playheadPosition, converted to steps.
* NOT dependant on BPM, because the size of a grid square does not change with BPM.
*/
var playheadPositionInSteps(get, set):Float;
function get_playheadPositionInSteps():Float
{
return playheadPositionInPixels / GRID_SIZE;
}
function set_playheadPositionInSteps(value:Float):Float
{
playheadPositionInPixels = value * GRID_SIZE;
return value;
}
/**
* playheadPosition, converted to milliseconds.
* DEPENDANT on BPM, because the duration of a grid square changes with BPM.
*/
var playheadPositionInMs(get, set):Float;
function get_playheadPositionInMs():Float
{
return Conductor.instance.getStepTimeInMs(playheadPositionInSteps);
}
function set_playheadPositionInMs(value:Float):Float
{
playheadPositionInSteps = Conductor.instance.getTimeInSteps(value);
return value;
}
// Playbar (at the bottom)
/**
* Whether a skip button has been pressed on the playbar, and which one.
* `null` if no button has been pressed.
* This will be used to update the scrollPosition (in the same function that handles the scroll wheel), then cleared.
*/
var playbarButtonPressed:Null<String> = null;
/**
* 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;
// Tools Status
/**
* The note kind to use for notes being placed in the chart. Defaults to `null`.
*/
var noteKindToPlace:Null<String> = null;
/**
* The note params to use for notes being placed in the chart. Defaults to `[]`.
*/
var noteParamsToPlace:Array<NoteParamData> = [];
/**
* The event type to use for events being placed in the chart. Defaults to `''`.
*/
var eventKindToPlace:String = 'FocusCamera';
/**
* The event data to use for events being placed in the chart.
*/
var eventDataToPlace:DynamicAccess<Dynamic> = {};
/**
* The internal index of what note snapping value is in use.
* Increment to make placement more preceise and decrement to make placement less precise.
*/
var noteSnapQuantIndex:Int = BASE_QUANT_INDEX;
/**
* The current note snapping value.
* For example, `32` when snapping to 32nd notes.
*/
var noteSnapQuant(get, never):Int;
function get_noteSnapQuant():Int
{
return SNAP_QUANTS[noteSnapQuantIndex];
}
/**
* The ratio of the current note snapping value to the default.
* For example, `32` becomes `0.5` when snapping to 16th notes.
*/
var noteSnapRatio(get, never):Float;
function get_noteSnapRatio():Float
{
return BASE_QUANT / noteSnapQuant;
}
/**
* The currently selected live input style.
*/
var currentLiveInputStyle:ChartEditorLiveInputStyle = None;
/**
* If true, playtesting a chart will skip to the current playhead position.
*/
var playtestStartTime:Bool = false;
/**
* If true, playtesting a chart will let you "gameover" / die when you lose ur health!
*/
var playtestPracticeMode:Bool = false;
/**
* If true, playtesting a chart will make the computer do it for you!
*/
var playtestBotPlayMode:Bool = false;
/**
* Enables or disables the "debugger" popup that appears when you run into a flixel error.
*/
var enabledDebuggerPopup:Bool = true;
/**
* Whether song scripts should be enabled during playtesting.
* You should probably check the box if the song has custom mechanics.
*/
var playtestSongScripts:Bool = true;
// Visuals
/**
* 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;
notePreviewViewportBoundsDirty = true;
this.scrollPositionInPixels = this.scrollPositionInPixels;
// Characters have probably changed too.
healthIconsDirty = true;
return isViewDownscroll;
}
/**
* The current theme used by the editor.
* Dictates the appearance of many UI elements.
* Currently hardcoded to just Light and Dark.
*/
var currentTheme(default, set):ChartEditorTheme = ChartEditorTheme.Light;
function set_currentTheme(value:ChartEditorTheme):ChartEditorTheme
{
if (value == null || value == currentTheme) return currentTheme;
currentTheme = value;
this.updateTheme();
return value;
}
/**
* The character sprite in the Player Preview window.
* `null` until accessed.
*/
var currentPlayerCharacterPlayer:Null<CharacterPlayer> = null;
/**
* The character sprite in the Opponent Preview window.
* `null` until accessed.
*/
var currentOpponentCharacterPlayer:Null<CharacterPlayer> = null;
// HaxeUI
/**
* 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.
*/
var isHaxeUIFocused(get, never):Bool;
function get_isHaxeUIFocused():Bool
{
return FocusManager.instance.focus != null;
}
/**
* 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.viewX, FlxG.mouse.viewY);
}
/**
* 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;
/**
* Set by ChartEditorDialogHandler, used to prevent background interaction while the dialog is open.
*/
var isHaxeUIDialogOpen:Bool = false;
/**
* The Dialog components representing the currently available tool windows.
* Dialogs are retained here even when collapsed or hidden.
*/
var activeToolboxes:Map<String, CollapsibleDialog> = new Map<String, CollapsibleDialog>();
/**
* The camera component we're using for this state.
*/
var uiCamera:FlxCamera;
// Audio
/**
* Whether to play a metronome sound while the playhead is moving, and what volume.
*/
var metronomeVolume:Float = 1.0;
/**
* The volume to play the player's hitsounds at.
*/
var hitsoundVolumePlayer:Float = 1.0;
/**
* The volume to play the opponent's hitsounds at.
*/
var hitsoundVolumeOpponent:Float = 1.0;
/**
* Whether hitsounds are enabled for at least one character.
*/
var hitsoundsEnabled(get, never):Bool;
function get_hitsoundsEnabled():Bool
{
return hitsoundVolumePlayer + hitsoundVolumeOpponent > 0;
}
// Auto-save
/**
* A timer used to auto-save the chart after a period of inactivity.
*/
var autoSaveTimer:Null<FlxTimer> = null;
// Scrolling
/**
* Whether the user's last mouse click was on the playhead scroll area.
*/
var gridPlayheadScrollAreaPressed:Bool = false;
/**
* 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;
/**
* The current process that is lerping the scroll position.
*/
var currentScrollEase:Null<Float>;
/**
* 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;
// Note Placement
/**
* 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.
*/
var currentPlaceNoteData(default, set):Null<SongNoteData> = null;
function set_currentPlaceNoteData(value:Null<SongNoteData>):Null<SongNoteData>
{
noteDisplayDirty = true;
return currentPlaceNoteData = value;
}
/**
* 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> = [];
// Note Movement
/**
* The note sprite we are currently moving, if any.
*/
var dragTargetNote:Null<ChartEditorNoteSprite> = null;
/**
* The song event sprite we are currently moving, if any.
*/
var dragTargetEvent:Null<ChartEditorEventSprite> = null;
/**
* The amount of vertical steps the note sprite has moved by since the user started dragging.
*/
var dragTargetCurrentStep:Float = 0;
/**
* The amount of horizontal columns the note sprite has moved by since the user started dragging.
*/
var dragTargetCurrentColumn:Int = 0;
// Hold Note Dragging
/**
* The current length of the hold note we are dragging, in steps.
* Play a sound when this value changes.
*/
var dragLengthCurrent:Float = 0;
/**
* 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> = [];
/**
* Flip-flop to alternate between two stretching sounds.
*/
var stretchySounds:Bool = false;
// Selection
/**
* The notes which are currently in the user's selection.
*/
var currentNoteSelection(default, set):Array<SongNoteData> = [];
function set_currentNoteSelection(value:Array<SongNoteData>):Array<SongNoteData>
{
// 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);
currentNoteSelection = value;
if (!isEqual)
{
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;
}
}
return currentNoteSelection;
}
/**
* 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;
// 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> = [];
// Dirty Flags
/**
* 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;
var noteTooltipsDirty:Bool = true;
/**
* Whether the selected charactesr have been modified and the health icons need to be updated.
*/
var healthIconsDirty:Bool = true;
/**
* Whether the note preview graphic needs to be FULLY rebuilt.
*/
var notePreviewDirty(default, set):Bool = true;
function set_notePreviewDirty(value:Bool):Bool
{
// trace('Note preview dirtied!');
return notePreviewDirty = value;
}
var notePreviewViewportBoundsDirty:Bool = true;
/**
* 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
{
if (value == saveDataDirty) return value;
if (value)
{
// Start the auto-save timer.
autoSaveTimer = new FlxTimer().start(Constants.AUTOSAVE_TIMER_DELAY_SEC, (_) -> autoSave());
}
else
{
if (autoSaveTimer != null)
{
// Stop the auto-save timer.
autoSaveTimer.cancel();
autoSaveTimer.destroy();
autoSaveTimer = null;
}
}
saveDataDirty = value;
applyWindowTitle();
return saveDataDirty;
}
var shouldShowBackupAvailableDialog(get, set):Bool;
function get_shouldShowBackupAvailableDialog():Bool
{
return Save.instance.chartEditorHasBackup;
}
function set_shouldShowBackupAvailableDialog(value:Bool):Bool
{
return Save.instance.chartEditorHasBackup = value;
}
/**
* 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>