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

Merge branch 'development'

This commit is contained in:
SpoinkyNL 2016-03-02 01:30:12 +01:00
commit edeffeda21
83 changed files with 2904 additions and 8213 deletions

View File

@ -1,12 +1,10 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 14
VisualStudioVersion = 14.0.23107.0 VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}"
EndProject EndProject
Project("{6141683F-8A12-4E36-9623-2EB02B2C2303}") = "ArtemisSetup", "ArtemisSetup\ArtemisSetup.isproj", "{9E76B2E0-12AE-431D-8FA5-2233D6853F29}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
CD_ROM|Any CPU = CD_ROM|Any CPU CD_ROM|Any CPU = CD_ROM|Any CPU
@ -56,36 +54,6 @@ Global
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x64.Build.0 = Release|x64 {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x64.Build.0 = Release|x64
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.ActiveCfg = Release|x86 {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.ActiveCfg = Release|x86
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.Build.0 = Release|x86 {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.Build.0 = Release|x86
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|Any CPU.ActiveCfg = CD_ROM
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|Any CPU.Build.0 = CD_ROM
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|x64.ActiveCfg = CD_ROM
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|x64.Build.0 = CD_ROM
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|x86.ActiveCfg = CD_ROM
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.CD_ROM|x86.Build.0 = CD_ROM
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|Any CPU.ActiveCfg = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|Any CPU.Build.0 = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|x64.ActiveCfg = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|x64.Build.0 = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|x86.ActiveCfg = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Debug|x86.Build.0 = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|Any CPU.ActiveCfg = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|Any CPU.Build.0 = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|x64.ActiveCfg = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|x64.Build.0 = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|x86.ActiveCfg = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.DVD-5|x86.Build.0 = DVD-5
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|Any CPU.ActiveCfg = SingleImage
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|Any CPU.Build.0 = SingleImage
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|x64.ActiveCfg = SingleImage
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|x64.Build.0 = SingleImage
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|x86.ActiveCfg = SingleImage
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.Release|x86.Build.0 = SingleImage
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|Any CPU.ActiveCfg = SingleImage
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|Any CPU.Build.0 = SingleImage
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|x64.ActiveCfg = SingleImage
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|x64.Build.0 = SingleImage
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|x86.ActiveCfg = SingleImage
{9E76B2E0-12AE-431D-8FA5-2233D6853F29}.SingleImage|x86.Build.0 = SingleImage
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -2,44 +2,19 @@
<configuration> <configuration>
<configSections> <configSections>
<sectionGroup name="userSettings" <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <section name="Artemis.Modules.Overlays.VolumeDisplay.VolumeDisplay" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.RocketLeague.RocketLeague" <section name="Artemis.Modules.Games.RocketLeague.RocketLeague" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" <section name="Artemis.Settings.Offsets" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Modules.Games.Witcher3.Witcher3" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.Offsets" <section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" <section name="Artemis.Modules.Games.CounterStrike.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Settings.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.Witcher3.Witcher3" <section name="Artemis.Settings.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" <section name="Artemis.Settings.RocketLeague" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization" <section name="Artemis.Settings.TypeWave" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" <section name="Artemis.Settings.General" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.CounterStrike.CounterStrike"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.CounterStrike"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.VolumeDisplay"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.AudioVisualization"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.RocketLeague"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.TypeWave"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.General"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup> </sectionGroup>
</configSections> </configSections>
<connectionStrings /> <connectionStrings />
@ -47,6 +22,17 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup> </startup>
<userSettings> <userSettings>
<Artemis.Modules.Overlays.VolumeDisplay.VolumeDisplay>
<setting name="Enabled" serializeAs="String">
<value>True</value>
</setting>
<setting name="MainColor" serializeAs="String">
<value>#FFFF2900</value>
</setting>
<setting name="SecondaryColor" serializeAs="String">
<value>#FF26F600</value>
</setting>
</Artemis.Modules.Overlays.VolumeDisplay.VolumeDisplay>
<Artemis.Modules.Games.RocketLeague.RocketLeague> <Artemis.Modules.Games.RocketLeague.RocketLeague>
<setting name="Enabled" serializeAs="String"> <setting name="Enabled" serializeAs="String">
<value>True</value> <value>True</value>
@ -57,6 +43,9 @@
<setting name="SecondaryColor" serializeAs="String"> <setting name="SecondaryColor" serializeAs="String">
<value>#FFFF0000</value> <value>#FFFF0000</value>
</setting> </setting>
<setting name="ContextualColor" serializeAs="String">
<value>False</value>
</setting>
</Artemis.Modules.Games.RocketLeague.RocketLeague> </Artemis.Modules.Games.RocketLeague.RocketLeague>
<Artemis.Settings.Offsets> <Artemis.Settings.Offsets>
<setting name="RocketLeague" serializeAs="String"> <setting name="RocketLeague" serializeAs="String">
@ -95,6 +84,9 @@
</setting> </setting>
</Artemis.Modules.Effects.AudioVisualizer.AudioVisualization> </Artemis.Modules.Effects.AudioVisualizer.AudioVisualization>
<Artemis.Modules.Games.CounterStrike.CounterStrike> <Artemis.Modules.Games.CounterStrike.CounterStrike>
<setting name="Enabled" serializeAs="String">
<value>True</value>
</setting>
<setting name="GameDirectory" serializeAs="String"> <setting name="GameDirectory" serializeAs="String">
<value /> <value />
</setting> </setting>
@ -119,9 +111,6 @@
<setting name="LowHpEnabled" serializeAs="String"> <setting name="LowHpEnabled" serializeAs="String">
<value>True</value> <value>True</value>
</setting> </setting>
<setting name="Enabled" serializeAs="String">
<value>True</value>
</setting>
</Artemis.Modules.Games.CounterStrike.CounterStrike> </Artemis.Modules.Games.CounterStrike.CounterStrike>
<Artemis.Settings.CounterStrike> <Artemis.Settings.CounterStrike>
<setting name="GameDirectory" serializeAs="String"> <setting name="GameDirectory" serializeAs="String">
@ -149,17 +138,6 @@
<value>True</value> <value>True</value>
</setting> </setting>
</Artemis.Settings.CounterStrike> </Artemis.Settings.CounterStrike>
<Artemis.Settings.VolumeDisplay>
<setting name="MainColor" serializeAs="String">
<value>#FFFF2900</value>
</setting>
<setting name="SecondaryColor" serializeAs="String">
<value>#FF26F600</value>
</setting>
<setting name="Enabled" serializeAs="String">
<value>True</value>
</setting>
</Artemis.Settings.VolumeDisplay>
<Artemis.Settings.AudioVisualization> <Artemis.Settings.AudioVisualization>
<setting name="Sensitivity" serializeAs="String"> <setting name="Sensitivity" serializeAs="String">
<value>4</value> <value>4</value>
@ -221,7 +199,7 @@
<value>TypeWave</value> <value>TypeWave</value>
</setting> </setting>
<setting name="LastKeyboard" serializeAs="String"> <setting name="LastKeyboard" serializeAs="String">
<value>Logitech G910 RGB</value> <value />
</setting> </setting>
<setting name="EnablePointersUpdate" serializeAs="String"> <setting name="EnablePointersUpdate" serializeAs="String">
<value>True</value> <value>True</value>
@ -230,11 +208,17 @@
<value>51364</value> <value>51364</value>
</setting> </setting>
<setting name="Autorun" serializeAs="String"> <setting name="Autorun" serializeAs="String">
<value>True</value> <value>False</value>
</setting> </setting>
<setting name="Suspended" serializeAs="String"> <setting name="Suspended" serializeAs="String">
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="ShowOnStartup" serializeAs="String">
<value>True</value>
</setting>
<setting name="CheckForUpdates" serializeAs="String">
<value>True</value>
</setting>
</Artemis.Settings.General> </Artemis.Settings.General>
</userSettings> </userSettings>
<runtime> <runtime>

View File

@ -1,14 +1,14 @@
<Application x:Class="Artemis.App" <Application x:Class="Artemis.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Artemis" xmlns:artemis="clr-namespace:Artemis"
DispatcherUnhandledException="Application_DispatcherUnhandledException" DispatcherUnhandledException="Application_DispatcherUnhandledException"
ShutdownMode="OnExplicitShutdown"> ShutdownMode="OnExplicitShutdown">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary> <ResourceDictionary>
<local:ArtemisBootstrapper x:Key="ArtemisBootstrapper" /> <artemis:ArtemisBootstrapper x:Key="ArtemisBootstrapper" />
</ResourceDictionary> </ResourceDictionary>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! --> <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />

View File

@ -25,7 +25,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
<PublishUrl>C:\Users\spoin\Desktop\Artemis builds\</PublishUrl> <PublishUrl>C:\Users\Robert\Desktop\Artemis builds\</PublishUrl>
<Install>true</Install> <Install>true</Install>
<InstallFrom>Disk</InstallFrom> <InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled> <UpdateEnabled>false</UpdateEnabled>
@ -35,9 +35,13 @@
<UpdatePeriodically>false</UpdatePeriodically> <UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired> <UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions> <MapFileExtensions>true</MapFileExtensions>
<SupportUrl>https://github.com/SpoinkyNL/Artemis/wiki/Frequently-Asked-Questions-%28FAQ%29</SupportUrl>
<ProductName>Artemis</ProductName>
<PublisherName>Artemis</PublisherName>
<ApplicationRevision>0</ApplicationRevision> <ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.0</ApplicationVersion> <ApplicationVersion>1.0.2.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
@ -74,7 +78,7 @@
<SignManifests>false</SignManifests> <SignManifests>false</SignManifests>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>logo.ico</ApplicationIcon> <ApplicationIcon>Resources\logo.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -135,12 +139,8 @@
<HintPath>..\packages\Colore.4.0.0\lib\net35\Corale.Colore.dll</HintPath> <HintPath>..\packages\Colore.4.0.0\lib\net35\Corale.Colore.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="CUE.NET, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="CUE.NET, Version=1.0.2.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CUE.NET.1.0.2\lib\net45\CUE.NET.dll</HintPath> <HintPath>..\packages\CUE.NET.1.0.2.1\lib\net45\CUE.NET.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Gma.System.MouseKeyHook, Version=5.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MouseKeyHook.5.4.0\lib\net40\Gma.System.MouseKeyHook.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
@ -172,10 +172,7 @@
<Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<HintPath>..\packages\MahApps.Metro.1.2.4.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -189,6 +186,10 @@
<HintPath>..\packages\WpfExceptionViewer.1.0.0.0\lib\VioletTape.WpfExceptionViewer.dll</HintPath> <HintPath>..\packages\WpfExceptionViewer.1.0.0.0\lib\VioletTape.WpfExceptionViewer.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="VirtualInput, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\VirtualInput.1.0.1\lib\net20\VirtualInput.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
@ -228,7 +229,7 @@
</Compile> </Compile>
<Compile Include="ArtemisBootstrapper.cs" /> <Compile Include="ArtemisBootstrapper.cs" />
<Compile Include="Events\ToggleEnabled.cs" /> <Compile Include="Events\ToggleEnabled.cs" />
<Compile Include="Events\ChangeActiveEffect.cs" /> <Compile Include="Events\ActiveEffectChanged.cs" />
<Compile Include="Events\ChangeBitmap.cs" /> <Compile Include="Events\ChangeBitmap.cs" />
<Compile Include="KeyboardProviders\Corsair\CorsairRGB.cs" /> <Compile Include="KeyboardProviders\Corsair\CorsairRGB.cs" />
<Compile Include="KeyboardProviders\KeyboardProvider.cs" /> <Compile Include="KeyboardProviders\KeyboardProvider.cs" />
@ -241,8 +242,12 @@
<Compile Include="KeyboardProviders\ProviderHelper.cs" /> <Compile Include="KeyboardProviders\ProviderHelper.cs" />
<Compile Include="KeyboardProviders\Razer\BlackWidow.cs" /> <Compile Include="KeyboardProviders\Razer\BlackWidow.cs" />
<Compile Include="KeyboardProviders\Razer\Utilities\RazerUtilities.cs" /> <Compile Include="KeyboardProviders\Razer\Utilities\RazerUtilities.cs" />
<Compile Include="Managers\EffectManager.cs" />
<Compile Include="Managers\KeyboardManager.cs" />
<Compile Include="Managers\MainManager.cs" />
<Compile Include="Models\EffectModel.cs" /> <Compile Include="Models\EffectModel.cs" />
<Compile Include="Models\GamePointersCollectionModel.cs" /> <Compile Include="Models\EffectSettings.cs" />
<Compile Include="Models\GameSettings.cs" />
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualization.Designer.cs"> <Compile Include="Modules\Effects\AudioVisualizer\AudioVisualization.Designer.cs">
<DependentUpon>AudioVisualization.settings</DependentUpon> <DependentUpon>AudioVisualization.settings</DependentUpon>
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
@ -271,25 +276,23 @@
<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\Witcher3Settings.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>
<DependentUpon>Witcher3.settings</DependentUpon> <DependentUpon>Witcher3.settings</DependentUpon>
</Compile> </Compile>
<Compile Include="Modules\Games\Witcher3\Witcher3Model.cs" /> <Compile Include="Modules\Games\Witcher3\Witcher3Model.cs" />
<Compile Include="Models\MainModel.cs" />
<Compile Include="Models\OverlayModel.cs" /> <Compile Include="Models\OverlayModel.cs" />
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplay.cs" /> <Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplay.cs" />
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplay.Designer.cs"> <Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplay.Designer.cs">
<DependentUpon>VolumeDisplay.settings</DependentUpon>
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>VolumeDisplay.settings</DependentUpon>
</Compile> </Compile>
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayModel.cs" /> <Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayModel.cs" />
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerSettings.cs" /> <Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerSettings.cs" />
<Compile Include="Modules\Effects\Debug\DebugEffectSettings.cs" /> <Compile Include="Modules\Effects\Debug\DebugEffectSettings.cs" />
<Compile Include="Models\EffectSettings.cs" />
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplaySettings.cs" /> <Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplaySettings.cs" />
<Compile Include="Modules\Games\RocketLeague\RocketLeagueSettings.cs" /> <Compile Include="Modules\Games\RocketLeague\RocketLeagueSettings.cs" />
<Compile Include="Modules\Effects\TypeWave\TypeWaveSettings.cs" /> <Compile Include="Modules\Effects\TypeWave\TypeWaveSettings.cs" />
@ -299,6 +302,8 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<Compile Include="Services\DialogService.cs" />
<Compile Include="Services\MetroDialogService.cs" />
<Compile Include="Settings\General.Designer.cs"> <Compile Include="Settings\General.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
@ -317,12 +322,16 @@
<Compile Include="Utilities\GameState\GameStateWebServer.cs" /> <Compile Include="Utilities\GameState\GameStateWebServer.cs" />
<Compile Include="Utilities\ImageUtilities.cs" /> <Compile Include="Utilities\ImageUtilities.cs" />
<Compile Include="Utilities\Keyboard\KeyboardHook.cs" /> <Compile Include="Utilities\Keyboard\KeyboardHook.cs" />
<Compile Include="Utilities\Memory\GamePointer.cs" />
<Compile Include="Utilities\Memory\Memory.cs" /> <Compile Include="Utilities\Memory\Memory.cs" />
<Compile Include="Utilities\Memory\MemoryHelpers.cs" /> <Compile Include="Utilities\Memory\MemoryHelpers.cs" />
<Compile Include="Utilities\Memory\Win32.cs" /> <Compile Include="Utilities\Memory\Win32.cs" />
<Compile Include="Utilities\Keyboard\Key.cs" /> <Compile Include="Utilities\Keyboard\Key.cs" />
<Compile Include="Utilities\Keyboard\KeyboardRectangle.cs" /> <Compile Include="Utilities\Keyboard\KeyboardRectangle.cs" />
<Compile Include="Utilities\ShellLink.cs" /> <Compile Include="Utilities\ShellLink.cs" />
<Compile Include="Utilities\Updater.cs" />
<Compile Include="ViewModels\Abstract\EffectViewModel.cs" />
<Compile Include="ViewModels\Abstract\GameViewModel.cs" />
<Compile Include="ViewModels\EffectsViewModel.cs" /> <Compile Include="ViewModels\EffectsViewModel.cs" />
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerViewModel.cs" /> <Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerViewModel.cs" />
<Compile Include="Modules\Effects\Debug\DebugEffectViewModel.cs" /> <Compile Include="Modules\Effects\Debug\DebugEffectViewModel.cs" />
@ -426,9 +435,13 @@
<Resource Include="Resources\bow.png" /> <Resource Include="Resources\bow.png" />
<Resource Include="Resources\WindowsIcons-license.txt" /> <Resource Include="Resources\WindowsIcons-license.txt" />
<Resource Include="Resources\Entypo-license.txt" /> <Resource Include="Resources\Entypo-license.txt" />
<Content Include="logo.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="Resources\logo.ico" />
<Resource Include="Resources\logo-disabled.ico" />
<Content Include="Resources\Witcher3\playerWitcher.txt" /> <Content Include="Resources\Witcher3\playerWitcher.txt" />
<Content Include="Resources\Witcher3\artemis.txt" /> <Content Include="Resources\Witcher3\artemis.txt" />
<Resource Include="logo-disabled.ico" />
<Resource Include="Resources\Entypo.ttf" /> <Resource Include="Resources\Entypo.ttf" />
<None Include="Settings\Offsets.settings"> <None Include="Settings\Offsets.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
@ -519,9 +532,6 @@
<Content Include="RzChromaSDK64.dll"> <Content Include="RzChromaSDK64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Resource Include="logo.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Content Include="Resources\CounterStrike\gamestateConfiguration.txt" /> <Content Include="Resources\CounterStrike\gamestateConfiguration.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -537,12 +547,12 @@
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\CUE.NET.1.0.2\build\net45\CUE.NET.targets" Condition="Exists('..\packages\CUE.NET.1.0.2\build\net45\CUE.NET.targets')" /> <Import Project="..\packages\CUE.NET.1.0.2.1\build\net45\CUE.NET.targets" Condition="Exists('..\packages\CUE.NET.1.0.2.1\build\net45\CUE.NET.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\CUE.NET.1.0.2\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.0.2\build\net45\CUE.NET.targets'))" /> <Error Condition="!Exists('..\packages\CUE.NET.1.0.2.1\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.0.2.1\build\net45\CUE.NET.targets'))" />
</Target> </Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,8 +1,8 @@
namespace Artemis.Events namespace Artemis.Events
{ {
public class ChangeActiveEffect public class ActiveEffectChanged
{ {
public ChangeActiveEffect(string activeEffect) public ActiveEffectChanged(string activeEffect)
{ {
ActiveEffect = activeEffect; ActiveEffect = activeEffect;
} }

View File

@ -16,8 +16,8 @@ namespace Artemis.KeyboardProviders.Corsair
public CorsairRGB() public CorsairRGB()
{ {
Name = "Corsair RGB Keyboards"; Name = "Corsair RGB Keyboards";
CantEnableText = "Couldn't connect to your Corsair keyboard.\n " + CantEnableText = "Couldn't connect to your Corsair keyboard.\n" +
"Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n\n " + "Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n\n" +
"If needed, you can select a different keyboard in Artemis under settings."; "If needed, you can select a different keyboard in Artemis under settings.";
KeyboardRegions = new List<KeyboardRegion>(); KeyboardRegions = new List<KeyboardRegion>();
} }

View File

@ -4,15 +4,15 @@ namespace Artemis.KeyboardProviders
{ {
public class KeyboardRegion public class KeyboardRegion
{ {
public string RegionName { get; set; }
public Point TopLeft { get; set; }
public Point BottomRight { get; set; }
public KeyboardRegion(string regionName, Point topLeft, Point bottomRight) public KeyboardRegion(string regionName, Point topLeft, Point bottomRight)
{ {
RegionName = regionName; RegionName = regionName;
TopLeft = topLeft; TopLeft = topLeft;
BottomRight = bottomRight; BottomRight = bottomRight;
} }
public string RegionName { get; set; }
public Point TopLeft { get; set; }
public Point BottomRight { get; set; }
} }
} }

View File

@ -11,7 +11,8 @@ namespace Artemis.KeyboardProviders.Logitech
{ {
Name = "Logitech G910 RGB"; Name = "Logitech G910 RGB";
CantEnableText = "Couldn't connect to your Logitech G910.\n " + CantEnableText = "Couldn't connect to your Logitech G910.\n " +
"Please check your cables and updating the Logitech Gaming Software.\n\n " + "Please check your cables and updating the Logitech Gaming Software\n" +
"A minimum version of 8.81.15 is required).\n\n " +
"If needed, you can select a different keyboard in Artemis under settings."; "If needed, you can select a different keyboard in Artemis under settings.";
Height = 6; Height = 6;
Width = 21; Width = 21;
@ -20,8 +21,17 @@ namespace Artemis.KeyboardProviders.Logitech
public override bool CanEnable() public override bool CanEnable()
{ {
// TODO int majorNum = 0, minorNum = 0, buildNum = 0;
return true;
LogitechGSDK.LogiLedInit();
LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(KeyboardNames.A, 100, 100, 100);
LogitechGSDK.LogiLedGetSdkVersion(ref majorNum, ref minorNum, ref buildNum);
LogitechGSDK.LogiLedRestoreLighting();
LogitechGSDK.LogiLedShutdown();
// Turn it into one long number...
var version = int.Parse($"{majorNum}{minorNum}{buildNum}");
return version >= 88115;
} }
public override void Enable() public override void Enable()

View File

@ -0,0 +1,177 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Events;
using Artemis.Models;
using Artemis.Settings;
using Caliburn.Micro;
namespace Artemis.Managers
{
public class EffectManager
{
private readonly IEventAggregator _events;
private readonly MainManager _mainManager;
private bool _clearing;
private EffectModel _pauseEffect;
public EffectManager(MainManager mainManager, IEventAggregator events)
{
_mainManager = mainManager;
_events = events;
EffectModels = new List<EffectModel>();
}
public List<EffectModel> EffectModels { get; set; }
public EffectModel ActiveEffect { get; private set; }
public IEnumerable<OverlayModel> EnabledOverlays
{
get { return EffectModels.OfType<OverlayModel>().Where(o => o.Enabled); }
}
public IEnumerable<GameModel> EnabledGames
{
get { return EffectModels.OfType<GameModel>().Where(g => g.Enabled); }
}
/// <summary>
/// Loads the last active effect from settings and enables it.
/// </summary>
/// <returns>Whether enabling was successful or not.</returns>
public EffectModel GetLastEffect()
{
if (General.Default.LastEffect == null)
return null;
var effect = EffectModels.FirstOrDefault(e => e.Name == General.Default.LastEffect);
// Fall back to the first effect found, in case settings are messed up
return effect ?? EffectModels.First();
}
/// <summary>
/// Disables the current effect and changes it to the provided effect.
/// </summary>
/// <param name="effectModel"></param>
/// <param name="force">Changes the effect, even if it's already running (effectively restarting it)</param>
public void ChangeEffect(EffectModel effectModel, bool force = false)
{
if (effectModel is OverlayModel)
throw new ArgumentException("Can't set an Overlay effect as the active effect");
// Game models are only used if they are enabled
var gameModel = effectModel as GameModel;
if (gameModel != null)
if (!gameModel.Enabled)
return;
if (ActiveEffect != null)
if (effectModel.Name == ActiveEffect.Name && !force)
return;
// If the main manager is running, pause it and safely change the effect
if (_mainManager.Running)
{
ChangeEffectWithPause(effectModel);
return;
}
// If it's not running start it, and let the next recursion handle changing the effect
_mainManager.Start(effectModel);
}
private void ChangeEffectWithPause(EffectModel effectModel)
{
if (_pauseEffect != null)
return;
_pauseEffect = effectModel;
_mainManager.Pause();
_mainManager.PauseCallback += ChangeEffectPauseCallback;
}
private void ChangeEffectPauseCallback()
{
// Change effect logic
ActiveEffect?.Dispose();
ActiveEffect = _pauseEffect;
ActiveEffect.Enable();
// Let the ViewModels know
_events.PublishOnUIThread(new ActiveEffectChanged(ActiveEffect.Name));
_mainManager.Unpause();
_pauseEffect = null;
if (ActiveEffect is GameModel)
return;
// Non-game effects are stored as the new LastEffect.
General.Default.LastEffect = ActiveEffect.Name;
General.Default.Save();
}
/// <summary>
/// Clears the current effect
/// </summary>
public void ClearEffect()
{
if (_clearing)
return;
// Don't mess with the ActiveEffect if in the process of changing the effect.
if (_pauseEffect != null)
return;
if (ActiveEffect == null)
return;
_clearing = true;
_mainManager.Pause();
_mainManager.PauseCallback += ClearEffectPauseCallback;
}
private void ClearEffectPauseCallback()
{
ActiveEffect.Dispose();
ActiveEffect = null;
General.Default.LastEffect = null;
General.Default.Save();
_events.PublishOnUIThread(new ActiveEffectChanged(""));
_clearing = false;
_mainManager.Unpause();
}
/// <summary>
/// Disables the given game
/// </summary>
/// <param name="activeEffect"></param>
public void DisableGame(EffectModel activeEffect)
{
if (GetLastEffect() == null)
ClearEffect();
else
ChangeEffect(GetLastEffect());
}
/// <summary>
/// Disables the current ActiveEffect if it's a game that is disabled.
/// </summary>
public void DisableInactiveGame()
{
if (!(ActiveEffect is GameModel))
return;
if (EnabledGames.Contains(ActiveEffect))
return;
DisableGame(ActiveEffect);
}
}
}

View File

@ -0,0 +1,92 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Artemis.KeyboardProviders;
using Artemis.Settings;
namespace Artemis.Managers
{
public class KeyboardManager
{
private readonly MainManager _mainManager;
public KeyboardManager(MainManager mainManager)
{
_mainManager = mainManager;
KeyboardProviders = ProviderHelper.GetKeyboardProviders();
}
public List<KeyboardProvider> KeyboardProviders { get; set; }
public KeyboardProvider ActiveKeyboard { get; set; }
/// <summary>
/// Enables the last keyboard according to the settings file
/// </summary>
public void EnableLastKeyboard()
{
if (General.Default.LastKeyboard == null)
return;
if (General.Default.LastKeyboard == "")
return;
var keyboard = KeyboardProviders.FirstOrDefault(k => k.Name == General.Default.LastKeyboard);
EnableKeyboard(keyboard);
}
/// <summary>
/// Enables the given keyboard
/// </summary>
/// <param name="keyboardProvider"></param>
public void EnableKeyboard(KeyboardProvider keyboardProvider)
{
ReleaseActiveKeyboard();
if (keyboardProvider == null)
return;
if (ActiveKeyboard != null)
if (keyboardProvider.Name == ActiveKeyboard.Name)
return;
// Disable everything if there's no active keyboard found
if (!keyboardProvider.CanEnable())
{
_mainManager.DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText);
return;
}
ActiveKeyboard = keyboardProvider;
ActiveKeyboard.Enable();
General.Default.LastKeyboard = ActiveKeyboard.Name;
General.Default.Save();
}
/// <summary>
/// Releases the active keyboard
/// </summary>
public void ReleaseActiveKeyboard()
{
if (ActiveKeyboard == null)
return;
ActiveKeyboard.Disable();
ActiveKeyboard = null;
}
/// <summary>
/// Changes the active keyboard
/// </summary>
/// <param name="keyboardProvider"></param>
public void ChangeKeyboard(KeyboardProvider keyboardProvider)
{
if (keyboardProvider == ActiveKeyboard)
return;
General.Default.LastKeyboard = keyboardProvider?.Name;
General.Default.Save();
_mainManager.Restart();
}
}
}

View File

@ -0,0 +1,298 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Artemis.Events;
using Artemis.Models;
using Artemis.Services;
using Artemis.Utilities.GameState;
using Artemis.Utilities.Keyboard;
using Caliburn.Micro;
namespace Artemis.Managers
{
public class MainManager
{
public delegate void PauseCallbackHandler();
private readonly int _fps;
private bool _paused;
private bool _restarting;
public MainManager(IEventAggregator events, MetroDialogService dialogService)
{
Events = events;
DialogService = dialogService;
KeyboardManager = new KeyboardManager(this);
EffectManager = new EffectManager(this, Events);
KeyboardHook = new KeyboardHook();
_fps = 25;
UpdateWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
ProcessWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
UpdateWorker.DoWork += UpdateWorker_DoWork;
UpdateWorker.RunWorkerCompleted += BackgroundWorkerExceptionCatcher;
ProcessWorker.DoWork += ProcessWorker_DoWork;
ProcessWorker.RunWorkerCompleted += BackgroundWorkerExceptionCatcher;
// Process worker will always run (and just do nothing when ProgramEnabled is false)
ProcessWorker.RunWorkerAsync();
ProgramEnabled = false;
Running = false;
// Create and start the web server
GameStateWebServer = new GameStateWebServer();
GameStateWebServer.Start();
}
public BackgroundWorker UpdateWorker { get; set; }
public BackgroundWorker ProcessWorker { get; set; }
public KeyboardManager KeyboardManager { get; set; }
public EffectManager EffectManager { get; set; }
public KeyboardHook KeyboardHook { get; set; }
public GameStateWebServer GameStateWebServer { get; set; }
public IEventAggregator Events { get; set; }
public MetroDialogService DialogService { get; set; }
public bool ProgramEnabled { get; private set; }
public bool Suspended { get; set; }
public bool Running { get; private set; }
public event PauseCallbackHandler PauseCallback;
/// <summary>
/// Take control of the keyboard and start sending data to it
/// </summary>
/// <returns>Whether starting was successful or not</returns>
public bool Start(EffectModel effect = null)
{
// Can't take control when not enabled
if (!ProgramEnabled || UpdateWorker.CancellationPending || UpdateWorker.IsBusy || _paused)
return false;
// Do nothing if already running
if (Running)
return true;
// Only continue if a keyboard was loaded
KeyboardManager.EnableLastKeyboard();
if (KeyboardManager.ActiveKeyboard == null)
return false;
Running = true;
if (effect != null)
EffectManager.ChangeEffect(effect);
// Start the update worker
if (!UpdateWorker.IsBusy)
UpdateWorker.RunWorkerAsync();
return Running;
}
/// <summary>
/// Releases control of the keyboard and stop sending data to it
/// </summary>
public void Stop()
{
if (!Running || UpdateWorker.CancellationPending || _paused)
return;
// Stop the update worker
UpdateWorker.CancelAsync();
UpdateWorker.RunWorkerCompleted += FinishStop;
}
private void FinishStop(object sender, RunWorkerCompletedEventArgs e)
{
KeyboardManager.ReleaseActiveKeyboard();
Running = false;
}
public void Pause()
{
if (!Running || UpdateWorker.CancellationPending || _paused)
return;
_paused = true;
}
public void Unpause()
{
if (!_paused)
return;
_paused = false;
PauseCallback = null;
}
public void Shutdown()
{
Stop();
ProcessWorker.CancelAsync();
GameStateWebServer.Stop();
}
public void Restart()
{
if (_restarting)
return;
if (!Running)
{
Start();
return;
}
_restarting = true;
UpdateWorker.RunWorkerCompleted += FinishRestart;
Stop();
}
public void FinishRestart(object sender, RunWorkerCompletedEventArgs e)
{
UpdateWorker.RunWorkerCompleted -= FinishRestart;
if (e.Error != null)
return;
Start();
_restarting = false;
}
/// <summary>
/// Loads the last active effect and starts the program
/// </summary>
public void EnableProgram()
{
ProgramEnabled = true;
Start(EffectManager.GetLastEffect());
Events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
}
/// <summary>
/// Stops the program
/// </summary>
public void DisableProgram()
{
Stop();
ProgramEnabled = false;
Events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
}
#region Workers
private void UpdateWorker_DoWork(object sender, DoWorkEventArgs e)
{
var sw = new Stopwatch();
while (!UpdateWorker.CancellationPending)
{
// Skip frame when paused
if (_paused)
{
PauseCallback?.Invoke();
Thread.Sleep(1000/_fps);
continue;
}
// Stop if no keyboard/effect are present
if (KeyboardManager.ActiveKeyboard == null || EffectManager.ActiveEffect == null)
{
Thread.Sleep(1000/_fps);
Stop();
continue;
}
// Don't stop when the effect is still initialized, just skip this frame
if (!EffectManager.ActiveEffect.Initialized)
{
Thread.Sleep(1000/_fps);
continue;
}
sw.Start();
// Update the current effect
if (EffectManager.ActiveEffect.Initialized)
EffectManager.ActiveEffect.Update();
// Get ActiveEffect's bitmap
var bitmap = EffectManager.ActiveEffect.Initialized
? EffectManager.ActiveEffect.GenerateBitmap()
: null;
// Draw enabled overlays on top
foreach (var overlayModel in EffectManager.EnabledOverlays)
{
overlayModel.Update();
bitmap = bitmap != null ? overlayModel.GenerateBitmap(bitmap) : overlayModel.GenerateBitmap();
}
// If it exists, send bitmap to the device
if (bitmap != null && KeyboardManager.ActiveKeyboard != null)
{
KeyboardManager.ActiveKeyboard.DrawBitmap(bitmap);
// debugging TODO: Disable when window isn't shown
Events.PublishOnUIThread(new ChangeBitmap(bitmap));
}
// Sleep according to time left this frame
var sleep = (int) (1000/_fps - sw.ElapsedMilliseconds);
if (sleep > 0)
Thread.Sleep(sleep);
sw.Reset();
}
}
private void BackgroundWorkerExceptionCatcher(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
throw e.Error;
}
private void ProcessWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (!ProcessWorker.CancellationPending)
{
if (!ProgramEnabled)
{
Thread.Sleep(1000);
continue;
}
var runningProcesses = Process.GetProcesses();
// If the currently active effect is a disabled game, get rid of it.
if (EffectManager.ActiveEffect != null)
EffectManager.DisableInactiveGame();
// If the currently active effect is a no longer running game, get rid of it.
var activeGame = EffectManager.ActiveEffect as GameModel;
if (activeGame != null)
if (runningProcesses.All(p => p.ProcessName != activeGame.ProcessName))
EffectManager.DisableGame(activeGame);
// Look for running games, stopping on the first one that's found.
var newGame = EffectManager.EnabledGames
.FirstOrDefault(g => runningProcesses.Any(p => p.ProcessName == g.ProcessName));
// If it's not already enabled, do so.
if (newGame != null && EffectManager.ActiveEffect != newGame)
EffectManager.ChangeEffect(newGame);
Thread.Sleep(1000);
}
}
#endregion
}
}

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Drawing; using System.Drawing;
using Artemis.Managers;
namespace Artemis.Models namespace Artemis.Models
{ {
@ -7,18 +8,18 @@ namespace Artemis.Models
{ {
public delegate void SettingsUpdateHandler(EffectSettings settings); public delegate void SettingsUpdateHandler(EffectSettings settings);
public MainModel MainModel; public bool Initialized;
public MainManager MainManager;
public string Name; public string Name;
protected EffectModel(MainModel mainModel) protected EffectModel(MainManager mainManager)
{ {
MainModel = mainModel; MainManager = mainManager;
} }
public abstract void Dispose(); public abstract void Dispose();
public event SettingsUpdateHandler SettingsUpdateEvent;
// Called on creation // Called on creation
public abstract void Enable(); public abstract void Enable();

View File

@ -1,11 +1,13 @@
namespace Artemis.Models using Artemis.Managers;
namespace Artemis.Models
{ {
public abstract class GameModel : EffectModel public abstract class GameModel : EffectModel
{ {
public bool Enabled; public bool Enabled;
public string ProcessName; public string ProcessName;
protected GameModel(MainModel mainModel) : base(mainModel) protected GameModel(MainManager mainManager) : base(mainManager)
{ {
} }
} }

View File

@ -0,0 +1,7 @@
namespace Artemis.Models
{
public abstract class GameSettings : EffectSettings
{
public bool Enabled { get; set; }
}
}

View File

@ -1,314 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using Artemis.Events;
using Artemis.KeyboardProviders;
using Artemis.Settings;
using Artemis.Utilities.GameState;
using Artemis.Utilities.Keyboard;
using Artemis.Utilities.Memory;
using Caliburn.Micro;
namespace Artemis.Models
{
public class MainModel
{
private readonly int _fps;
private readonly BackgroundWorker _processWorker;
private readonly BackgroundWorker _updateWorker;
private EffectModel _activeEffect;
private bool _wasSuspendedBeforeGame;
public MainModel(IEventAggregator events)
{
EffectModels = new List<EffectModel>();
KeyboardProviders = ProviderHelper.GetKeyboardProviders();
GameStateWebServer = new GameStateWebServer();
KeyboardHook = new KeyboardHook();
Suspended = false;
Events = events;
_fps = 25;
_updateWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
_processWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
_updateWorker.DoWork += UpdateWorker_DoWork;
_processWorker.DoWork += ProcessWorker_DoWork;
}
public KeyboardHook KeyboardHook { get; set; }
public KeyboardProvider ActiveKeyboard { get; set; }
public List<EffectModel> EffectModels { get; set; }
public List<KeyboardProvider> KeyboardProviders { get; set; }
public GameStateWebServer GameStateWebServer { get; set; }
public IEventAggregator Events { get; set; }
public bool Enabled { get; private set; }
public bool Suspended { get; private set; }
#region Effect methods
public void StartEffects()
{
if (Enabled)
return;
if (_updateWorker.IsBusy || _processWorker.IsBusy)
{
Events.PublishOnUIThread(new ToggleEnabled(Enabled));
return;
}
LoadLastKeyboard();
// If no keyboard was loaded, don't enable effects.
if (ActiveKeyboard == null)
return;
// Start the webserver
GameStateWebServer.Start();
// Load last non-game effect and enable
LoadLastEffect();
// Start the Background Workers
_updateWorker.RunWorkerAsync();
_processWorker.RunWorkerAsync();
Enabled = true;
Events.PublishOnUIThread(new ToggleEnabled(Enabled));
if (General.Default.Suspended && !Suspended)
ToggleSuspension();
}
public void ShutdownEffects()
{
if (!Enabled)
return;
// Stop the Background Worker
_updateWorker.CancelAsync();
_processWorker.CancelAsync();
// Dispose the current active effect
_activeEffect?.Dispose();
_activeEffect = null;
ActiveKeyboard?.Disable();
ActiveKeyboard = null;
Enabled = false;
Events.PublishOnUIThread(new ToggleEnabled(Enabled));
}
private void LoadLastEffect()
{
var effect = EffectModels.FirstOrDefault(e => e.Name == General.Default.LastEffect);
ChangeEffect(effect ?? EffectModels.First(e => e.Name == "TypeWave"));
}
private void ChangeEffect(EffectModel effectModel)
{
if (effectModel is OverlayModel)
throw new ArgumentException("Can't set an Overlay effect as the active effect");
// Game models are only used if they are enabled
var gameModel = effectModel as GameModel;
if (gameModel != null)
if (!gameModel.Enabled)
return;
if (_activeEffect != null && effectModel.Name == _activeEffect.Name)
return;
_activeEffect?.Dispose();
// If needed, unsuspend when loading a new effect
if (Suspended)
{
_wasSuspendedBeforeGame = true;
ToggleSuspension();
}
_activeEffect = effectModel;
_activeEffect.Enable();
if (_activeEffect is GameModel)
return;
// Non-game effects are stored as the new LastEffect.
General.Default.LastEffect = _activeEffect.Name;
General.Default.Save();
// Let the ViewModels know
Events.PublishOnUIThread(new ChangeActiveEffect(_activeEffect.Name));
}
public void EnableEffect(EffectModel effectModel)
{
if (effectModel is GameModel || effectModel is OverlayModel)
return;
ChangeEffect(effectModel);
}
public void ToggleSuspension()
{
if (Suspended)
{
LoadLastKeyboard();
Suspended = false;
General.Default.Suspended = false;
General.Default.Save();
Events.PublishOnUIThread(new ChangeActiveEffect(_activeEffect?.Name));
return;
}
Suspended = true;
General.Default.Suspended = true;
General.Default.Save();
ActiveKeyboard?.Disable();
ActiveKeyboard = null;
Events.PublishOnUIThread(new ChangeActiveEffect(_activeEffect?.Name));
}
public bool IsEnabled(EffectModel effectModel)
{
if (Suspended)
return false;
if (effectModel is GameModel)
return false;
return General.Default.LastEffect == effectModel.Name;
}
#endregion
#region Keyboard methods
private void LoadLastKeyboard()
{
var keyboard = KeyboardProviders.FirstOrDefault(k => k.Name == General.Default.LastKeyboard);
ChangeKeyboard(keyboard ?? KeyboardProviders.First());
}
public void ChangeKeyboard(KeyboardProvider keyboardProvider)
{
if (ActiveKeyboard != null && keyboardProvider.Name == ActiveKeyboard.Name)
return;
ActiveKeyboard?.Disable();
// Disable everything if there's no active keyboard found
if (!keyboardProvider.CanEnable())
{
ActiveKeyboard = null;
MessageBox.Show(keyboardProvider.CantEnableText, "Artemis (╯°□°)╯︵ ┻━┻",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
ShutdownEffects();
return;
}
ActiveKeyboard = keyboardProvider;
ActiveKeyboard.Enable();
General.Default.LastKeyboard = ActiveKeyboard.Name;
General.Default.Save();
}
#endregion
#region Workers
private void UpdateWorker_DoWork(object sender, DoWorkEventArgs e)
{
var sw = new Stopwatch();
while (!_updateWorker.CancellationPending)
{
if (ActiveKeyboard == null || Suspended || _activeEffect == null)
{
Thread.Sleep(1000/_fps);
continue;
}
sw.Start();
// Update the current effect
_activeEffect.Update();
// Get ActiveEffect's bitmap
var bitmap = _activeEffect.GenerateBitmap();
// Draw enabled overlays on top
foreach (var overlayModel in EffectModels.OfType<OverlayModel>()
.Where(overlayModel => overlayModel.Enabled))
{
overlayModel.Update();
bitmap = bitmap != null ? overlayModel.GenerateBitmap(bitmap) : overlayModel.GenerateBitmap();
}
// If it exists, send bitmap to the device
if (bitmap != null && ActiveKeyboard != null)
{
ActiveKeyboard.DrawBitmap(bitmap);
// debugging TODO: Disable when window isn't shown
Events.PublishOnUIThread(new ChangeBitmap(bitmap));
}
// Sleep according to time left this frame
var sleep = (int) (1000/_fps - sw.ElapsedMilliseconds);
if (sleep > 0)
Thread.Sleep(sleep);
sw.Reset();
}
}
private void ProcessWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (!_processWorker.CancellationPending)
{
var foundProcess = false;
// ReSharper disable once LoopCanBePartlyConvertedToQuery
foreach (var effectModel in EffectModels.OfType<GameModel>())
{
var process = MemoryHelpers.GetProcessIfRunning(effectModel.ProcessName);
if (process == null)
continue;
if (process.HasExited)
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);
foundProcess = true;
}
}
// If no game process is found, but the active effect still belongs to a game,
// set it to a normal effect, and if needed, suspend again.
if (!foundProcess && _activeEffect is GameModel)
{
LoadLastEffect();
if (_wasSuspendedBeforeGame)
{
ToggleSuspension();
_wasSuspendedBeforeGame = false;
}
}
Thread.Sleep(1000);
}
}
#endregion
}
}

View File

@ -1,4 +1,5 @@
using System.Drawing; using System.Drawing;
using Artemis.Managers;
namespace Artemis.Models namespace Artemis.Models
{ {
@ -7,11 +8,10 @@ namespace Artemis.Models
private bool _enabled; private bool _enabled;
public string ProcessName; public string ProcessName;
protected OverlayModel(MainModel mainModel) : base(mainModel) protected OverlayModel(MainManager mainManager) : base(mainManager)
{ {
} }
// 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

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Linq; using System.Linq;
using Artemis.Managers;
using Artemis.Models; using Artemis.Models;
using Artemis.Utilities; using Artemis.Utilities;
using Artemis.Utilities.Audio; using Artemis.Utilities.Audio;
@ -16,16 +17,19 @@ namespace Artemis.Modules.Effects.AudioVisualizer
{ {
private const int FftLength = 2048; private const int FftLength = 2048;
private readonly SampleAggregator _sampleAggregator = new SampleAggregator(FftLength); private readonly SampleAggregator _sampleAggregator = new SampleAggregator(FftLength);
private bool _fromBottom;
private bool _generating; private bool _generating;
private int _sensitivity;
private IWaveIn _waveIn; private IWaveIn _waveIn;
public AudioVisualizerModel(MainModel mainModel, AudioVisualizerSettings settings) : base(mainModel) public AudioVisualizerModel(MainManager mainManager, AudioVisualizerSettings settings) : base(mainManager)
{ {
Settings = settings; Settings = settings;
Name = "Audiovisualizer"; Name = "Audiovisualizer";
DeviceIds = new List<string>(); DeviceIds = new List<string>();
SpectrumData = new List<byte>(); SpectrumData = new List<byte>();
Scale = 4; Scale = 4;
Initialized = false;
} }
public int Lines { get; set; } public int Lines { get; set; }
@ -41,6 +45,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
public override void Dispose() public override void Dispose()
{ {
Initialized = false;
_sampleAggregator.PerformFFT = false; _sampleAggregator.PerformFFT = false;
_sampleAggregator.FftCalculated -= FftCalculated; _sampleAggregator.FftCalculated -= FftCalculated;
@ -51,18 +56,20 @@ namespace Artemis.Modules.Effects.AudioVisualizer
public override void Enable() public override void Enable()
{ {
Lines = MainModel.ActiveKeyboard.Width; Initialized = false;
Lines = MainManager.KeyboardManager.ActiveKeyboard.Width;
// TODO: Device selection // TODO: Device selection
SelectedDeviceId = new MMDeviceEnumerator() SelectedDeviceId = new MMDeviceEnumerator()
.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active) .EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active)
.FirstOrDefault()?.ID; .FirstOrDefault()?.ID;
// Apply settings
SoundRectangles = new List<KeyboardRectangle>(); SoundRectangles = new List<KeyboardRectangle>();
for (var i = 0; i < Lines; i++) for (var i = 0; i < Lines; i++)
{ {
SoundRectangles.Add(new KeyboardRectangle( SoundRectangles.Add(new KeyboardRectangle(
MainModel.ActiveKeyboard, MainManager.KeyboardManager.ActiveKeyboard,
0, 0, new List<Color> 0, 0, new List<Color>
{ {
ColorHelpers.ToDrawingColor(Settings.TopColor), ColorHelpers.ToDrawingColor(Settings.TopColor),
@ -71,13 +78,17 @@ namespace Artemis.Modules.Effects.AudioVisualizer
}, },
LinearGradientMode.Vertical) {ContainedBrush = false, Height = 0}); LinearGradientMode.Vertical) {ContainedBrush = false, Height = 0});
} }
_sensitivity = Settings.Sensitivity;
_fromBottom = Settings.FromBottom;
_sampleAggregator.FftCalculated += FftCalculated; _sampleAggregator.FftCalculated += FftCalculated;
_sampleAggregator.PerformFFT = true; _sampleAggregator.PerformFFT = true;
// Start listening for sound data
_waveIn = new WasapiLoopbackCapture(); _waveIn = new WasapiLoopbackCapture();
_waveIn.DataAvailable += OnDataAvailable; _waveIn.DataAvailable += OnDataAvailable;
_waveIn.StartRecording(); _waveIn.StartRecording();
Initialized = true;
} }
public override void Update() public override void Update()
@ -107,8 +118,9 @@ namespace Artemis.Modules.Effects.AudioVisualizer
height = (int) Math.Round(SpectrumData[i]/2.55); height = (int) Math.Round(SpectrumData[i]/2.55);
// Apply Sensitivity setting // Apply Sensitivity setting
height = height*Settings.Sensitivity; height = height*_sensitivity;
var keyboardHeight = (int) Math.Round(MainModel.ActiveKeyboard.Height/100.00*height*Scale); var keyboardHeight =
(int) Math.Round(MainManager.KeyboardManager.ActiveKeyboard.Height/100.00*height*Scale);
if (keyboardHeight > SoundRectangles[i].Height) if (keyboardHeight > SoundRectangles[i].Height)
SoundRectangles[i].Height = keyboardHeight; SoundRectangles[i].Height = keyboardHeight;
else else
@ -117,8 +129,9 @@ namespace Artemis.Modules.Effects.AudioVisualizer
SoundRectangles[i].X = i*Scale; SoundRectangles[i].X = i*Scale;
SoundRectangles[i].Width = Scale; SoundRectangles[i].Width = Scale;
if (Settings.FromBottom) if (_fromBottom)
SoundRectangles[i].Y = MainModel.ActiveKeyboard.Height*Scale - SoundRectangles[i].Height; SoundRectangles[i].Y = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale -
SoundRectangles[i].Height;
} }
_generating = false; _generating = false;
} }
@ -131,7 +144,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
// Lock the _spectrumData array while busy with it // Lock the _spectrumData array while busy with it
_generating = true; _generating = true;
var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale); var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{ {
foreach (var soundRectangle in SoundRectangles) foreach (var soundRectangle in SoundRectangles)

View File

@ -37,17 +37,17 @@
<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}" Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" /> cal:Message.Attach="[Event Click] = [Action ToggleEffect]"
ToolTip="Note: You can't enable an effect when Artemis is disabled" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<!-- Top color --> <!-- Top color -->
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" <TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
Height="16" Margin="0,8"> Height="16" Margin="0,8">
Color used on top Color used on top
</TextBlock> </TextBlock>
<xctk:ColorPicker x:Name="TopColor" <xctk:ColorPicker x:Name="TopColor"
SelectedColor="{Binding Path=AudioVisualizerSettings.TopColor, Mode=TwoWay}" SelectedColor="{Binding Path=EffectSettings.TopColor, Mode=TwoWay}"
Grid.Row="1" Grid.Column="1" Width="110" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" /> VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
@ -57,7 +57,7 @@
Color used in the middle Color used in the middle
</TextBlock> </TextBlock>
<xctk:ColorPicker x:Name="MiddleColor" <xctk:ColorPicker x:Name="MiddleColor"
SelectedColor="{Binding Path=AudioVisualizerSettings.MiddleColor, Mode=TwoWay}" SelectedColor="{Binding Path=EffectSettings.MiddleColor, Mode=TwoWay}"
Grid.Row="2" Grid.Column="1" Width="110" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" /> VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
@ -67,19 +67,18 @@
Color used on the bottom Color used on the bottom
</TextBlock> </TextBlock>
<xctk:ColorPicker x:Name="Bottom" <xctk:ColorPicker x:Name="Bottom"
SelectedColor="{Binding Path=AudioVisualizerSettings.BottomColor, Mode=TwoWay}" SelectedColor="{Binding Path=EffectSettings.BottomColor, Mode=TwoWay}"
Grid.Row="3" Grid.Column="1" Width="110" HorizontalAlignment="Right" Grid.Row="3" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" /> VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
<!-- Bar direction --> <!-- Bar direction -->
<TextBlock Grid.Row="4" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" <TextBlock Grid.Row="4" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
Height="16" Margin="0,9,0,10"> Height="16" Margin="0,9,0,10">
Grow bars bottom (broken, sorry!) Grow bars bottom
</TextBlock> </TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=AudioVisualizerSettings.FromBottom, Mode=TwoWay}" <controls:ToggleSwitch IsChecked="{Binding Path=EffectSettings.FromBottom, Mode=TwoWay}"
Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes"
OffLabel="No" OffLabel="No" Margin="0,0,-5,0" Width="114" />
Margin="0,0,-5,0" Width="114" IsEnabled="False" />
<!-- Bars amount --> <!-- Bars amount -->
<TextBlock Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" <TextBlock Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
@ -88,7 +87,7 @@
</TextBlock> </TextBlock>
<Slider x:Name="Bars" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center" <Slider x:Name="Bars" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1" HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
Value="{Binding Path=AudioVisualizerSettings.Bars, Mode=TwoWay}" Minimum="2" Maximum="21" Value="{Binding Path=EffectSettings.Bars, Mode=TwoWay}" Minimum="2" Maximum="21"
SmallChange="1" IsSnapToTickEnabled="True" /> SmallChange="1" IsSnapToTickEnabled="True" />
<!-- Sensitivity --> <!-- Sensitivity -->
@ -98,7 +97,7 @@
</TextBlock> </TextBlock>
<Slider x:Name="Sensitivity" Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" <Slider x:Name="Sensitivity" Grid.Row="6" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1" HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
Value="{Binding Path=AudioVisualizerSettings.Sensitivity, Mode=TwoWay}" Minimum="1" Maximum="10" Value="{Binding Path=EffectSettings.Sensitivity, Mode=TwoWay}" Minimum="1" Maximum="10"
SmallChange="1" IsSnapToTickEnabled="True" /> SmallChange="1" IsSnapToTickEnabled="True" />
<!-- Fade speed --> <!-- Fade speed -->
@ -108,7 +107,7 @@
</TextBlock> </TextBlock>
<Slider x:Name="FadeSpeed" Grid.Row="7" Grid.Column="1" VerticalAlignment="Center" <Slider x:Name="FadeSpeed" Grid.Row="7" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1" HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
Value="{Binding Path=AudioVisualizerSettings.FadeSpeed, Mode=TwoWay}" Minimum="1" Maximum="3" Value="{Binding Path=EffectSettings.FadeSpeed, Mode=TwoWay}" Minimum="1" Maximum="3"
SmallChange="1" IsSnapToTickEnabled="True" /> SmallChange="1" IsSnapToTickEnabled="True" />
<!-- Buttons --> <!-- Buttons -->

View File

@ -1,74 +1,31 @@
using Artemis.Events; using Artemis.Events;
using Artemis.Models; using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.Modules.Effects.AudioVisualizer namespace Artemis.Modules.Effects.AudioVisualizer
{ {
public class AudioVisualizerViewModel : Screen, IHandle<ChangeActiveEffect> public class AudioVisualizerViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{ {
private AudioVisualizerSettings _audioVisualizerSettings; public AudioVisualizerViewModel(MainManager mainManager)
public AudioVisualizerViewModel(MainModel mainModel)
{ {
// Subscribe to main model // Subscribe to main model
MainModel = mainModel; MainManager = mainManager;
MainModel.Events.Subscribe(this); MainManager.Events.Subscribe(this);
// Settings are loaded from file by class // Settings are loaded from file by class
AudioVisualizerSettings = new AudioVisualizerSettings(); EffectSettings = new AudioVisualizerSettings();
// Create effect model and add it to MainModel // Create effect model and add it to MainManager
AudioVisualizerModel = new AudioVisualizerModel(mainModel, AudioVisualizerSettings); EffectModel = new AudioVisualizerModel(mainManager, (AudioVisualizerSettings) EffectSettings);
MainModel.EffectModels.Add(AudioVisualizerModel); MainManager.EffectManager.EffectModels.Add(EffectModel);
} }
public MainModel MainModel { get; set; }
public AudioVisualizerModel AudioVisualizerModel { get; set; }
public static string Name => "Audio Visualizer"; public static string Name => "Audio Visualizer";
public bool EffectEnabled => MainModel.IsEnabled(AudioVisualizerModel);
public AudioVisualizerSettings AudioVisualizerSettings public void Handle(ActiveEffectChanged message)
{
get { return _audioVisualizerSettings; }
set
{
if (Equals(value, _audioVisualizerSettings)) return;
_audioVisualizerSettings = value;
NotifyOfPropertyChange(() => AudioVisualizerSettings);
}
}
public void Handle(ChangeActiveEffect message)
{ {
NotifyOfPropertyChange(() => EffectEnabled); NotifyOfPropertyChange(() => EffectEnabled);
} }
public void ToggleEffect()
{
if (EffectEnabled && !MainModel.Suspended)
MainModel.ToggleSuspension();
else if (!EffectEnabled && !MainModel.Suspended)
MainModel.EnableEffect(AudioVisualizerModel);
else
{
MainModel.ToggleSuspension();
MainModel.EnableEffect(AudioVisualizerModel);
}
}
public void SaveSettings()
{
AudioVisualizerSettings?.Save();
}
public void ResetSettings()
{
// TODO: Confirmation dialog (Generic MVVM approach)
AudioVisualizerSettings.ToDefault();
NotifyOfPropertyChange(() => AudioVisualizerSettings);
SaveSettings();
}
} }
} }

View File

@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using Artemis.Managers;
using Artemis.Models; using Artemis.Models;
using Artemis.Utilities.Keyboard; using Artemis.Utilities.Keyboard;
@ -8,11 +9,12 @@ namespace Artemis.Modules.Effects.Debug
{ {
internal class DebugEffectModel : EffectModel internal class DebugEffectModel : EffectModel
{ {
public DebugEffectModel(MainModel mainModel, DebugEffectSettings settings) : base(mainModel) public DebugEffectModel(MainManager mainManager, DebugEffectSettings settings) : base(mainManager)
{ {
Name = "Debug Effect"; Name = "Debug Effect";
Settings = settings; Settings = settings;
Scale = 4; Scale = 4;
Initialized = false;
} }
public int Scale { get; set; } public int Scale { get; set; }
@ -23,11 +25,14 @@ namespace Artemis.Modules.Effects.Debug
public override void Dispose() public override void Dispose()
{ {
Initialized = false;
} }
public override void Enable() public override void Enable()
{ {
KeyboardRectangle = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color> Initialized = false;
KeyboardRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>
{ {
Color.Red, Color.Red,
Color.OrangeRed, Color.OrangeRed,
@ -37,6 +42,8 @@ namespace Artemis.Modules.Effects.Debug
Color.Purple, Color.Purple,
Color.DeepPink Color.DeepPink
}, LinearGradientMode.Horizontal); }, LinearGradientMode.Horizontal);
Initialized = true;
} }
public override void Update() public override void Update()

View File

@ -35,7 +35,9 @@
<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}" Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" /> cal:Message.Attach="[Event Click] = [Action ToggleEffect]"
ToolTip="Note: You can't enable an effect when Artemis is disabled"
ToolTipService.ShowOnDisabled="True" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
@ -54,7 +56,7 @@
</TextBlock> </TextBlock>
<Slider x:Name="Width" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" <Slider x:Name="Width" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1" HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
Value="{Binding Path=DebugEffectSettings.Width, Mode=TwoWay}" Minimum="0" Maximum="84" Value="{Binding Path=EffectSettings.Width, Mode=TwoWay}" Minimum="0" Maximum="84"
SmallChange="1" IsSnapToTickEnabled="True" /> SmallChange="1" IsSnapToTickEnabled="True" />
<!-- Height --> <!-- Height -->
@ -64,7 +66,7 @@
</TextBlock> </TextBlock>
<Slider x:Name="Height" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" <Slider x:Name="Height" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1" HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
Value="{Binding Path=DebugEffectSettings.Height, Mode=TwoWay}" Minimum="0" Maximum="24" Value="{Binding Path=EffectSettings.Height, Mode=TwoWay}" Minimum="0" Maximum="24"
SmallChange="1" IsSnapToTickEnabled="True" /> SmallChange="1" IsSnapToTickEnabled="True" />
<!-- Scale --> <!-- Scale -->
@ -74,7 +76,7 @@
</TextBlock> </TextBlock>
<Slider x:Name="Scale" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" <Slider x:Name="Scale" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1" HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
Value="{Binding Path=DebugEffectSettings.Scale, Mode=TwoWay}" Minimum="1" Maximum="4" Value="{Binding Path=EffectSettings.Scale, Mode=TwoWay}" Minimum="1" Maximum="4"
SmallChange="1" IsSnapToTickEnabled="True" /> SmallChange="1" IsSnapToTickEnabled="True" />
<!-- Color rotation --> <!-- Color rotation -->
@ -82,7 +84,7 @@
Height="16" Margin="0,9,0,10"> Height="16" Margin="0,9,0,10">
Rotate colors on debug-rectangle Rotate colors on debug-rectangle
</TextBlock> </TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=DebugEffectSettings.Rotate, Mode=TwoWay}" <controls:ToggleSwitch IsChecked="{Binding Path=EffectSettings.Rotate, Mode=TwoWay}"
Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes"
OffLabel="No" OffLabel="No"
Margin="0,0,-5,0" Width="114" /> Margin="0,0,-5,0" Width="114" />

View File

@ -5,49 +5,33 @@ using System.IO;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using Artemis.Events; using Artemis.Events;
using Artemis.Models; using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.Modules.Effects.Debug namespace Artemis.Modules.Effects.Debug
{ {
internal class DebugEffectViewModel : Screen, IHandle<ChangeBitmap>, IHandle<ChangeActiveEffect> internal class DebugEffectViewModel : EffectViewModel, IHandle<ChangeBitmap>, IHandle<ActiveEffectChanged>
{ {
private DebugEffectSettings _debugEffectSettings;
private ImageSource _imageSource; private ImageSource _imageSource;
private string _selectedRectangleType; private string _selectedRectangleType;
public DebugEffectViewModel(MainModel mainModel) public DebugEffectViewModel(MainManager mainManager)
{ {
// Subscribe to main model // Subscribe to main model
MainModel = mainModel; MainManager = mainManager;
MainModel.Events.Subscribe(this); MainManager.Events.Subscribe(this);
// Settings are loaded from file by class // Settings are loaded from file by class
DebugEffectSettings = new DebugEffectSettings(); EffectSettings = new DebugEffectSettings();
// Create effect model and add it to MainModel // Create effect model and add it to MainManager
DebugEffectModel = new DebugEffectModel(mainModel, DebugEffectSettings); EffectModel = new DebugEffectModel(mainManager, (DebugEffectSettings) EffectSettings);
MainModel.EffectModels.Add(DebugEffectModel); MainManager.EffectManager.EffectModels.Add(EffectModel);
} }
public MainModel MainModel { get; set; }
public DebugEffectModel DebugEffectModel { get; set; }
public static string Name => "Type Waves"; public static string Name => "Debug Effect";
public bool EffectEnabled => MainModel.IsEnabled(DebugEffectModel);
public DebugEffectSettings DebugEffectSettings
{
get { return _debugEffectSettings; }
set
{
if (Equals(value, _debugEffectSettings)) return;
_debugEffectSettings = value;
NotifyOfPropertyChange(() => DebugEffectSettings);
SelectedRectangleType = value.Type.ToString();
}
}
public BindableCollection<string> RectangleTypes public BindableCollection<string> RectangleTypes
=> new BindableCollection<string>(Enum.GetNames(typeof (LinearGradientMode))); => new BindableCollection<string>(Enum.GetNames(typeof (LinearGradientMode)));
@ -61,7 +45,8 @@ namespace Artemis.Modules.Effects.Debug
_selectedRectangleType = value; _selectedRectangleType = value;
NotifyOfPropertyChange(() => SelectedRectangleType); NotifyOfPropertyChange(() => SelectedRectangleType);
DebugEffectSettings.Type = (LinearGradientMode) Enum.Parse(typeof (LinearGradientMode), value); ((DebugEffectSettings) EffectSettings).Type =
(LinearGradientMode) Enum.Parse(typeof (LinearGradientMode), value);
} }
} }
@ -75,14 +60,13 @@ namespace Artemis.Modules.Effects.Debug
} }
} }
public void Handle(ChangeActiveEffect message) public void Handle(ActiveEffectChanged message)
{ {
NotifyOfPropertyChange(() => EffectEnabled); NotifyOfPropertyChange(() => EffectEnabled);
} }
public void Handle(ChangeBitmap message) public void Handle(ChangeBitmap message)
{ {
// Doesn't show transparancy
using (var memory = new MemoryStream()) using (var memory = new MemoryStream())
{ {
message.Bitmap.Save(memory, ImageFormat.Png); message.Bitmap.Save(memory, ImageFormat.Png);
@ -97,25 +81,5 @@ namespace Artemis.Modules.Effects.Debug
ImageSource = bitmapImage; ImageSource = bitmapImage;
} }
} }
public void ToggleEffect()
{
if (EffectEnabled && !MainModel.Suspended)
MainModel.ToggleSuspension();
else if (!EffectEnabled && !MainModel.Suspended)
MainModel.EnableEffect(DebugEffectModel);
else
{
MainModel.ToggleSuspension();
MainModel.EnableEffect(DebugEffectModel);
}
}
public void ResetSettings()
{
// TODO: Confirmation dialog (Generic MVVM approach)
DebugEffectSettings.ToDefault();
NotifyOfPropertyChange(() => DebugEffectSettings);
}
} }
} }

