using System; 
 | 
using System.Collections.Generic; 
 | 
  
 | 
using UnityEngine; 
 | 
  
 | 
public class RichTableEvent : TRichTextEvent 
 | 
{ 
 | 
    public RichTableEvent() 
 | 
    { 
 | 
        RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.TABLE, this); 
 | 
        RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.SHOWITEM, this); 
 | 
    } 
 | 
  
 | 
    public override bool Execute(RichTextEventEnum type, RichTextMgr.HrefInfo href) 
 | 
    { 
 | 
        switch (type) 
 | 
        { 
 | 
            case RichTextEventEnum.SHOWITEM: 
 | 
                { 
 | 
                    var config = ItemConfig.Get(int.Parse(href.mSplits["showitem"])); 
 | 
                    if (config != null) 
 | 
                    { 
 | 
                        DisplayItem(config.ID, href); 
 | 
                    } 
 | 
                } 
 | 
                break; 
 | 
        } 
 | 
        return false; 
 | 
    } 
 | 
  
 | 
     
 | 
    public override string GetDisplay(RichTextEventEnum type, Dictionary<string, string> _dict) 
 | 
    { 
 | 
        switch (type) 
 | 
        { 
 | 
            case RichTextEventEnum.TABLE: 
 | 
                { 
 | 
                    if (_dict.ContainsKey("info")) 
 | 
                    { 
 | 
                        string info = _dict["info"]; 
 | 
                        switch (info) 
 | 
                        { 
 | 
                            case "richtextmsgreplace": 
 | 
                                { 
 | 
                                    int id = 0; 
 | 
                                    if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id)) 
 | 
                                    { 
 | 
                                        return RichTextMsgReplaceConfig.GetRichReplace(_dict["name"], id); 
 | 
                                    } 
 | 
                                } 
 | 
                                break; 
 | 
                            case "item": 
 | 
                                { 
 | 
                                    int id = 0; 
 | 
                                    if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id)) 
 | 
                                    { 
 | 
                                        ItemConfig cfg = ItemConfig.Get(id); 
 | 
                                        if (cfg != null) 
 | 
                                        { 
 | 
                                            var _itemColor = cfg.ItemColor; 
 | 
                                            if (ItemLogicUtility.Instance.IsWing(id))//翅膀 
 | 
                                            { 
 | 
                                                Dictionary<int, List<int>> userdata = null; 
 | 
                                                if (TryGetUserData(_dict, out userdata)) 
 | 
                                                { 
 | 
                                                    _itemColor = ItemLogicUtility.Instance.GetItemQuality(cfg.ID, userdata); 
 | 
                                                } 
 | 
                                            } 
 | 
                                            var itemName = cfg.ItemName; 
 | 
                                            if (_dict.ContainsKey("chatsend")) 
 | 
                                            { 
 | 
                                                itemName = StringUtility.Contact("[", itemName, "]"); 
 | 
                                            } 
 | 
                                            if (_dict.ContainsKey("count")) 
 | 
                                            { 
 | 
                                                var count = 0; 
 | 
                                                int.TryParse(_dict["count"], out count); 
 | 
                                                if (count > 0) 
 | 
                                                { 
 | 
                                                    itemName = StringUtility.Contact(itemName, "x", count); 
 | 
                                                } 
 | 
                                            } 
 | 
                                            var suitLabel = string.Empty; 
 | 
                                            if (!_dict.ContainsKey("chatsend")) 
 | 
                                            { 
 | 
                                                var text = RichTextMgr.Inst.presentRichText; 
 | 
                                                int colorType = 0; 
 | 
                                                if (text != null) 
 | 
                                                { 
 | 
                                                    colorType = text.colorType == RichText.ColorType.Dark ? 0 : 1; 
 | 
                                                } 
 | 
                                                // if (ItemLogicUtility.Instance.IsSuitEquip(id)) 
 | 
                                                // { 
 | 
                                                //     suitLabel = StringUtility.Contact("<Suitname=", UIHelper.GetEquipSuitName(id, colorType == 1), "/>|"); 
 | 
                                                // } 
 | 
                                            } 
 | 
                                            return StringUtility.Contact(suitLabel, AppendColor(itemName, _itemColor, _dict)); 
 | 
                                        } 
 | 
                                        else 
 | 
                                        { 
 | 
                                            Debug.LogError(string.Format("物品表里没有ID{0}对应的物品", id)); 
 | 
                                        } 
 | 
                                    } 
 | 
                                } 
 | 
                                break; 
 | 
                            case "npc": 
 | 
                                { 
 | 
                                    int id = 0; 
 | 
                                    if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id)) 
 | 
                                    { 
 | 
                                        NPCConfig cfg = NPCConfig.Get(id); 
 | 
                                        if (cfg != null) 
 | 
                                        { 
 | 
                                            return cfg.charName; 
 | 
                                        } 
 | 
                                    } 
 | 
                                } 
 | 
                                break; 
 | 
                            case "map": 
 | 
                                { 
 | 
                                    //     int id = 0; 
 | 
                                    //     if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id)) 
 | 
                                    //     { 
 | 
                                    //         var lineId = 0; 
 | 
                                    //         if (_dict.ContainsKey("lineid") && int.TryParse(_dict["lineid"], out lineId)) 
 | 
                                    //         { 
 | 
                                    //             var mapResourceConfig = MapResourcesConfig.GetConfig(id, lineId); 
 | 
                                    //             if (mapResourceConfig != null) 
 | 
                                    //             { 
 | 
                                    //                 return mapResourceConfig.Name; 
 | 
                                    //             } 
 | 
                                    //         } 
 | 
                                    //         MapConfig cfg = MapConfig.Get(id); 
 | 
                                    //         if (cfg != null) 
 | 
                                    //         { 
 | 
                                    //             return cfg.Name; 
 | 
                                    //         } 
 | 
                                    //     } 
 | 
                                    return "map"; 
 | 
                                 } 
 | 
                                break; 
 | 
                            case "skill": 
 | 
                                { 
 | 
                                    int id = 0; 
 | 
                                    if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id)) 
 | 
                                    { 
 | 
                                        SkillConfig cfg = SkillConfig.Get(id); 
 | 
                                        if (cfg != null) 
 | 
                                        { 
 | 
                                            return cfg.SkillName; 
 | 
                                        } 
 | 
                                    } 
 | 
                                } 
 | 
                                break; 
 | 
                            case "realm": 
 | 
                                { 
 | 
                                    int id = 0; 
 | 
                                    if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id)) 
 | 
                                    { 
 | 
                                        RealmConfig _cfg = RealmConfig.Get(id); 
 | 
                                        if (_cfg != null) 
 | 
                                        { 
 | 
                                            var text = RichTextMgr.Inst.presentRichText; 
 | 
                                            int colorType = 0; 
 | 
                                            if (text != null) 
 | 
                                            { 
 | 
                                                colorType = text.colorType == RichText.ColorType.Dark ? 0 : 1; 
 | 
                                            } 
 | 
                                            return UIHelper.GetRealmName(id, colorType == 1); 
 | 
                                        } 
 | 
                                    } 
 | 
                                } 
 | 
                                break; 
 | 
                            case "pet": 
 | 
                                { 
 | 
                                    // int id = 0; 
 | 
                                    // if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out id)) 
 | 
                                    // { 
 | 
                                    //     PetInfoConfig _cfg = PetInfoConfig.Get(id); 
 | 
                                    //     if (_cfg != null) 
 | 
                                    //     { 
 | 
                                    //         return AppendColor(_cfg.Name, _cfg.Quality, _dict); 
 | 
                                    //     } 
 | 
                                    // } 
 | 
                                    return "pet"; 
 | 
                                } 
 | 
                                break; 
 | 
                            case "buffdesc": 
 | 
                                { 
 | 
                                    var _id = 0; 
 | 
                                    if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id)) 
 | 
                                    { 
 | 
                                        var _cfg = SkillConfig.Get(_id); 
 | 
                                        if (_cfg != null) 
 | 
                                        { 
 | 
                                            return _cfg.Description; 
 | 
                                        } 
 | 
                                    } 
 | 
                                } 
 | 
                                break; 
 | 
                            case "property": 
 | 
                                { 
 | 
                                    var _id = 0; 
 | 
                                    if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id)) 
 | 
                                    { 
 | 
                                        var _cfg = PlayerPropertyConfig.Get(_id); 
 | 
                                        if (_cfg != null) 
 | 
                                        { 
 | 
                                            return _cfg.Name; 
 | 
                                        } 
 | 
                                    } 
 | 
                                } 
 | 
                                break; 
 | 
                            case "mount": 
 | 
                                { 
 | 
                                    // var _id = 0; 
 | 
                                    // if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id)) 
 | 
                                    // { 
 | 
                                    //     var _cfg = HorseConfig.Get(_id); 
 | 
                                    //     if (_cfg != null) 
 | 
                                    //     { 
 | 
                                    //         return AppendColor(_cfg.Name, _cfg.Quality, _dict); 
 | 
                                    //     } 
 | 
                                    // } 
 | 
                                } 
 | 
                                break; 
 | 
                            case "success": 
 | 
                                { 
 | 
                                    var _id = 0; 
 | 
                                    if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id)) 
 | 
                                    { 
 | 
                                        var _cfg = SuccessConfig.Get(_id); 
 | 
                                        if (_cfg != null) 
 | 
                                        { 
 | 
                                            return _cfg.Describe; 
 | 
                                        } 
 | 
                                    } 
 | 
                                } 
 | 
                                break; 
 | 
  
 | 
                            case "treasureprivilege": 
 | 
                                { 
 | 
                                    // var _id = 0; 
 | 
                                    // if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id)) 
 | 
                                    // { 
 | 
                                    //     var _cfg = TreasurePrivilegeConfig.Get(_id); 
 | 
                                    //     if (_cfg != null) 
 | 
                                    //     { 
 | 
                                    //         return _cfg.Name; 
 | 
                                    //     } 
 | 
                                    // } 
 | 
                                    return "treasureprivilege"; 
 | 
                                } 
 | 
                                break; 
 | 
                             
 | 
                            // case "skytowerfloor": 
 | 
                            //     { 
 | 
                            //         var _id = 0; 
 | 
                            //         if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id)) 
 | 
                            //         { 
 | 
                            //             var config = SkyTowerConfig.Get(_id); 
 | 
                            //             if (config != null) 
 | 
                            //             { 
 | 
                            //                 return config.floorName; 
 | 
                            //             } 
 | 
                            //         } 
 | 
                            //     } 
 | 
                            //     break; 
 | 
                            case "coloritem": 
 | 
                                { 
 | 
                                    var _id = 0; 
 | 
                                    if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id)) 
 | 
                                    { 
 | 
                                        var config = ItemConfig.Get(_id); 
 | 
                                        if (config != null) 
 | 
                                        { 
 | 
                                            return StringUtility.Contact(GetItemColorName(config.ItemColor), AppendColor(config.ItemName, config.ItemColor, _dict)); 
 | 
                                        } 
 | 
                                    } 
 | 
                                } 
 | 
                                break; 
 | 
                            // case "crossserverarena": 
 | 
                            //     { 
 | 
                            //         var _id = 0; 
 | 
                            //         if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id)) 
 | 
                            //         { 
 | 
                            //             var text = RichTextMgr.Inst.presentRichText; 
 | 
                            //             int colorType = 0; 
 | 
                            //             if (text != null) 
 | 
                            //             { 
 | 
                            //                 colorType = text.colorType == RichText.ColorType.Dark ? 0 : 1; 
 | 
                            //             } 
 | 
                            //             return UIHelper.AppendDanLVNameColor(_id, colorType == 1); 
 | 
                            //         } 
 | 
                            //     } 
 | 
                            //     break; 
 | 
  
 | 
                            case "title": 
 | 
                                { 
 | 
                                    var _id = 0; 
 | 
                                    if (_dict.ContainsKey("id") && int.TryParse(_dict["id"], out _id)) 
 | 
                                    { 
 | 
                                        return UIHelper.AppendColor(TextColType.Green, DienstgradConfig.Get(_id).Name, true); 
 | 
                                    } 
 | 
                                } 
 | 
                                break; 
 | 
                            case "orderInfo": 
 | 
                                { 
 | 
                                    if (_dict.ContainsKey("id")) 
 | 
                                    { 
 | 
                                        var cpInfo = _dict["id"]; 
 | 
                                        string goodsName = string.Empty; 
 | 
                                        OrderInfoConfig orderInfo = null; 
 | 
                                        if (RechargeManager.Instance.orderInfoToCTGID[cpInfo] != 0) 
 | 
                                        { 
 | 
                                            RechargeManager.Instance.TryGetOrderInfo(RechargeManager.Instance.orderInfoToCTGID[cpInfo], out orderInfo); 
 | 
                                            goodsName = CTGConfig.Get(RechargeManager.Instance.orderInfoToCTGID[cpInfo]).Title; 
 | 
                                        } 
 | 
                                        else 
 | 
                                        { 
 | 
                                            var keys = OrderInfoConfig.GetKeys(); 
 | 
                                            for (int i = 0; i < keys.Count; i++) 
 | 
                                            { 
 | 
                                                orderInfo = OrderInfoConfig.Get(keys[i]); 
 | 
                                                if (orderInfo != null && orderInfo.OrderInfo == cpInfo) 
 | 
                                                { 
 | 
                                                    break; 
 | 
                                                } 
 | 
                                            } 
 | 
                                            goodsName = Language.Get("DayGoods_1", UIHelper.GetMoneyFormat(orderInfo.PayRMBNum)); 
 | 
                                        } 
 | 
  
 | 
                                        return goodsName; 
 | 
                                    } 
 | 
                                } 
 | 
                                break; 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
                break; 
 | 
        } 
 | 
        return string.Empty; 
 | 
    } 
 | 
  
 | 
  
 | 
    private void DisplayItem(int itemId, RichTextMgr.HrefInfo hrefInfo) 
 | 
    { 
 | 
        // ItemTipUtility.CustomItemPlus itemplus = default(ItemTipUtility.CustomItemPlus); 
 | 
        // itemplus.Preview = 1; 
 | 
        // if (hrefInfo.mSplits.ContainsKey("itemplus") && !string.IsNullOrEmpty(hrefInfo.mSplits["itemplus"])) 
 | 
        // { 
 | 
        //     itemplus = LitJson.JsonMapper.ToObject<ItemTipUtility.CustomItemPlus>(hrefInfo.mSplits["itemplus"]); 
 | 
        //     itemplus.Preview = 0; 
 | 
        // } 
 | 
        // else if (hrefInfo.mSplits.ContainsKey("guid")) 
 | 
        // { 
 | 
        //     var userdata = string.Empty; 
 | 
        //     if (hrefInfo.mSplits.ContainsKey("userdata")) 
 | 
        //     { 
 | 
        //         userdata = hrefInfo.mSplits["userdata"]; 
 | 
        //     } 
 | 
  
 | 
        //     var guid = hrefInfo.mSplits["guid"]; 
 | 
        //     if (!string.IsNullOrEmpty(guid)) 
 | 
        //     { 
 | 
        //         RichViewItemUtility.SendViewNotifyItem(guid, userdata); 
 | 
        //         return; 
 | 
        //     } 
 | 
        // } 
 | 
        // else if (hrefInfo.mSplits.ContainsKey("userdata")) 
 | 
        // { 
 | 
        //     itemplus.UserData = hrefInfo.mSplits["userdata"]; 
 | 
        // } 
 | 
  
 | 
        // RichViewItemUtility.DisplayItem(itemId, itemplus); 
 | 
    } 
 | 
  
 | 
    static string GetItemColorName(int _itemColor) 
 | 
    { 
 | 
        // switch (_itemColor) 
 | 
        // { 
 | 
        //     case 2: 
 | 
        //         return Language.Get("EquipSuitBlue"); 
 | 
        //     case 3: 
 | 
        //         return Language.Get("EquipSuitPurple"); 
 | 
        //     case 4: 
 | 
        //         return Language.Get("EquipSuitOrange"); 
 | 
        //     case 5: 
 | 
        //         return Language.Get("EquipSuitRed"); 
 | 
        //     default: 
 | 
        //         return Language.Get("EquipSuitWhite"); 
 | 
        // } 
 | 
        return string.Empty; 
 | 
    } 
 | 
  
 | 
    static string AppendColor(string info, int _itemColor, Dictionary<string, string> dic) 
 | 
    { 
 | 
        if (dic.ContainsKey("col")) 
 | 
        { 
 | 
            if (int.Parse(dic["col"]) == 0) 
 | 
            { 
 | 
                return info; 
 | 
            } 
 | 
        } 
 | 
        var text = RichTextMgr.Inst.presentRichText; 
 | 
        int colorType = 0; 
 | 
        if (text != null) 
 | 
        { 
 | 
            colorType = text.colorType == RichText.ColorType.Dark ? 0 : 1; 
 | 
        } 
 | 
        return UIHelper.AppendColor(_itemColor, info, colorType == 1); 
 | 
    } 
 | 
  
 | 
    static bool TryGetUserData(Dictionary<string, string> href, out Dictionary<int, List<int>> userdata) 
 | 
    { 
 | 
        userdata = null; 
 | 
        if (href.ContainsKey("itemplus")) 
 | 
        { 
 | 
            var itemplus = LitJson.JsonMapper.ToObject<ItemTipUtility.CustomItemPlus>(href["itemplus"]); 
 | 
            userdata = ConfigParse.Analysis(itemplus.UserData); 
 | 
        } 
 | 
        else if (href.ContainsKey("userdata")) 
 | 
        { 
 | 
            userdata = ConfigParse.Analysis(href["userdata"]); 
 | 
        } 
 | 
        return false; 
 | 
    } 
 | 
} 
 |