예제 #1
0
 public void OnDisable()
 {
     if (this._action != InputMappingIcons.Actions.None)
     {
         ActionIcon actionIcon = ActionIconSystem.UnregisterIcon(base.transform);
         if (actionIcon)
         {
             if (this._overrideDepth)
             {
                 if (this._currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInBook)
                 {
                     actionIcon._follow._depthRatioBook = this._oldDepth;
                 }
                 else
                 {
                     actionIcon._follow._minDepth = this._oldDepth;
                 }
             }
             if (this._overrideHeight)
             {
                 if (this._currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInBook)
                 {
                     actionIcon._follow._worldOffsetBook.y = this._oldHeight;
                 }
                 else
                 {
                     actionIcon._follow._worldOffset.y = this._oldHeight;
                 }
             }
         }
     }
 }
예제 #2
0
 public void OnEnable()
 {
     if (this._action != InputMappingIcons.Actions.None && (!this._gamepadOnly || TheForest.Utils.Input.IsGamePad) && (!this._mouseOnly || !TheForest.Utils.Input.IsGamePad))
     {
         ActionIcon actionIcon = ActionIconSystem.RegisterIcon(base.transform, this._action, this._sideIcon, this._currentViewOption, false, false, null, null, false);
         if (actionIcon)
         {
             this.FillSprite = actionIcon._fillSprite;
         }
         if ((this._overrideDepth || this._overrideHeight || this._currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInBook || this._currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInInventory) && actionIcon)
         {
             if (this._overrideDepth)
             {
                 if (this._currentViewOption != ActionIconSystem.CurrentViewOptions.AllowInBook)
                 {
                     this._oldDepth = actionIcon._follow._minDepth;
                     actionIcon._follow._minDepth = this._depth;
                 }
             }
             if (this._overrideHeight)
             {
                 if (this._currentViewOption != ActionIconSystem.CurrentViewOptions.AllowInBook)
                 {
                     this._oldHeight = actionIcon._follow._worldOffset.y;
                     actionIcon._follow._worldOffset.y = this._height;
                 }
             }
             if (this._currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInBook || this._currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInInventory)
             {
                 actionIcon._follow._viewportOffsetBook = this._viewportOffset;
             }
         }
     }
 }
예제 #3
0
 private void OnDestroy()
 {
     if (ActionIconSystem.Instance == this)
     {
         ActionIconSystem.Instance = null;
     }
 }
예제 #4
0
 public void OnDisable()
 {
     if (this._action != InputMappingIcons.Actions.None)
     {
         ActionIconSystem.UnregisterIcon(base.transform, this._useAltTextIcon, this._registeredAsBigIcon);
     }
 }
예제 #5
0
        public static ActionIcon RegisterIcon(Transform target, InputMappingIcons.Actions action, ActionIcon.SideIconTypes sideIcon, ActionIconSystem.CurrentViewOptions currentViewOption = ActionIconSystem.CurrentViewOptions.AllowInWorld, bool useAltTextIcon = false, bool useBigIcon = false, Texture2D vrIcon = null, string actionStringOverride = null, bool useFillSprite = false)
        {
            ActionIcon actionIcon = ActionIconSystem.InitializeActionIcon(target, action, sideIcon, currentViewOption, useAltTextIcon, useBigIcon);

            if (ForestVR.Enabled && !ActionIconSystem.Instance._activeVRButtonActionIcons.ContainsKey(target))
            {
                VRControllerDisplayManager.AutoShowAction(action, true, vrIcon, sideIcon, actionStringOverride, (!actionIcon.IsNull()) ? actionIcon._fillSpriteAction : null, useFillSprite);
                ActionIconSystem.Instance._activeVRButtonActionIcons.Add(target, action);
            }
            return(actionIcon);
        }
예제 #6
0
 public static UISprite RegisterIcon(Transform target, InputMappingIcons.Actions action, ActionIconSystem.CurrentViewOptions currentViewOption = ActionIconSystem.CurrentViewOptions.AllowInWorld)
 {
     if (ActionIconSystem.Instance && !ActionIconSystem.Instance._activeIcons.ContainsKey(target))
     {
         ActionIcon actionIcon;
         if (!InputMappingIcons.UsesText(action))
         {
             if (ActionIconSystem.Instance._spriteIconPool.Count > 0)
             {
                 actionIcon = ActionIconSystem.Instance._spriteIconPool.Dequeue();
                 actionIcon.gameObject.SetActive(true);
                 ActionIconSystem.Instance.SetIconHolderTr(actionIcon.transform, currentViewOption);
             }
             else
             {
                 actionIcon = UnityEngine.Object.Instantiate<ActionIcon>(ActionIconSystem.Instance._spriteIconPrefab);
                 ActionIconSystem.Instance.SetIconHolderTr(actionIcon.transform, currentViewOption);
                 actionIcon.transform.localScale = ActionIconSystem.Instance._spriteIconPrefab.transform.localScale;
             }
             actionIcon._sprite.spriteName = InputMappingIcons.GetMappingFor(action);
             UISpriteData atlasSprite = actionIcon._sprite.GetAtlasSprite();
             if (atlasSprite == null)
             {
                 ActionIconSystem.Instance.DisableActionIcon(actionIcon);
                 return null;
             }
             actionIcon._sprite.width = Mathf.RoundToInt((float)atlasSprite.width / (float)atlasSprite.height * (float)actionIcon._sprite.height);
         }
         else
         {
             if (ActionIconSystem.Instance._textIconPool.Count > 0)
             {
                 actionIcon = ActionIconSystem.Instance._textIconPool.Dequeue();
                 actionIcon.gameObject.SetActive(true);
                 ActionIconSystem.Instance.SetIconHolderTr(actionIcon.transform, currentViewOption);
             }
             else
             {
                 actionIcon = UnityEngine.Object.Instantiate<ActionIcon>(ActionIconSystem.Instance._textIconPrefab);
                 ActionIconSystem.Instance.SetIconHolderTr(actionIcon.transform, currentViewOption);
                 actionIcon.transform.localScale = ActionIconSystem.Instance._textIconPrefab.transform.localScale;
             }
             actionIcon._label.text = InputMappingIcons.GetMappingFor(action);
         }
         actionIcon._follow._target = target;
         actionIcon._fillSprite.gameObject.SetActive(false);
         actionIcon._follow._inBook = (currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInBook);
         ActionIconSystem.Instance._activeIcons.Add(target, actionIcon);
         return actionIcon._fillSprite;
     }
     return null;
 }
