Esempio n. 1
0
        private void DownloadNewVersion()
        {
            if (File.Exists(NetUtils.DownloadedTargetTempPath))
            {
                File.Delete(NetUtils.DownloadedTargetTempPath);
            }

            var downloadForm = new DownloadForm("Download Update");

            downloadForm.OnCancel += (o, e) =>
            {
                NetUtils.Cancel();
            };

            NetUtils.OnProgressChanged += (o, e) =>
            {
                downloadForm.SetValues(e.CurrentSpeed, e.TotalSize, e.TotalDownloaded, e.Remaining, e.CurrentPercentage);
            };
            NetUtils.OnError += (o, e) =>
            {
            };
            NetUtils.OnDownloadCompleted += (o, e) =>
            {
                downloadForm.Close();
                ApplyUpdate();
            };
            downloadForm.Show(this);
            NetUtils.DownloadLatestVersion();
        }
Esempio n. 2
0
        public async void DoIfUpdateNeeded(CurrentProjectClass project)
        {
            if (project.ProjectVersion == "1.0.0")
            {
                if (!Directory.Exists(project.ProjectPath + "/dependencies"))
                {
                    //Setup sampctl for it
                    project.SampCtlData = new PawnJson()
                    {
                        entry        = "gamemodes\\" + project.ProjectName + ".pwn",
                        output       = "gamemodes\\" + project.ProjectName + ".amx",
                        user         = Environment.UserName,
                        repo         = project.ProjectName,
                        dependencies = new List <string>()
                        {
                            "sampctl/samp-stdlib"
                        },
                        builds = new List <BuildInfo>()
                        {
                            new BuildInfo()
                            {
                                name = "main",
                                args = Program.SettingsForm.GetCompilerArgs().Split(' ').ToList()
                            }
                        },
                        runtime = new RuntimeInfo()
                        {
                            version = "latest"
                        },
                    };
                    project.SaveInfo();
                    project.LoadSampCtlData(); //to make sure pawno/includes is also supported.
                    DownloadForm frm = new DownloadForm
                    {
                        progressBar1 = { Style = ProgressBarStyle.Marquee },
                        descLabel    = { Text = translations.StartupForm_CreateProjectBtn_Click_Ensuring_packages }
                    };
                    frm.Show();
                    await SampCtl.SendCommand(Path.Combine(Application.StartupPath, "sampctl.exe"), project.ProjectPath, "p ensure");

                    frm.Close();
                }
            }
            project.ProjectVersion = CurrentVersion;
        }
