mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
merge
This commit is contained in:
commit
a31a33a6c9
@ -3,6 +3,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<configSections>
|
<configSections>
|
||||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<section name="Artemis.Modules.Games.Dota2.Dota2" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
<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.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" 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" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
<section name="Artemis.Settings.Offsets" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
<section name="Artemis.Settings.Offsets" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
@ -22,6 +23,20 @@
|
|||||||
<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.Games.Dota2.Dota2>
|
||||||
|
<setting name="Enabled" serializeAs="String">
|
||||||
|
<value>True</value>
|
||||||
|
</setting>
|
||||||
|
<setting name="GameDirectory" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
|
<setting name="CanCastAbility" serializeAs="String">
|
||||||
|
<value>True</value>
|
||||||
|
</setting>
|
||||||
|
<setting name="ShowHealth" serializeAs="String">
|
||||||
|
<value>True</value>
|
||||||
|
</setting>
|
||||||
|
</Artemis.Modules.Games.Dota2.Dota2>
|
||||||
<Artemis.Modules.Overlays.VolumeDisplay.VolumeDisplay>
|
<Artemis.Modules.Overlays.VolumeDisplay.VolumeDisplay>
|
||||||
<setting name="Enabled" serializeAs="String">
|
<setting name="Enabled" serializeAs="String">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
<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:artemis="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>
|
||||||
<artemis: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" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
|
||||||
<!-- Accent and AppTheme setting -->
|
<!-- Accent and AppTheme setting -->
|
||||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Teal.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Teal.xaml" />
|
||||||
<ResourceDictionary
|
<ResourceDictionary
|
||||||
Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
|
Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
|
||||||
<ResourceDictionary Source="/Resources/Icons.xaml" />
|
<ResourceDictionary Source="/Resources/Icons.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</Application>
|
||||||
@ -293,6 +293,14 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Modules\Games\CounterStrike\CounterStrikeModel.cs" />
|
<Compile Include="Modules\Games\CounterStrike\CounterStrikeModel.cs" />
|
||||||
<Compile Include="Modules\Games\CounterStrike\CounterStrikeSettings.cs" />
|
<Compile Include="Modules\Games\CounterStrike\CounterStrikeSettings.cs" />
|
||||||
|
<Compile Include="Modules\Games\Dota2\Dota2.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
<DependentUpon>Dota2.settings</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Modules\Games\Dota2\Dota2DataModel.cs" />
|
||||||
|
<Compile Include="Modules\Games\Dota2\Dota2Model.cs" />
|
||||||
|
<Compile Include="Modules\Games\Dota2\Dota2Settings.cs" />
|
||||||
<Compile Include="Modules\Games\RocketLeague\RocketLeague.Designer.cs">
|
<Compile Include="Modules\Games\RocketLeague\RocketLeague.Designer.cs">
|
||||||
<DependentUpon>RocketLeague.settings</DependentUpon>
|
<DependentUpon>RocketLeague.settings</DependentUpon>
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
@ -430,6 +438,7 @@
|
|||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<None Include="Modules\Effects\AudioVisualizer\AudioVisualization.settings">
|
<None Include="Modules\Effects\AudioVisualizer\AudioVisualization.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
@ -443,6 +452,10 @@
|
|||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>CounterStrike.Designer.cs</LastGenOutput>
|
<LastGenOutput>CounterStrike.Designer.cs</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="Modules\Games\Dota2\Dota2.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Dota2.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
<None Include="Modules\Games\RocketLeague\RocketLeague.settings">
|
<None Include="Modules\Games\RocketLeague\RocketLeague.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>RocketLeague.Designer.cs</LastGenOutput>
|
<LastGenOutput>RocketLeague.Designer.cs</LastGenOutput>
|
||||||
@ -465,6 +478,7 @@
|
|||||||
</Content>
|
</Content>
|
||||||
<Resource Include="Resources\logo.ico" />
|
<Resource Include="Resources\logo.ico" />
|
||||||
<Resource Include="Resources\logo-disabled.ico" />
|
<Resource Include="Resources\logo-disabled.ico" />
|
||||||
|
<Resource Include="Resources\Dota2\dotaGamestateConfiguration.txt" />
|
||||||
<None Include="Resources\LogitechLED.dll" />
|
<None Include="Resources\LogitechLED.dll" />
|
||||||
<Content Include="Resources\Witcher3\playerWitcher.txt" />
|
<Content Include="Resources\Witcher3\playerWitcher.txt" />
|
||||||
<Content Include="Resources\Witcher3\artemis.txt" />
|
<Content Include="Resources\Witcher3\artemis.txt" />
|
||||||
@ -559,7 +573,7 @@
|
|||||||
<Content Include="LogitechLedEnginesWrapper.dll">
|
<Content Include="LogitechLedEnginesWrapper.dll">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Resources\CounterStrike\gamestateConfiguration.txt" />
|
<Content Include="Resources\CounterStrike\csgoGamestateConfiguration.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
|
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using Artemis.Utilities;
|
||||||
using Corale.Colore.Razer.Keyboard.Effects;
|
using Corale.Colore.Razer.Keyboard.Effects;
|
||||||
|
|
||||||
namespace Artemis.KeyboardProviders.Razer.Utilities
|
namespace Artemis.KeyboardProviders.Razer.Utilities
|
||||||
@ -11,7 +12,7 @@ namespace Artemis.KeyboardProviders.Razer.Utilities
|
|||||||
{
|
{
|
||||||
var keyboardGrid = Custom.Create();
|
var keyboardGrid = Custom.Create();
|
||||||
if (b.Width > width || b.Height > height)
|
if (b.Width > width || b.Height > height)
|
||||||
b = ResizeImage(b, width, height);
|
b = ImageUtilities.ResizeImage(b, width, height);
|
||||||
|
|
||||||
for (var y = 0; y < b.Height; y++)
|
for (var y = 0; y < b.Height; y++)
|
||||||
for (var x = 0; x < b.Width; x++)
|
for (var x = 0; x < b.Width; x++)
|
||||||
@ -19,37 +20,5 @@ namespace Artemis.KeyboardProviders.Razer.Utilities
|
|||||||
|
|
||||||
return keyboardGrid;
|
return keyboardGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Resize the image to the specified width and height.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="image">The image to resize.</param>
|
|
||||||
/// <param name="width">The width to resize to.</param>
|
|
||||||
/// <param name="height">The height to resize to.</param>
|
|
||||||
/// <returns>The resized image.</returns>
|
|
||||||
public static Bitmap ResizeImage(Image image, int width, int height)
|
|
||||||
{
|
|
||||||
var destRect = new Rectangle(0, 0, width, height);
|
|
||||||
var destImage = new Bitmap(width, height);
|
|
||||||
|
|
||||||
destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
|
|
||||||
|
|
||||||
using (var graphics = Graphics.FromImage(destImage))
|
|
||||||
{
|
|
||||||
graphics.CompositingMode = CompositingMode.SourceCopy;
|
|
||||||
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
|
||||||
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
|
||||||
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
|
||||||
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
|
||||||
|
|
||||||
using (var wrapMode = new ImageAttributes())
|
|
||||||
{
|
|
||||||
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
|
|
||||||
graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return destImage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,139 +1,139 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Artemis.Utilities.Keyboard;
|
using Artemis.Utilities.Keyboard;
|
||||||
using Kaliko.ImageLibrary;
|
using Kaliko.ImageLibrary;
|
||||||
using Kaliko.ImageLibrary.Filters;
|
using Kaliko.ImageLibrary.Filters;
|
||||||
|
|
||||||
namespace Artemis.Modules.Effects.AmbientLightning
|
namespace Artemis.Modules.Effects.AmbientLightning
|
||||||
{
|
{
|
||||||
internal class AmbientLightningEffectModel : EffectModel
|
internal class AmbientLightningEffectModel : EffectModel
|
||||||
{
|
{
|
||||||
private KeyboardRectangle _botRect;
|
private KeyboardRectangle _botRect;
|
||||||
private List<Color> _colors;
|
private List<Color> _colors;
|
||||||
private List<Rectangle> _rectangles;
|
private List<Rectangle> _rectangles;
|
||||||
private ScreenCapture _screenCapturer;
|
private ScreenCapture _screenCapturer;
|
||||||
private KeyboardRectangle _topRect;
|
private KeyboardRectangle _topRect;
|
||||||
|
|
||||||
public AmbientLightningEffectModel(MainManager mainManager, AmbientLightningEffectSettings settings)
|
public AmbientLightningEffectModel(MainManager mainManager, AmbientLightningEffectSettings settings)
|
||||||
: base(mainManager)
|
: base(mainManager)
|
||||||
{
|
{
|
||||||
Name = "Ambient Lightning";
|
Name = "Ambient Lightning";
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
|
|
||||||
public AmbientLightningEffectSettings Settings { get; set; }
|
public AmbientLightningEffectSettings Settings { get; set; }
|
||||||
|
|
||||||
public KeyboardRectangle KeyboardRectangle { get; set; }
|
public KeyboardRectangle KeyboardRectangle { get; set; }
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
|
||||||
_screenCapturer.Dispose();
|
_screenCapturer.Dispose();
|
||||||
_screenCapturer = null;
|
_screenCapturer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
|
||||||
_colors = new List<Color>();
|
_colors = new List<Color>();
|
||||||
_screenCapturer = new ScreenCapture();
|
_screenCapturer = new ScreenCapture();
|
||||||
_topRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
_topRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
||||||
LinearGradientMode.Horizontal) {Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale/2};
|
LinearGradientMode.Horizontal) {Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale/2};
|
||||||
_botRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
_botRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
||||||
LinearGradientMode.Horizontal);
|
LinearGradientMode.Horizontal);
|
||||||
|
|
||||||
Initialized = true;
|
Initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
var capture = _screenCapturer.Capture();
|
var capture = _screenCapturer.Capture();
|
||||||
if (capture == null)
|
if (capture == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_rectangles = new List<Rectangle>();
|
_rectangles = new List<Rectangle>();
|
||||||
// Analise the result
|
// Analise the result
|
||||||
// Chop the screen into 2 rows and 3 columns
|
// Chop the screen into 2 rows and 3 columns
|
||||||
var resolution = Screen.PrimaryScreen.Bounds;
|
var resolution = Screen.PrimaryScreen.Bounds;
|
||||||
var blockWidth = resolution.Width/3;
|
var blockWidth = resolution.Width/3;
|
||||||
var blockHeight = resolution.Height/2;
|
var blockHeight = resolution.Height/2;
|
||||||
var colorIndex = 0;
|
var colorIndex = 0;
|
||||||
for (var row = 0; row < 2; row++)
|
for (var row = 0; row < 2; row++)
|
||||||
{
|
{
|
||||||
for (var column = 0; column < 3; column++)
|
for (var column = 0; column < 3; column++)
|
||||||
{
|
{
|
||||||
var blockBase = new Point(blockWidth*column, blockHeight*row);
|
var blockBase = new Point(blockWidth*column, blockHeight*row);
|
||||||
var samples = new List<Color>();
|
var samples = new List<Color>();
|
||||||
// For each block, take samples
|
// For each block, take samples
|
||||||
for (var blockRow = 0; blockRow < 6; blockRow++)
|
for (var blockRow = 0; blockRow < 6; blockRow++)
|
||||||
{
|
{
|
||||||
for (var blockColumn = 0; blockColumn < 6; blockColumn++)
|
for (var blockColumn = 0; blockColumn < 6; blockColumn++)
|
||||||
{
|
{
|
||||||
var x = blockWidth/6*blockColumn + blockWidth/6/4 + blockBase.X;
|
var x = blockWidth/6*blockColumn + blockWidth/6/4 + blockBase.X;
|
||||||
var y = blockHeight/6*blockRow + blockHeight/6/4 + blockBase.Y;
|
var y = blockHeight/6*blockRow + blockHeight/6/4 + blockBase.Y;
|
||||||
samples.Add(_screenCapturer.GetColor(capture, new Point(x, y)));
|
samples.Add(_screenCapturer.GetColor(capture, new Point(x, y)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take the average of the samples
|
// Take the average of the samples
|
||||||
var averageR = samples.Sum(s => s.R)/samples.Count;
|
var averageR = samples.Sum(s => s.R)/samples.Count;
|
||||||
var averageG = samples.Sum(s => s.G)/samples.Count;
|
var averageG = samples.Sum(s => s.G)/samples.Count;
|
||||||
var averageB = samples.Sum(s => s.B)/samples.Count;
|
var averageB = samples.Sum(s => s.B)/samples.Count;
|
||||||
|
|
||||||
if (_colors.Count <= colorIndex)
|
if (_colors.Count <= colorIndex)
|
||||||
_colors.Add(Color.FromArgb(255, averageR, averageG, averageB));
|
_colors.Add(Color.FromArgb(255, averageR, averageG, averageB));
|
||||||
else
|
else
|
||||||
_colors[colorIndex] = Color.FromArgb(255, (averageR + _colors[colorIndex].R * 5) / 6, (averageG + _colors[colorIndex].G * 5) / 6, (averageB + _colors[colorIndex].B * 5) / 6);
|
_colors[colorIndex] = Color.FromArgb(255, (averageR + _colors[colorIndex].R * 5) / 6, (averageG + _colors[colorIndex].G * 5) / 6, (averageB + _colors[colorIndex].B * 5) / 6);
|
||||||
colorIndex++;
|
colorIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the resulting colors in 6 rectangles, their size differs per keyboard
|
// Put the resulting colors in 6 rectangles, their size differs per keyboard
|
||||||
var rectWidth = MainManager.KeyboardManager.ActiveKeyboard.Width/3*Scale;
|
var rectWidth = MainManager.KeyboardManager.ActiveKeyboard.Width/3*Scale;
|
||||||
var rectHeight = MainManager.KeyboardManager.ActiveKeyboard.Height/2*Scale;
|
var rectHeight = MainManager.KeyboardManager.ActiveKeyboard.Height/2*Scale;
|
||||||
for (var row = 0; row < 2; row++)
|
for (var row = 0; row < 2; row++)
|
||||||
{
|
{
|
||||||
for (var column = 0; column < 3; column++)
|
for (var column = 0; column < 3; column++)
|
||||||
{
|
{
|
||||||
var rectBase = new Point(rectWidth * column, rectHeight * row);
|
var rectBase = new Point(rectWidth * column, rectHeight * row);
|
||||||
_rectangles.Add(new Rectangle(rectBase.X, rectBase.Y, rectWidth, rectHeight));
|
_rectangles.Add(new Rectangle(rectBase.X, rectBase.Y, rectWidth, rectHeight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Bitmap GenerateBitmap()
|
public override Bitmap GenerateBitmap()
|
||||||
{
|
{
|
||||||
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
var i = 0;
|
var i = 0;
|
||||||
foreach (var rectangle in _rectangles)
|
foreach (var rectangle in _rectangles)
|
||||||
{
|
{
|
||||||
g.FillRectangle(new SolidBrush(_colors[i]), rectangle);
|
g.FillRectangle(new SolidBrush(_colors[i]), rectangle);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var test = new KalikoImage(bitmap);
|
var test = new KalikoImage(bitmap);
|
||||||
test.ApplyFilter(new GaussianBlurFilter(8f));
|
test.ApplyFilter(new GaussianBlurFilter(8f));
|
||||||
var ms = new MemoryStream();
|
var ms = new MemoryStream();
|
||||||
test.SaveBmp(ms);
|
test.SaveBmp(ms);
|
||||||
ms.Position = 0;
|
ms.Position = 0;
|
||||||
return new Bitmap(ms);
|
return new Bitmap(ms);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
return;
|
return;
|
||||||
if (Directory.Exists(((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg"))
|
if (Directory.Exists(((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg"))
|
||||||
{
|
{
|
||||||
var cfgFile = Resources.gamestateConfiguration.Replace("{{port}}",
|
var cfgFile = Resources.csgoGamestateConfiguration.Replace("{{port}}",
|
||||||
MainManager.GameStateWebServer.Port.ToString());
|
MainManager.GameStateWebServer.Port.ToString());
|
||||||
File.WriteAllText(
|
File.WriteAllText(
|
||||||
((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg/gamestate_integration_artemis.cfg",
|
((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg/gamestate_integration_artemis.cfg",
|
||||||
|
|||||||
74
Artemis/Artemis/Modules/Games/Dota2/Dota2.Designer.cs
generated
Normal file
74
Artemis/Artemis/Modules/Games/Dota2/Dota2.Designer.cs
generated
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Artemis.Modules.Games.Dota2 {
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||||
|
internal sealed partial class Dota2 : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
|
private static Dota2 defaultInstance = ((Dota2)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Dota2())));
|
||||||
|
|
||||||
|
public static Dota2 Default {
|
||||||
|
get {
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[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.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
|
public string GameDirectory {
|
||||||
|
get {
|
||||||
|
return ((string)(this["GameDirectory"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["GameDirectory"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||||
|
public bool CanCastAbility {
|
||||||
|
get {
|
||||||
|
return ((bool)(this["CanCastAbility"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["CanCastAbility"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||||
|
public bool ShowHealth {
|
||||||
|
get {
|
||||||
|
return ((bool)(this["ShowHealth"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["ShowHealth"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Artemis/Artemis/Modules/Games/Dota2/Dota2.settings
Normal file
18
Artemis/Artemis/Modules/Games/Dota2/Dota2.settings
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Artemis.Modules.Games.Dota2" GeneratedClassName="Dota2">
|
||||||
|
<Profiles />
|
||||||
|
<Settings>
|
||||||
|
<Setting Name="Enabled" Type="System.Boolean" Scope="User">
|
||||||
|
<Value Profile="(Default)">True</Value>
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="GameDirectory" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)" />
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="CanCastAbility" Type="System.Boolean" Scope="User">
|
||||||
|
<Value Profile="(Default)">True</Value>
|
||||||
|
</Setting>
|
||||||
|
<Setting Name="ShowHealth" Type="System.Boolean" Scope="User">
|
||||||
|
<Value Profile="(Default)">True</Value>
|
||||||
|
</Setting>
|
||||||
|
</Settings>
|
||||||
|
</SettingsFile>
|
||||||
227
Artemis/Artemis/Modules/Games/Dota2/Dota2DataModel.cs
Normal file
227
Artemis/Artemis/Modules/Games/Dota2/Dota2DataModel.cs
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
namespace Artemis.Modules.Games.Dota2
|
||||||
|
{
|
||||||
|
class Dota2DataModel
|
||||||
|
{
|
||||||
|
public class Rootobject
|
||||||
|
{
|
||||||
|
public Provider provider { get; set; }
|
||||||
|
public Map map { get; set; }
|
||||||
|
public Player player { get; set; }
|
||||||
|
public Hero hero { get; set; }
|
||||||
|
public Abilities abilities { get; set; }
|
||||||
|
public Items items { get; set; }
|
||||||
|
public Previously previously { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Provider
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public int appid { get; set; }
|
||||||
|
public int version { get; set; }
|
||||||
|
public int timestamp { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Map
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public long matchid { get; set; }
|
||||||
|
public int game_time { get; set; }
|
||||||
|
public int clock_time { get; set; }
|
||||||
|
public bool daytime { get; set; }
|
||||||
|
public bool nightstalker_night { get; set; }
|
||||||
|
public string game_state { get; set; }
|
||||||
|
public string win_team { get; set; }
|
||||||
|
public string customgamename { get; set; }
|
||||||
|
public int ward_purchase_cooldown { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Player
|
||||||
|
{
|
||||||
|
public string steamid { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string activity { get; set; }
|
||||||
|
public int kills { get; set; }
|
||||||
|
public int deaths { get; set; }
|
||||||
|
public int assists { get; set; }
|
||||||
|
public int last_hits { get; set; }
|
||||||
|
public int denies { get; set; }
|
||||||
|
public int kill_streak { get; set; }
|
||||||
|
public string team_name { get; set; }
|
||||||
|
public int gold { get; set; }
|
||||||
|
public int gold_reliable { get; set; }
|
||||||
|
public int gold_unreliable { get; set; }
|
||||||
|
public int gpm { get; set; }
|
||||||
|
public int xpm { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Hero
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public int level { get; set; }
|
||||||
|
public bool alive { get; set; }
|
||||||
|
public int respawn_seconds { get; set; }
|
||||||
|
public int buyback_cost { get; set; }
|
||||||
|
public int buyback_cooldown { get; set; }
|
||||||
|
public int health { get; set; }
|
||||||
|
public int max_health { get; set; }
|
||||||
|
public int health_percent { get; set; }
|
||||||
|
public int mana { get; set; }
|
||||||
|
public int max_mana { get; set; }
|
||||||
|
public int mana_percent { get; set; }
|
||||||
|
public bool silenced { get; set; }
|
||||||
|
public bool stunned { get; set; }
|
||||||
|
public bool disarmed { get; set; }
|
||||||
|
public bool magicimmune { get; set; }
|
||||||
|
public bool hexed { get; set; }
|
||||||
|
public bool muted { get; set; }
|
||||||
|
public bool _break { get; set; }
|
||||||
|
public bool has_debuff { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Abilities
|
||||||
|
{
|
||||||
|
public Ability0 ability0 { get; set; }
|
||||||
|
public Ability1 ability1 { get; set; }
|
||||||
|
public Ability2 ability2 { get; set; }
|
||||||
|
public Ability3 ability3 { get; set; }
|
||||||
|
public Attributes attributes { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Ability0
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public int level { get; set; }
|
||||||
|
public bool can_cast { get; set; }
|
||||||
|
public bool passive { get; set; }
|
||||||
|
public bool ability_active { get; set; }
|
||||||
|
public int cooldown { get; set; }
|
||||||
|
public bool ultimate { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Ability1
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public int level { get; set; }
|
||||||
|
public bool can_cast { get; set; }
|
||||||
|
public bool passive { get; set; }
|
||||||
|
public bool ability_active { get; set; }
|
||||||
|
public int cooldown { get; set; }
|
||||||
|
public bool ultimate { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Ability2
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public int level { get; set; }
|
||||||
|
public bool can_cast { get; set; }
|
||||||
|
public bool passive { get; set; }
|
||||||
|
public bool ability_active { get; set; }
|
||||||
|
public int cooldown { get; set; }
|
||||||
|
public bool ultimate { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Ability3
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public int level { get; set; }
|
||||||
|
public bool can_cast { get; set; }
|
||||||
|
public bool passive { get; set; }
|
||||||
|
public bool ability_active { get; set; }
|
||||||
|
public int cooldown { get; set; }
|
||||||
|
public bool ultimate { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Attributes
|
||||||
|
{
|
||||||
|
public int level { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Items
|
||||||
|
{
|
||||||
|
public Slot0 slot0 { get; set; }
|
||||||
|
public Slot1 slot1 { get; set; }
|
||||||
|
public Slot2 slot2 { get; set; }
|
||||||
|
public Slot3 slot3 { get; set; }
|
||||||
|
public Slot4 slot4 { get; set; }
|
||||||
|
public Slot5 slot5 { get; set; }
|
||||||
|
public Stash0 stash0 { get; set; }
|
||||||
|
public Stash1 stash1 { get; set; }
|
||||||
|
public Stash2 stash2 { get; set; }
|
||||||
|
public Stash3 stash3 { get; set; }
|
||||||
|
public Stash4 stash4 { get; set; }
|
||||||
|
public Stash5 stash5 { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Slot0
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Slot1
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Slot2
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Slot3
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Slot4
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Slot5
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Stash0
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Stash1
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Stash2
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Stash3
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Stash4
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Stash5
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Previously
|
||||||
|
{
|
||||||
|
public Player1 player { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Player1
|
||||||
|
{
|
||||||
|
public int gold { get; set; }
|
||||||
|
public int gold_unreliable { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
118
Artemis/Artemis/Modules/Games/Dota2/Dota2Model.cs
Normal file
118
Artemis/Artemis/Modules/Games/Dota2/Dota2Model.cs
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Artemis.KeyboardProviders;
|
||||||
|
using Artemis.Managers;
|
||||||
|
using Artemis.Models;
|
||||||
|
using Artemis.Utilities.GameState;
|
||||||
|
using Artemis.Utilities.Keyboard;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Artemis.Modules.Games.Dota2;
|
||||||
|
|
||||||
|
namespace Artemis.Modules.Games.Dota2
|
||||||
|
{
|
||||||
|
class Dota2Model : GameModel
|
||||||
|
{
|
||||||
|
|
||||||
|
private KeyboardRegion _topRow;
|
||||||
|
public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager)
|
||||||
|
{
|
||||||
|
Settings = settings;
|
||||||
|
Name = "Dota2";
|
||||||
|
ProcessName = "dota2";
|
||||||
|
Enabled = Settings.Enabled;
|
||||||
|
Initialized = false;
|
||||||
|
Scale = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Variables
|
||||||
|
|
||||||
|
public Dota2Settings Settings { get; set; }
|
||||||
|
public Dota2DataModel.Rootobject D2Json { get; set; }
|
||||||
|
public int Scale { get; set; }
|
||||||
|
public KeyboardRectangle HealthRect { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
Initialized = false;
|
||||||
|
MainManager.GameStateWebServer.GameDataReceived -= HandleGameData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Enable()
|
||||||
|
{
|
||||||
|
Initialized = false;
|
||||||
|
_topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
|
||||||
|
HealthRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X,
|
||||||
|
new List<Color>(),
|
||||||
|
LinearGradientMode.Horizontal)
|
||||||
|
{ Height = Scale, ContainedBrush = false };
|
||||||
|
MainManager.GameStateWebServer.GameDataReceived += HandleGameData;
|
||||||
|
Initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
if (D2Json == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Settings.CanCastAbility)
|
||||||
|
UpdateAbilities();
|
||||||
|
if (Settings.ShowHealth)
|
||||||
|
UpdateHealth();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateHealth()
|
||||||
|
{
|
||||||
|
var health = D2Json.hero.health_percent;
|
||||||
|
if(health > 66)
|
||||||
|
HealthRect.Colors = new List<Color> { Color.Lime };
|
||||||
|
else if (health > 33)
|
||||||
|
HealthRect.Colors = new List<Color> {Color.Yellow};
|
||||||
|
else
|
||||||
|
HealthRect.Colors = new List<Color> {Color.Red};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateAbilities()
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
|
//Update keys according to the abilities they take.
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Bitmap GenerateBitmap()
|
||||||
|
{
|
||||||
|
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||||
|
|
||||||
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
|
{
|
||||||
|
g.Clear(Color.Transparent);
|
||||||
|
HealthRect.Draw(g);
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void HandleGameData(object sender, GameDataReceivedEventArgs e)
|
||||||
|
{
|
||||||
|
var jsonString = e.Json.ToString();
|
||||||
|
|
||||||
|
// Ensure it's Dota 2 JSON
|
||||||
|
if (!jsonString.Contains("Dota 2"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Parse the JSON
|
||||||
|
D2Json = JsonConvert.DeserializeObject<Dota2DataModel.Rootobject>(jsonString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
52
Artemis/Artemis/Modules/Games/Dota2/Dota2Settings.cs
Normal file
52
Artemis/Artemis/Modules/Games/Dota2/Dota2Settings.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Artemis.Models;
|
||||||
|
|
||||||
|
namespace Artemis.Modules.Games.Dota2
|
||||||
|
{
|
||||||
|
class Dota2Settings : GameSettings
|
||||||
|
{
|
||||||
|
|
||||||
|
public Dota2Settings()
|
||||||
|
{
|
||||||
|
Load();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region Variables
|
||||||
|
public string GameDirectory { get; set; }
|
||||||
|
public bool CanCastAbility { get; set; }
|
||||||
|
public bool ShowHealth { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
public override void Load()
|
||||||
|
{
|
||||||
|
ShowHealth = Dota2.Default.ShowHealth;
|
||||||
|
CanCastAbility = Dota2.Default.CanCastAbility;
|
||||||
|
Enabled = Dota2.Default.Enabled;
|
||||||
|
GameDirectory = Dota2.Default.GameDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Save()
|
||||||
|
{
|
||||||
|
Dota2.Default.ShowHealth = ShowHealth;
|
||||||
|
Dota2.Default.CanCastAbility = CanCastAbility;
|
||||||
|
Dota2.Default.Enabled = Enabled;
|
||||||
|
Dota2.Default.GameDirectory = GameDirectory;
|
||||||
|
|
||||||
|
Dota2.Default.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ToDefault()
|
||||||
|
{
|
||||||
|
ShowHealth = true;
|
||||||
|
CanCastAbility = true;
|
||||||
|
Enabled = false;
|
||||||
|
GameDirectory = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,88 @@
|
|||||||
<UserControl x:Class="Artemis.Modules.Games.Dota2.Dota2View"
|
<UserControl x:Class="Artemis.Modules.Games.Dota2.Dota2View"
|
||||||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
mc:Ignorable="d"
|
xmlns:cal="http://www.caliburnproject.org"
|
||||||
d:DesignHeight="300" d:DesignWidth="300">
|
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
|
mc:Ignorable="d"
|
||||||
<Grid>
|
d:DesignHeight="424" d:DesignWidth="635">
|
||||||
<TextBlock Text="Dota 2 support is still to be done." />
|
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
|
||||||
</Grid>
|
<Grid Margin="15, 5, 15, 5">
|
||||||
</ScrollViewer>
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="80" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,1,0">
|
||||||
|
<Label FontSize="20" HorizontalAlignment="Left">
|
||||||
|
<Label.Content>
|
||||||
|
<AccessText TextWrapping="Wrap"
|
||||||
|
Text="Shows various information Dota 2." />
|
||||||
|
</Label.Content>
|
||||||
|
</Label>
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
|
<Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" />
|
||||||
|
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
|
||||||
|
IsChecked="{Binding Path=GameSettings.Enabled, Mode=TwoWay}"
|
||||||
|
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||||
|
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Grid.ColumnSpan="2" Margin="0,0,1,0">
|
||||||
|
<Label FontSize="16" Content="Dota 2 Directory" FontFamily="Segoe UI Semibold" Foreground="#535353"
|
||||||
|
Width="130" HorizontalAlignment="Left" />
|
||||||
|
<Grid>
|
||||||
|
<TextBox x:Name="GameDirectory" Height="23" TextWrapping="Wrap" Margin="5,0,30,0"
|
||||||
|
Text="{Binding Path=GameSettings.GameDirectory, Mode=TwoWay}"
|
||||||
|
cal:Message.Attach="[Event LostFocus] = [Action PlaceConfigFile]" />
|
||||||
|
<Button x:Name="BrowseDirectory" Content="..." RenderTransformOrigin="-0.039,-0.944"
|
||||||
|
HorizontalAlignment="Right" Width="25"
|
||||||
|
Style="{DynamicResource SquareButtonStyle}" Height="25" />
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Abilities Display -->
|
||||||
|
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
|
||||||
|
Height="16" Margin="0,10,0,9">
|
||||||
|
Show abilities that can be cast.
|
||||||
|
</TextBlock>
|
||||||
|
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.CanCastAbility, Mode=TwoWay}"
|
||||||
|
Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
|
||||||
|
Margin="0,0,-5,0" Width="114" />
|
||||||
|
|
||||||
|
<!-- Health Display -->
|
||||||
|
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
|
||||||
|
Height="16" Margin="0,10,0,9">
|
||||||
|
Show health on F-Keys.
|
||||||
|
</TextBlock>
|
||||||
|
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ShowHealth, Mode=TwoWay}"
|
||||||
|
Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
|
||||||
|
Margin="0,0,-5,0" Width="114" />
|
||||||
|
|
||||||
|
<StackPanel Grid.Column="0" Grid.Row="9" Orientation="Horizontal" VerticalAlignment="Bottom">
|
||||||
|
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100"
|
||||||
|
Style="{DynamicResource SquareButtonStyle}" />
|
||||||
|
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100"
|
||||||
|
Margin="10,0,0,0"
|
||||||
|
Style="{DynamicResource SquareButtonStyle}" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</ScrollViewer>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -1,16 +1,73 @@
|
|||||||
using Artemis.Managers;
|
using System;
|
||||||
using Artemis.ViewModels.Abstract;
|
using System.IO;
|
||||||
|
using System.Windows.Forms;
|
||||||
namespace Artemis.Modules.Games.Dota2
|
using Artemis.Managers;
|
||||||
{
|
using Artemis.Properties;
|
||||||
public class Dota2ViewModel : GameViewModel
|
using Artemis.ViewModels.Abstract;
|
||||||
{
|
|
||||||
public Dota2ViewModel(MainManager mainManager)
|
namespace Artemis.Modules.Games.Dota2
|
||||||
{
|
{
|
||||||
MainManager = mainManager;
|
public class Dota2ViewModel : GameViewModel
|
||||||
}
|
{
|
||||||
|
public Dota2ViewModel(MainManager mainManager)
|
||||||
public static string Name => "Dota 2 (NYI)";
|
{
|
||||||
public string Content => "Dota 2 Content";
|
MainManager = mainManager;
|
||||||
}
|
GameSettings = new Dota2Settings();
|
||||||
|
|
||||||
|
GameModel = new Dota2Model(mainManager, (Dota2Settings) GameSettings);
|
||||||
|
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||||
|
PlaceConfigFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Name => "Dota 2";
|
||||||
|
public string Content => "Dota 2 Content";
|
||||||
|
|
||||||
|
public void BrowseDirectory()
|
||||||
|
{
|
||||||
|
var dialog = new FolderBrowserDialog { SelectedPath = ((Dota2Settings)GameSettings).GameDirectory };
|
||||||
|
var result = dialog.ShowDialog();
|
||||||
|
if (result != DialogResult.OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
((Dota2Settings)GameSettings).GameDirectory = dialog.SelectedPath;
|
||||||
|
NotifyOfPropertyChange(() => GameSettings);
|
||||||
|
|
||||||
|
GameSettings.Save();
|
||||||
|
PlaceConfigFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlaceConfigFile()
|
||||||
|
{
|
||||||
|
if (((Dota2Settings)GameSettings).GameDirectory == string.Empty)
|
||||||
|
return;
|
||||||
|
if (Directory.Exists(((Dota2Settings)GameSettings).GameDirectory + "/game/dota/cfg"))
|
||||||
|
{
|
||||||
|
var cfgFile = Resources.dotaGamestateConfiguration.Replace("{{port}}",
|
||||||
|
MainManager.GameStateWebServer.Port.ToString());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.WriteAllText(
|
||||||
|
((Dota2Settings)GameSettings).GameDirectory + "/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg",
|
||||||
|
cfgFile);
|
||||||
|
}
|
||||||
|
catch (DirectoryNotFoundException)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(((Dota2Settings) GameSettings).GameDirectory + "/game/dota/cfg/gamestate_integration/");
|
||||||
|
File.WriteAllText(
|
||||||
|
((Dota2Settings)GameSettings).GameDirectory + "/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg",
|
||||||
|
cfgFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MainManager.DialogService.ShowErrorMessageBox("Please select a valid Dota 2 directory\n\n" +
|
||||||
|
@"By default Dota 2 is in \SteamApps\common\Dota2");
|
||||||
|
((Dota2Settings)GameSettings).GameDirectory = string.Empty;
|
||||||
|
NotifyOfPropertyChange(() => GameSettings);
|
||||||
|
|
||||||
|
GameSettings.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
79
Artemis/Artemis/Properties/Resources.Designer.cs
generated
79
Artemis/Artemis/Properties/Resources.Designer.cs
generated
@ -61,14 +61,14 @@ namespace Artemis.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to <?xml version="1.0" encoding="UTF-16"?>
|
/// Looks up a localized string similar to <?xml version="1.0" encoding="UTF-16"?>
|
||||||
///<!-- Used by Artemis to get the active Sign -->
|
///<!-- Used by Artemis to get the active Sign -->
|
||||||
///<UserConfig>
|
///<UserConfig>
|
||||||
/// <Group id="Artemis" displayName="Artemis">
|
/// <Group id="Artemis" displayName="Artemis">
|
||||||
/// <VisibleVars>
|
/// <VisibleVars>
|
||||||
/// <Var id="ActiveSign" displayName="ActiveSign" displayType="SLIDER:0:1:1000000"/>
|
/// <Var id="ActiveSign" displayName="ActiveSign" displayType="SLIDER:0:1:1000000"/>
|
||||||
/// </VisibleVars>
|
/// </VisibleVars>
|
||||||
/// </Group>
|
/// </Group>
|
||||||
///</UserConfig>.
|
///</UserConfig>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string artemisXml {
|
internal static string artemisXml {
|
||||||
@ -88,28 +88,53 @@ namespace Artemis.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to "Artemis"
|
/// Looks up a localized string similar to "Artemis"
|
||||||
///{
|
///{
|
||||||
/// "uri" "http://localhost:{{port}}/csgo_game_event"
|
/// "uri" "http://localhost:{{port}}/csgo_game_event"
|
||||||
/// "timeout" "5.0"
|
/// "timeout" "5.0"
|
||||||
/// "buffer" "0.1"
|
/// "buffer" "0.1"
|
||||||
/// "throttle" "0.1"
|
/// "throttle" "0.1"
|
||||||
/// "heartbeat" "30.0"
|
/// "heartbeat" "30.0"
|
||||||
/// "data"
|
/// "data"
|
||||||
/// {
|
/// {
|
||||||
/// "provider" "1"
|
/// "provider" "1"
|
||||||
/// "map" "1"
|
/// "map" "1"
|
||||||
/// "round" "1"
|
/// "round" "1"
|
||||||
/// "player_id" "1"
|
/// "player_id" "1"
|
||||||
/// "player_state" "1"
|
/// "player_state" "1"
|
||||||
/// "player_weapons" "1"
|
/// "player_weapons" "1"
|
||||||
/// "player_match_stats" "1"
|
/// "player_match_stats" "1"
|
||||||
/// }
|
/// }
|
||||||
///}.
|
///}.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string gamestateConfiguration {
|
internal static string csgoGamestateConfiguration {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("gamestateConfiguration", resourceCulture);
|
return ResourceManager.GetString("csgoGamestateConfiguration", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to "Artemis"
|
||||||
|
///{
|
||||||
|
/// "uri" "http://localhost:4000/"
|
||||||
|
/// "timeout" "5.0"
|
||||||
|
/// "buffer" "0.1"
|
||||||
|
/// "throttle" "0.1"
|
||||||
|
/// "heartbeat" "30.0"
|
||||||
|
/// "data"
|
||||||
|
/// {
|
||||||
|
/// "provider" "1"
|
||||||
|
/// "map" "1"
|
||||||
|
/// "player" "1"
|
||||||
|
/// "hero" "1"
|
||||||
|
/// "abilities" "1"
|
||||||
|
/// "items" "1"
|
||||||
|
/// }
|
||||||
|
///}.
|
||||||
|
/// </summary>
|
||||||
|
internal static string dotaGamestateConfiguration {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("dotaGamestateConfiguration", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -124,8 +124,11 @@
|
|||||||
<data name="bow" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="bow" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\bow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\bow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="gamestateConfiguration" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="csgoGamestateConfiguration" 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\csgoGamestateconfiguration.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||||
|
</data>
|
||||||
|
<data name="dotaGamestateConfiguration" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\resources\dota2\dotaGamestateconfiguration.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="LogitechLED" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="LogitechLED" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\LogitechLED.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>..\Resources\LogitechLED.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
|||||||
@ -0,0 +1,17 @@
|
|||||||
|
"Artemis"
|
||||||
|
{
|
||||||
|
"uri" "http://localhost:{{port}}/"
|
||||||
|
"timeout" "5.0"
|
||||||
|
"buffer" "0.1"
|
||||||
|
"throttle" "0.1"
|
||||||
|
"heartbeat" "30.0"
|
||||||
|
"data"
|
||||||
|
{
|
||||||
|
"provider" "1"
|
||||||
|
"map" "1"
|
||||||
|
"player" "1"
|
||||||
|
"hero" "1"
|
||||||
|
"abilities" "1"
|
||||||
|
"items" "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,110 +1,110 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
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 System.Windows.Forms;
|
||||||
using Artemis.Settings;
|
using Artemis.Settings;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Artemis.Utilities.GameState
|
namespace Artemis.Utilities.GameState
|
||||||
{
|
{
|
||||||
public class GameStateWebServer
|
public class GameStateWebServer
|
||||||
{
|
{
|
||||||
public delegate void GameDataReceivedEventHandler(
|
public delegate void GameDataReceivedEventHandler(
|
||||||
object sender, GameDataReceivedEventArgs gameDataReceivedEventArgs);
|
object sender, GameDataReceivedEventArgs gameDataReceivedEventArgs);
|
||||||
|
|
||||||
private readonly HttpListener _listener = new HttpListener();
|
private readonly HttpListener _listener = new HttpListener();
|
||||||
|
|
||||||
public GameStateWebServer()
|
public GameStateWebServer()
|
||||||
{
|
{
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Port { get; private set; }
|
public int Port { get; private set; }
|
||||||
public bool Running { get; private set; }
|
public bool Running { get; private set; }
|
||||||
|
|
||||||
public event GameDataReceivedEventHandler GameDataReceived;
|
public event GameDataReceivedEventHandler GameDataReceived;
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
if (Running)
|
if (Running)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
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)
|
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.");
|
MessageBox.Show("Couldn't start the webserver. CS:GO/Dota2 effects won't work :c \n\nTry changing the port in Settings and restart Artemis.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadPool.QueueUserWorkItem(o =>
|
ThreadPool.QueueUserWorkItem(o =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (_listener.IsListening)
|
while (_listener.IsListening)
|
||||||
{
|
{
|
||||||
ThreadPool.QueueUserWorkItem(c =>
|
ThreadPool.QueueUserWorkItem(c =>
|
||||||
{
|
{
|
||||||
var ctx = c as HttpListenerContext;
|
var ctx = c as HttpListenerContext;
|
||||||
if (ctx == null)
|
if (ctx == null)
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var rstr = HandleRequest(ctx.Request);
|
var rstr = HandleRequest(ctx.Request);
|
||||||
var buf = Encoding.UTF8.GetBytes(rstr);
|
var buf = Encoding.UTF8.GetBytes(rstr);
|
||||||
ctx.Response.ContentLength64 = buf.Length;
|
ctx.Response.ContentLength64 = buf.Length;
|
||||||
ctx.Response.OutputStream.Write(buf, 0, buf.Length);
|
ctx.Response.OutputStream.Write(buf, 0, buf.Length);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// always close the stream
|
// always close the stream
|
||||||
ctx.Response.OutputStream.Close();
|
ctx.Response.OutputStream.Close();
|
||||||
}
|
}
|
||||||
}, _listener.GetContext());
|
}, _listener.GetContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Running = true;
|
Running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
_listener.Stop();
|
_listener.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string HandleRequest(HttpListenerRequest request)
|
private string HandleRequest(HttpListenerRequest request)
|
||||||
{
|
{
|
||||||
object json;
|
object json;
|
||||||
using (var reader = new StreamReader(request.InputStream, request.ContentEncoding))
|
using (var reader = new StreamReader(request.InputStream, request.ContentEncoding))
|
||||||
{
|
{
|
||||||
var result = reader.ReadToEnd();
|
var result = reader.ReadToEnd();
|
||||||
json = JsonConvert.DeserializeObject<object>(result);
|
json = JsonConvert.DeserializeObject<object>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json != null)
|
if (json != null)
|
||||||
OnGameDataReceived(new GameDataReceivedEventArgs(json));
|
OnGameDataReceived(new GameDataReceivedEventArgs(json));
|
||||||
return JsonConvert.SerializeObject(json);
|
return JsonConvert.SerializeObject(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnGameDataReceived(GameDataReceivedEventArgs e)
|
protected virtual void OnGameDataReceived(GameDataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
GameDataReceived?.Invoke(this, e);
|
GameDataReceived?.Invoke(this, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,44 +78,6 @@ namespace Artemis.Utilities
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Saves an image as a jpeg image, with the given quality
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">Path to which the image would be saved.</param>
|
|
||||||
/// <param name="quality">
|
|
||||||
/// An integer from 0 to 100, with 100 being the
|
|
||||||
/// highest quality
|
|
||||||
/// </param>
|
|
||||||
/// <exception cref="ArgumentOutOfRangeException">
|
|
||||||
/// An invalid value was entered for image quality.
|
|
||||||
/// </exception>
|
|
||||||
public static void SaveJpeg(string path, Image image, int quality)
|
|
||||||
{
|
|
||||||
//ensure the quality is within the correct range
|
|
||||||
if ((quality < 0) || (quality > 100))
|
|
||||||
{
|
|
||||||
//create the error message
|
|
||||||
var error =
|
|
||||||
string.Format(
|
|
||||||
"Jpeg image quality must be between 0 and 100, with 100 being the highest quality. A value of {0} was specified.",
|
|
||||||
quality);
|
|
||||||
//throw a helpful exception
|
|
||||||
throw new ArgumentOutOfRangeException(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
//create an encoder parameter for the image quality
|
|
||||||
var qualityParam = new EncoderParameter(Encoder.Quality, quality);
|
|
||||||
//get the jpeg codec
|
|
||||||
var jpegCodec = GetEncoderInfo("image/jpeg");
|
|
||||||
|
|
||||||
//create a collection of all parameters that we will pass to the encoder
|
|
||||||
var encoderParams = new EncoderParameters(1);
|
|
||||||
//set the quality parameter for the codec
|
|
||||||
encoderParams.Param[0] = qualityParam;
|
|
||||||
//save the image using the codec and the parameters
|
|
||||||
image.Save(path, jpegCodec, encoderParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the image codec with the given mime type
|
/// Returns the image codec with the given mime type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -18,7 +18,7 @@ namespace Artemis.ViewModels
|
|||||||
{
|
{
|
||||||
_rocketLeagueVm = new RocketLeagueViewModel(mainManager) {DisplayName = "Rocket League"};
|
_rocketLeagueVm = new RocketLeagueViewModel(mainManager) {DisplayName = "Rocket League"};
|
||||||
_counterStrikeVm = new CounterStrikeViewModel(mainManager) {DisplayName = "CS:GO"};
|
_counterStrikeVm = new CounterStrikeViewModel(mainManager) {DisplayName = "CS:GO"};
|
||||||
//_dota2Vm = new Dota2ViewModel(MainManager) {DisplayName = "Dota 2 (NYI)"};
|
_dota2Vm = new Dota2ViewModel(mainManager) {DisplayName = "Dota 2"};
|
||||||
_witcher3Vm = new Witcher3ViewModel(mainManager) {DisplayName = "The Witcher 3"};
|
_witcher3Vm = new Witcher3ViewModel(mainManager) {DisplayName = "The Witcher 3"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ namespace Artemis.ViewModels
|
|||||||
|
|
||||||
ActivateItem(_rocketLeagueVm);
|
ActivateItem(_rocketLeagueVm);
|
||||||
ActivateItem(_counterStrikeVm);
|
ActivateItem(_counterStrikeVm);
|
||||||
//ActivateItem(_dota2Vm);
|
ActivateItem(_dota2Vm);
|
||||||
ActivateItem(_witcher3Vm);
|
ActivateItem(_witcher3Vm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user