Ejemplo n.º 1
0
 public static void SetKeyNevigation(List <GameObject> buttonList)
 {
     for (Int32 i = 0; i < buttonList.Count; i++)
     {
         GameObject      gameObject = buttonList[i];
         UIKeyNavigation component  = gameObject.GetComponent <UIKeyNavigation>();
         if (!(component == (UnityEngine.Object)null))
         {
             if (i + 1 < buttonList.Count)
             {
                 component.onDown = buttonList[i + 1];
             }
             else
             {
                 component.onDown = buttonList[0];
             }
             if (i - 1 > -1)
             {
                 component.onUp = buttonList[i - 1];
             }
             else
             {
                 component.onUp = buttonList[buttonList.Count - 1];
             }
         }
     }
 }
    // Token: 0x06000246 RID: 582 RVA: 0x00018BAC File Offset: 0x00016DAC
    public GameObject Get(Vector3 myDir, float x = 1f, float y = 1f)
    {
        Transform transform = base.transform;

        myDir = transform.TransformDirection(myDir);
        Vector3    center = UIKeyNavigation.GetCenter(base.gameObject);
        float      num    = float.MaxValue;
        GameObject result = null;

        for (int i = 0; i < UIKeyNavigation.list.size; i++)
        {
            UIKeyNavigation uikeyNavigation = UIKeyNavigation.list.buffer[i];
            if (!(uikeyNavigation == this) && uikeyNavigation.constraint != UIKeyNavigation.Constraint.Explicit && uikeyNavigation.isColliderEnabled)
            {
                UIWidget component = uikeyNavigation.GetComponent <UIWidget>();
                if (!(component != null) || component.alpha != 0f)
                {
                    Vector3 direction = UIKeyNavigation.GetCenter(uikeyNavigation.gameObject) - center;
                    if (Vector3.Dot(myDir, direction.normalized) >= 0.707f)
                    {
                        direction    = transform.InverseTransformDirection(direction);
                        direction.x *= x;
                        direction.y *= y;
                        float sqrMagnitude = direction.sqrMagnitude;
                        if (sqrMagnitude <= num)
                        {
                            result = uikeyNavigation.gameObject;
                            num    = sqrMagnitude;
                        }
                    }
                }
            }
        }
        return(result);
    }
Ejemplo n.º 3
0
 private void Start()
 {
     if (this.textLabel != null)
     {
         EventDelegate.Add(this.onChange, new EventDelegate.Callback(this.textLabel.SetCurrentSelection));
         this.textLabel = null;
     }
     if (Application.isPlaying)
     {
         if (string.IsNullOrEmpty(this.mSelectedItem))
         {
             if (this.items.Count > 0)
             {
                 this.value = this.items[0];
             }
         }
         else
         {
             string value = this.mSelectedItem;
             this.mSelectedItem = null;
             this.value         = value;
         }
     }
     this.keys       = base.GetComponent <UIKeyNavigation>();
     this.currentlbl = base.GetComponent <UILabel>();
 }
Ejemplo n.º 4
0
 public void Start()
 {
     if (this.mStarted)
     {
         return;
     }
     if (this.selectOnTab != null)
     {
         UIKeyNavigation uIKeyNavigation = base.GetComponent <UIKeyNavigation>();
         if (uIKeyNavigation == null)
         {
             uIKeyNavigation        = base.gameObject.AddComponent <UIKeyNavigation>();
             uIKeyNavigation.onDown = this.selectOnTab;
         }
         this.selectOnTab = null;
         NGUITools.SetDirty(this, "last change");
     }
     if (this.mLoadSavedValue && !string.IsNullOrEmpty(this.savedAs))
     {
         this.LoadValue();
     }
     else
     {
         this.value = this.mValue.Replace("\\n", "\n");
     }
     this.mStarted = true;
 }
Ejemplo n.º 5
0
    // Token: 0x060007A2 RID: 1954 RVA: 0x0003F1C0 File Offset: 0x0003D3C0
    private void OnKey(KeyCode key)
    {
        int frameCount = Time.frameCount;

        if (UIInput.mIgnoreKey == frameCount)
        {
            return;
        }
        if (this.mCam != null && (key == this.mCam.cancelKey0 || key == this.mCam.cancelKey1))
        {
            UIInput.mIgnoreKey = frameCount;
            this.isSelected    = false;
            return;
        }
        if (key == KeyCode.Tab)
        {
            UIInput.mIgnoreKey = frameCount;
            this.isSelected    = false;
            UIKeyNavigation component = base.GetComponent <UIKeyNavigation>();
            if (component != null)
            {
                component.OnKey(KeyCode.Tab);
            }
        }
    }
