示例#1
0
        public override void Input()
        {
            if (!ModalActive)
            {
                return;
            }
            IInputMap inputMap = Woofer.Controller.InputManager.ActiveInputMap;

            Vector2D movement = inputMap.Movement;

            if (movement.Magnitude > 1e-5 && Editor.MoveTimeframe.Execute())
            {
                if (movement.Y > 0)
                {
                    if (SelectedPropertyIndex - 1 >= 0)
                    {
                        SelectedPropertyIndex--;
                    }
                }
                else if (movement.Y < 0)
                {
                    if (SelectedPropertyIndex + 1 < Members.Count)
                    {
                        SelectedPropertyIndex++;
                    }
                }
            }

            if (inputMap.Jump.Consume())
            {
                IMemberSummary member = Members.ElementAt(SelectedPropertyIndex);
                if (member.CanSet)
                {
                    bool modalNeedsChange = member.TriggerEdit(inputMap.Interact.Pressed);
                    if (modalNeedsChange)
                    {
                        ModalActive = false;
                    }
                }
            }
        }
示例#2
0
        public override void Input()
        {
            if (!ModalActive)
            {
                return;
            }

            IInputMap inputMap = Woofer.Controller.InputManager.ActiveInputMap;

            Vector2D movement = inputMap.Movement;

            if (movement.Magnitude > 1e-5 && Editor.MoveTimeframe.Execute())
            {
                if (movement.Y > 0)
                {
                    if (ComponentLocked)
                    {
                        if (SelectedPropertyIndex - 1 >= 0)
                        {
                            SelectedPropertyIndex--;
                        }
                    }
                    else
                    {
                        if (SelectedAnimationIndex - 1 >= -2)
                        {
                            SelectedAnimationIndex--;
                        }
                    }
                }
                else if (movement.Y < 0)
                {
                    if (ComponentLocked)
                    {
                        if (SelectedPropertyIndex + 1 < SelectedAnimation.Members.Count)
                        {
                            SelectedPropertyIndex++;
                        }
                    }
                    else
                    {
                        if (SelectedAnimationIndex + 1 <= Animations.Count)
                        {
                            SelectedAnimationIndex++;
                        }
                    }
                }

                if (movement.Y != 0)
                {
                    RemoveTimer = 0;
                }

                /*if (SelectedComponentIndex < StartOffset)
                 * {
                 *  StartOffset = SelectedComponentIndex;
                 * }
                 * if (SelectedComponentIndex > StartOffset + AmountVisible)
                 * {
                 *  StartOffset = SelectedComponentIndex - AmountVisible;
                 * }*/
            }

            if (inputMap.Jump.Consume())
            {
                if (SelectedAnimationIndex == Animations.Count)
                {
                    Animations.Add(new AnimatedSprite());
                }
                else if (!ComponentLocked)
                {
                    SelectedAnimation     = new ObjectSummary(Owner, Animations[SelectedAnimationIndex]);
                    SelectedPropertyIndex = 0;
                    ComponentLocked       = true;
                }
                else
                {
                    if (SelectedPropertyIndex >= SelectedAnimation.Members.Count)
                    {
                        return;
                    }
                    IMemberSummary member = SelectedAnimation.Members.Values.ElementAt(SelectedPropertyIndex);
                    if (member.CanSet)
                    {
                        bool modalNeedsChange = member.TriggerEdit(inputMap.Interact.Pressed);
                        if (modalNeedsChange)
                        {
                            ModalActive = false;
                        }
                    }
                }
            }

            if (RemoveTimer > 0)
            {
                RemoveTimer--;
            }
            if (inputMap.Pulse.Pressed && SelectedAnimationIndex >= 0 && !ComponentLocked)
            {
                RemoveTimer += 2;
                if (RemoveTimer / 25 > 3)
                {
                    Animations.RemoveAt(SelectedAnimationIndex);
                    RemoveTimer = 0;
                    if (SelectedAnimationIndex >= Animations.Count)
                    {
                        SelectedAnimationIndex = Animations.Count - 1;
                    }
                }
            }
            else
            {
                RemoveTimer = 0;
            }

            if (SelectedAnimationIndex >= 0 && SelectedAnimationIndex < AnimationRenderOffsets.Count)
            {
                int y = AnimationRenderOffsets[SelectedAnimationIndex];
                if (y < 0)
                {
                    ListFromIndex--;
                }
                else if (y > 720)
                {
                    ListFromIndex = Math.Max(0, SelectedAnimationIndex - 2);
                }
            }
        }
