1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Added The Division skeleton code, Dota2 Logitech fixes

This commit is contained in:
SpoinkyNL 2016-03-10 11:17:16 +01:00
parent 96eb3c1e6a
commit c61908f36b
14 changed files with 312 additions and 57 deletions

View File

@ -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.TheDivision.TheDivision" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<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" />
@ -23,6 +24,11 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<userSettings>
<Artemis.Modules.Games.TheDivision.TheDivision>
<setting name="Enabled" serializeAs="String">
<value>True</value>
</setting>
</Artemis.Modules.Games.TheDivision.TheDivision>
<Artemis.Modules.Games.Dota2.Dota2>
<setting name="Enabled" serializeAs="String">
<value>True</value>

View File

@ -314,6 +314,17 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Modules\Games\RocketLeague\RocketLeagueModel.cs" />
<Compile Include="Modules\Games\TheDivision\TheDivision.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>TheDivision.settings</DependentUpon>
</Compile>
<Compile Include="Modules\Games\TheDivision\TheDivisionModel.cs" />
<Compile Include="Modules\Games\TheDivision\TheDivisionSettings.cs" />
<Compile Include="Modules\Games\TheDivision\TheDivisionView.xaml.cs">
<DependentUpon>TheDivisionView.xaml</DependentUpon>
</Compile>
<Compile Include="Modules\Games\TheDivision\TheDivisionViewModel.cs" />
<Compile Include="Modules\Games\Witcher3\Witcher3Settings.cs" />
<Compile Include="Modules\Games\Witcher3\Witcher3.Designer.cs">
<AutoGen>True</AutoGen>
@ -466,6 +477,10 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>RocketLeague.Designer.cs</LastGenOutput>
</None>
<None Include="Modules\Games\TheDivision\TheDivision.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>TheDivision.Designer.cs</LastGenOutput>
</None>
<None Include="Modules\Games\Witcher3\Witcher3.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Witcher3.Designer.cs</LastGenOutput>
@ -506,6 +521,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Modules\Games\TheDivision\TheDivisionView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resources\Icons.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>

View File

@ -14,5 +14,7 @@ namespace Artemis.KeyboardProviders
public string RegionName { get; set; }
public Point TopLeft { get; set; }
public Point BottomRight { get; set; }
public Rectangle GetRectangle() => new Rectangle(TopLeft.X, TopLeft.Y, BottomRight.X - TopLeft.X, BottomRight.Y - TopLeft.Y);
}
}

View File

@ -18,8 +18,8 @@ namespace Artemis.KeyboardProviders.Logitech
Width = 21;
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))
new KeyboardRegion("TopRow", new Point(0, 0), new Point(16, 0)),
new KeyboardRegion("NumPad", new Point(17, 1), new Point(21, 6))
};
}

View File

