| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Text.RegularExpressions; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | using UnityEngine; |
| | | public class ImgAnalysis : TRichAnalysis<ImgAnalysis> |
| | |
| | | |
| | | private RichTextMgr.ImgInfo presentImgInfo = null; |
| | | |
| | | public override string Analysis(string val, bool IsRich) |
| | | public override async UniTask<string> Analysis(string val, bool IsRich) |
| | | { |
| | | if (!Img_Regex.IsMatch(val)) |
| | | { |
| | |
| | | |
| | | presentImgInfo = imgInfo; |
| | | m_StringBuilder.Append(val.Substring(index, match.Index - index)); |
| | | AnalysisSplitEvent(match.Groups[1].Value); |
| | | await AnalysisSplitEvent(match.Groups[1].Value); |
| | | |
| | | if (IsRich) |
| | | { |
| | |
| | | return val; |
| | | } |
| | | |
| | | private void AnalysisSplitEvent(string val) |
| | | private async UniTask AnalysisSplitEvent(string val) |
| | | { |
| | | string[] array = GetSplitEvent(val); |
| | | if (array.Length > 0) |
| | |
| | | AnalysisSplitData(split_event); |
| | | } |
| | | } |
| | | LoadSprite(); |
| | | await LoadSprite(); |
| | | } |
| | | |
| | | private void AnalysisSplitData(string val) |
| | |
| | | m_StringBuilder.Append("/></color>"); |
| | | } |
| | | |
| | | private void LoadSprite() |
| | | private async UniTask LoadSprite() |
| | | { |
| | | if (presentImgInfo.IsFace) return; |
| | | if (IconConfig.isInit) |
| | | { |
| | | if (!string.IsNullOrEmpty(presentImgInfo.folderName)) |
| | | { |
| | | presentImgInfo.sprite = UILoader.LoadSprite(presentImgInfo.folderName, presentImgInfo.spriteName); |
| | | presentImgInfo.sprite = await UILoader.LoadSpriteAsync(presentImgInfo.folderName, presentImgInfo.spriteName); |
| | | } |
| | | else |
| | | { |
| | | presentImgInfo.sprite = UILoader.LoadSprite(presentImgInfo.spriteName); |
| | | presentImgInfo.sprite = await UILoader.LoadSpriteAsync(presentImgInfo.spriteName); |
| | | } |
| | | } |
| | | |
| | | if (presentImgInfo.sprite != null) |
| | | { |
| | | RichText text = RichTextMgr.Inst.presentRichText; |
| | | if (text != null) |
| | | { |
| | | if (text.LockImgSize) |
| | | { |
| | | presentImgInfo.width = presentImgInfo.height = text.fontSize; |
| | | return; |
| | | } |
| | | else if (text.ModifyImgSiez) |
| | | { |
| | | presentImgInfo.width = text.ModifyImgWidth; |
| | | presentImgInfo.height = text.ModifyImgHeight; |
| | | return; |
| | | } |
| | | } |
| | | if (presentImgInfo.scale != 1f) |
| | | { |
| | | presentImgInfo.width = presentImgInfo.sprite.rect.width * presentImgInfo.scale; |
| | | presentImgInfo.height = presentImgInfo.sprite.rect.height * presentImgInfo.scale; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private async UniTask LoadSpriteAsync() |
| | | { |
| | | if (presentImgInfo.IsFace) return; |
| | | if (IconConfig.isInit) |
| | | { |
| | | if (!string.IsNullOrEmpty(presentImgInfo.folderName)) |
| | | { |
| | | presentImgInfo.sprite = await UILoader.LoadSpriteAsync(presentImgInfo.folderName, presentImgInfo.spriteName); |
| | | } |
| | | else |
| | | { |
| | | presentImgInfo.sprite = await UILoader.LoadSpriteAsync(presentImgInfo.spriteName); |
| | | } |
| | | } |
| | | |