File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ class ConsoleCommands
6464 console .registerClass (FlxCamera );
6565
6666 console .registerObject (" FlxDebuggerLayout" , FlxDebuggerLayout );
67+ console .registerObject (" selection" , null );
6768 }
6869
6970 private function help (? Alias : String ): String
Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ class Pointer extends Tool
104104 _selectionCancelled = false ;
105105 _selectionStartPoint .set (_brain .flixelPointer .x , _brain .flixelPointer .y );
106106 _itemsInSelectionArea .clearArray ();
107+ updateConsoleSelection ();
107108 }
108109
109110 /**
@@ -134,12 +135,28 @@ class Pointer extends Tool
134135 calculateSelectionArea ();
135136
136137 if (findItems )
138+ {
137139 _brain .findItemsWithinState (_itemsInSelectionArea , FlxG .state , _selectionArea );
140+ updateConsoleSelection ();
141+ }
138142
139143 // Clear everything
140144 _selectionHappening = false ;
141145 _selectionArea .set (0 , 0 , 0 , 0 );
142146 }
147+
148+ /**
149+ * We register the current selection to the console for easy interaction.
150+ */
151+ private function updateConsoleSelection ()
152+ {
153+ FlxG .console .registerObject (" selection" , switch (_itemsInSelectionArea .length )
154+ {
155+ case 0 : null ;
156+ case 1 : _itemsInSelectionArea [0 ];
157+ case _ : _itemsInSelectionArea ;
158+ });
159+ }
143160
144161 private function handleItemAddition (itemsInSelectionArea : Array <FlxBasic >): Void
145162 {
You can’t perform that action at this time.
0 commit comments