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

One more CS:GO fix

This commit is contained in:
SpoinkyNL 2016-02-23 07:37:00 +01:00
parent 5a3e6341b0
commit 7fc2a6e03f
6 changed files with 39 additions and 20 deletions

View File

@ -232,6 +232,7 @@
<Compile Include="Events\ChangeBitmap.cs" />
<Compile Include="KeyboardProviders\Corsair\CorsairRGB.cs" />
<Compile Include="KeyboardProviders\KeyboardProvider.cs" />
<Compile Include="KeyboardProviders\KeyboardRegion.cs" />
<Compile Include="KeyboardProviders\Logitech\Orion.cs" />
<Compile Include="KeyboardProviders\Logitech\Utilities\KeyboardNames.cs" />
<Compile Include="KeyboardProviders\Logitech\Utilities\KeyMap.cs" />

View File

@ -1,4 +1,5 @@
using System.Drawing;
using System.Collections.Generic;
using System.Drawing;
using System.Threading;
using Artemis.Utilities;
using CUE.NET;
@ -18,6 +19,7 @@ namespace Artemis.KeyboardProviders.Corsair
CantEnableText = "Couldn't connect to your Corsair keyboard.\n " +
"Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
KeyboardRegions = new List<KeyboardRegion>();
}
public override bool CanEnable()
@ -71,13 +73,16 @@ namespace Artemis.KeyboardProviders.Corsair
case "K95 RGB":
Height = 7;
Width = 24;
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 20)));
break;
case "K70 RGB":
Height = 7;
Width = 21;
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 16)));
break;
case "Strafe RGB":
Height = 7;
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(1, 0), new Point(1, 16)));
Width = 22;
break;
}

View File

@ -1,4 +1,5 @@
using System.Drawing;
using System.Collections.Generic;
using System.Drawing;
namespace Artemis.KeyboardProviders
{
@ -9,6 +10,8 @@ namespace Artemis.KeyboardProviders
public int Width { get; set; }
public string CantEnableText { get; set; }
public List<KeyboardRegion> KeyboardRegions { get; set; }
public abstract bool CanEnable();
public abstract void Enable();
public abstract void Disable();

View File

@ -0,0 +1,18 @@
using System.Drawing;
namespace Artemis.KeyboardProviders
{
public class KeyboardRegion
{
public string RegionName { get; set; }
public Point TopLeft { get; set; }
public Point BottomRight { get; set; }
public KeyboardRegion(string regionName, Point topLeft, Point bottomRight)
{
RegionName = regionName;
TopLeft = topLeft;
BottomRight = bottomRight;
}
}
}

View File

@ -1,4 +1,5 @@
using System.Drawing;
using System.Collections.Generic;
using System.Drawing;
using System.Threading;
using Artemis.KeyboardProviders.Logitech.Utilities;
@ -14,6 +15,7 @@ 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))};
}
public override bool CanEnable()

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using Artemis.KeyboardProviders;
using Artemis.KeyboardProviders.Corsair;
using Artemis.KeyboardProviders.Logitech;
using Artemis.Models;
@ -16,7 +17,7 @@ namespace Artemis.Modules.Games.CounterStrike
{
public class CounterStrikeModel : GameModel
{
private int _ammoWidth;
private KeyboardRegion _topRow;
public CounterStrikeModel(MainModel mainModel, CounterStrikeSettings settings) : base(mainModel)
{
@ -47,23 +48,12 @@ namespace Artemis.Modules.Games.CounterStrike
public override void Enable()
{
// Some keyboards have a different baseline, Corsair F-keys start at row 1
int baseLine;
if (MainModel.ActiveKeyboard is CorsairRGB)
{
baseLine = 1;
_ammoWidth = 19;
}
else
{
baseLine = 0;
_ammoWidth = 16;
}
AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, baseLine, new List<Color>(),
_topRow = MainModel.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X, new List<Color>(),
LinearGradientMode.Horizontal) {Height = Scale, ContainedBrush = false};
TeamRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, baseLine + 1, new List<Color>(),
TeamRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X + 1, new List<Color>(),
LinearGradientMode.Horizontal) {Height = MainModel.ActiveKeyboard.Height*Scale - Scale};
EventRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, baseLine + 1, new List<Color>(),
EventRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, _topRow.TopLeft.X + 1, new List<Color>(),
LinearGradientMode.Horizontal) {Height = MainModel.ActiveKeyboard.Height*Scale - Scale};
MainModel.GameStateWebServer.GameDataReceived += HandleGameData;
}
@ -162,7 +152,7 @@ namespace Artemis.Modules.Games.CounterStrike
return;
var ammoPercentage = (int) Math.Ceiling(100.00/maxAmmo)*ammo;
AmmoRect.Width = (int) Math.Floor(_ammoWidth / 100.00*ammoPercentage)*Scale;
AmmoRect.Width = (int) Math.Floor(_topRow.BottomRight.Y / 100.00*ammoPercentage)*Scale;
AmmoRect.Colors = new List<Color>
{
ColorHelpers.ToDrawingColor(Settings.AmmoMainColor),