@ -2,27 +2,23 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Artemis.KeyboardProviders;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Utilities;
using Artemis.Utilities.GameState;
using Artemis.Utilities.Keyboard;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Artemis.Modules.Games.Dota2;
using Artemis.Utilities;
namespace Artemis.Modules.Games.Dota2
{
class Dota2Model : GameModel
internal class Dota2Model : GameModel
{
private KeyboardRegion _keyPad;
private KeyboardRegion _topRow;
private KeyboardRegion _keyPad;
public Dota2Model(MainManager mainManager, Dota2Settings settings) : base(mainManager)
{
Settings = settings;
@ -33,17 +29,6 @@ namespace Artemis.Modules.Games.Dota2
Scale = 4;
}
#region Variables
public Dota2Settings Settings { get; set; }
public Dota2DataModel.Rootobject D2Json { get; set; }
public int Scale { get; set; }
public KeyboardRectangle HealthRectangle { get; set; }
public KeyboardRectangle EventRectangle { get; set; }
public KeyboardRectangle DayCycleRectangle { get; set; }
public KeyboardRectangle ManaRectangle { get; set; }
#endregion
public override void Dispose()
{
@ -58,34 +43,37 @@ namespace Artemis.Modules.Games.Dota2
_keyPad = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "NumPad");
HealthRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
, 0
, _topRow.TopLeft.X
, _topRow.BottomRight.Y*Scale
, new List<Color>()
, LinearGradientMode.Horizontal)
{ Height = Scale, ContainedBrush = false };
{Height = Scale, ContainedBrush = false};
ManaRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard
, 0
, _topRow.TopLeft.X+1
, (_topRow.BottomRight.Y + 1)*Scale
, new List<Color>()
, LinearGradientMode.Horizontal)
{ Height = Scale, ContainedBrush = false };
{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};
, 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
, _keyPad.TopLeft.X*Scale
, _keyPad.TopLeft.Y*Scale
, new List<Color>()
, LinearGradientMode.Horizontal)
{
Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale,
Width = MainManager.KeyboardManager.ActiveKeyboard.Width - (MainManager.KeyboardManager.ActiveKeyboard.Width * Scale - Scale - 12)
Height = _keyPad.GetRectangle().Height*Scale,
Width = _keyPad.GetRectangle().Width*Scale
};
MainManager.GameStateWebServer.GameDataReceived += HandleGameData;
Initialized = true;
@ -112,14 +100,11 @@ namespace Artemis.Modules.Games.Dota2
UpdateMana();
if (Settings.CanCastItem)
UpdateItems();
}
private void UpdateMainColor()
{
var list = new List<Color> { ColorHelpers.ToDrawingColor(Settings.MainColor) };
var list = new List<Color> {ColorHelpers.ToDrawingColor(Settings.MainColor)};
EventRectangle.Colors = list;
DayCycleRectangle.Colors = list;
HealthRectangle.Colors = list;
@ -128,31 +113,31 @@ namespace Artemis.Modules.Games.Dota2
private void UpdateLifeStatus()
{
var list = new List<Color> { Color.LightGray };
var list = new List<Color> {Color.LightGray};
EventRectangle.Colors = list;
DayCycleRectangle.Colors = list;
HealthRectangle.Colors = list;
ManaRectangle.Colors = list;
}
private void UpdateDay()
{
if (D2Json?.map?.daytime == null)
return;
if (D2Json.map.nightstalker_night)
{
DayCycleRectangle.Colors = new List<Color> { Color.Blue };
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 };
var timeLeft = 240 - D2Json.map.clock_time%240;
var timePercentage = 100.00/240*timeLeft;
var test = _keyPad.GetRectangle().Width;
DayCycleRectangle.Width = (int) (_keyPad.GetRectangle().Width*Scale/100.00*timePercentage);
DayCycleRectangle.Colors = D2Json.map.daytime
? new List<Color> {Color.Yellow}
: new List<Color> {Color.Blue};
}
private void UpdateMana()
@ -161,8 +146,8 @@ namespace Artemis.Modules.Games.Dota2
return;
var manaPercent = D2Json.hero.mana_percent;
ManaRectangle.Colors = new List<Color> { ColorHelpers.ToDrawingColor(Settings.ManaColor) };
ManaRectangle.Width = (int)Math.Floor(_topRow.BottomRight.Y / 100.00 * manaPercent) * Scale;
ManaRectangle.Colors = new List<Color> {ColorHelpers.ToDrawingColor(Settings.ManaColor)};
ManaRectangle.Width = (int) Math.Floor(_topRow.GetRectangle().Width*Scale/100.00*manaPercent);
}
private void UpdateItems()
@ -172,7 +157,6 @@ namespace Artemis.Modules.Games.Dota2
private void UpdateAbilities()
{
//Console.WriteLine();
//Update keys according to the abilities they take.
@ -185,15 +169,14 @@ namespace Artemis.Modules.Games.Dota2
return;
var healthPercent = D2Json.hero.health_percent;
if(healthPercent > 66)
HealthRectangle.Colors = new List<Color> { Color.Lime };
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;
HealthRectangle.Width = (int) Math.Floor(_topRow.GetRectangle().Width*Scale/100.00*healthPercent);
}
@ -208,13 +191,11 @@ namespace Artemis.Modules.Games.Dota2
HealthRectangle.Draw(g);
ManaRectangle.Draw(g);
DayCycleRectangle.Draw(g);
}
return bitmap;
}
public void HandleGameData(object sender, GameDataReceivedEventArgs e)
{
var jsonString = e.Json.ToString();
@ -226,5 +207,17 @@ namespace Artemis.Modules.Games.Dota2
// Parse the JSON
D2Json = JsonConvert.DeserializeObject<Dota2DataModel.Rootobject>(jsonString);
}
#region Variables
public Dota2Settings Settings { get; set; }
public Dota2DataModel.Rootobject D2Json { get; set; }
public int Scale { get; set; }
public KeyboardRectangle HealthRectangle { get; set; }
public KeyboardRectangle EventRectangle { get; set; }
public KeyboardRectangle DayCycleRectangle { get; set; }
public KeyboardRectangle ManaRectangle { get; set; }
#endregion
}
}
}

View File

@ -0,0 +1,38 @@
//------------------------------------------------------------------------------
// <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.TheDivision {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class TheDivision : global::System.Configuration.ApplicationSettingsBase {
private static TheDivision defaultInstance = ((TheDivision)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new TheDivision())));
public static TheDivision 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;
}
}
}
}

View File

