static public void MacroToString( ref List <string> _ss, ref Js_notes_OBJ _notes) { StateTimeline[] Handbusy = { new StateTimeline(), new StateTimeline(), }; string _noteType, _LeftRightForced; double _x_int; for (int i0 = 0, _lr, _fl, _time; i0 < _notes.Notes.Length; ++i0) { _lr = _notes.Notes[i0].EndX * 2 + 1 <= _notes.TrackCount ? 0 : 1; _LeftRightForced = ""; if (Handbusy[_lr].IsIn(_notes.Notes[i0].Ticks)) { _lr = 1 - _lr; _LeftRightForced = _lr == 0 ? "s" : "d"; } _fl = _notes.Notes[i0].FollowingNotes == null ? 0 : _notes.Notes[i0].FollowingNotes.Length; _time = FromTicksToMilisecond(_notes.Notes[i0].Ticks, _notes.Conductors); _x_int = Math.Floor(_notes.Notes[i0].EndX); if (_fl == 0) { _noteType = _notes.Notes[i0].Type == 100 ? "!" : _notes.Notes[i0].FlickDirection == 1 ? "L" : _notes.Notes[i0].FlickDirection == 2 ? "U" : _notes.Notes[i0].FlickDirection == 3 ? "R" : ""; _ss.Add( _time + "," + (_notes.Notes[i0].EndX == _x_int ? ((int)_x_int + 1).ToString() : "(" + (_notes.Notes[i0].EndX + 1).ToString() + ")") + _LeftRightForced + _noteType ); if (_notes.Notes[i0].FlickDirection == 0) { Handbusy[_lr].Insert(_notes.Notes[i0].Ticks, _notes.Notes[i0].Ticks + 5); } else { Handbusy[_lr].Insert(_notes.Notes[i0].Ticks - 20, _notes.Notes[i0].Ticks + 20); } } else { _ss.Add( _time + "," + (_notes.Notes[i0].EndX == _x_int ? ((int)_x_int + 1).ToString() : "(" + (_notes.Notes[i0].EndX + 1).ToString() + ")") + _LeftRightForced + "+" ); for (int i1 = 0; i1 < _fl; ++i1) { _time = FromTicksToMilisecond(_notes.Notes[i0].FollowingNotes[i1].Ticks, _notes.Conductors); _x_int = Math.Floor(_notes.Notes[i0].FollowingNotes[i1].EndX); _noteType = _notes.Notes[i0].FollowingNotes[i1].FlickDirection == 1 ? "L" : _notes.Notes[i0].FollowingNotes[i1].FlickDirection == 2 ? "U" : _notes.Notes[i0].FollowingNotes[i1].FlickDirection == 3 ? "R" : i1 + 1 == _fl ? "-" : "="; _ss.Add( _time + "," + (_notes.Notes[i0].FollowingNotes[i1].EndX == _x_int ? ((int)_x_int + 1).ToString() : "(" + (_notes.Notes[i0].FollowingNotes[i1].EndX + 1).ToString() + ")") + _LeftRightForced + _noteType ); } Handbusy[_lr].Insert(_notes.Notes[i0].Ticks, _notes.Notes[i0].FollowingNotes.Last().Ticks); } } _ss.Sort((s1, s2) => { return(Convert.ToInt32(s1.Split(',')[0]) - Convert.ToInt32(s2.Split(',')[0])); }); }
static public void ConvertMacro( ref Js_macro_OBJ _macros, ref Js_notes_OBJ _notes, ref SongName _song, ref DiffName _diff) { ((Js_macro_OBJ.class_Primitive_Combo)_macros.Primitives[0]).Description = _song.urlName + "_" + _diff.shortName + " (left)"; ((Js_macro_OBJ.class_Primitive_Combo)_macros.Primitives[1]).Description = _song.urlName + "_" + _diff.shortName + " (right)"; List <Js_macro_OBJ.class_Primitive_Combo.class_Event>[] events = { new List <Js_macro_OBJ.class_Primitive_Combo.class_Event>(0x400), new List <Js_macro_OBJ.class_Primitive_Combo.class_Event>(0x400), }; StateTimeline[] Handbusy = { new StateTimeline(), new StateTimeline(), }; for (int i0 = 0, _lr, _fl, _time; i0 < _notes.Notes.Length; ++i0) { _lr = _diff.IsLeft(_notes.Notes[i0].EndX) && !Handbusy[0].IsIn(_notes.Notes[i0].Ticks) || Handbusy[1].IsIn(_notes.Notes[i0].Ticks) ? 0 : 1; _fl = _notes.Notes[i0].FollowingNotes == null ? 0 : _notes.Notes[i0].FollowingNotes.Length; _time = FromTicksToMilisecond(_notes.Notes[i0].Ticks, _notes.Conductors); if (_fl == 0) { InsertNoteMacro( ref events[_lr], _time, _notes.Notes[i0].EndX, _notes.Notes[i0].Type == 100 ? 7 : _notes.Notes[i0].FlickDirection, ref _diff); if (_notes.Notes[i0].FlickDirection == 0) { Handbusy[_lr].Insert(_notes.Notes[i0].Ticks, _notes.Notes[i0].Ticks + 5); } else { Handbusy[_lr].Insert(_notes.Notes[i0].Ticks - 20, _notes.Notes[i0].Ticks + 20); } } else { InsertNoteMacro( ref events[_lr], _time, _notes.Notes[i0].EndX, 4, ref _diff); for (int i1 = 0; i1 < _fl; ++i1) { _time = FromTicksToMilisecond(_notes.Notes[i0].FollowingNotes[i1].Ticks, _notes.Conductors); InsertNoteMacro( ref events[_lr], _time, _notes.Notes[i0].FollowingNotes[i1].EndX, _notes.Notes[i0].FollowingNotes[i1].FlickDirection != 0 ? _notes.Notes[i0].FollowingNotes[i1].FlickDirection : i1 + 1 == _fl ? 6 : 5, ref _diff); } Handbusy[_lr].Insert(_notes.Notes[i0].Ticks, _notes.Notes[i0].FollowingNotes.Last().Ticks); } } PostProcessMacro(ref _macros, events); }
private void button_Download_Click(object sender, EventArgs e) { if ((index_song_selected = combo_SongName.SelectedIndex) == -1) { return; } if ((index_diff_selected = combo_difficulty.SelectedIndex) == -1) { return; } button_Download.Enabled = false; button_Save.Enabled = false; button_FromMacros.Enabled = false; name_save = songs[index_song_selected].fullName + "_" + diffs[index_diff_selected].shortName + ".cfg"; output_000.Text = ""; Task t = new Task(() => { try { HttpWebRequest xhr = (HttpWebRequest)WebRequest.Create("https://million.hyrorre.com/musics/" + songs[index_song_selected].urlName + "/" + diffs[index_diff_selected].urlName); xhr.Method = "GET"; Invoke(new Action(() => { output_000.Text += "Connecting... "; })); HttpWebResponse xhrr = xhr.GetResponse() as HttpWebResponse; Invoke(new Action(() => { output_000.Text += "Success.\r\nProcessingText..."; })); StreamReader sr = new StreamReader(xhrr.GetResponseStream()); string string_sr = sr.ReadToEnd(); sr.Close(); Match m_u = Regex.Match(string_sr, "(?<=<div id=\"score_str\">)[^<]*"); if (!m_u.Success) { throw new Exception("Notes information is not found."); } string_sr = Regex.Replace(m_u.Value, """, "\""); Invoke(new Action(() => { output_000.Text += "Success.\r\nParsingJSON..."; })); js_notes = JsonConvert.DeserializeObject <Js_notes_OBJ>(string_sr); Invoke(new Action(() => { if (checkBox_tempo.Checked) { js_notes.Conductors[0].Tempo = (int)numericUpDown_tempo.Value; } else { numericUpDown_tempo.Value = js_notes.Conductors[0].Tempo; } })); Converter_NotesMacro.ConvertMacro( ref js_macro, ref js_notes, ref songs[index_song_selected], ref diffs[index_diff_selected]); Invoke(new Action(() => { output_000.Text += "Success."; button_Save.Enabled = true; button_Download.Enabled = true; button_FromMacros.Enabled = true; })); } catch (Exception err) { Invoke(new Action(() => { output_000.Text += "\r\n" + err.ToString(); })); button_Download.Enabled = true; } }); t.Start(); }