Beispiel #1
0
        private void OnNewJsonAdd(string json)
        {
            int l = json.LastIndexOf("\"live_difficulty_id\"");

            if (l >= 0)
            {
                int    r   = json.IndexOf(",", l);
                string id  = "";
                string tem = json.Substring(l, r - l + 1);
                for (int i = 0; i < tem.Length; i++)
                {
                    id += (tem[i] >= 48 && tem[i] <= 57) ? tem[i].ToString() : "";
                }
                int  ldi = int.Parse(id);
                bool b   = llks.Reset(ldi);
                Log("当前选择歌曲id: " + ldi);
                if (!b)
                {
                    Log("历史记录中查询不到该歌曲,如果未捕获到谱面将会导致打歌失败");
                }
            }

            //
            //bool isCFEvent = true;
            //isCFEvent &= json.Contains("challenge_info");
            //isCFEvent &= json.Contains("round");
            //应继续搜索live_difficulty_id
            //

            bool isLiveList = false;

            isLiveList |= json.Contains("\"notes_speed\"");
            isLiveList |= json.Contains("\"is_random\"");
            isLiveList &= json.Contains("\"timing_sec\"");
            if (!isLiveList)
            {
                return;
            }

            if (json.Contains("live_list"))
            {
                MusicNotes mn = Utils.Deserialize <MusicNotes>(json);
                if (mn == null)
                {
                    return;
                }

                Live_info li = mn.response_data.live_list[0].live_info;

                llks.Reset(li);
                Log("谱面捕获 id: " + li.live_difficulty_id);
            }
        }
Beispiel #2
0
 private bool Load(int live_difficulty_id)
 {
     try
     {
         string path = LiveDifficultyPath + "/" + live_difficulty_id.ToString("00000000") + ".txt";
         if (File.Exists(path))
         {
             string json = File.ReadAllText(path);
             li = JsonConvert.DeserializeObject <Live_info>(json);
             return(true);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(false);
 }
Beispiel #3
0
        private void Btn_LoadListFromFile_Click(object sender, EventArgs e)
        {
            openFileDialog.Title = "选取谱面数据";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    string json = Encoding.UTF8.GetString(File.ReadAllBytes(openFileDialog.FileName));

                    Live_info li = Utils.Deserialize <Live_info>(json);
                    llks.Reset(li);
                    Log("手动载入谱面 id: " + li.live_difficulty_id);
                }
                catch
                {
                    Log("载入失败");
                }
            }
        }
Beispiel #4
0
 public void Reset(Live_info li)
 {
     this.li = li;
     isRun   = false;
     Save();
 }
Beispiel #5
0
        //数据来源 "http://a.llsif.win/"
        //谱面数据-名称表 "http://r.llsif.win/maps.json"
        //谱面数据-数据表 "http://a.llsif.win/live/json/[live_setting_id=1]"
        private void Btn_GetLivelist_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否从 http://llsif.win 下载谱面数据?", "下载谱面数据", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                folderBrowserDialog.Description = "选择谱面保存位置(文件夹),相同名称文件执行覆盖操作";

                if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                {
                    bool   isThread = true;
                    string message  = "";
                    new Thread(() =>
                    {
                        try
                        {
                            string listJson       = Utils.GetWebString("http://r.llsif.win/maps.json");
                            List <RD3Map> rd3Maps = Utils.Deserialize <List <RD3Map> >(listJson);
                            string path           = folderBrowserDialog.SelectedPath + "/";

                            string mapJson = Utils.Serialize(rd3Maps);
                            File.WriteAllBytes(path + "0_map.txt", Encoding.UTF8.GetBytes(mapJson));

                            for (int i = 0; i < rd3Maps.Count; i++)
                            {
                                RD3Map rd3      = rd3Maps[i];
                                string noteJson = Utils.GetWebString("http://a.llsif.win/live/json/" + rd3.live_setting_id);
                                Notes_list[] nl = Utils.Deserialize <Notes_list[]>(noteJson);
                                Live_info li    = new Live_info
                                {
                                    is_random          = false,
                                    notes_speed        = 0.0f,
                                    live_difficulty_id = rd3.live_setting_id,
                                    notes_list         = nl
                                };
                                string liveJson = Utils.Serialize(li);
                                string liveName = $"{rd3.live_setting_id.ToString("00000000")}-{rd3.name}-{rd3.difficulty_text}";
                                liveName        = liveName.ReplaceToSpace("\\", "/", ":", "*", "?", "\"", "<", ">", "|");
                                File.WriteAllBytes(path + liveName + ".txt", Encoding.UTF8.GetBytes(liveJson));

                                message = i + " / " + rd3Maps.Count;
                            }
                            isThread = false;
                            MessageBox.Show("完成");
                            LogClear();
                        }
                        catch (Exception ex)
                        {
                            isThread = false;
                            Thread.Sleep(300);
                            LogClear();
                            MessageBox.Show("网络异常\r\n" + ex.Message + ex.StackTrace);
                        }
                    }).Start();
                    new Thread(() =>
                    {
                        while (isThread)
                        {
                            LogClear();
                            Log(message);
                            Thread.Sleep(500);
                        }
                    }).Start();
                }
            }
        }