Ejemplo n.º 1
0
 public void RestoreToOriginal()
 {
     if (!filename.Contains(New_JsonEditor.readOnlyName))
     {
         DialogResult diag = MessageBox.Show("You are trying to restore this file to the original unmodded version. Are you sure you want to do this?", "Restore to original?", MessageBoxButtons.YesNo);
         if (diag == DialogResult.Yes)
         {
             string backupProj = Environment.CurrentDirectory + "\\Backups\\" + CurrentProjectVariables.GameName + "_BackupProject\\" + path.Replace(CurrentProjectVariables.PathToProjectFiles.Replace("\\\\", "\\"), "");
             if (File.Exists(backupProj))
             {
                 if (path.Contains("."))
                 {
                     if (File.Exists(path))
                     {
                         JsonEditorHandler.CloseFile(path);
                         File.Delete(path);
                     }
                     File.Copy(backupProj, path);
                     JsonEditorHandler.OpenFile(path);
                     ConsoleHandler.append_CanRepeat(filename + "has been restored");
                 }
             }
             else
             {
                 ConsoleHandler.append_CanRepeat("Could not find file in backup project... Unable to restore file");
             }
         }
         else
         {
             ConsoleHandler.append_CanRepeat("User cancelled restore");
         }
     }
     else
     {
         ConsoleHandler.append_Notice("You can't restore this file because it IS the original " + filename.Replace(New_JsonEditor.readOnlyName, "") + " and it is read only");
     }
 }
Ejemplo n.º 2
0
        private void CloseFile_Button_Click(object sender, EventArgs e)
        {
            string jetpath       = CurrentProjectVariables.PathToProjectClassFile + "\\" + CurrentProjectVariables.ProjectName + ".jet";
            string backupJetPath = Environment.CurrentDirectory + "\\Backups\\" + CurrentProjectVariables.GameName + "_Original.jet";

            ZipFile backup = new ZipFile(backupJetPath);

            backup.Password = CurrentProjectVariables.JetPassword;

            if (!jsonError)
            {
                JsonEditorHandler.CloseFile(path);
                Serializer.SaveSettings();
            }
            else
            {
                DialogResult dialogResult = MessageBox.Show("This file has a JSON error! Are you sure you want to close and save it?", "ARE YOU SURE!!!!!", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    JsonEditorHandler.CloseFile(path);
                    Serializer.SaveSettings();
                }
            }
        }