void CreateTextItem(ref UGUIRichItem item, ref UGUILine mNewLine) { //如果没有溢出,则更新当前的宽度,向行中加入新元素 if (mCurWidth + mRichStyle.GetStrWidth(item.Inner) <= mMaxWidth) { mCurWidth += mRichStyle.GetStrWidth(item.Inner); mNewLine.EnItemQueue(item); } //如果溢出,开始截断文字,溢出代表至少文字被分割成两个部分,如果被切割成三个部分,则第二部分一定是单独的一行 else { mCutList.Clear(); CutStr(item.Inner, mMaxWidth - mCurWidth, mMaxWidth); mAddTextItemHandler(item, ref mNewLine, 0); mResultLines.Enqueue(mNewLine); mCutList.RemoveAt(0); for (int i = 0; i < mCutList.Count; i++) { if (i != mCutList.Count - 1) { UGUILine line = new UGUILine(0); mAddTextItemHandler(item, ref line, i); mResultLines.Enqueue(line); } else { mCurWidth = mRichStyle.GetStrWidth(mCutList[i]); mNewLine = new UGUILine(0); mAddTextItemHandler(item, ref mNewLine, i); } } } }
void CreateImageItem(ref UGUIRichItem item, ref UGUILine mNewLine) { UGUIRichItemImage imgItem = item as UGUIRichItemImage; if (mCurWidth + mRichStyle.EmojiSize.x <= mMaxWidth) { mCurWidth += mRichStyle.EmojiSpWidth; mNewLine.EnItemQueue(imgItem); mNewLine.LineNum = mRichStyle.EmojiHeightSpaceNum; } else { mResultLines.Enqueue(mNewLine); mNewLine = new UGUILine(0); mNewLine.EnItemQueue(imgItem); mNewLine.LineNum = mRichStyle.EmojiHeightSpaceNum; mCurWidth = mRichStyle.EmojiSize.x; } }
void AddTextToLine(UGUIRichItem item, ref UGUILine mNewLine, int index) { mNewLine.EnItemQueue(new UGUIRichItemText( Color.black, mCutList[index])); }
void AddHrefToLine(UGUIRichItem item, ref UGUILine mNewLine, int index) { mNewLine.EnItemQueue(new UGUIRichItemHref( (item as UGUIRichItemHref).HrefNormalColor, mCutList[index], (item as UGUIRichItemHref).Url)); }