private static void AddControlTreeItemsRecursive(InputControlLayout layout, TreeViewItem parent, string prefix, string deviceControlId, string commonUsage) { foreach (var control in layout.controls.OrderBy(a => a.name)) { if (control.isModifyingChildControlByPath) { continue; } // Skip variants except the default variant and variants dictated by the layout itself. if (!control.variants.IsEmpty() && control.variants != InputControlLayout.DefaultVariant && (layout.variants.IsEmpty() || !InputControlLayout.VariantsMatch(layout.variants, control.variants))) { continue; } var child = new ControlTreeViewItem(control, prefix, deviceControlId, commonUsage) { depth = parent.depth + 1, }; parent.AddChild(child); var childLayout = EditorInputControlLayoutCache.TryGetLayout(control.layout); if (childLayout != null) { AddControlTreeItemsRecursive(childLayout, parent, child.controlPath, deviceControlId, commonUsage); } } }
private void AddControlTreeItemsRecursive(InputControlLayout layout, DeviceDropdownItem parent, string device, string usage, bool searchable, ControlDropdownItem parentControl = null) { foreach (var control in layout.controls.OrderBy(a => a.name)) { if (control.isModifyingChildControlByPath) { continue; } // Skip variants except the default variant and variants dictated by the layout itself. if (!control.variants.IsEmpty() && control.variants != InputControlLayout.DefaultVariant && (layout.variants.IsEmpty() || !InputControlLayout.VariantsMatch(layout.variants, control.variants))) { continue; } var child = new ControlDropdownItem(parentControl, control.name, control.displayName, device, usage, searchable); child.icon = EditorInputControlLayoutCache.GetIconForLayout(control.layout); if (LayoutMatchesExpectedControlLayoutFilter(control.layout)) { parent.AddChild(child); } var controlLayout = EditorInputControlLayoutCache.TryGetLayout(control.layout); if (controlLayout != null) { AddControlTreeItemsRecursive(controlLayout, parent, device, usage, searchable, child); } } // Add optional controls for devices. var optionalControls = EditorInputControlLayoutCache.GetOptionalControlsForLayout(layout.name); if (optionalControls.Any() && layout.isDeviceLayout) { var optionalGroup = new AdvancedDropdownItem("Optional Controls"); foreach (var optionalControl in optionalControls) { if (LayoutMatchesExpectedControlLayoutFilter(optionalControl.layout)) { var child = new OptionalControlDropdownItem(optionalControl, device, usage); child.icon = EditorInputControlLayoutCache.GetIconForLayout(optionalControl.layout); optionalGroup.AddChild(child); } } if (optionalGroup.children.Any()) { var deviceName = EditorInputControlLayoutCache.TryGetLayout(device).m_DisplayName ?? ObjectNames.NicifyVariableName(device); parent.AddSeparator("Controls Present on More Specific " + deviceName.GetPlural()); parent.AddChild(optionalGroup); } } }
private void AddControlTreeItemsRecursive(InputControlLayout layout, AdvancedDropdownItem parent, string prefix, string deviceControlId, string commonUsage) { foreach (var control in layout.controls.OrderBy(a => a.name)) { if (control.isModifyingChildControlByPath) { continue; } // Skip variants except the default variant and variants dictated by the layout itself. if (!control.variants.IsEmpty() && control.variants != InputControlLayout.DefaultVariant && (layout.variants.IsEmpty() || !InputControlLayout.VariantsMatch(layout.variants, control.variants))) { continue; } var child = new ControlTreeViewItem(control, prefix, deviceControlId, commonUsage); if (LayoutMatchesExpectedControlLayoutFilter(control.layout)) { parent.AddChild(child); } var childLayout = EditorInputControlLayoutCache.TryGetLayout(control.layout); if (childLayout != null) { AddControlTreeItemsRecursive(childLayout, parent, child.controlPath, deviceControlId, commonUsage); } } // Add optional layouts for devices var optionalLayouts = EditorInputControlLayoutCache.GetOptionalControlsForLayout(layout.name); if (optionalLayouts.Any() && layout.isDeviceLayout) { var optionalGroup = new AdvancedDropdownItem("Optional"); foreach (var optionalLayout in optionalLayouts) { if (LayoutMatchesExpectedControlLayoutFilter(optionalLayout.layout)) { optionalGroup.AddChild(new OptionalControlTreeViewItem(optionalLayout, deviceControlId, commonUsage)); } } if (optionalGroup.children.Any()) { parent.AddChild(optionalGroup); } } }