mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Core - Refactored display conditions
Profile editor - Added UIs for each condition type
This commit is contained in:
1 parent
66ea718316
commit
3dfc25b092
47 files changed
+1305
-546
No files matched your search
@@ -5,7 +5,7 @@ using Artemis.VisualScripting.Nodes.Operators.Screens;
|
||||
namespace Artemis.VisualScripting.Nodes.Operators;
|
||||
|
||||
[Node("Enum Equals", "Determines the equality between an input and a selected enum value", "Operators", InputType = typeof(Enum), OutputType = typeof(bool))]
|
||||
public class EnumEqualsNode : Node<Enum, EnumEqualsNodeCustomViewModel>
|
||||
public class EnumEqualsNode : Node<int, EnumEqualsNodeCustomViewModel>
|
||||
{
|
||||
public EnumEqualsNode() : base("Enum Equals", "Determines the equality between an input and a selected enum value")
|
||||
{
|
||||
@@ -17,20 +17,18 @@ public class EnumEqualsNode : Node<Enum, EnumEqualsNodeCustomViewModel>
|
||||
|
||||
private void InputPinOnPinConnected(object? sender, SingleValueEventArgs<IPin> e)
|
||||
{
|
||||
if (Storage?.GetType() != InputPin.ConnectedTo.First().Type)
|
||||
Storage = Enum.GetValues(InputPin.ConnectedTo.First().Type).Cast<Enum>().FirstOrDefault();
|
||||
Storage = 0;
|
||||
}
|
||||
|
||||
public InputPin<Enum> InputPin { get; }
|
||||
public OutputPin<bool> OutputPin { get; }
|
||||
|
||||
#region Overrides of Node
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Evaluate()
|
||||
{
|
||||
OutputPin.Value = InputPin.Value != null && InputPin.Value.Equals(Storage);
|
||||
if (InputPin.Value == null)
|
||||
OutputPin.Value = false;
|
||||
else
|
||||
OutputPin.Value = Convert.ToInt32(InputPin.Value) == Storage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
x:DataType="screens:EnumEqualsNodeCustomViewModel">
|
||||
<ComboBox IsEnabled="{CompiledBinding EnumValues.Count}"
|
||||
Items="{CompiledBinding EnumValues}"
|
||||
SelectedItem="{CompiledBinding CurrentValue}"
|
||||
SelectedIndex="{CompiledBinding CurrentValue}"
|
||||
PlaceholderText="Connect a pin..."
|
||||
Classes="condensed"
|
||||
VerticalAlignment="Center" />
|
||||
|
||||
+4
-8
@@ -33,11 +33,7 @@ public class EnumEqualsNodeCustomViewModel : CustomNodeViewModel
|
||||
}
|
||||
|
||||
Observable.FromEventPattern<SingleValueEventArgs<IPin>>(x => _node.InputPin.PinConnected += x, x => _node.InputPin.PinConnected -= x)
|
||||
.Subscribe(p =>
|
||||
{
|
||||
EnumValues.AddRange(Enum.GetValues(p.EventArgs.Value.Type).Cast<Enum>());
|
||||
this.RaisePropertyChanged(nameof(CurrentValue));
|
||||
})
|
||||
.Subscribe(p => EnumValues.AddRange(Enum.GetValues(p.EventArgs.Value.Type).Cast<Enum>()))
|
||||
.DisposeWith(d);
|
||||
Observable.FromEventPattern<SingleValueEventArgs<IPin>>(x => _node.InputPin.PinDisconnected += x, x => _node.InputPin.PinDisconnected -= x)
|
||||
.Subscribe(_ => EnumValues.Clear())
|
||||
@@ -47,13 +43,13 @@ public class EnumEqualsNodeCustomViewModel : CustomNodeViewModel
|
||||
|
||||
public ObservableCollection<Enum> EnumValues { get; } = new();
|
||||
|
||||
public Enum? CurrentValue
|
||||
public int CurrentValue
|
||||
{
|
||||
get => _node.Storage;
|
||||
set
|
||||
{
|
||||
if (value != null && !Equals(_node.Storage, value))
|
||||
_nodeEditorService.ExecuteCommand(Script, new UpdateStorage<Enum>(_node, value));
|
||||
if (!Equals(_node.Storage, value))
|
||||
_nodeEditorService.ExecuteCommand(Script, new UpdateStorage<int>(_node, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user