コード例 #1
0
        public modInfo[] load_mods_info()
        {
            string  data = File.ReadAllText(Hoi4_Mods);
            JObject mods = JObject.Parse(data);

            IList <JToken> results = mods.Children().Children().ToList();

            IList <modInfo> modsList = new List <modInfo>();

            foreach (JToken result in results)
            {
                modInfo mod = result.ToObject <modInfo>();
                modsList.Add(mod);
            }
            return(modsList.ToArray());
        }
コード例 #2
0
        private void UpdateModList(object data)
        {
            ClearList();
            DisableBtns();
            SetProgressBarMaxValue(3);
            SetStatusLabelText("Updating mods...");
            bool AllowUnstable = (bool)data;

            try
            {
                WebClient      wc       = new WebClient();
                string         jsonBack = wc.DownloadString(@"https://repo.evemodx.com/api/v1/getmods");
                ModsJsonStruct obj      = JsonConvert.DeserializeObject <ModsJsonStruct>(jsonBack);
                SetStatusLabelText("validating...");
                SetProgressBarValue(2);
                foreach (modInfo mod in obj.data)
                {
                    if (!AllowUnstable && mod.type == "不稳定")
                    {
                        continue;
                    }
                    string InstV = "";
                    if (File.Exists(@"mod/" + mod.modname + ".zip"))
                    {
                        modInfo tempMI = EVEModX.Program.FRM.Mods.Find(i => i.modname == mod.modname);
                        InstV = tempMI.Version.ToString();
                    }
                    AddListItem(new ListViewItem(new string[] { mod.modname, mod.author, mod.brief, InstV, mod.Version.ToString(), mod.type }));
                    Mods.Add(mod);
                }
                SetStatusLabelText("Update completed.");
                SetProgressBarValue(3);
            }catch (Exception e)
            {
                MessageBox.Show("Update failed, reason:" + e.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Logger.Warning("Warning: " + e.Message + "  (" + e.HResult + ")");
            }
            isFirstInit = false;
            EnableBtns();
        }