1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Implemented enabling/disabling games and overlays

This commit is contained in:
SpoinkyNL 2016-02-17 19:56:07 +01:00
parent b6199098f1
commit 66aa2e8d04
22 changed files with 166 additions and 95 deletions

View File

@ -232,6 +232,7 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Compile Include="Modules\Games\RocketLeague\RocketLeagueModel.cs" /> <Compile Include="Modules\Games\RocketLeague\RocketLeagueModel.cs" />
<Compile Include="Modules\Games\Witcher3\RocketLeagueSettings.cs" />
<Compile Include="Modules\Games\Witcher3\Witcher3.Designer.cs"> <Compile Include="Modules\Games\Witcher3\Witcher3.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>

View File

@ -5,6 +5,8 @@ namespace Artemis.Models
{ {
public abstract class EffectModel : IDisposable public abstract class EffectModel : IDisposable
{ {
public delegate void SettingsUpdateHandler(EffectSettings settings);
public MainModel MainModel; public MainModel MainModel;
public string Name; public string Name;
@ -13,6 +15,8 @@ namespace Artemis.Models
MainModel = mainModel; MainModel = mainModel;
} }
public event SettingsUpdateHandler SettingsUpdateEvent;
public abstract void Dispose(); public abstract void Dispose();
// Called on creation // Called on creation

View File

@ -2,7 +2,7 @@
{ {
public abstract class GameModel : EffectModel public abstract class GameModel : EffectModel
{ {
public abstract bool Enabled(); public bool Enabled;
public string ProcessName; public string ProcessName;
protected GameModel(MainModel mainModel) : base(mainModel) protected GameModel(MainModel mainModel) : base(mainModel)

View File

@ -111,7 +111,7 @@ namespace Artemis.Models
// Game models are only used if they are enabled // Game models are only used if they are enabled
var gameModel = effectModel as GameModel; var gameModel = effectModel as GameModel;
if (gameModel != null) if (gameModel != null)
if (!gameModel.Enabled()) if (!gameModel.Enabled)
return; return;
if (ActiveEffect != null && effectModel.Name == ActiveEffect.Name) if (ActiveEffect != null && effectModel.Name == ActiveEffect.Name)
@ -204,9 +204,16 @@ namespace Artemis.Models
if (process.HasExited) if (process.HasExited)
continue; continue;
// If the active effect is a disabled game model, disable it
var model = ActiveEffect as GameModel;
if (model != null && !model.Enabled)
LoadLastEffect();
else
{
ChangeEffect(effectModel); ChangeEffect(effectModel);
foundProcess = true; foundProcess = true;
} }
}
// If no game process is found, but the active effect still belongs to a game, // If no game process is found, but the active effect still belongs to a game,
// set it to a normal effect // set it to a normal effect

View File

@ -11,6 +11,7 @@ namespace Artemis.Models
{ {
} }
// Overlay Enabled() and Dispose() is called when changing the Enabled value
public bool Enabled public bool Enabled
{ {
get { return _enabled; } get { return _enabled; }

View File

@ -14,16 +14,17 @@ namespace Artemis.Modules.Games.CounterStrike
{ {
public class CounterStrikeModel : GameModel public class CounterStrikeModel : GameModel
{ {
private readonly CounterStrikeSettings _settings;
public CounterStrikeModel(MainModel mainModel, CounterStrikeSettings settings) : base(mainModel) public CounterStrikeModel(MainModel mainModel, CounterStrikeSettings settings) : base(mainModel)
{ {
_settings = settings; Settings = settings;
Name = "CounterStrike"; Name = "CounterStrike";
ProcessName = "csgo"; ProcessName = "csgo";
Scale = 4; Scale = 4;
Enabled = Settings.Enabled;
} }
public CounterStrikeSettings Settings { get; set; }
public KeyboardRectangle EventRect { get; set; } public KeyboardRectangle EventRect { get; set; }
public KeyboardRectangle TeamRect { get; set; } public KeyboardRectangle TeamRect { get; set; }
public KeyboardRectangle AmmoRect { get; set; } public KeyboardRectangle AmmoRect { get; set; }
@ -34,11 +35,6 @@ namespace Artemis.Modules.Games.CounterStrike
public int Scale { get; set; } public int Scale { get; set; }
public override bool Enabled()
{
return _settings.Enabled;
}
public override void Dispose() public override void Dispose()
{ {
MainModel.GameStateWebServer.GameDataReceived -= HandleGameData; MainModel.GameStateWebServer.GameDataReceived -= HandleGameData;
@ -50,9 +46,9 @@ namespace Artemis.Modules.Games.CounterStrike
AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color>(), AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color>(),
LinearGradientMode.Horizontal) {Height = Scale, ContainedBrush = false}; LinearGradientMode.Horizontal) {Height = Scale, ContainedBrush = false};
TeamRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 1, new List<Color>(), TeamRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 1, new List<Color>(),
LinearGradientMode.Horizontal) {Height = (MainModel.ActiveKeyboard.Height*Scale) - Scale}; LinearGradientMode.Horizontal) {Height = MainModel.ActiveKeyboard.Height*Scale - Scale};
EventRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 1, new List<Color>(), EventRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 1, new List<Color>(),
LinearGradientMode.Horizontal) {Height = (MainModel.ActiveKeyboard.Height*Scale) - Scale}; LinearGradientMode.Horizontal) {Height = MainModel.ActiveKeyboard.Height*Scale - Scale};
MainModel.GameStateWebServer.GameDataReceived += HandleGameData; MainModel.GameStateWebServer.GameDataReceived += HandleGameData;
} }
@ -61,15 +57,15 @@ namespace Artemis.Modules.Games.CounterStrike
if (CsJson == null) if (CsJson == null)
return; return;
if (_settings.AmmoEnabled) if (Settings.AmmoEnabled)
UpdateAmmo(); UpdateAmmo();
if (_settings.TeamColorEnabled) if (Settings.TeamColorEnabled)
UpdateTeam(); UpdateTeam();
if (_settings.LowHpEnabled) if (Settings.LowHpEnabled)
UpdateHealth(); UpdateHealth();
if (_settings.FlashEnabled) if (Settings.FlashEnabled)
UpdateFlash(); UpdateFlash();
if (_settings.SmokeEnabled) if (Settings.SmokeEnabled)
UpdateSmoke(); UpdateSmoke();
} }
@ -95,7 +91,7 @@ namespace Artemis.Modules.Games.CounterStrike
return; return;
EventRect.Colors = new List<Color> {Color.FromArgb(smoked, 255, 255, 255)}; EventRect.Colors = new List<Color> {Color.FromArgb(smoked, 255, 255, 255)};
DrawingSmoke = (smoked != 0); DrawingSmoke = smoked != 0;
} }
private void UpdateFlash() private void UpdateFlash()
@ -108,7 +104,7 @@ namespace Artemis.Modules.Games.CounterStrike
return; return;
EventRect.Colors = new List<Color> {Color.FromArgb(flashed, 255, 255, 255)}; EventRect.Colors = new List<Color> {Color.FromArgb(flashed, 255, 255, 255)};
DrawingFlash = (flashed != 0); DrawingFlash = flashed != 0;
} }
private void UpdateTeam() private void UpdateTeam()
@ -150,11 +146,11 @@ namespace Artemis.Modules.Games.CounterStrike
return; return;
var ammoPercentage = (int) Math.Ceiling(100.00/maxAmmo)*ammo; var ammoPercentage = (int) Math.Ceiling(100.00/maxAmmo)*ammo;
AmmoRect.Width = ((int) Math.Floor((16/100.00)*ammoPercentage))*Scale; AmmoRect.Width = (int) Math.Floor(16/100.00*ammoPercentage)*Scale;
AmmoRect.Colors = new List<Color> AmmoRect.Colors = new List<Color>
{ {
ColorHelpers.ToDrawingColor(_settings.AmmoMainColor), ColorHelpers.ToDrawingColor(Settings.AmmoMainColor),
ColorHelpers.ToDrawingColor(_settings.AmmoSecondaryColor) ColorHelpers.ToDrawingColor(Settings.AmmoSecondaryColor)
}; };
// Low ammo indicator // Low ammo indicator

