@@ -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 }
@@ -596,6 +599,7 @@ class StageEditorState extends UIState
596599 if (FlxG .keys .justPressed .TAB && ! FlxG .keys .pressed .SHIFT ) curTestChar ++ ;
597600
598601 if (curTestChar >= getCharacters ().length ) curTestChar = 0 ;
602+ else if (curTestChar < 0 ) curTestChar = getCharacters ().length - 1 ;
599603
600604 bottomBarSelectText .text = Std .string (getCharacters ()[curTestChar ].characterType );
601605
@@ -627,8 +631,7 @@ class StageEditorState extends UIState
627631 // key shortcuts and inputs
628632 if (allowInput )
629633 {
630- // "WINDOWS" key code is the same keycode as COMMAND on mac
631- if (FlxG .keys .pressed .CONTROL || FlxG .keys .pressed .WINDOWS )
634+ if (pressingControl ())
632635 {
633636 if (FlxG .keys .justPressed .Z ) onMenuItemClick (" undo" );
634637 if (FlxG .keys .justPressed .Y ) onMenuItemClick (" redo" );
@@ -637,6 +640,7 @@ class StageEditorState extends UIState
637640 if (FlxG .keys .justPressed .X ) onMenuItemClick (" cut object" );
638641 if (FlxG .keys .justPressed .S ) FlxG .keys .pressed .SHIFT ? onMenuItemClick (" save stage as" ) : onMenuItemClick (" save stage" );
639642 if (FlxG .keys .justPressed .F ) onMenuItemClick (" find object" );
643+ if (FlxG .keys .justPressed .D ) onMenuItemClick (" select none" );
640644 if (FlxG .keys .justPressed .O ) onMenuItemClick (" open stage" );
641645 if (FlxG .keys .justPressed .N ) onMenuItemClick (" new stage" );
642646 if (FlxG .keys .justPressed .Q ) onMenuItemClick (" exit" );
@@ -654,7 +658,8 @@ class StageEditorState extends UIState
654658 FlxG .camera .zoom = 1 ;
655659 }
656660
657- if (FlxG .keys .pressed .W || FlxG .keys .pressed .S || FlxG .keys .pressed .A || FlxG .keys .pressed .D )
661+ if (! pressingControl ()
662+ && (FlxG .keys .pressed .W || FlxG .keys .pressed .S || FlxG .keys .pressed .A || FlxG .keys .pressed .D ))
658663 {
659664 if (FlxG .keys .pressed .W ) camFollow .velocity .y = - 90 * (2 / FlxG .camera .zoom );
660665 else if (FlxG .keys .pressed .S ) camFollow .velocity .y = 90 * (2 / FlxG .camera .zoom );
@@ -681,30 +686,33 @@ class StageEditorState extends UIState
681686
682687 if (moveMode == " assets" )
683688 {
684- if (selectedSprite != null && ! FlxG .mouse .overlaps (selectedSprite ) && FlxG .mouse .justPressed && ! isCursorOverHaxeUI )
689+ if (selectedSprite != null
690+ && (! FlxG .mouse .overlaps (selectedSprite )
691+ || (FlxG .mouse .overlaps (selectedSprite ) && pressingControl ()))
692+ && FlxG .mouse .justPressed
693+ && ! isCursorOverHaxeUI )
685694 {
686695 selectedSprite = null ;
687696 }
688697
689- for ( spr in spriteArray )
698+ if ( ! isCursorOverHaxeUI )
690699 {
691- if (FlxG .mouse .overlaps (spr ))
700+ nameTxt .visible = true ;
701+ for (spr in spriteArray )
692702 {
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 )
703+ if (! pressingControl () && FlxG .mouse .overlaps (spr ))
696704 {
697- selectedSprite = spr ;
698- }
699- }
700-
701- if (spr == selectedSprite )
702- {
703- infoSelection = spr .name ;
705+ if (spr .visible && ! FlxG .keys .pressed .SHIFT ) nameTxt .text = spr .name ;
704706
705- if (FlxG .keys .pressed .SHIFT ) nameTxt .text = spr .name + " (LOCKED)" ;
707+ if (FlxG .mouse .justPressed && allowInput && spr .visible && ! FlxG .keys .pressed .SHIFT )
708+ {
709+ selectedSprite = spr ;
710+ }
711+ }
706712 }
713+ if (FlxG .keys .pressed .SHIFT ) nameTxt .text = selectedSprite .name + " (LOCKED)" ;
707714 }
715+ else if (nameTxt .visible ) nameTxt .visible = false ;
708716
709717 if (FlxG .mouse .pressed && allowInput && selectedSprite != null && FlxG .mouse .overlaps (selectedSprite ) && FlxG .mouse .justMoved && ! isCursorOverHaxeUI )
710718 {
@@ -746,29 +754,26 @@ class StageEditorState extends UIState
746754 else
747755 {
748756 selectedChar .shader = null ;
749-
750- for (char in getCharacters ())
757+ if (! isCursorOverHaxeUI )
751758 {
752- if (char != selectedChar ) char .shader = charDeselectShader ;
753-
754- if (char != null && checkCharOverlaps (char )) // flxg.mouse.overlaps crashes the game
759+ nameTxt .visible = true ;
760+ for (char in getCharacters ())
755761 {
756- if (char . visible && ! FlxG . keys . pressed . SHIFT ) nameTxt . text = Std . string ( char . characterType ) ;
762+ if (char != selectedChar ) char . shader = charDeselectShader ;
757763
758- if (FlxG . mouse . justPressed && allowInput && char . visible && ! FlxG . keys . pressed . SHIFT && ! isCursorOverHaxeUI )
764+ if (char != null && checkCharOverlaps ( char )) // flxg.mouse.overlaps crashes the game
759765 {
760- selectedChar = char ;
761- updateDialog (StageEditorDialogType .CHARACTER );
762- }
763- }
764-
765- if (selectedChar == char )
766- {
767- infoSelection = Std .string (char .characterType );
766+ if (char .visible && ! FlxG .keys .pressed .SHIFT ) nameTxt .text = Std .string (char .characterType );
768767
769- if (FlxG .keys .pressed .SHIFT ) nameTxt .text = Std .string (char .characterType ) + " (LOCKED)" ;
768+ if (FlxG .mouse .justPressed && allowInput && char .visible && ! FlxG .keys .pressed .SHIFT && ! isCursorOverHaxeUI )
769+ {
770+ selectedChar = char ;
771+ }
772+ }
770773 }
774+ if (FlxG .keys .pressed .SHIFT ) nameTxt .text = Std .string (selectedChar .characterType ) + " (LOCKED)" ;
771775 }
776+ else if (nameTxt .visible ) nameTxt .visible = false ;
772777
773778 if (FlxG .mouse .pressed && allowInput && checkCharOverlaps (selectedChar ) && FlxG .mouse .justMoved && ! isCursorOverHaxeUI )
774779 {
@@ -794,8 +799,6 @@ class StageEditorState extends UIState
794799 arrowMovement (selectedChar );
795800 updateMarkerPos ();
796801 }
797-
798- if ((selectedSprite == null && moveMode == " assets" ) || (selectedChar == null && moveMode == " chars" )) infoSelection = " None" ;
799802 bottomBarSelectText .text = infoSelection ;
800803
801804 // ui stuff
@@ -816,6 +819,20 @@ class StageEditorState extends UIState
816819 menubarItemRedo .disabled = redoArray .length == 0 ;
817820 }
818821
822+ /**
823+ * Small helper for MacOS, "WINDOWS" is keycode 15, which maps to "COMMAND" on Mac, which is more often used than "CONTROL"
824+ * Everywhere else, it just returns `FlxG.keys.pressed.CONTROL`
825+ * @return Bool
826+ */
827+ function pressingControl (): Bool
828+ {
829+ #if mac
830+ return FlxG .keys .pressed .WINDOWS ;
831+ #else
832+ return FlxG .keys .pressed .CONTROL ;
833+ #end
834+ }
835+
819836 public function getCharacters ()
820837 {
821838 return [gf , dad , bf ];
@@ -1010,17 +1027,6 @@ class StageEditorState extends UIState
10101027 bg .screenCenter ();
10111028 }
10121029
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-
10241030 var sprDependant : Array <MenuItem > = [];
10251031
10261032 function addUI (): Void
@@ -1039,13 +1045,49 @@ class StageEditorState extends UIState
10391045 menubarItemDelete .onClick = function (_ ) onMenuItemClick (" delete object" );
10401046 menubarItemNewObj .onClick = function (_ ) onMenuItemClick (" new object" );
10411047 menubarItemFindObj .onClick = function (_ ) onMenuItemClick (" find object" );
1048+ menubarItemSelectNone .onClick = function (_ ) onMenuItemClick (" select none" );
10421049 menubarButtonText .onClick = function (_ ) onMenuItemClick (" test stage" );
10431050 menubarItemUserGuide .onClick = function (_ ) onMenuItemClick (" user guide" );
10441051 menubarItemGoToBackupsFolder .onClick = function (_ ) onMenuItemClick (" open folder" );
10451052 menubarItemAbout .onClick = function (_ ) onMenuItemClick (" about" );
10461053
10471054 bottomBarModeText .onClick = function (_ ) onMenuItemClick (" switch mode" );
1048- bottomBarSelectText .onClick = function (_ ) onMenuItemClick (" switch focus" );
1055+ bottomBarModeText .onRightClick = function (_ ) onMenuItemClick (" switch mode" );
1056+
1057+ function switchFocus (rightClick : Bool = false )
1058+ if (testingMode )
1059+ {
1060+ (rightClick ) ? curTestChar -- : curTestChar ++ ;
1061+ }
1062+ else
1063+ {
1064+ if (moveMode == " chars" )
1065+ {
1066+ var chars = getCharacters ();
1067+ var index = chars .indexOf (selectedChar );
1068+ (rightClick ) ? index -- : index ++ ;
1069+
1070+ if (index >= chars .length ) index = 0 ;
1071+ else if (index < 0 ) index = chars .length - 1 ;
1072+
1073+ selectedChar = chars [index ];
1074+ }
1075+ else
1076+ {
1077+ if (selectedSprite == null ) return ;
1078+
1079+ var index = spriteArray .indexOf (selectedSprite );
1080+ (rightClick ) ? index -- : index ++ ;
1081+
1082+ if (index >= spriteArray .length ) index = 0 ;
1083+ else if (index < 0 ) index = spriteArray .length - 1 ;
1084+
1085+ selectedSprite = spriteArray [index ];
1086+ }
1087+ }
1088+
1089+ bottomBarSelectText .onClick = function (_ ) switchFocus ();
1090+ bottomBarSelectText .onRightClick = function (_ ) switchFocus (true );
10491091
10501092 var stepOptions = [" 1px" , " 2px" , " 3px" , " 5px" , " 10px" , " 25px" , " 50px" , " 100px" ];
10511093 bottomBarMoveStepText .text = stepOptions .contains (Save .instance .stageEditorMoveStep ) ? Save .instance .stageEditorMoveStep : " 1px" ;
@@ -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 ();
@@ -1415,7 +1435,6 @@ class StageEditorState extends UIState
14151435 remove (selectedSprite , true );
14161436 selectedSprite .destroy ();
14171437 selectedSprite = null ;
1418-
14191438 updateArray ();
14201439
14211440 case " copy object" :
0 commit comments