View File

@ -1,21 +1,31 @@
using System.Drawing; using System.Drawing;
using Artemis.Managers;
using Artemis.Models; using Artemis.Models;
namespace Artemis.Modules.Effects.TypeHole namespace Artemis.Modules.Effects.TypeHole
{ {
public class TypeHoleModel : EffectModel public class TypeHoleModel : EffectModel
{ {
public TypeHoleModel(MainModel mainModel) : base(mainModel) public TypeHoleModel(MainManager mainManager) : base(mainManager)
{ {
Name = "TypeHole"; Name = "TypeHole";
Initialized = false;
} }
public override void Dispose() public override void Dispose()
{ {
Initialized = false;
// Disable logic
} }
public override void Enable() public override void Enable()
{ {
Initialized = false;
// Enable logic
Initialized = true;
} }
public override void Update() public override void Update()

View File

@ -31,9 +31,17 @@
<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"
IsChecked="{Binding Path=EffectEnabled, Mode=OneWay}"
Style="{DynamicResource MetroCircleToggleButtonStyle}" Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" /> cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
<Popup PlacementTarget="{Binding ElementName=EffectEnabled}"
IsOpen="{Binding Path=ShowDisabledPopup, Mode=TwoWay}" Placement="Left" VerticalOffset="-10"
PopupAnimation="Fade" StaysOpen="False">
<Border Margin="1">
<TextBlock Background="{DynamicResource AccentColorBrush}"
Foreground="{DynamicResource IdealForegroundColorBrush}"
Text="You can't enable an effect when Artemis is disabled" Padding="4" />
</Border>
</Popup>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Grid> </Grid>

View File

@ -1,44 +1,28 @@
using Artemis.Events; using Artemis.Events;
using Artemis.Models; using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.Modules.Effects.TypeHole namespace Artemis.Modules.Effects.TypeHole
{ {
public class TypeHoleViewModel : Screen, IHandle<ChangeActiveEffect> public class TypeHoleViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{ {
public TypeHoleViewModel(MainModel mainModel) public TypeHoleViewModel(MainManager mainManager)
{ {
// Subscribe to main model // Subscribe to main model
MainModel = mainModel; MainManager = mainManager;
MainModel.Events.Subscribe(this); MainManager.Events.Subscribe(this);
// Create effect model and add it to MainModel // Create effect model and add it to MainManager
TypeHoleModel = new TypeHoleModel(mainModel); EffectModel = new TypeHoleModel(mainManager);
MainModel.EffectModels.Add(TypeHoleModel); MainManager.EffectManager.EffectModels.Add(EffectModel);
} }
public MainModel MainModel { get; set; }
public TypeHoleModel TypeHoleModel { get; set; }
public static string Name => "Type Holes (NYI)"; public static string Name => "Type Holes (NYI)";
public bool EffectEnabled => MainModel.IsEnabled(TypeHoleModel);
public void Handle(ChangeActiveEffect message) public void Handle(ActiveEffectChanged message)
{ {
NotifyOfPropertyChange(() => EffectEnabled); NotifyOfPropertyChange(() => EffectEnabled);
} }
public void ToggleEffect()
{
if (EffectEnabled && !MainModel.Suspended)
MainModel.ToggleSuspension();
else if (!EffectEnabled && !MainModel.Suspended)
MainModel.EnableEffect(TypeHoleModel);
else
{
MainModel.ToggleSuspension();
MainModel.EnableEffect(TypeHoleModel);
}
}
} }
} }

View File

@ -2,10 +2,10 @@
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Artemis.KeyboardProviders.Corsair; using Artemis.KeyboardProviders.Corsair;
using Artemis.KeyboardProviders.Logitech.Utilities; using Artemis.KeyboardProviders.Logitech.Utilities;
using Artemis.Managers;
using Artemis.Models; using Artemis.Models;
using Artemis.Utilities; using Artemis.Utilities;
@ -16,25 +16,50 @@ namespace Artemis.Modules.Effects.TypeWave
private readonly List<Wave> _waves; private readonly List<Wave> _waves;
private Color _randomColor; private Color _randomColor;
public TypeWaveModel(MainModel mainModel, TypeWaveSettings settings) : base(mainModel) public TypeWaveModel(MainManager mainManager, TypeWaveSettings settings) : base(mainManager)
{ {
Name = "TypeWave"; Name = "TypeWave";
_waves = new List<Wave>(); _waves = new List<Wave>();
_randomColor = Color.Red; _randomColor = Color.Red;
Settings = settings; Settings = settings;
Initialized = false;
Scale = 4;
} }
public int Scale { get; set; }
public TypeWaveSettings Settings { get; set; } public TypeWaveSettings Settings { get; set; }
public override void Dispose() public override void Dispose()
{ {
MainModel.KeyboardHook.Unsubscribe(HandleKeypress); Initialized = false;
MainManager.KeyboardHook.KeyDownCallback -= KeyboardHookOnKeyDownCallback;
}
private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
{
// More than 25 waves is pointless
if (_waves.Count >= 25)
return;
var keyMatch = KeyMap.UsEnglishOrionKeys.FirstOrDefault(k => k.KeyCode == e.KeyCode);
if (keyMatch == null)
return;
_waves.Add(Settings.IsRandomColors
? new Wave(new Point(keyMatch.PosX * Scale, keyMatch.PosY * Scale), 0, _randomColor)
: new Wave(new Point(keyMatch.PosX * Scale, keyMatch.PosY * Scale), 0,
ColorHelpers.ToDrawingColor(Settings.WaveColor)));
} }
public override void Enable() public override void Enable()
{ {
Initialized = false;
// Listener won't start unless the effect is active // Listener won't start unless the effect is active
MainModel.KeyboardHook.Subscribe(HandleKeypress); MainManager.KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback;
Initialized = true;
} }
public override void Update() public override void Update()
@ -47,7 +72,7 @@ namespace Artemis.Modules.Effects.TypeWave
// TODO: Get from settings // TODO: Get from settings
var fps = 25; var fps = 25;
_waves[i].Size += Settings.SpreadSpeed; _waves[i].Size += Settings.SpreadSpeed * Scale;
if (Settings.IsShiftColors) if (Settings.IsShiftColors)
_waves[i].Color = ColorHelpers.ShiftColor(_waves[i].Color, Settings.ShiftColorSpeed); _waves[i].Color = ColorHelpers.ShiftColor(_waves[i].Color, Settings.ShiftColorSpeed);
@ -71,13 +96,13 @@ namespace Artemis.Modules.Effects.TypeWave
if (_waves.Count == 0) if (_waves.Count == 0)
return null; return null;
var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(); var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{ {
g.Clear(Color.Transparent); g.Clear(Color.Transparent);
g.SmoothingMode = SmoothingMode.HighQuality; g.SmoothingMode = SmoothingMode.HighQuality;
// Don't want a foreach, collection is changed in different thread // Don't want a for-each, collection is changed in different thread
// ReSharper disable once ForCanBeConvertedToForeach // ReSharper disable once ForCanBeConvertedToForeach
for (var i = 0; i < _waves.Count; i++) for (var i = 0; i < _waves.Count; i++)
{ {
@ -88,7 +113,7 @@ namespace Artemis.Modules.Effects.TypeWave
_waves[i].Size, _waves[i].Size); _waves[i].Size, _waves[i].Size);
Color fillColor; Color fillColor;
if (MainModel.ActiveKeyboard is CorsairRGB) if (MainManager.KeyboardManager.ActiveKeyboard is CorsairRGB)
fillColor = Color.Black; fillColor = Color.Black;
else else
fillColor = Color.Transparent; fillColor = Color.Transparent;
@ -109,27 +134,6 @@ namespace Artemis.Modules.Effects.TypeWave
} }
return bitmap; return bitmap;
} }
private void HandleKeypress(object sender, KeyEventArgs e)
{
Task.Factory.StartNew(() => KeyPressTask(e));
}
private void KeyPressTask(KeyEventArgs e)
{
// More than 25 waves is pointless
if (_waves.Count >= 25)
return;
var keyMatch = KeyMap.UsEnglishOrionKeys.FirstOrDefault(k => k.KeyCode == e.KeyCode);
if (keyMatch == null)
return;
_waves.Add(Settings.IsRandomColors
? new Wave(new Point(keyMatch.PosX, keyMatch.PosY), 0, _randomColor)
: new Wave(new Point(keyMatch.PosX, keyMatch.PosY), 0,
ColorHelpers.ToDrawingColor(Settings.WaveColor)));
}
} }
public class Wave public class Wave

