mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Core - Reworked profile render override for the editor and new previewer
This commit is contained in:
1 parent
c6a318b6e3
commit
d2b8123a30
42 files changed
+812
-399
No files matched your search
@@ -10,7 +10,6 @@ using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Shared.Services.MainWindow;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||
using Avalonia.Threading;
|
||||
using DynamicData;
|
||||
using Serilog;
|
||||
|
||||
@@ -140,14 +139,14 @@ internal class ProfileEditorService : IProfileEditorService
|
||||
private void ApplyFocusMode()
|
||||
{
|
||||
if (_suspendedEditingSubject.Value)
|
||||
_profileService.EditorFocus = null;
|
||||
_profileService.FocusProfileElement = null;
|
||||
|
||||
_profileService.EditorFocus = _focusModeSubject.Value switch
|
||||
_profileService.FocusProfileElement = _focusModeSubject.Value switch
|
||||
{
|
||||
ProfileEditorFocusMode.None => null,
|
||||
ProfileEditorFocusMode.Folder => _profileElementSubject.Value?.Parent,
|
||||
ProfileEditorFocusMode.Selection => _profileElementSubject.Value,
|
||||
_ => _profileService.EditorFocus
|
||||
_ => _profileService.FocusProfileElement
|
||||
};
|
||||
}
|
||||
|
||||
@@ -164,52 +163,38 @@ internal class ProfileEditorService : IProfileEditorService
|
||||
|
||||
public async Task ChangeCurrentProfileConfiguration(ProfileConfiguration? profileConfiguration)
|
||||
{
|
||||
if (ReferenceEquals(_profileConfigurationSubject.Value, profileConfiguration))
|
||||
ProfileConfiguration? previous = _profileConfigurationSubject.Value;
|
||||
if (ReferenceEquals(previous, profileConfiguration))
|
||||
return;
|
||||
|
||||
_logger.Verbose("ChangeCurrentProfileConfiguration {profile}", profileConfiguration);
|
||||
|
||||
// Stop playing and save the current profile
|
||||
Pause();
|
||||
if (_profileConfigurationSubject.Value?.Profile != null)
|
||||
{
|
||||
_profileConfigurationSubject.Value.Profile.Reset();
|
||||
_profileConfigurationSubject.Value.Profile.LastSelectedProfileElement = _profileElementSubject.Value;
|
||||
}
|
||||
|
||||
await SaveProfileAsync();
|
||||
|
||||
// No need to deactivate the profile, if needed it will be deactivated next update
|
||||
if (_profileConfigurationSubject.Value != null)
|
||||
_profileConfigurationSubject.Value.IsBeingEdited = false;
|
||||
|
||||
// Deselect whatever profile element was active
|
||||
ChangeCurrentProfileElement(null);
|
||||
ChangeSuspendedEditing(false);
|
||||
|
||||
// Close the command scope if one was open
|
||||
_profileEditorHistoryScope?.Dispose();
|
||||
|
||||
// The new profile may need activation
|
||||
if (profileConfiguration != null)
|
||||
// Activate the profile and it's mode off of the UI thread
|
||||
await Task.Run(() =>
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
profileConfiguration.IsBeingEdited = true;
|
||||
_moduleService.SetActivationOverride(profileConfiguration.Module);
|
||||
// Activate the profile if one was provided
|
||||
if (profileConfiguration != null)
|
||||
_profileService.ActivateProfile(profileConfiguration);
|
||||
_profileService.RenderForEditor = true;
|
||||
});
|
||||
if (profileConfiguration.Profile?.LastSelectedProfileElement is RenderProfileElement renderProfileElement)
|
||||
ChangeCurrentProfileElement(renderProfileElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
_moduleService.SetActivationOverride(null);
|
||||
_profileService.RenderForEditor = false;
|
||||
}
|
||||
// If there is no profile configuration or module, deliberately set the override to null
|
||||
_moduleService.SetActivationOverride(profileConfiguration?.Module);
|
||||
});
|
||||
|
||||
_profileService.FocusProfile = profileConfiguration;
|
||||
_profileConfigurationSubject.OnNext(profileConfiguration);
|
||||
|
||||
ChangeTime(TimeSpan.Zero);
|
||||
previous?.Profile?.Reset();
|
||||
}
|
||||
|
||||
public void ChangeCurrentProfileElement(RenderProfileElement? renderProfileElement)
|
||||
@@ -238,23 +223,23 @@ internal class ProfileEditorService : IProfileEditorService
|
||||
if (_suspendedEditingSubject.Value == suspend)
|
||||
return;
|
||||
|
||||
_suspendedEditingSubject.OnNext(suspend);
|
||||
if (suspend)
|
||||
{
|
||||
Pause();
|
||||
_profileService.RenderForEditor = false;
|
||||
_profileService.UpdateFocusProfile = true;
|
||||
_profileConfigurationSubject.Value?.Profile?.Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_profileConfigurationSubject.Value != null)
|
||||
_profileService.RenderForEditor = true;
|
||||
_profileService.UpdateFocusProfile = false;
|
||||
Tick(_timeSubject.Value);
|
||||
}
|
||||
|
||||
_suspendedEditingSubject.OnNext(suspend);
|
||||
ApplyFocusMode();
|
||||
}
|
||||
|
||||
|
||||
public void ChangeFocusMode(ProfileEditorFocusMode focusMode)
|
||||
{
|
||||
if (_focusModeSubject.Value == focusMode)
|
||||
@@ -411,10 +396,8 @@ internal class ProfileEditorService : IProfileEditorService
|
||||
public void SaveProfile()
|
||||
{
|
||||
Profile? profile = _profileConfigurationSubject.Value?.Profile;
|
||||
if (profile == null)
|
||||
return;
|
||||
|
||||
_profileService.SaveProfile(profile, true);
|
||||
if (profile != null)
|
||||
_profileService.SaveProfile(profile, true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -10,15 +10,10 @@
|
||||
<TextBlock Classes="h5">This is heading 5</TextBlock>
|
||||
<TextBlock Classes="h6">This is heading 6</TextBlock>
|
||||
<TextBlock Classes="subtitle">This is a subtitle</TextBlock>
|
||||
<TextBlock>
|
||||
<Run Classes="h1">This is heading 1</Run>
|
||||
<Run Classes="h2">This is heading 2</Run>
|
||||
<Run Classes="h3">This is heading 3</Run>
|
||||
<Run Classes="h4">This is heading 4</Run>
|
||||
<Run Classes="h5">This is heading 5</Run>
|
||||
<Run Classes="h6">This is heading 6</Run>
|
||||
<Run Classes="subtitle">This is a subtitle</Run>
|
||||
</TextBlock>
|
||||
<TextBlock Classes="danger">Danger</TextBlock>
|
||||
<TextBlock Classes="warning">Warning</TextBlock>
|
||||
<TextBlock Classes="success">Success</TextBlock>
|
||||
<TextBlock Classes="info">Info</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Design.PreviewWith>
|
||||
@@ -81,4 +76,30 @@
|
||||
<Style Selector="Run.subtitle">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextFillColorTertiaryBrush}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="TextBlock.danger">
|
||||
<Setter Property="Foreground" Value="#FF5C5C"></Setter>
|
||||
</Style>
|
||||
<Style Selector="TextBlock.warning">
|
||||
<Setter Property="Foreground" Value="#DAA520"></Setter>
|
||||
</Style>
|
||||
<Style Selector="TextBlock.success">
|
||||
<Setter Property="Foreground" Value="#12B775"></Setter>
|
||||
</Style>
|
||||
<Style Selector="TextBlock.info">
|
||||
<Setter Property="Foreground" Value="{DynamicResource AccentButtonBackground}"></Setter>
|
||||
</Style>
|
||||
|
||||
<Style Selector="Run.danger">
|
||||
<Setter Property="Foreground" Value="#FF5C5C"></Setter>
|
||||
</Style>
|
||||
<Style Selector="Run.warning">
|
||||
<Setter Property="Foreground" Value="#DAA520"></Setter>
|
||||
</Style>
|
||||
<Style Selector="Run.success">
|
||||
<Setter Property="Foreground" Value="#12B775"></Setter>
|
||||
</Style>
|
||||
<Style Selector="Run.info">
|
||||
<Setter Property="Foreground" Value="{DynamicResource AccentButtonBackground}"></Setter>
|
||||
</Style>
|
||||
</Styles>
|
||||
Reference in new issue
Block a user