mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Modules - Added enable override mechanism
Profile modules - Added animated module enable/disable
This commit is contained in:
1 parent
73e992bbb7
commit
ed479abebc
21 files changed
+442
-122
No files matched your search
@@ -51,6 +51,14 @@ namespace Artemis.Core.Services.Storage.Interfaces
|
||||
/// <param name="profileModule"></param>
|
||||
void ActivateLastProfile(ProfileModule profileModule);
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously activates the last profile of the given profile module using a fade animation
|
||||
/// </summary>
|
||||
/// <param name="profileModule"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
Task ActivateLastProfileAnimated(ProfileModule profileModule);
|
||||
|
||||
/// <summary>
|
||||
/// Activates the profile described in the given <see cref="ProfileDescriptor" /> with the currently active surface
|
||||
/// </summary>
|
||||
|
||||
@@ -64,6 +64,13 @@ namespace Artemis.Core.Services.Storage
|
||||
ActivateProfile(activeProfile);
|
||||
}
|
||||
|
||||
public async Task ActivateLastProfileAnimated(ProfileModule profileModule)
|
||||
{
|
||||
var activeProfile = GetLastActiveProfile(profileModule);
|
||||
if (activeProfile != null)
|
||||
await ActivateProfileAnimated(activeProfile);
|
||||
}
|
||||
|
||||
public Profile ActivateProfile(ProfileDescriptor profileDescriptor)
|
||||
{
|
||||
if (profileDescriptor.ProfileModule.ActiveProfile?.EntityId == profileDescriptor.Id)
|
||||
@@ -94,12 +101,25 @@ namespace Artemis.Core.Services.Storage
|
||||
var profile = new Profile(profileDescriptor.ProfileModule, profileEntity);
|
||||
InstantiateProfile(profile);
|
||||
|
||||
void ActivatingProfileSurfaceUpdate(object sender, SurfaceConfigurationEventArgs e) => profile.PopulateLeds(e.Surface);
|
||||
void ActivatingProfilePluginToggle(object sender, PluginEventArgs e) => InstantiateProfile(profile);
|
||||
|
||||
// This could happen during activation so subscribe to it
|
||||
_pluginService.PluginEnabled += ActivatingProfilePluginToggle;
|
||||
_pluginService.PluginDisabled += ActivatingProfilePluginToggle;
|
||||
_surfaceService.SurfaceConfigurationUpdated += ActivatingProfileSurfaceUpdate;
|
||||
|
||||
await profileDescriptor.ProfileModule.ChangeActiveProfileAnimated(profile, _surfaceService.ActiveSurface);
|
||||
SaveActiveProfile(profileDescriptor.ProfileModule);
|
||||
|
||||
_pluginService.PluginEnabled -= ActivatingProfilePluginToggle;
|
||||
_pluginService.PluginDisabled -= ActivatingProfilePluginToggle;
|
||||
_surfaceService.SurfaceConfigurationUpdated -= ActivatingProfileSurfaceUpdate;
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
||||
public void ClearActiveProfile(ProfileModule module)
|
||||
{
|
||||
module.ChangeActiveProfile(null, _surfaceService.ActiveSurface);
|
||||
@@ -234,6 +254,9 @@ namespace Artemis.Core.Services.Storage
|
||||
|
||||
private void SaveActiveProfile(ProfileModule module)
|
||||
{
|
||||
if (module.ActiveProfile == null)
|
||||
return;
|
||||
|
||||
var profileEntities = _profileRepository.GetByPluginGuid(module.PluginInfo.Guid);
|
||||
foreach (var profileEntity in profileEntities)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user