diff --git a/Artemis/Artemis/Models/GameSettings.cs b/Artemis/Artemis/Models/GameSettings.cs new file mode 100644 index 000000000..dcfe3527f --- /dev/null +++ b/Artemis/Artemis/Models/GameSettings.cs @@ -0,0 +1,7 @@ +namespace Artemis.Models +{ + public abstract class GameSettings : EffectSettings + { + public bool Enabled { get; set; } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Resources/logo-disabled.ico b/Artemis/Artemis/Resources/logo-disabled.ico new file mode 100644 index 000000000..da8f0f275 Binary files /dev/null and b/Artemis/Artemis/Resources/logo-disabled.ico differ diff --git a/Artemis/Artemis/Resources/logo.ico b/Artemis/Artemis/Resources/logo.ico new file mode 100644 index 000000000..e3f35618e Binary files /dev/null and b/Artemis/Artemis/Resources/logo.ico differ diff --git a/Artemis/Artemis/Services/DialogService.cs b/Artemis/Artemis/Services/DialogService.cs new file mode 100644 index 000000000..b5a312a7d --- /dev/null +++ b/Artemis/Artemis/Services/DialogService.cs @@ -0,0 +1,48 @@ +//The MIT License(MIT) + +//Copyright(c) 2015 ihtfw + +//Permission is hereby granted, free of charge, to any person obtaining a copy +//of this software and associated documentation files (the "Software"), to deal +//in the Software without restriction, including without limitation the rights +//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +//copies of the Software, and to permit persons to whom the Software is +//furnished to do so, subject to the following conditions: + +//The above copyright notice and this permission notice shall be included in all +//copies or substantial portions of the Software. + +//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +//SOFTWARE. + +using System; +using System.Threading.Tasks; + +namespace Artemis.Services +{ + public abstract class DialogService + { + public void ShowErrorMessageBox(Exception e) + { + ShowErrorMessageBox(e.Message); + } + + public void ShowErrorMessageBox(string message) + { + ShowMessageBox("Error", message); + } + + public abstract void ShowMessageBox(string title, string message); + + public abstract bool ShowOpenDialog(out string path, string defaultExt, string filter, string initialDir = null); + + public abstract Task ShowInputDialog(string title, string message); + + public abstract Task ShowQuestionMessageBox(string title, string message); + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Services/MetroDialogService.cs b/Artemis/Artemis/Services/MetroDialogService.cs new file mode 100644 index 000000000..e8ef0b398 --- /dev/null +++ b/Artemis/Artemis/Services/MetroDialogService.cs @@ -0,0 +1,143 @@ +//The MIT License(MIT) + +//Copyright(c) 2015 ihtfw + +//Permission is hereby granted, free of charge, to any person obtaining a copy +//of this software and associated documentation files (the "Software"), to deal +//in the Software without restriction, including without limitation the rights +//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +//copies of the Software, and to permit persons to whom the Software is +//furnished to do so, subject to the following conditions: + +//The above copyright notice and this permission notice shall be included in all +//copies or substantial portions of the Software. + +//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +//SOFTWARE. + +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using Artemis.ViewModels; +using Caliburn.Micro; +using MahApps.Metro.Controls; +using MahApps.Metro.Controls.Dialogs; +using Microsoft.Win32; + +namespace Artemis.Services +{ + public class MetroDialogService : DialogService + { + private readonly ShellViewModel _shellViewModel; + + public MetroDialogService(ShellViewModel shellViewModel) + { + _shellViewModel = shellViewModel; + } + + private MetroWindow GetActiveWindow() + { + MetroWindow window = null; + + Execute.OnUIThread(() => + { + window = Application.Current.Windows.OfType().FirstOrDefault(w => w.IsActive); + if (window == null) + { + window = Application.Current.Windows.OfType().FirstOrDefault(); + } + }); + + return window; + } + + public override void ShowMessageBox(string title, string message) + { + if (_shellViewModel.IsActive == false) + return; + + Execute.OnUIThread(() => GetActiveWindow().ShowMessageAsync(title, message)); + } + + public override async Task ShowQuestionMessageBox(string title, string message) + { + if (_shellViewModel.IsActive == false) + return null; + + var metroDialogSettings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"}; + var result = + await + GetActiveWindow() + .ShowMessageAsync(title, message, MessageDialogStyle.AffirmativeAndNegative, metroDialogSettings); + switch (result) + { + case MessageDialogResult.Negative: + return false; + case MessageDialogResult.Affirmative: + return true; + default: + return null; + } + } + + public override Task ShowInputDialog(string title, string message) + { + if (_shellViewModel.IsActive == false) + return null; + + return GetActiveWindow().ShowInputAsync(title, message); + } + + public override bool ShowOpenDialog(out string path, string defaultExt, string filter, string initialDir = null) + { + if (_shellViewModel.IsActive == false) + { + path = null; + return false; + } + + bool? res = null; + string lPath = null; + + Execute.OnUIThread(() => + { + var ofd = new OpenFileDialog + { + DefaultExt = defaultExt, + Filter = filter + }; + + if (initialDir != null) + { + ofd.InitialDirectory = initialDir; + } + + if (Application.Current.MainWindow != null) + { + res = ofd.ShowDialog(Application.Current.MainWindow); + } + else + { + res = ofd.ShowDialog(); + } + if (res == true) + { + lPath = ofd.FileName; + } + else + { + res = false; + } + }); + + path = lPath; + + return res.Value; + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Utilities/Memory/GamePointer.cs b/Artemis/Artemis/Utilities/Memory/GamePointer.cs new file mode 100644 index 000000000..856fc1d73 --- /dev/null +++ b/Artemis/Artemis/Utilities/Memory/GamePointer.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Artemis.Utilities.Memory +{ + public class GamePointer + { + public string Description { get; set; } + public IntPtr BasePointer { get; set; } + public int[] Offsets { get; set; } + + public override string ToString() + { + return Offsets.Aggregate(BasePointer.ToString("X"), + (current, offset) => current + $"+{offset.ToString("X")}"); + } + } + + public class GamePointersCollection + { + public string Game { get; set; } + public string GameVersion { get; set; } + public List GameAddresses { get; set; } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs b/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs new file mode 100644 index 000000000..857c35b46 --- /dev/null +++ b/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs @@ -0,0 +1,57 @@ +using Artemis.Managers; +using Artemis.Models; +using Caliburn.Micro; + +namespace Artemis.ViewModels.Abstract +{ + public abstract class GameViewModel : Screen + { + private GameSettings _gameSettings; + + public GameModel GameModel { get; set; } + public MainManager MainManager { get; set; } + + public GameSettings GameSettings + { + get { return _gameSettings; } + set + { + if (Equals(value, _gameSettings)) return; + _gameSettings = value; + NotifyOfPropertyChange(() => GameSettings); + } + } + + public bool GameEnabled => MainManager.EffectManager.ActiveEffect == GameModel; + + public void ToggleEffect() + { + GameModel.Enabled = GameSettings.Enabled; + } + + public void SaveSettings() + { + GameSettings?.Save(); + if (!GameEnabled) + return; + + // Restart the game if it's currently running to apply settings. + MainManager.EffectManager.ChangeEffect(GameModel, true); + } + + public async void ResetSettings() + { + var resetConfirm = await + MainManager.DialogService.ShowQuestionMessageBox("Reset effect settings", + "Are you sure you wish to reset this effect's settings? \nAny changes you made will be lost."); + + if (!resetConfirm.Value) + return; + + GameSettings.ToDefault(); + NotifyOfPropertyChange(() => GameSettings); + + SaveSettings(); + } + } +} \ No newline at end of file