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

Added much more dota support

This commit is contained in:
Logan Saso 2016-03-08 23:36:36 -08:00
parent 1db97b73cb
commit dcd88331f6
13 changed files with 332 additions and 164 deletions

View File

@ -30,6 +30,12 @@
<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">

View File

@ -435,6 +435,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>
@ -474,6 +475,7 @@
</Content>
<Resource Include="Resources\logo.ico" />
<Resource Include="Resources\logo-disabled.ico" />
<Resource Include="Resources\Dota2\dotaGamestateConfiguration.txt" />
<Content Include="Resources\Witcher3\playerWitcher.txt" />
<Content Include="Resources\Witcher3\artemis.txt" />
<Resource Include="Resources\Entypo.ttf" />
@ -567,7 +569,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">

View File

@ -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",

View File

@ -46,5 +46,29 @@ namespace Artemis.Modules.Games.Dota2 {
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;
}
}
}
}

View File

@ -8,5 +8,11 @@
<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>

View File

@ -1,12 +1,15 @@
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;
@ -14,6 +17,8 @@ namespace Artemis.Modules.Games.Dota2
{
class Dota2Model : GameModel
{
private KeyboardRegion _topRow;
public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager)
{
Settings = settings;
@ -29,6 +34,8 @@ namespace Artemis.Modules.Games.Dota2
public Dota2Settings Settings { get; set; }
public JObject D2Json { get; set; }
public int Scale { get; set; }
public KeyboardRectangle HealthRect { get; set; }
#endregion
@ -41,14 +48,41 @@ namespace Artemis.Modules.Games.Dota2
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()
{
throw new NotImplementedException();
if (D2Json == null)
return;
if (Settings.CanCastAbility)
UpdateAbilities();
if (Settings.ShowHealth)
UpdateHealth();
}
private void UpdateHealth()
{
var health = D2Json["hero"]["health_percent"];
if((int)health > 66)
HealthRect.Colors = new List<Color> { Color.Lime };
else if ((int) health > 33)
HealthRect.Colors = new List<Color> {Color.Yellow};
else
HealthRect.Colors = new List<Color> {Color.Red};
}
private void UpdateAbilities()
{
//Update keys according to the abilities they take.
}
public override Bitmap GenerateBitmap()
@ -58,16 +92,18 @@ namespace Artemis.Modules.Games.Dota2
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 CS:GO JSON
// Ensure it's Dota 2 JSON
if (!jsonString.Contains("Dota 2"))
return;

View File

@ -18,23 +18,31 @@ namespace Artemis.Modules.Games.Dota2
#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;
}
public override void ToDefault()
{
ShowHealth = true;
CanCastAbility = true;
Enabled = false;
GameDirectory = string.Empty;
}

View File

@ -4,6 +4,7 @@
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="424" d:DesignWidth="635">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
@ -54,6 +55,34 @@
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>

View File

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Windows.Forms;
using Artemis.Managers;
using Artemis.Properties;
@ -39,13 +40,24 @@ namespace Artemis.Modules.Games.Dota2
{
if (((Dota2Settings)GameSettings).GameDirectory == string.Empty)
return;
if (Directory.Exists(((Dota2Settings)GameSettings).GameDirectory + "/dota2/cfg"))
if (Directory.Exists(((Dota2Settings)GameSettings).GameDirectory + "/game/dota/cfg"))
{
var cfgFile = Resources.gamestateConfiguration.Replace("{{port}}",
var cfgFile = Resources.dotaGamestateConfiguration.Replace("{{port}}",
MainManager.GameStateWebServer.Port.ToString());
try
{
File.WriteAllText(
((Dota2Settings)GameSettings).GameDirectory + "/dota2/cfg/gamestate_integration_artemis.cfg",
((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;
}

View File

@ -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 &quot;Artemis&quot;
///{
/// &quot;uri&quot; &quot;http://localhost:4000/&quot;
/// &quot;timeout&quot; &quot;5.0&quot;
/// &quot;buffer&quot; &quot;0.1&quot;
/// &quot;throttle&quot; &quot;0.1&quot;
/// &quot;heartbeat&quot; &quot;30.0&quot;
/// &quot;data&quot;
/// {
/// &quot;provider&quot; &quot;1&quot;
/// &quot;map&quot; &quot;1&quot;
/// &quot;player&quot; &quot;1&quot;
/// &quot;hero&quot; &quot;1&quot;
/// &quot;abilities&quot; &quot;1&quot;
/// &quot;items&quot; &quot;1&quot;
/// }
///}.
/// </summary>
internal static string dotaGamestateConfiguration {
get {
return ResourceManager.GetString("dotaGamestateConfiguration", resourceCulture);
}
}

View File

@ -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="logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logo.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>

View File

@ -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"
}
}