Exemplo n.º 1
0
        public EntityEditWidget(Entity target, EntityEditor editor)
        {
            BuildUI();

            if (target.Parent is null)
            {
                _deleteEntityButton.Enabled = false;
            }

            _tagTextBox.Text = target.Tag;

            _setTagButton.Click += (s, a) =>
            {
                var    newTag = _tagTextBox.Text;
                string oldTag = target.Tag;

                if (!(target.Parent is null))
                {
                    foreach ((string key, Entity entity) in target.Parent.Children)
                    {
                        if (key == newTag)
                        {
                            ErrorBox box = new ErrorBox("Duplicate tag. Children of a parent must have a unique tag.", null);

                            box.ShowModal(Desktop);
                            return;
                        }
                    }
                    target.Parent.Children.Remove(oldTag);
                    target.Parent.Children.Add(newTag, target);
                }
                target.Tag = newTag;
                editor.RebuildTree();
            };
        }
Exemplo n.º 2
0
 public void ShowEditor <T>(EntityEditor <T> editor, Action <AlertAction> onClose = null) where T : new()
 {
     _editor = editor;
     _actions.Add(AlertAction.Ok);
     _actions.Add(AlertAction.Cancel);
     Show(onClose);
 }
Exemplo n.º 3
0
        bool MogitorsRoot.IDragDropHandler.OnDragOver(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position)
        {
            if (dragData.Object == null)
            {
                return(false);
            }

            Mogre.Ray mouseRay = vp.Camera.GetCameraToViewportRay(position.x, position.y);

            EntityEditor entity = dragData.Object as EntityEditor;

            bool hitFound = false;

            if (!hitFound)
            {
                if (entity.Position.x == 999999 && entity.Position.y == 999999 && entity.Position.z == 999999)
                {
                    entity.Position = mouseRay.Origin + mouseRay.Direction * 40.0f;
                }
                else
                {
                    entity.Position = MogitorsRoot.Instance.GetGizmoIntersectCameraPlane(entity, mouseRay);
                }
            }

            return(true);
        }
Exemplo n.º 4
0
        public override float GetPropertyHeight(UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            var h     = 22f + 18f;
            var list  = property.GetSerializedValue <ME.ECS.Collections.DataList <Entity> >();
            var world = ME.ECS.Worlds.currentWorld;

            if (world == null || list.Count == 0)
            {
                h += DataListEntityListPropertyEditor.EMPTY_HEIGHT;
            }
            else
            {
                var i = 0;
                if (list.IsCreated() == true)
                {
                    foreach (var item in list.Read())
                    {
                        var elementLabel = new UnityEngine.GUIContent($"Element {i}");
                        h += EntityEditor.GetHeight(item, elementLabel);
                        ++i;
                    }
                }
            }

            return(h);
        }
Exemplo n.º 5
0
 public override void Update(PositionComponent position, SpawnEvent ev, EntityEditor editor)
 {
     if (ev.Request != _config.Request)
     {
         return;
     }
     _config.SpawnCallback(editor.AddEntity(), position.Point);
 }
Exemplo n.º 6
0
    public object DrawAndGetNewValue(Type type, string fieldName, object value, Entity entity, int index, IComponent component)
    {
        var myObject  = (CustomObject)value;
        var fieldType = myObject.GetType().GetField("name").FieldType;

        EntityEditor.DrawAndSetElement(fieldType, "customObject.name", myObject.name,
                                       entity, index, component, newValue => myObject.name = (string)newValue);
        return(myObject);
    }
Exemplo n.º 7
0
    protected override void OnEnable()
    {
        base.OnEnable();

        entityEditor = new EntityEditor();
        actionEditor = new ActionEditor();
        normEditor   = new NormEditor();
        goalEditor   = new GoalEditor();
    }
Exemplo n.º 8
0
        public void ClickingEntityTwiceDisposesOldEditor()
        {
            if (mouse == null)
            {
                return;                 // ncrunch: no coverage
            }
            selector.Add(ellipse);
            Click(Vector2D.Half);
            EntityEditor oldEditor = selector.ActiveEditor;

            Click(Vector2D.Half);
            Assert.AreEqual(0, oldEditor.scene.Controls.Count);
            Assert.AreNotEqual(oldEditor, selector.ActiveEditor);
        }
Exemplo n.º 9
0
 private void OnGUI()
 {
     if (GUILayout.Button("Entity Editor"))
     {
         EntityEditor.ShowWindow();
     }
     if (GUILayout.Button("Item Editor"))
     {
         ItemEditor.ShowWindow();
     }
     if (GUILayout.Button("Quest Editor"))
     {
         QuestEditor.ShowWindow();
     }
 }
Exemplo n.º 10
0
        public void ShowInput <T>(T defaultValue, string label, Action <AlertAction, T> onClose = null)
        {
            var entity = new InputValue <T>()
            {
                Value = defaultValue
            };

            var editor = new EntityEditor <InputValue <T> >(entity)
                         .Label(e => e.Value, label)
                         .Required(e => e.Value);

            ShowEditor(editor, (action) =>
            {
                onClose?.Invoke(action, entity.Value);
            });
        }
