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; } }
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); }
protected abstract IPointerInput GetCurrentPointerInput(IPointerInput previousPointerInput);
private IPointerInput GetCurrentPointerInput() { if(null == lastMouseInput) { lastMouseInput = CreateDefaultPointerInput(); } var previousPointerInput = lastMouseInput; return GetCurrentPointerInput(previousPointerInput); }
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); }
public virtual bool Update(IPointerInput input) { if(input.IsNewActivation) { var activatedSprite = FindActivatedSprite(input.Location); if(null != activatedSprite) { return this.selectedHandlers[activatedSprite](activatedSprite); } } return false; }
protected PointerHandler(IPointerInput input) { this.input = input; }
protected override IPointerInput GetCurrentPointerInput(IPointerInput previousPointerInput) { return new MouseInput((MouseInput)previousPointerInput); }
public static IDisposable Activate(IPointerInput pointer) { return(new InputControllerMartyr <IPointerInput>(inputStack: _pointerInputStack, inputController: pointer)); }
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; } }
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; }
public PointerHandler(IPointerInput input) { this.input = input; }
public void AttachTo(IPointerInput inputToAttach) { displayWidget.AttachTo(inputToAttach); }
public void DetachFrom(IPointerInput inputToDetach) { displayWidget.DetachFrom(inputToDetach); }