mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
Added App Center analytics; Added downloaded progress to update dialog; Bumped version
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using Microsoft.AppCenter;
|
||||||
|
using Microsoft.AppCenter.Analytics;
|
||||||
|
using Microsoft.AppCenter.Crashes;
|
||||||
|
|
||||||
namespace ZuneModdingHelper
|
namespace ZuneModdingHelper
|
||||||
{
|
{
|
||||||
@@ -10,7 +13,7 @@ namespace ZuneModdingHelper
|
|||||||
{
|
{
|
||||||
public static string Title => "Zune Modding Helper";
|
public static string Title => "Zune Modding Helper";
|
||||||
|
|
||||||
public static Version VersionNum => new(2021, 4, 26, 1);
|
public static Version VersionNum => new(2021, 5, 6, 0);
|
||||||
public static string VersionStatus => "alpha";
|
public static string VersionStatus => "alpha";
|
||||||
public static string Version => VersionNum.ToString() + (VersionStatus != string.Empty ? "-" + VersionStatus : string.Empty);
|
public static string Version => VersionNum.ToString() + (VersionStatus != string.Empty ? "-" + VersionStatus : string.Empty);
|
||||||
|
|
||||||
@@ -25,5 +28,14 @@ namespace ZuneModdingHelper
|
|||||||
bool isNewer = otherNum > VersionNum;
|
bool isNewer = otherNum > VersionNum;
|
||||||
return isNotAlpha || isNewer;
|
return isNotAlpha || isNewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnStartup(e);
|
||||||
|
|
||||||
|
// Set up App Center analytics
|
||||||
|
AppCenter.SetCountryCode(System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName);
|
||||||
|
AppCenter.Start("24903c19-b3d9-4ab5-b445-b981ca647125", typeof(Analytics), typeof(Crashes));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Flurl.Http;
|
using Flurl.Http;
|
||||||
using MahApps.Metro.Controls;
|
using MahApps.Metro.Controls;
|
||||||
using MahApps.Metro.Controls.Dialogs;
|
using MahApps.Metro.Controls.Dialogs;
|
||||||
|
using Microsoft.AppCenter.Analytics;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using OwlCore.AbstractUI.ViewModels;
|
using OwlCore.AbstractUI.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
@@ -72,10 +73,20 @@ namespace ZuneModdingHelper
|
|||||||
if (applyResult != null)
|
if (applyResult != null)
|
||||||
{
|
{
|
||||||
progDialog.SetMessage($"Failed to apply '{mod.Title}':\r\n{applyResult}");
|
progDialog.SetMessage($"Failed to apply '{mod.Title}':\r\n{applyResult}");
|
||||||
|
|
||||||
|
Analytics.TrackEvent("Failed to apply mod", new Dictionary<string, string> {
|
||||||
|
{ "ModID", mod.Id },
|
||||||
|
{ "ErrorMessage", applyResult }
|
||||||
|
});
|
||||||
|
|
||||||
await Task.Delay(15000);
|
await Task.Delay(15000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
progDialog.SetProgress(++numCompleted);
|
progDialog.SetProgress(++numCompleted);
|
||||||
|
|
||||||
|
Analytics.TrackEvent("Applied mod", new Dictionary<string, string> {
|
||||||
|
{ "ModID", mod.Id },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await progDialog.CloseAsync();
|
await progDialog.CloseAsync();
|
||||||
@@ -106,15 +117,25 @@ namespace ZuneModdingHelper
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
progDialog.SetMessage($"Resetting '{mod.Title}'");
|
progDialog.SetMessage($"Resetting '{mod.Title}'");
|
||||||
string applyResult = await mod.Reset();
|
string resetResult = await mod.Reset();
|
||||||
if (applyResult != null)
|
if (resetResult != null)
|
||||||
{
|
{
|
||||||
|
Analytics.TrackEvent("Failed to reset mod", new Dictionary<string, string> {
|
||||||
|
{ "ModID", mod.Id },
|
||||||
|
{ "ErrorMessage", resetResult }
|
||||||
|
});
|
||||||
|
|
||||||
await progDialog.CloseAsync();
|
await progDialog.CloseAsync();
|
||||||
await this.ShowMessageAsync("Completed", $"Failed to reset '{mod.Title}':\r\n{applyResult}", settings: defaultMetroDialogSettings);
|
await this.ShowMessageAsync("Completed", $"Failed to reset '{mod.Title}':\r\n{resetResult}", settings: defaultMetroDialogSettings);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
progDialog.SetProgress(++numCompleted);
|
progDialog.SetProgress(++numCompleted);
|
||||||
|
|
||||||
|
Analytics.TrackEvent("Reset mod", new Dictionary<string, string> {
|
||||||
|
{ "ModID", mod.Id },
|
||||||
|
});
|
||||||
|
|
||||||
await progDialog.CloseAsync();
|
await progDialog.CloseAsync();
|
||||||
await this.ShowMessageAsync("Completed", $"Successfully reset '{mod.Title}'", settings: defaultMetroDialogSettings);
|
await this.ShowMessageAsync("Completed", $"Successfully reset '{mod.Title}'", settings: defaultMetroDialogSettings);
|
||||||
}
|
}
|
||||||
@@ -147,6 +168,11 @@ namespace ZuneModdingHelper
|
|||||||
if (!App.CheckIfNewerVersion(latest["tag_name"].Value<string>()))
|
if (!App.CheckIfNewerVersion(latest["tag_name"].Value<string>()))
|
||||||
{
|
{
|
||||||
// Already up-to-date
|
// Already up-to-date
|
||||||
|
|
||||||
|
Analytics.TrackEvent("Checked for updates", new Dictionary<string, string> {
|
||||||
|
{ "UpdatesFound", bool.FalseString },
|
||||||
|
});
|
||||||
|
|
||||||
await checkDialog.CloseAsync();
|
await checkDialog.CloseAsync();
|
||||||
await this.ShowMessageAsync("No updates available", "You're already using the latest version.", settings: defaultMetroDialogSettings);
|
await this.ShowMessageAsync("No updates available", "You're already using the latest version.", settings: defaultMetroDialogSettings);
|
||||||
return;
|
return;
|
||||||
@@ -164,10 +190,12 @@ namespace ZuneModdingHelper
|
|||||||
await checkDialog.CloseAsync();
|
await checkDialog.CloseAsync();
|
||||||
var promptResult = await this.ShowMessageAsync("Update available", $"Relase {latest["name"]} is available. Would you like to download it now?",
|
var promptResult = await this.ShowMessageAsync("Update available", $"Relase {latest["name"]} is available. Would you like to download it now?",
|
||||||
MessageDialogStyle.AffirmativeAndNegative, promptSettings);
|
MessageDialogStyle.AffirmativeAndNegative, promptSettings);
|
||||||
|
bool acceptedUpdate = promptResult == MessageDialogResult.Affirmative;
|
||||||
|
|
||||||
if (promptResult == MessageDialogResult.Affirmative)
|
if (acceptedUpdate)
|
||||||
{
|
{
|
||||||
var progDialog = await this.ShowProgressAsync("Downloading update...", "This may take a few minutes.", settings: defaultMetroDialogSettings);
|
var progDialog = await this.ShowProgressAsync("Downloading update...", "This may take a few minutes.", settings: defaultMetroDialogSettings);
|
||||||
|
progDialog.Maximum = 100;
|
||||||
progDialog.SetIndeterminate();
|
progDialog.SetIndeterminate();
|
||||||
|
|
||||||
// Download new version to AppData
|
// Download new version to AppData
|
||||||
@@ -177,6 +205,12 @@ namespace ZuneModdingHelper
|
|||||||
if (File.Exists(downloadedFile)) File.Delete(downloadedFile);
|
if (File.Exists(downloadedFile)) File.Delete(downloadedFile);
|
||||||
using (var client = new System.Net.WebClient())
|
using (var client = new System.Net.WebClient())
|
||||||
{
|
{
|
||||||
|
client.DownloadProgressChanged += (object sender, System.Net.DownloadProgressChangedEventArgs e) => {
|
||||||
|
// Update UI with download progress
|
||||||
|
progDialog.SetProgress(e.ProgressPercentage);
|
||||||
|
};
|
||||||
|
|
||||||
|
progDialog.SetProgress(0);
|
||||||
await client.DownloadFileTaskAsync(new Uri(asset["browser_download_url"].Value<string>()), downloadedFile);
|
await client.DownloadFileTaskAsync(new Uri(asset["browser_download_url"].Value<string>()), downloadedFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,14 +219,19 @@ namespace ZuneModdingHelper
|
|||||||
{
|
{
|
||||||
FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads", assetName)
|
FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads", assetName)
|
||||||
};
|
};
|
||||||
if (saveFileDialog.ShowDialog() == true)
|
bool dialogResult = saveFileDialog.ShowDialog() ?? false;
|
||||||
|
await progDialog.CloseAsync();
|
||||||
|
if (dialogResult)
|
||||||
{
|
{
|
||||||
File.Copy(downloadedFile, saveFileDialog.FileName, true);
|
File.Copy(downloadedFile, saveFileDialog.FileName, true);
|
||||||
|
|
||||||
await progDialog.CloseAsync();
|
|
||||||
await this.ShowMessageAsync("Update complete", "You may now exit this program and open the new version.", settings: defaultMetroDialogSettings);
|
await this.ShowMessageAsync("Update complete", "You may now exit this program and open the new version.", settings: defaultMetroDialogSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Analytics.TrackEvent("Checked for updates", new Dictionary<string, string> {
|
||||||
|
{ "UpdatesFound", bool.TrueString },
|
||||||
|
{ "Accepted", acceptedUpdate.ToString() },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Flurl.Http" Version="3.2.0" />
|
<PackageReference Include="Flurl.Http" Version="3.2.0" />
|
||||||
<PackageReference Include="MahApps.Metro" Version="2.4.5" />
|
<PackageReference Include="MahApps.Metro" Version="2.4.5" />
|
||||||
|
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="4.2.0" />
|
||||||
|
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.2.0" />
|
||||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
|
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
|
||||||
<PackageReference Include="OwlCore" Version="0.0.2" />
|
<PackageReference Include="OwlCore" Version="0.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user