diff --git a/Minecraft Note Block Studio.yyp b/Minecraft Note Block Studio.yyp index 2d91c96a..6e8185d8 100644 --- a/Minecraft Note Block Studio.yyp +++ b/Minecraft Note Block Studio.yyp @@ -7430,4 +7430,5 @@ "MetaData": { "IDEVersion": "2022.0.3.85", }, + {"id":{"name":"selection_flip","path":"scripts/selection_flip/selection_flip.yy",},"order":39,}, } \ No newline at end of file diff --git a/scripts/control_draw/control_draw.gml b/scripts/control_draw/control_draw.gml index b22193b1..57fac985 100644 --- a/scripts/control_draw/control_draw.gml +++ b/scripts/control_draw/control_draw.gml @@ -533,6 +533,8 @@ function control_draw() { inactive(current_song.selected = 0 && current_song.totalblocks = 0) + get_hotkey("invert_selection") + "$Invert selection|-|"+ inactive(current_song.totalblocks = 0 || selbx >= current_song.enda) + "Select all to the right ->|"+ inactive(current_song.totalblocks = 0 || selbx <= 0) + "Select all to the left <-|-|"+ + inactive(current_song.selection_l < 2) + "Flip selection horizontally|"+ + inactive(current_song.selection_h < 2) + "Flip selection vertically|-|"+ inactive(current_song.instrument.num_blocks = 0) + "Select all " + clean(current_song.instrument.name) + "|"+ inactive(current_song.instrument.num_blocks = current_song.totalblocks) + "Select all but " + clean(current_song.instrument.name) + "|-|"+ inactive(current_song.selected = 0) + get_hotkey("action_1") + "$" + get_mode_actions(1) + "|"+ @@ -571,6 +573,8 @@ function control_draw() { inactive(current_song.selected = 0 && current_song.totalblocks = 0) + get_hotkey("invert_selection") + "$选择反转|-|"+ inactive(current_song.totalblocks = 0 || selbx >= current_song.enda) + "选择右侧所有 ->|"+ inactive(current_song.totalblocks = 0 || selbx <= 0) + "选择左侧所有 <-|-|"+ + inactive(current_song.selection_l < 2) + "Flip selection horizontally (TRANSLATION_NEEDED)|"+ + inactive(current_song.selection_h < 2) + "Flip selection vertically (TRANSLATION_NEEDED)|-|"+ inactive(current_song.instrument.num_blocks = 0) + "选择所有 " + clean(current_song.instrument.name) + "|"+ inactive(current_song.instrument.num_blocks = current_song.totalblocks) + "选择所有除了 " + clean(current_song.instrument.name) + "|-|"+ inactive(current_song.selected = 0) + get_hotkey("action_1") + "$" + get_mode_actions(1) + "|"+ @@ -637,6 +641,13 @@ function control_draw() { window_scale = get_default_window_scale() set_msg(condstr(language = 1, "窗口缩放", "Window scale") + " => " + string(window_scale * 100) + "%") } + + // ASK FOR CHANGES BEFORE FLIGHT! + if (keyboard_check_pressed(ord("J"))) + selection_flip(true) + if (keyboard_check_pressed(ord("H"))) + selection_flip(false) + if ((os_type != os_macosx && keyboard_check_pressed(187)) || (os_type = os_macosx && keyboard_check_pressed(24)) || (mouse_wheel_up_dynamic())) { if (window_scale >= 0.5 && window_scale < 0.67) {window_scale = 0.67} else if (window_scale < 0.75) {window_scale = 0.75} @@ -1747,6 +1758,8 @@ function control_draw() { inactive(current_song.totalblocks = 0) + get_hotkey("select_all") + "$Select all|"+ inactive(current_song.selected = 0) + "Deselect all|"+ inactive(current_song.selected = 0 && current_song.totalblocks = 0) + get_hotkey("invert_selection") + "$Invert selection|-|"+ + inactive(current_song.selection_l < 2) + "Flip selection horizontally|"+ + inactive(current_song.selection_h < 2) + "Flip selection vertically|-|"+ inactive(current_song.instrument.num_blocks = 0) + "Select all " + clean(current_song.instrument.name) + "|"+ inactive(current_song.instrument.num_blocks = current_song.totalblocks) + "Select all but " + clean(current_song.instrument.name) + "|-|"+ inactive(current_song.selected = 0) + get_hotkey("action_1") + "$" + get_mode_actions(1) + "|"+ @@ -1842,6 +1855,8 @@ function control_draw() { inactive(current_song.totalblocks = 0) + get_hotkey("select_all") + "$全选|"+ inactive(current_song.selected = 0) + "全不选|"+ inactive(current_song.selected = 0 && current_song.totalblocks = 0) + get_hotkey("invert_selection") + "$选择反转|-|"+ + inactive(current_song.selection_l < 2) + "Flip selection horizontally (TRANSLATION_NEEDED)|"+ + inactive(current_song.selection_h < 2) + "Flip selection vertically (TRANSLATION_NEEDED)|-|"+ inactive(current_song.instrument.num_blocks = 0) + "选择所有 " + clean(current_song.instrument.name) + "|"+ inactive(current_song.instrument.num_blocks = current_song.totalblocks) + "选择所有除了 " + clean(current_song.instrument.name) + "|-|"+ inactive(current_song.selected = 0) + get_hotkey("action_1") + "$" + get_mode_actions(1) + "|"+ diff --git a/scripts/menu_click/menu_click.gml b/scripts/menu_click/menu_click.gml index 665fd61e..9354fdfe 100644 --- a/scripts/menu_click/menu_click.gml +++ b/scripts/menu_click/menu_click.gml @@ -68,11 +68,11 @@ function menu_click(argument0) { break } case "edit": { - if ((editmode = m_key) && (sel >= 15)) { + if ((editmode = m_key) && (sel >= 17)) { sel += 2 } var insoffset = ds_list_size(songs[song].instrument_list) + insmenu - 1 - var ins = sel - 18 + var ins = sel - 20 ins -= floor(ins / 26) // subtract the "More..." entries to get the instrument number if (sel = 0) action_undo() if (sel = 1) action_redo() @@ -98,44 +98,46 @@ function menu_click(argument0) { if (sel = 6) select_all(-1, 0) if (sel = 7) selection_place(0) if (sel = 8) selection_invert() - if (sel = 9) select_all(songs[song].instrument, 0) - if (sel = 10) select_all(songs[song].instrument, 1) - if (sel = 11) mode_action(1) - if (sel = 12) mode_action(2) - if (sel = 13) mode_action(3) - if (sel = 14) mode_action(4) - if (sel = 15 && editmode != m_key) mode_action(5) - if (sel = 16 && editmode != m_key) mode_action(6) - if (sel > 17 && sel < 18 + insoffset) selection_changeins(songs[song].instrument_list[| ins]) - if (sel = 18 + insoffset) selection_expand() - if (sel = 19 + insoffset) selection_compress() - if (sel = 21 + insoffset) window = w_tremolo - if (sel = 22 + insoffset) window = w_stereo - if (sel = 23 + insoffset) window = w_arpeggio - if (sel = 24 + insoffset) window = w_portamento - if (sel = 25 + insoffset) macro_vibrato() - if (sel = 26 + insoffset) window = w_stagger - if (sel = 27 + insoffset) macro_chorus() - if (sel = 28 + insoffset) macro_velocitylfo() - if (sel = 29 + insoffset) macro_fadein() - if (sel = 30 + insoffset) macro_fadeout() - if (sel = 31 + insoffset) macro_replacekey() - if (sel = 32 + insoffset) window = w_setvelocity - if (sel = 33 + insoffset) window = w_setpanning - if (sel = 34 + insoffset) window = w_setpitch - if (sel = 35 + insoffset) macro_reset() - if (sel = 36 + insoffset) { + if (sel = 9) selection_flip(0) + if (sel = 10) selection_flip(1) + if (sel = 11) select_all(songs[song].instrument, 0) + if (sel = 12) select_all(songs[song].instrument, 1) + if (sel = 13) mode_action(1) + if (sel = 14) mode_action(2) + if (sel = 15) mode_action(3) + if (sel = 16) mode_action(4) + if (sel = 17 && editmode != m_key) mode_action(5) + if (sel = 18 && editmode != m_key) mode_action(6) + if (sel > 19 && sel < 20 + insoffset) selection_changeins(songs[song].instrument_list[| ins]) + if (sel = 20 + insoffset) selection_expand() + if (sel = 21 + insoffset) selection_compress() + if (sel = 23 + insoffset) window = w_tremolo + if (sel = 24 + insoffset) window = w_stereo + if (sel = 25 + insoffset) window = w_arpeggio + if (sel = 26 + insoffset) window = w_portamento + if (sel = 27 + insoffset) macro_vibrato() + if (sel = 28 + insoffset) window = w_stagger + if (sel = 29 + insoffset) macro_chorus() + if (sel = 30 + insoffset) macro_velocitylfo() + if (sel = 31 + insoffset) macro_fadein() + if (sel = 32 + insoffset) macro_fadeout() + if (sel = 33 + insoffset) macro_replacekey() + if (sel = 34 + insoffset) window = w_setvelocity + if (sel = 35 + insoffset) window = w_setpanning + if (sel = 36 + insoffset) window = w_setpitch + if (sel = 37 + insoffset) macro_reset() + if (sel = 38 + insoffset) { if (language != 1) {if (question("Transpose selected notes so that they fall within Minecraft's 2 octaves?", "Transpose notes")) selection_transpose()} else {if (question("转换音符使其在 Minecraft 的 2 八度以内吗?", "转换音符")) selection_transpose()} } break } case "editext": { - if ((editmode = m_key) && (sel >= 15)) { + if ((editmode = m_key) && (sel >= 17)) { sel += 2 } var insoffset = ds_list_size(songs[song].instrument_list) + insmenu - 1 - var ins = sel - 18 + var ins = sel - 20 ins -= floor((ins) / 26) // subtract the "More..." entries to get the instrument number if (sel = 0) action_copy() if (sel = 1) action_cut() @@ -152,33 +154,35 @@ function menu_click(argument0) { selection_place(0) selection_add(0, 0, obj_menu.menuc, songs[song].endb, 0, 0) } - if (sel = 9) select_all(songs[song].instrument, 0) - if (sel = 10) select_all(songs[song].instrument, 1) - if (sel = 11) mode_action(1) - if (sel = 12) mode_action(2) - if (sel = 13) mode_action(3) - if (sel = 14) mode_action(4) - if (sel = 15 && editmode != m_key) mode_action(5) - if (sel = 16 && editmode != m_key) mode_action(6) - if (sel > 17 && sel < 18 + insoffset) selection_changeins(songs[song].instrument_list[| ins]) - if (sel = 18 + insoffset) selection_expand() - if (sel = 19 + insoffset) selection_compress() - if (sel = 21 + insoffset) window = w_tremolo - if (sel = 22 + insoffset) window = w_stereo - if (sel = 23 + insoffset) window = w_arpeggio - if (sel = 24 + insoffset) window = w_portamento - if (sel = 25 + insoffset) macro_vibrato() - if (sel = 26 + insoffset) window = w_stagger - if (sel = 27 + insoffset) macro_chorus() - if (sel = 28 + insoffset) macro_velocitylfo() - if (sel = 29 + insoffset) macro_fadein() - if (sel = 30 + insoffset) macro_fadeout() - if (sel = 31 + insoffset) macro_replacekey() - if (sel = 32 + insoffset) window = w_setvelocity - if (sel = 33 + insoffset) window = w_setpanning - if (sel = 34 + insoffset) window = w_setpitch - if (sel = 35 + insoffset) macro_reset() - if (sel = 36 + insoffset) { + if (sel = 9) selection_flip(0) + if (sel = 10) selection_flip(1) + if (sel = 11) select_all(songs[song].instrument, 0) + if (sel = 12) select_all(songs[song].instrument, 1) + if (sel = 13) mode_action(1) + if (sel = 14) mode_action(2) + if (sel = 15) mode_action(3) + if (sel = 16) mode_action(4) + if (sel = 17 && editmode != m_key) mode_action(5) + if (sel = 18 && editmode != m_key) mode_action(6) + if (sel > 19 && sel < 20 + insoffset) selection_changeins(songs[song].instrument_list[| ins]) + if (sel = 20 + insoffset) selection_expand() + if (sel = 21 + insoffset) selection_compress() + if (sel = 23 + insoffset) window = w_tremolo + if (sel = 24 + insoffset) window = w_stereo + if (sel = 25 + insoffset) window = w_arpeggio + if (sel = 26 + insoffset) window = w_portamento + if (sel = 27 + insoffset) macro_vibrato() + if (sel = 28 + insoffset) window = w_stagger + if (sel = 29 + insoffset) macro_chorus() + if (sel = 30 + insoffset) macro_velocitylfo() + if (sel = 31 + insoffset) macro_fadein() + if (sel = 32 + insoffset) macro_fadeout() + if (sel = 33 + insoffset) macro_replacekey() + if (sel = 34 + insoffset) window = w_setvelocity + if (sel = 35 + insoffset) window = w_setpanning + if (sel = 36 + insoffset) window = w_setpitch + if (sel = 37 + insoffset) macro_reset() + if (sel = 38 + insoffset) { if (language != 1) {if (question("Transpose selected notes so that they fall within Minecraft's 2 octaves?", "Transpose notes")) selection_transpose()} else {if (question("转换音符使其在 Minecraft 的 2 八度以内吗?", "转换音符")) selection_transpose()} } diff --git a/scripts/menu_macos_init/menu_macos_init.gml b/scripts/menu_macos_init/menu_macos_init.gml index c6be208b..ec1f7e39 100644 --- a/scripts/menu_macos_init/menu_macos_init.gml +++ b/scripts/menu_macos_init/menu_macos_init.gml @@ -54,6 +54,8 @@ function menu_macos_init(){ inactive(current_song.totalblocks = 0) + get_hotkey_menubar("select_all") + "$Select all|"+ inactive(current_song.selected = 0) + "Deselect all|"+ inactive(current_song.selected = 0 && current_song.totalblocks = 0) + get_hotkey_menubar("invert_selection") + "$Invert selection|-|"+ + inactive(current_song.selection_l < 2) + "Flip selection horizontally|"+ + inactive(current_song.selection_h < 2) + "Flip selection vertically|-|"+ inactive(current_song.instrument.num_blocks = 0) + "Select all " + clean(current_song.instrument.name) + "|"+ inactive(current_song.instrument.num_blocks = current_song.totalblocks) + "Select all but " + clean(current_song.instrument.name) + "|-|"+ inactive(current_song.selected = 0) + get_hotkey_menubar("action_1") + "$" + get_mode_actions(1) + "|"+ @@ -158,6 +160,8 @@ function menu_macos_init(){ inactive(current_song.totalblocks = 0) + get_hotkey_menubar("select_all") + "$全选|"+ inactive(current_song.selected = 0) + "全不选|"+ inactive(current_song.selected = 0 && current_song.totalblocks = 0) + get_hotkey_menubar("invert_selection") + "$选择反转|-|"+ + inactive(current_song.selection_l < 2) + "Flip selection horizontally (TRANSLATION_NEEDED)|"+ + inactive(current_song.selection_h < 2) + "Flip selection vertically (TRANSLATION_NEEDED)|-|"+ inactive(current_song.instrument.num_blocks = 0) + "选择所有 " + clean(current_song.instrument.name) + "|"+ inactive(current_song.instrument.num_blocks = current_song.totalblocks) + "选择所有除了 " + clean(current_song.instrument.name) + "|-|"+ inactive(current_song.selected = 0) + get_hotkey_menubar("action_1") + "$" + get_mode_actions(1) + "|"+ diff --git a/scripts/selection_flip/selection_flip.gml b/scripts/selection_flip/selection_flip.gml new file mode 100644 index 00000000..0d1ba8ca --- /dev/null +++ b/scripts/selection_flip/selection_flip.gml @@ -0,0 +1,120 @@ +function selection_flip(flipVertically){ + //if flipVertical is true, well, it'll flip the selection vertically. Otherwise, horizontally. + + var row, column, current_song, str; + + var old_ins, old_key, old_vel, old_pan, old_pit, old_exists; + + current_song = songs[song]; + + str = current_song.selection_code; + + // expand all the column properites before flipping + for (var i = 0; i < current_song.selection_l; i++) { + + for (var j = current_song.selection_colfirst[i]; j < current_song.selection_h; j++) { + if (j < 0 || current_song.selection_exists[i, j]) continue; + + current_song.selection_colfirst[i] = -1 + current_song.selection_collast[i] = -1 + current_song.selection_exists[i, j] = 0 + current_song.selection_ins[i, j] = 0 + current_song.selection_key[i, j] = 0 + current_song.selection_vel[i, j] = 0 + current_song.selection_pan[i, j] = 0 + current_song.selection_pit[i, j] = 0 + } + } + + + + if (flipVertically) + // vertical flip + for (column = 0; column < current_song.selection_l; column++) { + for (row = 0; row < current_song.selection_h / 2; row++) { + var target_row = current_song.selection_h - row - 1; + + old_ins = current_song.selection_ins[column, row]; + old_key = current_song.selection_key[column, row]; + old_vel = current_song.selection_vel[column, row]; + old_pan = current_song.selection_pan[column, row]; + old_pit = current_song.selection_pit[column, row]; + old_exists = current_song.selection_exists[column,row]; + + current_song.selection_ins[column, row] = current_song.selection_ins[column, target_row]; + current_song.selection_ins[column, target_row] = old_ins; + + current_song.selection_key[column, row] = current_song.selection_key[column, target_row]; + current_song.selection_key[column, target_row] = old_key; + + current_song.selection_vel[column, row] = current_song.selection_vel[column, target_row]; + current_song.selection_vel[column, target_row] = old_vel; + + current_song.selection_pan[column, row] = current_song.selection_pan[column, target_row]; + current_song.selection_pan[column, target_row] = old_pan; + + current_song.selection_pit[column, row] = current_song.selection_pit[column, target_row]; + current_song.selection_pit[column, target_row] = old_pit; + + current_song.selection_exists[column, row] = current_song.selection_exists[column, target_row]; + current_song.selection_exists[column, target_row] = old_exists; + } + } + else + // horizontal flip + for (column = 0; column < current_song.selection_l / 2; column++) { + for (row = 0; row < current_song.selection_h; row++) { + var target_column = current_song.selection_l - column - 1; + + old_ins = current_song.selection_ins[column, row]; + old_key = current_song.selection_key[column, row]; + old_vel = current_song.selection_vel[column, row]; + old_pan = current_song.selection_pan[column, row]; + old_pit = current_song.selection_pit[column, row]; + old_exists = current_song.selection_exists[column, row]; + + current_song.selection_ins[column, row] = current_song.selection_ins[target_column, row]; + current_song.selection_ins[target_column, row] = old_ins; + + current_song.selection_key[column, row] = current_song.selection_key[target_column, row]; + current_song.selection_key[target_column, row] = old_key; + + current_song.selection_vel[column, row] = current_song.selection_vel[target_column, row]; + current_song.selection_vel[target_column, row] = old_vel; + + current_song.selection_pan[column, row] = current_song.selection_pan[target_column, row]; + current_song.selection_pan[target_column, row] = old_pan; + + current_song.selection_pit[column, row] = current_song.selection_pit[target_column, row]; + current_song.selection_pit[target_column, row] = old_pit; + + current_song.selection_exists[column, row] = current_song.selection_exists[target_column, row]; + current_song.selection_exists[target_column, row] = old_exists; + } + } + + // find the fist row number in the columns + for (var i = 0; i < current_song.selection_l; i++) { + for (var j = 0; j < current_song.selection_h; j++) { + if (current_song.selection_exists[i,j]) { + current_song.selection_colfirst[i] = j; + break; + } + } + } + + // find the last row number in the columns + for (var i = current_song.selection_l; i >= 0; i--) { + for (var j = current_song.selection_h; j >= 0; j--) { + if (current_song.selection_exists[i,j]) { + current_song.selection_collast[i] = j; + break; + } + } + } + + selection_trim(); + + selection_code_update(); + history_set(h_selectchange, current_song.selection_x, current_song.selection_y, current_song.selection_code, current_song.selection_x, current_song.selection_y, str); +} \ No newline at end of file diff --git a/scripts/selection_flip/selection_flip.yy b/scripts/selection_flip/selection_flip.yy new file mode 100644 index 00000000..19e5fe02 --- /dev/null +++ b/scripts/selection_flip/selection_flip.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "selection_flip", + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "Selection", + "path": "folders/Scripts/Note Blocks/Selection.yy", + }, +} \ No newline at end of file