Ejemplo n.º 1
0
        void RefreshKeyLabels()
        {
            InputManager input = InputManager.instance;

            for (int i = 0; i < mItems.Length; i++)
            {
                InputManager.Key key = input.GetBindKey(playerIndex, actions[i].index, actions[i].keys[0]);
                mItems[i].primaryLabel.text = key.isValid ? key.GetKeyString() : "None";

                key = input.GetBindKey(playerIndex, actions[i].index, actions[i].keys[1]);
                mItems[i].secondaryLabel.text = key.isValid ? key.GetKeyString() : "None";
            }

            LayoutBase.RefreshNow(transform);
        }
Ejemplo n.º 2
0
 public static int Comparer(LayoutBase l1, LayoutBase l2)
 {
     return((M8.Util.GetNodeLayer(l1.transform) * 1000 + l1.priority).CompareTo(M8.Util.GetNodeLayer(l2.transform) * 1000 + l2.priority));
 }
Ejemplo n.º 3
0
 public override void Open()
 {
     LayoutBase.RefreshNow(transform);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Set the text and such for the dialog, call this before opening the dialog
        /// </summary>
        public override void Apply(bool isLocalized, string text, string aName = null, string portraitSpriteRef = null, string[] choices = null)
        {
            InitData();

            textLabel.text = isLocalized ? Localize.instance.GetText(text) : text;

            if (nameLabel != null)
            {
                if (!string.IsNullOrEmpty(aName))
                {
                    nameLabel.text = isLocalized ? Localize.instance.GetText(aName) : aName;
                    nameLabel.gameObject.SetActive(true);
                }
                else
                {
                    nameLabel.gameObject.SetActive(false);
                }
            }

            if (portrait != null)
            {
                if (portraitSpriteRef != null)
                {
                    portrait.spriteName = portraitSpriteRef;
                    portrait.gameObject.SetActive(true);
                }
                else
                {
                    portrait.gameObject.SetActive(false);
                }
            }

            //apply choices
            ResetChoices();

            if (mChoiceEvents != null)
            {
                if (choices != null && choices.Length > 0)
                {
                    mNumChoices = Mathf.Min(choices.Length, mChoiceEvents.Length);

                    if (mNumChoices > 0)
                    {
                        choiceContainer.gameObject.SetActive(true);

                        for (int i = 0; i < mNumChoices; i++)
                        {
                            mChoiceEvents[i].listener.gameObject.SetActive(true);
                            if (mChoiceEvents[i].label != null)
                            {
                                mChoiceEvents[i].label.text = isLocalized ? Localize.instance.GetText(choices[i]) : choices[i];
                            }

                            if (mChoiceEvents[i].keys != null)
                            {
                                if (i == 0)
                                {
                                    mChoiceEvents[i].keys.selectOnUp = mChoiceEvents[mNumChoices - 1].keys;
                                }
                                else
                                {
                                    mChoiceEvents[i].keys.selectOnUp = mChoiceEvents[i - 1].keys;
                                }

                                if (i < mNumChoices - 1)
                                {
                                    mChoiceEvents[i].keys.selectOnDown = mChoiceEvents[i + 1].keys;
                                }
                                else
                                {
                                    mChoiceEvents[i].keys.selectOnDown = mChoiceEvents[0].keys;
                                }
                            }
                        }
                    }
                    else
                    {
                        choiceContainer.gameObject.SetActive(false);
                    }
                }
            }

            //if dialog is already open, apply positioning
            if (gameObject.activeSelf)
            {
                ApplyActive();

                if (refreshLate)
                {
                    StartCoroutine(LayoutBase.RefreshLate(transform));
                }
                else
                {
                    LayoutBase.RefreshNow(transform);
                }
            }
        }