Commit 39d6ffe3 authored by Pine Stone's avatar Pine Stone
Browse files

Add checks if the user is unable to download the mod list.

parent 6af8afb5
Loading
Loading
Loading
Loading
+37 −4
Original line number Original line Diff line number Diff line
@@ -126,8 +126,25 @@ namespace ModInstaller


        private void FillModsList()
        private void FillModsList()
        {
        {
            XDocument dllist = XDocument.Load("https://drive.google.com/uc?export=download&id=1HN5P35vvpFcjcYQ72XvZr35QxD09GUwh");
            XElement[] mods;
            XElement[] mods = dllist.Element("ModLinks")?.Element("ModList")?.Elements("ModLink").ToArray();
            try
            {
                XDocument dllist =
                    XDocument.Load("https://drive.google.com/uc?export=download&id=1HN5P35vvpFcjcYQ72XvZr35QxD09GUwh");
                mods = dllist.Element("ModLinks")?.Element("ModList")?.Elements("ModLink").ToArray();
            }
            catch (Exception e)
            {
                DialogResult didClose = MessageBox.Show("Unable to download mod list.\nCheck your internet settings and press ok to try again.");
                if (didClose == DialogResult.Abort || didClose == DialogResult.Cancel)
                {
                    System.Windows.Forms.Application.Exit();
                    Environment.Exit(0);
                }
                FillModsList();
                return;
            }

            foreach (XElement mod in mods)
            foreach (XElement mod in mods)
            {
            {
                if (!mod.Element("Dependencies").IsEmpty)
                if (!mod.Element("Dependencies").IsEmpty)
@@ -149,9 +166,25 @@ namespace ModInstaller
        }
        }


        private void PopulateList()
        private void PopulateList()
        {
            try
            {
            {
                List<Mod> modsSortedList = modsList.OrderBy(mod => mod.Name).ToList();
                List<Mod> modsSortedList = modsList.OrderBy(mod => mod.Name).ToList();
                modsList = modsSortedList;
                modsList = modsSortedList;
            }
            catch (InvalidOperationException e)
            {
                DialogResult didClose = MessageBox.Show("Unable to populate mod list.\n" +
                                                        "Check your internet settings and press ok to try again.");
                if (didClose == DialogResult.Abort || didClose == DialogResult.Cancel)
                {
                    System.Windows.Forms.Application.Exit();
                    Environment.Exit(0);
                }
                FillModsList();
                PopulateList();
                return;
            }


            DirectoryInfo modsFolder = new DirectoryInfo(Properties.Settings.Default.modFolder);
            DirectoryInfo modsFolder = new DirectoryInfo(Properties.Settings.Default.modFolder);
            FileInfo[] modsFiles = modsFolder.GetFiles("*.dll");
            FileInfo[] modsFiles = modsFolder.GetFiles("*.dll");