void BuildCriteriaForComponentQuery(ComponentQueryDeclarationModel componentQueryDeclarationModel, ref int nbRows, Blackboard blackboard) { var componentQuery = blackboard != null ? new ComponentQuery(componentQueryDeclarationModel, Store, blackboard.Rebuild) : new ComponentQuery(componentQueryDeclarationModel, Store, _ => { }); var componentQueryDeclarationExpandableRow = new ExpandableRow("") { name = "componentsSectionComponentQuery", viewDataKey = "CriteriaSubSection/" + componentQueryDeclarationModel.GetId(), userData = $"CriteriaSubSection/{componentQueryDeclarationModel.name}", }; componentQueryDeclarationExpandableRow.Sortable = true; componentQueryDeclarationExpandableRow.ExpandableRowTitleContainer.AddManipulator(new Clickable(() => { })); componentQueryDeclarationExpandableRow.ExpandableRowTitleContainer.Add(componentQuery); componentQueryDeclarationExpandableRow.ExpandableRowTitleContainer.Add(new Label("(" + componentQueryDeclarationModel.CriteriaModels.Count + ")") { name = "count" }); componentQueryDeclarationExpandableRow.ExpandableRowTitleContainer.Add(new Button(() => { AddCriteriaModel(componentQueryDeclarationModel); }) { name = "addCriteriaButton", text = "+" }); var rowName = $"{ComponentQueriesRow.BlackboardEcsProviderTypeName}/{GetType().Name}/{componentQueryDeclarationModel}"; componentQueryDeclarationExpandableRow.OnExpanded += e => Store.GetState().EditorDataModel?.ExpandBlackboardRowsUponCreation(new[] { rowName }, e); State state = blackboard?.Store.GetState(); if (state != null && state.EditorDataModel.ShouldExpandBlackboardRowUponCreation(rowName)) { componentQueryDeclarationExpandableRow.Expanded = true; } ExpandedContainer.Add(componentQueryDeclarationExpandableRow); blackboard?.GraphVariables.Add(componentQuery); componentQueryDeclarationModel.ExpandOnCreateUI = false; nbRows += AddCriteriaModelRows(componentQueryDeclarationModel, componentQueryDeclarationExpandableRow.ExpandedContainer); }
public ComponentsSubSection(Stencil stencil, IReadOnlyCollection <ComponentQueryDeclarationModel> componentQueryDeclarationModels, Blackboard blackboard) : base("Components", graphElementModel: null, store: blackboard.Store, parentElement: null, rebuildCallback: null, canAcceptDrop: null) { m_Stencil = stencil; name = "componentsSection"; userData = name; AddToClassList("subSection"); int nbRows = 0; State state = blackboard.Store.GetState(); foreach (var componentQueryDeclarationModel in componentQueryDeclarationModels) { var componentQuery = new ComponentQuery(componentQueryDeclarationModel, Store, blackboard.Rebuild); var componentQueryDeclarationExpandableRow = new ExpandableRow("") { name = "componentsSectionComponentQuery", viewDataKey = "ComponentsSubSection/" + componentQueryDeclarationModel.GetId(), userData = $"ComponentsSubSection/{componentQueryDeclarationModel.name}", }; componentQueryDeclarationExpandableRow.Sortable = true; componentQueryDeclarationExpandableRow.ExpandableRowTitleContainer.AddManipulator(new Clickable(() => {})); componentQueryDeclarationExpandableRow.ExpandableRowTitleContainer.Add(componentQuery); componentQueryDeclarationExpandableRow.ExpandableRowTitleContainer.Add(new Label($"({(componentQueryDeclarationModel.Query?.Components?.Count ?? 0)})") { name = "count" }); componentQueryDeclarationExpandableRow.ExpandableRowTitleContainer.Add(new Button(() => { AddComponentToQuery(componentQueryDeclarationModel); }) { name = "addComponentButton", text = "+" }); var rowName = $"{ComponentQueriesRow.BlackboardEcsProviderTypeName}/{GetType().Name}/{componentQueryDeclarationModel}"; componentQueryDeclarationExpandableRow.OnExpanded += e => Store.GetState().EditorDataModel?.ExpandBlackboardRowsUponCreation(new[] { rowName }, e); if (state.EditorDataModel.ShouldExpandBlackboardRowUponCreation(rowName)) { componentQueryDeclarationExpandableRow.Expanded = true; } ExpandedContainer.Add(componentQueryDeclarationExpandableRow); blackboard.GraphVariables.Add(componentQuery); componentQueryDeclarationModel.ExpandOnCreateUI = false; nbRows += AddRows(componentQueryDeclarationModel, componentQueryDeclarationExpandableRow.ExpandedContainer); } viewDataKey = "blackboardComponentsSection"; OnExpanded = e => Store.GetState().EditorDataModel?.ExpandBlackboardRowsUponCreation( new[] { $"{ComponentQueriesRow.BlackboardEcsProviderTypeName}/{GetType().Name}" }, e); SectionTitle.text += " (" + nbRows + ")"; }