--[[ 显示某个俱乐部的玩法信息 只显示包间玩法,不允许操作 --]] local ClubBaojianRule = class("ClubBaojianRule", cc.UIView) -- clubId : 俱乐部ID -- baojianId : 包间ID function ClubBaojianRule:ctor(clubId, baojianId) ClubBaojianRule.super.ctor(self) self.clubId = clubId self.baojianid = baojianId self.ui = loadUI("res/ui/ui_club/clubnew/ui_club_baojian_rule_info.ui") self:addChild(self.ui) end function ClubBaojianRule:onEnter() ClubBaojianRule.super.onEnter(self) -- 关闭按钮 self.ui.Items.Button_Close:registerClick(handler(self, self.onClickButtonClose)) -- 滑动时间 self.ui.Items.ScrollView:addEventListener(handler(self, self.onScrollViewEvent)) -- 哪些游戏是需要显示的 local baojianInfo = app.club_php:getBaoJian(self.clubId, self.baojianid) if not baojianInfo or type(baojianInfo) ~= "table" then return end logD("ClubBaojianRule:onEnter() baojianInfo = ", table.tostring(baojianInfo)) local gameId = tonumber(baojianInfo.gameId) local baojianName = tostring(baojianInfo.title) local ttGameInfo = json.decode(baojianInfo.strGameRule) if not ttGameInfo or type(ttGameInfo) ~= "table" then return end logD("ClubBaojianRule:onEnter() ttGameInfo = ", table.tostring(ttGameInfo)) local ruleId = tonumber(ttGameInfo.gamerule) or tonumber(ttGameInfo.gameRule) local jushu = tonumber(ttGameInfo.jushu) self.ui.Items.Text_2:setText(baojianName) self.ui.Items.Text_4:setText(tostring(jushu)) local mScorllView = self.ui.Items.ScrollView mScorllView:hideAllBar() mScorllView:removeAllChildren() local ruleConfig = getSubGameCreateRuleConfig(gameId) if ruleConfig then self.ruleView = import("core.luaScript.Views.CreateRoom.CreateRoomItemNew"):new(ruleConfig, ttGameInfo, gameId, ruleId, false) mScorllView:addChild(self.ruleView) local layoutSize = self.ruleView:getLayoutContentSize() if layoutSize then mScorllView:setInnerContainerSize(layoutSize) end --[[ local innerSize = mScorllView:getInnerContainer():getContentSize() if innerSize.height > mScorllView:getContentSize().height then self.ui.Items.ImageView_Arrow:setVisible(true) else self.ui.Items.ImageView_Arrow:setVisible(false) end --]] else local ruleClass = getSubGameCreateRoomUi(gameId, ruleId) if ruleClass then self.ruleView = import(ruleClass):new(ttGameInfo, ruleId) mScorllView:addChild(self.ruleView) local layoutSize = self.ruleView:getLayoutContentSize() if layoutSize then mScorllView:setInnerContainerSize(layoutSize) end --[[ local innerSize = mScorllView:getInnerContainer():getContentSize() if innerSize.height > mScorllView:getContentSize().height then self.ui.Items.ImageView_Arrow:setVisible(true) else self.ui.Items.ImageView_Arrow:setVisible(false) end --]] end end local innerContainer = self.ui.Items.ScrollView:getInnerContainer() local sizeInnerContainer = innerContainer:getContentSize() local layout_mask = self.ui.Items.Layout_mask:getCopied() layout_mask:setContentSize(sizeInnerContainer) self.ruleView.ui:addChild(layout_mask) mScorllView:jumpToTop() end function ClubBaojianRule:onScrollViewEvent(obj, eventType) logD(eventType) if eventType == 4 then local sizeScrollView = self.ui.Items.ScrollView:getContentSize() local innerContainer = self.ui.Items.ScrollView:getInnerContainer() local sizeInnerContainer = innerContainer:getContentSize() local posInnerContainer = innerContainer:getPosition() self.ui.Items.ImageView_Arrow_Up:setVisible(posInnerContainer.y < 0) self.ui.Items.ImageView_Arrow_Down:setVisible(posInnerContainer.y + sizeInnerContainer.height > sizeScrollView.height) end end function ClubBaojianRule:onClickButtonClose() self:removeFromParent() end return ClubBaojianRule