Skip to content

Commit ee3288c

Browse files
committed
impl: The selection_code variable is now compressed by default
- This should reduce memory usage when there is a selection and reduce the amount of `try_compress_selection()` calls; - Add a new function `macro_column_count()` to replace `string_count("-1", ...)` in some macros; - The selection code will be decompressed when exporting to a pattern file or displaying in the "Secret clipboard editor" dialog.
1 parent c17559b commit ee3288c

36 files changed

Lines changed: 78 additions & 66 deletions

File tree

scripts/action_paste/action_paste.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function action_paste(argument0, argument1) {
44
xx = argument0
55
yy = argument1
66
selection_load(xx, yy, selection_copied, false)
7-
history_set(h_selectpaste, xx, yy, try_compress_selection(selection_code))
7+
history_set(h_selectpaste, xx, yy, selection_code)
88
changed = 1
99

1010

scripts/buffer_pos_char/buffer_pos_char.gml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
function buffer_pos_char(argument0, argument1, argument2){
1+
function buffer_pos_char(buffer, buffer_size, char){
22
// Find the position of a character in a text buffer, optionally from a start position.
33
// Return the buffer length if not found.
44

5-
var buffer = argument0
6-
var buffer_size = argument1
7-
var char = argument2
85
if (is_string(char)) {
96
char = ord(char)
107
}

scripts/buffer_substr_copy/buffer_substr_copy.gml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
function buffer_substr_copy(argument0, argument1, argument2, argument3){
1+
function buffer_substr_copy(buffer, pos, size, text_buffer){
22
// Copy a sub-string from a buffer to a text buffer and return the extracted string
3-
4-
var buffer = argument0
5-
var pos = argument1
6-
var size = argument2
7-
var text_buffer = argument3
8-
3+
94
buffer_resize(text_buffer, size)
105
buffer_copy(buffer, pos, size, text_buffer, 0)
116
var str = buffer_read(text_buffer, buffer_string)

scripts/draw_window_clip_editor/draw_window_clip_editor.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function draw_window_clip_editor() {
2222
else draw_areaheader(x1 + 22, y1 + 48, 396, 330, "剪贴板")
2323
draw_theme_color()
2424
//text_exists[59] = 0
25-
selection_copied = draw_text_edit(59, selection_copied, x1 + 32, y1 + 23 * 3, 370, 300, 0, 0)
25+
selection_copied = try_compress_selection(draw_text_edit(59, try_decompress_selection(selection_copied), x1 + 32, y1 + 23 * 3, 370, 300, 0, 0))
2626

2727
if (draw_button2(x1 + 320, y1 + 398, 72, condstr(language != 1, "OK", "确定")) && (windowopen = 1 || theme != 3)) {
2828
windowclose = 1

scripts/draw_window_macro_arpeggio/draw_window_macro_arpeggio.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function draw_window_macro_arpeggio() {
6565
}
6666
var new_str = array_to_selection(arr_data, total_vals)
6767
selection_load_ext(selection_x, selection_y, new_str)
68-
history_set(h_selectchange, selection_x, selection_y, try_compress_selection(selection_code), selection_x, selection_y, try_compress_selection(str))
68+
history_set(h_selectchange, selection_x, selection_y, selection_code, selection_x, selection_y, str)
6969
if(!keyboard_check(vk_alt)) selection_place(false)
7070
}
7171
if (draw_button2(x1 + 70, y1 + 98, 60, condstr(language !=1, "Cancel", "取消")) && (windowopen = 1 || theme != 3)) {windowclose = 1}

scripts/draw_window_macro_portamento/draw_window_macro_portamento.gml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ function draw_window_macro_portamento() {
2929
windowalpha = 0
3030
windowclose = 0
3131
windowopen = 0
32+
window = 0
3233
str = selection_code
33-
val = 0
34-
decr = port_cent / string_count("-1", str)
35-
inc = decr
3634
var arr_data = selection_to_array(str)
37-
window = 0
3835
total_vals = array_length(arr_data)
36+
decr = port_cent / macro_column_count(arr_data)
37+
inc = decr
3938
val = 0
4039
while (val < total_vals) {
4140
val += 6
@@ -57,7 +56,7 @@ function draw_window_macro_portamento() {
5756
}
5857
var new_str = array_to_selection(arr_data, total_vals)
5958
selection_load_ext(selection_x, selection_y, new_str)
60-
history_set(h_selectchange, selection_x, selection_y, try_compress_selection(selection_code), selection_x, selection_y, try_compress_selection(str))
59+
history_set(h_selectchange, selection_x, selection_y, selection_code, selection_x, selection_y, str)
6160
if(!keyboard_check(vk_alt)) selection_place(false)
6261
}
6362
if (draw_button2(x1 + 70, y1 + 98, 60, condstr(language !=1, "Cancel", "取消")) && (windowopen = 1 || theme != 3)) {windowclose = 1}

scripts/draw_window_macro_setvelocity/draw_window_macro_setvelocity.gml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ function draw_window_macro_setvelocity() {
3131
windowclose = 0
3232
windowopen = 0
3333
window = 0
34-
str = selection_code
3534
if (!percentvel) {
3635
selection_change(m_vel, setvel, false)
3736
} else {
@@ -47,7 +46,7 @@ function draw_window_macro_setvelocity() {
4746
}
4847
}
4948
selection_code_update()
50-
history_set(h_selectchange, selection_x, selection_y, try_compress_selection(selection_code), selection_x, selection_y, try_compress_selection(str))
49+
history_set(h_selectchange, selection_x, selection_y, selection_code, selection_x, selection_y, str)
5150
}
5251
if(!keyboard_check(vk_alt)) selection_place(false)
5352
}

scripts/draw_window_macro_stagger/draw_window_macro_stagger.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function draw_window_macro_stagger() {
8888
}
8989
var new_str = array_to_selection(arr_data, total_vals)
9090
selection_load(selection_x, selection_y, new_str, true)
91-
history_set(h_selectchange, selection_x, selection_y, try_compress_selection(selection_code), selection_x, selection_y, try_compress_selection(str))
91+
history_set(h_selectchange, selection_x, selection_y, selection_code, selection_x, selection_y, str)
9292
if(!keyboard_check(vk_alt)) selection_place(false)
9393
}
9494
if (draw_button2(x1 + 75, y1 + 128, 60, condstr(language != 1, "Cancel", "取消")) && (windowopen = 1 || theme != 3)) {windowclose = 1}

scripts/draw_window_macro_stereo/draw_window_macro_stereo.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function draw_window_macro_stereo() {
6969
}
7070
var new_str = array_to_selection(arr_data, total_vals)
7171
selection_load_ext(selection_x, selection_y, new_str)
72-
history_set(h_selectchange, selection_x, selection_y, try_compress_selection(selection_code), selection_x, selection_y, try_compress_selection(str))
72+
history_set(h_selectchange, selection_x, selection_y, selection_code, selection_x, selection_y, str)
7373
if(!keyboard_check(vk_alt)) selection_place(false)
7474
}
7575
if (draw_button2(x1 + 70, y1 + 98, 60, condstr(language != 1, "Cancel", "取消")) && (windowopen = 1 || theme != 3)) {windowclose = 1}

scripts/macro_chorus/macro_chorus.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function macro_chorus() {
4343
}
4444
var new_str = array_to_selection(arr_data, total_vals)
4545
selection_load_ext(selection_x, selection_y, new_str)
46-
history_set(h_selectchange, selection_x, selection_y, try_compress_selection(selection_code), selection_x, selection_y, try_compress_selection(str))
46+
history_set(h_selectchange, selection_x, selection_y, selection_code, selection_x, selection_y, str)
4747
if(!keyboard_check(vk_alt)) selection_place(false)
4848

4949

0 commit comments

Comments
 (0)