public override void Initialize(LayoutElementsContainer layout) { _proxy = (PropertiesProxy)Values[0]; if (_proxy?.DefaultValues == null) { layout.Label("Loading...", TextAlignment.Center); return; } var isPlayModeActive = _proxy.Window.Editor.StateMachine.IsPlayMode; if (isPlayModeActive) { layout.Label("Play mode is active. Editing runtime values.", TextAlignment.Center); layout.Space(10); foreach (var e in _proxy.DefaultValues) { var name = e.Key; var value = _proxy.Asset.GetValue(name); var valueContainer = new VariableValueContainer(_proxy, name, value, false); var propertyLabel = new PropertyNameLabel(name) { Tag = name, }; string tooltip = null; if (_proxy.DefaultValues.TryGetValue(name, out var defaultValue)) { tooltip = "Default value: " + defaultValue; } layout.Object(propertyLabel, valueContainer, null, tooltip); } } else { foreach (var e in _proxy.DefaultValues) { var name = e.Key; var value = e.Value; var valueContainer = new VariableValueContainer(_proxy, name, value, true); var propertyLabel = new ClickablePropertyNameLabel(name) { Tag = name, }; propertyLabel.MouseLeftDoubleClick += (label, location) => StartParameterRenaming(name, label); propertyLabel.SetupContextMenu += OnPropertyLabelSetupContextMenu; layout.Object(propertyLabel, valueContainer, null, "Type: " + CustomEditorsUtil.GetTypeNameUI(value.GetType())); } // TODO: improve the UI layout.Space(40); var addParamType = layout.ComboBox().ComboBox; addParamType.Items = AllowedTypes.Select(CustomEditorsUtil.GetTypeNameUI).ToList(); addParamType.SelectedIndex = 0; _addParamType = addParamType; var addParamButton = layout.Button("Add").Button; addParamButton.Clicked += OnAddParamButtonClicked; } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); // Reset options button layout.Space(30); var panel = layout.Space(30); var resetButton = new Button(4, 4, 100); resetButton.Text = "Reset"; resetButton.Parent = panel.ContainerControl; resetButton.Clicked += OnResetButtonClicked; }
public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); var skeletonActor = Values[0] as SkeletonToActors; layout.Space(20); var updateButton = layout.Button("Create", Color.Green); updateButton.Button.Clicked += () => { skeletonActor.Create(); }; var saveButton = layout.Button("Save", Color.Green); saveButton.Button.Clicked += () => { if (skeletonActor.VirtualModel && skeletonActor.VirtualModel.IsVirtual) { new Task(() => { skeletonActor.VirtualModel.Save(true, $"Content/SkeletonActor/{skeletonActor.ID}_SkinnedModel.flax"); }).Start(); } }; }
public override void Initialize(LayoutElementsContainer layout) { layout.Label("Scene Animation Rendering Utility", TextAlignment.Center); layout.Space(10.0f); base.Initialize(layout); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { // Set control type button var space = layout.Space(20); float setTypeButtonWidth = 60.0f; var setTypeButton = new Button((layout.ContainerControl.Width - setTypeButtonWidth) / 2, 1, setTypeButtonWidth, 18) { TooltipText = "Sets the control to the given type", AnchorStyle = AnchorStyle.UpperCenter, Text = "Set Type", Parent = space.Spacer }; setTypeButton.ButtonClicked += OnSetTypeButtonClicked; // Don't show editor if any control is invalid if (Values.HasNull) { var label = layout.Label("Select control type to create", TextAlignment.Center); label.Label.Enabled = false; return; } // Add control type helper label { var type = Values[0].GetType(); var label = layout.AddPropertyItem("Type", "The type of the created control."); label.Label(type.FullName); } // Show control properties base.Initialize(layout); }
public override void Initialize(LayoutElementsContainer layout) { var window = ((PropertiesProxy)Values[0])._window; if (window == null) { layout.Label("Loading...", TextAlignment.Center); return; } // Texture properties { var texture = window.Asset; var group = layout.Group("General"); group.Label("Format: " + texture.Format); group.Label(string.Format("Size: {0}x{1}", texture.Width, texture.Height)); group.Label("Mip levels: " + texture.MipLevels); group.Label("Memory usage: " + Utilities.Utils.FormatBytesCount(texture.TotalMemoryUsage)); } base.Initialize(layout); layout.Space(10); var reimportButton = layout.Button("Reimport"); reimportButton.Button.Clicked += () => ((PropertiesProxy)Values[0]).Reimport(); }
public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); var surface = Values[0] as ImplicitSurface.ImplicitSurface; layout.Space(20); var updateButton = layout.Button("Update", Color.Green); updateButton.Button.Clicked += () => { surface.CreateVirtualModel(); surface.UpdateMesh(); }; var saveButton = layout.Button("Save", Color.Green); saveButton.Button.Clicked += () => { if (surface.Model && surface.Model.IsVirtual) { new Task(() => { surface.Actor.Model = null; surface.Model.Save(true, $"Content/ImplicitSurface/{surface.ID}_Model.flax"); }).Start(); } }; }
public override void Initialize(LayoutElementsContainer layout) { var window = ((PropertiesProxy)Values[0])._window; if (window == null) { layout.Label("Loading...", TextAlignment.Center); return; } // Audio properties { var audio = window.Asset; AudioClip.AudioDataInfo info; audio.GetInfo(out info); int originalSize, importedSize; Editor.Internal_GetAudioClipMetadata(audio.unmanagedPtr, out originalSize, out importedSize); var group = layout.Group("General"); group.Label("Format: " + audio.Format); group.Label("Length: " + (Mathf.CeilToInt(audio.Length * 100.0f) / 100.0f) + "s"); group.Label(string.Format("{0}kHz, channels: {1}, bit depth: {2}", info.SampleRate / 1000, info.NumChannels, info.BitDepth)); group.Label("Original size: " + Utilities.Utils.FormatBytesCount((ulong)originalSize)); group.Label("Imported size: " + Utilities.Utils.FormatBytesCount((ulong)importedSize)); group.Label("Compression ratio: " + Mathf.CeilToInt((float)importedSize / originalSize * 100.0f) + "%"); } base.Initialize(layout); layout.Space(10); var reimportButton = layout.Button("Reimport"); reimportButton.Button.Clicked += () => ((PropertiesProxy)Values[0]).Reimport(); }
private void OnAfterLayout(LayoutElementsContainer layout) { layout.Space(10); var button = layout.Button("Render").Button; button.TooltipText = "Start the Scene Animation rendering using the specified options"; button.Clicked += StartRendering; }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); layout.Space(10); _cookButton = layout.Button("Cook"); _cookButton.Button.Clicked += OnCookButtonClicked; }
public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); layout.Space(20); var button = layout.Button("New on the edge", Color.DarkGray); button.Button.Clicked += () => (Values[0] as JumpTrajectoryPreview)?.CreateNewOnTheEdge(); }
public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); layout.Space(10); var reimportButton = layout.Button("Reimport"); reimportButton.Button.Clicked += () => ((PropertiesProxy)Values[0]).Reimport(); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); if (Values.HasDifferentTypes == false) { layout.Space(10); _bake = layout.Button("Bake").Button; _bake.Clicked += BakeButtonClicked; } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); if (Values.HasDifferentTypes == false) { // Add 'Bake' button layout.Space(10); var button = layout.Button("Bake"); button.Button.Clicked += BakeButtonClicked; } }
private void ShowJoin() { _layout.ContainerControl.DisposeChildren(); //_layout.ContainerControl.AnchorStyle = AnchorStyle.Upper; EditingSessionPlugin.Instance.SessionState = EditingSessionPlugin.State.Join; _layout.ClearLayout(); _layout.Space(5); var label = _layout.Label("Joining Session", TextAlignment.Center); var fontReference = label.Label.Font; fontReference.Size = 11; label.Label.Font = fontReference; _layout.Space(5); var clientSettingsEditor = new CustomEditorPresenter(null); clientSettingsEditor.Panel.Parent = _layout.ContainerControl; clientSettingsEditor.Select(_clientSettings); var button = _layout.Button("Join"); var returnButton = _layout.Button("Return"); button.Button.Clicked += async() => { button.Button.Enabled = false; var session = new ClientSession(); bool connected = await session.Start(_clientSettings); button.Button.Enabled = true; if (connected) { EditingSessionPlugin.Instance.Session = session; ShowSession(); } }; returnButton.Button.Clicked += () => ShowNoSession(); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); if (Values.HasDifferentTypes == false) { layout.Space(10); var grid = layout.CustomContainer <UniformGridPanel>(); grid.CustomControl.SlotsHorizontally = 2; grid.CustomControl.SlotsVertically = 1; grid.Button("Set Linear Tangents").Button.Clicked += OnSetTangentsLinear; grid.Button("Set Smooth Tangents").Button.Clicked += OnSetTangentsSmooth; } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { base.Initialize(layout); var space = layout.Space(22); var removeButton = new Button(2, 2.0f, 80.0f, 18.0f) { Text = "Remove", TooltipText = "Removes the selected foliage type and all foliage instances using this type", Parent = space.Spacer }; removeButton.Clicked += OnRemoveButtonClicked; _info = new Label(removeButton.Right + 6, 2, 200, 18.0f) { HorizontalAlignment = TextAlignment.Near, Parent = space.Spacer }; }
public override void Initialize(LayoutElementsContainer layout) { var window = ((PropertiesProxy)Values[0])._window; var texture = window?.Asset; if (texture == null || !texture.IsLoaded) { layout.Label("Loading...", TextAlignment.Center); return; } // Texture info var general = layout.Group("General"); general.Label("Format: " + texture.Format); general.Label(string.Format("Size: {0}x{1}", texture.Width, texture.Height)); general.Label("Mip levels: " + texture.MipLevels); general.Label("Memory usage: " + Utilities.Utils.FormatBytesCount(texture.TotalMemoryUsage)); // Texture properties var properties = layout.Group("Properties"); var textureGroup = new CustomValueContainer(new ScriptType(typeof(int)), texture.TextureGroup, (instance, index) => texture.TextureGroup, (instance, index, value) => { texture.TextureGroup = (int)value; window.MarkAsEdited(); }); properties.Property("Texture Group", textureGroup, new TextureGroupEditor(), "The texture group used by this texture."); // Import settings base.Initialize(layout); // Reimport layout.Space(10); var reimportButton = layout.Button("Reimport"); reimportButton.Button.Clicked += () => ((PropertiesProxy)Values[0]).Reimport(); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var proxy = (PropertiesProxy)Values[0]; if (proxy.Asset == null || !proxy.Asset.IsLoaded) { layout.Label("Loading..."); return; } base.Initialize(layout); // General properties { var group = layout.Group("General"); Animation.Info info; proxy.Asset.GetInfo(out info); group.Label("Length: " + info.Length + "s"); group.Label("Frames: " + info.FramesCount); group.Label("Chanels: " + info.ChannelsCount); group.Label("Keyframes: " + info.KeyframesCount); } // Import Settings { var group = layout.Group("Import Settings"); var importSettingsField = typeof(PropertiesProxy).GetField("ImportSettings", BindingFlags.NonPublic | BindingFlags.Instance); var importSettingsValues = new ValueContainer(importSettingsField) { proxy.ImportSettings }; group.Object(importSettingsValues); layout.Space(5); var reimportButton = group.Button("Reimport"); reimportButton.Button.Clicked += () => ((PropertiesProxy)Values[0]).Reimport(); } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { _visibleIfCaches = null; // Collect items to edit List <ItemInfo> items; if (!HasDifferentTypes) { var value = Values[0]; if (value == null) { // Check if it's an object type that can be created in editor var type = Values.Type; if (type != null && type.GetConstructor(Type.EmptyTypes) != null) { layout = layout.Space(20); const float ButtonSize = 14.0f; var button = new Button { Text = "+", TooltipText = "Create a new instance of the object", Height = ButtonSize, Width = ButtonSize, X = layout.ContainerControl.Width - ButtonSize - 4, AnchorStyle = AnchorStyle.CenterRight, Parent = layout.ContainerControl }; button.Clicked += () => { var newType = Values.Type; SetValue(Activator.CreateInstance(newType)); RebuildLayoutOnRefresh(); }; } layout.Label("<null>"); return; } items = GetItemsForType(value.GetType()); } else { var types = ValuesTypes; items = new List <ItemInfo>(GetItemsForType(types[0])); for (int i = 1; i < types.Length && items.Count > 0; i++) { var otherItems = GetItemsForType(types[i]); // Merge items for (int j = 0; j < items.Count && items.Count > 0; j++) { bool isInvalid = true; for (int k = 0; k < otherItems.Count; k++) { var a = items[j]; var b = otherItems[k]; if (ItemInfo.CanMerge(a, b)) { isInvalid = false; break; } } if (isInvalid) { items.RemoveAt(j--); } } } } // Sort items items.Sort(); // Add items GroupElement lastGroup = null; for (int i = 0; i < items.Count; i++) { var item = items[i]; // Check if use group LayoutElementsContainer itemLayout; if (item.UseGroup) { if (lastGroup == null || lastGroup.Panel.HeaderText != item.Display.Group) { lastGroup = layout.Group(item.Display.Group); } itemLayout = lastGroup; } else { lastGroup = null; itemLayout = layout; } // Space if (item.Space != null) { itemLayout.Space(item.Space.Height); } // Header if (item.Header != null) { itemLayout.Header(item.Header.Text); } // Peek values ValueContainer itemValues; try { itemValues = item.GetValues(Values); } catch (Exception ex) { Editor.LogWarning("Failed to get object values for item " + item); Editor.LogWarning(ex.Message); Editor.LogWarning(ex.StackTrace); return; } // Spawn property editor SpawnProperty(itemLayout, itemValues, item); // Expand all parent groups if need to if (item.ExpandGroups) { var c = itemLayout.ContainerControl; do { if (c is DropPanel dropPanel) { dropPanel.Open(false); } else if (c is CustomEditorPresenter.PresenterPanel) { break; } c = c.Parent; } while (c != null); } } }
public override void Initialize(LayoutElementsContainer layout) { var proxy = (PropertiesProxy)Values[0]; proxy._materialSlotComboBoxes.Clear(); proxy._isolateCheckBoxes.Clear(); proxy._highlightCheckBoxes.Clear(); var meshes = proxy.Asset.Meshes; var nodes = proxy.Asset.Nodes; var bones = proxy.Asset.Bones; // General properties { var group = layout.Group("General"); var minScreenSize = group.FloatValue("Min Screen Size", "The minimum screen size to draw model (the bottom limit). Used to cull small models. Set to 0 to disable this feature."); minScreenSize.FloatValue.MinValue = 0.0f; minScreenSize.FloatValue.MaxValue = 1.0f; minScreenSize.FloatValue.Value = proxy.Asset.MinScreenSize; minScreenSize.FloatValue.ValueChanged += () => { proxy.Asset.MinScreenSize = minScreenSize.FloatValue.Value; proxy.Window.MarkAsEdited(); }; int triangleCount = 0, vertexCount = 0; for (int meshIndex = 0; meshIndex < meshes.Length; meshIndex++) { var mesh = meshes[meshIndex]; triangleCount += mesh.Triangles; vertexCount += mesh.Vertices; } group.Label(string.Format("Triangles: {0:N0} Vertices: {1:N0}", triangleCount, vertexCount)); group.Label("Nodes: " + nodes.Length); group.Label("Bones: " + bones.Length); } // Group per mesh var meshesGroup = layout.Group("Meshes"); meshesGroup.Panel.Close(false); for (int meshIndex = 0; meshIndex < meshes.Length; meshIndex++) { var mesh = meshes[meshIndex]; var group = meshesGroup.Group("Mesh " + meshIndex); group.Label(string.Format("Triangles: {0:N0} Vertices: {1:N0}", mesh.Triangles, mesh.Vertices)); // Material Slot var materialSlot = group.ComboBox("Material Slot", "Material slot used by this mesh during rendering"); materialSlot.ComboBox.Tag = mesh; materialSlot.ComboBox.SelectedIndexChanged += comboBox => proxy.SetMaterialSlot((SkinnedMesh)comboBox.Tag, comboBox.SelectedIndex); proxy._materialSlotComboBoxes.Add(materialSlot.ComboBox); // Isolate var isolate = group.Checkbox("Isolate", "Shows only this mesh (and meshes using the same material slot)"); isolate.CheckBox.Tag = mesh; isolate.CheckBox.StateChanged += (box) => proxy.SetIsolate(box.Checked ? (SkinnedMesh)box.Tag : null); proxy._isolateCheckBoxes.Add(isolate.CheckBox); // Highlight var highlight = group.Checkbox("Highlight", "Highlights this mesh with a tint color (and meshes using the same material slot)"); highlight.CheckBox.Tag = mesh; highlight.CheckBox.StateChanged += (box) => proxy.SetHighlight(box.Checked ? (SkinnedMesh)box.Tag : null); proxy._highlightCheckBoxes.Add(highlight.CheckBox); } // Skeleton Bones { var group = layout.Group("Skeleton Bones"); group.Panel.Close(false); var tree = group.Tree(); for (int i = 0; i < bones.Length; i++) { if (bones[i].ParentIndex == -1) { var node = tree.Node(nodes[bones[i].NodeIndex].Name); BuildSkeletonBonesTree(nodes, bones, node, i); node.TreeNode.ExpandAll(true); } } } // Skeleton Nodes { var group = layout.Group("Skeleton Nodes"); group.Panel.Close(false); var tree = group.Tree(); for (int i = 0; i < nodes.Length; i++) { if (nodes[i].ParentIndex == -1) { var node = tree.Node(nodes[i].Name); BuildSkeletonNodesTree(nodes, node, i); node.TreeNode.ExpandAll(true); } } } // Import Settings { var group = layout.Group("Import Settings"); var importSettingsField = typeof(PropertiesProxy).GetField("ImportSettings", BindingFlags.NonPublic | BindingFlags.Instance); var importSettingsValues = new ValueContainer(importSettingsField) { proxy.ImportSettings }; group.Object(importSettingsValues); layout.Space(5); var reimportButton = group.Button("Reimport"); reimportButton.Button.Clicked += () => ((PropertiesProxy)Values[0]).Reimport(); } // Refresh UI proxy.UpdateMaterialSlotsUI(); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { // No support for different collections for now if (HasDifferentValues || HasDifferentTypes) { return; } var type = Values.Type; var size = Count; var argTypes = type.GetGenericArguments(); var keyType = argTypes[0]; var valueType = argTypes[1]; _canEditKeys = keyType == typeof(string) || keyType.IsPrimitive || keyType.IsEnum; _background = FlaxEngine.GUI.Style.Current.CollectionBackgroundColor; _readOnly = false; _notNullItems = false; // Try get CollectionAttribute for collection editor meta var attributes = Values.GetAttributes(); Type overrideEditorType = null; float spacing = 0.0f; var collection = (CollectionAttribute)attributes?.FirstOrDefault(x => x is CollectionAttribute); if (collection != null) { _readOnly = collection.ReadOnly; _notNullItems = collection.NotNullItems; if (collection.BackgroundColor.HasValue) { _background = collection.BackgroundColor.Value; } overrideEditorType = TypeUtils.GetType(collection.OverrideEditorTypeName).Type; spacing = collection.Spacing; } // Size if (_readOnly || !_canEditKeys) { layout.Label("Size", size.ToString()); } else { _size = layout.IntegerValue("Size"); _size.IntValue.MinValue = 0; _size.IntValue.MaxValue = _notNullItems ? size : ushort.MaxValue; _size.IntValue.Value = size; _size.IntValue.ValueChanged += OnSizeChanged; } // Elements if (size > 0) { var panel = layout.VerticalPanel(); panel.Panel.BackgroundColor = _background; var keysEnumerable = ((IDictionary)Values[0]).Keys.OfType <object>(); var keys = keysEnumerable as object[] ?? keysEnumerable.ToArray(); var valuesType = new ScriptType(valueType); // Use separate layout cells for each collection items to improve layout updates for them in separation var useSharedLayout = valueType.IsPrimitive || valueType.IsEnum; for (int i = 0; i < size; i++) { if (i != 0 && spacing > 0f) { if (panel.Children.Count > 0 && panel.Children[panel.Children.Count - 1] is PropertiesListElement propertiesListElement) { if (propertiesListElement.Labels.Count > 0) { var label = propertiesListElement.Labels[propertiesListElement.Labels.Count - 1]; var margin = label.Margin; margin.Bottom += spacing; label.Margin = margin; } propertiesListElement.Space(spacing); } else { panel.Space(spacing); } } var key = keys.ElementAt(i); var overrideEditor = overrideEditorType != null ? (CustomEditor)Activator.CreateInstance(overrideEditorType) : null; var property = panel.AddPropertyItem(new DictionaryItemLabel(this, key)); var itemLayout = useSharedLayout ? (LayoutElementsContainer)property : property.VerticalPanel(); itemLayout.Object(new DictionaryValueContainer(valuesType, key, Values), overrideEditor); } } _elementsCount = size; // Add/Remove buttons if (!_readOnly && _canEditKeys) { var area = layout.Space(20); var addButton = new Button(area.ContainerControl.Width - (16 + 16 + 2 + 2), 2, 16, 16) { Text = "+", TooltipText = "Add new item", AnchorPreset = AnchorPresets.TopRight, Parent = area.ContainerControl, Enabled = !_notNullItems, }; addButton.Clicked += () => { if (IsSetBlocked) { return; } Resize(Count + 1); }; var removeButton = new Button(addButton.Right + 2, addButton.Y, 16, 16) { Text = "-", TooltipText = "Remove last item", AnchorPreset = AnchorPresets.TopRight, Parent = area.ContainerControl, Enabled = size > 0, }; removeButton.Clicked += () => { if (IsSetBlocked) { return; } Resize(Count - 1); }; } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var window = Values[0] as IVisjectSurfaceWindow; var asset = window?.VisjectAsset; if (asset == null) { layout.Label("No parameters"); return; } if (asset.LastLoadFailed) { layout.Label("Failed to load asset"); return; } if (!asset.IsLoaded) { layout.Label("Loading..."); return; } var parameters = window.VisjectSurface.Parameters; GroupElement lastGroup = null; for (int i = 0; i < parameters.Count; i++) { var p = parameters[i]; if (!p.IsPublic) { continue; } var pIndex = i; var pValue = p.Value; var attributes = p.Meta.GetAttributes(); if (attributes == null || attributes.Length == 0) { attributes = DefaultAttributes; } var itemLayout = layout; var name = p.Name; // Editor Display var editorDisplay = (EditorDisplayAttribute)attributes.FirstOrDefault(x => x is EditorDisplayAttribute); if (editorDisplay?.Group != null) { if (lastGroup == null || lastGroup.Panel.HeaderText != editorDisplay.Group) { lastGroup = layout.Group(editorDisplay.Group); lastGroup.Panel.Open(false); } itemLayout = lastGroup; } else { lastGroup = null; itemLayout = layout; } if (editorDisplay?.Name != null) { name = editorDisplay.Name; } // Space var space = (SpaceAttribute)attributes.FirstOrDefault(x => x is SpaceAttribute); if (space != null) { itemLayout.Space(space.Height); } // Header var header = (HeaderAttribute)attributes.FirstOrDefault(x => x is HeaderAttribute); if (header != null) { itemLayout.Header(header.Text); } var propertyValue = new CustomValueContainer ( p.Type, pValue, (instance, index) => ((IVisjectSurfaceWindow)instance).GetParameter(pIndex), (instance, index, value) => ((IVisjectSurfaceWindow)instance).SetParameter(pIndex, value), attributes ); var propertyLabel = new DraggablePropertyNameLabel(name) { Tag = pIndex, Drag = OnDragParameter }; var tooltip = (TooltipAttribute)attributes.FirstOrDefault(x => x is TooltipAttribute); propertyLabel.MouseLeftDoubleClick += (label, location) => StartParameterRenaming(pIndex, label); propertyLabel.SetupContextMenu += OnPropertyLabelSetupContextMenu; var property = itemLayout.AddPropertyItem(propertyLabel, tooltip?.Text); property.Object(propertyValue); } // Parameters creating var newParameterTypes = window.NewParameterTypes; if (newParameterTypes != null) { layout.Space(parameters.Count > 0 ? 10 : 4); var newParam = layout.Button("Add parameter..."); newParam.Button.ButtonClicked += OnAddParameterButtonClicked; layout.Space(10); } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { _readOnly = false; _canReorderItems = true; _notNullItems = false; // No support for different collections for now if (HasDifferentValues || HasDifferentTypes) { return; } var size = Count; // Try get CollectionAttribute for collection editor meta var attributes = Values.GetAttributes(); Type overrideEditorType = null; float spacing = 10.0f; var collection = (CollectionAttribute)attributes?.FirstOrDefault(x => x is CollectionAttribute); if (collection != null) { // TODO: handle NotNullItems by filtering child editors SetValue _readOnly = collection.ReadOnly; _canReorderItems = collection.CanReorderItems; _notNullItems = collection.NotNullItems; overrideEditorType = TypeUtils.GetType(collection.OverrideEditorTypeName).Type; spacing = collection.Spacing; } // Size if (_readOnly) { layout.Label("Size", size.ToString()); } else { _size = layout.IntegerValue("Size"); _size.IntValue.MinValue = 0; _size.IntValue.MaxValue = ushort.MaxValue; _size.IntValue.Value = size; _size.IntValue.ValueChanged += OnSizeChanged; } // Elements if (size > 0) { var elementType = ElementType; if (_canReorderItems) { for (int i = 0; i < size; i++) { if (i != 0 && spacing > 0f) { if (layout.Children.Count > 0 && layout.Children[layout.Children.Count - 1] is PropertiesListElement propertiesListElement) { if (propertiesListElement.Labels.Count > 0) { var label = propertiesListElement.Labels[propertiesListElement.Labels.Count - 1]; var margin = label.Margin; margin.Bottom += spacing; label.Margin = margin; } propertiesListElement.Space(spacing); } else { layout.Space(spacing); } } var overrideEditor = overrideEditorType != null ? (CustomEditor)Activator.CreateInstance(overrideEditorType) : null; layout.Object(new CollectionItemLabel(this, i), new ListValueContainer(elementType, i, Values), overrideEditor); } } else { for (int i = 0; i < size; i++) { if (i != 0 && spacing > 0f) { if (layout.Children.Count > 0 && layout.Children[layout.Children.Count - 1] is PropertiesListElement propertiesListElement) { propertiesListElement.Space(spacing); } else { layout.Space(spacing); } } var overrideEditor = overrideEditorType != null ? (CustomEditor)Activator.CreateInstance(overrideEditorType) : null; layout.Object("Element " + i, new ListValueContainer(elementType, i, Values), overrideEditor); } } } _elementsCount = size; // Add/Remove buttons if (!_readOnly) { var area = layout.Space(20); var addButton = new Button(area.ContainerControl.Width - (16 + 16 + 2 + 2), 2, 16, 16) { Text = "+", TooltipText = "Add new item", AnchorPreset = AnchorPresets.TopRight, Parent = area.ContainerControl }; addButton.Clicked += () => { if (IsSetBlocked) { return; } Resize(Count + 1); }; var removeButton = new Button(addButton.Right + 2, addButton.Y, 16, 16) { Text = "-", TooltipText = "Remove last item", AnchorPreset = AnchorPresets.TopRight, Parent = area.ContainerControl, Enabled = size > 0 }; removeButton.Clicked += () => { if (IsSetBlocked) { return; } Resize(Count - 1); }; } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { _readOnly = false; _canReorderItems = true; _notNullItems = false; // No support for different collections for now if (HasDifferentValues || HasDifferentTypes) { return; } var size = Count; // Try get MemberCollectionAttribute for collection editor meta var attributes = Values.GetAttributes(); if (attributes != null) { var memberCollection = (MemberCollectionAttribute)attributes.FirstOrDefault(x => x is MemberCollectionAttribute); if (memberCollection != null) { // TODO: handle NotNullItems by filtering child editors SetValue _readOnly = memberCollection.ReadOnly; _canReorderItems = memberCollection.CanReorderItems; _notNullItems = memberCollection.NotNullItems; } } // Size if (_readOnly) { layout.Label("Size", size.ToString()); } else { _size = layout.IntegerValue("Size"); _size.IntValue.MinValue = 0; _size.IntValue.MaxValue = ushort.MaxValue; _size.IntValue.Value = size; _size.IntValue.ValueChanged += OnSizeChanged; } // Elements if (size > 0) { var elementType = ElementType; if (_canReorderItems) { for (int i = 0; i < size; i++) { layout.Object(new CollectionItemLabel(this, i), new ListValueContainer(elementType, i, Values)); } } else { for (int i = 0; i < size; i++) { layout.Object("Element " + i, new ListValueContainer(elementType, i, Values)); } } } _elementsCount = size; // Add/Remove buttons if (!_readOnly) { var area = layout.Space(20); var addButton = new Button(area.ContainerControl.Width - (16 + 16 + 2 + 2), 2, 16, 16) { Text = "+", TooltipText = "Add new item", AnchorStyle = AnchorStyle.UpperRight, Parent = area.ContainerControl }; addButton.Clicked += () => { if (IsSetBlocked) { return; } Resize(Count + 1); }; var removeButton = new Button(addButton.Right + 2, addButton.Y, 16, 16) { Text = "-", TooltipText = "Remove last item", AnchorStyle = AnchorStyle.UpperRight, Parent = area.ContainerControl, Enabled = size > 0 }; removeButton.Clicked += () => { if (IsSetBlocked) { return; } Resize(Count - 1); }; } }
public override void Initialize(LayoutElementsContainer layout) { var proxy = (PropertiesProxy)Values[0]; proxy._materialSlotComboBoxes.Clear(); proxy._isolateCheckBoxes.Clear(); proxy._highlightCheckBoxes.Clear(); var lods = proxy.Asset.LODs; // General properties { var group = layout.Group("General"); var minScreenSize = group.FloatValue("Min Screen Size", "The minimum screen size to draw model (the bottom limit). Used to cull small models. Set to 0 to disable this feature."); minScreenSize.FloatValue.MinValue = 0.0f; minScreenSize.FloatValue.MaxValue = 1.0f; minScreenSize.FloatValue.Value = proxy.Asset.MinScreenSize; minScreenSize.FloatValue.ValueChanged += () => { proxy.Asset.MinScreenSize = minScreenSize.FloatValue.Value; proxy.Window.MarkAsEdited(); }; } // Group per LOD for (int lodIndex = 0; lodIndex < lods.Length; lodIndex++) { var lod = lods[lodIndex]; int triangleCount = 0, vertexCount = 0; for (int meshIndex = 0; meshIndex < lod.Meshes.Length; meshIndex++) { var mesh = lod.Meshes[meshIndex]; triangleCount += mesh.Triangles; vertexCount += mesh.Vertices; } var group = layout.Group("LOD " + lodIndex); group.Label(string.Format("Triangles: {0:N0} Vertices: {1:N0}", triangleCount, vertexCount)); group.Label("Size: " + lod.Bounds.Size); var screenSize = group.FloatValue("Screen Size", "The screen size to switch LODs. Bottom limit of the model screen size to render this LOD."); screenSize.FloatValue.MinValue = 0.0f; screenSize.FloatValue.MaxValue = 10.0f; screenSize.FloatValue.Value = lod.ScreenSize; screenSize.FloatValue.ValueChanged += () => { lod.ScreenSize = screenSize.FloatValue.Value; proxy.Window.MarkAsEdited(); }; // Every mesh properties for (int meshIndex = 0; meshIndex < lod.Meshes.Length; meshIndex++) { var mesh = lod.Meshes[meshIndex]; group.Label("Mesh " + meshIndex); // Material Slot var materialSlot = group.ComboBox("Material Slot", "Material slot used by this mesh during rendering"); materialSlot.ComboBox.Tag = mesh; materialSlot.ComboBox.SelectedIndexChanged += comboBox => proxy.SetMaterialSlot((Mesh)comboBox.Tag, comboBox.SelectedIndex); proxy._materialSlotComboBoxes.Add(materialSlot.ComboBox); // Isolate var isolate = group.Checkbox("Isolate", "Shows only this mesh (and meshes using the same material slot)"); isolate.CheckBox.Tag = mesh; isolate.CheckBox.StateChanged += (box) => proxy.SetIsolate(box.Checked ? (Mesh)box.Tag : null); proxy._isolateCheckBoxes.Add(isolate.CheckBox); // Highlight var highlight = group.Checkbox("Highlight", "Highlights this mesh with a tint color (and meshes using the same material slot)"); highlight.CheckBox.Tag = mesh; highlight.CheckBox.StateChanged += (box) => proxy.SetHighlight(box.Checked ? (Mesh)box.Tag : null); proxy._highlightCheckBoxes.Add(highlight.CheckBox); } } // Import Settings { var group = layout.Group("Import Settings"); var importSettingsField = typeof(PropertiesProxy).GetField("ImportSettings", BindingFlags.NonPublic | BindingFlags.Instance); var importSettingsValues = new ValueContainer(importSettingsField) { proxy.ImportSettings }; group.Object(importSettingsValues); layout.Space(5); var reimportButton = group.Button("Reimport"); reimportButton.Button.Clicked += () => ((PropertiesProxy)Values[0]).Reimport(); } // Refresh UI proxy.UpdateMaterialSlotsUI(); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { _readOnly = false; _notNullItems = false; // No support for different collections for now if (HasDifferentValues || HasDifferentTypes) { return; } var type = Values.Type; var size = Count; var argTypes = type.GetGenericArguments(); var keyType = argTypes[0]; var valueType = argTypes[1]; _canEditKeys = keyType == typeof(string) || keyType.IsPrimitive || keyType.IsEnum; // Try get CollectionAttribute for collection editor meta var attributes = Values.GetAttributes(); Type overrideEditorType = null; float spacing = 0.0f; if (attributes != null) { var collection = (CollectionAttribute)attributes.FirstOrDefault(x => x is CollectionAttribute); if (collection != null) { // TODO: handle ReadOnly and NotNullItems by filtering child editors SetValue _readOnly = collection.ReadOnly; _notNullItems = collection.NotNullItems; overrideEditorType = TypeUtils.GetType(collection.OverrideEditorTypeName).Type; spacing = collection.Spacing; } } // Size if (_readOnly || !_canEditKeys) { layout.Label("Size", size.ToString()); } else { _size = layout.IntegerValue("Size"); _size.IntValue.MinValue = 0; _size.IntValue.MaxValue = ushort.MaxValue; _size.IntValue.Value = size; _size.IntValue.ValueChanged += OnSizeChanged; } // Elements if (size > 0) { var keysEnumerable = ((IDictionary)Values[0]).Keys.OfType <object>(); var keys = keysEnumerable as object[] ?? keysEnumerable.ToArray(); for (int i = 0; i < size; i++) { if (i != 0 && spacing > 0f) { if (layout.Children.Count > 0 && layout.Children[layout.Children.Count - 1] is PropertiesListElement propertiesListElement) { if (propertiesListElement.Labels.Count > 0) { var label = propertiesListElement.Labels[propertiesListElement.Labels.Count - 1]; var margin = label.Margin; margin.Bottom += spacing; label.Margin = margin; } propertiesListElement.Space(spacing); } else { layout.Space(spacing); } } var key = keys.ElementAt(i); var overrideEditor = overrideEditorType != null ? (CustomEditor)Activator.CreateInstance(overrideEditorType) : null; layout.Object(new DictionaryItemLabel(this, key), new DictionaryValueContainer(new ScriptType(valueType), key, Values), overrideEditor); } } _elementsCount = size; // Add/Remove buttons if (!_readOnly && _canEditKeys) { var area = layout.Space(20); var addButton = new Button(area.ContainerControl.Width - (16 + 16 + 2 + 2), 2, 16, 16) { Text = "+", TooltipText = "Add new item", AnchorPreset = AnchorPresets.TopRight, Parent = area.ContainerControl }; addButton.Clicked += () => { if (IsSetBlocked) { return; } Resize(Count + 1); }; var removeButton = new Button(addButton.Right + 2, addButton.Y, 16, 16) { Text = "-", TooltipText = "Remove last item", AnchorPreset = AnchorPresets.TopRight, Parent = area.ContainerControl, Enabled = size > 0 }; removeButton.Clicked += () => { if (IsSetBlocked) { return; } Resize(Count - 1); }; } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var materialWin = Values[0] as MaterialWindow; var material = materialWin?.Asset; if (material == null) { _parametersHash = -1; layout.Label("No parameters"); return; } if (!material.IsLoaded) { _parametersHash = -2; layout.Label("Loading..."); return; } _parametersHash = material._parametersHash; var parameters = material.Parameters; for (int i = 0; i < parameters.Length; i++) { var p = parameters[i]; if (!p.IsPublic) { continue; } var pIndex = i; var pValue = p.Value; var pGuidType = false; Type pType; switch (p.Type) { case MaterialParameterType.CubeTexture: pType = typeof(CubeTexture); pGuidType = true; break; case MaterialParameterType.Texture: case MaterialParameterType.NormalMap: pType = typeof(Texture); pGuidType = true; break; case MaterialParameterType.RenderTarget: pType = typeof(RenderTarget); pGuidType = true; break; default: pType = p.Value.GetType(); break; } var propertyValue = new CustomValueContainer( pType, pValue, (instance, index) => { // Get material parameter var win = (MaterialWindow)instance; return(win.Asset.Parameters[pIndex].Value); }, (instance, index, value) => { // Set material parameter and surface parameter var win = (MaterialWindow)instance; // Visject surface paramaters are only value type objects so convert value if need to (eg. instead of texture ref write texture id) var surfaceParam = value; if (pGuidType) { surfaceParam = (value as FlaxEngine.Object)?.ID ?? Guid.Empty; } win.Asset.Parameters[pIndex].Value = value; win.Surface.Parameters[pIndex].Value = surfaceParam; win._paramValueChange = true; } ); var propertyLabel = new DragablePropertyNameLabel(p.Name); propertyLabel.Tag = pIndex; propertyLabel.MouseLeftDoubleClick += (label, location) => StartParameterRenaming(pIndex, label); propertyLabel.MouseRightClick += (label, location) => ShowParameterMenu(pIndex, label, ref location); propertyLabel.Drag = DragParameter; var property = layout.AddPropertyItem(propertyLabel); property.Object(propertyValue); } if (parameters.Length > 0) { layout.Space(10); } // Parameters creating var paramType = layout.Enum(typeof(NewParameterType)); paramType.Value = (int)NewParameterType.Float; var newParam = layout.Button("Add parameter"); newParam.Button.Clicked += () => AddParameter((ParameterType)paramType.Value); }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { string[] layerNames = LayersAndTagsSettings.GetCurrentLayers(); int layersCount = Math.Max(4, layerNames.Length); _checkBoxes = new List <CheckBox>(); _layersCount = layersCount; float labelsWidth = 100.0f; float labelsHeight = 18; var panel = layout.Space(100).Spacer; var gridPanel = new GridPanel(0) { Parent = panel, }; var upperLeftCell = new Label { Parent = gridPanel, }; var upperRightCell = new VerticalPanel { ClipChildren = false, Pivot = new Vector2(0.0f, 0.0f), Offset = new Vector2(-labelsWidth, 0), Rotation = -90, Spacing = 0, TopMargin = 0, BottomMargin = 0, Parent = gridPanel, }; var bottomLeftCell = new VerticalPanel { Spacing = 0, TopMargin = 0, BottomMargin = 0, Parent = gridPanel, }; var grid = new UniformGridPanel(0) { SlotsHorizontally = layersCount, SlotsVertically = layersCount, Parent = gridPanel, }; // Set layer names int layerIndex = 0; for (; layerIndex < layerNames.Length; layerIndex++) { upperRightCell.AddChild(new Label { Height = labelsHeight, Text = layerNames[layerNames.Length - layerIndex - 1], HorizontalAlignment = TextAlignment.Near, }); bottomLeftCell.AddChild(new Label { Height = labelsHeight, Text = layerNames[layerIndex], HorizontalAlignment = TextAlignment.Far, }); } for (; layerIndex < layersCount; layerIndex++) { string name = "Layer " + layerIndex; upperRightCell.AddChild(new Label { Height = labelsHeight, Text = name, HorizontalAlignment = TextAlignment.Near, }); bottomLeftCell.AddChild(new Label { Height = labelsHeight, Text = name, HorizontalAlignment = TextAlignment.Far, }); } // Arrange panel.Height = gridPanel.Height = gridPanel.Width = labelsWidth + layersCount * 18; gridPanel.RowFill[0] = gridPanel.ColumnFill[0] = labelsWidth / gridPanel.Width; gridPanel.RowFill[1] = gridPanel.ColumnFill[1] = 1 - gridPanel.ColumnFill[0]; // Create matrix for (int row = 0; row < layersCount; row++) { int column = 0; for (; column < layersCount - row; column++) { var box = new CheckBox(0, 0, true) { Tag = new Vector2(_layersCount - column - 1, row), Parent = grid, Checked = GetBit(column, row), }; box.StateChanged += OnCheckBoxChanged; _checkBoxes.Add(box); } for (; column < layersCount; column++) { grid.AddChild(new Label()); } } }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var window = Values[0] as VisjectSurfaceWindow <TAsset, TSurface, TPreview>; var asset = window?.Asset; if (asset == null) { layout.Label("No parameters"); return; } if (!asset.IsLoaded) { layout.Label("Loading..."); return; } var parameters = window.Surface.Parameters; for (int i = 0; i < parameters.Count; i++) { var p = parameters[i]; if (!p.IsPublic) { continue; } var pIndex = i; var pValue = p.Value; Type pType; object[] attributes = null; switch (p.Type) { case ParameterType.CubeTexture: pType = typeof(CubeTexture); break; case ParameterType.Texture: case ParameterType.NormalMap: pType = typeof(Texture); break; case ParameterType.RenderTarget: case ParameterType.RenderTargetArray: case ParameterType.RenderTargetCube: case ParameterType.RenderTargetVolume: pType = typeof(RenderTarget); break; default: pType = p.Value.GetType(); // TODO: support custom attributes with defined value range for parameter (min, max) attributes = DefaultAttributes; break; } var propertyValue = new CustomValueContainer ( pType, pValue, (instance, index) => ((VisjectSurfaceWindow <TAsset, TSurface, TPreview>)instance).GetParameter(pIndex), (instance, index, value) => ((VisjectSurfaceWindow <TAsset, TSurface, TPreview>)instance).SetParameter(pIndex, value), attributes ); var propertyLabel = new DragablePropertyNameLabel(p.Name) { Tag = pIndex, Drag = DragParameter }; propertyLabel.MouseLeftDoubleClick += (label, location) => StartParameterRenaming(pIndex, label); propertyLabel.MouseRightClick += (label, location) => ShowParameterMenu(pIndex, label, ref location); var property = layout.AddPropertyItem(propertyLabel); property.Object(propertyValue); } // Parameters creating var newParameterTypes = window.NewParameterTypes; if (newParameterTypes != null) { if (parameters.Count > 0) { layout.Space(10); } var paramType = layout.Enum(newParameterTypes); paramType.Value = (int)ParameterType.Float; var newParam = layout.Button("Add parameter"); newParam.Button.Clicked += () => AddParameter((ParameterType)paramType.Value); } }