/// <summary> /// Adds a tooltip to a Steam mod showing its update status. /// </summary> /// <param name="tooltip">The tooltip under construction.</param> /// <param name="modUpdate">The mod update executor which can update this mod.</param> /// <param name="localDate">The local last update date.</param> /// <param name="updButton">The button to be used for updating this mod.</param> /// <returns>The status of the Steam mod.</returns> private static ModStatus AddSteamUpdate(StringBuilder tooltip, ModToUpdate modUpdate, System.DateTime localDate, PButton updButton) { var steamDate = modUpdate.LastSteamUpdate; var updated = ModStatus.Disabled; if (steamDate > System.DateTime.MinValue) { // Generate tooltip for mod's current date and last Steam update var ours = ModUpdateInfo.FindModInConfig(modUpdate.SteamID.m_PublishedFileId); var ourDate = System.DateTime.MinValue; var globalDate = modUpdate.LastSteamUpdate; // Do we have a better estimate? if (ours != null) { ourDate = new System.DateTime(ours.LastUpdated, DateTimeKind.Utc); } // Allow some time for download delays etc if (localDate.AddMinutes(UPDATE_JITTER) >= globalDate) { tooltip.Append(ModUpdateDateStrings.MOD_UPDATED); updated = ModStatus.UpToDate; } else if (ourDate.AddMinutes(UPDATE_JITTER) >= globalDate) { tooltip.Append(ModUpdateDateStrings.MOD_UPDATED_BYUS); localDate = ourDate; updated = ModStatus.UpToDateLocal; } else { tooltip.Append(ModUpdateDateStrings.MOD_OUTDATED); updated = ModStatus.Outdated; } // AppendLine appends platform specific separator tooltip.Append("\n"); tooltip.AppendFormat(ModUpdateDateStrings.LOCAL_UPDATE, localDate. ToLocalTime()); tooltip.Append("\n"); tooltip.AppendFormat(ModUpdateDateStrings.STEAM_UPDATE, globalDate. ToLocalTime()); updButton.OnClick = new ModUpdateTask(modUpdate).TryUpdateMods; } else { // Steam update could not be determined tooltip.AppendFormat(ModUpdateDateStrings.LOCAL_UPDATE, localDate. ToLocalTime()); tooltip.Append("\n"); tooltip.AppendFormat(ModUpdateDateStrings.STEAM_UPDATE_UNKNOWN); } return(updated); }
/// <summary> /// Updates the settings for the specified mod ID. /// </summary> /// <param name="id">The Steam mod ID to update.</param> /// <param name="lastUpdated">The new last updated date.</param> internal static void UpdateConfigFor(ulong id, System.DateTime lastUpdated) { lock (DETAILS) { var settings = ModUpdateInfo.Settings; if (settings.ModUpdates == null) { settings = new ModUpdateInfo(); } var info = ModUpdateInfo.FindModInConfig(id); // Now tracked by this mod if (info == null) { info = new ModUpdateData(id, lastUpdated); settings.ModUpdates.Add(info); } else { info.LastUpdated = lastUpdated.Ticks; } info.Status = ModUpdateStatus.PendingUpdate; POptions.WriteSettingsForAssembly(settings); } }
/// <summary> /// Updates the mod local update time and archive path. /// </summary> internal void Summon() { var id = ugcMod.fileId; if (SteamUGC.GetItemInstallInfo(id, out _, out installPath, 260U, out uint ts)) { updateTimestamp = SteamVersionChecker.UnixEpochToDateTime(ts); } else { installPath = null; updateTimestamp = System.DateTime.MinValue; } // But reuse the local timestamp if we updated it var ourData = ModUpdateInfo.FindModInConfig(id.m_PublishedFileId); if (ourData != null) { updateTimestamp = new System.DateTime(ourData.LastUpdated, DateTimeKind. Utc); } }