示例#1
0
        // ----------------------------------------------------------------------------------------------
        // Update
        // ----------------------------------------------------------------------------------------------
        public void Update()
        {
            Download.waiter.Reset();
            Download.waiter = new ManualResetEvent(false);

            // Clear RetroArch Nightlies List before each run
            if (Queue.NightliesList != null)
            {
                Queue.NightliesList.Clear();
                Queue.NightliesList.TrimExcess();
            }

            //var message = string.Join(Environment.NewLine, Queue.NightliesList); //debug
            //MessageBox.Show(message); //debug

            // Add backslash to Location Textbox path if missing
            if (!string.IsNullOrEmpty(VM.MainView.RetroArchPath_Text) && !VM.MainView.RetroArchPath_Text.EndsWith("\\"))
            {
                VM.MainView.RetroArchPath_Text = VM.MainView.RetroArchPath_Text + "\\";
            }
            // Load the User's RetroArch Location from Text Box / Saved Settings
            Paths.retroarchPath = VM.MainView.RetroArchPath_Text; //end with backslash


            // If RetroArch Path is empty, halt progress
            if (string.IsNullOrEmpty(Paths.retroarchPath) &&
                VM.MainView.Download_SelectedItem != "Stellar") // ignore if Stellar Self Update
            {
                ready = false;
                MessageBox.Show("Please select your RetroArch main folder.",
                                "Notice",
                                MessageBoxButton.OK,
                                MessageBoxImage.Information);

                return;
            }

            // MUST BE IN THIS ORDER: 1. SetArchitecture -> 2. parsePage -> 3. SetArchiver  ##################
            // If you checkArchiver before parsePage, it will not set the Parse.nightly7z string in the CLI Arguments first
            // Maybe solve this by putting CLI Arguments in another method?

            // 1. Call SetArchitecture Method
            Paths.SetArchitecture();

            // 2. Call parse Page (HTML) Method
            if (VM.MainView.Download_SelectedItem == "New Install" ||
                VM.MainView.Download_SelectedItem == "Upgrade" ||
                VM.MainView.Download_SelectedItem == "RA+Cores" ||
                VM.MainView.Download_SelectedItem == "RetroArch" ||
                VM.MainView.Download_SelectedItem == "Redist")
            {
                // Progress Info
                VM.MainView.ProgressInfo_Text = "Fetching RetroArch List...";

                Parse.ParseBuildbotPage();
            }

            // 3. Call checkArchiver Method
            // If Archiver exists, Set string
            Archiver.SetArchiver(this);


            // -------------------------
            // Stellar Self-Update
            // -------------------------
            if (VM.MainView.Download_SelectedItem == "Stellar")
            {
                // Parse GitHub Page HTML
                Parse.ParseGitHubReleases();

                if (Parse.latestVersion != null && MainWindow.currentVersion != null)
                {
                    // Check if Stellar is the Latest Version
                    if (Parse.latestVersion > MainWindow.currentVersion)
                    {
                        // Yes/No Dialog Confirmation
                        //
                        MessageBoxResult result = MessageBox.Show("v" + Parse.latestVersion + "-" + Parse.latestBuildPhase + "\n\nDownload Update?", "Update Available", MessageBoxButton.YesNo);
                        switch (result)
                        {
                        case MessageBoxResult.Yes:
                            // Proceed
                            break;

                        case MessageBoxResult.No:
                            // Lock
                            MainWindow.ready = false;
                            break;
                        }
                    }
                    else if (Parse.latestVersion <= MainWindow.currentVersion)
                    {
                        // Lock
                        MainWindow.ready = false;
                        MessageBox.Show("This version is up to date.",
                                        "Notice",
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Information);
                    }
                    else // null
                    {
                        // Lock
                        MainWindow.ready = false;
                        MessageBox.Show("Could not find download. Try updating manually.",
                                        "Notice",
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Warning);
                    }
                }
            }


            // -----------------------------------------------
            // If New Install (RetroArch + Cores)
            // -----------------------------------------------
            if (VM.MainView.Download_SelectedItem == "New Install")
            {
                // -------------------------
                // Create Cores Folder
                // -------------------------
                using (Process execMakeCoresDir = new Process())
                {
                    execMakeCoresDir.StartInfo.UseShellExecute        = false;
                    execMakeCoresDir.StartInfo.Verb                   = "runas"; //use with ShellExecute for admin
                    execMakeCoresDir.StartInfo.CreateNoWindow         = true;
                    execMakeCoresDir.StartInfo.RedirectStandardOutput = true;    //set to false if using ShellExecute
                    execMakeCoresDir.StartInfo.FileName               = "cmd.exe";
                    execMakeCoresDir.StartInfo.Arguments              = "/c cd " + "\"" + Paths.retroarchPath + "\"" + " && mkdir cores";
                    execMakeCoresDir.Start();
                    execMakeCoresDir.WaitForExit();
                    execMakeCoresDir.Close();
                }

                // Set Cores Folder (Dont Scan PC)
                Paths.coresPath = Paths.retroarchPath + "cores\\";
                // Call Parse Builtbot Page Method
                Parse.ParseBuildbotCoresIndex();
            }



            // -----------------------------------------------
            // RetroArch+Cores or Cores Only Update
            // -----------------------------------------------
            if (VM.MainView.Download_SelectedItem == "New Install" ||
                VM.MainView.Download_SelectedItem == "RA+Cores" ||
                VM.MainView.Download_SelectedItem == "Cores" ||
                VM.MainView.Download_SelectedItem == "New Cores")
            {
                // Progress Info
                VM.MainView.ProgressInfo_Text = "Fetching Cores List...";

                // Create Builtbot Cores List
                Parse.ParseBuildbotCoresIndex();

                // Create PC Cores List
                Parse.ScanPcCoresDir();

                // Create Cores to Update List
                Queue.CoresToUpdate();

                // Check if Cores Up To Date
                // If All Cores up to date, display message
                Queue.CoresUpToDateCheck(); //Note there are Clears() in this method
            }



            // -----------------------------------------------
            // Ready
            // -----------------------------------------------
            if (ready == true)
            {
                // Start Download
                if (CheckForInternetConnection() == true)
                {
                    Download.StartDownload();
                }
                // Internet Connection Failed
                else
                {
                    MessageBox.Show("Could not detect Internet Connection.",
                                    "Error",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);

                    return;
                }
            }
            else
            {
                // Restart & Reset ready value
                ready = true;
                // Call Garbage Collector
                GC.Collect();
            }
        }
