コード例 #1
0
        private static async Task <bool> CheckUpdate()
        {
            SplashScreen.SetText("Checking for updates...");

            var isUpToDate = await UpdateManager.IsUpToDate().ConfigureAwait(false);

            if (isUpToDate)
            {
                return(false);
            }

            SetForegroundWindow(Process.GetCurrentProcess().MainWindowHandle);
            bool result = App.Current.Dispatcher.Invoke(() =>
            {
                var patchnotes = new UpdatePopup();
                patchnotes.ShowDialog();
                if ((patchnotes.DialogResult ?? false) != true)
                {
                    return(false);
                }
                return(UpdateManager.Update());
            });

            return(result);
        }
コード例 #2
0
ファイル: Updater.cs プロジェクト: sjb8100/uplift
        private static IEnumerator CheckForUpdateRoutine()
        {
            IEnumerator e = GitHub.LoadReleases("https://api.github.com/repos/DragonBox/uplift/releases");

            while (e.MoveNext())
            {
                yield return(e.Current);
            }

            GitHubRelease[] releases = (GitHubRelease[])e.Current;

            if (releases == null)
            {
                Debug.LogError("Unable to check for Uplift updates");
            }
            else if (!releases.Any(release => VersionParser.GreaterThan(release.tag, About.Version)))
            {
                Debug.Log("No udpate for Uplift available");
            }
            else
            {
                UpdatePopup popup = EditorWindow.GetWindow(typeof(UpdatePopup), true) as UpdatePopup;
                popup.SetReleases(releases.Where(release => VersionParser.GreaterThan(release.tag, About.Version, true)).ToArray());
            }
            EditorApplication.update -= EditorUpdate;
            EditorPrefs.SetString(
                lastUpdateCheckKey,
                DateTime.UtcNow.ToString(dateFormat, provider)
                );
        }
コード例 #3
0
        private async void OnProgressStoryboardCompleted(object sender, object e)
        {
            LikeButton.State     = ProgressState.Completed;
            CoinButton.State     = ProgressState.Completed;
            FavoriteButton.State = ProgressState.Completed;
            await Task.Delay(TimeSpan.FromSeconds(2));

            var _updatePopup = new UpdatePopup();

            _updatePopup.ShowPopup();
        }
コード例 #4
0
        public async void CheckAppUpdate()
        {
            string localVersion = AppTool.GetLocalSetting(Settings.LocalVersion, "");
            string nowVersion   = string.Format("{0}.{1}.{2}.{3}", Package.Current.Id.Version.Major, Package.Current.Id.Version.Minor, Package.Current.Id.Version.Build, Package.Current.Id.Version.Revision);

            if (localVersion != nowVersion)
            {
                var updateFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Others/Update.txt"));

                string updateInfo = await FileIO.ReadTextAsync(updateFile);

                if (_updatePopup == null)
                {
                    _updatePopup = new UpdatePopup(updateInfo);
                }
                _updatePopup.ShowPopup();
                AppTool.WriteLocalSetting(Settings.LocalVersion, nowVersion);
            }
        }