View File

@ -22,7 +22,6 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
@ -35,8 +34,17 @@
<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"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" Style="{DynamicResource MetroCircleToggleButtonStyle}"
Style="{DynamicResource MetroCircleToggleButtonStyle}" /> cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
<Popup PlacementTarget="{Binding ElementName=EffectEnabled}"
IsOpen="{Binding Path=ShowDisabledPopup, Mode=TwoWay}" Placement="Left" VerticalOffset="-10"
PopupAnimation="Fade" StaysOpen="False">
<Border Margin="1">
<TextBlock Background="{DynamicResource AccentColorBrush}"
Foreground="{DynamicResource IdealForegroundColorBrush}"
Text="You can't enable an effect when Artemis is disabled" Padding="4" />
</Border>
</Popup>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
@ -46,7 +54,7 @@
Wave color Wave color
</TextBlock> </TextBlock>
<xctk:ColorPicker x:Name="MiddleColor" <xctk:ColorPicker x:Name="MiddleColor"
SelectedColor="{Binding Path=TypeWaveSettings.WaveColor, Mode=TwoWay}" SelectedColor="{Binding Path=EffectSettings.WaveColor, Mode=TwoWay}"
Grid.Row="1" Grid.Column="1" Width="110" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" /> VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
@ -55,7 +63,7 @@
Height="16" Margin="0,8"> Height="16" Margin="0,8">
Use random colors Use random colors
</TextBlock> </TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=TypeWaveSettings.IsRandomColors, Mode=TwoWay}" <controls:ToggleSwitch IsChecked="{Binding Path=EffectSettings.IsRandomColors, Mode=TwoWay}"
Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes"
OffLabel="No" OffLabel="No"
Margin="0,0,-5,0" Width="114" /> Margin="0,0,-5,0" Width="114" />
@ -65,7 +73,7 @@
Height="16" Margin="0,8"> Height="16" Margin="0,8">
Shift through colors as the wave grows Shift through colors as the wave grows
</TextBlock> </TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=TypeWaveSettings.IsShiftColors, Mode=TwoWay}" <controls:ToggleSwitch IsChecked="{Binding Path=EffectSettings.IsShiftColors, Mode=TwoWay}"
Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes"
OffLabel="No" OffLabel="No"
Margin="0,0,-5,0" Width="114" /> Margin="0,0,-5,0" Width="114" />
@ -77,7 +85,7 @@
</TextBlock> </TextBlock>
<Slider x:Name="ColorShiftSpeed" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" <Slider x:Name="ColorShiftSpeed" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1" HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
Value="{Binding Path=TypeWaveSettings.ShiftColorSpeed, Mode=TwoWay}" Minimum="1" Maximum="200" Value="{Binding Path=EffectSettings.ShiftColorSpeed, Mode=TwoWay}" Minimum="1" Maximum="200"
SmallChange="45" IsSnapToTickEnabled="True" /> SmallChange="45" IsSnapToTickEnabled="True" />
<!-- TTL --> <!-- TTL -->
@ -87,7 +95,7 @@
</TextBlock> </TextBlock>
<Slider x:Name="TimeToLive" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center" <Slider x:Name="TimeToLive" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1" HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
Value="{Binding Path=TypeWaveSettings.TimeToLive, Mode=TwoWay}" Minimum="100" Maximum="2000" Value="{Binding Path=EffectSettings.TimeToLive, Mode=TwoWay}" Minimum="100" Maximum="2000"
SmallChange="45" IsSnapToTickEnabled="True" /> SmallChange="45" IsSnapToTickEnabled="True" />
<!-- Growth speed --> <!-- Growth speed -->
@ -97,11 +105,11 @@
</TextBlock> </TextBlock>
<Slider x:Name="SpreadSpeed" Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" <Slider x:Name="SpreadSpeed" Grid.Row="6" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1" HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
Value="{Binding Path=TypeWaveSettings.SpreadSpeed, Mode=TwoWay}" Minimum="1" Maximum="6" Value="{Binding Path=EffectSettings.SpreadSpeed, Mode=TwoWay}" Minimum="1" Maximum="6"
SmallChange="1" IsSnapToTickEnabled="True" /> SmallChange="1" IsSnapToTickEnabled="True" />
<!-- Buttons --> <!-- Buttons -->
<StackPanel Grid.Column="0" Grid.Row="7" Orientation="Horizontal" VerticalAlignment="Bottom"> <StackPanel Grid.Column="0" Grid.Row="8" Orientation="Horizontal" VerticalAlignment="Bottom">
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100" <Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100"
Style="{DynamicResource SquareButtonStyle}" /> Style="{DynamicResource SquareButtonStyle}" />
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100" <Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100"