Exemplo n.º 11
0
        public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
        {
            var headerRect = position;

            headerRect.height = 22f;

            var countRect = position;

            countRect.y     += headerRect.height;
            countRect.height = 18f;

            var contentRect = position;

            contentRect.y      += headerRect.height + countRect.height;
            contentRect.height -= headerRect.height + countRect.height;

            var list = property.GetSerializedValue <ME.ECS.Collections.DataList <Entity> >();

            UnityEngine.GUI.Label(headerRect, label, UnityEditor.EditorStyles.boldLabel);
            UnityEngine.GUI.Label(countRect, $"Count: {list.Count}");
            var world = ME.ECS.Worlds.currentWorld;

            if (world == null || list.Count == 0)
            {
                UnityEngine.GUI.Label(contentRect, "List is empty");
            }
            else
            {
                var rect = contentRect;
                var i    = 0;
                if (list.IsCreated() == true)
                {
                    foreach (var item in list.Read())
                    {
                        var elementLabel = new UnityEngine.GUIContent($"Element {i}");
                        var h            = EntityEditor.GetHeight(item, elementLabel);
                        rect.height = h;
                        EntityEditor.Draw(rect, item, elementLabel);
                        rect.y += h;
                        ++i;
                    }
                }
            }
        }
Exemplo n.º 12
0
        public void ShowTextInput(string defaultValue, string label, Action <AlertAction, string> onClose = null, bool required = true)
        {
            var entity = new InputValue <string>()
            {
                Value = defaultValue
            };

            var editor = new EntityEditor <InputValue <string> >(entity)
                         .Label(e => e.Value, label)
                         .Editor(e => e.Value, e => e.Text(multiLine: true));

            if (required)
            {
                editor.Required(e => e.Value);
            }

            ShowEditor(editor, (action) =>
            {
                onClose?.Invoke(action, entity.Value);
            });
        }
Exemplo n.º 13
0
        void MogitorsRoot.IDragDropHandler.OnDragWheel(DragData dragData, Mogre.Viewport vp, float delta)
        {
            if (dragData.Object == null)
            {
                return;
            }

            EntityEditor entity = dragData.Object as EntityEditor;

            Mogre.Vector3 vPos     = entity.Position;
            float         distance = (vPos - vp.Camera.DerivedPosition).Length + (delta / 120.0f);

            if (vPos.x == 999999 && vPos.y == 999999 && vPos.z == 999999)
            {
                return;
            }
            else
            {
                vPos = vp.Camera.DerivedPosition + ((vPos - vp.Camera.DerivedPosition).NormalisedCopy * distance);
            }

            entity.Position = vPos;
        }
Exemplo n.º 14
0
        private void grid_RowActivated(object o, Data.RowActivatedArgs args)
        {
            DbTable?table = dataQueryResult.Table;

            if (table == null)
            {
                return;
            }

            DataField [] idFields = dataQueryResult.IdFields;
            if (idFields == null || idFields.Length == 0)
            {
                return;
            }

            SourceItemId id = new SourceItemId(
                new RowReader(dataQueryResult.Result [args.Row], dataQueryResult.Columns),
                table, idFields);

            id.AddConstants(dataQueryResult.IdConstants);
            BusinessDomain.FeedbackProvider.TrackEvent("Feature", "Open Entity from Report");

            EntityEditor.OpenEntityForEdit(id);
        }
Exemplo n.º 15
0
 public abstract void Update(Entity entity, T component, EntityEditor editor);
