Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
deepnight committed May 6, 2024
1 parent 9f84e4d commit 02473e9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/game/ui/UiGroupController.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@ enum abstract GroupDir(Int) {
var West;
}


/**
This process takes care of interactions with a group of UiComponents.
This includes:
- focus/blur on a component,
- user interaction with a component,
- supports gamepad, keyboard and mouse.
USAGE:
- Add some UiComponents to your scene,
- Create a UiGroupController instance,
- Register the UiComponents in the UiGroupController.
**/
class UiGroupController extends dn.Process {
var uid : Int;
var ca : ControllerAccess<GameAction>;
var currentComp : Null<UiComponent>;
public var currentComp(default,null) : Null<UiComponent>;

var components : Array<UiComponent> = [];

Expand Down Expand Up @@ -305,6 +316,12 @@ class UiGroupController extends dn.Process {
currentComp = null;
}

public function clearAllRegisteredComponents() {
currentComp = null;
components = [];
invalidateConnections();
}

function focusClosestComponentFromGlobalCoord(x:Float, y:Float) {
var best = Lib.findBestInArray(components, e->{
return -M.dist(x, y, e.globalCenterX, e.globalCenterY);
Expand Down

0 comments on commit 02473e9

Please sign in to comment.