View File

@ -1,77 +1,31 @@
using Artemis.Events; using Artemis.Events;
using Artemis.Models; using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.Modules.Effects.TypeWave namespace Artemis.Modules.Effects.TypeWave
{ {
public class TypeWaveViewModel : Screen, IHandle<ChangeActiveEffect> public class TypeWaveViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{ {
private TypeWaveSettings _typeWaveSettings; public TypeWaveViewModel(MainManager mainManager)
public TypeWaveViewModel(MainModel mainModel)
{ {
// Subscribe to main model // Subscribe to main model
MainModel = mainModel; MainManager = mainManager;
MainModel.Events.Subscribe(this); MainManager.Events.Subscribe(this);
// Settings are loaded from file by class // Settings are loaded from file by class
TypeWaveSettings = new TypeWaveSettings(); EffectSettings = new TypeWaveSettings();
// Create effect model and add it to MainModel // Create effect model and add it to MainManager
TypeWaveModel = new TypeWaveModel(mainModel, TypeWaveSettings); EffectModel = new TypeWaveModel(mainManager, (TypeWaveSettings) EffectSettings);
MainModel.EffectModels.Add(TypeWaveModel); MainManager.EffectManager.EffectModels.Add(EffectModel);
} }
public MainModel MainModel { get; set; }
public TypeWaveModel TypeWaveModel { get; set; }
public static string Name => "Type Waves"; public static string Name => "Type Waves";
public bool EffectEnabled => MainModel.IsEnabled(TypeWaveModel);
public TypeWaveSettings TypeWaveSettings public void Handle(ActiveEffectChanged message)
{
get { return _typeWaveSettings; }
set
{
if (Equals(value, _typeWaveSettings)) return;
_typeWaveSettings = value;
NotifyOfPropertyChange(() => TypeWaveSettings);
}
}
public void Handle(ChangeActiveEffect message)
{ {
NotifyOfPropertyChange(() => EffectEnabled); NotifyOfPropertyChange(() => EffectEnabled);
} }
public void ToggleEffect()
{
if (EffectEnabled && !MainModel.Suspended)
MainModel.ToggleSuspension();
else if (!EffectEnabled && !MainModel.Suspended)
MainModel.EnableEffect(TypeWaveModel);
else
{
MainModel.ToggleSuspension();
MainModel.EnableEffect(TypeWaveModel);
}
}
public void SaveSettings()
{
if (TypeWaveModel == null)
return;
TypeWaveSettings.Save();
}
public void ResetSettings()
{
// TODO: Confirmation dialog (Generic MVVM approach)
TypeWaveSettings.ToDefault();
NotifyOfPropertyChange(() => TypeWaveSettings);
SaveSettings();
}
} }
} }

View File

