---@class KLUIChatSmallItem:UIKmlLuaPanelBase ---@field view KLUIChatSmallItemView local KLUIChatSmallItem = class(UIKmlLuaPanelBase) local this = KLUIChatSmallItem ---创建时调用一次 function this:Init() end ---创建或者刷新界面数据时调用 function this:Refresh() end function this:RefreshItem(data) self.message = data.message self.itemIndex = data.itemIndex local is_me = false if self.message.senderId == SL:GetMetaValue(EMetaVarGetKey.UID) then is_me = true end local is_union_system = false if self.message.channel == EChatChannelType.UNION and (not self.message.senderId or self.message.senderId == 0) then is_union_system = true end if not self.message.career then self.message.career = 0 end if not self.message.sendName then self.message.sendName = "" end local channel = self.message.channel if channel == EChatChannelType.PERSONAL then local isFriend = false if is_me then isFriend = SL:CheckIsFriend(self.message.receiverId) else isFriend = SL:CheckIsFriend(self.message.senderId) end if isFriend then channel = EChatChannelType.FRIEND end end local typeStr = SL:ChatInfo_GetChatTypeStr(channel) local typeTitleStr = self:GetTypeTitle(typeStr,channel) local sendName if channel == EChatChannelType.SYSTEM then sendName = "" elseif is_union_system then sendName = "" else sendName = self.message.sendName end local str = typeTitleStr .. sendName ..":" ..self.message.message if not self.message.chatiteminfo and self.message.itemList and #self.message.itemList >0 then local chatiteminfo = "" for i, v in ipairs(self.message.itemList) do local item = SL:GetConfig("cfg_item", v.cfgId) local name_color = "#d2d2d2" if item.type == EItemType.Equip then local grade = SL:GetEquipValue(EMetaVarGetKey.EQUIP_GRADE, "", v.cfgId) --不读品质了,全部走配置 local colorid = SL:GetConfig('cfg_item', v.cfgId).color name_color = SL:GetConfig('cfg_color', colorid).color else local colorid = SL:GetConfig('cfg_item', v.cfgId).color name_color = SL:GetConfig('cfg_color', colorid).color end local oneStr = "" if i ~= 1 then oneStr = "|" end oneStr = oneStr .. v.id .. "*" .. v.cfgId .. "*" .. name_color chatiteminfo = chatiteminfo .. oneStr SL:ChatInfo_AddChaItemInfo(v) end self.message.chatiteminfo = chatiteminfo end GUI:RichText_setchatiteminfo(self.view.richSmall,self.message.chatiteminfo) if not str then str = "" end GUI:Text_setString(self.view.richSmall,str) if self.message and self.message.itemSizeSmall then GUI:setContentSize(self.view.samll_one_bg, 360,self.message.itemSizeSmall.y+10) end end ---注册UI事件和服务器消息 function this:RegistEvents() --GUI:AddOnClickEvent(self.view.button_id,self,self.BtnOnClick) GUI:AddOnClickEvent(self.view.root, self, self.OpenChatPanel) end function this:OpenChatPanel() SL:OpenChatUI() end function this:Close() end function this:GetTypeTitle(typeStr,channel) if channel == EChatChannelType.SYSTEM then return "[".. typeStr.."]" elseif channel == EChatChannelType.WORLD then return "[".. typeStr.."]" elseif channel == EChatChannelType.NEARBY then return "[".. typeStr.."]" elseif channel == EChatChannelType.UNION then return "[".. typeStr.."]" elseif channel == EChatChannelType.TEAM then return "[".. typeStr.."]" elseif channel == EChatChannelType.FRIEND then return "[".. typeStr.."]" elseif channel == EChatChannelType.PERSONAL then return "[".. typeStr.."]" elseif channel == EChatChannelType.RECRUIT then return "[".. typeStr.."]" end return "[".. typeStr.."]" end return this