Esempio n. 1
0
        public static void Move(CommandItem source, CommandListView dest, int index)
        {
            //Debug.Log($"{source.GetIndex()} to {index}");
            if (source.ParentList == dest && source.GetIndex() == index)
            {
                return;
            }

            PersistentSerializedProperty sourcePProp = source.CommandProperty;

            if (dest.CommandArrayProperty.AbsolutePath.StartsWith(sourcePProp.AbsolutePath))
            {
                EditorUtility.DisplayDialog("", "コマンドをそれ自身の子に移動することはできません。", "OK");
                return;
            }

            var destItem = dest.AddCommandAt(index, sourcePProp);

            //コピー元の削除
            //データの削除
            var sourceIndex = sourcePProp.GetArrayIndex();

            source.ParentList.RemoveCommandAt(sourceIndex);

            //コピー先の選択
            destItem.Select();
        }
Esempio n. 2
0
 public CommandMoveTargetManipulator(CommandListView list, Func <MovementPart, int> getIndexFunc,
                                     Action onHoverTop,
                                     Action onHoverBottom,
                                     Action onHoverRelease)
 {
     CommandList         = list;
     GetIndexFunc        = getIndexFunc;
     this.OnHoverTop     = onHoverTop;
     this.OnHoverBottom  = onHoverBottom;
     this.OnHoverRelease = onHoverRelease;
 }
Esempio n. 3
0
 public CommandListView(CommandListView parentList, PersistentSerializedProperty commandArray)
 {
     Domain = parentList.Domain;
     CommandArrayProperty = commandArray;
     if (!CommandArrayProperty.IsArray)
     {
         throw new ArgumentException("commandArray must be an array.");
     }
     ParentList = parentList;
     BuildList();
 }
Esempio n. 4
0
        public override void OnCreated()
        {
            CustomDetailRoot.Clear();

            var commandProp = CommandItem.CommandProperty;

            var containerProp     = commandProp.GetChildProperty("container.commands");
            var containerListView = new CommandListView(CommandItem.ParentList, containerProp);

            CustomDetailRoot.Add(containerListView);
        }
Esempio n. 5
0
        public override void OnCreated()
        {
            CustomDetailRoot.Clear();

            var l0 = new Label("ルーチン");

            CustomDetailRoot.Add(l0);

            var commandProp = CommandItem.CommandProperty;

            var trueProp     = commandProp.GetChildProperty("routine.commands");
            var trueListView = new CommandListView(CommandItem.ParentList, trueProp);

            CustomDetailRoot.Add(trueListView);
        }
Esempio n. 6
0
        /// <summary>
        /// EventCommandEditorが作成されたときに呼び出されます。
        /// </summary>
        public virtual void OnCreated()
        {
            //ShowListViewInCustomDetailAttributeがついてるEventCommandListをDetailに追加する
            var commandProp = CommandItem.CommandProperty.GetProperty();
            var typeDesc    = commandProp.managedReferenceFullTypename.Split(' ');

            var assemblyName = typeDesc[0];
            var typeName     = typeDesc[1];

            var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name == assemblyName);

            if (assembly == default)
            {
                return;
            }

            var type = assembly.DefinedTypes.FirstOrDefault(t => t.FullName == typeName);

            if (type == default)
            {
                return;
            }

            var fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            var field  = fields.FirstOrDefault(f => Enumerable.Any <CustomAttributeData>(f.CustomAttributes,
                                                                                         a => a.AttributeType == typeof(ShowListViewInCustomDetailAttribute)));

            if (field == default)
            {
                return;
            }
            if (field.FieldType != typeof(EventCommandList))
            {
                return;
            }

            var listProp = CommandItem.CommandProperty.GetChildProperty(field.Name);

            if (listProp.GetProperty() == null)
            {
                return;
            }

            var list = new CommandListView(CommandItem.ParentList, listProp.GetChildProperty("commands"));

            CustomDetailRoot.Add(list);
        }
Esempio n. 7
0
        public override void OnCreated()
        {
            CustomDetailRoot.Clear();

            var l0 = new Label("真の場合");

            CustomDetailRoot.Add(l0);

            var commandProp = CommandItem.CommandProperty;

            var trueProp     = commandProp.GetChildProperty("ifTrue.commands");
            var trueListView = new CommandListView(CommandItem.ParentList, trueProp);

            CustomDetailRoot.Add(trueListView);

            var l1 = new Label("偽の場合");

            CustomDetailRoot.Add(l1);

            var falseProp     = commandProp.GetChildProperty("ifFalse.commands");
            var falseListView = new CommandListView(CommandItem.ParentList, falseProp);

            CustomDetailRoot.Add(falseListView);
        }
Esempio n. 8
0
 public void Move(CommandListView dest, int index)
 {
     CommandListView.Move(target as CommandItem, dest, index);
 }
Esempio n. 9
0
        public CommandItem(CommandEditorDomain domain, CommandListView parentList,
                           PersistentSerializedProperty property,
                           Action <CommandItem, CommandListView, int> onMove) : base()
        {
            Domain          = domain;
            ParentList      = parentList;
            CommandProperty = property;

            this.binding = new CommandItemBinding(() =>
            {
                if (this != Domain.SelectedItem)
                {
                    return;
                }
                UpdateCommandDetail();
            });

            VisualTreeAsset uiAsset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(visualTreeAssetPath);
            VisualElement   root    = uiAsset.CloneTree();

            this.Add(root);

            this.AddManipulator(new CommandMovableManipulator(this));
            this.AddManipulator(new CommandMoveTargetManipulator(
                                    ParentList,
                                    part =>
            {
                switch (part)
                {
                case MovementPart.Top:
                    return(GetIndex());

                case MovementPart.Bottom:
                    return(GetIndex() + 1);

                default:
                    throw new ArgumentOutOfRangeException(nameof(part), part, null);
                }
            },
                                    () =>
            {
                this.style.borderBottomWidth = new StyleFloat(0f);
                this.style.borderTopWidth    = new StyleFloat(3f);
                this.style.borderTopColor    = new StyleColor(new Color(0.2f, 0.3411765f, 0.8509805f));
            },
                                    () =>
            {
                this.style.borderTopWidth    = new StyleFloat(0f);
                this.style.borderBottomWidth = new StyleFloat(3f);
                this.style.borderBottomColor = new StyleColor(new Color(0.2f, 0.3411765f, 0.8509805f));
            },
                                    () =>
            {
                this.style.borderTopWidth    = new StyleFloat(0f);
                this.style.borderBottomWidth = new StyleFloat(0f);
            }));

            this.RegisterCallback <MouseDownEvent>(evt =>
            {
                evt.StopPropagation();
                Select();
            });

            var enabledToggle = this.Q <Toggle>("CommandEnabled");

            enabledToggle.RegisterCallback <ChangeEvent <bool> >(evt =>
            {
                var prop              = CommandProperty.GetProperty();
                var propEnabled       = prop.FindPropertyRelative("enabled");
                propEnabled.boolValue = evt.newValue;
                propEnabled.serializedObject.ApplyModifiedProperties();
            });

            //string typeName = GetTypeName();

            var customContentContainer = this.Q <VisualElement>("CommandCustomDetailContent");

            customContentContainer.Clear();
            Editor = CreateEditor(GetCommandType(), this, customContentContainer);
            UpdateCommandDetail();
        }
Esempio n. 10
0
 internal CommandEditorDomain(SerializedProperty rootCommandArray, Action <CommandItem> onItemSelected)
 {
     RootCommandListView = new CommandListView(this, rootCommandArray);
     OnItemSelected      = onItemSelected;
 }