Beispiel #1
0
        private void button_FromMacros_Click(object sender, EventArgs e)
        {
            if (js_notes == null)
            {
                MessageBox.Show("Notes data is not loaded.");
                return;
            }

            List <string> ss = new List <string>(0x400);

            Converter_NotesMacro.MacroToString(ref ss, ref js_notes);
            text_Score.Text                = string.Join("\r\n", ss);
            textb_SongName.Text            = songs[index_song_selected].urlName;
            combo_difficulty.SelectedIndex = index_diff_selected;

            tabC_main.SelectedIndex = 1;
        }
Beispiel #2
0
        private void button_ToMacros_Click(object sender, EventArgs e)
        {
            if ((index_song_selected = combo_SongName.SelectedIndex) == -1)
            {
                return;
            }
            if ((index_diff_selected = combo_difficulty.SelectedIndex) == -1)
            {
                return;
            }
            name_save = textb_SongName.Text + "_" + diffs[index_diff_selected].shortName + ".cfg";

            if (MessageBox.Show(
                    "The current difficulty is \"" + diffs[index_diff_selected].displayName + "\". Sure?",
                    "Confirm",
                    MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }

            button_ToMacros.Enabled   = false;
            button_Save.Enabled       = false;
            button_FromMacros.Enabled = false;

            output_000.Text = "Processing...";

            try {
                Converter_NotesMacro.ConvertMacro(
                    ref js_macro,
                    text_Score.Lines,
                    textb_SongName.Text,
                    ref diffs[index_diff_selected]);
            }
            catch (Exception err) {
                output_000.Text        += "\r\n" + err.ToString();
                button_ToMacros.Enabled = true;
            }

            MessageBox.Show("Done.");
            output_000.Text        += "Done.";
            button_ToMacros.Enabled = true;
            button_Save.Enabled     = true;
        }
Beispiel #3
0
        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, "&quot;", "\"");

                    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();
        }