mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Untracked files
This commit is contained in:
parent
ef9af2cd83
commit
9a583764c5
7
Artemis/Artemis/Models/GameSettings.cs
Normal file
7
Artemis/Artemis/Models/GameSettings.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Artemis.Models
|
||||
{
|
||||
public abstract class GameSettings : EffectSettings
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
}
|
||||
BIN
Artemis/Artemis/Resources/logo-disabled.ico
Normal file
BIN
Artemis/Artemis/Resources/logo-disabled.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 361 KiB |
BIN
Artemis/Artemis/Resources/logo.ico
Normal file
BIN
Artemis/Artemis/Resources/logo.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 361 KiB |
48
Artemis/Artemis/Services/DialogService.cs
Normal file
48
Artemis/Artemis/Services/DialogService.cs
Normal file
@ -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<string> ShowInputDialog(string title, string message);
|
||||
|
||||
public abstract Task<bool?> ShowQuestionMessageBox(string title, string message);
|
||||
}
|
||||
}
|
||||
143
Artemis/Artemis/Services/MetroDialogService.cs
Normal file
143
Artemis/Artemis/Services/MetroDialogService.cs
Normal file
@ -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<MetroWindow>().FirstOrDefault(w => w.IsActive);
|
||||
if (window == null)
|
||||
{
|
||||
window = Application.Current.Windows.OfType<MetroWindow>().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<bool?> 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<string> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Artemis/Artemis/Utilities/Memory/GamePointer.cs
Normal file
26
Artemis/Artemis/Utilities/Memory/GamePointer.cs
Normal file
@ -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<GamePointer> GameAddresses { get; set; }
|
||||
}
|
||||
}
|
||||
57
Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs
Normal file
57
Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user