mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Core - Updated RGB.NET
Plugins - Allow device providers to override the device layout name
This commit is contained in:
1 parent
8b1ce4e0ec
commit
3c827d1a0a
10 files changed
+75
-75
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Ninject;
|
||||
using RGB.NET.Core;
|
||||
using Serilog;
|
||||
@@ -75,7 +76,7 @@ namespace Artemis.Core.DeviceProviders
|
||||
layoutDir,
|
||||
device.RgbDevice.DeviceInfo.Manufacturer,
|
||||
device.DeviceType.ToString(),
|
||||
device.GetLayoutFileName()
|
||||
GetDeviceLayoutName(device)
|
||||
);
|
||||
return new ArtemisLayout(filePath, LayoutSource.Plugin);
|
||||
}
|
||||
@@ -92,7 +93,7 @@ namespace Artemis.Core.DeviceProviders
|
||||
layoutDir,
|
||||
device.RgbDevice.DeviceInfo.Manufacturer,
|
||||
device.DeviceType.ToString(),
|
||||
device.GetLayoutFileName()
|
||||
GetDeviceLayoutName(device)
|
||||
);
|
||||
return new ArtemisLayout(filePath, LayoutSource.User);
|
||||
}
|
||||
@@ -108,5 +109,20 @@ namespace Artemis.Core.DeviceProviders
|
||||
{
|
||||
throw new NotImplementedException("Device provider does not support detecting logical layouts (don't call base.GetLogicalLayout())");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when determining which file name to use when loading the layout of the specified <paramref name="device"></paramref>.
|
||||
/// </summary>
|
||||
/// <param name="device">The device to determine the layout file name for.</param>
|
||||
/// <returns>A file name, including an extension</returns>
|
||||
public virtual string GetDeviceLayoutName(ArtemisDevice device)
|
||||
{
|
||||
// Take out invalid file name chars, may not be perfect but neither are you
|
||||
string fileName = Path.GetInvalidFileNameChars().Aggregate(device.RgbDevice.DeviceInfo.Model, (current, c) => current.Replace(c, '-'));
|
||||
if (device.RgbDevice.DeviceInfo.DeviceType == RGBDeviceType.Keyboard)
|
||||
fileName = $"{fileName}-{device.PhysicalLayout.ToString().ToUpper()}";
|
||||
|
||||
return fileName + ".xml";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user