// Copyright (c) Wojciech Figat. All rights reserved. using System; using FlaxEditor.GUI; using FlaxEngine; using FlaxEngine.Utilities; namespace FlaxEditor.Surface.Elements { /// /// Combo box for enum element. /// /// /// /// [HideInEditor] public class EnumValue : EnumComboBox, ISurfaceNodeElement { /// public SurfaceNode ParentNode { get; } /// public NodeElementArchetype Archetype { get; } /// /// Gets the surface. /// public VisjectSurface Surface => ParentNode.Surface; /// public EnumValue(SurfaceNode parentNode, NodeElementArchetype archetype) : base(TypeUtils.GetType(archetype.Text).Type) { Bounds = new Rectangle(archetype.ActualPositionX, archetype.ActualPositionY, archetype.Size.X, Constants.BoxRowHeight); ParentNode = parentNode; Archetype = archetype; Value = Convert.ToInt32(ParentNode.Values[Archetype.ValueIndex]); } /// protected override void OnValueChanged() { if (Convert.ToInt32(ParentNode.Values[Archetype.ValueIndex]) != (int)Value) { // Edit value ParentNode.SetValue(Archetype.ValueIndex, Value); } base.OnValueChanged(); } } }