Skip to content

Commit

Permalink
Revert "Merge branch 'development'"
Browse files Browse the repository at this point in the history
This reverts commit be217ff, reversing
changes made to 524296e.
  • Loading branch information
RobertBeekman committed Oct 9, 2023
1 parent be217ff commit ebf4099
Show file tree
Hide file tree
Showing 62 changed files with 1,254 additions and 1,489 deletions.
27 changes: 0 additions & 27 deletions src/Artemis.Core/Events/Plugins/DeviceProviderEventArgs.cs

This file was deleted.

13 changes: 2 additions & 11 deletions src/Artemis.Core/Models/ProfileConfiguration/Hotkey.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Artemis.Core.Services;
using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile;

namespace Artemis.Core;
Expand All @@ -17,14 +16,6 @@ public Hotkey()
Entity = new ProfileConfigurationHotkeyEntity();
}

/// <inheritdoc />
public Hotkey(KeyboardKey? key, KeyboardModifierKey? modifiers)
{
Key = key;
Modifiers = modifiers;
Entity = new ProfileConfigurationHotkeyEntity();
}

/// <summary>
/// Creates a new instance of <see cref="Hotkey" /> based on the provided entity
/// </summary>
Expand Down Expand Up @@ -55,7 +46,7 @@ public Hotkey(ProfileConfigurationHotkeyEntity entity)
/// <returns><see langword="true" /> if the event args match the hotkey; otherwise <see langword="false" /></returns>
public bool MatchesEventArgs(ArtemisKeyboardKeyEventArgs eventArgs)
{
return eventArgs.Key == Key && (eventArgs.Modifiers == Modifiers || (eventArgs.Modifiers == KeyboardModifierKey.None && Modifiers == null));
return eventArgs.Key == Key && eventArgs.Modifiers == Modifiers;
}

#region Implementation of IStorageModel
Expand Down
77 changes: 4 additions & 73 deletions src/Artemis.Core/Models/Surface/ArtemisDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@ namespace Artemis.Core;
/// </summary>
public class ArtemisDevice : CorePropertyChanged
{
private readonly List<OriginalLed> _originalLeds;
private readonly Size _originalSize;
private SKPath? _path;
private SKRect _rectangle;

internal ArtemisDevice(IRGBDevice rgbDevice, DeviceProvider deviceProvider)
{
_originalLeds = new List<OriginalLed>(rgbDevice.Select(l => new OriginalLed(l)));
Rectangle ledRectangle = new(rgbDevice.Select(x => x.Boundary));
_originalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);

Identifier = rgbDevice.GetDeviceIdentifier();
DeviceEntity = new DeviceEntity();
RgbDevice = rgbDevice;
Expand Down Expand Up @@ -54,10 +48,6 @@ internal ArtemisDevice(IRGBDevice rgbDevice, DeviceProvider deviceProvider)

internal ArtemisDevice(IRGBDevice rgbDevice, DeviceProvider deviceProvider, DeviceEntity deviceEntity)
{
_originalLeds = new List<OriginalLed>(rgbDevice.Select(l => new OriginalLed(l)));
Rectangle ledRectangle = new(rgbDevice.Select(x => x.Boundary));
_originalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);

Identifier = rgbDevice.GetDeviceIdentifier();
DeviceEntity = deviceEntity;
RgbDevice = rgbDevice;
Expand Down Expand Up @@ -360,40 +350,6 @@ public override string ToString()
return artemisLed;
}

/// <summary>
/// Returns the most preferred device layout for this device.
/// </summary>
/// <returns>The most preferred device layout for this device.</returns>
public ArtemisLayout? GetBestDeviceLayout()
{
ArtemisLayout? layout;

// Configured layout path takes precedence over all other options
if (CustomLayoutPath != null)
{
layout = new ArtemisLayout(CustomLayoutPath, LayoutSource.Configured);
if (layout.IsValid)
return layout;
}

// Look for a layout provided by the user
layout = DeviceProvider.LoadUserLayout(this);
if (layout.IsValid)
return layout;

if (DisableDefaultLayout)
return null;

// Look for a layout provided by the plugin
layout = DeviceProvider.LoadLayout(this);
if (layout.IsValid)
return layout;

// Finally fall back to a default layout
layout = ArtemisLayout.GetDefaultLayout(this);
return layout;
}

/// <summary>
/// Occurs when the underlying RGB.NET device was updated
/// </summary>
Expand Down Expand Up @@ -459,52 +415,27 @@ protected virtual void OnDeviceUpdated()
/// A boolean indicating whether to remove excess LEDs present in the device but missing
/// in the layout
/// </param>
internal void ApplyLayout(ArtemisLayout? layout, bool createMissingLeds, bool removeExcessiveLeds)
internal void ApplyLayout(ArtemisLayout layout, bool createMissingLeds, bool removeExcessiveLeds)
{
if (layout == null)
{
ClearLayout();
UpdateLeds();

CalculateRenderProperties();
OnDeviceUpdated();
return;
}

if (createMissingLeds && !DeviceProvider.CreateMissingLedsSupported)
throw new ArtemisCoreException($"Cannot apply layout with {nameof(createMissingLeds)} " +
"set to true because the device provider does not support it");
if (removeExcessiveLeds && !DeviceProvider.RemoveExcessiveLedsSupported)
throw new ArtemisCoreException($"Cannot apply layout with {nameof(removeExcessiveLeds)} " +
"set to true because the device provider does not support it");

ClearLayout();
if (layout.IsValid)
layout.ApplyTo(RgbDevice, createMissingLeds, removeExcessiveLeds);


UpdateLeds();

Layout = layout;
Layout.ApplyDevice(this);

CalculateRenderProperties();
OnDeviceUpdated();
}

private void ClearLayout()
{
if (Layout == null)
return;

RgbDevice.DeviceInfo.LayoutMetadata = null;
RgbDevice.Size = _originalSize;
Layout = null;

while (RgbDevice.Any())
RgbDevice.RemoveLed(RgbDevice.First().Id);
foreach (OriginalLed originalLed in _originalLeds)
RgbDevice.AddLed(originalLed.Id, originalLed.Location, originalLed.Size, originalLed.CustomData);
}

internal void ApplyToEntity()
{
// Other properties are computed
Expand Down
4 changes: 2 additions & 2 deletions src/Artemis.Core/Models/Surface/ArtemisLed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ public override string ToString()

internal void CalculateRectangles()
{
Rectangle = RenderScale.CreateScaleCompatibleRect(
Rectangle = Utilities.CreateScaleCompatibleRect(
RgbLed.Boundary.Location.X,
RgbLed.Boundary.Location.Y,
RgbLed.Boundary.Size.Width,
RgbLed.Boundary.Size.Height
);
AbsoluteRectangle = RenderScale.CreateScaleCompatibleRect(
AbsoluteRectangle = Utilities.CreateScaleCompatibleRect(
RgbLed.AbsoluteBoundary.Location.X,
RgbLed.AbsoluteBoundary.Location.Y,
RgbLed.AbsoluteBoundary.Size.Width,
Expand Down
19 changes: 0 additions & 19 deletions src/Artemis.Core/Models/Surface/OriginalLed.cs

This file was deleted.

23 changes: 0 additions & 23 deletions src/Artemis.Core/Services/Core/IRenderer.cs

This file was deleted.

Loading

0 comments on commit ebf4099

Please sign in to comment.