Esempio n. 3
0
        private async void CreateProjectBtn_Click(object sender, EventArgs e)
        {
            string newPath = Convert.ToString(locTextBox.PathText.Text);

            if (preExistCheck.Checked)
            {
                if (!Directory.Exists(newPath) ||
                    GeneralFunctions.IsValidExtremeProject(newPath) || !GeneralFunctions.IsValidSAMPFolder(newPath))
                {
                    MessageBox.Show(
                        Convert.ToString(translations.StartupForm_CreateProjectBtn_Click_InvalidSampFolder));
                    return;
                }
                else
                {
                    //Create the default file
                    if (!File.Exists(newPath + "/gamemodes/" + nameTextBox.Text + ".pwn"))
                    {
                        File.WriteAllText(
                            newPath + "/gamemodes/" + nameTextBox.Text + ".pwn",
                            Convert.ToString(Properties.Resources.newfileTemplate));
                    }

                    //Fill pawnctl data
                    Program.MainForm.CurrentProject.SampCtlData = new PawnJson()
                    {
                        entry        = "gamemodes\\" + nameTextBox.Text + ".pwn",
                        output       = "gamemodes\\" + nameTextBox.Text + ".amx",
                        user         = Environment.UserName,
                        repo         = nameTextBox.Text,
                        dependencies = new List <string>()
                        {
                            "sampctl/samp-stdlib"
                        },
                        builds = new List <BuildInfo>()
                        {
                            new BuildInfo()
                            {
                                name = "main",
                                args = Program.SettingsForm.GetCompilerArgs().Split(' ').ToList()
                            }
                        },
                        runtime = new RuntimeInfo()
                        {
                            version = verListBox.SelectedItem?.ToString() ?? "latest"
                        },
                    };
                    Program.MainForm.CurrentProject.ProjectName    = nameTextBox.Text;
                    Program.MainForm.CurrentProject.ProjectPath    = newPath;
                    Program.MainForm.CurrentProject.ProjectVersion = _versionHandler.CurrentVersion;
                    Program.MainForm.CurrentProject.CreateTables();    //Create the tables of the db.
                    Program.MainForm.CurrentProject.SaveInfo();        //Write the default extremeStudio config.
                    Program.MainForm.CurrentProject.CopyGlobalConfig();
                    Program.MainForm.CurrentProject.LoadSampCtlData(); //to ensure pawno/includes is there.

                    //Ensure the packages are ready
                    DownloadForm frm = new DownloadForm
                    {
                        progressBar1 = { Style = ProgressBarStyle.Continuous },
                        descLabel    = { Text = translations.StartupForm_CreateProjectBtn_Click_Ensuring_packages }
                    };
                    frm.Show();
                    Enabled = false;
                    await SampCtl.SendCommand(Path.Combine(Application.StartupPath, "sampctl.exe"), newPath, "p ensure");

                    frm.Close();
                    Enabled = true;

                    AddNewRecent(
                        Convert.ToString(Program.MainForm.CurrentProject.ProjectPath)); //Add it to the recent list.
                    Program.MainForm.Show();
                    _isClosedProgram = true;
                    Close();
                }
            }
            else
            {
                //Add to the path folder name.
                if (nameTextBox.Text.IsValidFileName() == false)
                {
                    MessageBox.Show(
                        Convert.ToString(translations.StartupForm_CreateProjectBtn_Click_InvalidName));
                    return;
                }

                newPath = Path.Combine(Convert.ToString(locTextBox.PathText.Text),
                                       Convert.ToString(nameTextBox.Text));
                if (!string.IsNullOrEmpty(newPath) &&
                    Directory.Exists(newPath) == false)
                {
                    Directory.CreateDirectory(newPath);
                }

                //Check if entered path exist.
                if (Directory.Exists(newPath) &&
                    File.Exists(
                        newPath + "/extremeStudio.config") == false)
                {
                    if (verListBox.SelectedIndex != -1)
                    {
                        //Create directories.
                        Directory.CreateDirectory(newPath + "/gamemodes");
                        Directory.CreateDirectory(newPath + "/plugins");
                        Directory.CreateDirectory(newPath + "/scriptfiles");

                        //Create the default file
                        File.WriteAllText(
                            newPath + "/gamemodes/" + nameTextBox.Text + ".pwn",
                            Convert.ToString(Properties.Resources.newfileTemplate));

                        //Fill pawnctl data
                        Program.MainForm.CurrentProject.SampCtlData = new PawnJson()
                        {
                            entry        = "gamemodes\\" + nameTextBox.Text + ".pwn",
                            output       = "gamemodes\\" + nameTextBox.Text + ".amx",
                            user         = Environment.UserName,
                            repo         = nameTextBox.Text,
                            dependencies = new List <string>()
                            {
                                "sampctl/samp-stdlib"
                            },
                            builds = new List <BuildInfo>()
                            {
                                new BuildInfo()
                                {
                                    name = "main", args = Program.SettingsForm.GetCompilerArgs().Split(' ').ToList()
                                }
                            },
                            runtime = new RuntimeInfo()
                            {
                                version = verListBox.SelectedItem.ToString()
                            },
                        };
                        Program.MainForm.CurrentProject.ProjectName    = nameTextBox.Text;
                        Program.MainForm.CurrentProject.ProjectPath    = newPath;
                        Program.MainForm.CurrentProject.ProjectVersion = _versionHandler.CurrentVersion;
                        Program.MainForm.CurrentProject.CreateTables(); //Create the tables of the db.
                        Program.MainForm.CurrentProject.SaveInfo();     //Write the default extremeStudio config.
                        Program.MainForm.CurrentProject.CopyGlobalConfig();

                        //Ensure the packages are ready
                        DownloadForm frm = new DownloadForm
                        {
                            progressBar1 = { Style = ProgressBarStyle.Marquee },
                            descLabel    = { Text = translations.StartupForm_CreateProjectBtn_Click_Ensuring_packages }
                        };
                        frm.Show();
                        Enabled = false;
                        await SampCtl.SendCommand(Path.Combine(Application.StartupPath, "sampctl.exe"), newPath, "p ensure");

                        frm.Close();
                        Enabled = true;

                        AddNewRecent(
                            Convert.ToString(Program.MainForm.CurrentProject.ProjectPath)); //Add it to the recent list.
                        Program.MainForm.Show();
                        _isClosedProgram = true;
                        Close();
                    }
                    else
                    {
                        MessageBox.Show(
                            Convert.ToString(translations.StartupForm_CreateProjectBtn_Click_NoSampSelected));
                        return;
                    }
                }
                else
                {
                    MessageBox.Show(Convert.ToString(translations.StartupForm_CreateProjectBtn_Click_DirError));
                    return;
                }
            }
        }