Skip to content

Commit

Permalink
Added game and online version checking
Browse files Browse the repository at this point in the history
  • Loading branch information
MontagueM committed Jul 17, 2022
1 parent c984333 commit dfc022b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
28 changes: 24 additions & 4 deletions Charm/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,46 @@ public MainWindow()
}

// Check version
CheckVersion();

// Log game version
CheckGameVersion();


var a = 0;
}

private void CheckGameVersion()
{
try
{
CheckVersion();
var path = ConfigHandler.GetPackagesPath().Split("packages")[0] + "destiny2.exe";
var versionInfo = FileVersionInfo.GetVersionInfo(path);
string version = versionInfo.FileVersion;
Log.Information("Game version: " + version);
}
finally
catch (Exception e)
{
Log.Information("Version check complete.");
Log.Error($"Could not get game version error {e}.");
}
}

private async void CheckVersion()
{
var currentVersion = new ApplicationVersion("1.0.0");
var versionChecker = new ApplicationVersionChecker("https://github.com/MontagueM/Charm/tree/main/Charm/versions.xml", currentVersion);
var versionChecker = new ApplicationVersionChecker("http://192.168.1.159/", currentVersion);
versionChecker.LatestVersionName = "version";
try
{
var upToDate = await versionChecker.IsUpToDate();
if (!upToDate)
{
MessageBox.Show("New version available on GitHub!");
Log.Information($"Version is not to date (local {versionChecker.CurrentVersion.Id} vs ext {versionChecker.LatestVersion.Id}).");
}
else
{
Log.Information($"Version is up to date ({versionChecker.CurrentVersion.Id}).");
}
}
catch (Exception e)
Expand Down
3 changes: 3 additions & 0 deletions version.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Version>
<Id>1.0.0</Id>
</Version>

0 comments on commit dfc022b

Please sign in to comment.