View File

@ -22,7 +22,7 @@ namespace Artemis.Modules.Games.CounterStrike
public bool SmokeEnabled { get; set; } public bool SmokeEnabled { get; set; }
public bool LowHpEnabled { get; set; } public bool LowHpEnabled { get; set; }
public override sealed void Load() public sealed override void Load()
{ {
Enabled = CounterStrike.Default.Enabled; Enabled = CounterStrike.Default.Enabled;
GameDirectory = CounterStrike.Default.GameDirectory; GameDirectory = CounterStrike.Default.GameDirectory;
@ -37,7 +37,7 @@ namespace Artemis.Modules.Games.CounterStrike
LowHpEnabled = CounterStrike.Default.LowHpEnabled; LowHpEnabled = CounterStrike.Default.LowHpEnabled;
} }
public override sealed void Save() public sealed override void Save()
{ {
CounterStrike.Default.Enabled = Enabled; CounterStrike.Default.Enabled = Enabled;
CounterStrike.Default.GameDirectory = GameDirectory; CounterStrike.Default.GameDirectory = GameDirectory;
@ -54,7 +54,7 @@ namespace Artemis.Modules.Games.CounterStrike
CounterStrike.Default.Save(); CounterStrike.Default.Save();
} }
public override sealed void ToDefault() public sealed override void ToDefault()
{ {
Enabled = true; Enabled = true;
GameDirectory = string.Empty; GameDirectory = string.Empty;

View File

@ -37,7 +37,9 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" /> <Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" />
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25" <ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
Style="{DynamicResource MetroCircleToggleButtonStyle}" /> IsChecked="{Binding Path=CounterStrikeSettings.Enabled, Mode=TwoWay}"
Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>

View File

@ -41,6 +41,25 @@ namespace Artemis.Modules.Games.CounterStrike
public static string Name => "CS:GO"; public static string Name => "CS:GO";
public string Content => "Counter-Strike: GO Content"; public string Content => "Counter-Strike: GO Content";
public void SaveSettings()
{
CounterStrikeSettings?.Save();
}
public void ResetSettings()
{
// TODO: Confirmation dialog (Generic MVVM approach)
CounterStrikeSettings.ToDefault();
NotifyOfPropertyChange(() => CounterStrikeSettings);
SaveSettings();
}
public void ToggleEffect()
{
CounterStrikeModel.Enabled = _counterStrikeSettings.Enabled;
}
public void BrowseDirectory() public void BrowseDirectory()
{ {
var dialog = new FolderBrowserDialog {SelectedPath = CounterStrikeSettings.GameDirectory}; var dialog = new FolderBrowserDialog {SelectedPath = CounterStrikeSettings.GameDirectory};
@ -70,19 +89,5 @@ namespace Artemis.Modules.Games.CounterStrike
CounterStrikeSettings.GameDirectory = string.Empty; CounterStrikeSettings.GameDirectory = string.Empty;
NotifyOfPropertyChange(() => CounterStrikeSettings); NotifyOfPropertyChange(() => CounterStrikeSettings);
} }
public void SaveSettings()
{
CounterStrikeSettings?.Save();
}
public void ResetSettings()
{
// TODO: Confirmation dialog (Generic MVVM approach)
CounterStrikeSettings.ToDefault();
NotifyOfPropertyChange(() => CounterStrikeSettings);
SaveSettings();
}
} }
} }

