Ejemplo n.º 1
0
        /// <summary>
        /// Ensures our Appdata folder is set up, loads the databse, etc.
        /// </summary>
        public static void InitAppData()
        {
            try
            {
                if (!Directory.Exists(AppDataPath))
                {
                    Directory.CreateDirectory(AppDataPath);
                }

                if (!Directory.Exists(ArchivesPath))
                {
                    Directory.CreateDirectory(ArchivesPath);
                }

                if (!Directory.Exists(TempPath))
                {
                    Directory.CreateDirectory(TempPath);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not create the application data folder. Please ensure you have permission to write to '" + AppDataPath + "'.\n\nThe original error was:\n\n" + ex.ToString());
                Environment.Exit(1);
            }

            try
            {
                Database.InitDatabase();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could initialize the application database. Please ensure you have permission to write to '" + AppDataPath + "'.\n\nThe original error was:\n\n" + ex.ToString());
                Environment.Exit(1);
            }

            Mod.LoadFromUrl("base_manifests/minecraft.xml");
            Mod.LoadFromUrl("singlePlayerCommands.xml");
            Mod.LoadFromUrl("test.xml");

            try
            {
                mods = Mod.LoadMods().ToDictionary(k => k.Id);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not load the list of mods from the database. Please ensure you have permission to write to '" + AppDataPath + "'.\n\nThe original error was:\n\n" + ex.ToString());
                Environment.Exit(1);
            }

            /*foreach (Mod m in Mods.Values)
             * {
             *  foreach (ModVersion v in m.Versions)
             *  {
             *      if (!v.IsDownloaded)
             *      {
             *          try
             *          {
             *              v.Download();
             *          }
             *          catch (Exception)
             *          {
             *          }
             *      }
             *
             *      if (v.IsDownloaded)
             *      {
             *          v.AnalyzeMod();
             *      }
             *  }
             * }*/
        }