mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Nodes - Aded popout editor
This commit is contained in:
parent
afc4bee7ac
commit
7d3f5da3c9
@ -5,6 +5,7 @@ using Artemis.Core.ScriptingProviders;
|
||||
using Artemis.UI.Screens.Header;
|
||||
using Artemis.UI.Screens.Plugins;
|
||||
using Artemis.UI.Screens.ProfileEditor.Conditions;
|
||||
using Artemis.UI.Screens.ProfileEditor.DisplayConditions;
|
||||
using Artemis.UI.Screens.ProfileEditor.LayerProperties;
|
||||
using Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings;
|
||||
using Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.ConditionalDataBinding;
|
||||
@ -17,6 +18,7 @@ using Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs.AdaptionHints;
|
||||
using Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem;
|
||||
using Artemis.UI.Screens.ProfileEditor.Visualization;
|
||||
using Artemis.UI.Screens.ProfileEditor.Visualization.Tools;
|
||||
using Artemis.UI.Screens.ProfileEditor.Windows;
|
||||
using Artemis.UI.Screens.Scripting;
|
||||
using Artemis.UI.Screens.Settings.Device;
|
||||
using Artemis.UI.Screens.Settings.Device.Tabs;
|
||||
@ -124,6 +126,11 @@ namespace Artemis.UI.Ninject.Factories
|
||||
ModuleActivationRequirementViewModel ModuleActivationRequirementViewModel(IModuleActivationRequirement activationRequirement);
|
||||
}
|
||||
|
||||
public interface INodeVmFactory : IVmFactory
|
||||
{
|
||||
NodeScriptWindowViewModel NodeScriptWindowViewModel(NodeScript nodeScript);
|
||||
}
|
||||
|
||||
// TODO: Move these two
|
||||
public interface IDataBindingsVmFactory
|
||||
{
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
xmlns:displayConditions="clr-namespace:Artemis.UI.Screens.ProfileEditor.DisplayConditions"
|
||||
xmlns:core="clr-namespace:Artemis.Core;assembly=Artemis.Core"
|
||||
xmlns:controls="clr-namespace:Artemis.VisualScripting.Editor.Controls;assembly=Artemis.VisualScripting"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.DisplayConditions.DisplayConditionsView"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
@ -16,6 +17,7 @@
|
||||
<UserControl.Resources>
|
||||
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
|
||||
<converters:ComparisonConverter x:Key="ComparisonConverter" />
|
||||
<shared:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Margin="10">
|
||||
@ -40,35 +42,36 @@
|
||||
|
||||
<Separator Grid.Row="1" Grid.Column="0" Style="{StaticResource MaterialDesignDarkSeparator}" Margin="-2 0" />
|
||||
|
||||
<Grid Grid.Row="2" Grid.Column="0">
|
||||
<controls:VisualScriptEditor Script="{Binding RenderProfileElement.DisplayCondition}" AvailableNodes="{Binding AvailableNodes}" />
|
||||
|
||||
<!--<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Background="{StaticResource MaterialDesignCardBackground}">
|
||||
<ContentControl s:View.Model="{Binding ActiveItem}" />
|
||||
</ScrollViewer>
|
||||
|
||||
<materialDesign:Card
|
||||
Visibility="{Binding DisplayStartHint, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
|
||||
VerticalAlignment="Top"
|
||||
Background="{DynamicResource PrimaryHueDarkBrush}"
|
||||
Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
|
||||
Margin="5 30 5 0"
|
||||
Padding="8"
|
||||
Width="315"
|
||||
HorizontalAlignment="Left">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<materialDesign:PackIcon Kind="Redo" Margin="0 0 5 0">
|
||||
<materialDesign:PackIcon.RenderTransform>
|
||||
<RotateTransform Angle="225" CenterX="8" CenterY="8" />
|
||||
</materialDesign:PackIcon.RenderTransform>
|
||||
</materialDesign:PackIcon>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center">Click the plus icon to start using display conditions!</TextBlock>
|
||||
</Grid>
|
||||
</materialDesign:Card>-->
|
||||
<Grid Grid.Row="2" Grid.Column="0" MouseUp="{s:Action ScriptGridMouseUp}" Cursor="Hand">
|
||||
<controls:VisualScriptEditor Script="{Binding RenderProfileElement.DisplayCondition}"
|
||||
Visibility="{Binding RenderProfileElement.DisplayCondition, Converter={StaticResource NullToVisibilityConverter}}" />
|
||||
<Border Background="#CD353535" Opacity="0">
|
||||
<Border.Style>
|
||||
<Style>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type Grid}, Mode=FindAncestor}}" Value="True">
|
||||
<DataTrigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.25" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.EnterActions>
|
||||
<DataTrigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.25" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.ExitActions>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center">Click to edit script</TextBlock>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="3" Visibility="{Binding IsEventCondition, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}">
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.ProfileEditor.Conditions;
|
||||
using Artemis.UI.Shared;
|
||||
@ -13,33 +11,17 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
||||
{
|
||||
public class DisplayConditionsViewModel : Conductor<DataModelConditionGroupViewModel>, IProfileEditorPanelViewModel
|
||||
{
|
||||
private readonly IDataModelConditionsVmFactory _dataModelConditionsVmFactory;
|
||||
private readonly INodeVmFactory _nodeVmFactory;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly INodeService _nodeService;
|
||||
private RenderProfileElement _renderProfileElement;
|
||||
private bool _displayStartHint;
|
||||
private readonly IWindowManager _windowManager;
|
||||
private bool _isEventCondition;
|
||||
private RenderProfileElement _renderProfileElement;
|
||||
|
||||
public DisplayConditionsViewModel(IProfileEditorService profileEditorService, INodeService nodeService, IDataModelConditionsVmFactory dataModelConditionsVmFactory)
|
||||
public DisplayConditionsViewModel(IProfileEditorService profileEditorService, IWindowManager windowManager, INodeVmFactory nodeVmFactory)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
_nodeService = nodeService;
|
||||
_dataModelConditionsVmFactory = dataModelConditionsVmFactory;
|
||||
|
||||
AvailableNodes = _nodeService.AvailableNodes;
|
||||
}
|
||||
|
||||
private IEnumerable<NodeData> _availableNodes;
|
||||
public IEnumerable<NodeData> AvailableNodes
|
||||
{
|
||||
get => _availableNodes;
|
||||
set => SetAndNotify(ref _availableNodes, value);
|
||||
}
|
||||
|
||||
public bool DisplayStartHint
|
||||
{
|
||||
get => _displayStartHint;
|
||||
set => SetAndNotify(ref _displayStartHint, value);
|
||||
_windowManager = windowManager;
|
||||
_nodeVmFactory = nodeVmFactory;
|
||||
}
|
||||
|
||||
public bool IsEventCondition
|
||||
@ -111,19 +93,9 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
private void SelectedProfileEditorServiceOnSelectedProfileElementChanged(object sender, RenderProfileElementEventArgs e)
|
||||
{
|
||||
Update(e.RenderProfileElement);
|
||||
}
|
||||
|
||||
private void Update(RenderProfileElement renderProfileElement)
|
||||
{
|
||||
if (RenderProfileElement != null)
|
||||
{
|
||||
//RenderProfileElement.DisplayCondition.ChildAdded -= DisplayConditionOnChildrenModified;
|
||||
//RenderProfileElement.DisplayCondition.ChildRemoved -= DisplayConditionOnChildrenModified;
|
||||
RenderProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
}
|
||||
if (RenderProfileElement != null) RenderProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
|
||||
RenderProfileElement = renderProfileElement;
|
||||
|
||||
@ -137,27 +109,32 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure the layer has a root display condition group
|
||||
//if (renderProfileElement.DisplayCondition == null)
|
||||
// renderProfileElement.DisplayCondition = new DataModelConditionGroup(null);
|
||||
|
||||
if (renderProfileElement.DisplayCondition == null)
|
||||
renderProfileElement.DisplayCondition = new NodeScript<bool>("Display Condition (TODO)", "-");
|
||||
|
||||
//List<Module> modules = new();
|
||||
//if (_profileEditorService.SelectedProfileConfiguration?.Module != null)
|
||||
// modules.Add(_profileEditorService.SelectedProfileConfiguration.Module);
|
||||
//ActiveItem = _dataModelConditionsVmFactory.DataModelConditionGroupViewModel(renderProfileElement.DisplayCondition, ConditionGroupType.General, modules);
|
||||
//ActiveItem.IsRootGroup = true;
|
||||
|
||||
//DisplayStartHint = !RenderProfileElement.DisplayCondition.Children.Any();
|
||||
//IsEventCondition = RenderProfileElement.DisplayCondition.Children.Any(c => c is DataModelConditionEvent);
|
||||
|
||||
//RenderProfileElement.DisplayCondition.ChildAdded += DisplayConditionOnChildrenModified;
|
||||
//RenderProfileElement.DisplayCondition.ChildRemoved += DisplayConditionOnChildrenModified;
|
||||
RenderProfileElement.Timeline.PropertyChanged += TimelineOnPropertyChanged;
|
||||
}
|
||||
|
||||
#region Event handlers
|
||||
|
||||
public void ScriptGridMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton != MouseButton.Left)
|
||||
return;
|
||||
|
||||
RenderProfileElement.DisplayCondition ??= new NodeScript<bool>("End Result", "");
|
||||
|
||||
_windowManager.ShowDialog(_nodeVmFactory.NodeScriptWindowViewModel(RenderProfileElement.DisplayCondition));
|
||||
_profileEditorService.SaveSelectedProfileElement();
|
||||
}
|
||||
|
||||
public void EventTriggerModeSelected()
|
||||
{
|
||||
_profileEditorService.SaveSelectedProfileElement();
|
||||
}
|
||||
|
||||
private void SelectedProfileEditorServiceOnSelectedProfileElementChanged(object sender, RenderProfileElementEventArgs e)
|
||||
{
|
||||
Update(e.RenderProfileElement);
|
||||
}
|
||||
|
||||
private void TimelineOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(DisplayContinuously));
|
||||
@ -165,15 +142,6 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
||||
NotifyOfPropertyChange(nameof(EventOverlapMode));
|
||||
}
|
||||
|
||||
private void DisplayConditionOnChildrenModified(object sender, EventArgs e)
|
||||
{
|
||||
//DisplayStartHint = !RenderProfileElement.DisplayCondition.Children.Any();
|
||||
//IsEventCondition = RenderProfileElement.DisplayCondition.Children.Any(c => c is DataModelConditionEvent);
|
||||
}
|
||||
|
||||
public void EventTriggerModeSelected()
|
||||
{
|
||||
_profileEditorService.SaveSelectedProfileElement();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
<mde:MaterialWindow x:Class="Artemis.UI.Screens.ProfileEditor.Windows.NodeScriptWindowView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mde="https://spiegelp.github.io/MaterialDesignExtensions/winfx/xaml"
|
||||
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
|
||||
xmlns:controls="clr-namespace:Artemis.VisualScripting.Editor.Controls;assembly=Artemis.VisualScripting"
|
||||
xmlns:windows="clr-namespace:Artemis.UI.Screens.ProfileEditor.Windows"
|
||||
mc:Ignorable="d"
|
||||
Title="Node Script | Artemis"
|
||||
TitleBarIcon="{svgc:SvgImage Source=/Resources/Images/Logo/bow-white.svg}"
|
||||
Foreground="{DynamicResource MaterialDesignBody}"
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
|
||||
UseLayoutRounding="True"
|
||||
FadeContentIfInactive="False"
|
||||
Width="1200"
|
||||
Height="1000"
|
||||
d:DesignHeight="800" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance windows:NodeScriptWindowViewModel}"
|
||||
Icon="/Resources/Images/Logo/bow.ico">
|
||||
<Grid>
|
||||
<controls:VisualScriptEditor Script="{Binding NodeScript}" AvailableNodes="{Binding AvailableNodes}" />
|
||||
</Grid>
|
||||
</mde:MaterialWindow>
|
||||
@ -0,0 +1,18 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Windows
|
||||
{
|
||||
public class NodeScriptWindowViewModel : Screen
|
||||
{
|
||||
public NodeScriptWindowViewModel(NodeScript nodeScript, INodeService nodeService)
|
||||
{
|
||||
NodeScript = nodeScript;
|
||||
AvailableNodes = new BindableCollection<NodeData>(nodeService.AvailableNodes);
|
||||
}
|
||||
|
||||
public NodeScript NodeScript { get; }
|
||||
public BindableCollection<NodeData> AvailableNodes { get; }
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user