Ejemplo n.º 6
0
    private void PrepareListItemWithIndex(Transform item, Int32 newIndex, Int32 oldIndex)
    {
        if (newIndex < oldIndex)
        {
            item.localPosition += new Vector3(0f, (Single)(this.poolSize / this.Column) * this.cellHeight, 0f);
        }
        else
        {
            item.localPosition -= new Vector3(0f, (Single)(this.poolSize / this.Column) * this.cellHeight, 0f);
        }
        item.GetComponent <RecycleListItem>().ItemDataIndex = newIndex;
        UIKeyNavigation component = item.GetComponent <UIKeyNavigation>();

        if (component)
        {
            component.startsSelected = (this.activeNumber == newIndex);
        }
        if (oldIndex == this.activeNumber)
        {
            ButtonGroupState component2 = item.GetComponent <ButtonGroupState>();
            ButtonGroupState.RemoveActiveStateOnGroup(item.gameObject, component2.GroupName);
        }
        if (newIndex == this.activeNumber)
        {
            ButtonGroupState component3 = item.GetComponent <ButtonGroupState>();
            ButtonGroupState.HoldActiveStateOnGroup(item.gameObject, component3.GroupName);
        }
        item.name = "Item " + newIndex;
        this.PopulateListItemWithData(item, this.dataList[newIndex], newIndex, false);
        this.dataTracker.Add(newIndex, this.dataTracker[oldIndex]);
        this.dataTracker.Remove(oldIndex);
    }
Ejemplo n.º 7
0
    private void OnKey(KeyCode key)
    {
        //IL_0012: Unknown result type (might be due to invalid IL or missing references)
        //IL_0019: Unknown result type (might be due to invalid IL or missing references)
        //IL_0023: Unknown result type (might be due to invalid IL or missing references)
        //IL_002a: Unknown result type (might be due to invalid IL or missing references)
        //IL_0046: Unknown result type (might be due to invalid IL or missing references)
        //IL_0049: Invalid comparison between Unknown and I4
        int frameCount = Time.get_frameCount();

        if (mIgnoreKey != frameCount)
        {
            if (key == mCam.cancelKey0 || key == mCam.cancelKey1)
            {
                mIgnoreKey = frameCount;
                isSelected = false;
            }
            else if ((int)key == 9)
            {
                mIgnoreKey = frameCount;
                isSelected = false;
                UIKeyNavigation component = this.GetComponent <UIKeyNavigation>();
                if (component != null)
                {
                    component.OnKey(9);
                }
            }
        }
    }
Ejemplo n.º 8
0
    public GameObject Get(Vector3 myDir, float x = 1f, float y = 1f)
    {
        //IL_0001: Unknown result type (might be due to invalid IL or missing references)
        //IL_0006: Expected O, but got Unknown
        //IL_0008: Unknown result type (might be due to invalid IL or missing references)
        //IL_0009: Unknown result type (might be due to invalid IL or missing references)
        //IL_000e: Unknown result type (might be due to invalid IL or missing references)
        //IL_0011: Unknown result type (might be due to invalid IL or missing references)
        //IL_0016: Expected O, but got Unknown
        //IL_0016: Unknown result type (might be due to invalid IL or missing references)
        //IL_001b: Unknown result type (might be due to invalid IL or missing references)
        //IL_0093: Unknown result type (might be due to invalid IL or missing references)
        //IL_0098: Expected O, but got Unknown
        //IL_0098: Unknown result type (might be due to invalid IL or missing references)
        //IL_009d: Unknown result type (might be due to invalid IL or missing references)
        //IL_009e: Unknown result type (might be due to invalid IL or missing references)
        //IL_00a3: Unknown result type (might be due to invalid IL or missing references)
        //IL_00a5: Unknown result type (might be due to invalid IL or missing references)
        //IL_00a8: Unknown result type (might be due to invalid IL or missing references)
        //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
        //IL_00c8: Unknown result type (might be due to invalid IL or missing references)
        //IL_00cd: Unknown result type (might be due to invalid IL or missing references)
        //IL_0105: Unknown result type (might be due to invalid IL or missing references)
        //IL_010a: Expected O, but got Unknown
        Transform val = this.get_transform();

        myDir = val.TransformDirection(myDir);
        Vector3    center = GetCenter(this.get_gameObject());
        float      num    = 3.40282347E+38f;
        GameObject result = null;

        for (int i = 0; i < list.size; i++)
        {
            UIKeyNavigation uIKeyNavigation = list[i];
            if (!(uIKeyNavigation == this) && uIKeyNavigation.constraint != Constraint.Explicit && uIKeyNavigation.isColliderEnabled)
            {
                UIWidget component = uIKeyNavigation.GetComponent <UIWidget>();
                if (!(component != null) || component.alpha != 0f)
                {
                    Vector3 val2 = GetCenter(uIKeyNavigation.get_gameObject()) - center;
                    float   num2 = Vector3.Dot(myDir, val2.get_normalized());
                    if (!(num2 < 0.707f))
                    {
                        val2    = val.InverseTransformDirection(val2);
                        val2.x *= x;
                        val2.y *= y;
                        float sqrMagnitude = val2.get_sqrMagnitude();
                        if (!(sqrMagnitude > num))
                        {
                            result = uIKeyNavigation.get_gameObject();
                            num    = sqrMagnitude;
                        }
                    }
                }
            }
        }
        return(result);
    }
