Skip to content

Commit

Permalink
Add and remove units from the selection with shift. #81
Browse files Browse the repository at this point in the history
  • Loading branch information
williamsokol authored and Scony committed Dec 12, 2023
1 parent f0c7d78 commit a69238d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ move_map_right={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
]
}
shift_selecting={
"deadzone": 0.5,
"events": [null, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}

[internationalization]

Expand Down
2 changes: 2 additions & 0 deletions source/match/Match.gd
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func _ready():

func _unhandled_input(event):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
if(Input.is_action_pressed("shift_selecting")):
return
MatchSignals.deselect_all_units.emit()


Expand Down
2 changes: 1 addition & 1 deletion source/match/handlers/SelectionHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func _get_controlled_units_from_navigation_domain_within_topdown_polygon_2d(


func _select_units(units_to_select):
if not units_to_select.empty():
if not units_to_select.empty() && not Input.is_action_pressed("shift_selecting"):
MatchSignals.deselect_all_units.emit()
for unit in units_to_select.iterate():
var selection = unit.find_child("Selection")
Expand Down
3 changes: 3 additions & 0 deletions source/match/units/traits/Selection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@ func _update_circle_params():

func _on_input_event(_camera, event, _click_position, _click_normal, _shape_idx):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
if(_selected and Input.is_action_pressed("shift_selecting")):
deselect()
return
select()

0 comments on commit a69238d

Please sign in to comment.