public static bool IsInteractableAndActive(this IComponent item)
        {
            if (item == null)
            {
                return(false);
            }

            IInteractableComponent button = null;

            if (item is LinkerComponent)
            {
                button = (item as LinkerComponent).Get <IInteractableComponent>();
            }
            else
            {
                button = item as IInteractableComponent;
            }

            if (button != null && button.IsVisible() == true && button.IsInteractable() == true)
            {
                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public static void Select(IInteractableComponent button)
        {
            if (button != null)
            {
                var sel = button.GetSelectable();
                if (sel != null)
                {
                    if (button.IsVisible() == false)
                    {
                        var buttonBase = (button as WindowComponentBase);

                        System.Action callback = null;
                        callback = () => {
                            WindowSystem.GetEvents().Unregister(buttonBase, WindowEventType.OnShowEnd, callback);
                            WindowSystemInput.Select_INTERNAL(button);
                        };

                        WindowSystem.GetEvents().Register(buttonBase, WindowEventType.OnShowEnd, callback);
                    }
                    else
                    {
                        WindowSystemInput.Select_INTERNAL(button);
                    }
                }
            }
        }
 public override void Shutdown()
 {
     if (interactableComponent != null)
     {
         interactableComponent.OnAttackHand -= InteractableComponent_OnAttackHand;
         interactableComponent = null;
     }
     base.Shutdown();
 }
		public static void Deselect(IInteractableComponent button) {

			if (button != null) {

				var sel = button.GetSelectable();
				if (sel != null) sel.OnDeselect(null);

			}

		}
Beispiel #5
0
        public static void WaitForClickOnElement(IInteractableComponent button, List <IInteractableComponent> except, System.Action onClick = null, object paramObject = null)
        {
            WindowSystemInput.waitForClickOnElementCallback   = onClick;
            WindowSystemInput.waitForClickOnElement           = button;
            WindowSystemInput.waitForClickOnElementExceptList = except;

            if (WindowSystemInput.instance.waitForClickWindowSource != null)
            {
                WindowSystemInput.instance.waitForClickWindowInstance = WindowSystem.Show(WindowSystemInput.instance.waitForClickWindowSource as WindowBase, x => (x as IWaitForClickOnElementWindow).OnParametersPass(button, paramObject));
            }
        }
Beispiel #6
0
 public static void Deselect(IInteractableComponent button)
 {
     if (button != null)
     {
         var sel = button.GetSelectable();
         if (sel != null)
         {
             sel.OnDeselect(null);
         }
     }
 }
Beispiel #7
0
        public static void ResetWaitForClickOnElement()
        {
            WindowSystemInput.waitForClickOnElementCallback   = null;
            WindowSystemInput.waitForClickOnElement           = null;
            WindowSystemInput.waitForClickOnElementExceptList = null;

            if (WindowSystemInput.instance.waitForClickWindowInstance != null)
            {
                WindowSystemInput.instance.waitForClickWindowInstance.Hide();
                WindowSystemInput.instance.waitForClickWindowInstance = null;
            }
        }
        public InteractionHandler(
            IInteractableComponent component,
            EventTracker <T> highlightTracker,
            EventTracker <T> interactionTracker)
        {
            Assert.IsNotNull(component, "component != null");
            Assert.IsNotNull(highlightTracker, "highlightTracker != null");
            Assert.IsNotNull(interactionTracker, "interactionTracker != null");

            Component          = component;
            HighlightTracker   = highlightTracker;
            InteractionTracker = interactionTracker;
        }
 public override void Initialize()
 {
     if (Owner.TryGetComponent <IInteractableComponent>(out var interactable))
     {
         interactableComponent = interactable;
         interactableComponent.OnAttackHand += InteractableComponent_OnAttackHand;
     }
     else
     {
         Logger.Error($"Item component must have an interactable component to function! Prototype: {Owner.Prototype.ID}");
     }
     base.Initialize();
 }
Beispiel #10
0
        private static void Select_INTERNAL(IInteractableComponent button)
        {
            var sel = button.GetSelectable();

            if (sel != null)
            {
                WindowSystemInput.Deselect(button);
                sel.Select();
                if (sel is ButtonExtended)
                {
                    (sel as ButtonExtended).Select(forced: true);
                }
            }
        }
Beispiel #11
0
 public static void Deselect(IInteractableComponent button)
 {
     if (button != null)
     {
         var sel = button.GetSelectable();
         if (sel != null)
         {
             if (EventSystem.current.currentSelectedGameObject == sel.gameObject)
             {
                 EventSystem.current.SetSelectedGameObject(null);
             }
         }
     }
 }
Beispiel #12
0
 public static void RaiseWaitForClickOnElement(IInteractableComponent button)
 {
     if (WindowSystemInput.CanClickOnElement(button) == true)
     {
         if (WindowSystemInput.waitForClickOnElement == null || WindowSystemInput.waitForClickOnElement == button)
         {
             var callback = WindowSystemInput.waitForClickOnElementCallback;
             WindowSystemInput.ResetWaitForClickOnElement();
             if (callback != null)
             {
                 callback.Invoke();
             }
         }
     }
 }
Beispiel #13
0
        public static bool CanClickOnElement(IInteractableComponent button)
        {
            if (WindowSystemInput.waitForClickOnElementWindows != null)
            {
                var isTargetWindow = WindowSystemInput.waitForClickOnElementWindows.Contains(button.GetWindow().GetType());
                if (isTargetWindow == false)
                {
                    return(true);
                }
            }

            if (WindowSystemInput.waitForClickOnElementExceptList != null)
            {
                if (WindowSystemInput.waitForClickOnElementExceptList.Contains(button) == true)
                {
                    return(true);
                }
            }

            return(WindowSystemInput.waitForClickOnElement == null || WindowSystemInput.waitForClickOnElement == button);
        }
Beispiel #14
0
 public UnsettableColor ValueFor(IInteractableComponent component) =>
 ValueFor(!component.Interactable, component.Highlighted, component.Interacting);
Beispiel #15
0
        public static IInteractableComponent FindFirstActiveAncestor(this IInteractableComponent component)
        {
            var ancestor = component.Ancestors.FirstOrDefault(a => a is IInteractableComponent && a.Visible);

            return(ancestor as IInteractableComponent);
        }
Beispiel #16
0
        public static bool HasActiveChild(this IInteractableComponent component)
        {
            var active = (component.Context as IRuntimeUIContext)?.ActiveComponent;

            return(active?.Ancestors.FirstOrDefault(c => ReferenceEquals(c, component)) != null);
        }
Beispiel #17
0
 public TextStyle ValueFor(IInteractableComponent component) =>
 ValueFor(!component.Interactable, component.Highlighted, component.Interacting);
Beispiel #18
0
 public static void WaitForClickOnElement(IInteractableComponent button, System.Action onClick = null, object paramObject = null)
 {
     WindowSystemInput.WaitForClickOnElement(button, null, onClick, paramObject);
 }