Ejemplo n.º 9
0
        public GONavigationButton(GameObject obj)
            : base(obj)
        {
            KeyNavigation = obj.GetExactComponent <UIKeyNavigation>();
            ButtonGroup   = obj.GetExactComponent <ButtonGroupState>();

            Name       = new GOLabel(obj.GetChild(0));
            Highlight  = new GOSprite(obj.GetChild(1));
            Background = new GOThinBackground(obj.GetChild(2));
        }
Ejemplo n.º 10
0
    protected GameObject Get(Vector3 myDir, bool horizontal)
    {
        Transform t = transform;

        myDir = t.TransformDirection(myDir);
        Vector3    myCenter = GetCenter(gameObject);
        float      min      = float.MaxValue;
        GameObject go       = null;

        for (int i = 0; i < list.size; ++i)
        {
            UIKeyNavigation nav = list[i];
            if (nav == this)
            {
                continue;
            }

            // Ignore disabled buttons
            UIButton btn = nav.GetComponent <UIButton>();
            if (btn != null && !btn.isEnabled)
            {
                continue;
            }

            // Reject objects that are not within a 45 degree angle of the desired direction
            Vector3 dir = GetCenter(nav.gameObject) - myCenter;
            float   dot = Vector3.Dot(myDir, dir.normalized);
            if (dot < 0.707f)
            {
                continue;
            }

            // Exaggerate the movement in the undesired direction
            dir = t.InverseTransformDirection(dir);
            if (horizontal)
            {
                dir.y *= 2f;
            }
            else
            {
                dir.x *= 2f;
            }

            // Compare the distance
            float mag = dir.sqrMagnitude;
            if (mag > min)
            {
                continue;
            }
            go  = nav.gameObject;
            min = mag;
        }
        return(go);
    }
Ejemplo n.º 11
0
 public static void SetCursorStartSelect(GameObject go, String group)
 {
     if (go != (UnityEngine.Object)null && ButtonGroupState.ButtonGroupList.ContainsKey(group))
     {
         foreach (GameObject gameObject in ButtonGroupState.ButtonGroupList[group])
         {
             UIKeyNavigation component = gameObject.GetComponent <UIKeyNavigation>();
             component.startsSelected = (gameObject == go);
         }
     }
 }
Ejemplo n.º 12
0
 public GameObject GetRight()
 {
     if (UIKeyNavigation.IsActive(this.onRight))
     {
         return(this.onRight);
     }
     if (this.constraint == UIKeyNavigation.Constraint.Vertical || this.constraint == UIKeyNavigation.Constraint.Explicit)
     {
         return(null);
     }
     return(this.Get(Vector3.right, 1f, 2f));
 }
Ejemplo n.º 13
0
 private static bool CanSkipToNext(GameObject go)
 {
     if (go)
     {
         UIKeyNavigation component = go.GetComponent <UIKeyNavigation>();
         if (component)
         {
             return(component.SkipToNextWhenDisabled);
         }
     }
     return(false);
 }
