You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 regels
2.4 KiB

  1. -- 战绩单元Layout
  2. local MJZhanJiItem = class("MJZhanJiItem")
  3. function MJZhanJiItem:ctor(zhanjiInfo, showBtnShare)
  4. self.zhanjiInfo = zhanjiInfo
  5. logI(table.tostring(self.roomInfo))
  6. self.showBtnShare = showBtnShare;
  7. self.gameRule = tonumber(zhanjiInfo.gext.gamerule) or 0
  8. self.ui = loadUI("mj/res/ui/ui_zhanji/mj_dt_zhanji_tiao.ui")
  9. self:initView()
  10. end
  11. function MJZhanJiItem:initView()
  12. -- 详情按钮
  13. self.ui.Items.Button_xiangqing:registerClick(handler(self, self.onClickDetails))
  14. -- 分享按钮
  15. -- self.ui.Items.Button_Share:registerClick(handler(self, self.onClickShare))
  16. -- self.ui.Items.Button_Share:setVisible(self.showBtnShare == true)
  17. --ui展示
  18. --房号
  19. local roomid = self.zhanjiInfo.roomid.."("..self.zhanjiInfo.fbound.."/"..self.zhanjiInfo.nbound..")";
  20. self.ui.Items.Text_RoomNum:setText(roomid);
  21. --时间
  22. local time = os.date("%Y-%m-%d %H:%M",self.zhanjiInfo.endtime)
  23. self.ui.Items.Text_time:setText(time)
  24. -- 所有的玩家
  25. local index=1
  26. -- local uiPlayers = self.ui.Items.Layout_Players
  27. for uid, score in pairs(self.zhanjiInfo.tscore) do
  28. local playerInfo = app.playerInfoManager:getPlayerInfo(uid)
  29. if playerInfo then
  30. -- 名称
  31. local name=playerInfo.name and getSubStringNickname(playerInfo.name) or ""
  32. self.ui.Items["name_"..index]:setText(name)
  33. end
  34. --分数
  35. self.ui.Items["score_"..index]:setText(score)
  36. index=index+1
  37. end
  38. for i=1,4 do
  39. if index-1<i then
  40. self.ui.Items["Layout_"..i]:setVisible(false)
  41. end
  42. end
  43. end
  44. -- 分享
  45. function MJZhanJiItem:onClickShare()
  46. playBtnEffect()
  47. local fileName = cc.FileUtils:getInstance():getWritablePath().."zhanji_"..tostring(self.zhanjiInfo.roomid).."_screen.jpg"
  48. cc.FileUtils:getInstance():screenToFile(fileName, function(ret)
  49. if 1 == tonumber(ret) then
  50. local info = {}
  51. info.scene = "talk"
  52. info.contentType = "image"
  53. info.image = fileName
  54. info.imageWidth = 1000
  55. info.thumbWidth = 100
  56. app.plugin:shareGame(info)
  57. else
  58. showTooltip("截图保存失败");
  59. end
  60. end );
  61. end
  62. -- 详情按钮
  63. function MJZhanJiItem:onClickDetails()
  64. playBtnEffect()
  65. local protocolZhanJi = app:getProtocolZhanJi(app.gameId)
  66. if protocolZhanJi then
  67. local function showDanJuView()
  68. local view = import("mj.luaScript.Views.Zhanji.MJZhanJiDanJuView"):new(self.zhanjiInfo)
  69. view:setAnchorPoint(cc.p(0.5, 0.5))
  70. app:showWaitDialog(view)
  71. end
  72. protocolZhanJi:getZhanJiDetail(self.zhanjiInfo.pid, 0, showDanJuView)
  73. end
  74. end
  75. return MJZhanJiItem