@ -4,8 +4,7 @@ using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Linq; using System.Linq;
using Artemis.KeyboardProviders; using Artemis.KeyboardProviders;
using Artemis.KeyboardProviders.Corsair; using Artemis.Managers;
using Artemis.KeyboardProviders.Logitech;
using Artemis.Models; using Artemis.Models;
using Artemis.Utilities; using Artemis.Utilities;
using Artemis.Utilities.GameState; using Artemis.Utilities.GameState;
@ -19,13 +18,14 @@ namespace Artemis.Modules.Games.CounterStrike
{ {
private KeyboardRegion _topRow; private KeyboardRegion _topRow;
public CounterStrikeModel(MainModel mainModel, CounterStrikeSettings settings) : base(mainModel) public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager)
{ {
Settings = settings; Settings = settings;
Name = "CounterStrike"; Name = "CounterStrike";
ProcessName = "csgo"; ProcessName = "csgo";
Scale = 4; Scale = 4;
Enabled = Settings.Enabled; Enabled = Settings.Enabled;
Initialized = false;
} }
public CounterStrikeSettings Settings { get; set; } public CounterStrikeSettings Settings { get; set; }
@ -42,20 +42,34 @@ namespace Artemis.Modules.Games.CounterStrike
public override void Dispose() public override void Dispose()
{ {
MainModel.GameStateWebServer.GameDataReceived -= HandleGameData; Initialized = false;
MainManager.GameStateWebServer.GameDataReceived -= HandleGameData;
} }
public override void Enable() public override void Enable()
{ {
Initialized = false;
// Some keyboards have a different baseline, Corsair F-keys start at row 1 // Some keyboards have a different baseline, Corsair F-keys start at row 1
_topRow = MainModel.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow"); _topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X, new List<Color>(), AmmoRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X,
new List<Color>(),
LinearGradientMode.Horizontal) {Height = Scale, ContainedBrush = false}; LinearGradientMode.Horizontal) {Height = Scale, ContainedBrush = false};
TeamRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X + 1, new List<Color>(), TeamRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X + 1,
LinearGradientMode.Horizontal) {Height = MainModel.ActiveKeyboard.Height*Scale - Scale}; new List<Color>(),
EventRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X + 1, new List<Color>(), LinearGradientMode.Horizontal)
LinearGradientMode.Horizontal) {Height = MainModel.ActiveKeyboard.Height*Scale - Scale}; {
MainModel.GameStateWebServer.GameDataReceived += HandleGameData; Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale
};
EventRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X + 1,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale
};
MainManager.GameStateWebServer.GameDataReceived += HandleGameData;
Initialized = true;
} }
public override void Update() public override void Update()
@ -152,7 +166,7 @@ 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(_topRow.BottomRight.Y / 100.00*ammoPercentage)*Scale; AmmoRect.Width = (int) Math.Floor(_topRow.BottomRight.Y/100.00*ammoPercentage)*Scale;
AmmoRect.Colors = new List<Color> AmmoRect.Colors = new List<Color>
{ {
ColorHelpers.ToDrawingColor(Settings.AmmoMainColor), ColorHelpers.ToDrawingColor(Settings.AmmoMainColor),
@ -168,7 +182,7 @@ namespace Artemis.Modules.Games.CounterStrike
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale); var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{ {

View File

@ -3,14 +3,13 @@ using Artemis.Models;
namespace Artemis.Modules.Games.CounterStrike namespace Artemis.Modules.Games.CounterStrike
{ {
public class CounterStrikeSettings : EffectSettings public class CounterStrikeSettings : GameSettings
{ {
public CounterStrikeSettings() public CounterStrikeSettings()
{ {
Load(); Load();
} }
public bool Enabled { get; set; }
public string GameDirectory { get; set; } public string GameDirectory { get; set; }
public bool AmmoEnabled { get; set; } public bool AmmoEnabled { get; set; }

View File

@ -37,7 +37,7 @@
<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"
IsChecked="{Binding Path=CounterStrikeSettings.Enabled, Mode=TwoWay}" IsChecked="{Binding Path=GameSettings.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>
@ -50,7 +50,7 @@
Width="130" HorizontalAlignment="Left" /> Width="130" HorizontalAlignment="Left" />
<Grid> <Grid>
<TextBox x:Name="GameDirectory" Height="23" TextWrapping="Wrap" Margin="5,0,30,0" <TextBox x:Name="GameDirectory" Height="23" TextWrapping="Wrap" Margin="5,0,30,0"
Text="{Binding Path=CounterStrikeSettings.GameDirectory, Mode=TwoWay}" Text="{Binding Path=GameSettings.GameDirectory, Mode=TwoWay}"
cal:Message.Attach="[Event LostFocus] = [Action PlaceConfigFile]" /> cal:Message.Attach="[Event LostFocus] = [Action PlaceConfigFile]" />
<Button x:Name="BrowseDirectory" Content="..." RenderTransformOrigin="-0.039,-0.944" <Button x:Name="BrowseDirectory" Content="..." RenderTransformOrigin="-0.039,-0.944"
HorizontalAlignment="Right" Width="25" HorizontalAlignment="Right" Width="25"
@ -63,7 +63,7 @@
Height="16" Margin="0,10,0,9"> Height="16" Margin="0,10,0,9">
Display ammo on F-keys Display ammo on F-keys
</TextBlock> </TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=CounterStrikeSettings.AmmoEnabled, Mode=TwoWay}" <controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.AmmoEnabled, Mode=TwoWay}"
Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" /> Margin="0,0,-5,0" Width="114" />
@ -73,7 +73,7 @@
Main ammo color Main ammo color
</TextBlock> </TextBlock>
<xctk:ColorPicker x:Name="MainColor" <xctk:ColorPicker x:Name="MainColor"
SelectedColor="{Binding Path=CounterStrikeSettings.AmmoMainColor, Mode=TwoWay}" SelectedColor="{Binding Path=GameSettings.AmmoMainColor, Mode=TwoWay}"
Grid.Row="3" Grid.Column="1" Width="110" HorizontalAlignment="Right" Grid.Row="3" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" /> VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
@ -83,7 +83,7 @@
Secondary ammo color Secondary ammo color
</TextBlock> </TextBlock>
<xctk:ColorPicker x:Name="SecondaryColor" <xctk:ColorPicker x:Name="SecondaryColor"
SelectedColor="{Binding Path=CounterStrikeSettings.AmmoSecondaryColor, Mode=TwoWay}" SelectedColor="{Binding Path=GameSettings.AmmoSecondaryColor, Mode=TwoWay}"
Grid.Row="4" Grid.Column="1" Width="110" HorizontalAlignment="Right" Grid.Row="4" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" /> VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
@ -92,7 +92,7 @@
Height="16" Margin="0,9,0,10"> Height="16" Margin="0,9,0,10">
Display smoked effect Display smoked effect
</TextBlock> </TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=CounterStrikeSettings.SmokeEnabled, Mode=TwoWay}" <controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.SmokeEnabled, Mode=TwoWay}"
Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No" Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" /> Margin="0,0,-5,0" Width="114" />
@ -101,7 +101,7 @@
Height="16" Margin="0,10,0,9"> Height="16" Margin="0,10,0,9">
Display flashed effect Display flashed effect
</TextBlock> </TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=CounterStrikeSettings.FlashEnabled, Mode=TwoWay}" <controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.FlashEnabled, Mode=TwoWay}"
Grid.Row="6" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No" Grid.Row="6" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" /> Margin="0,0,-5,0" Width="114" />
@ -110,7 +110,7 @@
Height="16" Margin="0,9,0,10"> Height="16" Margin="0,9,0,10">
Color keyboard according to team Color keyboard according to team
</TextBlock> </TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=CounterStrikeSettings.TeamColorEnabled, Mode=TwoWay}" <controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.TeamColorEnabled, Mode=TwoWay}"
Grid.Row="7" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No" Grid.Row="7" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" /> Margin="0,0,-5,0" Width="114" />
@ -119,7 +119,7 @@
Height="16" Margin="0,10,0,9"> Height="16" Margin="0,10,0,9">
Color keyboard red on low HP Color keyboard red on low HP
</TextBlock> </TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=CounterStrikeSettings.LowHpEnabled, Mode=TwoWay}" <controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.LowHpEnabled, Mode=TwoWay}"
Grid.Row="8" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No" Grid.Row="8" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" /> Margin="0,0,-5,0" Width="114" />

View File

@ -1,93 +1,64 @@
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using Artemis.Models; using Artemis.Managers;
using Artemis.Properties; using Artemis.Properties;
using Screen = Caliburn.Micro.Screen; using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.CounterStrike namespace Artemis.Modules.Games.CounterStrike
{ {
public class CounterStrikeViewModel : Screen public class CounterStrikeViewModel : GameViewModel
{ {
private CounterStrikeSettings _counterStrikeSettings; public CounterStrikeViewModel(MainManager mainManager)
public CounterStrikeViewModel(MainModel mainModel)
{ {
MainModel = mainModel; MainManager = mainManager;
// Settings are loaded from file by class // Settings are loaded from file by class
CounterStrikeSettings = new CounterStrikeSettings(); GameSettings = new CounterStrikeSettings();
// Create effect model and add it to MainModel // Create effect model and add it to MainManager
CounterStrikeModel = new CounterStrikeModel(mainModel, CounterStrikeSettings); GameModel = new CounterStrikeModel(mainManager, (CounterStrikeSettings) GameSettings);
MainModel.EffectModels.Add(CounterStrikeModel); MainManager.EffectManager.EffectModels.Add(GameModel);
PlaceConfigFile(); PlaceConfigFile();
} }
public CounterStrikeSettings CounterStrikeSettings
{
get { return _counterStrikeSettings; }
set
{
if (Equals(value, _counterStrikeSettings)) return;
_counterStrikeSettings = value;
NotifyOfPropertyChange(() => CounterStrikeSettings);
}
}
public CounterStrikeModel CounterStrikeModel { get; set; }
public MainModel MainModel { get; set; }
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) GameSettings).GameDirectory};
var result = dialog.ShowDialog(); var result = dialog.ShowDialog();
if (result != DialogResult.OK) if (result != DialogResult.OK)
return; return;
CounterStrikeSettings.GameDirectory = dialog.SelectedPath; ((CounterStrikeSettings) GameSettings).GameDirectory = dialog.SelectedPath;
NotifyOfPropertyChange(() => CounterStrikeSettings); NotifyOfPropertyChange(() => GameSettings);
GameSettings.Save();
PlaceConfigFile(); PlaceConfigFile();
} }
public void PlaceConfigFile() public void PlaceConfigFile()
{ {
if (CounterStrikeSettings.GameDirectory == string.Empty) if (((CounterStrikeSettings) GameSettings).GameDirectory == string.Empty)
return; return;
if (Directory.Exists(CounterStrikeSettings.GameDirectory + "/csgo/cfg")) if (Directory.Exists(((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg"))
{ {
var cfgFile = Resources.gamestateConfiguration.Replace("{{port}}", var cfgFile = Resources.gamestateConfiguration.Replace("{{port}}",
MainModel.GameStateWebServer.Port.ToString()); MainManager.GameStateWebServer.Port.ToString());
File.WriteAllText(CounterStrikeSettings.GameDirectory + "/csgo/cfg/gamestate_integration_artemis.cfg", File.WriteAllText(
((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg/gamestate_integration_artemis.cfg",
cfgFile); cfgFile);
return; return;
} }
MessageBox.Show("Please select a valid CS:GO directory"); MainManager.DialogService.ShowErrorMessageBox("Please select a valid CS:GO directory\n\n" +
CounterStrikeSettings.GameDirectory = string.Empty; @"By default CS:GO is in \SteamApps\common\Counter-Strike Global Offensive");
NotifyOfPropertyChange(() => CounterStrikeSettings); ((CounterStrikeSettings) GameSettings).GameDirectory = string.Empty;
NotifyOfPropertyChange(() => GameSettings);
GameSettings.Save();
} }
} }
} }

View File

@ -1,17 +1,15 @@
using Artemis.Models; using Artemis.Managers;
using Caliburn.Micro; using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.Dota2 namespace Artemis.Modules.Games.Dota2
{ {
public class Dota2ViewModel : Screen public class Dota2ViewModel : GameViewModel
{ {
public Dota2ViewModel(MainModel mainModel) public Dota2ViewModel(MainManager mainManager)
{ {
MainModel = mainModel; MainManager = mainManager;
} }
public MainModel MainModel { get; set; }
public static string Name => "Dota 2 (NYI)"; public static string Name => "Dota 2 (NYI)";
public string Content => "Dota 2 Content"; public string Content => "Dota 2 Content";
} }

View File

@ -58,5 +58,17 @@ namespace Artemis.Modules.Games.RocketLeague {
this["SecondaryColor"] = value; this["SecondaryColor"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool ContextualColor {
get {
return ((bool)(this["ContextualColor"]));
}
set {
this["ContextualColor"] = value;
}
}
} }
} }

View File

@ -13,5 +13,8 @@
<Setting Name="SecondaryColor" Type="System.Windows.Media.Color" Scope="User"> <Setting Name="SecondaryColor" Type="System.Windows.Media.Color" Scope="User">
<Value Profile="(Default)">#FFFF0000</Value> <Value Profile="(Default)">#FFFF0000</Value>
</Setting> </Setting>
<Setting Name="ContextualColor" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -5,6 +5,7 @@ using System.Drawing.Drawing2D;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Managers;
using Artemis.Models; using Artemis.Models;
using Artemis.Settings; using Artemis.Settings;
using Artemis.Utilities; using Artemis.Utilities;
@ -19,17 +20,19 @@ namespace Artemis.Modules.Games.RocketLeague
private int _boostAmount; private int _boostAmount;
private bool _boostGrowing; private bool _boostGrowing;
private KeyboardRectangle _boostRect; private KeyboardRectangle _boostRect;
private bool _contextualColor;
private Memory _memory; private Memory _memory;
private GamePointersCollectionModel _pointer; private GamePointersCollection _pointer;
private int _previousBoost; private int _previousBoost;
public RocketLeagueModel(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel) public RocketLeagueModel(MainManager mainManager, RocketLeagueSettings settings) : base(mainManager)
{ {
Settings = settings; Settings = settings;
Name = "RocketLeague"; Name = "RocketLeague";
ProcessName = "RocketLeague"; ProcessName = "RocketLeague";
Scale = 4; Scale = 4;
Enabled = Settings.Enabled; Enabled = Settings.Enabled;
Initialized = false;
} }
public RocketLeagueSettings Settings { get; set; } public RocketLeagueSettings Settings { get; set; }
@ -38,37 +41,29 @@ namespace Artemis.Modules.Games.RocketLeague
public override void Dispose() public override void Dispose()
{ {
Initialized = false;
_memory = null; _memory = null;
} }
public override void Enable() public override void Enable()
{ {
_boostRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color> Initialized = false;
_contextualColor = Settings.ContextualColor;
_boostRect = new KeyboardRectangle(MainManager.KeyboardManager.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(); Updater.GetPointers();
_pointer = JsonConvert.DeserializeObject<GamePointersCollectionModel>(Offsets.Default.RocketLeague); _pointer = JsonConvert.DeserializeObject<GamePointersCollection>(Offsets.Default.RocketLeague);
//var test =
// JsonConvert.SerializeObject(new List<GamePointersCollectionModel>
// {
// new GamePointersCollectionModel
// {
// Game = "RocketLeague",
// GameVersion = "1.12",
// GameAddresses = new List<GamePointer> {new GamePointer
// {
// Description = "Boost",
// BasePointer = new IntPtr(0x01581AF4),
// Offsets = new []{0xB4, 0x104, 0x320, 0x708, 0x21C}
// }}
// }
// });
var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessName); var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessName);
_memory = new Memory(tempProcess); _memory = new Memory(tempProcess);
Initialized = true;
} }
public override void Update() public override void Update()
@ -91,12 +86,18 @@ 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 =
_boostRect.Colors = new List<Color> (int) Math.Ceiling(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
if (_contextualColor)
{ {
ColorHelpers.ToDrawingColor(Settings.MainColor), if (_boostAmount < 33)
ColorHelpers.ToDrawingColor(Settings.SecondaryColor) _boostRect.Colors = new List<Color> {Color.Red};
}; else if (_boostAmount >= 33 && _boostAmount < 66)
_boostRect.Colors = new List<Color> {Color.Yellow};
else if (_boostAmount >= 66)
_boostRect.Colors = new List<Color> {Color.Lime};
}
Task.Run(() => GrowIfHigher()); Task.Run(() => GrowIfHigher());
} }
@ -113,7 +114,8 @@ 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(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
for (var i = 0; i < amountOfSteps; i++) for (var i = 0; i < amountOfSteps; i++)
{ {
@ -121,10 +123,12 @@ 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(MainManager.KeyboardManager.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(MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*_boostAmount);
Thread.Sleep(50); Thread.Sleep(50);
} }
@ -134,7 +138,7 @@ namespace Artemis.Modules.Games.RocketLeague
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale); var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
if (_boostRect == null) if (_boostRect == null)
return null; return null;

View File

@ -3,22 +3,23 @@ using Artemis.Models;
namespace Artemis.Modules.Games.RocketLeague namespace Artemis.Modules.Games.RocketLeague
{ {
public class RocketLeagueSettings : EffectSettings public class RocketLeagueSettings : GameSettings
{ {
public RocketLeagueSettings() public RocketLeagueSettings()
{ {
Load(); Load();
} }
public bool Enabled { get; set; }
public Color MainColor { get; set; } public Color MainColor { get; set; }
public Color SecondaryColor { get; set; } public Color SecondaryColor { get; set; }
public bool ContextualColor { get; set; }
public sealed override 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;
ContextualColor = RocketLeague.Default.ContextualColor;
} }
public sealed override void Save() public sealed override void Save()
@ -26,6 +27,7 @@ namespace Artemis.Modules.Games.RocketLeague
RocketLeague.Default.Enabled = Enabled; RocketLeague.Default.Enabled = Enabled;
RocketLeague.Default.MainColor = MainColor; RocketLeague.Default.MainColor = MainColor;
RocketLeague.Default.SecondaryColor = SecondaryColor; RocketLeague.Default.SecondaryColor = SecondaryColor;
RocketLeague.Default.ContextualColor = ContextualColor;
RocketLeague.Default.Save(); RocketLeague.Default.Save();
} }
@ -35,6 +37,7 @@ namespace Artemis.Modules.Games.RocketLeague
Enabled = true; Enabled = true;
MainColor = Color.FromArgb(255, 255, 80, 0); MainColor = Color.FromArgb(255, 255, 80, 0);
SecondaryColor = Color.FromArgb(255, 255, 0, 0); SecondaryColor = Color.FromArgb(255, 255, 0, 0);
ContextualColor = false;
} }
} }
} }

View File

@ -5,6 +5,7 @@
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" xmlns:cal="http://www.caliburnproject.org"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
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">
@ -19,6 +20,7 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
@ -32,7 +34,7 @@
<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"
IsChecked="{Binding Path=RocketLeagueSettings.Enabled, Mode=TwoWay}" IsChecked="{Binding Path=GameSettings.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>
@ -44,7 +46,7 @@
Main boost display color Main boost display color
</TextBlock> </TextBlock>
<xctk:ColorPicker x:Name="MainColor" <xctk:ColorPicker x:Name="MainColor"
SelectedColor="{Binding Path=RocketLeagueSettings.MainColor, Mode=TwoWay}" SelectedColor="{Binding Path=GameSettings.MainColor, Mode=TwoWay}"
Grid.Row="1" Grid.Column="1" Width="110" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" /> VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
@ -54,21 +56,30 @@
Secondary boost display color Secondary boost display color
</TextBlock> </TextBlock>
<xctk:ColorPicker x:Name="SecondaryColor" <xctk:ColorPicker x:Name="SecondaryColor"
SelectedColor="{Binding Path=RocketLeagueSettings.SecondaryColor, Mode=TwoWay}" SelectedColor="{Binding Path=GameSettings.SecondaryColor, Mode=TwoWay}"
Grid.Row="2" Grid.Column="1" Width="110" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" /> VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8" <!-- Secondary color -->
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
Height="16" Margin="0,8">
Color bar according to boost amount
</TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ContextualColor, Mode=TwoWay}"
Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" />
<!-- Info text -->
<TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold" TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
Foreground="#535353" MaxWidth="510" TextAlignment="Justify"> MaxWidth="510" TextAlignment="Justify">
Tip: To find a color combination you like, start an exhibition match, pickup 100 boost and play around with the colors. Tip: To find a color combination you like, start an exhibition match, pickup 100 boost and play around with the colors.
They'll appear on your keyboard immediately! Once you're satisfied don't forget to click save changes. They'll appear on your keyboard immediately! Once you're satisfied don't forget to click save changes.
</TextBlock> </TextBlock>
<TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8" <TextBlock x:Name="VersionText" Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center"
Margin="0,8"
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold" TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
Foreground="#535353" MaxWidth="510" TextAlignment="Justify"> Foreground="{DynamicResource HighlightBrush}" MaxWidth="510" TextAlignment="Justify" />
Note: Requires patch x.x. When a new patch is released Artemis downloads new pointers for the latest version (unless disabled in settings).
</TextBlock>
<!-- Buttons --> <!-- Buttons -->
<StackPanel Grid.Column="0" Grid.Row="9" Orientation="Horizontal" VerticalAlignment="Bottom"> <StackPanel Grid.Column="0" Grid.Row="9" Orientation="Horizontal" VerticalAlignment="Bottom">

View File