예제 #7
0
 public void OnEnable()
 {
     if (this._action != InputMappingIcons.Actions.None)
     {
         this.FillSprite = ActionIconSystem.RegisterIcon(base.transform, this._action, this._currentViewOption);
         if (this._overrideDepth || this._overrideHeight)
         {
             ActionIcon actionIcon = ActionIconSystem.GetActionIcon(base.transform);
             if (actionIcon)
             {
                 if (this._overrideDepth)
                 {
                     if (this._currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInBook)
                     {
                         this._oldDepth = actionIcon._follow._depthRatioBook;
                         actionIcon._follow._depthRatioBook = this._depth;
                     }
                     else
                     {
                         this._oldDepth = actionIcon._follow._minDepth;
                         actionIcon._follow._minDepth = this._depth;
                     }
                 }
                 if (this._overrideHeight)
                 {
                     if (this._currentViewOption == ActionIconSystem.CurrentViewOptions.AllowInBook)
                     {
                         this._oldHeight = actionIcon._follow._worldOffsetBook.y;
                         actionIcon._follow._worldOffsetBook.y = this._height;
                     }
                     else
                     {
                         this._oldHeight = actionIcon._follow._worldOffset.y;
                         actionIcon._follow._worldOffset.y = this._height;
                     }
                 }
             }
         }
     }
 }
예제 #8
0
 private void Awake()
 {
     ActionIconSystem.Instance = this;
 }
예제 #9
0
 public void OnEnable()
 {
     if (this._action != InputMappingIcons.Actions.None && (!this._gamepadOnly || TheForest.Utils.Input.IsGamePad || ForestVR.Enabled))
     {
         this._registeredAsBigIcon = (this._useBigIcon || (TheForest.Utils.Input.IsGamePad && this._useBigIconForGamepad));
         Transform transform = base.transform;
         InputMappingIcons.Actions           action            = this._action;
         ActionIcon.SideIconTypes            sideIcon          = this._sideIcon;
         ActionIconSystem.CurrentViewOptions currentViewOption = this._currentViewOption;
         bool       useAltTextIcon      = this._useAltTextIcon;
         bool       registeredAsBigIcon = this._registeredAsBigIcon;
         string     actionTextOverride  = this._actionTextOverride;
         ActionIcon actionIcon          = ActionIconSystem.RegisterIcon(transform, action, sideIcon, currentViewOption, useAltTextIcon, registeredAsBigIcon, null, actionTextOverride, false);
         if (actionIcon)
         {
             this._fillSprite = actionIcon._fillSprite;
             if (this._fillSprite)
             {
                 if (this._fillSprite.gameObject.activeSelf != this._useFillSprite)
                 {
                     this._fillSprite.gameObject.SetActive(this._useFillSprite);
                 }
                 if (this._useFillSprite && actionIcon._fillSpriteAction)
                 {
                     actionIcon._fillSpriteAction.SetAction(this._action);
                 }
             }
             if (actionIcon._sprite && this._widget && this._refreshSiblings)
             {
                 Transform target = this._widget.leftAnchor.target;
                 this._widget.leftAnchor.target = null;
                 this._widget.width             = Mathf.RoundToInt((float)actionIcon._sprite.width / base.transform.localScale.x);
                 this._widget.leftAnchor.target = target;
                 this._widget.SkipWidthUpdate   = true;
                 IEnumerator enumerator = base.transform.GetEnumerator();
                 try
                 {
                     while (enumerator.MoveNext())
                     {
                         object    obj        = enumerator.Current;
                         Transform transform2 = (Transform)obj;
                         UILabel   component  = transform2.GetComponent <UILabel>();
                         if (component)
                         {
                             component.MarkAsChanged();
                             component.ProcessText();
                         }
                     }
                 }
                 finally
                 {
                     IDisposable disposable;
                     if ((disposable = (enumerator as IDisposable)) != null)
                     {
                         disposable.Dispose();
                     }
                 }
             }
         }
     }
     if (this._sprite)
     {
         this._sprite.enabled = false;
     }
     if (this._label)
     {
         this._label.enabled = false;
     }
 }
예제 #10
0
 private void SetIconHolderTr(Transform t, ActionIconSystem.CurrentViewOptions currentViewOption)
 {
     switch (currentViewOption)
     {
     case ActionIconSystem.CurrentViewOptions.AllowInWorld:
         t.parent = this._iconHolderTr;
         break;
     case ActionIconSystem.CurrentViewOptions.AllowInBook:
         t.parent = this._iconHolderBookTr;
         break;
     case ActionIconSystem.CurrentViewOptions.AllowInPlane:
         t.parent = this._iconHolderPlaneTr;
         break;
     }
 }
예제 #11
0
 private void OnDestroy()
 {
     if (ActionIconSystem.Instance == this)
     {
         ActionIconSystem.Instance = null;
     }
 }
예제 #12
0
 private void Awake()
 {
     ActionIconSystem.Instance = this;
 }