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); }
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); } }
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)); } }
public static void Deselect(IInteractableComponent button) { if (button != null) { var sel = button.GetSelectable(); if (sel != null) { sel.OnDeselect(null); } } }
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(); }
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); } } }
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); } } } }
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(); } } } }
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); }
public UnsettableColor ValueFor(IInteractableComponent component) => ValueFor(!component.Interactable, component.Highlighted, component.Interacting);
public static IInteractableComponent FindFirstActiveAncestor(this IInteractableComponent component) { var ancestor = component.Ancestors.FirstOrDefault(a => a is IInteractableComponent && a.Visible); return(ancestor as IInteractableComponent); }
public static bool HasActiveChild(this IInteractableComponent component) { var active = (component.Context as IRuntimeUIContext)?.ActiveComponent; return(active?.Ancestors.FirstOrDefault(c => ReferenceEquals(c, component)) != null); }
public TextStyle ValueFor(IInteractableComponent component) => ValueFor(!component.Interactable, component.Highlighted, component.Interacting);
public static void WaitForClickOnElement(IInteractableComponent button, System.Action onClick = null, object paramObject = null) { WindowSystemInput.WaitForClickOnElement(button, null, onClick, paramObject); }