123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- ---@class KLUIChatItem:UIKmlLuaPanelBase
- ---@field view KLUIChatItemView
- local KLUIChatItem = class(UIKmlLuaPanelBase)
- local this = KLUIChatItem
- ---创建时调用一次
- function this:Init()
-
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- end
- function this:RefreshItem(data)
- if not SL:MeData_Check() then
- return
- end
- self.message = data.message
- self.itemIndex = data.itemIndex
- --self.data.sendName
- 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 is_me = false
- if self.message.senderId == SL:GetMetaValue(EMetaVarGetKey.UID) then
- is_me = true
- end
- local career = self.message.career
- local careerStr
- 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 str = typeTitleStr
- if channel ~= EChatChannelType.SYSTEM and not is_union_system then
- local career = self.message.career
- careerStr = "1"..career
- str = typeTitleStr.. self.message.sendName
- end
-
- if is_me and channel ~= EChatChannelType.SYSTEM then
- GUI:setAnchorPoint(self.view.icon_root,2,1)
- GUI:setAnchorPoint(self.view.name,2,1)
- GUI:setAnchorPoint(self.view.qipao,2,1)
- GUI:setPositionX(self.view.name,-75)
- GUI:setPositionX(self.view.qipao,-70)
- GUI:Image_loadTexture(self.view.qipao,"img_chat_pao2","Atlas/KLChatPanel.spriteatlas")
- GUI:setAnchorPoint(self.view.richT,2,0)
- GUI:setPositionX(self.view.richT,-13)
- else
- GUI:setAnchorPoint(self.view.icon_root,1,1)
- GUI:setAnchorPoint(self.view.name,1,1)
- GUI:setAnchorPoint(self.view.qipao,1,1)
- GUI:setPositionX(self.view.name,75)
- GUI:setPositionX(self.view.qipao,70)
- GUI:Image_loadTexture(self.view.qipao,"img_chat_pao","Atlas/KLChatPanel.spriteatlas")
- GUI:setAnchorPoint(self.view.richT,1,0)
- GUI:setPositionX(self.view.richT,13)
- end
- GUI:Text_setString(self.view.name,str)
- if channel == EChatChannelType.SYSTEM or is_union_system then
- GUI:setVisible(self.view.icon_root,false)
- GUI:setPositionX(self.view.name,10)
- GUI:setPositionX(self.view.qipao,12)
-
- else
- GUI:Image_loadTexture(self.view.icon,careerStr,"Atlas/MUIcon.spriteatlas")
- GUI:setVisible(self.view.icon_root,true)
- end
- 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:GetConfigMultiKeys('cfg_equip_quality', grade, 'id').nameColor
- -- name_color = SL:GetConfigMultiKeys('cfg_color', colorid, 'id').color
- --不读品质了,全部走配置
- 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
- -- SL:LogError(self.message.message)
- -- SL:LogTable(self.message.chatiteminfo)
- GUI:RichText_setchatiteminfo(self.view.richT,self.message.chatiteminfo)
- GUI:Text_setString(self.view.richT,self.message.message)
- local playerid = ""
- if self.message.senderId and self.message.senderId~=0 then
- playerid = tostring(self.message.senderId)
- end
- GUI:RichText_setchatplayerid(self.view.richT,playerid)
-
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.icon,self,self.OnclickIcon)
- 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
- function this:OnclickIcon()
- local id = self.message.senderId
- if id == SL:GetMetaValue(EMetaVarGetKey.UID) then
- return
- end
- local _x,_y,_z = GUI:GetWorldPosition(self.view.icon_root)
- _x = math.floor(_x * 100) / 100
- _y = math.floor(_y * 100) / 100
- _z = math.floor(_z * 100) / 100
- if _y < 359.1 then
- _y = 359.1
- end
- GUI:UIPanel_Open("dev/ui/FriendSys/Panel/KLFriendOperate/KLFriendOperatePanel", _, _, {rid = id,pos={x=_x+4.9,y=_y-2.3,z=_z},name = self.message.sendName,isHideMainUI=true})
- end
- function this:Close()
- end
- return this
|