diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index a414a6ddb..688c9aad9 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -325,6 +325,7 @@
+
diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs
index 9cb040daa..ca275a914 100644
--- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs
+++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueModel.cs
@@ -1,161 +1,161 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Settings;
-using Artemis.Utilities;
-using Artemis.Utilities.Keyboard;
-using Artemis.Utilities.Memory;
-using Newtonsoft.Json;
-
-namespace Artemis.Modules.Games.RocketLeague
-{
- public class RocketLeagueModel : GameModel
- {
- private int _boostAmount;
- private bool _boostGrowing;
- private KeyboardRectangle _boostRect;
- private Memory _memory;
- private GamePointersCollectionModel _pointer;
- private int _previousBoost;
-
- public RocketLeagueModel(MainManager mainManager, RocketLeagueSettings settings) : base(mainManager)
- {
- Settings = settings;
- Name = "RocketLeague";
- ProcessName = "RocketLeague";
- Scale = 4;
- Enabled = Settings.Enabled;
- Initialized = false;
- ContextualColor = Settings.ContextualColor;
- }
-
- public RocketLeagueSettings Settings { get; set; }
-
- public int Scale { get; set; }
- public bool ContextualColor { get; set; }
-
- public override void Dispose()
- {
- Initialized = false;
- _memory = null;
- }
-
- public override void Enable()
- {
- Initialized = false;
-
- _boostRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List
- {
- ColorHelpers.ToDrawingColor(Settings.MainColor),
- ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
- }, LinearGradientMode.Horizontal);
-
- MemoryHelpers.GetPointers();
- _pointer = JsonConvert.DeserializeObject(Offsets.Default.RocketLeague);
-
- var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessName);
- _memory = new Memory(tempProcess);
-
- Initialized = true;
- }
-
- public override void Update()
- {
- if (_boostGrowing)
- return;
- if (_memory == null)
- return;
-
- var offsets = _pointer.GameAddresses.First(ga => ga.Description == "Boost").ToString();
- var boostAddress = _memory.GetAddress("\"RocketLeague.exe\"" + offsets);
- var boostFloat = _memory.ReadFloat(boostAddress)*100/3;
-
- _previousBoost = _boostAmount;
- _boostAmount = (int) Math.Ceiling(boostFloat);
-
- // Take care of any reading errors resulting in an OutOfMemory on draw
- if (_boostAmount < 0)
- _boostAmount = 0;
- if (_boostAmount > 100)
- _boostAmount = 100;
-
- _boostRect.Width =
- (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
-
- if (ContextualColor)
- {
- if(_boostAmount < 33)
- _boostRect.Colors = new List{ Color.Red };
- else if(_boostAmount >= 33 && _boostAmount < 66)
- _boostRect.Colors = new List { Color.Yellow };
- else if(_boostAmount >= 66)
- _boostRect.Colors = new List { Color.Lime };
- }
- else
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Artemis.Managers;
+using Artemis.Models;
+using Artemis.Settings;
+using Artemis.Utilities;
+using Artemis.Utilities.Keyboard;
+using Artemis.Utilities.Memory;
+using Newtonsoft.Json;
+
+namespace Artemis.Modules.Games.RocketLeague
+{
+ public class RocketLeagueModel : GameModel
+ {
+ private int _boostAmount;
+ private bool _boostGrowing;
+ private KeyboardRectangle _boostRect;
+ private Memory _memory;
+ private GamePointersCollectionModel _pointer;
+ private int _previousBoost;
+
+ public RocketLeagueModel(MainManager mainManager, RocketLeagueSettings settings) : base(mainManager)
+ {
+ Settings = settings;
+ Name = "RocketLeague";
+ ProcessName = "RocketLeague";
+ Scale = 4;
+ Enabled = Settings.Enabled;
+ Initialized = false;
+ ContextualColor = Settings.ContextualColor;
+ }
+
+ public RocketLeagueSettings Settings { get; set; }
+
+ public int Scale { get; set; }
+ public bool ContextualColor { get; set; }
+
+ public override void Dispose()
+ {
+ Initialized = false;
+ _memory = null;
+ }
+
+ public override void Enable()
+ {
+ Initialized = false;
+
+ _boostRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List
{
- _boostRect.Colors = new List
- {
- ColorHelpers.ToDrawingColor(Settings.MainColor),
- ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
- };
- }
-
-
- Task.Run(() => GrowIfHigher());
- }
-
- private void GrowIfHigher()
- {
- if (_boostAmount <= _previousBoost || _boostGrowing)
- return;
-
- _boostGrowing = true;
- const int amountOfSteps = 6;
-
- var difference = _boostAmount - _previousBoost;
- var differenceStep = difference/amountOfSteps;
- var differenceStepRest = difference%amountOfSteps;
- _boostAmount = _previousBoost;
- _boostRect.Width =
- (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
-
- for (var i = 0; i < amountOfSteps; i++)
- {
- if (differenceStepRest > 0)
- {
- differenceStepRest -= 1;
- _boostAmount += 1;
- _boostRect.Width =
- (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
- }
- _boostAmount += differenceStep;
- _boostRect.Width =
- (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
-
- Thread.Sleep(50);
- }
-
- _boostGrowing = false;
- }
-
- public override Bitmap GenerateBitmap()
- {
- var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
- if (_boostRect == null)
- return null;
-
- using (var g = Graphics.FromImage(bitmap))
- {
- g.Clear(Color.Transparent);
- _boostRect.Draw(g);
- }
- return bitmap;
- }
- }
+ ColorHelpers.ToDrawingColor(Settings.MainColor),
+ ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
+ }, LinearGradientMode.Horizontal);
+
+ Updater.GetPointers();
+ _pointer = JsonConvert.DeserializeObject(Offsets.Default.RocketLeague);
+
+ var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessName);
+ _memory = new Memory(tempProcess);
+
+ Initialized = true;
+ }
+
+ public override void Update()
+ {
+ if (_boostGrowing)
+ return;
+ if (_memory == null)
+ return;
+
+ var offsets = _pointer.GameAddresses.First(ga => ga.Description == "Boost").ToString();
+ var boostAddress = _memory.GetAddress("\"RocketLeague.exe\"" + offsets);
+ var boostFloat = _memory.ReadFloat(boostAddress)*100/3;
+
+ _previousBoost = _boostAmount;
+ _boostAmount = (int) Math.Ceiling(boostFloat);
+
+ // Take care of any reading errors resulting in an OutOfMemory on draw
+ if (_boostAmount < 0)
+ _boostAmount = 0;
+ if (_boostAmount > 100)
+ _boostAmount = 100;
+
+ _boostRect.Width =
+ (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
+
+ if (ContextualColor)
+ {
+ if(_boostAmount < 33)
+ _boostRect.Colors = new List{ Color.Red };
+ else if(_boostAmount >= 33 && _boostAmount < 66)
+ _boostRect.Colors = new List { Color.Yellow };
+ else if(_boostAmount >= 66)
+ _boostRect.Colors = new List { Color.Lime };
+ }
+ else
+ {
+ _boostRect.Colors = new List
+ {
+ ColorHelpers.ToDrawingColor(Settings.MainColor),
+ ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
+ };
+ }
+
+
+ Task.Run(() => GrowIfHigher());
+ }
+
+ private void GrowIfHigher()
+ {
+ if (_boostAmount <= _previousBoost || _boostGrowing)
+ return;
+
+ _boostGrowing = true;
+ const int amountOfSteps = 6;
+
+ var difference = _boostAmount - _previousBoost;
+ var differenceStep = difference/amountOfSteps;
+ var differenceStepRest = difference%amountOfSteps;
+ _boostAmount = _previousBoost;
+ _boostRect.Width =
+ (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
+
+ for (var i = 0; i < amountOfSteps; i++)
+ {
+ if (differenceStepRest > 0)
+ {
+ differenceStepRest -= 1;
+ _boostAmount += 1;
+ _boostRect.Width =
+ (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
+ }
+ _boostAmount += differenceStep;
+ _boostRect.Width =
+ (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
+
+ Thread.Sleep(50);
+ }
+
+ _boostGrowing = false;
+ }
+
+ public override Bitmap GenerateBitmap()
+ {
+ var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
+ if (_boostRect == null)
+ return null;
+
+ using (var g = Graphics.FromImage(bitmap))
+ {
+ g.Clear(Color.Transparent);
+ _boostRect.Draw(g);
+ }
+ return bitmap;
+ }
+ }
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs
index 1b05445cd..c7b9787e3 100644
--- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs
@@ -1,6 +1,7 @@
using Artemis.Managers;
using Artemis.Models;
using Artemis.Settings;
+using Artemis.Utilities;
using Artemis.Utilities.Memory;
using Caliburn.Micro;
using Newtonsoft.Json;
@@ -62,7 +63,7 @@ namespace Artemis.Modules.Games.RocketLeague
return;
}
- MemoryHelpers.GetPointers();
+ Updater.GetPointers();
var version = JsonConvert
.DeserializeObject(Offsets.Default.RocketLeague)
.GameVersion;
diff --git a/Artemis/Artemis/Utilities/Memory/MemoryHelpers.cs b/Artemis/Artemis/Utilities/Memory/MemoryHelpers.cs
index 61df97f21..a36f3eb9c 100644
--- a/Artemis/Artemis/Utilities/Memory/MemoryHelpers.cs
+++ b/Artemis/Artemis/Utilities/Memory/MemoryHelpers.cs
@@ -43,35 +43,5 @@ namespace Artemis.Utilities.Memory
}
return address;
}
-
- public static void GetPointers()
- {
- if (!General.Default.EnablePointersUpdate)
- return;
-
- try
- {
- var jsonClient = new WebClient();
- // Random number to get around cache issues
- var rand = new Random(DateTime.Now.Millisecond);
- var json =
- jsonClient.DownloadString(
- "https://raw.githubusercontent.com/SpoinkyNL/Artemis/master/pointers.json?random=" + rand.Next());
-
- // Get a list of pointers
- var pointers = JsonConvert.DeserializeObject>(json);
- // Assign each pointer to the settings file
- var rlPointers = JsonConvert.SerializeObject(pointers.FirstOrDefault(p => p.Game == "RocketLeague"));
- if (rlPointers != null)
- {
- Offsets.Default.RocketLeague = rlPointers;
- Offsets.Default.Save();
- }
- }
- catch (Exception)
- {
- // ignored
- }
- }
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Utilities/Updater.cs b/Artemis/Artemis/Utilities/Updater.cs
new file mode 100644
index 000000000..ba1585175
--- /dev/null
+++ b/Artemis/Artemis/Utilities/Updater.cs
@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Windows.Forms;
+using Artemis.Models;
+using Artemis.Settings;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+namespace Artemis.Utilities
+{
+ public static class Updater
+ {
+ public static int CurrentVersion = 100;
+
+ public static void CheckForUpdate()
+ {
+ var newRelease = IsUpdateAvailable();
+ if (newRelease == null)
+ return;
+
+ var viewUpdate =
+ MessageBox.Show(
+ $"A new version of Artemis is available, version {newRelease["tag_name"].Value()}.\n" +
+ "Do you wish to view the update on GitHub now?\n\n" +
+ "Note: You can disable update notifications in the settings menu", "Artemis - Update available",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Information);
+ if (viewUpdate == DialogResult.Yes)
+ Process.Start(new ProcessStartInfo(newRelease["html_url"].Value()));
+ }
+
+ public static JObject IsUpdateAvailable()
+ {
+ if (!General.Default.EnablePointersUpdate)
+ return null;
+
+ try
+ {
+ var jsonClient = new WebClient();
+
+ // GitHub trips if we don't add a user agent
+ jsonClient.Headers.Add("user-agent",
+ "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
+
+ // Random number to get around cache issues
+ var rand = new Random(DateTime.Now.Millisecond);
+ var json =
+ jsonClient.DownloadString("https://api.github.com/repos/SpoinkyNL/Artemis/releases/latest?random=" +
+ rand.Next());
+
+ // Get a list of pointers
+ var release = JsonConvert.DeserializeObject(json);
+
+ // Parse a version number string to an int
+ var remoteVersion = int.Parse(release["tag_name"].Value().Replace(".", ""));
+
+ return remoteVersion > CurrentVersion ? release : null;
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+
+ public static void GetPointers()
+ {
+ if (!General.Default.EnablePointersUpdate)
+ return;
+
+ try
+ {
+ var jsonClient = new WebClient();
+
+ // Random number to get around cache issues
+ var rand = new Random(DateTime.Now.Millisecond);
+ var json =
+ jsonClient.DownloadString(
+ "https://raw.githubusercontent.com/SpoinkyNL/Artemis/master/pointers.json?random=" + rand.Next());
+
+ // Get a list of pointers
+ var pointers = JsonConvert.DeserializeObject>(json);
+ // Assign each pointer to the settings file
+ var rlPointers = JsonConvert.SerializeObject(pointers.FirstOrDefault(p => p.Game == "RocketLeague"));
+ if (rlPointers != null)
+ {
+ Offsets.Default.RocketLeague = rlPointers;
+ Offsets.Default.Save();
+ }
+ }
+ catch (Exception)
+ {
+ // ignored
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs b/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs
index 426754abb..25b25a4c2 100644
--- a/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs
+++ b/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs
@@ -1,7 +1,13 @@
using System;
-using System.Windows;
+using System.Diagnostics;
+using System.Threading.Tasks;
+using System.Windows.Forms;
using Artemis.Events;
+using Artemis.Utilities;
using Caliburn.Micro;
+using Newtonsoft.Json.Linq;
+using Application = System.Windows.Application;
+using Screen = Caliburn.Micro.Screen;
namespace Artemis.ViewModels
{
@@ -10,6 +16,7 @@ namespace Artemis.ViewModels
private readonly ShellViewModel _shellViewModel;
private readonly IWindowManager _windowManager;
+ private bool _checkedForUpdate;
private bool _enabled;
private string _toggleText;
/*
@@ -27,6 +34,7 @@ namespace Artemis.ViewModels
_shellViewModel = shellViewModel;
_shellViewModel.MainManager.Events.Subscribe(this);
_shellViewModel.MainManager.EnableProgram();
+ _checkedForUpdate = false;
// TODO: Check if show on startup is enabled, if so, show window.
}
@@ -85,6 +93,13 @@ namespace Artemis.ViewModels
if (!CanShowWindow)
return;
+ if (!_checkedForUpdate)
+ {
+ _checkedForUpdate = true;
+ var updateTask = new Task(Updater.CheckForUpdate);
+ updateTask.Start();
+ }
+
// manually show the next window view-model
_windowManager.ShowWindow(_shellViewModel);
@@ -92,6 +107,7 @@ namespace Artemis.ViewModels
NotifyOfPropertyChange(() => CanHideWindow);
}
+
public void HideWindow()
{
if (!CanHideWindow)