2023-10-26 05:46:22 -04:00
package funkin . ui . debug . charting . handlers ;
2022-10-26 01:14:29 -04:00
2023-09-25 23:24:07 -04:00
import funkin . play . stage . StageData . StageDataParser ;
import funkin . play . stage . StageData ;
import funkin . play . character . CharacterData ;
import funkin . play . character . CharacterData . CharacterDataParser ;
2023-09-12 23:37:07 -04:00
import haxe . ui . components . HorizontalSlider ;
2023-08-14 23:13:12 -04:00
import haxe . ui . containers . TreeView ;
import haxe . ui . containers . TreeViewNode ;
2022-12-17 15:19:42 -05:00
import funkin . play . character . BaseCharacter . CharacterType ;
2023-01-22 19:55:30 -05:00
import funkin . play . event . SongEvent ;
2023-09-08 17:46:44 -04:00
import funkin . data . event . SongEventData ;
import funkin . data . song . SongData . SongTimeChange ;
2023-11-29 16:53:08 -05:00
import funkin . ui . debug . charting . commands . ChangeStartingBPMCommand ;
2023-10-26 05:46:22 -04:00
import funkin . play . character . BaseCharacter . CharacterType ;
2023-09-25 23:24:07 -04:00
import funkin . play . character . CharacterData ;
import funkin . play . character . CharacterData . CharacterDataParser ;
2023-01-22 19:55:30 -05:00
import funkin . play . event . SongEvent ;
2022-12-17 15:19:42 -05:00
import funkin . play . song . SongSerializer ;
2023-10-26 05:46:22 -04:00
import funkin . play . stage . StageData ;
import funkin . play . stage . StageData . StageDataParser ;
2023-11-24 00:42:07 -05:00
import haxe . ui . RuntimeComponentBuilder ;
2023-10-26 05:46:22 -04:00
import funkin . ui . debug . charting . util . ChartEditorDropdowns ;
2023-01-22 19:55:30 -05:00
import funkin . ui . haxeui . components . CharacterPlayer ;
2023-09-25 23:24:07 -04:00
import funkin . util . FileUtil ;
2022-12-17 15:19:42 -05:00
import haxe . ui . components . Button ;
2023-01-22 19:55:30 -05:00
import haxe . ui . components . CheckBox ;
2022-10-26 01:14:29 -04:00
import haxe . ui . components . DropDown ;
2023-10-26 05:46:22 -04:00
import haxe . ui . components . HorizontalSlider ;
2023-01-22 19:55:30 -05:00
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 ;
2023-06-08 16:48:34 -04:00
import haxe . ui . containers . dialogs . CollapsibleDialog ;
import haxe . ui . containers . dialogs . Dialog . DialogButton ;
import haxe . ui . containers . dialogs . Dialog . DialogEvent ;
2023-10-26 05:46:22 -04:00
import haxe . ui . containers . Frame ;
import haxe . ui . containers . Grid ;
import haxe . ui . containers . TreeView ;
import haxe . ui . containers . TreeViewNode ;
2023-01-22 19:55:30 -05:00
import haxe . ui . core . Component ;
2023-06-08 16:48:34 -04:00
import haxe . ui . data . ArrayDataSource ;
2022-10-26 01:14:29 -04:00
import haxe . ui . events . UIEvent ;
2023-06-08 16:48:34 -04:00
/ * *
* Static functions which handle building themed UI elements for a p r o v i d e d C h a r t E d i t o r S t a t e .
* /
2023-08-31 18:47:23 -04:00
@ : nullSafety
2023-10-26 05:46:22 -04:00
@ : access ( funkin . ui . debug . charting . ChartEditorState )
2022-10-26 01:14:29 -04:00
class ChartEditorToolboxHandler
{
2023-01-22 19:55:30 -05:00
public static function setToolboxState ( state : ChartEditorState , id : String , shown : Bool ) : Void
{
2023-06-08 16:48:34 -04:00
if ( shown )
{
showToolbox ( state , id ) ;
}
2023-01-22 19:55:30 -05:00
e lse
2023-06-08 16:48:34 -04:00
{
2023-01-22 19:55:30 -05:00
hideToolbox ( state , id ) ;
2023-06-08 16:48:34 -04:00
}
2023-01-22 19:55:30 -05:00
}
2023-06-08 16:48:34 -04:00
public static function showToolbox ( state : ChartEditorState , id : String ) : Void
2023-01-22 19:55:30 -05:00
{
2023-08-31 18:47:23 -04:00
var toolbox: Null < CollapsibleDialog > = state . activeToolboxes . get ( id ) ;
2023-01-22 19:55:30 -05:00
2023-01-22 22:25:45 -05:00
if ( toolbox == null ) toolbox = initToolbox ( state , id ) ;
2023-01-22 19:55:30 -05:00
if ( toolbox != null )
{
toolbox . showDialog ( false ) ;
2023-08-14 23:13:12 -04:00
2023-10-26 05:46:22 -04:00
state . playSound ( Paths . sound ( ' c h a r t i n g S o u n d s / o p e n W i n d o w ' ) ) ;
2023-10-11 19:39:52 -04:00
2023-08-14 23:13:12 -04:00
switch ( id )
{
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT :
onShowToolboxNoteData ( state , toolbox ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT :
onShowToolboxEventData ( state , toolbox ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT :
onShowToolboxDifficulty ( state , toolbox ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_METADATA_LAYOUT :
onShowToolboxMetadata ( state , toolbox ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT :
onShowToolboxPlayerPreview ( state , toolbox ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT :
onShowToolboxOpponentPreview ( state , toolbox ) ;
d efault :
// This happens if you try to load an unknown layout.
trace ( ' C h a r t E d i t o r T o o l b o x H a n d l e r . s h o w T o o l b o x ( ) - U n k n o w n t o o l b o x I D : $ id ' ) ;
}
2023-01-22 19:55:30 -05:00
}
e lse
{
trace ( ' C h a r t E d i t o r T o o l b o x H a n d l e r . s h o w T o o l b o x ( ) - C o u l d n o t r e t r i e v e t o o l b o x : $ id ' ) ;
}
}
public static function hideToolbox ( state : ChartEditorState , id : String ) : Void
{
2023-08-31 18:47:23 -04:00
var toolbox: Null < CollapsibleDialog > = state . activeToolboxes . get ( id ) ;
2023-01-22 19:55:30 -05:00
2023-01-22 22:25:45 -05:00
if ( toolbox == null ) toolbox = initToolbox ( state , id ) ;
2023-01-22 19:55:30 -05:00
if ( toolbox != null )
{
toolbox . hideDialog ( DialogButton . CANCEL ) ;
2023-08-14 23:13:12 -04:00
2023-10-26 05:46:22 -04:00
state . playSound ( Paths . sound ( ' c h a r t i n g S o u n d s / e x i t W i n d o w ' ) ) ;
2023-10-11 19:39:52 -04:00
2023-08-14 23:13:12 -04:00
switch ( id )
{
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT :
onHideToolboxNoteData ( state , toolbox ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT :
onHideToolboxEventData ( state , toolbox ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT :
onHideToolboxDifficulty ( state , toolbox ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_METADATA_LAYOUT :
onHideToolboxMetadata ( state , toolbox ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT :
onHideToolboxPlayerPreview ( state , toolbox ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT :
onHideToolboxOpponentPreview ( state , toolbox ) ;
d efault :
// This happens if you try to load an unknown layout.
trace ( ' C h a r t E d i t o r T o o l b o x H a n d l e r . h i d e T o o l b o x ( ) - U n k n o w n t o o l b o x I D : $ id ' ) ;
}
2023-01-22 19:55:30 -05:00
}
e lse
{
trace ( ' C h a r t E d i t o r T o o l b o x H a n d l e r . h i d e T o o l b o x ( ) - C o u l d n o t r e t r i e v e t o o l b o x : $ id ' ) ;
}
}
2023-10-17 16:57:06 -04:00
public static function rememberOpenToolboxes ( state : ChartEditorState ) : Void { }
public static function openRememberedToolboxes ( state : ChartEditorState ) : Void { }
public static function hideAllToolboxes ( state : ChartEditorState ) : Void
{
for ( toolbox in state . activeToolboxes . values ( ) )
{
toolbox . hideDialog ( DialogButton . CANCEL ) ;
}
}
2023-06-08 16:48:34 -04:00
public static function minimizeToolbox ( state : ChartEditorState , id : String ) : Void
{
2023-08-31 18:47:23 -04:00
var toolbox: Null < CollapsibleDialog > = state . activeToolboxes . get ( id ) ;
2023-06-08 16:48:34 -04:00
if ( toolbox == null ) return ;
2023-01-22 19:55:30 -05:00
2023-06-08 16:48:34 -04:00
toolbox . minimized = true ;
}
2023-01-22 19:55:30 -05:00
2023-06-08 16:48:34 -04:00
public static function maximizeToolbox ( state : ChartEditorState , id : String ) : Void
2023-01-22 19:55:30 -05:00
{
2023-08-31 18:47:23 -04:00
var toolbox: Null < CollapsibleDialog > = state . activeToolboxes . get ( id ) ;
2023-06-08 16:48:34 -04:00
if ( toolbox == null ) return ;
toolbox . minimized = false ;
}
2023-08-31 18:47:23 -04:00
public static function initToolbox ( state : ChartEditorState , id : String ) : Null < CollapsibleDialog >
2023-06-08 16:48:34 -04:00
{
2023-08-31 18:47:23 -04:00
var toolbox: Null < CollapsibleDialog > = null ;
2023-01-22 19:55:30 -05:00
switch ( id )
{
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT :
toolbox = buildToolboxNoteDataLayout ( state ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT :
toolbox = buildToolboxEventDataLayout ( state ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT :
toolbox = buildToolboxDifficultyLayout ( state ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_METADATA_LAYOUT :
toolbox = buildToolboxMetadataLayout ( state ) ;
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT :
2023-08-28 15:03:29 -04:00
toolbox = buildToolboxPlayerPreviewLayout ( state ) ;
2023-01-22 19:55:30 -05:00
c ase ChartEditorState . CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT :
2023-08-28 15:03:29 -04:00
toolbox = buildToolboxOpponentPreviewLayout ( state ) ;
2023-01-22 19:55:30 -05:00
d efault :
// This happens if you try to load an unknown layout.
trace ( ' C h a r t E d i t o r T o o l b o x H a n d l e r . i n i t T o o l b o x ( ) - U n k n o w n t o o l b o x I D : $ id ' ) ;
toolbox = null ;
}
// This happens if the layout you try to load has a syntax error.
2023-01-22 22:25:45 -05:00
if ( toolbox == null ) return null ;
2023-01-22 19:55:30 -05:00
// Make sure we can reuse the toolbox later.
toolbox . destroyOnClose = false ;
state . activeToolboxes . set ( id , toolbox ) ;
return toolbox ;
}
2023-06-08 16:48:34 -04:00
/ * *
* Retrieve a toolbox by its layout ' s a s s e t I D .
* @ param state The ChartEditorState instance .
* @ param id The asset ID of the toolbox layout .
* @ return The toolbox .
* /
2023-08-31 18:47:23 -04:00
public static function getToolbox ( state : ChartEditorState , id : String ) : Null < CollapsibleDialog >
2023-01-22 19:55:30 -05:00
{
2023-08-31 18:47:23 -04:00
var toolbox: Null < CollapsibleDialog > = state . activeToolboxes . get ( id ) ;
2023-01-22 19:55:30 -05:00
// Initialize the toolbox without showing it.
2023-01-22 22:25:45 -05:00
if ( toolbox == null ) toolbox = initToolbox ( state , id ) ;
2023-01-22 19:55:30 -05:00
2023-08-28 15:03:29 -04:00
if ( toolbox == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . g e t T o o l b o x ( ) - C o u l d n o t r e t r i e v e o r b u i l d t o o l b o x : $ id ' ;
2023-01-22 19:55:30 -05:00
return toolbox ;
}
2023-08-31 18:47:23 -04:00
static function buildToolboxNoteDataLayout ( state : ChartEditorState ) : Null < CollapsibleDialog >
2023-01-22 19:55:30 -05:00
{
2023-11-24 00:42:07 -05:00
var toolbox: CollapsibleDialog = cast RuntimeComponentBuilder . fromAsset ( ChartEditorState . CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT ) ;
2023-01-22 19:55:30 -05:00
2023-01-22 22:25:45 -05:00
if ( toolbox == null ) return null ;
2023-01-22 19:55:30 -05:00
// Starting position.
toolbox . x = 75 ;
toolbox . y = 100 ;
2023-06-08 16:48:34 -04:00
toolbox . onDialogClosed = function ( event : DialogEvent ) {
2023-11-24 00:42:07 -05:00
state . menubarItemToggleToolboxNotes . selected = false ;
2023-01-22 19:55:30 -05:00
}
2023-08-31 18:47:23 -04:00
var toolboxNotesNoteKind: Null < DropDown > = toolbox . findComponent ( ' t o o l b o x N o t e s N o t e K i n d ' , DropDown ) ;
if ( toolboxNotesNoteKind == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x N o t e D a t a L a y o u t ( ) - C o u l d n o t f i n d t o o l b o x N o t e s N o t e K i n d c o m p o n e n t . ' ;
var toolboxNotesCustomKindLabel: Null < Label > = toolbox . findComponent ( ' t o o l b o x N o t e s C u s t o m K i n d L a b e l ' , Label ) ;
if ( toolboxNotesCustomKindLabel == null )
throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x N o t e D a t a L a y o u t ( ) - C o u l d n o t f i n d t o o l b o x N o t e s C u s t o m K i n d L a b e l c o m p o n e n t . ' ;
var toolboxNotesCustomKind: Null < TextField > = toolbox . findComponent ( ' t o o l b o x N o t e s C u s t o m K i n d ' , TextField ) ;
if ( toolboxNotesCustomKind == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x N o t e D a t a L a y o u t ( ) - C o u l d n o t f i n d t o o l b o x N o t e s C u s t o m K i n d c o m p o n e n t . ' ;
2023-01-22 19:55:30 -05:00
2023-06-08 16:48:34 -04:00
toolboxNotesNoteKind . onChange = function ( event : UIEvent ) {
var isCustom: Bool = ( event . data . id == ' ~ C U S T O M ~ ' ) ;
2023-01-22 19:55:30 -05:00
if ( isCustom )
{
toolboxNotesCustomKindLabel . hidden = false ;
toolboxNotesCustomKind . hidden = false ;
state . selectedNoteKind = toolboxNotesCustomKind . text ;
}
e lse
{
toolboxNotesCustomKindLabel . hidden = true ;
toolboxNotesCustomKind . hidden = true ;
state . selectedNoteKind = event . data . id ;
}
}
2023-06-08 16:48:34 -04:00
toolboxNotesCustomKind . onChange = function ( event : UIEvent ) {
2023-01-22 19:55:30 -05:00
state . selectedNoteKind = toolboxNotesCustomKind . text ;
}
return toolbox ;
}
2023-08-14 23:13:12 -04:00
static function onShowToolboxNoteData ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void { }
static function onHideToolboxNoteData ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void { }
2023-08-31 18:47:23 -04:00
static function buildToolboxEventDataLayout ( state : ChartEditorState ) : Null < CollapsibleDialog >
2023-01-22 19:55:30 -05:00
{
2023-11-24 00:42:07 -05:00
var toolbox: CollapsibleDialog = cast RuntimeComponentBuilder . fromAsset ( ChartEditorState . CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT ) ;
2023-01-22 19:55:30 -05:00
2023-01-22 22:25:45 -05:00
if ( toolbox == null ) return null ;
2023-01-22 19:55:30 -05:00
// Starting position.
toolbox . x = 100 ;
toolbox . y = 150 ;
2023-06-08 16:48:34 -04:00
toolbox . onDialogClosed = function ( event : DialogEvent ) {
2023-11-24 00:42:07 -05:00
state . menubarItemToggleToolboxEvents . selected = false ;
2023-01-22 19:55:30 -05:00
}
2023-08-31 18:47:23 -04:00
var toolboxEventsEventKind: Null < DropDown > = toolbox . findComponent ( ' t o o l b o x E v e n t s E v e n t K i n d ' , DropDown ) ;
if ( toolboxEventsEventKind == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x E v e n t D a t a L a y o u t ( ) - C o u l d n o t f i n d t o o l b o x E v e n t s E v e n t K i n d c o m p o n e n t . ' ;
var toolboxEventsDataGrid: Null < Grid > = toolbox . findComponent ( ' t o o l b o x E v e n t s D a t a G r i d ' , Grid ) ;
if ( toolboxEventsDataGrid == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x E v e n t D a t a L a y o u t ( ) - C o u l d n o t f i n d t o o l b o x E v e n t s D a t a G r i d c o m p o n e n t . ' ;
2023-01-22 19:55:30 -05:00
toolboxEventsEventKind . dataSource = new ArrayDataSource ( ) ;
var songEvents: Array < SongEvent > = SongEventParser . listEvents ( ) ;
for ( event in songEvents )
{
toolboxEventsEventKind . dataSource . add ( { text : event . getTitle ( ) , value : event . id } ) ;
}
2023-06-08 16:48:34 -04:00
toolboxEventsEventKind . onChange = function ( event : UIEvent ) {
2023-01-22 19:55:30 -05:00
var eventType: String = event . data . value ;
trace ( ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x E v e n t D a t a L a y o u t ( ) - E v e n t t y p e c h a n g e d : $ eventType ' ) ;
2023-10-27 01:42:05 -04:00
state . selectedEventKind = eventType ;
2023-01-22 19:55:30 -05:00
var schema: SongEventSchema = SongEventParser . getEventSchema ( eventType ) ;
if ( schema == null )
{
trace ( ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x E v e n t D a t a L a y o u t ( ) - U n k n o w n e v e n t k i n d : $ eventType ' ) ;
return ;
}
buildEventDataFormFromSchema ( state , toolboxEventsDataGrid , schema ) ;
}
2023-10-27 01:42:05 -04:00
toolboxEventsEventKind . value = state . selectedEventKind ;
2023-01-22 19:55:30 -05:00
return toolbox ;
}
2023-08-14 23:13:12 -04:00
static function onShowToolboxEventData ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void { }
static function onHideToolboxEventData ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void { }
2023-01-22 19:55:30 -05:00
static function buildEventDataFormFromSchema ( state : ChartEditorState , target : Box , schema : SongEventSchema ) : Void
{
trace ( schema ) ;
// Clear the frame.
target . removeAllComponents ( ) ;
state . selectedEventData = { } ;
for ( field in schema )
{
2023-08-31 18:47:23 -04:00
if ( field == null ) continue ;
2023-01-22 19:55:30 -05:00
// Add a label.
var label: Label = new Label ( ) ;
label . text = field . title ;
2023-10-27 01:42:05 -04:00
label . verticalAlign = " c e n t e r " ;
2023-01-22 19:55:30 -05:00
target . addComponent ( label ) ;
var input: Component ;
switch ( field . type )
{
c ase INTEGER :
var numberStepper: NumberStepper = new NumberStepper ( ) ;
numberStepper . id = field . name ;
2023-08-31 18:47:23 -04:00
numberStepper . step = field . step ? ? 1.0 ;
numberStepper . min = field . min ? ? 0.0 ;
numberStepper . max = field . max ? ? 10.0 ;
if ( field . defaultValue != null ) numberStepper . value = field . defaultValue ;
2023-01-22 19:55:30 -05:00
input = numberStepper ;
c ase FLOAT :
var numberStepper: NumberStepper = new NumberStepper ( ) ;
numberStepper . id = field . name ;
2023-08-31 18:47:23 -04:00
numberStepper . step = field . step ? ? 0.1 ;
2023-10-27 01:42:05 -04:00
if ( field . min != null ) numberStepper . min = field . min ;
if ( field . max != null ) numberStepper . max = field . max ;
2023-08-31 18:47:23 -04:00
if ( field . defaultValue != null ) numberStepper . value = field . defaultValue ;
2023-01-22 19:55:30 -05:00
input = numberStepper ;
c ase BOOL :
2023-06-08 16:48:34 -04:00
var checkBox: CheckBox = new CheckBox ( ) ;
2023-01-22 19:55:30 -05:00
checkBox . id = field . name ;
2023-08-31 18:47:23 -04:00
if ( field . defaultValue != null ) checkBox . selected = field . defaultValue ;
2023-01-22 19:55:30 -05:00
input = checkBox ;
c ase ENUM :
var dropDown: DropDown = new DropDown ( ) ;
dropDown . id = field . name ;
2023-11-02 17:40:00 -04:00
dropDown . width = 200.0 ;
2023-01-22 19:55:30 -05:00
dropDown . dataSource = new ArrayDataSource ( ) ;
2023-08-31 18:47:23 -04:00
if ( field . keys == null ) throw ' F i e l d " ${ field . name } " i s o f E n u m t y p e b u t h a s n o k e y s . ' ;
2023-01-22 19:55:30 -05:00
// Add entries to the dropdown.
2023-08-31 18:47:23 -04:00
2023-01-22 19:55:30 -05:00
for ( optionName in field . keys . keys ( ) )
{
2023-10-27 01:42:05 -04:00
var optionValue: Null < Dynamic > = field . keys . get ( optionName ) ;
2023-01-22 19:55:30 -05:00
trace ( ' $ optionName : $ optionValue ' ) ;
dropDown . dataSource . add ( { value : optionValue , text : optionName } ) ;
}
dropDown . value = field . defaultValue ;
input = dropDown ;
c ase STRING :
input = new TextField ( ) ;
input . id = field . name ;
2023-08-31 18:47:23 -04:00
if ( field . defaultValue != null ) input . text = field . defaultValue ;
2023-01-22 19:55:30 -05:00
d efault :
// Unknown type. Display a label so we know what it is.
input = new Label ( ) ;
input . id = field . name ;
input . text = field . type ;
}
target . addComponent ( input ) ;
2023-06-08 16:48:34 -04:00
input . onChange = function ( event : UIEvent ) {
2023-10-27 01:42:05 -04:00
var value = event . target . value ;
if ( field . type == ENUM )
{
value = event . target . value . value ;
}
trace ( ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d E v e n t D a t a F o r m F r o m S c h e m a ( ) - ${ event . target . id } = ${ value } ' ) ;
if ( value == null )
{
state . selectedEventData . remove ( event . target . id ) ;
}
2023-01-22 19:55:30 -05:00
e lse
2023-10-27 01:42:05 -04:00
{
state . selectedEventData . set ( event . target . id , value ) ;
}
2023-01-22 19:55:30 -05:00
}
}
}
2023-08-31 18:47:23 -04:00
static function buildToolboxDifficultyLayout ( state : ChartEditorState ) : Null < CollapsibleDialog >
2023-01-22 19:55:30 -05:00
{
2023-11-24 00:42:07 -05:00
var toolbox: CollapsibleDialog = cast RuntimeComponentBuilder . fromAsset ( ChartEditorState . CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT ) ;
2023-01-22 19:55:30 -05:00
2023-01-22 22:25:45 -05:00
if ( toolbox == null ) return null ;
2023-01-22 19:55:30 -05:00
// Starting position.
toolbox . x = 125 ;
toolbox . y = 200 ;
2023-06-08 16:48:34 -04:00
toolbox . onDialogClosed = function ( event : UIEvent ) {
2023-11-24 00:42:07 -05:00
state . menubarItemToggleToolboxDifficulty . selected = false ;
2023-01-22 19:55:30 -05:00
}
2023-09-25 23:24:07 -04:00
var difficultyToolboxAddVariation: Null < Button > = toolbox . findComponent ( ' d i f f i c u l t y T o o l b o x A d d V a r i a t i o n ' , Button ) ;
if ( difficultyToolboxAddVariation == null )
throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x D i f f i c u l t y L a y o u t ( ) - C o u l d n o t f i n d d i f f i c u l t y T o o l b o x A d d V a r i a t i o n c o m p o n e n t . ' ;
var difficultyToolboxAddDifficulty: Null < Button > = toolbox . findComponent ( ' d i f f i c u l t y T o o l b o x A d d D i f f i c u l t y ' , Button ) ;
if ( difficultyToolboxAddDifficulty == null )
throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x D i f f i c u l t y L a y o u t ( ) - C o u l d n o t f i n d d i f f i c u l t y T o o l b o x A d d D i f f i c u l t y c o m p o n e n t . ' ;
2023-08-31 18:47:23 -04:00
var difficultyToolboxSaveMetadata: Null < Button > = toolbox . findComponent ( ' d i f f i c u l t y T o o l b o x S a v e M e t a d a t a ' , Button ) ;
if ( difficultyToolboxSaveMetadata == null )
throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x D i f f i c u l t y L a y o u t ( ) - C o u l d n o t f i n d d i f f i c u l t y T o o l b o x S a v e M e t a d a t a c o m p o n e n t . ' ;
var difficultyToolboxSaveChart: Null < Button > = toolbox . findComponent ( ' d i f f i c u l t y T o o l b o x S a v e C h a r t ' , Button ) ;
if ( difficultyToolboxSaveChart == null )
throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x D i f f i c u l t y L a y o u t ( ) - C o u l d n o t f i n d d i f f i c u l t y T o o l b o x S a v e C h a r t c o m p o n e n t . ' ;
2023-09-25 23:24:07 -04:00
// var difficultyToolboxSaveAll:Null<Button> = toolbox.findComponent('difficultyToolboxSaveAll', Button);
// if (difficultyToolboxSaveAll == null) throw 'ChartEditorToolboxHandler.buildToolboxDifficultyLayout() - Could not find difficultyToolboxSaveAll component.';
2023-08-31 18:47:23 -04:00
var difficultyToolboxLoadMetadata: Null < Button > = toolbox . findComponent ( ' d i f f i c u l t y T o o l b o x L o a d M e t a d a t a ' , Button ) ;
if ( difficultyToolboxLoadMetadata == null )
throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x D i f f i c u l t y L a y o u t ( ) - C o u l d n o t f i n d d i f f i c u l t y T o o l b o x L o a d M e t a d a t a c o m p o n e n t . ' ;
var difficultyToolboxLoadChart: Null < Button > = toolbox . findComponent ( ' d i f f i c u l t y T o o l b o x L o a d C h a r t ' , Button ) ;
if ( difficultyToolboxLoadChart == null )
throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x D i f f i c u l t y L a y o u t ( ) - C o u l d n o t f i n d d i f f i c u l t y T o o l b o x L o a d C h a r t c o m p o n e n t . ' ;
2023-01-22 19:55:30 -05:00
2023-09-25 23:24:07 -04:00
difficultyToolboxAddVariation . onClick = function ( _ : UIEvent ) {
2023-10-26 05:46:22 -04:00
state . openAddVariationDialog ( true ) ;
2023-01-22 19:55:30 -05:00
} ;
2023-09-25 23:24:07 -04:00
difficultyToolboxAddDifficulty . onClick = function ( _ : UIEvent ) {
2023-10-26 05:46:22 -04:00
state . openAddDifficultyDialog ( true ) ;
2023-01-22 19:55:30 -05:00
} ;
2023-09-25 23:24:07 -04:00
difficultyToolboxSaveMetadata . onClick = function ( _ : UIEvent ) {
var vari: String = state . selectedVariation != Constants . DEFAULT_VARIATION ? ' - ${ state . selectedVariation } ' : ' ' ;
FileUtil . writeFileReference ( ' ${ state . currentSongId } $ vari - m e t a d a t a . j s o n ' , state . currentSongMetadata . serialize ( ) ) ;
2023-01-22 19:55:30 -05:00
} ;
2023-09-25 23:24:07 -04:00
difficultyToolboxSaveChart . onClick = function ( _ : UIEvent ) {
var vari: String = state . selectedVariation != Constants . DEFAULT_VARIATION ? ' - ${ state . selectedVariation } ' : ' ' ;
FileUtil . writeFileReference ( ' ${ state . currentSongId } $ vari - c h a r t . j s o n ' , state . currentSongChartData . serialize ( ) ) ;
} ;
difficultyToolboxLoadMetadata . onClick = function ( _ : UIEvent ) {
2023-01-22 19:55:30 -05:00
// Replace metadata for current variation.
2023-06-02 15:25:13 -04:00
SongSerializer . importSongMetadataAsync ( function ( songMetadata ) {
2023-01-22 19:55:30 -05:00
state . currentSongMetadata = songMetadata ;
} ) ;
} ;
2023-09-25 23:24:07 -04:00
difficultyToolboxLoadChart . onClick = function ( _ : UIEvent ) {
2023-01-22 19:55:30 -05:00
// Replace chart data for current variation.
2023-06-02 15:25:13 -04:00
SongSerializer . importSongChartDataAsync ( function ( songChartData ) {
2023-01-22 19:55:30 -05:00
state . currentSongChartData = songChartData ;
state . noteDisplayDirty = true ;
} ) ;
} ;
state . difficultySelectDirty = true ;
return toolbox ;
}
2023-08-14 23:13:12 -04:00
static function onShowToolboxDifficulty ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void
{
// Update the selected difficulty when reopening the toolbox.
2023-08-31 18:47:23 -04:00
var treeView: Null < TreeView > = toolbox . findComponent ( ' d i f f i c u l t y T o o l b o x T r e e ' ) ;
2023-08-14 23:13:12 -04:00
if ( treeView == null ) return ;
2023-08-31 18:47:23 -04:00
var current = state . getCurrentTreeDifficultyNode ( treeView ) ;
if ( current == null ) return ;
treeView . selectedNode = current ;
2023-08-14 23:13:12 -04:00
trace ( ' s e l e c t e d n o d e : ${ treeView . selectedNode } ' ) ;
}
static function onHideToolboxDifficulty ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void { }
2023-08-31 18:47:23 -04:00
static function buildToolboxMetadataLayout ( state : ChartEditorState ) : Null < CollapsibleDialog >
2023-01-22 19:55:30 -05:00
{
2023-11-24 00:42:07 -05:00
var toolbox: CollapsibleDialog = cast RuntimeComponentBuilder . fromAsset ( ChartEditorState . CHART_EDITOR_TOOLBOX_METADATA_LAYOUT ) ;
2023-01-22 19:55:30 -05:00
2023-01-22 22:25:45 -05:00
if ( toolbox == null ) return null ;
2023-01-22 19:55:30 -05:00
// Starting position.
toolbox . x = 150 ;
toolbox . y = 250 ;
2023-06-08 16:48:34 -04:00
toolbox . onDialogClosed = function ( event : UIEvent ) {
2023-11-24 00:42:07 -05:00
state . menubarItemToggleToolboxMetadata . selected = false ;
2023-01-22 19:55:30 -05:00
}
2023-08-31 18:47:23 -04:00
var inputSongName: Null < TextField > = toolbox . findComponent ( ' i n p u t S o n g N a m e ' , TextField ) ;
if ( inputSongName == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d i n p u t S o n g N a m e c o m p o n e n t . ' ;
2023-06-08 16:48:34 -04:00
inputSongName . onChange = function ( event : UIEvent ) {
var valid: Bool = event . target . text != null && event . target . text != ' ' ;
2023-01-22 19:55:30 -05:00
if ( valid )
{
inputSongName . removeClass ( ' i n v a l i d - v a l u e ' ) ;
state . currentSongMetadata . songName = event . target . text ;
}
e lse
{
2023-08-31 18:47:23 -04:00
state . currentSongMetadata . songName = ' ' ;
2023-01-22 19:55:30 -05:00
}
} ;
2023-06-08 16:48:34 -04:00
inputSongName . value = state . currentSongMetadata . songName ;
2023-01-22 19:55:30 -05:00
2023-08-31 18:47:23 -04:00
var inputSongArtist: Null < TextField > = toolbox . findComponent ( ' i n p u t S o n g A r t i s t ' , TextField ) ;
if ( inputSongArtist == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d i n p u t S o n g A r t i s t c o m p o n e n t . ' ;
2023-06-08 16:48:34 -04:00
inputSongArtist . onChange = function ( event : UIEvent ) {
var valid: Bool = event . target . text != null && event . target . text != ' ' ;
2023-01-22 19:55:30 -05:00
if ( valid )
{
inputSongArtist . removeClass ( ' i n v a l i d - v a l u e ' ) ;
state . currentSongMetadata . artist = event . target . text ;
}
e lse
{
2023-08-31 18:47:23 -04:00
state . currentSongMetadata . artist = ' ' ;
2023-01-22 19:55:30 -05:00
}
} ;
2023-06-08 16:48:34 -04:00
inputSongArtist . value = state . currentSongMetadata . artist ;
2023-01-22 19:55:30 -05:00
2023-10-31 14:43:01 -04:00
var inputStage: Null < DropDown > = toolbox . findComponent ( ' i n p u t S t a g e ' , DropDown ) ;
2023-08-31 18:47:23 -04:00
if ( inputStage == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d i n p u t S t a g e c o m p o n e n t . ' ;
2023-06-08 16:48:34 -04:00
inputStage . onChange = function ( event : UIEvent ) {
var valid: Bool = event . data != null && event . data . id != null ;
2023-01-22 19:55:30 -05:00
if ( valid )
{
state . currentSongMetadata . playData . stage = event . data . id ;
}
} ;
2023-09-25 23:24:07 -04:00
var startingValueStage = ChartEditorDropdowns . populateDropdownWithStages ( inputStage , state . currentSongMetadata . playData . stage ) ;
inputStage . value = startingValueStage ;
2023-10-31 14:43:01 -04:00
var inputNoteStyle: Null < DropDown > = toolbox . findComponent ( ' i n p u t N o t e S t y l e ' , DropDown ) ;
2023-09-25 23:24:07 -04:00
if ( inputNoteStyle == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d i n p u t N o t e S t y l e c o m p o n e n t . ' ;
inputNoteStyle . onChange = function ( event : UIEvent ) {
if ( event . data ? . id == null ) r e t u r n ;
state . currentSongNoteStyle = event . data . id ;
} ;
inputNoteStyle . value = state . currentSongNoteStyle ;
2023-01-22 19:55:30 -05:00
2023-09-25 23:24:07 -04:00
// By using this flag, we prevent the dropdown value from changing while it is being populated.
2023-10-31 14:43:01 -04:00
var inputCharacterPlayer: Null < DropDown > = toolbox . findComponent ( ' i n p u t C h a r a c t e r P l a y e r ' , DropDown ) ;
2023-09-25 23:24:07 -04:00
if ( inputCharacterPlayer == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d i n p u t C h a r a c t e r P l a y e r c o m p o n e n t . ' ;
inputCharacterPlayer . onChange = function ( event : UIEvent ) {
if ( event . data ? . id == null ) r e t u r n ;
state . currentSongMetadata . playData . characters . player = event . data . id ;
} ;
var startingValuePlayer = ChartEditorDropdowns . populateDropdownWithCharacters ( inputCharacterPlayer , CharacterType . BF ,
state . currentSongMetadata . playData . characters . player ) ;
inputCharacterPlayer . value = startingValuePlayer ;
2023-10-31 14:43:01 -04:00
var inputCharacterOpponent: Null < DropDown > = toolbox . findComponent ( ' i n p u t C h a r a c t e r O p p o n e n t ' , DropDown ) ;
2023-09-25 23:24:07 -04:00
if ( inputCharacterOpponent == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d i n p u t C h a r a c t e r O p p o n e n t c o m p o n e n t . ' ;
inputCharacterOpponent . onChange = function ( event : UIEvent ) {
if ( event . data ? . id == null ) r e t u r n ;
state . currentSongMetadata . playData . characters . opponent = event . data . id ;
2023-01-22 19:55:30 -05:00
} ;
2023-09-25 23:24:07 -04:00
var startingValueOpponent = ChartEditorDropdowns . populateDropdownWithCharacters ( inputCharacterOpponent , CharacterType . DAD ,
state . currentSongMetadata . playData . characters . opponent ) ;
inputCharacterOpponent . value = startingValueOpponent ;
2023-10-31 14:43:01 -04:00
var inputCharacterGirlfriend: Null < DropDown > = toolbox . findComponent ( ' i n p u t C h a r a c t e r G i r l f r i e n d ' , DropDown ) ;
2023-09-25 23:24:07 -04:00
if ( inputCharacterGirlfriend == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d i n p u t C h a r a c t e r G i r l f r i e n d c o m p o n e n t . ' ;
inputCharacterGirlfriend . onChange = function ( event : UIEvent ) {
if ( event . data ? . id == null ) r e t u r n ;
state . currentSongMetadata . playData . characters . girlfriend = event . data . id == " n o n e " ? " " : event . data . id ;
} ;
var startingValueGirlfriend = ChartEditorDropdowns . populateDropdownWithCharacters ( inputCharacterGirlfriend , CharacterType . GF ,
state . currentSongMetadata . playData . characters . girlfriend ) ;
inputCharacterGirlfriend . value = startingValueGirlfriend ;
2023-01-22 19:55:30 -05:00
2023-08-31 18:47:23 -04:00
var inputBPM: Null < NumberStepper > = toolbox . findComponent ( ' i n p u t B P M ' , NumberStepper ) ;
if ( inputBPM == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d i n p u t B P M c o m p o n e n t . ' ;
2023-06-08 16:48:34 -04:00
inputBPM . onChange = function ( event : UIEvent ) {
2023-01-22 22:25:45 -05:00
if ( event . value == null || event . value <= 0 ) return ;
2023-01-22 19:55:30 -05:00
2023-11-28 20:36:59 -05:00
// Use a command so we can undo/redo this action.
2023-11-29 16:53:08 -05:00
var startingBPM = state . currentSongMetadata . timeChanges [ 0 ] . bpm ;
if ( event . value != startingBPM )
{
state . performCommand ( new ChangeStartingBPMCommand ( event . value ) ) ;
}
2023-01-22 19:55:30 -05:00
} ;
2023-06-08 16:48:34 -04:00
inputBPM . value = state . currentSongMetadata . timeChanges [ 0 ] . bpm ;
2023-01-22 19:55:30 -05:00
2023-08-31 18:47:23 -04:00
var labelScrollSpeed: Null < Label > = toolbox . findComponent ( ' l a b e l S c r o l l S p e e d ' , Label ) ;
if ( labelScrollSpeed == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d l a b e l S c r o l l S p e e d c o m p o n e n t . ' ;
2023-08-11 14:00:38 -04:00
2023-08-31 18:47:23 -04:00
var inputScrollSpeed: Null < Slider > = toolbox . findComponent ( ' i n p u t S c r o l l S p e e d ' , Slider ) ;
if ( inputScrollSpeed == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d i n p u t S c r o l l S p e e d c o m p o n e n t . ' ;
2023-06-08 16:48:34 -04:00
inputScrollSpeed . onChange = function ( event : UIEvent ) {
var valid: Bool = event . target . value != null && event . target . value > 0 ;
2023-01-22 19:55:30 -05:00
if ( valid )
{
inputScrollSpeed . removeClass ( ' i n v a l i d - v a l u e ' ) ;
2023-06-08 16:48:34 -04:00
state . currentSongChartScrollSpeed = event . target . value ;
2023-01-22 19:55:30 -05:00
}
e lse
{
2023-06-08 16:48:34 -04:00
state . currentSongChartScrollSpeed = 1.0 ;
2023-01-22 19:55:30 -05:00
}
2023-08-11 14:00:38 -04:00
labelScrollSpeed . text = ' S c r o l l S p e e d : ${ state . currentSongChartScrollSpeed } x ' ;
2023-01-22 19:55:30 -05:00
} ;
2023-08-11 14:00:38 -04:00
inputScrollSpeed . value = state . currentSongChartScrollSpeed ;
labelScrollSpeed . text = ' S c r o l l S p e e d : ${ state . currentSongChartScrollSpeed } x ' ;
2023-01-22 19:55:30 -05:00
2023-08-31 18:47:23 -04:00
var frameVariation: Null < Frame > = toolbox . findComponent ( ' f r a m e V a r i a t i o n ' , Frame ) ;
if ( frameVariation == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d f r a m e V a r i a t i o n c o m p o n e n t . ' ;
2023-08-15 16:08:12 -04:00
frameVariation . text = ' V a r i a t i o n : ${ state . selectedVariation . toTitleCase ( ) } ' ;
2023-08-31 18:47:23 -04:00
var frameDifficulty: Null < Frame > = toolbox . findComponent ( ' f r a m e D i f f i c u l t y ' , Frame ) ;
if ( frameDifficulty == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x M e t a d a t a L a y o u t ( ) - C o u l d n o t f i n d f r a m e D i f f i c u l t y c o m p o n e n t . ' ;
2023-08-15 16:08:12 -04:00
frameDifficulty . text = ' D i f f i c u l t y : ${ state . selectedDifficulty . toTitleCase ( ) } ' ;
2023-01-22 19:55:30 -05:00
return toolbox ;
}
2023-08-15 16:08:12 -04:00
static function onShowToolboxMetadata ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void
{
2023-09-25 23:24:07 -04:00
state . refreshMetadataToolbox ( ) ;
2023-08-15 16:08:12 -04:00
}
2023-08-14 23:13:12 -04:00
static function onHideToolboxMetadata ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void { }
2023-08-31 18:47:23 -04:00
static function buildToolboxPlayerPreviewLayout ( state : ChartEditorState ) : Null < CollapsibleDialog >
2023-01-22 19:55:30 -05:00
{
2023-11-24 00:42:07 -05:00
var toolbox: CollapsibleDialog = cast RuntimeComponentBuilder . fromAsset ( ChartEditorState . CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT ) ;
2023-01-22 19:55:30 -05:00
2023-01-22 22:25:45 -05:00
if ( toolbox == null ) return null ;
2023-01-22 19:55:30 -05:00
// Starting position.
toolbox . x = 200 ;
toolbox . y = 350 ;
2023-06-08 16:48:34 -04:00
toolbox . onDialogClosed = function ( event : DialogEvent ) {
2023-11-24 00:42:07 -05:00
state . menubarItemToggleToolboxPlayerPreview . selected = false ;
2023-01-22 19:55:30 -05:00
}
2023-08-31 18:47:23 -04:00
var charPlayer: Null < CharacterPlayer > = toolbox . findComponent ( ' c h a r P l a y e r ' ) ;
if ( charPlayer == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x P l a y e r P r e v i e w L a y o u t ( ) - C o u l d n o t f i n d c h a r P l a y e r c o m p o n e n t . ' ;
2023-01-22 19:55:30 -05:00
// TODO: We need to implement character swapping in ChartEditorState.
charPlayer . loadCharacter ( ' b f ' ) ;
2023-06-08 16:48:34 -04:00
charPlayer . characterType = CharacterType . BF ;
2023-01-22 19:55:30 -05:00
charPlayer . flip = true ;
2023-06-08 16:48:34 -04:00
charPlayer . targetScale = 0.5 ;
2023-01-22 19:55:30 -05:00
return toolbox ;
}
2023-08-14 23:13:12 -04:00
static function onShowToolboxPlayerPreview ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void { }
static function onHideToolboxPlayerPreview ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void { }
2023-08-31 18:47:23 -04:00
static function buildToolboxOpponentPreviewLayout ( state : ChartEditorState ) : Null < CollapsibleDialog >
2023-01-22 19:55:30 -05:00
{
2023-11-24 00:42:07 -05:00
var toolbox: CollapsibleDialog = cast RuntimeComponentBuilder . fromAsset ( ChartEditorState . CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT ) ;
2023-01-22 19:55:30 -05:00
2023-01-22 22:25:45 -05:00
if ( toolbox == null ) return null ;
2023-01-22 19:55:30 -05:00
// Starting position.
toolbox . x = 200 ;
toolbox . y = 350 ;
2023-06-08 16:30:45 -04:00
toolbox . onDialogClosed = ( event : DialogEvent ) - > {
2023-11-24 00:42:07 -05:00
state . menubarItemToggleToolboxOpponentPreview . selected = false ;
2023-01-22 19:55:30 -05:00
}
2023-08-31 18:47:23 -04:00
var charPlayer: Null < CharacterPlayer > = toolbox . findComponent ( ' c h a r P l a y e r ' ) ;
if ( charPlayer == null ) throw ' C h a r t E d i t o r T o o l b o x H a n d l e r . b u i l d T o o l b o x O p p o n e n t P r e v i e w L a y o u t ( ) - C o u l d n o t f i n d c h a r P l a y e r c o m p o n e n t . ' ;
2023-01-22 19:55:30 -05:00
// TODO: We need to implement character swapping in ChartEditorState.
charPlayer . loadCharacter ( ' d a d ' ) ;
2023-06-08 16:48:34 -04:00
charPlayer . characterType = CharacterType . DAD ;
2023-01-22 19:55:30 -05:00
charPlayer . flip = false ;
2023-06-08 16:48:34 -04:00
charPlayer . targetScale = 0.5 ;
2023-01-22 19:55:30 -05:00
return toolbox ;
}
2023-08-14 23:13:12 -04:00
static function onShowToolboxOpponentPreview ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void { }
static function onHideToolboxOpponentPreview ( state : ChartEditorState , toolbox : CollapsibleDialog ) : Void { }
2022-10-26 01:14:29 -04:00
}