Exemplo n.º 16
0
 protected virtual EditorItem GetEditorItem(CustomDataType type, string custom, PropertyInfo property)
 {
     RequiredAttribute required = property.GetCustomAttributes(typeof(RequiredAttribute), true).FirstOrDefault() as RequiredAttribute;
     EditorItem item;
     switch (type)
     {
         case CustomDataType.Boolean:
             item = new BoolEditor(Frame);
             break;
         case CustomDataType.Currency:
             item = new CurrencyEditor(Frame);
             break;
         case CustomDataType.Date:
             item = new DateEditor(Frame);
             break;
         case CustomDataType.DateTime:
             item = new DateTimeEditor(Frame);
             break;
         case CustomDataType.Default:
             item = new DefaultEditor(Frame);
             if (required != null)
                 ((DefaultEditor)item).IsAllowdEmpty = required.AllowEmptyStrings;
             break;
         case CustomDataType.EmailAddress:
             item = new EmailAddressEditor(Frame);
             break;
         case CustomDataType.Html:
             item = new HtmlEditor(Frame);
             break;
         case CustomDataType.ImageUrl:
             item = new ImageUrlEditor(Frame);
             break;
         case CustomDataType.Image:
             item = new ImageEditor(Frame);
             break;
         case CustomDataType.Integer:
             item = new IntegerEditor(Frame);
             break;
         case CustomDataType.MultilineText:
             item = new MultilineTextEditor(Frame);
             if (required != null)
                 ((MultilineTextEditor)item).IsAllowdEmpty = required.AllowEmptyStrings;
             break;
         case CustomDataType.Number:
             item = new NumberEditor(Frame);
             break;
         case CustomDataType.Password:
             item = new PasswordEditor(Frame);
             break;
         case CustomDataType.PhoneNumber:
             item = new PhoneNumberEditor(Frame);
             break;
         case CustomDataType.Sex:
             item = new SexEditor(Frame);
             break;
         case CustomDataType.Text:
             item = new DefaultEditor(Frame);
             break;
         case CustomDataType.Time:
             item = new TimeEditor(Frame);
             break;
         case CustomDataType.Url:
             item = new UrlEditor(Frame);
             break;
         default:
             switch (custom)
             {
                 case "Enum":
                     item = GetEnumEditorItem(property.PropertyType);
                     break;
                 case "Entity":
                     item = new EntityEditor(Frame, property.PropertyType);
                     break;
                 case "Collection":
                     item = new CollectionEditor(Frame, property.PropertyType.GetGenericArguments()[0]);
                     break;
                 default:
                     throw new NotSupportedException("不支持自定义类型编辑器。");
             }
             break;
     }
     if (required != null)
         item.IsRequired = true;
     return item;
 }
Exemplo n.º 17
0
 public abstract void Update(T1 component1, T2 component2, EntityEditor editor);
Exemplo n.º 18
0
        protected virtual EditorItem GetEditorItem(CustomDataType type, string custom, PropertyInfo property)
        {
            RequiredAttribute required = property.GetCustomAttributes(typeof(RequiredAttribute), true).FirstOrDefault() as RequiredAttribute;
            EditorItem        item;

            switch (type)
            {
            case CustomDataType.Boolean:
                item = new BoolEditor(Frame);
                break;

            case CustomDataType.Currency:
                item = new CurrencyEditor(Frame);
                break;

            case CustomDataType.Date:
                item = new DateEditor(Frame);
                break;

            case CustomDataType.DateTime:
                item = new DateTimeEditor(Frame);
                break;

            case CustomDataType.Default:
                item = new DefaultEditor(Frame);
                if (required != null)
                {
                    ((DefaultEditor)item).IsAllowdEmpty = required.AllowEmptyStrings;
                }
                break;

            case CustomDataType.EmailAddress:
                item = new EmailAddressEditor(Frame);
                break;

            case CustomDataType.Html:
                item = new HtmlEditor(Frame);
                break;

            case CustomDataType.ImageUrl:
                item = new ImageUrlEditor(Frame);
                break;

            case CustomDataType.Image:
                item = new ImageEditor(Frame);
                break;

            case CustomDataType.Integer:
                item = new IntegerEditor(Frame);
                break;

            case CustomDataType.MultilineText:
                item = new MultilineTextEditor(Frame);
                if (required != null)
                {
                    ((MultilineTextEditor)item).IsAllowdEmpty = required.AllowEmptyStrings;
                }
                break;

            case CustomDataType.Number:
                item = new NumberEditor(Frame);
                break;

            case CustomDataType.Password:
                item = new PasswordEditor(Frame);
                break;

            case CustomDataType.PhoneNumber:
                item = new PhoneNumberEditor(Frame);
                break;

            case CustomDataType.Sex:
                item = new SexEditor(Frame);
                break;

            case CustomDataType.Text:
                item = new DefaultEditor(Frame);
                break;

            case CustomDataType.Time:
                item = new TimeEditor(Frame);
                break;

            case CustomDataType.Url:
                item = new UrlEditor(Frame);
                break;

            default:
                switch (custom)
                {
                case "Enum":
                    item = GetEnumEditorItem(property.PropertyType);
                    break;

                case "Entity":
                    item = new EntityEditor(Frame, property.PropertyType);
                    break;

                case "Collection":
                    item = new CollectionEditor(Frame, property.PropertyType.GetGenericArguments()[0]);
                    break;

                default:
                    throw new NotSupportedException("不支持自定义类型编辑器。");
                }
                break;
            }
            if (required != null)
            {
                item.IsRequired = true;
            }
            return(item);
        }
Exemplo n.º 19
0
 public override void Update(Entity entity, DestroyEvent _, EntityEditor editor)
 {
     editor.RemoveEntity(entity);
 }
Exemplo n.º 20
0
        public override void Update(PositionComponent pos, TrailComponent trail, MovementEvent mov, EntityEditor editor)
        {
            var oldPosition = pos.Point - mov.Offset;
            var color       = trail.Color;
            var entity      = editor.AddEntity();

            entity.AddComponent <PositionComponent>().Init(oldPosition);
            entity.AddComponent <RenderComponent>().Init(color);
            entity.AddComponent <FadeRenderComponent>().Init(_decrease);
        }