function scr_rhythmgame_editor_insert_note(arg0, arg1, arg2 = 0, arg3 = false, arg4 = 0) { for (i = 0; i <= maxnote; i++) { if (i == maxnote || arg0 < notetime[i]) { if (maxnote == 0) { notetime[0] = arg0; notetype[0] = arg1; noteend[0] = arg2; notealive[0] = 1; notescore[0] = 0; noteanim[0] = arg4; } else { array_insert(notetime, i, arg0); array_insert(notetype, i, arg1); array_insert(noteend, i, arg2); array_insert(notealive, i, 1); array_insert(notescore, i, 0); array_insert(noteanim, i, arg4); } maxnote++; changesmade = true; erasecon = true; if (!arg3) { scr_rhythmgame_editor_add_undo(1, i, arg0, arg1, arg2); scr_rhythmgame_editor_refresh(); } return i; } if (arg0 == notetime[i] && arg1 != notetype[i] && instrument == 2) { if (!arg3) { scr_rhythmgame_editor_record_undo(i); scr_rhythmgame_editor_refresh(); } notetype[i] = arg1; changesmade = true; return i; } } } function scr_rhythmgame_editor_batch_undo(arg0 = true) { if (arg0) scr_rhythmgame_editor_add_undo(-3, 0, 0, 0, 0, 0); else scr_rhythmgame_editor_add_undo(3, 0, 0, 0, 0, 0); } function scr_rhythmgame_editor_delete_note(arg0, arg1 = false) { if (!arg1) scr_rhythmgame_editor_add_undo(-1, arg0, notetime[arg0], notetype[arg0], noteend[arg0], noteanim[arg0]); array_delete(notetime, arg0, 1); array_delete(notetype, arg0, 1); array_delete(noteend, arg0, 1); array_delete(notescore, arg0, 1); array_delete(notealive, arg0, 1); array_delete(noteanim, arg0, 1); maxnote--; changesmade = true; if (!arg1) scr_rhythmgame_editor_refresh(); } function scr_rhythmgame_editor_note_anim(arg0, arg1 = false) { if (!arg1) { scr_rhythmgame_editor_record_undo(arg0); scr_rhythmgame_editor_refresh(); } noteanim[arg0] = 1 - noteanim[arg0]; changesmade = true; } function scr_rhythmgame_editor_move_note(arg0, arg1, arg2, arg3 = 0, arg4 = false) { if (!arg4) scr_rhythmgame_editor_add_undo(-2, arg0, notetime[arg0], notetype[arg0], noteend[arg0], noteanim[arg0]); var _anim = noteanim[arg0]; scr_rhythmgame_editor_delete_note(arg0, true); var __newIndex = scr_rhythmgame_editor_insert_note(arg1, arg2, arg3, true, _anim); if (!arg4) { scr_rhythmgame_editor_add_undo(2, __newIndex, arg1, arg2, arg3); scr_rhythmgame_editor_refresh(); } } function scr_rhythmgame_editor_record_undo(arg0) { scr_rhythmgame_editor_add_undo(0, arg0, notetime[arg0], notetype[arg0], noteend[arg0], noteanim[arg0]); } function scr_rhythmgame_editor_add_undo(arg0, arg1, arg2, arg3, arg4 = 0, arg5 = 0) { undo_action[undo_queue] = arg0; undo_index[undo_queue] = arg1; undo_time[undo_queue] = arg2; undo_type[undo_queue] = arg3; undo_end[undo_queue] = arg4; undo_anim[undo_queue] = arg5; undo_queue++; undo_cap = undo_queue; } function scr_rhythmgame_editor_undo(arg0 = false) { if (undo_queue == 0) { scr_debug_print("No actions left to undo."); exit; } undo_queue--; var _action = undo_action[undo_queue]; if (_action == -1) { scr_rhythmgame_editor_insert_note(undo_time[undo_queue], undo_type[undo_queue], undo_end[undo_queue], true, undo_anim[undo_queue]); } else if (_action == 1) { scr_rhythmgame_editor_delete_note(undo_index[undo_queue], true); if (!arg0) scr_debug_print("Undid adding note."); } else if (_action == 2) { 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]); undo_queue--; if (!arg0) scr_debug_print("Undid moving note."); } else if (_action == -2) { scr_debug_print("Undo started from the wrong end of a move action. Let Taxi know!"); } else if (_action == 3) { if (undo_action[undo_queue - 1] == 1) scr_debug_print("Undid paste."); else if (undo_action[undo_queue - 1] == -1) scr_debug_print("Undid cut."); batch_action = true; while (batch_action && undo_queue > 0) scr_rhythmgame_editor_undo(true); batch_action = false; } else if (_action == -3) { if (batch_action) batch_action = false; else scr_debug_print("Undo started from the wrong end of a batch action. Let Taxi know!"); } else { scr_rhythmgame_editor_undo_swap(); } if (!arg0) scr_rhythmgame_editor_refresh(); } function scr_rhythmgame_editor_undo_swap() { var _index = undo_index[undo_queue]; var _remtype = notetype[_index]; var _remend = noteend[_index]; var _remtime = notetime[_index]; var _remanim = noteanim[_index]; notetype[_index] = undo_type[undo_queue]; noteend[_index] = undo_end[undo_queue]; notetime[_index] = undo_time[undo_queue]; noteanim[_index] = undo_anim[undo_queue]; undo_type[undo_queue] = _remtype; undo_end[undo_queue] = _remend; undo_time[undo_queue] = _remtime; undo_anim[undo_queue] = _remanim; scr_rhythmgame_editor_refresh(); } function scr_rhythmgame_editor_redo(arg0 = false) { if (undo_queue == undo_cap) { scr_debug_print("No actions left to redo."); exit; } var _action = undo_action[undo_queue]; if (_action == 1) { scr_rhythmgame_editor_insert_note(undo_time[undo_queue], undo_type[undo_queue], undo_end[undo_queue], true, undo_anim[undo_queue]); if (!arg0) scr_debug_print("Redid adding note."); } else if (_action == -1) { scr_rhythmgame_editor_delete_note(undo_index[undo_queue], true); if (!arg0) scr_debug_print("Redid erasing note."); } else if (_action == -2) { 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]); undo_queue++; if (!arg0) scr_debug_print("Redid moving note."); } else if (_action == 2) { scr_debug_print("Redo started from wrong end of a move action. Let Taxi know!"); } else if (_action == -3) { if (undo_action[undo_queue + 1] == 1) scr_debug_print("Redid paste."); else if (undo_action[undo_queue + 1] == -1) scr_debug_print("Redid cut."); batch_action = true; undo_queue++; while (batch_action && undo_queue < undo_cap) scr_rhythmgame_editor_redo(true); batch_action = false; exit; } else if (_action == 3) { if (batch_action) batch_action = false; else scr_debug_print("Redo started from the wrong end of a batch action. Let Taxi know!"); } else { scr_rhythmgame_editor_undo_swap(); } if (!arg0) scr_rhythmgame_editor_refresh(); undo_queue++; } function scr_rhythmgame_editor_copy(arg0 = -1, arg1 = false) { var _pos = arg1 ? min(sel_a, sel_b) : trackpos; var _clipstart = scr_round_to_beat(trackpos, bpm, 2) - (meter * 0.05); if (arg0 <= 0) arg0 = meter; var _clipend = _clipstart + arg0; if (arg1) { _clipstart = scr_round_to_beat(min(sel_a, sel_b), bpm, 2); _clipend = scr_round_to_beat(max(sel_a, sel_b), bpm, 2); arg0 = _clipend - _clipstart; } var _notesfound = false; clip_start = _clipstart; clip_end = _clipend; for (var _i = 0; _i < maxnote; _i++) { var _notetime = notetime[_i]; if (_notetime >= _clipend) break; if (notetime[_i] >= _clipstart) { if (!_notesfound) { _notesfound = true; clip_size = 0; clip_time = []; clip_end = []; clip_type = []; clip_anim = []; } clip_time[clip_size] = _notetime - _clipstart; clip_type[clip_size] = notetype[_i]; if (noteend[_i] > 0) clip_end[clip_size] = noteend[_i] - _clipstart; else clip_end[clip_size] = noteend[_i]; clip_anim[clip_size] = noteanim[_i]; clip_size++; } } if (_notesfound) scr_debug_print(stringsetsub("copied ~1 notes to clipboard (~2 beats)", string(clip_size), string(round(arg0 / (meter / 4))))); else scr_debug_print("nothing to copy."); } function scr_rhythmgame_editor_clear_selection(arg0, arg1 = true) { var _clipsize = meter; if (keyboard_check(vk_lalt) && sel_a > -1) arg1 = true; else if (keyboard_check(vk_lshift)) _clipsize = meter * 2; var _clipstart = arg1 ? scr_round_to_beat(min(sel_a, sel_b), bpm, 2) : scr_round_to_beat(trackpos, bpm, 2); var _clipend = arg1 ? scr_round_to_beat(max(sel_a, sel_b), bpm, 2) : (trackpos + arg0); var _deletecount = 0; scr_rhythmgame_editor_batch_undo(true); var _i = maxnote - 1; while (_i >= 0) { var _notetime = notetime[_i]; if (_notetime < _clipstart) break; if (notetime[_i] < _clipend) { scr_rhythmgame_editor_delete_note(_i); _deletecount++; } _i--; } scr_rhythmgame_editor_batch_undo(false); scr_debug_print(stringsetsub("Deleted ~1 notes", string(_deletecount))); } function scr_rhythmgame_editor_cut(arg0 = -1, arg1 = false) { var _clipsize = meter; if (sel_a >= 0 && sel_b >= 0) arg1 = true; else if (keyboard_check(vk_lshift)) _clipsize = meter * 2; scr_rhythmgame_editor_copy(arg0, arg1); scr_rhythmgame_editor_clear_selection(arg0, arg1); } function scr_rhythmgame_editor_paste() { if (clip_size == 0) { scr_debug_print("Nothing to paste."); } else { if (clip_size > 1) scr_rhythmgame_editor_batch_undo(true); var _pastestart = scr_round_to_beat(trackpos, bpm, keyboard_check(vk_lshift) ? 4 : 2); for (var _i = 0; _i < clip_size; _i++) { var _clip_end = clip_end[_i]; if (_clip_end > 0) _clip_end += _pastestart; scr_rhythmgame_editor_insert_note(clip_time[_i] + _pastestart, clip_type[_i], _clip_end, false, clip_anim[_i]); } scr_debug_print(stringsetsub("Pasted ~1 notes.", string(clip_size))); if (clip_size > 1) scr_rhythmgame_editor_batch_undo(false); scr_rhythmgame_editor_refresh(); } } function scr_rhythmgame_editor_refresh() { with (obj_rhythmgame_editor_note_node) instance_destroy(); if (paused) do_refresh = true; } function scr_rhythmgame_editor_note_refresh(arg0 = false) { minnote = 0; var _starttime = arg0 ? 0 : trackpos; for (i = 0; i < maxnote; i++) { if (_starttime > notetime[i]) { notealive[i] = false; minnote = i + 1; } else if (notealive[i] == true) { exit; } else { notescore[i] = 0; notealive[i] = true; } } scroll_init = 1; } function scr_rhythmgame_editor_info_save(arg0 = "music_timing_info.txt", arg1 = false) { var _file = file_text_open_write(arg0); if (!arg1 && bpm_count > 1) { file_text_write_string(_file, "BPM CHANGE"); file_text_writeln(_file); } for (i = 1; i < bpm_count; i++) { if (arg1) file_text_write_string(_file, "\tscr_rhythmgame_add_bpm(" + string(bpm_change[i]) + "," + string(bpm_time[i]) + ");"); else file_text_write_string(_file, string(bpm_time[i]) + "," + string(bpm_change[i])); file_text_writeln(_file); } if (!arg1) { if (bpm_count > 1) file_text_writeln(_file); file_text_write_string(_file, "TIME SIGNATURES"); file_text_writeln(_file); } for (i = 1; i < signature_count; i++) { if (arg1) file_text_write_string(_file, "\tscr_rhythmgame_add_time_signature(" + string(signature_change[i]) + "," + string(signature_time[i]) + ");"); else file_text_write_string(_file, string(signature_time[i]) + "," + string(signature_change[i])); file_text_writeln(_file); } file_text_close(_file); changesmade = false; } function scr_rhythmgame_editor_save(arg0 = "music_timing.txt", arg1 = false) { var _file = file_text_open_write(arg0); var _div = 0; for (i = 0; i < maxnote; i++) { if (instrument == 0 && song_id == 0 && _div < array_length(timestamp) && notetime[i] > timestamp[_div] && arg1) { if (_div == 0) file_text_write_string(_file, "\t//start of solo"); else file_text_write_string(_file, "\t}"); file_text_writeln(_file); if (_div != 3) { if (_div == 0) file_text_write_string(_file, "\tif (argument0 == " + string(_div) + ")"); else file_text_write_string(_file, "\telse if (argument0 == " + string(_div) + ")"); file_text_writeln(_file); file_text_write_string(_file, "\t{"); } else { file_text_write_string(_file, "\t//start of finale"); } file_text_writeln(_file); _div++; } var _string; if (noteend[i] > 0) _string = string(notetime[i]) + "," + string(notetype[i]) + "," + string(noteend[i]); else _string = string(notetime[i]) + "," + string(notetype[i]) + ",0"; if (noteanim[i] > 0) _string += ("," + string(noteanim[i])); if (arg1) { if (_div == 4) file_text_write_string(_file, "\tscr_rhythmgame_addnote(" + _string + ");"); else if (song_id == 2) file_text_write_string(_file, "\t\tscr_rhythmgame_addnote_range(" + _string + ");"); else file_text_write_string(_file, "\t\tscr_rhythmgame_addnote(" + _string + ");"); } else { file_text_write_string(_file, _string); } file_text_writeln(_file); } file_text_close(_file); changesmade = false; } function scr_rhythmgame_editor_save_simple(arg0 = "music_event_timing.txt") { var _file = file_text_open_write(arg0); var _notetime = "notetime = ["; var _notetype = "notetype = ["; var _noteend = "noteend = ["; var _noteanim = "noteanim =["; var _lyrictiming = "lyrictiming =["; var _div = 0; for (i = 0; i < maxnote; i++) { if (i > 0) { _notetime += ","; _notetype += ","; _noteend += ","; _noteanim += ","; } _notetime += string(notetime[i]); _notetype += string(notetype[i]); if (noteend[i] > 0) _noteend += string(noteend[i]); else _noteend += "0"; if (noteanim[i] > 0) { _noteanim += string(noteanim[i]); if (i > 0) _lyrictiming += ","; _lyrictiming += string(notetime[i]); } else { _noteanim += "0"; } } file_text_write_string(_file, _notetime + "];"); file_text_writeln(_file); file_text_write_string(_file, _notetype + "];"); file_text_writeln(_file); file_text_write_string(_file, _noteend + "];"); file_text_writeln(_file); file_text_write_string(_file, _noteanim + "];"); file_text_writeln(_file); file_text_write_string(_file, _lyrictiming + "];"); file_text_writeln(_file); file_text_write_string(_file, "maxnote = " + string(maxnote) + ";"); file_text_writeln(_file); file_text_write_string(_file, "scr_rhythmgame_prep_chart_simple();"); file_text_close(_file); changesmade = false; } function scr_rhythmgame_load(arg0 = "lead") { scr_rhythmgame_notechart_lead(); if (savecon == -1) savecon = -2; } function scr_rhythmgame_clear_notes(arg0 = true) { maxnote = 0; notetime = []; notetype = []; noteend = []; notealive = []; notescore = []; noteanim = []; if (arg0) { undo_action = []; undo_index = []; undo_time = []; undo_type = []; undo_end = []; undo_anim = []; undo_queue = 0; undo_cap = 0; } } function scr_rhythmgame_load_chart_from_file(arg0, arg1, arg2 = false) { savestring = scr_rhythmgame_editor_savestring(arg0, 0, arg2); substring = savestring; if (arg1 == 1) savestring += "_drums"; else if (arg1 == 2) savestring += "_vocals"; if (file_exists(savestring + ".txt")) scr_rhythmgame_editor_load(savestring + ".txt", arg2); if (file_exists(substring + "_info.txt")) scr_rhythmgame_editor_info_load(substring + "_info.txt", arg2); } function scr_rhythmgame_prep_chart_simple() { for (var i = 0; i < maxnote; i++) { notealive[i] = 1; notescore[i] = 0; } } function scr_rhythmgame_editor_load(arg0 = "music_timing.txt", arg1 = true) { file = file_text_open_read(arg0); while (!file_text_eof(file)) { var line = file_text_read_string(file); var l_arg = gml_std_string_split(line, ","); if (array_length(l_arg) >= 4) scr_rhythmgame_addnote(real(l_arg[0]), real(l_arg[1]), real(l_arg[2]), real(l_arg[3])); else if (array_length(l_arg) >= 3) scr_rhythmgame_addnote(real(l_arg[0]), real(l_arg[1]), real(l_arg[2])); file_text_readln(file); } file_text_close(file); if (arg1) { changesmade = false; if (savecon == -1) savecon = -2; } } function scr_rhythmgame_editor_load_track_directory(arg0 = "rhythm_chart_list", arg1 = true) { file = file_text_open_read(arg0); while (!file_text_eof(file)) { var line = file_text_read_string(file); var l_arg = gml_std_string_split(line, ","); if (array_length(l_arg) >= 4) scr_rhythmgame_addnote(real(l_arg[0]), real(l_arg[1]), real(l_arg[2]), real(l_arg[3])); else if (array_length(l_arg) >= 3) scr_rhythmgame_addnote(real(l_arg[0]), real(l_arg[1]), real(l_arg[2])); file_text_readln(file); } file_text_close(file); if (arg1) { changesmade = false; if (savecon == -1) savecon = -2; } } function scr_rhythmgame_editor_info_load(arg0 = "music_timing_info.txt", arg1 = true) { file = file_text_open_read(arg0); var _ts = false; while (!file_text_eof(file)) { var line = file_text_read_string(file); var l_arg = gml_std_string_split(line, ","); var _char = string_char_at(line, 1); if (array_length(l_arg) >= 2) { if (_ts) scr_rhythmgame_add_time_signature(real(l_arg[1]), real(l_arg[0])); else scr_rhythmgame_add_bpm(real(l_arg[1]), real(l_arg[0])); } else { _char = string_char_at(line, 1); if (_char == "B" || _char == "b") _ts = false; else if (_char == "T" || _char == "t") _ts = true; } file_text_readln(file); } file_text_close(file); if (arg1) { changesmade = false; if (savecon == -1) savecon = -2; } } function scr_rhythmgame_editor_custom_savestring(arg0, arg1, arg2) { if (arg1 == 1) arg0 += "_drums"; if (arg1 == 2) arg0 += "_vocals"; return arg0; } function scr_rhythmgame_editor_savestring(arg0, arg1 = 0, arg2 = true) { var __savestring = "music_timing"; if (arg0 == 0) scr_debug_print("loading rock video"); if (arg0 == 1) { scr_debug_print("loading practice song"); __savestring += "_practice"; } else if (arg0 == 2) { arg0 = 2; __savestring += "_tenna"; scr_debug_print("loading tenna_battle"); if (arg2) bpm = 148; } else if (arg0 == 3) { arg0 = 3; __savestring += "_tutorial"; scr_debug_print("loading tutorial song"); if (arg2) bpm = 190; } else if (arg0 == 4) { arg0 = 4; __savestring += "_board4"; scr_debug_print("loading board4_rhythm"); if (arg2) bpm = 120; } else if (arg0 == 5) { arg0 = 5; __savestring += "_rudebuster_boss"; scr_debug_print("loading rudebuster_boss"); if (arg2) bpm = 140; } else if (arg0 == 6) { arg0 = 6; __savestring += "_vapor"; scr_debug_print("loading battle_vapor"); if (arg2) bpm = 200; } else if (arg0 == 8) { __savestring += "_rudebuster"; scr_debug_print("loading rudebuster"); } else if (arg0 == 9) { __savestring += "_fieldofhopes"; scr_debug_print("loading field of hopes and dreams"); } else if (arg0 == 10) { __savestring += "_knockyoudown"; scr_debug_print("loading Knock You Down!!"); } else if (arg0 == 15) { __savestring += "_churchx"; scr_debug_print("loading 4rd Sanctuary"); } else { __savestring += "_unnamed"; scr_debug_print("loading unnamed song"); } if (arg1 == 1) __savestring += "_drums"; if (arg1 == 2) __savestring += "_vocals"; return __savestring; } function scr_rhythmgame_editor_trail_add(arg0, arg1) { if (rec_count == rec_max) { array_delete(rec_time, 0, 1); array_delete(rec_type, 0, 1); array_delete(rec_endtime, 0, 1); rec_count--; } rec_time[rec_count] = arg0; rec_type[rec_count] = arg1; rec_endtime[rec_count] = 0; rec_count++; }