123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- ---@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 "<color=#4cc5feff>[".. typeStr.."]</color>"
- elseif channel == EChatChannelType.WORLD then
- return "<color=#B3C5E3>[".. typeStr.."]</color>"
- elseif channel == EChatChannelType.NEARBY then
- return "<color=#00ff00ff>[".. typeStr.."]</color>"
- elseif channel == EChatChannelType.UNION then
- return "<color=#ffc000ff>[".. typeStr.."]</color>"
- elseif channel == EChatChannelType.TEAM then
- return "<color=#d916d9ff>[".. typeStr.."]</color>"
- elseif channel == EChatChannelType.FRIEND then
- return "<color=#4cc5feff>[".. typeStr.."]</color>"
- elseif channel == EChatChannelType.PERSONAL then
- return "<color=#28e529ff>[".. typeStr.."]</color>"
- elseif channel == EChatChannelType.RECRUIT then
- return "[".. typeStr.."]"
- end
- return "[".. typeStr.."]"
- end
- return this
|