From 5e13dac219f6938c811939008eaaec7614a634df Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Tue, 9 Aug 2016 21:27:13 +0200 Subject: [PATCH 1/7] UT WIP --- Artemis/Artemis/App.config | 12 ++ Artemis/Artemis/Artemis.csproj | 20 +++ Artemis/Artemis/DAL/ProfileProvider.cs | 3 +- .../InjectionModules/ArtemisModules.cs | 2 + .../UnrealTournament.Designer.cs | 62 +++++++ .../UnrealTournament.settings | 15 ++ .../UnrealTournamentDataModel.cs | 34 ++++ .../UnrealTournament/UnrealTournamentModel.cs | 67 ++++++++ .../UnrealTournamentSettings.cs | 31 ++++ .../UnrealTournamentView.xaml | 56 +++++++ .../UnrealTournamentView.xaml.cs | 15 ++ .../UnrealTournamentViewModel.cs | 39 +++++ Artemis/UT2Artemis/UT2Artemis.vcxproj | 153 ++++++++++++++++++ Artemis/UT2Artemis/UT2Artemis.vcxproj.filters | 17 ++ 14 files changed, 524 insertions(+), 2 deletions(-) create mode 100644 Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournament.Designer.cs create mode 100644 Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournament.settings create mode 100644 Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs create mode 100644 Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentModel.cs create mode 100644 Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentSettings.cs create mode 100644 Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml create mode 100644 Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml.cs create mode 100644 Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentViewModel.cs create mode 100644 Artemis/UT2Artemis/UT2Artemis.vcxproj create mode 100644 Artemis/UT2Artemis/UT2Artemis.vcxproj.filters diff --git a/Artemis/Artemis/App.config b/Artemis/Artemis/App.config index 62b94b3c1..aaffe972e 100644 --- a/Artemis/Artemis/App.config +++ b/Artemis/Artemis/App.config @@ -2,6 +2,7 @@ +
@@ -27,6 +28,17 @@ + + + True + + + Default + + + + + True diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 0016043d5..4284da4c1 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -312,6 +312,18 @@ + + True + True + UnrealTournament.settings + + + + + + UnrealTournamentView.xaml + + True True @@ -617,6 +629,10 @@ Code + + SettingsSingleFileGenerator + UnrealTournament.Designer.cs + SettingsSingleFileGenerator WoW.Designer.cs @@ -732,6 +748,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/Artemis/Artemis/DAL/ProfileProvider.cs b/Artemis/Artemis/DAL/ProfileProvider.cs index 2e5aae995..6f64cf8dd 100644 --- a/Artemis/Artemis/DAL/ProfileProvider.cs +++ b/Artemis/Artemis/DAL/ProfileProvider.cs @@ -172,7 +172,6 @@ namespace Artemis.DAL /// The loaded profile, or null if invalid public static ProfileModel LoadProfileIfValid(string path) { - // TODO: What exception on load failure? try { var prof = JsonConvert.DeserializeObject(File.ReadAllText(path)); @@ -182,7 +181,7 @@ namespace Artemis.DAL return null; return prof; } - catch (Exception) + catch (JsonSerializationException) { return null; } diff --git a/Artemis/Artemis/InjectionModules/ArtemisModules.cs b/Artemis/Artemis/InjectionModules/ArtemisModules.cs index 68f35bd1a..a8c38414c 100644 --- a/Artemis/Artemis/InjectionModules/ArtemisModules.cs +++ b/Artemis/Artemis/InjectionModules/ArtemisModules.cs @@ -10,6 +10,7 @@ using Artemis.Modules.Games.Dota2; using Artemis.Modules.Games.Overwatch; using Artemis.Modules.Games.RocketLeague; using Artemis.Modules.Games.TheDivision; +using Artemis.Modules.Games.UnrealTournament; using Artemis.Modules.Games.Witcher3; using Artemis.Modules.Overlays.VolumeDisplay; using Artemis.Profiles.Layers.Animations; @@ -46,6 +47,7 @@ namespace Artemis.InjectionModules Bind().To().InSingletonScope(); Bind().To().InSingletonScope(); Bind().To().InSingletonScope(); + Bind().To().InSingletonScope(); // Overlays Bind().To().InSingletonScope(); diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournament.Designer.cs b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournament.Designer.cs new file mode 100644 index 000000000..1458db06a --- /dev/null +++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournament.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Artemis.Modules.Games.UnrealTournament { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + internal sealed partial class UnrealTournament : global::System.Configuration.ApplicationSettingsBase { + + private static UnrealTournament defaultInstance = ((UnrealTournament)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new UnrealTournament()))); + + public static UnrealTournament Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool Enabled { + get { + return ((bool)(this["Enabled"])); + } + set { + this["Enabled"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Default")] + public string LastProfile { + get { + return ((string)(this["LastProfile"])); + } + set { + this["LastProfile"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string GameDirectory { + get { + return ((string)(this["GameDirectory"])); + } + set { + this["GameDirectory"] = value; + } + } + } +} diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournament.settings b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournament.settings new file mode 100644 index 000000000..aac062e37 --- /dev/null +++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournament.settings @@ -0,0 +1,15 @@ + + + + + + True + + + Default + + + + + + \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs new file mode 100644 index 000000000..5e0ad4f86 --- /dev/null +++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs @@ -0,0 +1,34 @@ +using Artemis.Models.Interfaces; + +namespace Artemis.Modules.Games.UnrealTournament +{ + public class UnrealTournamentDataModel : IDataModel + { + public State State { get; set; } + public Environment Environment { get; set; } + public Player Player { get; set; } + } + + public enum State + { + MainMenu, + Spectating, + Alive, + Dead + } + + public class Player + { + public string Name { get; set; } + public string Team { get; set; } + public int Health { get; set; } + public int Armor { get; set; } + public string Powerup { get; set; } + } + + public class Environment + { + public string Mode { get; set; } + public string MapName { get; set; } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentModel.cs b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentModel.cs new file mode 100644 index 000000000..0fa7828db --- /dev/null +++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentModel.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using Artemis.Managers; +using Artemis.Models; +using Artemis.Modules.Games.CounterStrike; +using Artemis.Profiles.Layers.Models; +using Artemis.Utilities.Memory; +using Newtonsoft.Json; + +namespace Artemis.Modules.Games.UnrealTournament +{ + public class UnrealTournamentModel : GameModel + { + private Memory _memory; + private GamePointersCollection _pointer; + + public UnrealTournamentModel(MainManager mainManager, UnrealTournamentSettings settings) + : base(mainManager, settings, new UnrealTournamentDataModel()) + { + Name = "UnrealTournament"; + ProcessName = "UE4-Win64-Shipping"; + Scale = 4; + Enabled = Settings.Enabled; + Initialized = false; + } + + public int Scale { get; set; } + + public override void Dispose() + { + Initialized = false; + MainManager.PipeServer.PipeMessage -= PipeServerOnPipeMessage; + } + + public override void Enable() + { + MainManager.PipeServer.PipeMessage += PipeServerOnPipeMessage; + Initialized = true; + } + + private void PipeServerOnPipeMessage(string message) + { + if (!message.Contains("\"Environment\":")) + return; + + // Parse the JSON + try + { + DataModel = JsonConvert.DeserializeObject(message); + } + catch (Exception) + { + //ignored + } + + } + + public override void Update() + { + } + + public override List GetRenderLayers(bool keyboardOnly) + { + return Profile.GetRenderLayers(DataModel, keyboardOnly); + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentSettings.cs b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentSettings.cs new file mode 100644 index 000000000..f172da3e3 --- /dev/null +++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentSettings.cs @@ -0,0 +1,31 @@ +using Artemis.Models; + +namespace Artemis.Modules.Games.UnrealTournament +{ + public class UnrealTournamentSettings : GameSettings + { + public UnrealTournamentSettings() + { + Load(); + } + + public sealed override void Load() + { + Enabled = UnrealTournament.Default.Enabled; + LastProfile = UnrealTournament.Default.LastProfile; + } + + public sealed override void Save() + { + UnrealTournament.Default.Enabled = Enabled; + UnrealTournament.Default.LastProfile = LastProfile; + + UnrealTournament.Default.Save(); + } + + public sealed override void ToDefault() + { + Enabled = true; + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml new file mode 100644 index 000000000..dfa2cce41 --- /dev/null +++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +