@@ -102,6 +102,7 @@ class StageEditorState extends UIState
102102 var menubarItemDelete : MenuItem ; // delete
103103 var menubarItemNewObj : MenuItem ; // new
104104 var menubarItemFindObj : MenuItem ; // find
105+ var menubarItemSelectNone : MenuItem ; // access none
105106 var menubarItemMoveStep : Menu ; // move step submenu
106107
107108 var menubarMenuView : Menu ;
@@ -141,6 +142,7 @@ class StageEditorState extends UIState
141142 {
142143 selectedSprite ?. selectedShader .setAmount (0 );
143144 this .selectedSprite = value ;
145+ infoSelection = value ?. name ?? " None" ;
144146 updateDialog (StageEditorDialogType .OBJECT_GRAPHIC );
145147 updateDialog (StageEditorDialogType .OBJECT_ANIMS );
146148 updateDialog (StageEditorDialogType .OBJECT_PROPERTIES );
@@ -161,6 +163,7 @@ class StageEditorState extends UIState
161163 function set_selectedChar (value : BaseCharacter )
162164 {
163165 this .selectedChar = value ;
166+ infoSelection = Std .string (value ?. characterType ) ?? " None" ;
164167 updateDialog (StageEditorDialogType .CHARACTER );
165168 return selectedChar ;
166169 }
@@ -579,7 +582,6 @@ class StageEditorState extends UIState
579582
580583 // testmode
581584 menubarMenuFile .disabled = menubarMenuEdit .disabled = bottomBarModeText .disabled = menubarMenuWindow .disabled = testingMode ;
582- menubarButtonText .selected = testingMode ;
583585
584586 if (testingMode )
585587 {
@@ -596,6 +598,7 @@ class StageEditorState extends UIState
596598 if (FlxG .keys .justPressed .TAB && ! FlxG .keys .pressed .SHIFT ) curTestChar ++ ;
597599
598600 if (curTestChar >= getCharacters ().length ) curTestChar = 0 ;
601+ else if (curTestChar < 0 ) curTestChar = getCharacters ().length - 1 ;
599602
600603 bottomBarSelectText .text = Std .string (getCharacters ()[curTestChar ].characterType );
601604
@@ -625,10 +628,11 @@ class StageEditorState extends UIState
625628 }
626629
627630 // key shortcuts and inputs
628- if (allowInput )
631+ if (pressingControl () && FlxG .keys .justPressed .Q ) onMenuItemClick (" exit" );
632+
633+ if (allowInput && welcomeDialog == null )
629634 {
630- // "WINDOWS" key code is the same keycode as COMMAND on mac
631- if (FlxG .keys .pressed .CONTROL || FlxG .keys .pressed .WINDOWS )
635+ if (pressingControl ())
632636 {
633637 if (FlxG .keys .justPressed .Z ) onMenuItemClick (" undo" );
634638 if (FlxG .keys .justPressed .Y ) onMenuItemClick (" redo" );
@@ -637,24 +641,24 @@ class StageEditorState extends UIState
637641 if (FlxG .keys .justPressed .X ) onMenuItemClick (" cut object" );
638642 if (FlxG .keys .justPressed .S ) FlxG .keys .pressed .SHIFT ? onMenuItemClick (" save stage as" ) : onMenuItemClick (" save stage" );
639643 if (FlxG .keys .justPressed .F ) onMenuItemClick (" find object" );
644+ if (FlxG .keys .justPressed .D ) onMenuItemClick (" select none" );
640645 if (FlxG .keys .justPressed .O ) onMenuItemClick (" open stage" );
641646 if (FlxG .keys .justPressed .N ) onMenuItemClick (" new stage" );
642- if (FlxG .keys .justPressed .Q ) onMenuItemClick (" exit" );
643647 }
644648
645649 if (FlxG .keys .justPressed .TAB ) onMenuItemClick (" switch mode" );
646650 if (FlxG .keys .justPressed .DELETE ) onMenuItemClick (" delete object" );
647651 if (FlxG .keys .justPressed .ENTER ) onMenuItemClick (" test stage" );
648- if (FlxG .keys .justPressed .ESCAPE ) onMenuItemClick (" exit" );
649- if (FlxG .keys .justPressed .F1 && welcomeDialog == null && userGuideDialog == null ) onMenuItemClick (" user guide" );
652+ if (FlxG .keys .justPressed .F1 && userGuideDialog == null ) onMenuItemClick (" user guide" );
650653
651654 if (FlxG .keys .justPressed .T )
652655 {
653656 camFollow .screenCenter ();
654657 FlxG .camera .zoom = 1 ;
655658 }
656659
657- if (FlxG .keys .pressed .W || FlxG .keys .pressed .S || FlxG .keys .pressed .A || FlxG .keys .pressed .D )
660+ if (! pressingControl ()
661+ && (FlxG .keys .pressed .W || FlxG .keys .pressed .S || FlxG .keys .pressed .A || FlxG .keys .pressed .D ))
658662 {
659663 if (FlxG .keys .pressed .W ) camFollow .velocity .y = - 90 * (2 / FlxG .camera .zoom );
660664 else if (FlxG .keys .pressed .S ) camFollow .velocity .y = 90 * (2 / FlxG .camera .zoom );
@@ -681,30 +685,33 @@ class StageEditorState extends UIState
681685
682686 if (moveMode == " assets" )
683687 {
684- if (selectedSprite != null && ! FlxG .mouse .overlaps (selectedSprite ) && FlxG .mouse .justPressed && ! isCursorOverHaxeUI )
688+ if (selectedSprite != null
689+ && (! FlxG .mouse .overlaps (selectedSprite )
690+ || (FlxG .mouse .overlaps (selectedSprite ) && pressingControl ()))
691+ && FlxG .mouse .justPressed
692+ && ! isCursorOverHaxeUI )
685693 {
686694 selectedSprite = null ;
687695 }
688696
689- for ( spr in spriteArray )
697+ if ( ! isCursorOverHaxeUI )
690698 {
691- if (FlxG .mouse .overlaps (spr ))
699+ if (menubarItemViewNameText .selected ) nameTxt .visible = true ;
700+ for (spr in spriteArray )
692701 {
693- if (spr .visible && ! FlxG .keys .pressed .SHIFT ) nameTxt .text = spr .name ;
694-
695- if (FlxG .mouse .justPressed && allowInput && spr .visible && ! FlxG .keys .pressed .SHIFT && ! isCursorOverHaxeUI )
702+ if (! pressingControl () && FlxG .mouse .overlaps (spr ))
696703 {
697- selectedSprite = spr ;
698- }
699- }
704+ if (spr .visible && ! FlxG .keys .pressed .SHIFT ) nameTxt .text = spr .name ;
700705
701- if (spr == selectedSprite )
702- {
703- infoSelection = spr . name ;
704-
705- if ( FlxG . keys . pressed . SHIFT ) nameTxt . text = spr . name + " (LOCKED) " ;
706+ if (FlxG . mouse . justPressed && allowInput && spr . visible && ! FlxG . keys . pressed . SHIFT )
707+ {
708+ selectedSprite = spr ;
709+ }
710+ }
706711 }
712+ if (selectedSprite != null && FlxG .keys .pressed .SHIFT ) nameTxt .text = selectedSprite .name + " (LOCKED)" ;
707713 }
714+ else if (nameTxt .visible ) nameTxt .visible = false ;
708715
709716 if (FlxG .mouse .pressed && allowInput && selectedSprite != null && FlxG .mouse .overlaps (selectedSprite ) && FlxG .mouse .justMoved && ! isCursorOverHaxeUI )
710717 {
@@ -746,29 +753,26 @@ class StageEditorState extends UIState
746753 else
747754 {
748755 selectedChar .shader = null ;
749-
750- for (char in getCharacters ())
756+ if (! isCursorOverHaxeUI )
751757 {
752- if (char != selectedChar ) char .shader = charDeselectShader ;
753-
754- if (char != null && checkCharOverlaps (char )) // flxg.mouse.overlaps crashes the game
758+ if (menubarItemViewNameText .selected ) nameTxt .visible = true ;
759+ for (char in getCharacters ())
755760 {
756- if (char . visible && ! FlxG . keys . pressed . SHIFT ) nameTxt . text = Std . string ( char . characterType ) ;
761+ if (char != selectedChar ) char . shader = charDeselectShader ;
757762
758- if (FlxG . mouse . justPressed && allowInput && char . visible && ! FlxG . keys . pressed . SHIFT && ! isCursorOverHaxeUI )
763+ if (char != null && checkCharOverlaps ( char )) // flxg.mouse.overlaps crashes the game
759764 {
760- selectedChar = char ;
761- updateDialog (StageEditorDialogType .CHARACTER );
762- }
763- }
764-
765- if (selectedChar == char )
766- {
767- infoSelection = Std .string (char .characterType );
765+ if (char .visible && ! FlxG .keys .pressed .SHIFT ) nameTxt .text = Std .string (char .characterType );
768766
769- if (FlxG .keys .pressed .SHIFT ) nameTxt .text = Std .string (char .characterType ) + " (LOCKED)" ;
767+ if (FlxG .mouse .justPressed && allowInput && char .visible && ! FlxG .keys .pressed .SHIFT && ! isCursorOverHaxeUI )
768+ {
769+ selectedChar = char ;
770+ }
771+ }
770772 }
773+ if (selectedChar != null && FlxG .keys .pressed .SHIFT ) nameTxt .text = Std .string (selectedChar .characterType ) + " (LOCKED)" ;
771774 }
775+ else if (nameTxt .visible ) nameTxt .visible = false ;
772776
773777 if (FlxG .mouse .pressed && allowInput && checkCharOverlaps (selectedChar ) && FlxG .mouse .justMoved && ! isCursorOverHaxeUI )
774778 {
@@ -794,8 +798,6 @@ class StageEditorState extends UIState
794798 arrowMovement (selectedChar );
795799 updateMarkerPos ();
796800 }
797-
798- if ((selectedSprite == null && moveMode == " assets" ) || (selectedChar == null && moveMode == " chars" )) infoSelection = " None" ;
799801 bottomBarSelectText .text = infoSelection ;
800802
801803 // ui stuff
@@ -816,6 +818,20 @@ class StageEditorState extends UIState
816818 menubarItemRedo .disabled = redoArray .length == 0 ;
817819 }
818820
821+ /**
822+ * Small helper for MacOS, "WINDOWS" is keycode 15, which maps to "COMMAND" on Mac, which is more often used than "CONTROL"
823+ * Everywhere else, it just returns `FlxG.keys.pressed.CONTROL`
824+ * @return Bool
825+ */
826+ function pressingControl (): Bool
827+ {
828+ #if mac
829+ return FlxG .keys .pressed .WINDOWS ;
830+ #else
831+ return FlxG .keys .pressed .CONTROL ;
832+ #end
833+ }
834+
819835 public function getCharacters ()
820836 {
821837 return [gf , dad , bf ];
@@ -906,7 +922,7 @@ class StageEditorState extends UIState
906922 if (obj == null ) return ;
907923 if (FlxG .keys .pressed .R ) return ; // rotations
908924
909- if (allowInput )
925+ if (allowInput && welcomeDialog == null )
910926 {
911927 if ((FlxG .keys .justPressed .UP || FlxG .keys .justPressed .DOWN || FlxG .keys .justPressed .LEFT || FlxG .keys .justPressed .RIGHT )
912928 && ! moveUndoed )
@@ -1010,17 +1026,6 @@ class StageEditorState extends UIState
10101026 bg .screenCenter ();
10111027 }
10121028
1013- function checkOverlaps (spr : FlxSprite ): Bool
1014- {
1015- if (FlxG .mouse .overlaps (spr ) /* spr.overlapsPoint(FlxG.mouse.getWorldPosition(spr.camera), true, spr.camera) */
1016- && Screen .instance != null
1017- && ! Screen .instance .hasSolidComponentUnderPoint (FlxG .mouse .screenX , FlxG .mouse .screenY )
1018- && WindowManager .instance .windows .length == 0 ) // ik its stupid but maybe I have other cases soon (i did)
1019- return true ;
1020-
1021- return false ;
1022- }
1023-
10241029 var sprDependant : Array <MenuItem > = [];
10251030
10261031 function addUI (): Void
@@ -1039,13 +1044,49 @@ class StageEditorState extends UIState
10391044 menubarItemDelete .onClick = function (_ ) onMenuItemClick (" delete object" );
10401045 menubarItemNewObj .onClick = function (_ ) onMenuItemClick (" new object" );
10411046 menubarItemFindObj .onClick = function (_ ) onMenuItemClick (" find object" );
1047+ menubarItemSelectNone .onClick = function (_ ) onMenuItemClick (" select none" );
10421048 menubarButtonText .onClick = function (_ ) onMenuItemClick (" test stage" );
10431049 menubarItemUserGuide .onClick = function (_ ) onMenuItemClick (" user guide" );
10441050 menubarItemGoToBackupsFolder .onClick = function (_ ) onMenuItemClick (" open folder" );
10451051 menubarItemAbout .onClick = function (_ ) onMenuItemClick (" about" );
10461052
10471053 bottomBarModeText .onClick = function (_ ) onMenuItemClick (" switch mode" );
1048- bottomBarSelectText .onClick = function (_ ) onMenuItemClick (" switch focus" );
1054+ bottomBarModeText .onRightClick = function (_ ) onMenuItemClick (" switch mode" );
1055+
1056+ function switchFocus (rightClick : Bool = false )
1057+ if (testingMode )
1058+ {
1059+ (rightClick ) ? curTestChar -- : curTestChar ++ ;
1060+ }
1061+ else
1062+ {
1063+ if (moveMode == " chars" )
1064+ {
1065+ var chars = getCharacters ();
1066+ var index = chars .indexOf (selectedChar );
1067+ (rightClick ) ? index -- : index ++ ;
1068+
1069+ if (index >= chars .length ) index = 0 ;
1070+ else if (index < 0 ) index = chars .length - 1 ;
1071+
1072+ selectedChar = chars [index ];
1073+ }
1074+ else
1075+ {
1076+ if (selectedSprite == null || FlxG .keys .pressed .SHIFT ) return ;
1077+
1078+ var index = spriteArray .indexOf (selectedSprite );
1079+ (rightClick ) ? index -- : index ++ ;
1080+
1081+ if (index >= spriteArray .length ) index = 0 ;
1082+ else if (index < 0 ) index = spriteArray .length - 1 ;
1083+
1084+ selectedSprite = spriteArray [index ];
1085+ }
1086+ }
1087+
1088+ bottomBarSelectText .onClick = function (_ ) switchFocus ();
1089+ bottomBarSelectText .onRightClick = function (_ ) switchFocus (true );
10491090
10501091 var stepOptions = [" 1px" , " 2px" , " 3px" , " 5px" , " 10px" , " 25px" , " 50px" , " 100px" ];
10511092 bottomBarMoveStepText .text = stepOptions .contains (Save .instance .stageEditorMoveStep ) ? Save .instance .stageEditorMoveStep : " 1px" ;
@@ -1119,6 +1160,7 @@ class StageEditorState extends UIState
11191160
11201161 menubarItemViewChars .onChange = function (_ ) showChars = menubarItemViewChars .selected ;
11211162 menubarItemViewNameText .onChange = function (_ ) nameTxt .visible = menubarItemViewNameText .selected ;
1163+ menubarItemViewNameText .selected = true ; // TODO: Remove this when this haxeUI bug is fixed (it starts as false in the code)?
11221164 menubarItemViewCamBounds .onChange = function (_ ) camFields .visible = menubarItemViewCamBounds .selected ;
11231165
11241166 menubarItemViewFloorLines .onChange = function (_ ) {
@@ -1131,7 +1173,7 @@ class StageEditorState extends UIState
11311173 coolbeans .visible = menubarItemViewPosMarkers .selected ;
11321174 }
11331175
1134- sprDependant = [menubarItemCopy , menubarItemCut , menubarItemDelete ];
1176+ sprDependant = [menubarItemCopy , menubarItemCut , menubarItemDelete , menubarItemSelectNone ];
11351177 reloadRecentFiles ();
11361178 }
11371179
@@ -1289,37 +1331,9 @@ class StageEditorState extends UIState
12891331 if (testingMode ) return ;
12901332 moveMode = (moveMode == " assets" ? " chars" : " assets" );
12911333
1292- selectedSprite ?. selectedShader . setAmount (( moveMode == " assets" ? 1 : 0 )) ;
1334+ infoSelection = ( moveMode == " chars " ) ? ( Std . string ( selectedChar ?. characterType ) ?? " None " ) : ( moveMode == " assets" ) ? ( selectedSprite ?. name ?? " None " ) : " Wut " ;
12931335
1294- case " switch focus" :
1295- if (testingMode )
1296- {
1297- curTestChar ++ ;
1298- }
1299- else
1300- {
1301- if (moveMode == " chars" )
1302- {
1303- var chars = getCharacters ();
1304- var index = chars .indexOf (selectedChar );
1305- index ++ ;
1306-
1307- if (index >= chars .length ) index = 0 ;
1308-
1309- selectedChar = chars [index ];
1310- }
1311- else
1312- {
1313- if (selectedSprite == null ) return ;
1314-
1315- var index = spriteArray .indexOf (selectedSprite );
1316- index ++ ;
1317-
1318- if (index >= spriteArray .length ) index = 0 ;
1319-
1320- selectedSprite = spriteArray [index ];
1321- }
1322- }
1336+ selectedSprite ?. selectedShader .setAmount ((moveMode == " assets" ? 1 : 0 ));
13231337
13241338 case " new object" :
13251339 findObjDialog .hideDialog (DialogButton .CANCEL );
@@ -1338,6 +1352,12 @@ class StageEditorState extends UIState
13381352 findObjDialog = new FindObjDialog (this , selectedSprite == null ? " " : selectedSprite .name );
13391353 findObjDialog .showDialog (false );
13401354
1355+ case " select none" :
1356+ if (menubarItemSelectNone .disabled == false )
1357+ {
1358+ selectedSprite = null ;
1359+ }
1360+
13411361 case " about" :
13421362 aboutDialog = new AboutDialog ();
13431363 aboutDialog .showDialog ();
@@ -1371,6 +1391,8 @@ class StageEditorState extends UIState
13711391 {
13721392 menubarItemWindowObjectGraphic .selected = menubarItemWindowObjectAnims .selected = menubarItemWindowObjectProps .selected = menubarItemWindowCharacter .selected = menubarItemWindowStage .selected = false ;
13731393 }
1394+ nameTxt .exists = testingMode ;
1395+ menubarButtonText .selected = ! testingMode ;
13741396
13751397 selectedSprite ?. selectedShader .setAmount ((testingMode ? (moveMode == " assets" ? 1 : 0 ) : 0 ));
13761398 testingMode = ! testingMode ;
@@ -1415,7 +1437,6 @@ class StageEditorState extends UIState
14151437 remove (selectedSprite , true );
14161438 selectedSprite .destroy ();
14171439 selectedSprite = null ;
1418-
14191440 updateArray ();
14201441
14211442 case " copy object" :
0 commit comments