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.

84 rivejä
2.3 KiB

  1. -- 战绩单元Layout
  2. local ZPZhanJiItem = class("ZPZhanJiItem")
  3. --[[
  4. 显示某个战绩的结算信息。
  5. 主要是显示房间内每个玩家的基本信息和输赢情况,以及大赢家、土豪等标签
  6. --]]
  7. function ZPZhanJiItem:ctor(zhanjiInfo)
  8. logD("sortZhanji zhanjiInfo = ", table.tostring(zhanjiInfo))
  9. self.zhanjiInfo = zhanjiInfo;
  10. self.gameRule = tonumber(zhanjiInfo.gext.gamerule) or 0
  11. self.ui = loadUI("zp_base/res/ui/ui_zhanji/zipai_dt_zhanji_tiao.ui")
  12. self:initView()
  13. end
  14. --初始化界面
  15. function ZPZhanJiItem:initView()
  16. -- 清空数据
  17. self.ui.Items.Layout_Players:removeAllChildren();
  18. -- 校验数据
  19. if not self.zhanjiInfo or not self.zhanjiInfo.tscore or table.nums(self.zhanjiInfo.tscore) <= 0 then
  20. return
  21. end
  22. -- 房号
  23. -- 局数
  24. local juShu = string.format("%d/%d",tostring(self.zhanjiInfo.fbound), tostring(self.zhanjiInfo.nbound))
  25. local str1 = tostring(self.zhanjiInfo.roomid).."("..juShu.."局)"
  26. self.ui.Items.Text_RoomNum:setText(str1)
  27. -- 时间
  28. local timeString = os.date("%Y-%m-%d %H:%M",self.zhanjiInfo.endtime)
  29. self.ui.Items.Text_time:setText(timeString)
  30. -- 详情按钮
  31. self.ui.Items.Button_xiangqing:registerClick(handler(self, self.onClickDetail))
  32. -- 所有的玩家
  33. local uiPlayers = self.ui.Items.Layout_Players
  34. for uid, score in pairs(self.zhanjiInfo.tscore) do
  35. local item = import("zp_base.luaScript.Views.ZhanJi.ZPZhanJiPlayer"):new(self.gameRule, uid, score)
  36. if item and item.ui then
  37. uiPlayers:addChild(item.ui)
  38. end
  39. end
  40. end
  41. -- 分享
  42. function ZPZhanJiItem:onClickShare()
  43. playBtnEffect()
  44. local fileName = cc.FileUtils:getInstance():getWritablePath().."zhanji_"..tostring(self.zhanjiInfo.roomid).."_screen.jpg"
  45. cc.FileUtils:getInstance():screenToFile(fileName, function(ret)
  46. if 1 == tonumber(ret) then
  47. local info = {}
  48. info.scene = "talk"
  49. info.contentType = "image"
  50. info.image = fileName
  51. info.imageWidth = 1000
  52. info.thumbWidth = 100
  53. app.plugin:shareGame(info)
  54. else
  55. showTooltip("截图保存失败");
  56. end
  57. end );
  58. end
  59. -- 显示战绩详情
  60. function ZPZhanJiItem:onClickDetail()
  61. local protocolZhanJi = app:getProtocolZhanJi(app.gameId)
  62. if protocolZhanJi then
  63. local view = import("zp_base.luaScript.Views.ZhanJi.ZPDanJuView"):new(self.zhanjiInfo)
  64. view:setAnchorPoint(cc.p(0.5, 0.5))
  65. app:showWaitDialog(view)
  66. end
  67. end
  68. return ZPZhanJiItem