Beispiel #1
0
        public static ModDownloadObject DownloadModFromId(string modId)
        {
            var modDownloadObject = new ModDownloadObject();

            if (modId == "")
            {
                MessageBox.Show("请填写mod编号");
            }
            else
            {
                var postString   = "mid=" + modId;
                var httpPostBack = HttpHelper.HttpPost("http://t.vvwall.com/DST/modinfo.php", postString);
                Debug.WriteLine("mod Json:" + httpPostBack);
                var jObject = JObject.Parse(httpPostBack);
                if (jObject["code"].ToString() == "200")
                {
                    modDownloadObject.ModId = jObject["mid"].ToString();
                    if (jObject["title"] != null)
                    {
                        modDownloadObject.ModName = jObject["title"].ToString();
                        if (jObject["des"] != null)
                        {
                            modDownloadObject.ModDescribe = jObject["des"].ToString();
                        }
                    }
                    if (jObject["url"] != null)
                    {
                        modDownloadObject.ModDownloadUrl = jObject["url"].ToString();
                    }
                }
                else
                {
                    MessageBox.Show(jObject["code"].ToString() == "404" ? "部分功能不能使用" : "未找到该mod");
                    return(null);
                }
            }
            return(modDownloadObject);
        }
Beispiel #2
0
 public static void DownloadModFile(ModDownloadObject modDownloadObject)
 {
     Directory.CreateDirectory(@".\Temp\ModUpdate\");
     HttpHelper.DownloadFile(modDownloadObject.ModDownloadUrl, @".\Temp\ModUpdate\workshop-" + modDownloadObject.ModId + ".zip");
 }