private void Main_Load(object sender, EventArgs e)                        //When the form is done loading
 {
     USM.createDirs();                                                     //Create the needed directories
     USM.createFiles();                                                    //Create the needed files
     if (Directory.GetDirectories(USM.DIR_SAVES).Count() < 64)             //Check if a preset save is missing?
     {
         if (Directory.GetDirectories(USM.DIR_SAVES).Count() > 0)          //If there are any saves
         {
             foreach (string d in Directory.GetDirectories(USM.DIR_SAVES)) //Foreach preset save
             {
                 Directory.Delete(d, true);                                //Delete
             }
         }
         GetSaveFiles.downloadSaves(USM.LINK_SAVEFILES); //Download the preset saves and extract them to the saves folder
     }
     foreach (string dir in Directory.GetDirectories(USM.DIR_SAVES))
     {
         DirectoryInfo info = new DirectoryInfo(dir);
         cb_save.Items.Add(info.Name);
         saves.Add(info.FullName);
     }
     refreshInfo();
 }
Пример #2
0
 static public void set(string path) //Set the save to the selected path
 {
     if (USM.getSetting("CreateBackup") == "True")
     {
         string name = Prompt.ShowDialog("Please enter a name for the backup", "Backup - USMCE"); //Get a name for the backup
         if (!string.IsNullOrEmpty(name))                                                         //If the name is valid
         {
             Random r = new Random();                                                             //Create random instance
             string b = r.Next(0, 1000000).ToString();                                            //Create random number (This is so that backups have their own unique id)
             Save.backup(USM.DIR_BACKUPS + @"\bu_id_" + b, true, name, @"bu_id_" + b);            //Call the backup function
         }
         else //If not
         {
             MessageBox.Show("Backup has not been made: Name may not be empty. Canceled setting the save!");
             return;
         }
     }
     if (verify(path))
     { //If the save file is valid
         string[] savefiles = Directory.GetFiles(path);
         string[] utfiles   = Directory.GetFiles(USM.DIR_UNDERTALE);
         foreach (string file in utfiles)//Delete the current save files
         {
             File.Delete(file);
         }
         foreach (string save in savefiles) //Replace them with the new ones
         {
             FileInfo info = new FileInfo(save);
             File.Copy(save, USM.DIR_UNDERTALE + @"\" + info.Name, true);
         }
     }
     else
     {
         MessageBox.Show("Invalid save"); //Tell the user something is wrong
     }
 }