Skip to content

Improve note selections and macro operations #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Minecraft Note Block Studio.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion objects/obj_controller/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
script_execute(control_create,0,0,0,0,0);
control_create();
2 changes: 1 addition & 1 deletion objects/obj_controller/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
script_execute(control_draw,0,0,0,0,0);
control_draw();
2 changes: 1 addition & 1 deletion objects/obj_controller/Other_3.gml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
script_execute(control_end,0,0,0,0,0);
control_end();
2 changes: 1 addition & 1 deletion objects/obj_controller/Other_62.gml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
script_execute(control_http,0,0,0,0,0);
control_http();
2 changes: 1 addition & 1 deletion objects/obj_controller/Step_0.gml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
script_execute(control_step,0,0,0,0,0);
control_step();
1 change: 1 addition & 0 deletions objects/obj_controller/obj_controller.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 52 additions & 30 deletions scripts/action_redo/action_redo.gml
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,57 @@ function action_redo() {
arg14 = history[historypos, 15]
changed = 1

if (t = h_addblock) {
add_block(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
} else if (t = h_removeblock) {
remove_block(arg0, arg1)
} else if (t = h_changeblock) {
change_block(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
} else if (t = h_selectadd) {
selection_add(arg0, arg1, arg2 - 1, arg3 - 1, arg4, 1)
} else if (t = h_selectremove) {
selection_remove(arg0, arg1, arg2, arg3, 0, 1)
} else if (t = h_selectchange) {
selection_delete(1)
selection_load(arg0, arg1, arg2, 1)
} else if (t = h_selectmove) {
selection_x = arg0
selection_y = arg1
} else if (t = h_selectpaste) {
selection_load(arg0, arg1, arg2, 1)
} else if (t = h_select) {
selection_place(1)
selection_load_ext(arg0, arg1, arg2)
} else if (t = h_addlayer) {
add_layer(arg0, true, arg1, arg2, arg3, arg4, arg5, arg6)
} else if (t = h_removelayer) {
remove_layer(arg0, true)
} else if (t = h_swaplayer) {
shift_layers(arg0, arg1, true)
switch (t) {
case h_addblock: {
add_block(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
break
}
case h_removeblock: {
remove_block(arg0, arg1)
break
}
case h_changeblock: {
change_block(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
break
}
case h_selectadd: {
selection_add(arg0, arg1, arg2 - 1, arg3 - 1, arg4, 1)
break
}
case h_selectremove: {
selection_remove(arg0, arg1, arg2, arg3, 0, 1)
break
}
case h_selectchange: {
selection_delete(1)
selection_load(arg0, arg1, arg2, 1)
break
}
case h_selectmove: {
selection_x = arg0
selection_y = arg1
break
}
case h_selectpaste: {
selection_load(arg0, arg1, arg2, 1)
break
}
case h_select: {
selection_place(1)
selection_load_ext(arg0, arg1, arg2)
break
}
case h_addlayer: {
add_layer(arg0, true, arg1, arg2, arg3, arg4, arg5, arg6)
break
}
case h_removelayer: {
remove_layer(arg0, true)
break
}
case h_swaplayer: {
shift_layers(arg0, arg1, true)
break
}
}



}
94 changes: 59 additions & 35 deletions scripts/action_undo/action_undo.gml
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,64 @@ function action_undo() {
arg14 = history[historypos, 15]
historypos += 1
changed = 1
if (t = h_addblock) {
remove_block(arg0, arg1)
} else if (t = h_removeblock) {
add_block(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
} else if (t = h_changeblock) {
change_block(arg0, arg1, arg7, arg8, arg9, arg10, arg11)
} else if (t = h_selectadd) {
selection_remove(arg0, arg1, arg2, arg3, 0, 1)
} else if (t = h_selectremove) {
selection_add(arg0, arg1, arg2 - 1, arg3 - 1, 0, 1)
selection_delete(1)
selection_load(arg4, arg5, arg6, true)
region_code_load(arg0, arg1, arg7)
} else if (t = h_selectchange) {
selection_delete(1)
selection_load(arg3, arg4, arg5, 1)
} else if (t = h_selectmove) {
selection_x = arg2
selection_y = arg3
} else if (t = h_selectpaste) {
selection_delete(1)
} else if (t = h_select) {
selection_place(1)
selection_load_ext(arg3, arg4, arg5)
} else if (t = h_addlayer) {
remove_layer(arg0, true)
} else if (t = h_removelayer) {
add_layer(arg0, true, arg1, arg2, arg3, arg4, arg5, arg6)
} else if (t = h_swaplayer) {
shift_layers(arg1, arg0, true)
} else if (t = h_stereoize) {
selection_load(arg0, arg1, arg2, true)
switch (t) {
case h_addblock: {
remove_block(arg0, arg1)
break
}
case h_removeblock: {
add_block(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
break
}
case h_changeblock: {
change_block(arg0, arg1, arg7, arg8, arg9, arg10, arg11)
break
}
case h_selectadd: {
selection_remove(arg0, arg1, arg2, arg3, 0, 1)
break
}
case h_selectremove: {
selection_add(arg0, arg1, arg2 - 1, arg3 - 1, 0, 1)
selection_delete(1)
selection_load(arg4, arg5, arg6, true)
region_code_load(arg0, arg1, arg7)
break
}
case h_selectchange: {
selection_delete(1)
selection_load(arg3, arg4, arg5, 1)
break
}
case h_selectmove: {
selection_x = arg2
selection_y = arg3
break
}
case h_selectpaste: {
selection_delete(1)
break
}
case h_select: {
selection_place(1)
selection_load_ext(arg3, arg4, arg5)
break
}
case h_addlayer: {
remove_layer(arg0, true)
break
}
case h_removelayer: {
add_layer(arg0, true, arg1, arg2, arg3, arg4, arg5, arg6)
break
}
case h_swaplayer: {
shift_layers(arg1, arg0, true)
break
}
case h_stereoize: {
selection_load(arg0, arg1, arg2, true)
break
}
}



}
44 changes: 22 additions & 22 deletions scripts/add_block/add_block.gml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ function add_block() {

// Initialize cells
if (xx >= arraylength) {
for (a = arraylength; a <= xx; a += 1) {
colfirst[a] = -1
collast[a] = -1
colamount[a] = 0
for (b = 0; b < max(yy + 1, arrayheight); b += 1) song_exists[a, b] = 0
}
arraylength = xx + 1
for (a = xx; a >= arraylength; --a) {
colfirst[@ a] = -1
collast[@ a] = -1
colamount[@ a] = 0
for (b = max(yy + 1, arrayheight) - 1; b >= 0; --b) song_exists[@ a, b] = 0
}
arraylength = xx + 1
}
if (yy >= arrayheight) {
for (a = 0; a < arraylength; a += 1) {
for (b = arrayheight; b <= yy ;b += 1) {
rowamount[b] = 0
song_exists[a, b] = 0
for (a = arraylength - 1; a >= 0; --a) {
for (b = yy; b >= arrayheight; --b) {
rowamount[@ b] = 0
song_exists[@ a, b] = 0
}
}
arrayheight = yy + 1
Expand All @@ -37,16 +37,16 @@ function add_block() {
if (song_exists[xx, yy]) return 0

// Add block
song_exists[xx, yy] = 1
song_ins[xx, yy] = ins
song_key[xx, yy] = key
song_vel[xx, yy] = vel
song_pan[xx, yy] = pan
song_pit[xx, yy] = pit
song_played[xx, yy] = 0
song_added[xx, yy] = 0
colamount[xx] += 1
rowamount[yy] += 1
song_exists[@ xx, yy] = 1
song_ins[@ xx, yy] = ins
song_key[@ xx, yy] = key
song_vel[@ xx, yy] = vel
song_pan[@ xx, yy] = pan
song_pit[@ xx, yy] = pit
song_played[@xx, yy] = 0
song_added[@ xx, yy] = 0
colamount[@ xx] += 1
rowamount[@ yy] += 1
if (!insnum) {
ins.num_blocks++
if (ins.user) block_custom += 1
Expand All @@ -56,7 +56,7 @@ function add_block() {
totalblocks += 1

if (colfirst[xx] = -1 || yy < colfirst[xx]) colfirst[xx] = yy
if (yy > collast[xx]) collast[xx] = yy
if (yy > collast[xx]) collast[@ xx] = yy

if (xx >= enda) enda = xx
if (yy >= endb) endb = yy
Expand Down
22 changes: 11 additions & 11 deletions scripts/add_block_select/add_block_select.gml
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ function add_block_select(argument0, argument1, argument2, argument3, argument4,

// Add block
song_exists[xx, yy] = 1
song_ins[xx, yy] = ins
song_key[xx, yy] = key
song_vel[xx, yy] = vel
song_pan[xx, yy] = pan
song_pit[xx, yy] = pit
song_played[xx, yy] = 0
song_added[xx, yy] = 0
colamount[xx] += 1
rowamount[yy] += 1
song_ins[@ xx, yy] = ins
song_key[@ xx, yy] = key
song_vel[@ xx, yy] = vel
song_pan[@ xx, yy] = pan
song_pit[@ xx, yy] = pit
song_played[@ xx, yy] = 0
song_added[@ xx, yy] = 0
colamount[@ xx] += 1
rowamount[@ yy] += 1
ins.num_blocks++
if (key < 33 || key > 57) block_outside += 1
if (ins.user) block_custom += 1
if (pit != 0) block_pitched += 1
totalblocks += 1

if (colfirst[xx] = -1 || yy < colfirst[xx]) colfirst[xx] = yy
if (yy > collast[xx]) collast[xx] = yy
if (colfirst[xx] = -1 || yy < colfirst[xx]) colfirst[@ xx] = yy
if (yy > collast[xx]) collast[@ xx] = yy

if (xx >= enda) enda = xx
if (yy >= endb) endb = yy
Expand Down
15 changes: 15 additions & 0 deletions scripts/array_grow_then_set/array_grow_then_set.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function array_grow_then_set(array, index, value) {
// Set a value at the index of the array; also allows custom growth of the array

var length = array_length(array)
if (index >= length) {
var new_size = index + 1
var new_length = new_size * 3 / 2; // 1.5x growth factor
//var new_length = (new_size + (new_size >> 3) + 6) & ~3; // Python-style growth
//show_debug_message(string(length) + " -> " + string(floor(new_length)))
for (var i = new_length - 1; i >= length; --i) {
array[@ i] = 0
}
}
array[@ index] = value
}
Loading