Skip to content

Commit

Permalink
Pointer: register selected items to the console
Browse files Browse the repository at this point in the history
This allows easily manipulation of what's currently selected via the console.
  • Loading branch information
Gama11 committed Mar 15, 2017
1 parent f52c73e commit 1bb7b48
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions flixel/system/debug/console/ConsoleCommands.hx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ConsoleCommands
console.registerClass(FlxCamera);

console.registerObject("FlxDebuggerLayout", FlxDebuggerLayout);
console.registerObject("selection", null);
}

private function help(?Alias:String):String
Expand Down
17 changes: 17 additions & 0 deletions flixel/system/debug/interaction/tools/Pointer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class Pointer extends Tool
_selectionCancelled = false;
_selectionStartPoint.set(_brain.flixelPointer.x, _brain.flixelPointer.y);
_itemsInSelectionArea.clearArray();
updateConsoleSelection();
}

/**
Expand Down Expand Up @@ -134,12 +135,28 @@ class Pointer extends Tool
calculateSelectionArea();

if (findItems)
{
_brain.findItemsWithinState(_itemsInSelectionArea, FlxG.state, _selectionArea);
updateConsoleSelection();
}

// Clear everything
_selectionHappening = false;
_selectionArea.set(0, 0, 0, 0);
}

/**
* We register the current selection to the console for easy interaction.
*/
private function updateConsoleSelection()
{
FlxG.console.registerObject("selection", switch(_itemsInSelectionArea.length)
{
case 0: null;
case 1: _itemsInSelectionArea[0];
case _: _itemsInSelectionArea;
});
}

private function handleItemAddition(itemsInSelectionArea:Array<FlxBasic>):Void
{
Expand Down

0 comments on commit 1bb7b48

Please sign in to comment.