KLUIRankListPanel.lua 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. ---@class KLUIRankListPanel:UIKmlLuaPanelBase
  2. ---@field view KLUIRankListPanelView
  3. ---@field leftCfgDataList table<number,cfg_rank_column>
  4. ---@field titleCfgDataList table<number,cfg_rank_column>
  5. ---@field allCfgDataList table<number,table<number,table<number,cfg_rank_column>>>
  6. local KLUIRankListPanel = class(UIKmlLuaPanelBase)
  7. local this =KLUIRankListPanel
  8. ---创建时调用一次
  9. function this:Init()
  10. ---@type cfg_global_column
  11. local globalCfg = SL:GetConfig("cfg_global",16)
  12. GUI:Text_setString(self.view.TimeText,"排行榜每"..globalCfg.value.."分钟刷新一次")
  13. ---左侧复选框cfg数据(根据类型)
  14. self.leftCfgDataList = {}
  15. ---顶部选择框cfg数据
  16. self.titleCfgDataList = {}
  17. ---所有cfg数据(根据类型归类)
  18. self.allCfgDataList = {}
  19. ---排行榜玩家信息
  20. self.playerSeverDataList = {}
  21. ---选择的玩家id
  22. self.selectPlayerId = 0
  23. self.worshipList = {}
  24. ---当前选择的跨服榜单
  25. self.nowRootType = 1
  26. self.nowRootTypeNameStrList = {[1] = "本服榜",[2] = "跨服榜"}
  27. self.rankType = 0
  28. GUI:DataListInitData(self.view.LeftDataList,function()
  29. return self:LeftDataListItemCountFunc()
  30. end,function(realIndex)
  31. return self:LeftDataListItemGetFunc(realIndex)
  32. end,function(realIndex, kmlcontrol)
  33. return self:LeftDataListItemInitFunc(realIndex, kmlcontrol)
  34. end, function(realIndex, kmlcontrol)
  35. return self:LeftDataListItemUpdateFunc(realIndex, kmlcontrol)
  36. end)
  37. GUI:DataListInitData(self.view.TitleDatalist,function()
  38. return self:TitleDatalistItemCountFunc()
  39. end,function(realIndex)
  40. return self:TitleDatalistItemGetFunc(realIndex)
  41. end,function(realIndex, kmlcontrol)
  42. return self:TitleDatalistItemInitFunc(realIndex, kmlcontrol)
  43. end, function(realIndex, kmlcontrol)
  44. return self:TitleDatalistItemUpdateFunc(realIndex, kmlcontrol)
  45. end)
  46. GUI:DataListInitData(self.view.PlayerDataList,function()
  47. return self:PlayerDataListItemCountFunc()
  48. end,function(realIndex)
  49. return self:PlayerDataListItemGetFunc(realIndex)
  50. end,function(realIndex, kmlcontrol)
  51. return self:PlayerDataListItemInitFunc(realIndex, kmlcontrol)
  52. end, function(realIndex, kmlcontrol)
  53. return self:PlayerDataListItemUpdateFunc(realIndex, kmlcontrol)
  54. end)
  55. self:GetCfgData()
  56. end
  57. ---创建或者刷新界面数据时调用
  58. function this:Refresh()
  59. self:InitMyRankInfo()
  60. end
  61. ---根据根排行榜获取左侧按钮
  62. function this:GetRootTypeLeftButton()
  63. local subTypeList = {}
  64. self.leftCfgDataList = {}
  65. for i, roottypeList in ipairs(self.allCfgDataList) do
  66. table.insert(self.leftCfgDataList,{buttonType = i, toggleType = i .. "_0", name = self.nowRootTypeNameStrList[i]})
  67. for z, v in pairs(roottypeList) do
  68. if self.nowRootType == v[1].roottype then
  69. table.insert(subTypeList,v[1])
  70. end
  71. end
  72. --排个序再把数据添加到左侧按钮列表中
  73. if #subTypeList > 0 then
  74. table.sort(subTypeList,function(a, b)
  75. return a.type < b.type
  76. end)
  77. for z, v in ipairs(subTypeList) do
  78. v.toggleType = i .. "_" .. v.type
  79. table.insert(self.leftCfgDataList,v)
  80. end
  81. subTypeList = {}
  82. end
  83. end
  84. end
  85. ---获取排行榜表数据
  86. function this:GetCfgData()
  87. local cfg = SL:GetConfigTable("cfg_rank")
  88. local nowType = 0
  89. ---@param v cfg_rank_column
  90. for i, v in pairs(cfg) do
  91. if SL:CheckCondition(v.condition) then
  92. if nowType ~= v.type then
  93. nowType = v.type
  94. end
  95. if not self.allCfgDataList[v.roottype] then
  96. self.allCfgDataList[v.roottype] = {}
  97. end
  98. if not self.allCfgDataList[v.roottype][nowType] then
  99. self.allCfgDataList[v.roottype][nowType] = {}
  100. end
  101. table.insert(self.allCfgDataList[v.roottype][nowType],v)
  102. end
  103. end
  104. if #self.allCfgDataList > 0 then
  105. for i, roottypeList in pairs(self.allCfgDataList) do
  106. for z, v in pairs(roottypeList) do
  107. if #v > 0 then
  108. table.sort(v,function(a, b)
  109. return a.id < b.id
  110. end)
  111. end
  112. end
  113. end
  114. end
  115. self:GetRootTypeLeftButton()
  116. GUI:DataListUpdateData(self.view.LeftDataList, nil, function()
  117. SL:RefreshPanelALLRedPoint("KLUIRankListPanel")
  118. end)
  119. end
  120. ---初始化个人排名信息
  121. function this:InitMyRankInfo(info,rankNo)
  122. local rankValue = -1
  123. if rankNo then
  124. rankValue = rankNo
  125. end
  126. local name = SL:GetMetaValue(EMetaVarGetKey.USER_NAME)
  127. self:SetPlayerName(self.view.MyRank_Name,name)
  128. if info and info.value then--排行榜有值的情况下
  129. self:SetRankShowInfo(self.view.MyRank_UnionName, info.value)
  130. else--排行榜没有值的情况下直接拿自身数据
  131. if self.rankType == 4 and info and info.score then
  132. self:SetRankShowInfo(self.view.MyRank_UnionName, info.score)
  133. else
  134. local myValue = "无"
  135. ---1.等级排行榜
  136. ---2.勇气试炼排行榜
  137. ---3.战力排行榜
  138. if self.rankType == 1 then
  139. myValue = SL:MeData_GetLevel()
  140. elseif self.rankType == 2 then
  141. elseif self.rankType == 3 then
  142. myValue = SL:MeData_GetFightValue()
  143. end
  144. self:SetRankShowInfo(self.view.MyRank_UnionName, myValue)
  145. end
  146. end
  147. self:SetPlayerLv(self.view.MyRank_LV, "")
  148. self:SetRankValueIconOrText(self.view.MyRank_RankText,self.view.MyRank_RankIcon,self.view.MyRank_NoRank,rankValue)
  149. self:SetPlayerHead(self.view.MyRank_HeadIcon,SL:MeData_GetCareer())
  150. self:SetRankBG(self.view.MyRank_BG,rankValue)
  151. end
  152. ---设置玩家等级
  153. function this:SetPlayerLv(Control,lv)
  154. GUI:Text_setString(Control,tostring(lv))
  155. end
  156. function this:SetRankShowInfo(control, value)
  157. local name = ""
  158. ---1.等级排行榜
  159. ---2.勇气试炼排行榜
  160. ---3.战力排行榜
  161. if self.rankType == 1 then
  162. name = "等级:"
  163. elseif self.rankType == 2 then
  164. name = "层数:"
  165. elseif self.rankType == 3 then
  166. name = "战力:"
  167. value = SL:GetSimpleNumber(value,1)
  168. elseif self.rankType == 4 then
  169. name = "圣杯总评分:"
  170. if value ~= "无" then
  171. value = SL:GetSimpleNumber(value,1)
  172. end
  173. end
  174. GUI:Text_setString(control, name .. value)
  175. end
  176. ---设置玩家名字
  177. function this:SetPlayerName(Control,name)
  178. GUI:Text_setString(Control,name)
  179. end
  180. ---设置玩家战盟名字
  181. function this:SetPlayerUnionName(Control,unionName)
  182. if not unionName or unionName == "" then
  183. GUI:Text_setString(Control,"战盟:无")
  184. return
  185. end
  186. GUI:Text_setString(Control,"战盟:"..unionName)
  187. end
  188. ---设置玩家头像
  189. ---@param career CommonProtos.Career @职业数据
  190. function this:SetPlayerHead(Control,career)
  191. GUI:Image_loadTexture(Control,"1"..career.baseCareer,"Atlas/MUIcon.spriteatlas")
  192. end
  193. ---根据排名显示图片或文字
  194. function this:SetRankValueIconOrText(Control_Text,Control_Image,Control_Image2,rankValue)
  195. rankValue = tonumber(rankValue)
  196. GUI:SetActive(Control_Text,false)
  197. GUI:SetActive(Control_Image,false)
  198. if Control_Image2 then
  199. GUI:SetActive(Control_Image2,false)
  200. end
  201. if rankValue == -1 then
  202. if Control_Image2 then
  203. GUI:SetActive(Control_Image2,true)
  204. end
  205. return
  206. end
  207. if rankValue > 0 and rankValue < 4 then
  208. GUI:SetActive(Control_Image,true)
  209. GUI:Image_loadTexture(Control_Image,"S_icon"..rankValue,"Atlas/UIRankListPanel.spriteatlas")
  210. return
  211. end
  212. GUI:SetActive(Control_Text,true)
  213. GUI:Text_setString(Control_Text,tostring(rankValue))
  214. end
  215. ---根据排名显示背景图
  216. function this:SetRankBG(Control,rankValue)
  217. rankValue = tonumber(rankValue)
  218. if rankValue == -1 then
  219. GUI:Image_loadTexture(Control,"Pic_My","Atlas/UIRankListPanel.spriteatlas")
  220. return
  221. end
  222. if rankValue > 0 and rankValue < 4 then
  223. GUI:Image_loadTexture(Control,"Pic_"..rankValue,"Atlas/UIRankListPanel.spriteatlas")
  224. return
  225. end
  226. GUI:Image_loadTexture(Control,"Pic_4","Atlas/UIRankListPanel.spriteatlas")
  227. end
  228. --------------------------------左侧复选框(父类)-------------------------------------------------------
  229. function this:LeftDataListItemCountFunc()
  230. return #self.leftCfgDataList
  231. end
  232. function this:LeftDataListItemGetFunc(realIndex)
  233. end
  234. function this:LeftDataListItemInitFunc(realIndex, kmlcontrol)
  235. end
  236. function this:LeftDataListItemUpdateFunc(realIndex, kmlcontrol)
  237. local data = self.leftCfgDataList[realIndex + 1]
  238. local _button = GUI:GetChildControl(self.view.LeftDataList,realIndex,'LeftButton')
  239. GUI:SetID(_button, "LeftButton_" .. data.toggleType)
  240. local isShowMainButton = data and data.buttonType
  241. if isShowMainButton then
  242. GUI:setContentSize(_button,150,50)
  243. GUI:Button_loadTextureNormal(_button,"btnA_02","Atlas/UISynthesisPanel.spriteatlas")
  244. if self.nowRootType == data.buttonType then
  245. GUI:Button_loadTextureNormal(_button,"btnA_01","Atlas/UISynthesisPanel.spriteatlas")
  246. end
  247. GUI:AddOnClickEvent(_button,self,self.OnClickRefreshLeftButton,{data = data,button = _button})
  248. GUI:Button_setTitleText(_button,data.name)
  249. GUI:Button_setTitleFontSize(_button,20)
  250. else
  251. GUI:setContentSize(_button,150,40)
  252. GUI:Button_loadTextureNormal(_button,"btnC_02","Atlas/UISynthesisPanel.spriteatlas")
  253. GUI:AddOnClickEvent(_button,self,self.LeftOnClick,{data = data,button = _button})
  254. if self.rankType == 0 then
  255. self:LeftOnClick(_button,{data = data,button = _button})
  256. end
  257. GUI:Button_setTitleText(_button,data.name)
  258. GUI:Button_setTitleFontSize(_button,18)
  259. end
  260. end
  261. ---点击选择排行榜
  262. ---@param control UIKmlLuaControl
  263. ---@param eventData {data:cfg_rank_column,button:UIKmlLuaControl}
  264. function this:LeftOnClick(control, eventData)
  265. if self.rankType ~= eventData.data.type then
  266. self.rankType = eventData.data.type
  267. if self.selectLeftButton1 then
  268. GUI:Button_loadTextureNormal(self.selectLeftButton1,"btnC_02","Atlas/UISynthesisPanel.spriteatlas")
  269. self.selectLeftButton1 = nil
  270. end
  271. self.selectLeftButton1 = eventData.button
  272. self.titleCfgDataList = self.allCfgDataList[eventData.data.roottype][eventData.data.type]
  273. GUI:Button_loadTextureNormal(self.selectLeftButton1,"btnC_01","Atlas/UISynthesisPanel.spriteatlas")
  274. GUI:DataListUpdateData(self.view.TitleDatalist)
  275. end
  276. end
  277. ---点击刷新左侧按钮
  278. ---@param control UIKmlLuaControl
  279. function this:OnClickRefreshLeftButton(control, eventData)
  280. if self.nowRootType ~= eventData.data.buttonType then
  281. self.nowRootType = eventData.data.buttonType
  282. self.rankType = 0
  283. if self.selectLeftButton1 then
  284. self.selectLeftButton1 = nil
  285. end
  286. self:GetRootTypeLeftButton()
  287. GUI:DataListUpdateData(self.view.LeftDataList)
  288. end
  289. end
  290. ------------------------------------------------------------------------------------------------
  291. --------------------------------顶部复选框(子类)-------------------------------------------------------
  292. function this:TitleDatalistItemCountFunc()
  293. return #self.titleCfgDataList
  294. end
  295. function this:TitleDatalistItemGetFunc(realIndex)
  296. end
  297. function this:TitleDatalistItemInitFunc(realIndex, kmlcontrol)
  298. end
  299. function this:TitleDatalistItemUpdateFunc(realIndex, kmlcontrol)
  300. local data = self.titleCfgDataList[realIndex + 1]
  301. local _toggle = GUI:GetChildControl(self.view.TitleDatalist,realIndex,'TitleToggle')
  302. local _toggleText = GUI:GetChildControl(self.view.TitleDatalist,realIndex,'TitleToggleText')
  303. GUI:Text_setString(_toggleText,data.careerName)
  304. GUI:SetToggleOnValueChange(_toggle,self,self.TitleOnToggle,data)
  305. if realIndex == 0 then
  306. if GUI:Toggle_getIsOn(_toggle) == "1" then
  307. self:TitleOnToggle(_toggle, data)
  308. else
  309. GUI:Toggle_setIsOn(_toggle,true)
  310. end
  311. end
  312. end
  313. ---@param control UIKmlLuaControl
  314. ---@param eventData cfg_rank_column
  315. function this:TitleOnToggle(control, eventData)
  316. if GUI:Toggle_getIsOn(control) == "1" and self.titleId ~= eventData.id then
  317. self.titleId = eventData.id
  318. GUI:Text_setString(self.view.RewardText,eventData.rewardText)
  319. if eventData.type == 4 then
  320. ---首次生成列表需要默认选中第一个并且生成玩家模型
  321. self.reqOtherRoleInfo = true
  322. ---选中的玩家
  323. self.selectPlayerIndex = 0
  324. self.selectPlayerId = 0
  325. local reqData = {}
  326. reqData["type"] = eventData.roottype - 1
  327. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_ANGEL_GRAIL_RANKING_INFO,reqData)
  328. else
  329. ---首次生成列表需要默认选中第一个并且生成玩家模型
  330. self.reqOtherRoleInfo = true
  331. ---选中的玩家
  332. self.selectPlayerIndex = 0
  333. self.selectPlayerId = 0
  334. local reqData = {}
  335. reqData["career"] = eventData.career
  336. reqData["type"] = eventData.type
  337. reqData["roottype"] = eventData.roottype
  338. SL:SendLuaNetMsg(LuaMessageIdToSever.LOAD_RANK_DATA,reqData)
  339. end
  340. end
  341. end
  342. ------------------------------------------------------------------------------------------------
  343. --------------------------------排行榜玩家信息-------------------------------------------------------
  344. function this:PlayerDataListItemCountFunc()
  345. return #self.playerSeverDataList
  346. end
  347. function this:PlayerDataListItemGetFunc(realIndex)
  348. end
  349. function this:PlayerDataListItemInitFunc(realIndex, kmlcontrol)
  350. end
  351. function this:PlayerDataListItemUpdateFunc(realIndex, kmlcontrol)
  352. local data = self.playerSeverDataList[realIndex + 1]
  353. local _button = GUI:GetChildControl(self.view.PlayerDataList,realIndex,'PlayerItem_Button',kmlcontrol)
  354. local _selectImg = GUI:GetChildControl(self.view.PlayerDataList,realIndex,'PlayerItem_Select',kmlcontrol)
  355. local _bg = GUI:GetChildControl(self.view.PlayerDataList,realIndex,'PlayerItem_BG',kmlcontrol)
  356. local _headIcon = GUI:GetChildControl(self.view.PlayerDataList,realIndex,'PlayerItem_HeadIcon',kmlcontrol)
  357. local _rankText = GUI:GetChildControl(self.view.PlayerDataList,realIndex,'PlayerItem_RankText',kmlcontrol)
  358. local _rankIcon = GUI:GetChildControl(self.view.PlayerDataList,realIndex,'PlayerItem_RankIcon',kmlcontrol)
  359. local _name = GUI:GetChildControl(self.view.PlayerDataList,realIndex,'PlayerItem_Name',kmlcontrol)
  360. local _unionName = GUI:GetChildControl(self.view.PlayerDataList,realIndex,'PlayerItem_UnionName',kmlcontrol)
  361. local _lv = GUI:GetChildControl(self.view.PlayerDataList,realIndex,'PlayerItem_LV',kmlcontrol)
  362. local _id = data["actor"]["id"]
  363. local rankNo = realIndex + 1
  364. self:SetRankBG(_bg,rankNo)
  365. self:SetPlayerHead(_headIcon,{baseCareer = data["career"]})
  366. self:SetRankValueIconOrText(_rankText,_rankIcon,nil,rankNo)
  367. local serverName = ""
  368. if self.nowRootType == 2 and data["serverid"] then
  369. serverName = "S"..data["serverid"].."."
  370. end
  371. self:SetPlayerName(_name,serverName..data["name"])
  372. if self.rankType == 2 then
  373. self:SetPlayerLv(_lv,"")
  374. else
  375. self:SetPlayerLv(_lv,data["level"])
  376. end
  377. self:SetRankShowInfo(_unionName, data.value)
  378. GUI:AddOnClickEvent(_button,self,self.OnClickPlayer,{realIndex,data,_selectImg})
  379. GUI:SetActive(_selectImg,false)
  380. local isSelect = false
  381. if self.selectPlayerId == 0 and self.selectPlayerIndex == 0 and self.selectPlayerIndex == realIndex then
  382. isSelect = true
  383. end
  384. if self.selectPlayerId > 0 and self.selectPlayerId == _id then
  385. isSelect = true
  386. end
  387. if isSelect then
  388. GUI:SetActive(_selectImg,true)
  389. self.selectItem = _selectImg
  390. self.selectPlayerId = _id
  391. self.selectPlayerServerId = data.serverid
  392. GUI:SetActive(self.view.LockButton,true)
  393. if self.rankType == 4 then
  394. GUI:SetActive(self.view.WorshipButton,true)
  395. GUI:setPositionX(self.view.LockButton,58)
  396. if (self.worshipList and self.worshipList[tostring(_id)] == 1) or self.remaindTimes == 0 then
  397. GUI:SetActive(self.view.WorshipButton,false)
  398. GUI:setPositionX(self.view.LockButton, -48)
  399. end
  400. else
  401. GUI:SetActive(self.view.WorshipButton,false)
  402. GUI:setPositionX(self.view.LockButton,-48)
  403. end
  404. if self.selectPlayerId == SL:GetMetaValue(EMetaVarGetKey.UID) then
  405. GUI:SetActive(self.view.LockButton,false)
  406. GUI:SetActive(self.view.WorshipButton,false)
  407. self:ShowMyRole()
  408. else
  409. if self.reqOtherRoleInfo then--避免多次请求
  410. self.reqOtherRoleInfo = false
  411. self.otherRoleInfo = nil
  412. SL.Friend:ReqOtherRoleInfoMessage(self.selectPlayerId, 1)
  413. end
  414. end
  415. end
  416. end
  417. ---@param control UIKmlLuaControl
  418. function this:OnClickPlayer(control, eventData)
  419. if self.selectItem then
  420. GUI:SetActive(self.selectItem,false)
  421. self.selectItem = nil
  422. end
  423. self.selectPlayerIndex = eventData[1]
  424. self.selectItem = eventData[3]
  425. self.selectPlayerId = eventData[2]["actor"]["id"]
  426. self.selectPlayerServerId = eventData[2].serverid
  427. GUI:SetActive(self.selectItem,true)
  428. GUI:SetActive(self.view.LockButton,true)
  429. if self.rankType == 4 then
  430. GUI:SetActive(self.view.WorshipButton,true)
  431. GUI:setPositionX(self.view.LockButton, 58)
  432. if (self.worshipList and self.worshipList[tostring(self.selectPlayerId)] == 1) or self.remaindTimes == 0 then
  433. GUI:SetActive(self.view.WorshipButton,false)
  434. GUI:setPositionX(self.view.LockButton, -48)
  435. end
  436. else
  437. GUI:SetActive(self.view.WorshipButton,false)
  438. GUI:setPositionX(self.view.LockButton, -48)
  439. end
  440. if self.selectPlayerId == SL:GetMetaValue(EMetaVarGetKey.UID) then
  441. self:ShowMyRole()
  442. GUI:SetActive(self.view.LockButton,false)
  443. GUI:SetActive(self.view.WorshipButton,false)
  444. else
  445. self.otherRoleInfo = nil
  446. SL.Friend:ReqOtherRoleInfoMessage(self.selectPlayerId, 1)
  447. end
  448. end
  449. ---@param data UserProtos.RoleInfo
  450. function this:GetPlayerRoleInfo(data)
  451. local role_param = { "body", "head", "armor", "hand", "pants", "boot" }
  452. local wear_list_str = ""
  453. local model_list_str = ""
  454. local equipInfo = data.roleInfoExt.equip
  455. if equipInfo then
  456. local default_tbl = SL:GetConfig("cfg_model_default", data.career.baseCareer)
  457. local model_list = {}
  458. for _, v in pairs(role_param) do
  459. model_list[v] = default_tbl[v]
  460. end
  461. for _, v in ipairs(equipInfo) do
  462. ---@type cfg_item_column
  463. local itemInfo = SL:GetConfig("cfg_item", v.cfgId)
  464. if itemInfo and itemInfo.type == 2 then
  465. if itemInfo.subType == 1 then
  466. if wear_list_str == "" then
  467. wear_list_str = "WeaponRspineParent#" .. itemInfo.field[1]
  468. else
  469. wear_list_str = wear_list_str .. ",WeaponRspineParent#" .. itemInfo.field[1]
  470. end
  471. elseif itemInfo.subType == 2 then
  472. if wear_list_str == "" then
  473. wear_list_str = "WeaponLspineParent#" .. itemInfo.field[1]
  474. else
  475. wear_list_str = wear_list_str .. ",WeaponLspineParent#" .. itemInfo.field[1]
  476. end
  477. elseif itemInfo.subType == 3 then
  478. if wear_list_str == "" then
  479. wear_list_str = "WeaponRspineParent#" .. itemInfo.field[1]
  480. else
  481. wear_list_str = wear_list_str .. ",WeaponRspineParent#" .. itemInfo.field[1]
  482. end
  483. elseif itemInfo.subType == 13 then
  484. if wear_list_str == "" then
  485. wear_list_str = "Wing#" .. itemInfo.field[1]
  486. else
  487. wear_list_str = wear_list_str .. ",Wing#" .. itemInfo.field[1]
  488. end
  489. elseif itemInfo.subType == 30 then
  490. if wear_list_str == "" then
  491. wear_list_str = "BuffspineParent#" .. itemInfo.field[1]
  492. else
  493. wear_list_str = wear_list_str .. ",BuffspineParent#" .. itemInfo.field[1]
  494. end
  495. else
  496. local point = ""
  497. ---@type cfg_model_charactor_column
  498. local model_tbl = SL:GetConfig("cfg_model_charactor", itemInfo.field[1])
  499. if model_tbl then
  500. if model_tbl.part == 23 then
  501. point = "body"
  502. elseif model_tbl.part == 11 then
  503. point = "head"
  504. elseif model_tbl.part == 2 then
  505. point = "armor"
  506. elseif model_tbl.part == 9 then
  507. point = "hand"
  508. elseif model_tbl.part == 15 then
  509. point = "pants"
  510. elseif model_tbl.part == 5 then
  511. point = "boot"
  512. end
  513. if point ~= "" then
  514. model_list[point] = itemInfo.field[1]
  515. end
  516. end
  517. end
  518. end
  519. end
  520. for _, v in pairs(model_list) do
  521. if model_list_str == "" then
  522. model_list_str = v
  523. else
  524. model_list_str = model_list_str .. "#" .. v
  525. end
  526. end
  527. end
  528. return model_list_str, wear_list_str
  529. end
  530. ---显示自己的模型
  531. function this:ShowMyRole()
  532. --local role = {roleInfoExt = {equip=RoleManager.meData.equips,mountId = RoleManager.meData.MountId},career = SL:MeData_GetCareer()}
  533. --local model_list, equip_list = self:GetPlayerRoleInfo(role)
  534. --self:CreateRole(model_list, equip_list)
  535. local mountId = InfoManager.mountInfo.ride_mount_id
  536. if InfoManager.mountInfo.isHasOwnerMount and not InfoManager.mountInfo.isRankShowMount then
  537. mountId = 0
  538. end
  539. local behaviour = EBehaviourType_Stand.Stand
  540. if self.selectPlayerIndex == 0 and mountId == 0 then
  541. behaviour = EBehaviourType_Stand.Sit
  542. end
  543. local iconName = mountId == 0 and "S_BG" or "rank_mount_bg"
  544. local rotation = mountId == 0 and 50 or 10
  545. GUI:Image_loadTexture(self.view.bg,iconName,"Atlas/UIRankListPanel.spriteatlas")
  546. GUI:SetImageNativeSize(self.view.bg)
  547. GUI:setPosition(self.view.bg, mountId == 0 and 78 or 0, -35)
  548. GUI:setPositionY(self.view.mountModel, mountId == 0 and -170 or -205)
  549. GUI:setPositionX(self.view.mountModel, mountId == 0 and 0 or 70)
  550. SL:UIModel_Recycle(self.curShowRole)
  551. self.curShowRole = SL:UIModel_Create(GUI:GetRectTransform(self.view.mountModel),SL:GetMetaValue(EMetaVarGetKey.UID),SL:MeData_GetCareer(),SL:MeData_GetLevel(),SL:GetMetaValue(EMetaVarGetKey.USER_NAME),mountId,EAction.Stand,behaviour,SL:MeData_GetRoleExtInfo().roleInfoExtData,-50,0,-76,170,0,rotation,0)
  552. end
  553. ---@param message UserProtos.OtherRoleInfoRes
  554. function this:ResOtherRoleInfoMessage(id, message)
  555. if message.type == 1 and self.selectPlayerId == message.role.rid then
  556. --local model_list, equip_list = self:GetPlayerRoleInfo(message.role)
  557. --self:CreateRole(model_list, equip_list)
  558. self.otherRoleInfo = message
  559. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_OTHER_MOUNT_RANK,message.role.rid)
  560. end
  561. end
  562. function this:RES_OTHER_MOUNT_RANK(id,message)
  563. if self.otherRoleInfo then
  564. local mountId = message
  565. local behaviour = EBehaviourType_Stand.Stand
  566. if self.selectPlayerIndex == 0 and mountId == 0 then
  567. behaviour = EBehaviourType_Stand.Sit
  568. end
  569. local iconName = mountId == 0 and "S_BG" or "rank_mount_bg"
  570. local rotation = mountId == 0 and 50 or 10
  571. if self.rankType == 4 then
  572. --GUI:Image_loadTexture(self.view.bg,"grail_bg","Atlas/UIRankListPanel.spriteatlas")
  573. --GUI:setPosition(self.view.bg, 78, -35)
  574. else
  575. GUI:Image_loadTexture(self.view.bg,iconName,"Atlas/UIRankListPanel.spriteatlas")
  576. GUI:setPosition(self.view.bg, mountId == 0 and 78 or 0, -35)
  577. end
  578. GUI:SetImageNativeSize(self.view.bg)
  579. GUI:setPositionY(self.view.mountModel, mountId == 0 and -170 or -205)
  580. GUI:setPositionX(self.view.mountModel, mountId == 0 and 0 or 70)
  581. SL:UIModel_Recycle(self.curShowRole)
  582. self.curShowRole = SL:UIModel_Create(GUI:GetRectTransform(self.view.mountModel),self.otherRoleInfo.role.rid,self.otherRoleInfo.role.career,self.otherRoleInfo.role.level,self.otherRoleInfo.role.name,mountId,EAction.Stand,behaviour,self.otherRoleInfo.role.roleInfoExt,-50,0,-76,170,0,rotation,0)
  583. end
  584. end
  585. function this:CreateRole(model_list, equip_list)
  586. local ani = "idle"
  587. if self.selectPlayerIndex == 0 then
  588. ani = "Sit"
  589. end
  590. self.view.Role.kmlControl:SetSingleAttr("ani", ani)
  591. GUI:SetPlayerRoleInfo(self.view.Role, model_list, equip_list,ani)
  592. end
  593. ------------------------------------------------------------------------------------------------
  594. ---注册UI事件和服务器消息
  595. function this:RegistEvents()
  596. SL:RegisterLUAEvent(LUA_EVENT_ROLE_INFO, self.ResOtherRoleInfoMessage, self)
  597. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_OTHER_MOUNT_RANK,self.RES_OTHER_MOUNT_RANK,self)
  598. GUI:AddOnClickEvent(self.view.CloseButton, self, self.OnClickCloseButton)
  599. GUI:AddOnClickEvent(self.view.LockButton, self, self.OnClickLockButton)
  600. GUI:AddOnClickEvent(self.view.WorshipButton, self, self.OnClickWorshipButton)
  601. SL:RegisterLuaNetMsg(LuaMessageIdToClient.SEND_RANK_DATA_TO_CLIENT,self.RankDataChange,self)
  602. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_GRAIL_RANKING_INFO,self.RankGrailChange,self)
  603. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_GRAIL_RANKING_WORSHIP_INFO,self.RES_GRAIL_RANKING_WORSHIP_INFO,self)
  604. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_PLAYER_EQUIP_GRAIL_INFO,self.RES_PLAYER_EQUIP_GRAIL_INFO,self)
  605. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_OTHER_ANGE_EQUIP_INFO, self.RES_OTHER_ANGE_EQUIP_INFO, self) -- 其它角色大天使装备信息
  606. end
  607. function this:OnClickCloseButton()
  608. GUI:UIPanel_Close("dev/outui/UIRankList/Panel/KLUIRankList/KLUIRankListPanel")
  609. SL.ShowMainPanel()
  610. end
  611. function this:OnClickLockButton()
  612. if not self.selectPlayerId or self.selectPlayerId == 0 then
  613. SL:TipMessage(SL:GetConfig('cfg_string',280).text,1,NoticeType.NoticeMid)--"请先选择查看的玩家",
  614. return
  615. end
  616. if self.rankType == 4 then
  617. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_PLAYER_EQUIP_GRAIL_INFO, self.selectPlayerId)
  618. else
  619. GUI:SetActive(self.view.closeEquipUIButton,true)
  620. --角色装备信息
  621. GUI:UIPanel_Open("dev/ui/Equip/Panel/KLEquipUI/KLEquipUIPanel", _, _, {
  622. isOther = true,
  623. rid = self.selectPlayerId,
  624. isHideMainUI = true,
  625. callBack = function() GUI:SetActive(self.view.closeEquipUIButton,false) end,
  626. x = 17
  627. })
  628. self.otherRoleAngelEquipInfo = {}
  629. local serverId
  630. if self.nowRootType == 2 then
  631. serverId = self.selectPlayerServerId
  632. end
  633. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_OTHER_ANGE_EQUIP_INFO, { rid = self.selectPlayerId, hostId = serverId })
  634. end
  635. end
  636. function this:OnClickWorshipButton()
  637. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_WORSHIP_ANGEL_GRAIL_RANKING, { type = self.nowRootType - 1, roleId = self.selectPlayerId })
  638. end
  639. ---排行榜回包
  640. function this:RankDataChange(_,message)
  641. GUI:setVisible(self.view.MyRank, true)
  642. GUI:setVisible(self.view.WorshipText, false)
  643. GUI:Button_setTitleText(self.view.LockButton, "查看装备")
  644. self.playerSeverDataList = {}
  645. local count = table.count(message["rankDatas"])
  646. if count <= 0 then
  647. GUI:setVisible(self.view.NoRankListImg, true)
  648. GUI:setVisible(self.view.RankList_Panel, false)
  649. else
  650. self:InitMyRankInfo(message["myRankData"])
  651. GUI:setVisible(self.view.NoRankListImg, false)
  652. GUI:setVisible(self.view.RankList_Panel, true)
  653. for i = 1, count do
  654. local data = message["rankDatas"][tostring(i)]
  655. if data["actor"]["id"] == SL:GetMetaValue(EMetaVarGetKey.UID) then
  656. self:InitMyRankInfo(data,i)
  657. end
  658. table.insert(self.playerSeverDataList,data)
  659. end
  660. GUI:DataListUpdateData(self.view.PlayerDataList)
  661. end
  662. end
  663. function this:RankGrailChange(_, message)
  664. self.worshipList = message.roleIds or {}
  665. local totleTimes = tonumber(SL:GetConfig("cfg_global", 28002).value)
  666. self.remaindTimes = totleTimes - message.worshipCount < 0 and 0 or totleTimes - message.worshipCount
  667. GUI:Text_setString(self.view.WorshipText, "今日膜拜剩余次数:" .. self.remaindTimes)
  668. GUI:setVisible(self.view.WorshipText, true)
  669. GUI:Button_setTitleText(self.view.LockButton, "查看圣杯")
  670. self.playerSeverDataList = {}
  671. local count = 0
  672. if message and message.rankingInfo and message.rankingInfo.all then
  673. count = table.count(message.rankingInfo.all)
  674. end
  675. if count > 0 then
  676. GUI:setVisible(self.view.NoRankListImg, false)
  677. GUI:setVisible(self.view.RankList_Panel, true)
  678. for i = 1, count do
  679. local v = message.rankingInfo.all[tostring(i)]
  680. local info = {}
  681. info.name = v.roleName
  682. info.value = v.score
  683. info.serverid = v.serverId
  684. info.rankno = v.ranking
  685. info.career = v.career or 1
  686. info.actor = { id = tonumber(v.roleId) }
  687. self.playerSeverDataList[#self.playerSeverDataList + 1] = info
  688. end
  689. GUI:DataListUpdateData(self.view.PlayerDataList)
  690. else
  691. GUI:setVisible(self.view.NoRankListImg, true)
  692. GUI:setVisible(self.view.RankList_Panel, false)
  693. end
  694. local rankNo, rankMy
  695. if message and message.rankingInfo and message.rankingInfo.my then
  696. rankNo = message.rankingInfo.my.ranking
  697. rankMy = message.rankingInfo.my
  698. end
  699. self:InitMyRankInfo(rankMy, rankNo)
  700. end
  701. function this:RES_GRAIL_RANKING_WORSHIP_INFO(_, message)
  702. if message then
  703. self.worshipList = message.grailIds or {}
  704. local totleTimes = tonumber(SL:GetConfig("cfg_global", 28002).value)
  705. self.remaindTimes = totleTimes - message.worshipCount < 0 and 0 or totleTimes - message.worshipCount
  706. GUI:Text_setString(self.view.WorshipText, "今日膜拜剩余次数:" .. self.remaindTimes)
  707. if (self.worshipList and self.worshipList[tostring(self.selectPlayerId)] == 1) or self.remaindTimes == 0 then
  708. GUI:SetActive(self.view.WorshipButton,false)
  709. GUI:setPositionX(self.view.LockButton, -48)
  710. end
  711. end
  712. end
  713. function this:RES_PLAYER_EQUIP_GRAIL_INFO(_, message)
  714. if message then
  715. InfoManager.archangeEquipInfo:SetOtherGrailInfo(message.grail)
  716. GUI:UIPanel_Open("dev/outui/Archangel/Panel/KLArchangelGrail/KLArchangelGrailPanel", nil, nil, { isOther = true })
  717. end
  718. end
  719. function this:RES_OTHER_ANGE_EQUIP_INFO(_, message)
  720. self.otherRoleAngelEquipInfo = {}
  721. if message then
  722. self.otherRoleAngelEquipInfo = message
  723. end
  724. end
  725. function this:GetOtherAngelEquipInfo(id)
  726. return self.otherRoleAngelEquipInfo[tostring(id)]
  727. end
  728. function this:Close()
  729. SL:SendLuaNetMsg(LuaMessageIdToSever.STOP_REFRESH_RANK_DATA)
  730. SL:UIModel_Recycle(self.curShowRole)
  731. self.curShowRole = nil
  732. self.otherRoleInfo = nil
  733. end
  734. return this