public bool RegisterDisabler(UIElementDisabler disabler)
 {
     bool result = false;
     if (!string.IsNullOrEmpty(disabler.UIElementID) && (!disablerMap.ContainsKey(disabler.UIElementID) || disabler.GiveUniqueID))
     {
         if (disablerMap.ContainsKey(disabler.UIElementID))
         {
             int num = 0;
             string text;
             do
             {
                 text = $"{disabler.UIElementID}_{num}";
                 num++;
             }
             while (disablerMap.ContainsKey(text));
             disabler.UIElementID = text;
         }
         disablerMap[disabler.UIElementID] = disabler;
         result = true;
         if (disabledElements.ContainsKey(disabler.UIElementID))
         {
             disabler.DisableElement(disabledElements[disabler.UIElementID]);
         }
         else
         {
             foreach (string key in disabledGroups.Keys)
             {
                 if (disablerGroupMap.ContainsKey(key) && disablerGroupMap[key].ContainsElement(disabler))
                 {
                     disabler.DisableElement(disabledGroups[key]);
                 }
             }
         }
         if (isShowingDebugLabels)
         {
             disabler.ShowDebugIDLabel();
         }
     }
     return result;
 }
Пример #2
0
    public void SetHighlight(DTutorialOverlay overlayData)
    {
        data = overlayData;
        Vector3 worldPoint = Vector3.zero;

        highlightSize = Vector2.zero;
        if (data.Target != null)
        {
            RectTransform component = data.Target.GetComponent <RectTransform>();
            if (component != null)
            {
                Canvas componentInParent = data.Target.GetComponentInParent <Canvas>();
                worldPoint = component.position;
                if (componentInParent.renderMode == RenderMode.ScreenSpaceCamera)
                {
                    worldPoint = RectTransformUtility.WorldToScreenPoint(componentInParent.worldCamera, worldPoint);
                }
                if (data.AutoSize)
                {
                    highlightSize = component.rect.size;
                }
            }
            else
            {
                worldPoint = Camera.main.WorldToScreenPoint(data.Target.transform.position);
            }
        }
        CanvasScalerExt component2 = GetComponentInParent <Canvas>().GetComponent <CanvasScalerExt>();
        Vector2         a          = new Vector2(component2.ReferenceResolutionY / (float)Screen.height, component2.ReferenceResolutionY / (float)Screen.height);

        a *= 1f / component2.ScaleModifier;
        int num = 0;
        DataEntityHandle entityByType = Service.Get <CPDataEntityCollection>().GetEntityByType <SystemBarsData>();

        if (!entityByType.IsNull)
        {
            SystemBarsData component3 = Service.Get <CPDataEntityCollection>().GetComponent <SystemBarsData>(entityByType);
            num = component3.CurrentNavigationBarHeight;
        }
        if (data.Target != null)
        {
            highlightPosition = new Vector2((data.Position.x + worldPoint.x) * a.x, (data.Position.y - (float)num + worldPoint.y) * a.y);
        }
        else
        {
            highlightPosition = new Vector2((float)Screen.width * data.Position.x * a.x, (float)Screen.height * (data.Position.y - (float)num) * a.y);
        }
        highlightSize += data.Size;
        Color color = new Color(1f, 1f, 1f, Mathf.Clamp(data.Opacity, 0f, 1f));

        BackgroundShape.GetComponent <Image>().sprite = getShapeSprite(data.Shape);
        BackgroundShape.GetComponent <Image>().color  = color;
        LeftBG.GetComponent <Image>().color           = color;
        RightBG.GetComponent <Image>().color          = color;
        TopBG.GetComponent <Image>().color            = color;
        BottomBG.GetComponent <Image>().color         = color;
        updateBackground();
        updatePopup();
        isShowing = true;
        base.gameObject.SetActive(value: true);
        if (data.DisableUI)
        {
            Service.Get <EventDispatcher>().DispatchEvent(default(UIDisablerEvents.DisableAllUIElements));
            Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.DisableUIElement("Joystick"));
            if (data.Target != null && data.EnableTarget)
            {
                UIElementDisabler component4 = data.Target.GetComponent <UIElementDisabler>();
                if (component4 != null)
                {
                    Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.EnableUIElement(component4.UIElementID));
                }
            }
        }
        UpdateHighlightOutline(data.ShowHighlightOutline);
        enableUIElementsOnClose = data.DisableUI;
        GetComponent <CanvasGroup>().blocksRaycasts = data.BlocksRaycast;
        Service.Get <BackButtonController>().Add(onBackClicked);
    }
 public bool ContainsElement(UIElementDisabler disabler)
 {
     return(groupElementsList.Contains(disabler));
 }