Skip to content

Commit 4bc4661

Browse files
committed
Add pattern file dropping at mouse pos
1 parent aa2203a commit 4bc4661

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

scripts/control_draw/control_draw.gml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function control_draw() {
4545
work_mins += 1 / (room_speed * 60)
4646
}
4747

48-
file_dnd_set_files("*.nbs;*.mid;*.midi", 1, 0, 0)
48+
file_dnd_set_files("*.nbs;*.mid;*.midi;*.nbp", 1, 0, 0)
4949
dndfile = file_dnd_get_files()
5050

5151
remove_emitters()
@@ -2258,7 +2258,11 @@ function control_draw() {
22582258
draw_windows()
22592259
if (showmsg) draw_msg()
22602260
if (rainbowtoggle) draw_accent_rainbow()
2261-
if (lastfile != dndfile && dndfile != "") {load_song(dndfile) lastfile = dndfile}
2261+
if (lastfile != dndfile && dndfile != "") {
2262+
if (filename_ext(dndfile) = ".nbp") pattern_import(dndfile, 1)
2263+
else load_song(dndfile)
2264+
lastfile = dndfile
2265+
}
22622266

22632267
// Draw update progress bar
22642268
if (update == 4) {

scripts/pattern_import/pattern_import.gml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
function pattern_import() {
2-
// selection_import()
2+
// selection_import([filename, at_mouse_pos])
33
// Can successfully read and store all the below into the arrays/variables, but can't seem to display or place the imported selection.
4-
var a, b, fn, file_ext, nw, temp_colfirst, temp_enda, temp_endb, temp_collast, temp_exists, temp_ins, temp_key, temp_vel, temp_pan, temp_pit, temp_played, byte1, byte2, temp_str, selection_l_temp;
4+
var a, b, fn, file_ext, nw, temp_colfirst, temp_enda, temp_endb, temp_collast, temp_exists, temp_ins, temp_key, temp_vel, temp_pan, temp_pit, temp_played, byte1, byte2, temp_str, selection_l_temp, at_mouse_pos, loadx, loady;
55
fn = ""
6+
at_mouse_pos = 0
7+
if (argument_count > 0) fn = argument[0]
8+
if (argument_count > 1) at_mouse_pos = argument[1]
9+
loadx = 0
10+
loady = 0
11+
if (at_mouse_pos) {
12+
if (selbx > -1 && selby > -1) {loadx = selbx; loady = selby}
13+
else {loadx = starta; loady = startb}
14+
}
615
if (selected != 0) return 0
716
if (fn = "") {
817
if (!directory_exists_lib(patternfolder)) patternfolder = pattern_directory
@@ -60,7 +69,7 @@ function pattern_import() {
6069
selection_collast[a] = temp_collast[a]
6170
// show_debug_message("selection_collast " + string(a) + " " + string(selection_collast[a]))
6271
}
63-
selection_load(0,0, selection_copied, false)
72+
selection_load(loadx, loady, selection_copied, false)
6473
} else {
6574
selection_l = selection_l_temp
6675
if (language != 1) message("There are more custom instruments in the pattern than what is loaded in the song!", "Error")

0 commit comments

Comments
 (0)