示例#2
0
        // -----------------------------------------------
        // Update Button
        // -----------------------------------------------
        // Launches Download and 7-Zip Extraction
        private void buttonUpdate_Click(object sender, RoutedEventArgs e)
        {
            // Add backslash to Location Textbox path if missing
            if (!textBoxLocation.Text.EndsWith("\\") && !string.IsNullOrWhiteSpace(textBoxLocation.Text))
            {
                textBoxLocation.Text = textBoxLocation.Text + "\\";
            }
            // Load the User's RetroArch Location from Text Box / Saved Settings
            Paths.retroarchPath = textBoxLocation.Text; //end with backslash


            // If RetroArch Path is empty, halt progress
            if (string.IsNullOrEmpty(Paths.retroarchPath) &&
                (string)comboBoxDownload.SelectedItem != "Stellar")    // ignore if Stellar Self Update
            {
                ready = false;
                MessageBox.Show("Please select your RetroArch main folder.");
            }

            // MUST BE IN THIS ORDER: 1. SetArchitecture -> 2. parsePage -> 3. SetArchiver  ##################
            // If you checkArchiver before parsePage, it will not set the Parse.nightly7z string in the CLI Arguments first
            // Maybe solve this by putting CLI Arguments in another method?

            // 1. Call SetArchitecture Method
            Paths.SetArchitecture(this);

            // 2. Call parse Page (HTML) Method
            Parse.ParseBuildbotPage(this);

            // 3. Call checkArchiver Method
            // If Archiver exists, Set string
            Archiver.SetArchiver(this);


            // -------------------------
            // Stellar Self-Update
            // -------------------------
            if ((string)comboBoxDownload.SelectedItem == "Stellar")
            {
                // Parse GitHub Page HTML
                Parse.ParseGitHubReleases(this);

                if (Parse.latestVersion != null && MainWindow.currentVersion != null)
                {
                    // Check if Stellar is the Latest Version
                    if (Parse.latestVersion > MainWindow.currentVersion)
                    {
                        // Yes/No Dialog Confirmation
                        //
                        MessageBoxResult result = MessageBox.Show("v" + Parse.latestVersion + "-" + Parse.latestBuildPhase + "\n\nDownload Update?", "Update Available", MessageBoxButton.YesNo);
                        switch (result)
                        {
                        case MessageBoxResult.Yes:
                            // Proceed
                            break;

                        case MessageBoxResult.No:
                            // Lock
                            MainWindow.ready = false;
                            break;
                        }
                    }
                    else if (Parse.latestVersion <= MainWindow.currentVersion)
                    {
                        // Lock
                        MainWindow.ready = false;
                        MessageBox.Show("This version is up to date.");
                    }
                    else // null
                    {
                        // Lock
                        MainWindow.ready = false;
                        MessageBox.Show("Could not find download. Try updating manually.");
                    }
                }
            }


            // -----------------------------------------------
            // If New Install (RetroArch + Cores)
            // -----------------------------------------------
            if ((string)comboBoxDownload.SelectedItem == "New Install")
            {
                // -------------------------
                // Create Cores Folder
                // -------------------------
                using (Process execMakeCoresDir = new Process())
                {
                    execMakeCoresDir.StartInfo.UseShellExecute        = false;
                    execMakeCoresDir.StartInfo.Verb                   = "runas"; //use with ShellExecute for admin
                    execMakeCoresDir.StartInfo.CreateNoWindow         = true;
                    execMakeCoresDir.StartInfo.RedirectStandardOutput = true;    //set to false if using ShellExecute
                    execMakeCoresDir.StartInfo.FileName               = "cmd.exe";
                    execMakeCoresDir.StartInfo.Arguments              = "/c cd " + "\"" + Paths.retroarchPath + "\"" + " && mkdir cores";
                    execMakeCoresDir.Start();
                    execMakeCoresDir.WaitForExit();
                    execMakeCoresDir.Close();
                }

                // Set Cores Folder (Dont Scan PC)
                Paths.coresPath = Paths.retroarchPath + "cores\\";
                // Call Parse Builtbot Page Method
                Parse.ParseBuildbotCoresIndex(this);
            }



            // -----------------------------------------------
            // If RetroArch+Cores or Cores Only Update
            // -----------------------------------------------
            // RA+Cores or Cores Selected
            if ((string)comboBoxDownload.SelectedItem == "New Install" ||
                (string)comboBoxDownload.SelectedItem == "RA+Cores" ||
                (string)comboBoxDownload.SelectedItem == "Cores" ||
                (string)comboBoxDownload.SelectedItem == "New Cores")
            {
                // Create Builtbot Cores List
                Parse.ParseBuildbotCoresIndex(this);

                // Create PC Cores List
                Parse.ScanPcCoresDir(this);

                // Create Cores to Update List
                Queue.UpdatedCores(this);

                // Check if Cores Up To Date
                // If All Cores up to date, display message
                Queue.CoresUpToDateCheck(this); //Note there are Clears() in this method
            }



            // -----------------------------------------------
            // Ready
            // -----------------------------------------------
            if (ready == true)
            {
                Download.StartDownload(this);
            }
            else
            {
                // Restart & Reset ready value
                ready = true;
                // Call Garbage Collector
                GC.Collect();
            }
        }