@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Artemis.Modules.Games.TheDivision" GeneratedClassName="TheDivision">
<Profiles />
<Settings>
<Setting Name="Enabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -0,0 +1,51 @@
using System.Drawing;
using Artemis.Managers;
using Artemis.Models;
namespace Artemis.Modules.Games.TheDivision
{
public class TheDivisionModel : GameModel
{
public TheDivisionModel(MainManager mainManager, TheDivisionSettings settings) : base(mainManager)
{
Settings = settings;
Name = "TheDivision";
ProcessName = "TheDivision";
Scale = 4;
Enabled = Settings.Enabled;
Initialized = false;
}
public TheDivisionSettings Settings { get; set; }
public int Scale { get; set; }
public override void Dispose()
{
Initialized = false;
}
public override void Enable()
{
Initialized = false;
// Enable logic, if any
Initialized = true;
}
public override void Update()
{
}
public override Bitmap GenerateBitmap()
{
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
}
return bitmap;
}
}
}

View File

@ -0,0 +1,29 @@
using Artemis.Models;
namespace Artemis.Modules.Games.TheDivision
{
public class TheDivisionSettings : GameSettings
{
public TheDivisionSettings()
{
Load();
}
public sealed override void Load()
{
Enabled = TheDivision.Default.Enabled;
}
public sealed override void Save()
{
TheDivision.Default.Enabled = Enabled;
TheDivision.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
}
}
}

View File

@ -0,0 +1,54 @@
<UserControl x:Class="Artemis.Modules.Games.TheDivision.TheDivisionView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:Artemis.Modules.Games.TheDivision"
xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d"
d:DesignHeight="416.495" d:DesignWidth="553.608">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<Grid Margin="15, 5, 15, 5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
<Label FontSize="20" HorizontalAlignment="Left">
<Label.Content>
<AccessText TextWrapping="Wrap"
Text="Shows lots of things, I should change this." />
</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>
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
Foreground="{DynamicResource HighlightBrush}" MaxWidth="510" TextAlignment="Justify">
Note: For this game to work with Artemis, please enable ... in The Division settings.
</TextBlock>
<!-- Buttons -->
<StackPanel Grid.Column="0" Grid.Row="4" 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

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Artemis.Modules.Games.TheDivision
{
/// <summary>
/// Interaction logic for TheDivisionView.xaml
/// </summary>
public partial class TheDivisionView : UserControl
{
public TheDivisionView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,22 @@
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.TheDivision
{
public class TheDivisionViewModel : GameViewModel
{
public TheDivisionViewModel(MainManager mainManager)
{
MainManager = mainManager;
// Settings are loaded from file by class
GameSettings = new TheDivisionSettings();
// Create effect model and add it to MainManager
GameModel = new TheDivisionModel(mainManager, (TheDivisionSettings) GameSettings);
MainManager.EffectManager.EffectModels.Add(GameModel);
}
public static string Name => "The Division";
}
}

View File

@ -33,8 +33,8 @@ namespace Artemis.Utilities.Keyboard
_blinkWorker.DoWork += BlinkWorker_DoWork;
Scale = 4;
X = x*Scale;
Y = y*Scale;
X = x;
Y = y;
Width = keyboard.Width*Scale;
Height = keyboard.Height*Scale;
Visible = true;

View File

@ -2,6 +2,7 @@
using Artemis.Modules.Games.CounterStrike;
using Artemis.Modules.Games.Dota2;
using Artemis.Modules.Games.RocketLeague;
using Artemis.Modules.Games.TheDivision;
using Artemis.Modules.Games.Witcher3;
using Caliburn.Micro;
@ -13,6 +14,7 @@ namespace Artemis.ViewModels
private readonly Dota2ViewModel _dota2Vm;
private readonly RocketLeagueViewModel _rocketLeagueVm;
private readonly Witcher3ViewModel _witcher3Vm;
private readonly TheDivisionViewModel _divisionVm;
public GamesViewModel(MainManager mainManager)
{
@ -20,6 +22,7 @@ namespace Artemis.ViewModels
_counterStrikeVm = new CounterStrikeViewModel(mainManager) {DisplayName = "CS:GO"};
_dota2Vm = new Dota2ViewModel(mainManager) {DisplayName = "Dota 2"};
_witcher3Vm = new Witcher3ViewModel(mainManager) {DisplayName = "The Witcher 3"};
_divisionVm = new TheDivisionViewModel(mainManager) {DisplayName = "The Division"};
}
protected override void OnActivate()
@ -30,6 +33,7 @@ namespace Artemis.ViewModels
ActivateItem(_counterStrikeVm);
ActivateItem(_dota2Vm);
ActivateItem(_witcher3Vm);
ActivateItem(_divisionVm);
}
}
}