@@ -12,6 +12,7 @@ import haxe.ui.containers.ScrollView;
1212import haxe .ui .core .Screen ;
1313import flixel .tweens .FlxTween ;
1414import flixel .tweens .FlxEase ;
15+ import haxe .ui .components .Button ;
1516
1617// @:nullSafety // TODO: Fix null safety when used with HaxeUI build macros.
1718@:access (funkin.ui.debug.charting. ChartEditorState )
@@ -21,14 +22,23 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
2122 public var charSelectScroll : ScrollView ;
2223 public var charIconName : Label ;
2324
25+ var currentCharButton : Button ;
26+
2427 public function new (chartEditorState2 : ChartEditorState , charType : CharacterType , lockPosition : Bool = false )
2528 {
2629 super (chartEditorState2 );
2730
2831 initialize (charType , lockPosition );
2932 this .alpha = 0 ;
3033 this .y - = 10 ;
31- FlxTween .tween (this , {alpha : 1 , y : this .y + 10 }, 0.2 , {ease : FlxEase .quartOut });
34+ FlxTween .tween (this , {alpha : 1 , y : this .y + 10 }, 0.2 ,
35+ {
36+ ease : FlxEase .quartOut ,
37+ onComplete : function (_ ) {
38+ // Just focus the button FFS. Idk why, but the scrollbar doesn't update until after the tween finishes with this????
39+ currentCharButton .focus = true ;
40+ }
41+ });
3242 }
3343
3444 function initialize (charType : CharacterType , lockPosition : Bool )
@@ -70,13 +80,15 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
7080 var charIds : Array <String > = CharacterDataParser .listCharacterIds ();
7181 charIds .sort (SortUtil .alphabetically );
7282
83+ charIds .insert (0 , " " ); // Add none/null/NuN character option
84+
7385 var defaultText : String = ' (choose a character)' ;
7486
7587 for (charIndex => charId in charIds )
7688 {
7789 var charData : CharacterData = CharacterDataParser .fetchCharacterData (charId );
7890
79- var charButton = new haxe.ui.components. Button ();
91+ var charButton = new Button ();
8092 charButton .width = 70 ;
8193 charButton .height = 70 ;
8294 charButton .padding = 8 ;
@@ -85,15 +97,17 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
8597 if (charId == currentCharId )
8698 {
8799 // Scroll to the character if it is already selected.
88- charSelectScroll .hscrollPos = Math .floor (charIndex / 5 ) * 80 ;
89- charButton .selected = true ;
100+ charSelectScroll .vscrollPos = Math .floor (charIndex / 5 ) * 80 ;
101+ charButton .focus = true ;
102+
103+ defaultText = (currentCharId != " " ) ? ' ${charData .name } [ ${charId }]' : ' None' ;
90104
91- defaultText = ' ${ charData . name } [ ${ charId } ] ' ;
105+ currentCharButton = charButton ;
92106 }
93107
94108 var LIMIT = 6 ;
95109 charButton .icon = haxe.ui.util. Variant .fromImageData (CharacterDataParser .getCharPixelIconAsset (charId ));
96- charButton .text = charData .name .length > LIMIT ? ' ${charData .name .substr (0 , LIMIT )}.' : ' ${charData .name }' ;
110+ charButton .text = ( charId != " " ) ? ( charData .name .length > LIMIT ? ' ${charData .name .substr (0 , LIMIT )}.' : ' ${charData .name }' ) : ' None ' ;
97111
98112 charButton .onClick = _ -> {
99113 switch (charType )
@@ -104,12 +118,13 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
104118 default : throw ' Invalid charType: ' + charType ;
105119 };
106120
121+ defaultText = (charId != " " ) ? ' ${charData .name } [ ${charId }]' : ' None' ;
107122 chartEditorState .healthIconsDirty = true ;
108123 chartEditorState .refreshToolbox (ChartEditorState .CHART_EDITOR_TOOLBOX_METADATA_LAYOUT );
109124 };
110125
111126 charButton .onMouseOver = _ -> {
112- charIconName .text = ' ${charData .name } [ ${charId }]' ;
127+ charIconName .text = ( charId != " " ) ? ' ${charData .name } [ ${charId }]' : ' None ' ;
113128 };
114129 charButton .onMouseOut = _ -> {
115130 charIconName .text = defaultText ;
0 commit comments