示例#1
0
        /// <summary>
        /// Helper to create toogle row for a specific `AtomType`.
        /// </summary>
        /// <param name="atomType">The provided `AtomType`.</param>
        /// <returns>A new toggle row (`VisualElement`).</returns>
        private VisualElement CreateAtomTypeToGenerateToggleRow(AtomType atomType)
        {
            var row = new VisualElement()
            {
                style = { flexDirection = FlexDirection.Row }
            };

            row.Add(new Label()
            {
                text = atomType.DisplayName, style = { width = 220, marginRight = 8 }
            });
            var toggle = new Toggle()
            {
                value = _atomTypesToGenerate.Contains(atomType)
            };

            toggle.RegisterCallback <ChangeEvent <bool> >(evt =>
            {
                if (evt.newValue)
                {
                    AddAtomTypeToGenerate(atomType);
                }
                else
                {
                    var disabledDeps = RemoveAtomTypeToGenerate(atomType);
                    SetWarningText(atomType, disabledDeps);
                }
            });

            row.Add(toggle);
            return(row);
        }
示例#2
0
        /// <summary>
        /// Remove provided `AtomType` from the list of Atom types to be generated.
        /// </summary>
        /// <param name="atomType">The `AtomType` to be removed.</param>
        private List <AtomType> RemoveAtomTypeToGenerate(AtomType atomType)
        {
            _atomTypesToGenerate.Remove(atomType);
            List <AtomType> disabledDeps = new List <AtomType>();

            foreach (KeyValuePair <AtomType, List <AtomType> > entry in AtomTypes.DEPENDENCY_GRAPH)
            {
                if (!_typeVEDict.ContainsKey(entry.Key))
                {
                    continue;
                }

                if (_atomTypesToGenerate.Contains(entry.Key) && entry.Value.Any((atom) => !_atomTypesToGenerate.Contains(atom)))
                {
                    _typeVEDict[entry.Key].SetEnabled(false);
                    var toggle = _typeVEDict[entry.Key].Query <Toggle>().First();
                    toggle.SetValueWithoutNotify(false);
                    toggle.MarkDirtyRepaint();
                    disabledDeps.Add(entry.Key);
                    disabledDeps = disabledDeps.Concat(RemoveAtomTypeToGenerate(entry.Key)).ToList();
                }
            }

            return(disabledDeps);
        }
示例#3
0
 /// <summary>
 /// Set and display warning text in the editor.
 /// </summary>
 /// <param name="atomType">`AtomType` to generate the warning for.</param>
 /// <param name="disabledDeps">List of disabled deps.</param>
 private void SetWarningText(AtomType atomType, List <AtomType> disabledDeps = null)
 {
     if (disabledDeps != null && disabledDeps.Count > 0)
     {
         string warningText = $"{String.Join(", ", disabledDeps.Select((a) => a.Name))} depend(s) on {atomType.Name}.";
         _typesToGenerateInfoRow.Query <Label>().First().text = warningText;
     }
     else
     {
         _typesToGenerateInfoRow.Query <Label>().First().text = "";
     }
 }
        /// <summary>
        /// Add provided `AtomType` to the list of Atom types to be generated.
        /// </summary>
        /// <param name="atomType">The `AtomType` to be added.</param>
        private void AddAtomTypeToGenerate(AtomType atomType)
        {
            _atomTypesToGenerate.Add(atomType);

            foreach (KeyValuePair <AtomType, List <AtomType> > entry in _dependencies)
            {
                if (entry.Value.All((atom) => _atomTypesToGenerate.Contains(atom)))
                {
                    _typeVEDict[entry.Key].SetEnabled(true);
                }
            }

            _typesToGenerateInfoRow.Query <Label>().First().text = "";
        }
示例#5
0
        /// <summary>
        /// Add provided `AtomType` to the list of Atom types to be generated.
        /// </summary>
        /// <param name="atomType">The `AtomType` to be added.</param>
        private void AddAtomTypeToGenerate(AtomType atomType)
        {
            _atomTypesToGenerate.Add(atomType);

            foreach (KeyValuePair <AtomType, List <AtomType> > entry in AtomTypes.DEPENDENCY_GRAPH)
            {
                if (!_typeVEDict.ContainsKey(entry.Key))
                {
                    continue;
                }

                if (entry.Value.All((atom) => _atomTypesToGenerate.Contains(atom)))
                {
                    _typeVEDict[entry.Key].SetEnabled(true);
                }
            }

            _typesToGenerateInfoRow.Query <Label>().First().text = "";
        }
示例#6
0
 public void Deconstruct(out AtomType atomType, out string valueType)
 {
     atomType  = this.AtomType;
     valueType = this.ValueType;
 }
示例#7
0
 public AtomReceipe(AtomType atomType, string valueType)
 {
     this.AtomType  = atomType;
     this.ValueType = valueType;
 }