mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Basic CS:GO support
This commit is contained in:
parent
baa5b10d5c
commit
dd52793ed7
@ -4,6 +4,7 @@
|
|||||||
<configSections>
|
<configSections>
|
||||||
<sectionGroup name="userSettings"
|
<sectionGroup name="userSettings"
|
||||||
type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<section name="Artemis.Settings.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
<section name="Artemis.Settings.VolumeDisplay" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
<section name="Artemis.Settings.VolumeDisplay" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
<section name="Artemis.Settings.AudioVisualization"
|
<section name="Artemis.Settings.AudioVisualization"
|
||||||
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
||||||
@ -26,6 +27,11 @@
|
|||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||||
</startup>
|
</startup>
|
||||||
<userSettings>
|
<userSettings>
|
||||||
|
<Artemis.Settings.CounterStrike>
|
||||||
|
<setting name="GameDirectory" serializeAs="String">
|
||||||
|
<value>C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive</value>
|
||||||
|
</setting>
|
||||||
|
</Artemis.Settings.CounterStrike>
|
||||||
<Artemis.Settings.VolumeDisplay>
|
<Artemis.Settings.VolumeDisplay>
|
||||||
<setting name="MainColor" serializeAs="String">
|
<setting name="MainColor" serializeAs="String">
|
||||||
<value>#FFFF2900</value>
|
<value>#FFFF2900</value>
|
||||||
|
|||||||
@ -192,6 +192,11 @@
|
|||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
<DependentUpon>AudioVisualization.settings</DependentUpon>
|
<DependentUpon>AudioVisualization.settings</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Settings\CounterStrike.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
<DependentUpon>CounterStrike.settings</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Settings\General.Designer.cs">
|
<Compile Include="Settings\General.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
@ -217,7 +222,6 @@
|
|||||||
<Compile Include="Utilities\ColorHelpers.cs" />
|
<Compile Include="Utilities\ColorHelpers.cs" />
|
||||||
<Compile Include="Utilities\GameSense\GameDataReceivedEventArgs.cs" />
|
<Compile Include="Utilities\GameSense\GameDataReceivedEventArgs.cs" />
|
||||||
<Compile Include="Utilities\GameSense\GameSenseWebServer.cs" />
|
<Compile Include="Utilities\GameSense\GameSenseWebServer.cs" />
|
||||||
<Compile Include="Utilities\GameSense\JsonModels\CounterStrikeJson.cs" />
|
|
||||||
<Compile Include="Utilities\Memory\Memory.cs" />
|
<Compile Include="Utilities\Memory\Memory.cs" />
|
||||||
<Compile Include="Utilities\Memory\MemoryHelpers.cs" />
|
<Compile Include="Utilities\Memory\MemoryHelpers.cs" />
|
||||||
<Compile Include="Utilities\Memory\Win32.cs" />
|
<Compile Include="Utilities\Memory\Win32.cs" />
|
||||||
@ -291,6 +295,10 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<AppDesigner Include="Properties\" />
|
<AppDesigner Include="Properties\" />
|
||||||
|
<None Include="Settings\CounterStrike.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>CounterStrike.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
<None Include="Settings\VolumeDisplay.settings">
|
<None Include="Settings\VolumeDisplay.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>VolumeDisplay.Designer.cs</LastGenOutput>
|
<LastGenOutput>VolumeDisplay.Designer.cs</LastGenOutput>
|
||||||
|
|||||||
@ -5,9 +5,9 @@ using System.Drawing.Drawing2D;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
using Artemis.Utilities.GameSense;
|
using Artemis.Utilities.GameSense;
|
||||||
using Artemis.Utilities.GameSense.JsonModels;
|
|
||||||
using Artemis.Utilities.Keyboard;
|
using Artemis.Utilities.Keyboard;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace Artemis.Modules.Games.CounterStrike
|
namespace Artemis.Modules.Games.CounterStrike
|
||||||
{
|
{
|
||||||
@ -23,13 +23,17 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
ProcessName = "csgo";
|
ProcessName = "csgo";
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
|
|
||||||
AmmoRect = new KeyboardRectangle(Scale, 0, 0, 84, 24, new List<Color> {Color.Blue, Color.Red},
|
AmmoRect = new KeyboardRectangle(Scale, 0, 0, 16*Scale, 1*Scale, new List<Color> {Color.Blue, Color.Red},
|
||||||
|
LinearGradientMode.Horizontal);
|
||||||
|
TeamRect = new KeyboardRectangle(Scale, 0, 1*Scale, 21*Scale, 8*Scale, new List<Color> {Color.CornflowerBlue},
|
||||||
LinearGradientMode.Horizontal);
|
LinearGradientMode.Horizontal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KeyboardRectangle TeamRect { get; set; }
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
|
|
||||||
public CounterStrikeJson CsJson { get; set; }
|
public JObject CsJson { get; set; }
|
||||||
public KeyboardRectangle AmmoRect { get; set; }
|
public KeyboardRectangle AmmoRect { get; set; }
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
@ -44,19 +48,46 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
if (CsJson?.player.weapons == null)
|
if (CsJson == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var activeWeapon = CsJson.player.weapons.FirstOrDefault(w => w.Value.state.Equals("active"));
|
UpdateAmmo();
|
||||||
|
UpdateTeam();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateTeam()
|
||||||
|
{
|
||||||
|
var currentTeam = CsJson["player"]["team"];
|
||||||
|
if (currentTeam == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TeamRect.Colors = currentTeam.Value<string>() == "T"
|
||||||
|
? new List<Color> {Color.FromArgb(255, 255, 129, 0)}
|
||||||
|
: new List<Color> {Color.FromArgb(255, 112, 209, 255)};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateAmmo()
|
||||||
|
{
|
||||||
|
var activeWeapon =
|
||||||
|
CsJson["player"]["weapons"].Children()
|
||||||
|
.Select(c => c.First)
|
||||||
|
.FirstOrDefault(w => w["state"]?.Value<string>() == "active");
|
||||||
|
|
||||||
// Update the ammo display
|
// Update the ammo display
|
||||||
var ammoPercentage = 0;
|
if (activeWeapon?["ammo_clip_max"] == null || activeWeapon["ammo_clip"] == null)
|
||||||
if (activeWeapon.Value?.ammo_clip_max > 0)
|
return;
|
||||||
ammoPercentage =
|
|
||||||
(int) ((Math.Ceiling(100.00/activeWeapon.Value.ammo_clip_max))*activeWeapon.Value.ammo_clip);
|
|
||||||
|
|
||||||
AmmoRect.Height = ammoPercentage;
|
var maxAmmo = activeWeapon["ammo_clip_max"].Value<int>();
|
||||||
if (ammoPercentage < 30)
|
var ammo = activeWeapon["ammo_clip"].Value<int>();
|
||||||
|
|
||||||
|
if (maxAmmo < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var ammoPercentage = (int) Math.Ceiling(100.00/maxAmmo)*ammo;
|
||||||
|
AmmoRect.Width = ((int) Math.Floor((16/100.00)*ammoPercentage))*Scale;
|
||||||
|
|
||||||
|
// Low ammo indicator
|
||||||
|
if (ammoPercentage < 37)
|
||||||
AmmoRect.StartBlink(1000);
|
AmmoRect.StartBlink(1000);
|
||||||
else
|
else
|
||||||
AmmoRect.StopBlink();
|
AmmoRect.StopBlink();
|
||||||
@ -64,12 +95,13 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
|
|
||||||
public override Bitmap GenerateBitmap()
|
public override Bitmap GenerateBitmap()
|
||||||
{
|
{
|
||||||
var bitmap = new Bitmap(21, 6);
|
var bitmap = new Bitmap(21*Scale, 6*Scale);
|
||||||
|
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
g.Clear(Color.Transparent);
|
g.Clear(Color.Transparent);
|
||||||
AmmoRect.Draw(g);
|
AmmoRect.Draw(g);
|
||||||
|
TeamRect.Draw(g);
|
||||||
}
|
}
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
@ -83,7 +115,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Parse the JSON
|
// Parse the JSON
|
||||||
CsJson = JsonConvert.DeserializeObject<CounterStrikeJson>(jsonString);
|
CsJson = JsonConvert.DeserializeObject<JObject>(jsonString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
38
Artemis/Artemis/Settings/CounterStrike.Designer.cs
generated
Normal file
38
Artemis/Artemis/Settings/CounterStrike.Designer.cs
generated
Normal 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.Settings {
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||||
|
internal sealed partial class CounterStrike : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
|
private static CounterStrike defaultInstance = ((CounterStrike)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new CounterStrike())));
|
||||||
|
|
||||||
|
public static CounterStrike Default {
|
||||||
|
get {
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("C:\\Program Files (x86)\\Steam\\steamapps\\common\\Counter-Strike Global Offensive")]
|
||||||
|
public string GameDirectory {
|
||||||
|
get {
|
||||||
|
return ((string)(this["GameDirectory"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["GameDirectory"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
Artemis/Artemis/Settings/CounterStrike.settings
Normal file
9
Artemis/Artemis/Settings/CounterStrike.settings
Normal 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.Settings" GeneratedClassName="CounterStrike">
|
||||||
|
<Profiles />
|
||||||
|
<Settings>
|
||||||
|
<Setting Name="GameDirectory" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)">C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive</Value>
|
||||||
|
</Setting>
|
||||||
|
</Settings>
|
||||||
|
</SettingsFile>
|
||||||
@ -1,96 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Artemis.Utilities.GameSense.JsonModels
|
|
||||||
{
|
|
||||||
public class CounterStrikeJson
|
|
||||||
{
|
|
||||||
public Provider provider { get; set; }
|
|
||||||
public Map map { get; set; }
|
|
||||||
public Round round { get; set; }
|
|
||||||
public Player player { get; set; }
|
|
||||||
public Auth auth { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Provider
|
|
||||||
{
|
|
||||||
public string name { get; set; }
|
|
||||||
public int appid { get; set; }
|
|
||||||
public int version { get; set; }
|
|
||||||
public string steamid { get; set; }
|
|
||||||
public int timestamp { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Map
|
|
||||||
{
|
|
||||||
public string name { get; set; }
|
|
||||||
public string phase { get; set; }
|
|
||||||
public int round { get; set; }
|
|
||||||
public Team_Ct team_ct { get; set; }
|
|
||||||
public Team_T team_t { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Team_Ct
|
|
||||||
{
|
|
||||||
public int score { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Team_T
|
|
||||||
{
|
|
||||||
public int score { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Round
|
|
||||||
{
|
|
||||||
public string phase { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Player
|
|
||||||
{
|
|
||||||
public string steamid { get; set; }
|
|
||||||
public string name { get; set; }
|
|
||||||
public string team { get; set; }
|
|
||||||
public string activity { get; set; }
|
|
||||||
public State state { get; set; }
|
|
||||||
public Dictionary<string, Weapon> weapons { get; set; }
|
|
||||||
public Match_Stats match_stats { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class State
|
|
||||||
{
|
|
||||||
public int health { get; set; }
|
|
||||||
public int armor { get; set; }
|
|
||||||
public bool helmet { get; set; }
|
|
||||||
public int flashed { get; set; }
|
|
||||||
public int smoked { get; set; }
|
|
||||||
public int burning { get; set; }
|
|
||||||
public int money { get; set; }
|
|
||||||
public int round_kills { get; set; }
|
|
||||||
public int round_killhs { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Match_Stats
|
|
||||||
{
|
|
||||||
public int kills { get; set; }
|
|
||||||
public int assists { get; set; }
|
|
||||||
public int deaths { get; set; }
|
|
||||||
public int mvps { get; set; }
|
|
||||||
public int score { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Weapon
|
|
||||||
{
|
|
||||||
public string name { get; set; }
|
|
||||||
public string paintkit { get; set; }
|
|
||||||
public string type { get; set; }
|
|
||||||
public string state { get; set; }
|
|
||||||
public int ammo_clip { get; set; }
|
|
||||||
public int ammo_clip_max { get; set; }
|
|
||||||
public int ammo_reserve { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Auth
|
|
||||||
{
|
|
||||||
public string key1 { get; set; }
|
|
||||||
public string key2 { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user