private void OpenProject_Button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.InitialDirectory = Environment.CurrentDirectory;
            fileDialog.Title            = "Select project path";
            fileDialog.CheckFileExists  = true;
            fileDialog.CheckPathExists  = true;
            fileDialog.Multiselect      = false;
            fileDialog.DefaultExt       = "wbp";
            fileDialog.Filter           = "Workbench projects (*.wbp)|*.wbp";

            var result = fileDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (!UserData.Instance.PreviousProjects.Contains(fileDialog.FileName))
                {
                    UserData.Instance.PreviousProjects.Add(fileDialog.FileName);
                    UserData.SaveUserData();
                }

                Wbp proj = new Wbp(fileDialog.FileName);
                ProjectData.Instance            = proj.getProjectData();
                ProjectData.Instance.WBP_Path   = fileDialog.FileName;
                ProjectData.Instance.LastOpened = DateTime.Now;
                proj.setProjectData(ProjectData.Instance); //update projData to have latest info (like date and path)

                JetEditor jetEditor = new JetEditor(fileDialog.FileName);
                MainWindow.Instance.Close();
            }
        }
        private void ContinueWithoutCode_Button_MouseUp(object sender, MouseButtonEventArgs e)
        {
            JetEditor jetEditor = new JetEditor();

            jetEditor.WindowState = WindowState.Maximized;
            jetEditor.Show();
            MainWindow.Instance.Close();
        }
Exemple #3
0
        private void Create_Button_Click(object sender, RoutedEventArgs e)
        {
            if (Game == GameType.None)
            {
                MessageBox.Show("Please select which game you want to create a project for");
                return;
            }

            if (Projects.Count == 0)
            {
                MessageBox.Show("Please select which type of mod you want to make");
                return;
            }

            if (String.IsNullOrEmpty(ProjPass_TextBox.Text) && Game == GameType.BTDB)
            {
                MessageBox.Show("You need to enter a password for BTD Battles jet file before you can continue");
                return;
            }

            if (ProjName_TextBox.Text.Length <= 0)
            {
                MessageBox.Show("You need to enter a project name before you can continue");
                return;
            }


            string projPath = ProjLocation_TextBox.Text;

            if (String.IsNullOrEmpty(projPath))
            {
                MessageBox.Show("You need to select where your project will be saved before you can continue");
                return;
            }

            if (File.Exists(projPath))
            {
                System.Windows.Forms.DialogResult diag = System.Windows.Forms.MessageBox.Show("A project with that name alread exists! Do you want to continue anyways?", "Overwrite existing project?", System.Windows.Forms.MessageBoxButtons.YesNo);
                if (diag == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
            }

            if (File.Exists(projPath))
            {
                File.Delete(projPath);
            }

            /* Create project metadata */
            ProjectData.Instance = new ProjectData(ProjName_TextBox.Text, projPath, DateTime.Now, Projects.Contains(ProjectTypes.Jet_Mod), Projects.Contains(ProjectTypes.Save_Mod), Projects.Contains(ProjectTypes.NKH_Mod), Game, null);
            string metaJson = JsonConvert.SerializeObject(ProjectData.Instance);

            ZipFile proj = new ZipFile(projPath);

            proj.AddEntry("meta.json", metaJson);
            foreach (var item in Projects)
            {
                proj.AddDirectoryByName(item.ToString());
            }

            proj.Save();

            JetEditor jetEditor = new JetEditor(ProjectData.Instance.WBP_Path);

            MainWindow.Instance.Close();
        }