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.

142 lines
4.1 KiB

  1. local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
  2. local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
  3. local ncmajShowAllTingCardView = class("ncmajShowAllTingCardView", cc.UIView)
  4. function ncmajShowAllTingCardView:ctor()
  5. ncmajShowAllTingCardView.super.ctor(self)
  6. self._tingCardData = nil;
  7. self:loadUI()
  8. end
  9. function ncmajShowAllTingCardView:loadUI()
  10. local ui = loadUI("mj_ncmaj/res/ui_fangjian/mj_ncmaj_showallting_cards.ui")
  11. self:addChild(ui)
  12. self.ui = ui
  13. self.ui.Items.Button_QueDing:registerClick(handler(self, self.onClickSure))
  14. self.ui.Items.Button_QuXiao:registerClick(handler(self, self.onClickCancel))
  15. -- 选择了摆的牌
  16. self:bindEvent(app.room , MJDefine.MJEvent.ChagneBaiCards, handler(self, self.ChagneBaiCards))
  17. end
  18. function ncmajShowAllTingCardView:setData(tingCardData)
  19. logD("ncmajShowAllTingCardView:setData", table.tostring(tingCardData))
  20. self._tingCardData = tingCardData;
  21. if not tingCardData or table.nums(tingCardData) <= 0 then
  22. return
  23. end
  24. table.sort(
  25. tingCardData,
  26. function(c1, c2)
  27. return c1.card < c2.card
  28. end
  29. )
  30. self.ui.Items.Layout_TingCard:removeAllChildren()
  31. local count = #tingCardData
  32. local row = 1--math.ceil(count / 6) --几行
  33. self.ui.Items.Layout_TingCard:setSize(cc.size(70*count, 80 * row))
  34. self.ui.Items.Layout_Ting_Tip_Card_Panel:setSize(cc.size(count < 5 and 400 or count * 70 + 116, 80 * row + 40))
  35. self.ui.Items.ImageView_Ting:setPositionY(self.ui.Items.Layout_Ting_Tip_Card_Panel:getContentSize().height - 60)
  36. for k, v in pairs(tingCardData) do
  37. --[[local layout=cc.Layout:create()
  38. layout:setSize(cc.size(134,80))
  39. local num = cc.Text:createNode()
  40. num:setDefaults()
  41. local config = num:getFontConfig()
  42. config.fontSize = 22
  43. config.texColor = cc.c4b(213,46,11,255)
  44. num:setFontConfig(config)
  45. num:setAnchorPoint(cc.p(0.5,0.5))
  46. num:setPosition(cc.p(20, 100))
  47. num:setString(v.count .. "张")
  48. layout:addChild(num)
  49. local mj = MJ:new(v.card, MJDefine.MJType.Stand, MJDefine.MyViewId, MJDefine.DesktopType.TwoD)
  50. mj:setPosition(cc.p(20, 50))
  51. mj:setScale(0.5)
  52. layout:addChild(mj)
  53. self.ui.Items.Layout_TingCard:addChild(layout)--]]
  54. local item = self.ui.Items.Item_Ting:getCopied()
  55. item:setVisible(true)
  56. local items = getUIItems(item)
  57. items.Text_Num:setString(v.count)
  58. local mj = MJ:new(v.card, MJDefine.MJType.Stand, MJDefine.MyViewId, MJDefine.DesktopType.TwoD)
  59. mj:setPosition(cc.p(30, 55))
  60. mj:setScale(0.6)
  61. items.Node:addChild(mj)
  62. self.ui.Items.Layout_TingCard:addChild(item)
  63. end
  64. self.ui.Items.Layout_TingCard:requestDoLayout()
  65. self.ui.Items.Layout_TingCard:doLayout()
  66. end
  67. function ncmajShowAllTingCardView:show()
  68. self:setVisible(true)
  69. end
  70. function ncmajShowAllTingCardView:hide()
  71. --self:setVisible(false)
  72. self.ui.Items.Layout_Bai_Tip_1:setVisible(false)
  73. self.ui.Items.Layout_Bai_Tip_2:setVisible(false)
  74. self.ui.Items.Layout_Ting_Tip_Card_Panel:setVisible(false)
  75. end
  76. function ncmajShowAllTingCardView:showTips1()
  77. self:hide()
  78. self.ui.Items.Layout_Bai_Tip_1:setVisible(true)
  79. self.ui.Items.Button_QueDing:setEnabled(false)
  80. end
  81. function ncmajShowAllTingCardView:showTips2()
  82. self:hide()
  83. self.ui.Items.Layout_Bai_Tip_2:setVisible(true)
  84. end
  85. function ncmajShowAllTingCardView:showTingCards()
  86. self:hide()
  87. self.ui.Items.Layout_Ting_Tip_Card_Panel:setVisible(true)
  88. end
  89. function ncmajShowAllTingCardView:getTingCardData ()
  90. return self._tingCardData;
  91. end
  92. -- 确定
  93. function ncmajShowAllTingCardView:onClickSure()
  94. playBtnEffect()
  95. self:showTips2()
  96. app.room:dispatchEvent({name = MJDefine.MJEvent.BaiOverOutCards,selectCards = self._selectCards})
  97. end
  98. -- 取消
  99. function ncmajShowAllTingCardView:onClickCancel()
  100. playBtnEffect()
  101. if self.quxiaoCB then
  102. self.quxiaoCB()
  103. end
  104. --self:hide()
  105. end
  106. function ncmajShowAllTingCardView:setQuXiaoCallBack(cb)
  107. if cb then
  108. self.quxiaoCB = cb
  109. end
  110. end
  111. function ncmajShowAllTingCardView:ChagneBaiCards(data)
  112. if not data then return end
  113. self.ui.Items.Button_QueDing:setEnabled(data.canCommit)
  114. self._selectCards = data.selectCards
  115. end
  116. return ncmajShowAllTingCardView