mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Implemented enabling/disabling games and overlays
This commit is contained in:
parent
b6199098f1
commit
66aa2e8d04
@ -232,6 +232,7 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Modules\Games\RocketLeague\RocketLeagueModel.cs" />
|
||||
<Compile Include="Modules\Games\Witcher3\RocketLeagueSettings.cs" />
|
||||
<Compile Include="Modules\Games\Witcher3\Witcher3.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
|
||||
@ -5,6 +5,8 @@ namespace Artemis.Models
|
||||
{
|
||||
public abstract class EffectModel : IDisposable
|
||||
{
|
||||
public delegate void SettingsUpdateHandler(EffectSettings settings);
|
||||
|
||||
public MainModel MainModel;
|
||||
public string Name;
|
||||
|
||||
@ -13,6 +15,8 @@ namespace Artemis.Models
|
||||
MainModel = mainModel;
|
||||
}
|
||||
|
||||
public event SettingsUpdateHandler SettingsUpdateEvent;
|
||||
|
||||
public abstract void Dispose();
|
||||
|
||||
// Called on creation
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
{
|
||||
public abstract class GameModel : EffectModel
|
||||
{
|
||||
public abstract bool Enabled();
|
||||
public bool Enabled;
|
||||
public string ProcessName;
|
||||
|
||||
protected GameModel(MainModel mainModel) : base(mainModel)
|
||||
|
||||
@ -111,7 +111,7 @@ namespace Artemis.Models
|
||||
// Game models are only used if they are enabled
|
||||
var gameModel = effectModel as GameModel;
|
||||
if (gameModel != null)
|
||||
if (!gameModel.Enabled())
|
||||
if (!gameModel.Enabled)
|
||||
return;
|
||||
|
||||
if (ActiveEffect != null && effectModel.Name == ActiveEffect.Name)
|
||||
@ -204,8 +204,15 @@ namespace Artemis.Models
|
||||
if (process.HasExited)
|
||||
continue;
|
||||
|
||||
ChangeEffect(effectModel);
|
||||
foundProcess = true;
|
||||
// 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);
|
||||
foundProcess = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If no game process is found, but the active effect still belongs to a game,
|
||||
|
||||
@ -11,6 +11,7 @@ namespace Artemis.Models
|
||||
{
|
||||
}
|
||||
|
||||
// Overlay Enabled() and Dispose() is called when changing the Enabled value
|
||||
public bool Enabled
|
||||
{
|
||||
get { return _enabled; }
|
||||
|
||||
@ -14,16 +14,17 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
{
|
||||
public class CounterStrikeModel : GameModel
|
||||
{
|
||||
private readonly CounterStrikeSettings _settings;
|
||||
|
||||
public CounterStrikeModel(MainModel mainModel, CounterStrikeSettings settings) : base(mainModel)
|
||||
{
|
||||
_settings = settings;
|
||||
Settings = settings;
|
||||
Name = "CounterStrike";
|
||||
ProcessName = "csgo";
|
||||
Scale = 4;
|
||||
Enabled = Settings.Enabled;
|
||||
}
|
||||
|
||||
public CounterStrikeSettings Settings { get; set; }
|
||||
|
||||
public KeyboardRectangle EventRect { get; set; }
|
||||
public KeyboardRectangle TeamRect { get; set; }
|
||||
public KeyboardRectangle AmmoRect { get; set; }
|
||||
@ -34,11 +35,6 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
|
||||
public int Scale { get; set; }
|
||||
|
||||
public override bool Enabled()
|
||||
{
|
||||
return _settings.Enabled;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
MainModel.GameStateWebServer.GameDataReceived -= HandleGameData;
|
||||
@ -50,9 +46,9 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color>(),
|
||||
LinearGradientMode.Horizontal) {Height = Scale, ContainedBrush = false};
|
||||
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>(),
|
||||
LinearGradientMode.Horizontal) {Height = (MainModel.ActiveKeyboard.Height*Scale) - Scale};
|
||||
LinearGradientMode.Horizontal) {Height = MainModel.ActiveKeyboard.Height*Scale - Scale};
|
||||
MainModel.GameStateWebServer.GameDataReceived += HandleGameData;
|
||||
}
|
||||
|
||||
@ -61,15 +57,15 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
if (CsJson == null)
|
||||
return;
|
||||
|
||||
if (_settings.AmmoEnabled)
|
||||
if (Settings.AmmoEnabled)
|
||||
UpdateAmmo();
|
||||
if (_settings.TeamColorEnabled)
|
||||
if (Settings.TeamColorEnabled)
|
||||
UpdateTeam();
|
||||
if (_settings.LowHpEnabled)
|
||||
if (Settings.LowHpEnabled)
|
||||
UpdateHealth();
|
||||
if (_settings.FlashEnabled)
|
||||
if (Settings.FlashEnabled)
|
||||
UpdateFlash();
|
||||
if (_settings.SmokeEnabled)
|
||||
if (Settings.SmokeEnabled)
|
||||
UpdateSmoke();
|
||||
}
|
||||
|
||||
@ -82,7 +78,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
if (health > 25 || health < 1)
|
||||
return;
|
||||
|
||||
TeamRect.Colors = new List<Color> {Color.Red, Color.OrangeRed, Color.Red, Color.OrangeRed };
|
||||
TeamRect.Colors = new List<Color> {Color.Red, Color.OrangeRed, Color.Red, Color.OrangeRed};
|
||||
}
|
||||
|
||||
private void UpdateSmoke()
|
||||
@ -93,9 +89,9 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
var smoked = CsJson["player"]["state"]["smoked"].Value<int>();
|
||||
if (smoked == 0 && !DrawingSmoke)
|
||||
return;
|
||||
|
||||
|
||||
EventRect.Colors = new List<Color> {Color.FromArgb(smoked, 255, 255, 255)};
|
||||
DrawingSmoke = (smoked != 0);
|
||||
DrawingSmoke = smoked != 0;
|
||||
}
|
||||
|
||||
private void UpdateFlash()
|
||||
@ -108,7 +104,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
return;
|
||||
|
||||
EventRect.Colors = new List<Color> {Color.FromArgb(flashed, 255, 255, 255)};
|
||||
DrawingFlash = (flashed != 0);
|
||||
DrawingFlash = flashed != 0;
|
||||
}
|
||||
|
||||
private void UpdateTeam()
|
||||
@ -150,11 +146,11 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
return;
|
||||
|
||||
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>
|
||||
{
|
||||
ColorHelpers.ToDrawingColor(_settings.AmmoMainColor),
|
||||
ColorHelpers.ToDrawingColor(_settings.AmmoSecondaryColor)
|
||||
ColorHelpers.ToDrawingColor(Settings.AmmoMainColor),
|
||||
ColorHelpers.ToDrawingColor(Settings.AmmoSecondaryColor)
|
||||
};
|
||||
|
||||
// Low ammo indicator
|
||||
|
||||
@ -22,7 +22,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
public bool SmokeEnabled { get; set; }
|
||||
public bool LowHpEnabled { get; set; }
|
||||
|
||||
public override sealed void Load()
|
||||
public sealed override void Load()
|
||||
{
|
||||
Enabled = CounterStrike.Default.Enabled;
|
||||
GameDirectory = CounterStrike.Default.GameDirectory;
|
||||
@ -37,7 +37,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
LowHpEnabled = CounterStrike.Default.LowHpEnabled;
|
||||
}
|
||||
|
||||
public override sealed void Save()
|
||||
public sealed override void Save()
|
||||
{
|
||||
CounterStrike.Default.Enabled = Enabled;
|
||||
CounterStrike.Default.GameDirectory = GameDirectory;
|
||||
@ -54,7 +54,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
CounterStrike.Default.Save();
|
||||
}
|
||||
|
||||
public override sealed void ToDefault()
|
||||
public sealed override void ToDefault()
|
||||
{
|
||||
Enabled = true;
|
||||
GameDirectory = string.Empty;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
|
||||
<Grid Margin="15, 5, 15, 5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
@ -37,7 +37,9 @@
|
||||
<StackPanel Orientation="Horizontal" 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"
|
||||
Style="{DynamicResource MetroCircleToggleButtonStyle}" />
|
||||
IsChecked="{Binding Path=CounterStrikeSettings.Enabled, Mode=TwoWay}"
|
||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
@ -41,6 +41,25 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
public static string Name => "CS:GO";
|
||||
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()
|
||||
{
|
||||
var dialog = new FolderBrowserDialog {SelectedPath = CounterStrikeSettings.GameDirectory};
|
||||
@ -70,19 +89,5 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
CounterStrikeSettings.GameDirectory = string.Empty;
|
||||
NotifyOfPropertyChange(() => CounterStrikeSettings);
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
{
|
||||
CounterStrikeSettings?.Save();
|
||||
}
|
||||
|
||||
public void ResetSettings()
|
||||
{
|
||||
// TODO: Confirmation dialog (Generic MVVM approach)
|
||||
CounterStrikeSettings.ToDefault();
|
||||
NotifyOfPropertyChange(() => CounterStrikeSettings);
|
||||
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
<?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 />
|
||||
<Settings>
|
||||
<Setting Name="Enabled" Type="System.Boolean" Scope="User">
|
||||
|
||||
@ -16,7 +16,6 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
{
|
||||
public class RocketLeagueModel : GameModel
|
||||
{
|
||||
private readonly RocketLeagueSettings _settings;
|
||||
private int _boostAmount;
|
||||
private bool _boostGrowing;
|
||||
private KeyboardRectangle _boostRect;
|
||||
@ -26,17 +25,14 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
|
||||
public RocketLeagueModel(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel)
|
||||
{
|
||||
Settings = settings;
|
||||
Name = "RocketLeague";
|
||||
ProcessName = "RocketLeague";
|
||||
Scale = 4;
|
||||
|
||||
_settings = settings;
|
||||
Enabled = Settings.Enabled;
|
||||
}
|
||||
|
||||
public override bool Enabled()
|
||||
{
|
||||
return _settings.Enabled;
|
||||
}
|
||||
public RocketLeagueSettings Settings { 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>
|
||||
{
|
||||
ColorHelpers.ToDrawingColor(_settings.MainColor),
|
||||
ColorHelpers.ToDrawingColor(_settings.SecondaryColor)
|
||||
ColorHelpers.ToDrawingColor(Settings.MainColor),
|
||||
ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
|
||||
}, LinearGradientMode.Horizontal);
|
||||
|
||||
MemoryHelpers.GetPointers();
|
||||
@ -80,11 +76,11 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
if (_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>
|
||||
{
|
||||
ColorHelpers.ToDrawingColor(_settings.MainColor),
|
||||
ColorHelpers.ToDrawingColor(_settings.SecondaryColor)
|
||||
ColorHelpers.ToDrawingColor(Settings.MainColor),
|
||||
ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
|
||||
};
|
||||
|
||||
Task.Run(() => GrowIfHigher());
|
||||
@ -102,7 +98,7 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
var differenceStep = difference/amountOfSteps;
|
||||
var differenceStepRest = difference%amountOfSteps;
|
||||
_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++)
|
||||
{
|
||||
@ -110,10 +106,10 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
{
|
||||
differenceStepRest -= 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;
|
||||
_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);
|
||||
}
|
||||
|
||||
@ -14,14 +14,14 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
public Color MainColor { get; set; }
|
||||
public Color SecondaryColor { get; set; }
|
||||
|
||||
public override sealed void Load()
|
||||
public sealed override void Load()
|
||||
{
|
||||
Enabled = RocketLeague.Default.Enabled;
|
||||
MainColor = RocketLeague.Default.MainColor;
|
||||
SecondaryColor = RocketLeague.Default.SecondaryColor;
|
||||
}
|
||||
|
||||
public override sealed void Save()
|
||||
public sealed override void Save()
|
||||
{
|
||||
RocketLeague.Default.Enabled = Enabled;
|
||||
RocketLeague.Default.MainColor = MainColor;
|
||||
@ -30,7 +30,7 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
RocketLeague.Default.Save();
|
||||
}
|
||||
|
||||
public override sealed void ToDefault()
|
||||
public sealed override void ToDefault()
|
||||
{
|
||||
Enabled = true;
|
||||
MainColor = Color.FromArgb(255, 255, 80, 0);
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="476.986" d:DesignWidth="538.772">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
|
||||
@ -31,7 +32,9 @@
|
||||
<StackPanel Orientation="Horizontal" 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"
|
||||
Style="{DynamicResource MetroCircleToggleButtonStyle}" />
|
||||
IsChecked="{Binding Path=RocketLeagueSettings.Enabled, Mode=TwoWay}"
|
||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
@ -51,5 +51,10 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
public void ToggleEffect()
|
||||
{
|
||||
RocketLeagueModel.Enabled = _rocketLeagueSettings.Enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,6 @@ using System.Drawing.Drawing2D;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using Artemis.Models;
|
||||
using Artemis.Modules.Games.RocketLeague;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
|
||||
namespace Artemis.Modules.Games.Witcher3
|
||||
@ -18,22 +17,21 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
private KeyboardRectangle _signRect;
|
||||
private string _witcherSettings;
|
||||
|
||||
public Witcher3Model(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel)
|
||||
public Witcher3Model(MainModel mainModel, Witcher3Settings settings) : base(mainModel)
|
||||
{
|
||||
Settings = settings;
|
||||
Name = "Witcher3";
|
||||
ProcessName = "witcher3";
|
||||
Scale = 4;
|
||||
Enabled = Settings.Enabled;
|
||||
|
||||
_updateSw = new Stopwatch();
|
||||
_signRegex = new Regex("ActiveSign=(.*)", RegexOptions.Compiled);
|
||||
}
|
||||
|
||||
public int Scale { get; set; }
|
||||
public Witcher3Settings Settings { get; set; }
|
||||
|
||||
public override bool Enabled()
|
||||
{
|
||||
return true; // TODO
|
||||
}
|
||||
public int Scale { get; set; }
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
|
||||
@ -3,19 +3,21 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="386.842" d:DesignWidth="554.887">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
|
||||
<Grid Margin="15, 5, 15, 5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
|
||||
<Label FontSize="20" HorizontalAlignment="Left">
|
||||
@ -27,7 +29,9 @@
|
||||
<StackPanel Orientation="Horizontal" 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"
|
||||
Style="{DynamicResource MetroCircleToggleButtonStyle}" />
|
||||
IsChecked="{Binding Path=Witcher3Settings.Enabled, Mode=TwoWay}"
|
||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
|
||||
@ -42,7 +46,16 @@
|
||||
If you do use conflicting mods, we'll let you know what to do.
|
||||
</TextBlock>
|
||||
<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>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@ -2,24 +2,24 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.Models;
|
||||
using Artemis.Modules.Games.RocketLeague;
|
||||
using Artemis.Properties;
|
||||
using Screen = Caliburn.Micro.Screen;
|
||||
|
||||
namespace Artemis.Modules.Games.Witcher3
|
||||
{
|
||||
public class Witcher3ViewModel : Screen
|
||||
{
|
||||
private RocketLeagueSettings _rocketLeagueSettings;
|
||||
private Witcher3Settings _witcher3Settings;
|
||||
|
||||
public Witcher3ViewModel(MainModel mainModel)
|
||||
{
|
||||
MainModel = mainModel;
|
||||
|
||||
// Settings are loaded from file by class
|
||||
RocketLeagueSettings = new RocketLeagueSettings();
|
||||
Witcher3Settings = new Witcher3Settings();
|
||||
|
||||
// Create effect model and add it to MainModel
|
||||
Witcher3Model = new Witcher3Model(mainModel, RocketLeagueSettings);
|
||||
Witcher3Model = new Witcher3Model(mainModel, Witcher3Settings);
|
||||
MainModel.EffectModels.Add(Witcher3Model);
|
||||
}
|
||||
|
||||
@ -28,14 +28,14 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
public MainModel MainModel { get; set; }
|
||||
public Witcher3Model Witcher3Model { get; set; }
|
||||
|
||||
public RocketLeagueSettings RocketLeagueSettings
|
||||
public Witcher3Settings Witcher3Settings
|
||||
{
|
||||
get { return _rocketLeagueSettings; }
|
||||
get { return _witcher3Settings; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _rocketLeagueSettings)) return;
|
||||
_rocketLeagueSettings = value;
|
||||
NotifyOfPropertyChange(() => RocketLeagueSettings);
|
||||
if (Equals(value, _witcher3Settings)) return;
|
||||
_witcher3Settings = value;
|
||||
NotifyOfPropertyChange(() => Witcher3Settings);
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,18 +44,23 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
if (Witcher3Model == null)
|
||||
return;
|
||||
|
||||
RocketLeagueSettings.Save();
|
||||
Witcher3Settings.Save();
|
||||
}
|
||||
|
||||
public void ResetSettings()
|
||||
{
|
||||
// TODO: Confirmation dialog (Generic MVVM approach)
|
||||
RocketLeagueSettings.ToDefault();
|
||||
NotifyOfPropertyChange(() => RocketLeagueSettings);
|
||||
Witcher3Settings.ToDefault();
|
||||
NotifyOfPropertyChange(() => Witcher3Settings);
|
||||
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
public void ToggleEffect()
|
||||
{
|
||||
Witcher3Model.Enabled = _witcher3Settings.Enabled;
|
||||
}
|
||||
|
||||
public void AutoInstall()
|
||||
{
|
||||
// Request The Witcher 3 folder
|
||||
@ -93,8 +98,9 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
if (!file.Contains("modArtemis"))
|
||||
{
|
||||
MessageBox.Show("Oh no, you have a conflicting mod!\n\n" +
|
||||
"Conflicting file: " + file.Remove(0, dialog.SelectedPath.Length) +
|
||||
"\n\nOnce you press OK you will be taken to an instructions page.", "Conflicting mod found");
|
||||
"Conflicting file: " + file.Remove(0, dialog.SelectedPath.Length) +
|
||||
"\n\nOnce you press OK you will be taken to an instructions page.",
|
||||
"Conflicting mod found");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -107,8 +113,10 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
Directory.CreateDirectory(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc");
|
||||
|
||||
// Install the mod files
|
||||
File.WriteAllText(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc\artemis.xml", Properties.Resources.artemis);
|
||||
File.WriteAllText(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player\playerWitcher.ws", Properties.Resources.playerWitcher);
|
||||
File.WriteAllText(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc\artemis.xml",
|
||||
Resources.artemis);
|
||||
File.WriteAllText(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
|
||||
Resources.playerWitcher);
|
||||
|
||||
MessageBox.Show("The mod was successfully installed!", "Success");
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
},
|
||||
LinearGradientMode.Horizontal)
|
||||
{
|
||||
Width = (int) ((MainModel.ActiveKeyboard.Width/100.00)*Volume)*Scale,
|
||||
Width = (int) ((MainModel.ActiveKeyboard.Width * Scale / 100.00)*Volume),
|
||||
ContainedBrush = false
|
||||
};
|
||||
volumeRect.Draw(g);
|
||||
|
||||
@ -10,8 +10,6 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
{
|
||||
public class VolumeDisplayModel : OverlayModel
|
||||
{
|
||||
private IKeyboardMouseEvents _mGlobalHook;
|
||||
|
||||
public VolumeDisplayModel(MainModel mainModel, VolumeDisplaySettings settings) : base(mainModel)
|
||||
{
|
||||
Settings = settings;
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
<StackPanel Orientation="Horizontal" 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"
|
||||
IsChecked="{Binding Path=VolumeDisplaySettings.Enabled, Mode=TwoWay}"
|
||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
|
||||
</StackPanel>
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
|
||||
public void ToggleEffect()
|
||||
{
|
||||
VolumeDisplayModel.Enabled = VolumeDisplaySettings.Enabled;
|
||||
VolumeDisplayModel.Enabled = _volumeDisplaySettings.Enabled;
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user