//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Get Character Colour Code //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private string GetCharacterColourCode(int a_iCharacterID) { CharacterHighlightEffect highlightInfo = MatchCharacterIDToHighlightEffect(a_iCharacterID); if (highlightInfo != null) { return("FFFFFF" + ((int)(highlightInfo.fadeinTimer.GetCompletionPercentage() * 255.0f)).ToString("X2")); } foreach (ColourPoints colourPoint in m_lColouredAreas) { if (a_iCharacterID >= colourPoint.from && a_iCharacterID <= colourPoint.to) { return(colourPoint.colourCode); } } return(m_sDefaultTextColourCode); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Set Text //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public void SetText(string text, FadeinAnimationType startAnimation = FadeinAnimationType.SINGLE_LINE_CHARACTERS_FADEIN) { DiscoverColouredAreas(text); SetDefaultTextColourCode(); m_sFullDisplayText = RemoveColourTags(text); m_asLinedSplitText = m_sFullDisplayText.Split(new char[] { '\n' }); m_aCharacterHighlightEffect = new CharacterHighlightEffect[TOTAL_HIGHLIGHTED_CHARACTERS * m_asLinedSplitText.Length]; for (int i = 0; i < m_aCharacterHighlightEffect.Length; ++i) { m_aCharacterHighlightEffect[i] = new CharacterHighlightEffect(); m_aCharacterHighlightEffect[i].fadeinTimer = new TimeTracker(m_fTextHighlightFadeTime); } m_alOrderedCharacters = new LinkedList <CharacterHighlightEffect> [m_asLinedSplitText.Length]; for (int i = 0; i < m_alOrderedCharacters.Length; ++i) { m_alOrderedCharacters[i] = new LinkedList <CharacterHighlightEffect>(); for (int j = 0; j < TOTAL_HIGHLIGHTED_CHARACTERS; ++j) { m_alOrderedCharacters[i].AddLast(m_aCharacterHighlightEffect[((i * TOTAL_HIGHLIGHTED_CHARACTERS) + j)]); } } if (startAnimation == FadeinAnimationType.INSTANT) { m_eCurrentAnimationState = AnimationState.IDLE_ANIMATION; } else { m_eCurrentAnimationState = AnimationState.FADE_IN_ANIMATION; if (m_eDesiredFadeinAnimationType == FadeinAnimationType.SINGLE_LINE_CHARACTERS_FADEIN) { SetupCharacterHighlightEffects(false); } else if (m_eDesiredFadeinAnimationType == FadeinAnimationType.ALL_LINES_CHARACTER_FADEIN) { SetupCharacterHighlightEffects(true); } } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * New Method: Get Single Line Character Fadein Effect //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private string GetSingleLineCharacterFadeinEffect(LinkedList <CharacterHighlightEffect> a_lCharacterFadeinEffect, int a_iStartIndex, int a_iLength) { UpdateHighlightEffectCharacters(a_lCharacterFadeinEffect, a_iStartIndex, a_iLength); // Get the CharacterID of whatever has currently been the furthermost rendered character. If it remains "INVALID" Just render all text as normal int iLowestCharacterLength = (a_iStartIndex + a_iLength); int iHighestCharacterID = INVALID_CHARACTER_ID; foreach (CharacterHighlightEffect che in a_lCharacterFadeinEffect) { if (che.characterID >= a_iStartIndex && che.characterID < iLowestCharacterLength) { iLowestCharacterLength = che.characterID; } if (che.characterID > iHighestCharacterID) { iHighestCharacterID = che.characterID; } } if (iLowestCharacterLength == INVALID_CHARACTER_ID) { iLowestCharacterLength = (a_iStartIndex + a_iLength); } if (iHighestCharacterID < iLowestCharacterLength) { iHighestCharacterID = iLowestCharacterLength; } string sReturnVal = ""; for (int i = a_iStartIndex; i < iLowestCharacterLength; ++i) { sReturnVal += "<color=#" + GetCharacterColourCode(i) + ">" + m_sFullDisplayText[i] + "</color>"; } for (int i = iLowestCharacterLength; i < iHighestCharacterID; ++i) { if (IsValidCharacter(m_sFullDisplayText[i])) { CharacterHighlightEffect highlightInfo = MatchCharacterIDToHighlightEffect(i); if (highlightInfo != null) { sReturnVal += "<color=#" + GetCharacterColourCode(i) + ">" + m_sFullDisplayText[i] + "</color>"; } else { sReturnVal += "<color=#FFFFFF00>" + m_sFullDisplayText[i] + "</color>"; } } else { sReturnVal += m_sFullDisplayText[i]; } } if (iHighestCharacterID < (a_iStartIndex + a_iLength)) { sReturnVal += "<color=#FFFFFF00>"; for (int i = iHighestCharacterID; (i < (a_iStartIndex + a_iLength)); ++i) { sReturnVal += m_sFullDisplayText[i]; } sReturnVal += "</color>"; } return(sReturnVal); }