Skip to content

Commit a36c71e

Browse files
committed
feat: allow deselecting selected layer by clicking 'select all' button
Fixes #476
1 parent 05d76c7 commit a36c71e

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

scripts/control_create/control_create.gml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ function control_create() {
307307
dragvol = 0
308308
dragstereob = 0
309309
dragstereo = 0
310+
selected_layers = ds_list_create()
310311

311312
// Piano
312313
show_piano = 1

scripts/control_draw/control_draw.gml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,11 +1398,18 @@ function control_draw() {
13981398
// Select all
13991399
if (draw_layericon(2, x1 + 162 - !realvolume-realstereo * 10, y1 + 8, condstr(language != 1, "Select all note blocks in this layer\n(Hold Ctrl to select multiple layers)", "选择本层所有方块\n(按住Ctrl选择多层)"), 0, 0)) {
14001400
playing = 0
1401-
if (!keyboard_check(vk_control)) {
1402-
selection_place(0)
1401+
1402+
// TODO: replace with array_contains() if we ever upgrade GameMaker...
1403+
var layer_id = startb + b
1404+
var layer_selected = ds_list_find_index(selected_layers, layer_id) > -1
1405+
if (layer_selected) {
1406+
selection_remove(0, startb + b, enda, startb + b, 0, 0)
1407+
ds_list_delete_value(selected_layers, layer_id)
1408+
} else {
1409+
selection_add(0, startb + b, enda, startb + b, 0, 0)
1410+
ds_list_add(selected_layers, layer_id)
14031411
}
1404-
selection_add(0, startb + b, enda, startb + b, 0, 0)
1405-
}
1412+
}
14061413
// Add layer
14071414
if (draw_layericon(3, x1 + 180 - !realvolume-realstereo * 10, y1 + 8, condstr(language != 1, "Add empty layer here", "新建层"), 0, 0)) {
14081415
playing = 0

scripts/selection_code_update/selection_code_update.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function selection_code_update() {
33
// Updates the selection code
44
var a, b, ca, cb;
55

6-
if (selected = 0) return 0
6+
if (selected = 0) ds_list_clear(selected_layers) return 0
77
ca = 0
88

99
var _selection_l = selection_l

scripts/selection_place/selection_place.gml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
function selection_place(argument0) {
22
// selection_place(undo)
33
// Releases the selection.
4+
ds_list_clear(selected_layers)
45
if (selected = 0) return 0
56
selection_remove(0, 0, 0, 0, 1, argument0)
67

0 commit comments

Comments
 (0)