示例#3
0
        public override void Input()
        {
            if (!ModalActive)
            {
                return;
            }
            if (!Owner.Entities.ContainsId(Selected))
            {
                return;
            }
            Entity entity = Owner.Entities[Selected];

            if (entity == null)
            {
                Owner.Events.InvokeEvent(new RequestModalChangeEvent(null));
                return;
            }

            IInputMap inputMap = Woofer.Controller.InputManager.ActiveInputMap;

            Vector2D movement = inputMap.Movement;

            if (movement.Magnitude > 1e-5 && Editor.MoveTimeframe.Execute())
            {
                if (movement.Y > 0)
                {
                    if (ComponentLocked)
                    {
                        if (SelectedPropertyIndex - 1 >= 0)
                        {
                            SelectedPropertyIndex--;
                        }
                    }
                    else
                    {
                        if (SelectedComponentIndex - 1 >= -2)
                        {
                            SelectedComponentIndex--;
                        }
                    }
                }
                else if (movement.Y < 0)
                {
                    if (ComponentLocked)
                    {
                        if (SelectedPropertyIndex + 1 < SelectedComponent.Members.Count)
                        {
                            SelectedPropertyIndex++;
                        }
                    }
                    else
                    {
                        if (SelectedComponentIndex + 1 <= entity.Components.Count + 1)
                        {
                            SelectedComponentIndex++;
                        }
                    }
                }

                if (movement.Y != 0)
                {
                    RemoveTimer = 0;
                }

                /*if (SelectedComponentIndex < StartOffset)
                 * {
                 *  StartOffset = SelectedComponentIndex;
                 * }
                 * if (SelectedComponentIndex > StartOffset + AmountVisible)
                 * {
                 *  StartOffset = SelectedComponentIndex - AmountVisible;
                 * }*/
            }

            if (inputMap.Jump.Consume())
            {
                if (SelectedComponentIndex == -2)
                {
                    new PropertySummary(Owner, typeof(Entity).GetProperty("Name"), entity).TriggerEdit(inputMap.Interact.Pressed);
                    ModalActive = false;
                }
                else if (SelectedComponentIndex == -1)
                {
                    entity.Active = !entity.Active;
                }
                else if (SelectedComponentIndex == Helper.Components.Count)
                {
                    Owner.Events.InvokeEvent(new StartEnumSelectEvent("Available components", Component.GetAllIdentifiers().Where(s => !Helper.Components.ContainsKey(s)).ToList(), AddComponent, null));
                    Owner.Events.InvokeEvent(new ForceModalChangeEvent("enum_select", null));
                    ModalActive  = false;
                    ModalVisible = false;
                }
                else if (SelectedComponentIndex == Helper.Components.Count + 1)
                {
                    Owner.Events.InvokeEvent(new StartTextInputEvent(entity.Name, n => TagIOUtils.SavePrefab(entity, n), null)
                    {
                        Label = "Prefab Name"
                    });
                    Owner.Events.InvokeEvent(new ForceModalChangeEvent("text_input", null));
                    ModalActive = false;
                }
                else if (!ComponentLocked)
                {
                    SelectedComponent     = Helper.Components.Values.ElementAt(SelectedComponentIndex);
                    SelectedPropertyIndex = 0;
                    ComponentLocked       = true;
                }
                else
                {
                    if (SelectedPropertyIndex >= Helper.Components.Values.ElementAt(SelectedComponentIndex).Members.Count)
                    {
                        return;
                    }
                    IMemberSummary member = Helper.Components.Values.ElementAt(SelectedComponentIndex).Members.Values.ElementAt(SelectedPropertyIndex);
                    if (member.CanSet)
                    {
                        bool modalNeedsChange = member.TriggerEdit(inputMap.Interact.Pressed);
                        if (modalNeedsChange)
                        {
                            ModalActive = false;
                        }
                    }
                }
            }

            if (RemoveTimer > 0)
            {
                RemoveTimer--;
            }
            if (inputMap.Pulse.Pressed && SelectedComponentIndex >= 0 && !ComponentLocked)
            {
                RemoveTimer += 2;
                if (RemoveTimer / 25 > 3)
                {
                    Owner.Entities[Selected].Components.Remove(Helper.Components.Values.ElementAt(SelectedComponentIndex).ComponentName);
                    RemoveTimer = 0;
                    Helper.Update(Selected);
                    if (SelectedComponentIndex >= Helper.Components.Count)
                    {
                        SelectedComponentIndex = Helper.Components.Count - 1;
                    }
                }
            }
            else
            {
                RemoveTimer = 0;
            }

            if (SelectedComponentIndex >= 0 && SelectedComponentIndex < ComponentRenderOffsets.Count)
            {
                int y = ComponentRenderOffsets[SelectedComponentIndex];
                if (y < 0)
                {
                    ListFromIndex--;
                }
                else if (y > 720)
                {
                    ListFromIndex = Math.Max(0, SelectedComponentIndex - 2);
                }
            }
        }