Example #1
0
        public void Attach(IPointerInput pointer = null, IKeyboard keyboard = null)
        {
            if (pointer != null)
            {
                var previousPointerHandler = pointerHandler;

                if (pointer is IRelativePositionPointerInput)
                {
                    status         = Status.NotGrabbed;
                    pointerHandler = new RelativePointerHandler((IRelativePositionPointerInput)pointer);
                }
                else if (pointer is IAbsolutePositionPointerInput)
                {
                    status         = Status.NotGrabbable;
                    pointerHandler = new AbsolutePointerHandler((IAbsolutePositionPointerInput)pointer, widget);
                }

                var pia = PointerInputAttached;
                if (pia != null)
                {
                    pia(pointerHandler, previousPointerHandler);
                }
            }

            if (keyboard != null)
            {
                keyboardHandler = keyboard;
            }
        }
Example #2
0
 public override bool Update(IPointerInput input)
 {
     if(!decision.CanSell()) {
         decision.Pass();
         return true;
     }
     return base.Update(input);
 }
        public void AttachTo(IPointerInput inputToAttach)
        {
            handler.Attach(pointer: inputToAttach);
            var ia = InputAttached;

            if (ia != null)
            {
                ia(inputToAttach);
            }
        }
 public void DetachFrom(IPointerInput inputToDetach)
 {
     handler.Detach(pointer: true);
 }
Example #5
0
 protected abstract IPointerInput GetCurrentPointerInput(IPointerInput previousPointerInput);
Example #6
0
 private IPointerInput GetCurrentPointerInput()
 {
     if(null == lastMouseInput)
     {
         lastMouseInput = CreateDefaultPointerInput();
     }
     var previousPointerInput = lastMouseInput;
     return GetCurrentPointerInput(previousPointerInput);
 }
Example #7
0
        protected override void Update(GameTime gameTime)
        {
            lastMouseInput = GetCurrentPointerInput();
            while(!game.IsOver && (null == decisionModel || decisionModel.Update(lastMouseInput)))
            {
                var spaceBeansDecision = game.Decisions.FirstOrDefault();
                if(null == spaceBeansDecision)
                {
                    break;
                }
                decisionModel = CreateModelForDecision(spaceBeansDecision);
                if(game.IsOver)
                {
                    break;
                }
                lastMouseInput = GetCurrentPointerInput();
            }

            base.Update(gameTime);
        }
Example #8
0
 public virtual bool Update(IPointerInput input)
 {
     if(input.IsNewActivation) {
         var activatedSprite = FindActivatedSprite(input.Location);
         if(null != activatedSprite) {
             return this.selectedHandlers[activatedSprite](activatedSprite);
         }
     }
     return false;
 }
Example #9
0
 protected PointerHandler(IPointerInput input)
 {
     this.input = input;
 }
Example #10
0
 protected override IPointerInput GetCurrentPointerInput(IPointerInput previousPointerInput)
 {
     return new MouseInput((MouseInput)previousPointerInput);
 }
Example #11
0
 public static IDisposable Activate(IPointerInput pointer)
 {
     return(new InputControllerMartyr <IPointerInput>(inputStack: _pointerInputStack, inputController: pointer));
 }
Example #12
0
 protected PointerHandler(IPointerInput input)
 {
     this.input = input;
 }
Example #13
0
        public void Attach(IPointerInput pointer = null, IKeyboard keyboard = null)
        {
            if(pointer != null)
            {
                var previousPointerHandler = pointerHandler;

                if(pointer is IRelativePositionPointerInput)
                {
                    status = Status.NotGrabbed;
                    pointerHandler = new RelativePointerHandler((IRelativePositionPointerInput)pointer);
                }
                else if(pointer is IAbsolutePositionPointerInput)
                {
                    status = Status.NotGrabbable;
                    pointerHandler = new AbsolutePointerHandler((IAbsolutePositionPointerInput)pointer, widget);
                }

                var pia = PointerInputAttached;
                if(pia != null)
                {
                    pia(pointerHandler, previousPointerHandler);
                }
            }

            if(keyboard != null)
            {
                keyboardHandler = keyboard;
            }
        }
Example #14
0
        void IHandler <Touch> .Handle(FrameArgs frame, Touch e)
        {
            Vector2 where;
            var src = this.FindInputSinkByPoint(e.SurfacePoint, Matrix4.Identity, out where);

            switch (e.State)
            {
            case TouchState.Start:
                if (_pointerId >= 0)
                {
                    return;
                }
                if (e.Index == _pointerId && _focused != null && src != _focused)
                {
                    _focused.OnPointerExit(where);
                    _focused.OnPointerUp(where);
                }
                if (src != null)
                {
                    _focused = src;
                    src.OnPointerDown(where);
                    _pointerId = e.Index;
                }
                break;

            case TouchState.Move:
                if (e.Index != _pointerId)
                {
                    return;
                }
                if (_focused != null)
                {
                    if (_focused != src)
                    {
                        _focused.OnPointerExit(where);
                    }
                    else if (_current != _focused && _focused == src)
                    {
                        _focused.OnPointerEnter(where);
                    }
                    else
                    {
                        _focused.OnPointerMove(where);
                    }
                }
                break;

            case TouchState.End:
                if (e.Index != _pointerId)
                {
                    return;
                }
                if (_focused != null)
                {
                    _focused.OnPointerUp(where);
                }
                _focused   = null;
                _pointerId = -1;
                break;

            case TouchState.Cancel:
                if (e.Index != _pointerId)
                {
                    return;
                }
                if (_focused != null)
                {
                    _focused.OnPointerExit(where);
                    _focused.OnPointerUp(where);
                }
                _focused   = null;
                _pointerId = -1;
                break;
            }
            _current = src;
        }
Example #15
0
 public PointerHandler(IPointerInput input)
 {
     this.input = input;
 }
 public void AttachTo(IPointerInput inputToAttach)
 {
     displayWidget.AttachTo(inputToAttach);
 }
 public void DetachFrom(IPointerInput inputToDetach)
 {
     displayWidget.DetachFrom(inputToDetach);
 }
Example #18
0
 public PointerHandler(IPointerInput input)
 {
     this.input = input;
 }