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

Added Mana Health and Day/Night to Dota2 Implementation. CSGO and DOTA will crash with a razer keyboard.

This commit is contained in:
Logan Saso 2016-03-09 21:03:17 -08:00
parent dc40a649e7
commit bfea9edc14
8 changed files with 270 additions and 46 deletions

View File

@ -36,6 +36,18 @@
<setting name="ShowHealth" serializeAs="String"> <setting name="ShowHealth" serializeAs="String">
<value>True</value> <value>True</value>
</setting> </setting>
<setting name="ShowDayCycle" serializeAs="String">
<value>True</value>
</setting>
<setting name="CanCastItem" serializeAs="String">
<value>True</value>
</setting>
<setting name="ShowMana" serializeAs="String">
<value>True</value>
</setting>
<setting name="ShowDead" serializeAs="String">
<value>True</value>
</setting>
</Artemis.Modules.Games.Dota2.Dota2> </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">

View File

@ -74,19 +74,24 @@ namespace Artemis.KeyboardProviders.Corsair
Height = 7; Height = 7;
Width = 24; Width = 24;
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 20))); KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 20)));
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(2, 21), new Point(7, 25)));
break; break;
case "K70 RGB": case "K70 RGB":
Height = 7; Height = 7;
Width = 21; Width = 21;
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 16))); KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 16)));
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(2, 17), new Point(7, 21)));
break; break;
case "K65 RGB": case "K65 RGB":
Height = 7; Height = 7;
Width = 18; Width = 18;
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 16)));
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(2, 17), new Point(7, 21)));
break; break;
case "STRAFE RGB": case "STRAFE RGB":
Height = 7; Height = 7;
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 16))); KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 16)));
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(2, 17), new Point(7, 21)));
Width = 22; Width = 22;
break; break;
} }

View File

@ -16,7 +16,11 @@ namespace Artemis.KeyboardProviders.Logitech
"If needed, you can select a different keyboard in Artemis under settings."; "If needed, you can select a different keyboard in Artemis under settings.";
Height = 6; Height = 6;
Width = 21; Width = 21;
KeyboardRegions = new List<KeyboardRegion> {new KeyboardRegion("TopRow", new Point(0, 0), new Point(0, 16))}; KeyboardRegions = new List<KeyboardRegion>
{
new KeyboardRegion("TopRow", new Point(0, 0), new Point(0, 16)),
new KeyboardRegion("NumPad", new Point(0, 17), new Point(0, 25))
};
} }
public override bool CanEnable() public override bool CanEnable()

View File