@ -1,60 +1,60 @@
using Artemis.Models; using Artemis.Managers;
using Caliburn.Micro; using Artemis.Settings;
using Artemis.Utilities;
using Artemis.Utilities.Memory;
using Artemis.ViewModels.Abstract;
using Newtonsoft.Json;
namespace Artemis.Modules.Games.RocketLeague namespace Artemis.Modules.Games.RocketLeague
{ {
public class RocketLeagueViewModel : Screen public class RocketLeagueViewModel : GameViewModel
{ {
private RocketLeagueSettings _rocketLeagueSettings; private string _versionText;
public RocketLeagueViewModel(MainModel mainModel) public RocketLeagueViewModel(MainManager mainManager)
{ {
MainModel = mainModel; MainManager = mainManager;
// Settings are loaded from file by class // Settings are loaded from file by class
RocketLeagueSettings = new RocketLeagueSettings(); GameSettings = new RocketLeagueSettings();
// Create effect model and add it to MainModel // Create effect model and add it to MainManager
RocketLeagueModel = new RocketLeagueModel(mainModel, RocketLeagueSettings); GameModel = new RocketLeagueModel(mainManager, (RocketLeagueSettings) GameSettings);
MainModel.EffectModels.Add(RocketLeagueModel); MainManager.EffectManager.EffectModels.Add(GameModel);
SetVersionText();
} }
public static string Name => "Rocket League"; public static string Name => "Rocket League";
public MainModel MainModel { get; set; } public string VersionText
public RocketLeagueModel RocketLeagueModel { get; set; }
public RocketLeagueSettings RocketLeagueSettings
{ {
get { return _rocketLeagueSettings; } get { return _versionText; }
set set
{ {
if (Equals(value, _rocketLeagueSettings)) return; if (value == _versionText) return;
_rocketLeagueSettings = value; _versionText = value;
NotifyOfPropertyChange(() => RocketLeagueSettings); NotifyOfPropertyChange(() => VersionText);
} }
} }
public void SaveSettings() public RocketLeagueModel RocketLeagueModel { get; set; }
private void SetVersionText()
{ {
if (RocketLeagueModel == null) if (!General.Default.EnablePointersUpdate)
{
VersionText = "Note: You disabled pointer updates, this could result in the " +
"Rocket League effect not working after a game update.";
return; return;
RocketLeagueSettings.Save();
} }
public void ResetSettings() Updater.GetPointers();
{ var version = JsonConvert
// TODO: Confirmation dialog (Generic MVVM approach) .DeserializeObject<GamePointersCollection>(Offsets.Default.RocketLeague)
RocketLeagueSettings.ToDefault(); .GameVersion;
NotifyOfPropertyChange(() => RocketLeagueSettings); VersionText = $"Note: Requires patch {version}. When a new patch is released Artemis downloads " +
"new pointers for the latest version (unless disabled in settings).";
SaveSettings();
}
public void ToggleEffect()
{
RocketLeagueModel.Enabled = _rocketLeagueSettings.Enabled;
} }
} }
} }

View File

