Exemplo n.º 1
0
        /// <summary>
        /// Refresh language text once.
        /// </summary>
        public void Refresh()
        {
            JCS_UIUtil.SetLangText(this.mLangData, this.mText);
#if TMP_PRO
            JCS_UIUtil.SetLangText(this.mLangData, this.mTextMesh);
#endif
        }
        /* Functions */

        private void Awake()
        {
            this.mRectTransform = this.GetComponent <RectTransform>();

            if (mPanelRoot == null)
            {
                mPanelRoot = this.GetComponentInParent <JCS_PanelRoot>();
            }

            if (IsResponsive())
            {
                mApplyToChildren = JCS_UIUtil.IsAchorPresets(mRectTransform, JCS_AnchorPresetsType.CENTER_MIDDLE);
            }
            else
            {
                mApplyToChildren = !JCS_UIUtil.IsUnityDefinedUI(mRectTransform);
            }

            // Rely on "Script Execution Order"
            {
                /* Check 'jpr' null for spawn GUI objects. */
                if (mPanelRoot != null)
                {
                    FitPerfectSize(
                        mPanelRoot.PanelDeltaWidthRatio,
                        mPanelRoot.PanelDeltaHeightRatio);
                }

                if (mApplyToChildren)
                {
                    // since we add this script assuming we are  int the fit
                    // perfect size mode
                    //
                    // see "JCS_PanelRoot" -> mFitScreenSize variables
                    AddPanelChild();
                }
            }
        }
Exemplo n.º 3
0
 private void DeactivePanel()
 {
     JCS_UIUtil.DeactivePanels(mDialogueObjects, mPlaySound);
     JCS_UIUtil.DeactivePanels(mTweenPanels);
 }
        /* Setter & Getter */

        /* Functions */

        public override void OnClick()
        {
            JCS_UIUtil.ShowCanvas(canvas);
        }
        /* Functions */

        public override void OnClick()
        {
            JCS_UIUtil.ActivePanels(mDialogueObjects, mPlaySound);
            JCS_UIUtil.ActivePanels(mTweenPanels);
        }
 private void Hide()
 {
     JCS_UIUtil.HideCanvas(canvas);
 }
 private void Show()
 {
     JCS_UIUtil.ShowCanvas(canvas);
 }
        /// <summary>
        /// Update the dropdown data.
        ///
        /// Call this when the option data from the dropdown object
        /// has been updated.
        /// </summary>
        public void UpdateDropdownData()
        {
            // Clear it before we refresh.
            mDropdownRealTexts.Clear();

            int centerLetterPos = mMaxLetters / 2;

            if (JCS_Mathf.IsOdd(mMaxLetters))
            {
                centerLetterPos += 1;
            }

            int halfDotCount = mDotCount / 2;

            string dot = ".";

            /* First get the dot string. */
            {
                for (int count = 1;
                     count < mDotCount;
                     ++count)
                {
                    dot += ".";
                }
            }

            int index = -1;

            foreach (Dropdown.OptionData od in mDropdown.options)
            {
                ++index;

                // Check if we need to shortcut this.
                string textData = od.text;

                if (IsShortcutText(textData, dot))
                {
                    // Add the value from backup then.
                    mDropdownRealTexts.Add(mDropdownBackupTexts[index]);
                    continue;
                }

                // add the text.
                mDropdownRealTexts.Add(textData);

                // make another backup.
                mDropdownBackupTexts.Add(textData);

                int textDataLen = textData.Length;

                // Check if we need the fold the option text.
                if (textDataLen <= mMaxLetters)
                {
                    continue;
                }

                int firstReplacePos = centerLetterPos - halfDotCount;

                int secondReplacePos = firstReplacePos;
                if (JCS_Mathf.IsOdd(mDotCount))
                {
                    if (mApproachSec)
                    {
                        secondReplacePos += 1;
                    }
                    else
                    {
                        firstReplacePos += 1;
                    }
                }

                // We start counting from the text data length.
                // So we simply just minus it.
                secondReplacePos = textDataLen - secondReplacePos;

                string newTextData =
                    // First half of the text data.
                    textData.Substring(0, firstReplacePos)
                    // Add replace dots.
                    + dot
                    // Add the second half of the text data.
                    + textData.Substring(secondReplacePos, textDataLen - secondReplacePos);

                // Apply new text data.
                od.text = newTextData;
            }

            // Refresh the selection.
            JCS_UIUtil.Dropdown_RefreshSelection(mDropdown);
        }