mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Merged with master, cleaned up device provider, reworked changing keyboard for new memory fixes
This commit is contained in:
commit
5bbb6803b5
@ -277,6 +277,9 @@
|
|||||||
<setting name="BubbleCount" serializeAs="String">
|
<setting name="BubbleCount" serializeAs="String">
|
||||||
<value>14</value>
|
<value>14</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="Smoothness" serializeAs="String">
|
||||||
|
<value>25</value>
|
||||||
|
</setting>
|
||||||
</Artemis.Modules.Effects.Bubbles.Bubbles>
|
</Artemis.Modules.Effects.Bubbles.Bubbles>
|
||||||
<Artemis.Settings.General>
|
<Artemis.Settings.General>
|
||||||
<setting name="LastEffect" serializeAs="String">
|
<setting name="LastEffect" serializeAs="String">
|
||||||
|
|||||||
@ -96,11 +96,14 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
g.DrawImage(image, new Rectangle(0, 3, 22, 7), new Rectangle(0, 2, 22, 7), GraphicsUnit.Pixel);
|
g.DrawImage(image, new Rectangle(0, 3, 22, 7), new Rectangle(0, 2, 22, 7), GraphicsUnit.Pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
image.Dispose();
|
||||||
image = strafeBitmap;
|
image = strafeBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
_keyboardBrush.Image = image;
|
_keyboardBrush.Image = image;
|
||||||
_keyboard.Update();
|
_keyboard.Update();
|
||||||
|
|
||||||
|
image.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -17,6 +17,7 @@ namespace Artemis.Managers
|
|||||||
private readonly EffectManager _effectManager;
|
private readonly EffectManager _effectManager;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly Timer _loopTimer;
|
private readonly Timer _loopTimer;
|
||||||
|
private Bitmap _keyboardBitmap;
|
||||||
|
|
||||||
public LoopManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager)
|
public LoopManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager)
|
||||||
{
|
{
|
||||||
@ -41,6 +42,7 @@ namespace Artemis.Managers
|
|||||||
{
|
{
|
||||||
_loopTimer.Stop();
|
_loopTimer.Stop();
|
||||||
_loopTimer.Dispose();
|
_loopTimer.Dispose();
|
||||||
|
_keyboardBitmap?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task StartAsync()
|
public Task StartAsync()
|
||||||
@ -75,6 +77,9 @@ namespace Artemis.Managers
|
|||||||
_effectManager.ChangeEffect(lastEffect);
|
_effectManager.ChangeEffect(lastEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// I assume that it's safe to use ActiveKeyboard and ActifeEffect here since both is checked above
|
||||||
|
_keyboardBitmap = _deviceManager.ActiveKeyboard.KeyboardBitmap(_effectManager.ActiveEffect.KeyboardScale);
|
||||||
|
|
||||||
Running = true;
|
Running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +92,8 @@ namespace Artemis.Managers
|
|||||||
Running = false;
|
Running = false;
|
||||||
|
|
||||||
_deviceManager.ReleaseActiveKeyboard();
|
_deviceManager.ReleaseActiveKeyboard();
|
||||||
|
_keyboardBitmap?.Dispose();
|
||||||
|
_keyboardBitmap = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Render(object sender, ElapsedEventArgs e)
|
private void Render(object sender, ElapsedEventArgs e)
|
||||||
@ -125,48 +132,37 @@ namespace Artemis.Managers
|
|||||||
renderEffect.Update();
|
renderEffect.Update();
|
||||||
|
|
||||||
// Get ActiveEffect's bitmap
|
// Get ActiveEffect's bitmap
|
||||||
Bitmap bitmap = null;
|
|
||||||
Brush mouseBrush = null;
|
Brush mouseBrush = null;
|
||||||
Brush headsetBrush = null;
|
Brush headsetBrush = null;
|
||||||
var mice = _deviceManager.MiceProviders.Where(m => m.CanUse).ToList();
|
var mice = _deviceManager.MiceProviders.Where(m => m.CanUse).ToList();
|
||||||
var headsets = _deviceManager.HeadsetProviders.Where(m => m.CanUse).ToList();
|
var headsets = _deviceManager.HeadsetProviders.Where(m => m.CanUse).ToList();
|
||||||
|
|
||||||
if (renderEffect.Initialized)
|
using (Graphics keyboardGraphics = Graphics.FromImage(_keyboardBitmap))
|
||||||
renderEffect.Render(out bitmap, out mouseBrush, out headsetBrush, mice.Any(), headsets.Any());
|
|
||||||
|
|
||||||
// Draw enabled overlays on top of the renderEffect
|
|
||||||
foreach (var overlayModel in _effectManager.EnabledOverlays)
|
|
||||||
{
|
{
|
||||||
overlayModel.Update();
|
// Fill the bitmap's background with black to avoid trailing colors on some keyboards
|
||||||
overlayModel.RenderOverlay(ref bitmap, ref mouseBrush, ref headsetBrush, mice.Any(), headsets.Any());
|
keyboardGraphics.Clear(Color.Black);
|
||||||
}
|
|
||||||
|
|
||||||
// Update mice and headsets
|
if (renderEffect.Initialized)
|
||||||
foreach (var mouse in mice)
|
renderEffect.Render(keyboardGraphics, out mouseBrush, out headsetBrush, mice.Any(),
|
||||||
mouse.UpdateDevice(mouseBrush);
|
headsets.Any());
|
||||||
foreach (var headset in headsets)
|
|
||||||
headset.UpdateDevice(headsetBrush);
|
|
||||||
|
|
||||||
// If no bitmap was generated this frame is done
|
// Draw enabled overlays on top of the renderEffect
|
||||||
if (bitmap == null)
|
foreach (var overlayModel in _effectManager.EnabledOverlays)
|
||||||
return;
|
|
||||||
|
|
||||||
// Fill the bitmap's background with black to avoid trailing colors on some keyboards
|
|
||||||
// Bitmaps needs to be disposd!
|
|
||||||
using (var fixedBmp = new Bitmap(bitmap.Width, bitmap.Height))
|
|
||||||
{
|
|
||||||
using (var g = Graphics.FromImage(fixedBmp))
|
|
||||||
{
|
{
|
||||||
g.Clear(Color.Black);
|
overlayModel.Update();
|
||||||
g.DrawImage(bitmap, 0, 0);
|
overlayModel.RenderOverlay(keyboardGraphics, ref mouseBrush, ref headsetBrush, mice.Any(),
|
||||||
|
headsets.Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap = fixedBmp;
|
// Update mice and headsets
|
||||||
|
foreach (var mouse in mice)
|
||||||
// Update the keyboard
|
mouse.UpdateDevice(mouseBrush);
|
||||||
_deviceManager.ActiveKeyboard?.DrawBitmap(bitmap);
|
foreach (var headset in headsets)
|
||||||
bitmap.Dispose();
|
headset.UpdateDevice(headsetBrush);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the keyboard
|
||||||
|
_deviceManager.ActiveKeyboard?.DrawBitmap(_keyboardBitmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,9 +15,11 @@ namespace Artemis.Models
|
|||||||
{
|
{
|
||||||
public delegate void SettingsUpdateHandler(EffectSettings settings);
|
public delegate void SettingsUpdateHandler(EffectSettings settings);
|
||||||
|
|
||||||
public bool Initialized;
|
public bool Initialized { get; set; }
|
||||||
public MainManager MainManager;
|
public MainManager MainManager { get; set; }
|
||||||
public string Name;
|
public string Name { get; set; }
|
||||||
|
public int KeyboardScale { get; set; } = 4;
|
||||||
|
|
||||||
private DateTime _lastTrace;
|
private DateTime _lastTrace;
|
||||||
|
|
||||||
protected EffectModel(MainManager mainManager, IDataModel dataModel)
|
protected EffectModel(MainManager mainManager, IDataModel dataModel)
|
||||||
@ -39,10 +41,8 @@ namespace Artemis.Models
|
|||||||
public abstract void Update();
|
public abstract void Update();
|
||||||
|
|
||||||
// Called after every update
|
// Called after every update
|
||||||
public virtual void Render(out Bitmap keyboard, out Brush mouse, out Brush headset, bool renderMice,
|
public virtual void Render(Graphics keyboard, out Brush mouse, out Brush headset, bool renderMice, bool renderHeadsets)
|
||||||
bool renderHeadsets)
|
|
||||||
{
|
{
|
||||||
keyboard = null;
|
|
||||||
mouse = null;
|
mouse = null;
|
||||||
headset = null;
|
headset = null;
|
||||||
|
|
||||||
@ -65,8 +65,7 @@ namespace Artemis.Models
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render the keyboard layer-by-layer
|
// Render the keyboard layer-by-layer
|
||||||
keyboard = Profile.GenerateBitmap(renderLayers, DataModel,
|
Profile.DrawProfile(keyboard, renderLayers, DataModel, MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale), false, true);
|
||||||
MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(4), false, true);
|
|
||||||
// Render the first enabled mouse (will default to null if renderMice was false)
|
// Render the first enabled mouse (will default to null if renderMice was false)
|
||||||
mouse = Profile.GenerateBrush(renderLayers.LastOrDefault(l => l.LayerType == LayerType.Mouse), DataModel);
|
mouse = Profile.GenerateBrush(renderLayers.LastOrDefault(l => l.LayerType == LayerType.Mouse), DataModel);
|
||||||
// Render the first enabled headset (will default to null if renderHeadsets was false)
|
// Render the first enabled headset (will default to null if renderHeadsets was false)
|
||||||
|
|||||||
@ -29,7 +29,7 @@ namespace Artemis.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void RenderOverlay(ref Bitmap keyboard, ref Brush mouse, ref Brush headset, bool renderMice,
|
public abstract void RenderOverlay(Graphics keyboard, ref Brush mouse, ref Brush headset, bool renderMice,
|
||||||
bool renderHeadsets);
|
bool renderHeadsets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ namespace Artemis.Models.Profiles
|
|||||||
if (ReferenceEquals(null, obj)) return false;
|
if (ReferenceEquals(null, obj)) return false;
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
if (ReferenceEquals(this, obj)) return true;
|
||||||
if (obj.GetType() != GetType()) return false;
|
if (obj.GetType() != GetType()) return false;
|
||||||
return Equals((ProfileModel) obj);
|
return Equals((ProfileModel)obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
@ -53,8 +53,8 @@ namespace Artemis.Models.Profiles
|
|||||||
unchecked
|
unchecked
|
||||||
{
|
{
|
||||||
var hashCode = Name?.GetHashCode() ?? 0;
|
var hashCode = Name?.GetHashCode() ?? 0;
|
||||||
hashCode = (hashCode*397) ^ (KeyboardSlug?.GetHashCode() ?? 0);
|
hashCode = (hashCode * 397) ^ (KeyboardSlug?.GetHashCode() ?? 0);
|
||||||
hashCode = (hashCode*397) ^ (GameName?.GetHashCode() ?? 0);
|
hashCode = (hashCode * 397) ^ (GameName?.GetHashCode() ?? 0);
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ namespace Artemis.Models.Profiles
|
|||||||
Layers[i].Order = i;
|
Layers[i].Order = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap GenerateBitmap<T>(Rect keyboardRect, IDataModel dataModel, bool preview,
|
public void DrawProfile<T>(Graphics keyboard, Rect keyboardRect, IDataModel dataModel, bool preview,
|
||||||
bool updateAnimations)
|
bool updateAnimations)
|
||||||
{
|
{
|
||||||
var visual = new DrawingVisual();
|
var visual = new DrawingVisual();
|
||||||
@ -83,8 +83,9 @@ namespace Artemis.Models.Profiles
|
|||||||
// Remove the clip
|
// Remove the clip
|
||||||
c.Pop();
|
c.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ImageUtilities.DrawinVisualToBitmap(visual, keyboardRect);
|
using (Bitmap bmp = ImageUtilities.DrawinVisualToBitmap(visual, keyboardRect))
|
||||||
|
keyboard.DrawImage(bmp, new PointF(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Brush GenerateBrush<T>(IDataModel dataModel, LayerType type, bool preview, bool updateAnimations)
|
public Brush GenerateBrush<T>(IDataModel dataModel, LayerType type, bool preview, bool updateAnimations)
|
||||||
@ -161,7 +162,7 @@ namespace Artemis.Models.Profiles
|
|||||||
if (layer.LayerType != LayerType.Keyboard && layer.LayerType != LayerType.KeyboardGif)
|
if (layer.LayerType != LayerType.Keyboard && layer.LayerType != LayerType.KeyboardGif)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var props = (KeyboardPropertiesModel) layer.Properties;
|
var props = (KeyboardPropertiesModel)layer.Properties;
|
||||||
var layerRect = new Rect(new Point(props.X, props.Y), new Size(props.Width, props.Height));
|
var layerRect = new Rect(new Point(props.X, props.Y), new Size(props.Width, props.Height));
|
||||||
if (keyboardRectangle.Contains(layerRect))
|
if (keyboardRectangle.Contains(layerRect))
|
||||||
continue;
|
continue;
|
||||||
@ -173,15 +174,15 @@ namespace Artemis.Models.Profiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates a bitmap showing all the provided layers of type Keyboard and KeyboardGif
|
/// Draw all the provided layers of type Keyboard and KeyboardGif
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="keyboard">The graphics to draw on</param>
|
||||||
/// <param name="renderLayers">The layers to render</param>
|
/// <param name="renderLayers">The layers to render</param>
|
||||||
/// <param name="dataModel">The data model to base the layer's properties on</param>
|
/// <param name="dataModel">The data model to base the layer's properties on</param>
|
||||||
/// <param name="keyboardRect">A rectangle matching the current keyboard's size on a scale of 4, used for clipping</param>
|
/// <param name="keyboardRect">A rectangle matching the current keyboard's size on a scale of 4, used for clipping</param>
|
||||||
/// <param name="preview">Indicates wheter the layer is drawn as a preview, ignoring dynamic properties</param>
|
/// <param name="preview">Indicates wheter the layer is drawn as a preview, ignoring dynamic properties</param>
|
||||||
/// <param name="updateAnimations">Wheter or not to update the layer's animations</param>
|
/// <param name="updateAnimations">Wheter or not to update the layer's animations</param>
|
||||||
/// <returns>The generated bitmap</returns>
|
internal void DrawProfile(Graphics keyboard, List<LayerModel> renderLayers, IDataModel dataModel, Rect keyboardRect,
|
||||||
internal Bitmap GenerateBitmap(List<LayerModel> renderLayers, IDataModel dataModel, Rect keyboardRect,
|
|
||||||
bool preview,
|
bool preview,
|
||||||
bool updateAnimations)
|
bool updateAnimations)
|
||||||
{
|
{
|
||||||
@ -203,8 +204,9 @@ namespace Artemis.Models.Profiles
|
|||||||
// Remove the clip
|
// Remove the clip
|
||||||
c.Pop();
|
c.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ImageUtilities.DrawinVisualToBitmap(visual, keyboardRect);
|
using (Bitmap bmp = ImageUtilities.DrawinVisualToBitmap(visual, keyboardRect))
|
||||||
|
keyboard.DrawImage(bmp, new PointF(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -30,14 +30,11 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
Name = "Audiovisualizer";
|
Name = "Audiovisualizer";
|
||||||
DeviceIds = new List<string>();
|
DeviceIds = new List<string>();
|
||||||
SpectrumData = new List<byte>();
|
SpectrumData = new List<byte>();
|
||||||
Scale = 4;
|
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Lines { get; set; }
|
public int Lines { get; set; }
|
||||||
|
|
||||||
public int Scale { get; set; }
|
|
||||||
|
|
||||||
public AudioVisualizerSettings Settings { get; set; }
|
public AudioVisualizerSettings Settings { get; set; }
|
||||||
public List<byte> SpectrumData { get; set; }
|
public List<byte> SpectrumData { get; set; }
|
||||||
public List<KeyboardRectangle> SoundRectangles { get; set; }
|
public List<KeyboardRectangle> SoundRectangles { get; set; }
|
||||||
@ -80,7 +77,8 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
ColorHelpers.ToDrawingColor(Settings.MiddleColor),
|
ColorHelpers.ToDrawingColor(Settings.MiddleColor),
|
||||||
ColorHelpers.ToDrawingColor(Settings.BottomColor)
|
ColorHelpers.ToDrawingColor(Settings.BottomColor)
|
||||||
},
|
},
|
||||||
LinearGradientMode.Vertical) {ContainedBrush = false, Height = 0});
|
LinearGradientMode.Vertical)
|
||||||
|
{ ContainedBrush = false, Height = 0 });
|
||||||
}
|
}
|
||||||
_sensitivity = Settings.Sensitivity;
|
_sensitivity = Settings.Sensitivity;
|
||||||
_fromBottom = Settings.FromBottom;
|
_fromBottom = Settings.FromBottom;
|
||||||
@ -120,22 +118,22 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
if (SpectrumData.Count - 1 < i || SpectrumData[i] == 0)
|
if (SpectrumData.Count - 1 < i || SpectrumData[i] == 0)
|
||||||
height = 0;
|
height = 0;
|
||||||
else
|
else
|
||||||
height = (int) Math.Round(SpectrumData[i]/2.55);
|
height = (int)Math.Round(SpectrumData[i] / 2.55);
|
||||||
|
|
||||||
// Apply Sensitivity setting
|
// Apply Sensitivity setting
|
||||||
height = height*_sensitivity;
|
height = height * _sensitivity;
|
||||||
var keyboardHeight =
|
var keyboardHeight =
|
||||||
(int) Math.Round(MainManager.DeviceManager.ActiveKeyboard.Height/100.00*height*Scale);
|
(int)Math.Round(MainManager.DeviceManager.ActiveKeyboard.Height / 100.00 * height * KeyboardScale);
|
||||||
if (keyboardHeight > SoundRectangles[i].Height)
|
if (keyboardHeight > SoundRectangles[i].Height)
|
||||||
SoundRectangles[i].Height = keyboardHeight;
|
SoundRectangles[i].Height = keyboardHeight;
|
||||||
else
|
else
|
||||||
SoundRectangles[i].Height = SoundRectangles[i].Height - Settings.FadeSpeed;
|
SoundRectangles[i].Height = SoundRectangles[i].Height - Settings.FadeSpeed;
|
||||||
// Apply Bars setting
|
// Apply Bars setting
|
||||||
SoundRectangles[i].X = i*Scale;
|
SoundRectangles[i].X = i * KeyboardScale;
|
||||||
SoundRectangles[i].Width = Scale;
|
SoundRectangles[i].Width = KeyboardScale;
|
||||||
|
|
||||||
if (_fromBottom)
|
if (_fromBottom)
|
||||||
SoundRectangles[i].Y = MainManager.DeviceManager.ActiveKeyboard.Height*Scale -
|
SoundRectangles[i].Y = MainManager.DeviceManager.ActiveKeyboard.Height * KeyboardScale -
|
||||||
SoundRectangles[i].Height;
|
SoundRectangles[i].Height;
|
||||||
}
|
}
|
||||||
_generating = false;
|
_generating = false;
|
||||||
@ -166,7 +164,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
for (x = 0; x < Lines; x++)
|
for (x = 0; x < Lines; x++)
|
||||||
{
|
{
|
||||||
float peak = 0;
|
float peak = 0;
|
||||||
var b1 = (int) Math.Pow(2, x*10.0/(Lines - 1));
|
var b1 = (int)Math.Pow(2, x * 10.0 / (Lines - 1));
|
||||||
if (b1 > 2047)
|
if (b1 > 2047)
|
||||||
b1 = 2047;
|
b1 = 2047;
|
||||||
if (b1 <= b0)
|
if (b1 <= b0)
|
||||||
@ -176,12 +174,12 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
if (peak < e.Result[1 + b0].X)
|
if (peak < e.Result[1 + b0].X)
|
||||||
peak = e.Result[1 + b0].X;
|
peak = e.Result[1 + b0].X;
|
||||||
}
|
}
|
||||||
var y = (int) (Math.Sqrt(peak)*3*255 - 4);
|
var y = (int)(Math.Sqrt(peak) * 3 * 255 - 4);
|
||||||
if (y > 255)
|
if (y > 255)
|
||||||
y = 255;
|
y = 255;
|
||||||
if (y < 0)
|
if (y < 0)
|
||||||
y = 0;
|
y = 0;
|
||||||
SpectrumData.Add((byte) y);
|
SpectrumData.Add((byte)y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,10 +188,9 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Render(out Bitmap keyboard, out Brush mouse, out Brush headset, bool renderMice,
|
public override void Render(Graphics keyboard, out Brush mouse, out Brush headset, bool renderMice,
|
||||||
bool renderHeadsets)
|
bool renderHeadsets)
|
||||||
{
|
{
|
||||||
keyboard = null;
|
|
||||||
mouse = null;
|
mouse = null;
|
||||||
headset = null;
|
headset = null;
|
||||||
|
|
||||||
@ -203,12 +200,8 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
// Lock the _spectrumData array while busy with it
|
// Lock the _spectrumData array while busy with it
|
||||||
_generating = true;
|
_generating = true;
|
||||||
|
|
||||||
keyboard = MainManager.DeviceManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
foreach (var soundRectangle in SoundRectangles)
|
||||||
using (var g = Graphics.FromImage(keyboard))
|
soundRectangle.Draw(keyboard);
|
||||||
{
|
|
||||||
foreach (var soundRectangle in SoundRectangles)
|
|
||||||
soundRectangle.Draw(g);
|
|
||||||
}
|
|
||||||
|
|
||||||
_generating = false;
|
_generating = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,5 +106,17 @@ namespace Artemis.Modules.Effects.Bubbles {
|
|||||||
this["BubbleCount"] = value;
|
this["BubbleCount"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("25")]
|
||||||
|
public int Smoothness {
|
||||||
|
get {
|
||||||
|
return ((int)(this["Smoothness"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["Smoothness"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,5 +23,8 @@
|
|||||||
<Setting Name="BubbleCount" Type="System.Int32" Scope="User">
|
<Setting Name="BubbleCount" Type="System.Int32" Scope="User">
|
||||||
<Value Profile="(Default)">14</Value>
|
<Value Profile="(Default)">14</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="Smoothness" Type="System.Int32" Scope="User">
|
||||||
|
<Value Profile="(Default)">25</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
@ -18,10 +16,7 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
|
|
||||||
private static readonly Random _random = new Random();
|
private static readonly Random _random = new Random();
|
||||||
|
|
||||||
private const int SCALE = 25;
|
|
||||||
|
|
||||||
private readonly List<Bubble> _bubbles = new List<Bubble>();
|
private readonly List<Bubble> _bubbles = new List<Bubble>();
|
||||||
private Bitmap _bitmap;
|
|
||||||
|
|
||||||
public BubblesSettings Settings { get; }
|
public BubblesSettings Settings { get; }
|
||||||
|
|
||||||
@ -43,19 +38,23 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
|
|
||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
Rect rect = MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(SCALE);
|
KeyboardScale = Settings.Smoothness;
|
||||||
_bitmap = MainManager.DeviceManager.ActiveKeyboard.KeyboardBitmap(SCALE);
|
|
||||||
|
Rect rect = MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
|
||||||
|
|
||||||
|
double scaleFactor = Settings.Smoothness / 25.0;
|
||||||
|
|
||||||
for (int i = 0; i < Settings.BubbleCount; i++)
|
for (int i = 0; i < Settings.BubbleCount; i++)
|
||||||
{
|
{
|
||||||
Color color = Settings.IsRandomColors ? ColorHelpers.GetRandomRainbowColor() : ColorHelpers.ToDrawingColor(Settings.BubbleColor);
|
Color color = Settings.IsRandomColors ? ColorHelpers.GetRandomRainbowColor() : ColorHelpers.ToDrawingColor(Settings.BubbleColor);
|
||||||
// -Settings.MoveSpeed because we want to spawn at least one move away from borders
|
// -Settings.MoveSpeed because we want to spawn at least one move away from borders
|
||||||
double initialPositionX = ((rect.Width - (Settings.BubbleSize * 2) - Settings.MoveSpeed) * _random.NextDouble()) + Settings.BubbleSize;
|
double initialPositionX = ((rect.Width - (Settings.BubbleSize * scaleFactor * 2) - Settings.MoveSpeed * scaleFactor) * _random.NextDouble()) + Settings.BubbleSize * scaleFactor;
|
||||||
double initialPositionY = ((rect.Height - (Settings.BubbleSize * 2) - Settings.MoveSpeed) * _random.NextDouble()) + Settings.BubbleSize;
|
double initialPositionY = ((rect.Height - (Settings.BubbleSize * scaleFactor * 2) - Settings.MoveSpeed * scaleFactor) * _random.NextDouble()) + Settings.BubbleSize * scaleFactor;
|
||||||
double initialDirectionX = (Settings.MoveSpeed * _random.NextDouble()) * (_random.Next(1) == 0 ? -1 : 1);
|
double initialDirectionX = (Settings.MoveSpeed * scaleFactor * _random.NextDouble()) * (_random.Next(1) == 0 ? -1 : 1);
|
||||||
double initialDirectionY = (Settings.MoveSpeed - Math.Abs(initialDirectionX)) * (_random.Next(1) == 0 ? -1 : 1);
|
double initialDirectionY = (Settings.MoveSpeed * scaleFactor - Math.Abs(initialDirectionX)) * (_random.Next(1) == 0 ? -1 : 1);
|
||||||
|
|
||||||
_bubbles.Add(new Bubble(color, Settings.BubbleSize, new System.Windows.Point(initialPositionX, initialPositionY), new Vector(initialDirectionX, initialDirectionY)));
|
_bubbles.Add(new Bubble(color, (int)Math.Round(Settings.BubbleSize * scaleFactor),
|
||||||
|
new System.Windows.Point(initialPositionX, initialPositionY), new Vector(initialDirectionX, initialDirectionY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Initialized = true;
|
Initialized = true;
|
||||||
@ -63,14 +62,13 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
_bitmap?.Dispose();
|
|
||||||
_bubbles.Clear();
|
_bubbles.Clear();
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
Rect keyboardRectangle = MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(SCALE);
|
Rect keyboardRectangle = MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
|
||||||
foreach (Bubble bubble in _bubbles)
|
foreach (Bubble bubble in _bubbles)
|
||||||
{
|
{
|
||||||
if (Settings.IsShiftColors)
|
if (Settings.IsShiftColors)
|
||||||
@ -81,20 +79,13 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Render(out Bitmap keyboard, out Brush mouse, out Brush headset, bool renderMice, bool renderHeadsets)
|
public override void Render(Graphics keyboard, out Brush mouse, out Brush headset, bool renderMice, bool renderHeadsets)
|
||||||
{
|
{
|
||||||
keyboard = _bitmap;
|
|
||||||
mouse = null;
|
mouse = null;
|
||||||
headset = null;
|
headset = null;
|
||||||
|
|
||||||
using (Graphics g = Graphics.FromImage(keyboard))
|
|
||||||
{
|
|
||||||
g.Clear(Color.Transparent);
|
|
||||||
g.SmoothingMode = SmoothingMode.None;
|
|
||||||
|
|
||||||
foreach (Bubble bubble in _bubbles)
|
foreach (Bubble bubble in _bubbles)
|
||||||
bubble.Draw(g);
|
bubble.Draw(keyboard);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override List<LayerModel> GetRenderLayers(bool renderMice, bool renderHeadsets)
|
public override List<LayerModel> GetRenderLayers(bool renderMice, bool renderHeadsets)
|
||||||
|
|||||||
@ -17,6 +17,7 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
public int BubbleSize { get; set; }
|
public int BubbleSize { get; set; }
|
||||||
public int MoveSpeed { get; set; }
|
public int MoveSpeed { get; set; }
|
||||||
public int BubbleCount { get; set; }
|
public int BubbleCount { get; set; }
|
||||||
|
public int Smoothness { get; set; }
|
||||||
|
|
||||||
public sealed override void Load()
|
public sealed override void Load()
|
||||||
{
|
{
|
||||||
@ -27,6 +28,7 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
BubbleSize = Bubbles.Default.BubbleSize;
|
BubbleSize = Bubbles.Default.BubbleSize;
|
||||||
MoveSpeed = Bubbles.Default.MoveSpeed;
|
MoveSpeed = Bubbles.Default.MoveSpeed;
|
||||||
BubbleCount = Bubbles.Default.BubbleCount;
|
BubbleCount = Bubbles.Default.BubbleCount;
|
||||||
|
Smoothness = Bubbles.Default.Smoothness;
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed override void Save()
|
public sealed override void Save()
|
||||||
@ -38,6 +40,7 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
Bubbles.Default.BubbleSize = BubbleSize;
|
Bubbles.Default.BubbleSize = BubbleSize;
|
||||||
Bubbles.Default.MoveSpeed = MoveSpeed;
|
Bubbles.Default.MoveSpeed = MoveSpeed;
|
||||||
Bubbles.Default.BubbleCount = BubbleCount;
|
Bubbles.Default.BubbleCount = BubbleCount;
|
||||||
|
Bubbles.Default.Smoothness = Smoothness;
|
||||||
|
|
||||||
Bubbles.Default.Save();
|
Bubbles.Default.Save();
|
||||||
}
|
}
|
||||||
@ -47,10 +50,11 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
IsRandomColors = true;
|
IsRandomColors = true;
|
||||||
BubbleColor = Color.FromArgb(255, 255, 0, 0);
|
BubbleColor = Color.FromArgb(255, 255, 0, 0);
|
||||||
IsShiftColors = true;
|
IsShiftColors = true;
|
||||||
ShiftColorSpeed = 4;
|
ShiftColorSpeed = 12;
|
||||||
BubbleSize = 25;
|
BubbleSize = 25;
|
||||||
MoveSpeed = 16;
|
MoveSpeed = 4;
|
||||||
BubbleCount = 14;
|
BubbleCount = 14;
|
||||||
|
Smoothness = 25;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
|
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
@ -119,9 +120,19 @@
|
|||||||
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
|
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
|
||||||
Value="{Binding Path=EffectSettings.MoveSpeed, Mode=TwoWay}" Minimum="1" Maximum="15"
|
Value="{Binding Path=EffectSettings.MoveSpeed, Mode=TwoWay}" Minimum="1" Maximum="15"
|
||||||
SmallChange="10" IsSnapToTickEnabled="True" />
|
SmallChange="10" IsSnapToTickEnabled="True" />
|
||||||
|
|
||||||
|
<!-- Smoothness -->
|
||||||
|
<TextBlock Grid.Row="9" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||||
|
Height="16" Margin="0,9,0,10">
|
||||||
|
Smoothness
|
||||||
|
</TextBlock>
|
||||||
|
<Slider x:Name="Smoothness" Grid.Row="9" Grid.Column="1" VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
|
||||||
|
Value="{Binding Path=EffectSettings.Smoothness, Mode=TwoWay}" Minimum="1" Maximum="100"
|
||||||
|
SmallChange="10" IsSnapToTickEnabled="True" />
|
||||||
|
|
||||||
<!-- Buttons -->
|
<!-- Buttons -->
|
||||||
<StackPanel Grid.Column="0" Grid.Row="9" Orientation="Horizontal" VerticalAlignment="Bottom">
|
<StackPanel Grid.Column="0" Grid.Row="10" Orientation="Horizontal" VerticalAlignment="Bottom">
|
||||||
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100"
|
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100"
|
||||||
Style="{DynamicResource SquareButtonStyle}" />
|
Style="{DynamicResource SquareButtonStyle}" />
|
||||||
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100"
|
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100"
|
||||||
|
|||||||
@ -35,10 +35,9 @@ namespace Artemis.Modules.Effects.ProfilePreview
|
|||||||
return Profile.GetRenderLayers<ProfilePreviewDataModel>(DataModel, renderMice, renderHeadsets, true);
|
return Profile.GetRenderLayers<ProfilePreviewDataModel>(DataModel, renderMice, renderHeadsets, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Render(out Bitmap keyboard, out Brush mouse, out Brush headset, bool renderMice,
|
public override void Render(Graphics keyboard, out Brush mouse, out Brush headset, bool renderMice,
|
||||||
bool renderHeadsets)
|
bool renderHeadsets)
|
||||||
{
|
{
|
||||||
keyboard = null;
|
|
||||||
mouse = null;
|
mouse = null;
|
||||||
headset = null;
|
headset = null;
|
||||||
|
|
||||||
@ -49,8 +48,7 @@ namespace Artemis.Modules.Effects.ProfilePreview
|
|||||||
var renderLayers = GetRenderLayers(renderMice, renderHeadsets);
|
var renderLayers = GetRenderLayers(renderMice, renderHeadsets);
|
||||||
|
|
||||||
// Render the keyboard layer-by-layer
|
// Render the keyboard layer-by-layer
|
||||||
keyboard = Profile?.GenerateBitmap(renderLayers, DataModel,
|
Profile?.DrawProfile(keyboard, renderLayers, DataModel, MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale), true, true);
|
||||||
MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(4), true, true);
|
|
||||||
// Render the first enabled mouse (will default to null if renderMice was false)
|
// Render the first enabled mouse (will default to null if renderMice was false)
|
||||||
mouse = Profile?.GenerateBrush(renderLayers.LastOrDefault(l => l.LayerType == LayerType.Mouse), DataModel);
|
mouse = Profile?.GenerateBrush(renderLayers.LastOrDefault(l => l.LayerType == LayerType.Mouse), DataModel);
|
||||||
// Render the first enabled headset (will default to null if renderHeadsets was false)
|
// Render the first enabled headset (will default to null if renderHeadsets was false)
|
||||||
|
|||||||
@ -25,11 +25,8 @@ namespace Artemis.Modules.Effects.TypeWave
|
|||||||
_randomColor = Color.Red;
|
_randomColor = Color.Red;
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
Scale = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Scale { get; set; }
|
|
||||||
|
|
||||||
public TypeWaveSettings Settings { get; set; }
|
public TypeWaveSettings Settings { get; set; }
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
@ -49,8 +46,8 @@ namespace Artemis.Modules.Effects.TypeWave
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_waves.Add(Settings.IsRandomColors
|
_waves.Add(Settings.IsRandomColors
|
||||||
? new Wave(new Point(keyMatch.PosX*Scale, keyMatch.PosY*Scale), 0, _randomColor)
|
? new Wave(new Point(keyMatch.PosX * KeyboardScale, keyMatch.PosY * KeyboardScale), 0, _randomColor)
|
||||||
: new Wave(new Point(keyMatch.PosX*Scale, keyMatch.PosY*Scale), 0,
|
: new Wave(new Point(keyMatch.PosX * KeyboardScale, keyMatch.PosY * KeyboardScale), 0,
|
||||||
ColorHelpers.ToDrawingColor(Settings.WaveColor)));
|
ColorHelpers.ToDrawingColor(Settings.WaveColor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,12 +71,12 @@ namespace Artemis.Modules.Effects.TypeWave
|
|||||||
// TODO: Get from settings
|
// TODO: Get from settings
|
||||||
var fps = 25;
|
var fps = 25;
|
||||||
|
|
||||||
_waves[i].Size += Settings.SpreadSpeed*Scale;
|
_waves[i].Size += Settings.SpreadSpeed * KeyboardScale;
|
||||||
|
|
||||||
if (Settings.IsShiftColors)
|
if (Settings.IsShiftColors)
|
||||||
_waves[i].Color = ColorHelpers.ShiftColor(_waves[i].Color, Settings.ShiftColorSpeed);
|
_waves[i].Color = ColorHelpers.ShiftColor(_waves[i].Color, Settings.ShiftColorSpeed);
|
||||||
|
|
||||||
var decreaseAmount = 255/(Settings.TimeToLive/fps);
|
var decreaseAmount = 255 / (Settings.TimeToLive / fps);
|
||||||
_waves[i].Color = Color.FromArgb(
|
_waves[i].Color = Color.FromArgb(
|
||||||
_waves[i].Color.A - decreaseAmount, _waves[i].Color.R,
|
_waves[i].Color.A - decreaseAmount, _waves[i].Color.R,
|
||||||
_waves[i].Color.G,
|
_waves[i].Color.G,
|
||||||
@ -98,51 +95,43 @@ namespace Artemis.Modules.Effects.TypeWave
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Render(out Bitmap keyboard, out Brush mouse, out Brush headset, bool renderMice,
|
public override void Render(Graphics keyboard, out Brush mouse, out Brush headset, bool renderMice,
|
||||||
bool renderHeadsets)
|
bool renderHeadsets)
|
||||||
{
|
{
|
||||||
keyboard = null;
|
|
||||||
mouse = null;
|
mouse = null;
|
||||||
headset = null;
|
headset = null;
|
||||||
|
|
||||||
if (_waves.Count == 0)
|
if (_waves.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
keyboard = MainManager.DeviceManager.ActiveKeyboard.KeyboardBitmap(Scale);
|
// Don't want a for-each, collection is changed in different thread
|
||||||
using (var g = Graphics.FromImage(keyboard))
|
// ReSharper disable once ForCanBeConvertedToForeach
|
||||||
|
for (var i = 0; i < _waves.Count; i++)
|
||||||
{
|
{
|
||||||
g.Clear(Color.Transparent);
|
if (_waves[i].Size == 0)
|
||||||
g.SmoothingMode = SmoothingMode.HighQuality;
|
continue;
|
||||||
|
var path = new GraphicsPath();
|
||||||
|
path.AddEllipse(_waves[i].Point.X - _waves[i].Size / 2, _waves[i].Point.Y - _waves[i].Size / 2,
|
||||||
|
_waves[i].Size, _waves[i].Size);
|
||||||
|
|
||||||
// Don't want a for-each, collection is changed in different thread
|
Color fillColor;
|
||||||
// ReSharper disable once ForCanBeConvertedToForeach
|
if (MainManager.DeviceManager.ActiveKeyboard is CorsairRGB)
|
||||||
for (var i = 0; i < _waves.Count; i++)
|
fillColor = Color.Black;
|
||||||
|
else
|
||||||
|
fillColor = Color.Transparent;
|
||||||
|
|
||||||
|
var pthGrBrush = new PathGradientBrush(path)
|
||||||
{
|
{
|
||||||
if (_waves[i].Size == 0)
|
SurroundColors = new[] { _waves[i].Color },
|
||||||
continue;
|
CenterColor = fillColor
|
||||||
var path = new GraphicsPath();
|
};
|
||||||
path.AddEllipse(_waves[i].Point.X - _waves[i].Size/2, _waves[i].Point.Y - _waves[i].Size/2,
|
|
||||||
_waves[i].Size, _waves[i].Size);
|
|
||||||
|
|
||||||
Color fillColor;
|
keyboard.FillPath(pthGrBrush, path);
|
||||||
if (MainManager.DeviceManager.ActiveKeyboard is CorsairRGB)
|
pthGrBrush.FocusScales = new PointF(0.3f, 0.8f);
|
||||||
fillColor = Color.Black;
|
|
||||||
else
|
|
||||||
fillColor = Color.Transparent;
|
|
||||||
|
|
||||||
var pthGrBrush = new PathGradientBrush(path)
|
keyboard.FillPath(pthGrBrush, path);
|
||||||
{
|
keyboard.DrawEllipse(new Pen(pthGrBrush, 1), _waves[i].Point.X - _waves[i].Size / 2,
|
||||||
SurroundColors = new[] {_waves[i].Color},
|
_waves[i].Point.Y - _waves[i].Size / 2, _waves[i].Size, _waves[i].Size);
|
||||||
CenterColor = fillColor
|
|
||||||
};
|
|
||||||
|
|
||||||
g.FillPath(pthGrBrush, path);
|
|
||||||
pthGrBrush.FocusScales = new PointF(0.3f, 0.8f);
|
|
||||||
|
|
||||||
g.FillPath(pthGrBrush, path);
|
|
||||||
g.DrawEllipse(new Pen(pthGrBrush, 1), _waves[i].Point.X - _waves[i].Size/2,
|
|
||||||
_waves[i].Point.Y - _waves[i].Size/2, _waves[i].Size, _waves[i].Size);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,10 +46,10 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
if (VolumeDisplay.Ttl < 1)
|
if (VolumeDisplay.Ttl < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var decreaseAmount = 500/fps;
|
var decreaseAmount = 500 / fps;
|
||||||
VolumeDisplay.Ttl = VolumeDisplay.Ttl - decreaseAmount;
|
VolumeDisplay.Ttl = VolumeDisplay.Ttl - decreaseAmount;
|
||||||
if (VolumeDisplay.Ttl < 128)
|
if (VolumeDisplay.Ttl < 128)
|
||||||
VolumeDisplay.Transparancy = (byte) (VolumeDisplay.Transparancy - 20);
|
VolumeDisplay.Transparancy = (byte)(VolumeDisplay.Transparancy - 20);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -57,26 +57,13 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
var volumeFloat =
|
var volumeFloat =
|
||||||
enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console)
|
enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console)
|
||||||
.AudioEndpointVolume.MasterVolumeLevelScalar;
|
.AudioEndpointVolume.MasterVolumeLevelScalar;
|
||||||
VolumeDisplay.Volume = (int) (volumeFloat*100);
|
VolumeDisplay.Volume = (int)(volumeFloat * 100);
|
||||||
}
|
}
|
||||||
catch (COMException)
|
catch (COMException)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap GenerateBitmap(Bitmap bitmap)
|
|
||||||
{
|
|
||||||
if (VolumeDisplay == null)
|
|
||||||
return bitmap;
|
|
||||||
if (VolumeDisplay.Ttl < 1)
|
|
||||||
return bitmap;
|
|
||||||
|
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
|
||||||
VolumeDisplay.Draw(g);
|
|
||||||
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override List<LayerModel> GetRenderLayers(bool renderMice, bool renderHeadsets)
|
public override List<LayerModel> GetRenderLayers(bool renderMice, bool renderHeadsets)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -91,13 +78,11 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
VolumeDisplay.Transparancy = 255;
|
VolumeDisplay.Transparancy = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RenderOverlay(ref Bitmap keyboard, ref Brush mouse, ref Brush headset, bool renderMice,
|
public override void RenderOverlay(Graphics keyboard, ref Brush mouse, ref Brush headset, bool renderMice,
|
||||||
bool renderHeadsets)
|
bool renderHeadsets)
|
||||||
{
|
{
|
||||||
if (MainManager.DeviceManager.ActiveKeyboard == null)
|
if (MainManager.DeviceManager.ActiveKeyboard != null && VolumeDisplay != null && VolumeDisplay.Ttl >= 1)
|
||||||
return;
|
VolumeDisplay.Draw(keyboard);
|
||||||
|
|
||||||
keyboard = GenerateBitmap(keyboard ?? MainManager.DeviceManager.ActiveKeyboard.KeyboardBitmap(4));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user