Deltarune (Chapter 5) script viewer

← back to main script listing

gml_GlobalScript_scr_rhythmgame_tools

(view raw script w/o annotations or w/e)
1
function scr_rhythmgame_editor_insert_note(arg0, arg1, arg2 = 0, arg3 = false, arg4 = 0)
2
{
3
    for (i = 0; i <= maxnote; i++)
4
    {
5
        if (i == maxnote || arg0 < notetime[i])
6
        {
7
            if (maxnote == 0)
8
            {
9
                notetime[0] = arg0;
10
                notetype[0] = arg1;
11
                noteend[0] = arg2;
12
                notealive[0] = 1;
13
                notescore[0] = 0;
14
                noteanim[0] = arg4;
15
            }
16
            else
17
            {
18
                array_insert(notetime, i, arg0);
19
                array_insert(notetype, i, arg1);
20
                array_insert(noteend, i, arg2);
21
                array_insert(notealive, i, 1);
22
                array_insert(notescore, i, 0);
23
                array_insert(noteanim, i, arg4);
24
            }
25
            maxnote++;
26
            changesmade = true;
27
            erasecon = true;
28
            if (!arg3)
29
            {
30
                scr_rhythmgame_editor_add_undo(1, i, arg0, arg1, arg2);
31
                scr_rhythmgame_editor_refresh();
32
            }
33
            return i;
34
        }
35
        if (arg0 == notetime[i] && arg1 != notetype[i] && instrument == 2)
36
        {
37
            if (!arg3)
38
            {
39
                scr_rhythmgame_editor_record_undo(i);
40
                scr_rhythmgame_editor_refresh();
41
            }
42
            notetype[i] = arg1;
43
            changesmade = true;
44
            return i;
45
        }
46
    }
47
}
48
49
function scr_rhythmgame_editor_batch_undo(arg0 = true)
50
{
51
    if (arg0)
52
        scr_rhythmgame_editor_add_undo(-3, 0, 0, 0, 0, 0);
53
    else
54
        scr_rhythmgame_editor_add_undo(3, 0, 0, 0, 0, 0);
55
}
56
57
function scr_rhythmgame_editor_delete_note(arg0, arg1 = false)
58
{
59
    if (!arg1)
60
        scr_rhythmgame_editor_add_undo(-1, arg0, notetime[arg0], notetype[arg0], noteend[arg0], noteanim[arg0]);
61
    array_delete(notetime, arg0, 1);
62
    array_delete(notetype, arg0, 1);
63
    array_delete(noteend, arg0, 1);
64
    array_delete(notescore, arg0, 1);
65
    array_delete(notealive, arg0, 1);
66
    array_delete(noteanim, arg0, 1);
67
    maxnote--;
68
    changesmade = true;
69
    if (!arg1)
70
        scr_rhythmgame_editor_refresh();
71
}
72
73
function scr_rhythmgame_editor_note_anim(arg0, arg1 = false)
74
{
75
    if (!arg1)
76
    {
77
        scr_rhythmgame_editor_record_undo(arg0);
78
        scr_rhythmgame_editor_refresh();
79
    }
80
    noteanim[arg0] = 1 - noteanim[arg0];
81
    changesmade = true;
82
}
83
84
function scr_rhythmgame_editor_move_note(arg0, arg1, arg2, arg3 = 0, arg4 = false)
85
{
86
    if (!arg4)
87
        scr_rhythmgame_editor_add_undo(-2, arg0, notetime[arg0], notetype[arg0], noteend[arg0], noteanim[arg0]);
88
    var _anim = noteanim[arg0];
89
    scr_rhythmgame_editor_delete_note(arg0, true);
90
    var __newIndex = scr_rhythmgame_editor_insert_note(arg1, arg2, arg3, true, _anim);
91
    if (!arg4)
92
    {
93
        scr_rhythmgame_editor_add_undo(2, __newIndex, arg1, arg2, arg3);
94
        scr_rhythmgame_editor_refresh();
95
    }
96
}
97
98
function scr_rhythmgame_editor_record_undo(arg0)
99
{
100
    scr_rhythmgame_editor_add_undo(0, arg0, notetime[arg0], notetype[arg0], noteend[arg0], noteanim[arg0]);
101
}
102
103
function scr_rhythmgame_editor_add_undo(arg0, arg1, arg2, arg3, arg4 = 0, arg5 = 0)
104
{
105
    undo_action[undo_queue] = arg0;
106
    undo_index[undo_queue] = arg1;
107
    undo_time[undo_queue] = arg2;
108
    undo_type[undo_queue] = arg3;
109
    undo_end[undo_queue] = arg4;
110
    undo_anim[undo_queue] = arg5;
111
    undo_queue++;
112
    undo_cap = undo_queue;
113
}
114
115
function scr_rhythmgame_editor_undo(arg0 = false)
116
{
117
    if (undo_queue == 0)
118
    {
119
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("No actions left to undo.");
120
        exit;
121
    }
122
    undo_queue--;
123
    var _action = undo_action[undo_queue];
124
    if (_action == -1)
125
    {
126
        scr_rhythmgame_editor_insert_note(undo_time[undo_queue], undo_type[undo_queue], undo_end[undo_queue], true, undo_anim[undo_queue]);
127
    }
128
    else if (_action == 1)
129
    {
130
        scr_rhythmgame_editor_delete_note(undo_index[undo_queue], true);
131
        if (!arg0)
132
            
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Undid adding note.");
133
    }
134
    else if (_action == 2)
135
    {
136
        scr_rhythmgame_editor_move_note(undo_index[undo_queue], undo_time[undo_queue - 1], undo_type[undo_queue - 1], undo_end[undo_queue - 1], true, undo_anim[undo_queue - 1]);
137
        undo_queue--;
138
        if (!arg0)
139
            
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Undid moving note.");
140
    }
141
    else if (_action == -2)
142
    {
143
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Undo started from the wrong end of a move action. Let Taxi know!");
144
    }
145
    else if (_action == 3)
146
    {
147
        if (undo_action[undo_queue - 1] == 1)
148
            
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Undid paste.");
149
        else if (undo_action[undo_queue - 1] == -1)
150
            
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Undid cut.");
151
        batch_action = true;
152
        while (batch_action && undo_queue > 0)
153
            scr_rhythmgame_editor_undo(true);
154
        batch_action = false;
155
    }
156
    else if (_action == -3)
157
    {
158
        if (batch_action)
159
            batch_action = false;
160
        else
161
            
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Undo started from the wrong end of a batch action. Let Taxi know!");
162
    }
163
    else
164
    {
165
        scr_rhythmgame_editor_undo_swap();
166
    }
167
    if (!arg0)
168
        scr_rhythmgame_editor_refresh();
169
}
170
171
function scr_rhythmgame_editor_undo_swap()
172
{
173
    var _index = undo_index[undo_queue];
174
    var _remtype = notetype[_index];
175
    var _remend = noteend[_index];
176
    var _remtime = notetime[_index];
177
    var _remanim = noteanim[_index];
178
    notetype[_index] = undo_type[undo_queue];
179
    noteend[_index] = undo_end[undo_queue];
180
    notetime[_index] = undo_time[undo_queue];
181
    noteanim[_index] = undo_anim[undo_queue];
182
    undo_type[undo_queue] = _remtype;
183
    undo_end[undo_queue] = _remend;
184
    undo_time[undo_queue] = _remtime;
185
    undo_anim[undo_queue] = _remanim;
186
    scr_rhythmgame_editor_refresh();
187
}
188
189
function scr_rhythmgame_editor_redo(arg0 = false)
190
{
191
    if (undo_queue == undo_cap)
192
    {
193
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("No actions left to redo.");
194
        exit;
195
    }
196
    var _action = undo_action[undo_queue];
197
    if (_action == 1)
198
    {
199
        scr_rhythmgame_editor_insert_note(undo_time[undo_queue], undo_type[undo_queue], undo_end[undo_queue], true, undo_anim[undo_queue]);
200
        if (!arg0)
201
            
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Redid adding note.");
202
    }
203
    else if (_action == -1)
204
    {
205
        scr_rhythmgame_editor_delete_note(undo_index[undo_queue], true);
206
        if (!arg0)
207
            
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Redid erasing note.");
208
    }
209
    else if (_action == -2)
210
    {
211
        scr_rhythmgame_editor_move_note(undo_index[undo_queue], undo_time[undo_queue + 1], undo_type[undo_queue + 1], undo_end[undo_queue + 1], true, undo_anim[undo_queue]);
212
        undo_queue++;
213
        if (!arg0)
214
            
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Redid moving note.");
215
    }
216
    else if (_action == 2)
217
    {
218
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Redo started from wrong end of a move action. Let Taxi know!");
219
    }
220
    else if (_action == -3)
221
    {
222
        if (undo_action[undo_queue + 1] == 1)
223
            
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Redid paste.");
224
        else if (undo_action[undo_queue + 1] == -1)
225
            
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Redid cut.");
226
        batch_action = true;
227
        undo_queue++;
228
        while (batch_action && undo_queue < undo_cap)
229
            scr_rhythmgame_editor_redo(true);
230
        batch_action = false;
231
        exit;
232
    }
233
    else if (_action == 3)
234
    {
235
        if (batch_action)
236
            batch_action = false;
237
        else
238
            
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Redo started from the wrong end of a batch action. Let Taxi know!");
239
    }
240
    else
241
    {
242
        scr_rhythmgame_editor_undo_swap();
243
    }
244
    if (!arg0)
245
        scr_rhythmgame_editor_refresh();
246
    undo_queue++;
247
}
248
249
function scr_rhythmgame_editor_copy(arg0 = -1, arg1 = false)
250
{
251
    var _pos = arg1 ? min(sel_a, sel_b) : trackpos;
252
    var _clipstart = scr_round_to_beat(trackpos, bpm, 2) - (meter * 0.05);
253
    if (arg0 <= 0)
254
        arg0 = meter;
255
    var _clipend = _clipstart + arg0;
256
    if (arg1)
257
    {
258
        _clipstart = scr_round_to_beat(min(sel_a, sel_b), bpm, 2);
259
        _clipend = scr_round_to_beat(max(sel_a, sel_b), bpm, 2);
260
        arg0 = _clipend - _clipstart;
261
    }
262
    var _notesfound = false;
263
    clip_start = _clipstart;
264
    clip_end = _clipend;
265
    for (var _i = 0; _i < maxnote; _i++)
266
    {
267
        var _notetime = notetime[_i];
268
        if (_notetime >= _clipend)
269
            break;
270
        if (notetime[_i] >= _clipstart)
271
        {
272
            if (!_notesfound)
273
            {
274
                _notesfound = true;
275
                clip_size = 0;
276
                clip_time = [];
277
                clip_end = [];
278
                clip_type = [];
279
                clip_anim = [];
280
            }
281
            clip_time[clip_size] = _notetime - _clipstart;
282
            clip_type[clip_size] = notetype[_i];
283
            if (noteend[_i] > 0)
284
                clip_end[clip_size] = noteend[_i] - _clipstart;
285
            else
286
                clip_end[clip_size] = noteend[_i];
287
            clip_anim[clip_size] = noteanim[_i];
288
            clip_size++;
289
        }
290
    }
291
    if (_notesfound)
292
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
(stringsetsub("copied ~1 notes to clipboard (~2 beats)", string(clip_size), string(round(arg0 / (meter / 4)))));
293
    else
294
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("nothing to copy.");
295
}
296
297
function scr_rhythmgame_editor_clear_selection(arg0, arg1 = true)
298
{
299
    var _clipsize = meter;
300
    if (keyboard_check(vk_lalt) && sel_a > -1)
301
        arg1 = true;
302
    else if (keyboard_check(vk_lshift))
303
        _clipsize = meter * 2;
304
    var _clipstart = arg1 ? scr_round_to_beat(min(sel_a, sel_b), bpm, 2) : scr_round_to_beat(trackpos, bpm, 2);
305
    var _clipend = arg1 ? scr_round_to_beat(max(sel_a, sel_b), bpm, 2) : (trackpos + arg0);
306
    var _deletecount = 0;
307
    scr_rhythmgame_editor_batch_undo(true);
308
    var _i = maxnote - 1;
309
    while (_i >= 0)
310
    {
311
        var _notetime = notetime[_i];
312
        if (_notetime < _clipstart)
313
            break;
314
        if (notetime[_i] < _clipend)
315
        {
316
            scr_rhythmgame_editor_delete_note(_i);
317
            _deletecount++;
318
        }
319
        _i--;
320
    }
321
    scr_rhythmgame_editor_batch_undo(false);
322
    
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
(stringsetsub("Deleted ~1 notes", string(_deletecount)));
323
}
324
325
function scr_rhythmgame_editor_cut(arg0 = -1, arg1 = false)
326
{
327
    var _clipsize = meter;
328
    if (sel_a >= 0 && sel_b >= 0)
329
        arg1 = true;
330
    else if (keyboard_check(vk_lshift))
331
        _clipsize = meter * 2;
332
    scr_rhythmgame_editor_copy(arg0, arg1);
333
    scr_rhythmgame_editor_clear_selection(arg0, arg1);
334
}
335
336
function scr_rhythmgame_editor_paste()
337
{
338
    if (clip_size == 0)
339
    {
340
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("Nothing to paste.");
341
    }
342
    else
343
    {
344
        if (clip_size > 1)
345
            scr_rhythmgame_editor_batch_undo(true);
346
        var _pastestart = scr_round_to_beat(trackpos, bpm, keyboard_check(vk_lshift) ? 4 : 2);
347
        for (var _i = 0; _i < clip_size; _i++)
348
        {
349
            var _clip_end = clip_end[_i];
350
            if (_clip_end > 0)
351
                _clip_end += _pastestart;
352
            scr_rhythmgame_editor_insert_note(clip_time[_i] + _pastestart, clip_type[_i], _clip_end, false, clip_anim[_i]);
353
        }
354
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
(stringsetsub("Pasted ~1 notes.", string(clip_size)));
355
        if (clip_size > 1)
356
            scr_rhythmgame_editor_batch_undo(false);
357
        scr_rhythmgame_editor_refresh();
358
    }
359
}
360
361
function scr_rhythmgame_editor_refresh()
362
{
363
    with (obj_rhythmgame_editor_note_node)
364
        instance_destroy();
365
    if (paused)
366
        do_refresh = true;
367
}
368
369
function scr_rhythmgame_editor_note_refresh(arg0 = false)
370
{
371
    minnote = 0;
372
    var _starttime = arg0 ? 0 : trackpos;
373
    for (i = 0; i < maxnote; i++)
374
    {
375
        if (_starttime > notetime[i])
376
        {
377
            notealive[i] = false;
378
            minnote = i + 1;
379
        }
380
        else if (notealive[i] == true)
381
        {
382
            exit;
383
        }
384
        else
385
        {
386
            notescore[i] = 0;
387
            notealive[i] = true;
388
        }
389
    }
390
    scroll_init = 1;
391
}
392
393
function scr_rhythmgame_editor_info_save(arg0 = "music_timing_info.txt", arg1 = false)
394
{
395
    var _file = file_text_open_write(arg0);
396
    if (!arg1 && bpm_count > 1)
397
    {
398
        file_text_write_string(_file, "BPM CHANGE");
399
        file_text_writeln(_file);
400
    }
401
    for (i = 1; i < bpm_count; i++)
402
    {
403
        if (arg1)
404
            file_text_write_string(_file, "\tscr_rhythmgame_add_bpm(" + string(bpm_change[i]) + "," + string(bpm_time[i]) + ");");
405
        else
406
            file_text_write_string(_file, string(bpm_time[i]) + "," + string(bpm_change[i]));
407
        file_text_writeln(_file);
408
    }
409
    if (!arg1)
410
    {
411
        if (bpm_count > 1)
412
            file_text_writeln(_file);
413
        file_text_write_string(_file, "TIME SIGNATURES");
414
        file_text_writeln(_file);
415
    }
416
    for (i = 1; i < signature_count; i++)
417
    {
418
        if (arg1)
419
            file_text_write_string(_file, "\tscr_rhythmgame_add_time_signature(" + string(signature_change[i]) + "," + string(signature_time[i]) + ");");
420
        else
421
            file_text_write_string(_file, string(signature_time[i]) + "," + string(signature_change[i]));
422
        file_text_writeln(_file);
423
    }
424
    file_text_close(_file);
425
    changesmade = false;
426
}
427
428
function scr_rhythmgame_editor_save(arg0 = "music_timing.txt", arg1 = false)
429
{
430
    var _file = file_text_open_write(arg0);
431
    var _div = 0;
432
    for (i = 0; i < maxnote; i++)
433
    {
434
        if (instrument == 0 && song_id == 0 && _div < array_length(timestamp) && notetime[i] > timestamp[_div] && arg1)
435
        {
436
            if (_div == 0)
437
                file_text_write_string(_file, "\t//start of solo");
438
            else
439
                file_text_write_string(_file, "\t}");
440
            file_text_writeln(_file);
441
            if (_div != 3)
442
            {
443
                if (_div == 0)
444
                    file_text_write_string(_file, "\tif (argument0 == " + string(_div) + ")");
445
                else
446
                    file_text_write_string(_file, "\telse if (argument0 == " + string(_div) + ")");
447
                file_text_writeln(_file);
448
                file_text_write_string(_file, "\t{");
449
            }
450
            else
451
            {
452
                file_text_write_string(_file, "\t//start of finale");
453
            }
454
            file_text_writeln(_file);
455
            _div++;
456
        }
457
        var _string;
458
        if (noteend[i] > 0)
459
            _string = string(notetime[i]) + "," + string(notetype[i]) + "," + string(noteend[i]);
460
        else
461
            _string = string(notetime[i]) + "," + string(notetype[i]) + ",0";
462
        if (noteanim[i] > 0)
463
            _string += ("," + string(noteanim[i]));
464
        if (arg1)
465
        {
466
            if (_div == 4)
467
                file_text_write_string(_file, "\tscr_rhythmgame_addnote(" + _string + ");");
468
            else if (song_id == 2)
469
                file_text_write_string(_file, "\t\tscr_rhythmgame_addnote_range(" + _string + ");");
470
            else
471
                file_text_write_string(_file, "\t\tscr_rhythmgame_addnote(" + _string + ");");
472
        }
473
        else
474
        {
475
            file_text_write_string(_file, _string);
476
        }
477
        file_text_writeln(_file);
478
    }
479
    file_text_close(_file);
480
    changesmade = false;
481
}
482
483
function scr_rhythmgame_editor_save_simple(arg0 = "music_event_timing.txt")
484
{
485
    var _file = file_text_open_write(arg0);
486
    var _notetime = "notetime = [";
487
    var _notetype = "notetype = [";
488
    var _noteend = "noteend = [";
489
    var _noteanim = "noteanim =[";
490
    var _lyrictiming = "lyrictiming =[";
491
    var _div = 0;
492
    for (i = 0; i < maxnote; i++)
493
    {
494
        if (i > 0)
495
        {
496
            _notetime += ",";
497
            _notetype += ",";
498
            _noteend += ",";
499
            _noteanim += ",";
500
        }
501
        _notetime += string(notetime[i]);
502
        _notetype += string(notetype[i]);
503
        if (noteend[i] > 0)
504
            _noteend += string(noteend[i]);
505
        else
506
            _noteend += "0";
507
        if (noteanim[i] > 0)
508
        {
509
            _noteanim += string(noteanim[i]);
510
            if (i > 0)
511
                _lyrictiming += ",";
512
            _lyrictiming += string(notetime[i]);
513
        }
514
        else
515
        {
516
            _noteanim += "0";
517
        }
518
    }
519
    file_text_write_string(_file, _notetime + "];");
520
    file_text_writeln(_file);
521
    file_text_write_string(_file, _notetype + "];");
522
    file_text_writeln(_file);
523
    file_text_write_string(_file, _noteend + "];");
524
    file_text_writeln(_file);
525
    file_text_write_string(_file, _noteanim + "];");
526
    file_text_writeln(_file);
527
    file_text_write_string(_file, _lyrictiming + "];");
528
    file_text_writeln(_file);
529
    file_text_write_string(_file, "maxnote = " + string(maxnote) + ";");
530
    file_text_writeln(_file);
531
    file_text_write_string(_file, "scr_rhythmgame_prep_chart_simple();");
532
    file_text_close(_file);
533
    changesmade = false;
534
}
535
536
function scr_rhythmgame_load(arg0 = "lead")
537
{
538
    scr_rhythmgame_notechart_lead();
539
    if (savecon == -1)
540
        savecon = -2;
541
}
542
543
function scr_rhythmgame_clear_notes(arg0 = true)
544
{
545
    maxnote = 0;
546
    notetime = [];
547
    notetype = [];
548
    noteend = [];
549
    notealive = [];
550
    notescore = [];
551
    noteanim = [];
552
    if (arg0)
553
    {
554
        undo_action = [];
555
        undo_index = [];
556
        undo_time = [];
557
        undo_type = [];
558
        undo_end = [];
559
        undo_anim = [];
560
        undo_queue = 0;
561
        undo_cap = 0;
562
    }
563
}
564
565
function scr_rhythmgame_load_chart_from_file(arg0, arg1, arg2 = false)
566
{
567
    savestring = scr_rhythmgame_editor_savestring(arg0, 0, arg2);
568
    substring = savestring;
569
    if (arg1 == 1)
570
        savestring += "_drums";
571
    else if (arg1 == 2)
572
        savestring += "_vocals";
573
    if (file_exists(savestring + ".txt"))
574
        scr_rhythmgame_editor_load(savestring + ".txt", arg2);
575
    if (file_exists(substring + "_info.txt"))
576
        scr_rhythmgame_editor_info_load(substring + "_info.txt", arg2);
577
}
578
579
function scr_rhythmgame_prep_chart_simple()
580
{
581
    for (var i = 0; i < maxnote; i++)
582
    {
583
        notealive[i] = 1;
584
        notescore[i] = 0;
585
    }
586
}
587
588
function scr_rhythmgame_editor_load(arg0 = "music_timing.txt", arg1 = true)
589
{
590
    file = file_text_open_read(arg0);
591
    while (!file_text_eof(file))
592
    {
593
        var line = file_text_read_string(file);
594
        var l_arg = gml_std_string_split(line, ",");
595
        if (array_length(l_arg) >= 4)
596
            
scr_rhythmgame_addnote
scr_rhythmgame_addnote

function
scr_rhythmgame_addnote(arg0, arg1, arg2 = 0, arg3 = 0, arg4 = false)
{ notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg2; noteanim[maxnote] = arg3; notealive[maxnote] = 1; notescore[maxnote] = 0; maxnote++; } function scr_rhythmgame_addnote_range(arg0, arg1, arg2 = 0, arg3 = 0, arg4 = false) { if (chart_end == 0 || (arg0 < (chart_end - track_length) && arg0 >= (chart_start - track_length))) {
scr_rhythmgame_addnote(arg0, arg1, arg2, arg3, arg4);
if (chart_end > 0) { notealive[maxnote - 1] = 0; notescore[maxnote - 1] = 40; } exit; } else if ((arg0 < chart_start || arg0 > chart_end) && chart_end > 0) { exit; } else {
scr_rhythmgame_addnote(arg0, arg1, arg2, arg3, arg4);
} } function scr_rhythmgame_addnote_bpm(arg0, arg1, arg2 = 0) { arg0 *= meter; arg0 -= startoffset; if (arg2 != 0) { arg2 *= meter; arg0 -= startoffset; } notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg2; noteanim[maxnote] = 0; notealive[maxnote] = 1; notescore[maxnote] = 0; maxnote++; } function scr_rhythmgame_addnote_snap(arg0, arg1, arg2 = 0, arg3 = 16) { arg0 = (arg0 / meter) * arg3; arg0 = (round(arg0) / arg3) * meter; if (arg2 != 0) { arg2 = (arg0 / meter) * arg3; arg2 = (round(arg0) / arg3) * meter; } notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg3; notealive[maxnote] = 1; notescore[maxnote] = 0; noteanim[maxnote] = 0; maxnote++; }
(real(l_arg[0]), real(l_arg[1]), real(l_arg[2]), real(l_arg[3]));
597
        else if (array_length(l_arg) >= 3)
598
            
scr_rhythmgame_addnote
scr_rhythmgame_addnote

function
scr_rhythmgame_addnote(arg0, arg1, arg2 = 0, arg3 = 0, arg4 = false)
{ notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg2; noteanim[maxnote] = arg3; notealive[maxnote] = 1; notescore[maxnote] = 0; maxnote++; } function scr_rhythmgame_addnote_range(arg0, arg1, arg2 = 0, arg3 = 0, arg4 = false) { if (chart_end == 0 || (arg0 < (chart_end - track_length) && arg0 >= (chart_start - track_length))) {
scr_rhythmgame_addnote(arg0, arg1, arg2, arg3, arg4);
if (chart_end > 0) { notealive[maxnote - 1] = 0; notescore[maxnote - 1] = 40; } exit; } else if ((arg0 < chart_start || arg0 > chart_end) && chart_end > 0) { exit; } else {
scr_rhythmgame_addnote(arg0, arg1, arg2, arg3, arg4);
} } function scr_rhythmgame_addnote_bpm(arg0, arg1, arg2 = 0) { arg0 *= meter; arg0 -= startoffset; if (arg2 != 0) { arg2 *= meter; arg0 -= startoffset; } notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg2; noteanim[maxnote] = 0; notealive[maxnote] = 1; notescore[maxnote] = 0; maxnote++; } function scr_rhythmgame_addnote_snap(arg0, arg1, arg2 = 0, arg3 = 16) { arg0 = (arg0 / meter) * arg3; arg0 = (round(arg0) / arg3) * meter; if (arg2 != 0) { arg2 = (arg0 / meter) * arg3; arg2 = (round(arg0) / arg3) * meter; } notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg3; notealive[maxnote] = 1; notescore[maxnote] = 0; noteanim[maxnote] = 0; maxnote++; }
(real(l_arg[0]), real(l_arg[1]), real(l_arg[2]));
599
        file_text_readln(file);
600
    }
601
    file_text_close(file);
602
    if (arg1)
603
    {
604
        changesmade = false;
605
        if (savecon == -1)
606
            savecon = -2;
607
    }
608
}
609
610
function scr_rhythmgame_editor_load_track_directory(arg0 = "rhythm_chart_list", arg1 = true)
611
{
612
    file = file_text_open_read(arg0);
613
    while (!file_text_eof(file))
614
    {
615
        var line = file_text_read_string(file);
616
        var l_arg = gml_std_string_split(line, ",");
617
        if (array_length(l_arg) >= 4)
618
            
scr_rhythmgame_addnote
scr_rhythmgame_addnote

function
scr_rhythmgame_addnote(arg0, arg1, arg2 = 0, arg3 = 0, arg4 = false)
{ notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg2; noteanim[maxnote] = arg3; notealive[maxnote] = 1; notescore[maxnote] = 0; maxnote++; } function scr_rhythmgame_addnote_range(arg0, arg1, arg2 = 0, arg3 = 0, arg4 = false) { if (chart_end == 0 || (arg0 < (chart_end - track_length) && arg0 >= (chart_start - track_length))) {
scr_rhythmgame_addnote(arg0, arg1, arg2, arg3, arg4);
if (chart_end > 0) { notealive[maxnote - 1] = 0; notescore[maxnote - 1] = 40; } exit; } else if ((arg0 < chart_start || arg0 > chart_end) && chart_end > 0) { exit; } else {
scr_rhythmgame_addnote(arg0, arg1, arg2, arg3, arg4);
} } function scr_rhythmgame_addnote_bpm(arg0, arg1, arg2 = 0) { arg0 *= meter; arg0 -= startoffset; if (arg2 != 0) { arg2 *= meter; arg0 -= startoffset; } notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg2; noteanim[maxnote] = 0; notealive[maxnote] = 1; notescore[maxnote] = 0; maxnote++; } function scr_rhythmgame_addnote_snap(arg0, arg1, arg2 = 0, arg3 = 16) { arg0 = (arg0 / meter) * arg3; arg0 = (round(arg0) / arg3) * meter; if (arg2 != 0) { arg2 = (arg0 / meter) * arg3; arg2 = (round(arg0) / arg3) * meter; } notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg3; notealive[maxnote] = 1; notescore[maxnote] = 0; noteanim[maxnote] = 0; maxnote++; }
(real(l_arg[0]), real(l_arg[1]), real(l_arg[2]), real(l_arg[3]));
619
        else if (array_length(l_arg) >= 3)
620
            
scr_rhythmgame_addnote
scr_rhythmgame_addnote

function
scr_rhythmgame_addnote(arg0, arg1, arg2 = 0, arg3 = 0, arg4 = false)
{ notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg2; noteanim[maxnote] = arg3; notealive[maxnote] = 1; notescore[maxnote] = 0; maxnote++; } function scr_rhythmgame_addnote_range(arg0, arg1, arg2 = 0, arg3 = 0, arg4 = false) { if (chart_end == 0 || (arg0 < (chart_end - track_length) && arg0 >= (chart_start - track_length))) {
scr_rhythmgame_addnote(arg0, arg1, arg2, arg3, arg4);
if (chart_end > 0) { notealive[maxnote - 1] = 0; notescore[maxnote - 1] = 40; } exit; } else if ((arg0 < chart_start || arg0 > chart_end) && chart_end > 0) { exit; } else {
scr_rhythmgame_addnote(arg0, arg1, arg2, arg3, arg4);
} } function scr_rhythmgame_addnote_bpm(arg0, arg1, arg2 = 0) { arg0 *= meter; arg0 -= startoffset; if (arg2 != 0) { arg2 *= meter; arg0 -= startoffset; } notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg2; noteanim[maxnote] = 0; notealive[maxnote] = 1; notescore[maxnote] = 0; maxnote++; } function scr_rhythmgame_addnote_snap(arg0, arg1, arg2 = 0, arg3 = 16) { arg0 = (arg0 / meter) * arg3; arg0 = (round(arg0) / arg3) * meter; if (arg2 != 0) { arg2 = (arg0 / meter) * arg3; arg2 = (round(arg0) / arg3) * meter; } notetime[maxnote] = arg0; notetype[maxnote] = arg1; noteend[maxnote] = arg3; notealive[maxnote] = 1; notescore[maxnote] = 0; noteanim[maxnote] = 0; maxnote++; }
(real(l_arg[0]), real(l_arg[1]), real(l_arg[2]));
621
        file_text_readln(file);
622
    }
623
    file_text_close(file);
624
    if (arg1)
625
    {
626
        changesmade = false;
627
        if (savecon == -1)
628
            savecon = -2;
629
    }
630
}
631
632
function scr_rhythmgame_editor_info_load(arg0 = "music_timing_info.txt", arg1 = true)
633
{
634
    file = file_text_open_read(arg0);
635
    var _ts = false;
636
    while (!file_text_eof(file))
637
    {
638
        var line = file_text_read_string(file);
639
        var l_arg = gml_std_string_split(line, ",");
640
        var _char = string_char_at(line, 1);
641
        if (array_length(l_arg) >= 2)
642
        {
643
            if (_ts)
644
                scr_rhythmgame_add_time_signature(real(l_arg[1]), real(l_arg[0]));
645
            else
646
                scr_rhythmgame_add_bpm(real(l_arg[1]), real(l_arg[0]));
647
        }
648
        else
649
        {
650
            _char = string_char_at(line, 1);
651
            if (_char == "B" || _char == "b")
652
                _ts = false;
653
            else if (_char == "T" || _char == "t")
654
                _ts = true;
655
        }
656
        file_text_readln(file);
657
    }
658
    file_text_close(file);
659
    if (arg1)
660
    {
661
        changesmade = false;
662
        if (savecon == -1)
663
            savecon = -2;
664
    }
665
}
666
667
function scr_rhythmgame_editor_custom_savestring(arg0, arg1, arg2)
668
{
669
    if (arg1 == 1)
670
        arg0 += "_drums";
671
    if (arg1 == 2)
672
        arg0 += "_vocals";
673
    return arg0;
674
}
675
676
function scr_rhythmgame_editor_savestring(arg0, arg1 = 0, arg2 = true)
677
{
678
    var __savestring = "music_timing";
679
    if (arg0 == 0)
680
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading rock video");
681
    if (arg0 == 1)
682
    {
683
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading practice song");
684
        __savestring += "_practice";
685
    }
686
    else if (arg0 == 2)
687
    {
688
        arg0 = 2;
689
        __savestring += "_tenna";
690
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading tenna_battle");
691
        if (arg2)
692
            bpm = 148;
693
    }
694
    else if (arg0 == 3)
695
    {
696
        arg0 = 3;
697
        __savestring += "_tutorial";
698
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading tutorial song");
699
        if (arg2)
700
            bpm = 190;
701
    }
702
    else if (arg0 == 4)
703
    {
704
        arg0 = 4;
705
        __savestring += "_board4";
706
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading board4_rhythm");
707
        if (arg2)
708
            bpm = 120;
709
    }
710
    else if (arg0 == 5)
711
    {
712
        arg0 = 5;
713
        __savestring += "_rudebuster_boss";
714
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading rudebuster_boss");
715
        if (arg2)
716
            bpm = 140;
717
    }
718
    else if (arg0 == 6)
719
    {
720
        arg0 = 6;
721
        __savestring += "_vapor";
722
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading battle_vapor");
723
        if (arg2)
724
            bpm = 200;
725
    }
726
    else if (arg0 == 8)
727
    {
728
        __savestring += "_rudebuster";
729
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading rudebuster");
730
    }
731
    else if (arg0 == 9)
732
    {
733
        __savestring += "_fieldofhopes";
734
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading field of hopes and dreams");
735
    }
736
    else if (arg0 == 10)
737
    {
738
        __savestring += "_knockyoudown";
739
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading Knock You Down!!");
740
    }
741
    else if (arg0 == 15)
742
    {
743
        __savestring += "_churchx";
744
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading 4rd Sanctuary");
745
    }
746
    else
747
    {
748
        __savestring += "_unnamed";
749
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("loading unnamed song");
750
    }
751
    if (arg1 == 1)
752
        __savestring += "_drums";
753
    if (arg1 == 2)
754
        __savestring += "_vocals";
755
    return __savestring;
756
}
757
758
function scr_rhythmgame_editor_trail_add(arg0, arg1)
759
{
760
    if (rec_count == rec_max)
761
    {
762
        array_delete(rec_time, 0, 1);
763
        array_delete(rec_type, 0, 1);
764
        array_delete(rec_endtime, 0, 1);
765
        rec_count--;
766
    }
767
    rec_time[rec_count] = arg0;
768
    rec_type[rec_count] = arg1;
769
    rec_endtime[rec_count] = 0;
770
    rec_count++;
771
}