コード例 #5
0
        public void ChangeVisualStatus()
        {
            if (!string.IsNullOrEmpty(LatestLauncherBuild))
            {
                var Revisions = CurrentLauncherBuild.CompareTo(LatestLauncherBuild);

                if (Revisions > 0)
                {
                    text.Text = "Launcher Status:\n - Insider Build";
                    status.BackgroundImage = Theming.UpdateIconWarning;
                    text.ForeColor         = Theming.Alert;
                    description.Text       = "Version: v" + Application.ProductVersion;

                    if (!string.IsNullOrEmpty(FileSettingsSave.IgnoreVersion))
                    {
                        FileSettingsSave.IgnoreVersion = String.Empty;
                        FileSettingsSave.SaveSettings();
                        Log.Info("IGNOREUPDATEVERSION: Cleared OLD IgnoreUpdateVersion Build Number. You're now on the Insider Build Branch!");
                    }
                }
                else if (Revisions == 0)
                {
                    text.Text = "Launcher Status:\n - Current Version";
                    status.BackgroundImage = Theming.UpdateIconSuccess;
                    text.ForeColor         = Theming.Sucess;
                    description.Text       = "Version: v" + Application.ProductVersion;

                    if (FileSettingsSave.IgnoreVersion == Application.ProductVersion)
                    {
                        FileSettingsSave.IgnoreVersion = String.Empty;
                        FileSettingsSave.SaveSettings();
                        Log.Info("IGNOREUPDATEVERSION: Cleared OLD IgnoreUpdateVersion Build Number. You're now on the Latest Game Launcher!");
                    }
                }
                else
                {
                    text.Text = "Launcher Status:\n - Update Available";
                    status.BackgroundImage = Theming.UpdateIconWarning;
                    text.ForeColor         = Theming.Alert;
                    description.Text       = "New Version: " + LatestLauncherBuild.ToString();

                    if (FileSettingsSave.IgnoreVersion == LatestLauncherBuild.ToString())
                    {
                        //No Update Popup
                        //Blame DavidCarbon if this Breaks (to some degree), not Zacam...
                    }
                    else
                    {
                        DialogResult updateConfirm = new UpdatePopup(LatestLauncherBuild).ShowDialog();

                        if (updateConfirm == DialogResult.OK)
                        {
                            if (File.Exists("GameLauncherUpdater.exe"))
                            {
                                Process.Start(@"GameLauncherUpdater.exe", Process.GetCurrentProcess().Id.ToString());
                            }
                            else
                            {
                                Process.Start(@"https://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases/latest");
                            }
                        }
                        ;

                        //Check if User clicked Ignore so it doesn't update "IgnoreUpdateVersion"
                        if (updateConfirm == DialogResult.Cancel)
                        {
                            FileSettingsSave.IgnoreVersion = String.Empty;
                        }
                        ;

                        //Write to Settings.ini to Skip Update
                        if (updateConfirm == DialogResult.Ignore)
                        {
                            FileSettingsSave.IgnoreVersion = LatestLauncherBuild.ToString();
                        }
                        ;
                    }
                    FileSettingsSave.SaveSettings();
                }
            }
            else
            {
                text.Text = "Launcher Status:\n - Backend Error";
                status.BackgroundImage = Theming.UpdateIconError;
                text.ForeColor         = Theming.Error;
                description.Text       = "Version: v" + Application.ProductVersion;
            }
            //----------------------//
        }
コード例 #6
0
        private static bool UpdateStatusResult()
        {
            bool StatusUpdate = false;

            if (!string.IsNullOrWhiteSpace(LatestLauncherBuild))
            {
                Revisions = CurrentLauncherBuild.CompareTo(LatestLauncherBuild);

                if (Revisions < 0)
                {
                    Log.Info("LAUNCHER POPUP: Checking if Popup is Required");

                    if (FileSettingsSave.IgnoreVersion != LatestLauncherBuild)
                    {
                        FunctionStatus.LoadingComplete = true;
                        SplashScreen.ThreadStatus("Stop");
                        UpdatePopupStoppedSplashScreen = true;

                        DialogResult UserResult = new UpdatePopup().ShowDialog();

                        if (UserResult == DialogResult.OK)
                        {
                            StatusUpdate = true;
                            string UpdaterPath = Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameUpdater));
                            if (File.Exists(UpdaterPath))
                            {
                                Process.Start(UpdaterPath, Process.GetCurrentProcess().Id.ToString() + " " +
                                              (EnableInsiderBetaTester.Allowed() || EnableInsiderDeveloper.Allowed() ? "Preview" : "Stable"));
                            }
                            else
                            {
                                Process.Start(@"https://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases/latest");
                                MessageBox.Show(null, Translations.Database("LauncherUpdateCheck_FS"), "GameLauncher", MessageBoxButtons.OK);
                            }
                        }
                        else if (UserResult == DialogResult.Ignore)
                        {
                            /* Save and Allow Version Update Skip Once user Reaches Main Screen */
                            SkipAvailableUpgrade = true;
                        }
                    }
                    else
                    {
                        Log.Completed("LAUNCHER POPUP: User Saved Skip Version Detected");
                    }
                }
                else
                {
                    Log.Completed("LAUNCHER POPUP: Update to Date");
                }
            }
            else
            {
                Log.Completed("LAUNCHER POPUP: Unable to run Update Popup (Null String)");
            }

            if (VersionJSON != null)
            {
                VersionJSON = null;
            }

            return(StatusUpdate);
        }
