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.

127 lines
3.7 KiB

  1. --[[
  2. 显示某个俱乐部的玩法信息
  3. 只显示包间玩法,不允许操作
  4. --]]
  5. local ClubBaojianRule = class("ClubBaojianRule", cc.UIView)
  6. -- clubId : 俱乐部ID
  7. -- baojianId : 包间ID
  8. function ClubBaojianRule:ctor(clubId, baojianId)
  9. ClubBaojianRule.super.ctor(self)
  10. self.clubId = clubId
  11. self.baojianid = baojianId
  12. self.ui = loadUI("res/ui/ui_club/clubnew/ui_club_baojian_rule_info.ui")
  13. self:addChild(self.ui)
  14. end
  15. function ClubBaojianRule:onEnter()
  16. ClubBaojianRule.super.onEnter(self)
  17. -- 关闭按钮
  18. self.ui.Items.Button_Close:registerClick(handler(self, self.onClickButtonClose))
  19. -- 滑动时间
  20. self.ui.Items.ScrollView:addEventListener(handler(self, self.onScrollViewEvent))
  21. -- 哪些游戏是需要显示的
  22. local baojianInfo = app.club_php:getBaoJian(self.clubId, self.baojianid)
  23. if not baojianInfo or type(baojianInfo) ~= "table" then
  24. return
  25. end
  26. logD("ClubBaojianRule:onEnter() baojianInfo = ", table.tostring(baojianInfo))
  27. local gameId = tonumber(baojianInfo.gameId)
  28. local baojianName = tostring(baojianInfo.title)
  29. local ttGameInfo = json.decode(baojianInfo.strGameRule)
  30. if not ttGameInfo or type(ttGameInfo) ~= "table" then
  31. return
  32. end
  33. logD("ClubBaojianRule:onEnter() ttGameInfo = ", table.tostring(ttGameInfo))
  34. local ruleId = tonumber(ttGameInfo.gamerule) or tonumber(ttGameInfo.gameRule)
  35. local jushu = tonumber(ttGameInfo.jushu)
  36. self.ui.Items.Text_2:setText(baojianName)
  37. self.ui.Items.Text_4:setText(tostring(jushu))
  38. local mScorllView = self.ui.Items.ScrollView
  39. mScorllView:hideAllBar()
  40. mScorllView:removeAllChildren()
  41. local ruleConfig = getSubGameCreateRuleConfig(gameId)
  42. if ruleConfig then
  43. self.ruleView = import("core.luaScript.Views.CreateRoom.CreateRoomItemNew"):new(ruleConfig, ttGameInfo, gameId, ruleId, false)
  44. mScorllView:addChild(self.ruleView)
  45. local layoutSize = self.ruleView:getLayoutContentSize()
  46. if layoutSize then
  47. mScorllView:setInnerContainerSize(layoutSize)
  48. end
  49. --[[
  50. local innerSize = mScorllView:getInnerContainer():getContentSize()
  51. if innerSize.height > mScorllView:getContentSize().height then
  52. self.ui.Items.ImageView_Arrow:setVisible(true)
  53. else
  54. self.ui.Items.ImageView_Arrow:setVisible(false)
  55. end
  56. --]]
  57. else
  58. local ruleClass = getSubGameCreateRoomUi(gameId, ruleId)
  59. if ruleClass then
  60. self.ruleView = import(ruleClass):new(ttGameInfo, ruleId)
  61. mScorllView:addChild(self.ruleView)
  62. local layoutSize = self.ruleView:getLayoutContentSize()
  63. if layoutSize then
  64. mScorllView:setInnerContainerSize(layoutSize)
  65. end
  66. --[[
  67. local innerSize = mScorllView:getInnerContainer():getContentSize()
  68. if innerSize.height > mScorllView:getContentSize().height then
  69. self.ui.Items.ImageView_Arrow:setVisible(true)
  70. else
  71. self.ui.Items.ImageView_Arrow:setVisible(false)
  72. end
  73. --]]
  74. end
  75. end
  76. local innerContainer = self.ui.Items.ScrollView:getInnerContainer()
  77. local sizeInnerContainer = innerContainer:getContentSize()
  78. local layout_mask = self.ui.Items.Layout_mask:getCopied()
  79. layout_mask:setContentSize(sizeInnerContainer)
  80. self.ruleView.ui:addChild(layout_mask)
  81. mScorllView:jumpToTop()
  82. end
  83. function ClubBaojianRule:onScrollViewEvent(obj, eventType)
  84. logD(eventType)
  85. if eventType == 4 then
  86. local sizeScrollView = self.ui.Items.ScrollView:getContentSize()
  87. local innerContainer = self.ui.Items.ScrollView:getInnerContainer()
  88. local sizeInnerContainer = innerContainer:getContentSize()
  89. local posInnerContainer = innerContainer:getPosition()
  90. self.ui.Items.ImageView_Arrow_Up:setVisible(posInnerContainer.y < 0)
  91. self.ui.Items.ImageView_Arrow_Down:setVisible(posInnerContainer.y + sizeInnerContainer.height > sizeScrollView.height)
  92. end
  93. end
  94. function ClubBaojianRule:onClickButtonClose()
  95. self:removeFromParent()
  96. end
  97. return ClubBaojianRule