Ejemplo n.º 14
0
 public GameObject GetUp()
 {
     if (UIKeyNavigation.IsActive(this.onUp))
     {
         return(this.onUp);
     }
     if (this.constraint == UIKeyNavigation.Constraint.Horizontal || this.constraint == UIKeyNavigation.Constraint.Explicit)
     {
         return((GameObject)null);
     }
     return(this.Get(Vector3.up, 2f, 1f));
 }
Ejemplo n.º 15
0
 public GameObject GetDown()
 {
     if (UIKeyNavigation.IsActive(this.onDown))
     {
         return(this.onDown);
     }
     if (this.constraint == UIKeyNavigation.Constraint.Horizontal || this.constraint == UIKeyNavigation.Constraint.Explicit)
     {
         return(null);
     }
     return(this.Get(Vector3.down, 2f, 1f));
 }
Ejemplo n.º 16
0
 static public int get_isColliderEnabled(IntPtr l)
 {
     try {
         UIKeyNavigation self = (UIKeyNavigation)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.isColliderEnabled);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 17
0
 static public int get_startsSelected(IntPtr l)
 {
     try {
         UIKeyNavigation self = (UIKeyNavigation)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.startsSelected);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 18
0
 static public int get_constraint(IntPtr l)
 {
     try {
         UIKeyNavigation self = (UIKeyNavigation)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.constraint);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 19
0
    private void SetAvalableCharacter(Boolean includeEmpty)
    {
        List <CharacterDetailHUD> characterDetailHudList = new List <CharacterDetailHUD>();

        if (!includeEmpty)
        {
            using (List <CharacterDetailHUD> .Enumerator enumerator = _targetHudList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    CharacterDetailHUD current = enumerator.Current;
                    if (current.Content.activeSelf)
                    {
                        characterDetailHudList.Add(current);
                        ButtonGroupState.SetButtonEnable(current.Self, true);
                    }
                    else
                    {
                        ButtonGroupState.SetButtonEnable(current.Self, false);
                    }
                }
            }
        }
        else
        {
            using (List <CharacterDetailHUD> .Enumerator enumerator = _targetHudList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    CharacterDetailHUD current = enumerator.Current;
                    characterDetailHudList.Add(current);
                    ButtonGroupState.SetButtonEnable(current.Self, true);
                }
            }
        }
        for (Int32 index1 = 0; index1 < characterDetailHudList.Count; ++index1)
        {
            Int32 index2 = index1 - 1;
            Int32 index3 = index1 + 1;
            if (index1 == 0)
            {
                index2 = characterDetailHudList.Count - 1;
            }
            if (index1 == characterDetailHudList.Count - 1)
            {
                index3 = 0;
            }
            UIKeyNavigation component = characterDetailHudList[index1].Self.GetComponent <UIKeyNavigation>();
            component.onUp   = characterDetailHudList[index2].Self;
            component.onDown = characterDetailHudList[index3].Self;
        }
    }
Ejemplo n.º 20
0
 static public int GetLeft(IntPtr l)
 {
     try {
         UIKeyNavigation self = (UIKeyNavigation)checkSelf(l);
         var             ret  = self.GetLeft();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 21
0
 static public int set_constraint(IntPtr l)
 {
     try {
         UIKeyNavigation            self = (UIKeyNavigation)checkSelf(l);
         UIKeyNavigation.Constraint v;
         checkEnum(l, 2, out v);
         self.constraint = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 22
0
 static public int set_onTab(IntPtr l)
 {
     try {
         UIKeyNavigation        self = (UIKeyNavigation)checkSelf(l);
         UnityEngine.GameObject v;
         checkType(l, 2, out v);
         self.onTab = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 23
0
 static public int set_startsSelected(IntPtr l)
 {
     try {
         UIKeyNavigation self = (UIKeyNavigation)checkSelf(l);
         System.Boolean  v;
         checkType(l, 2, out v);
         self.startsSelected = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 24
0
 static public int OnNavigate(IntPtr l)
 {
     try {
         UIKeyNavigation     self = (UIKeyNavigation)checkSelf(l);
         UnityEngine.KeyCode a1;
         checkEnum(l, 2, out a1);
         self.OnNavigate(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 25
0
 public static GameObject GetCursorStartSelect(String group)
 {
     if (ButtonGroupState.ButtonGroupList.ContainsKey(group))
     {
         foreach (GameObject gameObject in ButtonGroupState.ButtonGroupList[group])
         {
             UIKeyNavigation component = gameObject.GetComponent <UIKeyNavigation>();
             if (component.startsSelected)
             {
                 return(gameObject);
             }
         }
     }
     return((GameObject)null);
 }
Ejemplo n.º 26
0
    public GameObject Get(Vector3 myDir, float x = 1f, float y = 1f)
    {
        Transform t = transform;

        myDir = t.TransformDirection(myDir);
        Vector3    myCenter = GetCenter(gameObject);
        float      min      = float.MaxValue;
        GameObject go       = null;

        for (int i = 0; i < list.size; ++i)
        {
            UIKeyNavigation nav = list[i];
            if (nav == this || nav.constraint == Constraint.Explicit || !nav.isColliderEnabled)
            {
                continue;
            }

            // Ignore invisible widgets
            UIWidget widget = nav.GetComponent <UIWidget>();
            if (widget != null && widget.alpha == 0f)
            {
                continue;
            }

            // Reject objects that are not within a 45 degree angle of the desired direction
            Vector3 dir = GetCenter(nav.gameObject) - myCenter;
            float   dot = Vector3.Dot(myDir, dir.normalized);
            if (dot < 0.707f)
            {
                continue;
            }

            // Exaggerate the movement in the undesired direction
            dir    = t.InverseTransformDirection(dir);
            dir.x *= x;
            dir.y *= y;

            // Compare the distance
            float mag = dir.sqrMagnitude;
            if (mag > min)
            {
                continue;
            }
            go  = nav.gameObject;
            min = mag;
        }
        return(go);
    }
Ejemplo n.º 27
0
 public GameObject GetLeft()
 {
     if (UIKeyNavigation.IsActive(this.onLeft))
     {
         return(this.onLeft);
     }
     if (UIKeyNavigation.CanSkipToNext(this.onLeft))
     {
         return(this.onLeft.GetComponent <UIKeyNavigation>().GetLeft());
     }
     if (this.constraint == UIKeyNavigation.Constraint.Vertical || this.constraint == UIKeyNavigation.Constraint.Explicit)
     {
         return(null);
     }
     return(this.Get(Vector3.left, 1f, 2f));
 }
Ejemplo n.º 28
0
 public GameObject GetUp()
 {
     if (UIKeyNavigation.IsActive(this.onUp))
     {
         return(this.onUp);
     }
     if (UIKeyNavigation.CanSkipToNext(this.onUp))
     {
         return(this.onUp.GetComponent <UIKeyNavigation>().GetUp());
     }
     if (this.constraint == UIKeyNavigation.Constraint.Horizontal || this.constraint == UIKeyNavigation.Constraint.Explicit)
     {
         return(null);
     }
     return(this.Get(Vector3.up, 2f, 1f));
 }
Ejemplo n.º 29
0
    private void CheckEmptyLastRow()
    {
        UIKeyNavigation component = base.gameObject.GetComponent <UIKeyNavigation>();

        if (this.listPopulator != (UnityEngine.Object)null)
        {
            if (this.listItem.ItemDataIndex == this.listPopulator.ItemCount - 2)
            {
                GameObject gameObject = this.listPopulator.ItemsPool[this.listPopulator.DataTracker[this.listPopulator.ItemCount - 1]].gameObject;
                component.onDown = gameObject;
            }
            else if (component.onDown != (UnityEngine.Object)null)
            {
                base.gameObject.GetComponent <UIKeyNavigation>().onDown = (GameObject)null;
            }
        }
    }
Ejemplo n.º 30
0
    public void itemHasChanged(GameObject go)
    {
        RecycleListItem component = go.GetComponent <RecycleListItem>();

        if (component)
        {
            this.activeNumber = component.ItemDataIndex;
        }
        foreach (Transform transform in this.itemsPool)
        {
            UIKeyNavigation component2 = transform.gameObject.GetComponent <UIKeyNavigation>();
            RecycleListItem component3 = transform.gameObject.GetComponent <RecycleListItem>();
            if (component2)
            {
                component2.startsSelected = (this.activeNumber == component3.ItemDataIndex);
            }
        }
    }