@ -70,5 +70,53 @@ namespace Artemis.Modules.Games.Dota2 {
this["ShowHealth"] = value; this["ShowHealth"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool ShowDayCycle {
get {
return ((bool)(this["ShowDayCycle"]));
}
set {
this["ShowDayCycle"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool CanCastItem {
get {
return ((bool)(this["CanCastItem"]));
}
set {
this["CanCastItem"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool ShowMana {
get {
return ((bool)(this["ShowMana"]));
}
set {
this["ShowMana"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool ShowDead {
get {
return ((bool)(this["ShowDead"]));
}
set {
this["ShowDead"] = value;
}
}
} }
} }

View File

@ -14,5 +14,17 @@
<Setting Name="ShowHealth" Type="System.Boolean" Scope="User"> <Setting Name="ShowHealth" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
</Setting> </Setting>
<Setting Name="ShowDayCycle" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="CanCastItem" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="ShowMana" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="ShowDead" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -20,6 +21,7 @@ namespace Artemis.Modules.Games.Dota2
{ {
private KeyboardRegion _topRow; private KeyboardRegion _topRow;
private KeyboardRegion _keyPad;
public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager) public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager)
{ {
Settings = settings; Settings = settings;
@ -35,8 +37,10 @@ namespace Artemis.Modules.Games.Dota2
public Dota2Settings Settings { get; set; } public Dota2Settings Settings { get; set; }
public Dota2DataModel.Rootobject D2Json { get; set; } public Dota2DataModel.Rootobject D2Json { get; set; }
public int Scale { get; set; } public int Scale { get; set; }
public KeyboardRectangle HealthRect { get; set; } public KeyboardRectangle HealthRectangle { get; set; }
public KeyboardRectangle EventRectangle { get; set; }
public KeyboardRectangle DayCycleRectangle { get; set; }
public KeyboardRectangle ManaRectangle { get; set; }
#endregion #endregion
@ -50,10 +54,38 @@ namespace Artemis.Modules.Games.Dota2
{ {
Initialized = false; Initialized = false;
_topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow"); _topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
HealthRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X, _keyPad = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "NumPad");
new List<Color>(), HealthRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
LinearGradientMode.Horizontal) , 0
, _topRow.TopLeft.X
, new List<Color>()
, LinearGradientMode.Horizontal)
{ Height = Scale, ContainedBrush = false }; { Height = Scale, ContainedBrush = false };
ManaRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
, 0
, _topRow.TopLeft.X+1
, new List<Color>()
, LinearGradientMode.Horizontal)
{ Height = Scale, ContainedBrush = false };
EventRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
, 0
, _topRow.TopLeft.X + 2
, new List<Color>()
, LinearGradientMode.Horizontal )
{Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale
, Width = MainManager.KeyboardManager.ActiveKeyboard.Width*Scale-Scale-12};
DayCycleRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
, _keyPad.BottomRight.X * 3
, _keyPad.TopLeft.X
, new List<Color>()
, LinearGradientMode.Horizontal)
{
Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale,
Width = MainManager.KeyboardManager.ActiveKeyboard.Width - (MainManager.KeyboardManager.ActiveKeyboard.Width * Scale - Scale - 12)
};
MainManager.GameStateWebServer.GameDataReceived += HandleGameData; MainManager.GameStateWebServer.GameDataReceived += HandleGameData;
Initialized = true; Initialized = true;
} }
@ -63,41 +95,90 @@ namespace Artemis.Modules.Games.Dota2
if (D2Json == null) if (D2Json == null)
return; return;
if (Settings.ShowDead)
UpdateDead();
if (Settings.CanCastAbility) if (Settings.CanCastAbility)
UpdateAbilities(); UpdateAbilities();
if (Settings.ShowHealth) if (Settings.ShowHealth)
UpdateHealth(); UpdateHealth();
/* if (Settings.ShowDayCycle)
* if (Settings.ShowDayCycle) UpdateDay();
* UpdateDay(); if (Settings.ShowMana)
* if (Settings.ShowMana) //Not sure if this is in the Json. Will check when I get home UpdateMana();
* UpdateMana(); if (Settings.CanCastItem)
* if (Settings.CanCastItems) UpdateItems();
* UpdateItems();
* if (Settings.) //Add something
*/
} }
private void UpdateHealth() private void UpdateDead()
{ {
var health = D2Json.hero.health_percent; if (D2Json?.hero?.alive == null)
if(health > 66) return;
HealthRect.Colors = new List<Color> { Color.Lime };
else if (health > 33) EventRectangle.Colors = D2Json.hero.alive ? new List<Color> { Color.Lime } : new List<Color> {Color.LightGray};
HealthRect.Colors = new List<Color> {Color.Yellow}; }
else
HealthRect.Colors = new List<Color> {Color.Red}; private void UpdateDay()
{
if (D2Json?.map?.daytime == null)
return;
if (D2Json.map.nightstalker_night)
{
DayCycleRectangle.Colors = new List<Color> { Color.Blue };
return;
}
var timeLeft = 240 - (D2Json.map.clock_time % 240);
double width = (int) ((MainManager.KeyboardManager.ActiveKeyboard.Width*Scale - (MainManager.KeyboardManager.ActiveKeyboard.Width * Scale - Scale*Scale)) * (timeLeft/240D)) ;
DayCycleRectangle.Width = (int) (width/2) > 1 ? (int)(width / 2)+1 : (int)(width / 2);
DayCycleRectangle.Colors = D2Json.map.daytime ? new List<Color> { Color.Yellow } : new List<Color> { Color.Blue };
}
private void UpdateMana()
{
if (D2Json?.hero == null || D2Json.hero.mana_percent == -1)
return;
var manaPercent = D2Json.hero.mana_percent;
ManaRectangle.Colors = new List<Color> {Color.Blue};
ManaRectangle.Width = (int)Math.Floor(_topRow.BottomRight.Y / 100.00 * manaPercent) * Scale;
}
private void UpdateItems()
{
//throw new NotImplementedException();
} }
private void UpdateAbilities() private void UpdateAbilities()
{ {
Console.WriteLine(); //Console.WriteLine();
//Update keys according to the abilities they take. //Update keys according to the abilities they take.
} }
private void UpdateHealth()
{
if (D2Json?.hero == null || D2Json.hero.health_percent == -1)
return;
var healthPercent = D2Json.hero.health_percent;
if(healthPercent > 66)
HealthRectangle.Colors = new List<Color> { Color.Lime };
else if (healthPercent > 33)
HealthRectangle.Colors = new List<Color> {Color.Yellow};
else
HealthRectangle.Colors = new List<Color> {Color.Red};
HealthRectangle.Width = (int)Math.Floor(_topRow.BottomRight.Y / 100.00 * healthPercent) * Scale;
}
public override Bitmap GenerateBitmap() public override Bitmap GenerateBitmap()
{ {
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale); var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
@ -105,7 +186,11 @@ namespace Artemis.Modules.Games.Dota2
using (var g = Graphics.FromImage(bitmap)) using (var g = Graphics.FromImage(bitmap))
{ {
g.Clear(Color.Transparent); g.Clear(Color.Transparent);
HealthRect.Draw(g); EventRectangle.Draw(g);
HealthRectangle.Draw(g);
ManaRectangle.Draw(g);
DayCycleRectangle.Draw(g);
} }
return bitmap; return bitmap;
} }

