Skip to content

Commit

Permalink
SAToolsHub: Display all changes since the current version, confirm th…
Browse files Browse the repository at this point in the history
…e tools are up to date on manual check
  • Loading branch information
PiKeyAr committed Nov 3, 2024
1 parent e61dc04 commit a608478
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions SAToolsHub/ToolsHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using SplitTools.SplitDLL;
using SAToolsHub.Updater;
using Newtonsoft.Json;
using System.Text;

namespace SAToolsHub
{
Expand Down Expand Up @@ -1527,8 +1528,10 @@ private bool CheckForUpdates(bool force = false)
hubSettings.UpdateTime = DateTime.UtcNow.ToFileTimeUtc();

string currentTagName = File.Exists("satoolsver.txt") ? File.ReadAllText("satoolsver.txt") : "0";
uint currentID = 0;
bool cancelled = false;

if (!File.Exists("satoolsver.txt"))
if (!File.Exists("satoolsver.txt") || !uint.TryParse(currentTagName, out currentID))
{
if (!force)
return false;
Expand Down Expand Up @@ -1564,6 +1567,7 @@ private bool CheckForUpdates(bool force = false)
// Start update check
using (var wc = new Updater.UpdaterWebClient())
{
StringBuilder changelog = new StringBuilder();
List<GitHubRelease> releases;
string text_releases = string.Empty;
string url_releases = "https://api.github.com/repos/x-hax/sa_tools/releases";
Expand Down Expand Up @@ -1597,6 +1601,16 @@ private bool CheckForUpdates(bool force = false)
if (asset == null)
continue;

uint releaseID = 0;

if (uint.TryParse(release.TagName, out releaseID))
{
if (releaseID > currentID)
{
changelog.AppendLine(string.Format("Revision {0}\n{1}\n", release.TagName, release.Body));
}
}

DateTime uploaded = DateTime.Parse(asset.Uploaded, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
if (uploaded > dateCheck)
{
Expand All @@ -1613,9 +1627,7 @@ private bool CheckForUpdates(bool force = false)

if (latestRelease.TagName != currentTagName)
{
string body = Regex.Replace(latestRelease.Body, "(?<!\r)\n", "\r\n");

using (var dlg = new Updater.UpdateMessageDialog("SA Tools", body))
using (var dlg = new Updater.UpdateMessageDialog("SA Tools", Regex.Replace(changelog.ToString(), "(?<!\r)\n", "\r\n").TrimEnd()))
{
if (dlg.ShowDialog(this) == DialogResult.Yes)
{
Expand Down Expand Up @@ -1644,12 +1656,20 @@ private bool CheckForUpdates(bool force = false)
Close();
return true;
}
else
cancelled = true;
}
else
cancelled = true;
}
}
tsUpdate.Enabled = true;
checkForUpdatesToolStripMenuItem.Enabled = true;
}
if (force && !cancelled)
{
MessageBox.Show(this, "SA Tools are up to date.", "SA Tools Hub", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
return false;
}
#endregion
Expand Down

0 comments on commit a608478

Please sign in to comment.