View File

@ -1,5 +1,7 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Artemis.Modules.Games.RocketLeague" GeneratedClassName="RocketLeague">
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
GeneratedClassNamespace="Artemis.Modules.Games.RocketLeague" GeneratedClassName="RocketLeague">
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="Enabled" Type="System.Boolean" Scope="User"> <Setting Name="Enabled" Type="System.Boolean" Scope="User">

View File

@ -16,7 +16,6 @@ namespace Artemis.Modules.Games.RocketLeague
{ {
public class RocketLeagueModel : GameModel public class RocketLeagueModel : GameModel
{ {
private readonly RocketLeagueSettings _settings;
private int _boostAmount; private int _boostAmount;
private bool _boostGrowing; private bool _boostGrowing;
private KeyboardRectangle _boostRect; private KeyboardRectangle _boostRect;
@ -26,17 +25,14 @@ namespace Artemis.Modules.Games.RocketLeague
public RocketLeagueModel(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel) public RocketLeagueModel(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel)
{ {
Settings = settings;
Name = "RocketLeague"; Name = "RocketLeague";
ProcessName = "RocketLeague"; ProcessName = "RocketLeague";
Scale = 4; Scale = 4;
Enabled = Settings.Enabled;
_settings = settings;
} }
public override bool Enabled() public RocketLeagueSettings Settings { get; set; }
{
return _settings.Enabled;
}
public int Scale { get; set; } public int Scale { get; set; }
@ -49,8 +45,8 @@ namespace Artemis.Modules.Games.RocketLeague
{ {
_boostRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color> _boostRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color>
{ {
ColorHelpers.ToDrawingColor(_settings.MainColor), ColorHelpers.ToDrawingColor(Settings.MainColor),
ColorHelpers.ToDrawingColor(_settings.SecondaryColor) ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
}, LinearGradientMode.Horizontal); }, LinearGradientMode.Horizontal);
MemoryHelpers.GetPointers(); MemoryHelpers.GetPointers();
@ -80,11 +76,11 @@ namespace Artemis.Modules.Games.RocketLeague
if (_boostAmount > 100) if (_boostAmount > 100)
_boostAmount = 100; _boostAmount = 100;
_boostRect.Width = (int) Math.Ceiling(((MainModel.ActiveKeyboard.Width*Scale)/100.00)*_boostAmount); _boostRect.Width = (int) Math.Ceiling(MainModel.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
_boostRect.Colors = new List<Color> _boostRect.Colors = new List<Color>
{ {
ColorHelpers.ToDrawingColor(_settings.MainColor), ColorHelpers.ToDrawingColor(Settings.MainColor),
ColorHelpers.ToDrawingColor(_settings.SecondaryColor) ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
}; };
Task.Run(() => GrowIfHigher()); Task.Run(() => GrowIfHigher());
@ -102,7 +98,7 @@ namespace Artemis.Modules.Games.RocketLeague
var differenceStep = difference/amountOfSteps; var differenceStep = difference/amountOfSteps;
var differenceStepRest = difference%amountOfSteps; var differenceStepRest = difference%amountOfSteps;
_boostAmount = _previousBoost; _boostAmount = _previousBoost;
_boostRect.Width = (int) Math.Ceiling(((MainModel.ActiveKeyboard.Width*Scale)/100.00)*_boostAmount); _boostRect.Width = (int) Math.Ceiling(MainModel.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
for (var i = 0; i < amountOfSteps; i++) for (var i = 0; i < amountOfSteps; i++)
{ {
@ -110,10 +106,10 @@ namespace Artemis.Modules.Games.RocketLeague
{ {
differenceStepRest -= 1; differenceStepRest -= 1;
_boostAmount += 1; _boostAmount += 1;
_boostRect.Width = (int) Math.Ceiling(((MainModel.ActiveKeyboard.Width*Scale)/100.00)*_boostAmount); _boostRect.Width = (int) Math.Ceiling(MainModel.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
} }
_boostAmount += differenceStep; _boostAmount += differenceStep;
_boostRect.Width = (int) Math.Ceiling(((MainModel.ActiveKeyboard.Width*Scale)/100.00)*_boostAmount); _boostRect.Width = (int) Math.Ceiling(MainModel.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
Thread.Sleep(50); Thread.Sleep(50);
} }

View File

@ -14,14 +14,14 @@ namespace Artemis.Modules.Games.RocketLeague
public Color MainColor { get; set; } public Color MainColor { get; set; }
public Color SecondaryColor { get; set; } public Color SecondaryColor { get; set; }
public override sealed void Load() public sealed override void Load()
{ {
Enabled = RocketLeague.Default.Enabled; Enabled = RocketLeague.Default.Enabled;
MainColor = RocketLeague.Default.MainColor; MainColor = RocketLeague.Default.MainColor;
SecondaryColor = RocketLeague.Default.SecondaryColor; SecondaryColor = RocketLeague.Default.SecondaryColor;
} }
public override sealed void Save() public sealed override void Save()
{ {
RocketLeague.Default.Enabled = Enabled; RocketLeague.Default.Enabled = Enabled;
RocketLeague.Default.MainColor = MainColor; RocketLeague.Default.MainColor = MainColor;
@ -30,7 +30,7 @@ namespace Artemis.Modules.Games.RocketLeague
RocketLeague.Default.Save(); RocketLeague.Default.Save();
} }
public override sealed void ToDefault() public sealed override void ToDefault()
{ {
Enabled = true; Enabled = true;
MainColor = Color.FromArgb(255, 255, 80, 0); MainColor = Color.FromArgb(255, 255, 80, 0);

View File

@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="476.986" d:DesignWidth="538.772"> d:DesignHeight="476.986" d:DesignWidth="538.772">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
@ -31,7 +32,9 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" /> <Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" />
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25" <ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
Style="{DynamicResource MetroCircleToggleButtonStyle}" /> IsChecked="{Binding Path=RocketLeagueSettings.Enabled, Mode=TwoWay}"
Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>

View File

@ -51,5 +51,10 @@ namespace Artemis.Modules.Games.RocketLeague
SaveSettings(); SaveSettings();
} }
public void ToggleEffect()
{
RocketLeagueModel.Enabled = _rocketLeagueSettings.Enabled;
}
} }
} }

View File

@ -0,0 +1,31 @@
using Artemis.Models;
namespace Artemis.Modules.Games.Witcher3
{
public class Witcher3Settings : EffectSettings
{
public Witcher3Settings()
{
Load();
}
public bool Enabled { get; set; }
public sealed override void Load()
{
Enabled = Witcher3.Default.Enabled;
}
public sealed override void Save()
{
Witcher3.Default.Enabled = Enabled;
Witcher3.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
}
}
}

View File

@ -6,7 +6,6 @@ using System.Drawing.Drawing2D;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Artemis.Models; using Artemis.Models;
using Artemis.Modules.Games.RocketLeague;
using Artemis.Utilities.Keyboard; using Artemis.Utilities.Keyboard;
namespace Artemis.Modules.Games.Witcher3 namespace Artemis.Modules.Games.Witcher3
@ -18,22 +17,21 @@ namespace Artemis.Modules.Games.Witcher3
private KeyboardRectangle _signRect; private KeyboardRectangle _signRect;
private string _witcherSettings; private string _witcherSettings;
public Witcher3Model(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel) public Witcher3Model(MainModel mainModel, Witcher3Settings settings) : base(mainModel)
{ {
Settings = settings;
Name = "Witcher3"; Name = "Witcher3";
ProcessName = "witcher3"; ProcessName = "witcher3";
Scale = 4; Scale = 4;
Enabled = Settings.Enabled;
_updateSw = new Stopwatch(); _updateSw = new Stopwatch();
_signRegex = new Regex("ActiveSign=(.*)", RegexOptions.Compiled); _signRegex = new Regex("ActiveSign=(.*)", RegexOptions.Compiled);
} }
public int Scale { get; set; } public Witcher3Settings Settings { get; set; }
public override bool Enabled() public int Scale { get; set; }
{
return true; // TODO
}
public override void Dispose() public override void Dispose()
{ {

View File

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="386.842" d:DesignWidth="554.887"> d:DesignHeight="386.842" d:DesignWidth="554.887">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
@ -16,6 +17,7 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"> <StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
<Label FontSize="20" HorizontalAlignment="Left"> <Label FontSize="20" HorizontalAlignment="Left">
@ -27,7 +29,9 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" /> <Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" />
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25" <ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
Style="{DynamicResource MetroCircleToggleButtonStyle}" /> IsChecked="{Binding Path=Witcher3Settings.Enabled, Mode=TwoWay}"
Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8" <TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
@ -43,6 +47,15 @@
</TextBlock> </TextBlock>
<Button Grid.Row="3" Grid.Column="0" x:Name="AutoInstall" Content="Try automatic mod install" Width="160" <Button Grid.Row="3" Grid.Column="0" x:Name="AutoInstall" Content="Try automatic mod install" Width="160"
Style="{DynamicResource SquareButtonStyle}" HorizontalAlignment="Left" Margin="0,20,0,0" /> Style="{DynamicResource SquareButtonStyle}" HorizontalAlignment="Left" Margin="0,20,0,0" />
<!-- Buttons -->
<StackPanel Grid.Column="0" Grid.Row="4" Orientation="Horizontal" VerticalAlignment="Bottom">
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100"
Style="{DynamicResource SquareButtonStyle}" />
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100"
Margin="10,0,0,0"
Style="{DynamicResource SquareButtonStyle}" />
</StackPanel>
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</UserControl> </UserControl>

View File

@ -2,24 +2,24 @@
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using Artemis.Models; using Artemis.Models;
using Artemis.Modules.Games.RocketLeague; using Artemis.Properties;
using Screen = Caliburn.Micro.Screen; using Screen = Caliburn.Micro.Screen;
namespace Artemis.Modules.Games.Witcher3 namespace Artemis.Modules.Games.Witcher3
{ {
public class Witcher3ViewModel : Screen public class Witcher3ViewModel : Screen
{ {
private RocketLeagueSettings _rocketLeagueSettings; private Witcher3Settings _witcher3Settings;
public Witcher3ViewModel(MainModel mainModel) public Witcher3ViewModel(MainModel mainModel)
{ {
MainModel = mainModel; MainModel = mainModel;
// Settings are loaded from file by class // Settings are loaded from file by class
RocketLeagueSettings = new RocketLeagueSettings(); Witcher3Settings = new Witcher3Settings();
// Create effect model and add it to MainModel // Create effect model and add it to MainModel
Witcher3Model = new Witcher3Model(mainModel, RocketLeagueSettings); Witcher3Model = new Witcher3Model(mainModel, Witcher3Settings);
MainModel.EffectModels.Add(Witcher3Model); MainModel.EffectModels.Add(Witcher3Model);
} }
@ -28,14 +28,14 @@ namespace Artemis.Modules.Games.Witcher3
public MainModel MainModel { get; set; } public MainModel MainModel { get; set; }
public Witcher3Model Witcher3Model { get; set; } public Witcher3Model Witcher3Model { get; set; }
public RocketLeagueSettings RocketLeagueSettings public Witcher3Settings Witcher3Settings
{ {
get { return _rocketLeagueSettings; } get { return _witcher3Settings; }
set set
{ {
if (Equals(value, _rocketLeagueSettings)) return; if (Equals(value, _witcher3Settings)) return;
_rocketLeagueSettings = value; _witcher3Settings = value;
NotifyOfPropertyChange(() => RocketLeagueSettings); NotifyOfPropertyChange(() => Witcher3Settings);
} }
} }
@ -44,18 +44,23 @@ namespace Artemis.Modules.Games.Witcher3
if (Witcher3Model == null) if (Witcher3Model == null)
return; return;
RocketLeagueSettings.Save(); Witcher3Settings.Save();
} }
public void ResetSettings() public void ResetSettings()
{ {
// TODO: Confirmation dialog (Generic MVVM approach) // TODO: Confirmation dialog (Generic MVVM approach)
RocketLeagueSettings.ToDefault(); Witcher3Settings.ToDefault();
NotifyOfPropertyChange(() => RocketLeagueSettings); NotifyOfPropertyChange(() => Witcher3Settings);
SaveSettings(); SaveSettings();
} }
public void ToggleEffect()
{
Witcher3Model.Enabled = _witcher3Settings.Enabled;
}
public void AutoInstall() public void AutoInstall()
{ {
// Request The Witcher 3 folder // Request The Witcher 3 folder
@ -94,7 +99,8 @@ namespace Artemis.Modules.Games.Witcher3
{ {
MessageBox.Show("Oh no, you have a conflicting mod!\n\n" + MessageBox.Show("Oh no, you have a conflicting mod!\n\n" +
"Conflicting file: " + file.Remove(0, dialog.SelectedPath.Length) + "Conflicting file: " + file.Remove(0, dialog.SelectedPath.Length) +
"\n\nOnce you press OK you will be taken to an instructions page.", "Conflicting mod found"); "\n\nOnce you press OK you will be taken to an instructions page.",
"Conflicting mod found");
return; return;
} }
} }
@ -107,8 +113,10 @@ namespace Artemis.Modules.Games.Witcher3
Directory.CreateDirectory(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc"); Directory.CreateDirectory(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc");
// Install the mod files // Install the mod files
File.WriteAllText(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc\artemis.xml", Properties.Resources.artemis); File.WriteAllText(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc\artemis.xml",
File.WriteAllText(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player\playerWitcher.ws", Properties.Resources.playerWitcher); Resources.artemis);
File.WriteAllText(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
Resources.playerWitcher);
MessageBox.Show("The mod was successfully installed!", "Success"); MessageBox.Show("The mod was successfully installed!", "Success");
} }

View File

@ -37,7 +37,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
}, },
LinearGradientMode.Horizontal) LinearGradientMode.Horizontal)
{ {
Width = (int) ((MainModel.ActiveKeyboard.Width/100.00)*Volume)*Scale, Width = (int) ((MainModel.ActiveKeyboard.Width * Scale / 100.00)*Volume),
ContainedBrush = false ContainedBrush = false
}; };
volumeRect.Draw(g); volumeRect.Draw(g);

View File

@ -10,8 +10,6 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
{ {
public class VolumeDisplayModel : OverlayModel public class VolumeDisplayModel : OverlayModel
{ {
private IKeyboardMouseEvents _mGlobalHook;
public VolumeDisplayModel(MainModel mainModel, VolumeDisplaySettings settings) : base(mainModel) public VolumeDisplayModel(MainModel mainModel, VolumeDisplaySettings settings) : base(mainModel)
{ {
Settings = settings; Settings = settings;

View File

@ -30,6 +30,7 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Label Content="Enable overlay" Margin="0 3 0 0" HorizontalAlignment="Right" /> <Label Content="Enable overlay" Margin="0 3 0 0" HorizontalAlignment="Right" />
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25" <ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
IsChecked="{Binding Path=VolumeDisplaySettings.Enabled, Mode=TwoWay}"
Style="{DynamicResource MetroCircleToggleButtonStyle}" Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" /> cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
</StackPanel> </StackPanel>

View File

@ -37,7 +37,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
public void ToggleEffect() public void ToggleEffect()
{ {
VolumeDisplayModel.Enabled = VolumeDisplaySettings.Enabled; VolumeDisplayModel.Enabled = _volumeDisplaySettings.Enabled;
} }
public void SaveSettings() public void SaveSettings()