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>
|
||||
<configSections>
|
||||
<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.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" />
|
||||
@ -22,6 +23,20 @@
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
<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>
|
||||
<setting name="Enabled" serializeAs="String">
|
||||
<value>True</value>
|
||||
|
||||
@ -293,6 +293,14 @@
|
||||
</Compile>
|
||||
<Compile Include="Modules\Games\CounterStrike\CounterStrikeModel.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">
|
||||
<DependentUpon>RocketLeague.settings</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
@ -430,6 +438,7 @@
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<None Include="Modules\Effects\AudioVisualizer\AudioVisualization.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
@ -443,6 +452,10 @@
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>CounterStrike.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Modules\Games\Dota2\Dota2.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Dota2.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Modules\Games\RocketLeague\RocketLeague.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>RocketLeague.Designer.cs</LastGenOutput>
|
||||
@ -465,6 +478,7 @@
|
||||
</Content>
|
||||
<Resource Include="Resources\logo.ico" />
|
||||
<Resource Include="Resources\logo-disabled.ico" />
|
||||
<Resource Include="Resources\Dota2\dotaGamestateConfiguration.txt" />
|
||||
<None Include="Resources\LogitechLED.dll" />
|
||||
<Content Include="Resources\Witcher3\playerWitcher.txt" />
|
||||
<Content Include="Resources\Witcher3\artemis.txt" />
|
||||
@ -559,7 +573,7 @@
|
||||
<Content Include="LogitechLedEnginesWrapper.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Resources\CounterStrike\gamestateConfiguration.txt" />
|
||||
<Content Include="Resources\CounterStrike\csgoGamestateConfiguration.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using Artemis.Utilities;
|
||||
using Corale.Colore.Razer.Keyboard.Effects;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Razer.Utilities
|
||||
@ -11,7 +12,7 @@ namespace Artemis.KeyboardProviders.Razer.Utilities
|
||||
{
|
||||
var keyboardGrid = Custom.Create();
|
||||
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 x = 0; x < b.Width; x++)
|
||||
@ -19,37 +20,5 @@ namespace Artemis.KeyboardProviders.Razer.Utilities
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -44,7 +44,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
return;
|
||||
if (Directory.Exists(((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg"))
|
||||
{
|
||||
var cfgFile = Resources.gamestateConfiguration.Replace("{{port}}",
|
||||
var cfgFile = Resources.csgoGamestateConfiguration.Replace("{{port}}",
|
||||
MainManager.GameStateWebServer.Port.ToString());
|
||||
File.WriteAllText(
|
||||
((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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,11 +3,86 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
d:DesignHeight="424" d:DesignWidth="635">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
|
||||
<Grid>
|
||||
<TextBlock Text="Dota 2 support is still to be done." />
|
||||
<Grid Margin="15, 5, 15, 5">
|
||||
<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>
|
||||
@ -1,4 +1,8 @@
|
||||
using Artemis.Managers;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Properties;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
|
||||
namespace Artemis.Modules.Games.Dota2
|
||||
@ -8,9 +12,62 @@ namespace Artemis.Modules.Games.Dota2
|
||||
public Dota2ViewModel(MainManager mainManager)
|
||||
{
|
||||
MainManager = mainManager;
|
||||
GameSettings = new Dota2Settings();
|
||||
|
||||
GameModel = new Dota2Model(mainManager, (Dota2Settings) GameSettings);
|
||||
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||
PlaceConfigFile();
|
||||
}
|
||||
|
||||
public static string Name => "Dota 2 (NYI)";
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Artemis/Artemis/Properties/Resources.Designer.cs
generated
29
Artemis/Artemis/Properties/Resources.Designer.cs
generated
@ -107,9 +107,34 @@ namespace Artemis.Properties {
|
||||
/// }
|
||||
///}.
|
||||
/// </summary>
|
||||
internal static string gamestateConfiguration {
|
||||
internal static string csgoGamestateConfiguration {
|
||||
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">
|
||||
<value>..\Resources\bow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<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>
|
||||
<data name="csgoGamestateConfiguration" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<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 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>
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
@ -41,7 +41,7 @@ namespace Artemis.Utilities.GameState
|
||||
}
|
||||
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 =>
|
||||
|
||||
@ -78,44 +78,6 @@ namespace Artemis.Utilities
|
||||
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>
|
||||
/// Returns the image codec with the given mime type
|
||||
/// </summary>
|
||||
|
||||
@ -18,7 +18,7 @@ namespace Artemis.ViewModels
|
||||
{
|
||||
_rocketLeagueVm = new RocketLeagueViewModel(mainManager) {DisplayName = "Rocket League"};
|
||||
_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"};
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ namespace Artemis.ViewModels
|
||||
|
||||
ActivateItem(_rocketLeagueVm);
|
||||
ActivateItem(_counterStrikeVm);
|
||||
//ActivateItem(_dota2Vm);
|
||||
ActivateItem(_dota2Vm);
|
||||
ActivateItem(_witcher3Vm);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user