예제 #1
0
        public virtual void Update(GameTime gameTime)
        {
            if (_rearrangeList)
            {
                _interactableElements.RemoveAll(e => !e.IsInteractable);
                _interactableElements.Sort((e1, e2) => e1.TabIndex.CompareTo(e2.TabIndex));
            }

            foreach (var inputController in InputControllers)
            {
                inputController.Update(this);
            }

            if (_elementToGetFocus != null && _elementToGetFocus.State == UiState.Active)
            {
                _elementToGetFocus.Focus();
                CurrentElement     = _elementToGetFocus;
                _elementToGetFocus = null;
            }
        }
예제 #2
0
        private void ControllerOnMoveToNextElement()
        {
            var lastElement = CurrentElement;

            if (CurrentElement == null)
            {
                CurrentElement = _interactableElements.FirstOrDefault();
            }
            else
            {
                var index = _interactableElements.IndexOf(CurrentElement);
                CurrentElement = index == _interactableElements.Count - 1 ? _interactableElements[0] : _interactableElements[index + 1];
            }

            if (lastElement != CurrentElement)
            {
                lastElement?.Unfocus();
                CurrentElement?.Focus();
            }
        }
예제 #3
0
 protected void AddUiElement(UiElement element)
 {
     _interactableElements.Add(element);
     _rearrangeList = true;
 }
예제 #4
0
 private void ControllerOnOnAction(UiElement uiElement)
 {
     CurrentElement?.OnAction();
 }
 protected void InvokeAction(UiElement element)
 {
     OnAction?.Invoke(element);
 }
 protected void RemoveChild(UiElement element)
 {
     _children.Remove(element);
 }
 /// <summary>
 /// Adds a child control to compound element.
 /// </summary>
 /// <param name="element"></param>
 protected void AddChildElement(UiElement element)
 {
     _children.Add(element);
 }