/// <summary> /// Adds the group archetype to add to the menu. /// </summary> /// <param name="groupArchetype">The group.</param> public void AddGroup(GroupArchetype groupArchetype) { // Check if can create group for them to be spawned via GUI if (groupArchetype.Archetypes.Any(x => (x.Flags & NodeFlags.NoSpawnViaGUI) == 0)) { Profiler.BeginEvent("VisjectCM.AddGroup"); var group = new VisjectCMGroup(this, groupArchetype) { HeaderText = groupArchetype.Name }; group.Close(false); foreach (var nodeArchetype in groupArchetype.Archetypes) { var item = new VisjectCMItem(group, groupArchetype, nodeArchetype) { Parent = group }; } group.SortChildren(); group.Parent = _groupsPanel; _groups.Add(group); if (!IsLayoutLocked) { group.UnlockChildrenRecursive(); SortGroups(); group.PerformLayout(); if (_searchBox.TextLength != 0) { OnSearchFilterChanged(); } } Profiler.EndEvent(); } }
/// <inheritdoc /> public SurfaceNodeParamsGet(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { // Force first layout init for every param type _layoutType = (ParameterType)int.MaxValue; }
/// <inheritdoc /> public SurfaceNodeParamsGetVisualScript(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { Prototypes = null; }
/// <inheritdoc /> public ParticleAttributeNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public Sample(uint id, VisjectSurface surface, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, surface, nodeArch, groupArch) { }
/// <inheritdoc /> public SurfaceNodeParamsGet(uint id, VisjectSurface surface, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, surface, nodeArch, groupArch) { }
/// <summary> /// Initializes a new instance of the <see cref="VisjectCMGroup"/> class. /// </summary> /// <param name="cm">The context menu.</param> /// <param name="archetype">The group archetype.</param> public VisjectCMGroup(VisjectCM cm, GroupArchetype archetype) { ContextMenu = cm; Archetype = archetype; }
/// <inheritdoc /> public UnpackStructureNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch, true) { }
protected FunctionNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public SurfaceNodeMaterial(uint id, VisjectSurface surface, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, surface, nodeArch, groupArch) { }
/// <summary> /// Initializes a new instance of the <see cref="VisjectCM"/> class. /// </summary> /// <param name="groups">The group archetypes. Cannot be null.</param> /// <param name="canSpawnNodeType">The surface node type validation helper. Cannot be null.</param> /// <param name="parametersGetter">The surface parameters getter callback. Can be null.</param> /// <param name="customNodesGroup">The group with custom nodes.</param> public VisjectCM(List <GroupArchetype> groups, NodeSpawnCheckDelegate canSpawnNodeType, ParameterGetterDelegate parametersGetter = null, GroupArchetype customNodesGroup = null) { if (groups == null) { throw new ArgumentNullException(nameof(groups)); } if (canSpawnNodeType == null) { throw new ArgumentNullException(nameof(canSpawnNodeType)); } _parametersGetter = parametersGetter; // Context menu dimensions Size = new Vector2(320, 220); // Search box _searchBox = new TextBox(false, 1, 1) { Width = Width - 3, WatermarkText = "Search...", Parent = this }; _searchBox.TextChanged += OnSearchFilterChanged; // Create first panel (for scrollbar) var panel1 = new Panel(ScrollBars.Vertical) { Bounds = new Rectangle(0, _searchBox.Bottom + 1, Width, Height - _searchBox.Bottom - 2), Parent = this }; _panel1 = panel1; // Create second panel (for groups arrangement) var panel2 = new VerticalPanel { DockStyle = DockStyle.Top, IsScrollable = true, Parent = panel1 }; _groupsPanel = panel2; // Init groups int index = 0; var nodes = new List <NodeArchetype>(); foreach (var groupArchetype in groups) { // Get valid nodes nodes.Clear(); foreach (var nodeArchetype in groupArchetype.Archetypes) { if ((nodeArchetype.Flags & NodeFlags.NoSpawnViaGUI) != 0 || !canSpawnNodeType(nodeArchetype)) { continue; } nodes.Add(nodeArchetype); } // Check if can create group for them if (nodes.Count > 0) { var group = new VisjectCMGroup(this, groupArchetype); group.HeaderText = groupArchetype.Name; group.Close(false); for (int i = 0; i < nodes.Count; i++) { var item = new VisjectCMItem(group, groupArchetype, nodes[i]); item.Parent = group; } group.SortChildren(); group.Parent = panel2; group.DefaultIndex = index++; _groups.Add(group); } } // Add custom nodes (special handling) if (customNodesGroup?.Archetypes != null) { for (int i = 0; i < customNodesGroup.Archetypes.Length; i++) { var nodeArchetype = customNodesGroup.Archetypes[i]; if ((nodeArchetype.Flags & NodeFlags.NoSpawnViaGUI) != 0) { continue; } var groupName = Archetypes.Custom.GetNodeGroup(nodeArchetype); // Find group to reuse VisjectCMGroup group = null; for (int j = 0; j < _groups.Count; j++) { if (string.Equals(_groups[j].Archetype.Name, groupName, StringComparison.OrdinalIgnoreCase)) { group = _groups[j]; break; } } // Create new group if name is unique if (group == null) { group = new VisjectCMGroup(this, customNodesGroup); group.HeaderText = groupName; group.Close(false); group.Parent = _groupsPanel; group.DefaultIndex = _groups.Count; _groups.Add(group); } // Add new item var item = new VisjectCMItem(group, customNodesGroup, nodeArchetype); item.Parent = group; // Order items group.SortChildren(); } } }
/// <summary> /// Updates the surface parameters group. /// </summary> private void UpdateSurfaceParametersGroup() { // Remove the old one if (_surfaceParametersGroup != null) { _groups.Remove(_surfaceParametersGroup); _surfaceParametersGroup.Dispose(); _surfaceParametersGroup = null; } // Check if surface has any parameters var parameters = _parametersGetter != null?_parametersGetter() : null; int count = parameters?.Count(x => x.IsPublic) ?? 0; if (count > 0) { // TODO: cache the allocated memory to reduce dynamic allocations var archetypes = new NodeArchetype[count]; int archetypeIndex = 0; // ReSharper disable once PossibleNullReferenceException for (int i = 0; i < parameters.Count; i++) { if (!parameters[i].IsPublic) { continue; } archetypes[archetypeIndex++] = new NodeArchetype { TypeID = 1, Create = Archetypes.Parameters.CreateGetNode, Title = "Get " + parameters[i].Name, Description = "Parameter value getter", Size = new Vector2(140, 60), DefaultValues = new object[] { parameters[i].ID }, Elements = new[] { NodeElementArchetype.Factory.ComboBox(2, 0, 116) } }; } var groupArchetype = new GroupArchetype { GroupID = 6, Name = "Surface Parameters", Color = new Color(52, 73, 94), Archetypes = archetypes }; var group = new VisjectCMGroup(this, groupArchetype); group.HeaderText = groupArchetype.Name; group.Close(false); archetypeIndex = 0; for (int i = 0; i < parameters.Count; i++) { if (!parameters[i].IsPublic) { continue; } var item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++]); item.Parent = group; } group.SortChildren(); group.UnlockChildrenRecursive(); group.Parent = _groupsPanel; _groups.Add(group); _surfaceParametersGroup = group; } }
public SwitchOnEnumNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
public SampleTextureNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public GetGameplayGlobalNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> protected StructureNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch, bool isUnpacking) : base(id, context, nodeArch, groupArch) { _isUnpacking = isUnpacking; }
/// <inheritdoc /> public MultiBlend(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { var layoutOffsetY = FlaxEditor.Surface.Constants.LayoutOffsetY; _selectedAnimationLabel = new Label(300, 3 * layoutOffsetY, 120.0f, layoutOffsetY) { HorizontalAlignment = TextAlignment.Near, Text = "Selected Animation:", Parent = this }; _selectedAnimation = new ComboBox(_selectedAnimationLabel.X, 4 * layoutOffsetY, _selectedAnimationLabel.Width) { Parent = this }; _selectedAnimation.PopupShowing += OnSelectedAnimationPopupShowing; _selectedAnimation.SelectedIndexChanged += OnSelectedAnimationChanged; var items = new List <string>(MaxAnimationsCount); while (items.Count < MaxAnimationsCount) { items.Add(string.Empty); } _selectedAnimation.Items = items; _animationPicker = new AssetPicker(new ScriptType(typeof(FlaxEngine.Animation)), new Vector2(_selectedAnimation.Left, _selectedAnimation.Bottom + 4)) { Parent = this }; _animationPicker.SelectedItemChanged += OnAnimationPickerItemChanged; _animationSpeedLabel = new Label(_animationPicker.Left, _animationPicker.Bottom + 4, 40, TextBox.DefaultHeight) { HorizontalAlignment = TextAlignment.Near, Text = "Speed:", Parent = this }; _animationSpeed = new FloatValueBox(1.0f, _animationSpeedLabel.Right + 4, _animationSpeedLabel.Y, _selectedAnimation.Right - _animationSpeedLabel.Right - 4) { SlideSpeed = 0.01f, Parent = this }; _animationSpeed.ValueChanged += OnAnimationSpeedValueChanged; }
/// <inheritdoc /> public AppendNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
public AssetNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch, Guid assetId) : base(id, context, nodeArch, groupArch) { AssetId = assetId; // Init node UI var picker = new AssetPicker { Location = new Vector2(40, 2 * Constants.LayoutOffsetY), Width = 100.0f, CanEdit = false, Parent = this, }; // TODO: display some asset info like disk size, memory usage, etc. var asset = FlaxEngine.Content.LoadAsync <Asset>(AssetId); if (asset != null) { var path = asset.Path; picker.SelectedAsset = asset; Title = System.IO.Path.GetFileNameWithoutExtension(path); TooltipText = asset.TypeName + '\n' + path; } else { picker.SelectedID = AssetId; var assetItem = picker.SelectedItem; if (assetItem != null) { Title = assetItem.ShortName; TooltipText = assetItem.TypeName + '\n' + assetItem.Path; } else { Title = AssetId.ToString(); } } ResizeAuto(); LayoutHeight = Height; }
/// <summary> /// Creates the get node. /// </summary> /// <param name="id">The identifier.</param> /// <param name="surface">The surface.</param> /// <param name="arch">The node archetype.</param> /// <param name="groupArch">The group archetype.</param> /// <returns></returns> public static SurfaceNode CreateGetNode(uint id, VisjectSurface surface, NodeArchetype arch, GroupArchetype groupArch) { return(new SurfaceNodeParamsGet(id, surface, arch, groupArch)); }
/// <inheritdoc /> public MaterialFunctionNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public ParticleEmitterFunctionNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public SurfaceNodeMaterial(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public ParticleEmitterNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { Headers[0] = new ModulesHeader(this, ParticleModules.ModuleType.Spawn); Headers[1] = new ModulesHeader(this, ParticleModules.ModuleType.Initialize); Headers[2] = new ModulesHeader(this, ParticleModules.ModuleType.Update); Headers[3] = new ModulesHeader(this, ParticleModules.ModuleType.Render); }
/// <summary> /// Updates the surface parameters group. /// </summary> private void UpdateSurfaceParametersGroup() { // Remove the old one if (_surfaceParametersGroup != null) { _groups.Remove(_surfaceParametersGroup); _surfaceParametersGroup.Dispose(); _surfaceParametersGroup = null; } // Check if surface has any parameters var parameters = _parametersGetter != null?_parametersGetter() : null; int count = parameters?.Count(x => x.IsPublic) ?? 0; if (count > 0) { // TODO: cache the allocated memory to reduce dynamic allocations var archetypes = new NodeArchetype[count]; int archetypeIndex = 0; // ReSharper disable once PossibleNullReferenceException for (int i = 0; i < parameters.Count; i++) { if (!parameters[i].IsPublic) { continue; } var node = (NodeArchetype)_parameterGetNodeArchetype.Clone(); node.Title = "Get " + parameters[i].Name; node.DefaultValues[0] = parameters[i].ID; archetypes[archetypeIndex++] = node; } var groupArchetype = new GroupArchetype { GroupID = 6, Name = "Surface Parameters", Color = new Color(52, 73, 94), Archetypes = archetypes }; var group = new VisjectCMGroup(this, groupArchetype); group.HeaderText = groupArchetype.Name; group.Close(false); archetypeIndex = 0; for (int i = 0; i < parameters.Count; i++) { if (!parameters[i].IsPublic) { continue; } var item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++]); item.Parent = group; } group.SortChildren(); group.UnlockChildrenRecursive(); group.Parent = _groupsPanel; _groups.Add(group); _surfaceParametersGroup = group; } }
/// <inheritdoc /> public SurfaceNodeParamsGetParticleEmitter(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { Prototypes = DefaultPrototypesParticleEmitter; }
/// <inheritdoc /> public ColorGradientNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <inheritdoc /> public SurfaceNodeParamsSet(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch) : base(id, context, nodeArch, groupArch) { }
/// <summary> /// Initializes a new instance of the <see cref="VisjectCMGroup"/> class. /// </summary> /// <param name="cm">The context menu.</param> /// <param name="archetype">The group archetype.</param> public VisjectCMGroup(VisjectCM cm, GroupArchetype archetype) { HeaderText = archetype.Name; ContextMenu = cm; Archetype = archetype; }