mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Modules - Added activation requirements tab
Profile editor - Only override active profile with profile editor tab open
This commit is contained in:
1 parent
90383f2e41
commit
8d756128e4
12 files changed
+252
-53
No files matched your search
@@ -7,6 +7,7 @@ using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Modules;
|
||||
using Artemis.Core.Plugins.Settings;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.UI.Screens.ProfileEditor.Dialogs;
|
||||
using Artemis.UI.Screens.ProfileEditor.DisplayConditions;
|
||||
@@ -24,6 +25,7 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IModuleService _moduleService;
|
||||
private readonly ISnackbarMessageQueue _snackbarMessageQueue;
|
||||
private BindableCollection<ProfileDescriptor> _profiles;
|
||||
private PluginSetting<GridLength> _sidePanelsWidth;
|
||||
@@ -42,11 +44,13 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
IProfileService profileService,
|
||||
IDialogService dialogService,
|
||||
ISettingsService settingsService,
|
||||
IModuleService moduleService,
|
||||
ISnackbarMessageQueue snackbarMessageQueue)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
_profileService = profileService;
|
||||
_settingsService = settingsService;
|
||||
_moduleService = moduleService;
|
||||
_snackbarMessageQueue = snackbarMessageQueue;
|
||||
|
||||
DisplayName = "Profile editor";
|
||||
@@ -233,19 +237,21 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
LoadWorkspaceSettings();
|
||||
Module.IsProfileUpdatingDisabled = true;
|
||||
Module.ActiveProfileChanged += ModuleOnActiveProfileChanged;
|
||||
|
||||
Execute.PostToUIThread(LoadProfiles);
|
||||
LoadProfiles();
|
||||
|
||||
Task.Run(async () => { await _moduleService.SetActiveModuleOverride(Module); });
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
protected override void OnDeactivate()
|
||||
{
|
||||
SaveWorkspaceSettings();
|
||||
Module.IsProfileUpdatingDisabled = false;
|
||||
Module.ActiveProfileChanged -= ModuleOnActiveProfileChanged;
|
||||
|
||||
_profileEditorService.ChangeSelectedProfile(null);
|
||||
base.OnClose();
|
||||
Task.Run(async () => { await _moduleService.SetActiveModuleOverride(null); });
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
private void RemoveProfile(ProfileDescriptor profileDescriptor)
|
||||
@@ -309,19 +315,6 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
// Get all profiles from the database
|
||||
Profiles.Clear();
|
||||
Profiles.AddRange(_profileService.GetProfileDescriptors(Module).OrderBy(d => d.Name));
|
||||
|
||||
// Populate the selected profile
|
||||
var lastActiveProfile = Profiles.FirstOrDefault(p => p.IsLastActiveProfile) ?? Profiles.FirstOrDefault();
|
||||
if (lastActiveProfile != null)
|
||||
{
|
||||
SelectedProfile = lastActiveProfile;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a default profile if there is none
|
||||
var defaultProfile = _profileService.CreateProfileDescriptor(Module, "Default");
|
||||
Profiles.Add(defaultProfile);
|
||||
SelectedProfile = defaultProfile;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user