@ -5,6 +5,7 @@ using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Artemis.Managers;
using Artemis.Models; using Artemis.Models;
using Artemis.Utilities.Keyboard; using Artemis.Utilities.Keyboard;
@ -17,13 +18,14 @@ namespace Artemis.Modules.Games.Witcher3
private KeyboardRectangle _signRect; private KeyboardRectangle _signRect;
private string _witcherSettings; private string _witcherSettings;
public Witcher3Model(MainModel mainModel, Witcher3Settings settings) : base(mainModel) public Witcher3Model(MainManager mainManager, Witcher3Settings settings) : base(mainManager)
{ {
Settings = settings; Settings = settings;
Name = "Witcher3"; Name = "Witcher3";
ProcessName = "witcher3"; ProcessName = "witcher3";
Scale = 4; Scale = 4;
Enabled = Settings.Enabled; Enabled = Settings.Enabled;
Initialized = false;
_updateSw = new Stopwatch(); _updateSw = new Stopwatch();
_signRegex = new Regex("ActiveSign=(.*)", RegexOptions.Compiled); _signRegex = new Regex("ActiveSign=(.*)", RegexOptions.Compiled);
@ -35,6 +37,7 @@ namespace Artemis.Modules.Games.Witcher3
public override void Dispose() public override void Dispose()
{ {
Initialized = false;
_witcherSettings = null; _witcherSettings = null;
_updateSw.Reset(); _updateSw.Reset();
@ -42,7 +45,9 @@ namespace Artemis.Modules.Games.Witcher3
public override void Enable() public override void Enable()
{ {
_signRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color>(), Initialized = false;
_signRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
LinearGradientMode.Horizontal) LinearGradientMode.Horizontal)
{ {
Rotate = true, Rotate = true,
@ -56,6 +61,8 @@ namespace Artemis.Modules.Games.Witcher3
_witcherSettings = witcherSettings; _witcherSettings = witcherSettings;
_updateSw.Start(); _updateSw.Start();
Initialized = true;
} }
public override void Update() public override void Update()
@ -102,7 +109,7 @@ namespace Artemis.Modules.Games.Witcher3
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale); var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{ {
g.Clear(Color.Transparent); g.Clear(Color.Transparent);

View File

@ -2,15 +2,13 @@
namespace Artemis.Modules.Games.Witcher3 namespace Artemis.Modules.Games.Witcher3
{ {
public class Witcher3Settings : EffectSettings public class Witcher3Settings : GameSettings
{ {
public Witcher3Settings() public Witcher3Settings()
{ {
Load(); Load();
} }
public bool Enabled { get; set; }
public sealed override void Load() public sealed override void Load()
{ {
Enabled = Witcher3.Default.Enabled; Enabled = Witcher3.Default.Enabled;

View File

@ -29,21 +29,21 @@
<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"
IsChecked="{Binding Path=Witcher3Settings.Enabled, Mode=TwoWay}" IsChecked="{Binding Path=GameSettings.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>
</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"
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold" TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
Foreground="#535353" MaxWidth="510" TextAlignment="Justify"> MaxWidth="510" TextAlignment="Justify">
Artemis requires the latest Witcher 3 version and mod to be installed in order to work. If you don't use any (conflicting) Witcher 3 mods, the mod can automatically be installed. Artemis requires the latest Witcher 3 version and mod to be installed in order to work. If you don't use any (conflicting) Witcher 3 mods, the mod can automatically be installed.
</TextBlock> </TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8" <TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold" TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
Foreground="#535353" MaxWidth="510" TextAlignment="Justify"> Foreground="{DynamicResource HighlightBrush}" MaxWidth="510" TextAlignment="Justify">
If you do use conflicting mods, we'll let you know what to do. Note: If you do use conflicting mods, we'll let you know what to do.
</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" />

View File

@ -3,67 +3,29 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using Artemis.Models; using Artemis.Managers;
using Artemis.Properties; using Artemis.Properties;
using Screen = Caliburn.Micro.Screen; using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.Witcher3 namespace Artemis.Modules.Games.Witcher3
{ {
public class Witcher3ViewModel : Screen public class Witcher3ViewModel : GameViewModel
{ {
private Witcher3Settings _witcher3Settings; public Witcher3ViewModel(MainManager mainManager)
public Witcher3ViewModel(MainModel mainModel)
{ {
MainModel = mainModel; MainManager = mainManager;
// Settings are loaded from file by class // Settings are loaded from file by class
Witcher3Settings = new Witcher3Settings(); GameSettings = new Witcher3Settings();
// Create effect model and add it to MainModel // Create effect model and add it to MainManager
Witcher3Model = new Witcher3Model(mainModel, Witcher3Settings); GameModel = new Witcher3Model(mainManager, (Witcher3Settings) GameSettings);
MainModel.EffectModels.Add(Witcher3Model); MainManager.EffectManager.EffectModels.Add(GameModel);
} }
public static string Name => "The Witcher 3"; public static string Name => "The Witcher 3";
public MainModel MainModel { get; set; } public async void AutoInstall()
public Witcher3Model Witcher3Model { get; set; }
public Witcher3Settings Witcher3Settings
{
get { return _witcher3Settings; }
set
{
if (Equals(value, _witcher3Settings)) return;
_witcher3Settings = value;
NotifyOfPropertyChange(() => Witcher3Settings);
}
}
public void SaveSettings()
{
if (Witcher3Model == null)
return;
Witcher3Settings.Save();
}
public void ResetSettings()
{
// TODO: Confirmation dialog (Generic MVVM approach)
Witcher3Settings.ToDefault();
NotifyOfPropertyChange(() => Witcher3Settings);
SaveSettings();
}
public void ToggleEffect()
{
Witcher3Model.Enabled = _witcher3Settings.Enabled;
}
public void AutoInstall()
{ {
// Request The Witcher 3 folder // Request The Witcher 3 folder
var dialog = new FolderBrowserDialog var dialog = new FolderBrowserDialog
@ -77,14 +39,15 @@ namespace Artemis.Modules.Games.Witcher3
// If the subfolder doesn't contain witcher3.exe, it's the wrong folder. // If the subfolder doesn't contain witcher3.exe, it's the wrong folder.
if (!File.Exists(dialog.SelectedPath + @"\bin\x64\witcher3.exe")) if (!File.Exists(dialog.SelectedPath + @"\bin\x64\witcher3.exe"))
{ {
var error = MessageBox.Show("That's not a valid Witcher 3 directory\n\n" + var retry = await
MainManager.DialogService.ShowQuestionMessageBox("Installation error",
"That's not a valid Witcher 3 directory\n\n" +
"Default directories:\n" + "Default directories:\n" +
"Steam: C:\\Program Files (x86)\\Steam\\steamapps\\common\\The Witcher 3\n" + "Steam: \\SteamApps\\common\\The Witcher 3\n" +
"GOG: C:\\GOG Games\\The Witcher 3 Wild Hunt", "Installation error", "GOG: C:\\GOG Games\\The Witcher 3 Wild Hunt\n\n" +
MessageBoxButtons.RetryCancel); "Retry?");
if (error == DialogResult.Retry) if (retry.Value)
AutoInstall(); AutoInstall();
else
return; return;
} }
@ -99,27 +62,33 @@ namespace Artemis.Modules.Games.Witcher3
// Don't trip over our own mod // Don't trip over our own mod
if (!file.Contains("modArtemis")) if (!file.Contains("modArtemis"))
{ {
MessageBox.Show("Oh no, you have a conflicting mod!\n\n" + var viewHelp = await
MainManager.DialogService.ShowQuestionMessageBox("Conflicting mod found",
"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.", "\n\nWould you like to view instructions on how to manually install the mod?");
"Conflicting mod found"); if (!viewHelp.Value)
return;
// Put the mod in the documents folder instead // Put the mod in the documents folder instead
// Create the directory structure // Create the directory structure
var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Artemis"; var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Artemis";
if ( if (
!Directory.Exists(folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player")) !Directory.Exists(folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player"))
Directory.CreateDirectory(folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player"); Directory.CreateDirectory(folder +
@"\Witcher3\mods\modArtemis\content\scripts\game\player");
if ( if (
!Directory.Exists(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc")) !Directory.Exists(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc"))
Directory.CreateDirectory(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc"); Directory.CreateDirectory(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc");
// Install the mod files // Install the mod files
File.WriteAllText(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc\artemis.xml",Resources.artemisXml); File.WriteAllText(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc\artemis.xml",
File.WriteAllText(folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",Resources.playerWitcherWs); Resources.artemisXml);
File.WriteAllText(
folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
Resources.playerWitcherWs);
Process.Start(new ProcessStartInfo("https://github.com/SpoinkyNL/Artemis/wiki/The-Witcher-3")); Process.Start(new ProcessStartInfo("https://github.com/SpoinkyNL/Artemis/wiki/The-Witcher-3"));
return; return;
} }
} }
@ -137,7 +106,7 @@ namespace Artemis.Modules.Games.Witcher3
File.WriteAllText(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player\playerWitcher.ws", File.WriteAllText(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
Resources.playerWitcherWs); Resources.playerWitcherWs);
MessageBox.Show("The mod was successfully installed!", "Success"); MainManager.DialogService.ShowMessageBox("Success", "The mod was successfully installed!");
} }
} }
} }

View File

@ -8,7 +8,7 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace Artemis.Settings { namespace Artemis.Modules.Overlays.VolumeDisplay {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
@ -23,6 +23,18 @@ namespace Artemis.Settings {
} }
} }
[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.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("#FFFF2900")] [global::System.Configuration.DefaultSettingValueAttribute("#FFFF2900")]
@ -46,17 +58,5 @@ namespace Artemis.Settings {
this["SecondaryColor"] = value; this["SecondaryColor"] = value;
} }
} }
[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;
}
}
} }
} }

View File

@ -1,23 +1,23 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using Artemis.Models; using Artemis.Managers;
using Artemis.Utilities; using Artemis.Utilities;
using Artemis.Utilities.Keyboard; using Artemis.Utilities.Keyboard;
namespace Artemis.Modules.Overlays.VolumeDisplay namespace Artemis.Modules.Overlays.VolumeDisplay
{ {
public class VolumeDisplay public class VolumeBar
{ {
public VolumeDisplay(MainModel mainModel, VolumeDisplaySettings settings) public VolumeBar(MainManager mainManager, VolumeDisplaySettings settings)
{ {
MainModel = mainModel; MainManager = mainManager;
Settings = settings; Settings = settings;
Transparancy = 255; Transparancy = 255;
Scale = 4; Scale = 4;
} }
public MainModel MainModel { get; set; } public MainManager MainManager { get; set; }
public VolumeDisplaySettings Settings { get; set; } public VolumeDisplaySettings Settings { get; set; }
@ -30,14 +30,14 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
public void Draw(Graphics g) public void Draw(Graphics g)
{ {
var volumeRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color> var volumeRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>
{ {
ColorHelpers.ToDrawingColor(Settings.SecondaryColor), ColorHelpers.ToDrawingColor(Settings.SecondaryColor),
ColorHelpers.ToDrawingColor(Settings.MainColor) ColorHelpers.ToDrawingColor(Settings.MainColor)
}, },
LinearGradientMode.Horizontal) LinearGradientMode.Horizontal)
{ {
Width = (int) (MainModel.ActiveKeyboard.Width*Scale/100.00*Volume), Width = (int) (MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*Volume),
ContainedBrush = false ContainedBrush = false
}; };
volumeRect.Draw(g); volumeRect.Draw(g);

View File

@ -1,17 +1,17 @@
<?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)" <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="VolumeDisplay"> GeneratedClassNamespace="Artemis.Modules.Overlays.VolumeDisplay" GeneratedClassName="VolumeDisplay">
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="Enabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="MainColor" Type="System.Windows.Media.Color" Scope="User"> <Setting Name="MainColor" Type="System.Windows.Media.Color" Scope="User">
<Value Profile="(Default)">#FFFF2900</Value> <Value Profile="(Default)">#FFFF2900</Value>
</Setting> </Setting>
<Setting Name="SecondaryColor" Type="System.Windows.Media.Color" Scope="User"> <Setting Name="SecondaryColor" Type="System.Windows.Media.Color" Scope="User">
<Value Profile="(Default)">#FF26F600</Value> <Value Profile="(Default)">#FF26F600</Value>
</Setting> </Setting>
<Setting Name="Enabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -1,7 +1,7 @@
using System.Drawing; using System.Drawing;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Artemis.Managers;
using Artemis.Models; using Artemis.Models;
using NAudio.CoreAudioApi; using NAudio.CoreAudioApi;
@ -9,28 +9,28 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
{ {
public class VolumeDisplayModel : OverlayModel public class VolumeDisplayModel : OverlayModel
{ {
public VolumeDisplayModel(MainModel mainModel, VolumeDisplaySettings settings) : base(mainModel) public VolumeDisplayModel(MainManager mainManager, VolumeDisplaySettings settings) : base(mainManager)
{ {
Settings = settings; Settings = settings;
Name = "VolumeDisplay"; Name = "VolumeDisplay";
Enabled = Settings.Enabled; Enabled = Settings.Enabled;
VolumeDisplay = new VolumeDisplay(mainModel, settings); VolumeDisplay = new VolumeBar(mainManager, settings);
} }
public VolumeDisplay VolumeDisplay { get; set; } public VolumeBar VolumeDisplay { get; set; }
public VolumeDisplaySettings Settings { get; set; } public VolumeDisplaySettings Settings { get; set; }
public override void Dispose() public override void Dispose()
{ {
MainModel.KeyboardHook.Unsubscribe(HandleKeypress); MainManager.KeyboardHook.KeyDownCallback -= KeyPressTask;
} }
public override void Enable() public override void Enable()
{ {
// Listener won't start unless the effect is active // Listener won't start unless the effect is active
MainModel.KeyboardHook.Subscribe(HandleKeypress); MainManager.KeyboardHook.KeyDownCallback += KeyPressTask;
} }
public override void Update() public override void Update()
@ -63,7 +63,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
return GenerateBitmap(MainModel.ActiveKeyboard.KeyboardBitmap(4)); return GenerateBitmap(MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(4));
} }
public override Bitmap GenerateBitmap(Bitmap bitmap) public override Bitmap GenerateBitmap(Bitmap bitmap)
@ -79,11 +79,6 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
return bitmap; return bitmap;
} }
private void HandleKeypress(object sender, KeyEventArgs e)
{
Task.Factory.StartNew(() => KeyPressTask(e));
}
private void KeyPressTask(KeyEventArgs e) private void KeyPressTask(KeyEventArgs e)
{ {
if (e.KeyCode != Keys.VolumeUp && e.KeyCode != Keys.VolumeDown) if (e.KeyCode != Keys.VolumeUp && e.KeyCode != Keys.VolumeDown)

View File

@ -16,18 +16,18 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
public sealed override void Load() public sealed override void Load()
{ {
Enabled = Settings.VolumeDisplay.Default.Enabled; Enabled = VolumeDisplay.Default.Enabled;
MainColor = Settings.VolumeDisplay.Default.MainColor; MainColor = VolumeDisplay.Default.MainColor;
SecondaryColor = Settings.VolumeDisplay.Default.SecondaryColor; SecondaryColor = VolumeDisplay.Default.SecondaryColor;
} }
public sealed override void Save() public sealed override void Save()
{ {
Settings.VolumeDisplay.Default.Enabled = Enabled; VolumeDisplay.Default.Enabled = Enabled;
Settings.VolumeDisplay.Default.MainColor = MainColor; VolumeDisplay.Default.MainColor = MainColor;
Settings.VolumeDisplay.Default.SecondaryColor = SecondaryColor; VolumeDisplay.Default.SecondaryColor = SecondaryColor;
Settings.VolumeDisplay.Default.Save(); VolumeDisplay.Default.Save();
} }
public sealed override void ToDefault() public sealed override void ToDefault()

View File

@ -55,17 +55,23 @@
<xctk:ColorPicker x:Name="SecondaryColor" <xctk:ColorPicker x:Name="SecondaryColor"
SelectedColor="{Binding Path=VolumeDisplaySettings.SecondaryColor, Mode=TwoWay}" SelectedColor="{Binding Path=VolumeDisplaySettings.SecondaryColor, Mode=TwoWay}"
Grid.Row="2" Grid.Column="1" Width="110" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="1" Width="110" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" /> VerticalAlignment="Center" Margin="0,5,-1,5" Height="22">
<xctk:ColorPicker.Template>
<ControlTemplate>
<Rectangle />
</ControlTemplate>
</xctk:ColorPicker.Template>
</xctk:ColorPicker>
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8" <TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold" TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
Foreground="#535353" MaxWidth="520" TextAlignment="Justify"> MaxWidth="520" TextAlignment="Justify">
Note: This is an overlay. It will go over any other active effect, and is only shown at certain moments (in this case when changing volume). Please also note that it won't work if there aren't any active effects. Note: This is an overlay. It will go over any other active effect, and is only shown at certain moments (in this case when changing volume). Please also note that it won't work if there aren't any active effects.
</TextBlock> </TextBlock>
<TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8" <TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold" TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
Foreground="#B50000" MaxWidth="520" TextAlignment="Justify"> Foreground="{DynamicResource HighlightBrush}" MaxWidth="520" TextAlignment="Justify">
Please also note that it won't work if there aren't any active effects. Please also note that it won't work if there aren't any active effects.
</TextBlock> </TextBlock>

View File

@ -1,4 +1,4 @@
using Artemis.Models; using Artemis.Managers;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.Modules.Overlays.VolumeDisplay namespace Artemis.Modules.Overlays.VolumeDisplay
@ -7,21 +7,21 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
{ {
private VolumeDisplaySettings _volumeDisplaySettings; private VolumeDisplaySettings _volumeDisplaySettings;
public VolumeDisplayViewModel(MainModel mainModel) public VolumeDisplayViewModel(MainManager mainManager)
{ {
MainModel = mainModel; MainManager = mainManager;
// Settings are loaded from file by class // Settings are loaded from file by class
VolumeDisplaySettings = new VolumeDisplaySettings(); VolumeDisplaySettings = new VolumeDisplaySettings();
// Create effect model and add it to MainModel // Create effect model and add it to MainManager
VolumeDisplayModel = new VolumeDisplayModel(mainModel, VolumeDisplaySettings); VolumeDisplayModel = new VolumeDisplayModel(mainManager, VolumeDisplaySettings);
MainModel.EffectModels.Add(VolumeDisplayModel); MainManager.EffectManager.EffectModels.Add(VolumeDisplayModel);
} }
public static string Name => "Volume Display"; public static string Name => "Volume Display";
public MainModel MainModel { get; set; } public MainManager MainManager { get; set; }
public VolumeDisplayModel VolumeDisplayModel { get; set; } public VolumeDisplayModel VolumeDisplayModel { get; set; }
public VolumeDisplaySettings VolumeDisplaySettings public VolumeDisplaySettings VolumeDisplaySettings

View File

@ -113,6 +113,26 @@ namespace Artemis.Properties {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon logo {
get {
object obj = ResourceManager.GetObject("logo", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon logo_disabled {
get {
object obj = ResourceManager.GetObject("logo_disabled", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to /***********************************************************************/ /// Looks up a localized string similar to /***********************************************************************/
////** © 2015 CD PROJEKT S.A. All rights reserved. ////** © 2015 CD PROJEKT S.A. All rights reserved.

View File

@ -127,6 +127,12 @@
<data name="gamestateConfiguration" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="gamestateConfiguration" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\counterstrike\gamestateconfiguration.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value> <value>..\resources\counterstrike\gamestateconfiguration.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data> </data>
<data name="logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logo.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="logo_disabled" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logo-disabled.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="playerWitcherWs" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="playerWitcherWs" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\witcher3\playerwitcher.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value> <value>..\resources\witcher3\playerwitcher.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
</data> </data>

View File

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

View 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);
}
}

View 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;
}
}
}

View File

@ -37,7 +37,7 @@ namespace Artemis.Settings {
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Logitech G910 RGB")] [global::System.Configuration.DefaultSettingValueAttribute("")]
public string LastKeyboard { public string LastKeyboard {
get { get {
return ((string)(this["LastKeyboard"])); return ((string)(this["LastKeyboard"]));
@ -73,7 +73,7 @@ namespace Artemis.Settings {
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")] [global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool Autorun { public bool Autorun {
get { get {
return ((bool)(this["Autorun"])); return ((bool)(this["Autorun"]));
@ -94,5 +94,29 @@ namespace Artemis.Settings {
this["Suspended"] = value; this["Suspended"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool ShowOnStartup {
get {
return ((bool)(this["ShowOnStartup"]));
}
set {
this["ShowOnStartup"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool CheckForUpdates {
get {
return ((bool)(this["CheckForUpdates"]));
}
set {
this["CheckForUpdates"] = value;
}
}
} }
} }

View File

@ -1,14 +1,12 @@
<?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.Settings" GeneratedClassName="General">
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="General">
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="LastEffect" Type="System.String" Scope="User"> <Setting Name="LastEffect" Type="System.String" Scope="User">
<Value Profile="(Default)">TypeWave</Value> <Value Profile="(Default)">TypeWave</Value>
</Setting> </Setting>
<Setting Name="LastKeyboard" Type="System.String" Scope="User"> <Setting Name="LastKeyboard" Type="System.String" Scope="User">
<Value Profile="(Default)">Logitech G910 RGB</Value> <Value Profile="(Default)" />
</Setting> </Setting>
<Setting Name="EnablePointersUpdate" Type="System.Boolean" Scope="User"> <Setting Name="EnablePointersUpdate" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
@ -17,10 +15,16 @@
<Value Profile="(Default)">51364</Value> <Value Profile="(Default)">51364</Value>
</Setting> </Setting>
<Setting Name="Autorun" Type="System.Boolean" Scope="User"> <Setting Name="Autorun" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="Suspended" Type="System.Boolean" Scope="User"> <Setting Name="Suspended" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="ShowOnStartup" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="CheckForUpdates" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -38,6 +38,26 @@ namespace Artemis.Settings
} }
} }
public bool CheckForUpdates
{
get { return General.Default.CheckForUpdates; }
set
{
if (General.Default.CheckForUpdates == value) return;
General.Default.CheckForUpdates = value;
}
}
public bool ShowOnStartup
{
get { return General.Default.ShowOnStartup; }
set
{
if (General.Default.ShowOnStartup == value) return;
General.Default.ShowOnStartup = value;
}
}
private void ApplyGamestatePort() private void ApplyGamestatePort()
{ {
// TODO: Restart Gamestate server with new port // TODO: Restart Gamestate server with new port
@ -71,6 +91,8 @@ namespace Artemis.Settings
GamestatePort = 51364; GamestatePort = 51364;
EnablePointersUpdate = true; EnablePointersUpdate = true;
Autorun = true; Autorun = true;
CheckForUpdates = true;
ShowOnStartup = true;
SaveSettings(); SaveSettings();
} }

View File

@ -1,7 +1,9 @@
using System.IO; using System;
using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Windows.Forms;
using Artemis.Settings; using Artemis.Settings;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -29,11 +31,18 @@ namespace Artemis.Utilities.GameState
if (Running) if (Running)
return; return;
try
{
_listener.Prefixes.Clear(); _listener.Prefixes.Clear();
Port = General.Default.GamestatePort; Port = General.Default.GamestatePort;
_listener.Prefixes.Add($"http://localhost:{Port}/"); _listener.Prefixes.Add($"http://localhost:{Port}/");
_listener.Start(); _listener.Start();
}
catch (Exception)
{
MessageBox.Show("Couldn't start the webserver. CS:GO effect won't work :c \n\nTry changing the port in Settings and restart Artemis.");
}
ThreadPool.QueueUserWorkItem(o => ThreadPool.QueueUserWorkItem(o =>
{ {
@ -74,6 +83,11 @@ namespace Artemis.Utilities.GameState
Running = true; Running = true;
} }
public void Stop()
{
_listener.Stop();
}
private string HandleRequest(HttpListenerRequest request) private string HandleRequest(HttpListenerRequest request)
{ {
object json; object json;

View File

@ -1,31 +1,24 @@
using System.Windows.Forms; using System.Threading.Tasks;
using Gma.System.MouseKeyHook; using System.Windows.Forms;
using VirtualInput;
namespace Artemis.Utilities.Keyboard namespace Artemis.Utilities.Keyboard
{ {
public class KeyboardHook public class KeyboardHook
{ {
private IKeyboardMouseEvents _mGlobalHook; public delegate void KeyDownCallbackHandler(KeyEventArgs e);
public int Subscriptions { get; set; }
public void Subscribe(KeyEventHandler handleKeypress) public KeyboardHook()
{ {
if (Subscriptions < 1) VirtualKeyboard.KeyDown += VirtualKeyboardOnKeyDown;
_mGlobalHook = Hook.GlobalEvents(); VirtualKeyboard.StartInterceptor();
_mGlobalHook.KeyDown += handleKeypress;
Subscriptions++;
} }
public void Unsubscribe(KeyEventHandler handleKeypress) private void VirtualKeyboardOnKeyDown(object sender, KeyEventArgs keyEventArgs)
{ {
_mGlobalHook.KeyDown -= handleKeypress; Task.Factory.StartNew(() => { KeyDownCallback?.Invoke(keyEventArgs); });
Subscriptions--;
if (Subscriptions >= 1)
return;
_mGlobalHook.Dispose();
_mGlobalHook = null;
} }
public event KeyDownCallbackHandler KeyDownCallback;
} }
} }

View File

@ -2,15 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace Artemis.Models namespace Artemis.Utilities.Memory
{ {
public class GamePointersCollectionModel
{
public string Game { get; set; }
public string GameVersion { get; set; }
public List<GamePointer> GameAddresses { get; set; }
}
public class GamePointer public class GamePointer
{ {
public string Description { get; set; } public string Description { get; set; }
@ -23,4 +16,11 @@ namespace Artemis.Models
(current, offset) => current + $"+{offset.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; }
}
} }

View File

@ -1,12 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Artemis.Models;
using Artemis.Settings;
using Newtonsoft.Json;
namespace Artemis.Utilities.Memory namespace Artemis.Utilities.Memory
{ {
@ -18,8 +12,8 @@ namespace Artemis.Utilities.Memory
public static Process GetProcessIfRunning(string processName) public static Process GetProcessIfRunning(string processName)
{ {
var rlProcess = Process.GetProcessesByName(processName); var processes = Process.GetProcessesByName(processName);
return rlProcess.Length >= 1 ? rlProcess[0] : null; return processes.Length >= 1 ? processes[0] : null;
} }
public static IntPtr FindAddress(IntPtr pHandle, IntPtr baseAddress, IntPtr staticPointer, int[] offsets) public static IntPtr FindAddress(IntPtr pHandle, IntPtr baseAddress, IntPtr staticPointer, int[] offsets)
@ -43,35 +37,5 @@ namespace Artemis.Utilities.Memory
} }
return address; return address;
} }
public static void GetPointers()
{
if (!General.Default.EnablePointersUpdate)
return;
try
{
var jsonClient = new WebClient();
// Random number to get around cache issues
var rand = new Random(DateTime.Now.Millisecond);
var json =
jsonClient.DownloadString(
"https://raw.githubusercontent.com/SpoinkyNL/Artemis/master/pointers.json?random=" + rand.Next());
// Get a list of pointers
var pointers = JsonConvert.DeserializeObject<List<GamePointersCollectionModel>>(json);
// Assign each pointer to the settings file
var rlPointers = JsonConvert.SerializeObject(pointers.FirstOrDefault(p => p.Game == "RocketLeague"));
if (rlPointers != null)
{
Offsets.Default.RocketLeague = rlPointers;
Offsets.Default.Save();
}
}
catch (Exception)
{
// ignored
}
}
} }
} }

View File

@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Artemis.Services;
using Artemis.Settings;
using Artemis.Utilities.Memory;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Artemis.Utilities
{
public static class Updater
{
public static int CurrentVersion = 102;
public static async Task<Action> CheckForUpdate(MetroDialogService dialogService)
{
if (!General.Default.CheckForUpdates)
return null;
var newRelease = IsUpdateAvailable();
if (newRelease == null)
return null;
var viewUpdate = await
dialogService.ShowQuestionMessageBox("Update available",
$"A new version of Artemis is available, version {newRelease["tag_name"].Value<string>()}.\n" +
"Do you wish to view the update on GitHub now?\n\n" +
"Note: You can disable update notifications in the settings menu");
if (viewUpdate.Value)
Process.Start(new ProcessStartInfo(newRelease["html_url"].Value<string>()));
return null;
}
public static JObject IsUpdateAvailable()
{
if (!General.Default.EnablePointersUpdate)
return null;
try
{
var jsonClient = new WebClient();
// GitHub trips if we don't add a user agent
jsonClient.Headers.Add("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
// Random number to get around cache issues
var rand = new Random(DateTime.Now.Millisecond);
var json =
jsonClient.DownloadString("https://api.github.com/repos/SpoinkyNL/Artemis/releases/latest?random=" +
rand.Next());
// Get a list of pointers
var release = JsonConvert.DeserializeObject<JObject>(json);
// Parse a version number string to an int
var remoteVersion = int.Parse(release["tag_name"].Value<string>().Replace(".", ""));
return remoteVersion > CurrentVersion ? release : null;
}
catch (Exception)
{
return null;
}
}
public static void GetPointers()
{
if (!General.Default.EnablePointersUpdate)
return;
try
{
var jsonClient = new WebClient();
// Random number to get around cache issues
var rand = new Random(DateTime.Now.Millisecond);
var json =
jsonClient.DownloadString(
"https://raw.githubusercontent.com/SpoinkyNL/Artemis/master/pointers.json?random=" + rand.Next());
// Get a list of pointers
var pointers = JsonConvert.DeserializeObject<List<GamePointersCollection>>(json);
// Assign each pointer to the settings file
var rlPointers = JsonConvert.SerializeObject(pointers.FirstOrDefault(p => p.Game == "RocketLeague"));
if (rlPointers != null)
{
Offsets.Default.RocketLeague = rlPointers;
Offsets.Default.Save();
}
}
catch (Exception)
{
// ignored
}
}
}
}

View File

@ -0,0 +1,79 @@
using Artemis.Managers;
using Artemis.Models;
using Caliburn.Micro;
namespace Artemis.ViewModels.Abstract
{
public abstract class EffectViewModel : Screen
{
private EffectSettings _effectSettings;
private bool _showDisabledPopup;
public EffectModel EffectModel { get; set; }
public MainManager MainManager { get; set; }
public EffectSettings EffectSettings
{
get { return _effectSettings; }
set
{
if (Equals(value, _effectSettings)) return;
_effectSettings = value;
NotifyOfPropertyChange(() => EffectSettings);
}
}
public bool EffectEnabled => MainManager.EffectManager.ActiveEffect == EffectModel;
public bool ShowDisabledPopup
{
get { return _showDisabledPopup; }
set
{
if (value == _showDisabledPopup) return;
_showDisabledPopup = value;
NotifyOfPropertyChange(() => ShowDisabledPopup);
}
}
public void ToggleEffect()
{
if (!MainManager.ProgramEnabled)
{
NotifyOfPropertyChange(() => EffectEnabled);
ShowDisabledPopup = true;
return;
}
if (EffectEnabled)
MainManager.EffectManager.ClearEffect();
else
MainManager.EffectManager.ChangeEffect(EffectModel);
}
public void SaveSettings()
{
EffectSettings?.Save();
if (!EffectEnabled)
return;
// Restart the effect if it's currently running to apply settings.
MainManager.EffectManager.ChangeEffect(EffectModel, 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;
EffectSettings.ToDefault();
NotifyOfPropertyChange(() => EffectSettings);
SaveSettings();
}
}
}

View 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();
}
}
}

View File

@ -1,4 +1,4 @@
using Artemis.Models; using Artemis.Managers;
using Artemis.Modules.Effects.AudioVisualizer; using Artemis.Modules.Effects.AudioVisualizer;
using Artemis.Modules.Effects.Debug; using Artemis.Modules.Effects.Debug;
using Artemis.Modules.Effects.TypeHole; using Artemis.Modules.Effects.TypeHole;
@ -14,12 +14,12 @@ namespace Artemis.ViewModels
private readonly TypeHoleViewModel _typeHoleVm; private readonly TypeHoleViewModel _typeHoleVm;
private readonly TypeWaveViewModel _typeWaveVm; private readonly TypeWaveViewModel _typeWaveVm;
public EffectsViewModel(MainModel mainModel) public EffectsViewModel(MainManager mainManager)
{ {
_typeWaveVm = new TypeWaveViewModel(mainModel) {DisplayName = "Type Waves"}; _typeWaveVm = new TypeWaveViewModel(mainManager) {DisplayName = "Type Waves"};
//_typeHoleVm = new TypeHoleViewModel(mainModel) {DisplayName = "Type Holes (NYI)"}; //_typeHoleVm = new TypeHoleViewModel(MainManager) {DisplayName = "Type Holes (NYI)"};
_audioVisualizerVm = new AudioVisualizerViewModel(mainModel) {DisplayName = "Audio Visualization"}; _audioVisualizerVm = new AudioVisualizerViewModel(mainManager) {DisplayName = "Audio Visualization"};
_debugVm = new DebugEffectViewModel(mainModel) {DisplayName = "Debug Effect"}; _debugVm = new DebugEffectViewModel(mainManager) {DisplayName = "Debug Effect"};
} }
protected override void OnActivate() protected override void OnActivate()

View File

@ -1,27 +1,28 @@
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using Artemis.Events; using Artemis.Events;
using Artemis.Models; using Artemis.Managers;
using Artemis.Settings; using Artemis.Settings;
using Caliburn.Micro; using Caliburn.Micro;
using MahApps.Metro.Controls; using MahApps.Metro.Controls;
namespace Artemis.ViewModels.Flyouts namespace Artemis.ViewModels.Flyouts
{ {
public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled> public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled>, IHandle<ActiveEffectChanged>
{ {
private string _activeEffectName;
private bool _enabled; private bool _enabled;
private GeneralSettings _generalSettings; private GeneralSettings _generalSettings;
private string _selectedKeyboardProvider; private string _selectedKeyboardProvider;
public FlyoutSettingsViewModel(MainModel mainModel) public FlyoutSettingsViewModel(MainManager mainManager)
{ {
MainModel = mainModel; MainManager = mainManager;
Header = "settings"; Header = "Settings";
Position = Position.Right; Position = Position.Right;
GeneralSettings = new GeneralSettings(); GeneralSettings = new GeneralSettings();
MainModel.Events.Subscribe(this); MainManager.Events.Subscribe(this);
} }
public GeneralSettings GeneralSettings public GeneralSettings GeneralSettings
@ -35,10 +36,18 @@ namespace Artemis.ViewModels.Flyouts
} }
} }
public MainModel MainModel { get; set; } public MainManager MainManager { get; set; }
public BindableCollection<string> KeyboardProviders public BindableCollection<string> KeyboardProviders
=> new BindableCollection<string>(MainModel.KeyboardProviders.Select(k => k.Name)); {
get
{
var collection = new BindableCollection<string>(MainManager.KeyboardManager.KeyboardProviders
.Select(k => k.Name));
collection.Insert(0, "None");
return collection;
}
}
public string SelectedKeyboardProvider public string SelectedKeyboardProvider
{ {
@ -51,33 +60,52 @@ namespace Artemis.ViewModels.Flyouts
if (value == null) if (value == null)
return; return;
MainModel.ChangeKeyboard(MainModel.KeyboardProviders.First(k => k.Name == _selectedKeyboardProvider)); MainManager.KeyboardManager.ChangeKeyboard(
MainManager.KeyboardManager.KeyboardProviders.FirstOrDefault(
k => k.Name == _selectedKeyboardProvider));
} }
} }
public bool Enabled public bool Enabled
{ {
get { return _enabled; } get { return MainManager.ProgramEnabled; }
set set
{ {
if (value == _enabled) return; if (value)
_enabled = value; MainManager.EnableProgram();
else
NotifyOfPropertyChange(() => Enabled); MainManager.DisableProgram();
} }
} }
public string ActiveEffectName
{
get { return _activeEffectName; }
set
{
if (value == _activeEffectName) return;
_activeEffectName = value;
NotifyOfPropertyChange(() => ActiveEffectName);
}
}
public void Handle(ActiveEffectChanged message)
{
var effectDisplay = message.ActiveEffect.Length > 0 ? message.ActiveEffect : "none";
ActiveEffectName = $"Active effect: {effectDisplay}";
}
public void Handle(ToggleEnabled message) public void Handle(ToggleEnabled message)
{ {
Enabled = message.Enabled; NotifyOfPropertyChange(() => Enabled);
} }
public void ToggleEnabled() public void ToggleEnabled()
{ {
if (Enabled) if (Enabled)
MainModel.ShutdownEffects(); MainManager.DisableProgram();
else else
MainModel.StartEffects(); MainManager.EnableProgram();
} }
public void ResetSettings() public void ResetSettings()
@ -98,7 +126,9 @@ namespace Artemis.ViewModels.Flyouts
protected override void HandleOpen() protected override void HandleOpen()
{ {
SelectedKeyboardProvider = MainModel.ActiveKeyboard?.Name; SelectedKeyboardProvider = General.Default.LastKeyboard.Length > 0
? General.Default.LastKeyboard
: "None";
} }
} }
} }

View File

@ -1,4 +1,4 @@
using Artemis.Models; using Artemis.Managers;
using Artemis.Modules.Games.CounterStrike; using Artemis.Modules.Games.CounterStrike;
using Artemis.Modules.Games.Dota2; using Artemis.Modules.Games.Dota2;
using Artemis.Modules.Games.RocketLeague; using Artemis.Modules.Games.RocketLeague;
@ -14,12 +14,12 @@ namespace Artemis.ViewModels
private readonly RocketLeagueViewModel _rocketLeagueVm; private readonly RocketLeagueViewModel _rocketLeagueVm;
private readonly Witcher3ViewModel _witcher3Vm; private readonly Witcher3ViewModel _witcher3Vm;
public GamesViewModel(MainModel mainModel) public GamesViewModel(MainManager mainManager)
{ {
_rocketLeagueVm = new RocketLeagueViewModel(mainModel) {DisplayName = "Rocket League"}; _rocketLeagueVm = new RocketLeagueViewModel(mainManager) {DisplayName = "Rocket League"};
_counterStrikeVm = new CounterStrikeViewModel(mainModel) {DisplayName = "CS:GO"}; _counterStrikeVm = new CounterStrikeViewModel(mainManager) {DisplayName = "CS:GO"};
//_dota2Vm = new Dota2ViewModel(mainModel) {DisplayName = "Dota 2 (NYI)"}; //_dota2Vm = new Dota2ViewModel(MainManager) {DisplayName = "Dota 2 (NYI)"};
_witcher3Vm = new Witcher3ViewModel(mainModel) {DisplayName = "The Witcher 3"}; _witcher3Vm = new Witcher3ViewModel(mainManager) {DisplayName = "The Witcher 3"};
} }
protected override void OnActivate() protected override void OnActivate()

View File

@ -1,4 +1,4 @@
using Artemis.Models; using Artemis.Managers;
using Artemis.Modules.Overlays.VolumeDisplay; using Artemis.Modules.Overlays.VolumeDisplay;
using Caliburn.Micro; using Caliburn.Micro;
@ -6,12 +6,12 @@ namespace Artemis.ViewModels
{ {
public class OverlaysViewModel : Conductor<IScreen>.Collection.OneActive public class OverlaysViewModel : Conductor<IScreen>.Collection.OneActive
{ {
private readonly MainModel _mainModel; private readonly MainManager _mainManager;
private VolumeDisplayViewModel _volumeDisplayVm; private VolumeDisplayViewModel _volumeDisplayVm;
public OverlaysViewModel(MainModel mainModel) public OverlaysViewModel(MainManager mainManager)
{ {
_mainModel = mainModel; _mainManager = mainManager;
} }
protected override void OnActivate() protected override void OnActivate()
@ -21,7 +21,7 @@ namespace Artemis.ViewModels
Items.Clear(); Items.Clear();
// This VM appears to be going out of scope, so recreating it every time just to be sure. // This VM appears to be going out of scope, so recreating it every time just to be sure.
_volumeDisplayVm = new VolumeDisplayViewModel(_mainModel) { DisplayName = "Volume Display" }; _volumeDisplayVm = new VolumeDisplayViewModel(_mainManager) {DisplayName = "Volume Display"};
ActivateItem(_volumeDisplayVm); ActivateItem(_volumeDisplayVm);
ActiveItem = _volumeDisplayVm; ActiveItem = _volumeDisplayVm;
} }

View File

@ -1,7 +1,6 @@
using System; using System.Linq;
using System.Linq; using Artemis.Managers;
using System.Windows; using Artemis.Services;
using Artemis.Models;
using Artemis.ViewModels.Flyouts; using Artemis.ViewModels.Flyouts;
using Caliburn.Micro; using Caliburn.Micro;
@ -16,22 +15,24 @@ namespace Artemis.ViewModels
public ShellViewModel() public ShellViewModel()
{ {
var dialogService = new MetroDialogService(this);
IEventAggregator events = new EventAggregator(); IEventAggregator events = new EventAggregator();
MainModel = new MainModel(events);
MainManager = new MainManager(events, dialogService);
DisplayName = "Artemis"; DisplayName = "Artemis";
_welcomeVm = new WelcomeViewModel {DisplayName = "Welcome"}; _welcomeVm = new WelcomeViewModel {DisplayName = "Welcome"};
_effectsVm = new EffectsViewModel(MainModel) {DisplayName = "Effects"}; _effectsVm = new EffectsViewModel(MainManager) {DisplayName = "Effects"};
_gamesVm = new GamesViewModel(MainModel) {DisplayName = "Games"}; _gamesVm = new GamesViewModel(MainManager) {DisplayName = "Games"};
_overlaysVm = new OverlaysViewModel(MainModel) {DisplayName = "Overlays"}; _overlaysVm = new OverlaysViewModel(MainManager) {DisplayName = "Overlays"};
Flyouts.Add(new FlyoutSettingsViewModel(MainModel)); Flyouts.Add(new FlyoutSettingsViewModel(MainManager));
} }
public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; } = public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; } =
new BindableCollection<FlyoutBaseViewModel>(); new BindableCollection<FlyoutBaseViewModel>();
public MainModel MainModel { get; set; } public MainManager MainManager { get; set; }
protected override void OnActivate() protected override void OnActivate()
{ {
@ -45,15 +46,14 @@ namespace Artemis.ViewModels
ActiveItem = _welcomeVm; ActiveItem = _welcomeVm;
} }
public void OnClose(EventArgs e)
{
MainModel.ShutdownEffects();
Application.Current.Shutdown();
}
public void Settings() public void Settings()
{ {
Flyouts.First().IsOpen = !Flyouts.First().IsOpen; Flyouts.First().IsOpen = !Flyouts.First().IsOpen;
} }
public void CloseSettings()
{
Flyouts.First().IsOpen = false;
}
} }
} }

View File

@ -1,5 +1,9 @@
using System.Windows; using System;
using System.Windows;
using Artemis.Events; using Artemis.Events;
using Artemis.Properties;
using Artemis.Settings;
using Artemis.Utilities;
using Caliburn.Micro; using Caliburn.Micro;
namespace Artemis.ViewModels namespace Artemis.ViewModels
@ -9,31 +13,22 @@ namespace Artemis.ViewModels
private readonly ShellViewModel _shellViewModel; private readonly ShellViewModel _shellViewModel;
private readonly IWindowManager _windowManager; private readonly IWindowManager _windowManager;
private string _activeIcon;
private bool _checkedForUpdate;
private bool _enabled; private bool _enabled;
private string _toggleText; private string _toggleText;
/*
* NOTE: In this sample the system tray view-model doesn't receive any notification
* when the other window gets closed by pressing the top right 'x'.
* Thus no property notification is invoked, and system tray context-menu appears
* out of sync, still allowing 'Hide' and disabling 'Show'.
* Given the purpose of the sample - integrating Caliburn.Micro with WPF NotifyIcon -
* sync'ing the two view-models is not of interest here.
* */
public SystemTrayViewModel(IWindowManager windowManager, ShellViewModel shellViewModel) public SystemTrayViewModel(IWindowManager windowManager, ShellViewModel shellViewModel)
{ {
_windowManager = windowManager; _windowManager = windowManager;
_shellViewModel = shellViewModel; _shellViewModel = shellViewModel;
_shellViewModel.MainModel.Events.Subscribe(this); _shellViewModel.MainManager.Events.Subscribe(this);
_shellViewModel.MainManager.EnableProgram();
_checkedForUpdate = false;
//ActiveIcon = "../logo.ico";
/* if (General.Default.ShowOnStartup)
* By now Effects are added to the MainModel so we can savely start ShowWindow();
* This is done from here to make sure all UI elements listening to
* events will receive the first ToggleEnabled event
* */
_shellViewModel.MainModel.StartEffects();
// TODO: Check if show on startup is enabled, if so, show window.
} }
public bool CanShowWindow => !_shellViewModel.IsActive; public bool CanShowWindow => !_shellViewModel.IsActive;
@ -49,10 +44,21 @@ namespace Artemis.ViewModels
_enabled = value; _enabled = value;
ToggleText = _enabled ? "Disable Artemis" : "Enable Artemis"; ToggleText = _enabled ? "Disable Artemis" : "Enable Artemis";
ActiveIcon = _enabled ? "../Resources/logo.ico" : "../Resources/logo-disabled.ico";
NotifyOfPropertyChange(() => Enabled); NotifyOfPropertyChange(() => Enabled);
} }
} }
public string ActiveIcon
{
get { return _activeIcon; }
set
{
_activeIcon = value;
NotifyOfPropertyChange();
}
}
public string ToggleText public string ToggleText
{ {
get { return _toggleText; } get { return _toggleText; }
@ -72,9 +78,9 @@ namespace Artemis.ViewModels
public void ToggleEnabled() public void ToggleEnabled()
{ {
if (Enabled) if (Enabled)
_shellViewModel.MainModel.ShutdownEffects(); _shellViewModel.MainManager.DisableProgram();
else else
_shellViewModel.MainModel.StartEffects(); _shellViewModel.MainManager.EnableProgram();
} }
protected override void OnActivate() protected override void OnActivate()
@ -95,8 +101,15 @@ namespace Artemis.ViewModels
NotifyOfPropertyChange(() => CanShowWindow); NotifyOfPropertyChange(() => CanShowWindow);
NotifyOfPropertyChange(() => CanHideWindow); NotifyOfPropertyChange(() => CanHideWindow);
if (_checkedForUpdate)
return;
_checkedForUpdate = true;
Updater.CheckForUpdate(_shellViewModel.MainManager.DialogService);
} }
public void HideWindow() public void HideWindow()
{ {
if (!CanHideWindow) if (!CanHideWindow)
@ -110,8 +123,11 @@ namespace Artemis.ViewModels
public void ExitApplication() public void ExitApplication()
{ {
_shellViewModel.MainModel.ShutdownEffects(); _shellViewModel.MainManager.Shutdown();
Application.Current.Shutdown(); Application.Current.Shutdown();
// Sometimes you need to be rough.
Environment.Exit(0);
} }
} }
} }