View File

@ -20,6 +20,10 @@ namespace Artemis.Modules.Games.Dota2
public string GameDirectory { get; set; } public string GameDirectory { get; set; }
public bool CanCastAbility { get; set; } public bool CanCastAbility { get; set; }
public bool ShowHealth { get; set; } public bool ShowHealth { get; set; }
public bool ShowDayCycle { get; set; }
public bool CanCastItem { get; set; }
public bool ShowMana { get; set; }
public bool ShowDead { get; set; }
#endregion #endregion
@ -29,24 +33,39 @@ namespace Artemis.Modules.Games.Dota2
CanCastAbility = Dota2.Default.CanCastAbility; CanCastAbility = Dota2.Default.CanCastAbility;
Enabled = Dota2.Default.Enabled; Enabled = Dota2.Default.Enabled;
GameDirectory = Dota2.Default.GameDirectory; GameDirectory = Dota2.Default.GameDirectory;
CanCastItem = Dota2.Default.CanCastItem;
ShowDayCycle = Dota2.Default.ShowDayCycle;
ShowMana = Dota2.Default.ShowMana;
ShowDead = Dota2.Default.ShowDead;
} }
public override void Save() public override void Save()
{ {
Dota2.Default.ShowDayCycle = ShowDayCycle;
Dota2.Default.ShowHealth = ShowHealth; Dota2.Default.ShowHealth = ShowHealth;
Dota2.Default.CanCastAbility = CanCastAbility; Dota2.Default.CanCastAbility = CanCastAbility;
Dota2.Default.Enabled = Enabled; Dota2.Default.Enabled = Enabled;
Dota2.Default.GameDirectory = GameDirectory; Dota2.Default.GameDirectory = GameDirectory;
Dota2.Default.CanCastItem = CanCastItem;
Dota2.Default.ShowMana = ShowMana;
Dota2.Default.ShowDead = ShowDead;
Dota2.Default.Save(); Dota2.Default.Save();
} }
public override void ToDefault() public override void ToDefault()
{ {
ShowHealth = true;
CanCastAbility = true;
Enabled = false; Enabled = false;
GameDirectory = string.Empty; GameDirectory = string.Empty;
ShowHealth = true;
CanCastAbility = true;
ShowDayCycle = true;
CanCastItem = true;
ShowMana = true;
ShowDead = true;
} }
} }
} }

View File

@ -57,29 +57,68 @@
</StackPanel> </StackPanel>
<!-- Abilities Display --> <!-- Abilities Display -->
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center" <TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Height="16" Margin="0,10,0,9"> Height="16" Margin="0,10,0,9">
Show abilities that can be cast. Show abilities that can be cast.
</TextBlock> </TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.CanCastAbility, Mode=TwoWay}" <controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.CanCastAbility, Mode=TwoWay}"
Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" /> Margin="0,0,-5,0" Width="114" />
<!-- Items Display -->
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Height="16" Margin="0,10,0,9">
Show items that can be cast.
</TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.CanCastItem, Mode=TwoWay}"
Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" />
<!-- Health Display --> <!-- Health Display -->
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center" <TextBlock Grid.Row="4" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Height="16" Margin="0,10,0,9"> Height="16" Margin="0,10,0,9">
Show health on F-Keys. Show health on F-Keys.
</TextBlock> </TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ShowHealth, Mode=TwoWay}" <controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ShowHealth, Mode=TwoWay}"
Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" /> Margin="0,0,-5,0" Width="114" />
<StackPanel Grid.Column="0" Grid.Row="9" Orientation="Horizontal" VerticalAlignment="Bottom"> <!-- Mana Display-->
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100" <TextBlock Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Style="{DynamicResource SquareButtonStyle}" /> Height="16" Margin="0,10,0,9">
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100" Show mana on the number keys.
Margin="10,0,0,0" </TextBlock>
Style="{DynamicResource SquareButtonStyle}" /> <controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ShowMana, Mode=TwoWay}"
Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" />
<!-- Daytime Display -->
<TextBlock Grid.Row="6" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Height="16" Margin="0,10,0,9">
Show day/night cycle.
</TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ShowDayCycle, Mode=TwoWay}"
Grid.Row="6" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes" OffLabel="No"
Margin="0,0,-5,0" Width="114" />
<!-- Dead Display -->
<TextBlock Grid.Row="7" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
Height="16" Margin="0,10,0,9">
Turn grey when dead.
</TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ShowDead, Mode=TwoWay}"
Grid.Row="7" 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> </StackPanel>