mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Event condition - Added toggle off mode
Profile editor - Added element copy/pasting Shared UI - Fix namespaces
This commit is contained in:
1 parent
8c7bbc3f0f
commit
52f2338154
84 files changed
+1059
-608
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Events;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Branching;
|
||||
|
||||
[Node("Branch", "Forwards one of two values depending on an input boolean", "Branching", InputType = typeof(object), OutputType = typeof(object))]
|
||||
public class BooleanBranchNode : Node
|
||||
{
|
||||
public BooleanBranchNode() : base("Branch", "Forwards one of two values depending on an input boolean")
|
||||
{
|
||||
BooleanInput = CreateInputPin<bool>();
|
||||
TrueInput = CreateInputPin(typeof(object), "True");
|
||||
FalseInput = CreateInputPin(typeof(object), "False");
|
||||
|
||||
Output = CreateOutputPin(typeof(object));
|
||||
|
||||
TrueInput.PinConnected += InputPinConnected;
|
||||
FalseInput.PinConnected += InputPinConnected;
|
||||
TrueInput.PinDisconnected += InputPinDisconnected;
|
||||
FalseInput.PinDisconnected += InputPinDisconnected;
|
||||
}
|
||||
|
||||
private void InputPinConnected(object? sender, SingleValueEventArgs<IPin> e)
|
||||
{
|
||||
if (TrueInput.ConnectedTo.Any() && !FalseInput.ConnectedTo.Any())
|
||||
ChangeType(TrueInput.ConnectedTo.First().Type);
|
||||
if (FalseInput.ConnectedTo.Any() && !TrueInput.ConnectedTo.Any())
|
||||
ChangeType(FalseInput.ConnectedTo.First().Type);
|
||||
}
|
||||
|
||||
private void InputPinDisconnected(object? sender, SingleValueEventArgs<IPin> e)
|
||||
{
|
||||
if (!TrueInput.ConnectedTo.Any() && !FalseInput.ConnectedTo.Any())
|
||||
ChangeType(typeof(object));
|
||||
}
|
||||
|
||||
private void ChangeType(Type type)
|
||||
{
|
||||
TrueInput.ChangeType(type);
|
||||
FalseInput.ChangeType(type);
|
||||
Output.ChangeType(type);
|
||||
}
|
||||
|
||||
public InputPin<bool> BooleanInput { get; set; }
|
||||
public InputPin TrueInput { get; set; }
|
||||
public InputPin FalseInput { get; set; }
|
||||
|
||||
public OutputPin Output { get; set; }
|
||||
|
||||
#region Overrides of Node
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = BooleanInput.Value ? TrueInput.Value : FalseInput.Value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -12,8 +12,9 @@ public class DataModelEventNode : Node<DataModelPathEntity, DataModelEventNodeCu
|
||||
private int _currentIndex;
|
||||
private Type _currentType;
|
||||
private DataModelPath? _dataModelPath;
|
||||
private DateTime _lastTrigger;
|
||||
private bool _updating;
|
||||
private DateTime _lastTrigger;
|
||||
private object? _lastPathValue;
|
||||
|
||||
public DataModelEventNode() : base("Data Model-Event", "Responds to a data model event trigger")
|
||||
{
|
||||
@@ -47,27 +48,44 @@ public class DataModelEventNode : Node<DataModelPathEntity, DataModelEventNodeCu
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
object? outputValue = null;
|
||||
if (_dataModelPath?.GetValue() is IDataModelEvent dataModelEvent)
|
||||
object? pathValue = _dataModelPath?.GetValue();
|
||||
bool hasTriggered = pathValue is IDataModelEvent dataModelEvent
|
||||
? EvaluateEvent(dataModelEvent)
|
||||
: EvaluateValue(pathValue);
|
||||
|
||||
if (hasTriggered)
|
||||
{
|
||||
if (dataModelEvent.LastTrigger > _lastTrigger)
|
||||
{
|
||||
_lastTrigger = dataModelEvent.LastTrigger;
|
||||
_currentIndex++;
|
||||
_currentIndex++;
|
||||
|
||||
if (_currentIndex >= CycleValues.Count())
|
||||
_currentIndex = 0;
|
||||
}
|
||||
|
||||
outputValue = CycleValues.ElementAt(_currentIndex).PinValue;
|
||||
if (_currentIndex >= CycleValues.Count())
|
||||
_currentIndex = 0;
|
||||
}
|
||||
|
||||
object? outputValue = CycleValues.ElementAt(_currentIndex).PinValue;
|
||||
if (Output.Type.IsInstanceOfType(outputValue))
|
||||
Output.Value = outputValue;
|
||||
else if (Output.Type.IsValueType)
|
||||
Output.Value = Output.Type.GetDefault()!;
|
||||
}
|
||||
|
||||
private bool EvaluateEvent(IDataModelEvent dataModelEvent)
|
||||
{
|
||||
if (dataModelEvent.LastTrigger <= _lastTrigger)
|
||||
return false;
|
||||
|
||||
_lastTrigger = dataModelEvent.LastTrigger;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool EvaluateValue(object? pathValue)
|
||||
{
|
||||
if (Equals(pathValue, _lastPathValue))
|
||||
return false;
|
||||
|
||||
_lastPathValue = pathValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CycleValuesOnPinAdded(object? sender, SingleValueEventArgs<IPin> e)
|
||||
{
|
||||
e.Value.PinConnected += OnPinConnected;
|
||||
@@ -109,7 +127,6 @@ public class DataModelEventNode : Node<DataModelPathEntity, DataModelEventNodeCu
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void UpdateDataModelPath()
|
||||
{
|
||||
DataModelPath? old = _dataModelPath;
|
||||
|
||||
+5
-3
@@ -2,8 +2,8 @@
|
||||
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:dataModelPicker="clr-namespace:Artemis.UI.Shared.Controls.DataModelPicker;assembly=Artemis.UI.Shared"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.DataModel.Screens"
|
||||
xmlns:dataModelPicker="clr-namespace:Artemis.UI.Shared.DataModelPicker;assembly=Artemis.UI.Shared"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.DataModel.Screens.DataModelEventNodeCustomView"
|
||||
x:DataType="screens:DataModelEventNodeCustomViewModel">
|
||||
@@ -11,6 +11,8 @@
|
||||
DataModelPath="{CompiledBinding DataModelPath}"
|
||||
Modules="{CompiledBinding Modules}"
|
||||
ShowDataModelValues="{CompiledBinding ShowDataModelValues.Value}"
|
||||
FilterTypes="{CompiledBinding FilterTypes}"
|
||||
VerticalAlignment="Top"/>
|
||||
ShowFullPath="{CompiledBinding ShowFullPaths.Value}"
|
||||
IsEventPicker="True"
|
||||
VerticalAlignment="Top"
|
||||
MaxWidth="300"/>
|
||||
</UserControl>
|
||||
-1
@@ -50,7 +50,6 @@ public class DataModelEventNodeCustomViewModel : CustomNodeViewModel
|
||||
|
||||
public PluginSetting<bool> ShowFullPaths { get; }
|
||||
public PluginSetting<bool> ShowDataModelValues { get; }
|
||||
public ObservableCollection<Type> FilterTypes { get; } = new() {typeof(IDataModelEvent)};
|
||||
|
||||
public ObservableCollection<Module>? Modules
|
||||
{
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
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:dataModelPicker="clr-namespace:Artemis.UI.Shared.Controls.DataModelPicker;assembly=Artemis.UI.Shared"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.DataModel.Screens"
|
||||
xmlns:dataModelPicker="clr-namespace:Artemis.UI.Shared.DataModelPicker;assembly=Artemis.UI.Shared"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.DataModel.Screens.DataModelNodeCustomView"
|
||||
x:DataType="screens:DataModelNodeCustomViewModel">
|
||||
@@ -11,5 +11,6 @@
|
||||
DataModelPath="{CompiledBinding DataModelPath}"
|
||||
Modules="{CompiledBinding Modules}"
|
||||
ShowDataModelValues="{CompiledBinding ShowDataModelValues.Value}"
|
||||
ShowFullPath="{CompiledBinding ShowFullPaths.Value}"/>
|
||||
ShowFullPath="{CompiledBinding ShowFullPaths.Value}"
|
||||
MaxWidth="300"/>
|
||||
</UserControl>
|
||||
@@ -9,7 +9,7 @@
|
||||
<ComboBox IsEnabled="{CompiledBinding EnumValues.Count}"
|
||||
Items="{CompiledBinding EnumValues}"
|
||||
SelectedIndex="{CompiledBinding CurrentValue}"
|
||||
PlaceholderText="Connect a pin..."
|
||||
PlaceholderText="Select a value"
|
||||
Classes="condensed"
|
||||
VerticalAlignment="Center" />
|
||||
</UserControl>
|
||||
Reference in new issue
Block a user