Пример #1
0
        public void Init(LetterData letterData)
        {
            var isolatedChar = letterData.GetStringForDisplay(LetterForm.Isolated);
            var InitialChar  = letterData.GetStringForDisplay(LetterForm.Initial);
            var MedialChar   = letterData.GetStringForDisplay(LetterForm.Medial);
            var FinalChar    = letterData.GetStringForDisplay(LetterForm.Final);

            LetterTextIsolated.SetTextUnfiltered(isolatedChar);
            LetterTextInitial.SetTextUnfiltered(InitialChar);
            LetterTextMedial.SetTextUnfiltered(MedialChar);
            LetterTextFinal.SetTextUnfiltered(FinalChar);
        }
Пример #2
0
        public void Init(LetterData letterData)
        {
            currentLetter = letterData;
            var isolatedChar = letterData.GetStringForDisplay(LetterForm.Isolated);
            var InitialChar  = letterData.GetStringForDisplay(LetterForm.Initial);
            var MedialChar   = letterData.GetStringForDisplay(LetterForm.Medial);
            var FinalChar    = letterData.GetStringForDisplay(LetterForm.Final);

            if (Book.Book.I.TestShaddah)
            {
                isolatedChar = ReplaceWithShaddah(isolatedChar);
                InitialChar  = ReplaceWithShaddah(InitialChar);
                MedialChar   = ReplaceWithShaddah(MedialChar);
                FinalChar    = ReplaceWithShaddah(FinalChar);
            }

            if (AppManager.I.ParentEdition.BookShowRelatedWords)
            {
                LetterTextIsolated.gameObject.GetComponent <RectTransform>().offsetMin = new Vector2(0, 0);
                LetterTextInitial.gameObject.SetActive(false);
                LetterTextMedial.gameObject.SetActive(false);
                LetterTextFinal.gameObject.SetActive(false);
            }
            else
            {
                LetterTextIsolated.gameObject.GetComponent <RectTransform>().offsetMin = new Vector2(0, 130);
                LetterTextInitial.gameObject.SetActive(true);
                LetterTextMedial.gameObject.SetActive(true);
                LetterTextFinal.gameObject.SetActive(true);
            }

            LetterTextIsolated.SetTextUnfiltered(isolatedChar);
            LetterTextInitial.SetTextUnfiltered(InitialChar);
            LetterTextMedial.SetTextUnfiltered(MedialChar);
            LetterTextFinal.SetTextUnfiltered(FinalChar);

            if (Book.Book.I.EditDiacritics)
            {
                IsolatedSubtitle.gameObject.SetActive(true);
                IsolatedSubtitle.text = ($"<color=black>{letterData.GetUnicode(LetterForm.Isolated)}</color>");
                InitialSubtitle.text  = ($"<color=black>{letterData.GetUnicode(LetterForm.Initial)}</color>");
                MedialSubtitle.text   = ($"<color=black>{letterData.GetUnicode(LetterForm.Medial)}</color>");
                FinalSubtitle.text    = ($"<color=black>{letterData.GetUnicode(LetterForm.Final)}</color>");
            }
        }
Пример #3
0
        //        private UIButton uIButton;

        public void Init(LetterData _letterData)
        {
            myLetterData = _letterData;
            //            uIButton = GetComponent<UIButton>();

            if (myLetterData == null)
            {
                LetterText.SetTextUnfiltered("");
                SubtitleText.SetText("");
            }
            else
            {
                var isolatedChar = myLetterData.GetStringForDisplay(LetterForm.Isolated);
                LetterText.SetTextUnfiltered(isolatedChar);
                SubtitleText.SetText(myLetterData.Id);
            }
        }
        private IEnumerator FlashLetterInWordCoroutine(LetterData letterToFlash, Color color)
        {
            if (letterData is LL_WordData) {
                var splitLetters = ArabicAlphabetHelper.SplitWord(AppManager.I.DB, ((LL_WordData)letterData).Data);

                int charPosition = 0;
                List<int> foundLetterIndices = new List<int>();

                for (int index = 0; index < splitLetters.Count; ++index) {
                    if (splitLetters[index].letter.Id == letterToFlash.Id) {
                        foundLetterIndices.Add(charPosition);
                    }

                    charPosition += splitLetters[index].letter.GetStringForDisplay().Length;
                }

                if (foundLetterIndices.Count != 0) {
                    string originalText = ((LL_WordData)letterData).TextForLivingLetter;

                    letterObjectView.Label.SetText(originalText);

                    float timeElapsed = 0f;
                    int numCompletedCycles = 0;

                    float halfDuration = FLASH_CYCLE_DURATION * 0.5f;

                    string preparedText = ArabicAlphabetHelper.ProcessArabicString(originalText);
                    preparedText = originalText;

                    while (numCompletedCycles < NUM_FLASH_CYCLES) {
                        float interpolant = timeElapsed < halfDuration
                            ? timeElapsed / halfDuration
                            : 1 - ((timeElapsed - halfDuration) / halfDuration);
                        string tagStart = "<color=#" + GenericHelper.ColorToHex(Color.Lerp(Color.black, color, interpolant)) + ">";
                        string tagEnd = "</color>";

                        string composedString = "";

                        for (int i = 0; i < foundLetterIndices.Count; i++) {
                            int startIdx = i == 0 ? 0 : foundLetterIndices[i - 1] + letterToFlash.GetStringForDisplay().Length;
                            int endIdx = foundLetterIndices[i] - 1;

                            composedString += preparedText.Substring(startIdx, endIdx - startIdx + 1);

                            composedString += tagStart;
                            composedString += preparedText.Substring(foundLetterIndices[i], letterToFlash.GetStringForDisplay().Length);
                            composedString += tagEnd;
                        }

                        composedString += preparedText.Substring(foundLetterIndices[foundLetterIndices.Count - 1] + letterToFlash.GetStringForDisplay().Length);

                        letterObjectView.Label.SetText(composedString);

                        timeElapsed += Time.fixedDeltaTime;
                        if (timeElapsed >= FLASH_CYCLE_DURATION) {
                            numCompletedCycles++;
                            timeElapsed = 0f;
                        }

                        yield return new WaitForFixedUpdate();
                    }

                    letterObjectView.Label.SetText(originalText);
                }
            }

            flashLetterInWordCoroutine = null;
        }