コード例 #7
0
        public void checkAvailability()
        {
            text.Text        = "Launcher Status - Checking...";
            description.Text = "Version : v" + Application.ProductVersion;
            status.Image     = Properties.Resources.ac_unknown;
            text.ForeColor   = Color.FromArgb(0x848484);

            try {
                WebClientWithTimeout update_data = new WebClientWithTimeout();
                update_data.CancelAsync();
                update_data.DownloadStringAsync(new Uri(Self.mainserver + "/update.php?version=" + Application.ProductVersion));
                update_data.DownloadStringCompleted += (sender, e) => {
                    if (description.InvokeRequired == true)
                    {
                        description.Invoke(new Action(delegate() {
                            description.Visible = true;
                        }));
                    }
                    else
                    {
                        description.Visible = true;
                    }

                    if (e.Cancelled)
                    {
                        text.Text        = "Launcher Status - Error";
                        status.Image     = Properties.Resources.ac_error;
                        text.ForeColor   = Color.FromArgb(254, 0, 0);
                        description.Text = "Event cancelled.";
                    }
                    else if (e.Error != null)
                    {
                        text.Text        = "Launcher Status";
                        status.Image     = Properties.Resources.ac_success;
                        text.ForeColor   = Color.FromArgb(0x9fc120);
                        description.Text = "Version : v" + Application.ProductVersion;
                    }
                    else
                    {
                        UpdateCheckResponse updater = JsonConvert.DeserializeObject <UpdateCheckResponse>(e.Result);

                        try {
                            if (updater.Code == 0)
                            {
                                if (updater.Payload.UpdateExists == false)
                                {
                                    if (updater.Payload.LatestVersion.CompareTo(updater.Payload.ClientVersion) >= 0)
                                    {
                                        text.Text      = "Launcher Status - Updated";
                                        status.Image   = Properties.Resources.ac_success;
                                        text.ForeColor = Color.FromArgb(0x9fc120);
                                    }
                                    else
                                    {
                                        text.Text      = "Launcher Status - Prerelease";
                                        status.Image   = Properties.Resources.ac_warning;
                                        text.ForeColor = Color.Yellow;
                                    }

                                    description.Text = "Version : v" + Application.ProductVersion;
                                }
                                else
                                {
                                    text.Text        = "Launcher Status - Available";
                                    status.Image     = Properties.Resources.ac_warning;
                                    text.ForeColor   = Color.Yellow;
                                    description.Text = "New Version : " + updater.Payload.LatestVersion;

                                    Application.DoEvents();
                                    Thread.Sleep(3000);

                                    DialogResult updateConfirm = new UpdatePopup(updater).ShowDialog();

                                    if (updateConfirm == DialogResult.OK)
                                    {
                                        progress.Text = "DOWNLOADING GAMELAUNCHERUPDATER.EXE";
                                        new WebClientWithTimeout().DownloadFile(new Uri(Self.fileserver + "/GameLauncherUpdater.exe"), "GameLauncherUpdater.exe");
                                        Process.Start(@"GameLauncherUpdater.exe", Process.GetCurrentProcess().Id.ToString());
                                        //Let's fetch new downloader

                                        /*Properties.Settings.Default.IsRestarting = false;
                                         * Properties.Settings.Default.Save();
                                         *
                                         * WebClientWithTimeout updateDownload = new WebClientWithTimeout();
                                         * updateDownload.DownloadFileAsync(new Uri(updater.Payload.Update.DownloadUrl), "update.sbrw");
                                         * updateDownload.DownloadProgressChanged += (x, y) => {
                                         *  progress.Text = "DOWNLOADING UPDATE: " + y.ProgressPercentage + "%";
                                         * };
                                         *
                                         * updateDownload.DownloadFileCompleted += (x, y) => {
                                         *  progress.Text = "READY!";
                                         *
                                         *  if (File.Exists("Update.exe")) {
                                         *      Process.Start(@"Update.exe");
                                         *  } else {
                                         *      Process.Start(@"https://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases/latest");
                                         *  }
                                         *
                                         *  Process.GetProcessById(Process.GetCurrentProcess().Id).Kill();
                                         * };*/
                                    }
                                    ;
                                }
                            }
                            else
                            {
                                text.Text        = "Launcher Status - GitHub Error";
                                status.Image     = Properties.Resources.ac_error;
                                text.ForeColor   = Color.FromArgb(254, 0, 0);
                                description.Text = "Version : v" + Application.ProductVersion;
                            }
                        } catch (Exception ex) {
                            MessageBox.Show(ex.Message);

                            if (text.InvokeRequired == true) //checks skip, because we only need to know if we can access ui from actual thread
                            {
                                text.Invoke(new Action(delegate()
                                {
                                    text.Text      = "Launcher Status - Backend Error";
                                    text.ForeColor = Color.FromArgb(254, 0, 0);
                                }));
                                status.Invoke(new Action(delegate()
                                {
                                    status.Image = Properties.Resources.ac_error;
                                }));
                                description.Invoke(new Action(delegate()
                                {
                                    description.Text = "Version : v" + Application.ProductVersion;
                                }));
                            }
                            else
                            {
                                text.Text        = "Launcher Status - Backend Error";
                                status.Image     = Properties.Resources.ac_error;
                                text.ForeColor   = Color.FromArgb(254, 0, 0);
                                description.Text = "Version : v" + Application.ProductVersion;
                            }
                        }
                    }
                };
            } catch {
                text.Text        = "Launcher Status - Internal Error";
                status.Image     = Properties.Resources.ac_error;
                text.ForeColor   = Color.FromArgb(254, 0, 0);
                description.Text = "Version : v" + Application.ProductVersion;
            }
        }