View File

@ -6,7 +6,7 @@
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:cal="http://www.caliburnproject.org" xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" d:DesignHeight="600" d:DesignWidth="300"
Width="300"> Width="300">
<UserControl.Resources> <UserControl.Resources>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
@ -24,6 +24,8 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
@ -32,8 +34,7 @@
Content="Enable Artemis:" /> Content="Enable Artemis:" />
<controls:ToggleSwitch Grid.Row="0" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No" <controls:ToggleSwitch Grid.Row="0" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" VerticalAlignment="Center" HorizontalAlignment="Right" Width="125"
IsChecked="{Binding Path=Enabled, Mode=OneWay}" IsChecked="{Binding Path=Enabled, Mode=TwoWay}" />
cal:Message.Attach="[Event Unchecked] = [Action ToggleEnabled]; [Event Checked] = [Action ToggleEnabled]" />
<!-- Startup with Windows --> <!-- Startup with Windows -->
<Label Grid.Row="1" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" <Label Grid.Row="1" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
@ -42,38 +43,52 @@
IsChecked="{Binding Path=GeneralSettings.Autorun, Mode=TwoWay}" IsChecked="{Binding Path=GeneralSettings.Autorun, Mode=TwoWay}"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" /> VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" />
<!-- Keyboard selection --> <!-- Show on startup -->
<Label Grid.Row="2" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" <Label Grid.Row="2" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Show on startup:" />
<controls:ToggleSwitch Grid.Row="2" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
IsChecked="{Binding Path=GeneralSettings.ShowOnStartup, Mode=TwoWay}"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" />
<!-- Keyboard selection -->
<Label Grid.Row="3" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Keyboard:" /> Content="Keyboard:" />
<ComboBox Grid.Row="2" Grid.Column="1" x:Name="KeyboardProviders" Margin="10" VerticalAlignment="Center" <ComboBox Grid.Row="3" Grid.Column="1" x:Name="KeyboardProviders" Margin="10" VerticalAlignment="Center"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Width="140" /> Width="140" />
<!-- TODO: Ugly --> <!-- TODO: Ugly -->
<!-- Gamestate port --> <!-- Gamestate port -->
<Label Grid.Row="3" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" <Label Grid.Row="4" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Gamestate server port:" /> Content="Gamestate server port:" />
<controls:NumericUpDown Grid.Row="3" Grid.Column="1" Margin="10" VerticalAlignment="Center" <controls:NumericUpDown Grid.Row="4" Grid.Column="1" Margin="10" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="120" HorizontalAlignment="Right" Width="120"
Value="{Binding Path=GeneralSettings.GamestatePort, Mode=TwoWay}" /> Value="{Binding Path=GeneralSettings.GamestatePort, Mode=TwoWay}" />
<!-- Updates check -->
<Label Grid.Row="5" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Check for updates:" />
<controls:ToggleSwitch Grid.Row="5" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125"
IsChecked="{Binding Path=GeneralSettings.CheckForUpdates, Mode=TwoWay}" />
<!-- Update pointers --> <!-- Update pointers -->
<Label Grid.Row="4" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" <Label Grid.Row="6" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Download pointers:" /> Content="Download pointers:" />
<controls:ToggleSwitch Grid.Row="4" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No" <controls:ToggleSwitch Grid.Row="6" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" VerticalAlignment="Center" HorizontalAlignment="Right" Width="125"
IsChecked="{Binding Path=GeneralSettings.EnablePointersUpdate, Mode=TwoWay}" /> IsChecked="{Binding Path=GeneralSettings.EnablePointersUpdate, Mode=TwoWay}" />
<!-- Buttons --> <!-- Buttons -->
<Button Grid.Row="5" Grid.Column="0" Margin="10" x:Name="ResetSettings" Content="Reset settings" <Button Grid.Row="7" Grid.Column="0" Margin="10" x:Name="ResetSettings" Content="Reset settings"
VerticalAlignment="Center" HorizontalAlignment="Left" Width="120" VerticalAlignment="Center" HorizontalAlignment="Left" Width="120"
Style="{DynamicResource SquareButtonStyle}" /> Style="{DynamicResource SquareButtonStyle}" />
<Button Grid.Row="5" Grid.Column="1" Margin="10" x:Name="SaveSettings" Content="Save changes" <Button Grid.Row="7" Grid.Column="1" Margin="10" x:Name="SaveSettings" Content="Save changes"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="120" VerticalAlignment="Center" HorizontalAlignment="Right" Width="120"
Style="{DynamicResource SquareButtonStyle}" /> Style="{DynamicResource SquareButtonStyle}" />
<!-- Version --> <!-- Version -->
<Grid Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" Margin="10" VerticalAlignment="Bottom"> <Grid Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="2" Margin="10" VerticalAlignment="Bottom">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
@ -82,11 +97,14 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Artemis 1.0.0" VerticalAlignment="Center" <TextBlock Grid.Row="0" Grid.ColumnSpan="2" x:Name="ActiveEffectName" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="Artemis 1.0.2" VerticalAlignment="Center"
HorizontalAlignment="Left" /> HorizontalAlignment="Left" />
<Button Grid.Row="0" Grid.Column="1" Focusable="False" Style="{StaticResource AccentedSquareButtonStyle}" <Button Grid.Row="1" Grid.Column="1" Focusable="False"
Style="{StaticResource AccentedSquareButtonStyle}"
cal:Message.Attach="[Action NavigateTo('https://github.com/SpoinkyNL/Artemis')]" cal:Message.Attach="[Action NavigateTo('https://github.com/SpoinkyNL/Artemis')]"
Content="View on GitHub" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Right" /> Content="View on GitHub" Margin="5,0,0,0" VerticalAlignment="Center"
HorizontalAlignment="Right" />
</Grid> </Grid>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -5,10 +5,12 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:cal="http://www.caliburnproject.org" xmlns:cal="http://www.caliburnproject.org"
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
dialogs:DialogParticipation.Register="{Binding RelativeSource={RelativeSource Self}, Path=DataContext}"
mc:Ignorable="d" mc:Ignorable="d"
Title="Artemis" Height="670" Width="690" Title="Artemis" Height="670" Width="690"
MinWidth="500" MinHeight="400" MinWidth="500" MinHeight="400"
GlowBrush="{DynamicResource AccentColorBrush}" Icon="/Artemis;component/logo.ico"> GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico">
<!-- Bit of extra code to use a different icon than in the taskbar --> <!-- Bit of extra code to use a different icon than in the taskbar -->
<Controls:MetroWindow.IconTemplate> <Controls:MetroWindow.IconTemplate>
<DataTemplate> <DataTemplate>
@ -62,7 +64,7 @@
<ResourceDictionary <ResourceDictionary
Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" /> Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
</Grid.Resources> </Grid.Resources>
<TabControl Margin="0,10,10,10" TabStripPlacement="Left" x:Name="Items"> <TabControl Margin="0,10,10,10" TabStripPlacement="Left" x:Name="Items" cal:Message.Attach="[Event GotFocus] = [Action CloseSettings]">
<TabControl.ItemTemplate> <TabControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding DisplayName}" /> <TextBlock Text="{Binding DisplayName}" />

View File

@ -24,7 +24,7 @@
<!-- the application main system tray icon --> <!-- the application main system tray icon -->
<tb:TaskbarIcon x:Key="SystemTrayIcon" <tb:TaskbarIcon x:Key="SystemTrayIcon"
IconSource="../logo.ico" IconSource="{Binding Path=ActiveIcon, Mode=OneWay}"
ToolTipText="Artemis" ToolTipText="Artemis"
cal:Message.Attach="[Event TrayMouseDoubleClick] = [Action ShowWindow]" cal:Message.Attach="[Event TrayMouseDoubleClick] = [Action ShowWindow]"
ContextMenu="{StaticResource MainSysTrayMenu}" /> ContextMenu="{StaticResource MainSysTrayMenu}" />

View File

@ -28,8 +28,8 @@
</Label> </Label>
<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"
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold" TextWrapping="Wrap" HorizontalAlignment="Left"
Foreground="#070707" MaxWidth="520" TextAlignment="Justify"> MaxWidth="520" TextAlignment="Justify">
Hello, <LineBreak /><LineBreak /> Hello, <LineBreak /><LineBreak />
Thanks a bunch for downloading this application. You're going to enjoy this! :)<LineBreak /> Thanks a bunch for downloading this application. You're going to enjoy this! :)<LineBreak />
<LineBreak /> <LineBreak />

View File

@ -1,19 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Autofac" version="4.0.0-rc1-177" targetFramework="net452" /> <package id="Autofac" version="4.0.0-rc1-177" targetFramework="net452" />
<package id="Caliburn.Micro" version="2.0.2" targetFramework="net452" /> <package id="Caliburn.Micro" version="2.0.2" targetFramework="net452" />
<package id="Caliburn.Micro.AutofacBootstrap" version="2.0.9-beta" targetFramework="net452" /> <package id="Caliburn.Micro.AutofacBootstrap" version="2.0.9-beta" targetFramework="net452" />
<package id="Caliburn.Micro.Core" version="2.0.2" targetFramework="net452" /> <package id="Caliburn.Micro.Core" version="2.0.2" targetFramework="net452" />
<package id="Colore" version="4.0.0" targetFramework="net452" /> <package id="Colore" version="4.0.0" targetFramework="net452" />
<package id="CUE.NET" version="1.0.2" targetFramework="net452" /> <package id="CUE.NET" version="1.0.2.1" targetFramework="net452" />
<package id="Extended.Wpf.Toolkit" version="2.6" targetFramework="net452" /> <package id="Extended.Wpf.Toolkit" version="2.6" targetFramework="net452" />
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.5" targetFramework="net452" /> <package id="Hardcodet.NotifyIcon.Wpf" version="1.0.5" targetFramework="net452" />
<package id="log4net" version="2.0.5" targetFramework="net452" /> <package id="log4net" version="2.0.5" targetFramework="net452" />
<package id="MahApps.Metro" version="1.2.4.0" targetFramework="net452" /> <package id="MahApps.Metro" version="1.2.4.0" targetFramework="net452" />
<package id="MahApps.Metro.Resources" version="0.4.0.0" targetFramework="net452" /> <package id="MahApps.Metro.Resources" version="0.4.0.0" targetFramework="net452" />
<package id="MouseKeyHook" version="5.4.0" targetFramework="net452" />
<package id="NAudio" version="1.7.3" targetFramework="net452" /> <package id="NAudio" version="1.7.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" /> <package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" />
<package id="VirtualInput" version="1.0.1" targetFramework="net452" />
<package id="WpfExceptionViewer" version="1.0.0.0" targetFramework="net452" /> <package id="WpfExceptionViewer" version="1.0.0.0" targetFramework="net452" />
</packages> </packages>

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Select a Product Configuration -->
<InstallShieldProductConfiguration>Express</InstallShieldProductConfiguration>
<!-- Select a Visual Studio Configuration / InstallShield Release -->
<Configuration>Debug</Configuration>
<InstallShieldRelease>$(Configuration)</InstallShieldRelease>
</PropertyGroup>
<ItemGroup>
<!-- The InstallShieldProject item selects the project to build -->
<InstallShieldProject Include="$(MSBuildProjectDirectory)\$(MSBuildProjectName).isl"/>
<!-- The InstallShieldReleaseFlags sets Release Flags -->
<!--<InstallShieldReleaseFlags Include=""/>-->
<!-- The InstallShieldMergeModulePath specifies what directories are
searched for Merge Modules -->
<!--<InstallShieldMergeModulePath Include=""/>-->
</ItemGroup>
<ItemGroup>
<!-- The ProjectReference items refer to any Visual Studio solutions you want to automatically probe for Project Output Groups. -->
</ItemGroup>
<ItemGroup>
<!-- The TaggedOutputs items allow you to explicitly add extra files to output groups. Each item must include both Name and OutputGroup, as well as TargetPath metadata values. -->
<!--<TaggedOutputs Include="C:\My Test Exe.exe">
<Name>My Test Project</Name>
<OutputGroup>Primary output</OutputGroup>
<TargetPath>My Test Exe.exe</TargetPath>
</TaggedOutputs> -->
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\InstallShield\2015Limited\InstallShield.targets"/>
</Project>