mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +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:
parent
dc40a649e7
commit
bfea9edc14
@ -36,6 +36,18 @@
|
||||
<setting name="ShowHealth" serializeAs="String">
|
||||
<value>True</value>
|
||||
</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.Overlays.VolumeDisplay.VolumeDisplay>
|
||||
<setting name="Enabled" serializeAs="String">
|
||||
|
||||
@ -74,19 +74,24 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
Height = 7;
|
||||
Width = 24;
|
||||
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;
|
||||
case "K70 RGB":
|
||||
Height = 7;
|
||||
Width = 21;
|
||||
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;
|
||||
case "K65 RGB":
|
||||
Height = 7;
|
||||
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;
|
||||
case "STRAFE RGB":
|
||||
Height = 7;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -16,7 +16,11 @@ namespace Artemis.KeyboardProviders.Logitech
|
||||
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||
Height = 6;
|
||||
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()
|
||||
|
||||
@ -70,5 +70,53 @@ namespace Artemis.Modules.Games.Dota2 {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,5 +14,17 @@
|
||||
<Setting Name="ShowHealth" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</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>
|
||||
</SettingsFile>
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -20,6 +21,7 @@ namespace Artemis.Modules.Games.Dota2
|
||||
{
|
||||
|
||||
private KeyboardRegion _topRow;
|
||||
private KeyboardRegion _keyPad;
|
||||
public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager)
|
||||
{
|
||||
Settings = settings;
|
||||
@ -35,8 +37,10 @@ namespace Artemis.Modules.Games.Dota2
|
||||
public Dota2Settings Settings { get; set; }
|
||||
public Dota2DataModel.Rootobject D2Json { 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
|
||||
|
||||
|
||||
@ -50,10 +54,38 @@ namespace Artemis.Modules.Games.Dota2
|
||||
{
|
||||
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)
|
||||
_keyPad = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "NumPad");
|
||||
HealthRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
|
||||
, 0
|
||||
, _topRow.TopLeft.X
|
||||
, new List<Color>()
|
||||
, LinearGradientMode.Horizontal)
|
||||
{ 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;
|
||||
Initialized = true;
|
||||
}
|
||||
@ -63,41 +95,90 @@ namespace Artemis.Modules.Games.Dota2
|
||||
if (D2Json == null)
|
||||
return;
|
||||
|
||||
if (Settings.ShowDead)
|
||||
UpdateDead();
|
||||
if (Settings.CanCastAbility)
|
||||
UpdateAbilities();
|
||||
if (Settings.ShowHealth)
|
||||
UpdateHealth();
|
||||
/*
|
||||
* if (Settings.ShowDayCycle)
|
||||
* UpdateDay();
|
||||
* if (Settings.ShowMana) //Not sure if this is in the Json. Will check when I get home
|
||||
* UpdateMana();
|
||||
* if (Settings.CanCastItems)
|
||||
* UpdateItems();
|
||||
* if (Settings.) //Add something
|
||||
*/
|
||||
if (Settings.ShowDayCycle)
|
||||
UpdateDay();
|
||||
if (Settings.ShowMana)
|
||||
UpdateMana();
|
||||
if (Settings.CanCastItem)
|
||||
UpdateItems();
|
||||
|
||||
}
|
||||
|
||||
private void UpdateHealth()
|
||||
private void UpdateDead()
|
||||
{
|
||||
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};
|
||||
|
||||
if (D2Json?.hero?.alive == null)
|
||||
return;
|
||||
|
||||
EventRectangle.Colors = D2Json.hero.alive ? new List<Color> { Color.Lime } : new List<Color> {Color.LightGray};
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
Console.WriteLine();
|
||||
//Console.WriteLine();
|
||||
|
||||
//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()
|
||||
{
|
||||
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||
@ -105,7 +186,11 @@ namespace Artemis.Modules.Games.Dota2
|
||||
using (var g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
g.Clear(Color.Transparent);
|
||||
HealthRect.Draw(g);
|
||||
EventRectangle.Draw(g);
|
||||
HealthRectangle.Draw(g);
|
||||
ManaRectangle.Draw(g);
|
||||
DayCycleRectangle.Draw(g);
|
||||
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@ -20,6 +20,10 @@ namespace Artemis.Modules.Games.Dota2
|
||||
public string GameDirectory { get; set; }
|
||||
public bool CanCastAbility { 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
|
||||
|
||||
|
||||
@ -29,24 +33,39 @@ namespace Artemis.Modules.Games.Dota2
|
||||
CanCastAbility = Dota2.Default.CanCastAbility;
|
||||
Enabled = Dota2.Default.Enabled;
|
||||
GameDirectory = Dota2.Default.GameDirectory;
|
||||
CanCastItem = Dota2.Default.CanCastItem;
|
||||
ShowDayCycle = Dota2.Default.ShowDayCycle;
|
||||
ShowMana = Dota2.Default.ShowMana;
|
||||
ShowDead = Dota2.Default.ShowDead;
|
||||
}
|
||||
|
||||
public override void Save()
|
||||
{
|
||||
Dota2.Default.ShowDayCycle = ShowDayCycle;
|
||||
Dota2.Default.ShowHealth = ShowHealth;
|
||||
Dota2.Default.CanCastAbility = CanCastAbility;
|
||||
Dota2.Default.Enabled = Enabled;
|
||||
Dota2.Default.GameDirectory = GameDirectory;
|
||||
Dota2.Default.CanCastItem = CanCastItem;
|
||||
Dota2.Default.ShowMana = ShowMana;
|
||||
Dota2.Default.ShowDead = ShowDead;
|
||||
|
||||
Dota2.Default.Save();
|
||||
}
|
||||
|
||||
public override void ToDefault()
|
||||
{
|
||||
ShowHealth = true;
|
||||
CanCastAbility = true;
|
||||
|
||||
Enabled = false;
|
||||
GameDirectory = string.Empty;
|
||||
|
||||
ShowHealth = true;
|
||||
CanCastAbility = true;
|
||||
ShowDayCycle = true;
|
||||
CanCastItem = true;
|
||||
ShowMana = true;
|
||||
ShowDead = true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,29 +57,68 @@
|
||||
</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 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"
|
||||
<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" />
|
||||
|
||||
|
||||
<!-- 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 -->
|
||||
<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 Grid.Row="4" 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"
|
||||
<controls:ToggleSwitch IsChecked="{Binding Path=GameSettings.ShowHealth, Mode=TwoWay}"
|
||||
Grid.Row="4" 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}" />
|
||||
|
||||
<!-- Mana Display-->
|
||||
<TextBlock Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left" Width="168" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,10,0,9">
|
||||
Show mana on the number keys.
|
||||
</TextBlock>
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user