Example #1
0
        public UpdatePopup(UpdateCheckResponse updater)
        {
            InitializeComponent();

            changelogText.Text = new WebClientWithTimeout().DownloadString(Self.mainserver + "/launcher/changelog");
            changelogText.Select(0, 0);
            changelogText.SelectionLength = 0;
            changelogText.TabStop         = false;

            Bitmap bitmap1 = Bitmap.FromHicon(SystemIcons.Information.Handle);

            icon.Image = bitmap1;

            updateLabel.Text = "An update is available. Would you like to update?\nYour version: " + Application.ProductVersion + "\nUpdated version: " + updater.Payload.LatestVersion;

            this.update.DialogResult = DialogResult.OK;
        }
Example #2
0
        /// <summary>
        /// Called after the update checker is done (on error or success)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LanguageUpdateChecker_OnComplete(object sender, UpdateCheckResponse e)
        {
            if (labelNewestLangVersion.InvokeRequired)
            {
                labelNewestLangVersion.Invoke(new MethodInvoker(delegate { LanguageUpdateChecker_OnComplete(sender, e); }));
                return;
            }

            EnableForm(true);

            if (!e.Success)
            {
                labelNewestLangVersion.Visible       = false;
                linkLabelCheckLanguageUpdate.Visible = true;

                ErrorMessage(Properties.Resources.ErrorModalUpdateCheckFailed, e.Error?.Message ?? "Unknown error.");
                return;
            }

            labelNewestLangVersion.Text = e.Version.ToString();

            try
            {
                lanugageUpdateUrl = new Uri(e.UpdateLocation);
            }
            catch (UriFormatException)
            {
                ErrorMessage(Properties.Resources.ErrorModalUpdateCheckFailed, "Invalid update URL receieved.");
                return;
            }

            if (languageCatalog.Version == null || e.Version > languageCatalog.Version)
            {
                buttonLanguageUpdate.Visible = true;
            }
        }
        public override void OnMenuLoad()
        {
            ScrewablePartV2.version = this.Version;
            string availableVersion = this.Version;

            modsFolderFilePath   = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            dllFilePath          = Path.Combine(modsFolderFilePath, $"{ID}.dll");
            xmlFilePath          = Path.Combine(modsFolderFilePath, $"{ID}.xml");
            assetsBundleFilePath = Path.Combine(ModLoader.GetModAssetsFolder(this), assetsFile);

            old_dllFilePath          = dllFilePath.Replace(".dll", ".old_dll");
            old_xmlFilePath          = xmlFilePath.Replace(".xml", ".old_xml");
            old_assetsBundleFilePath = assetsBundleFilePath.Replace(".unity3d", ".old_unity3d");

            LoadSettingsSave();

            CheckForOldFiles();
            try
            {
                interfaceObject = GameObject.Find("Interface");
                interfaceActive = GameObject.Find("Quad 7");
                quad7           = GameObject.Find("InterfaceActive");
            }
            catch {}

            if (!serverReachable)
            {
                ModConsole.Warning($"{ID} could not reach the update server");
                LoadAssets();
                return;
            }

            if (!(bool)ignoreUpdatesSetting.Value)
            {
                try
                {
                    string responseJson = Helper.MakeGetRequest(GetLatestReleaseVersionUrl(Version));
                    UpdateCheckResponse updateCheckResponse = JsonConvert.DeserializeObject <UpdateCheckResponse>(responseJson);
                    availableVersion = updateCheckResponse.available;
                    switch (updateCheckResponse.message)
                    {
                    case "out-dated":
                        ModConsole.Warning($"ScrewablePartAPI outdated. version {updateCheckResponse.available} available");
                        SetMenuVisibility(false);
                        Helper.ShowCustom2ButtonMessage($"ScrewablePartAPI is outdated\n" +
                                                        $"version {updateCheckResponse.available} is available!!\n" +
                                                        $"Do you want to update automatically?\n" +
                                                        $"(Restart will be required)\n" +
                                                        $"This can break mods using outdated versions", "ScrewablePartAPI is outdated",
                                                        new UnityAction(delegate()
                        {
                            SetMenuVisibility(true);
                            LoadAssets();
                        }),
                                                        new UnityAction(delegate()
                        {
                            InstallVersion(updateCheckResponse.available);
                        }));
                        break;

                    case "up-to-date":
                        availableVersion = Version;
                        LoadAssets();
                        break;

                    default:
                        LoadAssets();
                        break;
                    }
                }
                catch (Exception ex)
                {
                    ModConsole.Error(ex.Message);
                    LoadAssets();
                }
            }
            else
            {
                LoadAssets();
            }
            GameObject mscLoaderInfo = GameObject.Find("MSCLoader Info");

            try
            {
                GameObject screwablePartMenuInfoTextObject = GameObject.Instantiate(GameObject.Find("MSCLoader Info Text"));
                screwablePartMenuInfoTextObject.name = "ScrewablePartAPI Info Text";
                screwablePartMenuInfoTextObject.transform.SetParent(mscLoaderInfo.transform);
                Text screwablePartMenuInfoText = screwablePartMenuInfoTextObject.GetComponent <Text>();
                screwablePartMenuInfoText.text =
                    $"{Name} <color=cyan>v{Version}</color> loaded! " +
                    $"({(Version == availableVersion ? "<color=lime>Up to date</color>" : "<color=red>Outdated</color>")})";
            }
            catch { }
        }
Example #4
0
        public void ShowNewVersionWindow(UpdateCheckResponse checkUpdateResponse)
        {
            var newVersionWindow = new NewVersionWindow(checkUpdateResponse);

            newVersionWindow.Show();
        }