mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Nodes - Added static boolean node
This commit is contained in:
parent
bc8b3b5482
commit
7a48bf788e
@ -0,0 +1,13 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
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:screens="clr-namespace:Artemis.VisualScripting.Nodes.Static.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.Static.Screens.StaticBooleanValueNodeCustomView"
|
||||
x:DataType="screens:StaticBooleanValueNodeCustomViewModel">
|
||||
<ComboBox Classes="condensed" SelectedIndex="{CompiledBinding CurrentValue}">
|
||||
<ComboBoxItem>False</ComboBoxItem>
|
||||
<ComboBoxItem>True</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</UserControl>
|
||||
@ -0,0 +1,19 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
public partial class StaticBooleanValueNodeCustomView : ReactiveUserControl<StaticBooleanValueNodeCustomViewModel>
|
||||
{
|
||||
public StaticBooleanValueNodeCustomView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services.NodeEditor;
|
||||
using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
public class StaticBooleanValueNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly StaticBooleanValueNode _node;
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
|
||||
public StaticBooleanValueNodeCustomViewModel(StaticBooleanValueNode node, INodeScript script, INodeEditorService nodeEditorService) : base(node, script)
|
||||
{
|
||||
_node = node;
|
||||
_nodeEditorService = nodeEditorService;
|
||||
|
||||
NodeModified += (_, _) => this.RaisePropertyChanged(nameof(CurrentValue));
|
||||
}
|
||||
|
||||
public int? CurrentValue
|
||||
{
|
||||
get => _node.Storage ? 1 : 0;
|
||||
set => _nodeEditorService.ExecuteCommand(Script, new UpdateStorage<bool>(_node, value == 1));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.Static.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Static;
|
||||
|
||||
[Node("Boolean-Value", "Outputs a configurable static boolean value.", "Static", OutputType = typeof(bool))]
|
||||
public class StaticBooleanValueNode : Node<bool, StaticBooleanValueNodeCustomViewModel>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public StaticBooleanValueNode()
|
||||
: base("Boolean", "Outputs a configurable static boolean value.")
|
||||
{
|
||||
Output = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public OutputPin<bool> Output { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = Storage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user