Skip to content

Commit 8319be1

Browse files
committed
feat: add loop end tick control to extend song length with silent note
1 parent ab377d2 commit 8319be1

2 files changed

Lines changed: 45 additions & 16 deletions

File tree

scripts/control_create/control_create.gml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ function control_create() {
393393
loop = 0
394394
loopmax = 0
395395
loopstart = 0
396+
loopend = 0
396397
//looptobarend = 1
397398
timestoloop = loopmax
398399
settempo = 0 // Tempo input box clicked

scripts/draw_window_properties/draw_window_properties.gml

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
function draw_window_properties() {
22
// draw_window_properties()
3+
4+
if (window != prevwindow) {
5+
// Initialize loop end to current last tick of the song
6+
loopend = enda + 1
7+
}
8+
39
var x1, y1, a;
410
windowanim = 1
511
if (theme = 3) draw_set_alpha(windowalpha)
@@ -82,31 +88,53 @@ function draw_window_properties() {
8288
draw_text_dynamic(x1 + 340, y1 + 305, loopstart)
8389
}
8490
if (a != loopstart) changed = 1
91+
92+
// Loop end tick
93+
if (!loop) draw_set_color(c_gray)
94+
if (language != 1) draw_text_dynamic(x1 + 252, y1 + 325, "Loop end tick:")
95+
else draw_text_dynamic(x1 + 252, y1 + 325, "Loop end tick:")
96+
a = loopend
97+
if (loop) {
98+
loopend = median(enda + 1, draw_dragvalue(20, x1 + 340, y1 + 325, loopend, 0.5), obj_controller.enda + 16 + 1)
99+
} else {
100+
draw_text_dynamic(x1 + 340, y1 + 325, loopend)
101+
}
102+
if (loopend != enda + 1) {
103+
draw_set_color(c_orange)
104+
draw_theme_font(font_small_bold)
105+
draw_text_dynamic(x1 + 25, y1 + 390, "[!]")
106+
draw_theme_font(font_small)
107+
draw_text_dynamic(x1 + 40 + (theme != 3) * 2, y1 + 390 + (theme == 3), "A silent note will be added to extend the length of the song.")
108+
draw_theme_font(font_main)
109+
draw_theme_color()
110+
}
111+
if (a != loopend) changed = 1
85112

86-
if (language != 1) draw_text_dynamic(x1 + 252, y1 + 325, "Times to loop:")
87-
else draw_text_dynamic(x1 + 252, y1 + 325, "循环次数:")
113+
if (language != 1) draw_text_dynamic(x1 + 252, y1 + 345, "Times to loop:")
114+
else draw_text_dynamic(x1 + 252, y1 + 345, "循环次数:")
88115
a = loopmax
89116
if (loop) {
90-
loopmax = median(0, draw_dragvalue(13, x1 + 340, y1 + 325, loopmax, 0.5), 10)
117+
loopmax = median(0, draw_dragvalue(13, x1 + 340, y1 + 345, loopmax, 0.5), 10)
91118
} else {
92-
draw_text_dynamic(x1 + 340, y1 + 325, loopmax)
119+
draw_text_dynamic(x1 + 340, y1 + 345, loopmax)
93120
}
94-
if (language != 1) {if (loopmax = 0) draw_text_dynamic(x1 + 360, y1 + 325, "(infinite)")}
95-
else {if (loopmax = 0) draw_text_dynamic(x1 + 360, y1 + 325, "(无限)")}
121+
if (language != 1) {if (loopmax = 0) draw_text_dynamic(x1 + 360, y1 + 345, "(infinite)")}
122+
else {if (loopmax = 0) draw_text_dynamic(x1 + 360, y1 + 345, "(无限)")}
96123
if (a != loopmax) changed = 1
97124
timestoloop = loopmax
98-
99-
if (loop) {
100-
draw_set_color(c_orange)
101-
draw_theme_font(font_small)
102-
draw_text_dynamic(x1 + 37, y1 + 315, "Warning: the 'Loop to bar end' setting was\nremoved to make playback consistent!\nTo make sure your song loops at the right\npoint, add a silent note at the end.")
103-
}
104-
105-
draw_theme_font(font_main)
125+
106126
draw_theme_color()
107127

108-
if (draw_button2(x1 + 430 - 72, y1 + 386, 72, condstr(language != 1, "OK", "确定")) && (windowopen = 1 || theme != 3)) {windowclose = 1}
109-
if (display_mouse_get_x() - window_get_x() >= 0 && display_mouse_get_y() - window_get_y() >= 0 && display_mouse_get_x() - window_get_x() < 0 + window_width && display_mouse_get_y() - window_get_y() < 0 + window_height) {
128+
if (draw_button2(x1 + 430 - 72, y1 + 386, 72, condstr(language != 1, "OK", "确定")) && (windowopen = 1 || theme != 3)) {
129+
130+
if (loopend != enda + 1) {
131+
show_debug_message("Loop end changed; adding extra note");
132+
add_block(loopend - 1, 0, instrument_list[| 0], 45, 0, 100, 0)
133+
}
134+
135+
windowclose = 1
136+
}
137+
if (display_mouse_get_x() - window_get_x() >= 0 && display_mouse_get_y() - window_get_y() >= 0 && display_mouse_get_x() - window_get_x() < 0 + window_width && display_mouse_get_y() - window_get_y() < 0 + window_height) {
110138
window_set_cursor(curs)
111139
if (array_length(text_mouseover) = 0) window_set_cursor(cr_default)
112140
}

0 commit comments

Comments
 (0)